요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
.. c:namespace:: V4L
.. _VIDIOC_SUBDEV_ENUM_MBUS_CODE:
**********************************
ioctl VIDIOC_SUBDEV_ENUM_MBUS_CODE
**********************************
Name
====
VIDIOC_SUBDEV_ENUM_MBUS_CODE - Enumerate media bus formats
Synopsis
========
.. c:macro:: VIDIOC_SUBDEV_ENUM_MBUS_CODE
``int ioctl(int fd, VIDIOC_SUBDEV_ENUM_MBUS_CODE, struct v4l2_subdev_mbus_code_enum * argp)``
Arguments
=========
``fd``
File descriptor returned by :c:func:`open()`.
``argp``
Pointer to struct :c:type:`v4l2_subdev_mbus_code_enum`.
Description
===========
This call is used by the application to access the enumeration
of media bus formats for the selected pad.
The enumerations are defined by the driver, and indexed using the ``index`` field
of struct :c:type:`v4l2_subdev_mbus_code_enum`.
Each enumeration starts with the ``index`` of 0, and
the lowest invalid index marks the end of enumeration.
Therefore, to enumerate media bus formats available at a given sub-device pad,
initialize the ``pad``, and ``which`` fields to desired values,
and set ``index`` to 0.
Then call the :ref:`VIDIOC_SUBDEV_ENUM_MBUS_CODE` ioctl
with a pointer to this structure.
A successful call will return with the ``code`` field filled in
with a mbus code value.
Repeat with increasing ``index`` until ``EINVAL`` is received.
``EINVAL`` means that either ``pad`` is invalid,
or that there are no more codes available at this pad.
The driver must not return the same value of ``code`` for different indices
at the same pad.
Available media bus formats may depend on the current 'try' formats at
other pads of the sub-device, as well as on the current active links.
See :ref:`VIDIOC_SUBDEV_G_FMT` for more
information about the try formats.
.. c:type:: v4l2_subdev_mbus_code_enum
.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
.. flat-table:: struct v4l2_subdev_mbus_code_enum
:header-rows: 0
:stub-columns: 0
:widths: 1 1 2
* - __u32
- ``pad``
- Pad number as reported by the media controller API. Filled in by the
application.
* - __u32
- ``index``
- Index of the mbus code in the enumeration belonging to the given pad.
Filled in by the application.
* - __u32
- ``code``
- The media bus format code, as defined in
:ref:`v4l2-mbus-format`. Filled in by the driver.
* - __u32
- ``which``
- Media bus format codes to be enumerated, from enum
:ref:`v4l2_subdev_format_whence <v4l2-subdev-format-whence>`.
* - __u32
- ``flags``
- See :ref:`v4l2-subdev-mbus-code-flags`
* - __u32
- ``stream``
- Stream identifier.
* - __u32
- ``reserved``\ [6]
- Reserved for future extensions. Applications and drivers must set
the array to zero.
.. raw:: latex
\footnotesize
.. tabularcolumns:: |p{8.8cm}|p{2.2cm}|p{6.3cm}|
.. _v4l2-subdev-mbus-code-flags:
.. flat-table:: Subdev Media Bus Code Enumerate Flags
:header-rows: 0
:stub-columns: 0
:widths: 1 1 2
* - V4L2_SUBDEV_MBUS_CODE_CSC_COLORSPACE
- 0x00000001
- The driver allows the application to try to change the default colorspace
encoding. The application can ask to configure the colorspace of the
subdevice when calling the :ref:`VIDIOC_SUBDEV_S_FMT <VIDIOC_SUBDEV_G_FMT>`
ioctl with :ref:`V4L2_MBUS_FRAMEFMT_SET_CSC <mbus-framefmt-set-csc>` set.
See :ref:`v4l2-mbus-format` on how to do this.
* - V4L2_SUBDEV_MBUS_CODE_CSC_XFER_FUNC
- 0x00000002
- The driver allows the application to try to change the default transform function.
The application can ask to configure the transform function of
the subdevice when calling the :ref:`VIDIOC_SUBDEV_S_FMT <VIDIOC_SUBDEV_G_FMT>`
ioctl with :ref:`V4L2_MBUS_FRAMEFMT_SET_CSC <mbus-framefmt-set-csc>` set.
See :ref:`v4l2-mbus-format` on how to do this.
* - V4L2_SUBDEV_MBUS_CODE_CSC_YCBCR_ENC
- 0x00000004
- The driver allows the application to try to change the default Y'CbCr
encoding. The application can ask to configure the Y'CbCr encoding of the
subdevice when calling the :ref:`VIDIOC_SUBDEV_S_FMT <VIDIOC_SUBDEV_G_FMT>`
ioctl with :ref:`V4L2_MBUS_FRAMEFMT_SET_CSC <mbus-framefmt-set-csc>` set.
See :ref:`v4l2-mbus-format` on how to do this.
* - V4L2_SUBDEV_MBUS_CODE_CSC_HSV_ENC
- 0x00000004
- The driver allows the application to try to change the default HSV
encoding. The application can ask to configure the HSV encoding of the
subdevice when calling the :ref:`VIDIOC_SUBDEV_S_FMT <VIDIOC_SUBDEV_G_FMT>`
ioctl with :ref:`V4L2_MBUS_FRAMEFMT_SET_CSC <mbus-framefmt-set-csc>` set.
See :ref:`v4l2-mbus-format` on how to do this.
* - V4L2_SUBDEV_MBUS_CODE_CSC_QUANTIZATION
- 0x00000008
- The driver allows the application to try to change the default
quantization. The application can ask to configure the quantization of
the subdevice when calling the :ref:`VIDIOC_SUBDEV_S_FMT <VIDIOC_SUBDEV_G_FMT>`
ioctl with :ref:`V4L2_MBUS_FRAMEFMT_SET_CSC <mbus-framefmt-set-csc>` set.
See :ref:`v4l2-mbus-format` on how to do this.
.. raw:: latex
\normalsize
Return Value
============
On success 0 is returned, on error -1 and the ``errno`` variable is set
appropriately. The generic error codes are described at the
:ref:`Generic Error Codes <gen-errors>` chapter.
EINVAL
The struct :c:type:`v4l2_subdev_mbus_code_enum` ``pad`` references a
non-existing pad, the ``which`` field has an unsupported value, or the
``index`` field is out of bounds.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
목적, 호출 형식과 인자
1-30`VIDIOC_SUBDEV_ENUM_MBUS_CODE`는 선택한 서브디바이스 pad에서 사용할 수 있는 media-bus 형식 코드를 열거합니다. `argp`는 `struct v4l2_subdev_mbus_code_enum`을 가리킵니다.
.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
.. c:namespace:: V4L
.. _VIDIOC_SUBDEV_ENUM_MBUS_CODE:
**********************************
ioctl VIDIOC_SUBDEV_ENUM_MBUS_CODE
**********************************
Name
====
VIDIOC_SUBDEV_ENUM_MBUS_CODE - Enumerate media bus formats
Synopsis
========
.. c:macro:: VIDIOC_SUBDEV_ENUM_MBUS_CODE
``int ioctl(int fd, VIDIOC_SUBDEV_ENUM_MBUS_CODE, struct v4l2_subdev_mbus_code_enum * argp)``
Arguments
=========
``fd``
File descriptor returned by :c:func:`open()`.
``argp``
Pointer to struct :c:type:`v4l2_subdev_mbus_code_enum`.
열거 규칙과 파이프라인 의존성
31-60드라이버가 pad별 열거 목록을 정의하며 `index = 0`에서 시작합니다. 응용 프로그램은 `pad`와 `which`를 설정한 뒤 인덱스를 1씩 늘려 호출합니다.
성공하면 드라이버가 `code`에 media-bus 형식 코드를 채웁니다. `EINVAL`은 pad가 잘못되었거나 해당 pad에서 더 이상 반환할 코드가 없음을 나타냅니다.
같은 pad의 서로 다른 인덱스에서 드라이버가 동일한 `code`를 중복 반환해서는 안 됩니다. 따라서 성공한 각 인덱스는 고유한 형식 항목입니다.
사용 가능한 형식은 다른 pad의 try format과 현재 활성 링크에 의존할 수 있습니다. `VIDIOC_SUBDEV_G_FMT`의 try format 규칙을 함께 적용해야 합니다.
pad와 which를 고정하고 인덱스를 증가시킵니다.
Description
===========
This call is used by the application to access the enumeration
of media bus formats for the selected pad.
The enumerations are defined by the driver, and indexed using the ``index`` field
of struct :c:type:`v4l2_subdev_mbus_code_enum`.
Each enumeration starts with the ``index`` of 0, and
the lowest invalid index marks the end of enumeration.
Therefore, to enumerate media bus formats available at a given sub-device pad,
initialize the ``pad``, and ``which`` fields to desired values,
and set ``index`` to 0.
Then call the :ref:`VIDIOC_SUBDEV_ENUM_MBUS_CODE` ioctl
with a pointer to this structure.
A successful call will return with the ``code`` field filled in
with a mbus code value.
Repeat with increasing ``index`` until ``EINVAL`` is received.
``EINVAL`` means that either ``pad`` is invalid,
or that there are no more codes available at this pad.
The driver must not return the same value of ``code`` for different indices
at the same pad.
Available media bus formats may depend on the current 'try' formats at
other pads of the sub-device, as well as on the current active links.
See :ref:`VIDIOC_SUBDEV_G_FMT` for more
information about the try formats.
struct v4l2_subdev_mbus_code_enum
61-97응용 프로그램이 지정할 조건과 드라이버가 채울 결과입니다.
.. c:type:: v4l2_subdev_mbus_code_enum
.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
.. flat-table:: struct v4l2_subdev_mbus_code_enum
:header-rows: 0
:stub-columns: 0
:widths: 1 1 2
* - __u32
- ``pad``
- Pad number as reported by the media controller API. Filled in by the
application.
* - __u32
- ``index``
- Index of the mbus code in the enumeration belonging to the given pad.
Filled in by the application.
* - __u32
- ``code``
- The media bus format code, as defined in
:ref:`v4l2-mbus-format`. Filled in by the driver.
* - __u32
- ``which``
- Media bus format codes to be enumerated, from enum
:ref:`v4l2_subdev_format_whence <v4l2-subdev-format-whence>`.
* - __u32
- ``flags``
- See :ref:`v4l2-subdev-mbus-code-flags`
* - __u32
- ``stream``
- Stream identifier.
* - __u32
- ``reserved``\ [6]
- Reserved for future extensions. Applications and drivers must set
the array to zero.
색 공간 변환 관련 flags
98-151다음 flags는 `VIDIOC_SUBDEV_S_FMT`를 호출할 때 `V4L2_MBUS_FRAMEFMT_SET_CSC`를 설정해 기본 색 표현의 특정 요소를 변경하도록 시도할 수 있음을 알립니다. 실제 구성 절차는 `v4l2-mbus-format` 규칙을 따릅니다.
각 비트는 응용 프로그램이 변경을 요청할 수 있는 색 표현 요소를 나타냅니다.
Y'CbCr와 HSV encoding flag는 원문 정의상 모두 `0x00000004`를 사용합니다. 현재 code가 나타내는 색 표현에 따라 해당 의미를 해석해야 합니다.
.. raw:: latex
\footnotesize
.. tabularcolumns:: |p{8.8cm}|p{2.2cm}|p{6.3cm}|
.. _v4l2-subdev-mbus-code-flags:
.. flat-table:: Subdev Media Bus Code Enumerate Flags
:header-rows: 0
:stub-columns: 0
:widths: 1 1 2
* - V4L2_SUBDEV_MBUS_CODE_CSC_COLORSPACE
- 0x00000001
- The driver allows the application to try to change the default colorspace
encoding. The application can ask to configure the colorspace of the
subdevice when calling the :ref:`VIDIOC_SUBDEV_S_FMT <VIDIOC_SUBDEV_G_FMT>`
ioctl with :ref:`V4L2_MBUS_FRAMEFMT_SET_CSC <mbus-framefmt-set-csc>` set.
See :ref:`v4l2-mbus-format` on how to do this.
* - V4L2_SUBDEV_MBUS_CODE_CSC_XFER_FUNC
- 0x00000002
- The driver allows the application to try to change the default transform function.
The application can ask to configure the transform function of
the subdevice when calling the :ref:`VIDIOC_SUBDEV_S_FMT <VIDIOC_SUBDEV_G_FMT>`
ioctl with :ref:`V4L2_MBUS_FRAMEFMT_SET_CSC <mbus-framefmt-set-csc>` set.
See :ref:`v4l2-mbus-format` on how to do this.
* - V4L2_SUBDEV_MBUS_CODE_CSC_YCBCR_ENC
- 0x00000004
- The driver allows the application to try to change the default Y'CbCr
encoding. The application can ask to configure the Y'CbCr encoding of the
subdevice when calling the :ref:`VIDIOC_SUBDEV_S_FMT <VIDIOC_SUBDEV_G_FMT>`
ioctl with :ref:`V4L2_MBUS_FRAMEFMT_SET_CSC <mbus-framefmt-set-csc>` set.
See :ref:`v4l2-mbus-format` on how to do this.
* - V4L2_SUBDEV_MBUS_CODE_CSC_HSV_ENC
- 0x00000004
- The driver allows the application to try to change the default HSV
encoding. The application can ask to configure the HSV encoding of the
subdevice when calling the :ref:`VIDIOC_SUBDEV_S_FMT <VIDIOC_SUBDEV_G_FMT>`
ioctl with :ref:`V4L2_MBUS_FRAMEFMT_SET_CSC <mbus-framefmt-set-csc>` set.
See :ref:`v4l2-mbus-format` on how to do this.
* - V4L2_SUBDEV_MBUS_CODE_CSC_QUANTIZATION
- 0x00000008
- The driver allows the application to try to change the default
quantization. The application can ask to configure the quantization of
the subdevice when calling the :ref:`VIDIOC_SUBDEV_S_FMT <VIDIOC_SUBDEV_G_FMT>`
ioctl with :ref:`V4L2_MBUS_FRAMEFMT_SET_CSC <mbus-framefmt-set-csc>` set.
See :ref:`v4l2-mbus-format` on how to do this.
.. raw:: latex
\normalsize
반환값과 EINVAL
152-163성공하면 0, 오류이면 -1을 반환하고 `errno`를 설정합니다.
pad, which 또는 index가 유효하지 않을 때 반환됩니다.
Return Value
============
On success 0 is returned, on error -1 and the ``errno`` variable is set
appropriately. The generic error codes are described at the
:ref:`Generic Error Codes <gen-errors>` chapter.
EINVAL
The struct :c:type:`v4l2_subdev_mbus_code_enum` ``pad`` references a
non-existing pad, the ``which`` field has an unsupported value, or the
``index`` field is out of bounds.
요약·해설
vidioc-subdev-enum-mbus-code.rst:1-163형식 code 목록은 pad마다 고유하며 파이프라인의 try format과 활성 링크에 따라 달라질 수 있으므로 구성 시점의 결과를 사용해야 합니다.