Commit db69d7d8 authored by Enrico Scholz's avatar Enrico Scholz

media:mx6s_capture: moved s_stream sd call into vb2 operations

Signed-off-by: Enrico Scholz's avatarEnrico Scholz <enrico.scholz@sigma-chemnitz.de>
parent 8c72df9d
......@@ -1022,6 +1022,7 @@ static void mx6s_release_bufs(struct list_head *bufs,
static int mx6s_start_streaming(struct vb2_queue *vq, unsigned int count)
{
struct mx6s_csi_dev *csi_dev = vb2_get_drv_priv(vq);
struct v4l2_subdev *sd = csi_dev->sd;
struct vb2_buffer *vb;
struct mx6s_buffer *buf;
unsigned long phys;
......@@ -1031,6 +1032,10 @@ static int mx6s_start_streaming(struct vb2_queue *vq, unsigned int count)
if (count < 2)
return -ENOBUFS;
rc = v4l2_subdev_call(sd, video, s_stream, 1);
if (rc < 0)
return rc;
/*
* I didn't manage to properly enable/disable
* a per frame basis during running transfers,
......@@ -1043,8 +1048,10 @@ static int mx6s_start_streaming(struct vb2_queue *vq, unsigned int count)
PAGE_ALIGN(csi_dev->discard_size),
&csi_dev->discard_buffer_dma,
GFP_DMA | GFP_KERNEL);
if (!csi_dev->discard_buffer)
return -ENOMEM;
if (!csi_dev->discard_buffer) {
rc = -ENOMEM;
goto out;
}
spin_lock_irqsave(&csi_dev->slock, flags);
......@@ -1105,12 +1112,16 @@ static int mx6s_start_streaming(struct vb2_queue *vq, unsigned int count)
rc = 0;
out:
if (rc < 0)
v4l2_subdev_call(sd, video, s_stream, 0);
return rc;
}
static void mx6s_stop_streaming(struct vb2_queue *vq)
{
struct mx6s_csi_dev *csi_dev = vb2_get_drv_priv(vq);
struct v4l2_subdev *sd = csi_dev->sd;
unsigned long flags;
struct mx6s_buffer *buf, *tmp;
void *b;
......@@ -1145,6 +1156,8 @@ static void mx6s_stop_streaming(struct vb2_queue *vq)
dma_free_coherent(csi_dev->v4l2_dev.dev,
csi_dev->discard_size, b,
csi_dev->discard_buffer_dma);
v4l2_subdev_call(sd, video, s_stream, 0);
}
static struct vb2_ops mx6s_videobuf_ops = {
......@@ -1413,7 +1426,6 @@ static int mx6s_csi_close(struct file *file)
rc = _vb2_fop_release(file, NULL);
if (do_release) {
v4l2_subdev_call(sd, video, s_stream, 0);
vb2_queue_release(&csi_dev->vb2_vidq);
mx6s_csi_deinit(csi_dev);
v4l2_subdev_call(sd, core, s_power, 0);
......@@ -1711,34 +1723,17 @@ static int mx6s_vidioc_streamon(struct file *file, void *priv,
enum v4l2_buf_type i)
{
struct mx6s_csi_dev *csi_dev = video_drvdata(file);
struct v4l2_subdev *sd = csi_dev->sd;
int ret;
if (i != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
ret = v4l2_subdev_call(sd, video, s_stream, 1);
if (ret < 0)
goto out;
ret = vb2_streamon(&csi_dev->vb2_vidq, i);
if (ret < 0) {
v4l2_subdev_call(sd, video, s_stream, 0);
goto out;
}
ret = 0;
out:
return ret;
return vb2_streamon(&csi_dev->vb2_vidq, i);
}
static int mx6s_vidioc_streamoff(struct file *file, void *priv,
enum v4l2_buf_type i)
{
struct mx6s_csi_dev *csi_dev = video_drvdata(file);
struct v4l2_subdev *sd = csi_dev->sd;
int rc;
if (i != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
......@@ -1747,16 +1742,7 @@ static int mx6s_vidioc_streamoff(struct file *file, void *priv,
* This calls buf_release from host driver's videobuf_queue_ops for all
* remaining buffers. When the last buffer is freed, stop capture
*/
rc = vb2_streamoff(&csi_dev->vb2_vidq, i);
if (rc < 0)
goto out;
v4l2_subdev_call(sd, video, s_stream, 0);
rc = 0;
out:
return rc;
return vb2_streamoff(&csi_dev->vb2_vidq, i);
}
static int mx6s_vidioc_cropcap(struct file *file, void *fh,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment