All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: linux-media@vger.kernel.org, laurent.pinchart@ideasonboard.com,
	tomi.valkeinen@ideasonboard.com, bingbu.cao@intel.com,
	hongju.wang@intel.com
Subject: Re: [RFC 0/7] Generic line based metadata support, internal pads
Date: Fri, 9 Jun 2023 14:59:20 +0100	[thread overview]
Message-ID: <CAPY8ntAQxojXVgaD9w8O41QEt6ZBdCB+dxNnnYwimnv6GMjgDQ@mail.gmail.com> (raw)
In-Reply-To: <20230505215257.60704-1-sakari.ailus@linux.intel.com>

Hi Sakari

Sorry to be late to the party.

On Fri, 5 May 2023 at 22:53, Sakari Ailus <sakari.ailus@linux.intel.com> wrote:
>
> Hi folks,
>
> Here are a few patches to add support generic, line based metadata as well
> as internal source pads. While the amount of code is not very large, to
> the contrary it is quite small actually IMO, I presume what this is about
> and why it is being proposed requires some explaining.
>
> Metadata mbus codes and formats have existed for some time in V4L2. They
> however have been only used by drivers that produce the data itself and
> effectively this metadata has always been statistics of some sort (at
> least when it comes to ISPs). What is different here is that we intend to
> add support for metadata originating from camera sensors.
>
> Camera sensors produce different kinds of metadata, embedded data (usually
> register address--value pairs used to capture the frame, in a more or less
> sensor specific format), histograms (in a very sensor specific format),
> dark pixels etc. The number of these formats is probably going to be about
> as large as image data formats if not larger, as the image data formats
> are much better standardised but a smaller subset of them will be
> supported by V4L2, at least initially but possibly much more in the long
> run.
>
> Having this many device specific formats would be a major problem for all
> the other drivers along that pipeline (not to mention the users of those
> drivers), including bridge (e.g. CSI-2 to parallel) but especially CSI-2
> receiver drivers that have DMA: the poor driver developer would not only
> need to know camera sensor specific formats but to choose the specific
> packing of that format suitable for the DMA used by the hardware. It is
> unlikely many of these would ever get tested while being present on the
> driver API. Also adding new sensors with new embedded data formats would
> involve updating all bridge and CSI-2 receiver drivers. I don't expect
> this to be a workable approach.
>
> Instead what I'm proposing is to use specific metadata formats on the
> sensor devices only, on internal pads (more about those soon) of the
> sensors, only visible in the UAPI, and then generic mbus formats along the
> pipeline and finally generic V4L2 metadata formats on the DMAs (specific
> to bit depth and packing). This would unsnarl the two, defining what data
> there is (specific mbus code) and how that is transported and packed
> (generic mbus codes and V4L2 formats).
>
> The user space would be required to "know" the path of that data from the
> sensor's internal pad to the V4L2 video node. I do not see this as these
> devices require at least some knowledge of the pipeline, i.e. hardware at
> hand. Separating what the data means and how it is packed may even be
> beneficial: it allows separating code that interprets the data (sensor
> internal mbus code) from the code that accesses it (packing).
>
> These formats are in practice line based, meaning that there may be
> padding at the end of the line, depending on the bus as well as the DMA.
> If non-line based formats are needed, it is always possible to set the
> "height" field to 1.
>
> The internal (source) pads are an alternative to source routes [1]. The
> source routes were not universally liked and I do have to say I like
> re-using existing interface concepts (pads and everything you can do with
> pads, including access format, selections etc.) wherever it makes sense,
> instead of duplicating functionality.
>
> Effectively internal source pads behave mostly just like sink pads, but
> they describe a flow of data that originates from a sub-device instead of
> arriving to a sub-device. The SUBDEV_S_ROUTING IOCTLs are used to enable
> and disable routes from internal source pads to sub-device's source pads.
> The subdev format IOCTLs are usable, too, so one can find which subdev
> format is available on given internal source pad.

Just to confirm my own understanding, the muxed streams API currently
copes with situations such as the FPD-Link devices combining a single
stream from each of a number of subdevs into one multiplexed stream
using virtual channels, but it doesn't handle multiple data types from
the same subdev. You're addressing that omission.

All seems reasonable.

One detail that I haven't seen covered and think ought to be clarified.
For raw sensors where you have image data and metadata, in my
experience the line width of that metadata and the packing format
(8/10/12/14/16/20/24 bit) are all dictated by the image data
configuration. You can't have eg 640 pixel wide _SBGGR10_1X10 image
data and 320 pixel wide _META_1X8_8 metadata. (it has to be 640 pixel
wide _META_1X10_10)

Which layer would be responsible for validating the configuration, and when?
a) The driver validates in set_stream, and fails if mismatched. That
potentially results in lots of duplication between drivers.
b) set_pad_format on the image pad updates the formats and widths of
the metadata pads automatically. Is there a way of notifying clients
that the formats on potentially unrelated pads has changed, or is it
something that just gets documented?
c) something else.

Either is workable, but IMHO it needs to be specified as to which is
the expected behaviour.

Thanks
  Dave

> This set depends on these patches:
>
> <URL:https://lore.kernel.org/linux-media/20230505205416.55002-1-sakari.ailus@linux.intel.com/T/#t>
>
> I've also pushed these here and I'll keep updating the branch:
>
> <URL:https://git.linuxtv.org/sailus/media_tree.git/log/?h=metadata>
>
> Questions and comments are most welcome.
>
>
> [1] <URL:https://lore.kernel.org/linux-media/20220831141357.1396081-20-tomi.valkeinen@ideasonboard.com/>
>
> Sakari Ailus (7):
>   media: mc: Add INTERNAL_SOURCE pad type flag
>   media: v4l: subdev: Support INTERNAL_SOURCE pads in routing IOCTLs
>   media: uapi: v4l: Document source routes
>   media: mc: Check pad flag validity
>   media: uapi: Add generic serial metadata mbus formats
>   media: uapi: Add generic 8-bit metadata format definitions
>   media: v4l: Support line-based metadata capture
>
>  .../media/mediactl/media-types.rst            |   7 +
>  .../userspace-api/media/v4l/dev-meta.rst      |  15 +
>  .../userspace-api/media/v4l/dev-subdev.rst    |  18 +
>  .../userspace-api/media/v4l/meta-formats.rst  |   1 +
>  .../media/v4l/metafmt-generic.rst             | 317 ++++++++++++++++++
>  .../media/v4l/subdev-formats.rst              | 257 ++++++++++++++
>  .../media/v4l/vidioc-enum-fmt.rst             |   7 +
>  .../media/v4l/vidioc-subdev-g-routing.rst     |   5 +
>  drivers/media/mc/mc-entity.c                  |  20 +-
>  drivers/media/v4l2-core/v4l2-ioctl.c          |   8 +
>  drivers/media/v4l2-core/v4l2-subdev.c         |   6 +-
>  include/uapi/linux/media-bus-format.h         |   9 +
>  include/uapi/linux/media.h                    |   1 +
>  include/uapi/linux/v4l2-subdev.h              |   6 +-
>  include/uapi/linux/videodev2.h                |  19 ++
>  15 files changed, 691 insertions(+), 5 deletions(-)
>  create mode 100644 Documentation/userspace-api/media/v4l/metafmt-generic.rst
>
> --
> 2.30.2
>

  parent reply	other threads:[~2023-06-09 13:59 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-05 21:52 [RFC 0/7] Generic line based metadata support, internal pads Sakari Ailus
2023-05-05 21:52 ` [RFC 1/7] media: mc: Add INTERNAL_SOURCE pad type flag Sakari Ailus
2023-05-08  9:52   ` Tomi Valkeinen
2023-05-08 12:04     ` Sakari Ailus
2023-05-08 12:07       ` Tomi Valkeinen
2023-05-08 12:28         ` Sakari Ailus
2023-06-02  9:18   ` Laurent Pinchart
2023-06-02 15:05     ` Sakari Ailus
2023-06-08  7:59   ` Hans Verkuil
2023-06-09 12:44     ` Sakari Ailus
2023-05-05 21:52 ` [RFC 2/7] media: v4l: subdev: Support INTERNAL_SOURCE pads in routing IOCTLs Sakari Ailus
2023-05-08 10:14   ` Tomi Valkeinen
2023-05-08 12:24     ` Sakari Ailus
2023-06-02  9:44       ` Laurent Pinchart
2023-06-02  9:46         ` Laurent Pinchart
2023-06-02 13:10           ` Sakari Ailus
2023-06-04 14:26             ` Laurent Pinchart
2023-06-05  8:06               ` Sakari Ailus
2023-06-05  8:23                 ` Laurent Pinchart
2023-06-08  8:06   ` Hans Verkuil
2023-05-05 21:52 ` [RFC 3/7] media: uapi: v4l: Document source routes Sakari Ailus
2023-05-08 10:33   ` Tomi Valkeinen
2023-05-08 16:26     ` Sakari Ailus
2023-05-08 16:35       ` Tomi Valkeinen
2023-05-08 17:41         ` Sakari Ailus
2023-06-02  9:56           ` Laurent Pinchart
2023-06-02  9:56         ` Laurent Pinchart
2023-06-09 12:55           ` Sakari Ailus
2023-06-08  8:20   ` Hans Verkuil
2023-05-05 21:52 ` [RFC 4/7] media: mc: Check pad flag validity Sakari Ailus
2023-06-02  9:58   ` Laurent Pinchart
2023-06-09 14:41     ` Sakari Ailus
2023-05-05 21:52 ` [RFC 5/7] media: uapi: Add generic serial metadata mbus formats Sakari Ailus
2023-06-02 10:36   ` Laurent Pinchart
2023-06-09 14:45     ` Sakari Ailus
2023-06-08  8:35   ` Hans Verkuil
2023-06-09 13:34     ` Sakari Ailus
2023-06-08  8:46   ` Hans Verkuil
2023-06-09 13:38     ` Sakari Ailus
2023-05-05 21:52 ` [RFC 6/7] media: uapi: Add generic 8-bit metadata format definitions Sakari Ailus
2023-06-08  8:54   ` Hans Verkuil
2023-06-09 14:27     ` Sakari Ailus
2023-05-05 21:52 ` [RFC 7/7] media: v4l: Support line-based metadata capture Sakari Ailus
2023-06-02 10:50   ` Laurent Pinchart
2023-06-09 13:46     ` Sakari Ailus
2023-06-02  7:54 ` [RFC 0/7] Generic line based metadata support, internal pads Naushir Patuck
2023-06-02  8:46   ` Sakari Ailus
2023-06-02  9:35     ` Naushir Patuck
2023-06-02 12:05       ` Sakari Ailus
2023-06-02  9:12   ` Laurent Pinchart
2023-06-02  9:43     ` Naushir Patuck
2023-06-09 13:20     ` Sakari Ailus
2023-06-09 13:59 ` Dave Stevenson [this message]
2023-06-09 14:41   ` Sakari Ailus
2023-08-03 22:36     ` 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=CAPY8ntAQxojXVgaD9w8O41QEt6ZBdCB+dxNnnYwimnv6GMjgDQ@mail.gmail.com \
    --to=dave.stevenson@raspberrypi.com \
    --cc=bingbu.cao@intel.com \
    --cc=hongju.wang@intel.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --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.