162306a36Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
262306a36Sopenharmony_ci.. c:namespace:: V4L
362306a36Sopenharmony_ci
462306a36Sopenharmony_ci.. _VIDIOC_G_DV_TIMINGS:
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci**********************************************
762306a36Sopenharmony_ciioctl VIDIOC_G_DV_TIMINGS, VIDIOC_S_DV_TIMINGS
862306a36Sopenharmony_ci**********************************************
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ciName
1162306a36Sopenharmony_ci====
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ciVIDIOC_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
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ciSynopsis
1662306a36Sopenharmony_ci========
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci.. c:macro:: VIDIOC_G_DV_TIMINGS
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci``int ioctl(int fd, VIDIOC_G_DV_TIMINGS, struct v4l2_dv_timings *argp)``
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci.. c:macro:: VIDIOC_S_DV_TIMINGS
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci``int ioctl(int fd, VIDIOC_S_DV_TIMINGS, struct v4l2_dv_timings *argp)``
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ci.. c:macro:: VIDIOC_SUBDEV_G_DV_TIMINGS
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci``int ioctl(int fd, VIDIOC_SUBDEV_G_DV_TIMINGS, struct v4l2_dv_timings *argp)``
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ci.. c:macro:: VIDIOC_SUBDEV_S_DV_TIMINGS
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ci``int ioctl(int fd, VIDIOC_SUBDEV_S_DV_TIMINGS, struct v4l2_dv_timings *argp)``
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ciArguments
3562306a36Sopenharmony_ci=========
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ci``fd``
3862306a36Sopenharmony_ci    File descriptor returned by :c:func:`open()`.
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ci``argp``
4162306a36Sopenharmony_ci    Pointer to struct :c:type:`v4l2_dv_timings`.
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ciDescription
4462306a36Sopenharmony_ci===========
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_ciTo set DV timings for the input or output, applications use the
4762306a36Sopenharmony_ci:ref:`VIDIOC_S_DV_TIMINGS <VIDIOC_G_DV_TIMINGS>` ioctl and to get the current timings,
4862306a36Sopenharmony_ciapplications use the :ref:`VIDIOC_G_DV_TIMINGS <VIDIOC_G_DV_TIMINGS>` ioctl. The detailed timing
4962306a36Sopenharmony_ciinformation is filled in using the structure struct
5062306a36Sopenharmony_ci:c:type:`v4l2_dv_timings`. These ioctls take a
5162306a36Sopenharmony_cipointer to the struct :c:type:`v4l2_dv_timings`
5262306a36Sopenharmony_cistructure as argument. If the ioctl is not supported or the timing
5362306a36Sopenharmony_civalues are not correct, the driver returns ``EINVAL`` error code.
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ciCalling ``VIDIOC_SUBDEV_S_DV_TIMINGS`` on a subdev device node that has been
5662306a36Sopenharmony_ciregistered in read-only mode is not allowed. An error is returned and the errno
5762306a36Sopenharmony_civariable is set to ``-EPERM``.
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ciThe ``linux/v4l2-dv-timings.h`` header can be used to get the timings of
6062306a36Sopenharmony_cithe formats in the :ref:`cea861` and :ref:`vesadmt` standards. If
6162306a36Sopenharmony_cithe current input or output does not support DV timings (e.g. if
6262306a36Sopenharmony_ci:ref:`VIDIOC_ENUMINPUT` does not set the
6362306a36Sopenharmony_ci``V4L2_IN_CAP_DV_TIMINGS`` flag), then ``ENODATA`` error code is returned.
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_ciReturn Value
6662306a36Sopenharmony_ci============
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_ciOn success 0 is returned, on error -1 and the ``errno`` variable is set
6962306a36Sopenharmony_ciappropriately. The generic error codes are described at the
7062306a36Sopenharmony_ci:ref:`Generic Error Codes <gen-errors>` chapter.
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_ciEINVAL
7362306a36Sopenharmony_ci    This ioctl is not supported, or the :ref:`VIDIOC_S_DV_TIMINGS <VIDIOC_G_DV_TIMINGS>`
7462306a36Sopenharmony_ci    parameter was unsuitable.
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ciENODATA
7762306a36Sopenharmony_ci    Digital video timings are not supported for this input or output.
7862306a36Sopenharmony_ci
7962306a36Sopenharmony_ciEBUSY
8062306a36Sopenharmony_ci    The device is busy and therefore can not change the timings.
8162306a36Sopenharmony_ci
8262306a36Sopenharmony_ciEPERM
8362306a36Sopenharmony_ci    ``VIDIOC_SUBDEV_S_DV_TIMINGS`` has been called on a read-only subdevice.
8462306a36Sopenharmony_ci
8562306a36Sopenharmony_ci.. c:type:: v4l2_bt_timings
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ci.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
8862306a36Sopenharmony_ci
8962306a36Sopenharmony_ci.. cssclass:: longtable
9062306a36Sopenharmony_ci
9162306a36Sopenharmony_ci.. flat-table:: struct v4l2_bt_timings
9262306a36Sopenharmony_ci    :header-rows:  0
9362306a36Sopenharmony_ci    :stub-columns: 0
9462306a36Sopenharmony_ci    :widths:       1 1 2
9562306a36Sopenharmony_ci
9662306a36Sopenharmony_ci    * - __u32
9762306a36Sopenharmony_ci      - ``width``
9862306a36Sopenharmony_ci      - Width of the active video in pixels.
9962306a36Sopenharmony_ci    * - __u32
10062306a36Sopenharmony_ci      - ``height``
10162306a36Sopenharmony_ci      - Height of the active video frame in lines. So for interlaced
10262306a36Sopenharmony_ci	formats the height of the active video in each field is
10362306a36Sopenharmony_ci	``height``/2.
10462306a36Sopenharmony_ci    * - __u32
10562306a36Sopenharmony_ci      - ``interlaced``
10662306a36Sopenharmony_ci      - Progressive (``V4L2_DV_PROGRESSIVE``) or interlaced (``V4L2_DV_INTERLACED``).
10762306a36Sopenharmony_ci    * - __u32
10862306a36Sopenharmony_ci      - ``polarities``
10962306a36Sopenharmony_ci      - This is a bit mask that defines polarities of sync signals. bit 0
11062306a36Sopenharmony_ci	(``V4L2_DV_VSYNC_POS_POL``) is for vertical sync polarity and bit
11162306a36Sopenharmony_ci	1 (``V4L2_DV_HSYNC_POS_POL``) is for horizontal sync polarity. If
11262306a36Sopenharmony_ci	the bit is set (1) it is positive polarity and if is cleared (0),
11362306a36Sopenharmony_ci	it is negative polarity.
11462306a36Sopenharmony_ci    * - __u64
11562306a36Sopenharmony_ci      - ``pixelclock``
11662306a36Sopenharmony_ci      - Pixel clock in Hz. Ex. 74.25MHz->74250000
11762306a36Sopenharmony_ci    * - __u32
11862306a36Sopenharmony_ci      - ``hfrontporch``
11962306a36Sopenharmony_ci      - Horizontal front porch in pixels
12062306a36Sopenharmony_ci    * - __u32
12162306a36Sopenharmony_ci      - ``hsync``
12262306a36Sopenharmony_ci      - Horizontal sync length in pixels
12362306a36Sopenharmony_ci    * - __u32
12462306a36Sopenharmony_ci      - ``hbackporch``
12562306a36Sopenharmony_ci      - Horizontal back porch in pixels
12662306a36Sopenharmony_ci    * - __u32
12762306a36Sopenharmony_ci      - ``vfrontporch``
12862306a36Sopenharmony_ci      - Vertical front porch in lines. For interlaced formats this refers
12962306a36Sopenharmony_ci	to the odd field (aka field 1).
13062306a36Sopenharmony_ci    * - __u32
13162306a36Sopenharmony_ci      - ``vsync``
13262306a36Sopenharmony_ci      - Vertical sync length in lines. For interlaced formats this refers
13362306a36Sopenharmony_ci	to the odd field (aka field 1).
13462306a36Sopenharmony_ci    * - __u32
13562306a36Sopenharmony_ci      - ``vbackporch``
13662306a36Sopenharmony_ci      - Vertical back porch in lines. For interlaced formats this refers
13762306a36Sopenharmony_ci	to the odd field (aka field 1).
13862306a36Sopenharmony_ci    * - __u32
13962306a36Sopenharmony_ci      - ``il_vfrontporch``
14062306a36Sopenharmony_ci      - Vertical front porch in lines for the even field (aka field 2) of
14162306a36Sopenharmony_ci	interlaced field formats. Must be 0 for progressive formats.
14262306a36Sopenharmony_ci    * - __u32
14362306a36Sopenharmony_ci      - ``il_vsync``
14462306a36Sopenharmony_ci      - Vertical sync length in lines for the even field (aka field 2) of
14562306a36Sopenharmony_ci	interlaced field formats. Must be 0 for progressive formats.
14662306a36Sopenharmony_ci    * - __u32
14762306a36Sopenharmony_ci      - ``il_vbackporch``
14862306a36Sopenharmony_ci      - Vertical back porch in lines for the even field (aka field 2) of
14962306a36Sopenharmony_ci	interlaced field formats. Must be 0 for progressive formats.
15062306a36Sopenharmony_ci    * - __u32
15162306a36Sopenharmony_ci      - ``standards``
15262306a36Sopenharmony_ci      - The video standard(s) this format belongs to. This will be filled
15362306a36Sopenharmony_ci	in by the driver. Applications must set this to 0. See
15462306a36Sopenharmony_ci	:ref:`dv-bt-standards` for a list of standards.
15562306a36Sopenharmony_ci    * - __u32
15662306a36Sopenharmony_ci      - ``flags``
15762306a36Sopenharmony_ci      - Several flags giving more information about the format. See
15862306a36Sopenharmony_ci	:ref:`dv-bt-flags` for a description of the flags.
15962306a36Sopenharmony_ci    * - struct :c:type:`v4l2_fract`
16062306a36Sopenharmony_ci      - ``picture_aspect``
16162306a36Sopenharmony_ci      - The picture aspect if the pixels are not square. Only valid if the
16262306a36Sopenharmony_ci        ``V4L2_DV_FL_HAS_PICTURE_ASPECT`` flag is set.
16362306a36Sopenharmony_ci    * - __u8
16462306a36Sopenharmony_ci      - ``cea861_vic``
16562306a36Sopenharmony_ci      - The Video Identification Code according to the CEA-861 standard.
16662306a36Sopenharmony_ci        Only valid if the ``V4L2_DV_FL_HAS_CEA861_VIC`` flag is set.
16762306a36Sopenharmony_ci    * - __u8
16862306a36Sopenharmony_ci      - ``hdmi_vic``
16962306a36Sopenharmony_ci      - The Video Identification Code according to the HDMI standard.
17062306a36Sopenharmony_ci        Only valid if the ``V4L2_DV_FL_HAS_HDMI_VIC`` flag is set.
17162306a36Sopenharmony_ci    * - __u8
17262306a36Sopenharmony_ci      - ``reserved[46]``
17362306a36Sopenharmony_ci      - Reserved for future extensions. Drivers and applications must set
17462306a36Sopenharmony_ci	the array to zero.
17562306a36Sopenharmony_ci
17662306a36Sopenharmony_ci.. tabularcolumns:: |p{3.5cm}|p{3.5cm}|p{7.0cm}|p{3.1cm}|
17762306a36Sopenharmony_ci
17862306a36Sopenharmony_ci.. c:type:: v4l2_dv_timings
17962306a36Sopenharmony_ci
18062306a36Sopenharmony_ci.. flat-table:: struct v4l2_dv_timings
18162306a36Sopenharmony_ci    :header-rows:  0
18262306a36Sopenharmony_ci    :stub-columns: 0
18362306a36Sopenharmony_ci    :widths:       1 1 2
18462306a36Sopenharmony_ci
18562306a36Sopenharmony_ci    * - __u32
18662306a36Sopenharmony_ci      - ``type``
18762306a36Sopenharmony_ci      - Type of DV timings as listed in :ref:`dv-timing-types`.
18862306a36Sopenharmony_ci    * - union {
18962306a36Sopenharmony_ci      - (anonymous)
19062306a36Sopenharmony_ci    * - struct :c:type:`v4l2_bt_timings`
19162306a36Sopenharmony_ci      - ``bt``
19262306a36Sopenharmony_ci      - Timings defined by BT.656/1120 specifications
19362306a36Sopenharmony_ci    * - __u32
19462306a36Sopenharmony_ci      - ``reserved``\ [32]
19562306a36Sopenharmony_ci      -
19662306a36Sopenharmony_ci    * - }
19762306a36Sopenharmony_ci      -
19862306a36Sopenharmony_ci
19962306a36Sopenharmony_ci.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
20062306a36Sopenharmony_ci
20162306a36Sopenharmony_ci.. _dv-timing-types:
20262306a36Sopenharmony_ci
20362306a36Sopenharmony_ci.. flat-table:: DV Timing types
20462306a36Sopenharmony_ci    :header-rows:  0
20562306a36Sopenharmony_ci    :stub-columns: 0
20662306a36Sopenharmony_ci    :widths:       1 1 2
20762306a36Sopenharmony_ci
20862306a36Sopenharmony_ci    * - Timing type
20962306a36Sopenharmony_ci      - value
21062306a36Sopenharmony_ci      - Description
21162306a36Sopenharmony_ci    * -
21262306a36Sopenharmony_ci      -
21362306a36Sopenharmony_ci      -
21462306a36Sopenharmony_ci    * - ``V4L2_DV_BT_656_1120``
21562306a36Sopenharmony_ci      - 0
21662306a36Sopenharmony_ci      - BT.656/1120 timings
21762306a36Sopenharmony_ci
21862306a36Sopenharmony_ci.. tabularcolumns:: |p{6.5cm}|p{11.0cm}|
21962306a36Sopenharmony_ci
22062306a36Sopenharmony_ci.. cssclass:: longtable
22162306a36Sopenharmony_ci
22262306a36Sopenharmony_ci.. _dv-bt-standards:
22362306a36Sopenharmony_ci
22462306a36Sopenharmony_ci.. flat-table:: DV BT Timing standards
22562306a36Sopenharmony_ci    :header-rows:  0
22662306a36Sopenharmony_ci    :stub-columns: 0
22762306a36Sopenharmony_ci
22862306a36Sopenharmony_ci    * - Timing standard
22962306a36Sopenharmony_ci      - Description
23062306a36Sopenharmony_ci    * - ``V4L2_DV_BT_STD_CEA861``
23162306a36Sopenharmony_ci      - The timings follow the CEA-861 Digital TV Profile standard
23262306a36Sopenharmony_ci    * - ``V4L2_DV_BT_STD_DMT``
23362306a36Sopenharmony_ci      - The timings follow the VESA Discrete Monitor Timings standard
23462306a36Sopenharmony_ci    * - ``V4L2_DV_BT_STD_CVT``
23562306a36Sopenharmony_ci      - The timings follow the VESA Coordinated Video Timings standard
23662306a36Sopenharmony_ci    * - ``V4L2_DV_BT_STD_GTF``
23762306a36Sopenharmony_ci      - The timings follow the VESA Generalized Timings Formula standard
23862306a36Sopenharmony_ci    * - ``V4L2_DV_BT_STD_SDI``
23962306a36Sopenharmony_ci      - The timings follow the SDI Timings standard.
24062306a36Sopenharmony_ci	There are no horizontal syncs/porches at all in this format.
24162306a36Sopenharmony_ci	Total blanking timings must be set in hsync or vsync fields only.
24262306a36Sopenharmony_ci
24362306a36Sopenharmony_ci.. tabularcolumns:: |p{7.7cm}|p{9.8cm}|
24462306a36Sopenharmony_ci
24562306a36Sopenharmony_ci.. cssclass:: longtable
24662306a36Sopenharmony_ci
24762306a36Sopenharmony_ci.. _dv-bt-flags:
24862306a36Sopenharmony_ci
24962306a36Sopenharmony_ci.. flat-table:: DV BT Timing flags
25062306a36Sopenharmony_ci    :header-rows:  0
25162306a36Sopenharmony_ci    :stub-columns: 0
25262306a36Sopenharmony_ci
25362306a36Sopenharmony_ci    * - Flag
25462306a36Sopenharmony_ci      - Description
25562306a36Sopenharmony_ci    * - ``V4L2_DV_FL_REDUCED_BLANKING``
25662306a36Sopenharmony_ci      - CVT/GTF specific: the timings use reduced blanking (CVT) or the
25762306a36Sopenharmony_ci	'Secondary GTF' curve (GTF). In both cases the horizontal and/or
25862306a36Sopenharmony_ci	vertical blanking intervals are reduced, allowing a higher
25962306a36Sopenharmony_ci	resolution over the same bandwidth. This is a read-only flag,
26062306a36Sopenharmony_ci	applications must not set this.
26162306a36Sopenharmony_ci    * - ``V4L2_DV_FL_CAN_REDUCE_FPS``
26262306a36Sopenharmony_ci      - CEA-861 specific: set for CEA-861 formats with a framerate that is
26362306a36Sopenharmony_ci	a multiple of six. These formats can be optionally played at 1 /
26462306a36Sopenharmony_ci	1.001 speed to be compatible with 60 Hz based standards such as
26562306a36Sopenharmony_ci	NTSC and PAL-M that use a framerate of 29.97 frames per second. If
26662306a36Sopenharmony_ci	the transmitter can't generate such frequencies, then the flag
26762306a36Sopenharmony_ci	will also be cleared. This is a read-only flag, applications must
26862306a36Sopenharmony_ci	not set this.
26962306a36Sopenharmony_ci    * - ``V4L2_DV_FL_REDUCED_FPS``
27062306a36Sopenharmony_ci      - CEA-861 specific: only valid for video transmitters or video
27162306a36Sopenharmony_ci        receivers that have the ``V4L2_DV_FL_CAN_DETECT_REDUCED_FPS``
27262306a36Sopenharmony_ci	set. This flag is cleared otherwise. It is also only valid for
27362306a36Sopenharmony_ci	formats with the ``V4L2_DV_FL_CAN_REDUCE_FPS`` flag set, for other
27462306a36Sopenharmony_ci	formats the flag will be cleared by the driver.
27562306a36Sopenharmony_ci
27662306a36Sopenharmony_ci	If the application sets this flag for a transmitter, then the
27762306a36Sopenharmony_ci	pixelclock used to set up the transmitter is divided by 1.001 to
27862306a36Sopenharmony_ci	make it compatible with NTSC framerates. If the transmitter can't
27962306a36Sopenharmony_ci	generate such frequencies, then the flag will be cleared.
28062306a36Sopenharmony_ci
28162306a36Sopenharmony_ci	If a video receiver detects that the format uses a reduced framerate,
28262306a36Sopenharmony_ci	then it will set this flag to signal this to the application.
28362306a36Sopenharmony_ci    * - ``V4L2_DV_FL_HALF_LINE``
28462306a36Sopenharmony_ci      - Specific to interlaced formats: if set, then the vertical
28562306a36Sopenharmony_ci	frontporch of field 1 (aka the odd field) is really one half-line
28662306a36Sopenharmony_ci	longer and the vertical backporch of field 2 (aka the even field)
28762306a36Sopenharmony_ci	is really one half-line shorter, so each field has exactly the
28862306a36Sopenharmony_ci	same number of half-lines. Whether half-lines can be detected or
28962306a36Sopenharmony_ci	used depends on the hardware.
29062306a36Sopenharmony_ci    * - ``V4L2_DV_FL_IS_CE_VIDEO``
29162306a36Sopenharmony_ci      - If set, then this is a Consumer Electronics (CE) video format.
29262306a36Sopenharmony_ci	Such formats differ from other formats (commonly called IT
29362306a36Sopenharmony_ci	formats) in that if R'G'B' encoding is used then by default the
29462306a36Sopenharmony_ci	R'G'B' values use limited range (i.e. 16-235) as opposed to full
29562306a36Sopenharmony_ci	range (i.e. 0-255). All formats defined in CEA-861 except for the
29662306a36Sopenharmony_ci	640x480p59.94 format are CE formats.
29762306a36Sopenharmony_ci    * - ``V4L2_DV_FL_FIRST_FIELD_EXTRA_LINE``
29862306a36Sopenharmony_ci      - Some formats like SMPTE-125M have an interlaced signal with a odd
29962306a36Sopenharmony_ci	total height. For these formats, if this flag is set, the first
30062306a36Sopenharmony_ci	field has the extra line. Else, it is the second field.
30162306a36Sopenharmony_ci    * - ``V4L2_DV_FL_HAS_PICTURE_ASPECT``
30262306a36Sopenharmony_ci      - If set, then the picture_aspect field is valid. Otherwise assume that
30362306a36Sopenharmony_ci        the pixels are square, so the picture aspect ratio is the same as the
30462306a36Sopenharmony_ci	width to height ratio.
30562306a36Sopenharmony_ci    * - ``V4L2_DV_FL_HAS_CEA861_VIC``
30662306a36Sopenharmony_ci      - If set, then the cea861_vic field is valid and contains the Video
30762306a36Sopenharmony_ci        Identification Code as per the CEA-861 standard.
30862306a36Sopenharmony_ci    * - ``V4L2_DV_FL_HAS_HDMI_VIC``
30962306a36Sopenharmony_ci      - If set, then the hdmi_vic field is valid and contains the Video
31062306a36Sopenharmony_ci        Identification Code as per the HDMI standard (HDMI Vendor Specific
31162306a36Sopenharmony_ci	InfoFrame).
31262306a36Sopenharmony_ci    * - ``V4L2_DV_FL_CAN_DETECT_REDUCED_FPS``
31362306a36Sopenharmony_ci      - CEA-861 specific: only valid for video receivers, the flag is
31462306a36Sopenharmony_ci        cleared by transmitters.
31562306a36Sopenharmony_ci        If set, then the hardware can detect the difference between
31662306a36Sopenharmony_ci	regular framerates and framerates reduced by 1000/1001. E.g.:
31762306a36Sopenharmony_ci	60 vs 59.94 Hz, 30 vs 29.97 Hz or 24 vs 23.976 Hz.
318