All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil-cisco@xs4all.nl>
To: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>,
	linux-media@vger.kernel.org, sakari.ailus@linux.intel.com,
	Jacopo Mondi <jacopo+renesas@jmondi.org>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	niklas.soderlund+renesas@ragnatech.se
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
	Pratyush Yadav <p.yadav@ti.com>
Subject: Re: [PATCH v9 30/36] media: Documentation: add multiplexed streams documentation
Date: Tue, 12 Oct 2021 17:34:33 +0200	[thread overview]
Message-ID: <d89afbd7-2f12-5231-a227-853f7e975e8e@xs4all.nl> (raw)
In-Reply-To: <20211005085750.138151-31-tomi.valkeinen@ideasonboard.com>

On 05/10/2021 10:57, Tomi Valkeinen wrote:
> Add documentation related to multiplexed streams.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
> ---
>  .../driver-api/media/v4l2-subdev.rst          |   8 +
>  .../userspace-api/media/v4l/dev-subdev.rst    | 164 ++++++++++++++++++
>  2 files changed, 172 insertions(+)
> 
> diff --git a/Documentation/driver-api/media/v4l2-subdev.rst b/Documentation/driver-api/media/v4l2-subdev.rst
> index c3fd57fff668..410e03a29f2a 100644
> --- a/Documentation/driver-api/media/v4l2-subdev.rst
> +++ b/Documentation/driver-api/media/v4l2-subdev.rst
> @@ -546,6 +546,14 @@ subdev drivers. In these cases the called subdev ops must also handle the NULL
>  case. This can be easily managed by the use of
>  v4l2_subdev_validate_and_lock_state() helper.
>  
> +Streams, multiplexed media pads and internal routing
> +----------------------------------------------------
> +
> +A subdevice driver can implement support for multiplexed streams by setting
> +the V4L2_SUBDEV_FL_MULTIPLEXED subdev flag and implementing support for
> +centrally managed subdev active state, routing and stream based
> +configuration.
> +
>  V4L2 sub-device functions and data structures
>  ---------------------------------------------
>  
> diff --git a/Documentation/userspace-api/media/v4l/dev-subdev.rst b/Documentation/userspace-api/media/v4l/dev-subdev.rst
> index a67c2749089a..ea3efa97bb08 100644
> --- a/Documentation/userspace-api/media/v4l/dev-subdev.rst
> +++ b/Documentation/userspace-api/media/v4l/dev-subdev.rst
> @@ -503,3 +503,167 @@ source pads.
>      :maxdepth: 1
>  
>      subdev-formats
> +
> +Streams, multiplexed media pads and internal routing
> +----------------------------------------------------
> +
> +Commonly V4L2 subdevices support only separate video streams, that is, each
> +link in the media grap and each pad in a subdevice passes through a single

passes -> pass
grap -> graph

> +video stream. Thus each pad contains a format configuration for that single
> +stream. In some cases a subdev can do stream processing and split a stream
> +into two or compose two streams into one, but the inputs and outputs for the
> +subdev are still a single stream per pad.
> +
> +Some hardware, e.g. MIPI CSI-2, support multiplexed streams, that is, a single
> +bus carries multiple streams. Thus a camera could output two streams, a pixel
> +stream and a metadata stream, and a bridge subdev could route the streams
> +from multiple input pads into a single output pad.
> +
> +Subdevice drivers that support multiplexed streams are compatible with
> +non-multiplexed subdev drivers, but, of course, requires such a routing

requires such -> require

> +configuration where the link between those two types of drivers contain only

contain -> contains

> +a single stream.
> +
> +Understanding streams
> +^^^^^^^^^^^^^^^^^^^^^
> +
> +A stream is a stream of content (e.g. pixel data or metadata) flowing through
> +the media pipeline from a source (e.g. a sensor) towards the final sink
> +(e.g. a receiver in a SoC). Each media link carries all the streams from

'receiver' is a bit vague. What sort of receiver are we talking about here?
What about: 'a receiver and demultiplexer in a SoC'. This implies that it is
the block that can receive a multiplexed stream and demux it. The demuxing
part is the critical feature of this block IMHO.

> +one end of the link to the other, whereas subdevices have routing tables

'whereas' is an odd word. Would simply 'and' not be a better word to use here?

> +which describe how the incoming streams from sink pads are routed to the
> +source pads.
> +
> +A stream ID (often just "stream") is a media link-local identifier for a
> +stream. In other words, configuration for a particular stream ID must exist

configuration -> a configuration

> +on both sides of a media link, but another stream ID can be used for the same
> +stream at the other side of the subdevice.
> +
> +A stream at a specific point in the media pipeline is identified with the
> +subdev and a (pad, stream) pair. For subdevices that do not support
> +multiplexed streams the 'stream' is always 0.

I find this section confusing. I think there are two issues here: what exactly is
meant with 'media link': a link between two pads from different entities?

And I also think that 'subdev' is sometimes used where 'media entity' is actually
meant. E.g. "at the other side of the subdevice" makes no sense, but "between two
other entities" makes more sense.

> +
> +Configuring streams
> +^^^^^^^^^^^^^^^^^^^
> +
> +The configuration of the streams is done individually for each subdevice and
> +the validity of the streams between subdevices is validated when the pipeline
> +is started.

Here too I think you really mean 'entities'. A subdev device node controls an
entity. It might be me, but when I think of a media stream I see it as a data
stream running through entities, and subdevs are just the interfaces through
which the entities are controlled.

> +
> +There are three steps in configuring the streams:
> +
> +1) Set up links. Connect the pads between subdevices using the :ref:`Media
> +Controller API <media_controller>`
> +
> +2) Routing. The routing table for the subdevice must be set with
> +:ref:`VIDIOC_SUBDEV_S_ROUTING <VIDIOC_SUBDEV_G_ROUTING>` ioctl.
> +
> +3) Configure streams. Each route endpoint must be configured
> +with :ref:`VIDIOC_SUBDEV_S_FMT <VIDIOC_SUBDEV_G_FMT>`.
> +
> +Multiplexed streams setup example
> +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> +
> +A simple example of a multiplexed stream setup might be as follows:
> +
> +- Two identical sensors (Sensor A and Sensor B). Each sensor has a single
> +  source pad (pad 0), and outputs two streams, pixel data and metadata.
> +
> +- Multiplexer bridge (Bridge). The bridge has two sink pads, connected to the
> +  sensors (pads 0, 1), and one source pad (pad 2), which outputs all 4
> +  streams.
> +
> +- Receiver in the SoC (Receiver). The receiver has a single sink pad (pad 0),
> +  connected to the bridge, and four source pads (pads 1-4), going to the DMA
> +  engine. The receiver demultiplexes the incoming streams to the four source
> +  pads.
> +
> +- Four DMA Engines in the SoC (DMA Engine). Each DMA engine is connected to a
> +  single source pad in the receiver.
> +
> +The sensors, the bridge and the receiver are modeled as V4L2 subdevices,
> +exposed to userspace via /dev/v4l-subdevX device nodes. The DMA engines are
> +modeled as V4L2 devices, exposed to userspace via /dev/videoX nodes.
> +
> +To configure this pipeline, the userspace must take the following steps:
> +
> +1) Set up media links between entities: connect the sensors to the bridge,
> +bridge to the receiver, and the receiver to the DMA engines. This step does
> +not differ from normal non-multiplexed media controller setup.
> +
> +2) Configure routing.
> +
> +.. flat-table:: Sensor routing table (identical on both sensors)
> +    :header-rows:  1
> +
> +    * - Sink Pad/Stream
> +      - Source Pad/Stream
> +      - Routing Flags
> +      - Comments
> +    * - 0/0 (unused)
> +      - 0/0
> +      - V4L2_SUBDEV_ROUTE_FL_ACTIVE | V4L2_SUBDEV_ROUTE_FL_SOURCE
> +      - Pixel data stream. Source route, i.e. the sink fields are unused.
> +    * - 0/0 (unused)
> +      - 0/1
> +      - V4L2_SUBDEV_ROUTE_FL_ACTIVE | V4L2_SUBDEV_ROUTE_FL_SOURCE
> +      - Metadata stream. Source route, i.e. the sink fields are unused.
> +
> +.. flat-table:: Bridge routing table
> +    :header-rows:  1
> +
> +    * - Sink Pad/Stream
> +      - Source Pad/Stream
> +      - Routing Flags
> +      - Comments
> +    * - 0/0
> +      - 2/0
> +      - V4L2_SUBDEV_ROUTE_FL_ACTIVE
> +      - Pixel data stream from Sensor A
> +    * - 0/1
> +      - 2/1
> +      - V4L2_SUBDEV_ROUTE_FL_ACTIVE
> +      - Metadata stream from Sensor A
> +    * - 1/0
> +      - 2/2
> +      - V4L2_SUBDEV_ROUTE_FL_ACTIVE
> +      - Pixel data stream from Sensor B
> +    * - 1/1
> +      - 2/3
> +      - V4L2_SUBDEV_ROUTE_FL_ACTIVE
> +      - Metadata stream from Sensor B
> +
> +.. flat-table:: Receiver routing table
> +    :header-rows:  1
> +
> +    * - Sink Pad/Stream
> +      - Source Pad/Stream
> +      - Routing Flags
> +      - Comments
> +    * - 0/0
> +      - 1/0
> +      - V4L2_SUBDEV_ROUTE_FL_ACTIVE
> +      - Pixel data stream from Sensor A
> +    * - 0/1
> +      - 2/0
> +      - V4L2_SUBDEV_ROUTE_FL_ACTIVE
> +      - Metadata stream from Sensor A
> +    * - 0/2
> +      - 3/0
> +      - V4L2_SUBDEV_ROUTE_FL_ACTIVE
> +      - Pixel data stream from Sensor B
> +    * - 0/3
> +      - 4/0
> +      - V4L2_SUBDEV_ROUTE_FL_ACTIVE
> +      - Metadata stream from Sensor B
> +
> +3) Configure streams
> +
> +After configuring the routing table, the next step is configuring the streams.
> +This step is similar to configuring the pads in a non-multiplexed streams
> +setup, with the difference that we need to configure each (pad, stream) pair
> +(i.e. route endpoint), instead of just a pad.
> +
> +Presuming there are no format conversions in the pipeline, the userspace needs

Presuming -> Assuming

> +to configure all the route endpoints using four formats (two pixel formats
> +and two metadata formats) with VIDIOC_SUBDEV_S_FMT.
> 

Actually, if there are format conversions, wouldn't you still do the same thing?

Is that 'Presuming...pipeline,' needed at all?

Regards,

	Hans

  reply	other threads:[~2021-10-12 15:34 UTC|newest]

Thread overview: 94+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-05  8:57 [PATCH v9 00/36] v4l: subdev internal routing and streams Tomi Valkeinen
2021-10-05  8:57 ` [PATCH v9 01/36] media: subdev: rename subdev-state alloc & free Tomi Valkeinen
2021-10-12 13:46   ` Hans Verkuil
2021-10-05  8:57 ` [PATCH v9 02/36] media: subdev: add active state to struct v4l2_subdev Tomi Valkeinen
2021-10-12 14:32   ` Hans Verkuil
2021-11-04 10:59     ` Tomi Valkeinen
2021-10-05  8:57 ` [PATCH v9 03/36] media: subdev: pass also the active state to subdevs from ioctls Tomi Valkeinen
2021-10-12 13:53   ` Hans Verkuil
2021-10-05  8:57 ` [PATCH v9 04/36] media: subdev: add subdev state locking Tomi Valkeinen
2021-10-12 14:36   ` Hans Verkuil
2021-11-04 11:11     ` Tomi Valkeinen
2021-10-05  8:57 ` [PATCH v9 05/36] media: subdev: Add v4l2_subdev_validate_and_lock_state() Tomi Valkeinen
2021-10-12 14:16   ` Hans Verkuil
2021-11-04 11:15     ` Tomi Valkeinen
2021-10-05  8:57 ` [PATCH v9 06/36] media: Documentation: add documentation about subdev state Tomi Valkeinen
2021-10-12 14:36   ` Hans Verkuil
2021-10-05  8:57 ` [PATCH v9 07/36] media: entity: Use pad as a starting point for graph walk Tomi Valkeinen
2021-10-12 14:46   ` Hans Verkuil
2021-10-05  8:57 ` [PATCH v9 08/36] media: entity: Use pads instead of entities in the media graph walk stack Tomi Valkeinen
2021-10-05  8:57 ` [PATCH v9 09/36] media: entity: Walk the graph based on pads Tomi Valkeinen
2021-10-05  8:57 ` [PATCH v9 10/36] media: mc: Start walk from a specific pad in use count calculation Tomi Valkeinen
2021-10-05  8:57 ` [PATCH v9 11/36] media: entity: Add iterator helper for entity pads Tomi Valkeinen
2021-10-05  8:57 ` [PATCH v9 12/36] media: entity: Move the pipeline from entity to pads Tomi Valkeinen
2021-10-05  8:57 ` [PATCH v9 13/36] media: entity: Use pad as the starting point for a pipeline Tomi Valkeinen
2021-10-05  8:57 ` [PATCH v9 14/36] media: entity: Add has_route entity operation Tomi Valkeinen
2021-10-05  8:57 ` [PATCH v9 15/36] media: entity: Add media_entity_has_route() function Tomi Valkeinen
2021-10-05  8:57 ` [PATCH v9 16/36] media: entity: Use routing information during graph traversal Tomi Valkeinen
2021-10-05  8:57 ` [PATCH v9 17/36] media: entity: Skip link validation for pads to which there is no route Tomi Valkeinen
2021-10-05  8:57 ` [PATCH v9 18/36] media: entity: Add an iterator helper for connected pads Tomi Valkeinen
2021-10-05  8:57 ` [PATCH v9 19/36] media: entity: Add only connected pads to the pipeline Tomi Valkeinen
2021-10-05  8:57 ` [PATCH v9 20/36] media: entity: Add debug information in graph walk route check Tomi Valkeinen
2021-10-05  8:57 ` [PATCH v9 21/36] media: Add bus type to frame descriptors Tomi Valkeinen
2021-10-05  8:57 ` [PATCH v9 22/36] media: Add CSI-2 bus configuration " Tomi Valkeinen
2021-10-05  8:57 ` [PATCH v9 23/36] media: Add stream to frame descriptor Tomi Valkeinen
2021-10-05  8:57 ` [PATCH v9 24/36] media: subdev: increase V4L2_FRAME_DESC_ENTRY_MAX to 8 Tomi Valkeinen
2021-10-12 14:44   ` Hans Verkuil
2021-10-05  8:57 ` [PATCH v9 25/36] media: add V4L2_SUBDEV_FL_MULTIPLEXED Tomi Valkeinen
2021-10-12 14:48   ` Hans Verkuil
2021-11-04 12:06     ` Tomi Valkeinen
2021-10-12 14:55   ` Hans Verkuil
2021-11-04 12:40     ` Tomi Valkeinen
2021-10-05  8:57 ` [PATCH v9 26/36] media: Documentation: Add GS_ROUTING documentation Tomi Valkeinen
2021-10-12 14:56   ` Hans Verkuil
2021-10-05  8:57 ` [PATCH v9 27/36] media: subdev: Add [GS]_ROUTING subdev ioctls and operations Tomi Valkeinen
2021-10-06  6:47   ` Tomi Valkeinen
2021-10-10  7:36   ` Laurent Pinchart
2021-10-11  7:57     ` Tomi Valkeinen
2021-10-12 15:04   ` Hans Verkuil
2021-10-15 12:13   ` Jacopo Mondi
2021-10-15 12:36     ` Tomi Valkeinen
2021-10-15 14:05       ` Jacopo Mondi
2021-10-15 15:17         ` Tomi Valkeinen
2021-10-15 15:28           ` Jacopo Mondi
2021-10-15 16:10             ` Tomi Valkeinen
2021-10-15 16:47               ` Jacopo Mondi
2021-10-15 16:55                 ` Tomi Valkeinen
2021-10-15 17:51                   ` Jacopo Mondi
2021-11-18 10:54   ` Tomi Valkeinen
2021-10-05  8:57 ` [PATCH v9 28/36] media: subdev: add v4l2_subdev_has_route() Tomi Valkeinen
2021-10-12 15:05   ` Hans Verkuil
2021-10-05  8:57 ` [PATCH v9 29/36] media: subdev: add v4l2_subdev_set_routing helper() Tomi Valkeinen
2021-10-10 10:21   ` Laurent Pinchart
2021-10-11  8:13     ` Tomi Valkeinen
2021-10-11 21:06       ` Laurent Pinchart
2021-10-12  5:09         ` Tomi Valkeinen
2021-10-12 15:07   ` Hans Verkuil
2021-10-05  8:57 ` [PATCH v9 30/36] media: Documentation: add multiplexed streams documentation Tomi Valkeinen
2021-10-12 15:34   ` Hans Verkuil [this message]
2021-11-04 13:27     ` Tomi Valkeinen
2021-10-05  8:57 ` [PATCH v9 31/36] media: subdev: add stream based configuration Tomi Valkeinen
2021-10-13  7:17   ` Hans Verkuil
2021-11-30 11:40     ` Tomi Valkeinen
2021-10-05  8:57 ` [PATCH v9 32/36] media: subdev: use streams in v4l2_subdev_link_validate() Tomi Valkeinen
2021-10-13  7:27   ` Hans Verkuil
2021-10-05  8:57 ` [PATCH v9 33/36] media: subdev: add "opposite" stream helper funcs Tomi Valkeinen
2021-10-10 14:15   ` Laurent Pinchart
2021-10-10 14:18     ` Laurent Pinchart
2021-10-11  8:21     ` Tomi Valkeinen
2021-10-11 15:01       ` Laurent Pinchart
2021-10-13  7:30   ` Hans Verkuil
2021-10-05  8:57 ` [PATCH v9 34/36] media: subdev: add v4l2_subdev_get_fmt() helper function Tomi Valkeinen
2021-10-13  7:32   ` Hans Verkuil
2021-10-05  8:57 ` [PATCH v9 35/36] media: subdev: add v4l2_subdev_set_routing_with_fmt() helper Tomi Valkeinen
2021-10-13  7:32   ` Hans Verkuil
2021-10-05  8:57 ` [PATCH v9 36/36] media: subdev: add v4l2_routing_simple_verify() helper Tomi Valkeinen
2021-10-10  1:23   ` Laurent Pinchart
2021-10-11  7:25     ` Tomi Valkeinen
2021-10-11 21:08       ` Laurent Pinchart
2021-10-13  7:34   ` Hans Verkuil
2021-10-05  9:08 ` [PATCH v9 00/36] v4l: subdev internal routing and streams Tomi Valkeinen
2021-10-11 15:29 ` Hans Verkuil
2021-10-26 11:54   ` Tomi Valkeinen
2021-10-26 12:32     ` Jacopo Mondi
2021-10-26 12:40       ` Tomi Valkeinen

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=d89afbd7-2f12-5231-a227-853f7e975e8e@xs4all.nl \
    --to=hverkuil-cisco@xs4all.nl \
    --cc=jacopo+renesas@jmondi.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=niklas.soderlund+renesas@ragnatech.se \
    --cc=p.yadav@ti.com \
    --cc=sakari.ailus@linux.intel.com \
    --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 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.