vidioc-querycap.rst 10.6 KB
Newer Older
1 2
.. -*- coding: utf-8; mode: rst -*-

3
.. _VIDIOC_QUERYCAP:
4 5 6 7 8

*********************
ioctl VIDIOC_QUERYCAP
*********************

9
Name
10
====
11

12
VIDIOC_QUERYCAP - Query device capabilities
13

14 15

Synopsis
16 17
========

18 19
.. c:function:: int ioctl( int fd, VIDIOC_QUERYCAP, struct v4l2_capability *argp )
    :name: VIDIOC_QUERYCAP
20

21

22
Arguments
23 24 25 26 27 28 29 30
=========

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

``argp``


31
Description
32 33 34 35 36 37 38
===========

All V4L2 devices support the ``VIDIOC_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 :ref:`v4l2_capability <v4l2-capability>` which is
filled by the driver. When the driver is not compatible with this
39
specification the ioctl returns an ``EINVAL`` error code.
40 41


42 43
.. tabularcolumns:: |p{1.5cm}|p{2.5cm}|p{13cm}|

44 45
.. _v4l2-capability:

46 47 48
.. flat-table:: struct v4l2_capability
    :header-rows:  0
    :stub-columns: 0
49
    :widths:       3 4 20
50 51 52 53 54

    -  .. row 1

       -  __u8

55
       -  ``driver``\ [16]
56 57

       -  Name of the driver, a unique NUL-terminated ASCII string. For
58 59 60
	  example: "bttv". Driver specific applications can use this
	  information to verify the driver identity. It is also useful to
	  work around known bugs, or to identify drivers in error reports.
61

62 63 64 65
	  Storing strings in fixed sized arrays is bad practice but
	  unavoidable here. Drivers and applications should take precautions
	  to never read or write beyond the end of the array and to make
	  sure the strings are properly NUL-terminated.
66 67 68 69 70

    -  .. row 2

       -  __u8

71
       -  ``card``\ [32]
72 73

       -  Name of the device, a NUL-terminated UTF-8 string. For example:
74 75 76 77 78 79 80
	  "Yoyodyne TV/FM". One driver may support different brands or
	  models of video hardware. This information is intended for users,
	  for example in a menu of available devices. Since multiple TV
	  cards of the same brand may be installed which are supported by
	  the same driver, this name should be combined with the character
	  device file name (e. g. ``/dev/video2``) or the ``bus_info``
	  string to avoid ambiguities.
81 82 83 84 85

    -  .. row 3

       -  __u8

86
       -  ``bus_info``\ [32]
87 88

       -  Location of the device in the system, a NUL-terminated ASCII
89 90 91 92 93 94 95 96
	  string. For example: "PCI:0000:05:06.0". This information is
	  intended for users, to distinguish multiple identical devices. If
	  no such information is available the field must simply count the
	  devices controlled by the driver ("platform:vivi-000"). The
	  bus_info must start with "PCI:" for PCI boards, "PCIe:" for PCI
	  Express boards, "usb-" for USB devices, "I2C:" for i2c devices,
	  "ISA:" for ISA devices, "parport" for parallel port devices and
	  "platform:" for platform devices.
97 98 99 100 101 102 103 104 105

    -  .. row 4

       -  __u32

       -  ``version``

       -  Version number of the driver.

106 107 108 109 110
	  Starting with kernel 3.1, 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.
111

112 113
	  The version number is formatted using the ``KERNEL_VERSION()``
	  macro:
114 115 116 117 118

    -  .. row 5

       -  :cspan:`2`

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

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

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

	  ``(version >> 16) & 0xFF, (version >> 8) & 0xFF, version & 0xFF);``
126 127 128 129 130 131 132 133

    -  .. row 6

       -  __u32

       -  ``capabilities``

       -  Available capabilities of the physical device as a whole, see
134 135 136 137 138 139 140 141 142
	  :ref:`device-capabilities`. The same physical device can export
	  multiple devices in /dev (e.g. /dev/videoX, /dev/vbiY and
	  /dev/radioZ). The ``capabilities`` field should contain a union of
	  all capabilities available around the several V4L2 devices
	  exported to userspace. For all those devices the ``capabilities``
	  field returns the same set of capabilities. This allows
	  applications to open just one of the devices (typically the video
	  device) and discover whether video, vbi and/or radio are also
	  supported.
143 144 145 146 147 148 149 150

    -  .. row 7

       -  __u32

       -  ``device_caps``

       -  Device capabilities of the opened device, see
151 152 153 154 155 156 157 158
	  :ref:`device-capabilities`. Should contain the available
	  capabilities of that specific device node. So, for example,
	  ``device_caps`` of a radio device will only contain radio related
	  capabilities and no video or vbi capabilities. This field is only
	  set if the ``capabilities`` field contains the
	  ``V4L2_CAP_DEVICE_CAPS`` capability. Only the ``capabilities``
	  field can have the ``V4L2_CAP_DEVICE_CAPS`` capability,
	  ``device_caps`` will never set ``V4L2_CAP_DEVICE_CAPS``.
159 160 161 162 163

    -  .. row 8

       -  __u32

164
       -  ``reserved``\ [3]
165 166

       -  Reserved for future extensions. Drivers must set this array to
167
	  zero.
168 169 170



171 172
.. tabularcolumns:: |p{6cm}|p{2.2cm}|p{8.8cm}|

173 174
.. _device-capabilities:

175 176
.. cssclass:: longtable

177 178 179 180 181 182 183 184 185 186 187 188
.. flat-table:: Device Capabilities Flags
    :header-rows:  0
    :stub-columns: 0
    :widths:       3 1 4

    -  .. row 1

       -  ``V4L2_CAP_VIDEO_CAPTURE``

       -  0x00000001

       -  The device supports the single-planar API through the
189
	  :ref:`Video Capture <capture>` interface.
190 191 192 193 194 195 196 197

    -  .. row 2

       -  ``V4L2_CAP_VIDEO_CAPTURE_MPLANE``

       -  0x00001000

       -  The device supports the :ref:`multi-planar API <planar-apis>`
198
	  through the :ref:`Video Capture <capture>` interface.
199 200 201 202 203 204 205 206

    -  .. row 3

       -  ``V4L2_CAP_VIDEO_OUTPUT``

       -  0x00000002

       -  The device supports the single-planar API through the
207
	  :ref:`Video Output <output>` interface.
208 209 210 211 212 213 214 215

    -  .. row 4

       -  ``V4L2_CAP_VIDEO_OUTPUT_MPLANE``

       -  0x00002000

       -  The device supports the :ref:`multi-planar API <planar-apis>`
216
	  through the :ref:`Video Output <output>` interface.
217 218 219 220 221 222 223 224

    -  .. row 5

       -  ``V4L2_CAP_VIDEO_M2M``

       -  0x00004000

       -  The device supports the single-planar API through the Video
225
	  Memory-To-Memory interface.
226 227 228 229 230 231 232 233

    -  .. row 6

       -  ``V4L2_CAP_VIDEO_M2M_MPLANE``

       -  0x00008000

       -  The device supports the :ref:`multi-planar API <planar-apis>`
234
	  through the Video Memory-To-Memory interface.
235 236 237 238 239 240 241 242

    -  .. row 7

       -  ``V4L2_CAP_VIDEO_OVERLAY``

       -  0x00000004

       -  The device supports the :ref:`Video Overlay <overlay>`
243 244 245
	  interface. A video overlay device typically stores captured images
	  directly in the video memory of a graphics card, with hardware
	  clipping and scaling.
246 247 248 249 250 251 252 253

    -  .. row 8

       -  ``V4L2_CAP_VBI_CAPTURE``

       -  0x00000010

       -  The device supports the :ref:`Raw VBI Capture <raw-vbi>`
254
	  interface, providing Teletext and Closed Caption data.
255 256 257 258 259 260 261 262

    -  .. row 9

       -  ``V4L2_CAP_VBI_OUTPUT``

       -  0x00000020

       -  The device supports the :ref:`Raw VBI Output <raw-vbi>`
263
	  interface.
264 265 266 267 268 269 270 271

    -  .. row 10

       -  ``V4L2_CAP_SLICED_VBI_CAPTURE``

       -  0x00000040

       -  The device supports the :ref:`Sliced VBI Capture <sliced>`
272
	  interface.
273 274 275 276 277 278 279 280

    -  .. row 11

       -  ``V4L2_CAP_SLICED_VBI_OUTPUT``

       -  0x00000080

       -  The device supports the :ref:`Sliced VBI Output <sliced>`
281
	  interface.
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297

    -  .. row 12

       -  ``V4L2_CAP_RDS_CAPTURE``

       -  0x00000100

       -  The device supports the :ref:`RDS <rds>` capture interface.

    -  .. row 13

       -  ``V4L2_CAP_VIDEO_OUTPUT_OVERLAY``

       -  0x00000200

       -  The device supports the :ref:`Video Output Overlay <osd>` (OSD)
298 299 300 301
	  interface. Unlike the *Video Overlay* interface, this is a
	  secondary function of video output devices and overlays an image
	  onto an outgoing video signal. When the driver sets this flag, it
	  must clear the ``V4L2_CAP_VIDEO_OVERLAY`` flag and vice
302
	  versa. [#f1]_
303 304 305 306 307 308 309 310

    -  .. row 14

       -  ``V4L2_CAP_HW_FREQ_SEEK``

       -  0x00000400

       -  The device supports the
311 312
	  :ref:`VIDIOC_S_HW_FREQ_SEEK` ioctl
	  for hardware frequency seeking.
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328

    -  .. row 15

       -  ``V4L2_CAP_RDS_OUTPUT``

       -  0x00000800

       -  The device supports the :ref:`RDS <rds>` output interface.

    -  .. row 16

       -  ``V4L2_CAP_TUNER``

       -  0x00010000

       -  The device has some sort of tuner to receive RF-modulated video
329 330
	  signals. For more information about tuner programming see
	  :ref:`tuner`.
331 332 333 334 335 336 337 338

    -  .. row 17

       -  ``V4L2_CAP_AUDIO``

       -  0x00020000

       -  The device has audio inputs or outputs. It may or may not support
339 340 341
	  audio recording or playback, in PCM or compressed formats. PCM
	  audio support must be implemented as ALSA or OSS interface. For
	  more information on audio inputs and outputs see :ref:`audio`.
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357

    -  .. row 18

       -  ``V4L2_CAP_RADIO``

       -  0x00040000

       -  This is a radio receiver.

    -  .. row 19

       -  ``V4L2_CAP_MODULATOR``

       -  0x00080000

       -  The device has some sort of modulator to emit RF-modulated
358 359
	  video/audio signals. For more information about modulator
	  programming see :ref:`tuner`.
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375

    -  .. row 20

       -  ``V4L2_CAP_SDR_CAPTURE``

       -  0x00100000

       -  The device supports the :ref:`SDR Capture <sdr>` interface.

    -  .. row 21

       -  ``V4L2_CAP_EXT_PIX_FORMAT``

       -  0x00200000

       -  The device supports the struct
376
	  :ref:`v4l2_pix_format <v4l2-pix-format>` extended fields.
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392

    -  .. row 22

       -  ``V4L2_CAP_SDR_OUTPUT``

       -  0x00400000

       -  The device supports the :ref:`SDR Output <sdr>` interface.

    -  .. row 23

       -  ``V4L2_CAP_READWRITE``

       -  0x01000000

       -  The device supports the :ref:`read() <rw>` and/or
393
	  :ref:`write() <rw>` I/O methods.
394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412

    -  .. row 24

       -  ``V4L2_CAP_ASYNCIO``

       -  0x02000000

       -  The device supports the :ref:`asynchronous <async>` I/O methods.

    -  .. row 25

       -  ``V4L2_CAP_STREAMING``

       -  0x04000000

       -  The device supports the :ref:`streaming <mmap>` I/O method.

    -  .. row 26

413 414 415 416 417 418 419 420
       -  ``V4L2_CAP_TOUCH``

       -  0x10000000

       -  This is a touch device.

    -  .. row 27

421 422 423 424 425
       -  ``V4L2_CAP_DEVICE_CAPS``

       -  0x80000000

       -  The driver fills the ``device_caps`` field. This capability can
426 427
	  only appear in the ``capabilities`` field and never in the
	  ``device_caps`` field.
428 429


430
Return Value
431 432 433 434 435 436
============

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.

437
.. [#f1]
438 439 440
   The struct :ref:`v4l2_framebuffer <v4l2-framebuffer>` lacks an
   enum :ref:`v4l2_buf_type <v4l2-buf-type>` field, therefore the
   type of overlay is implied by the driver capabilities.