diff options
Diffstat (limited to 'drivers/media/video/fsl-viu.c')
-rw-r--r-- | drivers/media/video/fsl-viu.c | 56 |
1 files changed, 42 insertions, 14 deletions
diff --git a/drivers/media/video/fsl-viu.c b/drivers/media/video/fsl-viu.c index 031af161015..908d7012c3f 100644 --- a/drivers/media/video/fsl-viu.c +++ b/drivers/media/video/fsl-viu.c @@ -766,7 +766,7 @@ inline void viu_activate_overlay(struct viu_reg *viu_reg) out_be32(&vr->picture_count, reg_val.picture_count); } -static int viu_start_preview(struct viu_dev *dev, struct viu_fh *fh) +static int viu_setup_preview(struct viu_dev *dev, struct viu_fh *fh) { int bpp; @@ -805,11 +805,6 @@ static int viu_start_preview(struct viu_dev *dev, struct viu_fh *fh) /* setup the base address of the overlay buffer */ reg_val.field_base_addr = (u32)dev->ovbuf.base; - dev->ovenable = 1; - viu_activate_overlay(dev->vr); - - /* start dma */ - viu_start_dma(dev); return 0; } @@ -825,13 +820,11 @@ static int vidioc_s_fmt_overlay(struct file *file, void *priv, if (err) return err; - mutex_lock(&dev->lock); fh->win = f->fmt.win; spin_lock_irqsave(&dev->slock, flags); - viu_start_preview(dev, fh); + viu_setup_preview(dev, fh); spin_unlock_irqrestore(&dev->slock, flags); - mutex_unlock(&dev->lock); return 0; } @@ -841,6 +834,28 @@ static int vidioc_try_fmt_overlay(struct file *file, void *priv, return 0; } +static int vidioc_overlay(struct file *file, void *priv, unsigned int on) +{ + struct viu_fh *fh = priv; + struct viu_dev *dev = (struct viu_dev *)fh->dev; + unsigned long flags; + + if (on) { + spin_lock_irqsave(&dev->slock, flags); + viu_activate_overlay(dev->vr); + dev->ovenable = 1; + + /* start dma */ + viu_start_dma(dev); + spin_unlock_irqrestore(&dev->slock, flags); + } else { + viu_stop_dma(dev); + dev->ovenable = 0; + } + + return 0; +} + int vidioc_g_fbuf(struct file *file, void *priv, struct v4l2_framebuffer *arg) { struct viu_fh *fh = priv; @@ -911,12 +926,16 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p) static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) { struct viu_fh *fh = priv; + struct viu_dev *dev = fh->dev; if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) return -EINVAL; if (fh->type != i) return -EINVAL; + if (dev->ovenable) + dev->ovenable = 0; + viu_start_dma(fh->dev); return videobuf_streamon(&fh->vb_vidq); @@ -1311,7 +1330,8 @@ static int viu_open(struct file *file) videobuf_queue_dma_contig_init(&fh->vb_vidq, &viu_video_qops, dev->dev, &fh->vbq_lock, fh->type, V4L2_FIELD_INTERLACED, - sizeof(struct viu_buf), fh, NULL); + sizeof(struct viu_buf), fh, + &fh->dev->lock); return 0; } @@ -1401,7 +1421,7 @@ static struct v4l2_file_operations viu_fops = { .release = viu_release, .read = viu_read, .poll = viu_poll, - .ioctl = video_ioctl2, /* V4L2 ioctl handler */ + .unlocked_ioctl = video_ioctl2, /* V4L2 ioctl handler */ .mmap = viu_mmap, }; @@ -1415,6 +1435,7 @@ static const struct v4l2_ioctl_ops viu_ioctl_ops = { .vidioc_g_fmt_vid_overlay = vidioc_g_fmt_overlay, .vidioc_try_fmt_vid_overlay = vidioc_try_fmt_overlay, .vidioc_s_fmt_vid_overlay = vidioc_s_fmt_overlay, + .vidioc_overlay = vidioc_overlay, .vidioc_g_fbuf = vidioc_g_fbuf, .vidioc_s_fbuf = vidioc_s_fbuf, .vidioc_reqbufs = vidioc_reqbufs, @@ -1498,9 +1519,6 @@ static int __devinit viu_of_probe(struct platform_device *op) INIT_LIST_HEAD(&viu_dev->vidq.active); INIT_LIST_HEAD(&viu_dev->vidq.queued); - /* initialize locks */ - mutex_init(&viu_dev->lock); - snprintf(viu_dev->v4l2_dev.name, sizeof(viu_dev->v4l2_dev.name), "%s", "VIU"); ret = v4l2_device_register(viu_dev->dev, &viu_dev->v4l2_dev); @@ -1531,8 +1549,15 @@ static int __devinit viu_of_probe(struct platform_device *op) viu_dev->vdev = vdev; + /* initialize locks */ + mutex_init(&viu_dev->lock); + viu_dev->vdev->lock = &viu_dev->lock; + spin_lock_init(&viu_dev->slock); + video_set_drvdata(viu_dev->vdev, viu_dev); + mutex_lock(&viu_dev->lock); + ret = video_register_device(viu_dev->vdev, VFL_TYPE_GRABBER, -1); if (ret < 0) { video_device_release(viu_dev->vdev); @@ -1559,6 +1584,8 @@ static int __devinit viu_of_probe(struct platform_device *op) goto err_irq; } + mutex_unlock(&viu_dev->lock); + dev_info(&op->dev, "Freescale VIU Video Capture Board\n"); return ret; @@ -1568,6 +1595,7 @@ err_irq: err_clk: video_unregister_device(viu_dev->vdev); err_vdev: + mutex_unlock(&viu_dev->lock); i2c_put_adapter(ad); v4l2_device_unregister(&viu_dev->v4l2_dev); err: |