linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kaaira Gupta <kgupta@es.iitr.ac.in>
To: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Cc: "Kaaira Gupta" <kgupta@es.iitr.ac.in>,
	"Helen Koike" <helen.koike@collabora.com>,
	"Shuah Khan" <skhan@linuxfoundation.org>,
	"Mauro Carvalho Chehab" <mchehab@kernel.org>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Kieran Bingham" <kieran.bingham@ideasonboard.com>,
	"Niklas Söderlund" <niklas.soderlund@ragnatech.se>
Subject: Re: [PATCH v2 3/3] media: vimc: Join pipeline if one already exists
Date: Tue, 28 Jul 2020 18:18:28 +0530	[thread overview]
Message-ID: <20200728124828.GA8928@kaaira-HP-Pavilion-Notebook> (raw)
In-Reply-To: <e70ecfa2-695f-70ca-eccc-841477700445@collabora.com>

On Tue, Jul 28, 2020 at 02:24:37PM +0200, Dafna Hirschfeld wrote:
> 
> 
> On 24.07.20 14:02, Kaaira Gupta wrote:
> > An output which is running is already part of a pipeline and trying to
> > start a new pipeline is not possible. This prevents two capture devices
> > from streaming at the same time.
> > 
> > Instead of failing to start the second capture device allow it to join
> > the already running pipeline. This allows two (or more) capture devices
> > to independently be started and stopped.
> > 
> > [Kaaira: Changed the search for an existing connected sensor, to search
> > for a non-NULL pipe instead, this helps to terminate the search at
> > output itself instead of going till the sensor, changed variable names,
> > commit message and conditions accordingly]
> > 
> > Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
> > Signed-off-by: Kaaira Gupta <kgupta@es.iitr.ac.in>
> > ---
> >   .../media/test-drivers/vimc/vimc-capture.c    | 35 ++++++++++++++++++-
> >   1 file changed, 34 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/media/test-drivers/vimc/vimc-capture.c b/drivers/media/test-drivers/vimc/vimc-capture.c
> > index c63496b17b9a..423d5e5a508d 100644
> > --- a/drivers/media/test-drivers/vimc/vimc-capture.c
> > +++ b/drivers/media/test-drivers/vimc/vimc-capture.c
> > @@ -237,16 +237,49 @@ static void vimc_cap_return_all_buffers(struct vimc_cap_device *vcap,
> >   	spin_unlock(&vcap->qlock);
> >   }
> > +static struct media_entity *vimc_cap_get_output(struct vimc_cap_device *vcap)
> > +{
> > +	struct media_entity *entity = &vcap->vdev.entity;
> > +	struct media_device *mdev = entity->graph_obj.mdev;
> > +	struct media_graph graph;
> > +
> > +	mutex_lock(&mdev->graph_mutex);
> > +	if (media_graph_walk_init(&graph, mdev)) {
> > +		mutex_unlock(&mdev->graph_mutex);
> > +		return NULL;
> > +	}
> > +
> > +	media_graph_walk_start(&graph, entity);
> > +
> > +	while ((entity = media_graph_walk_next(&graph)))
> > +		if (entity->pipe)
> > +			break;
> > +
> > +	mutex_unlock(&mdev->graph_mutex);
> > +
> > +	media_graph_walk_cleanup(&graph);
> > +
> > +	return entity;
> > +}
> > +
> >   static int vimc_cap_start_streaming(struct vb2_queue *vq, unsigned int count)
> >   {
> >   	struct vimc_cap_device *vcap = vb2_get_drv_priv(vq);
> >   	struct media_entity *entity = &vcap->vdev.entity;
> > +	struct media_pipeline *pipe = NULL;
> > +	struct media_entity *oent;
> >   	int ret;
> >   	vcap->sequence = 0;
> >   	/* Start the media pipeline */
> > -	ret = media_pipeline_start(entity, &vcap->stream.pipe);
> > +	oent = vimc_cap_get_output(vcap);
> > +	if (oent)
> > +		pipe = oent->pipe;
> > +	else
> > +		pipe = &vcap->stream.pipe;
> > +
> > +	ret = media_pipeline_start(entity, pipe);
> >   	if (ret) {
> >   		vimc_cap_return_all_buffers(vcap, VB2_BUF_STATE_QUEUED);
> >   		return ret;
> > 
> 
> I think there is actually no need to iterate the graph. If the capture is already connected to another capture
> that streams, it means that they both have the same pipe in the media core.
> So actually the code can just be:

Hi,
iterating the graph takes care of the case when output already exists.
So in case where an output is needed from both Capture1 and RGB capture,
don't they represent two different pipes?

> 
> if (vcap->ved.ent->pipe)
> 	pipe = vcap->ved.ent->pipe;
> else
> 	pipe = &vcap->stream.pipe;
> 
> 
> (and no need the function vimc_cap_get_output)
> 
> Thanks,
> Dafna

  reply	other threads:[~2020-07-28 12:48 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-24 12:02 [PATCH v2 0/3] media: vimc: Allow multiple capture devices to use the same sensor Kaaira Gupta
2020-07-24 12:02 ` [PATCH v2 1/3] media: vimc: Add usage count to subdevices Kaaira Gupta
2020-07-24 12:02 ` [PATCH v2 2/3] media: vimc: Serialize vimc_streamer_s_stream() Kaaira Gupta
2020-07-24 12:02 ` [PATCH v2 3/3] media: vimc: Join pipeline if one already exists Kaaira Gupta
2020-07-28 12:24   ` Dafna Hirschfeld
2020-07-28 12:48     ` Kaaira Gupta [this message]
2020-07-29 10:58       ` Dafna Hirschfeld
2020-07-24 12:15 ` [PATCH v2 0/3] media: vimc: Allow multiple capture devices to use the same sensor Niklas Söderlund
2020-07-24 12:21   ` Kaaira Gupta
2020-07-27 14:31     ` Kieran Bingham
2020-07-27 17:54       ` Helen Koike
2020-07-28 11:39         ` Kaaira Gupta
2020-07-28 12:07           ` Dafna Hirschfeld
2020-07-28 14:00             ` Dafna Hirschfeld
2020-07-28 14:26               ` Kaaira Gupta
2020-07-29 13:05               ` Kieran Bingham
2020-07-29 13:16                 ` Dafna Hirschfeld
2020-07-29 13:27                   ` Kieran Bingham
2020-07-29 15:24                     ` Dafna Hirschfeld
2020-07-31 17:22                       ` Kaaira Gupta
2020-08-04 10:24                         ` Kieran Bingham
2020-08-04 18:49                           ` Kaaira Gupta
2020-08-04 18:52                             ` Kaaira Gupta
2020-08-05 15:18                       ` Helen Koike
2020-07-30 10:51 ` Laurent Pinchart
2020-07-30 18:09   ` Kaaira Gupta
2020-07-30 22:21     ` Laurent Pinchart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200728124828.GA8928@kaaira-HP-Pavilion-Notebook \
    --to=kgupta@es.iitr.ac.in \
    --cc=dafna.hirschfeld@collabora.com \
    --cc=helen.koike@collabora.com \
    --cc=kieran.bingham@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=niklas.soderlund@ragnatech.se \
    --cc=skhan@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).