← Documents Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst GitHub 원문 ↗

Linux 6.18.37 · 사용자 공간 API

VIDIOC_SUBDEV_G_ROUTING 및 VIDIOC_SUBDEV_S_ROUTING ioctl

서브디바이스 내부 sink·source stream 라우팅의 조회·설정, 배열 크기 협상과 재구성 의무를 설명합니다.

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

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

1. 요약·해설

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

요약·해설

vidioc-subdev-g-routing.rst:1-164

S_ROUTING은 stream 구성을 모두 초기화하므로 route 적용 자체보다 이후 format과 selection을 빠짐없이 다시 설정하는 절차가 더 중요합니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2 .. c:namespace:: V4L
3
4 .. _VIDIOC_SUBDEV_G_ROUTING:
5
6 ******************************************************
7 ioctl VIDIOC_SUBDEV_G_ROUTING, VIDIOC_SUBDEV_S_ROUTING
8 ******************************************************
9
10 Name
11 ====
12
13 VIDIOC_SUBDEV_G_ROUTING - VIDIOC_SUBDEV_S_ROUTING - Get or set routing between streams of media pads in a media entity.
14
15
16 Synopsis
17 ========
18
19 .. c:macro:: VIDIOC_SUBDEV_G_ROUTING
20
21 ``int ioctl(int fd, VIDIOC_SUBDEV_G_ROUTING, struct v4l2_subdev_routing *argp)``
22
23 .. c:macro:: VIDIOC_SUBDEV_S_ROUTING
24
25 ``int ioctl(int fd, VIDIOC_SUBDEV_S_ROUTING, struct v4l2_subdev_routing *argp)``
26
27 Arguments
28 =========
29
30 ``fd``
31 File descriptor returned by :ref:`open() <func-open>`.
32
33 ``argp``
34 Pointer to struct :c:type:`v4l2_subdev_routing`.
35
36
37 Description
38 ===========
39
40 These ioctls are used to get and set the routing in a media entity.
41 The routing configuration determines the flows of data inside an entity.
42
43 Drivers report their current routing tables using the
44 ``VIDIOC_SUBDEV_G_ROUTING`` ioctl and application may enable or disable routes
45 with the ``VIDIOC_SUBDEV_S_ROUTING`` ioctl, by adding or removing routes and
46 setting or clearing flags of the ``flags`` field of a struct
47 :c:type:`v4l2_subdev_route`. Similarly to ``VIDIOC_SUBDEV_G_ROUTING``, also
48 ``VIDIOC_SUBDEV_S_ROUTING`` returns the routes back to the user.
49
50 All stream configurations are reset when ``VIDIOC_SUBDEV_S_ROUTING`` is called.
51 This means that the userspace must reconfigure all stream formats and selections
52 after calling the ioctl with e.g. ``VIDIOC_SUBDEV_S_FMT``.
53
54 Only subdevices which have both sink and source pads can support routing.
55
56 The ``len_routes`` field indicates the number of routes that can fit in the
57 ``routes`` array allocated by userspace. It is set by applications for both
58 ioctls to indicate how many routes the kernel can return, and is never modified
59 by the kernel.
60
61 The ``num_routes`` field indicates the number of routes in the routing
62 table. For ``VIDIOC_SUBDEV_S_ROUTING``, it is set by userspace to the number of
63 routes that the application stored in the ``routes`` array. For both ioctls, it
64 is returned by the kernel and indicates how many routes are stored in the
65 subdevice routing table. This may be smaller or larger than the value of
66 ``num_routes`` set by the application for ``VIDIOC_SUBDEV_S_ROUTING``, as
67 drivers may adjust the requested routing table.
68
69 The kernel can return a ``num_routes`` value larger than ``len_routes`` from
70 both ioctls. This indicates thare are more routes in the routing table than fits
71 the ``routes`` array. In this case, the ``routes`` array is filled by the kernel
72 with the first ``len_routes`` entries of the subdevice routing table. This is
73 not considered to be an error, and the ioctl call succeeds. If the applications
74 wants to retrieve the missing routes, it can issue a new
75 ``VIDIOC_SUBDEV_G_ROUTING`` call with a large enough ``routes`` array.
76
77 ``VIDIOC_SUBDEV_S_ROUTING`` may return more routes than the user provided in
78 ``num_routes`` field due to e.g. hardware properties.
79
80 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
81
82 .. c:type:: v4l2_subdev_routing
83
84 .. flat-table:: struct v4l2_subdev_routing
85 :header-rows: 0
86 :stub-columns: 0
87 :widths: 1 1 2
88
89 * - __u32
90 - ``which``
91 - Routing table to be accessed, from enum
92 :ref:`v4l2_subdev_format_whence <v4l2-subdev-format-whence>`.
93 * - __u32
94 - ``len_routes``
95 - The length of the array (as in memory reserved for the array)
96 * - struct :c:type:`v4l2_subdev_route`
97 - ``routes[]``
98 - Array of struct :c:type:`v4l2_subdev_route` entries
99 * - __u32
100 - ``num_routes``
101 - Number of entries of the routes array
102 * - __u32
103 - ``reserved``\ [11]
104 - Reserved for future extensions. Applications and drivers must set
105 the array to zero.
106
107 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
108
109 .. c:type:: v4l2_subdev_route
110
111 .. flat-table:: struct v4l2_subdev_route
112 :header-rows: 0
113 :stub-columns: 0
114 :widths: 1 1 2
115
116 * - __u32
117 - ``sink_pad``
118 - Sink pad number.
119 * - __u32
120 - ``sink_stream``
121 - Sink pad stream number.
122 * - __u32
123 - ``source_pad``
124 - Source pad number.
125 * - __u32
126 - ``source_stream``
127 - Source pad stream number.
128 * - __u32
129 - ``flags``
130 - Route enable/disable flags
131 :ref:`v4l2_subdev_routing_flags <v4l2-subdev-routing-flags>`.
132 * - __u32
133 - ``reserved``\ [5]
134 - Reserved for future extensions. Applications and drivers must set
135 the array to zero.
136
137 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
138
139 .. _v4l2-subdev-routing-flags:
140
141 .. flat-table:: enum v4l2_subdev_routing_flags
142 :header-rows: 0
143 :stub-columns: 0
144 :widths: 3 1 4
145
146 * - V4L2_SUBDEV_ROUTE_FL_ACTIVE
147 - 0x0001
148 - The route is enabled. Set by applications.
149
150 Return Value
151 ============
152
153 On success 0 is returned, on error -1 and the ``errno`` variable is set
154 appropriately. The generic error codes are described at the
155 :ref:`Generic Error Codes <gen-errors>` chapter.
156
157 EINVAL
158 The sink or source pad identifiers reference a non-existing pad or reference
159 pads of different types (ie. the sink_pad identifiers refers to a source
160 pad), or the ``which`` field has an unsupported value.
161
162 E2BIG
163 The application provided ``num_routes`` for ``VIDIOC_SUBDEV_S_ROUTING`` is
164 larger than the number of routes the driver can handle.
165

3. 한국어 전문 번역

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

목적, 호출 형식과 인자

1-36

`VIDIOC_SUBDEV_G_ROUTING`과 `VIDIOC_SUBDEV_S_ROUTING`은 미디어 엔티티의 pad stream 사이 라우팅을 조회하거나 설정합니다. 라우팅 구성은 엔티티 내부 데이터 흐름을 결정하며 `argp`는 `struct v4l2_subdev_routing`을 가리킵니다.

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

.. _VIDIOC_SUBDEV_G_ROUTING:

******************************************************
ioctl VIDIOC_SUBDEV_G_ROUTING, VIDIOC_SUBDEV_S_ROUTING
******************************************************

Name
====

VIDIOC_SUBDEV_G_ROUTING - VIDIOC_SUBDEV_S_ROUTING - Get or set routing between streams of media pads in a media entity.


Synopsis
========

.. c:macro:: VIDIOC_SUBDEV_G_ROUTING

``int ioctl(int fd, VIDIOC_SUBDEV_G_ROUTING, struct v4l2_subdev_routing *argp)``

.. c:macro:: VIDIOC_SUBDEV_S_ROUTING

``int ioctl(int fd, VIDIOC_SUBDEV_S_ROUTING, struct v4l2_subdev_routing *argp)``

Arguments
=========

``fd``
    File descriptor returned by :ref:`open() <func-open>`.

``argp``
    Pointer to struct :c:type:`v4l2_subdev_routing`.

라우팅 설정, 초기화와 배열 크기

37-78

G_ROUTING은 현재 라우팅 테이블을 보고합니다. S_ROUTING은 `struct v4l2_subdev_route` 항목을 추가·제거하고 `flags` 비트를 설정하거나 지워 route를 활성화·비활성화하며, 적용 뒤의 route 목록을 다시 사용자 공간에 반환합니다.

S_ROUTING을 호출하면 모든 stream 구성이 초기화됩니다. 사용자 공간은 호출 뒤 `VIDIOC_SUBDEV_S_FMT` 등을 사용해 모든 stream format과 selection을 다시 구성해야 합니다.

sink pad와 source pad를 모두 가진 서브디바이스만 routing을 지원할 수 있습니다.

`len_routes`는 사용자 공간이 할당한 `routes` 배열에 들어갈 항목 수입니다. 두 ioctl 모두 응용 프로그램이 설정하며 커널은 이 필드를 변경하지 않습니다.

`num_routes`는 라우팅 테이블의 실제 route 수입니다. S_ROUTING 입력에서는 배열에 넣은 요청 항목 수이고, 두 ioctl의 출력에서는 드라이버가 조정한 뒤 서브디바이스 테이블에 저장된 route 수입니다. 하드웨어 제약 때문에 입력보다 작거나 클 수 있습니다.

커널이 `len_routes`보다 큰 `num_routes`를 반환해도 오류가 아닙니다. 배열에는 앞의 `len_routes`개만 채워지고 ioctl은 성공합니다. 나머지를 얻으려면 더 큰 배열로 G_ROUTING을 다시 호출해야 합니다.

안전한 라우팅 조회와 설정
routes 배열을 할당하고 len_routes 설정G_ROUTING 또는 S_ROUTING 호출반환된 num_routes와 len_routes 비교num_routes가 더 크면 큰 배열로 G_ROUTING 재호출S_ROUTING 뒤 모든 stream format과 selection 재설정

배열 용량과 실제 route 수를 분리해 처리합니다.

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

These ioctls are used to get and set the routing in a media entity.
The routing configuration determines the flows of data inside an entity.

Drivers report their current routing tables using the
``VIDIOC_SUBDEV_G_ROUTING`` ioctl and application may enable or disable routes
with the ``VIDIOC_SUBDEV_S_ROUTING`` ioctl, by adding or removing routes and
setting or clearing flags of the ``flags`` field of a struct
:c:type:`v4l2_subdev_route`. Similarly to ``VIDIOC_SUBDEV_G_ROUTING``, also
``VIDIOC_SUBDEV_S_ROUTING`` returns the routes back to the user.

All stream configurations are reset when ``VIDIOC_SUBDEV_S_ROUTING`` is called.
This means that the userspace must reconfigure all stream formats and selections
after calling the ioctl with e.g. ``VIDIOC_SUBDEV_S_FMT``.

Only subdevices which have both sink and source pads can support routing.

The ``len_routes`` field indicates the number of routes that can fit in the
``routes`` array allocated by userspace. It is set by applications for both
ioctls to indicate how many routes the kernel can return, and is never modified
by the kernel.

The ``num_routes`` field indicates the number of routes in the routing
table. For ``VIDIOC_SUBDEV_S_ROUTING``, it is set by userspace to the number of
routes that the application stored in the ``routes`` array. For both ioctls, it
is returned by the kernel and indicates how many routes are stored in the
subdevice routing table. This may be smaller or larger than the value of
``num_routes`` set by the application for ``VIDIOC_SUBDEV_S_ROUTING``, as
drivers may adjust the requested routing table.

The kernel can return a ``num_routes`` value larger than ``len_routes`` from
both ioctls. This indicates thare are more routes in the routing table than fits
the ``routes`` array. In this case, the ``routes`` array is filled by the kernel
with the first ``len_routes`` entries of the subdevice routing table. This is
not considered to be an error, and the ioctl call succeeds. If the applications
wants to retrieve the missing routes, it can issue a new
``VIDIOC_SUBDEV_G_ROUTING`` call with a large enough ``routes`` array.

``VIDIOC_SUBDEV_S_ROUTING`` may return more routes than the user provided in
``num_routes`` field due to e.g. hardware properties.

라우팅과 route 구조체

79-149
struct v4l2_subdev_routing
형식필드의미
`__u32``which``v4l2_subdev_format_whence`에 따른 접근할 라우팅 테이블
`__u32``len_routes`사용자 공간이 확보한 routes 배열 용량
`struct v4l2_subdev_route[]``routes[]`route 항목 배열
`__u32``num_routes`요청 또는 실제 테이블의 route 수
`__u32[11]``reserved[11]`향후 확장용이며 응용 프로그램과 드라이버가 모두 0으로 설정

라우팅 테이블 상태와 사용자 배열을 연결합니다.

struct v4l2_subdev_route
형식필드의미
`__u32``sink_pad`sink pad 번호
`__u32``sink_stream`sink pad의 stream 번호
`__u32``source_pad`source pad 번호
`__u32``source_stream`source pad의 stream 번호
`__u32``flags`route 활성화·비활성화 flags
`__u32[5]``reserved[5]`향후 확장용이며 응용 프로그램과 드라이버가 모두 0으로 설정

sink stream에서 source stream으로 이어지는 한 route를 표현합니다.

v4l2_subdev_routing_flags
상수의미
`V4L2_SUBDEV_ROUTE_FL_ACTIVE``0x0001`응용 프로그램이 설정하며 route가 활성화됨

현재 정의된 활성 route 비트입니다.


.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|

.. c:type:: v4l2_subdev_routing

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

    * - __u32
      - ``which``
      - Routing table to be accessed, from enum
        :ref:`v4l2_subdev_format_whence <v4l2-subdev-format-whence>`.
    * - __u32
      - ``len_routes``
      - The length of the array (as in memory reserved for the array)
    * - struct :c:type:`v4l2_subdev_route`
      - ``routes[]``
      - Array of struct :c:type:`v4l2_subdev_route` entries
    * - __u32
      - ``num_routes``
      - Number of entries of the routes array
    * - __u32
      - ``reserved``\ [11]
      - Reserved for future extensions. Applications and drivers must set
	the array to zero.

.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|

.. c:type:: v4l2_subdev_route

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

    * - __u32
      - ``sink_pad``
      - Sink pad number.
    * - __u32
      - ``sink_stream``
      - Sink pad stream number.
    * - __u32
      - ``source_pad``
      - Source pad number.
    * - __u32
      - ``source_stream``
      - Source pad stream number.
    * - __u32
      - ``flags``
      - Route enable/disable flags
	:ref:`v4l2_subdev_routing_flags <v4l2-subdev-routing-flags>`.
    * - __u32
      - ``reserved``\ [5]
      - Reserved for future extensions. Applications and drivers must set
	the array to zero.

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

.. _v4l2-subdev-routing-flags:

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

    * - V4L2_SUBDEV_ROUTE_FL_ACTIVE
      - 0x0001
      - The route is enabled. Set by applications.

반환값과 오류

150-164

성공하면 0, 오류이면 -1을 반환하고 `errno`를 설정합니다.

Routing ioctl 오류
errno조건
`EINVAL`sink 또는 source pad가 없거나 pad 방향이 뒤바뀌었거나 which 값이 지원되지 않음
`E2BIG`S_ROUTING의 입력 `num_routes`가 드라이버가 처리할 수 있는 route 수보다 큼

pad 방향과 드라이버 route 용량을 검증합니다.

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 sink or source pad identifiers reference a non-existing pad or reference
   pads of different types (ie. the sink_pad identifiers refers to a source
   pad), or the ``which`` field has an unsupported value.

E2BIG
   The application provided ``num_routes`` for ``VIDIOC_SUBDEV_S_ROUTING`` is
   larger than the number of routes the driver can handle.