static inline int trv_nxsu_initialize(FAR struct trv_graphics_info_s *ginfo) { FAR struct fb_vtable_s *fbdev; int ret; /* Get the framebuffer device */ fbdev = trv_get_fbdev(); /* Open NX */ ginfo->hnx = nx_open(fbdev); if (!ginfo->hnx) { trv_abort("trv_nxsu_initialize: nx_open failed: %d\n", errno); } /* And use the background window */ trv_use_bgwindow(ginfo); }
int arch_tcinitialize(int minor) { FAR NX_DRIVERTYPE *dev; nxgl_mxpixel_t color; int ret; /* Initialize the simulated frame buffer device. We need to create an * X11 window to support the mouse-driven touchscreen simulation. */ ivdbg("Initializing framebuffer\n"); ret = up_fbinitialize(); if (ret < 0) { idbg("up_fbinitialize failed: %d\n", -ret); goto errout; } dev = up_fbgetvplane(0); if (!dev) { idbg("up_fbgetvplane 0 failed\n"); ret = -ENODEV; goto errout_with_fb; } /* Then open NX */ ivdbg("Open NX\n"); g_simtc.hnx = nx_open(dev); if (!g_simtc.hnx) { ret = -errno; idbg("nx_open failed: %d\n", ret); goto errout_with_fb; } /* Set the background to the configured background color */ ivdbg("Set background color=%d\n", CONFIG_EXAMPLES_TOUCHSCREEN_BGCOLOR); color = CONFIG_EXAMPLES_TOUCHSCREEN_BGCOLOR; ret = nx_setbgcolor(g_simtc.hnx, &color); if (ret < 0) { idbg("nx_setbgcolor failed: %d\n", ret); goto errout_with_nx; } /* Finally, initialize the touchscreen simulation on the X window */ ret = sim_tcinitialize(minor); if (ret < 0) { idbg("sim_tcinitialize failed: %d\n", ret); goto errout_with_nx; } return OK; errout_with_nx: nx_close(g_simtc.hnx); goto errout; errout_with_fb: fb_uninitialize(); errout: return ret; }
static inline int nxlines_initialize(void) { FAR NX_DRIVERTYPE *dev; #if defined(CONFIG_EXAMPLES_NXLINES_EXTERNINIT) /* Use external graphics driver initialization */ message("nxlines_initialize: Initializing external graphics device\n"); dev = up_nxdrvinit(CONFIG_EXAMPLES_NXLINES_DEVNO); if (!dev) { message("nxlines_initialize: up_nxdrvinit failed, devno=%d\n", CONFIG_EXAMPLES_NXLINES_DEVNO); g_nxlines.code = NXEXIT_EXTINITIALIZE; return ERROR; } #elif defined(CONFIG_NX_LCDDRIVER) int ret; /* Initialize the LCD device */ message("nxlines_initialize: Initializing LCD\n"); ret = up_lcdinitialize(); if (ret < 0) { message("nxlines_initialize: up_lcdinitialize failed: %d\n", -ret); g_nxlines.code = NXEXIT_LCDINITIALIZE; return ERROR; } /* Get the device instance */ dev = up_lcdgetdev(CONFIG_EXAMPLES_NXLINES_DEVNO); if (!dev) { message("nxlines_initialize: up_lcdgetdev failed, devno=%d\n", CONFIG_EXAMPLES_NXLINES_DEVNO); g_nxlines.code = NXEXIT_LCDGETDEV; return ERROR; } /* Turn the LCD on at 75% power */ (void)dev->setpower(dev, ((3*CONFIG_LCD_MAXPOWER + 3)/4)); #else int ret; /* Initialize the frame buffer device */ message("nxlines_initialize: Initializing framebuffer\n"); ret = up_fbinitialize(); if (ret < 0) { message("nxlines_initialize: up_fbinitialize failed: %d\n", -ret); g_nxlines.code = NXEXIT_FBINITIALIZE; return ERROR; } dev = up_fbgetvplane(CONFIG_EXAMPLES_NXLINES_VPLANE); if (!dev) { message("nxlines_initialize: up_fbgetvplane failed, vplane=%d\n", CONFIG_EXAMPLES_NXLINES_VPLANE); g_nxlines.code = NXEXIT_FBGETVPLANE; return ERROR; } #endif /* Then open NX */ message("nxlines_initialize: Open NX\n"); g_nxlines.hnx = nx_open(dev); if (!g_nxlines.hnx) { message("nxlines_initialize: nx_open failed: %d\n", errno); g_nxlines.code = NXEXIT_NXOPEN; return ERROR; } return OK; }
static inline int nximage_initialize(void) { FAR NX_DRIVERTYPE *dev; #if defined(CONFIG_EXAMPLES_NXIMAGE_EXTERNINIT) struct boardioc_graphics_s devinfo; int ret; /* Use external graphics driver initialization */ printf("nximage_initialize: Initializing external graphics device\n"); devinfo.devno = CONFIG_EXAMPLES_NXIMAGE_DEVNO; devinfo.dev = NULL; ret = boardctl(BOARDIOC_GRAPHICS_SETUP, (uintptr_t)&devinfo); if (ret < 0) { printf("nximage_initialize: boardctl failed, devno=%d: %d\n", CONFIG_EXAMPLES_NXIMAGE_DEVNO, errno); g_nximage.code = NXEXIT_EXTINITIALIZE; return ERROR; } dev = devinfo.dev; #elif defined(CONFIG_NX_LCDDRIVER) int ret; /* Initialize the LCD device */ printf("nximage_initialize: Initializing LCD\n"); ret = board_lcd_initialize(); if (ret < 0) { printf("nximage_initialize: board_lcd_initialize failed: %d\n", -ret); g_nximage.code = NXEXIT_LCDINITIALIZE; return ERROR; } /* Get the device instance */ dev = board_lcd_getdev(CONFIG_EXAMPLES_NXIMAGE_DEVNO); if (!dev) { printf("nximage_initialize: board_lcd_getdev failed, devno=%d\n", CONFIG_EXAMPLES_NXIMAGE_DEVNO); g_nximage.code = NXEXIT_LCDGETDEV; return ERROR; } /* Turn the LCD on at 75% power */ (void)dev->setpower(dev, ((3*CONFIG_LCD_MAXPOWER + 3)/4)); #else int ret; /* Initialize the frame buffer device */ printf("nximage_initialize: Initializing framebuffer\n"); ret = up_fbinitialize(0); if (ret < 0) { printf("nximage_initialize: up_fbinitialize failed: %d\n", -ret); g_nximage.code = NXEXIT_FBINITIALIZE; return ERROR; } dev = up_fbgetvplane(0, CONFIG_EXAMPLES_NXIMAGE_VPLANE); if (!dev) { printf("nximage_initialize: up_fbgetvplane failed, vplane=%d\n", CONFIG_EXAMPLES_NXIMAGE_VPLANE); g_nximage.code = NXEXIT_FBGETVPLANE; return ERROR; } #endif /* Then open NX */ printf("nximage_initialize: Open NX\n"); g_nximage.hnx = nx_open(dev); if (!g_nximage.hnx) { printf("nximage_initialize: nx_open failed: %d\n", errno); g_nximage.code = NXEXIT_NXOPEN; return ERROR; } return OK; }
int board_tsc_setup(int minor) { FAR NX_DRIVERTYPE *dev; nxgl_mxpixel_t color; int ret; /* Initialize the simulated frame buffer device. We need to create an * X11 window to support the mouse-driven touchscreen simulation. */ iinfo("Initializing framebuffer\n"); ret = up_fbinitialize(0); if (ret < 0) { ierr("ERROR: up_fbinitialize failed: %d\n", -ret); goto errout; } dev = up_fbgetvplane(0, 0); if (!dev) { ierr("ERROR: up_fbgetvplane 0 failed\n"); ret = -ENODEV; goto errout_with_fb; } /* Then open NX */ iinfo("Open NX\n"); g_simtc.hnx = nx_open(dev); if (!g_simtc.hnx) { ret = -errno; ierr("ERROR: nx_open failed: %d\n", ret); goto errout_with_fb; } #ifdef CONFIG_VNCSERVER /* Setup the VNC server to support keyboard/mouse inputs */ ret = vnc_default_fbinitialize(0, g_simtc.hnx); if (ret < 0) { ierr("ERROR: vnc_default_fbinitialize failed: %d\n", ret); goto errout_with_fb; } #endif /* Set the background to the configured background color */ iinfo("Set background color=%d\n", CONFIG_EXAMPLES_TOUCHSCREEN_BGCOLOR); color = CONFIG_EXAMPLES_TOUCHSCREEN_BGCOLOR; ret = nx_setbgcolor(g_simtc.hnx, &color); if (ret < 0) { ierr("ERROR: nx_setbgcolor failed: %d\n", ret); goto errout_with_nx; } /* Finally, initialize the touchscreen simulation on the X window */ ret = board_tsc_setup(minor); if (ret < 0) { ierr("ERROR: board_tsc_setup failed: %d\n", ret); goto errout_with_nx; } return OK; errout_with_nx: nx_close(g_simtc.hnx); goto errout; errout_with_fb: up_fbuninitialize(0); errout: return ret; }