* [PATCH v13 00/72] Generic line based metadata support, internal pads
@ 2026-11-18 13:27 Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 01/73] media: uapi: Bump the STREAMS bit a little Sakari Ailus
` (72 more replies)
0 siblings, 73 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Hi folks,
Here are a few patches to add support generic, line based metadata as well
as internal pads, sub-device configuration models (including the common
raw sensor model) and a streaming control helper for MC-enabled drivers.
The amount of code and documentation is in this version is no longer small
but it still 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 controls to convey the colour pattern
and metadata layout. Generic mbus codes convey the width of the data
transferred on serial buses (for now, corresponding parallel formats may
be added when needed) but the control is only relevant on the UAPI, not
between drivers. This approach unsnarls the layout of the data and its
colour components, defining what data there is (specific mbus code) and
how that is transported and packed (generic mbus codes and V4L2 formats)
separately.
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.
Internal sink pads behave mostly like regular 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 sink 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 sink pad.
I've tested the patches using the IPU6 / ov2740 pair of drivers as well as
Unicam / imx219.
Questions and comments are most welcome.
Preliminary media-ctl and yavta patches can be found here:
<URL:https://git.retiisi.eu/?p=~sailus/yavta.git;a=shortlog;h=refs/heads/metadata>
<URL:https://git.retiisi.eu/?p=~sailus/v4l-utils.git;a=shortlog;h=refs/heads/metadata>
The patches are on my metadata branch
<URL:https://git.linuxtv.org/sailus/media_tree.git/log/>.
The documentation build output can be found here:
<URL:https://www.retiisi.eu/~sailus/v4l2/tmp/metadata/>.
since v12:
- Merged ipu6 patches.
- Merged client_info changes.
- Improve internal sink pad documentation.
- Add subdev-config-model rst file to index directly.
- Improve HBLANK and VBLANK control documentation.
- Use hexadecimal numbers for CFA pattern numbers and add a MONO pattern.
- Fix binning integer menu value example.
- Add unpacked raw pixelformats for 10, 12 and 14 bpp.
- Document the compose rectangle isn't modifiable in Common Raw Sensor
Model.
- Fix selection rectangle values for imx219.
- Do not maintain streaming state locally in imx219.
- Dropped a local handler for LLP and FLL controls in imx219; use
generic v4l2_sensor_fll_llp_set() instead (moved from v4l2-mc.c to
v4l2-common.c).
- Grab binning control during streaming in imx219.
- Use factual (i.e. non-register) values for FLL, LLP and PIXEL_RATE.
- Call client_caps caps instead in struct v4l2_subdev_client_info.
- Drop the VALIDATE_LATE MC link flag.
- Drop v4l2_subdev_call_ci_state_try() and
v4l2_subdev_call_ci_state_active(); instead move the code in drivers
(one for each) and so avoid interesting-looking macros in v4l2-subdev.h.
- Include Frank's patch for media bus format info.
- Check client caps when accessing internal pads.
- Move out the patches to obtain frame descriptors. They can wait.
- Use __u* types in macros working with binning factors in
v4l2-controls.h.
since v11:
- Add a note (patch "media: Documentation: Add a note on Bayer raw mbus
codes") to document the use of new generic raw formats
- Link to the LINK_FREQ control from the tx-rx driver documentation.
- Refer to V4L2 fwnode endpoint parsing functions in tx-rx driver
documentation.
- Rename V4L2_CID_COLOR_PATTERN as V4L2_CID_CFA_PATTERN. This matches
better with the established use of the terms (CFA in particular).
- Improve and fix references in new camera sensor driver documentation.
- Improve and fix language regarding embedded data in camera sensor driver
documentation.
- Improve language in routing documentation in dev-subdev.rst.
- Document the IMMUTABLE route flag in routing documentation.
- Add a note in routing documentation that a sub-device may have either
user-created or static routes.
- Also use IMMUTABLE and STATIC flags in internal pads example.
- Elaborate image and metadata stream dependencies in imx219
documentation.
- Don't mention selections in sub-device configuration documentation for
internal pads.
- The source format of the camera sensor is configured using the source
pad; document this in the Common raw sensor model.
- Move binning factors from camera controls class to image source class
where they belong.
- Improve description of colour filter array patterns.
- Add that CFA_PATTERN_FLIP is a read-only control.
- Add references to metadata layouts into the metadata layout control.
- Refer to V4L2_METADATA_LAYOUT_OV2740 in ov2740 documentation (not
V4L2_METADATA_LAYOUT_CCS).
- Note that ov2740 embedded data dpc correction threshold uses bits 9--2.
- Postpone adding 16 and higher bpp generic raw formats until we have a
user (split into separate patches later in the set).
- Generic 16- and 24-bit format isn't really CSI-2 packed (but appears to
be big endian) so rename the two accordingly.
- Small but numerous fixes in generic raw image data format documentation.
- Improve documentation of different parts of the pixel array and relation
of that to the UAPI under common raw sensor model documentation.
- Reword documentation of the compose rectangle in common raw sensor
model documentation.
- Add crop bounds rectangle to the common raw sensor model to convey the
bounds of the pixel array. This allows using negative numbers as well.
- Document that the sensor's output format is configured on the source
pad.
- Add references to relevant controls in generic raw format documentation.
- Introduce V4L2_SUBDEV_CLIENT_CAP_COMMON_RAW_SENSOR sub-device capability
bit. This bit is set by the userspace to signal support for the common
raw sensor model and allows supporting common raw sensor model also in
existing drivers.
- Introduce the static route flag to indicate a route is always present.
- Add new struct v4l2_subdev_client_info as argument to certain pad
operations in order to support passing information on client
capabilities to sub-device drivers.
- Added common raw format support to the CCS driver.
- Drop leftover mutex_unlock() in ccs_set_format().
- Fully rely on sub-device state locking in the CCS driver.
- Make METADATA_LAYOUT control read-only.
- Add new controls FRAME_LENGTH_LINES and LINE_LENGTH_PIXELS.
- Don't handle the CFA pattern control in set_ctrl() -- ops is NULL.
- Support the common raw sensor model in imx219:
- Add support for BINNING_FACTORS, FRAME_LENGTH_LINES and
LINE_LENGTH_PIXELS controls.
- Support both Common Raw Sensor Model and old behaviour,
depending on V4L2_SUBDEV_CLIENT_CAP_COMMON_RAW_SENSOR bit. The
internal state is the same in both cases but the view to the
state and UAPI behaviour differs based on that bit.
- Keep track of enabled streams; any started stream starts
streaming on the sensor.
- Enumerate only generic raw mbus code on the internal image
source pad.
- Support set_selection for setting analogue crop area.
- Remove redundant comments in imx219_probe().
- Ipu6 driver changes:
- Lots of cleanups.
- Only start streaming on the upstream sub-device when all queues
in the pipeline have been set streaming.
- Use VALIDATE_LATE link flag for links to video nodes.
- Move streaming control to the CSI-2 driver. Streaming now starts
on the upstream sub-device once all participating video nodes
have been set streaming.
- Support generic raw formats in the unicam driver.
- Document that common raw sensor model requires implementing
FRAME_LENGTH_LINES and LINE_LENGTH_PIXELS controls.
since v10:
- Merge a few patches that aren't strictly related to metadata, mostly
documentation cleanups and improvements.
- Add V4L2_SUBDEV_ROUTE_FL_STATIC, to indicate a route is mutable but
hardware specific so it remains even if disabled. An example of this are
embedded data routes on camera sensors. IMMUTABLE implies STATIC.
- Postpone adding formats higher than 14 bpp and remove reference to
"little endian" for the CSI-2 packed formats. It's not entirely clear
how the data on higher bit depth formats are laid out in memory. The
documentation suggests these are in big endian format but that would be
impractical for CPU processing.
- Add references to controls in flipping documentation in
subdev-formats.rst.
- Add -ENXIO return code for device specific invalid routing configuration
and clarify routing error conditions for -EINVAL.
- Add braces for the case in imx219_enum_mbus_code() to make Clang happy.
- Rebase off of mc-streamon set (to my cleanup branch). The problem of
when to stream on and off still needs to be addressed but I'm looking
into a different, better integrated approach right now.
- Rename generic metadata formats at bit depths 16 and 24 as it seems
these have more generic packing than CSI-2.
since v9:
- Introduce controls for sub-device configuration models (separately
discussed in <20250203085853.1361401-1-sakari.ailus@linux.intel.com>),
with the following changes:
- Fix spelling and improve wording in documentation based on
comments.
- Use US English spelling for V4L2 control names.
- Allow for more than one internal pad for pixel data.
- Introduce (or change a bit) generic mbus codes for raw pixel
data and metadata.
- Introduce generic and CSI-2 specifc V4L2 pixelformats for image
data and metadata. Also 16- and 24-bit formats are generic, not
specific to CSI-2.
- Introduce new controls to convey metadata layout on bus and by
extension, in memory, instead of relying on separate metadata
mbus codes, aligning with pixel data.
- Use generic metadata codes in the example.
- Include imx219 embedded data support patches from Laurent, with
modifications.
- Patches to IPU6 ISYS driver needed to support metadata capture. Luma
formats added, too.
- Improved debug prints in v4l2_subdev_{en,dis}able_streams().
- Added a patch to make media_entity_to_video_device() NULL-safe.
- Drop _media-glossary-data-unit reference, use :term: to reference it.
- Include a patch to set IPU6 ISYS minimum height to 1.
- Patch 'media: uapi: Document which mbus format fields are valid for
metadata' already merged.
- Patch 'media: uapi: v4l: Add generic 8-bit metadata format definitions'
already merged.
- Patch 'media: v4l: Support line-based metadata capture' already merged.
- Patch 'media: Documentation: Document S_ROUTING behaviour' already merged.
- Patch 'media: v4l: subdev: Add len_routes field to struct
v4l2_subdev_routing' already merged.
since v8:
- Move the patch adding internal pad flag past the routing API reworks, as
well as a few other patches, in order to separate the patches to those
that could still be merged for v6.10 (routing changes) and those that
couldn't (sensor API related). The patch on the edge is "media: uapi:
v4l: subdev: Enable streams API".
- Include Laurent's two patches to address crop API issues wrt. streams.
- Add two patches to prepare for CCS driver rework (media: ccs: Move
ccs_pm_get_init function up and media: ccs: Rename out label of
ccs_start_streaming).
- Address issues in the ov2740 driver patches (as well as the driver
itself), 4 more patches towards the end of the set.
- Improved generic metadata format names, align with other existing
formats.
- Improved ov2740 embedded data documentation.
- Reworked streams and camera sensor documentation based on Laurent's
comments mainly. In particular, the contradictory concept of internal
source pads no longer should exist in the patches.
- Fixed pad numbering in the CCS example.
- Fixed S_ROUTING behaviour when len_routes is too small and when
S_ROUTING isn't implemented by the driver.
- Reorder sections in meta-formats.rst alphabetically.
- Add a note per struct fields that certain struct v4l2_subdev_format are
zero for metadata mbus codes.
- CCS driver patch cleanups.
- CCS driver metadata width fix for space-efficient embedded data at 16
bpp and over.
- Postpone CCS frame descriptor quirk for now.
- Use MIPI_CSI2_DT_USER_DEFINED(0) instead of a numerical value for
compressed data datatype.
since v7:
- Add embedded data support for the ov2740 driver.
- Add three patches on top, to add an IMMUTABLE flag to source streams
when they cannot be disabled.
- Improved documentation of len_routes and num_routes arguments of
[GS]_ROUTING.
- Remove one inclusion of twice-included media/v4l2-fwnode.h in
drivers/media/i2c/ccs/ccs-core.c .
- Add missing forward declaration of ccs_internal_ops in
drivers/media/i2c/ccs/ccs-core.c .
since v6:
- Improve embedded data UAPI documentation on camera sensors.
- Improve wording of stream glossary entry.
- Improve internal pad flag documentation.
- Fix definition of "data unit" and remove an extra "only" in INTERNAL pad
flag description (1st patch).
- Use IMX219 driver in examples consistently.
- Remove the CSI-2 to parallel bridge from the example to simplify the
example.
- Minor rewording of some parts of the routing examples.
- Rebase on unified sub-device state information access functions:
<URL:https://lore.kernel.org/linux-media/20231027095913.1010187-1-sakari.ailus@linux.intel.com/T/#t>
- In CCS driver, do not maintain current active configuration in driver's
device context struct (apart from mbus codes). Rely on sub-device state
locking and clean up the code. (Multiple patches towards the end of the
set.)
- Arrange the CCS patches early in the set towards the end of the set.
- Move the patch enabling streams API to the end of the set.
- Rework IOCTL argument copying condition for [GS]_ROUTING).
- Handle copying back routes in S_ROUTING, do not rely on G_ROUTING
IOCTL implementation.
- Rebase on metadata preparation patchset v6:
<URL:https://lore.kernel.org/linux-media/20231106121805.1266696-1-sakari.ailus@linux.intel.com/T/#t>.
since v5:
- Rebase on new set of preparation patches.
- Switch CCS driver from s_stream to enable_streams/disable_streams. Keep
streaming state information --- the sensor remains in streaming state if
any of the streams is enabled.
- Fix setting mbus code on embedded data in get_frame_desc() op in the CCS
driver.
since v4:
- Add a patch to acquire two sub-device states that may use the same lock.
- Add a patch for CCS driver to remove ccs_get_crop_compose() helper.
- Add a patch for CCS driver moving acquiring and releasing the mutex to
the s_stream callback.
- Add a patch for CCS driver to rely on sub-device state locking using a
single driver-provided lock.
- Fixed calculating minimum number of routes in copying the routes
(thanks, Laurent).
- Moved a label in S_ROUTING handling to make Clang happy (hopefully).
- Fixed setting emb_data_ctrl register for CCS embedded data support.
- Rebase on Laurent's cleanup patches.
- Wrap a few long lines.
- Write in embedded data documentation sensor drivers generally don't
allow configuring it.
since v3:
- Separate preparation patches from this set.
- Add a definition for "Data unit", a pixel that is not image data and use
it instead in format documentation.
- Fix more numbered lists in dev-subdev.rst.
- Remove a redundant definition for V4L2_META_FMT_GENERIC_CSI2_2_24 ---
V4L2_META_FMT_GENERIC_CSI2_12 can be used instead.
- Use "X" instead of "p" to denote padding in format documentation.
- Use IMX219 in examples instead of CCS.
- Document that the generic V4L2 CSI-2 metadata formats use padding
defined in CSI-2 spec and packing defined in CCS spec.
- Add patches to align [GS]_ROUTING behaviour with V4L2. This means mainly
returning configured routes as part of S_ROUTING as well. "len_routes"
field is added to denote the length of the array and having more routes
than fits in the array is no longer an error. Also added more reserved
fields.
- Added trivial support for S_ROUTING (via G_ROUTING implementation) for
use in drivers with static-only routes.
- Added helper functions to obtain mbus format as well as crop and compose
rectangles that are streams-independent.
- Added a patch to define generic CSI-2 long packet types.
- Removed MEDIA_BUS_FMT_IS_META() macro. It didn't seem useful in the end.
- Use a single CCS embedded data format. The bit depth can be selected
using the meta stream on the source pad.
- Fix mbus code numbers (there were holes due to removed redundant
formats).
- Fix generic mbus code documentation (byte was being used instead of
bit).
- Fix spelling of "length".
- Added a patch to remove v4l2_subdev_enable_streams_api that disables
streams API. This should be merged once libcamera support for streams
works nicely.
- Don't use strings in printing frame descriptor flags.
- Warn on string truncation in printing frame descriptor.
since v2:
- Add a better example, with formats.
- Add CCS static data media bus codes.
- Added an example demonstrating the use of internal pads. --- Is the
level of detail enough for the purpose?
- Improved documentation.
- Added a macro to tell whether a format is a metadata format.
(Documentation could be added.)
- A small ReST syntax fix in the same section.
- Drop leftovers of a patch checking for the INTERNAL_SOURCE flag.
since v1:
- Make the new pad flag just "INTERNAL", requiring either SINK or SOURCE
pad flag to accompany it. Removed the union in struct v4l2_subdev_route.
- Add the term "stream" to MC glossary.
- Improved and fixed documentation (according to comments).
- Note these formats are little endian.
- Remove 1X8 from the names of the mbus codes. These formats have generally
8 bits per pixel.
- Fix mbus code numbering (had holes in RFC).
- Add new metadata fields to debug prints.
- Fix a minor documentation build issue.
Frank Li (1):
media: v4l2-common: Add helper function
media_bus_fmt_to_csi2_(bpp|dt)()
Laurent Pinchart (4):
media: imx219: Add image stream
media: imx219: Report internal routes to userspace
media: imx219: Report streams using frame descriptors
media: imx219: Add embedded data support
Sakari Ailus (68):
media: uapi: Bump the STREAMS bit a little
Revert "media: mc: Keep INTERNAL pad flags just for the kernel, for
now"
media: uapi: Add generic CSI-2 raw pixelformats
media: uapi: Add new media bus codes for generic raw formats
media: uapi: Add V4L2_CID_CONFIG_MODEL control
media: uapi: Add V4L2_CID_CFA_PATTERN for describing color patterns
media: uapi: Add monochromatic CFA pattern
media: Documentation: Reference CFA pattern control in pixelformat
docs
media: Documentation: Reference CFA_PATTERN control in raw mbus docs
media: v4l: uapi: Add a control for color pattern flipping effect
media: Documentation: Reference flipping controls in raw format docs
media: Documentation: Document raw mbus codes and CFA for cameras
media: uapi: Add V4L2_CID_METADATA_LAYOUT control
media: Documentation: Refer to metadata layout in metadata
documentation
media: Documentation: v4l: Document internal sink pads
media: Documentation: Document embedded data guidelines for camera
sensors
media: uapi: Correct generic CSI-2 metadata format 4cc
Revert "media: uapi: v4l: Don't expose generic metadata formats to
userspace"
media: v4l: Add V4L2_SUBDEV_ROUTE_FL_IMMUTABLE sub-device routing flag
media: v4l: Add V4L2_SUBDEV_ROUTE_FL_STATIC sub-device routing flag
media: Documentation: There are either immutable or mutable routes
media: Documentation: Document IMMUTABLE and STATIC route flags
media: Documentation: Add subdev configuration models, raw sensor
model
media: v4l2-subdev: Prevent accessing internal pads without STREAMS
cap
media: subdev: Make get_fmt on INTERNAL pads without STREAMS an error
media: Documentation: Add scaling and post-scaler crop for common raw
media: uapi: Add MIPI CCS configuration model
media: uapi: Add V4L2_SUBDEV_CLIENT_CAP_COMMON_RAW_SENSOR
media: uapi: Add V4L2_CID_BINNING_FACTORS control for binning
configuration
media: uapi: Add controls for sub-sampling configuration
media: uapi: Add new controls for camera sensor FLL and LLP
media: v4l2-common: Add v4l2_sensor_fll_llp_set()
media: Documentation: Add binning and sub-sampling controls
media: v4l2-subdev: Set STATIC route flag if IMMUTABLE route flag is
set
media: uapi: v4l: subdev: Enable streams API
media: uapi: Add binning factor helper macros
media: Documentation: Document frame controls for common raw sensor
model
media: v4l2-ctrl: Improve v4l2_ctrl_g_ctrl{,int64} documentation
media: Documentation: Add sub-device internal pads example
media: Documentation: Document streaming behaviour for common raw
cameras
media: Documentation: Add a note on Bayer raw mbus codes
media: uapi: Add generic raw pixelformats for 10, 12 and 14 bits
media: uapi: Add more media bus codes for generic raw formats
media: uapi: ccs: Add metadata layout for MIPI CCS embedded data
media: Documentation: Document non-CCS use of CCS embedded data layout
media: ccs: Add support for generic raw mbus codes
media: ccs: Add support for embedded data stream
media: Documentation: ccs: Document routing
media: ccs: Add IMMUTABLE and STATIC route flags
media: uapi: Add metadata layout for ov2740 embedded data
media: ov2740: Add support for embedded data
media: ov2740: Add support for generic raw formats
media: ov2740: Add metadata layout control
media: ov2740: Add support for G_SELECTION IOCTL
media: ov2740: Add support for FLL and LLP controls
media: ov2740: Signal common raw sensor model support
media: ov2740: Add IMMUTABLE and STATIC route flags
media: imx219: Add internal image pad for Common Raw Sensor Model
media: imx219: Add support for generic raw formats
media: imx219: Add V4L2_CID_BINNING_FACTORS
media: imx219: Allow configuring cropping and binning through CRSM
media: imx219: Support LINE_LENGTH_PIXELS and FRAME_LENGTH_LINES
controls
media: bcm2835-unicam: Support generic raw formats
media: ipu6: Add support for raw CFA-agnostic formats
media: ipu6: Add support for generic unpacked pixel and metadata
formats
Documentation: media: Reword blanking control documentation
media: uapi: Add generic raw pixelformat for 16 bpp
media: uapi: Add generic CSI-2 raw pixelformats for 16, 20, 24 and 28
bpp
.../driver-api/media/camera-sensor.rst | 11 +
.../media/drivers/camera-sensor.rst | 79 ++
.../userspace-api/media/drivers/ccs.rst | 43 +-
.../media/v4l/common-raw-sensor.dia | 442 ++++++++++
.../media/v4l/common-raw-sensor.svg | 134 ++++
.../userspace-api/media/v4l/dev-subdev.rst | 174 +++-
.../userspace-api/media/v4l/devices.rst | 1 +
.../media/v4l/ext-ctrls-image-process.rst | 6 +
.../media/v4l/ext-ctrls-image-source.rst | 158 +++-
.../userspace-api/media/v4l/meta-formats.rst | 1 +
.../media/v4l/metadata-layouts.rst | 114 +++
.../media/v4l/metafmt-generic.rst | 48 +-
.../media/v4l/pixfmt-raw-generic.rst | 500 ++++++++++++
.../userspace-api/media/v4l/pixfmt.rst | 1 +
.../media/v4l/subdev-config-model.rst | 299 +++++++
.../media/v4l/subdev-formats.rst | 48 ++
.../media/v4l/vidioc-subdev-g-client-cap.rst | 6 +
.../media/v4l/vidioc-subdev-g-routing.rst | 9 +
drivers/media/i2c/ccs/ccs-core.c | 398 ++++++++-
drivers/media/i2c/ccs/ccs.h | 17 +-
drivers/media/i2c/imx219.c | 755 +++++++++++++++---
drivers/media/i2c/ov2740.c | 371 +++++++--
drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c | 3 +
.../media/pci/intel/ipu6/ipu6-isys-subdev.c | 3 +
.../media/pci/intel/ipu6/ipu6-isys-video.c | 18 +-
.../media/platform/broadcom/bcm2835-unicam.c | 27 +
drivers/media/v4l2-core/v4l2-common.c | 253 ++++++
drivers/media/v4l2-core/v4l2-ctrls-defs.c | 21 +
drivers/media/v4l2-core/v4l2-ioctl.c | 19 +-
drivers/media/v4l2-core/v4l2-subdev.c | 85 +-
include/media/mipi-csi2.h | 24 +
include/media/v4l2-common.h | 31 +
include/media/v4l2-ctrls.h | 4 +
include/media/v4l2-mc.h | 1 +
include/uapi/linux/media-bus-format.h | 10 +
include/uapi/linux/media.h | 6 -
include/uapi/linux/v4l2-controls.h | 34 +
include/uapi/linux/v4l2-subdev.h | 20 +-
include/uapi/linux/videodev2.h | 27 +-
39 files changed, 3868 insertions(+), 333 deletions(-)
create mode 100644 Documentation/userspace-api/media/v4l/common-raw-sensor.dia
create mode 100644 Documentation/userspace-api/media/v4l/common-raw-sensor.svg
create mode 100644 Documentation/userspace-api/media/v4l/metadata-layouts.rst
create mode 100644 Documentation/userspace-api/media/v4l/pixfmt-raw-generic.rst
create mode 100644 Documentation/userspace-api/media/v4l/subdev-config-model.rst
base-commit: decc53804e94320af09c3df13d1eee66caa9c25f
--
2.47.3
^ permalink raw reply [flat|nested] 74+ messages in thread
* [PATCH v13 01/73] media: uapi: Bump the STREAMS bit a little
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 02/73] Revert "media: mc: Keep INTERNAL pad flags just for the kernel, for now" Sakari Ailus
` (71 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Bump the V4L2_SUBDEV_CAP_STREAMS by one bit up, in order to avoid
confusing libcamera with streams that has moved forward from the original
libcamera implementation. The bit can presumably be taken into use but
only after the other free bits.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
include/uapi/linux/v4l2-subdev.h | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/include/uapi/linux/v4l2-subdev.h b/include/uapi/linux/v4l2-subdev.h
index 2347e266cf75..6160c3e21436 100644
--- a/include/uapi/linux/v4l2-subdev.h
+++ b/include/uapi/linux/v4l2-subdev.h
@@ -196,8 +196,11 @@ struct v4l2_subdev_capability {
/* The v4l2 sub-device video device node is registered in read-only mode. */
#define V4L2_SUBDEV_CAP_RO_SUBDEV 0x00000001
+/* Reserved, old STREAMS bit libcamera used before API stabilisation. */
+/* #define V4L2_SUBDEV_CAP_STREAMS_PRELIMINARY 0x00000002 */
+
/* The v4l2 sub-device supports routing and multiplexed streams. */
-#define V4L2_SUBDEV_CAP_STREAMS 0x00000002
+#define V4L2_SUBDEV_CAP_STREAMS 0x00000004
/*
* Is the route active? An active route will start when streaming is enabled
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 02/73] Revert "media: mc: Keep INTERNAL pad flags just for the kernel, for now"
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 01/73] media: uapi: Bump the STREAMS bit a little Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 03/73] media: uapi: Add generic CSI-2 raw pixelformats Sakari Ailus
` (70 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
This reverts commit 77a10651b2f23b6a56d27570fa9a870f8e977125.
The INTERNAL pads can now be made visible to the userspace so revert the
patch that made them kernel-only.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
include/uapi/linux/media.h | 6 ------
1 file changed, 6 deletions(-)
diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
index 2da6ae4da003..80cfd12a43fc 100644
--- a/include/uapi/linux/media.h
+++ b/include/uapi/linux/media.h
@@ -208,13 +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)
-#if defined(__KERNEL__)
-/*
- * Forgo INTERNAL pads until proper documentation and v4l2-compliance testing
- * are merged.
- */
#define MEDIA_PAD_FL_INTERNAL (1U << 3)
-#endif /* __KERNEL__ */
struct media_pad_desc {
__u32 entity; /* entity ID */
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 03/73] media: uapi: Add generic CSI-2 raw pixelformats
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 01/73] media: uapi: Bump the STREAMS bit a little Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 02/73] Revert "media: mc: Keep INTERNAL pad flags just for the kernel, for now" Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 04/73] media: uapi: Add new media bus codes for generic raw formats Sakari Ailus
` (69 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Add generic raw pixelformats for bit depths 8, 10, 12 and 14. These
formats are CSI-2 packed, apart from the 8-bit format.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
.../media/v4l/pixfmt-raw-generic.rst | 175 ++++++++++++++++++
.../userspace-api/media/v4l/pixfmt.rst | 1 +
drivers/media/v4l2-core/v4l2-ioctl.c | 4 +
include/uapi/linux/videodev2.h | 6 +
4 files changed, 186 insertions(+)
create mode 100644 Documentation/userspace-api/media/v4l/pixfmt-raw-generic.rst
diff --git a/Documentation/userspace-api/media/v4l/pixfmt-raw-generic.rst b/Documentation/userspace-api/media/v4l/pixfmt-raw-generic.rst
new file mode 100644
index 000000000000..254f8f18c7c5
--- /dev/null
+++ b/Documentation/userspace-api/media/v4l/pixfmt-raw-generic.rst
@@ -0,0 +1,175 @@
+.. SPDX-License-Identifier: GPL-2.0 OR GFDL-1.1-no-invariants-or-later
+
+************************************************************************************************************************************
+V4L2_PIX_FMT_RAW_8 ('RAW8'), V4L2_PIX_FMT_RAW_CSI2_10 ('RACA'), V4L2_PIX_FMT_RAW_CSI2_12 ('RACC'), V4L2_PIX_FMT_RAW_CSI2_14 ('RACE')
+************************************************************************************************************************************
+
+
+Generic line-based raw image data formats
+
+
+Description
+===========
+
+These generic raw image data formats define the memory layout of the data without
+defining the order of the colour components or even the colour components
+themselves.
+
+.. _v4l2-pix-fmt-raw-8:
+
+V4L2_PIX_FMT_RAW_8
+------------------
+
+The V4L2_PIX_FMT_RAW_8 format is a plain 8-bit raw pixel data format. This
+format is used on CSI-2 for 8 bits per :term:`Data Unit`.
+
+**Byte Order Of V4L2_PIX_FMT_RAW_8.**
+Each cell is one byte. "P" denotes a pixel.
+
+.. tabularcolumns:: |p{2.4cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|
+
+.. flat-table:: Sample 4x2 Image Frame
+ :header-rows: 0
+ :stub-columns: 0
+ :widths: 12 8 8 8 8
+
+ * - start + 0:
+ - P\ :sub:`00`
+ - P\ :sub:`10`
+ - P\ :sub:`20`
+ - P\ :sub:`30`
+ * - start + 4:
+ - P\ :sub:`01`
+ - P\ :sub:`11`
+ - P\ :sub:`21`
+ - P\ :sub:`31`
+
+.. _v4l2-pix-fmt-raw-csi2-10:
+
+V4L2_PIX_FMT_RAW_CSI2_10
+------------------------
+
+V4L2_PIX_FMT_RAW_CSI2_10 contains 10-bit packed image data, with four bytes
+containing the top 8 bits of the pixels followed by lowest 2 bits of the pixels
+packed into one byte. This format is typically used by CSI-2 receivers with
+a source that transmits MEDIA_BUS_FMT_RAW_10 and the CSI-2 receiver writes the
+received data to memory as-is.
+
+The packing of the data follows the MIPI CSI-2 specification.
+
+**Byte Order Of V4L2_PIX_FMT_RAW_CSI2_10.**
+Each cell is one byte. "P" denotes a pixel.
+
+.. tabularcolumns:: |p{2.4cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{2cm}|
+
+.. flat-table:: Sample 4x2 Image Frame
+ :header-rows: 0
+ :stub-columns: 0
+ :widths: 12 8 8 8 8 8
+
+ * - start + 0:
+ - P\ :sub:`00 bits 9--2`
+ - P\ :sub:`10 bits 9--2`
+ - P\ :sub:`20 bits 9--2`
+ - P\ :sub:`30 bits 9--2`
+ - P\ :sub:`00 bits 1--0` (bits 1--0),
+ P\ :sub:`10 bits 1--0` (bits 3--2),
+ P\ :sub:`20 bits 1--0` (bits 5--4),
+ P\ :sub:`30 bits 1--0` (bits 7--6)
+ * - start + 5:
+ - P\ :sub:`01 bits 9--2`
+ - P\ :sub:`11 bits 9--2`
+ - P\ :sub:`21 bits 9--2`
+ - P\ :sub:`31 bits 9--2`
+ - P\ :sub:`01 bits 1--0` (bits 1--0),
+ P\ :sub:`11 bits 1--0` (bits 3--2),
+ P\ :sub:`21 bits 1--0` (bits 5--4),
+ P\ :sub:`31 bits 1--0` (bits 7--6)
+
+.. _v4l2-pix-fmt-raw-csi2-12:
+
+V4L2_PIX_FMT_RAW_CSI2_12
+------------------------
+
+V4L2_PIX_FMT_RAW_CSI2_12 contains 12-bit packed image data, with two bytes
+containing the top 8 bits of the pixels followed by lowest 4 bits of the pixels
+packed into 1 byte. This format is typically used by CSI-2 receivers with
+a source that transmits MEDIA_BUS_FMT_RAW_12 and the CSI-2 receiver writes the
+received data to memory as-is.
+
+The packing of the data follows the MIPI CSI-2 specification.
+
+**Byte Order Of V4L2_PIX_FMT_RAW_CSI2_12.**
+Each cell is one byte. "P" denotes a pixel.
+
+.. tabularcolumns:: |p{2.4cm}|p{1.2cm}|p{1.2cm}|p{2cm}|p{1.2cm}|p{1.2cm}|p{2cm}|
+
+.. flat-table:: Sample 4x2 Image Frame
+ :header-rows: 0
+ :stub-columns: 0
+ :widths: 12 8 8 8 8 8 8
+
+ * - start + 0:
+ - P\ :sub:`00 bits 11--4`
+ - P\ :sub:`10 bits 11--4`
+ - P\ :sub:`00 bits 3--0` (bits 3--0),
+ P\ :sub:`10 bits 3--0` (bits 7--4)
+ - P\ :sub:`20 bits 11--4`
+ - P\ :sub:`30 bits 11--4`
+ - P\ :sub:`20 bits 3--0` (bits 3--0),
+ P\ :sub:`30 bits 3--0` (bits 7--4)
+ * - start + 6:
+ - P\ :sub:`01 bits 11--4`
+ - P\ :sub:`11 bits 11--4`
+ - P\ :sub:`01 bits 3--0` (bits 3--0),
+ P\ :sub:`11 bits 3--0` (bits 7--4)
+ - P\ :sub:`21 bits 11--4`
+ - P\ :sub:`31 bits 11--4`
+ - P\ :sub:`21 bits 3--0` (bits 3--0),
+ P\ :sub:`31 bits 3--0` (bits 7--4)
+
+.. _v4l2-pix-fmt-raw-csi2-14:
+
+V4L2_PIX_FMT_RAW_CSI2_14
+------------------------
+
+V4L2_PIX_FMT_RAW_CSI2_14 contains 14-bit packed image data, with four bytes
+containing the top 8 bits of the pixels followed by lowest 6 bits of the pixels
+packed into three bytes. This format is typically used by CSI-2 receivers with a
+source that transmits MEDIA_BUS_FMT_RAW_14 and the CSI-2 receiver writes the
+received data to memory as-is.
+
+The packing of the data follows the MIPI CSI-2 specification.
+
+**Byte Order Of V4L2_PIX_FMT_RAW_CSI2_14.**
+Each cell is one byte. "P" denotes a pixel.
+
+.. tabularcolumns:: |p{2.4cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{2cm}|p{2cm}|p{2cm}|
+
+.. flat-table:: Sample 4x2 Image Frame
+ :header-rows: 0
+ :stub-columns: 0
+ :widths: 12 8 8 8 8 8 8 8
+
+ * - start + 0:
+ - P\ :sub:`00 bits 13--6`
+ - P\ :sub:`10 bits 13--6`
+ - P\ :sub:`20 bits 13--6`
+ - P\ :sub:`30 bits 13--6`
+ - P\ :sub:`10 bits 1--0` (bits 7--6),
+ P\ :sub:`00 bits 5--0` (bits 5--0)
+ - P\ :sub:`20 bits 3--0` (bits 7--4),
+ P\ :sub:`10 bits 5--2` (bits 3--0)
+ - P\ :sub:`30 bits 5--0` (bits 7--2),
+ P\ :sub:`20 bits 5--4` (bits 1--0)
+ * - start + 7:
+ - P\ :sub:`01 bits 13--6`
+ - P\ :sub:`11 bits 13--6`
+ - P\ :sub:`21 bits 13--6`
+ - P\ :sub:`31 bits 13--6`
+ - P\ :sub:`11 bits 1--0` (bits 7--6),
+ P\ :sub:`01 bits 5--0` (bits 5--0)
+ - P\ :sub:`21 bits 3--0` (bits 7--4),
+ P\ :sub:`11 bits 5--2` (bits 3--0)
+ - P\ :sub:`31 bits 5--0` (bits 7--2),
+ P\ :sub:`21 bits 5--4` (bits 1--0)
diff --git a/Documentation/userspace-api/media/v4l/pixfmt.rst b/Documentation/userspace-api/media/v4l/pixfmt.rst
index 71b29267488f..520a8ec438c9 100644
--- a/Documentation/userspace-api/media/v4l/pixfmt.rst
+++ b/Documentation/userspace-api/media/v4l/pixfmt.rst
@@ -26,6 +26,7 @@ see also :ref:`VIDIOC_G_FBUF <VIDIOC_G_FBUF>`.)
pixfmt-indexed
pixfmt-rgb
pixfmt-bayer
+ pixfmt-raw-generic
yuv-formats
hsv-formats
depth-formats
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index 17ba1ae70735..13139ebf71f3 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1434,6 +1434,10 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
case V4L2_PIX_FMT_SGBRG16: descr = "16-bit Bayer GBGB/RGRG"; break;
case V4L2_PIX_FMT_SGRBG16: descr = "16-bit Bayer GRGR/BGBG"; break;
case V4L2_PIX_FMT_SRGGB16: descr = "16-bit Bayer RGRG/GBGB"; break;
+ case V4L2_PIX_FMT_RAW_8: descr = "8-bit Raw"; break;
+ case V4L2_PIX_FMT_RAW_CSI2_10: descr = "10-bit Raw, CSI-2 Packed"; break;
+ case V4L2_PIX_FMT_RAW_CSI2_12: descr = "12-bit Raw, CSI-2 Packed"; break;
+ case V4L2_PIX_FMT_RAW_CSI2_14: descr = "14-bit Raw, CSI-2 Packed"; break;
case V4L2_PIX_FMT_RAW_CRU20: descr = "14-bit Raw CRU Packed"; break;
case V4L2_PIX_FMT_SN9C20X_I420: descr = "GSPCA SN9C20X I420"; break;
case V4L2_PIX_FMT_SPCA501: descr = "GSPCA SPCA501"; break;
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 5373dba640fa..c9aa21e1a870 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -745,6 +745,12 @@ struct v4l2_pix_format {
#define V4L2_PIX_FMT_SGRBG16 v4l2_fourcc('G', 'R', '1', '6') /* 16 GRGR.. BGBG.. */
#define V4L2_PIX_FMT_SRGGB16 v4l2_fourcc('R', 'G', '1', '6') /* 16 RGRG.. GBGB.. */
+/* Generic CSI-2 packed raw pixel formats */
+#define V4L2_PIX_FMT_RAW_8 v4l2_fourcc('R', 'A', 'W', '8')
+#define V4L2_PIX_FMT_RAW_CSI2_10 v4l2_fourcc('R', 'A', 'C', 'A')
+#define V4L2_PIX_FMT_RAW_CSI2_12 v4l2_fourcc('R', 'A', 'C', 'C')
+#define V4L2_PIX_FMT_RAW_CSI2_14 v4l2_fourcc('R', 'A', 'C', 'E')
+
/* HSV formats */
#define V4L2_PIX_FMT_HSV24 v4l2_fourcc('H', 'S', 'V', '3')
#define V4L2_PIX_FMT_HSV32 v4l2_fourcc('H', 'S', 'V', '4')
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 04/73] media: uapi: Add new media bus codes for generic raw formats
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (2 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 03/73] media: uapi: Add generic CSI-2 raw pixelformats Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 05/73] media: uapi: Add V4L2_CID_CONFIG_MODEL control Sakari Ailus
` (68 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Add new media bus codes for generic raw formats that are not specific to
the colour filter array but that simply specify the bit depth. The layout
(packing) of the data is interface specific.
The rest of the properties of the format are specified with controls in
the image source.
The mbus codes added by this patch have bit depth of 8, 10, 12 and 14.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
.../media/v4l/subdev-formats.rst | 27 +++++++++++++++++++
include/uapi/linux/media-bus-format.h | 6 +++++
2 files changed, 33 insertions(+)
diff --git a/Documentation/userspace-api/media/v4l/subdev-formats.rst b/Documentation/userspace-api/media/v4l/subdev-formats.rst
index c9999b929773..fecb786cb8af 100644
--- a/Documentation/userspace-api/media/v4l/subdev-formats.rst
+++ b/Documentation/userspace-api/media/v4l/subdev-formats.rst
@@ -3855,6 +3855,33 @@ organization is given as an example for the first pixel only.
\endgroup
+Generic raw formats on serial interfaces
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Those formats transfer raw pixel data typically from raw camera sensors using
+Bayer and other Colour Filter Arrays (CFAs) on serial interfaces. The packing of
+the data on the bus is determined by the hardware, however the bit depth is
+still specific to the format.
+
+.. tabularcolumns:: |p{2.0cm}|p{4.0cm}|p{11.3cm}|
+
+.. cssclass:: longtable
+
+.. flat-table:: Generic raw formats on serial buses
+ :header-rows: 1
+ :stub-columns: 0
+ :widths: 1 1
+
+ * - Format name
+ - Bit depth
+ * - MEDIA_BUS_FMT_RAW_8
+ - 8
+ * - MEDIA_BUS_FMT_RAW_10
+ - 10
+ * - MEDIA_BUS_FMT_RAW_12
+ - 12
+ * - MEDIA_BUS_FMT_RAW_14
+ - 14
Packed YUV Formats
^^^^^^^^^^^^^^^^^^
diff --git a/include/uapi/linux/media-bus-format.h b/include/uapi/linux/media-bus-format.h
index 6005f033e62c..83feeae6a31e 100644
--- a/include/uapi/linux/media-bus-format.h
+++ b/include/uapi/linux/media-bus-format.h
@@ -190,4 +190,10 @@
#define MEDIA_BUS_FMT_META_20 0x8006
#define MEDIA_BUS_FMT_META_24 0x8007
+/* Generic (CFA independent) pixel data formats. Next is 0x9005. */
+#define MEDIA_BUS_FMT_RAW_8 0x9001
+#define MEDIA_BUS_FMT_RAW_10 0x9002
+#define MEDIA_BUS_FMT_RAW_12 0x9003
+#define MEDIA_BUS_FMT_RAW_14 0x9004
+
#endif /* __LINUX_MEDIA_BUS_FORMAT_H */
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 05/73] media: uapi: Add V4L2_CID_CONFIG_MODEL control
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (3 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 04/73] media: uapi: Add new media bus codes for generic raw formats Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 06/73] media: uapi: Add V4L2_CID_CFA_PATTERN for describing color patterns Sakari Ailus
` (67 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Add the V4L2_CID_CONFIG_MODEL control for the configuration model.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
.../userspace-api/media/v4l/ext-ctrls-image-process.rst | 4 ++++
drivers/media/v4l2-core/v4l2-ctrls-defs.c | 5 +++++
include/uapi/linux/v4l2-controls.h | 3 +++
3 files changed, 12 insertions(+)
diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-image-process.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-image-process.rst
index 57c2baf34acf..15566f409ca5 100644
--- a/Documentation/userspace-api/media/v4l/ext-ctrls-image-process.rst
+++ b/Documentation/userspace-api/media/v4l/ext-ctrls-image-process.rst
@@ -59,3 +59,7 @@ Image Process Control IDs
control value divided by e.g. 0x100, meaning that to get no
digital gain the control value needs to be 0x100. The no-gain
configuration is also typically the default.
+
+``V4L2_CID_CONFIG_MODEL (bitmask)``
+ Which configuration models the sub-device supports. Please see
+ :ref:`media_subdev_config_model`. This is a read-only control.
diff --git a/drivers/media/v4l2-core/v4l2-ctrls-defs.c b/drivers/media/v4l2-core/v4l2-ctrls-defs.c
index e062f2088490..66ec7b911e4f 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls-defs.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls-defs.c
@@ -1167,6 +1167,7 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_TEST_PATTERN: return "Test Pattern";
case V4L2_CID_DEINTERLACING_MODE: return "Deinterlacing Mode";
case V4L2_CID_DIGITAL_GAIN: return "Digital Gain";
+ case V4L2_CID_CONFIG_MODEL: return "Sub-device Configuration Model";
/* DV controls */
/* Keep the order of the 'case's the same as in v4l2-controls.h! */
@@ -1488,6 +1489,10 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
case V4L2_CID_DV_RX_POWER_PRESENT:
*type = V4L2_CTRL_TYPE_BITMASK;
break;
+ case V4L2_CID_CONFIG_MODEL:
+ *flags |= V4L2_CTRL_FLAG_READ_ONLY;
+ *type = V4L2_CTRL_TYPE_BITMASK;
+ break;
case V4L2_CID_MIN_BUFFERS_FOR_CAPTURE:
case V4L2_CID_MIN_BUFFERS_FOR_OUTPUT:
*type = V4L2_CTRL_TYPE_INTEGER;
diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
index d17e41d51d2e..6b97ee905c43 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -1269,6 +1269,9 @@ enum v4l2_jpeg_chroma_subsampling {
#define V4L2_CID_TEST_PATTERN (V4L2_CID_IMAGE_PROC_CLASS_BASE + 3)
#define V4L2_CID_DEINTERLACING_MODE (V4L2_CID_IMAGE_PROC_CLASS_BASE + 4)
#define V4L2_CID_DIGITAL_GAIN (V4L2_CID_IMAGE_PROC_CLASS_BASE + 5)
+#define V4L2_CID_CONFIG_MODEL (V4L2_CID_IMAGE_PROC_CLASS_BASE + 6)
+
+#define V4L2_CONFIG_MODEL_COMMON_RAW_SENSOR (1U << 0)
/* DV-class control IDs defined by V4L2 */
#define V4L2_CID_DV_CLASS_BASE (V4L2_CTRL_CLASS_DV | 0x900)
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 06/73] media: uapi: Add V4L2_CID_CFA_PATTERN for describing color patterns
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (4 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 05/73] media: uapi: Add V4L2_CID_CONFIG_MODEL control Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 07/73] media: uapi: Add monochromatic CFA pattern Sakari Ailus
` (66 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Add V4L2_CID_CFA_PATTERN to tell the camera sensor's native Color Filter
Array (CFA) pattern.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Mirela Rabulea <mirela.rabulea@nxp.com>
---
.../media/v4l/ext-ctrls-image-source.rst | 43 +++++++++++++++++++
.../media/v4l/subdev-formats.rst | 2 +
drivers/media/v4l2-core/v4l2-ctrls-defs.c | 1 +
include/uapi/linux/v4l2-controls.h | 6 +++
4 files changed, 52 insertions(+)
diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
index f9c0b7ad3b4e..d4ba8bd066f3 100644
--- a/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
+++ b/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
@@ -93,3 +93,46 @@ Image Source Control IDs
representing a gain of exactly 1.0. For example, if this default value
is reported as being (say) 128, then a value of 192 would represent
a gain of exactly 1.5.
+
+``V4L2_CID_CFA_PATTERN (integer)``
+ This control determines the color components and native pixel order in the
+ sensor's CFA (Color Filter Array) when used in conjunction with
+ :ref:`generic raw mbus codes MEDIA_BUS_FMT_RAW_x (where 'x' is the bit
+ depth) <v4l2-mbus-pixelcode-generic-raw>` pixelcodes. The native pixel
+ order is constant for a given device, it is not affected by cropping or
+ flipping.
+
+ This control may only be used on V4L2 sub-devices.
+
+ This is a read-only control.
+
+ Available patterns:
+
+.. flat-table:: V4L2 Color Filter Array Patterns
+ :header-rows: 1
+ :stub-columns: 0
+ :widths: 1 2 1
+
+ * - Macro name
+ - Synopsis
+ - Value
+ * - V4L2_CFA_PATTERN_GRBG
+ - Bayer pattern (2x2 macroblocks). Each macroblock has a green filter in
+ the top-left and bottom-right pixels, a red filter in the top-right
+ pixel, and a blue filter in the bottom-left pixel.
+ - 0x00000000
+ * - V4L2_CFA_PATTERN_RGGB
+ - Bayer pattern (2x2 macroblocks). Each macroblock has a green filter in
+ the top-right and bottom-left pixels, a red filter in the top-left
+ pixel, and a blue filter in the bottom-right pixel.
+ - 0x00000001
+ * - V4L2_CFA_PATTERN_BGGR
+ - Bayer pattern (2x2 macroblocks). Each macroblock has a green filter in
+ the top-right and bottom-left pixels, a blue filter in the top-left
+ pixel, and a red filter in the bottom-right pixel.
+ - 0x00000002
+ * - V4L2_CFA_PATTERN_GBRG
+ - Bayer pattern (2x2 macroblocks). Each macroblock has a green filter in
+ the top-left and bottom-right pixels, a blue filter in the top-right
+ pixel, and a red filter in the bottom-left pixel.
+ - 0x00000003
diff --git a/Documentation/userspace-api/media/v4l/subdev-formats.rst b/Documentation/userspace-api/media/v4l/subdev-formats.rst
index fecb786cb8af..7d34c2991f81 100644
--- a/Documentation/userspace-api/media/v4l/subdev-formats.rst
+++ b/Documentation/userspace-api/media/v4l/subdev-formats.rst
@@ -3855,6 +3855,8 @@ organization is given as an example for the first pixel only.
\endgroup
+.. _v4l2-mbus-pixelcode-generic-raw:
+
Generic raw formats on serial interfaces
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/drivers/media/v4l2-core/v4l2-ctrls-defs.c b/drivers/media/v4l2-core/v4l2-ctrls-defs.c
index 66ec7b911e4f..85ebd025c630 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls-defs.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls-defs.c
@@ -1158,6 +1158,7 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_TEST_PATTERN_BLUE: return "Blue Pixel Value";
case V4L2_CID_TEST_PATTERN_GREENB: return "Green (Blue) Pixel Value";
case V4L2_CID_NOTIFY_GAINS: return "Notify Gains";
+ case V4L2_CID_CFA_PATTERN: return "Color Filter Array Pattern";
/* Image processing controls */
/* Keep the order of the 'case's the same as in v4l2-controls.h! */
diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
index 6b97ee905c43..d948b2c0cf41 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -1258,6 +1258,12 @@ enum v4l2_jpeg_chroma_subsampling {
#define V4L2_CID_UNIT_CELL_SIZE (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 8)
#define V4L2_CID_NOTIFY_GAINS (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 9)
+#define V4L2_CID_CFA_PATTERN (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 10)
+#define V4L2_CFA_PATTERN_GRBG 0x00000000
+#define V4L2_CFA_PATTERN_RGGB 0x00000001
+#define V4L2_CFA_PATTERN_BGGR 0x00000002
+#define V4L2_CFA_PATTERN_GBRG 0x00000003
+
/* Image processing controls */
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 07/73] media: uapi: Add monochromatic CFA pattern
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (5 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 06/73] media: uapi: Add V4L2_CID_CFA_PATTERN for describing color patterns Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 08/73] media: Documentation: Reference CFA pattern control in pixelformat docs Sakari Ailus
` (65 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Add monochromatic CFA pattern to the V4L2_CID_CFA_PATTERN control.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
.../userspace-api/media/v4l/ext-ctrls-image-source.rst | 3 +++
include/uapi/linux/v4l2-controls.h | 1 +
2 files changed, 4 insertions(+)
diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
index d4ba8bd066f3..e1ca45a9b577 100644
--- a/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
+++ b/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
@@ -136,3 +136,6 @@ Image Source Control IDs
the top-left and bottom-right pixels, a blue filter in the top-right
pixel, and a red filter in the bottom-left pixel.
- 0x00000003
+ * - V4L2_CFA_PATTERN_MONO
+ - Monochromatic sensor, no CFA pattern.
+ - 0x00010000
diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
index d948b2c0cf41..c4dbc12609b3 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -1263,6 +1263,7 @@ enum v4l2_jpeg_chroma_subsampling {
#define V4L2_CFA_PATTERN_RGGB 0x00000001
#define V4L2_CFA_PATTERN_BGGR 0x00000002
#define V4L2_CFA_PATTERN_GBRG 0x00000003
+#define V4L2_CFA_PATTERN_MONO 0x00010000
/* Image processing controls */
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 08/73] media: Documentation: Reference CFA pattern control in pixelformat docs
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (6 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 07/73] media: uapi: Add monochromatic CFA pattern Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 09/73] media: Documentation: Reference CFA_PATTERN control in raw mbus docs Sakari Ailus
` (64 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Refer to the CFA pattern control in the generic raw pixelformat
documentation.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
.../userspace-api/media/v4l/ext-ctrls-image-source.rst | 2 ++
Documentation/userspace-api/media/v4l/pixfmt-raw-generic.rst | 4 +++-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
index e1ca45a9b577..97ff8a321849 100644
--- a/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
+++ b/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
@@ -94,6 +94,8 @@ Image Source Control IDs
is reported as being (say) 128, then a value of 192 would represent
a gain of exactly 1.5.
+.. _image-source-control-cfa-pattern:
+
``V4L2_CID_CFA_PATTERN (integer)``
This control determines the color components and native pixel order in the
sensor's CFA (Color Filter Array) when used in conjunction with
diff --git a/Documentation/userspace-api/media/v4l/pixfmt-raw-generic.rst b/Documentation/userspace-api/media/v4l/pixfmt-raw-generic.rst
index 254f8f18c7c5..708aa17b80b0 100644
--- a/Documentation/userspace-api/media/v4l/pixfmt-raw-generic.rst
+++ b/Documentation/userspace-api/media/v4l/pixfmt-raw-generic.rst
@@ -13,7 +13,9 @@ Description
These generic raw image data formats define the memory layout of the data without
defining the order of the colour components or even the colour components
-themselves.
+themselves. These formats may only be used with a Media Controller pipeline where
+the more specific format is reported by the :ref:`V4L2_CID_CFA_PATTERN
+<image-source-control-cfa-pattern>` control on the source sub-device.
.. _v4l2-pix-fmt-raw-8:
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 09/73] media: Documentation: Reference CFA_PATTERN control in raw mbus docs
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (7 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 08/73] media: Documentation: Reference CFA pattern control in pixelformat docs Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 10/73] media: v4l: uapi: Add a control for color pattern flipping effect Sakari Ailus
` (63 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Add a reference to the V4L2_CID_CFA_PATTERN control in the generic raw
media bus code documentation.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
Documentation/userspace-api/media/v4l/subdev-formats.rst | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Documentation/userspace-api/media/v4l/subdev-formats.rst b/Documentation/userspace-api/media/v4l/subdev-formats.rst
index 7d34c2991f81..3aa5bfdd5175 100644
--- a/Documentation/userspace-api/media/v4l/subdev-formats.rst
+++ b/Documentation/userspace-api/media/v4l/subdev-formats.rst
@@ -3865,6 +3865,9 @@ Bayer and other Colour Filter Arrays (CFAs) on serial interfaces. The packing of
the data on the bus is determined by the hardware, however the bit depth is
still specific to the format.
+The native Colour Filter Array (CFA) pattern is determined by the
+:ref:`V4L2_CID_CFA_PATTERN <image-source-control-cfa-pattern>` control.
+
.. tabularcolumns:: |p{2.0cm}|p{4.0cm}|p{11.3cm}|
.. cssclass:: longtable
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 10/73] media: v4l: uapi: Add a control for color pattern flipping effect
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (8 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 09/73] media: Documentation: Reference CFA_PATTERN control in raw mbus docs Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 11/73] media: Documentation: Reference flipping controls in raw format docs Sakari Ailus
` (62 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Add a bitmask control (V4L2_CID_CFA_PATTERN_FLIP) to tell whether flipping
results in a change in the sensor's Color Filter Array (CFA) pattern,
separately horizontally and vertically. The information is essential for
raw formats when using generic raw mbus codes.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
.../media/v4l/ext-ctrls-image-source.rst | 12 ++++++++++++
drivers/media/v4l2-core/v4l2-ctrls-defs.c | 2 ++
include/uapi/linux/v4l2-controls.h | 6 ++++++
3 files changed, 20 insertions(+)
diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
index 97ff8a321849..68ac4a2facfd 100644
--- a/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
+++ b/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
@@ -141,3 +141,15 @@ Image Source Control IDs
* - V4L2_CFA_PATTERN_MONO
- Monochromatic sensor, no CFA pattern.
- 0x00010000
+
+``V4L2_CID_CFA_PATTERN_FLIP (bitmask)``
+ This control determines whether the horizontal or vertical flipping controls
+ (V4L2_CID_HFLIP and V4L2_CID_VFLIP) have an effect on the pixel order of the
+ output color pattern. Macros ``V4L2_CFA_PATTERN_FLIP_HORIZONTAL`` and
+ ``V4L2_CFA_PATTERN_FLIP_VERTICAL`` define bitmasks for both bits. If either
+ horizontal or vertical bit is set, the readout pattern order is that of the
+ reversed readout. ``V4L2_CFA_PATTERN_FLIP_BOTH`` for setting both
+ ``V4L2_CFA_PATTERN_FLIP_HORIZONTAL`` and ``V4L2_CFA_PATTERN_FLIP_VERTICAL``
+ is provided as well.
+
+ This is a read-only control.
diff --git a/drivers/media/v4l2-core/v4l2-ctrls-defs.c b/drivers/media/v4l2-core/v4l2-ctrls-defs.c
index 85ebd025c630..8656fe3144c1 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls-defs.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls-defs.c
@@ -1159,6 +1159,7 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_TEST_PATTERN_GREENB: return "Green (Blue) Pixel Value";
case V4L2_CID_NOTIFY_GAINS: return "Notify Gains";
case V4L2_CID_CFA_PATTERN: return "Color Filter Array Pattern";
+ case V4L2_CID_CFA_PATTERN_FLIP: return "CFA Pattern Flip";
/* Image processing controls */
/* Keep the order of the 'case's the same as in v4l2-controls.h! */
@@ -1491,6 +1492,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
*type = V4L2_CTRL_TYPE_BITMASK;
break;
case V4L2_CID_CONFIG_MODEL:
+ case V4L2_CID_CFA_PATTERN_FLIP:
*flags |= V4L2_CTRL_FLAG_READ_ONLY;
*type = V4L2_CTRL_TYPE_BITMASK;
break;
diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
index c4dbc12609b3..b45a42d9442e 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -1265,6 +1265,12 @@ enum v4l2_jpeg_chroma_subsampling {
#define V4L2_CFA_PATTERN_GBRG 0x00000003
#define V4L2_CFA_PATTERN_MONO 0x00010000
+#define V4L2_CID_CFA_PATTERN_FLIP (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 11)
+#define V4L2_CFA_PATTERN_FLIP_HORIZONTAL (1U << 0)
+#define V4L2_CFA_PATTERN_FLIP_VERTICAL (1U << 1)
+#define V4L2_CFA_PATTERN_FLIP_BOTH \
+ (V4L2_CFA_PATTERN_FLIP_HORIZONTAL | V4L2_CFA_PATTERN_FLIP_VERTICAL)
+
/* Image processing controls */
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 11/73] media: Documentation: Reference flipping controls in raw format docs
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (9 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 10/73] media: v4l: uapi: Add a control for color pattern flipping effect Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 12/73] media: Documentation: Document raw mbus codes and CFA for cameras Sakari Ailus
` (61 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Add a reference to the flipping related controls (V4L2_CID_HFLIP,
V4L2_CID_VFLIP and V4L2_CID_COLOR_PATTERN_FLIP) to the generic raw format
documentation.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
.../userspace-api/media/v4l/ext-ctrls-image-source.rst | 2 ++
Documentation/userspace-api/media/v4l/subdev-formats.rst | 3 +++
2 files changed, 5 insertions(+)
diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
index 68ac4a2facfd..74d4f182222d 100644
--- a/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
+++ b/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
@@ -142,6 +142,8 @@ Image Source Control IDs
- Monochromatic sensor, no CFA pattern.
- 0x00010000
+.. _image-source-control-cfa-pattern-flip:
+
``V4L2_CID_CFA_PATTERN_FLIP (bitmask)``
This control determines whether the horizontal or vertical flipping controls
(V4L2_CID_HFLIP and V4L2_CID_VFLIP) have an effect on the pixel order of the
diff --git a/Documentation/userspace-api/media/v4l/subdev-formats.rst b/Documentation/userspace-api/media/v4l/subdev-formats.rst
index 3aa5bfdd5175..b207119415f1 100644
--- a/Documentation/userspace-api/media/v4l/subdev-formats.rst
+++ b/Documentation/userspace-api/media/v4l/subdev-formats.rst
@@ -3867,6 +3867,9 @@ still specific to the format.
The native Colour Filter Array (CFA) pattern is determined by the
:ref:`V4L2_CID_CFA_PATTERN <image-source-control-cfa-pattern>` control.
+Whether or not flipping controls (``V4L2_CID_HFLIP`` and ``V4L2_CID_VFLIP``)
+affect the pattern is conveyed via the :ref:`V4L2_CID_CFA_PATTERN_FLIP
+<image-source-control-cfa-pattern-flip>` control.
.. tabularcolumns:: |p{2.0cm}|p{4.0cm}|p{11.3cm}|
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 12/73] media: Documentation: Document raw mbus codes and CFA for cameras
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (10 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 11/73] media: Documentation: Reference flipping controls in raw format docs Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 13/73] media: uapi: Add V4L2_CID_METADATA_LAYOUT control Sakari Ailus
` (60 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Document the use of raw mbus codes for camera sensors and how the
V4L2_CID_CFA_PATTERN and V4L2_CID_CFA_PATTERN_FLIP controls are used to
convey the color filter array pattern on UAPI.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
.../userspace-api/media/drivers/camera-sensor.rst | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/Documentation/userspace-api/media/drivers/camera-sensor.rst b/Documentation/userspace-api/media/drivers/camera-sensor.rst
index 75fd9166383f..75d783b75c48 100644
--- a/Documentation/userspace-api/media/drivers/camera-sensor.rst
+++ b/Documentation/userspace-api/media/drivers/camera-sensor.rst
@@ -39,6 +39,19 @@ format set on a source pad at the end of the device's internal pipeline.
Most sensor drivers are implemented this way.
+V4L2_CID_CFA_PATTERN, raw mbus formats, flipping and cropping
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+For raw image data originating from camera sensors, specific :ref:`raw mbus
+codes MEDIA_BUS_FMT_RAW_x (where 'x' is the bit depth)
+<v4l2-mbus-pixelcode-generic-raw>` are used as Color Filter Array (CFA) agnostic
+raw formats. The :ref:`V4L2_CID_CFA_PATTERN <image-source-control-cfa-pattern>`
+control in the same sub-device defines the native CFA pattern of the
+device. Flipping may further affect the readout pattern as indicated by the
+:ref:`V4L2_CID_CFA_PATTERN_FLIP <image-source-control-cfa-pattern-flip>`
+control. Further on, cropping also has an effect on the pattern if cropped
+amount is not divisible by the size of the pattern, horizontally and vertically.
+
Frame interval configuration
----------------------------
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 13/73] media: uapi: Add V4L2_CID_METADATA_LAYOUT control
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (11 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 12/73] media: Documentation: Document raw mbus codes and CFA for cameras Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 14/73] media: Documentation: Refer to metadata layout in metadata documentation Sakari Ailus
` (59 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
The metadata layout control defines the layout of the metadata on the bus.
It is used on sub-devices that use generic metadata mbus codes on at least
one of the pads.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
.../userspace-api/media/v4l/ext-ctrls-image-source.rst | 6 ++++++
drivers/media/v4l2-core/v4l2-ctrls-defs.c | 7 +++++++
include/uapi/linux/v4l2-controls.h | 1 +
3 files changed, 14 insertions(+)
diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
index 74d4f182222d..bdb5ddc257d5 100644
--- a/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
+++ b/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
@@ -155,3 +155,9 @@ Image Source Control IDs
is provided as well.
This is a read-only control.
+
+``V4L2_CID_METADATA_LAYOUT (integer)``
+ The metadata layout control defines the metadata layout on the device's data
+ interface for metadata streams. The control is used in conjunction with
+ :ref:`generic metadata formats <media-bus-format-generic-meta>` formats to
+ specify the layout of the data.
diff --git a/drivers/media/v4l2-core/v4l2-ctrls-defs.c b/drivers/media/v4l2-core/v4l2-ctrls-defs.c
index 8656fe3144c1..950fb714dd5d 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls-defs.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls-defs.c
@@ -1160,6 +1160,7 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_NOTIFY_GAINS: return "Notify Gains";
case V4L2_CID_CFA_PATTERN: return "Color Filter Array Pattern";
case V4L2_CID_CFA_PATTERN_FLIP: return "CFA Pattern Flip";
+ case V4L2_CID_METADATA_LAYOUT: return "Metadata Layout";
/* Image processing controls */
/* Keep the order of the 'case's the same as in v4l2-controls.h! */
@@ -1324,6 +1325,12 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
*min = 0;
*max = *step = 1;
break;
+ case V4L2_CID_METADATA_LAYOUT:
+ *type = V4L2_CTRL_TYPE_INTEGER;
+ *flags |= V4L2_CTRL_FLAG_READ_ONLY;
+ *min = 0;
+ *step = 1;
+ break;
case V4L2_CID_ROTATE:
*type = V4L2_CTRL_TYPE_INTEGER;
*flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT;
diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
index b45a42d9442e..87b6286abb51 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -1271,6 +1271,7 @@ enum v4l2_jpeg_chroma_subsampling {
#define V4L2_CFA_PATTERN_FLIP_BOTH \
(V4L2_CFA_PATTERN_FLIP_HORIZONTAL | V4L2_CFA_PATTERN_FLIP_VERTICAL)
+#define V4L2_CID_METADATA_LAYOUT (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 12)
/* Image processing controls */
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 14/73] media: Documentation: Refer to metadata layout in metadata documentation
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (12 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 13/73] media: uapi: Add V4L2_CID_METADATA_LAYOUT control Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 15/73] media: Documentation: v4l: Document internal sink pads Sakari Ailus
` (58 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Using generic metadata mbus codes requires the use of
V4L2_CID_METADATA_LAYOUT control to define the metadata layout. Document
this in generic metadata format documentation.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
Documentation/userspace-api/media/v4l/metafmt-generic.rst | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/Documentation/userspace-api/media/v4l/metafmt-generic.rst b/Documentation/userspace-api/media/v4l/metafmt-generic.rst
index 23f69e1a1afa..7226b4810088 100644
--- a/Documentation/userspace-api/media/v4l/metafmt-generic.rst
+++ b/Documentation/userspace-api/media/v4l/metafmt-generic.rst
@@ -8,12 +8,16 @@ V4L2_META_FMT_GENERIC_8 ('MET8'), V4L2_META_FMT_GENERIC_CSI2_10 ('MC1A'), V4L2_M
Generic line-based metadata formats
-
Description
===========
These generic line-based metadata formats define the memory layout of the data
-without defining the format or meaning of the metadata itself.
+without defining the format or meaning of the metadata itself. These formats may
+only be used with a Media Controller pipeline where the exact metadata layout is
+reported using the :ref:`V4L2_CID_METADATA_LAYOUT control
+<image_source_control_metadata_layout>` by the sub-device generating the
+metadata. See also :ref:`source routes <subdev-routing>`.
+
.. _v4l2-meta-fmt-generic-8:
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 15/73] media: Documentation: v4l: Document internal sink pads
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (13 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 14/73] media: Documentation: Refer to metadata layout in metadata documentation Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 16/73] media: Documentation: Document embedded data guidelines for camera sensors Sakari Ailus
` (57 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Document internal sink pads, pads that have both SINK and INTERNAL flags
set. Use the IMX219 camera sensor as an example.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Julien Massot <julien.massot@collabora.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Mirela Rabulea <mirela.rabulea@nxp.com>
Reviewed-by: Jai Luthra <jai.luthra@ideasonboard.com
---
.../userspace-api/media/v4l/dev-subdev.rst | 22 +++++++++++++++++++
.../media/v4l/ext-ctrls-image-source.rst | 2 ++
2 files changed, 24 insertions(+)
diff --git a/Documentation/userspace-api/media/v4l/dev-subdev.rst b/Documentation/userspace-api/media/v4l/dev-subdev.rst
index 142e2cd95062..11d49f86e353 100644
--- a/Documentation/userspace-api/media/v4l/dev-subdev.rst
+++ b/Documentation/userspace-api/media/v4l/dev-subdev.rst
@@ -554,6 +554,23 @@ A stream at a specific point in the media pipeline is identified by the
sub-device and a (pad, stream) pair. For sub-devices that do not support
multiplexed streams the 'stream' field is always 0.
+Internal sink pads and routing
+------------------------------
+
+Internal sink pads are used to denote sources of routes that originate from
+within a sub-device itself. No external sink pads exist for such routes.
+Internal sink pads have the :ref:`MEDIA_PAD_FL_INTERNAL <MEDIA-PAD-FL-INTERNAL>`
+pad flag set.
+
+Internal pads have all the properties of an external pad, including formats and
+selections. The format in this case is the source format of the stream. An
+internal pad always has a single stream only (0).
+
+Routes from an internal sink pad to an external source pad are created by the
+driver and can be activated and deactivated using the
+:ref:`V4L2_SUBDEV_ROUTE_FL_ACTIVE <v4l2-subdev-routing-flags>` flag, depending
+on the device capabilities.
+
Interaction between routes, streams, formats and selections
-----------------------------------------------------------
@@ -691,3 +708,8 @@ To configure this pipeline, the userspace must take the following steps:
the configurations along the stream towards the receiver, using
:ref:`VIDIOC_SUBDEV_S_FMT <VIDIOC_SUBDEV_G_FMT>` ioctls to configure each
stream endpoint in each sub-device.
+
+ In case generic raw and metadata formats are used, :ref:`V4L2_CID_CFA_PATTERN
+ <image-source-control-cfa-pattern>` and :ref:`V4L2_CID_METADATA_LAYOUT
+ <image_source_control_metadata_layout>` controls are present on the source
+ sub-device to obtain the pixel array CFA pattern and metadata layout.
diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
index bdb5ddc257d5..a9fd1458e391 100644
--- a/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
+++ b/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
@@ -156,6 +156,8 @@ Image Source Control IDs
This is a read-only control.
+.. _image_source_control_metadata_layout:
+
``V4L2_CID_METADATA_LAYOUT (integer)``
The metadata layout control defines the metadata layout on the device's data
interface for metadata streams. The control is used in conjunction with
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 16/73] media: Documentation: Document embedded data guidelines for camera sensors
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (14 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 15/73] media: Documentation: v4l: Document internal sink pads Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 17/73] media: uapi: Correct generic CSI-2 metadata format 4cc Sakari Ailus
` (56 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Document how embedded data support should be implemented for camera
sensors, and when and how CCS embedded data layout should be referenced.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Julien Massot <julien.massot@collabora.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
.../media/drivers/camera-sensor.rst | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/Documentation/userspace-api/media/drivers/camera-sensor.rst b/Documentation/userspace-api/media/drivers/camera-sensor.rst
index 75d783b75c48..87f86a2f6cc5 100644
--- a/Documentation/userspace-api/media/drivers/camera-sensor.rst
+++ b/Documentation/userspace-api/media/drivers/camera-sensor.rst
@@ -117,3 +117,22 @@ register programming sequences shall initialize the :ref:`V4L2_CID_HFLIP
values programmed by the register sequences. The default values of these
controls shall be 0 (disabled). Especially these controls shall not be inverted,
independently of the sensor's mounting rotation.
+
+Embedded data
+-------------
+
+Many sensors, mostly raw sensors, support embedded data which is used to convey
+the sensor configuration for the captured frame back to the host. While CSI-2 is
+the most common data interface used by such sensors, embedded data can be
+available on other interfaces as well.
+
+Embedded data support is indicated by the presence of an internal sink pad (pad
+that has both the :ref:`MEDIA_PAD_FL_SINK <MEDIA-PAD-FL-SINK>` and
+:ref:`MEDIA_PAD_FL_INTERNAL <MEDIA-PAD-FL-INTERNAL>` flags set) with a metadata
+format to model the embedded data stream. If the sub-device driver supports
+disabling embedded data, this can be done by disabling the embedded data route
+via the ``VIDIOC_SUBDEV_S_ROUTING`` IOCTL.
+
+In general, changing the embedded data layout from the driver-configured values
+is not supported. The width of the metadata is device-specific and equal to or
+less than the width of the image data, as configured on the pixel data stream.
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 17/73] media: uapi: Correct generic CSI-2 metadata format 4cc
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (15 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 16/73] media: Documentation: Document embedded data guidelines for camera sensors Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 18/73] Revert "media: uapi: v4l: Don't expose generic metadata formats to userspace" Sakari Ailus
` (55 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Rework the pixelformat 4cc for CSI-2 generic metadata, the 16- and 24-bit
variants are not specific to CSI-2. This can be done as no driver uses
this yet and the interface is disabled.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
.../media/v4l/metafmt-generic.rst | 40 +++++++++----------
.../media/pci/intel/ipu6/ipu6-isys-video.c | 2 +-
drivers/media/v4l2-core/v4l2-ioctl.c | 8 ++--
include/uapi/linux/videodev2.h | 12 +++---
4 files changed, 30 insertions(+), 32 deletions(-)
diff --git a/Documentation/userspace-api/media/v4l/metafmt-generic.rst b/Documentation/userspace-api/media/v4l/metafmt-generic.rst
index 7226b4810088..07147b4d0dd2 100644
--- a/Documentation/userspace-api/media/v4l/metafmt-generic.rst
+++ b/Documentation/userspace-api/media/v4l/metafmt-generic.rst
@@ -2,7 +2,7 @@
.. c:namespace:: V4L
********************************************************************************************************************************************************************************************************************************************************************************
-V4L2_META_FMT_GENERIC_8 ('MET8'), V4L2_META_FMT_GENERIC_CSI2_10 ('MC1A'), V4L2_META_FMT_GENERIC_CSI2_12 ('MC1C'), V4L2_META_FMT_GENERIC_CSI2_14 ('MC1E'), V4L2_META_FMT_GENERIC_CSI2_16 ('MC1G'), V4L2_META_FMT_GENERIC_CSI2_20 ('MC1K'), V4L2_META_FMT_GENERIC_CSI2_24 ('MC1O')
+V4L2_META_FMT_GENERIC_8 ('MET8'), V4L2_META_FMT_GENERIC_CSI2_10 ('MECA'), V4L2_META_FMT_GENERIC_CSI2_12 ('MECC'), V4L2_META_FMT_GENERIC_CSI2_14 ('MECE'), V4L2_META_FMT_GENERIC_16 ('METG'), V4L2_META_FMT_GENERIC_CSI2_20 ('MECK'), V4L2_META_FMT_GENERIC_24 ('METO')
********************************************************************************************************************************************************************************************************************************************************************************
@@ -29,7 +29,7 @@ is used on CSI-2 for 8 bits per :term:`Data Unit`.
Additionally it is used for 16 bits per Data Unit when two bytes of metadata are
packed into one 16-bit Data Unit. Otherwise the 16 bits per pixel dataformat is
-:ref:`V4L2_META_FMT_GENERIC_CSI2_16 <v4l2-meta-fmt-generic-csi2-16>`.
+:ref:`V4L2_META_FMT_GENERIC_16 <v4l2-meta-fmt-generic-16>`.
**Byte Order Of V4L2_META_FMT_GENERIC_8.**
Each cell is one byte. "M" denotes a byte of metadata.
@@ -112,8 +112,8 @@ the data is defined in the MIPI CCS specification.
This format is also used in conjunction with 24 bits per :term:`Data Unit`
formats that pack two bytes of metadata into one Data Unit. Otherwise the
-24 bits per pixel dataformat is :ref:`V4L2_META_FMT_GENERIC_CSI2_24
-<v4l2-meta-fmt-generic-csi2-24>`.
+24 bits per pixel dataformat is :ref:`V4L2_META_FMT_GENERIC_24
+<v4l2-meta-fmt-generic-24>`.
This format is little endian.
@@ -185,16 +185,15 @@ Each cell is one byte. "M" denotes a byte of metadata and "x" a byte of padding.
- x
- x
-.. _v4l2-meta-fmt-generic-csi2-16:
+.. _v4l2-meta-fmt-generic-16:
-V4L2_META_FMT_GENERIC_CSI2_16
------------------------------
+V4L2_META_FMT_GENERIC_16
+------------------------
-V4L2_META_FMT_GENERIC_CSI2_16 contains 8-bit generic metadata packed in 16-bit
-Data Units, with one padding byte after every byte of metadata. This format is
-typically used by CSI-2 receivers with a source that transmits
-MEDIA_BUS_FMT_META_16 and the CSI-2 receiver writes the received data to memory
-as-is.
+V4L2_META_FMT_GENERIC_16 contains 8-bit generic metadata packed in 16-bit Data
+Units, with one padding byte after every byte of metadata. This format is also
+used by CSI-2 receivers with a source that transmits MEDIA_BUS_FMT_META_16 and
+the CSI-2 receiver writes the received data to memory as-is.
The packing of the data follows the MIPI CSI-2 specification and the padding of
the data is defined in the MIPI CCS specification.
@@ -205,7 +204,7 @@ Some devices support more efficient packing of metadata in conjunction with
This format is little endian.
-**Byte Order Of V4L2_META_FMT_GENERIC_CSI2_16.**
+**Byte Order Of V4L2_META_FMT_GENERIC_16.**
Each cell is one byte. "M" denotes a byte of metadata and "x" a byte of padding.
.. tabularcolumns:: |p{2.4cm}|p{1.2cm}|p{.8cm}|p{1.2cm}|p{.8cm}|p{1.2cm}|p{.8cm}|p{1.2cm}|p{.8cm}|
@@ -287,16 +286,15 @@ Each cell is one byte. "M" denotes a byte of metadata and "x" a byte of padding.
- x
- x
-.. _v4l2-meta-fmt-generic-csi2-24:
+.. _v4l2-meta-fmt-generic-24:
-V4L2_META_FMT_GENERIC_CSI2_24
------------------------------
+V4L2_META_FMT_GENERIC_24
+------------------------
-V4L2_META_FMT_GENERIC_CSI2_24 contains 8-bit generic metadata packed in 24-bit
-Data Units, with two padding bytes after every byte of metadata. This format is
-typically used by CSI-2 receivers with a source that transmits
-MEDIA_BUS_FMT_META_24 and the CSI-2 receiver writes the received data to memory
-as-is.
+V4L2_META_FMT_GENERIC_24 contains 8-bit generic metadata packed in 24-bit Data
+Units, with two padding bytes after every byte of metadata. This format is also
+used by CSI-2 receivers with a source that transmits MEDIA_BUS_FMT_META_24 and
+the CSI-2 receiver writes the received data to memory as-is.
The packing of the data follows the MIPI CSI-2 specification and the padding of
the data is defined in the MIPI CCS specification.
diff --git a/drivers/media/pci/intel/ipu6/ipu6-isys-video.c b/drivers/media/pci/intel/ipu6/ipu6-isys-video.c
index 129016e57446..165c840e92a3 100644
--- a/drivers/media/pci/intel/ipu6/ipu6-isys-video.c
+++ b/drivers/media/pci/intel/ipu6/ipu6-isys-video.c
@@ -105,7 +105,7 @@ const struct ipu6_isys_pixelformat ipu6_isys_pfmts[] = {
IPU6_FW_ISYS_FRAME_FORMAT_RAW10, true },
{ V4L2_META_FMT_GENERIC_CSI2_12, 12, 12, MEDIA_BUS_FMT_META_12,
IPU6_FW_ISYS_FRAME_FORMAT_RAW12, true },
- { V4L2_META_FMT_GENERIC_CSI2_16, 16, 16, MEDIA_BUS_FMT_META_16,
+ { V4L2_META_FMT_GENERIC_16, 16, 16, MEDIA_BUS_FMT_META_16,
IPU6_FW_ISYS_FRAME_FORMAT_RAW16, true },
};
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index 13139ebf71f3..5c4cd5bd65b1 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1491,9 +1491,9 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
case V4L2_META_FMT_GENERIC_CSI2_10: descr = "8-bit Generic Meta, 10b CSI-2"; break;
case V4L2_META_FMT_GENERIC_CSI2_12: descr = "8-bit Generic Meta, 12b CSI-2"; break;
case V4L2_META_FMT_GENERIC_CSI2_14: descr = "8-bit Generic Meta, 14b CSI-2"; break;
- case V4L2_META_FMT_GENERIC_CSI2_16: descr = "8-bit Generic Meta, 16b CSI-2"; break;
+ case V4L2_META_FMT_GENERIC_16: descr = "8-bit Generic Meta, 16b"; break;
case V4L2_META_FMT_GENERIC_CSI2_20: descr = "8-bit Generic Meta, 20b CSI-2"; break;
- case V4L2_META_FMT_GENERIC_CSI2_24: descr = "8-bit Generic Meta, 24b CSI-2"; break;
+ case V4L2_META_FMT_GENERIC_24: descr = "8-bit Generic Meta, 24b"; break;
default:
/* Compressed formats */
@@ -1581,9 +1581,9 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
case V4L2_META_FMT_GENERIC_CSI2_10:
case V4L2_META_FMT_GENERIC_CSI2_12:
case V4L2_META_FMT_GENERIC_CSI2_14:
- case V4L2_META_FMT_GENERIC_CSI2_16:
+ case V4L2_META_FMT_GENERIC_16:
case V4L2_META_FMT_GENERIC_CSI2_20:
- case V4L2_META_FMT_GENERIC_CSI2_24:
+ case V4L2_META_FMT_GENERIC_24:
fmt->flags |= V4L2_FMT_FLAG_META_LINE_BASED;
break;
default:
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index c9aa21e1a870..9cdb0fa3120b 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -905,12 +905,12 @@ struct v4l2_pix_format {
* adding new ones!
*/
#define V4L2_META_FMT_GENERIC_8 v4l2_fourcc('M', 'E', 'T', '8') /* Generic 8-bit metadata */
-#define V4L2_META_FMT_GENERIC_CSI2_10 v4l2_fourcc('M', 'C', '1', 'A') /* 10-bit CSI-2 packed 8-bit metadata */
-#define V4L2_META_FMT_GENERIC_CSI2_12 v4l2_fourcc('M', 'C', '1', 'C') /* 12-bit CSI-2 packed 8-bit metadata */
-#define V4L2_META_FMT_GENERIC_CSI2_14 v4l2_fourcc('M', 'C', '1', 'E') /* 14-bit CSI-2 packed 8-bit metadata */
-#define V4L2_META_FMT_GENERIC_CSI2_16 v4l2_fourcc('M', 'C', '1', 'G') /* 16-bit CSI-2 packed 8-bit metadata */
-#define V4L2_META_FMT_GENERIC_CSI2_20 v4l2_fourcc('M', 'C', '1', 'K') /* 20-bit CSI-2 packed 8-bit metadata */
-#define V4L2_META_FMT_GENERIC_CSI2_24 v4l2_fourcc('M', 'C', '1', 'O') /* 24-bit CSI-2 packed 8-bit metadata */
+#define V4L2_META_FMT_GENERIC_CSI2_10 v4l2_fourcc('M', 'E', 'C', 'A') /* 10-bit CSI-2 packed 8-bit metadata */
+#define V4L2_META_FMT_GENERIC_CSI2_12 v4l2_fourcc('M', 'E', 'C', 'C') /* 12-bit CSI-2 packed 8-bit metadata */
+#define V4L2_META_FMT_GENERIC_CSI2_14 v4l2_fourcc('M', 'E', 'C', 'E') /* 14-bit CSI-2 packed 8-bit metadata */
+#define V4L2_META_FMT_GENERIC_16 v4l2_fourcc('M', 'E', 'T', 'G') /* Generic 16-bit 8-bit metadata */
+#define V4L2_META_FMT_GENERIC_CSI2_20 v4l2_fourcc('M', 'E', 'C', 'K') /* 20-bit CSI-2 packed 8-bit metadata */
+#define V4L2_META_FMT_GENERIC_24 v4l2_fourcc('M', 'E', 'T', 'O') /* Generic 24-bit 8-bit metadata */
#endif
/* priv field value to indicates that subsequent fields are valid. */
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 18/73] Revert "media: uapi: v4l: Don't expose generic metadata formats to userspace"
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (16 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 17/73] media: uapi: Correct generic CSI-2 metadata format 4cc Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 19/73] media: v4l: Add V4L2_SUBDEV_ROUTE_FL_IMMUTABLE sub-device routing flag Sakari Ailus
` (54 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
This reverts commit d69c8429ea80af02e89e5b3eecb78e417ad049c8.
Now that the API has stabilised, make the generic metadata formats visible
for the userspace again.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
include/uapi/linux/videodev2.h | 2 --
1 file changed, 2 deletions(-)
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 9cdb0fa3120b..c9dfd51bd328 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -899,7 +899,6 @@ struct v4l2_pix_format {
#define V4L2_META_FMT_RPPX1_PARAMS v4l2_fourcc('D', 'R', '1', 'P') /* Dreamchip RPP-X1 Parameters */
#define V4L2_META_FMT_RPPX1_STATS v4l2_fourcc('D', 'R', '1', 'S') /* Dreamchip RPP-X1 Statistics */
-#ifdef __KERNEL__
/*
* Line-based metadata formats. Remember to update v4l_fill_fmtdesc() when
* adding new ones!
@@ -911,7 +910,6 @@ struct v4l2_pix_format {
#define V4L2_META_FMT_GENERIC_16 v4l2_fourcc('M', 'E', 'T', 'G') /* Generic 16-bit 8-bit metadata */
#define V4L2_META_FMT_GENERIC_CSI2_20 v4l2_fourcc('M', 'E', 'C', 'K') /* 20-bit CSI-2 packed 8-bit metadata */
#define V4L2_META_FMT_GENERIC_24 v4l2_fourcc('M', 'E', 'T', 'O') /* Generic 24-bit 8-bit metadata */
-#endif
/* priv field value to indicates that subsequent fields are valid. */
#define V4L2_PIX_FMT_PRIV_MAGIC 0xfeedcafe
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 19/73] media: v4l: Add V4L2_SUBDEV_ROUTE_FL_IMMUTABLE sub-device routing flag
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (17 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 18/73] Revert "media: uapi: v4l: Don't expose generic metadata formats to userspace" Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 20/73] media: v4l: Add V4L2_SUBDEV_ROUTE_FL_STATIC " Sakari Ailus
` (53 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Add a flag to denote immutable routes, V4L2_SUBDEV_ROUTE_FL_IMMUTABLE.
Such routes cannot be changed and they're always active.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
Documentation/userspace-api/media/v4l/dev-subdev.rst | 4 +++-
.../userspace-api/media/v4l/vidioc-subdev-g-routing.rst | 5 +++++
include/uapi/linux/v4l2-subdev.h | 5 +++++
3 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/Documentation/userspace-api/media/v4l/dev-subdev.rst b/Documentation/userspace-api/media/v4l/dev-subdev.rst
index 11d49f86e353..4a55ba0ddfdc 100644
--- a/Documentation/userspace-api/media/v4l/dev-subdev.rst
+++ b/Documentation/userspace-api/media/v4l/dev-subdev.rst
@@ -569,7 +569,9 @@ internal pad always has a single stream only (0).
Routes from an internal sink pad to an external source pad are created by the
driver and can be activated and deactivated using the
:ref:`V4L2_SUBDEV_ROUTE_FL_ACTIVE <v4l2-subdev-routing-flags>` flag, depending
-on the device capabilities.
+on the device capabilities. The :ref:`V4L2_SUBDEV_ROUTE_FL_IMMUTABLE
+<v4l2-subdev-routing-flags>` flag indicates that the
+``V4L2_SUBDEV_ROUTE_FLAG_ACTIVE`` of the route may not be unset.
Interaction between routes, streams, formats and selections
-----------------------------------------------------------
diff --git a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst b/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst
index 164cf0ad3593..1ef3bbf28091 100644
--- a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst
+++ b/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst
@@ -146,6 +146,11 @@ wants to retrieve the missing routes, it can issue a new
* - V4L2_SUBDEV_ROUTE_FL_ACTIVE
- 0x0001
- The route is enabled. Set by applications.
+ * - V4L2_SUBDEV_ROUTE_FL_IMMUTABLE
+ - 0x0002
+ - The route is immutable. Set by the driver. Indicates that the
+ ``V4L2_SUBDEV_ROUTE_FL_ACTIVE`` flag of an immutable route may not be
+ unset.
Return Value
============
diff --git a/include/uapi/linux/v4l2-subdev.h b/include/uapi/linux/v4l2-subdev.h
index 6160c3e21436..2be7db814288 100644
--- a/include/uapi/linux/v4l2-subdev.h
+++ b/include/uapi/linux/v4l2-subdev.h
@@ -207,6 +207,11 @@ struct v4l2_subdev_capability {
* on a video node.
*/
#define V4L2_SUBDEV_ROUTE_FL_ACTIVE (1U << 0)
+/*
+ * Is the route immutable? The ACTIVE flag of an immutable route may not be
+ * unset.
+ */
+#define V4L2_SUBDEV_ROUTE_FL_IMMUTABLE (1U << 1)
/**
* struct v4l2_subdev_route - A route inside a subdev
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 20/73] media: v4l: Add V4L2_SUBDEV_ROUTE_FL_STATIC sub-device routing flag
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (18 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 19/73] media: v4l: Add V4L2_SUBDEV_ROUTE_FL_IMMUTABLE sub-device routing flag Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 21/73] media: Documentation: There are either immutable or mutable routes Sakari Ailus
` (52 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Add a flag to denote static routes, V4L2_SUBDEV_ROUTE_FL_STATIC. Such
routes cannot be removed as they are related to hardware features.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
.../userspace-api/media/v4l/vidioc-subdev-g-routing.rst | 6 +++++-
include/uapi/linux/v4l2-subdev.h | 4 ++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst b/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst
index 1ef3bbf28091..72787642876f 100644
--- a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst
+++ b/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst
@@ -150,7 +150,11 @@ wants to retrieve the missing routes, it can issue a new
- 0x0002
- The route is immutable. Set by the driver. Indicates that the
``V4L2_SUBDEV_ROUTE_FL_ACTIVE`` flag of an immutable route may not be
- unset.
+ unset. Implies ``V4L2_SUBDEV_ROUTE_FL_STATIC``.
+ * - ``V4L2_SUBDEV_ROUTE_FL_STATIC``
+ - 0x0004
+ - The route is static. Set by the driver. Indicates that the route is
+ always present and cannot be removed.
Return Value
============
diff --git a/include/uapi/linux/v4l2-subdev.h b/include/uapi/linux/v4l2-subdev.h
index 2be7db814288..477d3ce3ddb4 100644
--- a/include/uapi/linux/v4l2-subdev.h
+++ b/include/uapi/linux/v4l2-subdev.h
@@ -212,6 +212,10 @@ struct v4l2_subdev_capability {
* unset.
*/
#define V4L2_SUBDEV_ROUTE_FL_IMMUTABLE (1U << 1)
+/*
+ * Is the route static? Routes with the STATIC flag are not removable.
+ */
+#define V4L2_SUBDEV_ROUTE_FL_STATIC (1U << 2)
/**
* struct v4l2_subdev_route - A route inside a subdev
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 21/73] media: Documentation: There are either immutable or mutable routes
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (19 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 20/73] media: v4l: Add V4L2_SUBDEV_ROUTE_FL_STATIC " Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 22/73] media: Documentation: Document IMMUTABLE and STATIC route flags Sakari Ailus
` (51 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Document that each sub-device may have either immutable or mutable routes,
not both of them.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
Documentation/userspace-api/media/v4l/dev-subdev.rst | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/Documentation/userspace-api/media/v4l/dev-subdev.rst b/Documentation/userspace-api/media/v4l/dev-subdev.rst
index 4a55ba0ddfdc..aa1f1a07af17 100644
--- a/Documentation/userspace-api/media/v4l/dev-subdev.rst
+++ b/Documentation/userspace-api/media/v4l/dev-subdev.rst
@@ -614,6 +614,12 @@ and user-created routes are fully replaced when ``VIDIOC_SUBDEV_S_ROUTING`` is
called on the sub-device. Such newly created routes have the device's default
configuration for format and selection rectangles.
+A sub-device may only have either static routes (routes that have
+``V4L2_SUBDEV_ROUTE_FL_STATIC`` flag set) or routes that are all user-created or
+user-removable (routes that do not have ``V4L2_SUBDEV_ROUTE_FL_STATIC``
+flag). Mixing static and non-static routes is not allowed in the same
+sub-device. This is subject to change in the future.
+
Configuring streams
-------------------
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 22/73] media: Documentation: Document IMMUTABLE and STATIC route flags
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (20 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 21/73] media: Documentation: There are either immutable or mutable routes Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 23/73] media: Documentation: Add subdev configuration models, raw sensor model Sakari Ailus
` (50 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Include the V4L2_SUBDEV_ROUTE_FL_IMMUTABLE and V4L2_SUBDEV_ROUTE_FL_STATIC
flags in V4L2 sub-device documentation that discusses routing.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
.../userspace-api/media/v4l/dev-subdev.rst | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/Documentation/userspace-api/media/v4l/dev-subdev.rst b/Documentation/userspace-api/media/v4l/dev-subdev.rst
index aa1f1a07af17..9168a3a45c9e 100644
--- a/Documentation/userspace-api/media/v4l/dev-subdev.rst
+++ b/Documentation/userspace-api/media/v4l/dev-subdev.rst
@@ -600,11 +600,15 @@ depending on the hardware. In all cases, however, only routes that have the
``V4L2_SUBDEV_ROUTE_FL_ACTIVE`` flag set are active.
Devices generating the streams may allow enabling and disabling some of the
-routes or have a fixed routing configuration. If the routes can be disabled, not
-declaring the routes (or declaring them without ``V4L2_SUBDEV_ROUTE_FL_ACTIVE``
-flag set) in ``VIDIOC_SUBDEV_S_ROUTING`` will disable the routes.
-``VIDIOC_SUBDEV_S_ROUTING`` will still return such routes back to the user in
-the routes array, with the ``V4L2_SUBDEV_ROUTE_FL_ACTIVE`` flag unset.
+routes or have a fixed routing configuration. Routes that are bound to hardware
+resources and are always present are marked with ``V4L2_SUBDEV_ROUTE_FL_STATIC``
+flag. Static routes that cannot be disabled are marked with
+``V4L2_SUBDEV_ROUTE_FL_IMMUTABLE`` route flag. Static routes can be disabled by
+not declaring the routes (or declaring them without
+``V4L2_SUBDEV_ROUTE_FL_ACTIVE`` flag set) in
+``VIDIOC_SUBDEV_S_ROUTING``. ``VIDIOC_SUBDEV_S_ROUTING`` will still return such
+routes back to the user in the routes array, with the
+``V4L2_SUBDEV_ROUTE_FL_ACTIVE`` flag unset.
Devices transporting the streams almost always have more configurability with
respect to routing. Typically any route between the sub-device's sink and source
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 23/73] media: Documentation: Add subdev configuration models, raw sensor model
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (21 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 22/73] media: Documentation: Document IMMUTABLE and STATIC route flags Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 24/73] media: v4l2-subdev: Prevent accessing internal pads without STREAMS cap Sakari Ailus
` (49 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Sub-device configuration models define what V4L2 API elements are
available on a compliant sub-device and how do they behave.
The patch also adds a model for common raw sensors.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Mirela Rabulea <mirela.rabulea@nxp.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
.../media/drivers/camera-sensor.rst | 4 +
.../media/v4l/common-raw-sensor.dia | 442 ++++++++++++++++++
.../media/v4l/common-raw-sensor.svg | 134 ++++++
.../userspace-api/media/v4l/dev-subdev.rst | 9 +-
.../userspace-api/media/v4l/devices.rst | 1 +
.../media/v4l/subdev-config-model.rst | 250 ++++++++++
6 files changed, 836 insertions(+), 4 deletions(-)
create mode 100644 Documentation/userspace-api/media/v4l/common-raw-sensor.dia
create mode 100644 Documentation/userspace-api/media/v4l/common-raw-sensor.svg
create mode 100644 Documentation/userspace-api/media/v4l/subdev-config-model.rst
diff --git a/Documentation/userspace-api/media/drivers/camera-sensor.rst b/Documentation/userspace-api/media/drivers/camera-sensor.rst
index 87f86a2f6cc5..8002893f1c36 100644
--- a/Documentation/userspace-api/media/drivers/camera-sensor.rst
+++ b/Documentation/userspace-api/media/drivers/camera-sensor.rst
@@ -18,6 +18,8 @@ binning functionality. The sensor drivers belong to two distinct classes, freely
configurable and register list-based drivers, depending on how the driver
configures this functionality.
+Also see :ref:`media_subdev_config_model_common_raw_sensor`.
+
Freely configurable camera sensor drivers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -118,6 +120,8 @@ values programmed by the register sequences. The default values of these
controls shall be 0 (disabled). Especially these controls shall not be inverted,
independently of the sensor's mounting rotation.
+.. _media_using_camera_sensor_drivers_embedded_data:
+
Embedded data
-------------
diff --git a/Documentation/userspace-api/media/v4l/common-raw-sensor.dia b/Documentation/userspace-api/media/v4l/common-raw-sensor.dia
new file mode 100644
index 000000000000..24b3f2b2a626
--- /dev/null
+++ b/Documentation/userspace-api/media/v4l/common-raw-sensor.dia
@@ -0,0 +1,442 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<dia:diagram xmlns:dia="http://www.lysator.liu.se/~alla/dia/">
+ <dia:diagramdata>
+ <dia:attribute name="background">
+ <dia:color val="#ffffffff"/>
+ </dia:attribute>
+ <dia:attribute name="pagebreak">
+ <dia:color val="#000099ff"/>
+ </dia:attribute>
+ <dia:attribute name="paper">
+ <dia:composite type="paper">
+ <dia:attribute name="name">
+ <dia:string>#A4#</dia:string>
+ </dia:attribute>
+ <dia:attribute name="tmargin">
+ <dia:real val="2.8222"/>
+ </dia:attribute>
+ <dia:attribute name="bmargin">
+ <dia:real val="2.8222"/>
+ </dia:attribute>
+ <dia:attribute name="lmargin">
+ <dia:real val="2.8222"/>
+ </dia:attribute>
+ <dia:attribute name="rmargin">
+ <dia:real val="2.8222"/>
+ </dia:attribute>
+ <dia:attribute name="is_portrait">
+ <dia:boolean val="true"/>
+ </dia:attribute>
+ <dia:attribute name="scaling">
+ <dia:real val="1"/>
+ </dia:attribute>
+ <dia:attribute name="fitto">
+ <dia:boolean val="false"/>
+ </dia:attribute>
+ </dia:composite>
+ </dia:attribute>
+ <dia:attribute name="grid">
+ <dia:composite type="grid">
+ <dia:attribute name="dynamic">
+ <dia:boolean val="true"/>
+ </dia:attribute>
+ <dia:attribute name="width_x">
+ <dia:real val="1"/>
+ </dia:attribute>
+ <dia:attribute name="width_y">
+ <dia:real val="1"/>
+ </dia:attribute>
+ <dia:attribute name="visible_x">
+ <dia:int val="1"/>
+ </dia:attribute>
+ <dia:attribute name="visible_y">
+ <dia:int val="1"/>
+ </dia:attribute>
+ <dia:composite type="color"/>
+ </dia:composite>
+ </dia:attribute>
+ <dia:attribute name="color">
+ <dia:color val="#d8e5e5ff"/>
+ </dia:attribute>
+ <dia:attribute name="guides"/>
+ <dia:attribute name="guide_color">
+ <dia:color val="#00ff00ff"/>
+ </dia:attribute>
+ <dia:attribute name="display">
+ <dia:composite type="display">
+ <dia:attribute name="antialiased">
+ <dia:boolean val="true"/>
+ </dia:attribute>
+ <dia:attribute name="snap-to-grid">
+ <dia:boolean val="false"/>
+ </dia:attribute>
+ <dia:attribute name="snap-to-guides">
+ <dia:boolean val="true"/>
+ </dia:attribute>
+ <dia:attribute name="snap-to-object">
+ <dia:boolean val="true"/>
+ </dia:attribute>
+ <dia:attribute name="show-grid">
+ <dia:boolean val="true"/>
+ </dia:attribute>
+ <dia:attribute name="show-guides">
+ <dia:boolean val="true"/>
+ </dia:attribute>
+ <dia:attribute name="show-connection-points">
+ <dia:boolean val="true"/>
+ </dia:attribute>
+ </dia:composite>
+ </dia:attribute>
+ </dia:diagramdata>
+ <dia:layer name="Background" visible="true" connectable="false"/>
+ <dia:layer name="Background" visible="true" connectable="false"/>
+ <dia:layer name="Background" visible="true" connectable="false"/>
+ <dia:layer name="Background" visible="true" connectable="true" active="true">
+ <dia:object type="Standard - Box" version="0" id="O0">
+ <dia:attribute name="obj_pos">
+ <dia:point val="16.35,11.5"/>
+ </dia:attribute>
+ <dia:attribute name="obj_bb">
+ <dia:rectangle val="16.3,11.45;25.8,18.45"/>
+ </dia:attribute>
+ <dia:attribute name="elem_corner">
+ <dia:point val="16.35,11.5"/>
+ </dia:attribute>
+ <dia:attribute name="elem_width">
+ <dia:real val="9.4000000000000021"/>
+ </dia:attribute>
+ <dia:attribute name="elem_height">
+ <dia:real val="6.9000000000000021"/>
+ </dia:attribute>
+ <dia:attribute name="show_background">
+ <dia:boolean val="true"/>
+ </dia:attribute>
+ </dia:object>
+ <dia:object type="Geometric - Perfect Circle" version="1" id="O1">
+ <dia:attribute name="obj_pos">
+ <dia:point val="25.5627,14.578"/>
+ </dia:attribute>
+ <dia:attribute name="obj_bb">
+ <dia:rectangle val="25.4627,14.478;26.0191,15.0344"/>
+ </dia:attribute>
+ <dia:attribute name="meta">
+ <dia:composite type="dict"/>
+ </dia:attribute>
+ <dia:attribute name="elem_corner">
+ <dia:point val="25.5627,14.578"/>
+ </dia:attribute>
+ <dia:attribute name="elem_width">
+ <dia:real val="0.35638032780853468"/>
+ </dia:attribute>
+ <dia:attribute name="elem_height">
+ <dia:real val="0.35638032780853468"/>
+ </dia:attribute>
+ <dia:attribute name="line_width">
+ <dia:real val="0.10000000000000001"/>
+ </dia:attribute>
+ <dia:attribute name="line_colour">
+ <dia:color val="#000000ff"/>
+ </dia:attribute>
+ <dia:attribute name="fill_colour">
+ <dia:color val="#ffffffff"/>
+ </dia:attribute>
+ <dia:attribute name="show_background">
+ <dia:boolean val="true"/>
+ </dia:attribute>
+ <dia:attribute name="line_style">
+ <dia:enum val="0"/>
+ <dia:real val="1"/>
+ </dia:attribute>
+ <dia:attribute name="flip_horizontal">
+ <dia:boolean val="false"/>
+ </dia:attribute>
+ <dia:attribute name="flip_vertical">
+ <dia:boolean val="false"/>
+ </dia:attribute>
+ <dia:attribute name="subscale">
+ <dia:real val="1"/>
+ </dia:attribute>
+ </dia:object>
+ <dia:object type="Geometric - Perfect Circle" version="1" id="O2">
+ <dia:attribute name="obj_pos">
+ <dia:point val="17.7702,13.2656"/>
+ </dia:attribute>
+ <dia:attribute name="obj_bb">
+ <dia:rectangle val="17.6702,13.1656;18.24,13.7354"/>
+ </dia:attribute>
+ <dia:attribute name="meta">
+ <dia:composite type="dict"/>
+ </dia:attribute>
+ <dia:attribute name="elem_corner">
+ <dia:point val="17.7702,13.2656"/>
+ </dia:attribute>
+ <dia:attribute name="elem_width">
+ <dia:real val="0.36980024191863681"/>
+ </dia:attribute>
+ <dia:attribute name="elem_height">
+ <dia:real val="0.36980024191863681"/>
+ </dia:attribute>
+ <dia:attribute name="line_width">
+ <dia:real val="0.10000000000000001"/>
+ </dia:attribute>
+ <dia:attribute name="line_colour">
+ <dia:color val="#000000ff"/>
+ </dia:attribute>
+ <dia:attribute name="fill_colour">
+ <dia:color val="#ffffffff"/>
+ </dia:attribute>
+ <dia:attribute name="show_background">
+ <dia:boolean val="true"/>
+ </dia:attribute>
+ <dia:attribute name="line_style">
+ <dia:enum val="0"/>
+ <dia:real val="1"/>
+ </dia:attribute>
+ <dia:attribute name="flip_horizontal">
+ <dia:boolean val="false"/>
+ </dia:attribute>
+ <dia:attribute name="flip_vertical">
+ <dia:boolean val="false"/>
+ </dia:attribute>
+ <dia:attribute name="subscale">
+ <dia:real val="1"/>
+ </dia:attribute>
+ </dia:object>
+ <dia:object type="Geometric - Perfect Circle" version="1" id="O3">
+ <dia:attribute name="obj_pos">
+ <dia:point val="17.7464,16.2056"/>
+ </dia:attribute>
+ <dia:attribute name="obj_bb">
+ <dia:rectangle val="17.6464,16.1056;18.2162,16.6754"/>
+ </dia:attribute>
+ <dia:attribute name="meta">
+ <dia:composite type="dict"/>
+ </dia:attribute>
+ <dia:attribute name="elem_corner">
+ <dia:point val="17.7464,16.2056"/>
+ </dia:attribute>
+ <dia:attribute name="elem_width">
+ <dia:real val="0.36980024191863681"/>
+ </dia:attribute>
+ <dia:attribute name="elem_height">
+ <dia:real val="0.36980024191863681"/>
+ </dia:attribute>
+ <dia:attribute name="line_width">
+ <dia:real val="0.10000000000000001"/>
+ </dia:attribute>
+ <dia:attribute name="line_colour">
+ <dia:color val="#000000ff"/>
+ </dia:attribute>
+ <dia:attribute name="fill_colour">
+ <dia:color val="#ffffffff"/>
+ </dia:attribute>
+ <dia:attribute name="show_background">
+ <dia:boolean val="true"/>
+ </dia:attribute>
+ <dia:attribute name="line_style">
+ <dia:enum val="0"/>
+ <dia:real val="1"/>
+ </dia:attribute>
+ <dia:attribute name="flip_horizontal">
+ <dia:boolean val="false"/>
+ </dia:attribute>
+ <dia:attribute name="flip_vertical">
+ <dia:boolean val="false"/>
+ </dia:attribute>
+ <dia:attribute name="subscale">
+ <dia:real val="1"/>
+ </dia:attribute>
+ </dia:object>
+ <dia:object type="Standard - Line" version="0" id="O4">
+ <dia:attribute name="obj_pos">
+ <dia:point val="18.1609,16.3413"/>
+ </dia:attribute>
+ <dia:attribute name="obj_bb">
+ <dia:rectangle val="18.1016,14.5712;25.6221,16.4007"/>
+ </dia:attribute>
+ <dia:attribute name="conn_endpoints">
+ <dia:point val="18.1609,16.3413"/>
+ <dia:point val="25.5627,14.7562"/>
+ </dia:attribute>
+ <dia:attribute name="numcp">
+ <dia:int val="1"/>
+ </dia:attribute>
+ <dia:attribute name="line_style">
+ <dia:enum val="1"/>
+ </dia:attribute>
+ <dia:attribute name="end_arrow">
+ <dia:enum val="1"/>
+ </dia:attribute>
+ <dia:attribute name="end_arrow_length">
+ <dia:real val="0.5"/>
+ </dia:attribute>
+ <dia:attribute name="end_arrow_width">
+ <dia:real val="0.5"/>
+ </dia:attribute>
+ <dia:connections>
+ <dia:connection handle="0" to="O3" connection="8"/>
+ <dia:connection handle="1" to="O1" connection="2"/>
+ </dia:connections>
+ </dia:object>
+ <dia:object type="Standard - Line" version="0" id="O5">
+ <dia:attribute name="obj_pos">
+ <dia:point val="18.14,13.4505"/>
+ </dia:attribute>
+ <dia:attribute name="obj_bb">
+ <dia:rectangle val="18.0821,13.3926;25.6206,14.9674"/>
+ </dia:attribute>
+ <dia:attribute name="conn_endpoints">
+ <dia:point val="18.14,13.4505"/>
+ <dia:point val="25.5627,14.7562"/>
+ </dia:attribute>
+ <dia:attribute name="numcp">
+ <dia:int val="1"/>
+ </dia:attribute>
+ <dia:attribute name="end_arrow">
+ <dia:enum val="1"/>
+ </dia:attribute>
+ <dia:attribute name="end_arrow_length">
+ <dia:real val="0.5"/>
+ </dia:attribute>
+ <dia:attribute name="end_arrow_width">
+ <dia:real val="0.5"/>
+ </dia:attribute>
+ <dia:connections>
+ <dia:connection handle="0" to="O2" connection="3"/>
+ <dia:connection handle="1" to="O1" connection="2"/>
+ </dia:connections>
+ </dia:object>
+ <dia:object type="Standard - Line" version="0" id="O6">
+ <dia:attribute name="obj_pos">
+ <dia:point val="25.919,14.7562"/>
+ </dia:attribute>
+ <dia:attribute name="obj_bb">
+ <dia:rectangle val="25.8686,14.3879;31.0068,15.0497"/>
+ </dia:attribute>
+ <dia:attribute name="conn_endpoints">
+ <dia:point val="25.919,14.7562"/>
+ <dia:point val="30.9564,14.7131"/>
+ </dia:attribute>
+ <dia:attribute name="numcp">
+ <dia:int val="1"/>
+ </dia:attribute>
+ <dia:attribute name="end_arrow">
+ <dia:enum val="1"/>
+ </dia:attribute>
+ <dia:attribute name="end_arrow_length">
+ <dia:real val="0.5"/>
+ </dia:attribute>
+ <dia:attribute name="end_arrow_width">
+ <dia:real val="0.5"/>
+ </dia:attribute>
+ <dia:connections>
+ <dia:connection handle="0" to="O1" connection="3"/>
+ </dia:connections>
+ </dia:object>
+ <dia:object type="Standard - Text" version="1" id="O7">
+ <dia:attribute name="obj_pos">
+ <dia:point val="17.9551,13.2656"/>
+ </dia:attribute>
+ <dia:attribute name="obj_bb">
+ <dia:rectangle val="17.9551,12.5181;22.7051,13.2656"/>
+ </dia:attribute>
+ <dia:attribute name="text">
+ <dia:composite type="text">
+ <dia:attribute name="string">
+ <dia:string>#image data (1)#</dia:string>
+ </dia:attribute>
+ <dia:attribute name="font">
+ <dia:font family="sans" style="0" name="Helvetica"/>
+ </dia:attribute>
+ <dia:attribute name="height">
+ <dia:real val="0.80000000000000004"/>
+ </dia:attribute>
+ <dia:attribute name="pos">
+ <dia:point val="17.9551,13.1131"/>
+ </dia:attribute>
+ <dia:attribute name="color">
+ <dia:color val="#000000ff"/>
+ </dia:attribute>
+ <dia:attribute name="alignment">
+ <dia:enum val="0"/>
+ </dia:attribute>
+ </dia:composite>
+ </dia:attribute>
+ <dia:attribute name="valign">
+ <dia:enum val="1"/>
+ </dia:attribute>
+ <dia:connections>
+ <dia:connection handle="0" to="O2" connection="1"/>
+ </dia:connections>
+ </dia:object>
+ <dia:object type="Standard - Text" version="1" id="O8">
+ <dia:attribute name="obj_pos">
+ <dia:point val="17.9313,16.5754"/>
+ </dia:attribute>
+ <dia:attribute name="obj_bb">
+ <dia:rectangle val="17.9313,16.5754;25.1825,17.379"/>
+ </dia:attribute>
+ <dia:attribute name="text">
+ <dia:composite type="text">
+ <dia:attribute name="string">
+ <dia:string>#embedded data (n - 1)#</dia:string>
+ </dia:attribute>
+ <dia:attribute name="font">
+ <dia:font family="sans" style="0" name="Helvetica"/>
+ </dia:attribute>
+ <dia:attribute name="height">
+ <dia:real val="0.80000000000000004"/>
+ </dia:attribute>
+ <dia:attribute name="pos">
+ <dia:point val="17.9313,17.1891"/>
+ </dia:attribute>
+ <dia:attribute name="color">
+ <dia:color val="#000000ff"/>
+ </dia:attribute>
+ <dia:attribute name="alignment">
+ <dia:enum val="0"/>
+ </dia:attribute>
+ </dia:composite>
+ </dia:attribute>
+ <dia:attribute name="valign">
+ <dia:enum val="0"/>
+ </dia:attribute>
+ <dia:connections>
+ <dia:connection handle="0" to="O3" connection="0"/>
+ </dia:connections>
+ </dia:object>
+ <dia:object type="Standard - Text" version="1" id="O9">
+ <dia:attribute name="obj_pos">
+ <dia:point val="26.1,14.125"/>
+ </dia:attribute>
+ <dia:attribute name="obj_bb">
+ <dia:rectangle val="26.1,13.53;30.7475,14.2775"/>
+ </dia:attribute>
+ <dia:attribute name="text">
+ <dia:composite type="text">
+ <dia:attribute name="string">
+ <dia:string>#source pad (0)#</dia:string>
+ </dia:attribute>
+ <dia:attribute name="font">
+ <dia:font family="sans" style="0" name="Helvetica"/>
+ </dia:attribute>
+ <dia:attribute name="height">
+ <dia:real val="0.80000000000000004"/>
+ </dia:attribute>
+ <dia:attribute name="pos">
+ <dia:point val="26.1,14.125"/>
+ </dia:attribute>
+ <dia:attribute name="color">
+ <dia:color val="#000000ff"/>
+ </dia:attribute>
+ <dia:attribute name="alignment">
+ <dia:enum val="0"/>
+ </dia:attribute>
+ </dia:composite>
+ </dia:attribute>
+ <dia:attribute name="valign">
+ <dia:enum val="3"/>
+ </dia:attribute>
+ </dia:object>
+ </dia:layer>
+</dia:diagram>
diff --git a/Documentation/userspace-api/media/v4l/common-raw-sensor.svg b/Documentation/userspace-api/media/v4l/common-raw-sensor.svg
new file mode 100644
index 000000000000..1d6055da2519
--- /dev/null
+++ b/Documentation/userspace-api/media/v4l/common-raw-sensor.svg
@@ -0,0 +1,134 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="296pt" height="142pt" viewBox="0 0 296 142" version="1.1">
+<defs>
+<g>
+<symbol overflow="visible" id="glyph0-0">
+<path style="stroke:none;" d="M 0.640625 2.265625 L 0.640625 -9.015625 L 7.03125 -9.015625 L 7.03125 2.265625 Z M 1.359375 1.546875 L 6.328125 1.546875 L 6.328125 -8.296875 L 1.359375 -8.296875 Z M 1.359375 1.546875 "/>
+</symbol>
+<symbol overflow="visible" id="glyph0-1">
+<path style="stroke:none;" d="M 1.203125 -7 L 2.359375 -7 L 2.359375 0 L 1.203125 0 Z M 1.203125 -9.71875 L 2.359375 -9.71875 L 2.359375 -8.265625 L 1.203125 -8.265625 Z M 1.203125 -9.71875 "/>
+</symbol>
+<symbol overflow="visible" id="glyph0-2">
+<path style="stroke:none;" d="M 6.65625 -5.65625 C 6.9375 -6.164062 7.273438 -6.546875 7.671875 -6.796875 C 8.078125 -7.046875 8.550781 -7.171875 9.09375 -7.171875 C 9.820312 -7.171875 10.382812 -6.914062 10.78125 -6.40625 C 11.175781 -5.894531 11.375 -5.164062 11.375 -4.21875 L 11.375 0 L 10.21875 0 L 10.21875 -4.1875 C 10.21875 -4.851562 10.097656 -5.347656 9.859375 -5.671875 C 9.628906 -6.003906 9.269531 -6.171875 8.78125 -6.171875 C 8.1875 -6.171875 7.710938 -5.972656 7.359375 -5.578125 C 7.015625 -5.179688 6.84375 -4.640625 6.84375 -3.953125 L 6.84375 0 L 5.6875 0 L 5.6875 -4.1875 C 5.6875 -4.863281 5.566406 -5.363281 5.328125 -5.6875 C 5.097656 -6.007812 4.734375 -6.171875 4.234375 -6.171875 C 3.648438 -6.171875 3.179688 -5.96875 2.828125 -5.5625 C 2.484375 -5.164062 2.3125 -4.628906 2.3125 -3.953125 L 2.3125 0 L 1.15625 0 L 1.15625 -7 L 2.3125 -7 L 2.3125 -5.90625 C 2.582031 -6.332031 2.898438 -6.648438 3.265625 -6.859375 C 3.628906 -7.066406 4.0625 -7.171875 4.5625 -7.171875 C 5.070312 -7.171875 5.503906 -7.039062 5.859375 -6.78125 C 6.222656 -6.519531 6.488281 -6.144531 6.65625 -5.65625 Z M 6.65625 -5.65625 "/>
+</symbol>
+<symbol overflow="visible" id="glyph0-3">
+<path style="stroke:none;" d="M 4.390625 -3.515625 C 3.460938 -3.515625 2.816406 -3.40625 2.453125 -3.1875 C 2.097656 -2.976562 1.921875 -2.617188 1.921875 -2.109375 C 1.921875 -1.703125 2.050781 -1.378906 2.3125 -1.140625 C 2.582031 -0.898438 2.953125 -0.78125 3.421875 -0.78125 C 4.054688 -0.78125 4.566406 -1.003906 4.953125 -1.453125 C 5.335938 -1.910156 5.53125 -2.515625 5.53125 -3.265625 L 5.53125 -3.515625 Z M 6.671875 -4 L 6.671875 0 L 5.53125 0 L 5.53125 -1.0625 C 5.269531 -0.632812 4.941406 -0.316406 4.546875 -0.109375 C 4.160156 0.0859375 3.679688 0.1875 3.109375 0.1875 C 2.390625 0.1875 1.816406 -0.015625 1.390625 -0.421875 C 0.972656 -0.828125 0.765625 -1.363281 0.765625 -2.03125 C 0.765625 -2.820312 1.023438 -3.414062 1.546875 -3.8125 C 2.078125 -4.21875 2.867188 -4.421875 3.921875 -4.421875 L 5.53125 -4.421875 L 5.53125 -4.53125 C 5.53125 -5.0625 5.351562 -5.46875 5 -5.75 C 4.65625 -6.039062 4.171875 -6.1875 3.546875 -6.1875 C 3.140625 -6.1875 2.75 -6.140625 2.375 -6.046875 C 2 -5.953125 1.632812 -5.8125 1.28125 -5.625 L 1.28125 -6.671875 C 1.695312 -6.835938 2.101562 -6.960938 2.5 -7.046875 C 2.894531 -7.128906 3.28125 -7.171875 3.65625 -7.171875 C 4.675781 -7.171875 5.429688 -6.90625 5.921875 -6.375 C 6.421875 -5.851562 6.671875 -5.0625 6.671875 -4 Z M 6.671875 -4 "/>
+</symbol>
+<symbol overflow="visible" id="glyph0-4">
+<path style="stroke:none;" d="M 5.8125 -3.578125 C 5.8125 -4.410156 5.640625 -5.054688 5.296875 -5.515625 C 4.953125 -5.972656 4.46875 -6.203125 3.84375 -6.203125 C 3.226562 -6.203125 2.75 -5.972656 2.40625 -5.515625 C 2.0625 -5.054688 1.890625 -4.410156 1.890625 -3.578125 C 1.890625 -2.753906 2.0625 -2.113281 2.40625 -1.65625 C 2.75 -1.195312 3.226562 -0.96875 3.84375 -0.96875 C 4.46875 -0.96875 4.953125 -1.195312 5.296875 -1.65625 C 5.640625 -2.113281 5.8125 -2.753906 5.8125 -3.578125 Z M 6.953125 -0.875 C 6.953125 0.320312 6.6875 1.207031 6.15625 1.78125 C 5.632812 2.363281 4.828125 2.65625 3.734375 2.65625 C 3.328125 2.65625 2.945312 2.625 2.59375 2.5625 C 2.238281 2.507812 1.890625 2.421875 1.546875 2.296875 L 1.546875 1.171875 C 1.890625 1.359375 2.222656 1.492188 2.546875 1.578125 C 2.878906 1.671875 3.21875 1.71875 3.5625 1.71875 C 4.3125 1.71875 4.875 1.519531 5.25 1.125 C 5.625 0.726562 5.8125 0.132812 5.8125 -0.65625 L 5.8125 -1.234375 C 5.570312 -0.816406 5.265625 -0.503906 4.890625 -0.296875 C 4.523438 -0.0976562 4.082031 0 3.5625 0 C 2.707031 0 2.015625 -0.328125 1.484375 -0.984375 C 0.960938 -1.640625 0.703125 -2.503906 0.703125 -3.578125 C 0.703125 -4.660156 0.960938 -5.53125 1.484375 -6.1875 C 2.015625 -6.84375 2.707031 -7.171875 3.5625 -7.171875 C 4.082031 -7.171875 4.523438 -7.066406 4.890625 -6.859375 C 5.265625 -6.648438 5.570312 -6.34375 5.8125 -5.9375 L 5.8125 -7 L 6.953125 -7 Z M 6.953125 -0.875 "/>
+</symbol>
+<symbol overflow="visible" id="glyph0-5">
+<path style="stroke:none;" d="M 7.1875 -3.78125 L 7.1875 -3.21875 L 1.90625 -3.21875 C 1.957031 -2.425781 2.195312 -1.820312 2.625 -1.40625 C 3.050781 -1 3.644531 -0.796875 4.40625 -0.796875 C 4.84375 -0.796875 5.269531 -0.847656 5.6875 -0.953125 C 6.101562 -1.066406 6.515625 -1.226562 6.921875 -1.4375 L 6.921875 -0.359375 C 6.515625 -0.179688 6.09375 -0.046875 5.65625 0.046875 C 5.21875 0.140625 4.78125 0.1875 4.34375 0.1875 C 3.21875 0.1875 2.328125 -0.132812 1.671875 -0.78125 C 1.023438 -1.4375 0.703125 -2.320312 0.703125 -3.4375 C 0.703125 -4.582031 1.007812 -5.488281 1.625 -6.15625 C 2.25 -6.832031 3.085938 -7.171875 4.140625 -7.171875 C 5.078125 -7.171875 5.816406 -6.863281 6.359375 -6.25 C 6.910156 -5.644531 7.1875 -4.820312 7.1875 -3.78125 Z M 6.046875 -4.125 C 6.035156 -4.75 5.859375 -5.25 5.515625 -5.625 C 5.171875 -6 4.71875 -6.1875 4.15625 -6.1875 C 3.507812 -6.1875 2.992188 -6.003906 2.609375 -5.640625 C 2.222656 -5.285156 2 -4.78125 1.9375 -4.125 Z M 6.046875 -4.125 "/>
+</symbol>
+<symbol overflow="visible" id="glyph0-6">
+<path style="stroke:none;" d=""/>
+</symbol>
+<symbol overflow="visible" id="glyph0-7">
+<path style="stroke:none;" d="M 5.8125 -5.9375 L 5.8125 -9.71875 L 6.953125 -9.71875 L 6.953125 0 L 5.8125 0 L 5.8125 -1.046875 C 5.570312 -0.628906 5.265625 -0.316406 4.890625 -0.109375 C 4.523438 0.0859375 4.082031 0.1875 3.5625 0.1875 C 2.71875 0.1875 2.03125 -0.148438 1.5 -0.828125 C 0.96875 -1.503906 0.703125 -2.394531 0.703125 -3.5 C 0.703125 -4.59375 0.96875 -5.476562 1.5 -6.15625 C 2.03125 -6.832031 2.71875 -7.171875 3.5625 -7.171875 C 4.082031 -7.171875 4.523438 -7.066406 4.890625 -6.859375 C 5.265625 -6.660156 5.570312 -6.351562 5.8125 -5.9375 Z M 1.890625 -3.5 C 1.890625 -2.644531 2.0625 -1.976562 2.40625 -1.5 C 2.757812 -1.019531 3.238281 -0.78125 3.84375 -0.78125 C 4.457031 -0.78125 4.9375 -1.019531 5.28125 -1.5 C 5.632812 -1.976562 5.8125 -2.644531 5.8125 -3.5 C 5.8125 -4.34375 5.632812 -5.003906 5.28125 -5.484375 C 4.9375 -5.960938 4.457031 -6.203125 3.84375 -6.203125 C 3.238281 -6.203125 2.757812 -5.960938 2.40625 -5.484375 C 2.0625 -5.003906 1.890625 -4.34375 1.890625 -3.5 Z M 1.890625 -3.5 "/>
+</symbol>
+<symbol overflow="visible" id="glyph0-8">
+<path style="stroke:none;" d="M 2.34375 -8.984375 L 2.34375 -7 L 4.71875 -7 L 4.71875 -6.109375 L 2.34375 -6.109375 L 2.34375 -2.3125 C 2.34375 -1.738281 2.421875 -1.367188 2.578125 -1.203125 C 2.734375 -1.046875 3.050781 -0.96875 3.53125 -0.96875 L 4.71875 -0.96875 L 4.71875 0 L 3.53125 0 C 2.644531 0 2.03125 -0.164062 1.6875 -0.5 C 1.351562 -0.832031 1.1875 -1.4375 1.1875 -2.3125 L 1.1875 -6.109375 L 0.34375 -6.109375 L 0.34375 -7 L 1.1875 -7 L 1.1875 -8.984375 Z M 2.34375 -8.984375 "/>
+</symbol>
+<symbol overflow="visible" id="glyph0-9">
+<path style="stroke:none;" d="M 3.96875 -9.703125 C 3.40625 -8.742188 2.988281 -7.796875 2.71875 -6.859375 C 2.445312 -5.929688 2.3125 -4.984375 2.3125 -4.015625 C 2.3125 -3.054688 2.445312 -2.101562 2.71875 -1.15625 C 3 -0.21875 3.414062 0.726562 3.96875 1.6875 L 2.96875 1.6875 C 2.34375 0.707031 1.875 -0.253906 1.5625 -1.203125 C 1.25 -2.148438 1.09375 -3.085938 1.09375 -4.015625 C 1.09375 -4.941406 1.25 -5.875 1.5625 -6.8125 C 1.875 -7.757812 2.34375 -8.722656 2.96875 -9.703125 Z M 3.96875 -9.703125 "/>
+</symbol>
+<symbol overflow="visible" id="glyph0-10">
+<path style="stroke:none;" d="M 1.59375 -1.0625 L 3.65625 -1.0625 L 3.65625 -8.171875 L 1.40625 -7.734375 L 1.40625 -8.875 L 3.640625 -9.328125 L 4.90625 -9.328125 L 4.90625 -1.0625 L 6.953125 -1.0625 L 6.953125 0 L 1.59375 0 Z M 1.59375 -1.0625 "/>
+</symbol>
+<symbol overflow="visible" id="glyph0-11">
+<path style="stroke:none;" d="M 1.03125 -9.703125 L 2.03125 -9.703125 C 2.65625 -8.722656 3.117188 -7.757812 3.421875 -6.8125 C 3.734375 -5.875 3.890625 -4.941406 3.890625 -4.015625 C 3.890625 -3.085938 3.734375 -2.148438 3.421875 -1.203125 C 3.117188 -0.253906 2.65625 0.707031 2.03125 1.6875 L 1.03125 1.6875 C 1.582031 0.726562 1.992188 -0.21875 2.265625 -1.15625 C 2.535156 -2.101562 2.671875 -3.054688 2.671875 -4.015625 C 2.671875 -4.984375 2.535156 -5.929688 2.265625 -6.859375 C 1.992188 -7.796875 1.582031 -8.742188 1.03125 -9.703125 Z M 1.03125 -9.703125 "/>
+</symbol>
+<symbol overflow="visible" id="glyph0-12">
+<path style="stroke:none;" d="M 6.234375 -3.5 C 6.234375 -4.34375 6.054688 -5.003906 5.703125 -5.484375 C 5.359375 -5.960938 4.882812 -6.203125 4.28125 -6.203125 C 3.664062 -6.203125 3.179688 -5.960938 2.828125 -5.484375 C 2.484375 -5.003906 2.3125 -4.34375 2.3125 -3.5 C 2.3125 -2.644531 2.484375 -1.976562 2.828125 -1.5 C 3.179688 -1.019531 3.664062 -0.78125 4.28125 -0.78125 C 4.882812 -0.78125 5.359375 -1.019531 5.703125 -1.5 C 6.054688 -1.976562 6.234375 -2.644531 6.234375 -3.5 Z M 2.3125 -5.9375 C 2.5625 -6.351562 2.867188 -6.660156 3.234375 -6.859375 C 3.597656 -7.066406 4.039062 -7.171875 4.5625 -7.171875 C 5.40625 -7.171875 6.09375 -6.832031 6.625 -6.15625 C 7.15625 -5.476562 7.421875 -4.59375 7.421875 -3.5 C 7.421875 -2.394531 7.15625 -1.503906 6.625 -0.828125 C 6.09375 -0.148438 5.40625 0.1875 4.5625 0.1875 C 4.039062 0.1875 3.597656 0.0859375 3.234375 -0.109375 C 2.867188 -0.316406 2.5625 -0.628906 2.3125 -1.046875 L 2.3125 0 L 1.15625 0 L 1.15625 -9.71875 L 2.3125 -9.71875 Z M 2.3125 -5.9375 "/>
+</symbol>
+<symbol overflow="visible" id="glyph0-13">
+<path style="stroke:none;" d="M 2.453125 -1.0625 L 6.859375 -1.0625 L 6.859375 0 L 0.9375 0 L 0.9375 -1.0625 C 1.414062 -1.5625 2.066406 -2.226562 2.890625 -3.0625 C 3.722656 -3.894531 4.242188 -4.429688 4.453125 -4.671875 C 4.859375 -5.128906 5.140625 -5.515625 5.296875 -5.828125 C 5.460938 -6.140625 5.546875 -6.445312 5.546875 -6.75 C 5.546875 -7.25 5.367188 -7.65625 5.015625 -7.96875 C 4.671875 -8.28125 4.21875 -8.4375 3.65625 -8.4375 C 3.257812 -8.4375 2.84375 -8.363281 2.40625 -8.21875 C 1.96875 -8.082031 1.5 -7.878906 1 -7.609375 L 1 -8.875 C 1.507812 -9.082031 1.984375 -9.238281 2.421875 -9.34375 C 2.867188 -9.445312 3.273438 -9.5 3.640625 -9.5 C 4.609375 -9.5 5.378906 -9.253906 5.953125 -8.765625 C 6.523438 -8.285156 6.8125 -7.640625 6.8125 -6.828125 C 6.8125 -6.453125 6.738281 -6.09375 6.59375 -5.75 C 6.445312 -5.40625 6.1875 -5 5.8125 -4.53125 C 5.707031 -4.40625 5.375 -4.054688 4.8125 -3.484375 C 4.257812 -2.910156 3.472656 -2.101562 2.453125 -1.0625 Z M 2.453125 -1.0625 "/>
+</symbol>
+<symbol overflow="visible" id="glyph0-14">
+<path style="stroke:none;" d="M 5.671875 -6.796875 L 5.671875 -5.703125 C 5.347656 -5.867188 5.007812 -5.992188 4.65625 -6.078125 C 4.300781 -6.160156 3.9375 -6.203125 3.5625 -6.203125 C 3 -6.203125 2.570312 -6.113281 2.28125 -5.9375 C 2 -5.769531 1.859375 -5.507812 1.859375 -5.15625 C 1.859375 -4.882812 1.957031 -4.671875 2.15625 -4.515625 C 2.363281 -4.367188 2.773438 -4.226562 3.390625 -4.09375 L 3.78125 -4 C 4.601562 -3.832031 5.1875 -3.585938 5.53125 -3.265625 C 5.875 -2.941406 6.046875 -2.5 6.046875 -1.9375 C 6.046875 -1.28125 5.785156 -0.757812 5.265625 -0.375 C 4.753906 0 4.050781 0.1875 3.15625 0.1875 C 2.78125 0.1875 2.390625 0.148438 1.984375 0.078125 C 1.578125 0.00390625 1.144531 -0.101562 0.6875 -0.25 L 0.6875 -1.4375 C 1.113281 -1.21875 1.53125 -1.050781 1.9375 -0.9375 C 2.351562 -0.832031 2.765625 -0.78125 3.171875 -0.78125 C 3.710938 -0.78125 4.128906 -0.875 4.421875 -1.0625 C 4.710938 -1.25 4.859375 -1.507812 4.859375 -1.84375 C 4.859375 -2.15625 4.753906 -2.394531 4.546875 -2.5625 C 4.335938 -2.726562 3.875 -2.890625 3.15625 -3.046875 L 2.765625 -3.140625 C 2.046875 -3.285156 1.53125 -3.515625 1.21875 -3.828125 C 0.90625 -4.140625 0.75 -4.566406 0.75 -5.109375 C 0.75 -5.765625 0.976562 -6.269531 1.4375 -6.625 C 1.90625 -6.988281 2.570312 -7.171875 3.4375 -7.171875 C 3.851562 -7.171875 4.25 -7.140625 4.625 -7.078125 C 5 -7.015625 5.347656 -6.921875 5.671875 -6.796875 Z M 5.671875 -6.796875 "/>
+</symbol>
+<symbol overflow="visible" id="glyph0-15">
+<path style="stroke:none;" d="M 3.921875 -6.1875 C 3.304688 -6.1875 2.816406 -5.945312 2.453125 -5.46875 C 2.097656 -4.988281 1.921875 -4.332031 1.921875 -3.5 C 1.921875 -2.65625 2.097656 -1.992188 2.453125 -1.515625 C 2.804688 -1.035156 3.296875 -0.796875 3.921875 -0.796875 C 4.535156 -0.796875 5.019531 -1.035156 5.375 -1.515625 C 5.726562 -2.003906 5.90625 -2.664062 5.90625 -3.5 C 5.90625 -4.320312 5.726562 -4.972656 5.375 -5.453125 C 5.019531 -5.941406 4.535156 -6.1875 3.921875 -6.1875 Z M 3.921875 -7.171875 C 4.921875 -7.171875 5.703125 -6.84375 6.265625 -6.1875 C 6.835938 -5.539062 7.125 -4.644531 7.125 -3.5 C 7.125 -2.351562 6.835938 -1.453125 6.265625 -0.796875 C 5.703125 -0.140625 4.921875 0.1875 3.921875 0.1875 C 2.910156 0.1875 2.117188 -0.140625 1.546875 -0.796875 C 0.984375 -1.453125 0.703125 -2.351562 0.703125 -3.5 C 0.703125 -4.644531 0.984375 -5.539062 1.546875 -6.1875 C 2.117188 -6.84375 2.910156 -7.171875 3.921875 -7.171875 Z M 3.921875 -7.171875 "/>
+</symbol>
+<symbol overflow="visible" id="glyph0-16">
+<path style="stroke:none;" d="M 1.09375 -2.765625 L 1.09375 -7 L 2.234375 -7 L 2.234375 -2.8125 C 2.234375 -2.144531 2.363281 -1.644531 2.625 -1.3125 C 2.882812 -0.976562 3.269531 -0.8125 3.78125 -0.8125 C 4.40625 -0.8125 4.894531 -1.007812 5.25 -1.40625 C 5.613281 -1.800781 5.796875 -2.34375 5.796875 -3.03125 L 5.796875 -7 L 6.953125 -7 L 6.953125 0 L 5.796875 0 L 5.796875 -1.078125 C 5.515625 -0.648438 5.191406 -0.332031 4.828125 -0.125 C 4.460938 0.0820312 4.035156 0.1875 3.546875 0.1875 C 2.742188 0.1875 2.132812 -0.0625 1.71875 -0.5625 C 1.300781 -1.0625 1.09375 -1.796875 1.09375 -2.765625 Z M 3.984375 -7.171875 Z M 3.984375 -7.171875 "/>
+</symbol>
+<symbol overflow="visible" id="glyph0-17">
+<path style="stroke:none;" d="M 5.265625 -5.921875 C 5.128906 -5.992188 4.984375 -6.046875 4.828125 -6.078125 C 4.679688 -6.117188 4.519531 -6.140625 4.34375 -6.140625 C 3.6875 -6.140625 3.179688 -5.925781 2.828125 -5.5 C 2.484375 -5.082031 2.3125 -4.476562 2.3125 -3.6875 L 2.3125 0 L 1.15625 0 L 1.15625 -7 L 2.3125 -7 L 2.3125 -5.90625 C 2.5625 -6.332031 2.878906 -6.648438 3.265625 -6.859375 C 3.648438 -7.066406 4.117188 -7.171875 4.671875 -7.171875 C 4.753906 -7.171875 4.84375 -7.164062 4.9375 -7.15625 C 5.03125 -7.144531 5.132812 -7.128906 5.25 -7.109375 Z M 5.265625 -5.921875 "/>
+</symbol>
+<symbol overflow="visible" id="glyph0-18">
+<path style="stroke:none;" d="M 6.25 -6.734375 L 6.25 -5.65625 C 5.914062 -5.832031 5.585938 -5.960938 5.265625 -6.046875 C 4.941406 -6.140625 4.613281 -6.1875 4.28125 -6.1875 C 3.53125 -6.1875 2.945312 -5.953125 2.53125 -5.484375 C 2.125 -5.015625 1.921875 -4.351562 1.921875 -3.5 C 1.921875 -2.644531 2.125 -1.976562 2.53125 -1.5 C 2.945312 -1.03125 3.53125 -0.796875 4.28125 -0.796875 C 4.613281 -0.796875 4.941406 -0.835938 5.265625 -0.921875 C 5.585938 -1.015625 5.914062 -1.148438 6.25 -1.328125 L 6.25 -0.265625 C 5.925781 -0.117188 5.59375 -0.0078125 5.25 0.0625 C 4.90625 0.144531 4.539062 0.1875 4.15625 0.1875 C 3.09375 0.1875 2.25 -0.144531 1.625 -0.8125 C 1.007812 -1.476562 0.703125 -2.375 0.703125 -3.5 C 0.703125 -4.632812 1.015625 -5.53125 1.640625 -6.1875 C 2.273438 -6.84375 3.132812 -7.171875 4.21875 -7.171875 C 4.570312 -7.171875 4.914062 -7.132812 5.25 -7.0625 C 5.59375 -6.988281 5.925781 -6.878906 6.25 -6.734375 Z M 6.25 -6.734375 "/>
+</symbol>
+<symbol overflow="visible" id="glyph0-19">
+<path style="stroke:none;" d="M 2.3125 -1.046875 L 2.3125 2.65625 L 1.15625 2.65625 L 1.15625 -7 L 2.3125 -7 L 2.3125 -5.9375 C 2.5625 -6.351562 2.867188 -6.660156 3.234375 -6.859375 C 3.597656 -7.066406 4.039062 -7.171875 4.5625 -7.171875 C 5.40625 -7.171875 6.09375 -6.832031 6.625 -6.15625 C 7.15625 -5.476562 7.421875 -4.59375 7.421875 -3.5 C 7.421875 -2.394531 7.15625 -1.503906 6.625 -0.828125 C 6.09375 -0.148438 5.40625 0.1875 4.5625 0.1875 C 4.039062 0.1875 3.597656 0.0859375 3.234375 -0.109375 C 2.867188 -0.316406 2.5625 -0.628906 2.3125 -1.046875 Z M 6.234375 -3.5 C 6.234375 -4.34375 6.054688 -5.003906 5.703125 -5.484375 C 5.359375 -5.960938 4.882812 -6.203125 4.28125 -6.203125 C 3.664062 -6.203125 3.179688 -5.960938 2.828125 -5.484375 C 2.484375 -5.003906 2.3125 -4.34375 2.3125 -3.5 C 2.3125 -2.644531 2.484375 -1.976562 2.828125 -1.5 C 3.179688 -1.019531 3.664062 -0.78125 4.28125 -0.78125 C 4.882812 -0.78125 5.359375 -1.019531 5.703125 -1.5 C 6.054688 -1.976562 6.234375 -2.644531 6.234375 -3.5 Z M 6.234375 -3.5 "/>
+</symbol>
+<symbol overflow="visible" id="glyph0-20">
+<path style="stroke:none;" d="M 4.0625 -8.5 C 3.414062 -8.5 2.925781 -8.175781 2.59375 -7.53125 C 2.269531 -6.894531 2.109375 -5.9375 2.109375 -4.65625 C 2.109375 -3.375 2.269531 -2.410156 2.59375 -1.765625 C 2.925781 -1.128906 3.414062 -0.8125 4.0625 -0.8125 C 4.71875 -0.8125 5.207031 -1.128906 5.53125 -1.765625 C 5.863281 -2.410156 6.03125 -3.375 6.03125 -4.65625 C 6.03125 -5.9375 5.863281 -6.894531 5.53125 -7.53125 C 5.207031 -8.175781 4.71875 -8.5 4.0625 -8.5 Z M 4.0625 -9.5 C 5.113281 -9.5 5.914062 -9.082031 6.46875 -8.25 C 7.019531 -7.425781 7.296875 -6.226562 7.296875 -4.65625 C 7.296875 -3.082031 7.019531 -1.878906 6.46875 -1.046875 C 5.914062 -0.222656 5.113281 0.1875 4.0625 0.1875 C 3.019531 0.1875 2.222656 -0.222656 1.671875 -1.046875 C 1.117188 -1.878906 0.84375 -3.082031 0.84375 -4.65625 C 0.84375 -6.226562 1.117188 -7.425781 1.671875 -8.25 C 2.222656 -9.082031 3.019531 -9.5 4.0625 -9.5 Z M 4.0625 -9.5 "/>
+</symbol>
+</g>
+</defs>
+<g id="surface11910">
+<rect x="0" y="0" width="296" height="142" style="fill:rgb(100%,100%,100%);fill-opacity:1;stroke:none;"/>
+<path style="fill-rule:evenodd;fill:rgb(100%,100%,100%);fill-opacity:1;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;" d="M 16.35 11.5 L 25.75 11.5 L 25.75 18.4 L 16.35 18.4 Z M 16.35 11.5 " transform="matrix(20,0,0,20,-325,-228)"/>
+<path style="fill-rule:evenodd;fill:rgb(100%,100%,100%);fill-opacity:1;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;" d="M 25.919141 14.75625 C 25.919141 14.99375 25.562695 14.99375 25.562695 14.75625 C 25.562695 14.518555 25.919141 14.518555 25.919141 14.75625 " transform="matrix(20,0,0,20,-325,-228)"/>
+<path style="fill-rule:evenodd;fill:rgb(100%,100%,100%);fill-opacity:1;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;" d="M 18.140039 13.450586 C 18.140039 13.69707 17.770117 13.69707 17.770117 13.450586 C 17.770117 13.203906 18.140039 13.203906 18.140039 13.450586 " transform="matrix(20,0,0,20,-325,-228)"/>
+<path style="fill-rule:evenodd;fill:rgb(100%,100%,100%);fill-opacity:1;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;" d="M 18.116211 16.39043 C 18.116211 16.637109 17.746484 16.637109 17.746484 16.39043 C 17.746484 16.143945 18.116211 16.143945 18.116211 16.39043 " transform="matrix(20,0,0,20,-325,-228)"/>
+<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-dasharray:1,1;stroke-miterlimit:10;" d="M 18.160937 16.341406 L 25.344141 14.80293 " transform="matrix(20,0,0,20,-325,-228)"/>
+<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;" d="M 25.016797 15.128711 L 25.45332 14.779687 L 24.912109 14.639844 " transform="matrix(20,0,0,20,-325,-228)"/>
+<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;" d="M 18.140039 13.450586 L 25.342383 14.717383 " transform="matrix(20,0,0,20,-325,-228)"/>
+<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;" d="M 24.916797 14.896484 L 25.452539 14.736914 L 25.003516 14.403906 " transform="matrix(20,0,0,20,-325,-228)"/>
+<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;" d="M 25.918945 14.75625 L 30.732813 14.715039 " transform="matrix(20,0,0,20,-325,-228)"/>
+<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;" d="M 30.34668 14.968359 L 30.844531 14.714062 L 30.342383 14.468359 " transform="matrix(20,0,0,20,-325,-228)"/>
+<g style="fill:rgb(0%,0%,0%);fill-opacity:1;">
+ <use xlink:href="#glyph0-1" x="34.101562" y="34.267687"/>
+ <use xlink:href="#glyph0-2" x="37.712674" y="34.267687"/>
+ <use xlink:href="#glyph0-3" x="50.212674" y="34.267687"/>
+ <use xlink:href="#glyph0-4" x="57.990451" y="34.267687"/>
+ <use xlink:href="#glyph0-5" x="66.046007" y="34.267687"/>
+ <use xlink:href="#glyph0-6" x="73.823785" y="34.267687"/>
+ <use xlink:href="#glyph0-7" x="77.990451" y="34.267687"/>
+ <use xlink:href="#glyph0-3" x="86.046007" y="34.267687"/>
+ <use xlink:href="#glyph0-8" x="93.823785" y="34.267687"/>
+ <use xlink:href="#glyph0-3" x="98.823785" y="34.267687"/>
+ <use xlink:href="#glyph0-6" x="106.601562" y="34.267687"/>
+ <use xlink:href="#glyph0-9" x="110.768229" y="34.267687"/>
+ <use xlink:href="#glyph0-10" x="115.768229" y="34.267687"/>
+ <use xlink:href="#glyph0-11" x="123.823785" y="34.267687"/>
+</g>
+<g style="fill:rgb(0%,0%,0%);fill-opacity:1;">
+ <use xlink:href="#glyph0-5" x="33.625" y="115.412218"/>
+ <use xlink:href="#glyph0-2" x="41.402778" y="115.412218"/>
+ <use xlink:href="#glyph0-12" x="53.902778" y="115.412218"/>
+ <use xlink:href="#glyph0-5" x="61.958333" y="115.412218"/>
+ <use xlink:href="#glyph0-7" x="69.736111" y="115.412218"/>
+ <use xlink:href="#glyph0-7" x="77.791667" y="115.412218"/>
+ <use xlink:href="#glyph0-5" x="85.847222" y="115.412218"/>
+ <use xlink:href="#glyph0-7" x="93.625" y="115.412218"/>
+ <use xlink:href="#glyph0-6" x="101.680556" y="115.412218"/>
+ <use xlink:href="#glyph0-7" x="105.847222" y="115.412218"/>
+ <use xlink:href="#glyph0-3" x="113.902778" y="115.412218"/>
+ <use xlink:href="#glyph0-8" x="121.680556" y="115.412218"/>
+ <use xlink:href="#glyph0-3" x="126.680556" y="115.412218"/>
+ <use xlink:href="#glyph0-6" x="134.458333" y="115.412218"/>
+ <use xlink:href="#glyph0-9" x="138.625" y="115.412218"/>
+ <use xlink:href="#glyph0-13" x="143.625" y="115.412218"/>
+ <use xlink:href="#glyph0-11" x="151.680556" y="115.412218"/>
+</g>
+<g style="fill:rgb(0%,0%,0%);fill-opacity:1;">
+ <use xlink:href="#glyph0-14" x="197" y="54.505968"/>
+ <use xlink:href="#glyph0-15" x="203.666667" y="54.505968"/>
+ <use xlink:href="#glyph0-16" x="211.444444" y="54.505968"/>
+ <use xlink:href="#glyph0-17" x="219.5" y="54.505968"/>
+ <use xlink:href="#glyph0-18" x="224.5" y="54.505968"/>
+ <use xlink:href="#glyph0-5" x="231.444444" y="54.505968"/>
+ <use xlink:href="#glyph0-6" x="239.222222" y="54.505968"/>
+ <use xlink:href="#glyph0-19" x="243.388889" y="54.505968"/>
+ <use xlink:href="#glyph0-3" x="251.444444" y="54.505968"/>
+ <use xlink:href="#glyph0-7" x="259.222222" y="54.505968"/>
+ <use xlink:href="#glyph0-6" x="267.277778" y="54.505968"/>
+ <use xlink:href="#glyph0-9" x="271.444444" y="54.505968"/>
+ <use xlink:href="#glyph0-20" x="276.444444" y="54.505968"/>
+ <use xlink:href="#glyph0-11" x="284.5" y="54.505968"/>
+</g>
+</g>
+</svg>
diff --git a/Documentation/userspace-api/media/v4l/dev-subdev.rst b/Documentation/userspace-api/media/v4l/dev-subdev.rst
index 9168a3a45c9e..3472b0591d79 100644
--- a/Documentation/userspace-api/media/v4l/dev-subdev.rst
+++ b/Documentation/userspace-api/media/v4l/dev-subdev.rst
@@ -721,7 +721,8 @@ To configure this pipeline, the userspace must take the following steps:
:ref:`VIDIOC_SUBDEV_S_FMT <VIDIOC_SUBDEV_G_FMT>` ioctls to configure each
stream endpoint in each sub-device.
- In case generic raw and metadata formats are used, :ref:`V4L2_CID_CFA_PATTERN
- <image-source-control-cfa-pattern>` and :ref:`V4L2_CID_METADATA_LAYOUT
- <image_source_control_metadata_layout>` controls are present on the source
- sub-device to obtain the pixel array CFA pattern and metadata layout.
+ In case generic raw and metadata formats are used,
+ :ref:`V4L2_CID_CFA_PATTERN <image-source-control-cfa-pattern>` and
+ :ref:`V4L2_CID_METADATA_LAYOUT <image_source_control_metadata_layout>`
+ controls are present on the source sub-device to obtain the pixel array CFA
+ pattern and metadata layout.
diff --git a/Documentation/userspace-api/media/v4l/devices.rst b/Documentation/userspace-api/media/v4l/devices.rst
index d4790b9ef81a..4d6b7b55b0b3 100644
--- a/Documentation/userspace-api/media/v4l/devices.rst
+++ b/Documentation/userspace-api/media/v4l/devices.rst
@@ -24,4 +24,5 @@ Interfaces
dev-touch
dev-event
dev-subdev
+ subdev-config-model
dev-meta
diff --git a/Documentation/userspace-api/media/v4l/subdev-config-model.rst b/Documentation/userspace-api/media/v4l/subdev-config-model.rst
new file mode 100644
index 000000000000..cbd12986b977
--- /dev/null
+++ b/Documentation/userspace-api/media/v4l/subdev-config-model.rst
@@ -0,0 +1,250 @@
+.. SPDX-License-Identifier: GPL-2.0 OR GFDL-1.1-no-invariants-or-later
+
+.. _media_subdev_config_model:
+
+Sub-device configuration models
+===============================
+
+The V4L2 specification defines a subdev API that exposes three type of
+configuration elements: formats, selection rectangles and controls. The
+specification contains generic information about how those configuration
+elements behave, but not precisely how they apply to particular hardware
+features. We leave some leeway to drivers to decide how to map selection
+rectangles to device features, as long as they comply with the V4L2
+specification. This is needed as hardware features differ between devices, so
+it's the driver's responsibility to handle this mapping.
+
+Unfortunately, this lack of clearly defined mapping in the specification has led
+to different drivers mapping the same hardware features to different API
+elements, or implementing the API elements with slightly different
+behaviours. Furthermore, many drivers have implemented selection rectangles in
+ways that do not comply with the V4L2 specification. All of this makes userspace
+development difficult.
+
+Sub-device configuration models specify in detail what the user space can expect
+from a sub-device in terms of V4L2 sub-device interface support, semantics
+included.
+
+A sub-device may implement more than one configuration model at the same
+time. The implemented configuration models can be obtained from the sub-device's
+``V4L2_CID_CONFIG_MODEL`` control.
+
+.. _media_subdev_config_model_common_raw_sensor:
+
+Common raw camera sensor model
+------------------------------
+
+The common raw camera sensor model defines a set of enumeration and
+configuration interfaces (formats, selections etc.) that cover the vast majority
+of functionality of raw camera sensors. Not all of the interfaces are
+necessarily offered by all drivers.
+
+A sub-device complies with the common raw sensor model if the
+``V4L2_CONFIG_MODEL_COMMON_RAW_SENSOR`` bit is set in the
+``V4L2_CID_CONFIG_MODEL`` control of the sub-device.
+
+The common raw camera sensor model is aligned with
+:ref:`media_using_camera_sensor_drivers`. Please refer to that regarding aspects
+not specified here.
+
+Each camera sensor implementing the common raw sensor model exposes a single
+V4L2 sub-device. The sub-device contains a single source pad (0) and two or more
+internal pads: one or more image data internal pads (starting from 1) and
+optionally an embedded data pad.
+
+Additionally, further internal pads may be supported for other features. Using
+more than one image data internal pad or more than one non-image data pad
+requires these pads documented separately for the given device. The indices of
+the image data internal pads shall be lower than those of the non-image data
+pads.
+
+This is shown in :ref:`media_subdev_config_model_common_raw_sensor_subdev`.
+
+.. _media_subdev_config_model_common_raw_sensor_subdev:
+
+.. kernel-figure:: common-raw-sensor.svg
+ :alt: common-raw-sensor.svg
+ :align: center
+
+ **Common raw sensor sub-device with two pads**
+
+Routes
+^^^^^^
+
+A sub-device conforming to common raw camera sensor model implements the
+following routes.
+
+.. flat-table:: Routes
+ :header-rows: 1
+
+ * - Sink pad/stream
+ - Source pad/stream
+ - Static (X/M(aybe)/-)
+ - Mandatory (X/-)
+ - Synopsis
+ * - 1/0
+ - 0/0
+ - X
+ - X
+ - Image data
+ * - 2/0
+ - 0/1
+ - M
+ - \-
+ - Embedded data
+
+Support for the embedded data stream is optional. Drivers supporting the
+embedded data stream may allow disabling and enabling the route.
+
+Sensor pixel array size, cropping and binning
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The sensor's pixel array is divided into one or more areas. The areas around the
+the visible pixel area in the pixel array, usually one or more sides, may
+contain optical black pixels, dummy pixels and other non-image pixels. The full
+size of the pixel array, including pixels that cannot be captured, is conveyed
+by the format on (pad, stream) pair 1/0.
+
+Capturing the non-visible pixels outside the visible pixel area may be supported
+by the sensor. This area corresponds to the ``V4L2_SEL_TGT_CROP_BOUNDS``
+selection target on (pad, stream) pair 1/0. Non-visible pixels may include
+optical black pixels, dummy pixels or other non-visible pixels. The visible
+pixel area corresponds to the ``V4L2_SEL_TGT_CROP_DEFAULT`` selection target on
+(pad, stream) pair 1/0.
+
+A rectangle within the pixel array contains the visible pixels. Capturing the
+non-visible pixels outside the visible pixel area may be supported by the
+sensor. The visible pixel area corresponds to the ``V4L2_SEL_TGT_CROP_DEFAULT``
+selection target on (pad, stream) pair 1/0.
+
+Sensors can perform multiple operations that affect the output image size. The first
+of these is the analogue crop. Analogue crop limits the area of the pixel array
+which the sensor will read, affecting sensor timing as well. The granularity of
+the analogue crop configuration varies greatly across sensors: some sensors
+support only a few different analogue crop configurations whereas others may
+support anything divisible by a given number of pixels. The analogue crop
+configuration corresponds to the ``V4L2_SEL_TGT_CROP`` selection target on (pad,
+stream) pair 1/0. The default analogue crop rectangle corresponds to the visible
+pixel area.
+
+In the next step, binning is performed on the image data read from camera
+sensor's pixel array, as determined by the analogue crop configuration. Enabling
+binning will effectively result in an image smaller than the original by given
+binning factors horizontally and vertically. Typical values are 1/2 and 1/3 but
+others may well be supported by the hardware as well.
+
+Sub-sampling follows binning. Sub-sampling, like binning, reduces the size of
+the image by including only a subset of samples read from the sensor's pixel
+matrix, typically every n'th pixel horizontally and vertically, taking the
+sensor's color pattern into account. Sub-sampling is generally configurable
+separately horizontally and vertically.
+
+The combined effect of binning and sub-sampling is configured using the
+``V4L2_SEL_TGT_COMPOSE`` rectangle, relative to the analogue crop rectangle, on
+(pad, stream) pair 1/0. The driver implementation determines how to configure
+binning and sub-sampling to achieve the desired size.
+
+The digital crop operation takes place after binning and sub-sampling. It is
+configured by setting the ``V4L2_SEL_TGT_CROP`` rectangle on (pad, stream) pair
+0/0. The resulting image size is further output by the sensor on the sensor's
+data interface.
+
+The sensor's output mbus code is configured by setting the format on the (pad,
+stream) pair 0/0. When setting the format, always use the same width and height
+as for the digital crop setting.
+
+Drivers may only support some or even none of these configurations, in which
+case they do not expose the corresponding selection rectangles. If any selection
+targets are omitted, the further selection rectangle or format is instead
+related to the previous implemented selection rectangle. For instance, if the
+sensor supports binning but not analogue crop, then the binning configuration
+(``V4L2_SEL_TGT_COMPOSE`` selection target) is done in relation to the visible
+pixel area (``V4L2_SEL_TGT_CROP_DEFAULT`` selection target).
+
+Also refer to :ref:`Selection targets <v4l2-selection-targets-table>`.
+
+.. flat-table:: Selection targets on pads
+ :header-rows: 1
+
+ * - Pad/Stream
+ - Selection target/format
+ - Mandatory (X/-)
+ - Modifiable (X/-)
+ - Synopsis
+ * - 1/0
+ - Format
+ - X
+ - \-
+ - The width and the height fields indicates the full size of the physical
+ pixel array, including non-visible pixels and pixels that cannot be
+ captured. The media bus code of this format reflects the native pixel
+ depth of the sensor.
+ * - 1/0
+ - ``V4L2_SEL_TGT_CROP_BOUNDS``
+ - X
+ - \-
+ - The width and the height fields indicates the full size of the pixel
+ array that can be captured, including non-visible pixels. Should the
+ shape of the pixel array not be a rectangle, this rectangle is the
+ smallest possible rectangle that covers all capturable pixels of the
+ pixel array. This rectangle is relative to the format on the same (pad,
+ stream).
+ * - 1/0
+ - ``V4L2_SEL_TGT_CROP_DEFAULT``
+ - X
+ - \-
+ - The visible pixel area. This rectangle is relative to the format on the
+ same (pad, stream).
+ * - 1/0
+ - ``V4L2_SEL_TGT_CROP``
+ - \-
+ - X
+ - Analogue crop. Analogue crop typically has a coarse granularity. This
+ rectangle is relative to the format on the same (pad, stream).
+ * - 1/0
+ - ``V4L2_SEL_TGT_COMPOSE``
+ - \-
+ - \-
+ - Binning and sub-sampling. This rectangle is relative to the
+ ``V4L2_SEL_TGT_CROP`` rectangle on the same (pad, stream). The
+ combination of binning and sub-sampling is expressed with this selection
+ target.
+ * - 2/0
+ - Format
+ - X
+ - \-
+ - Embedded data format.
+ * - 0/0
+ - ``V4L2_SEL_TGT_CROP``
+ - \-
+ - X
+ - Digital crop. This rectangle is relative to the ``V4L2_SEL_TGT_COMPOSE``
+ rectangle on (pad, stream) pair 1/0.
+ * - 0/0
+ - Format
+ - X
+ - X
+ - Image data source format. Always assign the width and height fields of
+ the format to the same values than for the ``V4L2_SEL_TGT_CROP``
+ rectangle on (pad, stream) pair 0/0. The media bus code reflects the
+ pixel data output of the sensor. Setting the media bus code on this pad
+ configures the output format.
+ * - 0/1
+ - Format
+ - X
+ - \-
+ - Embedded data source format.
+
+Embedded data
+^^^^^^^^^^^^^
+
+The embedded data stream is produced by the sensor when the corresponding route
+is enabled. The embedded data route may also be immutable or not exist at all,
+in case the sensor (or the driver) does not support it.
+
+Generally the sensor embedded data width is determined by the width of the image
+data whereas the number of lines are constant for the embedded data. The user
+space may obtain the size of the embedded data once the image data size on the
+source pad has been configured.
+
+Also see :ref:`media_using_camera_sensor_drivers_embedded_data`.
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 24/73] media: v4l2-subdev: Prevent accessing internal pads without STREAMS cap
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (22 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 23/73] media: Documentation: Add subdev configuration models, raw sensor model Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 25/73] media: subdev: Make get_fmt on INTERNAL pads without STREAMS an error Sakari Ailus
` (48 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
The internal pads are expected to be accessed by users that are aware of
streams. Require the V4L2_SUBDEV_CLIENT_CAP_STREAMS client capability to
be set before allowing accessing internal pads from the user space.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/v4l2-core/v4l2-subdev.c | 39 ++++++++++++++++++++++++---
1 file changed, 36 insertions(+), 3 deletions(-)
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index a07d77e584c3..92664f859369 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -233,6 +233,18 @@ static int check_state(struct v4l2_subdev *sd, struct v4l2_subdev_state *state,
return 0;
}
+static inline int check_caps(struct v4l2_subdev *sd,
+ struct v4l2_subdev_state *state,
+ const struct v4l2_subdev_client_info *ci,
+ u32 pad)
+{
+ if (ci && sd->entity.pads[pad].flags & MEDIA_PAD_FL_INTERNAL)
+ return ci->caps & V4L2_SUBDEV_CLIENT_CAP_STREAMS ?
+ 0 : -EINVAL;
+
+ return 0;
+}
+
static inline int check_format(struct v4l2_subdev *sd,
struct v4l2_subdev_state *state,
struct v4l2_subdev_format *format)
@@ -244,6 +256,15 @@ static inline int check_format(struct v4l2_subdev *sd,
check_state(sd, state, format->which, format->pad, format->stream);
}
+static inline int check_format_caps(struct v4l2_subdev *sd,
+ const struct v4l2_subdev_client_info *ci,
+ struct v4l2_subdev_state *state,
+ struct v4l2_subdev_format *format)
+{
+ return check_format(sd, state, format) ?:
+ check_caps(sd, state, ci, format->pad);
+}
+
#define do_subdev_call(sd, check, o, f, args...) \
(!(sd)->ops->o->f ? -ENOIOCTLCMD : (check) ? : \
(sd)->ops->o->f(sd, ##args))
@@ -266,7 +287,7 @@ static int call_set_fmt(struct v4l2_subdev *sd,
if (!sd->ops->pad->set_fmt && !sd->ops->pad->get_fmt)
return -ENOIOCTLCMD;
- ret = check_format(sd, state, format);
+ ret = check_format_caps(sd, ci, state, format);
if (ret)
return ret;
@@ -331,12 +352,24 @@ static inline int check_selection(struct v4l2_subdev *sd,
check_state(sd, state, sel->which, sel->pad, sel->stream);
}
+static inline int check_selection_caps(struct v4l2_subdev *sd,
+ const struct v4l2_subdev_client_info *ci,
+ struct v4l2_subdev_state *state,
+ struct v4l2_subdev_selection *sel)
+{
+ if (!sel)
+ return -EINVAL;
+
+ return check_selection(sd, state, sel) ? :
+ check_caps(sd, state, ci, sel->pad);
+}
+
static int call_get_selection(struct v4l2_subdev *sd,
const struct v4l2_subdev_client_info *ci,
struct v4l2_subdev_state *state,
struct v4l2_subdev_selection *sel)
{
- return do_subdev_call(sd, check_selection(sd, state, sel),
+ return do_subdev_call(sd, check_selection_caps(sd, ci, state, sel),
pad, get_selection, ci, state, sel);
}
@@ -345,7 +378,7 @@ static int call_set_selection(struct v4l2_subdev *sd,
struct v4l2_subdev_state *state,
struct v4l2_subdev_selection *sel)
{
- return do_subdev_call(sd, check_selection(sd, state, sel),
+ return do_subdev_call(sd, check_selection_caps(sd, ci, state, sel),
pad, set_selection, ci, state, sel);
}
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 25/73] media: subdev: Make get_fmt on INTERNAL pads without STREAMS an error
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (23 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 24/73] media: v4l2-subdev: Prevent accessing internal pads without STREAMS cap Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 26/73] media: Documentation: Add scaling and post-scaler crop for common raw Sakari Ailus
` (47 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Internal pads should only be accessible to file handles with
V4L2_SUBDEV_CLIENT_CAP_STREAMS flag set. Return an error otherwise.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/v4l2-core/v4l2-subdev.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index 92664f859369..4a7982e47575 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -887,8 +887,13 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg,
case VIDIOC_SUBDEV_G_FMT: {
struct v4l2_subdev_format *format = arg;
- if (!client_supports_streams)
+ if (!client_supports_streams) {
+ if (format->pad < sd->entity.num_pads &&
+ sd->entity.pads[format->pad].flags & MEDIA_PAD_FL_INTERNAL)
+ return -EINVAL;
+
format->stream = 0;
+ }
memset(format->reserved, 0, sizeof(format->reserved));
memset(format->format.reserved, 0, sizeof(format->format.reserved));
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 26/73] media: Documentation: Add scaling and post-scaler crop for common raw
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (24 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 25/73] media: subdev: Make get_fmt on INTERNAL pads without STREAMS an error Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 27/73] media: uapi: Add MIPI CCS configuration model Sakari Ailus
` (46 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Document scaling and post-scaler digital crop operations for the common
raw sensor model.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
.../media/v4l/subdev-config-model.rst | 26 ++++++++++++++-----
1 file changed, 20 insertions(+), 6 deletions(-)
diff --git a/Documentation/userspace-api/media/v4l/subdev-config-model.rst b/Documentation/userspace-api/media/v4l/subdev-config-model.rst
index cbd12986b977..a538a5c71aad 100644
--- a/Documentation/userspace-api/media/v4l/subdev-config-model.rst
+++ b/Documentation/userspace-api/media/v4l/subdev-config-model.rst
@@ -146,12 +146,19 @@ binning and sub-sampling to achieve the desired size.
The digital crop operation takes place after binning and sub-sampling. It is
configured by setting the ``V4L2_SEL_TGT_CROP`` rectangle on (pad, stream) pair
-0/0. The resulting image size is further output by the sensor on the sensor's
-data interface.
+0/0.
+
+The scaling operation is performed after the digital crop. It is configured by
+setting the ``V4L2_SEL_TGT_COMPOSE`` rectangle on (pad, stream) pair 0/0,
+relative to the digital crop. The resulting image size is further output by the
+sensor on the sensor's data interface.
The sensor's output mbus code is configured by setting the format on the (pad,
-stream) pair 0/0. When setting the format, always use the same width and height
-as for the digital crop setting.
+stream) pair 0/0. The width and height fields are used to configure post-scaler
+digital crop if supported by the driver, affecting the right and bottom edges of
+the frame. If post-scaler digital crop is not supported, the width and height
+fields of the format will match the compose rectangle sizes applied on the same
+0/0 (pad, stream) pair.
Drivers may only support some or even none of these configurations, in which
case they do not expose the corresponding selection rectangles. If any selection
@@ -220,12 +227,19 @@ Also refer to :ref:`Selection targets <v4l2-selection-targets-table>`.
- X
- Digital crop. This rectangle is relative to the ``V4L2_SEL_TGT_COMPOSE``
rectangle on (pad, stream) pair 1/0.
+ * - 0/0
+ - ``V4L2_SEL_TGT_COMPOSE``
+ - \-
+ - X
+ - Scaling. This rectangle is relative to the ``V4L2_SEL_TGT_CROP``
+ rectangle on (pad, stream) pair 0/0.
* - 0/0
- Format
- X
- X
- - Image data source format. Always assign the width and height fields of
- the format to the same values than for the ``V4L2_SEL_TGT_CROP``
+ - Image data source format and post-scaler crop. The width and height
+ fields of the format, used to configure post-scaler crop on the right
+ and bottom edges of the image, are related to the ``V4L2_SEL_TGT_COMPOSE``
rectangle on (pad, stream) pair 0/0. The media bus code reflects the
pixel data output of the sensor. Setting the media bus code on this pad
configures the output format.
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 27/73] media: uapi: Add MIPI CCS configuration model
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (25 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 26/73] media: Documentation: Add scaling and post-scaler crop for common raw Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 28/73] media: uapi: Add V4L2_SUBDEV_CLIENT_CAP_COMMON_RAW_SENSOR Sakari Ailus
` (45 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Add a configuration model for MIPI CCS sensors and refer to the CCS driver
documentation from it. If more drivers start implementing the CCS model
the documentation should be split into two but that appears to be unlikely
at the moment.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
.../userspace-api/media/v4l/subdev-config-model.rst | 6 ++++++
include/uapi/linux/v4l2-controls.h | 1 +
2 files changed, 7 insertions(+)
diff --git a/Documentation/userspace-api/media/v4l/subdev-config-model.rst b/Documentation/userspace-api/media/v4l/subdev-config-model.rst
index a538a5c71aad..ebe1a57fc061 100644
--- a/Documentation/userspace-api/media/v4l/subdev-config-model.rst
+++ b/Documentation/userspace-api/media/v4l/subdev-config-model.rst
@@ -262,3 +262,9 @@ space may obtain the size of the embedded data once the image data size on the
source pad has been configured.
Also see :ref:`media_using_camera_sensor_drivers_embedded_data`.
+
+MIPI Camera Command Set (CCS) model
+-----------------------------------
+
+The MIPI Camera Command Set configuration model is implemented by the :ref:`CCS
+driver <media-ccs-uapi>`.
diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
index 87b6286abb51..b61b047cf991 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -1286,6 +1286,7 @@ enum v4l2_jpeg_chroma_subsampling {
#define V4L2_CID_CONFIG_MODEL (V4L2_CID_IMAGE_PROC_CLASS_BASE + 6)
#define V4L2_CONFIG_MODEL_COMMON_RAW_SENSOR (1U << 0)
+#define V4L2_CONFIG_MODEL_MIPI_CCS (1U << 1)
/* DV-class control IDs defined by V4L2 */
#define V4L2_CID_DV_CLASS_BASE (V4L2_CTRL_CLASS_DV | 0x900)
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 28/73] media: uapi: Add V4L2_SUBDEV_CLIENT_CAP_COMMON_RAW_SENSOR
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (26 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 27/73] media: uapi: Add MIPI CCS configuration model Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 29/73] media: uapi: Add V4L2_CID_BINNING_FACTORS control for binning configuration Sakari Ailus
` (44 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Add V4L2_SUBDEV_CLIENT_CAP_COMMON_RAW_SENSOR client capability bit to
signal the userspace's support for the common raw sensor model and
document it. A specific capability bit is required for the purpose of
adding support for the common raw sensor model to existing drivers that
already have a well-established UAPI that cannot be modified without
breaking the userspace.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
.../userspace-api/media/v4l/ext-ctrls-image-process.rst | 2 ++
.../userspace-api/media/v4l/subdev-config-model.rst | 5 ++++-
.../userspace-api/media/v4l/vidioc-subdev-g-client-cap.rst | 6 ++++++
drivers/media/v4l2-core/v4l2-subdev.c | 3 ++-
include/uapi/linux/v4l2-subdev.h | 6 ++++++
5 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-image-process.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-image-process.rst
index 15566f409ca5..be212eb80c78 100644
--- a/Documentation/userspace-api/media/v4l/ext-ctrls-image-process.rst
+++ b/Documentation/userspace-api/media/v4l/ext-ctrls-image-process.rst
@@ -60,6 +60,8 @@ Image Process Control IDs
digital gain the control value needs to be 0x100. The no-gain
configuration is also typically the default.
+.. _v4l2-cid-config-model:
+
``V4L2_CID_CONFIG_MODEL (bitmask)``
Which configuration models the sub-device supports. Please see
:ref:`media_subdev_config_model`. This is a read-only control.
diff --git a/Documentation/userspace-api/media/v4l/subdev-config-model.rst b/Documentation/userspace-api/media/v4l/subdev-config-model.rst
index ebe1a57fc061..ff02761726f3 100644
--- a/Documentation/userspace-api/media/v4l/subdev-config-model.rst
+++ b/Documentation/userspace-api/media/v4l/subdev-config-model.rst
@@ -41,7 +41,10 @@ necessarily offered by all drivers.
A sub-device complies with the common raw sensor model if the
``V4L2_CONFIG_MODEL_COMMON_RAW_SENSOR`` bit is set in the
-``V4L2_CID_CONFIG_MODEL`` control of the sub-device.
+``V4L2_CID_CONFIG_MODEL`` control of the sub-device. A client supporting the
+common raw sensor model shall set the
+``V4L2_SUBDEV_CLIENT_CAP_COMMON_RAW_SENSOR`` :ref:`sub-device client capability
+<VIDIOC_SUBDEV_G_CLIENT_CAP>` bit.
The common raw camera sensor model is aligned with
:ref:`media_using_camera_sensor_drivers`. Please refer to that regarding aspects
diff --git a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-client-cap.rst b/Documentation/userspace-api/media/v4l/vidioc-subdev-g-client-cap.rst
index da4a358ce762..50ac223e10db 100644
--- a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-client-cap.rst
+++ b/Documentation/userspace-api/media/v4l/vidioc-subdev-g-client-cap.rst
@@ -91,6 +91,12 @@ is unknown to the kernel.
``which`` field. If this is not set (which is the default), the
``which`` field is forced to ``V4L2_SUBDEV_FORMAT_ACTIVE`` by the
kernel.
+ * - ``V4L2_SUBDEV_CLIENT_CAP_COMMON_RAW_SENSOR``
+ - The client is aware of the :ref:`common raw sensor model
+ <media_subdev_config_model_common_raw_sensor>` and expects it where it
+ is supported, as indicated by the :ref:`V4L2_CID_CONFIG_MODEL
+ <v4l2-cid-config-model>` control bit
+ ``V4L2_CONFIG_MODEL_COMMON_RAW_SENSOR``.
Return Value
============
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index 4a7982e47575..a4dfae1d7850 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -1230,7 +1230,8 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg,
/* Filter out unsupported capabilities */
client_cap->capabilities &= (V4L2_SUBDEV_CLIENT_CAP_STREAMS |
- V4L2_SUBDEV_CLIENT_CAP_INTERVAL_USES_WHICH);
+ V4L2_SUBDEV_CLIENT_CAP_INTERVAL_USES_WHICH |
+ V4L2_SUBDEV_CLIENT_CAP_COMMON_RAW_SENSOR);
subdev_fh->ci.caps = client_cap->capabilities;
diff --git a/include/uapi/linux/v4l2-subdev.h b/include/uapi/linux/v4l2-subdev.h
index 477d3ce3ddb4..9d5ba062be19 100644
--- a/include/uapi/linux/v4l2-subdev.h
+++ b/include/uapi/linux/v4l2-subdev.h
@@ -270,6 +270,12 @@ struct v4l2_subdev_routing {
*/
#define V4L2_SUBDEV_CLIENT_CAP_INTERVAL_USES_WHICH (1ULL << 1)
+/*
+ * The client is aware of the common raw sensor model and expects that on camera
+ * sensor UAPI where supported.
+ */
+#define V4L2_SUBDEV_CLIENT_CAP_COMMON_RAW_SENSOR (1ULL << 2)
+
/**
* struct v4l2_subdev_client_capability - Capabilities of the client accessing
* the subdev
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 29/73] media: uapi: Add V4L2_CID_BINNING_FACTORS control for binning configuration
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (27 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 28/73] media: uapi: Add V4L2_SUBDEV_CLIENT_CAP_COMMON_RAW_SENSOR Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 30/73] media: uapi: Add controls for sub-sampling configuration Sakari Ailus
` (43 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Add V4L2_CID_BINNING_FACTORS control for configuring binning and
enumerating a camera sensor's binning capabilities. The control combines
horizontal and vertical binning into a single control as the two are
generally related.
New drivers should use this control to configure binning.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Jai Luthra <jai.luthra@ideasonboard.com>
---
.../media/drivers/camera-sensor.rst | 12 ++++++++
.../media/v4l/ext-ctrls-image-source.rst | 30 +++++++++++++++++++
drivers/media/v4l2-core/v4l2-ctrls-defs.c | 2 ++
include/uapi/linux/v4l2-controls.h | 2 ++
4 files changed, 46 insertions(+)
diff --git a/Documentation/userspace-api/media/drivers/camera-sensor.rst b/Documentation/userspace-api/media/drivers/camera-sensor.rst
index 8002893f1c36..893aec08afab 100644
--- a/Documentation/userspace-api/media/drivers/camera-sensor.rst
+++ b/Documentation/userspace-api/media/drivers/camera-sensor.rst
@@ -120,6 +120,18 @@ values programmed by the register sequences. The default values of these
controls shall be 0 (disabled). Especially these controls shall not be inverted,
independently of the sensor's mounting rotation.
+Binning
+-------
+
+Binning has traditionally been configured using :ref:`the compose selection
+rectangle <v4l2-selection-targets-table>`. The :ref:`V4L2_CID_BINNING_FACTORS
+<image_source_control_binning_factors>` control is also available for binning
+configuration and users should use it when it's available. Drivers supporting
+the control shall also support the compose rectangle, albeit the rectangle may
+be read-only when the control is present.
+
+Binning isn't affected by flipping.
+
.. _media_using_camera_sensor_drivers_embedded_data:
Embedded data
diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
index a9fd1458e391..d4f33e50ef97 100644
--- a/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
+++ b/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
@@ -163,3 +163,33 @@ Image Source Control IDs
interface for metadata streams. The control is used in conjunction with
:ref:`generic metadata formats <media-bus-format-generic-meta>` formats to
specify the layout of the data.
+
+.. _image_source_control_binning_factors:
+
+``V4L2_CID_BINNING_FACTORS (integer menu)``
+
+ This control determines horizontal and vertical binning factors. Binning
+ combines several horizontal, vertical or both pixel values into a single
+ pixel. It is a way to scale an image. Binning typically produces fairly good
+ quality output.
+
+ Determines both horizontal and vertical binning factors for a camera
+ sensor. The values are encoded in the following way:
+
+.. flat-table::
+ :header-rows: 1
+ :stub-columns: 0
+
+ * - Bits
+ - Synopsis
+ * - 48--63
+ - Horizontal binning numerator.
+ * - 32--47
+ - Horizontal binning denominator.
+ * - 16--31
+ - Vertical binning numerator.
+ * - 0--15
+ - Vertical binning denominator.
+
+For instance, a value of ``0x0003000100030002`` indicates binning by 3
+(horizontally) * 3/2 (vertically).
diff --git a/drivers/media/v4l2-core/v4l2-ctrls-defs.c b/drivers/media/v4l2-core/v4l2-ctrls-defs.c
index 950fb714dd5d..b1b852884545 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls-defs.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls-defs.c
@@ -1161,6 +1161,7 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_CFA_PATTERN: return "Color Filter Array Pattern";
case V4L2_CID_CFA_PATTERN_FLIP: return "CFA Pattern Flip";
case V4L2_CID_METADATA_LAYOUT: return "Metadata Layout";
+ case V4L2_CID_BINNING_FACTORS: return "Binning Factors";
/* Image processing controls */
/* Keep the order of the 'case's the same as in v4l2-controls.h! */
@@ -1440,6 +1441,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
case V4L2_CID_HDR_SENSOR_MODE:
*type = V4L2_CTRL_TYPE_MENU;
break;
+ case V4L2_CID_BINNING_FACTORS:
case V4L2_CID_LINK_FREQ:
*type = V4L2_CTRL_TYPE_INTEGER_MENU;
break;
diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
index b61b047cf991..235a7e2b005f 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -1273,6 +1273,8 @@ enum v4l2_jpeg_chroma_subsampling {
#define V4L2_CID_METADATA_LAYOUT (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 12)
+#define V4L2_CID_BINNING_FACTORS (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 13)
+
/* Image processing controls */
#define V4L2_CID_IMAGE_PROC_CLASS_BASE (V4L2_CTRL_CLASS_IMAGE_PROC | 0x900)
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 30/73] media: uapi: Add controls for sub-sampling configuration
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (28 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 29/73] media: uapi: Add V4L2_CID_BINNING_FACTORS control for binning configuration Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 31/73] media: uapi: Add new controls for camera sensor FLL and LLP Sakari Ailus
` (42 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Sub-sampling is a way to decrease the data rates after the pixel array by
systematically discarding some samples, either vertically or horizontally
or both. Add two controls for the purpose and document them. The
sub-sampling configuration is taken into account in the compose rectangle.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
---
.../media/drivers/camera-sensor.rst | 16 +++++++++++++---
.../media/v4l/ext-ctrls-image-source.rst | 11 +++++++++++
drivers/media/v4l2-core/v4l2-ctrls-defs.c | 2 ++
include/uapi/linux/v4l2-controls.h | 2 ++
4 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/Documentation/userspace-api/media/drivers/camera-sensor.rst b/Documentation/userspace-api/media/drivers/camera-sensor.rst
index 893aec08afab..316d14437658 100644
--- a/Documentation/userspace-api/media/drivers/camera-sensor.rst
+++ b/Documentation/userspace-api/media/drivers/camera-sensor.rst
@@ -120,8 +120,8 @@ values programmed by the register sequences. The default values of these
controls shall be 0 (disabled). Especially these controls shall not be inverted,
independently of the sensor's mounting rotation.
-Binning
--------
+Binning and sub-sampling
+------------------------
Binning has traditionally been configured using :ref:`the compose selection
rectangle <v4l2-selection-targets-table>`. The :ref:`V4L2_CID_BINNING_FACTORS
@@ -130,7 +130,17 @@ configuration and users should use it when it's available. Drivers supporting
the control shall also support the compose rectangle, albeit the rectangle may
be read-only when the control is present.
-Binning isn't affected by flipping.
+Sub-sampling is often supported as part of a camera sensor's binning
+functionality and performed after the binning operation. Sub-sampling typically
+produces quality-wise worse results than binning. Sub-sampling factors are
+independent horizontally and vertically and they are controlled using two
+controls, :ref:`V4L2_CID_SUBSAMPLING_HORIZONTAL and
+V4L2_CID_SUBSAMPLING_VERTICAL <image_source_control_subsampling>`. In
+sub-sampling, the image size before sub-sampling is horizontally and vertically
+divided by the respective sub-sampling factors. Drivers supporting the control shall
+also reflect the sub-sampling configuration in the compose rectangle.
+
+Binning and sub-sampling aren't affected by flipping.
.. _media_using_camera_sensor_drivers_embedded_data:
diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
index d4f33e50ef97..0613c310ad0c 100644
--- a/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
+++ b/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
@@ -193,3 +193,14 @@ Image Source Control IDs
For instance, a value of ``0x0003000100030002`` indicates binning by 3
(horizontally) * 3/2 (vertically).
+
+.. _image_source_control_subsampling:
+
+``V4L2_CID_SUBSAMPLING_HORIZONTAL`` and ``V4L2_CID_SUBSAMPLING_VERTICAL``
+(integer)
+
+ Horizontal and vertical subsampling factors.
+
+ Sub-sampling is used to downscale an image, horizontally and vertically, by
+ discarding a part of the image data. Typically sub-sampling produces lower
+ quality images than binning.
diff --git a/drivers/media/v4l2-core/v4l2-ctrls-defs.c b/drivers/media/v4l2-core/v4l2-ctrls-defs.c
index b1b852884545..57c928be1992 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls-defs.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls-defs.c
@@ -1162,6 +1162,8 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_CFA_PATTERN_FLIP: return "CFA Pattern Flip";
case V4L2_CID_METADATA_LAYOUT: return "Metadata Layout";
case V4L2_CID_BINNING_FACTORS: return "Binning Factors";
+ case V4L2_CID_SUBSAMPLING_HORIZONTAL: return "Sub-Sampling Factor, Horizontal";
+ case V4L2_CID_SUBSAMPLING_VERTICAL: return "Sub-Sampling Factor, Vertical";
/* Image processing controls */
/* Keep the order of the 'case's the same as in v4l2-controls.h! */
diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
index 235a7e2b005f..1ca522b1e80a 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -1274,6 +1274,8 @@ enum v4l2_jpeg_chroma_subsampling {
#define V4L2_CID_METADATA_LAYOUT (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 12)
#define V4L2_CID_BINNING_FACTORS (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 13)
+#define V4L2_CID_SUBSAMPLING_HORIZONTAL (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 14)
+#define V4L2_CID_SUBSAMPLING_VERTICAL (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 15)
/* Image processing controls */
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 31/73] media: uapi: Add new controls for camera sensor FLL and LLP
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (29 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 30/73] media: uapi: Add controls for sub-sampling configuration Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 32/73] media: v4l2-common: Add v4l2_sensor_fll_llp_set() Sakari Ailus
` (41 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Add new controls for camera sensors, V4L2_CID_LINE_LENGTH_PIXELS and
V4L2_CID_FRAME_LENGTH_LINES, to convey the combined size of the analogue
crop rectangle and horizontal and vertical blanking.
The reason for adding the new controls is that they're much easier to use
as the user doesn't have to be concerned of the analogue crop in the same
context. Secondarily, the newly added common raw sensor model uses
different values for the same.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
.../userspace-api/media/v4l/ext-ctrls-image-source.rst | 10 ++++++++++
drivers/media/v4l2-core/v4l2-ctrls-defs.c | 2 ++
include/uapi/linux/v4l2-controls.h | 3 +++
3 files changed, 15 insertions(+)
diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
index 0613c310ad0c..4e307957c80a 100644
--- a/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
+++ b/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
@@ -204,3 +204,13 @@ For instance, a value of ``0x0003000100030002`` indicates binning by 3
Sub-sampling is used to downscale an image, horizontally and vertically, by
discarding a part of the image data. Typically sub-sampling produces lower
quality images than binning.
+
+.. _image_source_control_frame_length:
+
+``V4L2_CID_FRAME_LENGTH_LINES (integer)``
+ Frame length in lines. The value of the control is the number of lines
+ captured in the sensor's pixel array added to the vertical blanking.
+
+``V4L2_CID_LINE_LENGTH_PIXELS (integer)``
+ Line length in pixels. The value of the control is the number of pixels per
+ line captured in the sensor's pixel array added to the horizontal blanking.
diff --git a/drivers/media/v4l2-core/v4l2-ctrls-defs.c b/drivers/media/v4l2-core/v4l2-ctrls-defs.c
index 57c928be1992..5444a6986d70 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls-defs.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls-defs.c
@@ -1164,6 +1164,8 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_BINNING_FACTORS: return "Binning Factors";
case V4L2_CID_SUBSAMPLING_HORIZONTAL: return "Sub-Sampling Factor, Horizontal";
case V4L2_CID_SUBSAMPLING_VERTICAL: return "Sub-Sampling Factor, Vertical";
+ case V4L2_CID_FRAME_LENGTH_LINES: return "Frame Length in Lines";
+ case V4L2_CID_LINE_LENGTH_PIXELS: return "Line Length in Pixels";
/* Image processing controls */
/* Keep the order of the 'case's the same as in v4l2-controls.h! */
diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
index 1ca522b1e80a..8671ac06002a 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -1277,6 +1277,9 @@ enum v4l2_jpeg_chroma_subsampling {
#define V4L2_CID_SUBSAMPLING_HORIZONTAL (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 14)
#define V4L2_CID_SUBSAMPLING_VERTICAL (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 15)
+#define V4L2_CID_FRAME_LENGTH_LINES (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 16)
+#define V4L2_CID_LINE_LENGTH_PIXELS (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 17)
+
/* Image processing controls */
#define V4L2_CID_IMAGE_PROC_CLASS_BASE (V4L2_CTRL_CLASS_IMAGE_PROC | 0x900)
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 32/73] media: v4l2-common: Add v4l2_sensor_fll_llp_set()
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (30 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 31/73] media: uapi: Add new controls for camera sensor FLL and LLP Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 33/73] media: Documentation: Add binning and sub-sampling controls Sakari Ailus
` (40 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Add v4l2_sensor_fll_llp_set() to facilitate driver implementation of both
blanking and line and frame lenght controls.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/v4l2-core/v4l2-common.c | 66 +++++++++++++++++++++++++++
include/media/v4l2-common.h | 28 ++++++++++++
include/media/v4l2-mc.h | 1 +
3 files changed, 95 insertions(+)
diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
index 11ab684024c5..35eafde9d73b 100644
--- a/drivers/media/v4l2-core/v4l2-common.c
+++ b/drivers/media/v4l2-core/v4l2-common.c
@@ -862,3 +862,69 @@ struct clk *__devm_v4l2_sensor_clk_get(struct device *dev, const char *id,
return clk_hw->clk;
}
EXPORT_SYMBOL_GPL(__devm_v4l2_sensor_clk_get);
+
+int v4l2_sensor_fll_llp_set(struct v4l2_ctrl *fll, struct v4l2_ctrl *vblank,
+ struct v4l2_ctrl *llp, struct v4l2_ctrl *hblank,
+ struct v4l2_ctrl *exposure,
+ const struct v4l2_mbus_framefmt *format,
+ struct v4l2_ctrl *src, bool *setting_ctrl,
+ int exposure_margin)
+{
+ struct v4l2_ctrl *dest;
+ s32 val;
+ int ret;
+
+ /* Was setting the control user-initiated or were we called again? */
+ if (*setting_ctrl) {
+ *setting_ctrl = false;
+ return 0;
+ }
+
+ /* Are we being called for writing a value to a register? */
+ if (src->val == src->cur.val)
+ return 0;
+
+ switch (src->id) {
+ case V4L2_CID_FRAME_LENGTH_LINES:
+ dest = vblank;
+ val = src->val - format->height;
+ break;
+ case V4L2_CID_VBLANK:
+ dest = fll;
+ val = src->val + format->height;
+ break;
+ case V4L2_CID_LINE_LENGTH_PIXELS:
+ dest = hblank;
+ val = src->val - format->width;
+ break;
+ case V4L2_CID_HBLANK:
+ dest = llp;
+ val = src->val + format->width;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ if (val == dest->val)
+ return 0;
+
+ *setting_ctrl = true;
+
+ ret = __v4l2_ctrl_s_ctrl(dest, val);
+ if (ret)
+ return ret;
+
+ /*
+ * Only modify exposure range when setting fll, directly or via vblank.
+ */
+ if (src->id != V4L2_CID_FRAME_LENGTH_LINES &&
+ dest->id != V4L2_CID_FRAME_LENGTH_LINES)
+ return 0;
+
+ int exposure_max = fll->val - exposure_margin;
+
+ return __v4l2_ctrl_modify_range(exposure, exposure->minimum,
+ exposure_max, exposure->step,
+ exposure_max);
+}
+EXPORT_SYMBOL_GPL(v4l2_sensor_fll_llp_set);
diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
index 33f5713734cb..d29575a9f137 100644
--- a/include/media/v4l2-common.h
+++ b/include/media/v4l2-common.h
@@ -98,7 +98,9 @@ int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl,
/* ------------------------------------------------------------------------- */
struct clk;
+struct v4l2_ctrl;
struct v4l2_device;
+struct v4l2_mbus_framefmt;
struct v4l2_subdev;
struct v4l2_subdev_ops;
@@ -825,4 +827,30 @@ static inline bool v4l2_is_quant_valid(__u8 quantization)
quantization == V4L2_QUANTIZATION_LIM_RANGE;
}
+/**
+ * v4l2_sensor_fll_llp_set - Compatibility support for hblank and vblank
+ * controls
+ *
+ * @fll: Frame length in lines control
+ * @vblank: Vertical blanking control
+ * @llp: Line length in pixels control
+ * @hblank: Horizontal blanking control
+ * @exposure: Exposure control
+ * @format: Source pad format
+ * @src: The control being set -- one of the other four controls
+ * @setting_ctrl: Pointer to the sensor's setting_ctrl variable; false in
+ * initialisation
+ * @exposure_margin: The exposure margin of the sensor
+ *
+ * Compatiblity helper for handling frame time related controls for sensor
+ * drivers that support both the Common Raw Sensor Model and the legacy
+ * interface.
+ */
+int v4l2_sensor_fll_llp_set(struct v4l2_ctrl *fll, struct v4l2_ctrl *vblank,
+ struct v4l2_ctrl *llp, struct v4l2_ctrl *hblank,
+ struct v4l2_ctrl *exposure,
+ const struct v4l2_mbus_framefmt *format,
+ struct v4l2_ctrl *src, bool *setting_ctrl,
+ int exposure_margin);
+
#endif /* V4L2_COMMON_H_ */
diff --git a/include/media/v4l2-mc.h b/include/media/v4l2-mc.h
index 1837c9fd78cf..63030baee819 100644
--- a/include/media/v4l2-mc.h
+++ b/include/media/v4l2-mc.h
@@ -18,6 +18,7 @@
/* We don't need to include pci.h or usb.h here */
struct pci_dev;
struct usb_device;
+struct v4l2_ctrl;
#ifdef CONFIG_MEDIA_CONTROLLER
/**
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 33/73] media: Documentation: Add binning and sub-sampling controls
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (31 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 32/73] media: v4l2-common: Add v4l2_sensor_fll_llp_set() Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 34/73] media: v4l2-subdev: Set STATIC route flag if IMMUTABLE route flag is set Sakari Ailus
` (39 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Document the binning and sub-sampling controls (V4L2_CID_BINNING_FACTORS
and V4L2_CID_SUBSAMPLING_{HORIZONTAL,VERTICAL}) in the common raw sensor
model.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Jai Luthra <jai.luthra@ideasonboard.com>
---
.../media/v4l/subdev-config-model.rst | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/Documentation/userspace-api/media/v4l/subdev-config-model.rst b/Documentation/userspace-api/media/v4l/subdev-config-model.rst
index ff02761726f3..0acb48a0bcce 100644
--- a/Documentation/userspace-api/media/v4l/subdev-config-model.rst
+++ b/Documentation/userspace-api/media/v4l/subdev-config-model.rst
@@ -144,8 +144,12 @@ separately horizontally and vertically.
The combined effect of binning and sub-sampling is configured using the
``V4L2_SEL_TGT_COMPOSE`` rectangle, relative to the analogue crop rectangle, on
-(pad, stream) pair 1/0. The driver implementation determines how to configure
-binning and sub-sampling to achieve the desired size.
+(pad, stream) pair 1/0. It depends on the driver which of these operations are
+being used to achieve the resulting size. Binning and sub-sampling are also
+directly configured using :ref:`V4L2_CID_BINNING_FACTORS
+<image_source_control_binning_factors>` and
+:ref:`V4L2_CID_SUBSAMPLING_HORIZONTAL and V4L2_CID_SUBSAMPLING_VERTICAL
+<image_source_control_subsampling>` controls on drivers that support them.
The digital crop operation takes place after binning and sub-sampling. It is
configured by setting the ``V4L2_SEL_TGT_CROP`` rectangle on (pad, stream) pair
@@ -216,9 +220,13 @@ Also refer to :ref:`Selection targets <v4l2-selection-targets-table>`.
- \-
- \-
- Binning and sub-sampling. This rectangle is relative to the
- ``V4L2_SEL_TGT_CROP`` rectangle on the same (pad, stream). The
- combination of binning and sub-sampling is expressed with this selection
- target.
+ ``V4L2_SEL_TGT_CROP`` rectangle on the same (pad, stream). Binning is
+ configured using the :ref:`V4L2_CID_BINNING_FACTORS
+ <image_source_control_binning_factors>` control and sub-sampling is
+ configured using the :ref:`V4L2_CID_SUBSAMPLING_HORIZONTAL and
+ V4L2_CID_SUBSAMPLING_VERTICAL <image_source_control_subsampling>`
+ controls. The width and the height of this selection rectangle reflect
+ the combined effect of binning and subsampling.
* - 2/0
- Format
- X
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 34/73] media: v4l2-subdev: Set STATIC route flag if IMMUTABLE route flag is set
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (32 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 33/73] media: Documentation: Add binning and sub-sampling controls Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 35/73] media: uapi: v4l: subdev: Enable streams API Sakari Ailus
` (38 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
As the IMMUTABLE sub-device route flag implies the STATIC flag, do set the
STATIC flag for all IMMUTABLE routes returned to the user space.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/v4l2-core/v4l2-subdev.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index a4dfae1d7850..b0eaa59104dc 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -725,7 +725,11 @@ static void v4l2_subdev_copy_routes(struct v4l2_subdev_routing *routing,
(struct v4l2_subdev_route *)(uintptr_t)routing->routes;
u32 copy_routes = min(routing->len_routes, state->routing.num_routes);
- memcpy(routes, state->routing.routes, sizeof(*routes) * copy_routes);
+ for (u32 i = 0; i < copy_routes; i++) {
+ routes[i] = state->routing.routes[i];
+ if (routes[i].flags & V4L2_SUBDEV_ROUTE_FL_IMMUTABLE)
+ routes[i].flags |= V4L2_SUBDEV_ROUTE_FL_STATIC;
+ }
routing->num_routes = state->routing.num_routes;
}
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 35/73] media: uapi: v4l: subdev: Enable streams API
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (33 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 34/73] media: v4l2-subdev: Set STATIC route flag if IMMUTABLE route flag is set Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 36/73] media: uapi: Add binning factor helper macros Sakari Ailus
` (37 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Remove v4l2_subdev_enable_streams_api variable that was used to easily
enable streams API for development, and conditions that use the variable.
This patch enables the streams API for V4L2 sub-device interface which
allows transporting multiple streams on a single MC link.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Mirela Rabulea <mirela.rabulea@nxp.com>
---
drivers/media/v4l2-core/v4l2-subdev.c | 30 ---------------------------
1 file changed, 30 deletions(-)
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index b0eaa59104dc..648ed92e7d03 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -50,15 +50,6 @@ struct v4l2_subdev_stream_config {
struct v4l2_fract interval;
};
-#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
-/*
- * The Streams API is an experimental feature. To use the Streams API, set
- * 'v4l2_subdev_enable_streams_api' to 1 below.
- */
-
-static bool v4l2_subdev_enable_streams_api;
-#endif
-
/*
* Maximum stream ID is 63 for now, as we use u64 bitmask to represent a set
* of streams.
@@ -747,13 +738,6 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg,
V4L2_SUBDEV_CLIENT_CAP_STREAMS;
int rval;
- /*
- * If the streams API is not enabled, remove V4L2_SUBDEV_CAP_STREAMS.
- * Remove this when the API is no longer experimental.
- */
- if (!v4l2_subdev_enable_streams_api)
- streams_subdev = false;
-
switch (cmd) {
case VIDIOC_SUBDEV_QUERYCAP: {
struct v4l2_subdev_capability *cap = arg;
@@ -1112,9 +1096,6 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg,
case VIDIOC_SUBDEV_G_ROUTING: {
struct v4l2_subdev_routing *routing = arg;
- if (!v4l2_subdev_enable_streams_api)
- return -ENOIOCTLCMD;
-
if (!(sd->flags & V4L2_SUBDEV_FL_STREAMS))
return -ENOIOCTLCMD;
@@ -1136,9 +1117,6 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg,
unsigned int num_active_routes = 0;
unsigned int i;
- if (!v4l2_subdev_enable_streams_api)
- return -ENOIOCTLCMD;
-
if (!(sd->flags & V4L2_SUBDEV_FL_STREAMS))
return -ENOIOCTLCMD;
@@ -1224,14 +1202,6 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg,
case VIDIOC_SUBDEV_S_CLIENT_CAP: {
struct v4l2_subdev_client_capability *client_cap = arg;
- /*
- * Clear V4L2_SUBDEV_CLIENT_CAP_STREAMS if streams API is not
- * enabled. Remove this when streams API is no longer
- * experimental.
- */
- if (!v4l2_subdev_enable_streams_api)
- client_cap->capabilities &= ~V4L2_SUBDEV_CLIENT_CAP_STREAMS;
-
/* Filter out unsupported capabilities */
client_cap->capabilities &= (V4L2_SUBDEV_CLIENT_CAP_STREAMS |
V4L2_SUBDEV_CLIENT_CAP_INTERVAL_USES_WHICH |
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 36/73] media: uapi: Add binning factor helper macros
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (34 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 35/73] media: uapi: v4l: subdev: Enable streams API Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 37/73] media: Documentation: Document frame controls for common raw sensor model Sakari Ailus
` (36 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Add helper macros for handling binning factor integer control menu items.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
include/uapi/linux/v4l2-controls.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
index 8671ac06002a..da0123259b25 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -1274,6 +1274,13 @@ enum v4l2_jpeg_chroma_subsampling {
#define V4L2_CID_METADATA_LAYOUT (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 12)
#define V4L2_CID_BINNING_FACTORS (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 13)
+#define V4L2_BINNING_FACTORS_MAKE(hnum, hdem, vnum, vdem) \
+ (((__u64)(0xffff & hnum) << 48) | ((__u64)(0xffff & hdem) << 32) | \
+ ((__u64)(0xffff & vnum) << 16) | (__u64)(0xffff & vdem))
+#define V4L2_BINNING_FACTORS_HNUM(binning) (__u16)((binning >> 48) & 0xffff)
+#define V4L2_BINNING_FACTORS_HDEM(binning) (__u16)((binning >> 32) & 0xffff)
+#define V4L2_BINNING_FACTORS_VNUM(binning) (__u16)((binning >> 16) & 0xffff)
+#define V4L2_BINNING_FACTORS_VDEM(binning) (__u16)(binning & 0xffff)
#define V4L2_CID_SUBSAMPLING_HORIZONTAL (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 14)
#define V4L2_CID_SUBSAMPLING_VERTICAL (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 15)
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 37/73] media: Documentation: Document frame controls for common raw sensor model
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (35 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 36/73] media: uapi: Add binning factor helper macros Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 38/73] media: v4l2-ctrl: Improve v4l2_ctrl_g_ctrl{,int64} documentation Sakari Ailus
` (35 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Document that V4L2_CID_LINE_LENGTH_PIXELS V4L2_CID_FRAME_LENGTH_LINES are
used to configure frame rate in common raw camera sensor model. Also
mention the controls in camera sensor documentation.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
.../userspace-api/media/drivers/camera-sensor.rst | 8 ++++++++
.../userspace-api/media/v4l/subdev-config-model.rst | 8 ++++++++
2 files changed, 16 insertions(+)
diff --git a/Documentation/userspace-api/media/drivers/camera-sensor.rst b/Documentation/userspace-api/media/drivers/camera-sensor.rst
index 316d14437658..7f762d59eaa8 100644
--- a/Documentation/userspace-api/media/drivers/camera-sensor.rst
+++ b/Documentation/userspace-api/media/drivers/camera-sensor.rst
@@ -61,6 +61,8 @@ There are two different methods for obtaining possibilities for different frame
intervals as well as configuring the frame interval. Which one to implement
depends on the type of the device.
+.. _media_camera_sensor_frame_rate_raw:
+
Raw camera sensors
~~~~~~~~~~~~~~~~~~
@@ -78,6 +80,12 @@ The formula is bus independent and is applicable for raw timing parameters on
large variety of devices beyond camera sensors. Devices that have no analogue
crop, use the full source image size, i.e. pixel array size.
+The combined *analogue crop width + horizontal blanking* and *analogue crop
+height + vertical blanking* can be controlled directly using the
+:ref:`V4L2_CID_LINE_LENGTH_PIXELS and V4L2_CID_FRAME_LENGTH_LINES
+<image_source_control_frame_length>` controls, respectively, should the driver
+support them.
+
Horizontal and vertical blanking are specified by ``V4L2_CID_HBLANK`` and
``V4L2_CID_VBLANK``, respectively. The unit of the ``V4L2_CID_HBLANK`` control
is pixels and the unit of the ``V4L2_CID_VBLANK`` is lines. The pixel rate in
diff --git a/Documentation/userspace-api/media/v4l/subdev-config-model.rst b/Documentation/userspace-api/media/v4l/subdev-config-model.rst
index 0acb48a0bcce..46248c9d50ad 100644
--- a/Documentation/userspace-api/media/v4l/subdev-config-model.rst
+++ b/Documentation/userspace-api/media/v4l/subdev-config-model.rst
@@ -260,6 +260,14 @@ Also refer to :ref:`Selection targets <v4l2-selection-targets-table>`.
- \-
- Embedded data source format.
+Frame rate
+^^^^^^^^^^
+
+Drivers supporting the Common raw camera sensor model support
+:ref:`V4L2_CID_LINE_LENGTH_PIXELS and V4L2_CID_FRAME_LENGTH_LINES
+<image_source_control_frame_length>` controls for :ref:`frame rate configuration
+<media_camera_sensor_frame_rate_raw>`.
+
Embedded data
^^^^^^^^^^^^^
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 38/73] media: v4l2-ctrl: Improve v4l2_ctrl_g_ctrl{,int64} documentation
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (36 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 37/73] media: Documentation: Document frame controls for common raw sensor model Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 39/73] media: Documentation: Add sub-device internal pads example Sakari Ailus
` (34 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Improve documentation of v4l2_ctrl_g_ctrl() and v4l2_ctrl_g_ctrl_int64()
by documenting what the function returns on error (i.e. 0).
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
include/media/v4l2-ctrls.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
index cec9217d97ac..ac94bca52a3d 100644
--- a/include/media/v4l2-ctrls.h
+++ b/include/media/v4l2-ctrls.h
@@ -1111,6 +1111,8 @@ const s64 *v4l2_ctrl_get_int_menu(u32 id, u32 *len);
* used from within the &v4l2_ctrl_ops functions.
*
* This function is for integer type controls only.
+ *
+ * Returns: the value of the control or 0 on error.
*/
s32 v4l2_ctrl_g_ctrl(struct v4l2_ctrl *ctrl);
@@ -1162,6 +1164,8 @@ static inline int v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val)
* used from within the &v4l2_ctrl_ops functions.
*
* This function is for 64-bit integer type controls only.
+ *
+ * Returns: the value of the control or 0 on error.
*/
s64 v4l2_ctrl_g_ctrl_int64(struct v4l2_ctrl *ctrl);
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 39/73] media: Documentation: Add sub-device internal pads example
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (37 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 38/73] media: v4l2-ctrl: Improve v4l2_ctrl_g_ctrl{,int64} documentation Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 40/73] media: Documentation: Document streaming behaviour for common raw cameras Sakari Ailus
` (33 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Add an example using sub-device internal pads, with the Sony IMX219 camera
sensor.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
.../userspace-api/media/v4l/dev-subdev.rst | 129 ++++++++++++++++++
1 file changed, 129 insertions(+)
diff --git a/Documentation/userspace-api/media/v4l/dev-subdev.rst b/Documentation/userspace-api/media/v4l/dev-subdev.rst
index 3472b0591d79..f6c4dfcff06d 100644
--- a/Documentation/userspace-api/media/v4l/dev-subdev.rst
+++ b/Documentation/userspace-api/media/v4l/dev-subdev.rst
@@ -726,3 +726,132 @@ To configure this pipeline, the userspace must take the following steps:
:ref:`V4L2_CID_METADATA_LAYOUT <image_source_control_metadata_layout>`
controls are present on the source sub-device to obtain the pixel array CFA
pattern and metadata layout.
+
+Internal pads setup example
+---------------------------
+
+A simple example of a multiplexed stream setup might be as follows:
+
+- An IMX219 camera sensor source sub-device, with one source pad (0), one
+ internal sink pad (1) as the source of the image data and an internal sink
+ pad (2) as the source of the embedded data. There are two routes, one from the
+ internal sink pad 1 to the source pad 0 (image data) and another from the
+ internal sink pad 2 to the source pad 0 (embedded data). Both streams are
+ always active, i.e. there is no need to separately enable the embedded data
+ stream. The sensor uses the CSI-2 interface.
+
+- A CSI-2 receiver in the SoC. The receiver has a single sink pad (pad 0),
+ connected to the sensor's source pad (0), and two source pads (pads 1 and 2),
+ to two DMA engines. The receiver demultiplexes the incoming streams to the
+ source pads.
+
+- Two DMA engines in the SoC, one for each stream. Each DMA engine is connected
+ to a different source pad of the receiver.
+
+The sensor and the receiver are modelled as V4L2 sub-devices, exposed to
+userspace via /dev/v4l-subdevX device nodes. The DMA engines are modelled as
+V4L2 video 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: enable the links from the sensor to the
+ receiver and from the receiver to the DMA engines. This step does not differ
+ from normal non-multiplexed media controller setup.
+
+2) Configure routing
+
+.. flat-table:: Camera sensor. There are no configurable routes.
+ :header-rows: 1
+
+ * - Sink Pad/Stream
+ - Source Pad/Stream
+ - Routing Flags
+ - Comments
+ * - 1/0
+ - 0/0
+ - V4L2_SUBDEV_ROUTE_FL_ACTIVE | V4L2_SUBDEV_ROUTE_FL_IMMUTABLE |
+ V4L2_SUBDEV_ROUTE_FL_STATIC
+ - Pixel data stream from the internal image sink pad
+ * - 2/0
+ - 0/1
+ - V4L2_SUBDEV_ROUTE_FL_ACTIVE | V4L2_SUBDEV_ROUTE_FL_IMMUTABLE |
+ V4L2_SUBDEV_ROUTE_FL_STATIC
+ - Metadata stream from the internal embedded data sink pad
+
+While both routes are immutable for the IMX219, other camera sensors may offer
+more flexible configuration options. Routing configuration is dictated by the
+hardware capabilities: camera sensors typically always produce an image data
+stream, but some of them support enabling and disabling the embedded data
+stream.
+
+.. flat-table:: Receiver routing table. Typically both routes need to be
+ explicitly created.
+ :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 camera sensor
+ * - 0/1
+ - 2/0
+ - V4L2_SUBDEV_ROUTE_FL_ACTIVE
+ - Metadata stream from camera sensor
+
+3) Configure formats
+
+ This example assumes that the formats are propagated from sink pad to the
+ source pad as-is. The tables contain fields of both struct v4l2_subdev_format
+ and struct v4l2_mbus_framefmt.
+
+.. flat-table:: Formats set on the sub-devices. Bold values are set, others are
+ static or propagated. The order is aligned with configured
+ routes.
+ :header-rows: 1
+ :fill-cells:
+
+ * - Sub-device
+ - Pad/Stream
+ - Width
+ - Height
+ - Code
+ * - :rspan:`3` IMX219
+ - 1/0
+ - 3296
+ - 2480
+ - MEDIA_BUS_FMT_RAW_10
+ * - 0/0
+ - 3296
+ - 2480
+ - **MEDIA_BUS_FMT_RAW_10**
+ * - 2/0
+ - 3296
+ - 2
+ - MEDIA_BUS_FMT_META_10
+ * - 0/1
+ - 3296
+ - 2
+ - MEDIA_BUS_FMT_META_10
+ * - :rspan:`3` CSI-2 receiver
+ - 0/0
+ - **3296**
+ - **2480**
+ - **MEDIA_BUS_FMT_RAW_10**
+ * - 1/0
+ - 3296
+ - 2480
+ - MEDIA_BUS_FMT_RAW_10
+ * - 0/1
+ - **3296**
+ - **2**
+ - **MEDIA_BUS_FMT_META_10**
+ * - 2/0
+ - 3296
+ - 2
+ - MEDIA_BUS_FMT_META_10
+
+The embedded data format does not need to be configured on the sensor's pads as
+the format is dictated by the pixel data format in this case.
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 40/73] media: Documentation: Document streaming behaviour for common raw cameras
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (38 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 39/73] media: Documentation: Add sub-device internal pads example Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 41/73] media: Documentation: Add a note on Bayer raw mbus codes Sakari Ailus
` (32 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Document that streaming control is based on stream number 0 and additional
streams need to be started before that.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
.../userspace-api/media/v4l/subdev-config-model.rst | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/Documentation/userspace-api/media/v4l/subdev-config-model.rst b/Documentation/userspace-api/media/v4l/subdev-config-model.rst
index 46248c9d50ad..f606cd22a1a3 100644
--- a/Documentation/userspace-api/media/v4l/subdev-config-model.rst
+++ b/Documentation/userspace-api/media/v4l/subdev-config-model.rst
@@ -99,6 +99,16 @@ following routes.
Support for the embedded data stream is optional. Drivers supporting the
embedded data stream may allow disabling and enabling the route.
+Starting and stopping streaming
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Starting and stopping streaming is controlled through the stream number 0; if
+there's a desire to capture additional streams, such streams need to be started
+before stream 0. All streams start and stop at the same moment.
+
+This is subject to change in the future through additional API elements while
+the default behaviour will be maintained.
+
Sensor pixel array size, cropping and binning
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 41/73] media: Documentation: Add a note on Bayer raw mbus codes
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (39 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 40/73] media: Documentation: Document streaming behaviour for common raw cameras Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 42/73] media: uapi: Add generic raw pixelformats for 10, 12 and 14 bits Sakari Ailus
` (31 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Now that we do have CFA-independent raw mbus codes, document that using
them is required in sensor drivers and preferred in other drivers, too.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
Documentation/driver-api/media/camera-sensor.rst | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/Documentation/driver-api/media/camera-sensor.rst b/Documentation/driver-api/media/camera-sensor.rst
index c8552f70f496..27ea5055b3e8 100644
--- a/Documentation/driver-api/media/camera-sensor.rst
+++ b/Documentation/driver-api/media/camera-sensor.rst
@@ -127,6 +127,17 @@ Use ``v4l2_fwnode_device_parse()`` to obtain rotation and orientation
information from system firmware and ``v4l2_ctrl_new_fwnode_properties()`` to
register the appropriate controls.
+Media bus codes
+---------------
+
+Supporting the new :ref:`CFA-independent Media bus codes
+<v4l2-mbus-pixelcode-generic-raw>` is required in new drivers on serial
+interfaces and the old Bayer pattern specific Media bus codes are thus
+deprecated. If the rest of the pipeline does not support the new generic raw
+Media bus codes, the preference is to add support for the codes in the entire
+pipeline instead of supporting old Bayer pattern specific mbus codes in a sensor
+driver.
+
.. _media-camera-sensor-examples:
Example drivers
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 42/73] media: uapi: Add generic raw pixelformats for 10, 12 and 14 bits
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (40 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 41/73] media: Documentation: Add a note on Bayer raw mbus codes Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 43/73] media: uapi: Add more media bus codes for generic raw formats Sakari Ailus
` (30 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Add generic raw pixelformats for bit depths 10, 12 and 14 unpacked to 16
bits.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
.../media/v4l/pixfmt-raw-generic.rst | 123 +++++++++++++++++-
drivers/media/v4l2-core/v4l2-ioctl.c | 3 +
include/uapi/linux/videodev2.h | 3 +
3 files changed, 126 insertions(+), 3 deletions(-)
diff --git a/Documentation/userspace-api/media/v4l/pixfmt-raw-generic.rst b/Documentation/userspace-api/media/v4l/pixfmt-raw-generic.rst
index 708aa17b80b0..1599ce26f698 100644
--- a/Documentation/userspace-api/media/v4l/pixfmt-raw-generic.rst
+++ b/Documentation/userspace-api/media/v4l/pixfmt-raw-generic.rst
@@ -1,8 +1,8 @@
.. SPDX-License-Identifier: GPL-2.0 OR GFDL-1.1-no-invariants-or-later
-************************************************************************************************************************************
-V4L2_PIX_FMT_RAW_8 ('RAW8'), V4L2_PIX_FMT_RAW_CSI2_10 ('RACA'), V4L2_PIX_FMT_RAW_CSI2_12 ('RACC'), V4L2_PIX_FMT_RAW_CSI2_14 ('RACE')
-************************************************************************************************************************************
+******************************************************************************************************************************************************************************************************************************
+V4L2_PIX_FMT_RAW_8 ('RAW8'), V4L2_PIX_FMT_RAW_CSI2_10 ('RACA'), V4L2_PIX_FMT_RAW_CSI2_12 ('RACC'), V4L2_PIX_FMT_RAW_CSI2_14 ('RACE'), V4L2_PIX_FMT_RAW_10 ('RAWA'), V4L2_PIX_FMT_RAW_12 ('RAWC'), V4L2_PIX_FMT_RAW_14 ('RAWE')
+******************************************************************************************************************************************************************************************************************************
Generic line-based raw image data formats
@@ -175,3 +175,120 @@ Each cell is one byte. "P" denotes a pixel.
P\ :sub:`11 bits 5--2` (bits 3--0)
- P\ :sub:`31 bits 5--0` (bits 7--2),
P\ :sub:`21 bits 5--4` (bits 1--0)
+
+.. _v4l2-pix-fmt-raw-10:
+
+V4L2_PIX_FMT_RAW_10
+-------------------
+
+V4L2_PIX_FMT_RAW_10 contains 10-bit image data, with each two consecutive
+bytes forming a pixel value. This format is typically used by CSI-2 receivers
+with a source that transmits MEDIA_BUS_FMT_RAW_10 and the CSI-2 receiver writes
+the received data to memory unpacked.
+
+**Byte Order Of V4L2_PIX_FMT_RAW_10.**
+Each cell is one byte. "P" denotes a pixel.
+
+.. tabularcolumns:: |p{2.4cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|
+
+.. flat-table:: Sample 4x2 Image Frame
+ :header-rows: 0
+ :stub-columns: 0
+ :widths: 12 8 8 8 8 8 8 8 8
+
+ * - start + 0:
+ - P\ :sub:`00 bits 7--0`
+ - P\ :sub:`00 bits 9--8` (bits 1--0)
+ - P\ :sub:`10 bits 7--0`
+ - P\ :sub:`10 bits 9--8` (bits 1--0)
+ - P\ :sub:`20 bits 7--0`
+ - P\ :sub:`20 bits 9--8` (bits 1--0)
+ - P\ :sub:`30 bits 7--0`
+ - P\ :sub:`30 bits 9--8` (bits 1--0)
+ * - start + 8:
+ - P\ :sub:`01 bits 7--0`
+ - P\ :sub:`01 bits 9--8` (bits 1--0)
+ - P\ :sub:`11 bits 7--0`
+ - P\ :sub:`11 bits 9--8` (bits 1--0)
+ - P\ :sub:`21 bits 7--0`
+ - P\ :sub:`21 bits 9--8` (bits 1--0)
+ - P\ :sub:`31 bits 7--0`
+ - P\ :sub:`31 bits 9--8` (bits 1--0)
+
+.. _v4l2-pix-fmt-raw-12:
+
+V4L2_PIX_FMT_RAW_12
+-------------------
+
+V4L2_PIX_FMT_RAW_12 contains 12-bit image data, with each two consecutive
+bytes forming a pixel value. This format is typically used by CSI-2 receivers
+with a source that transmits MEDIA_BUS_FMT_RAW_12 and the CSI-2 receiver writes
+the received data to memory unpacked.
+
+**Byte Order Of V4L2_PIX_FMT_RAW_12.**
+Each cell is one byte. "P" denotes a pixel.
+
+.. tabularcolumns:: |p{2.4cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|
+
+.. flat-table:: Sample 4x2 Image Frame
+ :header-rows: 0
+ :stub-columns: 0
+ :widths: 12 8 8 8 8 8 8 8 8
+
+ * - start + 0:
+ - P\ :sub:`00 bits 7--0`
+ - P\ :sub:`00 bits 11--8` (bits 3--0)
+ - P\ :sub:`10 bits 7--0`
+ - P\ :sub:`10 bits 11--8` (bits 3--0)
+ - P\ :sub:`20 bits 7--0`
+ - P\ :sub:`20 bits 11--8` (bits 3--0)
+ - P\ :sub:`30 bits 7--0`
+ - P\ :sub:`30 bits 11--8` (bits 3--0)
+ * - start + 8:
+ - P\ :sub:`01 bits 7--0`
+ - P\ :sub:`01 bits 11--8` (bits 3--0)
+ - P\ :sub:`11 bits 7--0`
+ - P\ :sub:`11 bits 11--8` (bits 3--0)
+ - P\ :sub:`21 bits 7--0`
+ - P\ :sub:`21 bits 11--8` (bits 3--0)
+ - P\ :sub:`31 bits 7--0`
+ - P\ :sub:`31 bits 11--8` (bits 3--0)
+
+.. _v4l2-pix-fmt-raw-14:
+
+V4L2_PIX_FMT_RAW_14
+-------------------
+
+V4L2_PIX_FMT_RAW_14 contains 14-bit image data, with each two consecutive
+bytes forming a pixel value. This format is typically used by CSI-2 receivers
+with a source that transmits MEDIA_BUS_FMT_RAW_14 and the CSI-2 receiver writes
+the received data to memory unpacked.
+
+**Byte Order Of V4L2_PIX_FMT_RAW_14.**
+Each cell is one byte. "P" denotes a pixel.
+
+.. tabularcolumns:: |p{2.4cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|
+
+.. flat-table:: Sample 4x2 Image Frame
+ :header-rows: 0
+ :stub-columns: 0
+ :widths: 12 8 8 8 8 8 8 8 8
+
+ * - start + 0:
+ - P\ :sub:`00 bits 7--0`
+ - P\ :sub:`00 bits 13--8` (bits 5--0)
+ - P\ :sub:`10 bits 7--0`
+ - P\ :sub:`10 bits 13--8` (bits 5--0)
+ - P\ :sub:`20 bits 7--0`
+ - P\ :sub:`20 bits 13--8` (bits 5--0)
+ - P\ :sub:`30 bits 7--0`
+ - P\ :sub:`30 bits 13--8` (bits 5--0)
+ * - start + 8:
+ - P\ :sub:`01 bits 7--0`
+ - P\ :sub:`01 bits 13--8` (bits 5--0)
+ - P\ :sub:`11 bits 7--0`
+ - P\ :sub:`11 bits 13--8` (bits 5--0)
+ - P\ :sub:`21 bits 7--0`
+ - P\ :sub:`21 bits 13--8` (bits 5--0)
+ - P\ :sub:`31 bits 7--0`
+ - P\ :sub:`31 bits 13--8` (bits 5--0)
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index 5c4cd5bd65b1..01ba6ddc885b 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1438,6 +1438,9 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
case V4L2_PIX_FMT_RAW_CSI2_10: descr = "10-bit Raw, CSI-2 Packed"; break;
case V4L2_PIX_FMT_RAW_CSI2_12: descr = "12-bit Raw, CSI-2 Packed"; break;
case V4L2_PIX_FMT_RAW_CSI2_14: descr = "14-bit Raw, CSI-2 Packed"; break;
+ case V4L2_PIX_FMT_RAW_10: descr = "10-bit Raw"; break;
+ case V4L2_PIX_FMT_RAW_12: descr = "12-bit Raw"; break;
+ case V4L2_PIX_FMT_RAW_14: descr = "14-bit Raw"; break;
case V4L2_PIX_FMT_RAW_CRU20: descr = "14-bit Raw CRU Packed"; break;
case V4L2_PIX_FMT_SN9C20X_I420: descr = "GSPCA SN9C20X I420"; break;
case V4L2_PIX_FMT_SPCA501: descr = "GSPCA SPCA501"; break;
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index c9dfd51bd328..1209c9f457ab 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -750,6 +750,9 @@ struct v4l2_pix_format {
#define V4L2_PIX_FMT_RAW_CSI2_10 v4l2_fourcc('R', 'A', 'C', 'A')
#define V4L2_PIX_FMT_RAW_CSI2_12 v4l2_fourcc('R', 'A', 'C', 'C')
#define V4L2_PIX_FMT_RAW_CSI2_14 v4l2_fourcc('R', 'A', 'C', 'E')
+#define V4L2_PIX_FMT_RAW_10 v4l2_fourcc('R', 'A', 'W', 'A')
+#define V4L2_PIX_FMT_RAW_12 v4l2_fourcc('R', 'A', 'W', 'C')
+#define V4L2_PIX_FMT_RAW_14 v4l2_fourcc('R', 'A', 'W', 'E')
/* HSV formats */
#define V4L2_PIX_FMT_HSV24 v4l2_fourcc('H', 'S', 'V', '3')
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 43/73] media: uapi: Add more media bus codes for generic raw formats
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (41 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 42/73] media: uapi: Add generic raw pixelformats for 10, 12 and 14 bits Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 44/73] media: uapi: ccs: Add metadata layout for MIPI CCS embedded data Sakari Ailus
` (29 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Add new generic raw media bus codes for serial buses at bit depths or 16,
20, 24 and 28.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
Documentation/userspace-api/media/v4l/subdev-formats.rst | 8 ++++++++
include/uapi/linux/media-bus-format.h | 6 +++++-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/Documentation/userspace-api/media/v4l/subdev-formats.rst b/Documentation/userspace-api/media/v4l/subdev-formats.rst
index b207119415f1..4b832118060a 100644
--- a/Documentation/userspace-api/media/v4l/subdev-formats.rst
+++ b/Documentation/userspace-api/media/v4l/subdev-formats.rst
@@ -3890,6 +3890,14 @@ affect the pattern is conveyed via the :ref:`V4L2_CID_CFA_PATTERN_FLIP
- 12
* - MEDIA_BUS_FMT_RAW_14
- 14
+ * - MEDIA_BUS_FMT_RAW_16
+ - 16
+ * - MEDIA_BUS_FMT_RAW_20
+ - 20
+ * - MEDIA_BUS_FMT_RAW_24
+ - 24
+ * - MEDIA_BUS_FMT_RAW_28
+ - 28
Packed YUV Formats
^^^^^^^^^^^^^^^^^^
diff --git a/include/uapi/linux/media-bus-format.h b/include/uapi/linux/media-bus-format.h
index 83feeae6a31e..40912155c741 100644
--- a/include/uapi/linux/media-bus-format.h
+++ b/include/uapi/linux/media-bus-format.h
@@ -190,10 +190,14 @@
#define MEDIA_BUS_FMT_META_20 0x8006
#define MEDIA_BUS_FMT_META_24 0x8007
-/* Generic (CFA independent) pixel data formats. Next is 0x9005. */
+/* Generic (CFA independent) pixel data formats. Next is 0x9009. */
#define MEDIA_BUS_FMT_RAW_8 0x9001
#define MEDIA_BUS_FMT_RAW_10 0x9002
#define MEDIA_BUS_FMT_RAW_12 0x9003
#define MEDIA_BUS_FMT_RAW_14 0x9004
+#define MEDIA_BUS_FMT_RAW_16 0x9005
+#define MEDIA_BUS_FMT_RAW_20 0x9006
+#define MEDIA_BUS_FMT_RAW_24 0x9007
+#define MEDIA_BUS_FMT_RAW_28 0x9008
#endif /* __LINUX_MEDIA_BUS_FORMAT_H */
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 44/73] media: uapi: ccs: Add metadata layout for MIPI CCS embedded data
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (42 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 43/73] media: uapi: Add more media bus codes for generic raw formats Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 45/73] media: Documentation: Document non-CCS use of CCS embedded data layout Sakari Ailus
` (28 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Add new metadata layout (V4L2_METADATA_LAYOUT_CCS) for MIPI CCS embedded
data.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Julien Massot <julien.massot@collabora.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
.../media/v4l/ext-ctrls-image-source.rst | 12 ++++++
.../userspace-api/media/v4l/meta-formats.rst | 1 +
.../media/v4l/metadata-layouts.rst | 39 +++++++++++++++++++
.../media/v4l/metafmt-generic.rst | 2 +
.../media/v4l/subdev-formats.rst | 5 +++
include/uapi/linux/v4l2-controls.h | 1 +
6 files changed, 60 insertions(+)
create mode 100644 Documentation/userspace-api/media/v4l/metadata-layouts.rst
diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
index 4e307957c80a..335d38271d2c 100644
--- a/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
+++ b/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
@@ -164,6 +164,18 @@ Image Source Control IDs
:ref:`generic metadata formats <media-bus-format-generic-meta>` formats to
specify the layout of the data.
+.. flat-table:: V4L2 metadata layouts
+ :header-rows: 1
+ :stub-columns: 0
+ :widths: 1 2 1
+
+ * - Macro name
+ - Synopsis
+ - Value
+ * - V4L2_METADATA_LAYOUT_CCS
+ - :ref:`CCS embedded data <media-metadata-layout-ccs>`
+ - 1
+
.. _image_source_control_binning_factors:
``V4L2_CID_BINNING_FACTORS (integer menu)``
diff --git a/Documentation/userspace-api/media/v4l/meta-formats.rst b/Documentation/userspace-api/media/v4l/meta-formats.rst
index b5455229837e..18d036750e1a 100644
--- a/Documentation/userspace-api/media/v4l/meta-formats.rst
+++ b/Documentation/userspace-api/media/v4l/meta-formats.rst
@@ -17,6 +17,7 @@ These formats are used for the :ref:`metadata` interface only.
metafmt-c3-isp
metafmt-d4xx
metafmt-generic
+ metadata-layouts
metafmt-intel-ipu3
metafmt-pisp-be
metafmt-pisp-fe
diff --git a/Documentation/userspace-api/media/v4l/metadata-layouts.rst b/Documentation/userspace-api/media/v4l/metadata-layouts.rst
new file mode 100644
index 000000000000..cd190f453994
--- /dev/null
+++ b/Documentation/userspace-api/media/v4l/metadata-layouts.rst
@@ -0,0 +1,39 @@
+.. SPDX-License-Identifier: GPL-2.0 OR GFDL-1.1-no-invariants-or-later
+
+.. _media_metadata_layouts:
+
+Metadata Layouts
+----------------
+
+The :ref:`metadata layout control <image_source_control_metadata_layout>`
+specifies the exact layout of the metadata stream while the a :ref:`generic
+metadata mbus code <media-bus-format-generic-meta>` on the subdevice pads
+only describe the size of the :term:`Data Unit`.
+
+.. _media-metadata-layout-ccs:
+
+MIPI CCS Embedded Data Layout (``V4L2_METADATA_LAYOUT_CCS``)
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+`MIPI CCS <https://www.mipi.org/specifications/camera-command-set>`_ defines a
+metadata layout for sensor embedded data, identified by
+``V4L2_CID_METADATA_LAYOUT`` control value ``V4L2_METADATA_LAYOUT_CCS``, which
+is used to store the register configuration used for capturing a given
+frame. The layout itself is defined in the CCS specification.
+
+The CCS embedded data format (code ``0xa``) definition includes three levels:
+
+1. Padding within CSI-2 bus :term:`Data Unit` as documented in the MIPI CCS
+ specification.
+
+2. The tagged data format as documented in the MIPI CCS specification.
+
+3. Register addresses and register documentation as documented in the MIPI CCS
+ specification.
+
+The ``V4L2_METADATA_LAYOUT_CCS`` metadata layout value shall be used only by
+devices that fulfill all three levels above.
+
+This metadata layout code is only used for "2-byte simplified tagged data
+format" (code ``0xa``) but their use may be extended further in the future, to
+cover other CCS embedded data format codes.
diff --git a/Documentation/userspace-api/media/v4l/metafmt-generic.rst b/Documentation/userspace-api/media/v4l/metafmt-generic.rst
index 07147b4d0dd2..fb97fe4d3c72 100644
--- a/Documentation/userspace-api/media/v4l/metafmt-generic.rst
+++ b/Documentation/userspace-api/media/v4l/metafmt-generic.rst
@@ -8,6 +8,8 @@ V4L2_META_FMT_GENERIC_8 ('MET8'), V4L2_META_FMT_GENERIC_CSI2_10 ('MECA'), V4L2_M
Generic line-based metadata formats
+.. _v4l2-format-generic-meta:
+
Description
===========
diff --git a/Documentation/userspace-api/media/v4l/subdev-formats.rst b/Documentation/userspace-api/media/v4l/subdev-formats.rst
index 4b832118060a..30dd26804776 100644
--- a/Documentation/userspace-api/media/v4l/subdev-formats.rst
+++ b/Documentation/userspace-api/media/v4l/subdev-formats.rst
@@ -8932,6 +8932,11 @@ content is more or less device specific but the data is transmitted and received
by multiple devices that do not process the data in any way, simply writing
it to system memory for processing in software at the end of the pipeline.
+The exact layout of the data generated by the device is reported by the
+:ref:`V4L2_CID_METADATA_LAYOUT <image_source_control_metadata_layout>`
+control. For in-memory formats, :ref:`Generic line-based metadata formats
+<v4l2-format-generic-meta>` are used.
+
"b" in an array cell signifies a byte of data, followed by the number of the bit
and finally the bit number in subscript. "x" indicates a padding bit.
diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
index da0123259b25..66f509ad105c 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -1272,6 +1272,7 @@ enum v4l2_jpeg_chroma_subsampling {
(V4L2_CFA_PATTERN_FLIP_HORIZONTAL | V4L2_CFA_PATTERN_FLIP_VERTICAL)
#define V4L2_CID_METADATA_LAYOUT (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 12)
+#define V4L2_METADATA_LAYOUT_CCS 1U
#define V4L2_CID_BINNING_FACTORS (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 13)
#define V4L2_BINNING_FACTORS_MAKE(hnum, hdem, vnum, vdem) \
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 45/73] media: Documentation: Document non-CCS use of CCS embedded data layout
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (43 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 44/73] media: uapi: ccs: Add metadata layout for MIPI CCS embedded data Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 46/73] media: ccs: Add support for generic raw mbus codes Sakari Ailus
` (27 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
The CCS embedded data layout has multiple aspects (packing, encoding and
the rest, including register addresses and semantics). Explicitly allow
non-compliant embedded data to use the two former to reduce redundant
documentation.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
.../userspace-api/media/drivers/camera-sensor.rst | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/Documentation/userspace-api/media/drivers/camera-sensor.rst b/Documentation/userspace-api/media/drivers/camera-sensor.rst
index 7f762d59eaa8..8562e4144656 100644
--- a/Documentation/userspace-api/media/drivers/camera-sensor.rst
+++ b/Documentation/userspace-api/media/drivers/camera-sensor.rst
@@ -170,3 +170,16 @@ via the ``VIDIOC_SUBDEV_S_ROUTING`` IOCTL.
In general, changing the embedded data layout from the driver-configured values
is not supported. The width of the metadata is device-specific and equal to or
less than the width of the image data, as configured on the pixel data stream.
+
+CCS and non-CCS embedded data layout
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Embedded data which is fully compliant with CCS definitions uses :ref:`CCS
+embedded data layout <media-metadata-layout-ccs>` (level 3) for :ref:`the
+metadata layout control <image_source_control_metadata_layout>`. Device-specific
+embedded data compliant with either MIPI CCS embedded data levels 1 or 2 only
+shall not use CCS embedded data value ``V4L2_METADATA_LAYOUT_CCS`` for metadata
+layout, but may refer to CCS embedded data documentation with the level of
+conformance specified and omit documenting these aspects of the layout. The rest
+of the device-specific embedded data layout is documented in the context of the
+data layout itself.
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 46/73] media: ccs: Add support for generic raw mbus codes
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (44 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 45/73] media: Documentation: Document non-CCS use of CCS embedded data layout Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 47/73] media: ccs: Add support for embedded data stream Sakari Ailus
` (26 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Add support for generic media bus codes for 8, 10, 12 and 14 bits per
pixel.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/i2c/ccs/ccs-core.c | 54 ++++++++++++++++++++++----------
drivers/media/i2c/ccs/ccs.h | 2 ++
2 files changed, 39 insertions(+), 17 deletions(-)
diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c
index 1cc4350856fd..40866215f3e1 100644
--- a/drivers/media/i2c/ccs/ccs-core.c
+++ b/drivers/media/i2c/ccs/ccs-core.c
@@ -642,13 +642,18 @@ static const struct ccs_csi_data_format ccs_csi_data_formats[] = {
{ MEDIA_BUS_FMT_SRGGB8_1X8, 8, 8, CCS_PIXEL_ORDER_RGGB, },
{ MEDIA_BUS_FMT_SBGGR8_1X8, 8, 8, CCS_PIXEL_ORDER_BGGR, },
{ MEDIA_BUS_FMT_SGBRG8_1X8, 8, 8, CCS_PIXEL_ORDER_GBRG, },
+ /* Generic formats are placed below. */
+ { MEDIA_BUS_FMT_RAW_8, 8, 8, 0, true },
+ { MEDIA_BUS_FMT_RAW_10, 10, 10, 0, true },
+ { MEDIA_BUS_FMT_RAW_12, 12, 12, 0, true },
+ { MEDIA_BUS_FMT_RAW_14, 14, 14, 0, true },
};
static const char *pixel_order_str[] = { "GRBG", "RGGB", "BGGR", "GBRG" };
-#define to_csi_format_idx(fmt) (((unsigned long)(fmt) \
- - (unsigned long)ccs_csi_data_formats) \
- / sizeof(*ccs_csi_data_formats))
+#define to_csi_format_idx(fmt) \
+ (((unsigned long)(fmt) - (unsigned long)ccs_csi_data_formats) \
+ / sizeof(*ccs_csi_data_formats))
static u32 ccs_pixel_order(struct ccs_sensor *sensor)
{
@@ -669,27 +674,25 @@ static u32 ccs_pixel_order(struct ccs_sensor *sensor)
static void ccs_update_mbus_formats(struct ccs_sensor *sensor)
{
- struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd);
+ unsigned int mask = sensor->csi_format->is_generic ? ~0 : ~3;
unsigned int csi_format_idx =
- to_csi_format_idx(sensor->csi_format) & ~3;
+ to_csi_format_idx(sensor->csi_format) & mask;
unsigned int internal_csi_format_idx =
- to_csi_format_idx(sensor->internal_csi_format) & ~3;
- unsigned int pixel_order = ccs_pixel_order(sensor);
+ to_csi_format_idx(sensor->internal_csi_format) & mask;
+ unsigned int pixel_order = sensor->csi_format->is_generic ?
+ 0 : ccs_pixel_order(sensor);
if (WARN_ON_ONCE(max(internal_csi_format_idx, csi_format_idx) +
pixel_order >= ARRAY_SIZE(ccs_csi_data_formats)))
return;
sensor->mbus_frame_fmts =
- sensor->default_mbus_frame_fmts << pixel_order;
+ (sensor->default_mbus_frame_fmts << pixel_order) |
+ sensor->default_generic_mbus_frame_fmts;
sensor->csi_format =
&ccs_csi_data_formats[csi_format_idx + pixel_order];
sensor->internal_csi_format =
- &ccs_csi_data_formats[internal_csi_format_idx
- + pixel_order];
-
- dev_dbg(&client->dev, "new pixel order %s\n",
- pixel_order_str[pixel_order]);
+ &ccs_csi_data_formats[internal_csi_format_idx + pixel_order];
}
static const char * const ccs_test_patterns[] = {
@@ -896,7 +899,7 @@ static int ccs_init_controls(struct ccs_sensor *sensor)
struct v4l2_fwnode_device_properties props;
int rval;
- rval = v4l2_ctrl_handler_init(&sensor->pixel_array->ctrl_handler, 19);
+ rval = v4l2_ctrl_handler_init(&sensor->pixel_array->ctrl_handler, 21);
if (rval)
return rval;
@@ -1091,6 +1094,17 @@ static int ccs_init_controls(struct ccs_sensor *sensor)
v4l2_ctrl_cluster(2, &sensor->hflip);
+ v4l2_ctrl_new_std(&sensor->pixel_array->ctrl_handler, NULL,
+ V4L2_CID_CFA_PATTERN, sensor->default_pixel_order,
+ sensor->default_pixel_order, 1,
+ sensor->default_pixel_order);
+
+ v4l2_ctrl_new_std(&sensor->pixel_array->ctrl_handler, NULL,
+ V4L2_CID_CFA_PATTERN_FLIP,
+ V4L2_CFA_PATTERN_FLIP_BOTH,
+ V4L2_CFA_PATTERN_FLIP_BOTH, 1,
+ V4L2_CFA_PATTERN_FLIP_BOTH);
+
rval = v4l2_ctrl_handler_init(&sensor->src->ctrl_handler, 0);
if (rval)
return rval;
@@ -1199,15 +1213,21 @@ static int ccs_get_mbus_formats(struct ccs_sensor *sensor)
const struct ccs_csi_data_format *f =
&ccs_csi_data_formats[j];
- if (f->pixel_order != CCS_PIXEL_ORDER_GRBG)
- continue;
-
if (f->width != fmt >>
CCS_DATA_FORMAT_DESCRIPTOR_UNCOMPRESSED_SHIFT ||
f->compressed !=
(fmt & CCS_DATA_FORMAT_DESCRIPTOR_COMPRESSED_MASK))
continue;
+ if (f->is_generic) {
+ sensor->default_generic_mbus_frame_fmts |=
+ BIT_U64(j);
+ continue;
+ }
+
+ if (f->pixel_order != CCS_PIXEL_ORDER_GRBG)
+ continue;
+
dev_dbg(&client->dev, "jolly good! %u\n", j);
sensor->default_mbus_frame_fmts |= BIT_U64(j);
diff --git a/drivers/media/i2c/ccs/ccs.h b/drivers/media/i2c/ccs/ccs.h
index 58952c5bf06b..df044dbde23f 100644
--- a/drivers/media/i2c/ccs/ccs.h
+++ b/drivers/media/i2c/ccs/ccs.h
@@ -170,6 +170,7 @@ struct ccs_csi_data_format {
u8 width;
u8 compressed;
u8 pixel_order;
+ bool is_generic;
};
#define CCS_SUBDEVS 3
@@ -226,6 +227,7 @@ struct ccs_sensor {
const struct ccs_csi_data_format *csi_format;
const struct ccs_csi_data_format *internal_csi_format;
u64 default_mbus_frame_fmts;
+ u64 default_generic_mbus_frame_fmts;
int default_pixel_order;
struct ccs_data_container sdata, mdata;
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 47/73] media: ccs: Add support for embedded data stream
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (45 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 46/73] media: ccs: Add support for generic raw mbus codes Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 48/73] media: Documentation: ccs: Document routing Sakari Ailus
` (25 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Add support for embedded data stream, in UAPI and frame descriptor.
This patch adds also a new embedded data pad (2) to the source sub-device.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/i2c/ccs/ccs-core.c | 342 +++++++++++++++++++++++++++++--
drivers/media/i2c/ccs/ccs.h | 15 +-
2 files changed, 338 insertions(+), 19 deletions(-)
diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c
index 40866215f3e1..e8706267b6e8 100644
--- a/drivers/media/i2c/ccs/ccs-core.c
+++ b/drivers/media/i2c/ccs/ccs-core.c
@@ -899,7 +899,7 @@ static int ccs_init_controls(struct ccs_sensor *sensor)
struct v4l2_fwnode_device_properties props;
int rval;
- rval = v4l2_ctrl_handler_init(&sensor->pixel_array->ctrl_handler, 21);
+ rval = v4l2_ctrl_handler_init(&sensor->pixel_array->ctrl_handler, 22);
if (rval)
return rval;
@@ -1105,6 +1105,12 @@ static int ccs_init_controls(struct ccs_sensor *sensor)
V4L2_CFA_PATTERN_FLIP_BOTH, 1,
V4L2_CFA_PATTERN_FLIP_BOTH);
+ v4l2_ctrl_new_std(&sensor->pixel_array->ctrl_handler, NULL,
+ V4L2_CID_METADATA_LAYOUT,
+ V4L2_METADATA_LAYOUT_CCS,
+ V4L2_METADATA_LAYOUT_CCS, 1,
+ V4L2_METADATA_LAYOUT_CCS);
+
rval = v4l2_ctrl_handler_init(&sensor->src->ctrl_handler, 0);
if (rval)
return rval;
@@ -1871,6 +1877,57 @@ static int ccs_pm_get_init(struct ccs_sensor *sensor)
return rval;
}
+#define CCS_EMBEDDED_CODE_DEPTH(depth, half_depth) \
+ depth, \
+ CCS_EMB_DATA_CAPABILITY_TWO_BYTES_PER_RAW##depth, \
+ CCS_EMB_DATA_CAPABILITY_NO_ONE_BYTE_PER_RAW##depth, \
+ CCS_EMB_DATA_CTRL_RAW##half_depth##_PACKING_FOR_RAW##depth, \
+ MEDIA_BUS_FMT_META_##half_depth, \
+ MEDIA_BUS_FMT_META_##depth, \
+
+static const struct ccs_embedded_code {
+ u8 depth;
+ u8 cap_two_bytes_per_sample;
+ u8 cap_no_legacy;
+ u8 ctrl;
+ u32 code_two_bytes;
+ u32 code_legacy;
+} ccs_embedded_codes[] = {
+ { CCS_EMBEDDED_CODE_DEPTH(16, 8) },
+ { CCS_EMBEDDED_CODE_DEPTH(20, 10) },
+ { CCS_EMBEDDED_CODE_DEPTH(24, 12) },
+};
+
+static const struct ccs_embedded_code *ccs_embedded_code(unsigned int bpp)
+{
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE(ccs_embedded_codes); i++)
+ if (ccs_embedded_codes[i].depth == bpp)
+ return ccs_embedded_codes + i;
+
+ WARN_ON(1);
+
+ return ccs_embedded_codes;
+}
+
+static u32
+ccs_default_embedded_code(struct ccs_sensor *sensor,
+ const struct ccs_embedded_code *embedded_code)
+{
+ if (CCS_LIM(sensor, EMB_DATA_CAPABILITY) &
+ BIT(embedded_code->cap_two_bytes_per_sample))
+ return embedded_code->code_two_bytes;
+
+ if (!(CCS_LIM(sensor, EMB_DATA_CAPABILITY) &
+ BIT(embedded_code->cap_no_legacy)))
+ return embedded_code->code_legacy;
+
+ WARN_ON(1);
+
+ return embedded_code->code_legacy;
+}
+
static int ccs_enable_streams(struct v4l2_subdev *subdev,
struct v4l2_subdev_state *state, u32 pad,
u64 streams_mask)
@@ -2003,6 +2060,22 @@ static int ccs_enable_streams(struct v4l2_subdev *subdev,
if (rval < 0)
goto err_pm_put;
+ /* Configure embedded data */
+ if (sensor->csi_format->compressed >= 16) {
+ const struct ccs_embedded_code *embedded_code =
+ ccs_embedded_code(sensor->csi_format->compressed);
+ const struct v4l2_mbus_framefmt *meta_out_fmt =
+ v4l2_subdev_state_get_format(src_state, CCS_PAD_SRC,
+ CCS_STREAM_META);
+
+ rval = ccs_write(sensor, EMB_DATA_CTRL,
+ meta_out_fmt->code ==
+ embedded_code->code_legacy ?
+ 0 : embedded_code->ctrl);
+ if (rval < 0)
+ goto err_pm_put;
+ }
+
if (CCS_LIM(sensor, FLASH_MODE_CAPABILITY) &
(CCS_FLASH_MODE_CAPABILITY_SINGLE_STROBE |
SMIAPP_FLASH_MODE_CAPABILITY_MULTIPLE_STROBE) &&
@@ -2133,6 +2206,61 @@ static int ccs_enum_mbus_code(struct v4l2_subdev *subdev,
dev_err(&client->dev, "subdev %s, pad %u, index %u\n",
subdev->name, code->pad, code->index);
+ if (subdev == &sensor->src->sd) {
+ if (code->pad == CCS_PAD_META ||
+ code->stream == CCS_STREAM_META) {
+ struct v4l2_mbus_framefmt *pix_fmt =
+ v4l2_subdev_state_get_format(sd_state,
+ CCS_PAD_SRC,
+ CCS_STREAM_PIXEL);
+ const struct ccs_csi_data_format *csi_format =
+ ccs_validate_csi_data_format(sensor,
+ pix_fmt->code);
+ unsigned int i = 0;
+ u32 codes[2];
+
+ switch (csi_format->compressed) {
+ case 8:
+ codes[i++] = MEDIA_BUS_FMT_META_8;
+ break;
+ case 10:
+ codes[i++] = MEDIA_BUS_FMT_META_10;
+ break;
+ case 12:
+ codes[i++] = MEDIA_BUS_FMT_META_12;
+ break;
+ case 14:
+ codes[i++] = MEDIA_BUS_FMT_META_14;
+ break;
+ case 16:
+ case 20:
+ case 24: {
+ const struct ccs_embedded_code *embedded_code =
+ ccs_embedded_code(csi_format->compressed);
+
+ if (CCS_LIM(sensor, EMB_DATA_CAPABILITY) &
+ BIT(embedded_code->cap_two_bytes_per_sample))
+ codes[i++] =
+ embedded_code->code_two_bytes;
+
+ if (!(CCS_LIM(sensor, EMB_DATA_CAPABILITY) &
+ BIT(embedded_code->cap_no_legacy)))
+ codes[i++] = embedded_code->code_legacy;
+ break;
+ }
+ default:
+ WARN_ON(1);
+ }
+
+ if (WARN_ON(i > ARRAY_SIZE(codes)) || code->index >= i)
+ return -EINVAL;
+
+ code->code = codes[code->index];
+
+ return 0;
+ }
+ }
+
if (subdev != &sensor->src->sd || code->pad != CCS_PAD_SRC) {
if (code->index)
return -EINVAL;
@@ -2171,8 +2299,11 @@ static int ccs_get_format(struct v4l2_subdev *subdev,
struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_format *fmt)
{
- fmt->format = *v4l2_subdev_state_get_format(sd_state, fmt->pad);
- fmt->format.code = ccs_get_mbus_code(subdev, fmt->pad);
+ fmt->format = *v4l2_subdev_state_get_format(sd_state, fmt->pad,
+ fmt->stream);
+
+ if (fmt->pad != CCS_PAD_META && fmt->stream != CCS_STREAM_META)
+ fmt->format.code = ccs_get_mbus_code(subdev, fmt->pad);
return 0;
}
@@ -2262,6 +2393,86 @@ static int ccs_set_format_source(struct v4l2_subdev *subdev,
return ccs_pll_update(sensor);
}
+static inline unsigned int ccs_embedded_data_lines(struct ccs_sensor *sensor)
+{
+ return sensor->embedded_end - sensor->embedded_start;
+}
+
+static int ccs_set_format_meta(struct v4l2_subdev *subdev,
+ struct v4l2_subdev_state *sd_state,
+ struct v4l2_mbus_framefmt *fmt)
+{
+ struct ccs_sensor *sensor = to_ccs_sensor(subdev);
+ const struct ccs_csi_data_format *csi_format;
+ struct v4l2_mbus_framefmt *pix_fmt;
+ struct v4l2_mbus_framefmt *meta_fmt;
+ struct v4l2_mbus_framefmt *meta_out_fmt;
+ u32 code;
+
+ pix_fmt = v4l2_subdev_state_get_format(sd_state, CCS_PAD_SRC,
+ CCS_STREAM_PIXEL);
+ meta_fmt = v4l2_subdev_state_get_format(sd_state, CCS_PAD_META, 0);
+ meta_out_fmt = v4l2_subdev_state_get_format(sd_state, CCS_PAD_SRC,
+ CCS_STREAM_META);
+
+ code = fmt ? fmt->code : 0;
+
+ meta_fmt->width = pix_fmt->width;
+ meta_fmt->height = ccs_embedded_data_lines(sensor);
+
+ csi_format = ccs_validate_csi_data_format(sensor, pix_fmt->code);
+
+ switch (csi_format->compressed) {
+ case 8:
+ meta_fmt->code = MEDIA_BUS_FMT_META_8;
+ break;
+ case 10:
+ meta_fmt->code = MEDIA_BUS_FMT_META_10;
+ break;
+ case 12:
+ meta_fmt->code = MEDIA_BUS_FMT_META_12;
+ break;
+ case 14:
+ meta_fmt->code = MEDIA_BUS_FMT_META_14;
+ break;
+ case 16:
+ case 20:
+ case 24: {
+ const struct ccs_embedded_code *embedded_code;
+
+ embedded_code = ccs_embedded_code(csi_format->compressed);
+ meta_fmt->code =
+ ccs_default_embedded_code(sensor, embedded_code);
+
+ if (!(CCS_LIM(sensor, EMB_DATA_CAPABILITY) &
+ BIT(embedded_code->cap_no_legacy)) &&
+ code == embedded_code->code_legacy)
+ meta_fmt->code = embedded_code->code_legacy;
+
+ if (CCS_LIM(sensor, EMB_DATA_CAPABILITY) &
+ BIT(embedded_code->cap_two_bytes_per_sample) &&
+ code == embedded_code->code_two_bytes) {
+ meta_fmt->code = embedded_code->code_two_bytes;
+ meta_fmt->width <<= 1;
+ }
+
+ break;
+ }
+ default:
+ WARN_ON(1);
+ return 0;
+ }
+
+ meta_out_fmt->width = meta_fmt->width;
+ meta_out_fmt->height = meta_fmt->height;
+ meta_out_fmt->code = meta_fmt->code;
+
+ if (fmt)
+ *fmt = *meta_out_fmt;
+
+ return 0;
+}
+
static int ccs_set_format(struct v4l2_subdev *subdev,
const struct v4l2_subdev_client_info *ci,
struct v4l2_subdev_state *sd_state,
@@ -2271,10 +2482,21 @@ static int ccs_set_format(struct v4l2_subdev *subdev,
struct ccs_subdev *ssd = to_ccs_subdev(subdev);
struct v4l2_rect *crop;
+ if (ssd == sensor->src && fmt->pad == CCS_PAD_META)
+ return ccs_get_format(subdev, sd_state, fmt);
+
+ if (ssd == sensor->src && fmt->stream == CCS_STREAM_META) {
+ ccs_set_format_meta(subdev, sd_state, &fmt->format);
+
+ return 0;
+ }
+
if (fmt->pad == ssd->source_pad) {
int rval;
rval = ccs_set_format_source(subdev, ci, sd_state, fmt);
+ if (ccs_embedded_data_lines(sensor) && ssd == sensor->src)
+ ccs_set_format_meta(subdev, sd_state, NULL);
return rval;
}
@@ -2526,6 +2748,12 @@ static int ccs_sel_supported(struct v4l2_subdev *subdev,
struct ccs_sensor *sensor = to_ccs_sensor(subdev);
struct ccs_subdev *ssd = to_ccs_subdev(subdev);
+ if (sel->stream != CCS_STREAM_PIXEL)
+ return -EINVAL;
+
+ if (sel->pad == CCS_PAD_META)
+ return -EINVAL;
+
/* We only implement crop in three places. */
switch (sel->target) {
case V4L2_SEL_TGT_CROP:
@@ -2575,7 +2803,8 @@ static int ccs_set_crop(struct v4l2_subdev *subdev,
if (sel->pad == ssd->sink_pad) {
struct v4l2_mbus_framefmt *mfmt =
- v4l2_subdev_state_get_format(sd_state, sel->pad);
+ v4l2_subdev_state_get_format(sd_state, sel->pad,
+ CCS_STREAM_PIXEL);
src_size.width = mfmt->width;
src_size.height = mfmt->height;
@@ -2637,7 +2866,9 @@ static int ccs_get_selection(struct v4l2_subdev *subdev,
} else if (sel->pad == ssd->sink_pad) {
struct v4l2_mbus_framefmt *sink_fmt =
v4l2_subdev_state_get_format(sd_state,
- ssd->sink_pad);
+ ssd->sink_pad,
+ CCS_STREAM_PIXEL);
+
sel->r.top = sel->r.left = 0;
sel->r.width = sink_fmt->width;
sel->r.height = sink_fmt->height;
@@ -2723,6 +2954,18 @@ static int ccs_get_frame_desc(struct v4l2_subdev *subdev, unsigned int pad,
entry++;
desc->num_entries++;
+ if (ccs_embedded_data_lines(sensor)) {
+ struct v4l2_mbus_framefmt *meta_out_fmt =
+ v4l2_subdev_state_get_format(sd_state, CCS_PAD_SRC,
+ CCS_STREAM_META);
+
+ entry->pixelcode = meta_out_fmt->code;
+ entry->stream = CCS_STREAM_META;
+ entry->bus.csi2.dt = MIPI_CSI2_DT_EMBEDDED_8B;
+ entry++;
+ desc->num_entries++;
+ }
+
v4l2_subdev_unlock_state(sd_state);
return 0;
@@ -3063,7 +3306,8 @@ static int ccs_init_subdev(struct ccs_sensor *sensor,
ssd->sensor = sensor;
ssd->npads = num_pads;
- ssd->source_pad = num_pads - 1;
+ ssd->source_pad =
+ ssd == sensor->pixel_array ? CCS_PA_PAD_SRC : CCS_PAD_SRC;
v4l2_i2c_subdev_set_name(&ssd->sd, client, sensor->minfo.name, name);
@@ -3077,6 +3321,10 @@ static int ccs_init_subdev(struct ccs_sensor *sensor,
ssd->sd.owner = THIS_MODULE;
ssd->sd.dev = &client->dev;
v4l2_set_subdevdata(&ssd->sd, client);
+ } else {
+ ssd->sd.flags |= V4L2_SUBDEV_FL_STREAMS;
+ ssd->pads[CCS_PAD_META].flags =
+ MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_INTERNAL;
}
rval = media_entity_pads_init(&ssd->sd.entity, ssd->npads, ssd->pads);
@@ -3102,9 +3350,9 @@ static int ccs_init_state(struct v4l2_subdev *sd,
unsigned int pad = ssd == sensor->pixel_array ?
CCS_PA_PAD_SRC : CCS_PAD_SINK;
struct v4l2_mbus_framefmt *fmt =
- v4l2_subdev_state_get_format(sd_state, pad);
+ v4l2_subdev_state_get_format(sd_state, pad, CCS_STREAM_PIXEL);
struct v4l2_rect *crop =
- v4l2_subdev_state_get_crop(sd_state, pad);
+ v4l2_subdev_state_get_crop(sd_state, pad, CCS_STREAM_PIXEL);
ccs_get_native_size(ssd, crop);
@@ -3116,7 +3364,8 @@ static int ccs_init_state(struct v4l2_subdev *sd,
if (ssd == sensor->pixel_array)
return 0;
- fmt = v4l2_subdev_state_get_format(sd_state, CCS_PAD_SRC);
+ fmt = v4l2_subdev_state_get_format(sd_state, CCS_PAD_SRC,
+ CCS_STREAM_PIXEL);
fmt->code = ssd == sensor->src ?
sensor->csi_format->code : sensor->internal_csi_format->code;
fmt->field = V4L2_FIELD_NONE;
@@ -3126,6 +3375,47 @@ static int ccs_init_state(struct v4l2_subdev *sd,
return 0;
}
+static int ccs_src_init_state(struct v4l2_subdev *sd,
+ struct v4l2_subdev_state *sd_state)
+{
+ struct v4l2_subdev_route routes[] = {
+ {
+ .sink_pad = CCS_PAD_SINK,
+ .source_pad = CCS_PAD_SRC,
+ .source_stream = CCS_STREAM_PIXEL,
+ .flags = V4L2_SUBDEV_ROUTE_FL_ACTIVE,
+ }, {
+ .sink_pad = CCS_PAD_META,
+ .source_pad = CCS_PAD_SRC,
+ .source_stream = CCS_STREAM_META,
+ .flags = V4L2_SUBDEV_ROUTE_FL_ACTIVE,
+ }
+ };
+ struct v4l2_subdev_krouting routing = {
+ .routes = routes,
+ .num_routes = 1,
+ };
+ struct ccs_subdev *ssd = to_ccs_subdev(sd);
+ struct ccs_sensor *sensor = ssd->sensor;
+ int rval;
+
+ if (ccs_embedded_data_lines(sensor))
+ routing.num_routes++;
+
+ rval = v4l2_subdev_set_routing(sd, sd_state, &routing);
+ if (rval)
+ return rval;
+
+ rval = ccs_init_state(sd, sd_state);
+ if (rval)
+ return rval;
+
+ if (ccs_embedded_data_lines(sensor))
+ ccs_set_format_meta(sd, sd_state, NULL);
+
+ return 0;
+}
+
static const struct v4l2_subdev_video_ops ccs_video_ops = {
.s_stream = v4l2_subdev_s_stream_helper,
.pre_streamon = ccs_pre_streamon,
@@ -3138,6 +3428,14 @@ static const struct v4l2_subdev_pad_ops ccs_pad_ops = {
.set_fmt = ccs_set_format,
.get_selection = ccs_get_selection,
.set_selection = ccs_set_selection,
+};
+
+static const struct v4l2_subdev_pad_ops ccs_src_pad_ops = {
+ .enum_mbus_code = ccs_enum_mbus_code,
+ .get_fmt = ccs_get_format,
+ .set_fmt = ccs_set_format,
+ .get_selection = ccs_get_selection,
+ .set_selection = ccs_set_selection,
.enable_streams = ccs_enable_streams,
.disable_streams = ccs_disable_streams,
.get_frame_desc = ccs_get_frame_desc,
@@ -3154,6 +3452,12 @@ static const struct v4l2_subdev_ops ccs_ops = {
.sensor = &ccs_sensor_ops,
};
+static const struct v4l2_subdev_ops ccs_src_ops = {
+ .video = &ccs_video_ops,
+ .pad = &ccs_src_pad_ops,
+ .sensor = &ccs_sensor_ops,
+};
+
static const struct media_entity_operations ccs_entity_ops = {
.link_validate = v4l2_subdev_link_validate,
};
@@ -3162,8 +3466,8 @@ static const struct v4l2_subdev_internal_ops ccs_internal_ops = {
.init_state = ccs_init_state,
};
-static const struct v4l2_subdev_internal_ops ccs_internal_src_ops = {
- .init_state = ccs_init_state,
+static const struct v4l2_subdev_internal_ops ccs_src_internal_ops = {
+ .init_state = ccs_src_init_state,
.registered = ccs_registered,
.unregistered = ccs_unregistered,
};
@@ -3305,8 +3609,8 @@ static int ccs_probe(struct i2c_client *client)
sensor->src = &sensor->ssds[sensor->ssds_used];
- v4l2_i2c_subdev_init(&sensor->src->sd, client, &ccs_ops);
- sensor->src->sd.internal_ops = &ccs_internal_src_ops;
+ v4l2_i2c_subdev_init(&sensor->src->sd, client, &ccs_src_ops);
+ sensor->src->sd.internal_ops = &ccs_src_internal_ops;
sensor->regulators = devm_kcalloc(&client->dev,
ARRAY_SIZE(ccs_regulators),
@@ -3573,12 +3877,20 @@ static int ccs_probe(struct i2c_client *client)
goto out_cleanup;
}
- rval = ccs_init_subdev(sensor, sensor->scaler, " scaler", 2,
+ rval = ccs_init_subdev(sensor, sensor->scaler, " scaler",
+ sensor->ssds_used != CCS_SUBDEVS ?
+ CCS_PADS_NOMETA :
+ ccs_embedded_data_lines(sensor) ?
+ CCS_PADS : CCS_PADS_NOMETA,
MEDIA_ENT_F_PROC_VIDEO_SCALER,
"ccs scaler mutex", &scaler_lock_key);
if (rval)
goto out_cleanup;
- rval = ccs_init_subdev(sensor, sensor->binner, " binner", 2,
+ rval = ccs_init_subdev(sensor, sensor->binner, " binner",
+ sensor->ssds_used == CCS_SUBDEVS ?
+ CCS_PADS_NOMETA :
+ ccs_embedded_data_lines(sensor) ?
+ CCS_PADS : CCS_PADS_NOMETA,
MEDIA_ENT_F_PROC_VIDEO_SCALER,
"ccs binner mutex", &binner_lock_key);
if (rval)
diff --git a/drivers/media/i2c/ccs/ccs.h b/drivers/media/i2c/ccs/ccs.h
index df044dbde23f..122287ab5399 100644
--- a/drivers/media/i2c/ccs/ccs.h
+++ b/drivers/media/i2c/ccs/ccs.h
@@ -176,11 +176,18 @@ struct ccs_csi_data_format {
#define CCS_SUBDEVS 3
#define CCS_PA_PAD_SRC 0
-#define CCS_PAD_SINK 0
-#define CCS_PAD_SRC 1
-#define CCS_PADS 2
+enum {
+ CCS_PAD_SINK,
+ CCS_PAD_SRC,
+ CCS_PAD_META,
+ CCS_PADS_NOMETA = CCS_PAD_META,
+ CCS_PADS,
+};
-#define CCS_STREAM_PIXEL 0
+enum {
+ CCS_STREAM_PIXEL,
+ CCS_STREAM_META,
+};
struct ccs_binning_subtype {
u8 horizontal:4;
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 48/73] media: Documentation: ccs: Document routing
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (46 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 47/73] media: ccs: Add support for embedded data stream Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 49/73] media: ccs: Add IMMUTABLE and STATIC route flags Sakari Ailus
` (24 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Document which routes are available for the CCS driver (source) sub-device
and what configuration are possible.
Also update copyright.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
.../userspace-api/media/drivers/ccs.rst | 43 ++++++++++++++++++-
.../media/v4l/metadata-layouts.rst | 2 +
2 files changed, 44 insertions(+), 1 deletion(-)
diff --git a/Documentation/userspace-api/media/drivers/ccs.rst b/Documentation/userspace-api/media/drivers/ccs.rst
index 03015b33d5ab..67c7d2b62ed5 100644
--- a/Documentation/userspace-api/media/drivers/ccs.rst
+++ b/Documentation/userspace-api/media/drivers/ccs.rst
@@ -111,4 +111,45 @@ than in the centre.
Shading correction needs to be enabled for luminance correction level to have an
effect.
-**Copyright** |copy| 2020 Intel Corporation
+.. _media-ccs-routes:
+
+Routes
+------
+
+The CCS driver implements one or two :ref:`routes <subdev-routing>` in
+its source sub-device (scaler sub-device if it exists for the device, otherwise
+binner) depending on whether the sensor supports embedded data. (All CCS
+compliant sensors do but the CCS driver supports preceding standards that did
+not require embedded data support, too.)
+
+The first route of the CCS source sub-device is for pixel data (sink pad
+0/stream 0 -> source pad 1/stream 0) and the second one is for embedded data
+(internal sink pad 2/stream 0 -> source pad 1/stream 1).
+
+Embedded data
+~~~~~~~~~~~~~
+
+MIPI CCS supports generation of camera sensor embedded data. The metadata layout
+used for this format on the internal sink pad is :ref:`V4L2_METADATA_LAYOUT_CCS
+<media-metadata-layout-ccs>`.
+
+The bit depth of the CCS pixel data affects how the sensor will output the
+embedded data, adding padding to align with CSI-2 bus :term:`Data Unit` for that
+particular bit depth. This is indicated by the generic metadata format on the
+source pad of the sensor's source sub-device.
+
+Devices supporting embedded data for bit depths greater than or equal to 16 may
+support more dense packing or legacy single metadata byte per data unit, or both
+of these. The supported embedded data formats can be enumerated and configured
+on stream 1 of the source pad (1) of the CCS source sub-device.
+
+The use of the denser packing results in embedded data lines being longer than
+the pixel data in data units since the data units are smaller. In bytes the
+embedded data lines are still not longer than the image data lines.
+
+The embedded data format is determined by the sub-device image data format
+configured on the source sub-device. The embedded data mbus code is only changed
+when the bit depth of the image data changes in the source pad of the source
+sub-device.
+
+**Copyright** |copy| 2020, 2024--2025 Intel Corporation
diff --git a/Documentation/userspace-api/media/v4l/metadata-layouts.rst b/Documentation/userspace-api/media/v4l/metadata-layouts.rst
index cd190f453994..0f8709f2e9af 100644
--- a/Documentation/userspace-api/media/v4l/metadata-layouts.rst
+++ b/Documentation/userspace-api/media/v4l/metadata-layouts.rst
@@ -37,3 +37,5 @@ devices that fulfill all three levels above.
This metadata layout code is only used for "2-byte simplified tagged data
format" (code ``0xa``) but their use may be extended further in the future, to
cover other CCS embedded data format codes.
+
+Also see :ref:`CCS driver documentation <media-ccs-routes>`.
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 49/73] media: ccs: Add IMMUTABLE and STATIC route flags
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (47 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 48/73] media: Documentation: ccs: Document routing Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 50/73] media: uapi: Add metadata layout for ov2740 embedded data Sakari Ailus
` (23 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Add immutable and static route flags to the routing table. The embedded
data stream is always there.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Julien Massot <julien.massot@collabora.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
drivers/media/i2c/ccs/ccs-core.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c
index e8706267b6e8..a799d16f1b0f 100644
--- a/drivers/media/i2c/ccs/ccs-core.c
+++ b/drivers/media/i2c/ccs/ccs-core.c
@@ -3383,12 +3383,16 @@ static int ccs_src_init_state(struct v4l2_subdev *sd,
.sink_pad = CCS_PAD_SINK,
.source_pad = CCS_PAD_SRC,
.source_stream = CCS_STREAM_PIXEL,
- .flags = V4L2_SUBDEV_ROUTE_FL_ACTIVE,
+ .flags = V4L2_SUBDEV_ROUTE_FL_ACTIVE |
+ V4L2_SUBDEV_ROUTE_FL_IMMUTABLE |
+ V4L2_SUBDEV_ROUTE_FL_STATIC,
}, {
.sink_pad = CCS_PAD_META,
.source_pad = CCS_PAD_SRC,
.source_stream = CCS_STREAM_META,
- .flags = V4L2_SUBDEV_ROUTE_FL_ACTIVE,
+ .flags = V4L2_SUBDEV_ROUTE_FL_ACTIVE |
+ V4L2_SUBDEV_ROUTE_FL_IMMUTABLE |
+ V4L2_SUBDEV_ROUTE_FL_STATIC,
}
};
struct v4l2_subdev_krouting routing = {
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 50/73] media: uapi: Add metadata layout for ov2740 embedded data
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (48 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 49/73] media: ccs: Add IMMUTABLE and STATIC route flags Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 51/73] media: ov2740: Add support for " Sakari Ailus
` (22 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Add a metadata layout for ov2740 camera sensor embedded data and document
it.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Julien Massot <julien.massot@collabora.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
.../media/v4l/ext-ctrls-image-source.rst | 3 +
.../media/v4l/metadata-layouts.rst | 73 +++++++++++++++++++
include/uapi/linux/v4l2-controls.h | 1 +
3 files changed, 77 insertions(+)
diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
index 335d38271d2c..b2c515e519f2 100644
--- a/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
+++ b/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
@@ -175,6 +175,9 @@ Image Source Control IDs
* - V4L2_METADATA_LAYOUT_CCS
- :ref:`CCS embedded data <media-metadata-layout-ccs>`
- 1
+ * - V4L2_METADATA_LAYOUT_OV2740
+ - :ref:`OV2740 embedded data <media-metadata-layout-ov2740>`
+ - 2
.. _image_source_control_binning_factors:
diff --git a/Documentation/userspace-api/media/v4l/metadata-layouts.rst b/Documentation/userspace-api/media/v4l/metadata-layouts.rst
index 0f8709f2e9af..b4d04d82662b 100644
--- a/Documentation/userspace-api/media/v4l/metadata-layouts.rst
+++ b/Documentation/userspace-api/media/v4l/metadata-layouts.rst
@@ -39,3 +39,76 @@ format" (code ``0xa``) but their use may be extended further in the future, to
cover other CCS embedded data format codes.
Also see :ref:`CCS driver documentation <media-ccs-routes>`.
+
+.. _media-metadata-layout-ov2740:
+
+Omnivision OV2740 Embedded Data Layout (``V4L2_METADATA_LAYOUT_OV2740``)
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The Omnivision OV2740 camera sensor produces the following embedded data layout,
+indicated by ``V4L2_METADATA_LAYOUT_OV2740`` metadata layout. The format
+conforms to :ref:`CCS embedded data layout <media-metadata-layout-ccs>` up to
+level 1.
+
+.. flat-table:: Omnivision OV2740 Embedded Data Layout. Octets at indices marked
+ reserved or unused have been omitted from the table. The values
+ are in big endian byte order.
+ :header-rows: 1
+
+ * - Offset
+ - Size in bits (active bits if not the same as size)
+ - Content description
+ * - 4
+ - 16 (10--0)
+ - Analogue gain
+ * - 6
+ - 16
+ - Coarse integration time
+ * - 10
+ - 8
+ - DPC correction threshold bits 9--2
+ * - 15
+ - 16
+ - Output image width
+ * - 17
+ - 16
+ - Output image height
+ * - 23
+ - 8
+ - MIPI header revision number (2)
+ * - 31
+ - 8
+ - Vertical (bit 1) and horizontal flip (bit 0)
+ * - 32
+ - 8
+ - Frame duration A
+ * - 33
+ - 8
+ - Frame duration B
+ * - 34
+ - 8
+ - Context count (2)
+ * - 35
+ - 8
+ - Context select
+ * - 54
+ - 8
+ - Data pedestal bits 9--2
+ * - 63
+ - 8
+ - Frame average bits 9--2
+ * - 64
+ - 16
+ - Digital gain red
+ * - 66
+ - 16
+ - Digital gain greenr
+ * - 68
+ - 16
+ - Digital gain blue
+ * - 70
+ - 16
+ - Digital gain greenb
+ * - 89
+ - 8
+ - Frame counter (starts at 1, wraps to 0 after 255)
diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
index 66f509ad105c..b860b37e3efb 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -1273,6 +1273,7 @@ enum v4l2_jpeg_chroma_subsampling {
#define V4L2_CID_METADATA_LAYOUT (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 12)
#define V4L2_METADATA_LAYOUT_CCS 1U
+#define V4L2_METADATA_LAYOUT_OV2740 2U
#define V4L2_CID_BINNING_FACTORS (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 13)
#define V4L2_BINNING_FACTORS_MAKE(hnum, hdem, vnum, vdem) \
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 51/73] media: ov2740: Add support for embedded data
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (49 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 50/73] media: uapi: Add metadata layout for ov2740 embedded data Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 52/73] media: ov2740: Add support for generic raw formats Sakari Ailus
` (21 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Add support for embedded data. This introduces two internal pads for pixel
and embedded data streams. As the driver supports a single mode only,
there's no need for backward compatibility in mode selection.
The embedded data is configured to be placed before the image data whereas
after the image data is the default.
This patch includes switching to {enable,disable}_streams as well.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/i2c/ov2740.c | 258 ++++++++++++++++++++++++++++---------
1 file changed, 197 insertions(+), 61 deletions(-)
diff --git a/drivers/media/i2c/ov2740.c b/drivers/media/i2c/ov2740.c
index 536325bb7b92..e10df4840dca 100644
--- a/drivers/media/i2c/ov2740.c
+++ b/drivers/media/i2c/ov2740.c
@@ -12,6 +12,7 @@
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/unaligned.h>
+#include <media/mipi-csi2.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-device.h>
#include <media/v4l2-fwnode.h>
@@ -23,6 +24,11 @@
#define OV2740_DATA_LANES 2
#define OV2740_RGB_DEPTH 10
+#define OV2740_CROP_TOP 4U
+#define OV2740_CROP_LEFT 4U
+#define OV2740_ACTIVE_WIDTH 1936U
+#define OV2740_ACTIVE_HEIGHT 1096U
+
#define OV2740_REG_CHIP_ID 0x300a
#define OV2740_CHIP_ID 0x2740
@@ -72,6 +78,15 @@
#define OV2740_REG_ISP_CTRL00 0x5000
/* ISP CTRL01 */
#define OV2740_REG_ISP_CTRL01 0x5001
+
+/* Embedded data line location control */
+#define OV2740_REG_EMBEDDED_FLAG 0x5a08
+#define OV2740_EMBEDDED_FLAG_FOOTER BIT(2) /* otherwise it's in header */
+#define OV2740_EMBEDDED_FLAG_MYSTERY BIT(1)
+#define OV2740_REG_EMBEDDED_DT 0x3036
+#define OV2740_REG_EMBEDDED_CTRL 0x4307
+#define OV2740_EMBEDDED_CTRL_MYSTERY 0x30
+#define OV2740_EMBEDDED_CTRL_ENABLE BIT(0)
/* Customer Addresses: 0x7010 - 0x710F */
#define CUSTOMER_USE_OTP_SIZE 0x100
/* OTP registers from sensor */
@@ -83,6 +98,21 @@ static const char * const ov2740_supply_name[] = {
"DVDD",
};
+enum {
+ OV2740_PAD_SOURCE,
+ OV2740_PAD_PIXEL,
+ OV2740_PAD_META,
+ OV2740_NUM_PADS,
+};
+
+enum {
+ OV2740_STREAM_PIXEL,
+ OV2740_STREAM_META,
+};
+
+#define OV2740_META_WIDTH 100U
+#define OV2740_META_HEIGHT 1U
+
struct nvm_data {
struct nvmem_device *nvmem;
struct regmap *regmap;
@@ -156,6 +186,7 @@ static const struct ov2740_reg mode_1932x1092_regs_360mhz[] = {
{0x3000, 0x00},
{0x3018, 0x32},
{0x3031, 0x0a},
+ {OV2740_REG_EMBEDDED_DT, MIPI_CSI2_DT_EMBEDDED_8B},
{0x3080, 0x08},
{0x3083, 0xB4},
{0x3103, 0x00},
@@ -260,7 +291,8 @@ static const struct ov2740_reg mode_1932x1092_regs_360mhz[] = {
{0x4017, 0x10},
{0x4044, 0x02},
{0x4304, 0x08},
- {0x4307, 0x30},
+ {OV2740_REG_EMBEDDED_CTRL,
+ OV2740_EMBEDDED_CTRL_MYSTERY | OV2740_EMBEDDED_CTRL_ENABLE},
{0x4320, 0x80},
{0x4322, 0x00},
{0x4323, 0x00},
@@ -309,6 +341,7 @@ static const struct ov2740_reg mode_1932x1092_regs_180mhz[] = {
{0x3000, 0x00},
{0x3018, 0x32}, /* 0x32 for 2 lanes, 0x12 for 1 lane */
{0x3031, 0x0a},
+ {OV2740_REG_EMBEDDED_DT, MIPI_CSI2_DT_EMBEDDED_8B},
{0x3080, 0x08},
{0x3083, 0xB4},
{0x3103, 0x00},
@@ -413,7 +446,8 @@ static const struct ov2740_reg mode_1932x1092_regs_180mhz[] = {
{0x4017, 0x10},
{0x4044, 0x02},
{0x4304, 0x08},
- {0x4307, 0x30},
+ {OV2740_REG_EMBEDDED_CTRL,
+ OV2740_EMBEDDED_CTRL_MYSTERY | OV2740_EMBEDDED_CTRL_ENABLE},
{0x4320, 0x80},
{0x4322, 0x00},
{0x4323, 0x00},
@@ -522,7 +556,7 @@ struct ov2740 {
struct device *dev;
struct v4l2_subdev sd;
- struct media_pad pad;
+ struct media_pad pads[OV2740_NUM_PADS];
struct v4l2_ctrl_handler ctrl_handler;
/* V4L2 Controls */
@@ -837,15 +871,6 @@ static int ov2740_init_controls(struct ov2740 *ov2740)
return 0;
}
-static void ov2740_update_pad_format(const struct ov2740_mode *mode,
- struct v4l2_mbus_framefmt *fmt)
-{
- fmt->width = mode->width;
- fmt->height = mode->height;
- fmt->code = MEDIA_BUS_FMT_SGRBG10_1X10;
- fmt->field = V4L2_FIELD_NONE;
-}
-
static int ov2740_load_otp_data(struct nvm_data *nvm)
{
struct device *dev = regmap_get_device(nvm->regmap);
@@ -936,15 +961,25 @@ static int ov2740_load_otp_data(struct nvm_data *nvm)
return ret;
}
-static int ov2740_start_streaming(struct ov2740 *ov2740)
+static int ov2740_enable_streams(struct v4l2_subdev *sd,
+ struct v4l2_subdev_state *state, u32 pad,
+ u64 streams_mask)
{
+ struct ov2740 *ov2740 = to_ov2740(sd);
const struct ov2740_reg_list *reg_list;
int link_freq_index;
int ret;
+ if (!(streams_mask & 1ULL))
+ return 0;
+
+ ret = pm_runtime_resume_and_get(ov2740->dev);
+ if (ret < 0)
+ return ret;
+
ret = ov2740_identify_module(ov2740);
if (ret)
- return ret;
+ goto out_pm_put;
if (ov2740->nvm)
ov2740_load_otp_data(ov2740->nvm);
@@ -953,7 +988,7 @@ static int ov2740_start_streaming(struct ov2740 *ov2740)
ret = ov2740_write_reg(ov2740, 0x0103, 1, 0x01);
if (ret) {
dev_err(ov2740->dev, "failed to reset\n");
- return ret;
+ goto out_pm_put;
}
usleep_range(10000, 15000);
@@ -963,83 +998,98 @@ static int ov2740_start_streaming(struct ov2740 *ov2740)
ret = ov2740_write_reg_list(ov2740, reg_list);
if (ret) {
dev_err(ov2740->dev, "failed to set plls\n");
- return ret;
+ goto out_pm_put;
}
reg_list = &ov2740->cur_mode->reg_list;
ret = ov2740_write_reg_list(ov2740, reg_list);
if (ret) {
dev_err(ov2740->dev, "failed to set mode\n");
- return ret;
+ goto out_pm_put;
}
ret = __v4l2_ctrl_handler_setup(ov2740->sd.ctrl_handler);
if (ret)
- return ret;
+ goto out_pm_put;
+
+ ret = ov2740_write_reg(ov2740, OV2740_REG_EMBEDDED_FLAG, 1,
+ OV2740_EMBEDDED_FLAG_MYSTERY);
+ if (ret)
+ goto out_pm_put;
ret = ov2740_write_reg(ov2740, OV2740_REG_MODE_SELECT, 1,
OV2740_MODE_STREAMING);
- if (ret)
+ if (ret) {
dev_err(ov2740->dev, "failed to start streaming\n");
+ goto out_pm_put;
+ }
- return ret;
-}
+ return 0;
-static void ov2740_stop_streaming(struct ov2740 *ov2740)
-{
- if (ov2740_write_reg(ov2740, OV2740_REG_MODE_SELECT, 1,
- OV2740_MODE_STANDBY))
- dev_err(ov2740->dev, "failed to stop streaming\n");
+out_pm_put:
+ pm_runtime_put(ov2740->dev);
+
+ return ret;
}
-static int ov2740_set_stream(struct v4l2_subdev *sd, int enable)
+static int ov2740_disable_streams(struct v4l2_subdev *sd,
+ struct v4l2_subdev_state *state, u32 pad,
+ u64 streams_mask)
{
struct ov2740 *ov2740 = to_ov2740(sd);
- struct v4l2_subdev_state *sd_state;
- int ret = 0;
-
- sd_state = v4l2_subdev_lock_and_get_active_state(&ov2740->sd);
+ int ret;
- if (enable) {
- ret = pm_runtime_resume_and_get(ov2740->dev);
- if (ret < 0)
- goto out_unlock;
+ if (!(streams_mask & 1ULL))
+ return 0;
- ret = ov2740_start_streaming(ov2740);
- if (ret) {
- enable = 0;
- ov2740_stop_streaming(ov2740);
- pm_runtime_put(ov2740->dev);
- }
- } else {
- ov2740_stop_streaming(ov2740);
- pm_runtime_put(ov2740->dev);
- }
+ ret = ov2740_write_reg(ov2740, OV2740_REG_MODE_SELECT, 1,
+ OV2740_MODE_STANDBY);
-out_unlock:
- v4l2_subdev_unlock_state(sd_state);
+ pm_runtime_put(ov2740->dev);
return ret;
}
-static int ov2740_set_format(struct v4l2_subdev *sd,
- const struct v4l2_subdev_client_info *ci,
- struct v4l2_subdev_state *sd_state,
- struct v4l2_subdev_format *fmt)
+static int __ov2740_set_format(struct v4l2_subdev *sd,
+ struct v4l2_subdev_state *sd_state,
+ struct v4l2_mbus_framefmt *format,
+ enum v4l2_subdev_format_whence which,
+ unsigned int pad, unsigned int stream)
{
+ struct v4l2_mbus_framefmt *src_pix_fmt, *src_meta_fmt, *meta_fmt;
struct ov2740 *ov2740 = to_ov2740(sd);
const struct ov2740_mode *mode;
s32 vblank_def, h_blank;
+ /*
+ * Allow setting format on internal pixel pad as well as the source
+ * pad's pixel stream (for compatibility).
+ */
+ if ((pad == OV2740_PAD_SOURCE && stream == OV2740_STREAM_META) ||
+ pad == OV2740_PAD_META) {
+ *format = *v4l2_subdev_state_get_format(sd_state, pad, stream);
+ return 0;
+ }
+
+ meta_fmt = v4l2_subdev_state_get_format(sd_state, OV2740_PAD_META, 0);
+ src_pix_fmt = v4l2_subdev_state_get_format(sd_state, OV2740_PAD_SOURCE,
+ OV2740_STREAM_PIXEL);
+ src_meta_fmt = v4l2_subdev_state_get_format(sd_state, OV2740_PAD_SOURCE,
+ OV2740_STREAM_META);
+
mode = v4l2_find_nearest_size(ov2740->supported_modes,
ov2740->supported_modes_count,
width, height,
- fmt->format.width, fmt->format.height);
+ format->width, format->height);
- ov2740_update_pad_format(mode, &fmt->format);
- *v4l2_subdev_state_get_format(sd_state, fmt->pad) = fmt->format;
+ src_pix_fmt->code = format->code;
+ src_pix_fmt->width = mode->width;
+ src_pix_fmt->height = mode->height;
- if (fmt->which == V4L2_SUBDEV_FORMAT_TRY)
+ *format = *src_pix_fmt;
+ *src_meta_fmt = *meta_fmt;
+
+ if (which == V4L2_SUBDEV_FORMAT_TRY)
return 0;
ov2740->cur_mode = mode;
@@ -1059,6 +1109,15 @@ static int ov2740_set_format(struct v4l2_subdev *sd,
return 0;
}
+static int ov2740_set_format(struct v4l2_subdev *sd,
+ const struct v4l2_subdev_client_info *ci,
+ struct v4l2_subdev_state *sd_state,
+ struct v4l2_subdev_format *fmt)
+{
+ return __ov2740_set_format(sd, sd_state, &fmt->format, fmt->which,
+ fmt->pad, fmt->stream);
+}
+
static int ov2740_enum_mbus_code(struct v4l2_subdev *sd,
struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_mbus_code_enum *code)
@@ -1095,15 +1154,84 @@ static int ov2740_enum_frame_size(struct v4l2_subdev *sd,
static int ov2740_init_state(struct v4l2_subdev *sd,
struct v4l2_subdev_state *sd_state)
{
+ struct v4l2_subdev_route routes[] = {
+ {
+ .sink_pad = OV2740_PAD_PIXEL,
+ .source_pad = OV2740_PAD_SOURCE,
+ .source_stream = OV2740_STREAM_PIXEL,
+ .flags = V4L2_SUBDEV_ROUTE_FL_ACTIVE,
+ }, {
+ .sink_pad = OV2740_PAD_META,
+ .source_pad = OV2740_PAD_SOURCE,
+ .source_stream = OV2740_STREAM_META,
+ .flags = V4L2_SUBDEV_ROUTE_FL_ACTIVE,
+ },
+ };
+ struct v4l2_subdev_krouting routing = {
+ .routes = routes,
+ .num_routes = ARRAY_SIZE(routes),
+ };
struct ov2740 *ov2740 = to_ov2740(sd);
+ int ret;
+
+ ret = v4l2_subdev_set_routing(sd, sd_state, &routing);
+ if (ret)
+ return ret;
+
+ struct v4l2_subdev_state *active_state =
+ v4l2_subdev_get_locked_active_state(sd);
+ struct v4l2_mbus_framefmt *pix_fmt =
+ v4l2_subdev_state_get_format(sd_state, OV2740_PAD_PIXEL, 0);
+
+ pix_fmt->code = MEDIA_BUS_FMT_RAW_10;
+ pix_fmt->width = OV2740_CROP_LEFT + OV2740_ACTIVE_WIDTH;
+ pix_fmt->height = OV2740_CROP_TOP + OV2740_ACTIVE_HEIGHT;
+ pix_fmt->field = V4L2_FIELD_NONE;
+
+ struct v4l2_mbus_framefmt *meta_fmt =
+ v4l2_subdev_state_get_format(sd_state, OV2740_PAD_META, 0);
+
+ meta_fmt->code = MEDIA_BUS_FMT_META_10;
+ meta_fmt->width = OV2740_META_WIDTH;
+ meta_fmt->height = OV2740_META_HEIGHT;
+
+ return __ov2740_set_format(sd, sd_state, pix_fmt,
+ active_state == sd_state ?
+ V4L2_SUBDEV_FORMAT_ACTIVE :
+ V4L2_SUBDEV_FORMAT_TRY, OV2740_PAD_PIXEL, 0);
+}
+
+static int ov2740_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad,
+ struct v4l2_mbus_frame_desc *desc)
+{
+ struct v4l2_mbus_frame_desc_entry *entry = desc->entry;
+ struct v4l2_subdev_state *sd_state;
+ struct v4l2_mbus_framefmt *fmt;
+
+ desc->type = V4L2_MBUS_FRAME_DESC_TYPE_CSI2;
+
+ sd_state = v4l2_subdev_lock_and_get_active_state(sd);
+ fmt = v4l2_subdev_state_get_format(sd_state, OV2740_PAD_SOURCE,
+ OV2740_STREAM_PIXEL);
+ entry->pixelcode = fmt->code;
+ v4l2_subdev_unlock_state(sd_state);
+
+ entry->stream = OV2740_STREAM_PIXEL;
+ entry->bus.csi2.dt = MIPI_CSI2_DT_RAW10;
+ entry++;
+ desc->num_entries++;
+
+ entry->pixelcode = MEDIA_BUS_FMT_META_10;
+ entry->stream = OV2740_STREAM_META;
+ entry->bus.csi2.dt = MIPI_CSI2_DT_EMBEDDED_8B;
+ entry++;
+ desc->num_entries++;
- ov2740_update_pad_format(&ov2740->supported_modes[0],
- v4l2_subdev_state_get_format(sd_state, 0));
return 0;
}
static const struct v4l2_subdev_video_ops ov2740_video_ops = {
- .s_stream = ov2740_set_stream,
+ .s_stream = v4l2_subdev_s_stream_helper,
};
static const struct v4l2_subdev_pad_ops ov2740_pad_ops = {
@@ -1111,6 +1239,9 @@ static const struct v4l2_subdev_pad_ops ov2740_pad_ops = {
.set_fmt = ov2740_set_format,
.enum_mbus_code = ov2740_enum_mbus_code,
.enum_frame_size = ov2740_enum_frame_size,
+ .enable_streams = ov2740_enable_streams,
+ .disable_streams = ov2740_disable_streams,
+ .get_frame_desc = ov2740_get_frame_desc,
};
static const struct v4l2_subdev_ops ov2740_subdev_ops = {
@@ -1408,11 +1539,16 @@ static int ov2740_probe(struct i2c_client *client)
}
ov2740->sd.state_lock = ov2740->ctrl_handler.lock;
- ov2740->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
+ ov2740->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_STREAMS;
ov2740->sd.entity.ops = &ov2740_subdev_entity_ops;
ov2740->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
- ov2740->pad.flags = MEDIA_PAD_FL_SOURCE;
- ret = media_entity_pads_init(&ov2740->sd.entity, 1, &ov2740->pad);
+ ov2740->pads[OV2740_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
+ ov2740->pads[OV2740_PAD_PIXEL].flags =
+ MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_INTERNAL;
+ ov2740->pads[OV2740_PAD_META].flags =
+ MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_INTERNAL;
+ ret = media_entity_pads_init(&ov2740->sd.entity,
+ ARRAY_SIZE(ov2740->pads), ov2740->pads);
if (ret) {
dev_err_probe(dev, ret, "failed to init entity pads\n");
goto probe_error_v4l2_ctrl_handler_free;
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 52/73] media: ov2740: Add support for generic raw formats
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (50 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 51/73] media: ov2740: Add support for " Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 53/73] media: ov2740: Add metadata layout control Sakari Ailus
` (20 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Add RAW_10 media bus code and V4L2_CID_CFA_PATTERN as well as
V4L2_CID_CFA_PATTERN_FLIP control support.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/i2c/ov2740.c | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/drivers/media/i2c/ov2740.c b/drivers/media/i2c/ov2740.c
index e10df4840dca..fe7a8d72ac8b 100644
--- a/drivers/media/i2c/ov2740.c
+++ b/drivers/media/i2c/ov2740.c
@@ -804,7 +804,7 @@ static int ov2740_init_controls(struct ov2740 *ov2740)
int ret;
ctrl_hdlr = &ov2740->ctrl_handler;
- ret = v4l2_ctrl_handler_init(ctrl_hdlr, 10);
+ ret = v4l2_ctrl_handler_init(ctrl_hdlr, 12);
if (ret)
return ret;
@@ -852,6 +852,13 @@ static int ov2740_init_controls(struct ov2740 *ov2740)
V4L2_CID_TEST_PATTERN,
ARRAY_SIZE(ov2740_test_pattern_menu) - 1,
0, 0, ov2740_test_pattern_menu);
+ v4l2_ctrl_new_std(ctrl_hdlr, NULL, V4L2_CID_CFA_PATTERN,
+ V4L2_CFA_PATTERN_GRBG, V4L2_CFA_PATTERN_GRBG,
+ 1, V4L2_CFA_PATTERN_GRBG);
+ v4l2_ctrl_new_std(ctrl_hdlr, NULL,
+ V4L2_CID_CFA_PATTERN_FLIP,
+ 0, V4L2_CFA_PATTERN_FLIP_BOTH,
+ 0, V4L2_CFA_PATTERN_FLIP_BOTH);
ret = v4l2_fwnode_device_parse(ov2740->dev, &props);
if (ret) {
@@ -1082,6 +1089,9 @@ static int __ov2740_set_format(struct v4l2_subdev *sd,
width, height,
format->width, format->height);
+ if (format->code != MEDIA_BUS_FMT_RAW_10)
+ format->code = MEDIA_BUS_FMT_SGRBG10_1X10;
+
src_pix_fmt->code = format->code;
src_pix_fmt->width = mode->width;
src_pix_fmt->height = mode->height;
@@ -1122,10 +1132,14 @@ static int ov2740_enum_mbus_code(struct v4l2_subdev *sd,
struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_mbus_code_enum *code)
{
- if (code->index > 0)
+ const u32 codes[] = {
+ MEDIA_BUS_FMT_SGRBG10_1X10,
+ MEDIA_BUS_FMT_RAW_10,
+ };
+ if (code->index >= ARRAY_SIZE(codes))
return -EINVAL;
- code->code = MEDIA_BUS_FMT_SGRBG10_1X10;
+ code->code = codes[code->index];
return 0;
}
@@ -1140,7 +1154,8 @@ static int ov2740_enum_frame_size(struct v4l2_subdev *sd,
if (fse->index >= ov2740->supported_modes_count)
return -EINVAL;
- if (fse->code != MEDIA_BUS_FMT_SGRBG10_1X10)
+ if (fse->code != MEDIA_BUS_FMT_SGRBG10_1X10 &&
+ fse->code != MEDIA_BUS_FMT_RAW_10)
return -EINVAL;
fse->min_width = supported_modes[fse->index].width;
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 53/73] media: ov2740: Add metadata layout control
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (51 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 52/73] media: ov2740: Add support for generic raw formats Sakari Ailus
@ 2026-11-18 13:27 ` Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 54/73] media: ov2740: Add support for G_SELECTION IOCTL Sakari Ailus
` (19 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:27 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Add the V4L2_CID_METADATA_LAYOUT control to the sub-device's control
handler, to convey the metadata layout for the sensor-generated embedded
data.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/i2c/ov2740.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/media/i2c/ov2740.c b/drivers/media/i2c/ov2740.c
index fe7a8d72ac8b..71b5a2fbf686 100644
--- a/drivers/media/i2c/ov2740.c
+++ b/drivers/media/i2c/ov2740.c
@@ -804,7 +804,7 @@ static int ov2740_init_controls(struct ov2740 *ov2740)
int ret;
ctrl_hdlr = &ov2740->ctrl_handler;
- ret = v4l2_ctrl_handler_init(ctrl_hdlr, 12);
+ ret = v4l2_ctrl_handler_init(ctrl_hdlr, 13);
if (ret)
return ret;
@@ -859,6 +859,9 @@ static int ov2740_init_controls(struct ov2740 *ov2740)
V4L2_CID_CFA_PATTERN_FLIP,
0, V4L2_CFA_PATTERN_FLIP_BOTH,
0, V4L2_CFA_PATTERN_FLIP_BOTH);
+ v4l2_ctrl_new_std(ctrl_hdlr, NULL, V4L2_CID_METADATA_LAYOUT,
+ 0, V4L2_METADATA_LAYOUT_OV2740,
+ 1, V4L2_METADATA_LAYOUT_OV2740);
ret = v4l2_fwnode_device_parse(ov2740->dev, &props);
if (ret) {
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 54/73] media: ov2740: Add support for G_SELECTION IOCTL
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (52 preceding siblings ...)
2026-11-18 13:27 ` [PATCH v13 53/73] media: ov2740: Add metadata layout control Sakari Ailus
@ 2026-11-18 13:28 ` Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 55/73] media: ov2740: Add support for FLL and LLP controls Sakari Ailus
` (18 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:28 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Add support for the G_SELECTION IOCTL in the ov2740 driver.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/i2c/ov2740.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/drivers/media/i2c/ov2740.c b/drivers/media/i2c/ov2740.c
index 71b5a2fbf686..ff1f5158786b 100644
--- a/drivers/media/i2c/ov2740.c
+++ b/drivers/media/i2c/ov2740.c
@@ -1131,6 +1131,32 @@ static int ov2740_set_format(struct v4l2_subdev *sd,
fmt->pad, fmt->stream);
}
+static int ov2740_get_selection(struct v4l2_subdev *sd,
+ const struct v4l2_subdev_client_info *ci,
+ struct v4l2_subdev_state *state,
+ struct v4l2_subdev_selection *sel)
+{
+ if (!(ci && ci->caps & V4L2_SUBDEV_CLIENT_CAP_COMMON_RAW_SENSOR))
+ return -EINVAL;
+
+ if (sel->stream != OV2740_STREAM_PIXEL ||
+ sel->pad != OV2740_PAD_PIXEL)
+ return -EINVAL;
+
+ switch (sel->target) {
+ case V4L2_SEL_TGT_CROP_BOUNDS:
+ case V4L2_SEL_TGT_CROP_DEFAULT:
+ case V4L2_SEL_TGT_CROP:
+ sel->r.top = OV2740_CROP_TOP;
+ sel->r.left = OV2740_CROP_LEFT;
+ sel->r.width = OV2740_ACTIVE_WIDTH - OV2740_CROP_LEFT;
+ sel->r.height = OV2740_ACTIVE_HEIGHT - OV2740_CROP_TOP;
+ return 0;
+ }
+
+ return -EINVAL;
+}
+
static int ov2740_enum_mbus_code(struct v4l2_subdev *sd,
struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_mbus_code_enum *code)
@@ -1255,6 +1281,7 @@ static const struct v4l2_subdev_video_ops ov2740_video_ops = {
static const struct v4l2_subdev_pad_ops ov2740_pad_ops = {
.get_fmt = v4l2_subdev_get_fmt,
.set_fmt = ov2740_set_format,
+ .get_selection = ov2740_get_selection,
.enum_mbus_code = ov2740_enum_mbus_code,
.enum_frame_size = ov2740_enum_frame_size,
.enable_streams = ov2740_enable_streams,
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 55/73] media: ov2740: Add support for FLL and LLP controls
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (53 preceding siblings ...)
2026-11-18 13:28 ` [PATCH v13 54/73] media: ov2740: Add support for G_SELECTION IOCTL Sakari Ailus
@ 2026-11-18 13:28 ` Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 56/73] media: ov2740: Signal common raw sensor model support Sakari Ailus
` (17 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:28 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Add support for the V4L2_CID_FRAME_LENGTH_LINES and
V4L2_CID_LINE_LENGTH_PIXELS controls.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/i2c/ov2740.c | 55 ++++++++++++++++++++++++++++----------
1 file changed, 41 insertions(+), 14 deletions(-)
diff --git a/drivers/media/i2c/ov2740.c b/drivers/media/i2c/ov2740.c
index ff1f5158786b..eaf6183b802d 100644
--- a/drivers/media/i2c/ov2740.c
+++ b/drivers/media/i2c/ov2740.c
@@ -16,6 +16,7 @@
#include <media/v4l2-ctrls.h>
#include <media/v4l2-device.h>
#include <media/v4l2-fwnode.h>
+#include <media/v4l2-mc.h>
#define OV2740_LINK_FREQ_360MHZ 360000000ULL
#define OV2740_LINK_FREQ_180MHZ 180000000ULL
@@ -562,9 +563,12 @@ struct ov2740 {
/* V4L2 Controls */
struct v4l2_ctrl *link_freq;
struct v4l2_ctrl *pixel_rate;
+ struct v4l2_ctrl *fll;
struct v4l2_ctrl *vblank;
+ struct v4l2_ctrl *llp;
struct v4l2_ctrl *hblank;
struct v4l2_ctrl *exposure;
+ bool setting_ctrl;
/* GPIOs, clocks, regulators */
struct gpio_desc *reset_gpio;
@@ -738,18 +742,28 @@ static int ov2740_set_ctrl(struct v4l2_ctrl *ctrl)
{
struct ov2740 *ov2740 = container_of(ctrl->handler,
struct ov2740, ctrl_handler);
- s64 exposure_max;
- int ret;
+ int ret = 0;
/* Propagate change of current control to all related controls */
- if (ctrl->id == V4L2_CID_VBLANK) {
- /* Update max exposure while meeting expected vblanking */
- exposure_max = ov2740->cur_mode->height + ctrl->val -
- OV2740_EXPOSURE_MAX_MARGIN;
- __v4l2_ctrl_modify_range(ov2740->exposure,
- ov2740->exposure->minimum,
- exposure_max, ov2740->exposure->step,
- exposure_max);
+ switch (ctrl->id) {
+ case V4L2_CID_FRAME_LENGTH_LINES:
+ case V4L2_CID_VBLANK:
+ case V4L2_CID_LINE_LENGTH_PIXELS:
+ case V4L2_CID_HBLANK: {
+ struct v4l2_subdev_state *state =
+ v4l2_subdev_get_locked_active_state(&ov2740->sd);
+ const struct v4l2_mbus_framefmt *format =
+ v4l2_subdev_state_get_format(state, OV2740_PAD_SOURCE,
+ OV2740_STREAM_PIXEL);
+
+ ret = v4l2_sensor_fll_llp_set(ov2740->fll, ov2740->vblank,
+ ov2740->llp, ov2740->hblank,
+ ov2740->exposure, format,
+ ctrl, &ov2740->setting_ctrl,
+ OV2740_EXPOSURE_MAX_MARGIN);
+ if (ret)
+ return ret;
+ }
}
/* V4L2 controls values will be applied only when power is already up */
@@ -773,8 +787,10 @@ static int ov2740_set_ctrl(struct v4l2_ctrl *ctrl)
break;
case V4L2_CID_VBLANK:
- ret = ov2740_write_reg(ov2740, OV2740_REG_VTS, 2,
- ov2740->cur_mode->height + ctrl->val);
+ break;
+
+ case V4L2_CID_FRAME_LENGTH_LINES:
+ ret = ov2740_write_reg(ov2740, OV2740_REG_VTS, 2, ctrl->val);
break;
case V4L2_CID_TEST_PATTERN:
@@ -804,7 +820,7 @@ static int ov2740_init_controls(struct ov2740 *ov2740)
int ret;
ctrl_hdlr = &ov2740->ctrl_handler;
- ret = v4l2_ctrl_handler_init(ctrl_hdlr, 13);
+ ret = v4l2_ctrl_handler_init(ctrl_hdlr, 15);
if (ret)
return ret;
@@ -825,10 +841,22 @@ static int ov2740_init_controls(struct ov2740 *ov2740)
vblank_min = ov2740->cur_mode->vts_min - ov2740->cur_mode->height;
vblank_max = ov2740->cur_mode->vts_max - ov2740->cur_mode->height;
vblank_default = ov2740->cur_mode->vts_def - ov2740->cur_mode->height;
+ ov2740->fll = v4l2_ctrl_new_std(ctrl_hdlr, &ov2740_ctrl_ops,
+ V4L2_CID_FRAME_LENGTH_LINES,
+ ov2740->cur_mode->vts_min,
+ ov2740->cur_mode->vts_max, 1,
+ ov2740->cur_mode->vts_def);
ov2740->vblank = v4l2_ctrl_new_std(ctrl_hdlr, &ov2740_ctrl_ops,
V4L2_CID_VBLANK, vblank_min,
vblank_max, 1, vblank_default);
+ ov2740->llp = v4l2_ctrl_new_std(ctrl_hdlr, &ov2740_ctrl_ops,
+ V4L2_CID_LINE_LENGTH_PIXELS,
+ ov2740->cur_mode->hts,
+ ov2740->cur_mode->hts, 1,
+ ov2740->cur_mode->hts);
+ if (ov2740->llp)
+ ov2740->llp->flags |= V4L2_CTRL_FLAG_READ_ONLY;
h_blank = ov2740->cur_mode->hts - ov2740->cur_mode->width;
ov2740->hblank = v4l2_ctrl_new_std(ctrl_hdlr, &ov2740_ctrl_ops,
V4L2_CID_HBLANK, h_blank, h_blank, 1,
@@ -1215,7 +1243,6 @@ static int ov2740_init_state(struct v4l2_subdev *sd,
.routes = routes,
.num_routes = ARRAY_SIZE(routes),
};
- struct ov2740 *ov2740 = to_ov2740(sd);
int ret;
ret = v4l2_subdev_set_routing(sd, sd_state, &routing);
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 56/73] media: ov2740: Signal common raw sensor model support
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (54 preceding siblings ...)
2026-11-18 13:28 ` [PATCH v13 55/73] media: ov2740: Add support for FLL and LLP controls Sakari Ailus
@ 2026-11-18 13:28 ` Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 57/73] media: ov2740: Add IMMUTABLE and STATIC route flags Sakari Ailus
` (16 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:28 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Add support for the CONFIG_MODEL control and signal support for the common
raw sensor model.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/i2c/ov2740.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/media/i2c/ov2740.c b/drivers/media/i2c/ov2740.c
index eaf6183b802d..033db55c012f 100644
--- a/drivers/media/i2c/ov2740.c
+++ b/drivers/media/i2c/ov2740.c
@@ -820,7 +820,7 @@ static int ov2740_init_controls(struct ov2740 *ov2740)
int ret;
ctrl_hdlr = &ov2740->ctrl_handler;
- ret = v4l2_ctrl_handler_init(ctrl_hdlr, 15);
+ ret = v4l2_ctrl_handler_init(ctrl_hdlr, 16);
if (ret)
return ret;
@@ -890,6 +890,9 @@ static int ov2740_init_controls(struct ov2740 *ov2740)
v4l2_ctrl_new_std(ctrl_hdlr, NULL, V4L2_CID_METADATA_LAYOUT,
0, V4L2_METADATA_LAYOUT_OV2740,
1, V4L2_METADATA_LAYOUT_OV2740);
+ v4l2_ctrl_new_std(ctrl_hdlr, NULL, V4L2_CID_CONFIG_MODEL,
+ 0, V4L2_CONFIG_MODEL_COMMON_RAW_SENSOR,
+ 0, V4L2_CONFIG_MODEL_COMMON_RAW_SENSOR);
ret = v4l2_fwnode_device_parse(ov2740->dev, &props);
if (ret) {
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 57/73] media: ov2740: Add IMMUTABLE and STATIC route flags
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (55 preceding siblings ...)
2026-11-18 13:28 ` [PATCH v13 56/73] media: ov2740: Signal common raw sensor model support Sakari Ailus
@ 2026-11-18 13:28 ` Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 58/73] media: imx219: Add internal image pad for Common Raw Sensor Model Sakari Ailus
` (15 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:28 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Add immutable and static route flags to the routing table. The driver does
not support disabling the embedded data whereas the sensor itself does.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Julien Massot <julien.massot@collabora.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
drivers/media/i2c/ov2740.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/media/i2c/ov2740.c b/drivers/media/i2c/ov2740.c
index 033db55c012f..cbf47ad5f049 100644
--- a/drivers/media/i2c/ov2740.c
+++ b/drivers/media/i2c/ov2740.c
@@ -1234,12 +1234,16 @@ static int ov2740_init_state(struct v4l2_subdev *sd,
.sink_pad = OV2740_PAD_PIXEL,
.source_pad = OV2740_PAD_SOURCE,
.source_stream = OV2740_STREAM_PIXEL,
- .flags = V4L2_SUBDEV_ROUTE_FL_ACTIVE,
+ .flags = V4L2_SUBDEV_ROUTE_FL_ACTIVE |
+ V4L2_SUBDEV_ROUTE_FL_IMMUTABLE |
+ V4L2_SUBDEV_ROUTE_FL_STATIC,
}, {
.sink_pad = OV2740_PAD_META,
.source_pad = OV2740_PAD_SOURCE,
.source_stream = OV2740_STREAM_META,
- .flags = V4L2_SUBDEV_ROUTE_FL_ACTIVE,
+ .flags = V4L2_SUBDEV_ROUTE_FL_ACTIVE |
+ V4L2_SUBDEV_ROUTE_FL_IMMUTABLE |
+ V4L2_SUBDEV_ROUTE_FL_STATIC,
},
};
struct v4l2_subdev_krouting routing = {
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 58/73] media: imx219: Add internal image pad for Common Raw Sensor Model
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (56 preceding siblings ...)
2026-11-18 13:28 ` [PATCH v13 57/73] media: ov2740: Add IMMUTABLE and STATIC route flags Sakari Ailus
@ 2026-11-18 13:28 ` Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 59/73] media: imx219: Add image stream Sakari Ailus
` (14 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:28 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Add internal image pad in preparation of supporting the Common Raw Sensor
Model. A compatibility interface provided for the existing users.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Co-developed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/i2c/imx219.c | 232 +++++++++++++++++++++++++++----------
1 file changed, 173 insertions(+), 59 deletions(-)
diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c
index 1580562093e8..7facb1344e88 100644
--- a/drivers/media/i2c/imx219.c
+++ b/drivers/media/i2c/imx219.c
@@ -145,13 +145,19 @@
#define IMX219_DEFAULT_LINK_FREQ_4LANE_UNSUPPORTED 363000000
#define IMX219_DEFAULT_LINK_FREQ_4LANE 364000000
+/* For compatibility with the old UAPI. */
+#define IMX219_COMPAT_ACTIVE_AREA_TOP 8U
/* IMX219 native and active pixel array size. */
-#define IMX219_NATIVE_WIDTH 3296U
-#define IMX219_NATIVE_HEIGHT 2480U
+#define IMX219_INACTIVE_AREA_HEIGHT 42U
#define IMX219_ACTIVE_AREA_LEFT 8U
-#define IMX219_ACTIVE_AREA_TOP 8U
+#define IMX219_ACTIVE_AREA_TOP (IMX219_INACTIVE_AREA_HEIGHT + 8U)
#define IMX219_ACTIVE_AREA_WIDTH 3280U
#define IMX219_ACTIVE_AREA_HEIGHT 2464U
+#define IMX219_PIXEL_ARRAY_LEFT 0U
+#define IMX219_PIXEL_ARRAY_TOP IMX219_INACTIVE_AREA_HEIGHT
+#define IMX219_PIXEL_ARRAY_WIDTH 3296U
+#define IMX219_PIXEL_ARRAY_HEIGHT 2480U
+#define IMX219_NATIVE_FORMAT MEDIA_BUS_FMT_SRGGB10_1X10
/* Mode : resolution and related config&values */
struct imx219_mode {
@@ -351,9 +357,15 @@ static const struct imx219_mode supported_modes[] = {
},
};
+enum imx219_pad_ids {
+ IMX219_PAD_SOURCE = 0,
+ IMX219_PAD_IMAGE,
+ IMX219_NUM_PADS,
+};
+
struct imx219 {
struct v4l2_subdev sd;
- struct media_pad pad;
+ struct media_pad pads[IMX219_NUM_PADS];
struct regmap *regmap;
struct clk *xclk; /* system clock to IMX219 */
@@ -421,8 +433,9 @@ static void imx219_get_binning(struct v4l2_subdev_state *state, u8 *bin_h,
u8 *bin_v)
{
const struct v4l2_mbus_framefmt *format =
- v4l2_subdev_state_get_format(state, 0);
- const struct v4l2_rect *crop = v4l2_subdev_state_get_crop(state, 0);
+ v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE);
+ const struct v4l2_rect *crop =
+ v4l2_subdev_state_get_crop(state, IMX219_PAD_SOURCE);
u32 hbin = crop->width / format->width;
u32 vbin = crop->height / format->height;
@@ -460,7 +473,7 @@ static int imx219_set_ctrl(struct v4l2_ctrl *ctrl)
int ret = 0;
state = v4l2_subdev_get_locked_active_state(&imx219->sd);
- format = v4l2_subdev_state_get_format(state, 0);
+ format = v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE);
rate_factor = imx219_get_rate_factor(state);
if (ctrl->id == V4L2_CID_VBLANK) {
@@ -687,8 +700,8 @@ static int imx219_set_framefmt(struct imx219 *imx219,
u32 bpp;
int ret = 0;
- format = v4l2_subdev_state_get_format(state, 0);
- crop = v4l2_subdev_state_get_crop(state, 0);
+ format = v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE);
+ crop = v4l2_subdev_state_get_crop(state, IMX219_PAD_IMAGE);
bpp = imx219_get_format_bpp(format);
cci_write(imx219->regmap, IMX219_REG_X_ADD_STA_A,
@@ -815,10 +828,25 @@ static int imx219_enum_mbus_code(struct v4l2_subdev *sd,
{
struct imx219 *imx219 = to_imx219(sd);
- if (code->index >= (ARRAY_SIZE(imx219_mbus_formats) / 4))
- return -EINVAL;
+ if (code->pad == IMX219_PAD_IMAGE) {
+ /* The internal image pad is hardwired to the native format. */
+ if (code->index > 0)
+ return -EINVAL;
+
+ code->code = IMX219_NATIVE_FORMAT;
+ } else {
+ /*
+ * On the source pad, the sensor supports multiple raw formats
+ * with different bit depths.
+ */
+ u32 format;
- code->code = imx219_get_format_code(imx219, imx219_mbus_formats[code->index * 4]);
+ if (code->index >= ARRAY_SIZE(imx219_mbus_formats) / 4)
+ return -EINVAL;
+
+ format = imx219_mbus_formats[code->index * 4];
+ code->code = imx219_get_format_code(imx219, format);
+ }
return 0;
}
@@ -828,27 +856,32 @@ static int imx219_enum_frame_size(struct v4l2_subdev *sd,
struct v4l2_subdev_frame_size_enum *fse)
{
struct imx219 *imx219 = to_imx219(sd);
- u32 code;
-
- if (fse->index >= ARRAY_SIZE(supported_modes))
- return -EINVAL;
- code = imx219_get_format_code(imx219, fse->code);
- if (fse->code != code)
- return -EINVAL;
+ if (fse->pad == IMX219_PAD_IMAGE) {
+ if (fse->code != MEDIA_BUS_FMT_RAW_10 || fse->index > 0)
+ return -EINVAL;
- fse->min_width = supported_modes[fse->index].width;
- fse->max_width = fse->min_width;
- fse->min_height = supported_modes[fse->index].height;
- fse->max_height = fse->min_height;
+ fse->min_width = IMX219_PIXEL_ARRAY_WIDTH;
+ fse->max_width = IMX219_PIXEL_ARRAY_WIDTH;
+ fse->min_height = IMX219_PIXEL_ARRAY_HEIGHT;
+ fse->max_height = IMX219_PIXEL_ARRAY_HEIGHT;
+ } else {
+ if (fse->code != imx219_get_format_code(imx219, fse->code) ||
+ fse->index >= ARRAY_SIZE(supported_modes))
+ return -EINVAL;
+
+ fse->min_width = supported_modes[fse->index].width;
+ fse->max_width = fse->min_width;
+ fse->min_height = supported_modes[fse->index].height;
+ fse->max_height = fse->min_height;
+ }
return 0;
}
-static int imx219_set_pad_format(struct v4l2_subdev *sd,
- const struct v4l2_subdev_client_info *ci,
- struct v4l2_subdev_state *state,
- struct v4l2_subdev_format *fmt)
+static int imx219_set_pad_format_compat(struct v4l2_subdev *sd,
+ struct v4l2_subdev_state *state,
+ struct v4l2_subdev_format *fmt)
{
struct imx219 *imx219 = to_imx219(sd);
const struct imx219_mode *mode;
@@ -857,7 +890,7 @@ static int imx219_set_pad_format(struct v4l2_subdev *sd,
u8 bin_h, bin_v, bin_hv;
int ret;
- format = v4l2_subdev_state_get_format(state, 0);
+ format = v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE);
/*
* Adjust the requested format to match the closest mode. The Bayer
@@ -889,11 +922,12 @@ static int imx219_set_pad_format(struct v4l2_subdev *sd,
/* Ensure bin_h and bin_v are same to avoid 1:2 or 2:1 stretching */
bin_hv = min(bin_h, bin_v);
- crop = v4l2_subdev_state_get_crop(state, 0);
+ crop = v4l2_subdev_state_get_crop(state, IMX219_PAD_SOURCE);
crop->width = format->width * bin_hv;
crop->height = format->height * bin_hv;
- crop->left = (IMX219_NATIVE_WIDTH - crop->width) / 2;
- crop->top = (IMX219_NATIVE_HEIGHT - crop->height) / 2;
+ crop->left = (IMX219_PIXEL_ARRAY_WIDTH - crop->width) / 2;
+ crop->top = (IMX219_PIXEL_ARRAY_HEIGHT - crop->height) / 2 +
+ IMX219_ACTIVE_AREA_TOP;
if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE) {
int rate_factor = imx219_get_rate_factor(state);
@@ -959,51 +993,130 @@ static int imx219_set_pad_format(struct v4l2_subdev *sd,
return 0;
}
+static int imx219_set_pad_format(struct v4l2_subdev *sd,
+ const struct v4l2_subdev_client_info *ci,
+ struct v4l2_subdev_state *state,
+ struct v4l2_subdev_format *fmt)
+{
+ struct imx219 *imx219 = to_imx219(sd);
+ struct v4l2_mbus_framefmt *format;
+
+ if (!(ci && ci->caps & V4L2_SUBDEV_CLIENT_CAP_COMMON_RAW_SENSOR))
+ return imx219_set_pad_format_compat(sd, state, fmt);
+
+ if (fmt->pad != IMX219_PAD_SOURCE)
+ return v4l2_subdev_get_fmt(sd, state, fmt);
+
+ format = v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE);
+
+ format->code = fmt->format.code =
+ imx219_get_format_code(imx219, fmt->format.code);
+
+ return 0;
+}
+
static int imx219_get_selection(struct v4l2_subdev *sd,
const struct v4l2_subdev_client_info *ci,
struct v4l2_subdev_state *state,
struct v4l2_subdev_selection *sel)
{
- switch (sel->target) {
- case V4L2_SEL_TGT_CROP:
- sel->r = *v4l2_subdev_state_get_crop(state, 0);
- return 0;
+ if (!(ci &&
+ ci->caps & V4L2_SUBDEV_CLIENT_CAP_COMMON_RAW_SENSOR)) {
+ if (sel->pad != IMX219_PAD_SOURCE)
+ return -EINVAL;
+
+ switch (sel->target) {
+ case V4L2_SEL_TGT_CROP:
+ sel->r = *v4l2_subdev_state_get_crop(state,
+ IMX219_PAD_IMAGE);
+ sel->r.top += -IMX219_ACTIVE_AREA_TOP +
+ IMX219_COMPAT_ACTIVE_AREA_TOP;
+ return 0;
+
+ case V4L2_SEL_TGT_NATIVE_SIZE:
+ sel->r.top = 0;
+ sel->r.left = 0;
+ sel->r.width = IMX219_PIXEL_ARRAY_WIDTH;
+ sel->r.height = IMX219_PIXEL_ARRAY_HEIGHT;
+
+ return 0;
+
+ case V4L2_SEL_TGT_CROP_DEFAULT:
+ case V4L2_SEL_TGT_CROP_BOUNDS:
+ sel->r.top = IMX219_COMPAT_ACTIVE_AREA_TOP;
+ sel->r.left = IMX219_ACTIVE_AREA_LEFT;
+ sel->r.width = IMX219_ACTIVE_AREA_WIDTH;
+ sel->r.height = IMX219_ACTIVE_AREA_HEIGHT;
+
+ return 0;
+ }
- case V4L2_SEL_TGT_NATIVE_SIZE:
- sel->r.top = 0;
- sel->r.left = 0;
- sel->r.width = IMX219_NATIVE_WIDTH;
- sel->r.height = IMX219_NATIVE_HEIGHT;
+ return -EINVAL;
+ }
- return 0;
+ if (sel->pad != IMX219_PAD_IMAGE)
+ return -EINVAL;
- case V4L2_SEL_TGT_CROP_DEFAULT:
+ switch (sel->target) {
case V4L2_SEL_TGT_CROP_BOUNDS:
sel->r.top = IMX219_ACTIVE_AREA_TOP;
sel->r.left = IMX219_ACTIVE_AREA_LEFT;
sel->r.width = IMX219_ACTIVE_AREA_WIDTH;
sel->r.height = IMX219_ACTIVE_AREA_HEIGHT;
-
return 0;
+ case V4L2_SEL_TGT_CROP_DEFAULT:
+ sel->r.top = IMX219_ACTIVE_AREA_TOP;
+ sel->r.left = IMX219_ACTIVE_AREA_LEFT;
+ sel->r.width = IMX219_ACTIVE_AREA_WIDTH;
+ sel->r.height = IMX219_ACTIVE_AREA_HEIGHT;
+ return 0;
+ case V4L2_SEL_TGT_CROP:
+ sel->r = *v4l2_subdev_state_get_crop(state, sel->pad);
+ return 0;
+ case V4L2_SEL_TGT_COMPOSE:
+ sel->r = *v4l2_subdev_state_get_compose(state, sel->pad);
+ return 0;
+ default:
+ return -EINVAL;
}
-
- return -EINVAL;
}
static int imx219_init_state(struct v4l2_subdev *sd,
struct v4l2_subdev_state *state)
{
- struct v4l2_subdev_format fmt = {
- .which = V4L2_SUBDEV_FORMAT_TRY,
- .pad = 0,
- .format = {
- .code = MEDIA_BUS_FMT_SRGGB10_1X10,
- .width = supported_modes[0].width,
- .height = supported_modes[0].height,
- },
- };
+ struct v4l2_mbus_framefmt *pixel_array_format =
+ v4l2_subdev_state_get_format(state, IMX219_PAD_IMAGE);
+ struct v4l2_rect *analogue_crop =
+ v4l2_subdev_state_get_crop(state, IMX219_PAD_IMAGE);
+ struct v4l2_rect *compose =
+ v4l2_subdev_state_get_compose(state, IMX219_PAD_IMAGE);
+ struct v4l2_mbus_framefmt *source_format =
+ v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE);
+
+ /* The image pad models the pixel array, and thus has a fixed format. */
+ pixel_array_format->code = MEDIA_BUS_FMT_RAW_10;
+ pixel_array_format->width = IMX219_ACTIVE_AREA_WIDTH;
+ pixel_array_format->height = IMX219_ACTIVE_AREA_HEIGHT;
+ pixel_array_format->field = V4L2_FIELD_NONE;
+ pixel_array_format->colorspace = V4L2_COLORSPACE_RAW;
+ pixel_array_format->ycbcr_enc = V4L2_YCBCR_ENC_601;
+ pixel_array_format->quantization = V4L2_QUANTIZATION_FULL_RANGE;
+ pixel_array_format->xfer_func = V4L2_XFER_FUNC_NONE;
+
+ analogue_crop->top = IMX219_ACTIVE_AREA_TOP;
+ analogue_crop->left = IMX219_ACTIVE_AREA_LEFT;
+ analogue_crop->width = IMX219_ACTIVE_AREA_WIDTH;
+ analogue_crop->height = IMX219_ACTIVE_AREA_HEIGHT;
+
+ compose->width = analogue_crop->width;
+ compose->height = analogue_crop->height;
+
+ *source_format = *pixel_array_format;
+ source_format->code = IMX219_NATIVE_FORMAT;
+ source_format->width = compose->width;
+ source_format->height = compose->height;
- return imx219_set_pad_format(sd, NULL, state, &fmt);
+ return 0;
}
static const struct v4l2_subdev_video_ops imx219_video_ops = {
@@ -1270,14 +1383,15 @@ static int imx219_probe(struct i2c_client *client)
if (ret)
goto error_power_off;
- /* Initialize subdev */
imx219->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
imx219->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
- /* Initialize source pad */
- imx219->pad.flags = MEDIA_PAD_FL_SOURCE;
+ imx219->pads[IMX219_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
+ imx219->pads[IMX219_PAD_IMAGE].flags = MEDIA_PAD_FL_SINK
+ | MEDIA_PAD_FL_INTERNAL;
- ret = media_entity_pads_init(&imx219->sd.entity, 1, &imx219->pad);
+ ret = media_entity_pads_init(&imx219->sd.entity,
+ ARRAY_SIZE(imx219->pads), imx219->pads);
if (ret) {
dev_err_probe(dev, ret, "failed to init entity pads\n");
goto error_handler_free;
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 59/73] media: imx219: Add image stream
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (57 preceding siblings ...)
2026-11-18 13:28 ` [PATCH v13 58/73] media: imx219: Add internal image pad for Common Raw Sensor Model Sakari Ailus
@ 2026-11-18 13:28 ` Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 60/73] media: imx219: Report internal routes to userspace Sakari Ailus
` (13 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:28 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
In preparation for embedded data stream support, introduce a new
imx219_stream_ids enumeration for stream IDs, with a single value,
IMX219_STREAM_IMAGE for the image data stream. Use it when accessing the
formats, crop and compose rectangles on the source pad. This is meant to
reduce the size of further commits, and doesn't introduce any functional
change.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Co-developed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/i2c/imx219.c | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c
index 7facb1344e88..3acccb203210 100644
--- a/drivers/media/i2c/imx219.c
+++ b/drivers/media/i2c/imx219.c
@@ -363,6 +363,10 @@ enum imx219_pad_ids {
IMX219_NUM_PADS,
};
+enum imx219_stream_ids {
+ IMX219_STREAM_IMAGE,
+};
+
struct imx219 {
struct v4l2_subdev sd;
struct media_pad pads[IMX219_NUM_PADS];
@@ -433,9 +437,10 @@ static void imx219_get_binning(struct v4l2_subdev_state *state, u8 *bin_h,
u8 *bin_v)
{
const struct v4l2_mbus_framefmt *format =
- v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE);
+ v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE,
+ IMX219_STREAM_IMAGE);
const struct v4l2_rect *crop =
- v4l2_subdev_state_get_crop(state, IMX219_PAD_SOURCE);
+ v4l2_subdev_state_get_crop(state, IMX219_PAD_IMAGE);
u32 hbin = crop->width / format->width;
u32 vbin = crop->height / format->height;
@@ -473,7 +478,8 @@ static int imx219_set_ctrl(struct v4l2_ctrl *ctrl)
int ret = 0;
state = v4l2_subdev_get_locked_active_state(&imx219->sd);
- format = v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE);
+ format = v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE,
+ IMX219_STREAM_IMAGE);
rate_factor = imx219_get_rate_factor(state);
if (ctrl->id == V4L2_CID_VBLANK) {
@@ -700,7 +706,8 @@ static int imx219_set_framefmt(struct imx219 *imx219,
u32 bpp;
int ret = 0;
- format = v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE);
+ format = v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE,
+ IMX219_STREAM_IMAGE);
crop = v4l2_subdev_state_get_crop(state, IMX219_PAD_IMAGE);
bpp = imx219_get_format_bpp(format);
@@ -890,7 +897,8 @@ static int imx219_set_pad_format_compat(struct v4l2_subdev *sd,
u8 bin_h, bin_v, bin_hv;
int ret;
- format = v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE);
+ format = v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE,
+ IMX219_STREAM_IMAGE);
/*
* Adjust the requested format to match the closest mode. The Bayer
@@ -922,7 +930,7 @@ static int imx219_set_pad_format_compat(struct v4l2_subdev *sd,
/* Ensure bin_h and bin_v are same to avoid 1:2 or 2:1 stretching */
bin_hv = min(bin_h, bin_v);
- crop = v4l2_subdev_state_get_crop(state, IMX219_PAD_SOURCE);
+ crop = v4l2_subdev_state_get_crop(state, IMX219_PAD_IMAGE);
crop->width = format->width * bin_hv;
crop->height = format->height * bin_hv;
crop->left = (IMX219_PIXEL_ARRAY_WIDTH - crop->width) / 2;
@@ -1007,7 +1015,8 @@ static int imx219_set_pad_format(struct v4l2_subdev *sd,
if (fmt->pad != IMX219_PAD_SOURCE)
return v4l2_subdev_get_fmt(sd, state, fmt);
- format = v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE);
+ format = v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE,
+ IMX219_STREAM_IMAGE);
format->code = fmt->format.code =
imx219_get_format_code(imx219, fmt->format.code);
@@ -1091,7 +1100,8 @@ static int imx219_init_state(struct v4l2_subdev *sd,
struct v4l2_rect *compose =
v4l2_subdev_state_get_compose(state, IMX219_PAD_IMAGE);
struct v4l2_mbus_framefmt *source_format =
- v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE);
+ v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE,
+ IMX219_STREAM_IMAGE);
/* The image pad models the pixel array, and thus has a fixed format. */
pixel_array_format->code = MEDIA_BUS_FMT_RAW_10;
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 60/73] media: imx219: Report internal routes to userspace
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (58 preceding siblings ...)
2026-11-18 13:28 ` [PATCH v13 59/73] media: imx219: Add image stream Sakari Ailus
@ 2026-11-18 13:28 ` Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 61/73] media: imx219: Report streams using frame descriptors Sakari Ailus
` (12 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:28 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Usage of internal pads creates a route internal to the subdev, and the
V4L2 camera sensor API requires such routes to be reported to userspace.
Create the route in the .init_state() operation.
Internal routing support requires stream support, so set the
V4L2_SUBDEV_FL_STREAMS flag. As the route is immutable, there's no need
to implement the .set_routing() operation.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/i2c/imx219.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c
index 3acccb203210..882dabe2f2d8 100644
--- a/drivers/media/i2c/imx219.c
+++ b/drivers/media/i2c/imx219.c
@@ -1093,6 +1093,28 @@ static int imx219_get_selection(struct v4l2_subdev *sd,
static int imx219_init_state(struct v4l2_subdev *sd,
struct v4l2_subdev_state *state)
{
+ struct v4l2_subdev_route routes[1] = {
+ {
+ .sink_pad = IMX219_PAD_IMAGE,
+ .sink_stream = 0,
+ .source_pad = IMX219_PAD_SOURCE,
+ .source_stream = IMX219_STREAM_IMAGE,
+ .flags = V4L2_SUBDEV_ROUTE_FL_ACTIVE |
+ V4L2_SUBDEV_ROUTE_FL_IMMUTABLE |
+ V4L2_SUBDEV_ROUTE_FL_STATIC,
+ },
+ };
+ struct v4l2_subdev_krouting routing = {
+ .len_routes = ARRAY_SIZE(routes),
+ .num_routes = ARRAY_SIZE(routes),
+ .routes = routes,
+ };
+ int ret;
+
+ ret = v4l2_subdev_set_routing(sd, state, &routing);
+ if (ret)
+ return ret;
+
struct v4l2_mbus_framefmt *pixel_array_format =
v4l2_subdev_state_get_format(state, IMX219_PAD_IMAGE);
struct v4l2_rect *analogue_crop =
@@ -1393,7 +1415,8 @@ static int imx219_probe(struct i2c_client *client)
if (ret)
goto error_power_off;
- imx219->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
+ imx219->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE |
+ V4L2_SUBDEV_FL_STREAMS;
imx219->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
imx219->pads[IMX219_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 61/73] media: imx219: Report streams using frame descriptors
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (59 preceding siblings ...)
2026-11-18 13:28 ` [PATCH v13 60/73] media: imx219: Report internal routes to userspace Sakari Ailus
@ 2026-11-18 13:28 ` Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 62/73] media: imx219: Add embedded data support Sakari Ailus
` (11 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:28 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Implement the .get_frame_desc() subdev operation to report information
about streams to the connected CSI-2 receiver. This is required to let
the CSI-2 receiver driver know about virtual channels and data types for
each stream.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/i2c/imx219.c | 48 ++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c
index 882dabe2f2d8..f61dd3a25ac6 100644
--- a/drivers/media/i2c/imx219.c
+++ b/drivers/media/i2c/imx219.c
@@ -23,6 +23,7 @@
#include <linux/pm_runtime.h>
#include <linux/regulator/consumer.h>
+#include <media/mipi-csi2.h>
#include <media/v4l2-cci.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-device.h>
@@ -697,6 +698,24 @@ static void imx219_free_controls(struct imx219 *imx219)
* Subdev operations
*/
+static unsigned int imx219_format_bpp(u32 code)
+{
+ switch (code) {
+ case MEDIA_BUS_FMT_SRGGB8_1X8:
+ case MEDIA_BUS_FMT_SGRBG8_1X8:
+ case MEDIA_BUS_FMT_SGBRG8_1X8:
+ case MEDIA_BUS_FMT_SBGGR8_1X8:
+ return 8;
+
+ case MEDIA_BUS_FMT_SRGGB10_1X10:
+ case MEDIA_BUS_FMT_SGRBG10_1X10:
+ case MEDIA_BUS_FMT_SGBRG10_1X10:
+ case MEDIA_BUS_FMT_SBGGR10_1X10:
+ default:
+ return 10;
+ }
+}
+
static int imx219_set_framefmt(struct imx219 *imx219,
struct v4l2_subdev_state *state)
{
@@ -1090,6 +1109,34 @@ static int imx219_get_selection(struct v4l2_subdev *sd,
}
}
+static int imx219_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad,
+ struct v4l2_mbus_frame_desc *fd)
+{
+ const struct v4l2_mbus_framefmt *fmt;
+ struct v4l2_subdev_state *state;
+ u32 code;
+
+ if (pad != IMX219_PAD_SOURCE)
+ return -EINVAL;
+
+ state = v4l2_subdev_lock_and_get_active_state(sd);
+ fmt = v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE,
+ IMX219_STREAM_IMAGE);
+ code = fmt->code;
+ v4l2_subdev_unlock_state(state);
+
+ fd->type = V4L2_MBUS_FRAME_DESC_TYPE_CSI2;
+ fd->num_entries = 1;
+
+ fd->entry[0].pixelcode = code;
+ fd->entry[0].stream = IMX219_STREAM_IMAGE;
+ fd->entry[0].bus.csi2.vc = 0;
+ fd->entry[0].bus.csi2.dt = imx219_format_bpp(code) == 8 ?
+ MIPI_CSI2_DT_RAW8 : MIPI_CSI2_DT_RAW10;
+
+ return 0;
+}
+
static int imx219_init_state(struct v4l2_subdev *sd,
struct v4l2_subdev_state *state)
{
@@ -1161,6 +1208,7 @@ static const struct v4l2_subdev_pad_ops imx219_pad_ops = {
.set_fmt = imx219_set_pad_format,
.get_selection = imx219_get_selection,
.enum_frame_size = imx219_enum_frame_size,
+ .get_frame_desc = imx219_get_frame_desc,
.enable_streams = imx219_enable_streams,
.disable_streams = imx219_disable_streams,
};
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 62/73] media: imx219: Add embedded data support
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (60 preceding siblings ...)
2026-11-18 13:28 ` [PATCH v13 61/73] media: imx219: Report streams using frame descriptors Sakari Ailus
@ 2026-11-18 13:28 ` Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 63/73] media: imx219: Add support for generic raw formats Sakari Ailus
` (10 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:28 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
The IMX219 generates embedded data unconditionally. Report it as an
additional stream, with a new internal embedded data pad, and update
subdev operations accordingly.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Co-developed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/i2c/imx219.c | 176 +++++++++++++++++++++++++++++++------
1 file changed, 150 insertions(+), 26 deletions(-)
diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c
index f61dd3a25ac6..d0dad5c4eb46 100644
--- a/drivers/media/i2c/imx219.c
+++ b/drivers/media/i2c/imx219.c
@@ -160,6 +160,9 @@
#define IMX219_PIXEL_ARRAY_HEIGHT 2480U
#define IMX219_NATIVE_FORMAT MEDIA_BUS_FMT_SRGGB10_1X10
+/* Embedded metadata stream height */
+#define IMX219_EMBEDDED_DATA_HEIGHT 2U
+
/* Mode : resolution and related config&values */
struct imx219_mode {
/* Frame width */
@@ -361,11 +364,13 @@ static const struct imx219_mode supported_modes[] = {
enum imx219_pad_ids {
IMX219_PAD_SOURCE = 0,
IMX219_PAD_IMAGE,
+ IMX219_PAD_EDATA,
IMX219_NUM_PADS,
};
enum imx219_stream_ids {
IMX219_STREAM_IMAGE,
+ IMX219_STREAM_EDATA,
};
struct imx219 {
@@ -434,6 +439,25 @@ static u32 imx219_get_format_bpp(const struct v4l2_mbus_framefmt *format)
}
}
+static u32
+imx219_get_embedded_format_code(const struct v4l2_mbus_framefmt *format)
+{
+ switch (format->code) {
+ case MEDIA_BUS_FMT_SRGGB8_1X8:
+ case MEDIA_BUS_FMT_SGRBG8_1X8:
+ case MEDIA_BUS_FMT_SGBRG8_1X8:
+ case MEDIA_BUS_FMT_SBGGR8_1X8:
+ return MEDIA_BUS_FMT_META_8;
+
+ case MEDIA_BUS_FMT_SRGGB10_1X10:
+ case MEDIA_BUS_FMT_SGRBG10_1X10:
+ case MEDIA_BUS_FMT_SGBRG10_1X10:
+ case MEDIA_BUS_FMT_SBGGR10_1X10:
+ default:
+ return MEDIA_BUS_FMT_META_10;
+ }
+}
+
static void imx219_get_binning(struct v4l2_subdev_state *state, u8 *bin_h,
u8 *bin_v)
{
@@ -777,6 +801,9 @@ static int imx219_enable_streams(struct v4l2_subdev *sd,
struct i2c_client *client = v4l2_get_subdevdata(&imx219->sd);
int ret;
+ if (!(streams_mask & 1ULL))
+ return 0;
+
ret = pm_runtime_resume_and_get(&client->dev);
if (ret < 0)
return ret;
@@ -834,6 +861,9 @@ static int imx219_disable_streams(struct v4l2_subdev *sd,
struct i2c_client *client = v4l2_get_subdevdata(&imx219->sd);
int ret;
+ if (!(streams_mask & 1ULL))
+ return 0;
+
/* set stream off register */
ret = cci_write(imx219->regmap, IMX219_REG_MODE_SELECT,
IMX219_MODE_STANDBY, NULL);
@@ -854,17 +884,32 @@ static int imx219_enum_mbus_code(struct v4l2_subdev *sd,
{
struct imx219 *imx219 = to_imx219(sd);
- if (code->pad == IMX219_PAD_IMAGE) {
- /* The internal image pad is hardwired to the native format. */
+ switch (code->pad) {
+ case IMX219_PAD_IMAGE:
if (code->index > 0)
return -EINVAL;
- code->code = IMX219_NATIVE_FORMAT;
- } else {
- /*
- * On the source pad, the sensor supports multiple raw formats
- * with different bit depths.
- */
+ code->code = MEDIA_BUS_FMT_RAW_10;
+ return 0;
+
+ case IMX219_PAD_EDATA:
+ if (code->index > 0)
+ return -EINVAL;
+
+ code->code = MEDIA_BUS_FMT_META_8;
+ return 0;
+
+ case IMX219_PAD_SOURCE:
+ default:
+ break;
+ }
+
+ /*
+ * On the source pad, the sensor supports multiple image raw formats
+ * with different bit depths. The embedded data format bit depth
+ * follows the image stream.
+ */
+ if (code->stream == IMX219_STREAM_IMAGE) {
u32 format;
if (code->index >= ARRAY_SIZE(imx219_mbus_formats) / 4)
@@ -872,6 +917,15 @@ static int imx219_enum_mbus_code(struct v4l2_subdev *sd,
format = imx219_mbus_formats[code->index * 4];
code->code = imx219_get_format_code(imx219, format);
+ } else {
+ struct v4l2_mbus_framefmt *fmt;
+
+ if (code->index > 0)
+ return -EINVAL;
+
+ fmt = v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE,
+ IMX219_STREAM_EDATA);
+ code->code = fmt->code;
}
return 0;
@@ -883,15 +937,33 @@ static int imx219_enum_frame_size(struct v4l2_subdev *sd,
{
struct imx219 *imx219 = to_imx219(sd);
- if (fse->pad == IMX219_PAD_IMAGE) {
+ switch (fse->pad) {
+ case IMX219_PAD_IMAGE:
if (fse->code != MEDIA_BUS_FMT_RAW_10 || fse->index > 0)
return -EINVAL;
- fse->min_width = IMX219_PIXEL_ARRAY_WIDTH;
- fse->max_width = IMX219_PIXEL_ARRAY_WIDTH;
- fse->min_height = IMX219_PIXEL_ARRAY_HEIGHT;
- fse->max_height = IMX219_PIXEL_ARRAY_HEIGHT;
- } else {
+ fse->min_width = IMX219_ACTIVE_AREA_WIDTH;
+ fse->max_width = IMX219_ACTIVE_AREA_WIDTH;
+ fse->min_height = IMX219_ACTIVE_AREA_HEIGHT;
+ fse->max_height = IMX219_ACTIVE_AREA_HEIGHT;
+ return 0;
+
+ case IMX219_PAD_EDATA:
+ if (fse->code != MEDIA_BUS_FMT_META_8 || fse->index > 0)
+ return -EINVAL;
+
+ fse->min_width = IMX219_ACTIVE_AREA_WIDTH;
+ fse->max_width = IMX219_ACTIVE_AREA_WIDTH;
+ fse->min_height = IMX219_EMBEDDED_DATA_HEIGHT;
+ fse->max_height = IMX219_EMBEDDED_DATA_HEIGHT;
+ return 0;
+
+ case IMX219_PAD_SOURCE:
+ default:
+ break;
+ }
+
+ if (fse->stream == IMX219_STREAM_IMAGE) {
if (fse->code != imx219_get_format_code(imx219, fse->code) ||
fse->index >= ARRAY_SIZE(supported_modes))
return -EINVAL;
@@ -900,6 +972,21 @@ static int imx219_enum_frame_size(struct v4l2_subdev *sd,
fse->max_width = fse->min_width;
fse->min_height = supported_modes[fse->index].height;
fse->max_height = fse->min_height;
+ } else {
+ struct v4l2_mbus_framefmt *fmt;
+
+ fmt = v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE,
+ IMX219_STREAM_EDATA);
+ if (fse->code != fmt->code)
+ return -EINVAL;
+
+ if (fse->index > 0)
+ return -EINVAL;
+
+ fse->min_width = fmt->width;
+ fse->max_width = fmt->width;
+ fse->min_height = IMX219_EMBEDDED_DATA_HEIGHT;
+ fse->max_height = IMX219_EMBEDDED_DATA_HEIGHT;
}
return 0;
@@ -911,13 +998,16 @@ static int imx219_set_pad_format_compat(struct v4l2_subdev *sd,
{
struct imx219 *imx219 = to_imx219(sd);
const struct imx219_mode *mode;
- struct v4l2_mbus_framefmt *format;
+ struct v4l2_mbus_framefmt *format, *embedded_format;
struct v4l2_rect *crop;
u8 bin_h, bin_v, bin_hv;
int ret;
format = v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE,
IMX219_STREAM_IMAGE);
+ embedded_format =
+ v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE,
+ IMX219_STREAM_EDATA);
/*
* Adjust the requested format to match the closest mode. The Bayer
@@ -939,6 +1029,8 @@ static int imx219_set_pad_format_compat(struct v4l2_subdev *sd,
*format = fmt->format;
+ embedded_format->code = imx219_get_embedded_format_code(format);
+
/*
* Use binning to maximize the crop rectangle size, and centre it in the
* sensor.
@@ -1031,7 +1123,7 @@ static int imx219_set_pad_format(struct v4l2_subdev *sd,
if (!(ci && ci->caps & V4L2_SUBDEV_CLIENT_CAP_COMMON_RAW_SENSOR))
return imx219_set_pad_format_compat(sd, state, fmt);
- if (fmt->pad != IMX219_PAD_SOURCE)
+ if (fmt->pad != IMX219_PAD_SOURCE && fmt->stream != IMX219_STREAM_IMAGE)
return v4l2_subdev_get_fmt(sd, state, fmt);
format = v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE,
@@ -1082,7 +1174,11 @@ static int imx219_get_selection(struct v4l2_subdev *sd,
return -EINVAL;
}
- if (sel->pad != IMX219_PAD_IMAGE)
+ /*
+ * The embedded data stream doesn't support selection rectangles,
+ * neither on the embedded data pad nor on the source pad.
+ */
+ if (sel->pad != IMX219_PAD_IMAGE || sel->stream != IMX219_STREAM_IMAGE)
return -EINVAL;
switch (sel->target) {
@@ -1112,35 +1208,41 @@ static int imx219_get_selection(struct v4l2_subdev *sd,
static int imx219_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad,
struct v4l2_mbus_frame_desc *fd)
{
- const struct v4l2_mbus_framefmt *fmt;
struct v4l2_subdev_state *state;
- u32 code;
+ u32 img_code;
+ u32 ed_code;
if (pad != IMX219_PAD_SOURCE)
return -EINVAL;
state = v4l2_subdev_lock_and_get_active_state(sd);
- fmt = v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE,
- IMX219_STREAM_IMAGE);
- code = fmt->code;
+ img_code = v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE,
+ IMX219_STREAM_IMAGE)->code;
+ ed_code = v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE,
+ IMX219_STREAM_EDATA)->code;
v4l2_subdev_unlock_state(state);
fd->type = V4L2_MBUS_FRAME_DESC_TYPE_CSI2;
- fd->num_entries = 1;
+ fd->num_entries = 2;
- fd->entry[0].pixelcode = code;
+ fd->entry[0].pixelcode = img_code;
fd->entry[0].stream = IMX219_STREAM_IMAGE;
fd->entry[0].bus.csi2.vc = 0;
- fd->entry[0].bus.csi2.dt = imx219_format_bpp(code) == 8 ?
+ fd->entry[0].bus.csi2.dt = imx219_format_bpp(img_code) == 8 ?
MIPI_CSI2_DT_RAW8 : MIPI_CSI2_DT_RAW10;
+ fd->entry[1].pixelcode = ed_code;
+ fd->entry[1].stream = IMX219_STREAM_EDATA;
+ fd->entry[1].bus.csi2.vc = 0;
+ fd->entry[1].bus.csi2.dt = MIPI_CSI2_DT_EMBEDDED_8B;
+
return 0;
}
static int imx219_init_state(struct v4l2_subdev *sd,
struct v4l2_subdev_state *state)
{
- struct v4l2_subdev_route routes[1] = {
+ struct v4l2_subdev_route routes[] = {
{
.sink_pad = IMX219_PAD_IMAGE,
.sink_stream = 0,
@@ -1149,6 +1251,14 @@ static int imx219_init_state(struct v4l2_subdev *sd,
.flags = V4L2_SUBDEV_ROUTE_FL_ACTIVE |
V4L2_SUBDEV_ROUTE_FL_IMMUTABLE |
V4L2_SUBDEV_ROUTE_FL_STATIC,
+ }, {
+ .sink_pad = IMX219_PAD_EDATA,
+ .sink_stream = 0,
+ .source_pad = IMX219_PAD_SOURCE,
+ .source_stream = IMX219_STREAM_EDATA,
+ .flags = V4L2_SUBDEV_ROUTE_FL_ACTIVE |
+ V4L2_SUBDEV_ROUTE_FL_IMMUTABLE |
+ V4L2_SUBDEV_ROUTE_FL_STATIC,
},
};
struct v4l2_subdev_krouting routing = {
@@ -1171,6 +1281,11 @@ static int imx219_init_state(struct v4l2_subdev *sd,
struct v4l2_mbus_framefmt *source_format =
v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE,
IMX219_STREAM_IMAGE);
+ struct v4l2_mbus_framefmt *embedded_format =
+ v4l2_subdev_state_get_format(state, IMX219_PAD_EDATA);
+ struct v4l2_mbus_framefmt *embedded_source_format =
+ v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE,
+ IMX219_STREAM_EDATA);
/* The image pad models the pixel array, and thus has a fixed format. */
pixel_array_format->code = MEDIA_BUS_FMT_RAW_10;
@@ -1195,6 +1310,13 @@ static int imx219_init_state(struct v4l2_subdev *sd,
source_format->width = compose->width;
source_format->height = compose->height;
+ embedded_format->code = imx219_get_embedded_format_code(source_format);
+ embedded_format->width = source_format->width;
+ embedded_format->height = IMX219_EMBEDDED_DATA_HEIGHT;
+ embedded_format->field = V4L2_FIELD_NONE;
+
+ *embedded_source_format = *embedded_format;
+
return 0;
}
@@ -1470,6 +1592,8 @@ static int imx219_probe(struct i2c_client *client)
imx219->pads[IMX219_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
imx219->pads[IMX219_PAD_IMAGE].flags = MEDIA_PAD_FL_SINK
| MEDIA_PAD_FL_INTERNAL;
+ imx219->pads[IMX219_PAD_EDATA].flags = MEDIA_PAD_FL_SINK
+ | MEDIA_PAD_FL_INTERNAL;
ret = media_entity_pads_init(&imx219->sd.entity,
ARRAY_SIZE(imx219->pads), imx219->pads);
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 63/73] media: imx219: Add support for generic raw formats
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (61 preceding siblings ...)
2026-11-18 13:28 ` [PATCH v13 62/73] media: imx219: Add embedded data support Sakari Ailus
@ 2026-11-18 13:28 ` Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 64/73] media: imx219: Add V4L2_CID_BINNING_FACTORS Sakari Ailus
` (9 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:28 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Add support for colour pattern agnostic raw formats, including controls to
convey the colour pattern and the configuration model (common raw sensor).
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/i2c/imx219.c | 40 +++++++++++++++++++++++++++++++++++---
1 file changed, 37 insertions(+), 3 deletions(-)
diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c
index d0dad5c4eb46..e073e34df96b 100644
--- a/drivers/media/i2c/imx219.c
+++ b/drivers/media/i2c/imx219.c
@@ -306,6 +306,11 @@ static const u32 imx219_mbus_formats[] = {
MEDIA_BUS_FMT_SBGGR8_1X8,
};
+static const u32 imx219_mbus_formats_generic[] = {
+ MEDIA_BUS_FMT_RAW_10,
+ MEDIA_BUS_FMT_RAW_8,
+};
+
/*
* Initialisation delay between XCLR low->high and the moment when the sensor
* can start capture (i.e. can leave software stanby) must be not less than:
@@ -408,6 +413,10 @@ static u32 imx219_get_format_code(struct imx219 *imx219, u32 code)
{
unsigned int i;
+ for (i = 0; i < ARRAY_SIZE(imx219_mbus_formats_generic); i++)
+ if (imx219_mbus_formats_generic[i] == code)
+ return code;
+
for (i = 0; i < ARRAY_SIZE(imx219_mbus_formats); i++)
if (imx219_mbus_formats[i] == code)
break;
@@ -428,12 +437,14 @@ static u32 imx219_get_format_bpp(const struct v4l2_mbus_framefmt *format)
case MEDIA_BUS_FMT_SGRBG8_1X8:
case MEDIA_BUS_FMT_SGBRG8_1X8:
case MEDIA_BUS_FMT_SBGGR8_1X8:
+ case MEDIA_BUS_FMT_RAW_8:
return 8;
case MEDIA_BUS_FMT_SRGGB10_1X10:
case MEDIA_BUS_FMT_SGRBG10_1X10:
case MEDIA_BUS_FMT_SGBRG10_1X10:
case MEDIA_BUS_FMT_SBGGR10_1X10:
+ case MEDIA_BUS_FMT_RAW_10:
default:
return 10;
}
@@ -447,12 +458,14 @@ imx219_get_embedded_format_code(const struct v4l2_mbus_framefmt *format)
case MEDIA_BUS_FMT_SGRBG8_1X8:
case MEDIA_BUS_FMT_SGBRG8_1X8:
case MEDIA_BUS_FMT_SBGGR8_1X8:
+ case MEDIA_BUS_FMT_RAW_8:
return MEDIA_BUS_FMT_META_8;
case MEDIA_BUS_FMT_SRGGB10_1X10:
case MEDIA_BUS_FMT_SGRBG10_1X10:
case MEDIA_BUS_FMT_SGBRG10_1X10:
case MEDIA_BUS_FMT_SBGGR10_1X10:
+ case MEDIA_BUS_FMT_RAW_10:
default:
return MEDIA_BUS_FMT_META_10;
}
@@ -688,6 +701,20 @@ static int imx219_init_controls(struct imx219 *imx219)
/* The "Solid color" pattern is white by default */
}
+ v4l2_ctrl_new_std(ctrl_hdlr, NULL, V4L2_CID_CFA_PATTERN,
+ V4L2_CFA_PATTERN_RGGB, V4L2_CFA_PATTERN_RGGB,
+ 1, V4L2_CFA_PATTERN_RGGB);
+ v4l2_ctrl_new_std(ctrl_hdlr, NULL,
+ V4L2_CID_CFA_PATTERN_FLIP,
+ 0, V4L2_CFA_PATTERN_FLIP_BOTH,
+ 0, V4L2_CFA_PATTERN_FLIP_BOTH);
+ v4l2_ctrl_new_std(ctrl_hdlr, NULL, V4L2_CID_METADATA_LAYOUT,
+ 0, V4L2_METADATA_LAYOUT_CCS,
+ 1, V4L2_METADATA_LAYOUT_CCS);
+ v4l2_ctrl_new_std(ctrl_hdlr, NULL, V4L2_CID_CONFIG_MODEL,
+ 0, V4L2_CONFIG_MODEL_COMMON_RAW_SENSOR,
+ 0, V4L2_CONFIG_MODEL_COMMON_RAW_SENSOR);
+
if (ctrl_hdlr->error) {
ret = ctrl_hdlr->error;
dev_err_probe(&client->dev, ret, "Control init failed\n");
@@ -912,10 +939,17 @@ static int imx219_enum_mbus_code(struct v4l2_subdev *sd,
if (code->stream == IMX219_STREAM_IMAGE) {
u32 format;
- if (code->index >= ARRAY_SIZE(imx219_mbus_formats) / 4)
- return -EINVAL;
+ if (code->index >= ARRAY_SIZE(imx219_mbus_formats) / 4) {
+ u32 idx = code->index -
+ ARRAY_SIZE(imx219_mbus_formats) / 4;
+
+ if (idx >= ARRAY_SIZE(imx219_mbus_formats_generic))
+ return -EINVAL;
- format = imx219_mbus_formats[code->index * 4];
+ format = imx219_mbus_formats_generic[idx];
+ } else {
+ format = imx219_mbus_formats[code->index * 4];
+ }
code->code = imx219_get_format_code(imx219, format);
} else {
struct v4l2_mbus_framefmt *fmt;
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 64/73] media: imx219: Add V4L2_CID_BINNING_FACTORS
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (62 preceding siblings ...)
2026-11-18 13:28 ` [PATCH v13 63/73] media: imx219: Add support for generic raw formats Sakari Ailus
@ 2026-11-18 13:28 ` Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 65/73] media: imx219: Allow configuring cropping and binning through CRSM Sakari Ailus
` (8 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:28 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Add support for the V4L2_CID_BINNING_FACTORS control. It'll be read-only
for now.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/i2c/imx219.c | 92 ++++++++++++++++++++++----------------
1 file changed, 53 insertions(+), 39 deletions(-)
diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c
index e073e34df96b..7b7412da0d60 100644
--- a/drivers/media/i2c/imx219.c
+++ b/drivers/media/i2c/imx219.c
@@ -398,6 +398,7 @@ struct imx219 {
struct v4l2_ctrl *hflip;
struct v4l2_ctrl *vblank;
struct v4l2_ctrl *hblank;
+ struct v4l2_ctrl *binning;
/* Two or Four lanes */
u8 lanes;
@@ -471,40 +472,33 @@ imx219_get_embedded_format_code(const struct v4l2_mbus_framefmt *format)
}
}
-static void imx219_get_binning(struct v4l2_subdev_state *state, u8 *bin_h,
- u8 *bin_v)
-{
- const struct v4l2_mbus_framefmt *format =
- v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE,
- IMX219_STREAM_IMAGE);
- const struct v4l2_rect *crop =
- v4l2_subdev_state_get_crop(state, IMX219_PAD_IMAGE);
- u32 hbin = crop->width / format->width;
- u32 vbin = crop->height / format->height;
-
- if (hbin == 2 && vbin == 2) {
- *bin_h = IMX219_BINNING_X2_ANALOG;
- *bin_v = IMX219_BINNING_X2_ANALOG;
- } else {
- *bin_h = IMX219_BINNING_NONE;
- *bin_v = IMX219_BINNING_NONE;
- }
+/* -----------------------------------------------------------------------------
+ * Controls
+ */
-}
+enum imx219_binning_factor_indices {
+ IMX219_BINNING_11,
+ IMX219_BINNING_22,
+};
-static inline u32 imx219_get_rate_factor(struct v4l2_subdev_state *state)
-{
- u8 bin_h, bin_v;
+static const struct {
+ u8 h, v;
+} imx219_binnings[] = {
+ [IMX219_BINNING_11] = { IMX219_BINNING_NONE, IMX219_BINNING_NONE, },
+ [IMX219_BINNING_22] = { IMX219_BINNING_X2_ANALOG, IMX219_BINNING_X2_ANALOG, },
+};
- imx219_get_binning(state, &bin_h, &bin_v);
+static const s64 imx219_binning_factors[] = {
+ [IMX219_BINNING_11] = V4L2_BINNING_FACTORS_MAKE(1, 1, 1, 1),
+ [IMX219_BINNING_22] = V4L2_BINNING_FACTORS_MAKE(2, 1, 2, 1),
+};
- return (bin_h & bin_v) == IMX219_BINNING_X2_ANALOG ? 2 : 1;
+static inline u32 imx219_get_rate_factor(struct imx219 *imx219)
+{
+ return imx219_binnings[imx219->binning->val].v ==
+ IMX219_BINNING_X2_ANALOG ? 2 : 1;
}
-/* -----------------------------------------------------------------------------
- * Controls
- */
-
static int imx219_set_ctrl(struct v4l2_ctrl *ctrl)
{
struct imx219 *imx219 =
@@ -518,9 +512,10 @@ static int imx219_set_ctrl(struct v4l2_ctrl *ctrl)
state = v4l2_subdev_get_locked_active_state(&imx219->sd);
format = v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE,
IMX219_STREAM_IMAGE);
- rate_factor = imx219_get_rate_factor(state);
+ rate_factor = imx219_get_rate_factor(imx219);
- if (ctrl->id == V4L2_CID_VBLANK) {
+ switch (ctrl->id) {
+ case V4L2_CID_VBLANK: {
int exposure_max, exposure_def;
/* Update max exposure while meeting expected vblanking */
@@ -534,7 +529,10 @@ static int imx219_set_ctrl(struct v4l2_ctrl *ctrl)
rate_factor, exposure_def);
if (ret)
return ret;
-
+ break;
+ }
+ case V4L2_CID_BINNING_FACTORS:
+ return 0;
}
/*
@@ -612,6 +610,9 @@ static unsigned long imx219_get_pixel_rate(struct imx219 *imx219)
return (imx219->lanes == 2) ? IMX219_PIXEL_RATE : IMX219_PIXEL_RATE_4LANE;
}
+static_assert(ARRAY_SIZE(imx219_binnings) ==
+ ARRAY_SIZE(imx219_binning_factors));
+
/* Initialize control handlers */
static int imx219_init_controls(struct imx219 *imx219)
{
@@ -714,6 +715,12 @@ static int imx219_init_controls(struct imx219 *imx219)
v4l2_ctrl_new_std(ctrl_hdlr, NULL, V4L2_CID_CONFIG_MODEL,
0, V4L2_CONFIG_MODEL_COMMON_RAW_SENSOR,
0, V4L2_CONFIG_MODEL_COMMON_RAW_SENSOR);
+ imx219->binning =
+ v4l2_ctrl_new_int_menu(ctrl_hdlr, &imx219_ctrl_ops,
+ V4L2_CID_BINNING_FACTORS,
+ ARRAY_SIZE(imx219_binning_factors) - 1,
+ IMX219_BINNING_11,
+ imx219_binning_factors);
if (ctrl_hdlr->error) {
ret = ctrl_hdlr->error;
@@ -721,6 +728,8 @@ static int imx219_init_controls(struct imx219 *imx219)
goto error;
}
+ imx219->binning->flags = V4L2_CTRL_FLAG_READ_ONLY;
+
ret = v4l2_fwnode_device_parse(&client->dev, &props);
if (ret)
goto error;
@@ -772,7 +781,6 @@ static int imx219_set_framefmt(struct imx219 *imx219,
{
const struct v4l2_mbus_framefmt *format;
const struct v4l2_rect *crop;
- u8 bin_h, bin_v;
u32 bpp;
int ret = 0;
@@ -790,9 +798,10 @@ static int imx219_set_framefmt(struct imx219 *imx219,
cci_write(imx219->regmap, IMX219_REG_Y_ADD_END_A,
crop->top - IMX219_ACTIVE_AREA_TOP + crop->height - 1, &ret);
- imx219_get_binning(state, &bin_h, &bin_v);
- cci_write(imx219->regmap, IMX219_REG_BINNING_MODE_H, bin_h, &ret);
- cci_write(imx219->regmap, IMX219_REG_BINNING_MODE_V, bin_v, &ret);
+ cci_write(imx219->regmap, IMX219_REG_BINNING_MODE_H,
+ imx219_binnings[imx219->binning->val].h, &ret);
+ cci_write(imx219->regmap, IMX219_REG_BINNING_MODE_V,
+ imx219_binnings[imx219->binning->val].v, &ret);
cci_write(imx219->regmap, IMX219_REG_X_OUTPUT_SIZE,
format->width, &ret);
@@ -1083,12 +1092,16 @@ static int imx219_set_pad_format_compat(struct v4l2_subdev *sd,
IMX219_ACTIVE_AREA_TOP;
if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE) {
- int rate_factor = imx219_get_rate_factor(state);
int exposure_max;
int exposure_def;
int llp_min;
int pixel_rate;
+ ret = __v4l2_ctrl_s_ctrl(imx219->binning, bin_hv == 1 ?
+ IMX219_BINNING_11 : IMX219_BINNING_22);
+ if (ret)
+ return ret;
+
/* Update limits and set FPS to default */
ret = __v4l2_ctrl_modify_range(imx219->vblank, IMX219_VBLANK_MIN,
IMX219_FLL_MAX - mode->height,
@@ -1103,6 +1116,7 @@ static int imx219_set_pad_format_compat(struct v4l2_subdev *sd,
return ret;
/* Update max exposure while meeting expected vblanking */
+ int rate_factor = imx219_get_rate_factor(imx219);
exposure_max = mode->fll_def -
IMX219_EXPOSURE_OFFSET * rate_factor;
exposure_def = (exposure_max < IMX219_EXPOSURE_DEFAULT) ?
@@ -1120,9 +1134,9 @@ static int imx219_set_pad_format_compat(struct v4l2_subdev *sd,
* operates on two lines together. So we switch to a higher
* minimum of 3560.
*/
- imx219_get_binning(state, &bin_h, &bin_v);
- llp_min = (bin_h & bin_v) == IMX219_BINNING_X2_ANALOG ?
- IMX219_BINNED_LLP_MIN : IMX219_LLP_MIN;
+ llp_min = imx219_binnings[imx219->binning->val].h ==
+ IMX219_BINNING_X2_ANALOG ?
+ IMX219_BINNED_LLP_MIN : IMX219_LLP_MIN;
ret = __v4l2_ctrl_modify_range(imx219->hblank,
llp_min - mode->width,
IMX219_LLP_MAX - mode->width,
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 65/73] media: imx219: Allow configuring cropping and binning through CRSM
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (63 preceding siblings ...)
2026-11-18 13:28 ` [PATCH v13 64/73] media: imx219: Add V4L2_CID_BINNING_FACTORS Sakari Ailus
@ 2026-11-18 13:28 ` Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 66/73] media: imx219: Support LINE_LENGTH_PIXELS and FRAME_LENGTH_LINES controls Sakari Ailus
` (7 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:28 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Enable the configuration of cropping and binning through the Common Raw
Sensor Model. Also change the minimum embedded data line length the same
as that of the output pixel data line.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/i2c/imx219.c | 103 +++++++++++++++++++++++++++++++++----
1 file changed, 94 insertions(+), 9 deletions(-)
diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c
index 7b7412da0d60..0b0fbc082e18 100644
--- a/drivers/media/i2c/imx219.c
+++ b/drivers/media/i2c/imx219.c
@@ -160,6 +160,9 @@
#define IMX219_PIXEL_ARRAY_HEIGHT 2480U
#define IMX219_NATIVE_FORMAT MEDIA_BUS_FMT_SRGGB10_1X10
+#define IMX219_OUTPUT_X_SIZE_MIN 0x100
+#define IMX219_OUTPUT_Y_SIZE_MIN 0x100
+
/* Embedded metadata stream height */
#define IMX219_EMBEDDED_DATA_HEIGHT 2U
@@ -499,6 +502,45 @@ static inline u32 imx219_get_rate_factor(struct imx219 *imx219)
IMX219_BINNING_X2_ANALOG ? 2 : 1;
}
+static void imx219_apply_binning(struct v4l2_subdev_state *state,
+ struct v4l2_rect *crop, unsigned int index)
+{
+ struct v4l2_rect *compose =
+ v4l2_subdev_state_get_compose(state, IMX219_PAD_IMAGE);
+ struct v4l2_mbus_framefmt *source_format =
+ v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE,
+ IMX219_STREAM_IMAGE);
+ struct v4l2_mbus_framefmt *embedded_source_format =
+ v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE,
+ IMX219_STREAM_EDATA);
+ s64 binning = imx219_binning_factors[index];
+
+ crop->width = clamp(crop->width, IMX219_OUTPUT_X_SIZE_MIN *
+ V4L2_BINNING_FACTORS_HNUM(binning),
+ IMX219_ACTIVE_AREA_WIDTH) & ~1;
+ crop->height = clamp(crop->height, IMX219_OUTPUT_Y_SIZE_MIN *
+ V4L2_BINNING_FACTORS_VNUM(binning),
+ IMX219_ACTIVE_AREA_HEIGHT) & ~1;
+ crop->left = clamp((unsigned int)crop->left, IMX219_ACTIVE_AREA_LEFT,
+ IMX219_ACTIVE_AREA_LEFT + IMX219_ACTIVE_AREA_WIDTH -
+ crop->width);
+ crop->top = clamp((unsigned int)crop->top, IMX219_ACTIVE_AREA_TOP,
+ IMX219_ACTIVE_AREA_TOP + IMX219_ACTIVE_AREA_HEIGHT -
+ crop->height);
+
+ compose->width = crop->width / V4L2_BINNING_FACTORS_HNUM(binning);
+ compose->height = crop->height / V4L2_BINNING_FACTORS_VNUM(binning);
+
+ source_format->width = compose->width;
+ source_format->height = compose->height;
+
+ struct v4l2_mbus_framefmt *embedded_format =
+ v4l2_subdev_state_get_format(state, IMX219_PAD_EDATA);
+
+ embedded_format->width =
+ embedded_source_format->width = source_format->width;
+}
+
static int imx219_set_ctrl(struct v4l2_ctrl *ctrl)
{
struct imx219 *imx219 =
@@ -531,9 +573,21 @@ static int imx219_set_ctrl(struct v4l2_ctrl *ctrl)
return ret;
break;
}
- case V4L2_CID_BINNING_FACTORS:
+ case V4L2_CID_BINNING_FACTORS: {
+ struct v4l2_rect *crop =
+ v4l2_subdev_state_get_crop(state, IMX219_PAD_IMAGE);
+
+ cci_write(imx219->regmap, IMX219_REG_BINNING_MODE_H,
+ imx219_binnings[ctrl->val].h, &ret);
+ cci_write(imx219->regmap, IMX219_REG_BINNING_MODE_V,
+ imx219_binnings[ctrl->val].v, &ret);
+
+ if (ctrl->val != ctrl->cur.val)
+ imx219_apply_binning(state, crop, ctrl->val);
+
return 0;
}
+ }
/*
* Applying V4L2 control value only happens
@@ -728,8 +782,6 @@ static int imx219_init_controls(struct imx219 *imx219)
goto error;
}
- imx219->binning->flags = V4L2_CTRL_FLAG_READ_ONLY;
-
ret = v4l2_fwnode_device_parse(&client->dev, &props);
if (ret)
goto error;
@@ -798,11 +850,6 @@ static int imx219_set_framefmt(struct imx219 *imx219,
cci_write(imx219->regmap, IMX219_REG_Y_ADD_END_A,
crop->top - IMX219_ACTIVE_AREA_TOP + crop->height - 1, &ret);
- cci_write(imx219->regmap, IMX219_REG_BINNING_MODE_H,
- imx219_binnings[imx219->binning->val].h, &ret);
- cci_write(imx219->regmap, IMX219_REG_BINNING_MODE_V,
- imx219_binnings[imx219->binning->val].v, &ret);
-
cci_write(imx219->regmap, IMX219_REG_X_OUTPUT_SIZE,
format->width, &ret);
cci_write(imx219->regmap, IMX219_REG_Y_OUTPUT_SIZE,
@@ -881,6 +928,7 @@ static int imx219_enable_streams(struct v4l2_subdev *sd,
/* vflip and hflip cannot change during streaming */
__v4l2_ctrl_grab(imx219->vflip, true);
__v4l2_ctrl_grab(imx219->hflip, true);
+ __v4l2_ctrl_grab(imx219->binning, true);
return 0;
@@ -908,6 +956,7 @@ static int imx219_disable_streams(struct v4l2_subdev *sd,
__v4l2_ctrl_grab(imx219->vflip, false);
__v4l2_ctrl_grab(imx219->hflip, false);
+ __v4l2_ctrl_grab(imx219->binning, false);
pm_runtime_put_autosuspend(&client->dev);
@@ -995,7 +1044,7 @@ static int imx219_enum_frame_size(struct v4l2_subdev *sd,
if (fse->code != MEDIA_BUS_FMT_META_8 || fse->index > 0)
return -EINVAL;
- fse->min_width = IMX219_ACTIVE_AREA_WIDTH;
+ fse->min_width = IMX219_OUTPUT_X_SIZE_MIN;
fse->max_width = IMX219_ACTIVE_AREA_WIDTH;
fse->min_height = IMX219_EMBEDDED_DATA_HEIGHT;
fse->max_height = IMX219_EMBEDDED_DATA_HEIGHT;
@@ -1253,6 +1302,41 @@ static int imx219_get_selection(struct v4l2_subdev *sd,
}
}
+static int imx219_set_selection(struct v4l2_subdev *sd,
+ const struct v4l2_subdev_client_info *ci,
+ struct v4l2_subdev_state *state,
+ struct v4l2_subdev_selection *sel)
+{
+ if (!(ci && ci->caps & V4L2_SUBDEV_CLIENT_CAP_COMMON_RAW_SENSOR))
+ return -EINVAL;
+
+ /*
+ * The embedded data stream doesn't support selection rectangles,
+ * neither on the embedded data pad nor on the source pad.
+ */
+ if (sel->pad != IMX219_PAD_IMAGE || sel->stream != IMX219_STREAM_IMAGE)
+ return -EINVAL;
+
+ switch (sel->target) {
+ case V4L2_SEL_TGT_CROP: {
+ struct imx219 *imx219 = to_imx219(sd);
+ struct v4l2_rect *crop =
+ v4l2_subdev_state_get_crop(state, IMX219_PAD_IMAGE);
+
+ imx219_apply_binning(state, &sel->r, imx219->binning->val);
+
+ *crop = sel->r;
+
+ return 0;
+ }
+ case V4L2_SEL_TGT_COMPOSE:
+ sel->r = *v4l2_subdev_state_get_compose(state, sel->pad);
+ return 0;
+ default:
+ return -EINVAL;
+ }
+}
+
static int imx219_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad,
struct v4l2_mbus_frame_desc *fd)
{
@@ -1377,6 +1461,7 @@ static const struct v4l2_subdev_pad_ops imx219_pad_ops = {
.get_fmt = v4l2_subdev_get_fmt,
.set_fmt = imx219_set_pad_format,
.get_selection = imx219_get_selection,
+ .set_selection = imx219_set_selection,
.enum_frame_size = imx219_enum_frame_size,
.get_frame_desc = imx219_get_frame_desc,
.enable_streams = imx219_enable_streams,
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 66/73] media: imx219: Support LINE_LENGTH_PIXELS and FRAME_LENGTH_LINES controls
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (64 preceding siblings ...)
2026-11-18 13:28 ` [PATCH v13 65/73] media: imx219: Allow configuring cropping and binning through CRSM Sakari Ailus
@ 2026-11-18 13:28 ` Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 67/73] media: v4l2-common: Add helper function media_bus_fmt_to_csi2_(bpp|dt)() Sakari Ailus
` (6 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:28 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Support V4L2_CID_LINE_LENGTH_PIXELS and V4L2_CID_FRAME_LENGTH_LINES
controls. These two controls provide direct access to sensor's line and
frame lengths, without requiring a reference crop rectangle.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/i2c/imx219.c | 171 +++++++++++++++++++++++-------------
include/media/v4l2-common.h | 3 +
2 files changed, 112 insertions(+), 62 deletions(-)
diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c
index 0b0fbc082e18..bb3682be1c9f 100644
--- a/drivers/media/i2c/imx219.c
+++ b/drivers/media/i2c/imx219.c
@@ -399,12 +399,17 @@ struct imx219 {
struct v4l2_ctrl *exposure;
struct v4l2_ctrl *vflip;
struct v4l2_ctrl *hflip;
+ struct v4l2_ctrl *fll;
struct v4l2_ctrl *vblank;
+ struct v4l2_ctrl *llp;
struct v4l2_ctrl *hblank;
struct v4l2_ctrl *binning;
/* Two or Four lanes */
u8 lanes;
+
+ /* For handling frame timing dependencies. */
+ bool setting_ctrl;
};
static inline struct imx219 *to_imx219(struct v4l2_subdev *_sd)
@@ -486,9 +491,10 @@ enum imx219_binning_factor_indices {
static const struct {
u8 h, v;
+ u16 llp_min;
} imx219_binnings[] = {
- [IMX219_BINNING_11] = { IMX219_BINNING_NONE, IMX219_BINNING_NONE, },
- [IMX219_BINNING_22] = { IMX219_BINNING_X2_ANALOG, IMX219_BINNING_X2_ANALOG, },
+ [IMX219_BINNING_11] = { IMX219_BINNING_NONE, IMX219_BINNING_NONE, IMX219_LLP_MIN, },
+ [IMX219_BINNING_22] = { IMX219_BINNING_X2_ANALOG, IMX219_BINNING_X2_ANALOG, IMX219_BINNED_LLP_MIN, },
};
static const s64 imx219_binning_factors[] = {
@@ -502,8 +508,10 @@ static inline u32 imx219_get_rate_factor(struct imx219 *imx219)
IMX219_BINNING_X2_ANALOG ? 2 : 1;
}
-static void imx219_apply_binning(struct v4l2_subdev_state *state,
- struct v4l2_rect *crop, unsigned int index)
+static int imx219_apply_binning(struct imx219 *imx219,
+ struct v4l2_subdev_state *state,
+ struct v4l2_rect *crop, int rate_factor,
+ unsigned int index)
{
struct v4l2_rect *compose =
v4l2_subdev_state_get_compose(state, IMX219_PAD_IMAGE);
@@ -514,6 +522,7 @@ static void imx219_apply_binning(struct v4l2_subdev_state *state,
v4l2_subdev_state_get_format(state, IMX219_PAD_SOURCE,
IMX219_STREAM_EDATA);
s64 binning = imx219_binning_factors[index];
+ int ret;
crop->width = clamp(crop->width, IMX219_OUTPUT_X_SIZE_MIN *
V4L2_BINNING_FACTORS_HNUM(binning),
@@ -539,6 +548,33 @@ static void imx219_apply_binning(struct v4l2_subdev_state *state,
embedded_format->width =
embedded_source_format->width = source_format->width;
+
+ int fll_min = IMX219_VBLANK_MIN + source_format->height;
+ ret = __v4l2_ctrl_modify_range(imx219->fll, fll_min, IMX219_FLL_MAX,
+ rate_factor, fll_min);
+ if (ret)
+ return ret;
+
+ int vblank_min = IMX219_VBLANK_MIN;
+ ret = __v4l2_ctrl_modify_range(imx219->vblank,
+ vblank_min,
+ IMX219_FLL_MAX - source_format->height,
+ rate_factor, vblank_min);
+ if (ret)
+ return ret;
+
+ int llp_min = imx219_binnings[index].llp_min;
+ ret = __v4l2_ctrl_modify_range(imx219->llp, llp_min, IMX219_LLP_MAX,
+ IMX219_LLP_STEP, llp_min);
+ if (ret)
+ return ret;
+
+ return __v4l2_ctrl_modify_range(imx219->hblank,
+ llp_min - (int)source_format->width,
+ IMX219_LLP_MAX -
+ (int)source_format->width,
+ IMX219_LLP_STEP,
+ llp_min - (int)source_format->width);
}
static int imx219_set_ctrl(struct v4l2_ctrl *ctrl)
@@ -557,35 +593,27 @@ static int imx219_set_ctrl(struct v4l2_ctrl *ctrl)
rate_factor = imx219_get_rate_factor(imx219);
switch (ctrl->id) {
- case V4L2_CID_VBLANK: {
- int exposure_max, exposure_def;
-
- /* Update max exposure while meeting expected vblanking */
- exposure_max = format->height + ctrl->val -
- IMX219_EXPOSURE_OFFSET * rate_factor;
- exposure_def = (exposure_max < IMX219_EXPOSURE_DEFAULT) ?
- exposure_max : IMX219_EXPOSURE_DEFAULT;
- ret = __v4l2_ctrl_modify_range(imx219->exposure,
- imx219->exposure->minimum,
- exposure_max,
- rate_factor, exposure_def);
+ case V4L2_CID_FRAME_LENGTH_LINES:
+ case V4L2_CID_VBLANK:
+ case V4L2_CID_LINE_LENGTH_PIXELS:
+ case V4L2_CID_HBLANK:
+ ret = v4l2_sensor_fll_llp_set(imx219->fll, imx219->vblank,
+ imx219->llp, imx219->hblank,
+ imx219->exposure, format, ctrl,
+ &imx219->setting_ctrl,
+ IMX219_EXPOSURE_OFFSET *
+ rate_factor);
if (ret)
return ret;
break;
- }
case V4L2_CID_BINNING_FACTORS: {
struct v4l2_rect *crop =
v4l2_subdev_state_get_crop(state, IMX219_PAD_IMAGE);
- cci_write(imx219->regmap, IMX219_REG_BINNING_MODE_H,
- imx219_binnings[ctrl->val].h, &ret);
- cci_write(imx219->regmap, IMX219_REG_BINNING_MODE_V,
- imx219_binnings[ctrl->val].v, &ret);
-
- if (ctrl->val != ctrl->cur.val)
- imx219_apply_binning(state, crop, ctrl->val);
-
- return 0;
+ ret = imx219_apply_binning(imx219, state, crop, rate_factor,
+ ctrl->val);
+ if (ret)
+ return ret;
}
}
@@ -618,13 +646,22 @@ static int imx219_set_ctrl(struct v4l2_ctrl *ctrl)
cci_write(imx219->regmap, IMX219_REG_ORIENTATION,
imx219->hflip->val | imx219->vflip->val << 1, &ret);
break;
- case V4L2_CID_VBLANK:
+ case V4L2_CID_FRAME_LENGTH_LINES:
cci_write(imx219->regmap, IMX219_REG_FRM_LENGTH_A,
- (format->height + ctrl->val) / rate_factor, &ret);
+ ctrl->val / rate_factor, &ret);
break;
+ case V4L2_CID_LINE_LENGTH_PIXELS:
+ cci_write(imx219->regmap, IMX219_REG_LINE_LENGTH_A, ctrl->val,
+ &ret);
+ break;
+ case V4L2_CID_VBLANK:
case V4L2_CID_HBLANK:
- cci_write(imx219->regmap, IMX219_REG_LINE_LENGTH_A,
- format->width + ctrl->val, &ret);
+ break;
+ case V4L2_CID_BINNING_FACTORS:
+ cci_write(imx219->regmap, IMX219_REG_BINNING_MODE_H,
+ imx219_binnings[ctrl->val].h, &ret);
+ cci_write(imx219->regmap, IMX219_REG_BINNING_MODE_V,
+ imx219_binnings[ctrl->val].v, &ret);
break;
case V4L2_CID_TEST_PATTERN_RED:
cci_write(imx219->regmap, IMX219_REG_TESTP_RED,
@@ -699,10 +736,19 @@ static int imx219_init_controls(struct imx219 *imx219)
imx219->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
/* Initial blanking and exposure. Limits are updated during set_fmt */
+ imx219->fll = v4l2_ctrl_new_std(ctrl_hdlr, &imx219_ctrl_ops,
+ V4L2_CID_FRAME_LENGTH_LINES,
+ IMX219_ACTIVE_AREA_HEIGHT +
+ IMX219_VBLANK_MIN, IMX219_FLL_MAX, 1,
+ mode->fll_def);
imx219->vblank = v4l2_ctrl_new_std(ctrl_hdlr, &imx219_ctrl_ops,
V4L2_CID_VBLANK, IMX219_VBLANK_MIN,
IMX219_FLL_MAX - mode->height, 1,
mode->fll_def - mode->height);
+ imx219->llp = v4l2_ctrl_new_std(ctrl_hdlr, &imx219_ctrl_ops,
+ V4L2_CID_LINE_LENGTH_PIXELS,
+ IMX219_LLP_MIN, IMX219_LLP_MAX, 1,
+ IMX219_LLP_MIN);
imx219->hblank = v4l2_ctrl_new_std(ctrl_hdlr, &imx219_ctrl_ops,
V4L2_CID_HBLANK,
IMX219_LLP_MIN - mode->width,
@@ -782,6 +828,11 @@ static int imx219_init_controls(struct imx219 *imx219)
goto error;
}
+ imx219->fll->flags |= V4L2_CTRL_FLAG_UPDATE;
+ imx219->vblank->flags |= V4L2_CTRL_FLAG_UPDATE;
+ imx219->llp->flags |= V4L2_CTRL_FLAG_UPDATE;
+ imx219->hblank->flags |= V4L2_CTRL_FLAG_UPDATE;
+
ret = v4l2_fwnode_device_parse(&client->dev, &props);
if (ret)
goto error;
@@ -1141,39 +1192,39 @@ static int imx219_set_pad_format_compat(struct v4l2_subdev *sd,
IMX219_ACTIVE_AREA_TOP;
if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE) {
- int exposure_max;
- int exposure_def;
- int llp_min;
+ unsigned int binning = bin_hv == 1 ?
+ IMX219_BINNING_11 : IMX219_BINNING_22;
int pixel_rate;
- ret = __v4l2_ctrl_s_ctrl(imx219->binning, bin_hv == 1 ?
- IMX219_BINNING_11 : IMX219_BINNING_22);
+ ret = __v4l2_ctrl_s_ctrl(imx219->binning, binning);
+ if (ret)
+ return ret;
+
+ int rate_factor = imx219_get_rate_factor(imx219);
+ ret = imx219_apply_binning(imx219, state, crop, rate_factor,
+ binning);
if (ret)
return ret;
/* Update limits and set FPS to default */
- ret = __v4l2_ctrl_modify_range(imx219->vblank, IMX219_VBLANK_MIN,
- IMX219_FLL_MAX - mode->height,
+ ret = __v4l2_ctrl_modify_range(imx219->vblank,
+ imx219->vblank->minimum,
+ imx219->vblank->maximum,
rate_factor,
mode->fll_def - mode->height);
if (ret)
return ret;
- ret = __v4l2_ctrl_s_ctrl(imx219->vblank,
- mode->fll_def - mode->height);
+ ret = __v4l2_ctrl_modify_range(imx219->fll,
+ imx219->fll->minimum,
+ imx219->fll->maximum,
+ rate_factor,
+ mode->fll_def);
if (ret)
return ret;
- /* Update max exposure while meeting expected vblanking */
- int rate_factor = imx219_get_rate_factor(imx219);
- exposure_max = mode->fll_def -
- IMX219_EXPOSURE_OFFSET * rate_factor;
- exposure_def = (exposure_max < IMX219_EXPOSURE_DEFAULT) ?
- exposure_max : IMX219_EXPOSURE_DEFAULT;
- ret = __v4l2_ctrl_modify_range(imx219->exposure,
- imx219->exposure->minimum,
- exposure_max,
- rate_factor, exposure_def);
+ ret = __v4l2_ctrl_s_ctrl(imx219->vblank,
+ mode->fll_def - mode->height);
if (ret)
return ret;
@@ -1183,18 +1234,9 @@ static int imx219_set_pad_format_compat(struct v4l2_subdev *sd,
* operates on two lines together. So we switch to a higher
* minimum of 3560.
*/
- llp_min = imx219_binnings[imx219->binning->val].h ==
- IMX219_BINNING_X2_ANALOG ?
- IMX219_BINNED_LLP_MIN : IMX219_LLP_MIN;
- ret = __v4l2_ctrl_modify_range(imx219->hblank,
- llp_min - mode->width,
- IMX219_LLP_MAX - mode->width,
- IMX219_LLP_STEP,
- llp_min - mode->width);
- if (ret)
- return ret;
-
- ret = __v4l2_ctrl_s_ctrl(imx219->hblank, llp_min - mode->width);
+ ret = __v4l2_ctrl_s_ctrl(imx219->hblank,
+ imx219_binnings[binning].llp_min -
+ mode->width);
if (ret)
return ret;
@@ -1322,8 +1364,13 @@ static int imx219_set_selection(struct v4l2_subdev *sd,
struct imx219 *imx219 = to_imx219(sd);
struct v4l2_rect *crop =
v4l2_subdev_state_get_crop(state, IMX219_PAD_IMAGE);
+ int ret;
- imx219_apply_binning(state, &sel->r, imx219->binning->val);
+ ret = imx219_apply_binning(imx219, state, &sel->r,
+ imx219_get_rate_factor(imx219),
+ imx219->binning->val);
+ if (ret)
+ return ret;
*crop = sel->r;
diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
index d29575a9f137..bd244c00d91a 100644
--- a/include/media/v4l2-common.h
+++ b/include/media/v4l2-common.h
@@ -17,6 +17,9 @@
#include <linux/time.h>
#include <media/v4l2-dev.h>
+struct v4l2_ctrl;
+struct v4l2_mbus_framefmt;
+
/* Common printk constructs for v4l-i2c drivers. These macros create a unique
prefix consisting of the driver name, the adapter number and the i2c
address. */
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 67/73] media: v4l2-common: Add helper function media_bus_fmt_to_csi2_(bpp|dt)()
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (65 preceding siblings ...)
2026-11-18 13:28 ` [PATCH v13 66/73] media: imx219: Support LINE_LENGTH_PIXELS and FRAME_LENGTH_LINES controls Sakari Ailus
@ 2026-11-18 13:28 ` Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 68/73] media: bcm2835-unicam: Support generic raw formats Sakari Ailus
` (5 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:28 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
From: Frank Li <Frank.Li@nxp.com>
Add helper function media_bus_fmt_to_csi2_bpp() to get media bus fmt's bpp
to reduce codes such as
static const struct imx7_csi_pixfmt pixel_formats[] = {
{
.fourcc = V4L2_PIX_FMT_UYVY,
.codes = IMX_BUS_FMTS(
MEDIA_BUS_FMT_UYVY8_2X8,
MEDIA_BUS_FMT_UYVY8_1X16
),
.yuv = true,
.bpp = 16,
},
....
.bpp can be removed from pixel_formats with this helper function.
CSI2 data type is defined by MIPI Camera Serial Interface 2 Spec Ver4.1.
See section 9.4.
Add helper function media_bus_fmt_to_csi2_dt() to convert media bus fmt to
MIPI defined data type and avoid below duplicated static array in each CSI2
drivers.
{
.code = MEDIA_BUS_FMT_UYVY8_1X16,
.data_type = MIPI_CSI2_DT_YUV422_8B,
}
Only add known map for dt type. Need update media_bus_fmt_info when new
mapping used.
Signed-off-by: Frank Li <Frank.Li@nxp.com>
[Sakari Ailus: Add generic raw formats with bit depths 8, 10, 12 and 14.]
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/v4l2-core/v4l2-common.c | 187 ++++++++++++++++++++++++++
include/media/mipi-csi2.h | 24 ++++
2 files changed, 211 insertions(+)
diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
index 35eafde9d73b..a13f2f1ce269 100644
--- a/drivers/media/v4l2-core/v4l2-common.c
+++ b/drivers/media/v4l2-core/v4l2-common.c
@@ -46,6 +46,7 @@
#include <linux/uaccess.h>
#include <asm/io.h>
#include <asm/div64.h>
+#include <media/mipi-csi2.h>
#include <media/v4l2-common.h>
#include <media/v4l2-device.h>
#include <media/v4l2-ctrls.h>
@@ -928,3 +929,189 @@ int v4l2_sensor_fll_llp_set(struct v4l2_ctrl *fll, struct v4l2_ctrl *vblank,
exposure_max);
}
EXPORT_SYMBOL_GPL(v4l2_sensor_fll_llp_set);
+
+/**
+ * struct media_bus_fmt_info - information about a media bus format
+ * @code: media bus format identifier (MEDIA_BUS_FMT_*)
+ * @dt: data type define in MIPI spec (MIPI_CSI2_DT *)
+ * @bpp: bit width per pixel, which is suffix from MEDIA_BUS_FMT_*, no pad. no
+ * compressed data.
+ */
+struct media_bus_fmt_info {
+ u32 code;
+ u8 dt;
+ u8 bpp;
+};
+
+static const struct media_bus_fmt_info media_bus_fmt_info[] = {
+ { .code = MEDIA_BUS_FMT_RGB444_1X12, .bpp = 12 },
+ { .code = MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE, .bpp = 16 },
+ { .code = MEDIA_BUS_FMT_RGB444_2X8_PADHI_LE, .bpp = 16 },
+ { .code = MEDIA_BUS_FMT_RGB555_2X8_PADHI_BE, .bpp = 16 },
+ { .code = MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE, .bpp = 16 },
+ { .code = MEDIA_BUS_FMT_RGB565_1X16, .dt = MIPI_CSI2_DT_RGB565, .bpp = 16 },
+ { .code = MEDIA_BUS_FMT_BGR565_2X8_BE, .dt = MIPI_CSI2_DT_RGB565, .bpp = 16 },
+ { .code = MEDIA_BUS_FMT_BGR565_2X8_LE, .dt = MIPI_CSI2_DT_RGB565, .bpp = 16 },
+ { .code = MEDIA_BUS_FMT_RGB565_2X8_BE, .dt = MIPI_CSI2_DT_RGB565, .bpp = 16 },
+ { .code = MEDIA_BUS_FMT_RGB565_2X8_LE, .dt = MIPI_CSI2_DT_RGB565, .bpp = 16 },
+ { .code = MEDIA_BUS_FMT_RGB666_1X18, .bpp = 18 },
+ { .code = MEDIA_BUS_FMT_RGB666_2X9_BE, .bpp = 18 },
+ { .code = MEDIA_BUS_FMT_BGR666_1X18, .bpp = 18 },
+ { .code = MEDIA_BUS_FMT_RBG888_1X24, .dt = MIPI_CSI2_DT_RGB888, .bpp = 24 },
+ { .code = MEDIA_BUS_FMT_RGB666_1X24_CPADHI, .dt = MIPI_CSI2_DT_RGB888, .bpp = 24 },
+ { .code = MEDIA_BUS_FMT_BGR666_1X24_CPADHI, .dt = MIPI_CSI2_DT_RGB888, .bpp = 24 },
+ { .code = MEDIA_BUS_FMT_RGB565_1X24_CPADHI, .dt = MIPI_CSI2_DT_RGB888, .bpp = 24 },
+ { .code = MEDIA_BUS_FMT_RGB666_1X7X3_SPWG, .bpp = 21 },
+ { .code = MEDIA_BUS_FMT_BGR888_1X24, .dt = MIPI_CSI2_DT_RGB888, .bpp = 24 },
+ { .code = MEDIA_BUS_FMT_BGR888_3X8, .dt = MIPI_CSI2_DT_RGB888, .bpp = 24 },
+ { .code = MEDIA_BUS_FMT_GBR888_1X24, .dt = MIPI_CSI2_DT_RGB888, .bpp = 24 },
+ { .code = MEDIA_BUS_FMT_RGB888_1X24, .dt = MIPI_CSI2_DT_RGB888, .bpp = 24 },
+ { .code = MEDIA_BUS_FMT_RGB888_2X12_BE, .bpp = 24 },
+ { .code = MEDIA_BUS_FMT_RGB888_2X12_LE, .bpp = 24 },
+ { .code = MEDIA_BUS_FMT_RGB888_3X8, .dt = MIPI_CSI2_DT_RGB888, .bpp = 24 },
+ { .code = MEDIA_BUS_FMT_RGB888_3X8_DELTA, .bpp = 24 },
+ { .code = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG, .bpp = 28 },
+ { .code = MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA, .bpp = 28 },
+ { .code = MEDIA_BUS_FMT_RGB666_1X30_CPADLO, .bpp = 30 },
+ { .code = MEDIA_BUS_FMT_RGB888_1X30_CPADLO, .bpp = 30 },
+ { .code = MEDIA_BUS_FMT_ARGB8888_1X32, .bpp = 32 },
+ { .code = MEDIA_BUS_FMT_RGB888_1X32_PADHI, .bpp = 32 },
+ { .code = MEDIA_BUS_FMT_RGB101010_1X30, .bpp = 30 },
+ { .code = MEDIA_BUS_FMT_RGB101010_1X7X5_SPWG, .bpp = 35 },
+ { .code = MEDIA_BUS_FMT_RGB101010_1X7X5_JEIDA, .bpp = 35 },
+ { .code = MEDIA_BUS_FMT_RGB666_1X36_CPADLO, .bpp = 36 },
+ { .code = MEDIA_BUS_FMT_RGB888_1X36_CPADLO, .bpp = 36 },
+ { .code = MEDIA_BUS_FMT_RGB121212_1X36, .bpp = 36 },
+ { .code = MEDIA_BUS_FMT_RGB161616_1X48, .bpp = 48 },
+
+ { .code = MEDIA_BUS_FMT_Y8_1X8, .dt = MIPI_CSI2_DT_RAW8, .bpp = 8 },
+ { .code = MEDIA_BUS_FMT_UV8_1X8, .bpp = 8 },
+ { .code = MEDIA_BUS_FMT_UYVY8_1_5X8, .bpp = 12 },
+ { .code = MEDIA_BUS_FMT_VYUY8_1_5X8, .bpp = 12 },
+ { .code = MEDIA_BUS_FMT_YUYV8_1_5X8, .bpp = 12 },
+ { .code = MEDIA_BUS_FMT_YVYU8_1_5X8, .bpp = 12 },
+ { .code = MEDIA_BUS_FMT_UYVY8_2X8, .dt = MIPI_CSI2_DT_YUV422_8B, .bpp = 16 },
+ { .code = MEDIA_BUS_FMT_VYUY8_2X8, .dt = MIPI_CSI2_DT_YUV422_8B, .bpp = 16 },
+ { .code = MEDIA_BUS_FMT_YUYV8_2X8, .dt = MIPI_CSI2_DT_YUV422_8B, .bpp = 16 },
+ { .code = MEDIA_BUS_FMT_YVYU8_2X8, .dt = MIPI_CSI2_DT_YUV422_8B, .bpp = 16 },
+ { .code = MEDIA_BUS_FMT_Y10_1X10, .dt = MIPI_CSI2_DT_RAW10, .bpp = 10 },
+ { .code = MEDIA_BUS_FMT_Y10_2X8_PADHI_LE, .bpp = 16 },
+ { .code = MEDIA_BUS_FMT_UYVY10_2X10, .dt = MIPI_CSI2_DT_YUV422_10B, .bpp = 20 },
+ { .code = MEDIA_BUS_FMT_VYUY10_2X10, .dt = MIPI_CSI2_DT_YUV422_10B, .bpp = 20 },
+ { .code = MEDIA_BUS_FMT_YUYV10_2X10, .dt = MIPI_CSI2_DT_YUV422_10B, .bpp = 20 },
+ { .code = MEDIA_BUS_FMT_YVYU10_2X10, .dt = MIPI_CSI2_DT_YUV422_10B, .bpp = 20 },
+ { .code = MEDIA_BUS_FMT_Y12_1X12, .dt = MIPI_CSI2_DT_RAW12, .bpp = 12 },
+ { .code = MEDIA_BUS_FMT_UYVY12_2X12, .bpp = 24 },
+ { .code = MEDIA_BUS_FMT_VYUY12_2X12, .bpp = 24 },
+ { .code = MEDIA_BUS_FMT_YUYV12_2X12, .bpp = 24 },
+ { .code = MEDIA_BUS_FMT_YVYU12_2X12, .bpp = 24 },
+ { .code = MEDIA_BUS_FMT_Y14_1X14, .dt = MIPI_CSI2_DT_RAW14, .bpp = 14 },
+ { .code = MEDIA_BUS_FMT_Y16_1X16, .dt = MIPI_CSI2_DT_RAW16, .bpp = 16 },
+ { .code = MEDIA_BUS_FMT_UYVY8_1X16, .dt = MIPI_CSI2_DT_YUV422_8B, .bpp = 16 },
+ { .code = MEDIA_BUS_FMT_VYUY8_1X16, .dt = MIPI_CSI2_DT_YUV422_8B, .bpp = 16 },
+ { .code = MEDIA_BUS_FMT_YUYV8_1X16, .dt = MIPI_CSI2_DT_YUV422_8B, .bpp = 16 },
+ { .code = MEDIA_BUS_FMT_YVYU8_1X16, .dt = MIPI_CSI2_DT_YUV422_8B, .bpp = 16 },
+ { .code = MEDIA_BUS_FMT_YDYUYDYV8_1X16, .bpp = 16 },
+ { .code = MEDIA_BUS_FMT_UYVY10_1X20, .dt = MIPI_CSI2_DT_YUV422_10B, .bpp = 20 },
+ { .code = MEDIA_BUS_FMT_VYUY10_1X20, .dt = MIPI_CSI2_DT_YUV422_10B, .bpp = 20 },
+ { .code = MEDIA_BUS_FMT_YUYV10_1X20, .dt = MIPI_CSI2_DT_YUV422_10B, .bpp = 20 },
+ { .code = MEDIA_BUS_FMT_YVYU10_1X20, .dt = MIPI_CSI2_DT_YUV422_10B, .bpp = 20 },
+ { .code = MEDIA_BUS_FMT_VUY8_1X24, .bpp = 24 },
+ { .code = MEDIA_BUS_FMT_YUV8_1X24, .bpp = 24 },
+ { .code = MEDIA_BUS_FMT_UYYVYY8_0_5X24, .dt = MIPI_CSI2_DT_YUV420_8B, .bpp = 12 },
+ { .code = MEDIA_BUS_FMT_UYVY12_1X24, .bpp = 24 },
+ { .code = MEDIA_BUS_FMT_VYUY12_1X24, .bpp = 24 },
+ { .code = MEDIA_BUS_FMT_YUYV12_1X24, .bpp = 24 },
+ { .code = MEDIA_BUS_FMT_YVYU12_1X24, .bpp = 24 },
+ { .code = MEDIA_BUS_FMT_YUV10_1X30, .bpp = 30 },
+ { .code = MEDIA_BUS_FMT_UYYVYY10_0_5X30, .bpp = 15 },
+ { .code = MEDIA_BUS_FMT_AYUV8_1X32, .bpp = 32 },
+ { .code = MEDIA_BUS_FMT_UYYVYY12_0_5X36, .bpp = 18 },
+ { .code = MEDIA_BUS_FMT_YUV12_1X36, .bpp = 36 },
+ { .code = MEDIA_BUS_FMT_YUV16_1X48, .bpp = 48 },
+ { .code = MEDIA_BUS_FMT_UYYVYY16_0_5X48, .bpp = 24 },
+
+ { .code = MEDIA_BUS_FMT_SBGGR8_1X8, .dt = MIPI_CSI2_DT_RAW8, .bpp = 8 },
+ { .code = MEDIA_BUS_FMT_SGBRG8_1X8, .dt = MIPI_CSI2_DT_RAW8, .bpp = 8 },
+ { .code = MEDIA_BUS_FMT_SGRBG8_1X8, .dt = MIPI_CSI2_DT_RAW8, .bpp = 8 },
+ { .code = MEDIA_BUS_FMT_SRGGB8_1X8, .dt = MIPI_CSI2_DT_RAW8, .bpp = 8 },
+ { .code = MEDIA_BUS_FMT_RAW_8, .dt = MIPI_CSI2_DT_RAW8, .bpp = 8 },
+ { .code = MEDIA_BUS_FMT_SBGGR10_ALAW8_1X8, .bpp = 8 },
+ { .code = MEDIA_BUS_FMT_SGBRG10_ALAW8_1X8, .bpp = 8 },
+ { .code = MEDIA_BUS_FMT_SGRBG10_ALAW8_1X8, .bpp = 8 },
+ { .code = MEDIA_BUS_FMT_SRGGB10_ALAW8_1X8, .bpp = 8 },
+ { .code = MEDIA_BUS_FMT_SBGGR10_DPCM8_1X8, .bpp = 8 },
+ { .code = MEDIA_BUS_FMT_SGBRG10_DPCM8_1X8, .bpp = 8 },
+ { .code = MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8, .bpp = 8 },
+ { .code = MEDIA_BUS_FMT_SRGGB10_DPCM8_1X8, .bpp = 8 },
+ { .code = MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_BE, .bpp = 16 },
+ { .code = MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE, .bpp = 16 },
+ { .code = MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_BE, .bpp = 16 },
+ { .code = MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_LE, .bpp = 16 },
+ { .code = MEDIA_BUS_FMT_SBGGR10_1X10, .dt = MIPI_CSI2_DT_RAW10, .bpp = 10 },
+ { .code = MEDIA_BUS_FMT_SGBRG10_1X10, .dt = MIPI_CSI2_DT_RAW10, .bpp = 10 },
+ { .code = MEDIA_BUS_FMT_SGRBG10_1X10, .dt = MIPI_CSI2_DT_RAW10, .bpp = 10 },
+ { .code = MEDIA_BUS_FMT_SRGGB10_1X10, .dt = MIPI_CSI2_DT_RAW10, .bpp = 10 },
+ { .code = MEDIA_BUS_FMT_RAW_10, .dt = MIPI_CSI2_DT_RAW10, .bpp = 10 },
+ { .code = MEDIA_BUS_FMT_SBGGR12_1X12, .dt = MIPI_CSI2_DT_RAW12, .bpp = 12 },
+ { .code = MEDIA_BUS_FMT_SGBRG12_1X12, .dt = MIPI_CSI2_DT_RAW12, .bpp = 12 },
+ { .code = MEDIA_BUS_FMT_SGRBG12_1X12, .dt = MIPI_CSI2_DT_RAW12, .bpp = 12 },
+ { .code = MEDIA_BUS_FMT_SRGGB12_1X12, .dt = MIPI_CSI2_DT_RAW12, .bpp = 12 },
+ { .code = MEDIA_BUS_FMT_RAW_12, .dt = MIPI_CSI2_DT_RAW12, .bpp = 12 },
+ { .code = MEDIA_BUS_FMT_SBGGR14_1X14, .dt = MIPI_CSI2_DT_RAW14, .bpp = 14 },
+ { .code = MEDIA_BUS_FMT_SGBRG14_1X14, .dt = MIPI_CSI2_DT_RAW14, .bpp = 14 },
+ { .code = MEDIA_BUS_FMT_SGRBG14_1X14, .dt = MIPI_CSI2_DT_RAW14, .bpp = 14 },
+ { .code = MEDIA_BUS_FMT_SRGGB14_1X14, .dt = MIPI_CSI2_DT_RAW14, .bpp = 14 },
+ { .code = MEDIA_BUS_FMT_RAW_14, .dt = MIPI_CSI2_DT_RAW14, .bpp = 14 },
+ { .code = MEDIA_BUS_FMT_SBGGR16_1X16, .dt = MIPI_CSI2_DT_RAW16, .bpp = 16 },
+ { .code = MEDIA_BUS_FMT_SGBRG16_1X16, .dt = MIPI_CSI2_DT_RAW16, .bpp = 16 },
+ { .code = MEDIA_BUS_FMT_SGRBG16_1X16, .dt = MIPI_CSI2_DT_RAW16, .bpp = 16 },
+ { .code = MEDIA_BUS_FMT_SRGGB16_1X16, .dt = MIPI_CSI2_DT_RAW16, .bpp = 16 },
+
+ { .code = MEDIA_BUS_FMT_JPEG_1X8, .bpp = 8 },
+
+ { .code = MEDIA_BUS_FMT_S5C_UYVY_JPEG_1X8, .bpp = 8 },
+
+ { .code = MEDIA_BUS_FMT_AHSV8888_1X32, .bpp = 32 },
+
+ { .code = MEDIA_BUS_FMT_META_8, .bpp = 8 },
+ { .code = MEDIA_BUS_FMT_META_10, .bpp = 10 },
+ { .code = MEDIA_BUS_FMT_META_12, .bpp = 12 },
+ { .code = MEDIA_BUS_FMT_META_14, .bpp = 14 },
+ { .code = MEDIA_BUS_FMT_META_16, .bpp = 16 },
+ { .code = MEDIA_BUS_FMT_META_20, .bpp = 20 },
+ { .code = MEDIA_BUS_FMT_META_24, .bpp = 24 },
+};
+
+static const struct media_bus_fmt_info *media_bus_fmt_info_get(u32 bus_fmt)
+{
+ for (unsigned int i = 0; i < ARRAY_SIZE(media_bus_fmt_info); i++) {
+ if (media_bus_fmt_info[i].code == bus_fmt)
+ return &media_bus_fmt_info[i];
+ }
+
+ return NULL;
+}
+
+int media_bus_fmt_to_csi2_dt(u32 bus_fmt)
+{
+ const struct media_bus_fmt_info *info = media_bus_fmt_info_get(bus_fmt);
+
+ if (!info)
+ return -EINVAL;
+
+ /* Check bpp because 0 (MIPI_CSI2_DT_FS) is a valid data type code */
+ return info->bpp ? info->dt : -EINVAL;
+}
+EXPORT_SYMBOL_GPL(media_bus_fmt_to_csi2_dt);
+
+int media_bus_fmt_to_csi2_bpp(u32 bus_fmt)
+{
+ const struct media_bus_fmt_info *info = media_bus_fmt_info_get(bus_fmt);
+
+ if (!info)
+ return -EINVAL;
+
+ return info->bpp ? info->bpp : -EINVAL;
+}
+EXPORT_SYMBOL_GPL(media_bus_fmt_to_csi2_bpp);
diff --git a/include/media/mipi-csi2.h b/include/media/mipi-csi2.h
index 40fc0264250d..86601c9824bc 100644
--- a/include/media/mipi-csi2.h
+++ b/include/media/mipi-csi2.h
@@ -8,6 +8,8 @@
#ifndef _MEDIA_MIPI_CSI2_H
#define _MEDIA_MIPI_CSI2_H
+#include <linux/types.h>
+
/* Short packet data types */
#define MIPI_CSI2_DT_FS 0x00
#define MIPI_CSI2_DT_FE 0x01
@@ -44,4 +46,26 @@
#define MIPI_CSI2_DT_RAW20 0x2f
#define MIPI_CSI2_DT_USER_DEFINED(n) (0x30 + (n)) /* 0..7 */
+/**
+ * media_bus_fmt_to_csi2_dt - Get MIPI CSI2 data type from media bus format
+ *
+ * @bus_fmt: media bus format identifier (MEDIA_BUS_FMT_*)
+ *
+ * Return: MIPI CSI2 data type MIPI_CSI2_DT_*, or -EINVAL if no mbus code is
+ * found..
+ */
+int media_bus_fmt_to_csi2_dt(u32 bus_fmt);
+
+/**
+ * media_bus_fmt_to_csi2_bpp - Get media bus format's bit depth
+ *
+ * @bus_fmt: media bus format identifier (MEDIA_BUS_FMT_*)
+ *
+ * Return: bit depth, -EINVAL if fail to get from bus_fmt.
+ *
+ * Notes: this bpp is suffix from MEDIA_BUS_FMT_*, no pad, not for compressed
+ * data.
+ */
+int media_bus_fmt_to_csi2_bpp(u32 bus_fmt);
+
#endif /* _MEDIA_MIPI_CSI2_H */
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 68/73] media: bcm2835-unicam: Support generic raw formats
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (66 preceding siblings ...)
2026-11-18 13:28 ` [PATCH v13 67/73] media: v4l2-common: Add helper function media_bus_fmt_to_csi2_(bpp|dt)() Sakari Ailus
@ 2026-11-18 13:28 ` Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 69/73] media: ipu6: Add support for raw CFA-agnostic formats Sakari Ailus
` (4 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:28 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Add support for 8-bit unpacked and 10-, 12- and 14-bit packed generic raw
formats.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
.../media/platform/broadcom/bcm2835-unicam.c | 27 +++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/drivers/media/platform/broadcom/bcm2835-unicam.c b/drivers/media/platform/broadcom/bcm2835-unicam.c
index e7c708cdd7f8..6b31df2adbc2 100644
--- a/drivers/media/platform/broadcom/bcm2835-unicam.c
+++ b/drivers/media/platform/broadcom/bcm2835-unicam.c
@@ -452,6 +452,33 @@ static const struct unicam_format_info unicam_image_formats[] = {
.csi_dt = MIPI_CSI2_DT_RAW14,
.unpack = UNICAM_PUM_UNPACK14,
}, {
+ /* Generic raw formats */
+ .fourcc = V4L2_PIX_FMT_RAW_8,
+ .code = MEDIA_BUS_FMT_RAW_8,
+ .depth = 8,
+ .csi_dt = MIPI_CSI2_DT_RAW8,
+ }, {
+ .fourcc = V4L2_PIX_FMT_RAW_CSI2_10,
+ .unpacked_fourcc = V4L2_PIX_FMT_RAW_10,
+ .code = MEDIA_BUS_FMT_RAW_10,
+ .depth = 10,
+ .csi_dt = MIPI_CSI2_DT_RAW10,
+ .unpack = UNICAM_PUM_UNPACK10,
+ }, {
+ .fourcc = V4L2_PIX_FMT_RAW_CSI2_12,
+ .unpacked_fourcc = V4L2_PIX_FMT_RAW_12,
+ .code = MEDIA_BUS_FMT_RAW_12,
+ .depth = 12,
+ .csi_dt = MIPI_CSI2_DT_RAW12,
+ .unpack = UNICAM_PUM_UNPACK12,
+ }, {
+ .fourcc = V4L2_PIX_FMT_RAW_CSI2_14,
+ .unpacked_fourcc = V4L2_PIX_FMT_RAW_14,
+ .code = MEDIA_BUS_FMT_RAW_14,
+ .depth = 14,
+ .csi_dt = MIPI_CSI2_DT_RAW14,
+ .unpack = UNICAM_PUM_UNPACK14,
+ }, {
/* 16 bit Bayer formats could be supported. */
/* Greyscale formats */
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 69/73] media: ipu6: Add support for raw CFA-agnostic formats
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (67 preceding siblings ...)
2026-11-18 13:28 ` [PATCH v13 68/73] media: bcm2835-unicam: Support generic raw formats Sakari Ailus
@ 2026-11-18 13:28 ` Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 70/73] media: ipu6: Add support for generic unpacked pixel and metadata formats Sakari Ailus
` (3 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:28 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Add support for CFA-agnostic mbus codes and V4L2 pixelformats.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Bingbu Cao <bingbu.cao@intel.com>
---
drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c | 3 +++
drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c | 3 +++
drivers/media/pci/intel/ipu6/ipu6-isys-video.c | 8 ++++++++
3 files changed, 14 insertions(+)
diff --git a/drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c b/drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c
index 152545427930..b24c89bba579 100644
--- a/drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c
+++ b/drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c
@@ -51,6 +51,9 @@ static const u32 csi2_supported_codes[] = {
MEDIA_BUS_FMT_Y10_1X10,
MEDIA_BUS_FMT_Y12_1X12,
MEDIA_BUS_FMT_Y16_1X16,
+ MEDIA_BUS_FMT_RAW_8,
+ MEDIA_BUS_FMT_RAW_10,
+ MEDIA_BUS_FMT_RAW_12,
MEDIA_BUS_FMT_META_8,
MEDIA_BUS_FMT_META_10,
MEDIA_BUS_FMT_META_12,
diff --git a/drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c b/drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c
index 60070842ee68..0a15763d11df 100644
--- a/drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c
+++ b/drivers/media/pci/intel/ipu6/ipu6-isys-subdev.c
@@ -33,6 +33,7 @@ unsigned int ipu6_isys_mbus_code_to_bpp(u32 code)
case MEDIA_BUS_FMT_SGRBG12_1X12:
case MEDIA_BUS_FMT_SRGGB12_1X12:
case MEDIA_BUS_FMT_Y12_1X12:
+ case MEDIA_BUS_FMT_RAW_12:
case MEDIA_BUS_FMT_META_12:
return 12;
case MEDIA_BUS_FMT_SBGGR10_1X10:
@@ -40,6 +41,7 @@ unsigned int ipu6_isys_mbus_code_to_bpp(u32 code)
case MEDIA_BUS_FMT_SGRBG10_1X10:
case MEDIA_BUS_FMT_SRGGB10_1X10:
case MEDIA_BUS_FMT_Y10_1X10:
+ case MEDIA_BUS_FMT_RAW_10:
case MEDIA_BUS_FMT_META_10:
return 10;
case MEDIA_BUS_FMT_SBGGR8_1X8:
@@ -47,6 +49,7 @@ unsigned int ipu6_isys_mbus_code_to_bpp(u32 code)
case MEDIA_BUS_FMT_SGRBG8_1X8:
case MEDIA_BUS_FMT_SRGGB8_1X8:
case MEDIA_BUS_FMT_Y8_1X8:
+ case MEDIA_BUS_FMT_RAW_8:
case MEDIA_BUS_FMT_META_8:
return 8;
default:
diff --git a/drivers/media/pci/intel/ipu6/ipu6-isys-video.c b/drivers/media/pci/intel/ipu6/ipu6-isys-video.c
index 165c840e92a3..0e30725dda2f 100644
--- a/drivers/media/pci/intel/ipu6/ipu6-isys-video.c
+++ b/drivers/media/pci/intel/ipu6/ipu6-isys-video.c
@@ -99,6 +99,14 @@ const struct ipu6_isys_pixelformat ipu6_isys_pfmts[] = {
IPU6_FW_ISYS_FRAME_FORMAT_RGB565 },
{ V4L2_PIX_FMT_BGR24, 24, 24, MEDIA_BUS_FMT_RGB888_1X24,
IPU6_FW_ISYS_FRAME_FORMAT_RGBA888 },
+
+ { V4L2_PIX_FMT_RAW_8, 8, 8, MEDIA_BUS_FMT_RAW_8,
+ IPU6_FW_ISYS_FRAME_FORMAT_RAW8 },
+ { V4L2_PIX_FMT_RAW_CSI2_10, 10, 10, MEDIA_BUS_FMT_RAW_10,
+ IPU6_FW_ISYS_FRAME_FORMAT_RAW10 },
+ { V4L2_PIX_FMT_RAW_CSI2_12, 12, 12, MEDIA_BUS_FMT_RAW_12,
+ IPU6_FW_ISYS_FRAME_FORMAT_RAW12 },
+
{ V4L2_META_FMT_GENERIC_8, 8, 8, MEDIA_BUS_FMT_META_8,
IPU6_FW_ISYS_FRAME_FORMAT_RAW8, true },
{ V4L2_META_FMT_GENERIC_CSI2_10, 10, 10, MEDIA_BUS_FMT_META_10,
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 70/73] media: ipu6: Add support for generic unpacked pixel and metadata formats
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (68 preceding siblings ...)
2026-11-18 13:28 ` [PATCH v13 69/73] media: ipu6: Add support for raw CFA-agnostic formats Sakari Ailus
@ 2026-11-18 13:28 ` Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 71/73] Documentation: media: Reword blanking control documentation Sakari Ailus
` (2 subsequent siblings)
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:28 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Add support for V4L2_PIX_FMT_RAW_10 and V4L2_PIX_FMT_RAW_12 pixelformats
as well as V4L2_META_FMT_GENERIC_16 for 10- and 12-bit depths.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/pci/intel/ipu6/ipu6-isys-video.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/media/pci/intel/ipu6/ipu6-isys-video.c b/drivers/media/pci/intel/ipu6/ipu6-isys-video.c
index 0e30725dda2f..26925331d8d5 100644
--- a/drivers/media/pci/intel/ipu6/ipu6-isys-video.c
+++ b/drivers/media/pci/intel/ipu6/ipu6-isys-video.c
@@ -106,6 +106,10 @@ const struct ipu6_isys_pixelformat ipu6_isys_pfmts[] = {
IPU6_FW_ISYS_FRAME_FORMAT_RAW10 },
{ V4L2_PIX_FMT_RAW_CSI2_12, 12, 12, MEDIA_BUS_FMT_RAW_12,
IPU6_FW_ISYS_FRAME_FORMAT_RAW12 },
+ { V4L2_PIX_FMT_RAW_10, 16, 10, MEDIA_BUS_FMT_RAW_10,
+ IPU6_FW_ISYS_FRAME_FORMAT_RAW16 },
+ { V4L2_PIX_FMT_RAW_12, 16, 12, MEDIA_BUS_FMT_RAW_12,
+ IPU6_FW_ISYS_FRAME_FORMAT_RAW16 },
{ V4L2_META_FMT_GENERIC_8, 8, 8, MEDIA_BUS_FMT_META_8,
IPU6_FW_ISYS_FRAME_FORMAT_RAW8, true },
@@ -113,6 +117,10 @@ const struct ipu6_isys_pixelformat ipu6_isys_pfmts[] = {
IPU6_FW_ISYS_FRAME_FORMAT_RAW10, true },
{ V4L2_META_FMT_GENERIC_CSI2_12, 12, 12, MEDIA_BUS_FMT_META_12,
IPU6_FW_ISYS_FRAME_FORMAT_RAW12, true },
+ { V4L2_META_FMT_GENERIC_16, 16, 10, MEDIA_BUS_FMT_META_10,
+ IPU6_FW_ISYS_FRAME_FORMAT_RAW16, true },
+ { V4L2_META_FMT_GENERIC_16, 16, 12, MEDIA_BUS_FMT_META_12,
+ IPU6_FW_ISYS_FRAME_FORMAT_RAW16, true },
{ V4L2_META_FMT_GENERIC_16, 16, 16, MEDIA_BUS_FMT_META_16,
IPU6_FW_ISYS_FRAME_FORMAT_RAW16, true },
};
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 71/73] Documentation: media: Reword blanking control documentation
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (69 preceding siblings ...)
2026-11-18 13:28 ` [PATCH v13 70/73] media: ipu6: Add support for generic unpacked pixel and metadata formats Sakari Ailus
@ 2026-11-18 13:28 ` Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 72/73] media: uapi: Add generic raw pixelformat for 16 bpp Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 73/73] media: uapi: Add generic CSI-2 raw pixelformats for 16, 20, 24 and 28 bpp Sakari Ailus
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:28 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Originally the VBLANK and HBLANK controls were intended to signify camera
sensor vertical and horizontal blanking values, respectively, and were
used with the analogue crop rectangle and the pixel rate to calculate the
frame interval. Due to various factors, namely the reference size of
output format rather than analogue crop (non-CCS sensors) and the use of
analogue binning, these values in fact have primarily served frame
interval configuration whereas they may not have reflected blanking
anymore. Take this into account in documentation.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
.../media/v4l/ext-ctrls-image-source.rst | 22 ++++++++++++-------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
index b2c515e519f2..3a2dbf64fb72 100644
--- a/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
+++ b/Documentation/userspace-api/media/v4l/ext-ctrls-image-source.rst
@@ -22,16 +22,22 @@ Image Source Control IDs
The IMAGE_SOURCE class descriptor.
``V4L2_CID_VBLANK (integer)``
- Vertical blanking. The idle period after every frame during which no
- image data is produced. The unit of vertical blanking is a line.
- Every line has length of the image width plus horizontal blanking at
- the pixel rate defined by ``V4L2_CID_PIXEL_RATE`` control in the
- same sub-device.
+ Difference between the reference analogue crop rectangle (CCS) height or
+ output format height and the frame length in lines. See :ref:`frame interval
+ configuration <media_camera_sensor_frame_rate_raw>`.
+
+ The primary purpose of this control is low level frame interval
+ configuration. The value may also reflect vertical blanking but this is not
+ guaranteed.
``V4L2_CID_HBLANK (integer)``
- Horizontal blanking. The idle period after every line of image data
- during which no image data is produced. The unit of horizontal
- blanking is pixels.
+ Difference between the reference analogue crop rectangle (CCS) width or
+ output format width and the line length in pixels. See :ref:`frame interval
+ configuration <media_camera_sensor_frame_rate_raw>`.
+
+ The primary purpose of this control is low level frame interval
+ configuration. The value may also reflect horizontal blanking but this is
+ not guaranteed.
``V4L2_CID_ANALOGUE_GAIN (integer)``
Analogue gain is gain affecting all colour components in the pixel
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 72/73] media: uapi: Add generic raw pixelformat for 16 bpp
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (70 preceding siblings ...)
2026-11-18 13:28 ` [PATCH v13 71/73] Documentation: media: Reword blanking control documentation Sakari Ailus
@ 2026-11-18 13:28 ` Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 73/73] media: uapi: Add generic CSI-2 raw pixelformats for 16, 20, 24 and 28 bpp Sakari Ailus
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:28 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Add generic raw pixelformats for bit depth 16.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
.../media/v4l/pixfmt-raw-generic.rst | 49 +++++++++++++++++--
drivers/media/v4l2-core/v4l2-ioctl.c | 1 +
include/uapi/linux/videodev2.h | 1 +
3 files changed, 48 insertions(+), 3 deletions(-)
diff --git a/Documentation/userspace-api/media/v4l/pixfmt-raw-generic.rst b/Documentation/userspace-api/media/v4l/pixfmt-raw-generic.rst
index 1599ce26f698..88cde68bf3ef 100644
--- a/Documentation/userspace-api/media/v4l/pixfmt-raw-generic.rst
+++ b/Documentation/userspace-api/media/v4l/pixfmt-raw-generic.rst
@@ -1,8 +1,8 @@
.. SPDX-License-Identifier: GPL-2.0 OR GFDL-1.1-no-invariants-or-later
-******************************************************************************************************************************************************************************************************************************
-V4L2_PIX_FMT_RAW_8 ('RAW8'), V4L2_PIX_FMT_RAW_CSI2_10 ('RACA'), V4L2_PIX_FMT_RAW_CSI2_12 ('RACC'), V4L2_PIX_FMT_RAW_CSI2_14 ('RACE'), V4L2_PIX_FMT_RAW_10 ('RAWA'), V4L2_PIX_FMT_RAW_12 ('RAWC'), V4L2_PIX_FMT_RAW_14 ('RAWE')
-******************************************************************************************************************************************************************************************************************************
+************************************************************************************************************************************************************************************************************************************************************
+V4L2_PIX_FMT_RAW_8 ('RAW8'), V4L2_PIX_FMT_RAW_CSI2_10 ('RACA'), V4L2_PIX_FMT_RAW_CSI2_12 ('RACC'), V4L2_PIX_FMT_RAW_CSI2_14 ('RACE'), V4L2_PIX_FMT_RAW_10 ('RAWA'), V4L2_PIX_FMT_RAW_12 ('RAWC'), V4L2_PIX_FMT_RAW_14 ('RAWE'), V4L2_PIX_FMT_RAW_16 ('RAWG')
+************************************************************************************************************************************************************************************************************************************************************
Generic line-based raw image data formats
@@ -292,3 +292,46 @@ Each cell is one byte. "P" denotes a pixel.
- P\ :sub:`21 bits 13--8` (bits 5--0)
- P\ :sub:`31 bits 7--0`
- P\ :sub:`31 bits 13--8` (bits 5--0)
+
+.. _v4l2-pix-fmt-raw-16:
+
+V4L2_PIX_FMT_RAW_16
+-------------------
+
+V4L2_PIX_FMT_RAW_16 contains 16-bit image data, with each two consecutive
+bytes forming a pixel value. This format is typically used by CSI-2 receivers
+with a source that transmits MEDIA_BUS_FMT_RAW_16 and the CSI-2 receiver writes
+the received data to memory as-is.
+
+The packing of the data follows the MIPI CSI-2 specification.
+
+**Byte Order Of V4L2_PIX_FMT_RAW_16.**
+Each cell is one byte. "P" denotes a pixel.
+
+.. tabularcolumns:: |p{2.4cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|
+
+.. flat-table:: Sample 4x2 Image Frame
+ :header-rows: 0
+ :stub-columns: 0
+ :widths: 12 8 8 8 8 8 8 8 8
+
+ * - start + 0:
+ - P\ :sub:`00 bits 7--0`
+ - P\ :sub:`00 bits 15--8`
+ - P\ :sub:`10 bits 7--0`
+ - P\ :sub:`10 bits 15--8`
+ - P\ :sub:`20 bits 7--0`
+ - P\ :sub:`20 bits 15--8`
+ - P\ :sub:`30 bits 7--0`
+ - P\ :sub:`30 bits 15--8`
+ * - start + 8:
+ - P\ :sub:`01 bits 7--0`
+ - P\ :sub:`01 bits 15--8`
+ - P\ :sub:`11 bits 7--0`
+ - P\ :sub:`11 bits 15--8`
+ - P\ :sub:`21 bits 7--0`
+ - P\ :sub:`21 bits 15--8`
+ - P\ :sub:`31 bits 7--0`
+ - P\ :sub:`31 bits 15--8`
+
+.. _v4l2-pix-fmt-raw-csi2-20:
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index 01ba6ddc885b..131ca3f85a83 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1441,6 +1441,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
case V4L2_PIX_FMT_RAW_10: descr = "10-bit Raw"; break;
case V4L2_PIX_FMT_RAW_12: descr = "12-bit Raw"; break;
case V4L2_PIX_FMT_RAW_14: descr = "14-bit Raw"; break;
+ case V4L2_PIX_FMT_RAW_16: descr = "16-bit Raw"; break;
case V4L2_PIX_FMT_RAW_CRU20: descr = "14-bit Raw CRU Packed"; break;
case V4L2_PIX_FMT_SN9C20X_I420: descr = "GSPCA SN9C20X I420"; break;
case V4L2_PIX_FMT_SPCA501: descr = "GSPCA SPCA501"; break;
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 1209c9f457ab..74052ecbe780 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -753,6 +753,7 @@ struct v4l2_pix_format {
#define V4L2_PIX_FMT_RAW_10 v4l2_fourcc('R', 'A', 'W', 'A')
#define V4L2_PIX_FMT_RAW_12 v4l2_fourcc('R', 'A', 'W', 'C')
#define V4L2_PIX_FMT_RAW_14 v4l2_fourcc('R', 'A', 'W', 'E')
+#define V4L2_PIX_FMT_RAW_16 v4l2_fourcc('R', 'A', 'W', 'G')
/* HSV formats */
#define V4L2_PIX_FMT_HSV24 v4l2_fourcc('H', 'S', 'V', '3')
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
* [PATCH v13 73/73] media: uapi: Add generic CSI-2 raw pixelformats for 16, 20, 24 and 28 bpp
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
` (71 preceding siblings ...)
2026-11-18 13:28 ` [PATCH v13 72/73] media: uapi: Add generic raw pixelformat for 16 bpp Sakari Ailus
@ 2026-11-18 13:28 ` Sakari Ailus
72 siblings, 0 replies; 74+ messages in thread
From: Sakari Ailus @ 2026-11-18 13:28 UTC (permalink / raw)
To: linux-media
Cc: hans, laurent.pinchart, Prabhakar, Kate Hsuan, Dave Stevenson,
Tommaso Merciai, Benjamin Mugnier, Sylvain Petinot,
Christophe JAILLET, Julien Massot, Naushir Patuck, Yan, Dongcheng,
Stefan Klug, Mirela Rabulea, André Apitzsch,
Heimir Thor Sverrisson, Kieran Bingham, Mehdi Djait,
Ricardo Ribalda Delgado, Hans de Goede, Jacopo Mondi,
Tomi Valkeinen, David Plowman, Yu, Ong Hock, Ng, Khai Wen,
Jai Luthra, Rishikesh Donadkar, Mattijs Korpershoek, Antti Laakso,
Bajpai, Manik, Divyamani Tripathi
Add generic raw pixelformats for bit depths 16, 20, 24 and 28. These
formats are CSI-2 packed, apart from the 16-bit and 24-bit formats.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
.../media/v4l/pixfmt-raw-generic.rst | 169 +++++++++++++++++-
drivers/media/v4l2-core/v4l2-ioctl.c | 3 +
include/uapi/linux/videodev2.h | 3 +
3 files changed, 172 insertions(+), 3 deletions(-)
diff --git a/Documentation/userspace-api/media/v4l/pixfmt-raw-generic.rst b/Documentation/userspace-api/media/v4l/pixfmt-raw-generic.rst
index 88cde68bf3ef..9ccb750b8e4f 100644
--- a/Documentation/userspace-api/media/v4l/pixfmt-raw-generic.rst
+++ b/Documentation/userspace-api/media/v4l/pixfmt-raw-generic.rst
@@ -1,8 +1,8 @@
.. SPDX-License-Identifier: GPL-2.0 OR GFDL-1.1-no-invariants-or-later
-************************************************************************************************************************************************************************************************************************************************************
-V4L2_PIX_FMT_RAW_8 ('RAW8'), V4L2_PIX_FMT_RAW_CSI2_10 ('RACA'), V4L2_PIX_FMT_RAW_CSI2_12 ('RACC'), V4L2_PIX_FMT_RAW_CSI2_14 ('RACE'), V4L2_PIX_FMT_RAW_10 ('RAWA'), V4L2_PIX_FMT_RAW_12 ('RAWC'), V4L2_PIX_FMT_RAW_14 ('RAWE'), V4L2_PIX_FMT_RAW_16 ('RAWG')
-************************************************************************************************************************************************************************************************************************************************************
+****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
+V4L2_PIX_FMT_RAW_8 ('RAW8'), V4L2_PIX_FMT_RAW_CSI2_10 ('RACA'), V4L2_PIX_FMT_RAW_CSI2_12 ('RACC'), V4L2_PIX_FMT_RAW_CSI2_14 ('RACE'), V4L2_PIX_FMT_RAW_10 ('RAWA'), V4L2_PIX_FMT_RAW_12 ('RAWC'), V4L2_PIX_FMT_RAW_14 ('RAWE'), V4L2_PIX_FMT_RAW_16 ('RAWG'), V4L2_PIX_FMT_RAW_CSI2_20 ('RACK'), V4L2_PIX_FMT_RAW_24 ('RAWO'), V4L2_PIX_FMT_RAW_CSI2_28 ('RACS')
+****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
Generic line-based raw image data formats
@@ -335,3 +335,166 @@ Each cell is one byte. "P" denotes a pixel.
- P\ :sub:`31 bits 15--8`
.. _v4l2-pix-fmt-raw-csi2-20:
+
+V4L2_PIX_FMT_RAW_CSI2_20
+------------------------
+
+V4L2_PIX_FMT_RAW_CSI2_20 contains 20-bit packed image data, with four bytes
+containing the top 8 bits of two pixels followed by lowest 4 bits of the pixels
+packed into one byte. This format is typically used by CSI-2 receivers with a
+source that transmits MEDIA_BUS_FMT_RAW_20 and the CSI-2 receiver writes the
+received data to memory as-is.
+
+The packing of the data follows the MIPI CSI-2 specification.
+
+**Byte Order Of V4L2_PIX_FMT_RAW_CSI2_20.**
+Each cell is one byte. "P" denotes a pixel.
+
+.. tabularcolumns:: |p{2.4cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{2cm}
+
+.. flat-table:: Sample 4x2 Image Frame
+ :header-rows: 0
+ :stub-columns: 0
+ :widths: 12 8 8 8 8 8 8 8 8 8 8
+
+ * - start + 0:
+ - P\ :sub:`00 bits 19--12`
+ - P\ :sub:`00 bits 11--4`
+ - P\ :sub:`10 bits 19--12`
+ - P\ :sub:`10 bits 11--4`
+ - P\ :sub:`10 bits 3--0` (bits 7--4),
+ P\ :sub:`00 bits 3--0` (bits 3--0)
+ - P\ :sub:`20 bits 19--12`
+ - P\ :sub:`20 bits 11--4`
+ - P\ :sub:`30 bits 19--12`
+ - P\ :sub:`30 bits 11--4`
+ - P\ :sub:`30 bits 3--0` (bits 7--4),
+ P\ :sub:`20 bits 3--0` (bits 3--0)
+ * - start + 10:
+ - P\ :sub:`01 bits 19--12`
+ - P\ :sub:`01 bits 11--4`
+ - P\ :sub:`11 bits 19--12`
+ - P\ :sub:`11 bits 11--4`
+ - P\ :sub:`11 bits 3--0` (bits 7--4),
+ P\ :sub:`01 bits 3--0` (bits 3--0)
+ - P\ :sub:`21 bits 19--12`
+ - P\ :sub:`21 bits 11--4`
+ - P\ :sub:`31 bits 19--12`
+ - P\ :sub:`31 bits 11--4`
+ - P\ :sub:`31 bits 3--0` (bits 7--4),
+ P\ :sub:`21 bits 3--0` (bits 3--0)
+
+.. _v4l2-pix-fmt-raw-24:
+
+V4L2_PIX_FMT_RAW_24
+-------------------
+
+V4L2_PIX_FMT_RAW_24 contains 24-bit packed image data, with each three bytes
+containing the value of one pixel. This format is typically used by CSI-2
+receivers with a source that transmits MEDIA_BUS_FMT_RAW_24 and the CSI-2
+receiver writes the received data to memory as-is.
+
+The packing of the data follows the MIPI CSI-2 specification.
+
+**Byte Order Of V4L2_PIX_FMT_RAW_24.**
+Each cell is one byte. "P" denotes a pixel.
+
+.. tabularcolumns:: |p{2.4cm}|p{1.2cm}|p{.8cm}|p{.8cm}|p{1.2cm}|p{.8cm}|p{.8cm}|p{1.2cm}|p{.8cm}|p{.8cm}|p{1.2cm}|p{.8cm}|p{.8cm}|
+
+.. flat-table:: Sample 4x2 Image Frame
+ :header-rows: 0
+ :stub-columns: 0
+ :widths: 12 8 8 8 8 8 8 8 8 8 8 8 8
+
+ * - start + 0:
+ - P\ :sub:`00 bits 23--16`
+ - P\ :sub:`00 bits 15--8`
+ - P\ :sub:`00 bits 7--0`
+ - P\ :sub:`10 bits 23--16`
+ - P\ :sub:`10 bits 15--8`
+ - P\ :sub:`10 bits 7--0`
+ - P\ :sub:`20 bits 23--16`
+ - P\ :sub:`20 bits 15--8`
+ - P\ :sub:`20 bits 7--0`
+ - P\ :sub:`30 bits 23--16`
+ - P\ :sub:`30 bits 15--8`
+ - P\ :sub:`30 bits 7--0`
+ * - start + 12:
+ - P\ :sub:`01 bits 23--16`
+ - P\ :sub:`01 bits 15--8`
+ - P\ :sub:`01 bits 7--0`
+ - P\ :sub:`11 bits 23--16`
+ - P\ :sub:`11 bits 15--8`
+ - P\ :sub:`11 bits 7--0`
+ - P\ :sub:`21 bits 23--16`
+ - P\ :sub:`21 bits 15--8`
+ - P\ :sub:`21 bits 7--0`
+ - P\ :sub:`31 bits 23--16`
+ - P\ :sub:`31 bits 15--8`
+ - P\ :sub:`31 bits 7--0`
+
+.. _v4l2-pix-fmt-raw-csi2-28:
+
+V4L2_PIX_FMT_RAW_CSI2_28
+------------------------
+
+V4L2_PIX_FMT_RAW_CSI2_28 contains 28-bit packed image data, with four bytes
+containing the top 8 bits of two pixels followed by lowest 4 bits of the pixels
+packed into one byte. This format is typically used by CSI-2 receivers with a
+source that transmits MEDIA_BUS_FMT_RAW_28 and the CSI-2 receiver writes the
+received data to memory as-is.
+
+The packing of the data follows the MIPI CSI-2 specification.
+
+**Byte Order Of V4L2_PIX_FMT_RAW_CSI2_28.**
+Each cell is one byte. "P" denotes a pixel.
+
+.. tabularcolumns:: |p{2.4cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}
+
+.. flat-table:: Sample 4x2 Image Frame
+ :header-rows: 0
+ :stub-columns: 0
+ :widths: 12 8 8 8 8 8 8 8 8 8 8 8 8 8 8
+
+ * - start + 0:
+ - P\ :sub:`00 bits 27--20`
+ - P\ :sub:`00 bits 13--6`
+ - P\ :sub:`10 bits 27--20`
+ - P\ :sub:`10 bits 13--6`
+ - P\ :sub:`00 bits 19--14` (bits 7--2),
+ P\ :sub:`00 bits 1--0` (bits 1--0)
+ - P\ :sub:`00 bits 5--2` (bits 7--4),
+ P\ :sub:`10 bits 17--14` (bits 3--0)
+ - P\ :sub:`10 bits 19--18` (bits 7--6),
+ P\ :sub:`10 bits 5--0` (bits 5--0)
+ - P\ :sub:`20 bits 27--20`
+ - P\ :sub:`20 bits 13--6`
+ - P\ :sub:`30 bits 27--20`
+ - P\ :sub:`30 bits 13--6`
+ - P\ :sub:`20 bits 19--14` (bits 7--2),
+ P\ :sub:`20 bits 1--0` (bits 1--0)
+ - P\ :sub:`20 bits 5--2` (bits 7--4),
+ P\ :sub:`30 bits 17--14` (bits 3--0)
+ - P\ :sub:`30 bits 19--18` (bits 7--6),
+ P\ :sub:`30 bits 5--0` (bits 5--0)
+ * - start + 14:
+ - P\ :sub:`01 bits 27--20`
+ - P\ :sub:`01 bits 13--6`
+ - P\ :sub:`11 bits 27--20`
+ - P\ :sub:`11 bits 13--6`
+ - P\ :sub:`01 bits 19--14` (bits 7--2),
+ P\ :sub:`01 bits 1--0` (bits 1--0)
+ - P\ :sub:`01 bits 5--2` (bits 7--4),
+ P\ :sub:`11 bits 17--14` (bits 3--0)
+ - P\ :sub:`11 bits 19--18` (bits 7--6),
+ P\ :sub:`11 bits 5--0` (bits 5--0)
+ - P\ :sub:`21 bits 27--20`
+ - P\ :sub:`21 bits 13--6`
+ - P\ :sub:`31 bits 27--20`
+ - P\ :sub:`31 bits 13--6`
+ - P\ :sub:`21 bits 19--14` (bits 7--2),
+ P\ :sub:`21 bits 1--0` (bits 1--0)
+ - P\ :sub:`21 bits 5--2` (bits 7--4),
+ P\ :sub:`31 bits 17--14` (bits 3--0)
+ - P\ :sub:`31 bits 19--18` (bits 7--6),
+ P\ :sub:`31 bits 5--0` (bits 5--0)
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index 131ca3f85a83..1a71f56f951b 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1442,6 +1442,9 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
case V4L2_PIX_FMT_RAW_12: descr = "12-bit Raw"; break;
case V4L2_PIX_FMT_RAW_14: descr = "14-bit Raw"; break;
case V4L2_PIX_FMT_RAW_16: descr = "16-bit Raw"; break;
+ case V4L2_PIX_FMT_RAW_CSI2_20: descr = "20-bit Raw, CSI-2 Packed"; break;
+ case V4L2_PIX_FMT_RAW_24: descr = "24-bit Raw"; break;
+ case V4L2_PIX_FMT_RAW_CSI2_28: descr = "28-bit Raw, CSI-2 Packed"; break;
case V4L2_PIX_FMT_RAW_CRU20: descr = "14-bit Raw CRU Packed"; break;
case V4L2_PIX_FMT_SN9C20X_I420: descr = "GSPCA SN9C20X I420"; break;
case V4L2_PIX_FMT_SPCA501: descr = "GSPCA SPCA501"; break;
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 74052ecbe780..6b884f8af5c4 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -754,6 +754,9 @@ struct v4l2_pix_format {
#define V4L2_PIX_FMT_RAW_12 v4l2_fourcc('R', 'A', 'W', 'C')
#define V4L2_PIX_FMT_RAW_14 v4l2_fourcc('R', 'A', 'W', 'E')
#define V4L2_PIX_FMT_RAW_16 v4l2_fourcc('R', 'A', 'W', 'G')
+#define V4L2_PIX_FMT_RAW_CSI2_20 v4l2_fourcc('R', 'A', 'C', 'K')
+#define V4L2_PIX_FMT_RAW_24 v4l2_fourcc('R', 'A', 'W', 'O')
+#define V4L2_PIX_FMT_RAW_CSI2_28 v4l2_fourcc('R', 'A', 'C', 'S')
/* HSV formats */
#define V4L2_PIX_FMT_HSV24 v4l2_fourcc('H', 'S', 'V', '3')
--
2.47.3
^ permalink raw reply related [flat|nested] 74+ messages in thread
end of thread, other threads:[~2026-11-18 13:29 UTC | newest]
Thread overview: 74+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18 13:27 [PATCH v13 00/72] Generic line based metadata support, internal pads Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 01/73] media: uapi: Bump the STREAMS bit a little Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 02/73] Revert "media: mc: Keep INTERNAL pad flags just for the kernel, for now" Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 03/73] media: uapi: Add generic CSI-2 raw pixelformats Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 04/73] media: uapi: Add new media bus codes for generic raw formats Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 05/73] media: uapi: Add V4L2_CID_CONFIG_MODEL control Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 06/73] media: uapi: Add V4L2_CID_CFA_PATTERN for describing color patterns Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 07/73] media: uapi: Add monochromatic CFA pattern Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 08/73] media: Documentation: Reference CFA pattern control in pixelformat docs Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 09/73] media: Documentation: Reference CFA_PATTERN control in raw mbus docs Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 10/73] media: v4l: uapi: Add a control for color pattern flipping effect Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 11/73] media: Documentation: Reference flipping controls in raw format docs Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 12/73] media: Documentation: Document raw mbus codes and CFA for cameras Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 13/73] media: uapi: Add V4L2_CID_METADATA_LAYOUT control Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 14/73] media: Documentation: Refer to metadata layout in metadata documentation Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 15/73] media: Documentation: v4l: Document internal sink pads Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 16/73] media: Documentation: Document embedded data guidelines for camera sensors Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 17/73] media: uapi: Correct generic CSI-2 metadata format 4cc Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 18/73] Revert "media: uapi: v4l: Don't expose generic metadata formats to userspace" Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 19/73] media: v4l: Add V4L2_SUBDEV_ROUTE_FL_IMMUTABLE sub-device routing flag Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 20/73] media: v4l: Add V4L2_SUBDEV_ROUTE_FL_STATIC " Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 21/73] media: Documentation: There are either immutable or mutable routes Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 22/73] media: Documentation: Document IMMUTABLE and STATIC route flags Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 23/73] media: Documentation: Add subdev configuration models, raw sensor model Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 24/73] media: v4l2-subdev: Prevent accessing internal pads without STREAMS cap Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 25/73] media: subdev: Make get_fmt on INTERNAL pads without STREAMS an error Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 26/73] media: Documentation: Add scaling and post-scaler crop for common raw Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 27/73] media: uapi: Add MIPI CCS configuration model Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 28/73] media: uapi: Add V4L2_SUBDEV_CLIENT_CAP_COMMON_RAW_SENSOR Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 29/73] media: uapi: Add V4L2_CID_BINNING_FACTORS control for binning configuration Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 30/73] media: uapi: Add controls for sub-sampling configuration Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 31/73] media: uapi: Add new controls for camera sensor FLL and LLP Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 32/73] media: v4l2-common: Add v4l2_sensor_fll_llp_set() Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 33/73] media: Documentation: Add binning and sub-sampling controls Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 34/73] media: v4l2-subdev: Set STATIC route flag if IMMUTABLE route flag is set Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 35/73] media: uapi: v4l: subdev: Enable streams API Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 36/73] media: uapi: Add binning factor helper macros Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 37/73] media: Documentation: Document frame controls for common raw sensor model Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 38/73] media: v4l2-ctrl: Improve v4l2_ctrl_g_ctrl{,int64} documentation Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 39/73] media: Documentation: Add sub-device internal pads example Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 40/73] media: Documentation: Document streaming behaviour for common raw cameras Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 41/73] media: Documentation: Add a note on Bayer raw mbus codes Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 42/73] media: uapi: Add generic raw pixelformats for 10, 12 and 14 bits Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 43/73] media: uapi: Add more media bus codes for generic raw formats Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 44/73] media: uapi: ccs: Add metadata layout for MIPI CCS embedded data Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 45/73] media: Documentation: Document non-CCS use of CCS embedded data layout Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 46/73] media: ccs: Add support for generic raw mbus codes Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 47/73] media: ccs: Add support for embedded data stream Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 48/73] media: Documentation: ccs: Document routing Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 49/73] media: ccs: Add IMMUTABLE and STATIC route flags Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 50/73] media: uapi: Add metadata layout for ov2740 embedded data Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 51/73] media: ov2740: Add support for " Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 52/73] media: ov2740: Add support for generic raw formats Sakari Ailus
2026-11-18 13:27 ` [PATCH v13 53/73] media: ov2740: Add metadata layout control Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 54/73] media: ov2740: Add support for G_SELECTION IOCTL Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 55/73] media: ov2740: Add support for FLL and LLP controls Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 56/73] media: ov2740: Signal common raw sensor model support Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 57/73] media: ov2740: Add IMMUTABLE and STATIC route flags Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 58/73] media: imx219: Add internal image pad for Common Raw Sensor Model Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 59/73] media: imx219: Add image stream Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 60/73] media: imx219: Report internal routes to userspace Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 61/73] media: imx219: Report streams using frame descriptors Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 62/73] media: imx219: Add embedded data support Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 63/73] media: imx219: Add support for generic raw formats Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 64/73] media: imx219: Add V4L2_CID_BINNING_FACTORS Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 65/73] media: imx219: Allow configuring cropping and binning through CRSM Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 66/73] media: imx219: Support LINE_LENGTH_PIXELS and FRAME_LENGTH_LINES controls Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 67/73] media: v4l2-common: Add helper function media_bus_fmt_to_csi2_(bpp|dt)() Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 68/73] media: bcm2835-unicam: Support generic raw formats Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 69/73] media: ipu6: Add support for raw CFA-agnostic formats Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 70/73] media: ipu6: Add support for generic unpacked pixel and metadata formats Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 71/73] Documentation: media: Reword blanking control documentation Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 72/73] media: uapi: Add generic raw pixelformat for 16 bpp Sakari Ailus
2026-11-18 13:28 ` [PATCH v13 73/73] media: uapi: Add generic CSI-2 raw pixelformats for 16, 20, 24 and 28 bpp Sakari Ailus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox