Exemplo n.º 1
0
static void nxhello_position(NXWINDOW hwnd, FAR const struct nxgl_size_s *size,
                          FAR const struct nxgl_point_s *pos,
                          FAR const struct nxgl_rect_s *bounds,
                          FAR void *arg)
{
  /* Report the position */

  ginfo("hwnd=%p size=(%d,%d) pos=(%d,%d) bounds={(%d,%d),(%d,%d)}\n",
        hwnd, size->w, size->h, pos->x, pos->y,
        bounds->pt1.x, bounds->pt1.y, bounds->pt2.x, bounds->pt2.y);

  /* Have we picked off the window bounds yet? */

  if (!g_nxhello.havepos)
    {
      /* Save the background window handle */

      g_nxhello.hbkgd = hwnd;

      /* Save the window limits */

      g_nxhello.xres = bounds->pt2.x + 1;
      g_nxhello.yres = bounds->pt2.y + 1;

      g_nxhello.havepos = true;
      sem_post(&g_nxhello.sem);
      ginfo("Have xres=%d yres=%d\n", g_nxhello.xres, g_nxhello.yres);
    }
}
Exemplo n.º 2
0
Arquivo: btds4.c Projeto: matlo/GIMX
static int close_ps4_sdp(void * user)
{
  int btds4_number = (intptr_t) user;

  struct btds4_state* state = states + btds4_number;

  if(state->ps4_channels.sdp.id >= 0)
  {
    l2cap_abs_get()->close(state->ps4_channels.sdp.id);
    state->ps4_channels.sdp.id = -1;
  }

  if(state->sys.shutdown)
  {
    return 1;
  }

  /*
   * Warning: this is really hackish...
   * There is an issue at the very first connection.
   * Maybe the acl_send_data hack interferes in some way with the l2cap sockets.
   * As a work-around, we disconnect and restart the connection.
   */

  l2cap_abs_get()->disconnect(state->ps4_channels.control.id);
  close_ps4_control(user);
  close_ps4_interrupt(user);

  ginfo("connecting with hci%d = %s to %s psm 0x%04x\n", state->dongle_index,
      state->dongle_bdaddr.str, state->ps4_bdaddr, PSM_HID_CONTROL);

  if ((state->ps4_channels.control.id = l2cap_abs_get()->connect(state->dongle_bdaddr.str, state->ps4_bdaddr,
      PSM_HID_CONTROL, L2CAP_ABS_LM_MASTER | L2CAP_ABS_LM_AUTH | L2CAP_ABS_LM_ENCRYPT, user, connect_ps4_control, close_ps4_control)) < 0)
  {
    fprintf(stderr, "can't connect to control psm\n");
    return -1;
  }

  state->ps4_channels.control.pending = 1;

  ginfo("connecting with hci%d = %s to %s psm 0x%04x\n", state->dongle_index,
      state->dongle_bdaddr.str, state->ps4_bdaddr, PSM_HID_INTERRUPT);

  if ((state->ps4_channels.interrupt.id = l2cap_abs_get()->connect(state->dongle_bdaddr.str, state->ps4_bdaddr,
      PSM_HID_INTERRUPT, L2CAP_ABS_LM_MASTER | L2CAP_ABS_LM_AUTH | L2CAP_ABS_LM_ENCRYPT, user, connect_ps4_interrupt, close_ps4_control)) < 0)
  {
    close_ps4_control(user);
    fprintf(stderr, "can't connect to interrupt psm\n");
    return -1;
  }

  state->ps4_channels.interrupt.pending = 1;

  return 1;
}
Exemplo n.º 3
0
static int lcd_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno,
    FAR struct lcd_planeinfo_s *pinfo)
{
  DEBUGASSERT(dev && pinfo && planeno == 0);ginfo("planeno: %d bpp: %d\n", planeno, g_planeinfo.bpp);
  memcpy(pinfo, &g_planeinfo, sizeof(struct lcd_planeinfo_s));
  return OK;
}
Exemplo n.º 4
0
static int ssd1351_setpower(FAR struct lcd_dev_s *dev, int power)
{
  FAR struct ssd1351_dev_s *priv = (FAR struct ssd1351_dev_s *)dev;

  /* Sanity check */

  DEBUGASSERT(priv != NULL && (unsigned int)power <= LCD_FULL_ON);
  ginfo("power: %d\n", power);

  /* Select and lock the device */

  ssd1351_select(priv);

  if (power > LCD_FULL_OFF)
    {
      /* Turn the display on */

      ssd1351_write(priv, SSD1351_CMD_DISPON, NULL, 0);
      priv->power = LCD_FULL_ON;
    }
  else
    {
      /* Turn the display off */

      ssd1351_write(priv, SSD1351_CMD_DISPOFF, NULL, 0);
      priv->power = LCD_FULL_OFF;
    }

  /* Unlock and de-select the device */

  ssd1351_deselect(priv);

  return OK;
}
Exemplo n.º 5
0
static void nxhello_redraw(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
                        bool more, FAR void *arg)
{
  ginfo("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");
}
Exemplo n.º 6
0
static int lcd_getvideoinfo(FAR struct lcd_dev_s *dev,
    FAR struct fb_videoinfo_s *vinfo)
{
  DEBUGASSERT(dev && vinfo);ginfo("fmt: %d xres: %d yres: %d nplanes: %d\n",
      g_videoinfo.fmt, g_videoinfo.xres, g_videoinfo.yres, g_videoinfo.nplanes);
  memcpy(vinfo, &g_videoinfo, sizeof(struct fb_videoinfo_s));
  return OK;
}
Exemplo n.º 7
0
static int lcd_setpower(struct lcd_dev_s *dev, int power)
{
  uint16_t reg;

  if (g_lcddev.power == power) {
    return OK;
  }

  ginfo("power: %d\n", power);
  DEBUGASSERT(power <= CONFIG_LCD_MAXPOWER);

  /* Set new power level */
  reg = getreg16(ASIC_CONF_REG);
  if (power)
    {
      reg = getreg16(ASIC_CONF_REG);
      /* LCD Set I/O(3) / SA0 to I/O(3) mode */
      reg &= ~( (1 << 12) | (1 << 10) | (1 << 7) | (1 << 1)) ;
      /* don't set function pins to I2C Mode, C155 uses UWire */
      /* TWL3025: Set SPI+RIF RX clock to rising edge */
      reg |= (1 << 13) | (1 << 14);
      putreg16(reg, ASIC_CONF_REG);

      /* LCD Set I/O(3) to output mode and enable C155 backlight (IO1) */
      /* FIXME: Put the display backlight control to backlight.c */
      reg = getreg16(IO_CNTL_REG);
      reg &= ~( (1 << 3) | (1 << 1));
      putreg16(reg, IO_CNTL_REG);

      /* LCD Set I/O(3) output low */
      reg = getreg16(ARMIO_LATCH_OUT);
      reg &= ~(1 << 3);
      reg |= (1 << 1);
      putreg16(reg, ARMIO_LATCH_OUT);
    }
    else
    {
      ginfo("powering LCD off...\n");
      /* Switch pin from PWL to LT */
      reg &= ~ASCONF_PWL_ENA;
      putreg8(reg, ASIC_CONF_REG);
      /* Disable pwl */
      putreg8(0x00, PWL_REG(PWL_CTRL));
    }
    return OK;
}
Exemplo n.º 8
0
/**************************************************************************************
 * Name:  lcd_lcdinitialize
 *
 * Description:
 *   Set LCD panel contrast (0-CONFIG_LCD_MAXCONTRAST).
 *
 **************************************************************************************/
static inline void lcd_initialize(void)
{
  ginfo("%s: initializing LCD.\n",__FUNCTION__);
  calypso_reset_set(RESET_EXT, 0);
  usleep(5000);
  uwire_init();
  usleep(5000);
  fb_ssd1783_send_cmdlist(ssd1783_initdata);
}
Exemplo n.º 9
0
static int ssd1351_getpower(FAR struct lcd_dev_s *dev)
{
  FAR struct ssd1351_dev_s *priv = (FAR struct ssd1351_dev_s *)dev;

  /* Sanity check */

  DEBUGASSERT(priv != NULL);
  ginfo("power: %d\n", priv->power);

  return priv->power;
}
Exemplo n.º 10
0
static void ssd1351_deselect(FAR struct ssd1351_dev_s *priv)
{
  FAR struct spi_dev_s *spi = priv->spi;

  /* De-select the chip and relinquish the SPI bus */

  ginfo("DE-SELECTED\n");

  SPI_SELECT(spi, SPIDEV_DISPLAY, false);
  SPI_LOCK(spi, false);
}
Exemplo n.º 11
0
static void nxhello_kbdin(NXWINDOW hwnd, uint8_t nch, FAR const uint8_t *ch,
                       FAR void *arg)
{
  ginfo("hwnd=%p nch=%d\n", hwnd, nch);

   /* In this example, there is no keyboard so a keyboard event is not
    * expected.
    */

   printf("nxhello_kbdin: Unexpected keyboard callback\n");
}
Exemplo n.º 12
0
int board_lcd_initialize(void)
{
  ginfo("Initializing\n");

  lcd_initialize();

  /* Clear the display  */
  lcd_clear();

  return OK;
}
Exemplo n.º 13
0
static int ssd1351_getvideoinfo(FAR struct lcd_dev_s *dev,
                                FAR struct fb_videoinfo_s *vinfo)
{
  DEBUGASSERT(dev != NULL && vinfo != NULL);

  vinfo->fmt     = SSD1351_COLORFMT;
  vinfo->xres    = SSD1351_XRES;
  vinfo->yres    = SSD1351_YRES;
  vinfo->nplanes = 1;

  ginfo("fmt: %u xres: %u yres: %u nplanes: %u\n",
        vinfo->fmt, vinfo->xres, vinfo->yres, vinfo->nplanes);
  return OK;
}
Exemplo n.º 14
0
static int ssd1351_getplaneinfo(FAR struct lcd_dev_s *dev,
                                unsigned int planeno,
                                FAR struct lcd_planeinfo_s *pinfo)
{
  FAR struct ssd1351_dev_s *priv = (FAR struct ssd1351_dev_s *)dev;

  DEBUGASSERT(dev != NULL && pinfo != NULL && planeno == 0);

  pinfo->putrun = ssd1351_putrun;
  pinfo->getrun = ssd1351_getrun;
  pinfo->buffer = (uint8_t *)priv->runbuffer;
  pinfo->bpp    = SSD1351_BPP;

  ginfo("planeno: %u bpp: %u\n", planeno, pinfo->bpp);
  return OK;
}
Exemplo n.º 15
0
void nxbe_getrectangle(FAR struct nxbe_window_s *wnd,
                       FAR const struct nxgl_rect_s *rect, unsigned int plane,
                       FAR uint8_t *dest, unsigned int deststride)
{
  struct nxgl_rect_s remaining;

#ifdef CONFIG_DEBUG_FEATURES
  if (!wnd || !rect || !dest || plane >= wnd->be->vinfo.nplanes)
    {
      ginfo("Invalid parameters\n");
      return;
    }
#endif

  /* Offset the rectangle by the window origin to convert it into a
   * bounding box
   */

  nxgl_rectoffset(&remaining, rect, wnd->bounds.pt1.x, wnd->bounds.pt1.y);

  /* Clip to the bounding box to the limits of the window and of the
   * background screen
   */

  nxgl_rectintersect(&remaining, &remaining, &wnd->bounds);
  nxgl_rectintersect(&remaining, &remaining, &wnd->be->bkgd.bounds);

  /* The return the graphics memory at this location.  NOTE: Since raw
   * graphic memory is returned, the returned memory content may be
   * the memory of windows above this one and may not necessarily belong
   * to this window.
   */

  if (!nxgl_nullrect(&remaining))
    {
      FAR struct nxbe_plane_s *pplane = &wnd->be->plane[plane];
      pplane->getrectangle(&pplane->pinfo, &remaining, dest, deststride);
    }
}
Exemplo n.º 16
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
   */

  ginfo("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);
}
Exemplo n.º 17
0
Arquivo: ov2640.c Projeto: a1ien/nuttx
static int ovr2640_chipid(FAR struct i2c_master_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)
    {
      gerr("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)
    {
      gerr("ERROR: Unsupported PID=%02x$02x MID=%02x%02x\n",
            pidh, pidl, midh, midl);
      return -ENOSYS;
    }

  ginfo("PID=%02x$02x MID=%02x%02x\n", pidh, pidl, midh, midl);
  return OK;
}
Exemplo n.º 18
0
static inline FAR struct nxtext_glyph_s *
nxtext_renderglyph(FAR struct nxtext_state_s *st,
                   FAR const struct nx_fontbitmap_s *fbm, uint8_t ch)
{
  FAR struct nxtext_glyph_s *glyph = NULL;
  FAR nxgl_mxpixel_t *ptr;
#if CONFIG_EXAMPLES_NXTEXT_BPP < 8
  nxgl_mxpixel_t pixel;
#endif
  int bmsize;
  int row;
  int col;
  int ret;

  /* Make sure that there is room for another glyph */

  ginfo("ch=%c [%02x]\n", isprint(ch) ? ch : '.', ch);

  /* Allocate the glyph (always succeeds) */

  glyph         = nxtext_allocglyph(st);
  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;

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

  glyph->stride = (glyph->width * CONFIG_EXAMPLES_NXTEXT_BPP + 7) / 8;
  bmsize        =  glyph->stride * glyph->height;
  glyph->bitmap = (FAR uint8_t *)malloc(bmsize);

  if (glyph->bitmap)
    {
      /* Initialize the glyph memory to the background color */

#if CONFIG_EXAMPLES_NXTEXT_BPP < 8
      pixel  = st->wcolor[0];
#  if CONFIG_EXAMPLES_NXTEXT_BPP == 1
      /* Pack 1-bit pixels into a 2-bits */

      pixel &= 0x01;
      pixel  = (pixel) << 1 |pixel;
#  endif
#  if CONFIG_EXAMPLES_NXTEXT_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_EXAMPLES_NXTEXT_BPP == 24
# error "Additional logic is needed here for 24bpp support"

#else /* CONFIG_EXAMPLES_NXTEXT_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++ = st->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, st->fcolor[0]);
      if (ret < 0)
        {
          /* Actually, the RENDERER never returns a failure */

          printf("nxtext_renderglyph: RENDERER failed\n");
          nxtext_freeglyph(glyph);
          glyph = NULL;
        }
    }

  return glyph;
}
Exemplo n.º 19
0
int sam_isi_initialize(void)
{
  int ret;

  /* Configure PIO pins for the ISI (outputs) */
  /* Data pins */

  (void)sam_configpio(PIO_ISI_D0);
  (void)sam_configpio(PIO_ISI_D1);
  (void)sam_configpio(PIO_ISI_D2);
  (void)sam_configpio(PIO_ISI_D3);
  (void)sam_configpio(PIO_ISI_D4);
  (void)sam_configpio(PIO_ISI_D5);
  (void)sam_configpio(PIO_ISI_D6);
  (void)sam_configpio(PIO_ISI_D7);
  (void)sam_configpio(PIO_ISI_D8);
  (void)sam_configpio(PIO_ISI_D9);
  (void)sam_configpio(PIO_ISI_D10);
  (void)sam_configpio(PIO_ISI_D11);

  /* Horizontal and vertical sync pins (inputs) */

  (void)sam_configpio(PIO_ISI_HSYNC);
  (void)sam_configpio(PIO_ISI_VSYNC);

  /* Pixel clock input (ISI_PCK, not to be confused with the processor clock
   * (PCK) or the programmable clock (PCK).
   *
   * NOTE: "Several parts of the ISI controller use the pixel clock provided
   * by the image sensor (ISI_PCK). Thus the user must first program the
   * image sensor to provide this clock (ISI_PCK) before programming the
   * Image Sensor Controller."
   */

  (void)sam_configpio(PIO_ISI_PCK);

  /* Configure ISI_MCK programmable clock output.
   *
   * REVISIT:  Might this not be needed before the image sensor is
   * initialized?
   */

  g_isi.actual = sam_pck_configure(ISI_PCKID, PCKSRC_MCK, CONFIG_ISI_MCKFREQ);
  ginfo("PCK%d frequency=%d actual=%d\n",
        ISI_PCKID, CONFIG_ISI_MCKFREQ, g_isi.actual);

  /* Enable the MCK (output) */

  sam_pck_enable(ISI_PCKID, true);

  /* Configure the pixel clock */
#warning Missing logic

  /* Configure color */
#warning Missing logic

  /* Configure decimation */
#warning Missing logic

  /* Configure DMA */
#warning Missing logic
}
Exemplo n.º 20
0
int nxgl_splitline(FAR struct nxgl_vector_s *vector,
                   FAR struct nxgl_trapezoid_s *traps,
                   FAR struct nxgl_rect_s *rect,
                   nxgl_coord_t linewidth)
{
  struct nxgl_vector_s line;
  nxgl_coord_t iheight;
  nxgl_coord_t iwidth;
  nxgl_coord_t iyoffset;
  struct b16point_s quad[4];
  b16_t b16xoffset;
  b16_t b16yoffset;
  b16_t b16dxdy;
  b16_t angle;
  b16_t cosangle;
  b16_t sinangle;
  b16_t b16x;
  b16_t b16y;

  ginfo("vector: (%d,%d)->(%d,%d) linewidth: %d\n",
        vector->pt1.x, vector->pt1.y, vector->pt2.x, vector->pt2.y, linewidth);

  /* First, check the linewidth */

  if (linewidth < 1)
    {
      return -EINVAL;
    }

  /* Then make sure that the start position of the line is above the end
   * position of the line... in raster order.
   */

  if (vector->pt1.y < vector->pt2.y)
    {
      /* Vector is already in raster order */

      memcpy(&line, vector, sizeof(struct nxgl_vector_s));
    }
  else if (vector->pt1.y > vector->pt2.y)
    {
      /* Swap the top and bottom */

      line.pt1.x = vector->pt2.x;
      line.pt1.y = vector->pt2.y;
      line.pt2.x = vector->pt1.x;
      line.pt2.y = vector->pt1.y;
    }
  else /* if (vector->pt1.y == vector->pt2.y) */
    {
      /* First degenerate case:  The line is horizontal. */

      if (vector->pt1.x < vector->pt2.x)
        {
          rect->pt1.x = vector->pt1.x;
          rect->pt2.x = vector->pt2.x;
        }
      else
        {
          rect->pt1.x = vector->pt2.x;
          rect->pt2.x = vector->pt1.x;
        }

      /* The height of the rectangle is the width of the line, half above
       * and half below.
       */

      rect->pt1.y = vector->pt1.y - (linewidth >> 1);
      rect->pt2.y = rect->pt1.y + linewidth - 1;

      ginfo("Horizontal rect: (%d,%d),(%d,%d)\n",
            rect->pt1.x, rect->pt1.y, rect->pt2.x, rect->pt2.y);

      return 2;
    }

  /* Check if the line is vertical */

  if (line.pt1.x == line.pt2.x)
    {
      /* Second degenerate case:  The line is vertical. */

      rect->pt1.y = line.pt1.y;
      rect->pt2.y = line.pt2.y;

      rect->pt1.x = line.pt1.x - (linewidth >> 1);
      rect->pt2.x = rect->pt1.x + linewidth - 1;

      ginfo("Vertical rect: (%d,%d),(%d,%d)\n",
            rect->pt1.x, rect->pt1.y, rect->pt2.x, rect->pt2.y);

      return 2;
    }
Exemplo n.º 21
0
static int lcd_setcontrast(struct lcd_dev_s *dev, unsigned int contrast)
{
  ginfo("Not implemented\n");
  return -ENOSYS;
}
Exemplo n.º 22
0
static int lcd_getcontrast(struct lcd_dev_s *dev)
{
  ginfo("Not implemented\n");
  return -ENOSYS;
}
Exemplo n.º 23
0
static int lcd_getpower(struct lcd_dev_s *dev)
{
  ginfo("power: %d\n", 0);
  return g_lcddev.power;
}
Exemplo n.º 24
0
int lcd_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer,
    size_t npixels)
{
  ginfo("Not implemented\n");
  return -ENOSYS;
}