Re: [PATCH v12 1/7] media: v4l2: Add ignore_streaming flag

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



cc Tomasz Figa

Le mercredi 20 septembre 2023 à 14:59 +0200, Hans Verkuil a écrit :
> On 15/09/2023 23:11, Sebastian Fricke wrote:
> > Add a new flag to the `struct v4l2_m2m_dev` to toggle whether a queue
> > must be streaming in order to allow queuing jobs to the ready queue.
> > Currently, both queues (CAPTURE & OUTPUT) must be streaming in order to
> > allow adding new jobs. This behavior limits the usability of M2M for
> > some drivers, as these have to be able, to perform analysis of the
> 
> able, to -> able to
> 
> > sequence to ensure, that userspace prepares the CAPTURE queue correctly.
> 
> ensure, that -> ensure that
> 
> > 
> > Signed-off-by: Sebastian Fricke <sebastian.fricke@xxxxxxxxxxxxx>
> > Signed-off-by: Nicolas Dufresne <nicolas.dufresne@xxxxxxxxxxxxx>
> > ---
> >  include/media/v4l2-mem2mem.h | 17 +++++++++++++++++
> >  1 file changed, 17 insertions(+)
> > 
> > diff --git a/include/media/v4l2-mem2mem.h b/include/media/v4l2-mem2mem.h
> > index d6c8eb2b5201..97a48e61e358 100644
> > --- a/include/media/v4l2-mem2mem.h
> > +++ b/include/media/v4l2-mem2mem.h
> > @@ -57,6 +57,16 @@ struct v4l2_m2m_dev;
> >   * @rdy_spinlock: spin lock to protect the struct usage
> >   * @num_rdy:	number of buffers ready to be processed
> >   * @buffered:	is the queue buffered?
> > + * @ignore_streaming: Dictates whether the queue must be streaming for a job to
> > + *		      be queued.
> > + *		      This is useful, for example, when the driver requires to
> > + *		      initialize the sequence with a firmware, where only a
> > + *		      queued OUTPUT queue buffer and STREAMON on the OUTPUT
> > + *		      queue is required to perform the anlysis of the bitstream
> > + *		      header.
> > + *		      This means the driver is responsible for implementing the
> > + *		      job_ready callback correctly to make sure that requirements
> > + *		      for actual decoding are met.
> 
> This is a bad description and field name.

I wonder what's your opinion about the buffered one then :-D

> 
> Basically what this field does is that, if true, the streaming state of the
> capture queue is ignored. So just call it that: ignore_cap_streaming.
> 
> And explain that, if true, job_ready() will be called even if the capture
> queue is not streaming, and that that can be used to allow hardware to
> analyze the bitstream header that arrives on the OUTPUT queue.

Ack.

> 
> Also, doesn't this field belong to struct v4l2_m2m_ctx? It makes no sense
> for the output queue, this is really a configuration for the m2m context as
> a whole.

Unless we come up with a completely new type of M2M that can behave like a gap
filler (like a video rate m2m), it indeed makes no sense for output. I'm just
illustrating that this is true "now" but someone can come up with valid
expectation. So I agree with you, we can move it up in the hierarchy.

Recently over IRC and other threads, Tomasz raised a concern that CODECs where
introducing too much complexity into M2M. And I believe buffered (which is
barely documented) and this mechanism was being pointed.

My take on that is that adding boolean configuration is what introduce
complexity, and we can fix it by doing less in the m2m. After this discussion, I
came with the idea that we should remove buffered and ignore_streaming. For
drivers that don't implement job_ready, this logic would be moved inside the
default implementation. We can then add a helper to check the common conditions.

The alternative suggested by Tomasz, was to layer two ops. We'd have a
device_ready() ops and its default implementation would include the check we
have and would call job_ready(). Personally, I'd rather remove then add, but I
understadt the reasoning and would be fine committing to that instead.

I'd like your feedback on this proposal. If this is something we want, I'll do
this prior to V13, otherwise we will address your comments and fix the added
mechanism. I think though that we agree that for decoders, this is nice addition
to not have to trigger work manually from vb2 ops.

regards,
Nicolas

> 
> >   *
> >   * Queue for buffers ready to be processed as soon as this
> >   * instance receives access to the device.
> > @@ -69,6 +79,7 @@ struct v4l2_m2m_queue_ctx {
> >  	spinlock_t		rdy_spinlock;
> >  	u8			num_rdy;
> >  	bool			buffered;
> > +	bool			ignore_streaming;
> >  };
> >  
> >  /**
> > @@ -564,6 +575,12 @@ static inline void v4l2_m2m_set_dst_buffered(struct v4l2_m2m_ctx *m2m_ctx,
> >  	m2m_ctx->cap_q_ctx.buffered = buffered;
> >  }
> >  
> > +static inline void v4l2_m2m_set_dst_ignore_streaming(struct v4l2_m2m_ctx *m2m_ctx,
> > +						     bool ignore_streaming)
> > +{
> > +	m2m_ctx->cap_q_ctx.ignore_streaming = ignore_streaming;
> > +}
> > +
> 
> I think this is overkill, esp. when the field is moved to m2m_ctx. Just clearly
> document that drivers can set this.
> 
> Regards,
> 
> 	Hans
> 
> >  /**
> >   * v4l2_m2m_ctx_release() - release m2m context
> >   *
> > 
> 





[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux