diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2013-04-14 19:02:19 +0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2013-04-17 01:12:34 +0400 |
commit | ea3f7ac6e931f9aaa45e0a8445406f14e2a62011 (patch) | |
tree | 7d1bdfbe00e326943c3c69640c5cc10c1b917f34 /drivers/media/pci/cx25821/cx25821-video.c | |
parent | 7087d31b0c9dddbca71b8e33d3f0a3b719afa397 (diff) | |
download | linux-ea3f7ac6e931f9aaa45e0a8445406f14e2a62011.tar.xz |
[media] cx25821: replace custom ioctls with write()
Ideally this should be implemented with vb2, but it'll do for now.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/pci/cx25821/cx25821-video.c')
-rw-r--r-- | drivers/media/pci/cx25821/cx25821-video.c | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/drivers/media/pci/cx25821/cx25821-video.c b/drivers/media/pci/cx25821/cx25821-video.c index dde0ba3d3401..b194138961df 100644 --- a/drivers/media/pci/cx25821/cx25821-video.c +++ b/drivers/media/pci/cx25821/cx25821-video.c @@ -893,15 +893,47 @@ static int vidioc_s_fmt_vid_out(struct file *file, void *priv, return 0; } +static ssize_t video_write(struct file *file, const char __user *data, size_t count, + loff_t *ppos) +{ + struct cx25821_channel *chan = video_drvdata(file); + struct cx25821_dev *dev = chan->dev; + struct v4l2_fh *fh = file->private_data; + int err = 0; + + if (mutex_lock_interruptible(&dev->lock)) + return -ERESTARTSYS; + if (chan->streaming_fh && chan->streaming_fh != fh) { + err = -EBUSY; + goto unlock; + } + if (!chan->streaming_fh) { + err = cx25821_vidupstream_init(chan, chan->pixel_formats); + if (err) + goto unlock; + chan->streaming_fh = fh; + } + + err = cx25821_write_frame(chan, data, count); + count -= err; + *ppos += err; + +unlock: + mutex_unlock(&dev->lock); + return err; +} + static int video_out_release(struct file *file) { struct cx25821_channel *chan = video_drvdata(file); - struct cx25821_video_out_data *out = chan->out; struct cx25821_dev *dev = chan->dev; + struct v4l2_fh *fh = file->private_data; mutex_lock(&dev->lock); - if ((chan->id == SRAM_CH09 || chan->id == SRAM_CH10) && out->_is_running) + if (chan->streaming_fh == fh) { cx25821_stop_upstream_video(chan); + chan->streaming_fh = NULL; + } mutex_unlock(&dev->lock); return v4l2_fh_release(file); @@ -955,6 +987,7 @@ static const struct video_device cx25821_video_device = { static const struct v4l2_file_operations video_out_fops = { .owner = THIS_MODULE, .open = v4l2_fh_open, + .write = video_write, .release = video_out_release, .unlocked_ioctl = video_ioctl2, }; |