162306a36Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later 262306a36Sopenharmony_ci.. c:namespace:: V4L 362306a36Sopenharmony_ci 462306a36Sopenharmony_ci.. _sliced: 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci************************* 762306a36Sopenharmony_ciSliced VBI Data Interface 862306a36Sopenharmony_ci************************* 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ciVBI stands for Vertical Blanking Interval, a gap in the sequence of 1162306a36Sopenharmony_cilines of an analog video signal. During VBI no picture information is 1262306a36Sopenharmony_citransmitted, allowing some time while the electron beam of a cathode ray 1362306a36Sopenharmony_citube TV returns to the top of the screen. 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ciSliced VBI devices use hardware to demodulate data transmitted in the 1662306a36Sopenharmony_ciVBI. V4L2 drivers shall *not* do this by software, see also the 1762306a36Sopenharmony_ci:ref:`raw VBI interface <raw-vbi>`. The data is passed as short 1862306a36Sopenharmony_cipackets of fixed size, covering one scan line each. The number of 1962306a36Sopenharmony_cipackets per video frame is variable. 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ciSliced VBI capture and output devices are accessed through the same 2262306a36Sopenharmony_cicharacter special files as raw VBI devices. When a driver supports both 2362306a36Sopenharmony_ciinterfaces, the default function of a ``/dev/vbi`` device is *raw* VBI 2462306a36Sopenharmony_cicapturing or output, and the sliced VBI function is only available after 2562306a36Sopenharmony_cicalling the :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ioctl as defined 2662306a36Sopenharmony_cibelow. Likewise a ``/dev/video`` device may support the sliced VBI API, 2762306a36Sopenharmony_cihowever the default function here is video capturing or output. 2862306a36Sopenharmony_ciDifferent file descriptors must be used to pass raw and sliced VBI data 2962306a36Sopenharmony_cisimultaneously, if this is supported by the driver. 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_ciQuerying Capabilities 3262306a36Sopenharmony_ci===================== 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ciDevices supporting the sliced VBI capturing or output API set the 3562306a36Sopenharmony_ci``V4L2_CAP_SLICED_VBI_CAPTURE`` or ``V4L2_CAP_SLICED_VBI_OUTPUT`` flag 3662306a36Sopenharmony_cirespectively, in the ``capabilities`` field of struct 3762306a36Sopenharmony_ci:c:type:`v4l2_capability` returned by the 3862306a36Sopenharmony_ci:ref:`VIDIOC_QUERYCAP` ioctl. At least one of the 3962306a36Sopenharmony_ciread/write or streaming :ref:`I/O methods <io>` must be 4062306a36Sopenharmony_cisupported. Sliced VBI devices may have a tuner or modulator. 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ciSupplemental Functions 4362306a36Sopenharmony_ci====================== 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_ciSliced VBI devices shall support :ref:`video input or output <video>` 4662306a36Sopenharmony_ciand :ref:`tuner or modulator <tuner>` ioctls if they have these 4762306a36Sopenharmony_cicapabilities, and they may support :ref:`control` ioctls. 4862306a36Sopenharmony_ciThe :ref:`video standard <standard>` ioctls provide information vital 4962306a36Sopenharmony_cito program a sliced VBI device, therefore must be supported. 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_ci.. _sliced-vbi-format-negotitation: 5262306a36Sopenharmony_ci 5362306a36Sopenharmony_ciSliced VBI Format Negotiation 5462306a36Sopenharmony_ci============================= 5562306a36Sopenharmony_ci 5662306a36Sopenharmony_ciTo find out which data services are supported by the hardware 5762306a36Sopenharmony_ciapplications can call the 5862306a36Sopenharmony_ci:ref:`VIDIOC_G_SLICED_VBI_CAP <VIDIOC_G_SLICED_VBI_CAP>` ioctl. 5962306a36Sopenharmony_ciAll drivers implementing the sliced VBI interface must support this 6062306a36Sopenharmony_ciioctl. The results may differ from those of the 6162306a36Sopenharmony_ci:ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ioctl when the number of VBI 6262306a36Sopenharmony_cilines the hardware can capture or output per frame, or the number of 6362306a36Sopenharmony_ciservices it can identify on a given line are limited. For example on PAL 6462306a36Sopenharmony_ciline 16 the hardware may be able to look for a VPS or Teletext signal, 6562306a36Sopenharmony_cibut not both at the same time. 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_ciTo determine the currently selected services applications set the 6862306a36Sopenharmony_ci``type`` field of struct :c:type:`v4l2_format` to 6962306a36Sopenharmony_ci``V4L2_BUF_TYPE_SLICED_VBI_CAPTURE`` or 7062306a36Sopenharmony_ci``V4L2_BUF_TYPE_SLICED_VBI_OUTPUT``, and the 7162306a36Sopenharmony_ci:ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>` ioctl fills the ``fmt.sliced`` 7262306a36Sopenharmony_cimember, a struct 7362306a36Sopenharmony_ci:c:type:`v4l2_sliced_vbi_format`. 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ciApplications can request different parameters by initializing or 7662306a36Sopenharmony_cimodifying the ``fmt.sliced`` member and calling the 7762306a36Sopenharmony_ci:ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ioctl with a pointer to the 7862306a36Sopenharmony_cistruct :c:type:`v4l2_format` structure. 7962306a36Sopenharmony_ci 8062306a36Sopenharmony_ciThe sliced VBI API is more complicated than the raw VBI API because the 8162306a36Sopenharmony_cihardware must be told which VBI service to expect on each scan line. Not 8262306a36Sopenharmony_ciall services may be supported by the hardware on all lines (this is 8362306a36Sopenharmony_ciespecially true for VBI output where Teletext is often unsupported and 8462306a36Sopenharmony_ciother services can only be inserted in one specific line). In many 8562306a36Sopenharmony_cicases, however, it is sufficient to just set the ``service_set`` field 8662306a36Sopenharmony_cito the required services and let the driver fill the ``service_lines`` 8762306a36Sopenharmony_ciarray according to hardware capabilities. Only if more precise control 8862306a36Sopenharmony_ciis needed should the programmer set the ``service_lines`` array 8962306a36Sopenharmony_ciexplicitly. 9062306a36Sopenharmony_ci 9162306a36Sopenharmony_ciThe :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ioctl modifies the parameters 9262306a36Sopenharmony_ciaccording to hardware capabilities. When the driver allocates resources 9362306a36Sopenharmony_ciat this point, it may return an ``EBUSY`` error code if the required 9462306a36Sopenharmony_ciresources are temporarily unavailable. Other resource allocation points 9562306a36Sopenharmony_ciwhich may return ``EBUSY`` can be the 9662306a36Sopenharmony_ci:ref:`VIDIOC_STREAMON` ioctl and the first 9762306a36Sopenharmony_ci:c:func:`read()`, :c:func:`write()` and 9862306a36Sopenharmony_ci:c:func:`select()` call. 9962306a36Sopenharmony_ci 10062306a36Sopenharmony_ci.. c:type:: v4l2_sliced_vbi_format 10162306a36Sopenharmony_ci 10262306a36Sopenharmony_cistruct v4l2_sliced_vbi_format 10362306a36Sopenharmony_ci----------------------------- 10462306a36Sopenharmony_ci 10562306a36Sopenharmony_ci.. raw:: latex 10662306a36Sopenharmony_ci 10762306a36Sopenharmony_ci \begingroup 10862306a36Sopenharmony_ci \scriptsize 10962306a36Sopenharmony_ci \setlength{\tabcolsep}{2pt} 11062306a36Sopenharmony_ci 11162306a36Sopenharmony_ci.. tabularcolumns:: |p{.85cm}|p{3.3cm}|p{4.45cm}|p{4.45cm}|p{4.45cm}| 11262306a36Sopenharmony_ci 11362306a36Sopenharmony_ci.. cssclass:: longtable 11462306a36Sopenharmony_ci 11562306a36Sopenharmony_ci.. flat-table:: 11662306a36Sopenharmony_ci :header-rows: 0 11762306a36Sopenharmony_ci :stub-columns: 0 11862306a36Sopenharmony_ci :widths: 3 3 2 2 2 11962306a36Sopenharmony_ci 12062306a36Sopenharmony_ci * - __u16 12162306a36Sopenharmony_ci - ``service_set`` 12262306a36Sopenharmony_ci - :cspan:`2` 12362306a36Sopenharmony_ci 12462306a36Sopenharmony_ci If ``service_set`` is non-zero when passed with 12562306a36Sopenharmony_ci :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` or 12662306a36Sopenharmony_ci :ref:`VIDIOC_TRY_FMT <VIDIOC_G_FMT>`, the ``service_lines`` 12762306a36Sopenharmony_ci array will be filled by the driver according to the services 12862306a36Sopenharmony_ci specified in this field. For example, if ``service_set`` is 12962306a36Sopenharmony_ci initialized with ``V4L2_SLICED_TELETEXT_B | V4L2_SLICED_WSS_625``, 13062306a36Sopenharmony_ci a driver for the cx25840 video decoder sets lines 7-22 of both 13162306a36Sopenharmony_ci fields [#f1]_ to ``V4L2_SLICED_TELETEXT_B`` and line 23 of the first 13262306a36Sopenharmony_ci field to ``V4L2_SLICED_WSS_625``. If ``service_set`` is set to 13362306a36Sopenharmony_ci zero, then the values of ``service_lines`` will be used instead. 13462306a36Sopenharmony_ci 13562306a36Sopenharmony_ci On return the driver sets this field to the union of all elements 13662306a36Sopenharmony_ci of the returned ``service_lines`` array. It may contain less 13762306a36Sopenharmony_ci services than requested, perhaps just one, if the hardware cannot 13862306a36Sopenharmony_ci handle more services simultaneously. It may be empty (zero) if 13962306a36Sopenharmony_ci none of the requested services are supported by the hardware. 14062306a36Sopenharmony_ci * - __u16 14162306a36Sopenharmony_ci - ``service_lines``\ [2][24] 14262306a36Sopenharmony_ci - :cspan:`2` 14362306a36Sopenharmony_ci 14462306a36Sopenharmony_ci Applications initialize this array with sets of data services the 14562306a36Sopenharmony_ci driver shall look for or insert on the respective scan line. 14662306a36Sopenharmony_ci Subject to hardware capabilities drivers return the requested set, 14762306a36Sopenharmony_ci a subset, which may be just a single service, or an empty set. 14862306a36Sopenharmony_ci When the hardware cannot handle multiple services on the same line 14962306a36Sopenharmony_ci the driver shall choose one. No assumptions can be made on which 15062306a36Sopenharmony_ci service the driver chooses. 15162306a36Sopenharmony_ci 15262306a36Sopenharmony_ci Data services are defined in :ref:`vbi-services2`. Array indices 15362306a36Sopenharmony_ci map to ITU-R line numbers\ [#f2]_ as follows: 15462306a36Sopenharmony_ci * - 15562306a36Sopenharmony_ci - 15662306a36Sopenharmony_ci - Element 15762306a36Sopenharmony_ci - 525 line systems 15862306a36Sopenharmony_ci - 625 line systems 15962306a36Sopenharmony_ci * - 16062306a36Sopenharmony_ci - 16162306a36Sopenharmony_ci - ``service_lines``\ [0][1] 16262306a36Sopenharmony_ci - 1 16362306a36Sopenharmony_ci - 1 16462306a36Sopenharmony_ci * - 16562306a36Sopenharmony_ci - 16662306a36Sopenharmony_ci - ``service_lines``\ [0][23] 16762306a36Sopenharmony_ci - 23 16862306a36Sopenharmony_ci - 23 16962306a36Sopenharmony_ci * - 17062306a36Sopenharmony_ci - 17162306a36Sopenharmony_ci - ``service_lines``\ [1][1] 17262306a36Sopenharmony_ci - 264 17362306a36Sopenharmony_ci - 314 17462306a36Sopenharmony_ci * - 17562306a36Sopenharmony_ci - 17662306a36Sopenharmony_ci - ``service_lines``\ [1][23] 17762306a36Sopenharmony_ci - 286 17862306a36Sopenharmony_ci - 336 17962306a36Sopenharmony_ci * - 18062306a36Sopenharmony_ci - 18162306a36Sopenharmony_ci - :cspan:`2` Drivers must set ``service_lines`` [0][0] and 18262306a36Sopenharmony_ci ``service_lines``\ [1][0] to zero. The 18362306a36Sopenharmony_ci ``V4L2_VBI_ITU_525_F1_START``, ``V4L2_VBI_ITU_525_F2_START``, 18462306a36Sopenharmony_ci ``V4L2_VBI_ITU_625_F1_START`` and ``V4L2_VBI_ITU_625_F2_START`` 18562306a36Sopenharmony_ci defines give the start line numbers for each field for each 525 or 18662306a36Sopenharmony_ci 625 line format as a convenience. Don't forget that ITU line 18762306a36Sopenharmony_ci numbering starts at 1, not 0. 18862306a36Sopenharmony_ci * - __u32 18962306a36Sopenharmony_ci - ``io_size`` 19062306a36Sopenharmony_ci - :cspan:`2` Maximum number of bytes passed by one 19162306a36Sopenharmony_ci :c:func:`read()` or :c:func:`write()` call, 19262306a36Sopenharmony_ci and the buffer size in bytes for the 19362306a36Sopenharmony_ci :ref:`VIDIOC_QBUF` and 19462306a36Sopenharmony_ci :ref:`VIDIOC_DQBUF <VIDIOC_QBUF>` ioctl. Drivers set this field 19562306a36Sopenharmony_ci to the size of struct 19662306a36Sopenharmony_ci :c:type:`v4l2_sliced_vbi_data` times the 19762306a36Sopenharmony_ci number of non-zero elements in the returned ``service_lines`` 19862306a36Sopenharmony_ci array (that is the number of lines potentially carrying data). 19962306a36Sopenharmony_ci * - __u32 20062306a36Sopenharmony_ci - ``reserved``\ [2] 20162306a36Sopenharmony_ci - :cspan:`2` This array is reserved for future extensions. 20262306a36Sopenharmony_ci 20362306a36Sopenharmony_ci Applications and drivers must set it to zero. 20462306a36Sopenharmony_ci 20562306a36Sopenharmony_ci.. raw:: latex 20662306a36Sopenharmony_ci 20762306a36Sopenharmony_ci \endgroup 20862306a36Sopenharmony_ci 20962306a36Sopenharmony_ci.. _vbi-services2: 21062306a36Sopenharmony_ci 21162306a36Sopenharmony_ciSliced VBI services 21262306a36Sopenharmony_ci------------------- 21362306a36Sopenharmony_ci 21462306a36Sopenharmony_ci.. raw:: latex 21562306a36Sopenharmony_ci 21662306a36Sopenharmony_ci \footnotesize 21762306a36Sopenharmony_ci 21862306a36Sopenharmony_ci.. tabularcolumns:: |p{4.2cm}|p{1.1cm}|p{2.1cm}|p{2.0cm}|p{6.5cm}| 21962306a36Sopenharmony_ci 22062306a36Sopenharmony_ci.. flat-table:: 22162306a36Sopenharmony_ci :header-rows: 1 22262306a36Sopenharmony_ci :stub-columns: 0 22362306a36Sopenharmony_ci :widths: 2 1 1 2 2 22462306a36Sopenharmony_ci 22562306a36Sopenharmony_ci * - Symbol 22662306a36Sopenharmony_ci - Value 22762306a36Sopenharmony_ci - Reference 22862306a36Sopenharmony_ci - Lines, usually 22962306a36Sopenharmony_ci - Payload 23062306a36Sopenharmony_ci * - ``V4L2_SLICED_TELETEXT_B`` (Teletext System B) 23162306a36Sopenharmony_ci - 0x0001 23262306a36Sopenharmony_ci - :ref:`ets300706`, 23362306a36Sopenharmony_ci 23462306a36Sopenharmony_ci :ref:`itu653` 23562306a36Sopenharmony_ci - PAL/SECAM line 7-22, 320-335 (second field 7-22) 23662306a36Sopenharmony_ci - Last 42 of the 45 byte Teletext packet, that is without clock 23762306a36Sopenharmony_ci run-in and framing code, lsb first transmitted. 23862306a36Sopenharmony_ci * - ``V4L2_SLICED_VPS`` 23962306a36Sopenharmony_ci - 0x0400 24062306a36Sopenharmony_ci - :ref:`ets300231` 24162306a36Sopenharmony_ci - PAL line 16 24262306a36Sopenharmony_ci - Byte number 3 to 15 according to Figure 9 of ETS 300 231, lsb 24362306a36Sopenharmony_ci first transmitted. 24462306a36Sopenharmony_ci * - ``V4L2_SLICED_CAPTION_525`` 24562306a36Sopenharmony_ci - 0x1000 24662306a36Sopenharmony_ci - :ref:`cea608` 24762306a36Sopenharmony_ci - NTSC line 21, 284 (second field 21) 24862306a36Sopenharmony_ci - Two bytes in transmission order, including parity bit, lsb first 24962306a36Sopenharmony_ci transmitted. 25062306a36Sopenharmony_ci * - ``V4L2_SLICED_WSS_625`` 25162306a36Sopenharmony_ci - 0x4000 25262306a36Sopenharmony_ci - :ref:`itu1119`, 25362306a36Sopenharmony_ci 25462306a36Sopenharmony_ci :ref:`en300294` 25562306a36Sopenharmony_ci - PAL/SECAM line 23 25662306a36Sopenharmony_ci - See :ref:`v4l2-sliced-wss-625-payload` below. 25762306a36Sopenharmony_ci * - ``V4L2_SLICED_VBI_525`` 25862306a36Sopenharmony_ci - 0x1000 25962306a36Sopenharmony_ci - :cspan:`2` Set of services applicable to 525 line systems. 26062306a36Sopenharmony_ci * - ``V4L2_SLICED_VBI_625`` 26162306a36Sopenharmony_ci - 0x4401 26262306a36Sopenharmony_ci - :cspan:`2` Set of services applicable to 625 line systems. 26362306a36Sopenharmony_ci 26462306a36Sopenharmony_ci.. raw:: latex 26562306a36Sopenharmony_ci 26662306a36Sopenharmony_ci \normalsize 26762306a36Sopenharmony_ci 26862306a36Sopenharmony_ciDrivers may return an ``EINVAL`` error code when applications attempt to 26962306a36Sopenharmony_ciread or write data without prior format negotiation, after switching the 27062306a36Sopenharmony_civideo standard (which may invalidate the negotiated VBI parameters) and 27162306a36Sopenharmony_ciafter switching the video input (which may change the video standard as 27262306a36Sopenharmony_cia side effect). The :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ioctl may 27362306a36Sopenharmony_cireturn an ``EBUSY`` error code when applications attempt to change the 27462306a36Sopenharmony_ciformat while i/o is in progress (between a 27562306a36Sopenharmony_ci:ref:`VIDIOC_STREAMON` and 27662306a36Sopenharmony_ci:ref:`VIDIOC_STREAMOFF <VIDIOC_STREAMON>` call, and after the first 27762306a36Sopenharmony_ci:c:func:`read()` or :c:func:`write()` call). 27862306a36Sopenharmony_ci 27962306a36Sopenharmony_ci.. _v4l2-sliced-wss-625-payload: 28062306a36Sopenharmony_ci 28162306a36Sopenharmony_ciV4L2_SLICED_WSS_625 payload 28262306a36Sopenharmony_ci~~~~~~~~~~~~~~~~~~~~~~~~~~~ 28362306a36Sopenharmony_ci 28462306a36Sopenharmony_ciThe payload for ``V4L2_SLICED_WSS_625`` is: 28562306a36Sopenharmony_ci 28662306a36Sopenharmony_ci +-----+------------------+-----------------------+ 28762306a36Sopenharmony_ci |Byte | 0 | 1 | 28862306a36Sopenharmony_ci +-----+--------+---------+-----------+-----------+ 28962306a36Sopenharmony_ci | | msb | lsb | msb | lsb | 29062306a36Sopenharmony_ci | +-+-+-+--+--+-+-+--+--+-+--+---+---+--+-+--+ 29162306a36Sopenharmony_ci | Bit |7|6|5|4 | 3|2|1|0 | x|x|13|12 | 11|10|9|8 | 29262306a36Sopenharmony_ci +-----+-+-+-+--+--+-+-+--+--+-+--+---+---+--+-+--+ 29362306a36Sopenharmony_ci 29462306a36Sopenharmony_ciReading and writing sliced VBI data 29562306a36Sopenharmony_ci=================================== 29662306a36Sopenharmony_ci 29762306a36Sopenharmony_ciA single :c:func:`read()` or :c:func:`write()` 29862306a36Sopenharmony_cicall must pass all data belonging to one video frame. That is an array 29962306a36Sopenharmony_ciof struct :c:type:`v4l2_sliced_vbi_data` structures with one or 30062306a36Sopenharmony_cimore elements and a total size not exceeding ``io_size`` bytes. Likewise 30162306a36Sopenharmony_ciin streaming I/O mode one buffer of ``io_size`` bytes must contain data 30262306a36Sopenharmony_ciof one video frame. The ``id`` of unused 30362306a36Sopenharmony_cistruct :c:type:`v4l2_sliced_vbi_data` elements must be zero. 30462306a36Sopenharmony_ci 30562306a36Sopenharmony_ci.. c:type:: v4l2_sliced_vbi_data 30662306a36Sopenharmony_ci 30762306a36Sopenharmony_cistruct v4l2_sliced_vbi_data 30862306a36Sopenharmony_ci--------------------------- 30962306a36Sopenharmony_ci 31062306a36Sopenharmony_ci.. tabularcolumns:: |p{1.2cm}|p{2.2cm}|p{13.9cm}| 31162306a36Sopenharmony_ci 31262306a36Sopenharmony_ci.. flat-table:: 31362306a36Sopenharmony_ci :header-rows: 0 31462306a36Sopenharmony_ci :stub-columns: 0 31562306a36Sopenharmony_ci :widths: 3 1 4 31662306a36Sopenharmony_ci 31762306a36Sopenharmony_ci * - __u32 31862306a36Sopenharmony_ci - ``id`` 31962306a36Sopenharmony_ci - A flag from :ref:`vbi-services` identifying the type of data in 32062306a36Sopenharmony_ci this packet. Only a single bit must be set. When the ``id`` of a 32162306a36Sopenharmony_ci captured packet is zero, the packet is empty and the contents of 32262306a36Sopenharmony_ci other fields are undefined. Applications shall ignore empty 32362306a36Sopenharmony_ci packets. When the ``id`` of a packet for output is zero the 32462306a36Sopenharmony_ci contents of the ``data`` field are undefined and the driver must 32562306a36Sopenharmony_ci no longer insert data on the requested ``field`` and ``line``. 32662306a36Sopenharmony_ci * - __u32 32762306a36Sopenharmony_ci - ``field`` 32862306a36Sopenharmony_ci - The video field number this data has been captured from, or shall 32962306a36Sopenharmony_ci be inserted at. ``0`` for the first field, ``1`` for the second 33062306a36Sopenharmony_ci field. 33162306a36Sopenharmony_ci * - __u32 33262306a36Sopenharmony_ci - ``line`` 33362306a36Sopenharmony_ci - The field (as opposed to frame) line number this data has been 33462306a36Sopenharmony_ci captured from, or shall be inserted at. See :ref:`vbi-525` and 33562306a36Sopenharmony_ci :ref:`vbi-625` for valid values. Sliced VBI capture devices can 33662306a36Sopenharmony_ci set the line number of all packets to ``0`` if the hardware cannot 33762306a36Sopenharmony_ci reliably identify scan lines. The field number must always be 33862306a36Sopenharmony_ci valid. 33962306a36Sopenharmony_ci * - __u32 34062306a36Sopenharmony_ci - ``reserved`` 34162306a36Sopenharmony_ci - This field is reserved for future extensions. Applications and 34262306a36Sopenharmony_ci drivers must set it to zero. 34362306a36Sopenharmony_ci * - __u8 34462306a36Sopenharmony_ci - ``data``\ [48] 34562306a36Sopenharmony_ci - The packet payload. See :ref:`vbi-services` for the contents and 34662306a36Sopenharmony_ci number of bytes passed for each data type. The contents of padding 34762306a36Sopenharmony_ci bytes at the end of this array are undefined, drivers and 34862306a36Sopenharmony_ci applications shall ignore them. 34962306a36Sopenharmony_ci 35062306a36Sopenharmony_ciPackets are always passed in ascending line number order, without 35162306a36Sopenharmony_ciduplicate line numbers. The :c:func:`write()` function and 35262306a36Sopenharmony_cithe :ref:`VIDIOC_QBUF` ioctl must return an ``EINVAL`` 35362306a36Sopenharmony_cierror code when applications violate this rule. They must also return an 35462306a36Sopenharmony_ciEINVAL error code when applications pass an incorrect field or line 35562306a36Sopenharmony_cinumber, or a combination of ``field``, ``line`` and ``id`` which has not 35662306a36Sopenharmony_cibeen negotiated with the :ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>` or 35762306a36Sopenharmony_ci:ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ioctl. When the line numbers are 35862306a36Sopenharmony_ciunknown the driver must pass the packets in transmitted order. The 35962306a36Sopenharmony_cidriver can insert empty packets with ``id`` set to zero anywhere in the 36062306a36Sopenharmony_cipacket array. 36162306a36Sopenharmony_ci 36262306a36Sopenharmony_ciTo assure synchronization and to distinguish from frame dropping, when a 36362306a36Sopenharmony_cicaptured frame does not carry any of the requested data services drivers 36462306a36Sopenharmony_cimust pass one or more empty packets. When an application fails to pass 36562306a36Sopenharmony_ciVBI data in time for output, the driver must output the last VPS and WSS 36662306a36Sopenharmony_cipacket again, and disable the output of Closed Caption and Teletext 36762306a36Sopenharmony_cidata, or output data which is ignored by Closed Caption and Teletext 36862306a36Sopenharmony_cidecoders. 36962306a36Sopenharmony_ci 37062306a36Sopenharmony_ciA sliced VBI device may support :ref:`read/write <rw>` and/or 37162306a36Sopenharmony_cistreaming (:ref:`memory mapping <mmap>` and/or 37262306a36Sopenharmony_ci:ref:`user pointer <userp>`) I/O. The latter bears the possibility of 37362306a36Sopenharmony_cisynchronizing video and VBI data by using buffer timestamps. 37462306a36Sopenharmony_ci 37562306a36Sopenharmony_ciSliced VBI Data in MPEG Streams 37662306a36Sopenharmony_ci=============================== 37762306a36Sopenharmony_ci 37862306a36Sopenharmony_ciIf a device can produce an MPEG output stream, it may be capable of 37962306a36Sopenharmony_ciproviding 38062306a36Sopenharmony_ci:ref:`negotiated sliced VBI services <sliced-vbi-format-negotitation>` 38162306a36Sopenharmony_cias data embedded in the MPEG stream. Users or applications control this 38262306a36Sopenharmony_cisliced VBI data insertion with the 38362306a36Sopenharmony_ci:ref:`V4L2_CID_MPEG_STREAM_VBI_FMT <v4l2-mpeg-stream-vbi-fmt>` 38462306a36Sopenharmony_cicontrol. 38562306a36Sopenharmony_ci 38662306a36Sopenharmony_ciIf the driver does not provide the 38762306a36Sopenharmony_ci:ref:`V4L2_CID_MPEG_STREAM_VBI_FMT <v4l2-mpeg-stream-vbi-fmt>` 38862306a36Sopenharmony_cicontrol, or only allows that control to be set to 38962306a36Sopenharmony_ci:ref:`V4L2_MPEG_STREAM_VBI_FMT_NONE <v4l2-mpeg-stream-vbi-fmt>`, 39062306a36Sopenharmony_cithen the device cannot embed sliced VBI data in the MPEG stream. 39162306a36Sopenharmony_ci 39262306a36Sopenharmony_ciThe 39362306a36Sopenharmony_ci:ref:`V4L2_CID_MPEG_STREAM_VBI_FMT <v4l2-mpeg-stream-vbi-fmt>` 39462306a36Sopenharmony_cicontrol does not implicitly set the device driver to capture nor cease 39562306a36Sopenharmony_cicapturing sliced VBI data. The control only indicates to embed sliced 39662306a36Sopenharmony_ciVBI data in the MPEG stream, if an application has negotiated sliced VBI 39762306a36Sopenharmony_ciservice be captured. 39862306a36Sopenharmony_ci 39962306a36Sopenharmony_ciIt may also be the case that a device can embed sliced VBI data in only 40062306a36Sopenharmony_cicertain types of MPEG streams: for example in an MPEG-2 PS but not an 40162306a36Sopenharmony_ciMPEG-2 TS. In this situation, if sliced VBI data insertion is requested, 40262306a36Sopenharmony_cithe sliced VBI data will be embedded in MPEG stream types when 40362306a36Sopenharmony_cisupported, and silently omitted from MPEG stream types where sliced VBI 40462306a36Sopenharmony_cidata insertion is not supported by the device. 40562306a36Sopenharmony_ci 40662306a36Sopenharmony_ciThe following subsections specify the format of the embedded sliced VBI 40762306a36Sopenharmony_cidata. 40862306a36Sopenharmony_ci 40962306a36Sopenharmony_ciMPEG Stream Embedded, Sliced VBI Data Format: NONE 41062306a36Sopenharmony_ci-------------------------------------------------- 41162306a36Sopenharmony_ci 41262306a36Sopenharmony_ciThe 41362306a36Sopenharmony_ci:ref:`V4L2_MPEG_STREAM_VBI_FMT_NONE <v4l2-mpeg-stream-vbi-fmt>` 41462306a36Sopenharmony_ciembedded sliced VBI format shall be interpreted by drivers as a control 41562306a36Sopenharmony_cito cease embedding sliced VBI data in MPEG streams. Neither the device 41662306a36Sopenharmony_cinor driver shall insert "empty" embedded sliced VBI data packets in the 41762306a36Sopenharmony_ciMPEG stream when this format is set. No MPEG stream data structures are 41862306a36Sopenharmony_cispecified for this format. 41962306a36Sopenharmony_ci 42062306a36Sopenharmony_ciMPEG Stream Embedded, Sliced VBI Data Format: IVTV 42162306a36Sopenharmony_ci-------------------------------------------------- 42262306a36Sopenharmony_ci 42362306a36Sopenharmony_ciThe 42462306a36Sopenharmony_ci:ref:`V4L2_MPEG_STREAM_VBI_FMT_IVTV <v4l2-mpeg-stream-vbi-fmt>` 42562306a36Sopenharmony_ciembedded sliced VBI format, when supported, indicates to the driver to 42662306a36Sopenharmony_ciembed up to 36 lines of sliced VBI data per frame in an MPEG-2 *Private 42762306a36Sopenharmony_ciStream 1 PES* packet encapsulated in an MPEG-2 *Program Pack* in the 42862306a36Sopenharmony_ciMPEG stream. 42962306a36Sopenharmony_ci 43062306a36Sopenharmony_ci*Historical context*: This format specification originates from a 43162306a36Sopenharmony_cicustom, embedded, sliced VBI data format used by the ``ivtv`` driver. 43262306a36Sopenharmony_ciThis format has already been informally specified in the kernel sources 43362306a36Sopenharmony_ciin the file ``Documentation/userspace-api/media/drivers/cx2341x-uapi.rst`` . The 43462306a36Sopenharmony_cimaximum size of the payload and other aspects of this format are driven 43562306a36Sopenharmony_ciby the CX23415 MPEG decoder's capabilities and limitations with respect 43662306a36Sopenharmony_cito extracting, decoding, and displaying sliced VBI data embedded within 43762306a36Sopenharmony_cian MPEG stream. 43862306a36Sopenharmony_ci 43962306a36Sopenharmony_ciThis format's use is *not* exclusive to the ``ivtv`` driver *nor* 44062306a36Sopenharmony_ciexclusive to CX2341x devices, as the sliced VBI data packet insertion 44162306a36Sopenharmony_ciinto the MPEG stream is implemented in driver software. At least the 44262306a36Sopenharmony_ci``cx18`` driver provides sliced VBI data insertion into an MPEG-2 PS in 44362306a36Sopenharmony_cithis format as well. 44462306a36Sopenharmony_ci 44562306a36Sopenharmony_ciThe following definitions specify the payload of the MPEG-2 *Private 44662306a36Sopenharmony_ciStream 1 PES* packets that contain sliced VBI data when 44762306a36Sopenharmony_ci:ref:`V4L2_MPEG_STREAM_VBI_FMT_IVTV <v4l2-mpeg-stream-vbi-fmt>` 44862306a36Sopenharmony_ciis set. (The MPEG-2 *Private Stream 1 PES* packet header and 44962306a36Sopenharmony_ciencapsulating MPEG-2 *Program Pack* header are not detailed here. Please 45062306a36Sopenharmony_cirefer to the MPEG-2 specifications for details on those packet headers.) 45162306a36Sopenharmony_ci 45262306a36Sopenharmony_ciThe payload of the MPEG-2 *Private Stream 1 PES* packets that contain 45362306a36Sopenharmony_cisliced VBI data is specified by struct 45462306a36Sopenharmony_ci:c:type:`v4l2_mpeg_vbi_fmt_ivtv`. The 45562306a36Sopenharmony_cipayload is variable length, depending on the actual number of lines of 45662306a36Sopenharmony_cisliced VBI data present in a video frame. The payload may be padded at 45762306a36Sopenharmony_cithe end with unspecified fill bytes to align the end of the payload to a 45862306a36Sopenharmony_ci4-byte boundary. The payload shall never exceed 1552 bytes (2 fields 45962306a36Sopenharmony_ciwith 18 lines/field with 43 bytes of data/line and a 4 byte magic 46062306a36Sopenharmony_cinumber). 46162306a36Sopenharmony_ci 46262306a36Sopenharmony_ci.. c:type:: v4l2_mpeg_vbi_fmt_ivtv 46362306a36Sopenharmony_ci 46462306a36Sopenharmony_cistruct v4l2_mpeg_vbi_fmt_ivtv 46562306a36Sopenharmony_ci----------------------------- 46662306a36Sopenharmony_ci 46762306a36Sopenharmony_ci.. tabularcolumns:: |p{4.2cm}|p{2.0cm}|p{11.1cm}| 46862306a36Sopenharmony_ci 46962306a36Sopenharmony_ci.. flat-table:: 47062306a36Sopenharmony_ci :header-rows: 0 47162306a36Sopenharmony_ci :stub-columns: 0 47262306a36Sopenharmony_ci :widths: 1 1 2 47362306a36Sopenharmony_ci 47462306a36Sopenharmony_ci * - __u8 47562306a36Sopenharmony_ci - ``magic``\ [4] 47662306a36Sopenharmony_ci - A "magic" constant from :ref:`v4l2-mpeg-vbi-fmt-ivtv-magic` that 47762306a36Sopenharmony_ci indicates this is a valid sliced VBI data payload and also 47862306a36Sopenharmony_ci indicates which member of the anonymous union, ``itv0`` or 47962306a36Sopenharmony_ci ``ITV0``, to use for the payload data. 48062306a36Sopenharmony_ci * - union { 48162306a36Sopenharmony_ci - (anonymous) 48262306a36Sopenharmony_ci * - struct :c:type:`v4l2_mpeg_vbi_itv0` 48362306a36Sopenharmony_ci - ``itv0`` 48462306a36Sopenharmony_ci - The primary form of the sliced VBI data payload that contains 48562306a36Sopenharmony_ci anywhere from 1 to 35 lines of sliced VBI data. Line masks are 48662306a36Sopenharmony_ci provided in this form of the payload indicating which VBI lines 48762306a36Sopenharmony_ci are provided. 48862306a36Sopenharmony_ci * - struct :ref:`v4l2_mpeg_vbi_ITV0 <v4l2-mpeg-vbi-itv0-1>` 48962306a36Sopenharmony_ci - ``ITV0`` 49062306a36Sopenharmony_ci - An alternate form of the sliced VBI data payload used when 36 49162306a36Sopenharmony_ci lines of sliced VBI data are present. No line masks are provided 49262306a36Sopenharmony_ci in this form of the payload; all valid line mask bits are 49362306a36Sopenharmony_ci implicitly set. 49462306a36Sopenharmony_ci * - } 49562306a36Sopenharmony_ci - 49662306a36Sopenharmony_ci 49762306a36Sopenharmony_ci.. _v4l2-mpeg-vbi-fmt-ivtv-magic: 49862306a36Sopenharmony_ci 49962306a36Sopenharmony_ciMagic Constants for struct v4l2_mpeg_vbi_fmt_ivtv magic field 50062306a36Sopenharmony_ci------------------------------------------------------------- 50162306a36Sopenharmony_ci 50262306a36Sopenharmony_ci.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}| 50362306a36Sopenharmony_ci 50462306a36Sopenharmony_ci.. flat-table:: 50562306a36Sopenharmony_ci :header-rows: 1 50662306a36Sopenharmony_ci :stub-columns: 0 50762306a36Sopenharmony_ci :widths: 3 1 4 50862306a36Sopenharmony_ci 50962306a36Sopenharmony_ci * - Defined Symbol 51062306a36Sopenharmony_ci - Value 51162306a36Sopenharmony_ci - Description 51262306a36Sopenharmony_ci * - ``V4L2_MPEG_VBI_IVTV_MAGIC0`` 51362306a36Sopenharmony_ci - "itv0" 51462306a36Sopenharmony_ci - Indicates the ``itv0`` member of the union in struct 51562306a36Sopenharmony_ci :c:type:`v4l2_mpeg_vbi_fmt_ivtv` is 51662306a36Sopenharmony_ci valid. 51762306a36Sopenharmony_ci * - ``V4L2_MPEG_VBI_IVTV_MAGIC1`` 51862306a36Sopenharmony_ci - "ITV0" 51962306a36Sopenharmony_ci - Indicates the ``ITV0`` member of the union in struct 52062306a36Sopenharmony_ci :c:type:`v4l2_mpeg_vbi_fmt_ivtv` is 52162306a36Sopenharmony_ci valid and that 36 lines of sliced VBI data are present. 52262306a36Sopenharmony_ci 52362306a36Sopenharmony_ci 52462306a36Sopenharmony_ci.. c:type:: v4l2_mpeg_vbi_itv0 52562306a36Sopenharmony_ci 52662306a36Sopenharmony_ci.. c:type:: v4l2_mpeg_vbi_ITV0 52762306a36Sopenharmony_ci 52862306a36Sopenharmony_cistructs v4l2_mpeg_vbi_itv0 and v4l2_mpeg_vbi_ITV0 52962306a36Sopenharmony_ci------------------------------------------------- 53062306a36Sopenharmony_ci 53162306a36Sopenharmony_ci.. raw:: latex 53262306a36Sopenharmony_ci 53362306a36Sopenharmony_ci \footnotesize 53462306a36Sopenharmony_ci 53562306a36Sopenharmony_ci.. tabularcolumns:: |p{4.6cm}|p{2.0cm}|p{10.7cm}| 53662306a36Sopenharmony_ci 53762306a36Sopenharmony_ci.. flat-table:: 53862306a36Sopenharmony_ci :header-rows: 0 53962306a36Sopenharmony_ci :stub-columns: 0 54062306a36Sopenharmony_ci :widths: 1 1 2 54162306a36Sopenharmony_ci 54262306a36Sopenharmony_ci * - __le32 54362306a36Sopenharmony_ci - ``linemask``\ [2] 54462306a36Sopenharmony_ci - Bitmasks indicating the VBI service lines present. These 54562306a36Sopenharmony_ci ``linemask`` values are stored in little endian byte order in the 54662306a36Sopenharmony_ci MPEG stream. Some reference ``linemask`` bit positions with their 54762306a36Sopenharmony_ci corresponding VBI line number and video field are given below. 54862306a36Sopenharmony_ci b\ :sub:`0` indicates the least significant bit of a ``linemask`` 54962306a36Sopenharmony_ci value: 55062306a36Sopenharmony_ci 55162306a36Sopenharmony_ci 55262306a36Sopenharmony_ci :: 55362306a36Sopenharmony_ci 55462306a36Sopenharmony_ci linemask[0] b0: line 6 first field 55562306a36Sopenharmony_ci linemask[0] b17: line 23 first field 55662306a36Sopenharmony_ci linemask[0] b18: line 6 second field 55762306a36Sopenharmony_ci linemask[0] b31: line 19 second field 55862306a36Sopenharmony_ci linemask[1] b0: line 20 second field 55962306a36Sopenharmony_ci linemask[1] b3: line 23 second field 56062306a36Sopenharmony_ci linemask[1] b4-b31: unused and set to 0 56162306a36Sopenharmony_ci * - struct 56262306a36Sopenharmony_ci :c:type:`v4l2_mpeg_vbi_itv0_line` 56362306a36Sopenharmony_ci - ``line``\ [35] 56462306a36Sopenharmony_ci - This is a variable length array that holds from 1 to 35 lines of 56562306a36Sopenharmony_ci sliced VBI data. The sliced VBI data lines present correspond to 56662306a36Sopenharmony_ci the bits set in the ``linemask`` array, starting from b\ :sub:`0` 56762306a36Sopenharmony_ci of ``linemask``\ [0] up through b\ :sub:`31` of ``linemask``\ [0], 56862306a36Sopenharmony_ci and from b\ :sub:`0` of ``linemask``\ [1] up through b\ :sub:`3` of 56962306a36Sopenharmony_ci ``linemask``\ [1]. ``line``\ [0] corresponds to the first bit 57062306a36Sopenharmony_ci found set in the ``linemask`` array, ``line``\ [1] corresponds to 57162306a36Sopenharmony_ci the second bit found set in the ``linemask`` array, etc. If no 57262306a36Sopenharmony_ci ``linemask`` array bits are set, then ``line``\ [0] may contain 57362306a36Sopenharmony_ci one line of unspecified data that should be ignored by 57462306a36Sopenharmony_ci applications. 57562306a36Sopenharmony_ci 57662306a36Sopenharmony_ci.. raw:: latex 57762306a36Sopenharmony_ci 57862306a36Sopenharmony_ci \normalsize 57962306a36Sopenharmony_ci 58062306a36Sopenharmony_ci.. _v4l2-mpeg-vbi-itv0-1: 58162306a36Sopenharmony_ci 58262306a36Sopenharmony_cistruct v4l2_mpeg_vbi_ITV0 58362306a36Sopenharmony_ci------------------------- 58462306a36Sopenharmony_ci 58562306a36Sopenharmony_ci.. tabularcolumns:: |p{5.2cm}|p{2.4cm}|p{9.7cm}| 58662306a36Sopenharmony_ci 58762306a36Sopenharmony_ci.. flat-table:: 58862306a36Sopenharmony_ci :header-rows: 0 58962306a36Sopenharmony_ci :stub-columns: 0 59062306a36Sopenharmony_ci :widths: 1 1 2 59162306a36Sopenharmony_ci 59262306a36Sopenharmony_ci * - struct 59362306a36Sopenharmony_ci :c:type:`v4l2_mpeg_vbi_itv0_line` 59462306a36Sopenharmony_ci - ``line``\ [36] 59562306a36Sopenharmony_ci - A fixed length array of 36 lines of sliced VBI data. ``line``\ [0] 59662306a36Sopenharmony_ci through ``line``\ [17] correspond to lines 6 through 23 of the 59762306a36Sopenharmony_ci first field. ``line``\ [18] through ``line``\ [35] corresponds to 59862306a36Sopenharmony_ci lines 6 through 23 of the second field. 59962306a36Sopenharmony_ci 60062306a36Sopenharmony_ci 60162306a36Sopenharmony_ci.. c:type:: v4l2_mpeg_vbi_itv0_line 60262306a36Sopenharmony_ci 60362306a36Sopenharmony_cistruct v4l2_mpeg_vbi_itv0_line 60462306a36Sopenharmony_ci------------------------------ 60562306a36Sopenharmony_ci 60662306a36Sopenharmony_ci.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}| 60762306a36Sopenharmony_ci 60862306a36Sopenharmony_ci.. flat-table:: 60962306a36Sopenharmony_ci :header-rows: 0 61062306a36Sopenharmony_ci :stub-columns: 0 61162306a36Sopenharmony_ci :widths: 1 1 2 61262306a36Sopenharmony_ci 61362306a36Sopenharmony_ci * - __u8 61462306a36Sopenharmony_ci - ``id`` 61562306a36Sopenharmony_ci - A line identifier value from 61662306a36Sopenharmony_ci :ref:`ITV0-Line-Identifier-Constants` that indicates the type of 61762306a36Sopenharmony_ci sliced VBI data stored on this line. 61862306a36Sopenharmony_ci * - __u8 61962306a36Sopenharmony_ci - ``data``\ [42] 62062306a36Sopenharmony_ci - The sliced VBI data for the line. 62162306a36Sopenharmony_ci 62262306a36Sopenharmony_ci 62362306a36Sopenharmony_ci.. _ITV0-Line-Identifier-Constants: 62462306a36Sopenharmony_ci 62562306a36Sopenharmony_ciLine Identifiers for struct v4l2_mpeg_vbi_itv0_line id field 62662306a36Sopenharmony_ci------------------------------------------------------------ 62762306a36Sopenharmony_ci 62862306a36Sopenharmony_ci.. tabularcolumns:: |p{7.0cm}|p{1.8cm}|p{8.5cm}| 62962306a36Sopenharmony_ci 63062306a36Sopenharmony_ci.. flat-table:: 63162306a36Sopenharmony_ci :header-rows: 1 63262306a36Sopenharmony_ci :stub-columns: 0 63362306a36Sopenharmony_ci :widths: 3 1 4 63462306a36Sopenharmony_ci 63562306a36Sopenharmony_ci * - Defined Symbol 63662306a36Sopenharmony_ci - Value 63762306a36Sopenharmony_ci - Description 63862306a36Sopenharmony_ci * - ``V4L2_MPEG_VBI_IVTV_TELETEXT_B`` 63962306a36Sopenharmony_ci - 1 64062306a36Sopenharmony_ci - Refer to :ref:`Sliced VBI services <vbi-services2>` for a 64162306a36Sopenharmony_ci description of the line payload. 64262306a36Sopenharmony_ci * - ``V4L2_MPEG_VBI_IVTV_CAPTION_525`` 64362306a36Sopenharmony_ci - 4 64462306a36Sopenharmony_ci - Refer to :ref:`Sliced VBI services <vbi-services2>` for a 64562306a36Sopenharmony_ci description of the line payload. 64662306a36Sopenharmony_ci * - ``V4L2_MPEG_VBI_IVTV_WSS_625`` 64762306a36Sopenharmony_ci - 5 64862306a36Sopenharmony_ci - Refer to :ref:`Sliced VBI services <vbi-services2>` for a 64962306a36Sopenharmony_ci description of the line payload. 65062306a36Sopenharmony_ci * - ``V4L2_MPEG_VBI_IVTV_VPS`` 65162306a36Sopenharmony_ci - 7 65262306a36Sopenharmony_ci - Refer to :ref:`Sliced VBI services <vbi-services2>` for a 65362306a36Sopenharmony_ci description of the line payload. 65462306a36Sopenharmony_ci 65562306a36Sopenharmony_ci 65662306a36Sopenharmony_ci.. [#f1] 65762306a36Sopenharmony_ci According to :ref:`ETS 300 706 <ets300706>` lines 6-22 of the first 65862306a36Sopenharmony_ci field and lines 5-22 of the second field may carry Teletext data. 65962306a36Sopenharmony_ci 66062306a36Sopenharmony_ci.. [#f2] 66162306a36Sopenharmony_ci See also :ref:`vbi-525` and :ref:`vbi-625`. 662