162306a36Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
262306a36Sopenharmony_ci.. c:namespace:: V4L
362306a36Sopenharmony_ci
462306a36Sopenharmony_ci.. _VIDIOC_QUERYCAP:
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci*********************
762306a36Sopenharmony_ciioctl VIDIOC_QUERYCAP
862306a36Sopenharmony_ci*********************
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ciName
1162306a36Sopenharmony_ci====
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ciVIDIOC_QUERYCAP - Query device capabilities
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ciSynopsis
1662306a36Sopenharmony_ci========
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci.. c:macro:: VIDIOC_QUERYCAP
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci``int ioctl(int fd, VIDIOC_QUERYCAP, struct v4l2_capability *argp)``
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ciArguments
2362306a36Sopenharmony_ci=========
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ci``fd``
2662306a36Sopenharmony_ci    File descriptor returned by :c:func:`open()`.
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci``argp``
2962306a36Sopenharmony_ci    Pointer to struct :c:type:`v4l2_capability`.
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ciDescription
3262306a36Sopenharmony_ci===========
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ciAll V4L2 devices support the ``VIDIOC_QUERYCAP`` ioctl. It is used to
3562306a36Sopenharmony_ciidentify kernel devices compatible with this specification and to obtain
3662306a36Sopenharmony_ciinformation about driver and hardware capabilities. The ioctl takes a
3762306a36Sopenharmony_cipointer to a struct :c:type:`v4l2_capability` which is
3862306a36Sopenharmony_cifilled by the driver. When the driver is not compatible with this
3962306a36Sopenharmony_cispecification the ioctl returns an ``EINVAL`` error code.
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ci.. c:type:: v4l2_capability
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ci.. tabularcolumns:: |p{1.4cm}|p{2.8cm}|p{13.1cm}|
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ci.. cssclass:: longtable
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_ci.. flat-table:: struct v4l2_capability
4862306a36Sopenharmony_ci    :header-rows:  0
4962306a36Sopenharmony_ci    :stub-columns: 0
5062306a36Sopenharmony_ci    :widths:       3 4 20
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ci    * - __u8
5362306a36Sopenharmony_ci      - ``driver``\ [16]
5462306a36Sopenharmony_ci      - Name of the driver, a unique NUL-terminated ASCII string. For
5562306a36Sopenharmony_ci	example: "bttv". Driver specific applications can use this
5662306a36Sopenharmony_ci	information to verify the driver identity. It is also useful to
5762306a36Sopenharmony_ci	work around known bugs, or to identify drivers in error reports.
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ci	Storing strings in fixed sized arrays is bad practice but
6062306a36Sopenharmony_ci	unavoidable here. Drivers and applications should take precautions
6162306a36Sopenharmony_ci	to never read or write beyond the end of the array and to make
6262306a36Sopenharmony_ci	sure the strings are properly NUL-terminated.
6362306a36Sopenharmony_ci    * - __u8
6462306a36Sopenharmony_ci      - ``card``\ [32]
6562306a36Sopenharmony_ci      - Name of the device, a NUL-terminated UTF-8 string. For example:
6662306a36Sopenharmony_ci	"Yoyodyne TV/FM". One driver may support different brands or
6762306a36Sopenharmony_ci	models of video hardware. This information is intended for users,
6862306a36Sopenharmony_ci	for example in a menu of available devices. Since multiple TV
6962306a36Sopenharmony_ci	cards of the same brand may be installed which are supported by
7062306a36Sopenharmony_ci	the same driver, this name should be combined with the character
7162306a36Sopenharmony_ci	device file name (e. g. ``/dev/video2``) or the ``bus_info``
7262306a36Sopenharmony_ci	string to avoid ambiguities.
7362306a36Sopenharmony_ci    * - __u8
7462306a36Sopenharmony_ci      - ``bus_info``\ [32]
7562306a36Sopenharmony_ci      - Location of the device in the system, a NUL-terminated ASCII
7662306a36Sopenharmony_ci	string. For example: "PCI:0000:05:06.0". This information is
7762306a36Sopenharmony_ci	intended for users, to distinguish multiple identical devices. If
7862306a36Sopenharmony_ci	no such information is available the field must simply count the
7962306a36Sopenharmony_ci	devices controlled by the driver ("platform:vivid-000"). The
8062306a36Sopenharmony_ci	bus_info must start with "PCI:" for PCI boards, "PCIe:" for PCI
8162306a36Sopenharmony_ci	Express boards, "usb-" for USB devices, "I2C:" for i2c devices,
8262306a36Sopenharmony_ci	"ISA:" for ISA devices, "parport" for parallel port devices and
8362306a36Sopenharmony_ci	"platform:" for platform devices.
8462306a36Sopenharmony_ci    * - __u32
8562306a36Sopenharmony_ci      - ``version``
8662306a36Sopenharmony_ci      - Version number of the driver.
8762306a36Sopenharmony_ci
8862306a36Sopenharmony_ci	Starting with kernel 3.1, the version reported is provided by the
8962306a36Sopenharmony_ci	V4L2 subsystem following the kernel numbering scheme. However, it
9062306a36Sopenharmony_ci	may not always return the same version as the kernel if, for
9162306a36Sopenharmony_ci	example, a stable or distribution-modified kernel uses the V4L2
9262306a36Sopenharmony_ci	stack from a newer kernel.
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_ci	The version number is formatted using the ``KERNEL_VERSION()``
9562306a36Sopenharmony_ci	macro. For example if the media stack corresponds to the V4L2
9662306a36Sopenharmony_ci	version shipped with Kernel 4.14, it would be equivalent to:
9762306a36Sopenharmony_ci    * - :cspan:`2`
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_ci	``#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))``
10062306a36Sopenharmony_ci
10162306a36Sopenharmony_ci	``__u32 version = KERNEL_VERSION(4, 14, 0);``
10262306a36Sopenharmony_ci
10362306a36Sopenharmony_ci	``printf ("Version: %u.%u.%u\\n",``
10462306a36Sopenharmony_ci
10562306a36Sopenharmony_ci	``(version >> 16) & 0xFF, (version >> 8) & 0xFF, version & 0xFF);``
10662306a36Sopenharmony_ci    * - __u32
10762306a36Sopenharmony_ci      - ``capabilities``
10862306a36Sopenharmony_ci      - Available capabilities of the physical device as a whole, see
10962306a36Sopenharmony_ci	:ref:`device-capabilities`. The same physical device can export
11062306a36Sopenharmony_ci	multiple devices in /dev (e.g. /dev/videoX, /dev/vbiY and
11162306a36Sopenharmony_ci	/dev/radioZ). The ``capabilities`` field should contain a union of
11262306a36Sopenharmony_ci	all capabilities available around the several V4L2 devices
11362306a36Sopenharmony_ci	exported to userspace. For all those devices the ``capabilities``
11462306a36Sopenharmony_ci	field returns the same set of capabilities. This allows
11562306a36Sopenharmony_ci	applications to open just one of the devices (typically the video
11662306a36Sopenharmony_ci	device) and discover whether video, vbi and/or radio are also
11762306a36Sopenharmony_ci	supported.
11862306a36Sopenharmony_ci    * - __u32
11962306a36Sopenharmony_ci      - ``device_caps``
12062306a36Sopenharmony_ci      - Device capabilities of the opened device, see
12162306a36Sopenharmony_ci	:ref:`device-capabilities`. Should contain the available
12262306a36Sopenharmony_ci	capabilities of that specific device node. So, for example,
12362306a36Sopenharmony_ci	``device_caps`` of a radio device will only contain radio related
12462306a36Sopenharmony_ci	capabilities and no video or vbi capabilities. This field is only
12562306a36Sopenharmony_ci	set if the ``capabilities`` field contains the
12662306a36Sopenharmony_ci	``V4L2_CAP_DEVICE_CAPS`` capability. Only the ``capabilities``
12762306a36Sopenharmony_ci	field can have the ``V4L2_CAP_DEVICE_CAPS`` capability,
12862306a36Sopenharmony_ci	``device_caps`` will never set ``V4L2_CAP_DEVICE_CAPS``.
12962306a36Sopenharmony_ci    * - __u32
13062306a36Sopenharmony_ci      - ``reserved``\ [3]
13162306a36Sopenharmony_ci      - Reserved for future extensions. Drivers must set this array to
13262306a36Sopenharmony_ci	zero.
13362306a36Sopenharmony_ci
13462306a36Sopenharmony_ci
13562306a36Sopenharmony_ci.. tabularcolumns:: |p{7.0cm}|p{2.6cm}|p{7.7cm}|
13662306a36Sopenharmony_ci
13762306a36Sopenharmony_ci.. _device-capabilities:
13862306a36Sopenharmony_ci
13962306a36Sopenharmony_ci.. cssclass:: longtable
14062306a36Sopenharmony_ci
14162306a36Sopenharmony_ci.. flat-table:: Device Capabilities Flags
14262306a36Sopenharmony_ci    :header-rows:  0
14362306a36Sopenharmony_ci    :stub-columns: 0
14462306a36Sopenharmony_ci    :widths:       3 1 4
14562306a36Sopenharmony_ci
14662306a36Sopenharmony_ci    * - ``V4L2_CAP_VIDEO_CAPTURE``
14762306a36Sopenharmony_ci      - 0x00000001
14862306a36Sopenharmony_ci      - The device supports the single-planar API through the
14962306a36Sopenharmony_ci	:ref:`Video Capture <capture>` interface.
15062306a36Sopenharmony_ci    * - ``V4L2_CAP_VIDEO_CAPTURE_MPLANE``
15162306a36Sopenharmony_ci      - 0x00001000
15262306a36Sopenharmony_ci      - The device supports the :ref:`multi-planar API <planar-apis>`
15362306a36Sopenharmony_ci	through the :ref:`Video Capture <capture>` interface.
15462306a36Sopenharmony_ci    * - ``V4L2_CAP_VIDEO_OUTPUT``
15562306a36Sopenharmony_ci      - 0x00000002
15662306a36Sopenharmony_ci      - The device supports the single-planar API through the
15762306a36Sopenharmony_ci	:ref:`Video Output <output>` interface.
15862306a36Sopenharmony_ci    * - ``V4L2_CAP_VIDEO_OUTPUT_MPLANE``
15962306a36Sopenharmony_ci      - 0x00002000
16062306a36Sopenharmony_ci      - The device supports the :ref:`multi-planar API <planar-apis>`
16162306a36Sopenharmony_ci	through the :ref:`Video Output <output>` interface.
16262306a36Sopenharmony_ci    * - ``V4L2_CAP_VIDEO_M2M``
16362306a36Sopenharmony_ci      - 0x00008000
16462306a36Sopenharmony_ci      - The device supports the single-planar API through the Video
16562306a36Sopenharmony_ci	Memory-To-Memory interface.
16662306a36Sopenharmony_ci    * - ``V4L2_CAP_VIDEO_M2M_MPLANE``
16762306a36Sopenharmony_ci      - 0x00004000
16862306a36Sopenharmony_ci      - The device supports the :ref:`multi-planar API <planar-apis>`
16962306a36Sopenharmony_ci	through the Video Memory-To-Memory interface.
17062306a36Sopenharmony_ci    * - ``V4L2_CAP_VIDEO_OVERLAY``
17162306a36Sopenharmony_ci      - 0x00000004
17262306a36Sopenharmony_ci      - The device supports the :ref:`Video Overlay <overlay>`
17362306a36Sopenharmony_ci	interface. A video overlay device typically stores captured images
17462306a36Sopenharmony_ci	directly in the video memory of a graphics card, with hardware
17562306a36Sopenharmony_ci	clipping and scaling.
17662306a36Sopenharmony_ci    * - ``V4L2_CAP_VBI_CAPTURE``
17762306a36Sopenharmony_ci      - 0x00000010
17862306a36Sopenharmony_ci      - The device supports the :ref:`Raw VBI Capture <raw-vbi>`
17962306a36Sopenharmony_ci	interface, providing Teletext and Closed Caption data.
18062306a36Sopenharmony_ci    * - ``V4L2_CAP_VBI_OUTPUT``
18162306a36Sopenharmony_ci      - 0x00000020
18262306a36Sopenharmony_ci      - The device supports the :ref:`Raw VBI Output <raw-vbi>`
18362306a36Sopenharmony_ci	interface.
18462306a36Sopenharmony_ci    * - ``V4L2_CAP_SLICED_VBI_CAPTURE``
18562306a36Sopenharmony_ci      - 0x00000040
18662306a36Sopenharmony_ci      - The device supports the :ref:`Sliced VBI Capture <sliced>`
18762306a36Sopenharmony_ci	interface.
18862306a36Sopenharmony_ci    * - ``V4L2_CAP_SLICED_VBI_OUTPUT``
18962306a36Sopenharmony_ci      - 0x00000080
19062306a36Sopenharmony_ci      - The device supports the :ref:`Sliced VBI Output <sliced>`
19162306a36Sopenharmony_ci	interface.
19262306a36Sopenharmony_ci    * - ``V4L2_CAP_RDS_CAPTURE``
19362306a36Sopenharmony_ci      - 0x00000100
19462306a36Sopenharmony_ci      - The device supports the :ref:`RDS <rds>` capture interface.
19562306a36Sopenharmony_ci    * - ``V4L2_CAP_VIDEO_OUTPUT_OVERLAY``
19662306a36Sopenharmony_ci      - 0x00000200
19762306a36Sopenharmony_ci      - The device supports the :ref:`Video Output Overlay <osd>` (OSD)
19862306a36Sopenharmony_ci	interface. Unlike the *Video Overlay* interface, this is a
19962306a36Sopenharmony_ci	secondary function of video output devices and overlays an image
20062306a36Sopenharmony_ci	onto an outgoing video signal. When the driver sets this flag, it
20162306a36Sopenharmony_ci	must clear the ``V4L2_CAP_VIDEO_OVERLAY`` flag and vice
20262306a36Sopenharmony_ci	versa. [#f1]_
20362306a36Sopenharmony_ci    * - ``V4L2_CAP_HW_FREQ_SEEK``
20462306a36Sopenharmony_ci      - 0x00000400
20562306a36Sopenharmony_ci      - The device supports the
20662306a36Sopenharmony_ci	:ref:`VIDIOC_S_HW_FREQ_SEEK` ioctl
20762306a36Sopenharmony_ci	for hardware frequency seeking.
20862306a36Sopenharmony_ci    * - ``V4L2_CAP_RDS_OUTPUT``
20962306a36Sopenharmony_ci      - 0x00000800
21062306a36Sopenharmony_ci      - The device supports the :ref:`RDS <rds>` output interface.
21162306a36Sopenharmony_ci    * - ``V4L2_CAP_TUNER``
21262306a36Sopenharmony_ci      - 0x00010000
21362306a36Sopenharmony_ci      - The device has some sort of tuner to receive RF-modulated video
21462306a36Sopenharmony_ci	signals. For more information about tuner programming see
21562306a36Sopenharmony_ci	:ref:`tuner`.
21662306a36Sopenharmony_ci    * - ``V4L2_CAP_AUDIO``
21762306a36Sopenharmony_ci      - 0x00020000
21862306a36Sopenharmony_ci      - The device has audio inputs or outputs. It may or may not support
21962306a36Sopenharmony_ci	audio recording or playback, in PCM or compressed formats. PCM
22062306a36Sopenharmony_ci	audio support must be implemented as ALSA or OSS interface. For
22162306a36Sopenharmony_ci	more information on audio inputs and outputs see :ref:`audio`.
22262306a36Sopenharmony_ci    * - ``V4L2_CAP_RADIO``
22362306a36Sopenharmony_ci      - 0x00040000
22462306a36Sopenharmony_ci      - This is a radio receiver.
22562306a36Sopenharmony_ci    * - ``V4L2_CAP_MODULATOR``
22662306a36Sopenharmony_ci      - 0x00080000
22762306a36Sopenharmony_ci      - The device has some sort of modulator to emit RF-modulated
22862306a36Sopenharmony_ci	video/audio signals. For more information about modulator
22962306a36Sopenharmony_ci	programming see :ref:`tuner`.
23062306a36Sopenharmony_ci    * - ``V4L2_CAP_SDR_CAPTURE``
23162306a36Sopenharmony_ci      - 0x00100000
23262306a36Sopenharmony_ci      - The device supports the :ref:`SDR Capture <sdr>` interface.
23362306a36Sopenharmony_ci    * - ``V4L2_CAP_EXT_PIX_FORMAT``
23462306a36Sopenharmony_ci      - 0x00200000
23562306a36Sopenharmony_ci      - The device supports the struct
23662306a36Sopenharmony_ci	:c:type:`v4l2_pix_format` extended fields.
23762306a36Sopenharmony_ci    * - ``V4L2_CAP_SDR_OUTPUT``
23862306a36Sopenharmony_ci      - 0x00400000
23962306a36Sopenharmony_ci      - The device supports the :ref:`SDR Output <sdr>` interface.
24062306a36Sopenharmony_ci    * - ``V4L2_CAP_META_CAPTURE``
24162306a36Sopenharmony_ci      - 0x00800000
24262306a36Sopenharmony_ci      - The device supports the :ref:`metadata` capture interface.
24362306a36Sopenharmony_ci    * - ``V4L2_CAP_READWRITE``
24462306a36Sopenharmony_ci      - 0x01000000
24562306a36Sopenharmony_ci      - The device supports the :c:func:`read()` and/or
24662306a36Sopenharmony_ci	:c:func:`write()` I/O methods.
24762306a36Sopenharmony_ci    * - ``V4L2_CAP_STREAMING``
24862306a36Sopenharmony_ci      - 0x04000000
24962306a36Sopenharmony_ci      - The device supports the :ref:`streaming <mmap>` I/O method.
25062306a36Sopenharmony_ci    * - ``V4L2_CAP_META_OUTPUT``
25162306a36Sopenharmony_ci      - 0x08000000
25262306a36Sopenharmony_ci      - The device supports the :ref:`metadata` output interface.
25362306a36Sopenharmony_ci    * - ``V4L2_CAP_TOUCH``
25462306a36Sopenharmony_ci      - 0x10000000
25562306a36Sopenharmony_ci      - This is a touch device.
25662306a36Sopenharmony_ci    * - ``V4L2_CAP_IO_MC``
25762306a36Sopenharmony_ci      - 0x20000000
25862306a36Sopenharmony_ci      - There is only one input and/or output seen from userspace. The whole
25962306a36Sopenharmony_ci        video topology configuration, including which I/O entity is routed to
26062306a36Sopenharmony_ci        the input/output, is configured by userspace via the Media Controller.
26162306a36Sopenharmony_ci        See :ref:`media_controller`.
26262306a36Sopenharmony_ci    * - ``V4L2_CAP_DEVICE_CAPS``
26362306a36Sopenharmony_ci      - 0x80000000
26462306a36Sopenharmony_ci      - The driver fills the ``device_caps`` field. This capability can
26562306a36Sopenharmony_ci	only appear in the ``capabilities`` field and never in the
26662306a36Sopenharmony_ci	``device_caps`` field.
26762306a36Sopenharmony_ci
26862306a36Sopenharmony_ciReturn Value
26962306a36Sopenharmony_ci============
27062306a36Sopenharmony_ci
27162306a36Sopenharmony_ciOn success 0 is returned, on error -1 and the ``errno`` variable is set
27262306a36Sopenharmony_ciappropriately. The generic error codes are described at the
27362306a36Sopenharmony_ci:ref:`Generic Error Codes <gen-errors>` chapter.
27462306a36Sopenharmony_ci
27562306a36Sopenharmony_ci.. [#f1]
27662306a36Sopenharmony_ci   The struct :c:type:`v4l2_framebuffer` lacks an
27762306a36Sopenharmony_ci   enum :c:type:`v4l2_buf_type` field, therefore the
27862306a36Sopenharmony_ci   type of overlay is implied by the driver capabilities.
279