int
drm_open(struct dev_open_args *ap)
{
	struct cdev *kdev = ap->a_head.a_dev;
	int flags = ap->a_oflags;
	int fmt = 0;
	struct thread *p = curthread;
	struct drm_device *dev;
	int retcode;

	dev = DRIVER_SOFTC(minor(kdev));
	if (dev == NULL)
		return (ENXIO);

	DRM_DEBUG("open_count = %d\n", dev->open_count);

	retcode = drm_open_helper(kdev, flags, fmt, p, dev, ap->a_fp);

	if (retcode == 0) {
		atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
		DRM_LOCK(dev);
		device_busy(dev->dev);
		if (!dev->open_count++)
			retcode = drm_setup(dev);
		DRM_UNLOCK(dev);
	}

	DRM_DEBUG("return %d\n", retcode);

	return (retcode);
}
Пример #2
0
static int
dektec_open (struct cdev *cdev, int flag, int otyp, struct thread *td)
{
	struct dektec_sc *sc = cdev->si_drv1;

	device_busy (sc->dev);

	mtx_lock (&sc->dektec_mtx);

	sc->tx_watermark = 0;
	sc->rx_watermark = 0;

	mtx_unlock (&sc->dektec_mtx);

	dta1xx_gen_ctrl_reg_reset (sc->dta_base_bt, sc->dta_base_bh, sc->gen_base);
	dta1xx_gen_ctrl_reg_set_per_int_val (sc->dta_base_bt, sc->dta_base_bh, sc->gen_base, 4); /* 145 */
	dta1xx_gen_ctrl_reg_set_per_int_en (sc->dta_base_bt, sc->dta_base_bh, sc->gen_base, 1);

	switch (sc->model) {
	case BOARD_MODEL_140:
		break;

	case BOARD_MODEL_145:
	case BOARD_MODEL_2145:
		/* ASI/SDI Transmit (Tx) channel 0 at 0x180 (rx_base + 0x80) */
		dta1xx_tx_ctrl_reg_set_output_en (sc->dta_base_bt, sc->dta_base_bh, sc->rx_base + 0x80, 0);
		dta1xx_tx_ctrl_reg_set_output_en (sc->dta_base_bt, sc->dta_base_bh, sc->tx_base, 1);
		dta1xx_dma_timeout_set (sc->dta_base_bt, sc->dta_base_bh, sc->dma_base0, 0);
		dta1xx_dma_timeout_set (sc->dta_base_bt, sc->dta_base_bh, sc->dma_base1, 0);
		break;
	}

	return 0;
}
Пример #3
0
    void
    capture_scanner::validate_reply (void) const
    {
      if (byte (0x80) == rep_)
        return;

      if (byte (0x40) == rep_)
        BOOST_THROW_EXCEPTION (device_busy ());

      if (NAK == rep_)
        BOOST_THROW_EXCEPTION (invalid_command ());

      BOOST_THROW_EXCEPTION (unknown_reply ());
    }