blob: 5063be7d493847d2a21f3bc95ed1dbd4fcb3be7c [file] [log] [blame]
Markus Heiser5377d912016-06-30 15:18:56 +02001.. -*- 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
Mauro Carvalho Chehab73470812016-07-01 13:58:44 -030027:ref:`VIDIOC_QUERYCAP` ioctl. As secondary device
Markus Heiser5377d912016-06-30 15:18:56 +020028functions 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``
Mauro Carvalho Chehab4e03cb72016-07-03 10:02:29 -030065and call the :ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>` ioctl with a pointer
Markus Heiser5377d912016-06-30 15:18:56 +020066to 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
Mauro Carvalho Chehab4e03cb72016-07-03 10:02:29 -030075of :ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>`, and call the :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>`
Markus Heiser5377d912016-06-30 15:18:56 +020076ioctl with a pointer to this structure. Drivers may adjust the
Mauro Carvalho Chehab4e03cb72016-07-03 10:02:29 -030077parameters and finally return the actual parameters as :ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>`
Markus Heiser5377d912016-06-30 15:18:56 +020078does.
79
Mauro Carvalho Chehab2212ff22016-07-01 14:33:56 -030080Like :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` the :ref:`VIDIOC_TRY_FMT <VIDIOC_G_FMT>` ioctl
Markus Heiser5377d912016-06-30 15:18:56 +020081can 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
Mauro Carvalho Chehab4e03cb72016-07-03 10:02:29 -030087: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>`
Mauro Carvalho Chehab2212ff22016-07-01 14:33:56 -030089and :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ioctl, even if :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ignores all
Mauro Carvalho Chehab4e03cb72016-07-03 10:02:29 -030090requests and always returns default parameters as :ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>` does.
Mauro Carvalho Chehab2212ff22016-07-01 14:33:56 -030091:ref:`VIDIOC_TRY_FMT <VIDIOC_G_FMT>` is optional.
Markus Heiser5377d912016-06-30 15:18:56 +020092
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.