media: tegra_camera: add start streaming call
Bryan Wu [Mon, 8 Jun 2015 22:01:25 +0000 (15:01 -0700)]
Queueing buffer might happen before starting streaming. So any queueing
buffer operation before starting streaming shouldn't trigger real
capture but just queue the buffer. After starting streaming, it will
wake up kernel workqueue to start real capture.

Bug 1639982

Change-Id: I66fd527bbd12790b2d688f320214976e70a658f3
Signed-off-by: Bryan Wu <pengw@nvidia.com>
Reviewed-on: http://git-master/r/754710
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: David Wang (SW-TEGRA) <davidw@nvidia.com>
Reviewed-by: Winnie Hsu <whsu@nvidia.com>

drivers/media/platform/soc_camera/tegra_camera/common.c

index d8b4ff1..2fa4d78 100644 (file)
@@ -483,8 +483,10 @@ static void tegra_camera_videobuf_queue(struct vb2_buffer *vb)
 
        spin_lock_irq(&cam->videobuf_queue_lock);
        list_add_tail(&buf->queue, &cam->capture);
-       schedule_work(&cam->work);
        spin_unlock_irq(&cam->videobuf_queue_lock);
+
+       if (vb2_is_streaming(vb->vb2_queue))
+               schedule_work(&cam->work);
 }
 
 static void tegra_camera_videobuf_release(struct vb2_buffer *vb)
@@ -523,6 +525,19 @@ static int tegra_camera_videobuf_init(struct vb2_buffer *vb)
        return 0;
 }
 
+static int tegra_camera_start_streaming(struct vb2_queue *q, unsigned int count)
+{
+       struct soc_camera_device *icd = container_of(q,
+                                                    struct soc_camera_device,
+                                                    vb2_vidq);
+       struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
+       struct tegra_camera_dev *cam = ici->priv;
+
+       schedule_work(&cam->work);
+
+       return 0;
+}
+
 static int tegra_camera_stop_streaming(struct vb2_queue *q)
 {
        struct soc_camera_device *icd = container_of(q,
@@ -549,6 +564,7 @@ static struct vb2_ops tegra_camera_videobuf_ops = {
        .buf_init       = tegra_camera_videobuf_init,
        .wait_prepare   = soc_camera_unlock,
        .wait_finish    = soc_camera_lock,
+       .start_streaming = tegra_camera_start_streaming,
        .stop_streaming = tegra_camera_stop_streaming,
 };