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

Linux 6.18.37 · 사용자 공간 API

VIDIOC_SUBDEV_QUERYCAP ioctl

서브디바이스 호환 장치 식별, 드라이버 버전과 읽기 전용 capability 조회 방법을 설명합니다.

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

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

1. 요약·해설

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

요약·해설

vidioc-subdev-querycap.rst:1-104

QUERYCAP 성공 여부로 V4L2 서브디바이스를 식별하고, 읽기 전용 비트가 있으면 각 상태 변경 ioctl의 TRY·ACTIVE 제한을 개별 문서에서 확인해야 합니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2 .. c:namespace:: V4L
3
4 .. _VIDIOC_SUBDEV_QUERYCAP:
5
6 ****************************
7 ioctl VIDIOC_SUBDEV_QUERYCAP
8 ****************************
9
10 Name
11 ====
12
13 VIDIOC_SUBDEV_QUERYCAP - Query sub-device capabilities
14
15 Synopsis
16 ========
17
18 .. c:macro:: VIDIOC_SUBDEV_QUERYCAP
19
20 ``int ioctl(int fd, VIDIOC_SUBDEV_QUERYCAP, struct v4l2_subdev_capability *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_subdev_capability`.
30
31 Description
32 ===========
33
34 All V4L2 sub-devices support the ``VIDIOC_SUBDEV_QUERYCAP`` ioctl. It is used to
35 identify kernel devices compatible with this specification and to obtain
36 information about driver and hardware capabilities. The ioctl takes a pointer to
37 a struct :c:type:`v4l2_subdev_capability` which is filled by the driver. When
38 the driver is not compatible with this specification the ioctl returns
39 ``ENOTTY`` error code.
40
41 .. tabularcolumns:: |p{1.5cm}|p{2.9cm}|p{12.9cm}|
42
43 .. c:type:: v4l2_subdev_capability
44
45 .. flat-table:: struct v4l2_subdev_capability
46 :header-rows: 0
47 :stub-columns: 0
48 :widths: 3 4 20
49
50 * - __u32
51 - ``version``
52 - Version number of the driver.
53
54 The version reported is provided by the V4L2 subsystem following the
55 kernel numbering scheme. However, it may not always return the same
56 version as the kernel if, for example, a stable or
57 distribution-modified kernel uses the V4L2 stack from a newer kernel.
58
59 The version number is formatted using the ``KERNEL_VERSION()``
60 macro:
61 * - :cspan:`2`
62
63 ``#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))``
64
65 ``__u32 version = KERNEL_VERSION(0, 8, 1);``
66
67 ``printf ("Version: %u.%u.%u\\n",``
68
69 ``(version >> 16) & 0xFF, (version >> 8) & 0xFF, version & 0xFF);``
70 * - __u32
71 - ``capabilities``
72 - Sub-device capabilities of the opened device, see
73 :ref:`subdevice-capabilities`.
74 * - __u32
75 - ``reserved``\ [14]
76 - Reserved for future extensions. Set to 0 by the V4L2 core.
77
78 .. tabularcolumns:: |p{6.8cm}|p{2.4cm}|p{8.1cm}|
79
80 .. _subdevice-capabilities:
81
82 .. cssclass:: longtable
83
84 .. flat-table:: Sub-Device Capabilities Flags
85 :header-rows: 0
86 :stub-columns: 0
87 :widths: 3 1 4
88
89 * - V4L2_SUBDEV_CAP_RO_SUBDEV
90 - 0x00000001
91 - The sub-device device node is registered in read-only mode.
92 Access to the sub-device ioctls that modify the device state is
93 restricted. Refer to each individual subdevice ioctl documentation
94 for a description of which restrictions apply to a read-only sub-device.
95
96 Return Value
97 ============
98
99 On success 0 is returned, on error -1 and the ``errno`` variable is set
100 appropriately. The generic error codes are described at the
101 :ref:`Generic Error Codes <gen-errors>` chapter.
102
103 ENOTTY
104 The device node is not a V4L2 sub-device.
105

3. 한국어 전문 번역

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

목적, 호출 형식과 인자

1-30

`VIDIOC_SUBDEV_QUERYCAP`은 서브디바이스 장치가 이 V4L2 명세와 호환되는지 식별하고 드라이버·하드웨어 capability를 조회합니다. 모든 V4L2 서브디바이스가 지원해야 하며 `argp`는 `struct v4l2_subdev_capability`을 가리킵니다.

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

.. _VIDIOC_SUBDEV_QUERYCAP:

****************************
ioctl VIDIOC_SUBDEV_QUERYCAP
****************************

Name
====

VIDIOC_SUBDEV_QUERYCAP - Query sub-device capabilities

Synopsis
========

.. c:macro:: VIDIOC_SUBDEV_QUERYCAP

``int ioctl(int fd, VIDIOC_SUBDEV_QUERYCAP, struct v4l2_subdev_capability *argp)``

Arguments
=========

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

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

호환 장치 식별

31-40

드라이버는 전달받은 구조체를 채웁니다. 장치 노드의 드라이버가 이 명세와 호환되지 않으면 `ENOTTY`를 반환하므로, ioctl 성공 여부가 V4L2 서브디바이스 식별 절차가 됩니다.

서브디바이스 식별
장치 노드 열기VIDIOC_SUBDEV_QUERYCAP 호출성공하면 version과 capabilities 해석ENOTTY이면 V4L2 서브디바이스가 아님

장치 노드를 열고 QUERYCAP 결과로 종류를 판별합니다.

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

All V4L2 sub-devices support the ``VIDIOC_SUBDEV_QUERYCAP`` ioctl. It is used to
identify kernel devices compatible with this specification and to obtain
information about driver and hardware capabilities. The ioctl takes a pointer to
a struct :c:type:`v4l2_subdev_capability` which is filled by the driver. When
the driver is not compatible with this specification the ioctl returns
``ENOTTY`` error code.

구조체와 드라이버 버전

41-76
struct v4l2_subdev_capability
형식필드의미
`__u32``version`V4L2 subsystem이 제공하는 커널 번호 체계의 드라이버 버전
`__u32``capabilities`열린 서브디바이스의 capability 비트
`__u32[14]``reserved[14]`향후 확장용이며 V4L2 core가 0으로 설정

드라이버 버전과 열린 장치의 capability를 보고합니다.

보고된 `version`은 안정 버전이나 배포판 수정 커널이 더 새 V4L2 stack을 가져온 경우 실행 중인 커널 버전과 다를 수 있습니다. 따라서 이 값은 V4L2 subsystem이 보고하는 드라이버 버전으로 해석해야 합니다.

KERNEL_VERSION 비트 배치
요소비트추출식
major `a`23..16`(version >> 16) & 0xFF`
minor `b`15..8`(version >> 8) & 0xFF`
patch `c`7..0`version & 0xFF`

`KERNEL_VERSION(a,b,c)`가 32비트 값에 버전 요소를 넣는 위치입니다.

.. tabularcolumns:: |p{1.5cm}|p{2.9cm}|p{12.9cm}|

.. c:type:: v4l2_subdev_capability

.. flat-table:: struct v4l2_subdev_capability
    :header-rows:  0
    :stub-columns: 0
    :widths:       3 4 20

    * - __u32
      - ``version``
      - Version number of the driver.

	The version reported is provided by the V4L2 subsystem following the
	kernel numbering scheme. However, it may not always return the same
	version as the kernel if, for example, a stable or
	distribution-modified kernel uses the V4L2 stack from a newer kernel.

	The version number is formatted using the ``KERNEL_VERSION()``
	macro:
    * - :cspan:`2`

	``#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))``

	``__u32 version = KERNEL_VERSION(0, 8, 1);``

	``printf ("Version: %u.%u.%u\\n",``

	``(version >> 16) & 0xFF, (version >> 8) & 0xFF, version & 0xFF);``
    * - __u32
      - ``capabilities``
      - Sub-device capabilities of the opened device, see
	:ref:`subdevice-capabilities`.
    * - __u32
      - ``reserved``\ [14]
      - Reserved for future extensions. Set to 0 by the V4L2 core.

서브디바이스 capability

77-95
Sub-Device Capabilities Flags
상수의미
`V4L2_SUBDEV_CAP_RO_SUBDEV``0x00000001`서브디바이스 노드가 읽기 전용으로 등록되어 상태 변경 ioctl 접근이 제한됨

현재 정의된 읽기 전용 장치 노드 비트입니다.

읽기 전용 노드에서 어떤 제한이 적용되는지는 각 서브디바이스 ioctl 문서가 정의합니다. 일반적으로 TRY 상태 조회·협상은 허용될 수 있지만 ACTIVE 상태 변경은 제한됩니다.


.. tabularcolumns:: |p{6.8cm}|p{2.4cm}|p{8.1cm}|

.. _subdevice-capabilities:

.. cssclass:: longtable

.. flat-table:: Sub-Device Capabilities Flags
    :header-rows:  0
    :stub-columns: 0
    :widths:       3 1 4

    * - V4L2_SUBDEV_CAP_RO_SUBDEV
      - 0x00000001
      - The sub-device device node is registered in read-only mode.
	Access to the sub-device ioctls that modify the device state is
	restricted. Refer to each individual subdevice ioctl documentation
	for a description of which restrictions apply to a read-only sub-device.

반환값과 ENOTTY

96-104

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

QUERYCAP 전용 오류
errno조건
`ENOTTY`장치 노드가 V4L2 서브디바이스가 아님

장치 노드 종류를 판별하는 오류입니다.

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.

ENOTTY
    The device node is not a V4L2 sub-device.