static FAR struct fb_vtable_s *trv_get_fbdev(void)
{
  FAR struct fb_vtable_s *fbdev;
  int ret;

  /* Initialize the frame buffer device */

  ret = up_fbinitialize();
  if (ret < 0)
    {
      trv_abort("ERROR: up_fbinitialize failed: %d\n", -ret);
    }

  /* Set up to use video plane 0.  There is no support for anything but
   * video plane 0.
   */

  fbdev = up_fbgetvplane(0);
  if (!fbdev)
    {
      trv_abort("ERROR: up_fbgetvplane(0) failed\n");
    }

  return fbdev;
}
static inline FAR struct fb_vtable_s *ov2640_lcd_initialize(void)
{
  FAR struct fb_vtable_s *vplane;
  int ret;

  /* Initialize the frame buffer device */

  ret = up_fbinitialize();
  if (ret < 0)
    {
      gdbg("ERROR: up_fbinitialize failed: %d\n", -ret);
      return NULL;
    }

  vplane = up_fbgetvplane(0);
  if (!vplane)
    {
      gdbg("ERROR: up_fbgetvplane failed\n");
    }

  return vplane;
}
int nxcon_server(int argc, char *argv[])
{
  FAR NX_DRIVERTYPE *dev;
  int ret;

#if defined(CONFIG_EXAMPLES_NXCON_EXTERNINIT)
  /* Use external graphics driver initialization */

  message("nxcon_server: Initializing external graphics device\n");
  dev = up_nxdrvinit(CONFIG_EXAMPLES_NXCON_DEVNO);
  if (!dev)
    {
      message("nxcon_server: up_nxdrvinit failed, devno=%d\n", CONFIG_EXAMPLES_NXCON_DEVNO);
      return ERROR;
    }

#elif defined(CONFIG_NX_LCDDRIVER)
  /* Initialize the LCD device */

  message("nxcon_server: Initializing LCD\n");
  ret = up_lcdinitialize();
  if (ret < 0)
    {
      message("nxcon_server: up_lcdinitialize failed: %d\n", -ret);
      return 1;
    }

  /* Get the device instance */

  dev = up_lcdgetdev(CONFIG_EXAMPLES_NXCON_DEVNO);
  if (!dev)
    {
      message("nxcon_server: up_lcdgetdev failed, devno=%d\n", CONFIG_EXAMPLES_NXCON_DEVNO);
      return 2;
    }

  /* Turn the LCD on at 75% power */

  (void)dev->setpower(dev, ((3*CONFIG_LCD_MAXPOWER + 3)/4));
#else
  /* Initialize the frame buffer device */

  message("nxcon_server: Initializing framebuffer\n");
  ret = up_fbinitialize();
  if (ret < 0)
    {
      message("nxcon_server: up_fbinitialize failed: %d\n", -ret);
      return 1;
    }

  dev = up_fbgetvplane(CONFIG_EXAMPLES_NXCON_VPLANE);
  if (!dev)
    {
      message("nxcon_server: up_fbgetvplane failed, vplane=%d\n", CONFIG_EXAMPLES_NXCON_VPLANE);
      return 2;
    }
#endif

  /* Then start the server */

  ret = nx_run(dev);
  gvdbg("nx_run returned: %d\n", errno);
  return 3;
}
Ejemplo n.º 4
0
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;
}
Ejemplo n.º 5
0
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;
}
Ejemplo n.º 6
0
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;
}
Ejemplo n.º 7
0
int nx_servertask(int argc, char *argv[])
{
  FAR NX_DRIVERTYPE *dev;
  int ret;

#if defined(CONFIG_EXAMPLES_NX_EXTERNINIT)
  /* Use external graphics driver initialization */

  printf("nxeg_initialize: Initializing external graphics device\n");
  dev = boardctl(BOARDIOC_GRAPHICS_SETUP, CONFIG_EXAMPLES_NX_DEVNO);
  if (!dev)
    {
      printf("nxeg_initialize: boardctl failed, devno=%d\n",
             CONFIG_EXAMPLES_NX_DEVNO);
      g_exitcode = NXEXIT_EXTINITIALIZE;
      return ERROR;
    }

#elif defined(CONFIG_NX_LCDDRIVER)
  /* Initialize the LCD device */

  printf("nx_servertask: Initializing LCD\n");
  ret = board_lcd_initialize();
  if (ret < 0)
    {
      printf("nx_servertask: board_lcd_initialize failed: %d\n", -ret);
      return 1;
    }

  /* Get the device instance */

  dev = board_lcd_getdev(CONFIG_EXAMPLES_NX_DEVNO);
  if (!dev)
    {
      printf("nx_servertask: board_lcd_getdev failed, devno=%d\n",
             CONFIG_EXAMPLES_NX_DEVNO);
      return 2;
    }

  /* Turn the LCD on at 75% power */

  (void)dev->setpower(dev, ((3*CONFIG_LCD_MAXPOWER + 3)/4));
#else
  /* Initialize the frame buffer device */

  printf("nx_servertask: Initializing framebuffer\n");
  ret = up_fbinitialize();
  if (ret < 0)
    {
      printf("nx_servertask: up_fbinitialize failed: %d\n", -ret);
      return 1;
    }

  dev = up_fbgetvplane(CONFIG_EXAMPLES_NX_VPLANE);
  if (!dev)
    {
      printf("nx_servertask: up_fbgetvplane failed, vplane=%d\n", CONFIG_EXAMPLES_NX_VPLANE);
      return 2;
    }
#endif

  /* Then start the server */

  ret = nx_run(dev);
  printf("nx_servertask: nx_run returned: %d\n", errno);
  return 3;
}
Ejemplo n.º 8
0
int nx_server(int argc, char *argv[])
{
  FAR NX_DRIVERTYPE *dev;
  int ret;

#if defined(CONFIG_NXSTART_EXTERNINIT)
  /* Use external graphics driver initialization */

  dev = up_nxdrvinit(CONFIG_NXSTART_DEVNO);
  if (!dev)
    {
      gdbg("ERROR: up_nxdrvinit failed, devno=%d\n", CONFIG_NXSTART_DEVNO);
      return EXIT_FAILURE;
    }

#elif defined(CONFIG_NX_LCDDRIVER)
  /* Initialize the LCD device */

  ret = up_lcdinitialize();
  if (ret < 0)
    {
      gdbg("ERROR: up_lcdinitialize failed: %d\n", ret);
      return EXIT_FAILURE;
    }

  /* Get the device instance */

  dev = up_lcdgetdev(CONFIG_NXSTART_DEVNO);
  if (!dev)
    {
      gdbg("ERROR: up_lcdgetdev failed, devno=%d\n", CONFIG_NXSTART_DEVNO);
      return EXIT_FAILURE;
    }

  /* Turn the LCD on at 75% power */

  (void)dev->setpower(dev, ((3*CONFIG_LCD_MAXPOWER + 3)/4));

#else /* CONFIG_NX_LCDDRIVER */
  /* Initialize the frame buffer device */

  ret = up_fbinitialize();
  if (ret < 0)
    {
      gdbg("ERROR: up_fbinitialize failed: %d\n", ret);
      return EXIT_FAILURE;
    }

  dev = up_fbgetvplane(CONFIG_NXSTART_VPLANE);
  if (!dev)
    {
      gdbg("ERROR: up_fbgetvplane failed, vplane=%d\n", CONFIG_NXSTART_VPLANE);
      return EXIT_FAILURE;
    }

#endif /* CONFIG_NX_LCDDRIVER */

  /* Then start the server (nx_run does not normally return) */

  ret = nx_run(dev);
  gvdbg("nx_run returned: %d\n", ret);
  return EXIT_FAILURE;
}
Ejemplo n.º 9
0
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;
}
Ejemplo n.º 10
0
int nxterm_server(int argc, char *argv[])
{
  FAR NX_DRIVERTYPE *dev;
  int ret;

#if defined(CONFIG_EXAMPLES_NXTERM_EXTERNINIT)
  struct boardioc_graphics_s devinfo;
  int ret;

  /* Use external graphics driver initialization */

  printf("nxterm_server: Initializing external graphics device\n");

  devinfo.devno = CONFIG_EXAMPLES_NXTERM_DEVNO;
  devinfo.dev = NULL;

  ret = boardctl(BOARDIOC_GRAPHICS_SETUP, (uintptr_t)&devinfo);
  if (ret < 0)
    {
      printf("nxterm_server: boardctl failed, devno=%d: %d\n",
             CONFIG_EXAMPLES_NXTERM_DEVNO, errno);
      return ERROR;
    }

  dev = devinfo.dev;

#elif defined(CONFIG_NX_LCDDRIVER)
  /* Initialize the LCD device */

  printf("nxterm_server: Initializing LCD\n");
  ret = board_lcd_initialize();
  if (ret < 0)
    {
      printf("nxterm_server: board_lcd_initialize failed: %d\n", -ret);
      return 1;
    }

  /* Get the device instance */

  dev = board_lcd_getdev(CONFIG_EXAMPLES_NXTERM_DEVNO);
  if (!dev)
    {
      printf("nxterm_server: board_lcd_getdev failed, devno=%d\n",
             CONFIG_EXAMPLES_NXTERM_DEVNO);
      return 2;
    }

  /* Turn the LCD on at 75% power */

  (void)dev->setpower(dev, ((3*CONFIG_LCD_MAXPOWER + 3)/4));
#else
  /* Initialize the frame buffer device */

  printf("nxterm_server: Initializing framebuffer\n");

  ret = up_fbinitialize(0);
  if (ret < 0)
    {
      printf("nxterm_server: up_fbinitialize failed: %d\n", -ret);
      return 1;
    }

  dev = up_fbgetvplane(0, CONFIG_EXAMPLES_NXTERM_VPLANE);
  if (!dev)
    {
      printf("nxterm_server: up_fbgetvplane failed, vplane=%d\n",
             CONFIG_EXAMPLES_NXTERM_VPLANE);
      return 2;
    }
#endif

  /* Then start the server */

  ret = nx_run(dev);
  gvdbg("nx_run returned: %d\n", errno);
  return 3;
}