162306a36Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
262306a36Sopenharmony_ci.. c:namespace:: V4L
362306a36Sopenharmony_ci
462306a36Sopenharmony_ci.. _VIDIOC_SUBDEV_ENUM_MBUS_CODE:
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci**********************************
762306a36Sopenharmony_ciioctl VIDIOC_SUBDEV_ENUM_MBUS_CODE
862306a36Sopenharmony_ci**********************************
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ciName
1162306a36Sopenharmony_ci====
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ciVIDIOC_SUBDEV_ENUM_MBUS_CODE - Enumerate media bus formats
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ciSynopsis
1662306a36Sopenharmony_ci========
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci.. c:macro:: VIDIOC_SUBDEV_ENUM_MBUS_CODE
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci``int ioctl(int fd, VIDIOC_SUBDEV_ENUM_MBUS_CODE, struct v4l2_subdev_mbus_code_enum * argp)``
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ciArguments
2362306a36Sopenharmony_ci=========
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ci``fd``
2662306a36Sopenharmony_ci    File descriptor returned by :c:func:`open()`.
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci``argp``
2962306a36Sopenharmony_ci    Pointer to struct :c:type:`v4l2_subdev_mbus_code_enum`.
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ciDescription
3262306a36Sopenharmony_ci===========
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ciThis call is used by the application to access the enumeration
3562306a36Sopenharmony_ciof media bus formats for the selected pad.
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ciThe enumerations are defined by the driver, and indexed using the ``index`` field
3862306a36Sopenharmony_ciof struct :c:type:`v4l2_subdev_mbus_code_enum`.
3962306a36Sopenharmony_ciEach enumeration starts with the ``index`` of 0, and
4062306a36Sopenharmony_cithe lowest invalid index marks the end of enumeration.
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ciTherefore, to enumerate media bus formats available at a given sub-device pad,
4362306a36Sopenharmony_ciinitialize the ``pad``, and ``which`` fields to desired values,
4462306a36Sopenharmony_ciand set ``index`` to 0.
4562306a36Sopenharmony_ciThen call the :ref:`VIDIOC_SUBDEV_ENUM_MBUS_CODE` ioctl
4662306a36Sopenharmony_ciwith a pointer to this structure.
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ciA successful call will return with the ``code`` field filled in
4962306a36Sopenharmony_ciwith a mbus code value.
5062306a36Sopenharmony_ciRepeat with increasing ``index`` until ``EINVAL`` is received.
5162306a36Sopenharmony_ci``EINVAL`` means that either ``pad`` is invalid,
5262306a36Sopenharmony_cior that there are no more codes available at this pad.
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ciThe driver must not return the same value of ``code`` for different indices
5562306a36Sopenharmony_ciat the same pad.
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ciAvailable media bus formats may depend on the current 'try' formats at
5862306a36Sopenharmony_ciother pads of the sub-device, as well as on the current active links.
5962306a36Sopenharmony_ciSee :ref:`VIDIOC_SUBDEV_G_FMT` for more
6062306a36Sopenharmony_ciinformation about the try formats.
6162306a36Sopenharmony_ci
6262306a36Sopenharmony_ci.. c:type:: v4l2_subdev_mbus_code_enum
6362306a36Sopenharmony_ci
6462306a36Sopenharmony_ci.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
6562306a36Sopenharmony_ci
6662306a36Sopenharmony_ci.. flat-table:: struct v4l2_subdev_mbus_code_enum
6762306a36Sopenharmony_ci    :header-rows:  0
6862306a36Sopenharmony_ci    :stub-columns: 0
6962306a36Sopenharmony_ci    :widths:       1 1 2
7062306a36Sopenharmony_ci
7162306a36Sopenharmony_ci    * - __u32
7262306a36Sopenharmony_ci      - ``pad``
7362306a36Sopenharmony_ci      - Pad number as reported by the media controller API. Filled in by the
7462306a36Sopenharmony_ci        application.
7562306a36Sopenharmony_ci    * - __u32
7662306a36Sopenharmony_ci      - ``index``
7762306a36Sopenharmony_ci      - Index of the mbus code in the enumeration belonging to the given pad.
7862306a36Sopenharmony_ci        Filled in by the application.
7962306a36Sopenharmony_ci    * - __u32
8062306a36Sopenharmony_ci      - ``code``
8162306a36Sopenharmony_ci      - The media bus format code, as defined in
8262306a36Sopenharmony_ci	:ref:`v4l2-mbus-format`. Filled in by the driver.
8362306a36Sopenharmony_ci    * - __u32
8462306a36Sopenharmony_ci      - ``which``
8562306a36Sopenharmony_ci      - Media bus format codes to be enumerated, from enum
8662306a36Sopenharmony_ci	:ref:`v4l2_subdev_format_whence <v4l2-subdev-format-whence>`.
8762306a36Sopenharmony_ci    * - __u32
8862306a36Sopenharmony_ci      - ``flags``
8962306a36Sopenharmony_ci      - See :ref:`v4l2-subdev-mbus-code-flags`
9062306a36Sopenharmony_ci    * - __u32
9162306a36Sopenharmony_ci      - ``stream``
9262306a36Sopenharmony_ci      - Stream identifier.
9362306a36Sopenharmony_ci    * - __u32
9462306a36Sopenharmony_ci      - ``reserved``\ [6]
9562306a36Sopenharmony_ci      - Reserved for future extensions. Applications and drivers must set
9662306a36Sopenharmony_ci	the array to zero.
9762306a36Sopenharmony_ci
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_ci
10062306a36Sopenharmony_ci.. raw:: latex
10162306a36Sopenharmony_ci
10262306a36Sopenharmony_ci   \footnotesize
10362306a36Sopenharmony_ci
10462306a36Sopenharmony_ci.. tabularcolumns:: |p{8.8cm}|p{2.2cm}|p{6.3cm}|
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_ci.. _v4l2-subdev-mbus-code-flags:
10762306a36Sopenharmony_ci
10862306a36Sopenharmony_ci.. flat-table:: Subdev Media Bus Code Enumerate Flags
10962306a36Sopenharmony_ci    :header-rows:  0
11062306a36Sopenharmony_ci    :stub-columns: 0
11162306a36Sopenharmony_ci    :widths:       1 1 2
11262306a36Sopenharmony_ci
11362306a36Sopenharmony_ci    * - V4L2_SUBDEV_MBUS_CODE_CSC_COLORSPACE
11462306a36Sopenharmony_ci      - 0x00000001
11562306a36Sopenharmony_ci      - The driver allows the application to try to change the default colorspace
11662306a36Sopenharmony_ci	encoding. The application can ask to configure the colorspace of the
11762306a36Sopenharmony_ci	subdevice when calling the :ref:`VIDIOC_SUBDEV_S_FMT <VIDIOC_SUBDEV_G_FMT>`
11862306a36Sopenharmony_ci	ioctl with :ref:`V4L2_MBUS_FRAMEFMT_SET_CSC <mbus-framefmt-set-csc>` set.
11962306a36Sopenharmony_ci	See :ref:`v4l2-mbus-format` on how to do this.
12062306a36Sopenharmony_ci    * - V4L2_SUBDEV_MBUS_CODE_CSC_XFER_FUNC
12162306a36Sopenharmony_ci      - 0x00000002
12262306a36Sopenharmony_ci      - The driver allows the application to try to change the default transform function.
12362306a36Sopenharmony_ci	The application can ask to configure the transform function of
12462306a36Sopenharmony_ci	the subdevice when calling the :ref:`VIDIOC_SUBDEV_S_FMT <VIDIOC_SUBDEV_G_FMT>`
12562306a36Sopenharmony_ci	ioctl with :ref:`V4L2_MBUS_FRAMEFMT_SET_CSC <mbus-framefmt-set-csc>` set.
12662306a36Sopenharmony_ci	See :ref:`v4l2-mbus-format` on how to do this.
12762306a36Sopenharmony_ci    * - V4L2_SUBDEV_MBUS_CODE_CSC_YCBCR_ENC
12862306a36Sopenharmony_ci      - 0x00000004
12962306a36Sopenharmony_ci      - The driver allows the application to try to change the default Y'CbCr
13062306a36Sopenharmony_ci	encoding. The application can ask to configure the Y'CbCr encoding of the
13162306a36Sopenharmony_ci	subdevice when calling the :ref:`VIDIOC_SUBDEV_S_FMT <VIDIOC_SUBDEV_G_FMT>`
13262306a36Sopenharmony_ci	ioctl with :ref:`V4L2_MBUS_FRAMEFMT_SET_CSC <mbus-framefmt-set-csc>` set.
13362306a36Sopenharmony_ci	See :ref:`v4l2-mbus-format` on how to do this.
13462306a36Sopenharmony_ci    * - V4L2_SUBDEV_MBUS_CODE_CSC_HSV_ENC
13562306a36Sopenharmony_ci      - 0x00000004
13662306a36Sopenharmony_ci      - The driver allows the application to try to change the default HSV
13762306a36Sopenharmony_ci	encoding. The application can ask to configure the HSV encoding of the
13862306a36Sopenharmony_ci	subdevice when calling the :ref:`VIDIOC_SUBDEV_S_FMT <VIDIOC_SUBDEV_G_FMT>`
13962306a36Sopenharmony_ci	ioctl with :ref:`V4L2_MBUS_FRAMEFMT_SET_CSC <mbus-framefmt-set-csc>` set.
14062306a36Sopenharmony_ci	See :ref:`v4l2-mbus-format` on how to do this.
14162306a36Sopenharmony_ci    * - V4L2_SUBDEV_MBUS_CODE_CSC_QUANTIZATION
14262306a36Sopenharmony_ci      - 0x00000008
14362306a36Sopenharmony_ci      - The driver allows the application to try to change the default
14462306a36Sopenharmony_ci	quantization. The application can ask to configure the quantization of
14562306a36Sopenharmony_ci	the subdevice when calling the :ref:`VIDIOC_SUBDEV_S_FMT <VIDIOC_SUBDEV_G_FMT>`
14662306a36Sopenharmony_ci	ioctl with :ref:`V4L2_MBUS_FRAMEFMT_SET_CSC <mbus-framefmt-set-csc>` set.
14762306a36Sopenharmony_ci	See :ref:`v4l2-mbus-format` on how to do this.
14862306a36Sopenharmony_ci
14962306a36Sopenharmony_ci.. raw:: latex
15062306a36Sopenharmony_ci
15162306a36Sopenharmony_ci   \normalsize
15262306a36Sopenharmony_ci
15362306a36Sopenharmony_ciReturn Value
15462306a36Sopenharmony_ci============
15562306a36Sopenharmony_ci
15662306a36Sopenharmony_ciOn success 0 is returned, on error -1 and the ``errno`` variable is set
15762306a36Sopenharmony_ciappropriately. The generic error codes are described at the
15862306a36Sopenharmony_ci:ref:`Generic Error Codes <gen-errors>` chapter.
15962306a36Sopenharmony_ci
16062306a36Sopenharmony_ciEINVAL
16162306a36Sopenharmony_ci    The struct
16262306a36Sopenharmony_ci    :c:type:`v4l2_subdev_mbus_code_enum`
16362306a36Sopenharmony_ci    ``pad`` references a non-existing pad, or the ``index`` field is out
16462306a36Sopenharmony_ci    of bounds.
165