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