doc-rst: linux_tv: don't simplify VIDIOC_G_foo references
[deliverable/linux.git] / Documentation / linux_tv / media / v4l / dev-output.rst
CommitLineData
5377d91f
MH
1.. -*- coding: utf-8; mode: rst -*-
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. Note the same device files are used for video capture devices.
18
19
20Querying Capabilities
21=====================
22
23Devices supporting the video output interface set the
24``V4L2_CAP_VIDEO_OUTPUT`` or ``V4L2_CAP_VIDEO_OUTPUT_MPLANE`` flag in
25the ``capabilities`` field of struct
26:ref:`v4l2_capability <v4l2-capability>` returned by the
7347081e 27:ref:`VIDIOC_QUERYCAP` ioctl. As secondary device
5377d91f
MH
28functions they may also support the :ref:`raw VBI output <raw-vbi>`
29(``V4L2_CAP_VBI_OUTPUT``) interface. At least one of the read/write or
30streaming I/O methods must be supported. Modulators and audio outputs
31are optional.
32
33
34Supplemental Functions
35======================
36
37Video output devices shall support :ref:`audio output <audio>`,
38:ref:`modulator <tuner>`, :ref:`controls <control>`,
39:ref:`cropping and scaling <crop>` and
40:ref:`streaming parameter <streaming-par>` ioctls as needed. The
41:ref:`video output <video>` and :ref:`video standard <standard>`
42ioctls must be supported by all video output devices.
43
44
45Image Format Negotiation
46========================
47
48The output is determined by cropping and image format parameters. The
49former 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 also
52define how images are scaled in the process.
53
54As usual these parameters are *not* reset at :ref:`open() <func-open>`
55time to permit Unix tool chains, programming a device and then writing
56to it as if it was a plain file. Well written V4L2 applications ensure
57they really get what they want, including cropping and scaling.
58
59Cropping initialization at minimum requires to reset the parameters to
60defaults. An example is given in :ref:`crop`.
61
62To query the current image format applications set the ``type`` field of
63a struct :ref:`v4l2_format <v4l2-format>` to
64``V4L2_BUF_TYPE_VIDEO_OUTPUT`` or ``V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE``
4e03cb76 65and call the :ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>` ioctl with a pointer
5377d91f
MH
66to this structure. Drivers fill the struct
67:ref:`v4l2_pix_format <v4l2-pix-format>` ``pix`` or the struct
68:ref:`v4l2_pix_format_mplane <v4l2-pix-format-mplane>` ``pix_mp``
69member of the ``fmt`` union.
70
71To request different parameters applications set the ``type`` field of a
72struct :ref:`v4l2_format <v4l2-format>` as above and initialize all
73fields of the struct :ref:`v4l2_pix_format <v4l2-pix-format>`
74``vbi`` member of the ``fmt`` union, or better just modify the results
4e03cb76 75of :ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>`, and call the :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>`
5377d91f 76ioctl with a pointer to this structure. Drivers may adjust the
4e03cb76 77parameters and finally return the actual parameters as :ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>`
5377d91f
MH
78does.
79
2212ff25 80Like :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` the :ref:`VIDIOC_TRY_FMT <VIDIOC_G_FMT>` ioctl
5377d91f
MH
81can be used to learn about hardware limitations without disabling I/O or
82possibly time consuming hardware preparations.
83
84The contents of struct :ref:`v4l2_pix_format <v4l2-pix-format>` and
85struct :ref:`v4l2_pix_format_mplane <v4l2-pix-format-mplane>` are
86discussed in :ref:`pixfmt`. See also the specification of the
4e03cb76
MCC
87:ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>`, :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` and :ref:`VIDIOC_TRY_FMT <VIDIOC_G_FMT>` ioctls for
88details. Video output devices must implement both the :ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>`
2212ff25 89and :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ioctl, even if :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ignores all
4e03cb76 90requests and always returns default parameters as :ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>` does.
2212ff25 91:ref:`VIDIOC_TRY_FMT <VIDIOC_G_FMT>` is optional.
5377d91f
MH
92
93
94Writing Images
95==============
96
97A video output device may support the :ref:`write() function <rw>`
98and/or streaming (:ref:`memory mapping <mmap>` or
99:ref:`user pointer <userp>`) I/O. See :ref:`io` for details.
100
101
102.. ------------------------------------------------------------------------------
103.. This file was automatically converted from DocBook-XML with the dbxml
104.. library (https://github.com/return42/sphkerneldoc). The origin XML comes
105.. from the linux kernel, refer to:
106..
107.. * https://github.com/torvalds/linux/tree/master/Documentation/DocBook
108.. ------------------------------------------------------------------------------
This page took 0.090093 seconds and 5 git commands to generate.