diff mbox series

[v3,8/9] media: vimc: Join pipeline if one already exists

Message ID 20200819180442.11630-9-kgupta@es.iitr.ac.in (mailing list archive)
State New, archived
Headers show
Series media: vimc: Multiple stream support in vimc | expand

Commit Message

Kaaira Gupta Aug. 19, 2020, 6:04 p.m. UTC
Start another capture, if one is already running, by checking for
existing pipe. If it exists already, don't fail to start second capture,
instead join it to the already running pipeline.
Use the same stream struct used by already running capture.

Signed-off-by: Kaaira Gupta <kgupta@es.iitr.ac.in>
---
 drivers/media/test-drivers/vimc/vimc-capture.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

Comments

Kieran Bingham Sept. 2, 2020, 10:40 a.m. UTC | #1
Hi Kaaira,

On 19/08/2020 19:04, Kaaira Gupta wrote:
> Start another capture, if one is already running, by checking for
> existing pipe. If it exists already, don't fail to start second capture,
> instead join it to the already running pipeline.
> Use the same stream struct used by already running capture.
> 
> Signed-off-by: Kaaira Gupta <kgupta@es.iitr.ac.in>
> ---
>  drivers/media/test-drivers/vimc/vimc-capture.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/test-drivers/vimc/vimc-capture.c b/drivers/media/test-drivers/vimc/vimc-capture.c
> index 73e5bdd17c57..4d20eda9335e 100644
> --- a/drivers/media/test-drivers/vimc/vimc-capture.c
> +++ b/drivers/media/test-drivers/vimc/vimc-capture.c
> @@ -247,9 +247,15 @@ static int vimc_cap_start_streaming(struct vb2_queue *vq, unsigned int count)
>  	atomic_inc(&vcap->ved.use_count);
>  	vcap->sequence = 0;
>  
> -	stream = kzalloc(sizeof(*stream), GFP_ATOMIC);
> -	kref_init(&stream->refcount);
> -	pipe = &stream->pipe;
> +	if (vcap->ved.ent->pipe) {
> +		pipe = vcap->ved.ent->pipe;
> +		stream = container_of(pipe, struct vimc_stream, pipe);
> +		kref_get(&stream->refcount);
> +	} else {
> +		stream = kzalloc(sizeof(*stream), GFP_ATOMIC);
> +		kref_init(&stream->refcount);
> +		pipe = &stream->pipe;
> +	}
>  

Of course if we move the stream to the sensor entity (which I still
think is a good idea), we'll need a way to easily get from capture
entity to the sensor entity. We could put a reference pointer directly
in the capture ? Or have each entity provide a poitner to it's previous
entity and walk backwards, which would also help on the other code path
that had to do lots of conversions from video or subdev entities or such...


>  	/* Start the media pipeline */
>  	ret = media_pipeline_start(entity, pipe);
>
diff mbox series

Patch

diff --git a/drivers/media/test-drivers/vimc/vimc-capture.c b/drivers/media/test-drivers/vimc/vimc-capture.c
index 73e5bdd17c57..4d20eda9335e 100644
--- a/drivers/media/test-drivers/vimc/vimc-capture.c
+++ b/drivers/media/test-drivers/vimc/vimc-capture.c
@@ -247,9 +247,15 @@  static int vimc_cap_start_streaming(struct vb2_queue *vq, unsigned int count)
 	atomic_inc(&vcap->ved.use_count);
 	vcap->sequence = 0;
 
-	stream = kzalloc(sizeof(*stream), GFP_ATOMIC);
-	kref_init(&stream->refcount);
-	pipe = &stream->pipe;
+	if (vcap->ved.ent->pipe) {
+		pipe = vcap->ved.ent->pipe;
+		stream = container_of(pipe, struct vimc_stream, pipe);
+		kref_get(&stream->refcount);
+	} else {
+		stream = kzalloc(sizeof(*stream), GFP_ATOMIC);
+		kref_init(&stream->refcount);
+		pipe = &stream->pipe;
+	}
 
 	/* Start the media pipeline */
 	ret = media_pipeline_start(entity, pipe);