← Documents Documentation/userspace-api/media/v4l/vidioc-enum-framesizes.rst GitHub 원문 ↗

Linux 6.18.37 · 사용자 공간 API

VIDIOC_ENUM_FRAMESIZES ioctl

지정한 V4L2 pixel format의 discrete, step-wise, continuous frame size를 열거하고 각 구조체와 유형별 index 규칙을 설명합니다.

Source pathDocumentation/userspace-api/media/v4l/vidioc-enum-framesizes.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

vidioc-enum-framesizes.rst:1-194

지정한 V4L2 pixel format의 discrete, step-wise, continuous frame size를 열거하고 각 구조체와 유형별 index 규칙을 설명합니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2 .. c:namespace:: V4L
3
4 .. _VIDIOC_ENUM_FRAMESIZES:
5
6 ****************************
7 ioctl VIDIOC_ENUM_FRAMESIZES
8 ****************************
9
10 Name
11 ====
12
13 VIDIOC_ENUM_FRAMESIZES - Enumerate frame sizes
14
15 Synopsis
16 ========
17
18 .. c:macro:: VIDIOC_ENUM_FRAMESIZES
19
20 ``int ioctl(int fd, VIDIOC_ENUM_FRAMESIZES, struct v4l2_frmsizeenum *argp)``
21
22 Arguments
23 =========
24
25 ``fd``
26 File descriptor returned by :c:func:`open()`.
27
28 ``argp``
29 Pointer to struct :c:type:`v4l2_frmsizeenum`
30 that contains an index and pixel format and receives a frame width
31 and height.
32
33 Description
34 ===========
35
36 This ioctl allows applications to enumerate all frame sizes (i. e. width
37 and height in pixels) that the device supports for the given pixel
38 format.
39
40 The supported pixel formats can be obtained by using the
41 :ref:`VIDIOC_ENUM_FMT` function.
42
43 The return value and the content of the ``v4l2_frmsizeenum.type`` field
44 depend on the type of frame sizes the device supports. Here are the
45 semantics of the function for the different cases:
46
47 - **Discrete:** The function returns success if the given index value
48 (zero-based) is valid. The application should increase the index by
49 one for each call until ``EINVAL`` is returned. The
50 ``v4l2_frmsizeenum.type`` field is set to
51 ``V4L2_FRMSIZE_TYPE_DISCRETE`` by the driver. Of the union only the
52 ``discrete`` member is valid.
53
54 - **Step-wise:** The function returns success if the given index value
55 is zero and ``EINVAL`` for any other index value. The
56 ``v4l2_frmsizeenum.type`` field is set to
57 ``V4L2_FRMSIZE_TYPE_STEPWISE`` by the driver. Of the union only the
58 ``stepwise`` member is valid.
59
60 - **Continuous:** This is a special case of the step-wise type above.
61 The function returns success if the given index value is zero and
62 ``EINVAL`` for any other index value. The ``v4l2_frmsizeenum.type``
63 field is set to ``V4L2_FRMSIZE_TYPE_CONTINUOUS`` by the driver. Of
64 the union only the ``stepwise`` member is valid and the
65 ``step_width`` and ``step_height`` values are set to 1.
66
67 When the application calls the function with index zero, it must check
68 the ``type`` field to determine the type of frame size enumeration the
69 device supports. Only for the ``V4L2_FRMSIZE_TYPE_DISCRETE`` type does
70 it make sense to increase the index value to receive more frame sizes.
71
72 .. note::
73
74 The order in which the frame sizes are returned has no special
75 meaning. In particular does it not say anything about potential default
76 format sizes.
77
78 Applications can assume that the enumeration data does not change
79 without any interaction from the application itself. This means that the
80 enumeration data is consistent if the application does not perform any
81 other ioctl calls while it runs the frame size enumeration.
82
83 Structs
84 =======
85
86 In the structs below, *IN* denotes a value that has to be filled in by
87 the application, *OUT* denotes values that the driver fills in. The
88 application should zero out all members except for the *IN* fields.
89
90 .. c:type:: v4l2_frmsize_discrete
91
92 .. flat-table:: struct v4l2_frmsize_discrete
93 :header-rows: 0
94 :stub-columns: 0
95 :widths: 1 1 2
96
97 * - __u32
98 - ``width``
99 - Width of the frame [pixel].
100 * - __u32
101 - ``height``
102 - Height of the frame [pixel].
103
104
105 .. c:type:: v4l2_frmsize_stepwise
106
107 .. flat-table:: struct v4l2_frmsize_stepwise
108 :header-rows: 0
109 :stub-columns: 0
110 :widths: 1 1 2
111
112 * - __u32
113 - ``min_width``
114 - Minimum frame width [pixel].
115 * - __u32
116 - ``max_width``
117 - Maximum frame width [pixel].
118 * - __u32
119 - ``step_width``
120 - Frame width step size [pixel].
121 * - __u32
122 - ``min_height``
123 - Minimum frame height [pixel].
124 * - __u32
125 - ``max_height``
126 - Maximum frame height [pixel].
127 * - __u32
128 - ``step_height``
129 - Frame height step size [pixel].
130
131
132 .. c:type:: v4l2_frmsizeenum
133
134 .. tabularcolumns:: |p{6.4cm}|p{2.8cm}|p{8.1cm}|
135
136 .. flat-table:: struct v4l2_frmsizeenum
137 :header-rows: 0
138 :stub-columns: 0
139
140 * - __u32
141 - ``index``
142 - IN: Index of the given frame size in the enumeration.
143 * - __u32
144 - ``pixel_format``
145 - IN: Pixel format for which the frame sizes are enumerated.
146 * - __u32
147 - ``type``
148 - OUT: Frame size type the device supports.
149 * - union {
150 - (anonymous)
151 - OUT: Frame size with the given index.
152 * - struct :c:type:`v4l2_frmsize_discrete`
153 - ``discrete``
154 -
155 * - struct :c:type:`v4l2_frmsize_stepwise`
156 - ``stepwise``
157 -
158 * - }
159 -
160 -
161 * - __u32
162 - ``reserved[2]``
163 - Reserved space for future use. Must be zeroed by drivers and
164 applications.
165
166
167 Enums
168 =====
169
170 .. c:type:: v4l2_frmsizetypes
171
172 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}|
173
174 .. flat-table:: enum v4l2_frmsizetypes
175 :header-rows: 0
176 :stub-columns: 0
177 :widths: 3 1 4
178
179 * - ``V4L2_FRMSIZE_TYPE_DISCRETE``
180 - 1
181 - Discrete frame size.
182 * - ``V4L2_FRMSIZE_TYPE_CONTINUOUS``
183 - 2
184 - Continuous frame size.
185 * - ``V4L2_FRMSIZE_TYPE_STEPWISE``
186 - 3
187 - Step-wise defined frame size.
188
189 Return Value
190 ============
191
192 On success 0 is returned, on error -1 and the ``errno`` variable is set
193 appropriately. The generic error codes are described at the
194 :ref:`Generic Error Codes <gen-errors>` chapter.
195

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

목적, 호출 형식과 인자

1-32

`VIDIOC_ENUM_FRAMESIZES`는 지정한 pixel format에 대해 장치가 지원하는 모든 frame size, 즉 픽셀 단위의 너비와 높이를 열거하는 ioctl입니다. 호출 형식은 `int ioctl(int fd, VIDIOC_ENUM_FRAMESIZES, struct v4l2_frmsizeenum *argp)`입니다.

`fd`는 `open()`이 반환한 파일 디스크립터입니다. `argp`는 응용 프로그램이 `index`와 pixel format을 넣고 드라이버로부터 frame width와 height를 돌려받는 `struct v4l2_frmsizeenum`을 가리킵니다.

.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
.. c:namespace:: V4L

.. _VIDIOC_ENUM_FRAMESIZES:

****************************
ioctl VIDIOC_ENUM_FRAMESIZES
****************************

Name
====

VIDIOC_ENUM_FRAMESIZES - Enumerate frame sizes

Synopsis
========

.. c:macro:: VIDIOC_ENUM_FRAMESIZES

``int ioctl(int fd, VIDIOC_ENUM_FRAMESIZES, struct v4l2_frmsizeenum *argp)``

Arguments
=========

``fd``
    File descriptor returned by :c:func:`open()`.

``argp``
    Pointer to struct :c:type:`v4l2_frmsizeenum`
    that contains an index and pixel format and receives a frame width
    and height.

열거 방식과 일관성

33-82

지원 pixel format은 `VIDIOC_ENUM_FMT`로 먼저 얻습니다. 이 ioctl의 반환 방식과 `v4l2_frmsizeenum.type`은 장치가 지원하는 frame size 표현 유형에 따라 달라집니다.

Frame size 열거 방식
유형type호출 규칙
Discrete`V4L2_FRMSIZE_TYPE_DISCRETE`index 0부터 호출마다 1씩 증가해 `EINVAL`까지 반복하며 `discrete`만 유효
Step-wise`V4L2_FRMSIZE_TYPE_STEPWISE`index 0에서만 성공하고 나머지는 `EINVAL`; `stepwise`만 유효
Continuous`V4L2_FRMSIZE_TYPE_CONTINUOUS`step-wise의 특수 사례로 index 0에서만 성공하고 `step_width`와 `step_height`는 1

첫 호출의 type과 index 처리, 유효한 union 멤버를 비교합니다.

응용 프로그램은 `index` 0으로 처음 호출한 뒤 `type`을 확인해야 합니다. 더 많은 크기를 얻기 위해 index를 증가시키는 방식은 `V4L2_FRMSIZE_TYPE_DISCRETE`에서만 의미가 있습니다.

frame size가 반환되는 순서에는 특별한 의미가 없으며 잠재적인 기본 format size를 나타내지도 않습니다. 응용 프로그램이 열거 중 다른 ioctl을 호출하지 않으면 열거 데이터는 스스로 바뀌지 않으므로 일관된 결과를 가정할 수 있습니다.

Frame size 조회
VIDIOC_ENUM_FMT로 pixel_format 선택index=0, 나머지 필드=0VIDIOC_ENUM_FRAMESIZES 호출type 확인Discrete면 index 증가 반복Step-wise/Continuous면 너비·높이 범위 처리

유형을 판별하고 개별 크기 또는 지원 범위를 처리하는 순서입니다.

Description
===========

This ioctl allows applications to enumerate all frame sizes (i. e. width
and height in pixels) that the device supports for the given pixel
format.

The supported pixel formats can be obtained by using the
:ref:`VIDIOC_ENUM_FMT` function.

The return value and the content of the ``v4l2_frmsizeenum.type`` field
depend on the type of frame sizes the device supports. Here are the
semantics of the function for the different cases:

-  **Discrete:** The function returns success if the given index value
   (zero-based) is valid. The application should increase the index by
   one for each call until ``EINVAL`` is returned. The
   ``v4l2_frmsizeenum.type`` field is set to
   ``V4L2_FRMSIZE_TYPE_DISCRETE`` by the driver. Of the union only the
   ``discrete`` member is valid.

-  **Step-wise:** The function returns success if the given index value
   is zero and ``EINVAL`` for any other index value. The
   ``v4l2_frmsizeenum.type`` field is set to
   ``V4L2_FRMSIZE_TYPE_STEPWISE`` by the driver. Of the union only the
   ``stepwise`` member is valid.

-  **Continuous:** This is a special case of the step-wise type above.
   The function returns success if the given index value is zero and
   ``EINVAL`` for any other index value. The ``v4l2_frmsizeenum.type``
   field is set to ``V4L2_FRMSIZE_TYPE_CONTINUOUS`` by the driver. Of
   the union only the ``stepwise`` member is valid and the
   ``step_width`` and ``step_height`` values are set to 1.

When the application calls the function with index zero, it must check
the ``type`` field to determine the type of frame size enumeration the
device supports. Only for the ``V4L2_FRMSIZE_TYPE_DISCRETE`` type does
it make sense to increase the index value to receive more frame sizes.

.. note::

   The order in which the frame sizes are returned has no special
   meaning. In particular does it not say anything about potential default
   format sizes.

Applications can assume that the enumeration data does not change
without any interaction from the application itself. This means that the
enumeration data is consistent if the application does not perform any
other ioctl calls while it runs the frame size enumeration.

v4l2_frmsize_discrete 구조체

83-104

아래 구조체에서 IN은 응용 프로그램이 채우는 값, OUT은 드라이버가 채우는 값입니다. 응용 프로그램은 IN 필드를 제외한 모든 멤버를 0으로 초기화해야 합니다. `v4l2_frmsize_discrete`는 한 개의 고정 frame size를 나타냅니다.

struct v4l2_frmsize_discrete
형식필드의미
`__u32``width`frame 너비 [pixel]
`__u32``height`frame 높이 [pixel]

고정 frame size의 픽셀 치수입니다.

Structs
=======

In the structs below, *IN* denotes a value that has to be filled in by
the application, *OUT* denotes values that the driver fills in. The
application should zero out all members except for the *IN* fields.

.. c:type:: v4l2_frmsize_discrete

.. flat-table:: struct v4l2_frmsize_discrete
    :header-rows:  0
    :stub-columns: 0
    :widths:       1 1 2

    * - __u32
      - ``width``
      - Width of the frame [pixel].
    * - __u32
      - ``height``
      - Height of the frame [pixel].

v4l2_frmsize_stepwise 구조체

105-131
struct v4l2_frmsize_stepwise
형식필드의미
`__u32``min_width`최소 frame 너비 [pixel]
`__u32``max_width`최대 frame 너비 [pixel]
`__u32``step_width`frame 너비 증가 단위 [pixel]
`__u32``min_height`최소 frame 높이 [pixel]
`__u32``max_height`최대 frame 높이 [pixel]
`__u32``step_height`frame 높이 증가 단위 [pixel]

지원하는 너비와 높이의 최소값, 최대값, 증가 단위입니다.

Step-wise 유형에서 유효한 크기는 각 축의 최소값부터 최대값까지 해당 step의 배수로 증가하는 조합입니다. Continuous 유형은 같은 구조체를 사용하되 두 step 값이 모두 1이므로 범위 안의 모든 정수 픽셀 크기를 표현합니다.

.. c:type:: v4l2_frmsize_stepwise

.. flat-table:: struct v4l2_frmsize_stepwise
    :header-rows:  0
    :stub-columns: 0
    :widths:       1 1 2

    * - __u32
      - ``min_width``
      - Minimum frame width [pixel].
    * - __u32
      - ``max_width``
      - Maximum frame width [pixel].
    * - __u32
      - ``step_width``
      - Frame width step size [pixel].
    * - __u32
      - ``min_height``
      - Minimum frame height [pixel].
    * - __u32
      - ``max_height``
      - Maximum frame height [pixel].
    * - __u32
      - ``step_height``
      - Frame height step size [pixel].

v4l2_frmsizeenum 구조체

132-166
struct v4l2_frmsizeenum
형식필드방향과 의미
`__u32``index`IN: 열거할 frame size의 순번
`__u32``pixel_format`IN: frame size를 열거할 pixel format
`__u32``type`OUT: 장치가 지원하는 frame size 유형
union익명 unionOUT: 지정한 index 또는 범위의 frame size
`struct v4l2_frmsize_discrete``discrete`Discrete 유형의 width와 height
`struct v4l2_frmsize_stepwise``stepwise`Step-wise 또는 Continuous 유형의 범위와 step
`__u32[2]``reserved`미래 사용을 위한 공간이며 드라이버와 응용 프로그램 모두 0으로 설정

조회 조건과 드라이버가 반환하는 크기 표현을 원문 순서대로 정리합니다.

`type`이 선택한 union 멤버만 유효합니다. Discrete에서는 `discrete`, Step-wise와 Continuous에서는 `stepwise`를 읽어야 하며, 예약 필드는 호출 전후 모두 0 규칙을 지켜야 합니다.

.. c:type:: v4l2_frmsizeenum

.. tabularcolumns:: |p{6.4cm}|p{2.8cm}|p{8.1cm}|

.. flat-table:: struct v4l2_frmsizeenum
    :header-rows:  0
    :stub-columns: 0

    * - __u32
      - ``index``
      - IN: Index of the given frame size in the enumeration.
    * - __u32
      - ``pixel_format``
      - IN: Pixel format for which the frame sizes are enumerated.
    * - __u32
      - ``type``
      - OUT: Frame size type the device supports.
    * - union {
      - (anonymous)
      - OUT: Frame size with the given index.
    * - struct :c:type:`v4l2_frmsize_discrete`
      - ``discrete``
      -
    * - struct :c:type:`v4l2_frmsize_stepwise`
      - ``stepwise``
      -
    * - }
      -
      -
    * - __u32
      - ``reserved[2]``
      - Reserved space for future use. Must be zeroed by drivers and
	applications.

v4l2_frmsizetypes 열거형

167-188
enum v4l2_frmsizetypes
상수의미
`V4L2_FRMSIZE_TYPE_DISCRETE`1개별적으로 나열되는 frame size
`V4L2_FRMSIZE_TYPE_CONTINUOUS`2연속적인 frame size 범위
`V4L2_FRMSIZE_TYPE_STEPWISE`3일정 step으로 정의되는 frame size 범위

드라이버가 반환하는 frame size 표현 유형입니다.

Enums
=====

.. c:type:: v4l2_frmsizetypes

.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}|

.. flat-table:: enum v4l2_frmsizetypes
    :header-rows:  0
    :stub-columns: 0
    :widths:       3 1 4

    * - ``V4L2_FRMSIZE_TYPE_DISCRETE``
      - 1
      - Discrete frame size.
    * - ``V4L2_FRMSIZE_TYPE_CONTINUOUS``
      - 2
      - Continuous frame size.
    * - ``V4L2_FRMSIZE_TYPE_STEPWISE``
      - 3
      - Step-wise defined frame size.

반환값

189-194

성공하면 0을 반환합니다. 오류가 발생하면 -1을 반환하고 `errno`를 적절한 값으로 설정하며, 공통 오류 코드는 Generic Error Codes 장을 따릅니다. 열거 종료 또는 유형별로 허용되지 않는 index에서 반환되는 `EINVAL`을 정상적인 반복 종료 조건으로 처리해야 합니다.

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.