コード例 #1
0
ファイル: listener.cpp プロジェクト: joydit/solidframe
/*virtual*/ void Listener::execute(ExecuteContext &_rexectx){
	idbg("here");
	cassert(this->socketOk());
	if(notified()){
		Locker<Mutex>	lock(Manager::specific().mutex(*this));
		ulong sm = this->grabSignalMask();
		if(sm & frame::S_KILL){ 
			_rexectx.close();
			return;
		}
	}
	
	solid::uint cnt(10);
	
	while(cnt--){
		if(state == 0){
			switch(this->socketAccept(sd)){
				case frame::aio::AsyncError:
					_rexectx.close();
					return;
				case frame::aio::AsyncSuccess:break;
				case frame::aio::AsyncWait:
					state = 1;
					return;
			}
		}
		state = 0;
		cassert(sd.ok());
		//TODO: one may do some filtering on sd based on sd.remoteAddress()
		if(ctxptr.get()){
			rsvc.insertConnection(sd, ctxptr.get(), true);
		}else{
			rsvc.insertConnection(sd);
		}
	}
	_rexectx.reschedule();
}
コード例 #2
0
ファイル: stmpe811_gpio.c プロジェクト: casro/vrbrain_nuttx
int stmpe811_gpioread(STMPE811_HANDLE handle, uint8_t pinconfig, bool *value)
{
  FAR struct stmpe811_dev_s *priv = (FAR struct stmpe811_dev_s *)handle;
  int pin = (pinconfig & STMPE811_GPIO_PIN_MASK) >> STMPE811_GPIO_PIN_SHIFT;
  uint8_t regval;
  int ret;

  DEBUGASSERT(handle && (unsigned)pin < STMPE811_GPIO_NPINS);

  /* Get exclusive access to the device structure */

  ret = sem_wait(&priv->exclsem);
  if (ret < 0)
    {
      int errval = errno;
      idbg("sem_wait failed: %d\n", errval);
      return -errval;
    }

  regval  = stmpe811_getreg8(priv, STMPE811_GPIO_MPSTA);
  *value = ((regval & GPIO_PIN(pin)) != 0);
  sem_post(&priv->exclsem);
  return OK;
}
コード例 #3
0
ファイル: stmpe811_gpio.c プロジェクト: casro/vrbrain_nuttx
int stmpe811_gpioconfig(STMPE811_HANDLE handle, uint8_t pinconfig)
{
  FAR struct stmpe811_dev_s *priv = (FAR struct stmpe811_dev_s *)handle;
  int pin = (pinconfig & STMPE811_GPIO_PIN_MASK) >> STMPE811_GPIO_PIN_SHIFT;
  uint8_t pinmask = (1 << pin);
  uint8_t regval;
  int ret;

  DEBUGASSERT(handle && (unsigned)pin < STMPE811_GPIO_NPINS);

  /* Get exclusive access to the device structure */

  ret = sem_wait(&priv->exclsem);
  if (ret < 0)
    {
      int errval = errno;
      idbg("sem_wait failed: %d\n", errval);
      return -errval;
    }

  /* Make sure that the pin is not already in use */

  if ((priv->inuse & pinmask) != 0)
    {
      idbg("PIN%d is already in-use\n", pin);
      sem_post(&priv->exclsem);
      return -EBUSY;
    }

  /* Make sure that the GPIO block has been initialized */

  stmpe811_gpioinit(priv);

  /* Set the alternate function bit for the pin, making it a GPIO */

  regval  = stmpe811_getreg8(priv, STMPE811_GPIO_AF);
  regval |= pinmask;
  stmpe811_putreg8(priv, STMPE811_GPIO_AF, regval);

  /* Is the pin an input or an output? */

  if ((pinconfig & STMPE811_GPIO_DIR) == STMPE811_GPIO_OUTPUT)
    {
      /* The pin is an output */

      regval  = stmpe811_getreg8(priv, STMPE811_GPIO_DIR);
      regval &= ~pinmask;
      stmpe811_putreg8(priv, STMPE811_GPIO_DIR, regval);

      /* Set its initial output value */

      stmpe811_gpiowrite(handle, pinconfig,
                        (pinconfig & STMPE811_GPIO_VALUE) != STMPE811_GPIO_ZERO);
    }
  else
    {
      /* It is an input */

      regval  = stmpe811_getreg8(priv, STMPE811_GPIO_DIR);
      regval |= pinmask;
      stmpe811_putreg8(priv, STMPE811_GPIO_DIR, regval);

      /* Set up the falling edge detection */

      regval = stmpe811_getreg8(priv, STMPE811_GPIO_FE);
      if ((pinconfig & STMPE811_GPIO_FALLING) != 0)
        {
          regval |= pinmask;
        }
      else
        {
          regval &= pinmask;
        }
      stmpe811_putreg8(priv, STMPE811_GPIO_FE, regval);

      /* Set up the rising edge detection */

     regval = stmpe811_getreg8(priv, STMPE811_GPIO_RE);
      if ((pinconfig & STMPE811_GPIO_FALLING) != 0)
        {
          regval |= pinmask;
        }
      else
        {
          regval &= pinmask;
        }
      stmpe811_putreg8(priv, STMPE811_GPIO_RE, regval);
 
      /* Disable interrupts for now */

      regval = stmpe811_getreg8(priv, STMPE811_GPIO_EN);
      regval &= ~pinmask;
      stmpe811_putreg8(priv, STMPE811_GPIO_EN, regval);
    }

  /* Mark the pin as 'in use' */

  priv->inuse |= pinmask;
  sem_post(&priv->exclsem);
  return OK;
}
コード例 #4
0
ファイル: up_touchscreen.c プロジェクト: FreddieChopin/NuttX
static int tc_poll(FAR struct file *filep, FAR struct pollfd *fds,
                        bool setup)
{
  FAR struct inode         *inode;
  FAR struct tc_dev_s *priv;
  int                       ret;
  int                       i;

  ivdbg("setup: %d\n", (int)setup);
  DEBUGASSERT(filep && fds);
  inode = filep->f_inode;

  DEBUGASSERT(inode && inode->i_private);
  priv  = (FAR struct tc_dev_s *)inode->i_private;

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

  ret = sem_wait(&priv->devsem);
  if (ret < 0)
    {
      /* This should only happen if the wait was canceled by an signal */

      DEBUGASSERT(errno == EINTR);
      return -EINTR;
    }

  if (setup)
    {
      /* Ignore waits that do not include POLLIN */

      if ((fds->events & POLLIN) == 0)
        {
          idbg("Missing POLLIN: revents: %08x\n", fds->revents);
          ret = -EDEADLK;
          goto errout;
        }

      /* This is a request to set up the poll.  Find an available
       * slot for the poll structure reference
       */

      for (i = 0; i < CONFIG_TOUCHSCREEN_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_TOUCHSCREEN_NPOLLWAITERS)
        {
          idbg("No availabled slot found: %d\n", i);
          fds->priv    = NULL;
          ret          = -EBUSY;
          goto errout;
        }

      /* Should we immediately notify on any of the requested events? */

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

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

      /* Remove all memory of the poll setup */

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

errout:
  sem_post(&priv->devsem);
  return ret;
}
コード例 #5
0
ファイル: ads7843e.c プロジェクト: WayWingsDev/fernvale-nuttx
static int ads7843e_waitsample(FAR struct ads7843e_dev_s *priv,
                               FAR struct ads7843e_sample_s *sample)
{
  irqstate_t flags;
  int ret;

  /* Interrupts me be disabled when this is called to (1) prevent posting
   * of semaphores from interrupt handlers, and (2) to prevent sampled data
   * from changing until it has been reported.
   *
   * In addition, we will also disable pre-emption to prevent other threads
   * from getting control while we muck with the semaphores.
   */

  sched_lock();
  flags = irqsave();

  /* Now release the semaphore that manages mutually exclusive access to
   * the device structure.  This may cause other tasks to become ready to
   * run, but they cannot run yet because pre-emption is disabled.
   */

  sem_post(&priv->devsem);

  /* Try to get the a sample... if we cannot, then wait on the semaphore
   * that is posted when new sample data is available.
   */

  while (ads7843e_sample(priv, sample) < 0)
    {
      /* Wait for a change in the ADS7843E state */

      ivdbg("Waiting..\n");
      priv->nwaiters++;
      ret = sem_wait(&priv->waitsem);
      priv->nwaiters--;

      if (ret < 0)
        {
          /* If we are awakened by a signal, then we need to return
           * the failure now.
           */

          idbg("sem_wait: %d\n", errno);
          DEBUGASSERT(errno == EINTR);
          ret = -EINTR;
          goto errout;
        }
    }

  ivdbg("Sampled\n");

   /* Re-acquire the semaphore that manages mutually exclusive access to
   * the device structure.  We may have to wait here.  But we have our sample.
   * Interrupts and pre-emption will be re-enabled while we wait.
   */

  ret = sem_wait(&priv->devsem);

errout:
  /* Then re-enable interrupts.  We might get interrupt here and there
   * could be a new sample.  But no new threads will run because we still
   * have pre-emption disabled.
   */

  irqrestore(flags);

  /* Restore pre-emption.  We might get suspended here but that is okay
   * because we already have our sample.  Note:  this means that if there
   * were two threads reading from the ADS7843E for some reason, the data
   * might be read out of order.
   */

  sched_unlock();
  return ret;
}
コード例 #6
0
ファイル: ads7843e.c プロジェクト: WayWingsDev/fernvale-nuttx
static ssize_t ads7843e_read(FAR struct file *filep, FAR char *buffer, size_t len)
{
  FAR struct inode          *inode;
  FAR struct ads7843e_dev_s *priv;
  FAR struct touch_sample_s *report;
  struct ads7843e_sample_s   sample;
  int                        ret;

  ivdbg("buffer:%p len:%d\n", buffer, len);
  DEBUGASSERT(filep);
  inode = filep->f_inode;

  DEBUGASSERT(inode && inode->i_private);
  priv  = (FAR struct ads7843e_dev_s *)inode->i_private;

  /* Verify that the caller has provided a buffer large enough to receive
   * the touch data.
   */

  if (len < SIZEOF_TOUCH_SAMPLE_S(1))
    {
      /* We could provide logic to break up a touch report into segments and
       * handle smaller reads... but why?
       */

      idbg("Unsupported read size: %d\n", len);
      return -ENOSYS;
    }

  /* Get exclusive access to the driver data structure */

  ret = sem_wait(&priv->devsem);
  if (ret < 0)
    {
      /* This should only happen if the wait was canceled by an signal */

      idbg("sem_wait: %d\n", errno);
      DEBUGASSERT(errno == EINTR);
      return -EINTR;
    }

  /* Try to read sample data. */

  ret = ads7843e_sample(priv, &sample);
  if (ret < 0)
    {
      /* Sample data is not available now.  We would ave to wait to get
       * receive sample data.  If the user has specified the O_NONBLOCK
       * option, then just return an error.
       */

      ivdbg("Sample data is not available\n");
      if (filep->f_oflags & O_NONBLOCK)
        {
          ret = -EAGAIN;
          goto errout;
       }

      /* Wait for sample data */

      ret = ads7843e_waitsample(priv, &sample);
      if (ret < 0)
        {
          /* We might have been awakened by a signal */

          idbg("ads7843e_waitsample: %d\n", ret);
          goto errout;
        }
    }

  /* In any event, we now have sampled ADS7843E data that we can report
   * to the caller.
   */

  report = (FAR struct touch_sample_s *)buffer;
  memset(report, 0, SIZEOF_TOUCH_SAMPLE_S(1));
  report->npoints            = 1;
  report->point[0].id        = sample.id;
  report->point[0].x         = sample.x;
  report->point[0].y         = sample.y;

  /* Report the appropriate flags */

  if (sample.contact == CONTACT_UP)
    {
       /* Pen is now up.  Is the positional data valid?  This is important to
        * know because the release will be sent to the window based on its
        * last positional data.
        */

      if (sample.valid)
        {
          report->point[0].flags  = TOUCH_UP | TOUCH_ID_VALID | TOUCH_POS_VALID;
        }
      else
        {
          report->point[0].flags  = TOUCH_UP | TOUCH_ID_VALID;
        }
    }
  else if (sample.contact == CONTACT_DOWN)
    {
      /* First contact */

      report->point[0].flags  = TOUCH_DOWN | TOUCH_ID_VALID | TOUCH_POS_VALID;
    }
  else /* if (sample->contact == CONTACT_MOVE) */
    {
      /* Movement of the same contact */

      report->point[0].flags  = TOUCH_MOVE | TOUCH_ID_VALID | TOUCH_POS_VALID;
    }

  ivdbg("  id:      %d\n", report->point[0].id);
  ivdbg("  flags:   %02x\n", report->point[0].flags);
  ivdbg("  x:       %d\n", report->point[0].x);
  ivdbg("  y:       %d\n", report->point[0].y);

  ret = SIZEOF_TOUCH_SAMPLE_S(1);

errout:
  sem_post(&priv->devsem);
  ivdbg("Returning: %d\n", ret);
  return ret;
}
コード例 #7
0
ファイル: max11802.c プロジェクト: justdoitding/Nuttx_PSoC4
int max11802_register(FAR struct spi_dev_s *spi,
                      FAR struct max11802_config_s *config, int minor)
{
  FAR struct max11802_dev_s *priv;
  char devname[DEV_NAMELEN];
#ifdef CONFIG_MAX11802_MULTIPLE
  irqstate_t flags;
#endif
  int ret;

  ivdbg("spi: %p minor: %d\n", spi, minor);

  /* Debug-only sanity checks */

  DEBUGASSERT(spi != NULL && config != NULL && minor >= 0 && minor < 100);

  /* Create and initialize a MAX11802 device driver instance */

#ifndef CONFIG_MAX11802_MULTIPLE
  priv = &g_max11802;
#else
  priv = (FAR struct max11802_dev_s *)kmm_malloc(sizeof(struct max11802_dev_s));
  if (!priv)
    {
      idbg("kmm_malloc(%d) failed\n", sizeof(struct max11802_dev_s));
      return -ENOMEM;
    }
#endif

  /* Initialize the MAX11802 device driver instance */

  memset(priv, 0, sizeof(struct max11802_dev_s));
  priv->spi     = spi;               /* Save the SPI device handle */
  priv->config  = config;            /* Save the board configuration */
  priv->wdog    = wd_create();       /* Create a watchdog timer */
  priv->threshx = INVALID_THRESHOLD; /* Initialize thresholding logic */
  priv->threshy = INVALID_THRESHOLD; /* Initialize thresholding logic */

  sem_init(&priv->devsem,  0, 1);    /* Initialize device structure semaphore */
  sem_init(&priv->waitsem, 0, 0);    /* Initialize pen event wait semaphore */

  /* Make sure that interrupts are disabled */

  config->clear(config);
  config->enable(config, false);

  /* Attach the interrupt handler */

  ret = config->attach(config, max11802_interrupt);
  if (ret < 0)
    {
      idbg("Failed to attach interrupt\n");
      goto errout_with_priv;
    }

  idbg("Mode: %d Bits: 8 Frequency: %d\n",
       CONFIG_MAX11802_SPIMODE, CONFIG_MAX11802_FREQUENCY);

  /* Lock the SPI bus so that we have exclusive access */

  max11802_lock(spi);

  /* Configure MAX11802 registers */

  SPI_SELECT(priv->spi, SPIDEV_TOUCHSCREEN, true);
  (void)SPI_SEND(priv->spi, MAX11802_CMD_MODE_WR);
  (void)SPI_SEND(priv->spi, MAX11802_MODE);
  SPI_SELECT(priv->spi, SPIDEV_TOUCHSCREEN, false);

  SPI_SELECT(priv->spi, SPIDEV_TOUCHSCREEN, true);
  (void)SPI_SEND(priv->spi, MAX11802_CMD_AVG_WR);
  (void)SPI_SEND(priv->spi, MAX11802_AVG);
  SPI_SELECT(priv->spi, SPIDEV_TOUCHSCREEN, false);

  SPI_SELECT(priv->spi, SPIDEV_TOUCHSCREEN, true);
  (void)SPI_SEND(priv->spi, MAX11802_CMD_TIMING_WR);
  (void)SPI_SEND(priv->spi, MAX11802_TIMING);
  SPI_SELECT(priv->spi, SPIDEV_TOUCHSCREEN, false);

  SPI_SELECT(priv->spi, SPIDEV_TOUCHSCREEN, true);
  (void)SPI_SEND(priv->spi, MAX11802_CMD_DELAY_WR);
  (void)SPI_SEND(priv->spi, MAX11802_DELAY);
  SPI_SELECT(priv->spi, SPIDEV_TOUCHSCREEN, false);

  /* Test that the device access was successful. */

  SPI_SELECT(priv->spi, SPIDEV_TOUCHSCREEN, true);
  (void)SPI_SEND(priv->spi, MAX11802_CMD_MODE_RD);
  ret = SPI_SEND(priv->spi, 0);
  SPI_SELECT(priv->spi, SPIDEV_TOUCHSCREEN, false);

  /* Unlock the bus */

  max11802_unlock(spi);

  if (ret != MAX11802_MODE)
  {
    idbg("max11802 mode readback failed: %02x\n", ret);
    goto errout_with_priv;
  }

  /* Register the device as an input device */

  (void)snprintf(devname, DEV_NAMELEN, DEV_FORMAT, minor);
  ivdbg("Registering %s\n", devname);

  ret = register_driver(devname, &max11802_fops, 0666, priv);
  if (ret < 0)
    {
      idbg("register_driver() failed: %d\n", ret);
      goto errout_with_priv;
    }

  /* If multiple MAX11802 devices are supported, then we will need to add
   * this new instance to a list of device instances so that it can be
   * found by the interrupt handler based on the recieved IRQ number.
   */

#ifdef CONFIG_MAX11802_MULTIPLE
  flags          = irqsave();
  priv->flink    = g_max11802list;
  g_max11802list = priv;
  irqrestore(flags);
#endif

  /* Schedule work to perform the initial sampling and to set the data
   * availability conditions.
   */

  ret = work_queue(HPWORK, &priv->work, max11802_worker, priv, 0);
  if (ret != 0)
    {
      idbg("Failed to queue work: %d\n", ret);
      goto errout_with_priv;
    }

  /* And return success (?) */

  return OK;

errout_with_priv:
  sem_destroy(&priv->devsem);
#ifdef CONFIG_MAX11802_MULTIPLE
  kmm_free(priv);
#endif
  return ret;
}
コード例 #8
0
ファイル: ads7843e.c プロジェクト: WayWingsDev/fernvale-nuttx
int ads7843e_register(FAR struct spi_dev_s *spi,
                      FAR struct ads7843e_config_s *config, int minor)
{
  FAR struct ads7843e_dev_s *priv;
  char devname[DEV_NAMELEN];
#ifdef CONFIG_ADS7843E_MULTIPLE
  irqstate_t flags;
#endif
  int ret;

  ivdbg("spi: %p minor: %d\n", spi, minor);

  /* Debug-only sanity checks */

  DEBUGASSERT(spi != NULL && config != NULL && minor >= 0 && minor < 100);

  /* Create and initialize a ADS7843E device driver instance */

#ifndef CONFIG_ADS7843E_MULTIPLE
  priv = &g_ads7843e;
#else
  priv = (FAR struct ads7843e_dev_s *)kmalloc(sizeof(struct ads7843e_dev_s));
  if (!priv)
    {
      idbg("kmalloc(%d) failed\n", sizeof(struct ads7843e_dev_s));
      return -ENOMEM;
    }
#endif

  /* Initialize the ADS7843E device driver instance */

  memset(priv, 0, sizeof(struct ads7843e_dev_s));
  priv->spi     = spi;               /* Save the SPI device handle */
  priv->config  = config;            /* Save the board configuration */
  priv->wdog    = wd_create();       /* Create a watchdog timer */
  priv->threshx = INVALID_THRESHOLD; /* Initialize thresholding logic */
  priv->threshy = INVALID_THRESHOLD; /* Initialize thresholding logic */

  sem_init(&priv->devsem,  0, 1);    /* Initialize device structure semaphore */
  sem_init(&priv->waitsem, 0, 0);    /* Initialize pen event wait semaphore */

  /* Make sure that interrupts are disabled */

  config->clear(config);
  config->enable(config, false);

  /* Attach the interrupt handler */

  ret = config->attach(config, ads7843e_interrupt);
  if (ret < 0)
    {
      idbg("Failed to attach interrupt\n");
      goto errout_with_priv;
    }

  idbg("Mode: %d Bits: 8 Frequency: %d\n",
       CONFIG_ADS7843E_SPIMODE, CONFIG_ADS7843E_FREQUENCY);

  /* Lock the SPI bus so that we have exclusive access */

  ads7843e_lock(spi);

  /* Configure the SPI interface */

  ads7843e_configspi(spi);

  /* Enable the PEN IRQ */

  ads7843e_sendcmd(priv, ADS7843_CMD_ENABPENIRQ);

  /* Unlock the bus */

  ads7843e_unlock(spi);

  /* Register the device as an input device */

  (void)snprintf(devname, DEV_NAMELEN, DEV_FORMAT, minor);
  ivdbg("Registering %s\n", devname);

  ret = register_driver(devname, &ads7843e_fops, 0666, priv);
  if (ret < 0)
    {
      idbg("register_driver() failed: %d\n", ret);
      goto errout_with_priv;
    }

  /* If multiple ADS7843E devices are supported, then we will need to add
   * this new instance to a list of device instances so that it can be
   * found by the interrupt handler based on the recieved IRQ number.
   */

#ifdef CONFIG_ADS7843E_MULTIPLE
  priv->flink    = g_ads7843elist;
  g_ads7843elist = priv;
  irqrestore(flags);
#endif

  /* Schedule work to perform the initial sampling and to set the data
   * availability conditions.
   */

  ret = work_queue(HPWORK, &priv->work, ads7843e_worker, priv, 0);
  if (ret != 0)
    {
      idbg("Failed to queue work: %d\n", ret);
      goto errout_with_priv;
    }

  /* And return success (?) */

  return OK;

errout_with_priv:
  sem_destroy(&priv->devsem);
#ifdef CONFIG_ADS7843E_MULTIPLE
  kfree(priv);
#endif
  return ret;
}
コード例 #9
0
ファイル: up_touchscreen.c プロジェクト: FreddieChopin/NuttX
int arch_tcinitialize(int minor)
{
  FAR struct tc_dev_s *priv;
  char devname[DEV_NAMELEN];
  int ret;

  ivdbg("minor: %d\n", minor);
  DEBUGASSERT(minor >= 0 && minor < 100);

  /* Configure all touchscreen pins as inputs, undriven */

  putreg32(LCD_ALL_BITS, PIC32MX_IOPORTB_TRISSET);

  /* Configure all pins for as digital. AD1PCFG specifies the configuration
   * of device pins to be used as analog inputs. A pin is configured as an
   * analog input when the corresponding PCFGn bit is 0.
   */

  putreg32(LCD_ALL_BITS, PIC32MX_ADC_CFGSET);

  /* Create and initialize a touchscreen device driver instance */

#ifndef CONFIG_TOUCHSCREEN_MULTIPLE
  priv = &g_touchscreen;
#else
  priv = (FAR struct tc_dev_s *)kmm_malloc(sizeof(struct tc_dev_s));
  if (!priv)
    {
      idbg("kmm_malloc(%d) failed\n", sizeof(struct tc_dev_s));
      return -ENOMEM;
    }
#endif

  /* Initialize the touchscreen device driver instance */

  memset(priv, 0, sizeof(struct tc_dev_s));
  sem_init(&priv->devsem,  0, 1); /* Initialize device structure semaphore */
  sem_init(&priv->waitsem, 0, 0); /* Initialize pen event wait semaphore */

  /* Register the device as an input device */

  (void)snprintf(devname, DEV_NAMELEN, DEV_FORMAT, minor);
  ivdbg("Registering %s\n", devname);

  ret = register_driver(devname, &tc_fops, 0666, priv);
  if (ret < 0)
    {
      idbg("register_driver() failed: %d\n", ret);
      goto errout_with_priv;
    }

  /* Schedule work to perform the initial sampling and to set the data
   * availability conditions.
   */

  priv->state = TC_READY;
  ret = work_queue(HPWORK, &priv->work, tc_worker, priv, 0);
  if (ret != 0)
    {
      idbg("Failed to queue work: %d\n", ret);
      goto errout_with_priv;
    }

  /* And return success (?) */

  return OK;

errout_with_priv:
  sem_destroy(&priv->devsem);
#ifdef CONFIG_TOUCHSCREEN_MULTIPLE
  kmm_free(priv);
#endif
  return ret;
}
コード例 #10
0
ファイル: up_touchscreen.c プロジェクト: andrewms/nuttx_ap
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;
}
コード例 #11
0
ファイル: alphamessages.cpp プロジェクト: joydit/solidframe
size_t RemoteListMessage::release(){
	size_t rv = DynamicShared<frame::ipc::Message>::release();
	idbg(""<<(void*)this<<" usecount = "<<usecount);
	return rv;
}
コード例 #12
0
ファイル: alphamessages.cpp プロジェクト: joydit/solidframe
FetchMasterMessage::~FetchMasterMessage(){
	delete pmsg;
	idbg((void*)this<<"");
}
コード例 #13
0
ファイル: alphamessages.cpp プロジェクト: joydit/solidframe
RemoteListMessage::RemoteListMessage(
	const NumberType<1>&
):ppthlst(NULL), err(-1),tout(0), success(0){
	idbg(""<<(void*)this);
	shared_mutex_safe(this);
}
コード例 #14
0
ファイル: alphamessages.cpp プロジェクト: joydit/solidframe
//-----------------------------------------------------------------------------------
// RemoteListMessage
//-----------------------------------------------------------------------------------
RemoteListMessage::RemoteListMessage(
	uint32 _tout, uint16 _sentcnt
): ppthlst(NULL),err(-1),tout(_tout), success(0){
	idbg(""<<(void*)this);
	shared_mutex_safe(this);
}
コード例 #15
0
ファイル: alphamessages.cpp プロジェクト: joydit/solidframe
int FetchSlaveMessage::sent(const frame::ipc::ConnectionUid &_rconid){
	idbg((void*)this<<"");
	fromv.first = 0xffffffff;
	return AsyncError;
}
コード例 #16
0
ファイル: alphamessages.cpp プロジェクト: joydit/solidframe
FetchSlaveMessage::FetchSlaveMessage(): fromv(0xffffffff, 0xffffffff), ios(/*0*/), filesz(-10), streamsz(-1), requid(0){
	idbg(""<<(void*)this);
	serialized = false;
}
コード例 #17
0
ファイル: alphamessages.cpp プロジェクト: joydit/solidframe
void FetchMasterMessage::ipcOnComplete(frame::ipc::ConnectionContext const &_rctx, int _err){
	idbg((void*)this<<"");
	if(_err){
		Manager::the().notify(frame::S_RAISE | frame::S_KILL, ObjectUidT(fromv.first, fromv.second));
	}
}