summaryrefslogtreecommitdiff
path: root/drivers/media/pci/cx25821/cx25821-video.c
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2013-04-14 12:02:19 -0300
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-04-16 18:12:34 -0300
commitea3f7ac6e931f9aaa45e0a8445406f14e2a62011 (patch)
tree7d1bdfbe00e326943c3c69640c5cc10c1b917f34 /drivers/media/pci/cx25821/cx25821-video.c
parent7087d31b0c9dddbca71b8e33d3f0a3b719afa397 (diff)
[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.c37
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,
};