Example #1
0
static inline FAR const struct nx_fontset_s *
  nxf_getglyphset(uint16_t ch, FAR const struct nx_fontpackage_s *package)
{
  FAR const struct nx_fontset_s *fontset;

  /* Select the 7- or 8-bit font set */

  if (ch < 128)
    {
      /* Select the 7-bit font set */

      fontset = &package->font7;
    }
  else if (ch < 256)
    {
#if CONFIG_NXFONTS_CHARBITS >= 8
      /* Select the 8-bit font set */

      fontset = &package->font8;
#else
      gdbg("8-bit font support disabled: %d\n", ch);
      return NULL;
#endif
    }
  else
    {
      /* Someday, perhaps 16-bit fonts will go here */

      gdbg("16-bit font not currently supported\n");
      return NULL;
    }

  /* Then verify that the character actually resides in the font */

  if (ch >= fontset->first && ch < fontset->first +fontset->nchars)
    {
      return fontset;
    }

  gdbg("No bitmap for code %02x\n", ch);
  return NULL;
}
Example #2
0
static FAR void *vnc_updater(FAR void *arg)
{
  FAR struct vnc_session_s *session = (FAR struct vnc_session_s *)arg;
  FAR struct vnc_fbupdate_s *srcrect;
  int ret;

  DEBUGASSERT(session != NULL);
  gvdbg("Updater running for Display %d\n", session->display);

  /* Loop, processing updates until we are asked to stop.
   * REVISIT: Probably need some kind of signal mechanism to wake up
   * vnc_remove_queue() in order to stop.  Or perhaps a special STOP
   * message in the queue?
   */

  while (session->state == VNCSERVER_RUNNING)
    {
      /* Get the next queued rectangle update.  This call will block until an
       * upate is available for the case where the update queue is empty.
       */

      srcrect = vnc_remove_queue(session);
      DEBUGASSERT(srcrect != NULL);

      updvdbg("Dequeued {(%d, %d),(%d, %d)}\n",
              srcrect->rect.pt1.x, srcrect->rect.pt1.y,
              srcrect->rect.pt2.x, srcrect->rect.pt2.y);

      /* Attempt to use RRE encoding */

      ret = vnc_rre(session, &srcrect->rect);
      if (ret == 0)
        {
          /* Perform the framebuffer update using the default RAW encoding */

          ret = vnc_raw(session, &srcrect->rect);
        }

      /* Release the update structure */

      vnc_free_update(session, srcrect);

      /* Break out and terminate the server if the encoding failed */

      if (ret < 0)
        {
          gdbg("ERROR: Encoding failed: %d\n", ret);
          break;
        }
    }

  session->state = VNCSERVER_STOPPED;
  return NULL;
}
Example #3
0
FAR struct lcd_dev_s *qemu_vga_initialize(void)
{
  int ret = init_graph_vga(VGA_XRES, VGA_YRES, 1);
  if (ret < 0)
    {
      gdbg("ERROR: init_graph_vga returned %d\n",ret);
    }

  memset(g_pscreen, 0, VGA_XRES * VGA_YRES);
  return &g_lcddev;
}
Example #4
0
void qemu_vga(void)
{
  int ret = init_graph_vga(VGA_XRES, VGA_YRES, 1);
  if (ret < 0)
    {
      gdbg("ERROR: init_graph_vga returned %d\n",ret);
    }

  memset(g_pscreen, g_bg_color, VGA_XRES * VGA_YRES);
  (void)register_driver("/dev/lcd", &g_vgaops, 0666, NULL);
}
Example #5
0
void nxcon_redraw(NXCONSOLE handle, FAR const struct nxgl_rect_s *rect, bool more)
{
    FAR struct nxcon_state_s *priv;
    int ret;
    int i;

    DEBUGASSERT(handle && rect);
    gvdbg("rect={(%d,%d),(%d,%d)} more=%s\n",
          rect->pt1.x, rect->pt1.y, rect->pt2.x, rect->pt2.y,
          more ? "true" : "false");

    /* Recover our private state structure */

    priv = (FAR struct nxcon_state_s *)handle;

    /* Get exclusive access to the state structure */

    do
    {
        ret = nxcon_semwait(priv);

        /* Check for errors */

        if (ret < 0)
        {
            /* The only expected error is if the wait failed because of it
             * was interrupted by a signal.
             */

            DEBUGASSERT(errno == EINTR);
        }
    }
    while (ret < 0);

    /* Fill the rectangular region with the window background color */

    ret = priv->ops->fill(priv, rect, priv->wndo.wcolor);
    if (ret < 0)
    {
        gdbg("fill failed: %d\n", errno);
    }

    /* Then redraw each character on the display (Only the characters within
     * the rectangle will actually be redrawn).
     */

    for (i = 0; i < priv->nchars; i++)
    {
        nxcon_fillchar(priv, rect, &priv->bm[i]);
    }

    (void)nxcon_sempost(priv);
}
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;
}
Example #7
0
static int board_initthread(int argc, char *argv[])
{
  int ret;

  /* Perform NSH initialization here instead of from the NSH.  This
   * alternative NSH initialization is necessary when NSH is ran in user-space
   * but the initialization function must run in kernel space.
   */

#if defined(CONFIG_NSH_LIBRARY) && !defined(CONFIG_NSH_ARCHINIT)
  ret = board_app_initialize();
  if (ret < 0)
    {
      gdbg("ERROR: board_app_initialize failed: %d\n", ret);
    }
#endif

  /* Initialize the NX server */

#ifdef HAVE_NXSTART
  ret = nx_start();
  if (ret < 0)
    {
      gdbg("ERROR: nx_start failed: %d\n", ret);
    }
#endif

  /* Initialize the touchscreen */

#ifdef HAVE_TCINIT
  ret = board_tsc_setup(CONFIG_NXWM_TOUCHSCREEN_DEVNO);
  if (ret < 0)
    {
      gdbg("ERROR: board_tsc_setup failed: %d\n", ret);
    }
#endif

  return EXIT_SUCCESS;
}
Example #8
0
static int ov2640_reset(FAR struct i2c_dev_s *i2c)
{
  int ret;

  ret = ov2640_putreglist(i2c, g_ov2640_reset, OV2640_RESET_NENTRIES);
  if (ret < 0)
    {
      gdbg("ERROR: ov2640_putreglist failed: %d\n", ret);
      return ret;
    }

  up_mdelay(5);
  return OK;
}
Example #9
0
static int ovr2640_chipid(FAR struct i2c_dev_s *i2c)
{
  uint8_t pidl;
  uint8_t pidh;
#ifdef CONFIG_DEBUG_GRAPHICS
  uint8_t midh;
  uint8_t midl;
#endif
  int ret;

  /* Check and show product ID and manufacturer ID */

  ret = ov2640_putreg(i2c, 0xff, 0x01); /* Select the sensor address bank */
  if (ret < 0)
    {
      gdbg("ERROR: ov2640_putreg failed: %d\n", ret);
      return ret;
    }

  pidl = ov2640_getreg(i2c, 0x0a);      /* Product ID (MS) */
  pidh = ov2640_getreg(i2c, 0x0b);      /* Product ID (LS) */

#ifdef CONFIG_DEBUG_GRAPHICS
  midh = ov2640_getreg(i2c, 0x1c); /* Manufacturer ID (high) = 0x7f */
  midl = ov2640_getreg(i2c, 0x1d); /* Manufacturer ID (low) = 0xa2 */
#endif

  if (pidl != OVR2640_PRODUCT_IDL || pidh != OVR2640_PRODUCT_IDH)
    {
      gdbg("ERROR: Unsupported PID=%02x$02x MID=%02x%02x\n",
            pidh, pidl, midh, midl);
      return -ENOSYS;
    }

  gvdbg("PID=%02x$02x MID=%02x%02x\n", pidh, pidl, midh, midl);
  return OK;
}
Example #10
0
static inline void nxmu_blocked(FAR struct nxbe_window_s *wnd, FAR void *arg)
{
  struct nxclimsg_blocked_s outmsg;
  int ret;

  outmsg.msgid = NX_CLIMSG_BLOCKED;
  outmsg.wnd   = wnd;
  outmsg.arg   = arg;

  ret = nxmu_sendclient(wnd->conn, &outmsg, sizeof(struct nxclimsg_blocked_s));
  if (ret < 0)
    {
      gdbg("nxmu_sendclient failed: %d\n", errno);
    }
}
Example #11
0
int nx_filltrapezoid(NXWINDOW hwnd, FAR const struct nxgl_rect_s *clip,
                     FAR const struct nxgl_trapezoid_s *trap,
                     nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
{
  FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd;
  struct nxsvrmsg_filltrapezoid_s  outmsg;
  int ret;
  int i;

#ifdef CONFIG_DEBUG
  if (!wnd || !wnd->conn || !trap || !color)
    {
      errno = EINVAL;
      return ERROR;
    }
#endif

  /* Format the fill command */

  outmsg.msgid = NX_SVRMSG_FILLTRAP;
  outmsg.wnd   = wnd;

  if (clip)
    {
      nxgl_rectcopy(&outmsg.clip, clip);
    }
  else
    {
      memset(&outmsg.clip, 0, sizeof(struct nxgl_rect_s));
    }
  nxgl_trapcopy(&outmsg.trap, trap);

  for (i = 0; i < CONFIG_NX_NPLANES; i++)
    {
      outmsg.color[i] = color[i];
    }

  /* Forward the fill command to the server */

  ret = mq_send(wnd->conn->cwrmq, &outmsg,
                sizeof(struct nxsvrmsg_filltrapezoid_s), NX_SVRMSG_PRIO);
  if (ret < 0)
    {
      gdbg("mq_send failed: %d\n", errno);
    }
  return ret;
}
Example #12
0
static void nxtool_redraw(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
                          bool more, FAR void *arg)
{
  nxgl_mxpixel_t color[CONFIG_NX_NPLANES];
  int ret;

  gvdbg("hwnd=%p rect={(%d,%d),(%d,%d)} more=%s\n",
         hwnd, rect->pt1.x, rect->pt1.y, rect->pt2.x, rect->pt2.y,
         more ? "true" : "false");

  color[0] = CONFIG_EXAMPLES_NXCON_TBCOLOR;
  ret = nxtk_filltoolbar(hwnd, rect, color);
  if (ret < 0)
    {
      gdbg("nxtk_filltoolbar failed: %d\n", errno);
    }
}
Example #13
0
static int board_initthread(int argc, char *argv[])
{
	int ret;

	/* Perform NSH initialization here instead of from the NSH.  This
	 * alternative NSH initialization is necessary when NSH is ran in user-space
	 * but the initialization function must run in kernel space.
	 */

#if defined(CONFIG_NSH_LIBRARY) && !defined(CONFIG_NSH_ARCHINIT)
	ret = nsh_archinitialize();
	if (ret < 0)
	{
		gdbg("ERROR: nsh_archinitialize failed: %d\n", ret);
	}
#endif
	return EXIT_SUCCESS;
}
Example #14
0
int up_fbinitialize(void)
{
  int ret;

  gvdbg("Allocating framebuffers\n");
  ret = dm320_allocvideomemory();
  if (ret != 0)
    {
      gdbg("Failed to allocate video buffers\n");
      return ret;
    }

  /* Initialize the hardware */

  gvdbg("Initializing hardware\n");
  dm320_hwinitialize();
  return 0;
}
Example #15
0
int nx_raise(NXWINDOW hwnd)
{
  FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd;
  struct nxsvrmsg_raise_s outmsg;
  int ret;

  /* Send the RAISE message */

  outmsg.msgid = NX_SVRMSG_RAISE;
  outmsg.wnd   = wnd;

  ret = mq_send(wnd->conn->cwrmq, &outmsg, sizeof(struct nxsvrmsg_raise_s), NX_SVRMSG_PRIO);
  if (ret < 0)
    {
      gdbg("mq_send failed: %d\n", errno);
    }
 return ret;
}
Example #16
0
static int ov2640_putreglist(FAR struct i2c_dev_s *i2c,
                             FAR const struct ovr2640_reg_s *reglist,
                             size_t nentries)
{
  FAR const struct ovr2640_reg_s *entry;
  int ret;

  for (entry = reglist; nentries > 0; nentries--, entry++)
    {
      ret = ov2640_putreg(i2c, entry->regaddr, entry->regval);
      if (ret < 0)
        {
          gdbg("ERROR: ov2640_putreg failed: %d\n", ret);
          return ret;
        }
    }

  return OK;
}
Example #17
0
int nx_closewindow(NXWINDOW hwnd)
{
  FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd;
  FAR struct nxfe_conn_s *conn = wnd->conn;
  struct nxsvrmsg_closewindow_s outmsg;
  int ret;

  /* Request destruction of the window by the serer */

  outmsg.msgid = NX_SVRMSG_CLOSEWINDOW;
  outmsg.wnd   = wnd;

  ret = mq_send(conn->cwrmq, &outmsg, sizeof(struct nxsvrmsg_closewindow_s), NX_SVRMSG_PRIO);
  if (ret < 0)
    {
      gdbg("mq_send failed: %d\n", errno);
    }
  return ret;
}
Example #18
0
static inline void nxmu_disconnect(FAR struct nxfe_conn_s *conn)
{
  struct nxclimsg_disconnected_s outmsg;
  int ret;

  /* Send the handshake message back to the client */

  outmsg.msgid = NX_CLIMSG_DISCONNECTED;

  ret = nxmu_sendclient(conn, &outmsg, sizeof(struct nxclimsg_disconnected_s));
  if (ret < 0)
    {
      gdbg("nxmu_sendclient failed: %d\n", errno);
    }

  /* Close the outgoing client message queue */

  (void)mq_close(conn->swrmq);
}
Example #19
0
void nx_disconnect(NXHANDLE handle)
{
  FAR struct nxfe_conn_s *conn = (FAR struct nxfe_conn_s *)handle;
  struct nxsvrmsg_s       msg;
  int                     ret;

  /* Inform the server that this client no longer exists */

  msg.msgid = NX_SVRMSG_CONNECT;
  msg.conn  = conn;

  ret = mq_send(conn->cwrmq, &msg, sizeof(struct nxsvrmsg_s), NX_SVRMSG_PRIO);
  if (ret < 0)
    {
      gdbg("mq_send failed: %d\n", errno);
    }

  /* We will finish the teardown upon receipt of the DISCONNECTED message */
}
Example #20
0
void nx_disconnect(NXHANDLE handle)
{
  FAR struct nxfe_conn_s *conn = (FAR struct nxfe_conn_s *)handle;
  struct nxsvrmsg_s       outmsg;
  int                     ret;

  /* Inform the server that this client no longer exists */

  outmsg.msgid = NX_SVRMSG_DISCONNECT;
  outmsg.conn  = conn;

  /* We will finish the teardown upon receipt of the DISCONNECTED message */

  ret = nxmu_sendserver(conn, &outmsg, sizeof(struct nxsvrmsg_s));
  if (ret < 0)
    {
      gdbg("ERROR: nxmu_sendserver() returned %d\n", ret);
    }
}
Example #21
0
int nx_mousein(NXHANDLE handle, nxgl_coord_t x, nxgl_coord_t y, uint8_t buttons)
{
  FAR struct nxfe_conn_s *conn = (FAR struct nxfe_conn_s *)handle;
  struct nxsvrmsg_mousein_s outmsg;
  int ret;

  /* Inform the server that this client no longer exists */

  outmsg.msgid   = NX_SVRMSG_MOUSEIN;
  outmsg.pt.x    = x;
  outmsg.pt.y    = y;
  outmsg.buttons = buttons;

  ret = mq_send(conn->cwrmq, &outmsg, sizeof(struct nxsvrmsg_mousein_s), NX_SVRMSG_PRIO);
  if (ret < 0)
    {
      gdbg("mq_send failed: %d\n", errno);
    }
  return ret;
}
Example #22
0
void nx_redrawreq(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect)
{
  FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd;
  struct nxsvrmsg_redrawreq_s outmsg;
  int ret;

  DEBUGASSERT(wnd && rect);

  /* Inform the server of the changed position */

  outmsg.msgid = NX_SVRMSG_REDRAWREQ;
  outmsg.wnd   = wnd;
  nxgl_rectcopy(&outmsg.rect, rect);

  ret = nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_redrawreq_s));
  if (ret < 0)
    {
      gdbg("ERROR: nxmu_sendwindow failed: %d\n", errno);
    }
}
Example #23
0
static void ssd1351_select(FAR struct ssd1351_dev_s *priv)
{
  FAR struct spi_dev_s *spi = priv->spi;

  /* Select the chip, locking the SPI bus in case there are multiple devices
   * competing for the SPI bus
   */

  gdbg("SELECTED\n");
  SPI_LOCK(spi, true);
  SPI_SELECT(spi, SPIDEV_DISPLAY, true);

  /* Now make sure that the SPI bus is configured for this device (it might
   * have gotten configured for a different device while unlocked)
   */

  SPI_SETMODE(spi, CONFIG_SSD1351_SPIMODE);
  SPI_SETBITS(spi, SSD1351_SPIBITS);
  (void)SPI_HWFEATURES(spi, 0);
  (void)SPI_SETFREQUENCY(spi, CONFIG_SSD1351_SPIFREQ);
}
Example #24
0
static int tiff_datetime(FAR char *timbuf, unsigned int buflen)
{
  struct timespec ts;
  struct tm tm;
  int ret;

  /* Get the current time */

  ret = clock_gettime(CLOCK_REALTIME, &ts);
  if (ret < 0)
    {
      gdbg("clock_gettime failed: %d\n", errno);
      return ERROR;
    }

  /* Break the current time up into the format needed by strftime */

  (void)gmtime_r((FAR const time_t*)&ts.tv_sec, &tm);

  /* Comvert the current time in the TIFF format */

  (void)strftime(timbuf, buflen, TIFF_DATETIME_FORMAT, &tm);
  return OK;
}
static inline int ov2640_camera_initialize(void)
{
  FAR struct i2c_dev_s *i2c;
  uint32_t actual;
  int ret;

  /* Get the I2C driver that interfaces with the camers (OV2640_BUS)*/

  i2c = up_i2cinitialize(OV2640_BUS);
  if (!i2c)
    {
      gdbg("ERROR: Failed to initialize TWI%d\n", OV2640_BUS);
      return EXIT_FAILURE;
    }

  /* Enable clocking to the ISI peripheral */

  sam_isi_enableclk();

  /* Configure OV2640 pins
   *
   * ISI:
   * - HSYNC, VSYNC, PCK
   * - 8 data bits for 8-bit color
   * PCK
   * - PCK1 provides OV2640 system clock
   */

  sam_configpio(PIO_ISI_HSYNC);
  sam_configpio(PIO_ISI_VSYNC);
  sam_configpio(PIO_ISI_PCK);

  sam_configpio(PIO_ISI_D0);
  sam_configpio(PIO_ISI_D1);
  sam_configpio(PIO_ISI_D2);
  sam_configpio(PIO_ISI_D3);
  sam_configpio(PIO_ISI_D4);
  sam_configpio(PIO_ISI_D5);
  sam_configpio(PIO_ISI_D6);
  sam_configpio(PIO_ISI_D7);

  sam_configpio(PIO_PMC_PCK1);

  /* Configure and enable the PCK1 output */

  actual = sam_pck_configure(PCK1, OV2640_FREQUENCY);
  gvdbg("Desired PCK1 frequency: %ld Actual: %ld\n",
        (long)OV2640_FREQUENCY, (long)actual);

  sam_pck_enable(PCK1, true);

  /* Configure the ISI peripheral */
#warning Missing Logic

  /* Initialize the OV2640 camera */

  ret = ov2640_initialize(i2c);
  if (ret < 0)
    {
      gdbg("ERROR: Failed to initialize the OV2640: %d\n", ret);
      return EXIT_FAILURE;
    }

  return EXIT_FAILURE;
}
Example #26
0
NXHANDLE nx_connectinstance(FAR const char *svrmqname)
{
    FAR struct nxfe_conn_s *conn;
    struct nxsvrmsg_s       msg;
    char                    climqname[NX_CLIENT_MXNAMELEN];
    struct mq_attr          attr;
    int                     ret;

    /* Sanity checking */

#ifdef CONFIG_DEBUG
    if (!svrmqname)
    {
        errno = EINVAL;
        return NULL;
    }
#endif

    /* Allocate the NX client structure */

    conn = (FAR struct nxfe_conn_s *)zalloc(sizeof(struct nxfe_conn_s));
    if (!conn)
    {
        errno = ENOMEM;
        goto errout;
    }

    /* Create the client MQ name */

    nxmu_semtake(&g_nxlibsem);
    conn->cid = g_nxcid++;
    nxmu_semgive(&g_nxlibsem);

    sprintf(climqname, NX_CLIENT_MQNAMEFMT, conn->cid);

    /* Open the client MQ for reading */

    attr.mq_maxmsg  = CONFIG_NX_MXCLIENTMSGS;
    attr.mq_msgsize = NX_MXCLIMSGLEN;
    attr.mq_flags   = 0;

#ifdef CONFIG_NX_BLOCKING
    conn->crdmq = mq_open(climqname, O_RDONLY|O_CREAT, 0666, &attr);
#else
    conn->crdmq = mq_open(climqname, O_RDONLY|O_CREAT|O_NONBLOCK, 0666, &attr);
#endif
    if (conn->crdmq == (mqd_t)-1)
    {
        gdbg("mq_open(%s) failed: %d\n", climqname, errno);
        goto errout_with_conn;
    }

    /* Open the server MQ for writing */

    attr.mq_maxmsg  = CONFIG_NX_MXSERVERMSGS;
    attr.mq_msgsize = NX_MXSVRMSGLEN;
    attr.mq_flags   = 0;

    conn->cwrmq = mq_open(svrmqname, O_WRONLY|O_CREAT, 0666, &attr);
    if (conn->cwrmq == (mqd_t)-1)
    {
        gdbg("mq_open(%s) failed: %d\n", svrmqname, errno);
        goto errout_with_rmq;
    }

    /* Inform the server that this client exists */

    msg.msgid = NX_SVRMSG_CONNECT;
    msg.conn  = conn;

    ret = mq_send(conn->cwrmq, &msg, sizeof(struct nxsvrmsg_s), NX_SVRMSG_PRIO);
    if (ret < 0)
    {
        gdbg("mq_send failed: %d\n", errno);
        goto errout_with_wmq;
    }

#if 0
    /* Now read until we get a response to this message.  The server will
     * respond with either (1) NX_CLIMSG_CONNECTED, in which case the state
     * will change to NX_CLISTATE_CONNECTED, or (2) NX_CLIMSG_DISCONNECTED
     * in which case, nx_message will fail with errno = EHOSTDOWN.
     */

    do
    {
        ret = nx_eventhandler((NXHANDLE)conn);
        if (ret < 0)
        {
            gdbg("nx_message failed: %d\n", errno);
            goto errout_with_wmq;
        }
        usleep(300000);
    }
    while (conn->state != NX_CLISTATE_CONNECTED);
#endif
    return (NXHANDLE)conn;

errout_with_wmq:
    mq_close(conn->cwrmq);
errout_with_rmq:
    mq_close(conn->crdmq);
errout_with_conn:
    free(conn);
errout:
    return NULL;
}
Example #27
0
static inline FAR struct nxcon_glyph_s *
nxcon_renderglyph(FAR struct nxcon_state_s *priv,
                   FAR const struct nx_fontbitmap_s *fbm, uint8_t ch)
{
  FAR struct nxcon_glyph_s *glyph = NULL;
  FAR nxgl_mxpixel_t *ptr;
#if CONFIG_NXCONSOLE_BPP < 8
  nxgl_mxpixel_t pixel;
#endif
  int bmsize;
  int row;
  int col;
  int ret;

  /* Allocate the glyph (always succeeds) */

  glyph         = nxcon_allocglyph(priv);
  glyph->code   = ch;

  /* Get the dimensions of the glyph */

  glyph->width  = fbm->metric.width + fbm->metric.xoffset;
  glyph->height = fbm->metric.height + fbm->metric.yoffset;

  /* Get the physical width of the glyph in bytes */

  glyph->stride = (glyph->width * CONFIG_NXCONSOLE_BPP + 7) / 8;

  /* Allocate memory to hold the glyph with its offsets */

  bmsize        =  glyph->stride * glyph->height;
  glyph->bitmap = (FAR uint8_t *)kmalloc(bmsize);

  if (glyph->bitmap)
    {
      /* Initialize the glyph memory to the background color using the
       * hard-coded bits-per-pixel (BPP).
       *
       * TODO:  The rest of NX is configured to support multiple devices
       * with differing BPP.  They logic should be extended to support
       * differing BPP's as well.
       */

#if CONFIG_NXCONSOLE_BPP < 8
      pixel  = priv->wndo.wcolor[0];

#  if CONFIG_NXCONSOLE_BPP == 1

      /* Pack 1-bit pixels into a 2-bits */

      pixel &= 0x01;
      pixel  = (pixel) << 1 | pixel;

#  endif
#  if CONFIG_NXCONSOLE_BPP < 4

      /* Pack 2-bit pixels into a nibble */

      pixel &= 0x03;
      pixel  = (pixel) << 2 | pixel;

#  endif

      /* Pack 4-bit nibbles into a byte */

      pixel &= 0x0f;
      pixel  = (pixel) << 4 | pixel;

      ptr    = (FAR nxgl_mxpixel_t *)glyph->bitmap;
      for (row = 0; row < glyph->height; row++)
        {
          for (col = 0; col < glyph->stride; col++)
            {
              /* Transfer the packed bytes into the buffer */

              *ptr++ = pixel;
            }
        }

#elif CONFIG_NXCONSOLE_BPP == 24
# error "Additional logic is needed here for 24bpp support"

#else /* CONFIG_NXCONSOLE_BPP = {8,16,32} */

      ptr = (FAR nxgl_mxpixel_t *)glyph->bitmap;
      for (row = 0; row < glyph->height; row++)
        {
          /* Just copy the color value into the glyph memory */

          for (col = 0; col < glyph->width; col++)
            {
              *ptr++ = priv->wndo.wcolor[0];
            }
        }
#endif

      /* Then render the glyph into the allocated memory */

      ret = RENDERER((FAR nxgl_mxpixel_t*)glyph->bitmap,
                      glyph->height, glyph->width, glyph->stride,
                      fbm, priv->wndo.fcolor[0]);
      if (ret < 0)
        {
          /* Actually, the RENDERER never returns a failure */

          gdbg("nxcon_renderglyph: RENDERER failed\n");
          nxcon_freeglyph(glyph);
          glyph = NULL;
        }
    }

  return glyph;
}
Example #28
0
static void dm320_hwinitialize(void)
{
  /* Disable all planes */

  dm320_disable();

  /* Initialize the main video to correct the origin */

  gvdbg("Setup main video origin:\n");

  putreg16(CONFIG_DM320_BASEX, DM320_OSD_BASEPX);
  putreg16(CONFIG_DM320_BASEY, DM320_OSD_BASEPY);

  gvdbg("DM320_OSD_BASEPX:      %04x\n", getreg16(DM320_OSD_BASEPX));
  gvdbg("DM320_OSD_BASEPY:      %04x\n", getreg16(DM320_OSD_BASEPY));

  /* Set up the frame buffer address registers */

  gvdbg("Setup framebuffer addresses:\n");


  putreg16(((dm320_osd1upperoffset() << 8) |
        dm320_osd0upperoffset()), DM320_OSD_OSDWINADH);
  putreg16(dm320_osd0loweroffset(), DM320_OSD_OSDWIN0ADL);
  putreg16(dm320_osd1loweroffset(), DM320_OSD_OSDWIN1ADL);

  gvdbg("DM320_OSD_OSDWINADH:   %04x\n", getreg16(DM320_OSD_OSDWINADH));
  gvdbg("DM320_OSD_OSDWIN0ADL:  %04x\n", getreg16(DM320_OSD_OSDWIN0ADL));
  gvdbg("DM320_OSD_OSDWIN1ADL:  %04x\n", getreg16(DM320_OSD_OSDWIN1ADL));

  /* Set up VID WIN0 */

#if defined(CONFIG_DM320_VID0_DISABLE) || defined(CONFIG_DM320_VID1_DISABLE)
  putreg16(((dm320_vid1upperoffset() << 8) | dm320_vid0upperoffset()), DM320_OSD_VIDWINADH);
#endif

#ifndef CONFIG_DM320_VID0_DISABLE
  gvdbg("Initialize video win0:\n");
  putreg16(dm320_vid0loweroffset(), DM320_OSD_VIDWIN0ADL);

  gvdbg("DM320_OSD_VIDWINADH:   %04x\n", getreg16(DM320_OSD_VIDWINADH));
  gvdbg("DM320_OSD_VIDWIN0ADL:  %04x\n", getreg16(DM320_OSD_VIDWIN0ADL));
  dm320_blankscreen((uint8_t *)g_vid0base, DM320_VID0_FBLEN);

#ifndef CONFIG_DM320_DISABLE_PINGPONG
  putreg16(dm320_vid0ppupperoffset(), DM320_OSD_PPVWIN0ADH);
  putreg16(dm320_vid0pploweroffset(), DM320_OSD_PPVWIN0ADL);

  gvdbg("DM320_OSD_PPVWIN0ADH:  %04x\n", getreg16(DM320_OSD_PPVWIN0ADH));
  gvdbg("DM320_OSD_PPVWIN0ADL:  %04x\n", getreg16(DM320_OSD_PPVWIN0ADL));
  dm320_blankscreen((uint8_t *)g_vid0ppbase, DM320_VID0_FBLEN);
#endif

  putreg16(CONFIG_DM320_VID0_XPOS, DM320_OSD_VIDWIN0XP);
  putreg16(CONFIG_DM320_VID0_YPOS, DM320_OSD_VIDWIN0YP);
  putreg16((CONFIG_DM320_VID0_XRES >> 4), DM320_OSD_VIDWIN0OFST);
  putreg16(CONFIG_DM320_VID0_XRES, DM320_OSD_VIDWIN0XL);
  putreg16(CONFIG_DM320_VID0_YRES, DM320_OSD_VIDWIN0YL);

  gvdbg("DM320_OSD_VIDWIN0XP:   %04x\n", getreg16(DM320_OSD_VIDWIN0XP));
  gvdbg("DM320_OSD_VIDWIN0YP:   %04x\n", getreg16(DM320_OSD_VIDWIN0YP));
  gvdbg("DM320_OSD_VIDWIN0OFST: %04x\n", getreg16(DM320_OSD_VIDWIN0OFST));
  gvdbg("DM320_OSD_VIDWIN0XL:   %04x\n", getreg16(DM320_OSD_VIDWIN0XL));
  gvdbg("DM320_OSD_VIDWIN0YL:   %04x\n", getreg16(DM320_OSD_VIDWIN0YL));
#endif

  /* Set up VID WIN1 */

#ifndef CONFIG_DM320_VID1_DISABLE
  gvdbg("Initialize video win1:\n");
  putreg16(dm320_vid1loweroffset(), DM320_OSD_VIDWIN1ADL);

  gvdbg("DM320_OSD_VIDWINADH:   %04x\n", getreg16(DM320_OSD_VIDWINADH));
  gvdbg("DM320_OSD_VIDWIN1ADL:  %04x\n", getreg16(DM320_OSD_VIDWIN1ADL));
  dm320_blankscreen((uint8_t *)g_vid1base, DM320_VID1_FBLEN);

  putreg16(CONFIG_DM320_VID1_XPOS, DM320_OSD_VIDWIN1XP);
  putreg16(CONFIG_DM320_VID1_XPOS, DM320_OSD_VIDWIN1YP);
  putreg16((CONFIG_DM320_VID1_XRES >> 4), DM320_OSD_VIDWIN1OFST);
  putreg16(CONFIG_DM320_VID1_XRES, DM320_OSD_VIDWIN1XL);
  putreg16(CONFIG_DM320_VID1_YRES, DM320_OSD_VIDWIN1YL);

  gvdbg("DM320_OSD_VIDWIN1XP:   %04x\n", getreg16(DM320_OSD_VIDWIN1XP));
  gvdbg("DM320_OSD_VIDWIN1YP:   %04x\n", getreg16(DM320_OSD_VIDWIN1YP));
  gvdbg("DM320_OSD_VIDWIN1OFST: %04x\n", getreg16(DM320_OSD_VIDWIN1OFST));
  gvdbg("DM320_OSD_VIDWIN1XL:   %04x\n", getreg16(DM320_OSD_VIDWIN1XL));
  gvdbg("DM320_OSD_VIDWIN1YL:   %04x\n", getreg16(DM320_OSD_VIDWIN1YL));
#endif

  putreg16(DM320_VIDMODE, DM320_OSD_VIDWINMD);
  gvdbg("DM320_OSD_VIDWINMD:    %04x\n", getreg16(DM320_OSD_VIDWINMD));

  /* Set up OSD WIN0 */

#ifndef CONFIG_DM320_OSD0_DISABLE
  gvdbg("Initialize OSD win0:\n");
  dm320_blankscreen((uint8_t *)g_osd0base, DM320_OSD0_FBLEN);

  putreg16(CONFIG_DM320_OSD0_XPOS, DM320_OSD_OSDWIN0XP);
  putreg16(CONFIG_DM320_OSD0_YPOS, DM320_OSD_OSDWIN0YP);
#ifdef CONFIG_DM320_OSD1_RGB16
  putreg16((CONFIG_DM320_OSD0_XRES >> 4), DM320_OSD_OSDWIN0OFST);
#else
  putreg16((CONFIG_DM320_OSD0_XRES >> 5), DM320_OSD_OSDWIN0OFST);
#endif
  putreg16(CONFIG_DM320_OSD0_XRES, DM320_OSD_OSDWIN0XL);
  putreg16(CONFIG_DM320_OSD0_YRES, DM320_OSD_OSDWIN0YL);
  putreg16(INITIAL_OSD0MODE, DM320_OSD_OSDWIN0MD);

  gvdbg("DM320_OSD_OSDWIN0XP:   %04x\n", getreg16(DM320_OSD_OSDWIN0XP));
  gvdbg("DM320_OSD_OSDWIN0YP:   %04x\n", getreg16(DM320_OSD_OSDWIN0YP));
  gvdbg("DM320_OSD_OSDWIN0OFST: %04x\n", getreg16(DM320_OSD_OSDWIN0OFST));
  gvdbg("DM320_OSD_OSDWIN0XL:   %04x\n", getreg16(DM320_OSD_OSDWIN0XL));
  gvdbg("DM320_OSD_OSDWIN0YL:   %04x\n", getreg16(DM320_OSD_OSDWIN0YL));
  gvdbg("DM320_OSD_OSDWIN0MD:   %04x\n", getreg16(DM320_OSD_OSDWIN0MD));
#endif

  /* Set up OSD WIN1 */

#ifndef CONFIG_DM320_OSD1_DISABLE
  gvdbg("Initialize OSD win1\n");
  dm320_blankscreen((uint8_t *)g_osd1base, DM320_OSD1_FBLEN);

  putreg16(CONFIG_DM320_OSD1_XPOS, DM320_OSD_OSDWIN1XP);
  putreg16(CONFIG_DM320_OSD1_YPOS, DM320_OSD_OSDWIN1YP);
#ifdef CONFIG_DM320_OSD1_RGB16
  putreg16((CONFIG_DM320_OSD1_XRES >> 4), DM320_OSD_OSDWIN1OFST);
#else
  putreg16((CONFIG_DM320_OSD1_XRES >> 5), DM320_OSD_OSDWIN1OFST);
#endif
  putreg16(CONFIG_DM320_OSD1_XRES, DM320_OSD_OSDWIN1XL);
  putreg16(CONFIG_DM320_OSD1_YRES, DM320_OSD_OSDWIN1YL);
  putreg16(INITIAL_OSD1MODE, DM320_OSD_OSDWIN1MD);

  gvdbg("DM320_OSD_OSDWIN1XP:   %04x\n", getreg16(DM320_OSD_OSDWIN1XP));
  gvdbg("DM320_OSD_OSDWIN1YP:   %04x\n", getreg16(DM320_OSD_OSDWIN1YP));
  gvdbg("DM320_OSD_OSDWIN1OFST: %04x\n", getreg16(DM320_OSD_OSDWIN1OFST));
  gvdbg("DM320_OSD_OSDWIN1XL:   %04x\n", getreg16(DM320_OSD_OSDWIN1XL));
  gvdbg("DM320_OSD_OSDWIN1YL:   %04x\n", getreg16(DM320_OSD_OSDWIN1YL));
  gvdbg("DM320_OSD_OSDWIN1MD:   %04x\n", getreg16(DM320_OSD_OSDWIN1MD));
#endif

  /* Set up the rectangular cursor with defaults */

#ifdef CONFIG_FB_HWCURSOR
  gdbg("Initialize rectangular cursor\n");

  putreg16(0, DM320_OSD_CURXP);
  putreg16(0, DM320_OSD_CURYP);
  putreg16(CONFIG_DM320_RECTCURSOR_WIDTH, DM320_OSD_CURXL);
  putreg16(CONFIG_DM320_RECTCURSOR_HEIGHT, DM320_OSD_CURYL);

  /* DM320_RECTCURSOR_SETUP:
   *
   * Bit 0: 0=rectangular cursor inactive 1=on             0
   * Bits 113: Vertical line height: {1,2,4,6,8,10,12,14}  CONFIG_DM320_CURSORLINEHEIGHT
   * 4:6: Horizontal line width: {1,4,8,16,20,24,28}       CONFIG_DM320_CURSORLINEWIDTH
   * 7: 0=ROM lookup table, 1=RAM lookup table             0
   * 8:15: Rectangular cursor color pallette address       CONFIG_DM320_CURSORCLUT
   */

  putreg16(DM320_RECTCURSOR_SETUP, DM320_OSD_RECTCUR);

  gvdbg("DM320_OSD_CURXP:       %04x\n", getreg16(DM320_OSD_CURXP));
  gvdbg("DM320_OSD_CURYP:       %04x\n", getreg16(DM320_OSD_CURYP));
  gvdbg("DM320_OSD_CURXL:       %04x\n", getreg16(DM320_OSD_CURXL));
  gvdbg("DM320_OSD_CURYL:       %04x\n", getreg16(DM320_OSD_CURYL));
  gvdbg("DM320_OSD_RECTCUR:     %04x\n", getreg16(DM320_OSD_RECTCUR));
#endif

  /* Set main window to the hardware default state.  That initial
   * state is:
   *
   * FIELD                                         SETTING
   * Bits 0-7: background color clut               CONFIG_DM320_BKGDCLUT
   * Bit 8: background clut 0=ROM 1=RAM            0
   * Bit 9: field signal 0=normal 1=inverted       0
   * Bit 10: vid window H expansion: 1=x9/8        0
   * Bit 11: vid window V expansion: 1=x6/5        0
   * Bit 12: expansion filter 0=off 1=on           0
   * Bit 13: osd window H expansion: 1=x9/8        0
   * Bit 14: osd window V expansion: 1=x6/5        0
   * Bit 1515: 0=offset binary, 1=complement of 2  0
   */

  putreg16(CONFIG_DM320_BKGDCLUT, DM320_OSD_OSDMODE);
  gvdbg("DM320_OSD_OSDMODE:     %04x\n", getreg16(DM320_OSD_OSDMODE));
}
Example #29
0
void nxcon_kbdin(NXCONSOLE handle, FAR const uint8_t *buffer, uint8_t buflen)
{
  FAR struct nxcon_state_s *priv;
  ssize_t nwritten;
  int nexthead;
  char ch;
  int ret;

  gvdbg("buflen=%d\n");
  DEBUGASSERT(handle);

  /* Get the reference to the driver structure from the handle */

  priv = (FAR struct nxcon_state_s *)handle;

  /* Get exclusive access to the driver structure */

  ret = nxcon_semwait(priv);
  if (ret < 0)
    {
      gdbg("ERROR: nxcon_semwait failed\n");
      return;
    }

 /* Loop until all of the bytes have been written.  This function may be
  * called from an interrupt handler!  Semaphores cannot be used!
  *
  * The write logic only needs to modify the head index.  Therefore,
  * there is a difference in the way that head and tail are protected:
  * tail is protected with a semaphore; tail is protected by disabling
  * interrupts.
  */

  for (nwritten = 0; nwritten < buflen; nwritten++)
    {
      /* Add the next character */

      ch = buffer[nwritten];

      /* Calculate the write index AFTER the next byte is add to the ring
       * buffer
       */

      nexthead = priv->head + 1;
      if (nexthead >= CONFIG_NXCONSOLE_KBDBUFSIZE)
        {
          nexthead = 0;
        }

      /* Would the next write overflow the circular buffer? */

      if (nexthead == priv->tail)
        {
          /* Yes... Return an indication that nothing was saved in the buffer. */

          gdbg("ERROR: Keyboard data overrun\n");
          break;
        }

      /* No... copy the byte */

      priv->rxbuffer[priv->head] = ch;
      priv->head = nexthead;
    }

  /* Was anything written? */

  if (nwritten > 0)
    {
      int i;

      /* Are there threads waiting for read data? */

      sched_lock();
      for (i = 0; i < priv->nwaiters; i++)
        {
          /* Yes.. Notify all of the waiting readers that more data is available */

          sem_post(&priv->waitsem);
        }

      /* Notify all poll/select waiters that they can write to the FIFO */

#ifndef CONFIG_DISABLE_POLL
      nxcon_pollnotify(priv, POLLIN);
#endif
      sched_unlock();
    }

  nxcon_sempost(priv);
}
Example #30
0
int nxcon_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup)
{
  FAR struct inode *inode = filep->f_inode;
  FAR struct nxcon_state_s *priv;
  pollevent_t eventset;
  int ret;
  int i;

  /* Some sanity checking */

  DEBUGASSERT(inode && inode->i_private);
  priv = inode->i_private;

  /* Get exclusive access to the driver structure */

  ret = nxcon_semwait(priv);
  if (ret < 0)
    {
      gdbg("ERROR: nxcon_semwait failed\n");
      return ret;
    }

  /* Are we setting up the poll?  Or tearing it down? */

  if (setup)
    {
      /* This is a request to set up the poll.  Find an available
       * slot for the poll structure reference
       */

      for (i = 0; i < CONFIG_NXCONSOLE_NPOLLWAITERS; i++)
        {
          /* Find an available slot */

          if (!priv->fds[i])
            {
              /* Bind the poll structure and this slot */

              priv->fds[i] = fds;
              fds->priv       = &priv->fds[i];
              break;
            }
        }

      if (i >= CONFIG_NXCONSOLE_NPOLLWAITERS)
        {
          gdbg("ERROR: Too many poll waiters\n");

          fds->priv    = NULL;
          ret          = -EBUSY;
          goto errout;
        }

      /* Should immediately notify on any of the requested events?
       * This driver is always available for transmission.
       */

      eventset = POLLOUT;

      /* Check if the receive buffer is empty */

      if (priv->head != priv->tail)
       {
         eventset |= POLLIN;
       }

      if (eventset)
        {
          nxcon_pollnotify(priv, eventset);
        }

    }
  else if (fds->priv)
    {
      /* This is a request to tear down the poll. */

      struct pollfd **slot = (struct pollfd **)fds->priv;

#ifdef CONFIG_DEBUG
      if (!slot)
        {
          gdbg("ERROR: No slot\n");

          ret = -EIO;
          goto errout;
        }
#endif

      /* Remove all memory of the poll setup */

      *slot      = NULL;
      fds->priv  = NULL;
    }

errout:
  nxcon_sempost(priv);
  return ret;
}