brintos

brintos / linux-shallow public Read only

0
0
Text · 4.2 KiB · eadcb4a Raw
99 lines · plain
1.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later2.. c:namespace:: V4L3 4.. _output:5 6**********************7Video Output Interface8**********************9 10Video output devices encode stills or image sequences as analog video11signal. With this interface applications can control the encoding12process and move images from user space to the driver.13 14Conventionally V4L2 video output devices are accessed through character15device special files named ``/dev/video`` and ``/dev/video0`` to16``/dev/video63`` with major number 81 and minor numbers 0 to 63.17``/dev/video`` is typically a symbolic link to the preferred video18device.19 20.. note:: The same device file names are used also for video capture devices.21 22Querying Capabilities23=====================24 25Devices supporting the video output interface set the26``V4L2_CAP_VIDEO_OUTPUT`` or ``V4L2_CAP_VIDEO_OUTPUT_MPLANE`` flag in27the ``capabilities`` field of struct28:c:type:`v4l2_capability` returned by the29:ref:`VIDIOC_QUERYCAP` ioctl. As secondary device30functions they may also support the :ref:`raw VBI output <raw-vbi>`31(``V4L2_CAP_VBI_OUTPUT``) interface. At least one of the read/write or32streaming I/O methods must be supported. Modulators and audio outputs33are optional.34 35Supplemental Functions36======================37 38Video output devices shall support :ref:`audio output <audio>`,39:ref:`modulator <tuner>`, :ref:`controls <control>`,40:ref:`cropping and scaling <crop>` and41:ref:`streaming parameter <streaming-par>` ioctls as needed. The42:ref:`video output <video>` ioctls must be supported by all video43output devices.44 45Image Format Negotiation46========================47 48The output is determined by cropping and image format parameters. The49former select an area of the video picture where the image will appear,50the latter how images are stored in memory, i. e. in RGB or YUV format,51the number of bits per pixel or width and height. Together they also52define how images are scaled in the process.53 54As usual these parameters are *not* reset at :c:func:`open()`55time to permit Unix tool chains, programming a device and then writing56to it as if it was a plain file. Well written V4L2 applications ensure57they really get what they want, including cropping and scaling.58 59Cropping initialization at minimum requires to reset the parameters to60defaults. An example is given in :ref:`crop`.61 62To query the current image format applications set the ``type`` field of63a struct :c:type:`v4l2_format` to64``V4L2_BUF_TYPE_VIDEO_OUTPUT`` or ``V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE``65and call the :ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>` ioctl with a pointer66to this structure. Drivers fill the struct67:c:type:`v4l2_pix_format` ``pix`` or the struct68:c:type:`v4l2_pix_format_mplane` ``pix_mp``69member of the ``fmt`` union.70 71To request different parameters applications set the ``type`` field of a72struct :c:type:`v4l2_format` as above and initialize all73fields of the struct :c:type:`v4l2_pix_format`74``vbi`` member of the ``fmt`` union, or better just modify the results75of :ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>`, and call the :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>`76ioctl with a pointer to this structure. Drivers may adjust the77parameters and finally return the actual parameters as :ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>`78does.79 80Like :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` the :ref:`VIDIOC_TRY_FMT <VIDIOC_G_FMT>` ioctl81can be used to learn about hardware limitations without disabling I/O or82possibly time consuming hardware preparations.83 84The contents of struct :c:type:`v4l2_pix_format` and85struct :c:type:`v4l2_pix_format_mplane` are86discussed in :ref:`pixfmt`. See also the specification of the87:ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>`, :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` and :ref:`VIDIOC_TRY_FMT <VIDIOC_G_FMT>` ioctls for88details. Video output devices must implement both the :ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>`89and :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ioctl, even if :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ignores all90requests and always returns default parameters as :ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>` does.91:ref:`VIDIOC_TRY_FMT <VIDIOC_G_FMT>` is optional.92 93Writing Images94==============95 96A video output device may support the :ref:`write() function <rw>`97and/or streaming (:ref:`memory mapping <mmap>` or98:ref:`user pointer <userp>`) I/O. See :ref:`io` for details.99