0001 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
0002 .. c:namespace:: V4L
0003
0004 .. _VIDIOC_QUERYCAP:
0005
0006 *********************
0007 ioctl VIDIOC_QUERYCAP
0008 *********************
0009
0010 Name
0011 ====
0012
0013 VIDIOC_QUERYCAP - Query device capabilities
0014
0015 Synopsis
0016 ========
0017
0018 .. c:macro:: VIDIOC_QUERYCAP
0019
0020 ``int ioctl(int fd, VIDIOC_QUERYCAP, struct v4l2_capability *argp)``
0021
0022 Arguments
0023 =========
0024
0025 ``fd``
0026 File descriptor returned by :c:func:`open()`.
0027
0028 ``argp``
0029 Pointer to struct :c:type:`v4l2_capability`.
0030
0031 Description
0032 ===========
0033
0034 All V4L2 devices support the ``VIDIOC_QUERYCAP`` ioctl. It is used to
0035 identify kernel devices compatible with this specification and to obtain
0036 information about driver and hardware capabilities. The ioctl takes a
0037 pointer to a struct :c:type:`v4l2_capability` which is
0038 filled by the driver. When the driver is not compatible with this
0039 specification the ioctl returns an ``EINVAL`` error code.
0040
0041 .. c:type:: v4l2_capability
0042
0043 .. tabularcolumns:: |p{1.4cm}|p{2.8cm}|p{13.1cm}|
0044
0045 .. cssclass:: longtable
0046
0047 .. flat-table:: struct v4l2_capability
0048 :header-rows: 0
0049 :stub-columns: 0
0050 :widths: 3 4 20
0051
0052 * - __u8
0053 - ``driver``\ [16]
0054 - Name of the driver, a unique NUL-terminated ASCII string. For
0055 example: "bttv". Driver specific applications can use this
0056 information to verify the driver identity. It is also useful to
0057 work around known bugs, or to identify drivers in error reports.
0058
0059 Storing strings in fixed sized arrays is bad practice but
0060 unavoidable here. Drivers and applications should take precautions
0061 to never read or write beyond the end of the array and to make
0062 sure the strings are properly NUL-terminated.
0063 * - __u8
0064 - ``card``\ [32]
0065 - Name of the device, a NUL-terminated UTF-8 string. For example:
0066 "Yoyodyne TV/FM". One driver may support different brands or
0067 models of video hardware. This information is intended for users,
0068 for example in a menu of available devices. Since multiple TV
0069 cards of the same brand may be installed which are supported by
0070 the same driver, this name should be combined with the character
0071 device file name (e. g. ``/dev/video2``) or the ``bus_info``
0072 string to avoid ambiguities.
0073 * - __u8
0074 - ``bus_info``\ [32]
0075 - Location of the device in the system, a NUL-terminated ASCII
0076 string. For example: "PCI:0000:05:06.0". This information is
0077 intended for users, to distinguish multiple identical devices. If
0078 no such information is available the field must simply count the
0079 devices controlled by the driver ("platform:vivid-000"). The
0080 bus_info must start with "PCI:" for PCI boards, "PCIe:" for PCI
0081 Express boards, "usb-" for USB devices, "I2C:" for i2c devices,
0082 "ISA:" for ISA devices, "parport" for parallel port devices and
0083 "platform:" for platform devices.
0084 * - __u32
0085 - ``version``
0086 - Version number of the driver.
0087
0088 Starting with kernel 3.1, the version reported is provided by the
0089 V4L2 subsystem following the kernel numbering scheme. However, it
0090 may not always return the same version as the kernel if, for
0091 example, a stable or distribution-modified kernel uses the V4L2
0092 stack from a newer kernel.
0093
0094 The version number is formatted using the ``KERNEL_VERSION()``
0095 macro. For example if the media stack corresponds to the V4L2
0096 version shipped with Kernel 4.14, it would be equivalent to:
0097 * - :cspan:`2`
0098
0099 ``#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))``
0100
0101 ``__u32 version = KERNEL_VERSION(4, 14, 0);``
0102
0103 ``printf ("Version: %u.%u.%u\\n",``
0104
0105 ``(version >> 16) & 0xFF, (version >> 8) & 0xFF, version & 0xFF);``
0106 * - __u32
0107 - ``capabilities``
0108 - Available capabilities of the physical device as a whole, see
0109 :ref:`device-capabilities`. The same physical device can export
0110 multiple devices in /dev (e.g. /dev/videoX, /dev/vbiY and
0111 /dev/radioZ). The ``capabilities`` field should contain a union of
0112 all capabilities available around the several V4L2 devices
0113 exported to userspace. For all those devices the ``capabilities``
0114 field returns the same set of capabilities. This allows
0115 applications to open just one of the devices (typically the video
0116 device) and discover whether video, vbi and/or radio are also
0117 supported.
0118 * - __u32
0119 - ``device_caps``
0120 - Device capabilities of the opened device, see
0121 :ref:`device-capabilities`. Should contain the available
0122 capabilities of that specific device node. So, for example,
0123 ``device_caps`` of a radio device will only contain radio related
0124 capabilities and no video or vbi capabilities. This field is only
0125 set if the ``capabilities`` field contains the
0126 ``V4L2_CAP_DEVICE_CAPS`` capability. Only the ``capabilities``
0127 field can have the ``V4L2_CAP_DEVICE_CAPS`` capability,
0128 ``device_caps`` will never set ``V4L2_CAP_DEVICE_CAPS``.
0129 * - __u32
0130 - ``reserved``\ [3]
0131 - Reserved for future extensions. Drivers must set this array to
0132 zero.
0133
0134
0135 .. tabularcolumns:: |p{7.0cm}|p{2.6cm}|p{7.7cm}|
0136
0137 .. _device-capabilities:
0138
0139 .. cssclass:: longtable
0140
0141 .. flat-table:: Device Capabilities Flags
0142 :header-rows: 0
0143 :stub-columns: 0
0144 :widths: 3 1 4
0145
0146 * - ``V4L2_CAP_VIDEO_CAPTURE``
0147 - 0x00000001
0148 - The device supports the single-planar API through the
0149 :ref:`Video Capture <capture>` interface.
0150 * - ``V4L2_CAP_VIDEO_CAPTURE_MPLANE``
0151 - 0x00001000
0152 - The device supports the :ref:`multi-planar API <planar-apis>`
0153 through the :ref:`Video Capture <capture>` interface.
0154 * - ``V4L2_CAP_VIDEO_OUTPUT``
0155 - 0x00000002
0156 - The device supports the single-planar API through the
0157 :ref:`Video Output <output>` interface.
0158 * - ``V4L2_CAP_VIDEO_OUTPUT_MPLANE``
0159 - 0x00002000
0160 - The device supports the :ref:`multi-planar API <planar-apis>`
0161 through the :ref:`Video Output <output>` interface.
0162 * - ``V4L2_CAP_VIDEO_M2M``
0163 - 0x00008000
0164 - The device supports the single-planar API through the Video
0165 Memory-To-Memory interface.
0166 * - ``V4L2_CAP_VIDEO_M2M_MPLANE``
0167 - 0x00004000
0168 - The device supports the :ref:`multi-planar API <planar-apis>`
0169 through the Video Memory-To-Memory interface.
0170 * - ``V4L2_CAP_VIDEO_OVERLAY``
0171 - 0x00000004
0172 - The device supports the :ref:`Video Overlay <overlay>`
0173 interface. A video overlay device typically stores captured images
0174 directly in the video memory of a graphics card, with hardware
0175 clipping and scaling.
0176 * - ``V4L2_CAP_VBI_CAPTURE``
0177 - 0x00000010
0178 - The device supports the :ref:`Raw VBI Capture <raw-vbi>`
0179 interface, providing Teletext and Closed Caption data.
0180 * - ``V4L2_CAP_VBI_OUTPUT``
0181 - 0x00000020
0182 - The device supports the :ref:`Raw VBI Output <raw-vbi>`
0183 interface.
0184 * - ``V4L2_CAP_SLICED_VBI_CAPTURE``
0185 - 0x00000040
0186 - The device supports the :ref:`Sliced VBI Capture <sliced>`
0187 interface.
0188 * - ``V4L2_CAP_SLICED_VBI_OUTPUT``
0189 - 0x00000080
0190 - The device supports the :ref:`Sliced VBI Output <sliced>`
0191 interface.
0192 * - ``V4L2_CAP_RDS_CAPTURE``
0193 - 0x00000100
0194 - The device supports the :ref:`RDS <rds>` capture interface.
0195 * - ``V4L2_CAP_VIDEO_OUTPUT_OVERLAY``
0196 - 0x00000200
0197 - The device supports the :ref:`Video Output Overlay <osd>` (OSD)
0198 interface. Unlike the *Video Overlay* interface, this is a
0199 secondary function of video output devices and overlays an image
0200 onto an outgoing video signal. When the driver sets this flag, it
0201 must clear the ``V4L2_CAP_VIDEO_OVERLAY`` flag and vice
0202 versa. [#f1]_
0203 * - ``V4L2_CAP_HW_FREQ_SEEK``
0204 - 0x00000400
0205 - The device supports the
0206 :ref:`VIDIOC_S_HW_FREQ_SEEK` ioctl
0207 for hardware frequency seeking.
0208 * - ``V4L2_CAP_RDS_OUTPUT``
0209 - 0x00000800
0210 - The device supports the :ref:`RDS <rds>` output interface.
0211 * - ``V4L2_CAP_TUNER``
0212 - 0x00010000
0213 - The device has some sort of tuner to receive RF-modulated video
0214 signals. For more information about tuner programming see
0215 :ref:`tuner`.
0216 * - ``V4L2_CAP_AUDIO``
0217 - 0x00020000
0218 - The device has audio inputs or outputs. It may or may not support
0219 audio recording or playback, in PCM or compressed formats. PCM
0220 audio support must be implemented as ALSA or OSS interface. For
0221 more information on audio inputs and outputs see :ref:`audio`.
0222 * - ``V4L2_CAP_RADIO``
0223 - 0x00040000
0224 - This is a radio receiver.
0225 * - ``V4L2_CAP_MODULATOR``
0226 - 0x00080000
0227 - The device has some sort of modulator to emit RF-modulated
0228 video/audio signals. For more information about modulator
0229 programming see :ref:`tuner`.
0230 * - ``V4L2_CAP_SDR_CAPTURE``
0231 - 0x00100000
0232 - The device supports the :ref:`SDR Capture <sdr>` interface.
0233 * - ``V4L2_CAP_EXT_PIX_FORMAT``
0234 - 0x00200000
0235 - The device supports the struct
0236 :c:type:`v4l2_pix_format` extended fields.
0237 * - ``V4L2_CAP_SDR_OUTPUT``
0238 - 0x00400000
0239 - The device supports the :ref:`SDR Output <sdr>` interface.
0240 * - ``V4L2_CAP_META_CAPTURE``
0241 - 0x00800000
0242 - The device supports the :ref:`metadata` capture interface.
0243 * - ``V4L2_CAP_READWRITE``
0244 - 0x01000000
0245 - The device supports the :c:func:`read()` and/or
0246 :c:func:`write()` I/O methods.
0247 * - ``V4L2_CAP_ASYNCIO``
0248 - 0x02000000
0249 - The device supports the :ref:`asynchronous <async>` I/O methods.
0250 * - ``V4L2_CAP_STREAMING``
0251 - 0x04000000
0252 - The device supports the :ref:`streaming <mmap>` I/O method.
0253 * - ``V4L2_CAP_META_OUTPUT``
0254 - 0x08000000
0255 - The device supports the :ref:`metadata` output interface.
0256 * - ``V4L2_CAP_TOUCH``
0257 - 0x10000000
0258 - This is a touch device.
0259 * - ``V4L2_CAP_IO_MC``
0260 - 0x20000000
0261 - There is only one input and/or output seen from userspace. The whole
0262 video topology configuration, including which I/O entity is routed to
0263 the input/output, is configured by userspace via the Media Controller.
0264 See :ref:`media_controller`.
0265 * - ``V4L2_CAP_DEVICE_CAPS``
0266 - 0x80000000
0267 - The driver fills the ``device_caps`` field. This capability can
0268 only appear in the ``capabilities`` field and never in the
0269 ``device_caps`` field.
0270
0271 Return Value
0272 ============
0273
0274 On success 0 is returned, on error -1 and the ``errno`` variable is set
0275 appropriately. The generic error codes are described at the
0276 :ref:`Generic Error Codes <gen-errors>` chapter.
0277
0278 .. [#f1]
0279 The struct :c:type:`v4l2_framebuffer` lacks an
0280 enum :c:type:`v4l2_buf_type` field, therefore the
0281 type of overlay is implied by the driver capabilities.