All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
To: Helen Koike <helen@koikeco.de>
Cc: Helen Koike <helen.koike@collabora.com>,
	linux-media@vger.kernel.org, libcamera-devel@lists.libcamera.org
Subject: Re: [PATCH 3/3] vimc: Join pipeline if one already exists
Date: Thu, 11 Jul 2019 13:35:35 +0900	[thread overview]
Message-ID: <20190711043535.GF1557@wyvern> (raw)
In-Reply-To: <3369c4f6-d08b-efca-baed-e48cca2d4d87@koikeco.de>

Hi Helen,

Thanks for your feedback.

On 2019-07-09 15:24:10 -0300, Helen Koike wrote:
> Hi Niklas,
> 
> Thanks for the patch (and sorry for my late reply).
> 
> On 5/17/19 10:07 PM, Niklas Söderlund wrote:
> > A sensor which is running is already part of a pipeline and trying to
> > start a new pipeline is not possible. This prevents two capture devices
> > connected to the same sensor from running at the same time.
> > 
> > Instead of failing to start the second capture device allow it to join
> > the already running pipeline by looking it up at the sensor. This allows
> > two (or more) capture devices to independently be started and stopped
> > while still being connected to the same sensor.
> > 
> > Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
> > ---
> >  drivers/media/platform/vimc/vimc-capture.c | 35 +++++++++++++++++++++-
> >  1 file changed, 34 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/media/platform/vimc/vimc-capture.c b/drivers/media/platform/vimc/vimc-capture.c
> > index e7d0fc2228a6f0c1..f9eb1e327e311b4a 100644
> > --- a/drivers/media/platform/vimc/vimc-capture.c
> > +++ b/drivers/media/platform/vimc/vimc-capture.c
> > @@ -264,16 +264,49 @@ static void vimc_cap_return_all_buffers(struct vimc_cap_device *vcap,
> >  	spin_unlock(&vcap->qlock);
> >  }
> >  
> > +static struct media_entity *vimc_cap_get_sensor(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->function == MEDIA_ENT_F_CAM_SENSOR)
> > +			break;
> 
> I was wondering if it should search up to the sensor, or if it could just search the first entity with a pipe object, what do you think?
> Like this it should work with an output device instead of a sensor.

I think that might be a good idea, I will see what I can do for v2.

> 
> Regards,
> Helen
> 
> > +
> > +	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 *sensorent;
> >  	int ret;
> >  
> >  	vcap->sequence = 0;
> >  
> >  	/* Start the media pipeline */
> > -	ret = media_pipeline_start(entity, &vcap->stream.pipe);
> > +	sensorent = vimc_cap_get_sensor(vcap);
> > +	if (sensorent && sensorent->pipe)
> > +		pipe = sensorent->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;
> > 

-- 
Regards,
Niklas Söderlund

  reply	other threads:[~2019-07-11  4:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-18  1:07 [PATCH 0/3] vimc: Allow multiple capture devices to use the same sensor Niklas Söderlund
2019-05-18  1:07 ` [PATCH 1/3] vimc: Add usage count to subdevices Niklas Söderlund
2020-03-16 19:40   ` Helen Koike
2020-03-16 20:32     ` Niklas Söderlund
2019-05-18  1:07 ` [PATCH 2/3] vimc: Serialize vimc_streamer_s_stream() Niklas Söderlund
2019-05-18  1:07 ` [PATCH 3/3] vimc: Join pipeline if one already exists Niklas Söderlund
2019-07-09 18:24   ` Helen Koike
2019-07-11  4:35     ` Niklas Söderlund [this message]
2019-10-23  7:01 ` [PATCH 0/3] vimc: Allow multiple capture devices to use the same sensor Hans Verkuil
2019-10-23 10:22   ` Niklas Söderlund

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=20190711043535.GF1557@wyvern \
    --to=niklas.soderlund+renesas@ragnatech.se \
    --cc=helen.koike@collabora.com \
    --cc=helen@koikeco.de \
    --cc=libcamera-devel@lists.libcamera.org \
    --cc=linux-media@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.