static int empress_init(struct saa7134_dev *dev)
{
	int err;

	dprintk("%s: %s\n",dev->name,__func__);
	dev->empress_dev = video_device_alloc();
	if (NULL == dev->empress_dev)
		return -ENOMEM;
	*(dev->empress_dev) = saa7134_empress_template;
	dev->empress_dev->parent  = &dev->pci->dev;
	dev->empress_dev->release = video_device_release;
	snprintf(dev->empress_dev->name, sizeof(dev->empress_dev->name),
		 "%s empress (%s)", dev->name,
		 saa7134_boards[dev->board].name);

	INIT_WORK(&dev->empress_workqueue, empress_signal_update);

	video_set_drvdata(dev->empress_dev, dev);
	err = video_register_device(dev->empress_dev,VFL_TYPE_GRABBER,
				    empress_nr[dev->nr]);
	if (err < 0) {
		printk(KERN_INFO "%s: can't register video device\n",
		       dev->name);
		video_device_release(dev->empress_dev);
		dev->empress_dev = NULL;
		return err;
	}
	printk(KERN_INFO "%s: registered device %s [mpeg]\n",
	       dev->name, video_device_node_name(dev->empress_dev));

	videobuf_queue_sg_init(&dev->empress_tsq, &saa7134_ts_qops,
			    &dev->pci->dev, &dev->slock,
			    V4L2_BUF_TYPE_VIDEO_CAPTURE,
			    V4L2_FIELD_ALTERNATE,
			    sizeof(struct saa7134_buf),
			    dev);

	empress_signal_update(&dev->empress_workqueue);
	return 0;
}
Ejemplo n.º 2
0
static int empress_init(struct saa7134_dev *dev)
{
    struct v4l2_ctrl_handler *hdl = &dev->empress_ctrl_handler;
    struct vb2_queue *q;
    int err;

    pr_debug("%s: %s\n", dev->name, __func__);
    dev->empress_dev = video_device_alloc();
    if (NULL == dev->empress_dev)
        return -ENOMEM;
    *(dev->empress_dev) = saa7134_empress_template;
    dev->empress_dev->v4l2_dev  = &dev->v4l2_dev;
    dev->empress_dev->release = video_device_release;
    dev->empress_dev->lock = &dev->lock;
    snprintf(dev->empress_dev->name, sizeof(dev->empress_dev->name),
             "%s empress (%s)", dev->name,
             saa7134_boards[dev->board].name);
    v4l2_ctrl_handler_init(hdl, 21);
    v4l2_ctrl_add_handler(hdl, &dev->ctrl_handler, empress_ctrl_filter);
    if (dev->empress_sd)
        v4l2_ctrl_add_handler(hdl, dev->empress_sd->ctrl_handler, NULL);
    if (hdl->error) {
        video_device_release(dev->empress_dev);
        return hdl->error;
    }
    dev->empress_dev->ctrl_handler = hdl;

    INIT_WORK(&dev->empress_workqueue, empress_signal_update);

    q = &dev->empress_vbq;
    q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    /*
     * Do not add VB2_USERPTR: the saa7134 DMA engine cannot handle
     * transfers that do not start at the beginning of a page. A USERPTR
     * can start anywhere in a page, so USERPTR support is a no-go.
     */
    q->io_modes = VB2_MMAP | VB2_DMABUF | VB2_READ;
    q->drv_priv = &dev->ts_q;
    q->ops = &saa7134_empress_qops;
    q->gfp_flags = GFP_DMA32;
    q->mem_ops = &vb2_dma_sg_memops;
    q->buf_struct_size = sizeof(struct saa7134_buf);
    q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
    q->lock = &dev->lock;
    q->dev = &dev->pci->dev;
    err = vb2_queue_init(q);
    if (err)
        return err;
    dev->empress_dev->queue = q;

    video_set_drvdata(dev->empress_dev, dev);
    err = video_register_device(dev->empress_dev,VFL_TYPE_GRABBER,
                                empress_nr[dev->nr]);
    if (err < 0) {
        pr_info("%s: can't register video device\n",
                dev->name);
        video_device_release(dev->empress_dev);
        dev->empress_dev = NULL;
        return err;
    }
    pr_info("%s: registered device %s [mpeg]\n",
            dev->name, video_device_node_name(dev->empress_dev));

    empress_signal_update(&dev->empress_workqueue);
    return 0;
}