162306a36Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
262306a36Sopenharmony_ci.. c:namespace:: V4L
362306a36Sopenharmony_ci
462306a36Sopenharmony_ci.. _output:
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci**********************
762306a36Sopenharmony_ciVideo Output Interface
862306a36Sopenharmony_ci**********************
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ciVideo output devices encode stills or image sequences as analog video
1162306a36Sopenharmony_cisignal. With this interface applications can control the encoding
1262306a36Sopenharmony_ciprocess and move images from user space to the driver.
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ciConventionally V4L2 video output devices are accessed through character
1562306a36Sopenharmony_cidevice special files named ``/dev/video`` and ``/dev/video0`` to
1662306a36Sopenharmony_ci``/dev/video63`` with major number 81 and minor numbers 0 to 63.
1762306a36Sopenharmony_ci``/dev/video`` is typically a symbolic link to the preferred video
1862306a36Sopenharmony_cidevice.
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci.. note:: The same device file names are used also for video capture devices.
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ciQuerying Capabilities
2362306a36Sopenharmony_ci=====================
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ciDevices supporting the video output interface set the
2662306a36Sopenharmony_ci``V4L2_CAP_VIDEO_OUTPUT`` or ``V4L2_CAP_VIDEO_OUTPUT_MPLANE`` flag in
2762306a36Sopenharmony_cithe ``capabilities`` field of struct
2862306a36Sopenharmony_ci:c:type:`v4l2_capability` returned by the
2962306a36Sopenharmony_ci:ref:`VIDIOC_QUERYCAP` ioctl. As secondary device
3062306a36Sopenharmony_cifunctions they may also support the :ref:`raw VBI output <raw-vbi>`
3162306a36Sopenharmony_ci(``V4L2_CAP_VBI_OUTPUT``) interface. At least one of the read/write or
3262306a36Sopenharmony_cistreaming I/O methods must be supported. Modulators and audio outputs
3362306a36Sopenharmony_ciare optional.
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ciSupplemental Functions
3662306a36Sopenharmony_ci======================
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ciVideo output devices shall support :ref:`audio output <audio>`,
3962306a36Sopenharmony_ci:ref:`modulator <tuner>`, :ref:`controls <control>`,
4062306a36Sopenharmony_ci:ref:`cropping and scaling <crop>` and
4162306a36Sopenharmony_ci:ref:`streaming parameter <streaming-par>` ioctls as needed. The
4262306a36Sopenharmony_ci:ref:`video output <video>` ioctls must be supported by all video
4362306a36Sopenharmony_cioutput devices.
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ciImage Format Negotiation
4662306a36Sopenharmony_ci========================
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ciThe output is determined by cropping and image format parameters. The
4962306a36Sopenharmony_ciformer select an area of the video picture where the image will appear,
5062306a36Sopenharmony_cithe latter how images are stored in memory, i. e. in RGB or YUV format,
5162306a36Sopenharmony_cithe number of bits per pixel or width and height. Together they also
5262306a36Sopenharmony_cidefine how images are scaled in the process.
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ciAs usual these parameters are *not* reset at :c:func:`open()`
5562306a36Sopenharmony_citime to permit Unix tool chains, programming a device and then writing
5662306a36Sopenharmony_cito it as if it was a plain file. Well written V4L2 applications ensure
5762306a36Sopenharmony_cithey really get what they want, including cropping and scaling.
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ciCropping initialization at minimum requires to reset the parameters to
6062306a36Sopenharmony_cidefaults. An example is given in :ref:`crop`.
6162306a36Sopenharmony_ci
6262306a36Sopenharmony_ciTo query the current image format applications set the ``type`` field of
6362306a36Sopenharmony_cia struct :c:type:`v4l2_format` to
6462306a36Sopenharmony_ci``V4L2_BUF_TYPE_VIDEO_OUTPUT`` or ``V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE``
6562306a36Sopenharmony_ciand call the :ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>` ioctl with a pointer
6662306a36Sopenharmony_cito this structure. Drivers fill the struct
6762306a36Sopenharmony_ci:c:type:`v4l2_pix_format` ``pix`` or the struct
6862306a36Sopenharmony_ci:c:type:`v4l2_pix_format_mplane` ``pix_mp``
6962306a36Sopenharmony_cimember of the ``fmt`` union.
7062306a36Sopenharmony_ci
7162306a36Sopenharmony_ciTo request different parameters applications set the ``type`` field of a
7262306a36Sopenharmony_cistruct :c:type:`v4l2_format` as above and initialize all
7362306a36Sopenharmony_cifields of the struct :c:type:`v4l2_pix_format`
7462306a36Sopenharmony_ci``vbi`` member of the ``fmt`` union, or better just modify the results
7562306a36Sopenharmony_ciof :ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>`, and call the :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>`
7662306a36Sopenharmony_ciioctl with a pointer to this structure. Drivers may adjust the
7762306a36Sopenharmony_ciparameters and finally return the actual parameters as :ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>`
7862306a36Sopenharmony_cidoes.
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_ciLike :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` the :ref:`VIDIOC_TRY_FMT <VIDIOC_G_FMT>` ioctl
8162306a36Sopenharmony_cican be used to learn about hardware limitations without disabling I/O or
8262306a36Sopenharmony_cipossibly time consuming hardware preparations.
8362306a36Sopenharmony_ci
8462306a36Sopenharmony_ciThe contents of struct :c:type:`v4l2_pix_format` and
8562306a36Sopenharmony_cistruct :c:type:`v4l2_pix_format_mplane` are
8662306a36Sopenharmony_cidiscussed in :ref:`pixfmt`. See also the specification of the
8762306a36Sopenharmony_ci:ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>`, :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` and :ref:`VIDIOC_TRY_FMT <VIDIOC_G_FMT>` ioctls for
8862306a36Sopenharmony_cidetails. Video output devices must implement both the :ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>`
8962306a36Sopenharmony_ciand :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ioctl, even if :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ignores all
9062306a36Sopenharmony_cirequests and always returns default parameters as :ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>` does.
9162306a36Sopenharmony_ci:ref:`VIDIOC_TRY_FMT <VIDIOC_G_FMT>` is optional.
9262306a36Sopenharmony_ci
9362306a36Sopenharmony_ciWriting Images
9462306a36Sopenharmony_ci==============
9562306a36Sopenharmony_ci
9662306a36Sopenharmony_ciA video output device may support the :ref:`write() function <rw>`
9762306a36Sopenharmony_ciand/or streaming (:ref:`memory mapping <mmap>` or
9862306a36Sopenharmony_ci:ref:`user pointer <userp>`) I/O. See :ref:`io` for details.
99