linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>,
	linux-media@vger.kernel.org, bingbu.cao@intel.com,
	hongju.wang@intel.com, hverkuil@xs4all.nl,
	Andrey Konovalov <andrey.konovalov@linaro.org>,
	Jacopo Mondi <jacopo.mondi@ideasonboard.com>,
	Dmitry Perchanov <dmitry.perchanov@intel.com>,
	"Ng, Khai Wen" <khai.wen.ng@intel.com>,
	Alain Volmat <alain.volmat@foss.st.com>
Subject: Re: [PATCH v8 01/38] media: mc: Add INTERNAL pad flag
Date: Thu, 28 Mar 2024 09:47:26 +0000	[thread overview]
Message-ID: <ZgU8rsKcSGNPS7Dx@kekkonen.localdomain> (raw)
In-Reply-To: <20240321172032.GM9582@pendragon.ideasonboard.com>

Hi Laurent,

On Thu, Mar 21, 2024 at 07:20:32PM +0200, Laurent Pinchart wrote:
> On Wed, Mar 20, 2024 at 07:49:27AM +0000, Sakari Ailus wrote:
> > On Wed, Mar 20, 2024 at 12:17:07AM +0200, Laurent Pinchart wrote:
> > > On Thu, Mar 14, 2024 at 09:17:08AM +0200, Tomi Valkeinen wrote:
> > > > On 13/03/2024 09:24, Sakari Ailus wrote:
> > > > > Internal source pads will be used as routing endpoints in V4L2
> > > > > [GS]_ROUTING IOCTLs, to indicate that the stream begins in the entity.
> > > > > Internal source pads are pads that have both SINK and INTERNAL flags set.
> > > > > 
> > > > > Also prevent creating links to pads that have been flagged as internal and
> > > > > initialising SOURCE pads with INTERNAL flag set.
> > > > > 
> > > > > Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> > > > > ---
> > > > >   .../userspace-api/media/mediactl/media-types.rst       |  8 ++++++++
> > > > >   drivers/media/mc/mc-entity.c                           | 10 ++++++++--
> > > > >   include/uapi/linux/media.h                             |  1 +
> > > > >   3 files changed, 17 insertions(+), 2 deletions(-)
> > > > > 
> > > > > diff --git a/Documentation/userspace-api/media/mediactl/media-types.rst b/Documentation/userspace-api/media/mediactl/media-types.rst
> > > > > index 6332e8395263..f55ef055bcf8 100644
> > > > > --- a/Documentation/userspace-api/media/mediactl/media-types.rst
> > > > > +++ b/Documentation/userspace-api/media/mediactl/media-types.rst
> > > > > @@ -361,6 +361,7 @@ Types and flags used to represent the media graph elements
> > > > >   .. _MEDIA-PAD-FL-SINK:
> > > > >   .. _MEDIA-PAD-FL-SOURCE:
> > > > >   .. _MEDIA-PAD-FL-MUST-CONNECT:
> > > > > +.. _MEDIA-PAD-FL-INTERNAL:
> > > > >   
> > > > >   .. flat-table:: Media pad flags
> > > > >       :header-rows:  0
> > > > > @@ -381,6 +382,13 @@ Types and flags used to represent the media graph elements
> > > > >   	  enabled links even when this flag isn't set; the absence of the flag
> > > > >   	  doesn't imply there is none.
> > > > >   
> > > > > +    *  -  ``MEDIA_PAD_FL_INTERNAL``
> > > > > +       -  The internal flag indicates an internal pad that has no external
> > > > > +	  connections. Such a pad shall not be connected with a link.
> > > 
> > > I would expand this slightly, as it's the only source of documentation
> > > regarding internal pads.
> > 
> > Patch 9 adds more documentation, this patch is for MC only.
> 
> That's my point, it's the only source of documentation for internal
> pads from an MC point of view, so expanding the documentation would be
> good :-)

This is MC documentation, camera sensors aren't relevant in this context.

> 
> > > 
> > >        -  The internal flag indicates an internal pad that has no external
> > > 	  connections. This can be used to model, for instance, the pixel array
> > > 	  internal to an image sensor. As they are internal to entities,
> > > 	  internal pads shall not be connected with links.
> > 
> > I'd drop the sentence related to sensors.
> 
> I'm fine with another example, or a more generic explanation, but with
> that sentence dropped, I think this will leave the reader wondering what
> an internal pad is and what it's used for.

What we could and probably have here is that the internal sink pad
indicates a source of data. That's what it really is, whether that data is
image data or something else.

So I'd change this to:

The internal flag indicates an internal pad that has no external
connections. Such a pad shall not be connected with a link. The internal
pad flag is allowed only in conjunction with the sink pad flag. Together
the two flags indicate the pad is a source of data inside the entity.


> 
> > > > > +
> > > > > +	  The internal flag may currently be present only in a source pad where
> > > > 
> > > > s/source/sink/
> > > > 
> > > > Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
> > > > > +	  it indicates that the :ref:``stream <media-glossary-stream>``
> > > > > +	  originates from within the entity.
> > > > >   
> > > > >   One and only one of ``MEDIA_PAD_FL_SINK`` and ``MEDIA_PAD_FL_SOURCE``
> > > > >   must be set for every pad.
> > > > > diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c
> > > > > index 0e28b9a7936e..1973e9e1013e 100644
> > > > > --- a/drivers/media/mc/mc-entity.c
> > > > > +++ b/drivers/media/mc/mc-entity.c
> > > > > @@ -213,7 +213,9 @@ int media_entity_pads_init(struct media_entity *entity, u16 num_pads,
> > > > >   		iter->index = i++;
> > > > >   
> > > > >   		if (hweight32(iter->flags & (MEDIA_PAD_FL_SINK |
> > > > > -					     MEDIA_PAD_FL_SOURCE)) != 1) {
> > > > > +					     MEDIA_PAD_FL_SOURCE)) != 1 ||
> > > > > +		    (iter->flags & MEDIA_PAD_FL_INTERNAL &&
> > > > > +		     !(iter->flags & MEDIA_PAD_FL_SINK))) {
> > > > >   			ret = -EINVAL;
> > > > >   			break;
> > > > >   		}
> > > 
> > > This may become more readable written as a switch statement:
> > > 
> > > 		const u32 pad_flags_mask = MEDIA_PAD_FL_SINK |
> > > 					   MEDIA_PAD_FL_SOURCE |
> > > 					   MEDIA_PAD_FL_INTERNAL;
> > > 
> > > 		switch (iter->flags & pad_flags_mask) {
> > > 		case MEDIA_PAD_FL_SINK:
> > > 		case MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_INTERNAL:
> > > 		case MEDIA_PAD_FL_SOURCE:
> > > 			break;
> > > 
> > > 		default:
> > > 			ret = -EINVAL;
> > > 			break;
> > > 		}
> > > 
> > > 		if (ret)
> > > 			break;
> > > 
> > > And now that I've written this, I'm not too sure anymore :-) Another
> > > option would be
> > > 
> > > 
> > > 	const u32 pad_flags = iter->flags & (MEDIA_PAD_FL_SINK |
> > > 					     MEDIA_PAD_FL_SOURCE |
> > > 					     MEDIA_PAD_FL_INTERNAL);
> > > 
> > > 	if (pad_flags != MEDIA_PAD_FL_SINK &&
> > > 	    pad_flags != MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_INTERNAL
> > > 	    pad_flags != MEDIA_PAD_FL_SOURCE) {
> > > 		ret = -EINVAL;
> > > 		break;
> > > 	}
> > > 
> > > Up to you.
> > 
> > I'd prefer to keep it as-is since the original check is testing two
> > independent things instead of merging them: that only either SINK or SOURCE
> > is set, and then separately that if INTERNAL is set, then SINK is set, too.
> > 
> > Of the two options you suggested, I prefer the latter.
> 
> I prefer the latter too, and I think it's more readable than the current
> code. If we later end up having to test for more rules, we can separate
> the checks.

I can switch to the latter.

> 
> > > 
> > > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > 
> > Thank you!
> > 
> > > > > @@ -1112,7 +1114,8 @@ int media_get_pad_index(struct media_entity *entity, u32 pad_type,
> > > > >   
> > > > >   	for (i = 0; i < entity->num_pads; i++) {
> > > > >   		if ((entity->pads[i].flags &
> > > > > -		     (MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_SOURCE)) != pad_type)
> > > > > +		     (MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_SOURCE |
> > > > > +		      MEDIA_PAD_FL_INTERNAL)) != pad_type)
> > > > >   			continue;
> > > > >   
> > > > >   		if (entity->pads[i].sig_type == sig_type)
> > > > > @@ -1142,6 +1145,9 @@ media_create_pad_link(struct media_entity *source, u16 source_pad,
> > > > >   		return -EINVAL;
> > > > >   	if (WARN_ON(!(sink->pads[sink_pad].flags & MEDIA_PAD_FL_SINK)))
> > > > >   		return -EINVAL;
> > > > > +	if (WARN_ON(source->pads[source_pad].flags & MEDIA_PAD_FL_INTERNAL) ||
> > > > > +	    WARN_ON(sink->pads[sink_pad].flags & MEDIA_PAD_FL_INTERNAL))
> > > > > +		return -EINVAL;
> > > > >   
> > > > >   	link = media_add_link(&source->links);
> > > > >   	if (link == NULL)
> > > > > diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
> > > > > index 1c80b1d6bbaf..80cfd12a43fc 100644
> > > > > --- a/include/uapi/linux/media.h
> > > > > +++ b/include/uapi/linux/media.h
> > > > > @@ -208,6 +208,7 @@ struct media_entity_desc {
> > > > >   #define MEDIA_PAD_FL_SINK			(1U << 0)
> > > > >   #define MEDIA_PAD_FL_SOURCE			(1U << 1)
> > > > >   #define MEDIA_PAD_FL_MUST_CONNECT		(1U << 2)
> > > > > +#define MEDIA_PAD_FL_INTERNAL			(1U << 3)
> > > > >   
> > > > >   struct media_pad_desc {
> > > > >   	__u32 entity;		/* entity ID */

-- 
Regards,

Sakari Ailus

  reply	other threads:[~2024-03-28  9:47 UTC|newest]

Thread overview: 149+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-13  7:24 [PATCH v8 00/38] Generic line based metadata support, internal pads Sakari Ailus
2024-03-13  7:24 ` [PATCH v8 01/38] media: mc: Add INTERNAL pad flag Sakari Ailus
2024-03-14  7:17   ` Tomi Valkeinen
2024-03-19 13:21     ` Sakari Ailus
2024-03-19 22:17     ` Laurent Pinchart
2024-03-20  7:49       ` Sakari Ailus
2024-03-21 17:20         ` Laurent Pinchart
2024-03-28  9:47           ` Sakari Ailus [this message]
2024-03-28 10:05             ` Sakari Ailus
2024-03-28 15:25             ` Laurent Pinchart
2024-04-11  7:25               ` Sakari Ailus
2024-03-13  7:24 ` [PATCH v8 02/38] media: Documentation: Add "stream" into glossary Sakari Ailus
2024-03-14  7:18   ` Tomi Valkeinen
2024-03-19 22:20   ` Laurent Pinchart
2024-03-13  7:24 ` [PATCH v8 03/38] media: uapi: Add generic serial metadata mbus formats Sakari Ailus
2024-03-14  7:30   ` Tomi Valkeinen
2024-03-19 13:27     ` Sakari Ailus
2024-03-19 14:20       ` Tomi Valkeinen
2024-03-19 22:33         ` Laurent Pinchart
2024-03-19 23:00           ` Laurent Pinchart
2024-03-20  8:48             ` Sakari Ailus
2024-03-21 17:30               ` Laurent Pinchart
2024-03-22  6:50           ` Tomi Valkeinen
2024-03-25 14:02             ` Sakari Ailus
2024-03-20  8:36         ` Sakari Ailus
2024-03-19 22:59   ` Laurent Pinchart
2024-03-20 16:23     ` Sakari Ailus
2024-03-21 17:38       ` Laurent Pinchart
2024-03-13  7:24 ` [PATCH v8 04/38] media: uapi: Document which mbus format fields are valid for metadata Sakari Ailus
2024-03-14 15:23   ` Tomi Valkeinen
2024-03-19 23:14   ` Laurent Pinchart
2024-03-20 16:49     ` Sakari Ailus
2024-03-13  7:24 ` [PATCH v8 05/38] media: uapi: Add generic 8-bit metadata format definitions Sakari Ailus
2024-03-19 23:37   ` Laurent Pinchart
2024-04-15 14:05     ` Sakari Ailus
2024-03-13  7:24 ` [PATCH v8 06/38] media: v4l: Support line-based metadata capture Sakari Ailus
2024-03-19 23:40   ` Laurent Pinchart
2024-03-13  7:24 ` [PATCH v8 07/38] media: Documentation: Additional streams generally don't harm capture Sakari Ailus
2024-03-19 23:48   ` Laurent Pinchart
2024-04-15 14:27     ` Sakari Ailus
2024-03-13  7:24 ` [PATCH v8 08/38] media: Documentation: Document embedded data guidelines for camera sensors Sakari Ailus
2024-03-15 14:49   ` Julien Massot
2024-03-20  0:03   ` Laurent Pinchart
2024-04-09 11:12     ` Sakari Ailus
2024-03-13  7:24 ` [PATCH v8 09/38] media: Documentation: v4l: Document internal source pads Sakari Ailus
2024-03-15 15:32   ` Julien Massot
2024-03-19 13:47     ` Sakari Ailus
2024-03-19 14:38       ` Julien Massot
2024-03-20  0:26       ` Laurent Pinchart
2024-04-09 12:14         ` Sakari Ailus
2024-03-13  7:24 ` [PATCH v8 10/38] media: Documentation: Document S_ROUTING behaviour Sakari Ailus
2024-03-15 15:38   ` Julien Massot
2024-03-20  0:33   ` Laurent Pinchart
2024-04-11  8:02     ` Sakari Ailus
2024-03-13  7:24 ` [PATCH v8 11/38] media: v4l: subdev: Add a function to lock two sub-device states, use it Sakari Ailus
2024-03-15 15:42   ` Julien Massot
2024-03-20  0:36   ` Laurent Pinchart
2024-03-13  7:24 ` [PATCH v8 12/38] media: v4l: subdev: Move G_ROUTING handling below S_ROUTING Sakari Ailus
2024-03-15 15:43   ` Julien Massot
2024-03-20  0:37   ` Laurent Pinchart
2024-03-13  7:24 ` [PATCH v8 13/38] media: v4l: subdev: Copy argument back to user also for S_ROUTING Sakari Ailus
2024-03-15 15:50   ` Julien Massot
2024-03-20  0:39   ` Laurent Pinchart
2024-04-11  8:06     ` Sakari Ailus
2024-03-13  7:24 ` [PATCH v8 14/38] media: v4l: subdev: Add len_routes field to struct v4l2_subdev_routing Sakari Ailus
2024-03-20  1:36   ` Laurent Pinchart
2024-04-16  7:09     ` Sakari Ailus
2024-03-13  7:24 ` [PATCH v8 15/38] media: v4l: subdev: Return routes set using S_ROUTING Sakari Ailus
2024-03-20  1:45   ` Laurent Pinchart
2024-04-16  7:12     ` Sakari Ailus
2024-03-13  7:24 ` [PATCH v8 16/38] media: v4l: subdev: Allow a larger number of routes than there's room for Sakari Ailus
2024-03-20  1:53   ` Laurent Pinchart
2024-04-16  8:08     ` Sakari Ailus
2024-03-13  7:24 ` [PATCH v8 17/38] media: v4l: subdev: Add trivial set_routing support Sakari Ailus
2024-03-15 15:51   ` Julien Massot
2024-03-20  1:55   ` Laurent Pinchart
2024-04-01 23:41     ` Laurent Pinchart
2024-04-11  8:13       ` Sakari Ailus
2024-04-12 19:14         ` Laurent Pinchart
2024-04-15  8:10           ` Sakari Ailus
2024-03-13  7:24 ` [PATCH v8 18/38] media: ccs: No need to set streaming to false in power off Sakari Ailus
2024-03-13  9:31   ` Kieran Bingham
2024-03-21 16:35   ` Laurent Pinchart
2024-03-13  7:24 ` [PATCH v8 19/38] media: ccs: Use {enable,disable}_streams operations Sakari Ailus
2024-03-21 16:21   ` Laurent Pinchart
2024-03-13  7:24 ` [PATCH v8 20/38] media: ccs: Track streaming state Sakari Ailus
2024-03-15 15:56   ` Julien Massot
2024-03-21 16:36   ` Laurent Pinchart
2024-03-13  7:24 ` [PATCH v8 21/38] media: ccs: Move ccs_validate_csi_data_format up Sakari Ailus
2024-03-15 15:57   ` Julien Massot
2024-03-21 16:37   ` Laurent Pinchart
2024-03-13  7:25 ` [PATCH v8 22/38] media: ccs: Support frame descriptors Sakari Ailus
2024-03-15 16:02   ` Julien Massot
2024-03-21 16:44   ` Laurent Pinchart
2024-04-11  8:33     ` Sakari Ailus
2024-03-13  7:25 ` [PATCH v8 23/38] media: uapi: ccs: Add media bus code for MIPI CCS embedded data Sakari Ailus
2024-03-15 16:03   ` Julien Massot
2024-03-21 16:49   ` Laurent Pinchart
2024-04-11  9:04     ` Sakari Ailus
2024-04-12 19:07       ` Laurent Pinchart
2024-04-14 10:48         ` Sakari Ailus
2024-04-20  8:07           ` Laurent Pinchart
2024-03-13  7:25 ` [PATCH v8 24/38] media: ccs: Add support for embedded data stream Sakari Ailus
2024-03-13  7:25 ` [PATCH v8 25/38] media: ccs: Remove ccs_get_crop_compose helper Sakari Ailus
2024-03-21 18:05   ` Laurent Pinchart
2024-04-16  7:30     ` Sakari Ailus
2024-03-13  7:25 ` [PATCH v8 26/38] media: ccs: Rely on sub-device state locking Sakari Ailus
2024-03-13  7:25 ` [PATCH v8 27/38] media: ccs: Compute binning configuration from sub-device state Sakari Ailus
2024-03-21 17:57   ` Laurent Pinchart
2024-04-16  8:01     ` Sakari Ailus
2024-03-13  7:25 ` [PATCH v8 28/38] media: ccs: Compute scaling " Sakari Ailus
2024-03-21 17:50   ` Laurent Pinchart
2024-04-16  7:59     ` Sakari Ailus
2024-03-13  7:25 ` [PATCH v8 29/38] media: ccs: Remove which parameter from ccs_propagate Sakari Ailus
2024-03-21 17:39   ` Laurent Pinchart
2024-03-13  7:25 ` [PATCH v8 30/38] media: Documentation: ccs: Document routing Sakari Ailus
2024-03-21 17:43   ` Laurent Pinchart
2024-04-16  7:37     ` Sakari Ailus
2024-03-13  7:25 ` [PATCH v8 31/38] media: uapi: v4l: subdev: Enable streams API Sakari Ailus
2024-03-21 16:51   ` Laurent Pinchart
2024-03-13  7:25 ` [PATCH v8 32/38] media: uapi: Add media bus code for ov2740 embedded data Sakari Ailus
2024-03-15 16:10   ` Julien Massot
2024-03-21 16:54   ` Laurent Pinchart
2024-03-13  7:25 ` [PATCH v8 33/38] media: ov2740: Switch to {enable,disable}_streams Sakari Ailus
2024-03-15 16:13   ` Julien Massot
2024-03-21 16:56   ` Laurent Pinchart
2024-03-13  7:25 ` [PATCH v8 34/38] media: ov2740: Track streaming state Sakari Ailus
2024-03-15 16:13   ` Julien Massot
2024-03-21 16:57   ` Laurent Pinchart
2024-03-13  7:25 ` [PATCH v8 35/38] media: ov2740: Add support for embedded data Sakari Ailus
2024-03-14  7:00   ` Bingbu Cao
2024-03-19 13:13     ` Sakari Ailus
2024-03-14  8:24   ` Julien Massot
2024-03-19 13:18     ` Sakari Ailus
2024-03-21 17:16   ` Laurent Pinchart
2024-04-10 13:18     ` Sakari Ailus
2024-03-13  7:25 ` [PATCH v8 36/38] media: v4l: Add V4L2_SUBDEV_ROUTE_FL_IMMUTABLE sub-device routing flag Sakari Ailus
2024-03-13  7:34   ` Tomi Valkeinen
2024-03-13  7:39     ` Sakari Ailus
2024-03-21 17:03       ` Laurent Pinchart
2024-04-09 13:21         ` Sakari Ailus
2024-04-09 15:21           ` Laurent Pinchart
2024-03-13  7:25 ` [PATCH v8 37/38] media: ccs: Add IMMUTABLE route flag Sakari Ailus
2024-03-15 16:08   ` Julien Massot
2024-03-21 16:59   ` Laurent Pinchart
2024-04-11  9:06     ` Sakari Ailus
2024-03-13  7:25 ` [PATCH v8 38/38] media: ov2740: " Sakari Ailus
2024-03-15 16:14   ` Julien Massot
2024-03-21 17:00   ` 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=ZgU8rsKcSGNPS7Dx@kekkonen.localdomain \
    --to=sakari.ailus@linux.intel.com \
    --cc=alain.volmat@foss.st.com \
    --cc=andrey.konovalov@linaro.org \
    --cc=bingbu.cao@intel.com \
    --cc=dmitry.perchanov@intel.com \
    --cc=hongju.wang@intel.com \
    --cc=hverkuil@xs4all.nl \
    --cc=jacopo.mondi@ideasonboard.com \
    --cc=khai.wen.ng@intel.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=tomi.valkeinen@ideasonboard.com \
    /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).