media: staging: rkisp1: cap: serialize start/stop stream
authorHelen Koike <helen.koike@collabora.com>
Mon, 16 Mar 2020 21:00:44 +0000 (22:00 +0100)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Tue, 21 Apr 2020 15:01:49 +0000 (17:01 +0200)
In order to support simultaneous streaming from both capture devices,
start/stop vb2 calls need to be serialized to allow multiple concurrent
calls.

Signed-off-by: Helen Koike <helen.koike@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/staging/media/rkisp1/rkisp1-capture.c
drivers/staging/media/rkisp1/rkisp1-common.h
drivers/staging/media/rkisp1/rkisp1-dev.c

index b371bbd..144a690 100644 (file)
@@ -880,6 +880,8 @@ static void rkisp1_vb2_stop_streaming(struct vb2_queue *queue)
        struct rkisp1_device *rkisp1 = cap->rkisp1;
        int ret;
 
+       mutex_lock(&cap->rkisp1->stream_lock);
+
        rkisp1_stream_stop(cap);
        media_pipeline_stop(&node->vdev.entity);
        ret = rkisp1_pipeline_sink_walk(&node->vdev.entity, NULL,
@@ -896,6 +898,8 @@ static void rkisp1_vb2_stop_streaming(struct vb2_queue *queue)
                dev_err(rkisp1->dev, "power down failed error:%d\n", ret);
 
        rkisp1_dummy_buf_destroy(cap);
+
+       mutex_unlock(&cap->rkisp1->stream_lock);
 }
 
 /*
@@ -940,6 +944,8 @@ rkisp1_vb2_start_streaming(struct vb2_queue *queue, unsigned int count)
        struct media_entity *entity = &cap->vnode.vdev.entity;
        int ret;
 
+       mutex_lock(&cap->rkisp1->stream_lock);
+
        ret = rkisp1_dummy_buf_create(cap);
        if (ret)
                goto err_ret_buffers;
@@ -969,6 +975,8 @@ rkisp1_vb2_start_streaming(struct vb2_queue *queue, unsigned int count)
                goto err_pipe_disable;
        }
 
+       mutex_unlock(&cap->rkisp1->stream_lock);
+
        return 0;
 
 err_pipe_disable:
@@ -982,6 +990,7 @@ err_destroy_dummy:
        rkisp1_dummy_buf_destroy(cap);
 err_ret_buffers:
        rkisp1_return_all_buffers(cap, VB2_BUF_STATE_QUEUED);
+       mutex_unlock(&cap->rkisp1->stream_lock);
 
        return ret;
 }
index ccf4bb0..5d2c318 100644 (file)
@@ -240,6 +240,7 @@ struct rkisp1_debug {
  * @rkisp1_capture: capture video device
  * @stats: ISP statistics output device
  * @params: ISP input parameters device
+ * @stream_lock: lock to serialize start/stop streaming in capture devices.
  */
 struct rkisp1_device {
        void __iomem *base_addr;
@@ -259,6 +260,7 @@ struct rkisp1_device {
        struct rkisp1_params params;
        struct media_pipeline pipe;
        struct vb2_alloc_ctx *alloc_ctx;
+       struct mutex stream_lock;
        struct rkisp1_debug debug;
 };
 
index 3f62857..92d4cd6 100644 (file)
@@ -472,6 +472,8 @@ static int rkisp1_probe(struct platform_device *pdev)
        dev_set_drvdata(dev, rkisp1);
        rkisp1->dev = dev;
 
+       mutex_init(&rkisp1->stream_lock);
+
        rkisp1->base_addr = devm_platform_ioremap_resource(pdev, 0);
        if (IS_ERR(rkisp1->base_addr))
                return PTR_ERR(rkisp1->base_addr);