]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
[media] vimc: common: Add vimc_pipeline_s_stream helper
authorHelen Fornazier <helen.koike@collabora.com>
Mon, 19 Jun 2017 17:00:13 +0000 (14:00 -0300)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Fri, 23 Jun 2017 12:03:37 +0000 (09:03 -0300)
Move the vimc_cap_pipeline_s_stream from the vimc-cap.c to vimc-common.c
as this core will be reused by other subdevices to activate the stream
in their directly connected nodes

Signed-off-by: Helen Koike <helen.koike@collabora.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/platform/vimc/vimc-capture.c
drivers/media/platform/vimc/vimc-common.c
drivers/media/platform/vimc/vimc-common.h

index 9adb06d7e13db9645f458ab13f32d68007364968..93f6a0916329d3cd4337de974b7e5933409d7faa 100644 (file)
@@ -132,31 +132,6 @@ static void vimc_cap_return_all_buffers(struct vimc_cap_device *vcap,
        spin_unlock(&vcap->qlock);
 }
 
-static int vimc_cap_pipeline_s_stream(struct vimc_cap_device *vcap, int enable)
-{
-       struct v4l2_subdev *sd;
-       struct media_pad *pad;
-       int ret;
-
-       /* Start the stream in the subdevice direct connected */
-       pad = media_entity_remote_pad(&vcap->vdev.entity.pads[0]);
-
-       /*
-        * if it is a raw node from vimc-core, there is nothing to activate
-        * TODO: remove this when there are no more raw nodes in the
-        * core and return error instead
-        */
-       if (pad->entity->obj_type == MEDIA_ENTITY_TYPE_BASE)
-               return 0;
-
-       sd = media_entity_to_v4l2_subdev(pad->entity);
-       ret = v4l2_subdev_call(sd, video, s_stream, enable);
-       if (ret && ret != -ENOIOCTLCMD)
-               return ret;
-
-       return 0;
-}
-
 static int vimc_cap_start_streaming(struct vb2_queue *vq, unsigned int count)
 {
        struct vimc_cap_device *vcap = vb2_get_drv_priv(vq);
@@ -173,7 +148,7 @@ static int vimc_cap_start_streaming(struct vb2_queue *vq, unsigned int count)
        }
 
        /* Enable streaming from the pipe */
-       ret = vimc_cap_pipeline_s_stream(vcap, 1);
+       ret = vimc_pipeline_s_stream(&vcap->vdev.entity, 1);
        if (ret) {
                media_pipeline_stop(entity);
                vimc_cap_return_all_buffers(vcap, VB2_BUF_STATE_QUEUED);
@@ -192,7 +167,7 @@ static void vimc_cap_stop_streaming(struct vb2_queue *vq)
        struct vimc_cap_device *vcap = vb2_get_drv_priv(vq);
 
        /* Disable streaming from the pipe */
-       vimc_cap_pipeline_s_stream(vcap, 0);
+       vimc_pipeline_s_stream(&vcap->vdev.entity, 0);
 
        /* Stop the media pipeline */
        media_pipeline_stop(&vcap->vdev.entity);
index 3afbabd739a5ef56b4370fcb99ec59cc347a7bc2..f809a9d756b9be204c58e9d1c09d743850f876d3 100644 (file)
@@ -220,6 +220,38 @@ struct media_pad *vimc_pads_init(u16 num_pads, const unsigned long *pads_flag)
        return pads;
 }
 
+int vimc_pipeline_s_stream(struct media_entity *ent, int enable)
+{
+       struct v4l2_subdev *sd;
+       struct media_pad *pad;
+       unsigned int i;
+       int ret;
+
+       for (i = 0; i < ent->num_pads; i++) {
+               if (ent->pads[i].flags & MEDIA_PAD_FL_SOURCE)
+                       continue;
+
+               /* Start the stream in the subdevice direct connected */
+               pad = media_entity_remote_pad(&ent->pads[i]);
+
+               /*
+                * if this is a raw node from vimc-core, then there is
+                * nothing to activate
+                * TODO: remove this when there are no more raw nodes in the
+                * core and return error instead
+                */
+               if (pad->entity->obj_type == MEDIA_ENTITY_TYPE_BASE)
+                       continue;
+
+               sd = media_entity_to_v4l2_subdev(pad->entity);
+               ret = v4l2_subdev_call(sd, video, s_stream, enable);
+               if (ret && ret != -ENOIOCTLCMD)
+                       return ret;
+       }
+
+       return 0;
+}
+
 static const struct media_entity_operations vimc_ent_sd_mops = {
        .link_validate = v4l2_subdev_link_validate,
 };
index 9ec361c8d7e4c5bab6f81c3c497326b1ef70f6f4..73e7e9479956b4b1c9e91e01d4cad246715c0707 100644 (file)
@@ -96,6 +96,17 @@ static inline void vimc_pads_cleanup(struct media_pad *pads)
        kfree(pads);
 }
 
+/**
+ * vimc_pipeline_s_stream - start stream through the pipeline
+ *
+ * @ent:               the pointer to struct media_entity for the node
+ * @enable:            1 to start the stream and 0 to stop
+ *
+ * Helper function to call the s_stream of the subdevices connected
+ * in all the sink pads of the entity
+ */
+int vimc_pipeline_s_stream(struct media_entity *ent, int enable);
+
 /**
  * vimc_pix_map_by_code - get vimc_pix_map struct by media bus code
  *