Linux-libre 5.3.12-gnu
[librecmc/linux-libre.git] / Documentation / media / uapi / v4l / vidioc-g-dv-timings.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 .. _VIDIOC_G_DV_TIMINGS:
11
12 **********************************************
13 ioctl VIDIOC_G_DV_TIMINGS, VIDIOC_S_DV_TIMINGS
14 **********************************************
15
16 Name
17 ====
18
19 VIDIOC_G_DV_TIMINGS - VIDIOC_S_DV_TIMINGS - VIDIOC_SUBDEV_G_DV_TIMINGS - VIDIOC_SUBDEV_S_DV_TIMINGS - Get or set DV timings for input or output
20
21
22 Synopsis
23 ========
24
25 .. c:function:: int ioctl( int fd, VIDIOC_G_DV_TIMINGS, struct v4l2_dv_timings *argp )
26     :name: VIDIOC_G_DV_TIMINGS
27
28 .. c:function:: int ioctl( int fd, VIDIOC_S_DV_TIMINGS, struct v4l2_dv_timings *argp )
29     :name: VIDIOC_S_DV_TIMINGS
30
31 .. c:function:: int ioctl( int fd, VIDIOC_SUBDEV_G_DV_TIMINGS, struct v4l2_dv_timings *argp )
32     :name: VIDIOC_SUBDEV_G_DV_TIMINGS
33
34 .. c:function:: int ioctl( int fd, VIDIOC_SUBDEV_S_DV_TIMINGS, struct v4l2_dv_timings *argp )
35     :name: VIDIOC_SUBDEV_S_DV_TIMINGS
36
37
38 Arguments
39 =========
40
41 ``fd``
42     File descriptor returned by :ref:`open() <func-open>`.
43
44 ``argp``
45     Pointer to struct :c:type:`v4l2_dv_timings`.
46
47
48 Description
49 ===========
50
51 To set DV timings for the input or output, applications use the
52 :ref:`VIDIOC_S_DV_TIMINGS <VIDIOC_G_DV_TIMINGS>` ioctl and to get the current timings,
53 applications use the :ref:`VIDIOC_G_DV_TIMINGS <VIDIOC_G_DV_TIMINGS>` ioctl. The detailed timing
54 information is filled in using the structure struct
55 :c:type:`v4l2_dv_timings`. These ioctls take a
56 pointer to the struct :c:type:`v4l2_dv_timings`
57 structure as argument. If the ioctl is not supported or the timing
58 values are not correct, the driver returns ``EINVAL`` error code.
59
60 The ``linux/v4l2-dv-timings.h`` header can be used to get the timings of
61 the formats in the :ref:`cea861` and :ref:`vesadmt` standards. If
62 the current input or output does not support DV timings (e.g. if
63 :ref:`VIDIOC_ENUMINPUT` does not set the
64 ``V4L2_IN_CAP_DV_TIMINGS`` flag), then ``ENODATA`` error code is returned.
65
66
67 Return Value
68 ============
69
70 On success 0 is returned, on error -1 and the ``errno`` variable is set
71 appropriately. The generic error codes are described at the
72 :ref:`Generic Error Codes <gen-errors>` chapter.
73
74 EINVAL
75     This ioctl is not supported, or the :ref:`VIDIOC_S_DV_TIMINGS <VIDIOC_G_DV_TIMINGS>`
76     parameter was unsuitable.
77
78 ENODATA
79     Digital video timings are not supported for this input or output.
80
81 EBUSY
82     The device is busy and therefore can not change the timings.
83
84
85 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
86
87 .. c:type:: v4l2_bt_timings
88
89 .. flat-table:: struct v4l2_bt_timings
90     :header-rows:  0
91     :stub-columns: 0
92     :widths:       1 1 2
93
94     * - __u32
95       - ``width``
96       - Width of the active video in pixels.
97     * - __u32
98       - ``height``
99       - Height of the active video frame in lines. So for interlaced
100         formats the height of the active video in each field is
101         ``height``/2.
102     * - __u32
103       - ``interlaced``
104       - Progressive (``V4L2_DV_PROGRESSIVE``) or interlaced (``V4L2_DV_INTERLACED``).
105     * - __u32
106       - ``polarities``
107       - This is a bit mask that defines polarities of sync signals. bit 0
108         (``V4L2_DV_VSYNC_POS_POL``) is for vertical sync polarity and bit
109         1 (``V4L2_DV_HSYNC_POS_POL``) is for horizontal sync polarity. If
110         the bit is set (1) it is positive polarity and if is cleared (0),
111         it is negative polarity.
112     * - __u64
113       - ``pixelclock``
114       - Pixel clock in Hz. Ex. 74.25MHz->74250000
115     * - __u32
116       - ``hfrontporch``
117       - Horizontal front porch in pixels
118     * - __u32
119       - ``hsync``
120       - Horizontal sync length in pixels
121     * - __u32
122       - ``hbackporch``
123       - Horizontal back porch in pixels
124     * - __u32
125       - ``vfrontporch``
126       - Vertical front porch in lines. For interlaced formats this refers
127         to the odd field (aka field 1).
128     * - __u32
129       - ``vsync``
130       - Vertical sync length in lines. For interlaced formats this refers
131         to the odd field (aka field 1).
132     * - __u32
133       - ``vbackporch``
134       - Vertical back porch in lines. For interlaced formats this refers
135         to the odd field (aka field 1).
136     * - __u32
137       - ``il_vfrontporch``
138       - Vertical front porch in lines for the even field (aka field 2) of
139         interlaced field formats. Must be 0 for progressive formats.
140     * - __u32
141       - ``il_vsync``
142       - Vertical sync length in lines for the even field (aka field 2) of
143         interlaced field formats. Must be 0 for progressive formats.
144     * - __u32
145       - ``il_vbackporch``
146       - Vertical back porch in lines for the even field (aka field 2) of
147         interlaced field formats. Must be 0 for progressive formats.
148     * - __u32
149       - ``standards``
150       - The video standard(s) this format belongs to. This will be filled
151         in by the driver. Applications must set this to 0. See
152         :ref:`dv-bt-standards` for a list of standards.
153     * - __u32
154       - ``flags``
155       - Several flags giving more information about the format. See
156         :ref:`dv-bt-flags` for a description of the flags.
157     * - struct :c:type:`v4l2_fract`
158       - ``picture_aspect``
159       - The picture aspect if the pixels are not square. Only valid if the
160         ``V4L2_DV_FL_HAS_PICTURE_ASPECT`` flag is set.
161     * - __u8
162       - ``cea861_vic``
163       - The Video Identification Code according to the CEA-861 standard.
164         Only valid if the ``V4L2_DV_FL_HAS_CEA861_VIC`` flag is set.
165     * - __u8
166       - ``hdmi_vic``
167       - The Video Identification Code according to the HDMI standard.
168         Only valid if the ``V4L2_DV_FL_HAS_HDMI_VIC`` flag is set.
169     * - __u8
170       - ``reserved[46]``
171       - Reserved for future extensions. Drivers and applications must set
172         the array to zero.
173
174
175 .. tabularcolumns:: |p{3.5cm}|p{3.5cm}|p{7.0cm}|p{3.5cm}|
176
177 .. c:type:: v4l2_dv_timings
178
179 .. flat-table:: struct v4l2_dv_timings
180     :header-rows:  0
181     :stub-columns: 0
182     :widths:       1 1 2 1
183
184     * - __u32
185       - ``type``
186       -
187       - Type of DV timings as listed in :ref:`dv-timing-types`.
188     * - union
189       -
190       -
191     * -
192       - struct :c:type:`v4l2_bt_timings`
193       - ``bt``
194       - Timings defined by BT.656/1120 specifications
195     * -
196       - __u32
197       - ``reserved``\ [32]
198       -
199
200 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
201
202 .. _dv-timing-types:
203
204 .. flat-table:: DV Timing types
205     :header-rows:  0
206     :stub-columns: 0
207     :widths:       1 1 2
208
209     * - Timing type
210       - value
211       - Description
212     * -
213       -
214       -
215     * - ``V4L2_DV_BT_656_1120``
216       - 0
217       - BT.656/1120 timings
218
219 .. tabularcolumns:: |p{4.5cm}|p{12.8cm}|
220
221 .. _dv-bt-standards:
222
223 .. flat-table:: DV BT Timing standards
224     :header-rows:  0
225     :stub-columns: 0
226
227     * - Timing standard
228       - Description
229     * - ``V4L2_DV_BT_STD_CEA861``
230       - The timings follow the CEA-861 Digital TV Profile standard
231     * - ``V4L2_DV_BT_STD_DMT``
232       - The timings follow the VESA Discrete Monitor Timings standard
233     * - ``V4L2_DV_BT_STD_CVT``
234       - The timings follow the VESA Coordinated Video Timings standard
235     * - ``V4L2_DV_BT_STD_GTF``
236       - The timings follow the VESA Generalized Timings Formula standard
237     * - ``V4L2_DV_BT_STD_SDI``
238       - The timings follow the SDI Timings standard.
239         There are no horizontal syncs/porches at all in this format.
240         Total blanking timings must be set in hsync or vsync fields only.
241
242 .. tabularcolumns:: |p{7.0cm}|p{10.5cm}|
243
244 .. _dv-bt-flags:
245
246 .. flat-table:: DV BT Timing flags
247     :header-rows:  0
248     :stub-columns: 0
249
250     * - Flag
251       - Description
252     * - ``V4L2_DV_FL_REDUCED_BLANKING``
253       - CVT/GTF specific: the timings use reduced blanking (CVT) or the
254         'Secondary GTF' curve (GTF). In both cases the horizontal and/or
255         vertical blanking intervals are reduced, allowing a higher
256         resolution over the same bandwidth. This is a read-only flag,
257         applications must not set this.
258     * - ``V4L2_DV_FL_CAN_REDUCE_FPS``
259       - CEA-861 specific: set for CEA-861 formats with a framerate that is
260         a multiple of six. These formats can be optionally played at 1 /
261         1.001 speed to be compatible with 60 Hz based standards such as
262         NTSC and PAL-M that use a framerate of 29.97 frames per second. If
263         the transmitter can't generate such frequencies, then the flag
264         will also be cleared. This is a read-only flag, applications must
265         not set this.
266     * - ``V4L2_DV_FL_REDUCED_FPS``
267       - CEA-861 specific: only valid for video transmitters or video
268         receivers that have the ``V4L2_DV_FL_CAN_DETECT_REDUCED_FPS``
269         set. This flag is cleared otherwise. It is also only valid for
270         formats with the ``V4L2_DV_FL_CAN_REDUCE_FPS`` flag set, for other
271         formats the flag will be cleared by the driver.
272
273         If the application sets this flag for a transmitter, then the
274         pixelclock used to set up the transmitter is divided by 1.001 to
275         make it compatible with NTSC framerates. If the transmitter can't
276         generate such frequencies, then the flag will be cleared.
277
278         If a video receiver detects that the format uses a reduced framerate,
279         then it will set this flag to signal this to the application.
280     * - ``V4L2_DV_FL_HALF_LINE``
281       - Specific to interlaced formats: if set, then the vertical
282         backporch of field 1 (aka the odd field) is really one half-line
283         longer and the vertical backporch of field 2 (aka the even field)
284         is really one half-line shorter, so each field has exactly the
285         same number of half-lines. Whether half-lines can be detected or
286         used depends on the hardware.
287     * - ``V4L2_DV_FL_IS_CE_VIDEO``
288       - If set, then this is a Consumer Electronics (CE) video format.
289         Such formats differ from other formats (commonly called IT
290         formats) in that if R'G'B' encoding is used then by default the
291         R'G'B' values use limited range (i.e. 16-235) as opposed to full
292         range (i.e. 0-255). All formats defined in CEA-861 except for the
293         640x480p59.94 format are CE formats.
294     * - ``V4L2_DV_FL_FIRST_FIELD_EXTRA_LINE``
295       - Some formats like SMPTE-125M have an interlaced signal with a odd
296         total height. For these formats, if this flag is set, the first
297         field has the extra line. Else, it is the second field.
298     * - ``V4L2_DV_FL_HAS_PICTURE_ASPECT``
299       - If set, then the picture_aspect field is valid. Otherwise assume that
300         the pixels are square, so the picture aspect ratio is the same as the
301         width to height ratio.
302     * - ``V4L2_DV_FL_HAS_CEA861_VIC``
303       - If set, then the cea861_vic field is valid and contains the Video
304         Identification Code as per the CEA-861 standard.
305     * - ``V4L2_DV_FL_HAS_HDMI_VIC``
306       - If set, then the hdmi_vic field is valid and contains the Video
307         Identification Code as per the HDMI standard (HDMI Vendor Specific
308         InfoFrame).
309     * - ``V4L2_DV_FL_CAN_DETECT_REDUCED_FPS``
310       - CEA-861 specific: only valid for video receivers, the flag is
311         cleared by transmitters.
312         If set, then the hardware can detect the difference between
313         regular framerates and framerates reduced by 1000/1001. E.g.:
314         60 vs 59.94 Hz, 30 vs 29.97 Hz or 24 vs 23.976 Hz.