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