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