요약·해설과 원문, 전문 번역을 서로 분리했습니다. 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_G_PARM:
**********************************
ioctl VIDIOC_G_PARM, VIDIOC_S_PARM
**********************************
Name
====
VIDIOC_G_PARM - VIDIOC_S_PARM - Get or set streaming parameters
Synopsis
========
.. c:macro:: VIDIOC_G_PARM
``int ioctl(int fd, VIDIOC_G_PARM, v4l2_streamparm *argp)``
.. c:macro:: VIDIOC_S_PARM
``int ioctl(int fd, VIDIOC_S_PARM, v4l2_streamparm *argp)``
Arguments
=========
``fd``
File descriptor returned by :c:func:`open()`.
``argp``
Pointer to struct :c:type:`v4l2_streamparm`.
Description
===========
Applications can request a different frame interval. The capture or
output device will be reconfigured to support the requested frame
interval if possible. Optionally drivers may choose to skip or
repeat frames to achieve the requested frame interval.
For stateful encoders (see :ref:`encoder`) this represents the
frame interval that is typically embedded in the encoded video stream.
Changing the frame interval shall never change the format. Changing the
format, on the other hand, may change the frame interval.
Further these ioctls can be used to determine the number of buffers used
internally by a driver in read/write mode. For implications see the
section discussing the :c:func:`read()` function.
To get and set the streaming parameters applications call the
:ref:`VIDIOC_G_PARM <VIDIOC_G_PARM>` and
:ref:`VIDIOC_S_PARM <VIDIOC_G_PARM>` ioctl, respectively. They take a
pointer to a struct :c:type:`v4l2_streamparm` which contains a
union holding separate parameters for input and output devices.
.. tabularcolumns:: |p{3.7cm}|p{3.5cm}|p{10.1cm}|
.. c:type:: v4l2_streamparm
.. flat-table:: struct v4l2_streamparm
:header-rows: 0
:stub-columns: 0
:widths: 1 1 2
* - __u32
- ``type``
- The buffer (stream) type, same as struct
:c:type:`v4l2_format` ``type``, set by the
application. See :c:type:`v4l2_buf_type`.
* - union {
- ``parm``
* - struct :c:type:`v4l2_captureparm`
- ``capture``
- Parameters for capture devices, used when ``type`` is
``V4L2_BUF_TYPE_VIDEO_CAPTURE`` or
``V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE``.
* - struct :c:type:`v4l2_outputparm`
- ``output``
- Parameters for output devices, used when ``type`` is
``V4L2_BUF_TYPE_VIDEO_OUTPUT`` or ``V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE``.
* - __u8
- ``raw_data``\ [200]
- A place holder for future extensions.
* - }
.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
.. c:type:: v4l2_captureparm
.. flat-table:: struct v4l2_captureparm
:header-rows: 0
:stub-columns: 0
:widths: 1 1 2
* - __u32
- ``capability``
- See :ref:`parm-caps`.
* - __u32
- ``capturemode``
- Set by drivers and applications, see :ref:`parm-flags`.
* - struct :c:type:`v4l2_fract`
- ``timeperframe``
- This is the desired period between successive frames captured by
the driver, in seconds.
* - :cspan:`2`
This will configure the speed at which the video source (e.g. a sensor)
generates video frames. If the speed is fixed, then the driver may
choose to skip or repeat frames in order to achieve the requested
frame rate.
For stateful encoders (see :ref:`encoder`) this represents the
frame interval that is typically embedded in the encoded video stream.
Applications store here the desired frame period, drivers return
the actual frame period.
Changing the video standard (also implicitly by switching
the video input) may reset this parameter to the nominal frame
period. To reset manually applications can just set this field to
zero.
Drivers support this function only when they set the
``V4L2_CAP_TIMEPERFRAME`` flag in the ``capability`` field.
* - __u32
- ``extendedmode``
- Custom (driver specific) streaming parameters. When unused,
applications and drivers must set this field to zero. Applications
using this field should check the driver name and version, see
:ref:`querycap`.
* - __u32
- ``readbuffers``
- Applications set this field to the desired number of buffers used
internally by the driver in :c:func:`read()` mode.
Drivers return the actual number of buffers. When an application
requests zero buffers, drivers should just return the current
setting rather than the minimum or an error code. For details see
:ref:`rw`.
* - __u32
- ``reserved``\ [4]
- Reserved for future extensions. Drivers and applications must set
the array to zero.
.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
.. c:type:: v4l2_outputparm
.. flat-table:: struct v4l2_outputparm
:header-rows: 0
:stub-columns: 0
:widths: 1 1 2
* - __u32
- ``capability``
- See :ref:`parm-caps`.
* - __u32
- ``outputmode``
- Set by drivers and applications, see :ref:`parm-flags`.
* - struct :c:type:`v4l2_fract`
- ``timeperframe``
- This is the desired period between successive frames output by the
driver, in seconds.
* - :cspan:`2`
The field is intended to repeat frames on the driver side in
:c:func:`write()` mode (in streaming mode timestamps
can be used to throttle the output), saving I/O bandwidth.
For stateful encoders (see :ref:`encoder`) this represents the
frame interval that is typically embedded in the encoded video stream
and it provides a hint to the encoder of the speed at which raw
frames are queued up to the encoder.
Applications store here the desired frame period, drivers return
the actual frame period.
Changing the video standard (also implicitly by switching
the video output) may reset this parameter to the nominal frame
period. To reset manually applications can just set this field to
zero.
Drivers support this function only when they set the
``V4L2_CAP_TIMEPERFRAME`` flag in the ``capability`` field.
* - __u32
- ``extendedmode``
- Custom (driver specific) streaming parameters. When unused,
applications and drivers must set this field to zero. Applications
using this field should check the driver name and version, see
:ref:`querycap`.
* - __u32
- ``writebuffers``
- Applications set this field to the desired number of buffers used
internally by the driver in :c:func:`write()` mode. Drivers
return the actual number of buffers. When an application requests
zero buffers, drivers should just return the current setting
rather than the minimum or an error code. For details see
:ref:`rw`.
* - __u32
- ``reserved``\ [4]
- Reserved for future extensions. Drivers and applications must set
the array to zero.
.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}|
.. _parm-caps:
.. flat-table:: Streaming Parameters Capabilities
:header-rows: 0
:stub-columns: 0
:widths: 3 1 4
* - ``V4L2_CAP_TIMEPERFRAME``
- 0x1000
- The frame period can be modified by setting the ``timeperframe``
field.
.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}|
.. _parm-flags:
.. flat-table:: Capture Parameters Flags
:header-rows: 0
:stub-columns: 0
:widths: 3 1 4
* - ``V4L2_MODE_HIGHQUALITY``
- 0x0001
- High quality imaging mode. High quality mode is intended for still
imaging applications. The idea is to get the best possible image
quality that the hardware can deliver. It is not defined how the
driver writer may achieve that; it will depend on the hardware and
the ingenuity of the driver writer. High quality mode is a
different mode from the regular motion video capture modes. In
high quality mode:
- The driver may be able to capture higher resolutions than for
motion capture.
- The driver may support fewer pixel formats than motion capture
(eg; true color).
- The driver may capture and arithmetically combine multiple
successive fields or frames to remove color edge artifacts and
reduce the noise in the video data.
- The driver may capture images in slices like a scanner in order
to handle larger format images than would otherwise be
possible.
- An image capture operation may be significantly slower than
motion capture.
- Moving objects in the image might have excessive motion blur.
- Capture might only work through the :c:func:`read()` call.
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.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
목적, 호출 형식과 인자
1-34`VIDIOC_G_PARM`과 `VIDIOC_S_PARM`은 capture 또는 output stream의 매개변수를 조회·설정합니다. 두 명령은 input·output용 union을 담는 `v4l2_streamparm *argp`를 받습니다.
`fd`는 `open()`이 반환한 파일 디스크립터입니다. 애플리케이션은 stream 방향에 맞는 buffer type과 union 멤버를 선택해야 합니다.
.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
.. c:namespace:: V4L
.. _VIDIOC_G_PARM:
**********************************
ioctl VIDIOC_G_PARM, VIDIOC_S_PARM
**********************************
Name
====
VIDIOC_G_PARM - VIDIOC_S_PARM - Get or set streaming parameters
Synopsis
========
.. c:macro:: VIDIOC_G_PARM
``int ioctl(int fd, VIDIOC_G_PARM, v4l2_streamparm *argp)``
.. c:macro:: VIDIOC_S_PARM
``int ioctl(int fd, VIDIOC_S_PARM, v4l2_streamparm *argp)``
Arguments
=========
``fd``
File descriptor returned by :c:func:`open()`.
``argp``
Pointer to struct :c:type:`v4l2_streamparm`.
frame interval과 내부 buffer
35-58애플리케이션은 다른 frame interval을 요청할 수 있습니다. 장치는 가능하면 해당 interval을 지원하도록 재구성하며, 드라이버는 선택적으로 frame을 건너뛰거나 반복할 수 있습니다.
stateful encoder에서 이 값은 일반적으로 인코딩된 video stream에 포함되는 frame interval을 뜻합니다.
frame interval 변경은 format을 바꾸면 안 됩니다. 반대로 format을 변경하면 frame interval은 바뀔 수 있습니다. 따라서 S_FMT 뒤에는 streaming parameter를 다시 조회해야 합니다.
이 ioctl은 read/write 모드에서 드라이버가 내부적으로 사용하는 buffer 수를 확인·요청하는 데도 사용합니다.
format 변경 가능성을 고려해 frame interval을 마지막에 확정합니다.
Description
===========
Applications can request a different frame interval. The capture or
output device will be reconfigured to support the requested frame
interval if possible. Optionally drivers may choose to skip or
repeat frames to achieve the requested frame interval.
For stateful encoders (see :ref:`encoder`) this represents the
frame interval that is typically embedded in the encoded video stream.
Changing the frame interval shall never change the format. Changing the
format, on the other hand, may change the frame interval.
Further these ioctls can be used to determine the number of buffers used
internally by a driver in read/write mode. For implications see the
section discussing the :c:func:`read()` function.
To get and set the streaming parameters applications call the
:ref:`VIDIOC_G_PARM <VIDIOC_G_PARM>` and
:ref:`VIDIOC_S_PARM <VIDIOC_G_PARM>` ioctl, respectively. They take a
pointer to a struct :c:type:`v4l2_streamparm` which contains a
union holding separate parameters for input and output devices.
struct v4l2_streamparm
59-89stream type에 따라 capture 또는 output union 멤버를 사용합니다.
.. tabularcolumns:: |p{3.7cm}|p{3.5cm}|p{10.1cm}|
.. c:type:: v4l2_streamparm
.. flat-table:: struct v4l2_streamparm
:header-rows: 0
:stub-columns: 0
:widths: 1 1 2
* - __u32
- ``type``
- The buffer (stream) type, same as struct
:c:type:`v4l2_format` ``type``, set by the
application. See :c:type:`v4l2_buf_type`.
* - union {
- ``parm``
* - struct :c:type:`v4l2_captureparm`
- ``capture``
- Parameters for capture devices, used when ``type`` is
``V4L2_BUF_TYPE_VIDEO_CAPTURE`` or
``V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE``.
* - struct :c:type:`v4l2_outputparm`
- ``output``
- Parameters for output devices, used when ``type`` is
``V4L2_BUF_TYPE_VIDEO_OUTPUT`` or ``V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE``.
* - __u8
- ``raw_data``\ [200]
- A place holder for future extensions.
* - }
struct v4l2_captureparm
90-147capture source의 frame period와 read 모드 buffer를 다룹니다.
`timeperframe`은 sensor 같은 video source의 frame 생성 속도를 구성합니다. source 속도가 고정이면 드라이버가 frame을 건너뛰거나 반복해 요청 frame rate를 맞출 수 있습니다.
stateful encoder에서는 일반적으로 bitstream에 포함될 frame interval입니다. video standard가 바뀌거나 video input 전환으로 standard가 암묵적으로 바뀌면 nominal period로 재설정될 수 있고, 수동 재설정은 이 필드를 0으로 설정합니다.
`timeperframe`은 `capability`에 `V4L2_CAP_TIMEPERFRAME`이 있을 때만 지원됩니다. `extendedmode`를 쓰는 애플리케이션은 driver name과 version을 확인해야 합니다.
`readbuffers = 0` 요청은 최소 수나 오류가 아니라 현재 설정을 반환해야 합니다. 드라이버는 요청값을 받아 실제 내부 buffer 수를 돌려줍니다.
.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
.. c:type:: v4l2_captureparm
.. flat-table:: struct v4l2_captureparm
:header-rows: 0
:stub-columns: 0
:widths: 1 1 2
* - __u32
- ``capability``
- See :ref:`parm-caps`.
* - __u32
- ``capturemode``
- Set by drivers and applications, see :ref:`parm-flags`.
* - struct :c:type:`v4l2_fract`
- ``timeperframe``
- This is the desired period between successive frames captured by
the driver, in seconds.
* - :cspan:`2`
This will configure the speed at which the video source (e.g. a sensor)
generates video frames. If the speed is fixed, then the driver may
choose to skip or repeat frames in order to achieve the requested
frame rate.
For stateful encoders (see :ref:`encoder`) this represents the
frame interval that is typically embedded in the encoded video stream.
Applications store here the desired frame period, drivers return
the actual frame period.
Changing the video standard (also implicitly by switching
the video input) may reset this parameter to the nominal frame
period. To reset manually applications can just set this field to
zero.
Drivers support this function only when they set the
``V4L2_CAP_TIMEPERFRAME`` flag in the ``capability`` field.
* - __u32
- ``extendedmode``
- Custom (driver specific) streaming parameters. When unused,
applications and drivers must set this field to zero. Applications
using this field should check the driver name and version, see
:ref:`querycap`.
* - __u32
- ``readbuffers``
- Applications set this field to the desired number of buffers used
internally by the driver in :c:func:`read()` mode.
Drivers return the actual number of buffers. When an application
requests zero buffers, drivers should just return the current
setting rather than the minimum or an error code. For details see
:ref:`rw`.
* - __u32
- ``reserved``\ [4]
- Reserved for future extensions. Drivers and applications must set
the array to zero.
struct v4l2_outputparm
148-207output frame period와 write 모드 내부 buffer를 다룹니다.
output `timeperframe`은 write 모드에서 드라이버가 frame을 반복해 I/O bandwidth를 줄이는 용도입니다. streaming 모드에서는 timestamp로 출력 속도를 제한할 수 있습니다.
stateful encoder에서는 bitstream에 포함되는 frame interval이자 raw frame이 encoder에 queue되는 속도에 대한 힌트입니다.
video standard 또는 output 전환으로 nominal period에 재설정될 수 있으며 0을 써서 수동 재설정합니다. 지원 여부는 `V4L2_CAP_TIMEPERFRAME`으로 확인합니다.
`writebuffers = 0`이면 현재 설정을 반환해야 합니다. `extendedmode` 사용 시 driver name과 version을 확인하고 `reserved[4]`는 0으로 둡니다.
.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
.. c:type:: v4l2_outputparm
.. flat-table:: struct v4l2_outputparm
:header-rows: 0
:stub-columns: 0
:widths: 1 1 2
* - __u32
- ``capability``
- See :ref:`parm-caps`.
* - __u32
- ``outputmode``
- Set by drivers and applications, see :ref:`parm-flags`.
* - struct :c:type:`v4l2_fract`
- ``timeperframe``
- This is the desired period between successive frames output by the
driver, in seconds.
* - :cspan:`2`
The field is intended to repeat frames on the driver side in
:c:func:`write()` mode (in streaming mode timestamps
can be used to throttle the output), saving I/O bandwidth.
For stateful encoders (see :ref:`encoder`) this represents the
frame interval that is typically embedded in the encoded video stream
and it provides a hint to the encoder of the speed at which raw
frames are queued up to the encoder.
Applications store here the desired frame period, drivers return
the actual frame period.
Changing the video standard (also implicitly by switching
the video output) may reset this parameter to the nominal frame
period. To reset manually applications can just set this field to
zero.
Drivers support this function only when they set the
``V4L2_CAP_TIMEPERFRAME`` flag in the ``capability`` field.
* - __u32
- ``extendedmode``
- Custom (driver specific) streaming parameters. When unused,
applications and drivers must set this field to zero. Applications
using this field should check the driver name and version, see
:ref:`querycap`.
* - __u32
- ``writebuffers``
- Applications set this field to the desired number of buffers used
internally by the driver in :c:func:`write()` mode. Drivers
return the actual number of buffers. When an application requests
zero buffers, drivers should just return the current setting
rather than the minimum or an error code. For details see
:ref:`rw`.
* - __u32
- ``reserved``\ [4]
- Reserved for future extensions. Drivers and applications must set
the array to zero.
Capability와 High Quality mode
208-263frame period 변경 지원을 표시합니다.
`V4L2_MODE_HIGHQUALITY` (`0x0001`)은 still imaging용 고품질 모드입니다. 하드웨어가 낼 수 있는 최상의 화질을 목표로 하며 구현 방식은 하드웨어와 드라이버에 따라 다릅니다. 일반 motion video capture와 별개의 모드입니다.
화질을 높이는 대신 형식·속도·움직임과 I/O 방식에 제약이 생길 수 있습니다.
.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}|
.. _parm-caps:
.. flat-table:: Streaming Parameters Capabilities
:header-rows: 0
:stub-columns: 0
:widths: 3 1 4
* - ``V4L2_CAP_TIMEPERFRAME``
- 0x1000
- The frame period can be modified by setting the ``timeperframe``
field.
.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}|
.. _parm-flags:
.. flat-table:: Capture Parameters Flags
:header-rows: 0
:stub-columns: 0
:widths: 3 1 4
* - ``V4L2_MODE_HIGHQUALITY``
- 0x0001
- High quality imaging mode. High quality mode is intended for still
imaging applications. The idea is to get the best possible image
quality that the hardware can deliver. It is not defined how the
driver writer may achieve that; it will depend on the hardware and
the ingenuity of the driver writer. High quality mode is a
different mode from the regular motion video capture modes. In
high quality mode:
- The driver may be able to capture higher resolutions than for
motion capture.
- The driver may support fewer pixel formats than motion capture
(eg; true color).
- The driver may capture and arithmetically combine multiple
successive fields or frames to remove color edge artifacts and
reduce the noise in the video data.
- The driver may capture images in slices like a scanner in order
to handle larger format images than would otherwise be
possible.
- An image capture operation may be significantly slower than
motion capture.
- Moving objects in the image might have excessive motion blur.
- Capture might only work through the :c:func:`read()` call.
반환값
264-269성공하면 0을 반환합니다. 오류가 발생하면 -1을 반환하고 `errno`를 적절히 설정하며, 이 문서는 전용 오류를 별도로 열거하지 않고 Generic Error Codes 장을 따릅니다.
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.
요약·해설
vidioc-g-parm.rst:1-269stream의 frame interval과 내부 read/write buffer 및 high-quality capture mode를 다룹니다.