[media] soc_camera: use vb2_ops_wait_prepare/finish helper
authorLad, Prabhakar <prabhakar.csengg@gmail.com>
Wed, 26 Nov 2014 22:42:27 +0000 (19:42 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Mon, 2 Feb 2015 12:40:02 +0000 (10:40 -0200)
This patch drops driver specific wait_prepare() and
wait_finish() callbacks from vb2_ops and instead uses
the the helpers vb2_ops_wait_prepare/finish() provided
by the vb2 core, the lock member of the queue needs
to be initalized to a mutex so that vb2 helpers
vb2_ops_wait_prepare/finish() can make use of it.

Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Cc: Josh Wu <josh.wu@atmel.com>
Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/platform/soc_camera/atmel-isi.c
drivers/media/platform/soc_camera/mx3_camera.c
drivers/media/platform/soc_camera/rcar_vin.c
drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
drivers/media/platform/soc_camera/soc_camera.c

index 6d885239b16abf0b01b721de4f27cf924f6b7f4a..8526bf5c8429aecbb5afa8030fca537b0720b2ab 100644 (file)
@@ -455,8 +455,8 @@ static struct vb2_ops isi_video_qops = {
        .buf_queue              = buffer_queue,
        .start_streaming        = start_streaming,
        .stop_streaming         = stop_streaming,
-       .wait_prepare           = soc_camera_unlock,
-       .wait_finish            = soc_camera_lock,
+       .wait_prepare           = vb2_ops_wait_prepare,
+       .wait_finish            = vb2_ops_wait_finish,
 };
 
 /* ------------------------------------------------------------------
@@ -465,6 +465,8 @@ static struct vb2_ops isi_video_qops = {
 static int isi_camera_init_videobuf(struct vb2_queue *q,
                                     struct soc_camera_device *icd)
 {
+       struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
+
        q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
        q->io_modes = VB2_MMAP;
        q->drv_priv = icd;
@@ -472,6 +474,7 @@ static int isi_camera_init_videobuf(struct vb2_queue *q,
        q->ops = &isi_video_qops;
        q->mem_ops = &vb2_dma_contig_memops;
        q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+       q->lock = &ici->host_lock;
 
        return vb2_queue_init(q);
 }
index 0b3299dee05d453c87a492cd610d66e507f8a7ba..3435fd2ca8ecd2d56f06386375556efb0e2d0c3b 100644 (file)
@@ -435,14 +435,16 @@ static struct vb2_ops mx3_videobuf_ops = {
        .buf_queue      = mx3_videobuf_queue,
        .buf_cleanup    = mx3_videobuf_release,
        .buf_init       = mx3_videobuf_init,
-       .wait_prepare   = soc_camera_unlock,
-       .wait_finish    = soc_camera_lock,
+       .wait_prepare   = vb2_ops_wait_prepare,
+       .wait_finish    = vb2_ops_wait_finish,
        .stop_streaming = mx3_stop_streaming,
 };
 
 static int mx3_camera_init_videobuf(struct vb2_queue *q,
                                     struct soc_camera_device *icd)
 {
+       struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
+
        q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
        q->io_modes = VB2_MMAP | VB2_USERPTR;
        q->drv_priv = icd;
@@ -450,6 +452,7 @@ static int mx3_camera_init_videobuf(struct vb2_queue *q,
        q->mem_ops = &vb2_dma_contig_memops;
        q->buf_struct_size = sizeof(struct mx3_camera_buffer);
        q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+       q->lock = &ici->host_lock;
 
        return vb2_queue_init(q);
 }
index 9f1473c0a0cfa493227f50ac1920ae34818e670b..9c9d5e2bd34e3fad05a0fc5e5915603026b47455 100644 (file)
@@ -881,8 +881,8 @@ static struct vb2_ops rcar_vin_vb2_ops = {
        .buf_cleanup    = rcar_vin_videobuf_release,
        .buf_queue      = rcar_vin_videobuf_queue,
        .stop_streaming = rcar_vin_stop_streaming,
-       .wait_prepare   = soc_camera_unlock,
-       .wait_finish    = soc_camera_lock,
+       .wait_prepare   = vb2_ops_wait_prepare,
+       .wait_finish    = vb2_ops_wait_finish,
 };
 
 static irqreturn_t rcar_vin_irq(int irq, void *data)
@@ -1808,6 +1808,8 @@ static int rcar_vin_querycap(struct soc_camera_host *ici,
 static int rcar_vin_init_videobuf2(struct vb2_queue *vq,
                                   struct soc_camera_device *icd)
 {
+       struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
+
        vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
        vq->io_modes = VB2_MMAP | VB2_USERPTR;
        vq->drv_priv = icd;
@@ -1815,6 +1817,7 @@ static int rcar_vin_init_videobuf2(struct vb2_queue *vq,
        vq->mem_ops = &vb2_dma_contig_memops;
        vq->buf_struct_size = sizeof(struct rcar_vin_buffer);
        vq->timestamp_flags  = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+       vq->lock = &ici->host_lock;
 
        return vb2_queue_init(vq);
 }
index 71787702d4a26cce7ba7a1b02f2ab367ed388db5..9ce202f539344a07378b168285a2ab55e413f844 100644 (file)
@@ -496,8 +496,8 @@ static struct vb2_ops sh_mobile_ceu_videobuf_ops = {
        .buf_queue      = sh_mobile_ceu_videobuf_queue,
        .buf_cleanup    = sh_mobile_ceu_videobuf_release,
        .buf_init       = sh_mobile_ceu_videobuf_init,
-       .wait_prepare   = soc_camera_unlock,
-       .wait_finish    = soc_camera_lock,
+       .wait_prepare   = vb2_ops_wait_prepare,
+       .wait_finish    = vb2_ops_wait_finish,
        .stop_streaming = sh_mobile_ceu_stop_streaming,
 };
 
@@ -1661,6 +1661,8 @@ static int sh_mobile_ceu_querycap(struct soc_camera_host *ici,
 static int sh_mobile_ceu_init_videobuf(struct vb2_queue *q,
                                       struct soc_camera_device *icd)
 {
+       struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
+
        q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
        q->io_modes = VB2_MMAP | VB2_USERPTR;
        q->drv_priv = icd;
@@ -1668,6 +1670,7 @@ static int sh_mobile_ceu_init_videobuf(struct vb2_queue *q,
        q->mem_ops = &vb2_dma_contig_memops;
        q->buf_struct_size = sizeof(struct sh_mobile_ceu_buffer);
        q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+       q->lock = &ici->host_lock;
 
        return vb2_queue_init(q);
 }
index b3db51c82bded142ba9efc95a82d73878d18ad6f..4105a9ed5f71b2583b3a6b5a93306797394f5901 100644 (file)
@@ -843,22 +843,6 @@ static unsigned int soc_camera_poll(struct file *file, poll_table *pt)
        return res;
 }
 
-void soc_camera_lock(struct vb2_queue *vq)
-{
-       struct soc_camera_device *icd = vb2_get_drv_priv(vq);
-       struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
-       mutex_lock(&ici->host_lock);
-}
-EXPORT_SYMBOL(soc_camera_lock);
-
-void soc_camera_unlock(struct vb2_queue *vq)
-{
-       struct soc_camera_device *icd = vb2_get_drv_priv(vq);
-       struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
-       mutex_unlock(&ici->host_lock);
-}
-EXPORT_SYMBOL(soc_camera_unlock);
-
 static struct v4l2_file_operations soc_camera_fops = {
        .owner          = THIS_MODULE,
        .open           = soc_camera_open,