18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
28c2ecf20Sopenharmony_ci.. c:namespace:: V4L
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci.. _output:
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci**********************
78c2ecf20Sopenharmony_ciVideo Output Interface
88c2ecf20Sopenharmony_ci**********************
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ciVideo output devices encode stills or image sequences as analog video
118c2ecf20Sopenharmony_cisignal. With this interface applications can control the encoding
128c2ecf20Sopenharmony_ciprocess and move images from user space to the driver.
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ciConventionally V4L2 video output devices are accessed through character
158c2ecf20Sopenharmony_cidevice special files named ``/dev/video`` and ``/dev/video0`` to
168c2ecf20Sopenharmony_ci``/dev/video63`` with major number 81 and minor numbers 0 to 63.
178c2ecf20Sopenharmony_ci``/dev/video`` is typically a symbolic link to the preferred video
188c2ecf20Sopenharmony_cidevice.
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci.. note:: The same device file names are used also for video capture devices.
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ciQuerying Capabilities
238c2ecf20Sopenharmony_ci=====================
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ciDevices supporting the video output interface set the
268c2ecf20Sopenharmony_ci``V4L2_CAP_VIDEO_OUTPUT`` or ``V4L2_CAP_VIDEO_OUTPUT_MPLANE`` flag in
278c2ecf20Sopenharmony_cithe ``capabilities`` field of struct
288c2ecf20Sopenharmony_ci:c:type:`v4l2_capability` returned by the
298c2ecf20Sopenharmony_ci:ref:`VIDIOC_QUERYCAP` ioctl. As secondary device
308c2ecf20Sopenharmony_cifunctions they may also support the :ref:`raw VBI output <raw-vbi>`
318c2ecf20Sopenharmony_ci(``V4L2_CAP_VBI_OUTPUT``) interface. At least one of the read/write or
328c2ecf20Sopenharmony_cistreaming I/O methods must be supported. Modulators and audio outputs
338c2ecf20Sopenharmony_ciare optional.
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ciSupplemental Functions
368c2ecf20Sopenharmony_ci======================
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ciVideo output devices shall support :ref:`audio output <audio>`,
398c2ecf20Sopenharmony_ci:ref:`modulator <tuner>`, :ref:`controls <control>`,
408c2ecf20Sopenharmony_ci:ref:`cropping and scaling <crop>` and
418c2ecf20Sopenharmony_ci:ref:`streaming parameter <streaming-par>` ioctls as needed. The
428c2ecf20Sopenharmony_ci:ref:`video output <video>` ioctls must be supported by all video
438c2ecf20Sopenharmony_cioutput devices.
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ciImage Format Negotiation
468c2ecf20Sopenharmony_ci========================
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ciThe output is determined by cropping and image format parameters. The
498c2ecf20Sopenharmony_ciformer select an area of the video picture where the image will appear,
508c2ecf20Sopenharmony_cithe latter how images are stored in memory, i. e. in RGB or YUV format,
518c2ecf20Sopenharmony_cithe number of bits per pixel or width and height. Together they also
528c2ecf20Sopenharmony_cidefine how images are scaled in the process.
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ciAs usual these parameters are *not* reset at :c:func:`open()`
558c2ecf20Sopenharmony_citime to permit Unix tool chains, programming a device and then writing
568c2ecf20Sopenharmony_cito it as if it was a plain file. Well written V4L2 applications ensure
578c2ecf20Sopenharmony_cithey really get what they want, including cropping and scaling.
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ciCropping initialization at minimum requires to reset the parameters to
608c2ecf20Sopenharmony_cidefaults. An example is given in :ref:`crop`.
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ciTo query the current image format applications set the ``type`` field of
638c2ecf20Sopenharmony_cia struct :c:type:`v4l2_format` to
648c2ecf20Sopenharmony_ci``V4L2_BUF_TYPE_VIDEO_OUTPUT`` or ``V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE``
658c2ecf20Sopenharmony_ciand call the :ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>` ioctl with a pointer
668c2ecf20Sopenharmony_cito this structure. Drivers fill the struct
678c2ecf20Sopenharmony_ci:c:type:`v4l2_pix_format` ``pix`` or the struct
688c2ecf20Sopenharmony_ci:c:type:`v4l2_pix_format_mplane` ``pix_mp``
698c2ecf20Sopenharmony_cimember of the ``fmt`` union.
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ciTo request different parameters applications set the ``type`` field of a
728c2ecf20Sopenharmony_cistruct :c:type:`v4l2_format` as above and initialize all
738c2ecf20Sopenharmony_cifields of the struct :c:type:`v4l2_pix_format`
748c2ecf20Sopenharmony_ci``vbi`` member of the ``fmt`` union, or better just modify the results
758c2ecf20Sopenharmony_ciof :ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>`, and call the :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>`
768c2ecf20Sopenharmony_ciioctl with a pointer to this structure. Drivers may adjust the
778c2ecf20Sopenharmony_ciparameters and finally return the actual parameters as :ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>`
788c2ecf20Sopenharmony_cidoes.
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ciLike :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` the :ref:`VIDIOC_TRY_FMT <VIDIOC_G_FMT>` ioctl
818c2ecf20Sopenharmony_cican be used to learn about hardware limitations without disabling I/O or
828c2ecf20Sopenharmony_cipossibly time consuming hardware preparations.
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ciThe contents of struct :c:type:`v4l2_pix_format` and
858c2ecf20Sopenharmony_cistruct :c:type:`v4l2_pix_format_mplane` are
868c2ecf20Sopenharmony_cidiscussed in :ref:`pixfmt`. See also the specification of the
878c2ecf20Sopenharmony_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
888c2ecf20Sopenharmony_cidetails. Video output devices must implement both the :ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>`
898c2ecf20Sopenharmony_ciand :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ioctl, even if :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ignores all
908c2ecf20Sopenharmony_cirequests and always returns default parameters as :ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>` does.
918c2ecf20Sopenharmony_ci:ref:`VIDIOC_TRY_FMT <VIDIOC_G_FMT>` is optional.
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ciWriting Images
948c2ecf20Sopenharmony_ci==============
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ciA video output device may support the :ref:`write() function <rw>`
978c2ecf20Sopenharmony_ciand/or streaming (:ref:`memory mapping <mmap>` or
988c2ecf20Sopenharmony_ci:ref:`user pointer <userp>`) I/O. See :ref:`io` for details.
99