[media] media: platform: pxa_camera: change stop_streaming semantics
authorRobert Jarzmik <robert.jarzmik@free.fr>
Tue, 6 Sep 2016 09:04:22 +0000 (06:04 -0300)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Fri, 9 Sep 2016 13:53:31 +0000 (10:53 -0300)
Instead of the legacy behavior where it was required to wait for all
video buffers to be finished by the hardware, use a cancel like strategy
: as soon as the stop_streaming() call is done, abort all DMA transfers,
report the already buffers as failed and return.

This makes stop_streaming() more a "cancel capture" than a "wait for end
of capture" semantic.

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/platform/soc_camera/pxa_camera.c

index fb89b85f59abfe3663e630d433b03e2f4b2182c3..868c6ad4784c90eebeaed08867e9cf0a08f4a0a3 100644 (file)
@@ -523,7 +523,8 @@ static void pxa_camera_stop_capture(struct pxa_camera_dev *pcdev)
 }
 
 static void pxa_camera_wakeup(struct pxa_camera_dev *pcdev,
-                             struct pxa_buffer *buf)
+                             struct pxa_buffer *buf,
+                             enum vb2_buffer_state state)
 {
        struct vb2_buffer *vb = &buf->vbuf.vb2_buf;
        struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
@@ -645,7 +646,7 @@ static void pxa_camera_dma_irq(struct pxa_camera_dev *pcdev,
        }
        buf->active_dma &= ~act_dma;
        if (!buf->active_dma) {
-               pxa_camera_wakeup(pcdev, buf);
+               pxa_camera_wakeup(pcdev, buf, VB2_BUF_STATE_DONE);
                pxa_camera_check_link_miss(pcdev, last_buf->cookie[chan],
                                           last_issued);
        }
@@ -1087,7 +1088,15 @@ static int pxac_vb2_start_streaming(struct vb2_queue *vq, unsigned int count)
 
 static void pxac_vb2_stop_streaming(struct vb2_queue *vq)
 {
-       vb2_wait_for_all_buffers(vq);
+       struct pxa_camera_dev *pcdev = vb2_get_drv_priv(vq);
+       struct pxa_buffer *buf, *tmp;
+
+       dev_dbg(pcdev_to_dev(pcdev), "%s active=%p\n",
+               __func__, pcdev->active);
+       pxa_camera_stop_capture(pcdev);
+
+       list_for_each_entry_safe(buf, tmp, &pcdev->capture, queue)
+               pxa_camera_wakeup(pcdev, buf, VB2_BUF_STATE_ERROR);
 }
 
 static struct vb2_ops pxac_vb2_ops = {