dev-output.rst 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
  2. .. c:namespace:: V4L
  3. .. _output:
  4. **********************
  5. Video Output Interface
  6. **********************
  7. Video output devices encode stills or image sequences as analog video
  8. signal. With this interface applications can control the encoding
  9. process and move images from user space to the driver.
  10. Conventionally V4L2 video output devices are accessed through character
  11. device special files named ``/dev/video`` and ``/dev/video0`` to
  12. ``/dev/video63`` with major number 81 and minor numbers 0 to 63.
  13. ``/dev/video`` is typically a symbolic link to the preferred video
  14. device.
  15. .. note:: The same device file names are used also for video capture devices.
  16. Querying Capabilities
  17. =====================
  18. Devices supporting the video output interface set the
  19. ``V4L2_CAP_VIDEO_OUTPUT`` or ``V4L2_CAP_VIDEO_OUTPUT_MPLANE`` flag in
  20. the ``capabilities`` field of struct
  21. :c:type:`v4l2_capability` returned by the
  22. :ref:`VIDIOC_QUERYCAP` ioctl. As secondary device
  23. functions they may also support the :ref:`raw VBI output <raw-vbi>`
  24. (``V4L2_CAP_VBI_OUTPUT``) interface. At least one of the read/write or
  25. streaming I/O methods must be supported. Modulators and audio outputs
  26. are optional.
  27. Supplemental Functions
  28. ======================
  29. Video output devices shall support :ref:`audio output <audio>`,
  30. :ref:`modulator <tuner>`, :ref:`controls <control>`,
  31. :ref:`cropping and scaling <crop>` and
  32. :ref:`streaming parameter <streaming-par>` ioctls as needed. The
  33. :ref:`video output <video>` ioctls must be supported by all video
  34. output devices.
  35. Image Format Negotiation
  36. ========================
  37. The output is determined by cropping and image format parameters. The
  38. former select an area of the video picture where the image will appear,
  39. the latter how images are stored in memory, i. e. in RGB or YUV format,
  40. the number of bits per pixel or width and height. Together they also
  41. define how images are scaled in the process.
  42. As usual these parameters are *not* reset at :c:func:`open()`
  43. time to permit Unix tool chains, programming a device and then writing
  44. to it as if it was a plain file. Well written V4L2 applications ensure
  45. they really get what they want, including cropping and scaling.
  46. Cropping initialization at minimum requires to reset the parameters to
  47. defaults. An example is given in :ref:`crop`.
  48. To query the current image format applications set the ``type`` field of
  49. a struct :c:type:`v4l2_format` to
  50. ``V4L2_BUF_TYPE_VIDEO_OUTPUT`` or ``V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE``
  51. and call the :ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>` ioctl with a pointer
  52. to this structure. Drivers fill the struct
  53. :c:type:`v4l2_pix_format` ``pix`` or the struct
  54. :c:type:`v4l2_pix_format_mplane` ``pix_mp``
  55. member of the ``fmt`` union.
  56. To request different parameters applications set the ``type`` field of a
  57. struct :c:type:`v4l2_format` as above and initialize all
  58. fields of the struct :c:type:`v4l2_pix_format`
  59. ``vbi`` member of the ``fmt`` union, or better just modify the results
  60. of :ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>`, and call the :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>`
  61. ioctl with a pointer to this structure. Drivers may adjust the
  62. parameters and finally return the actual parameters as :ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>`
  63. does.
  64. Like :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` the :ref:`VIDIOC_TRY_FMT <VIDIOC_G_FMT>` ioctl
  65. can be used to learn about hardware limitations without disabling I/O or
  66. possibly time consuming hardware preparations.
  67. The contents of struct :c:type:`v4l2_pix_format` and
  68. struct :c:type:`v4l2_pix_format_mplane` are
  69. discussed in :ref:`pixfmt`. See also the specification of the
  70. :ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>`, :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` and :ref:`VIDIOC_TRY_FMT <VIDIOC_G_FMT>` ioctls for
  71. details. Video output devices must implement both the :ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>`
  72. and :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ioctl, even if :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ignores all
  73. requests and always returns default parameters as :ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>` does.
  74. :ref:`VIDIOC_TRY_FMT <VIDIOC_G_FMT>` is optional.
  75. Writing Images
  76. ==============
  77. A video output device may support the :ref:`write() function <rw>`
  78. and/or streaming (:ref:`memory mapping <mmap>` or
  79. :ref:`user pointer <userp>`) I/O. See :ref:`io` for details.