18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later 28c2ecf20Sopenharmony_ci.. c:namespace:: V4L 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci.. _buffer: 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci******* 78c2ecf20Sopenharmony_ciBuffers 88c2ecf20Sopenharmony_ci******* 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ciA buffer contains data exchanged by application and driver using one of 118c2ecf20Sopenharmony_cithe Streaming I/O methods. In the multi-planar API, the data is held in 128c2ecf20Sopenharmony_ciplanes, while the buffer structure acts as a container for the planes. 138c2ecf20Sopenharmony_ciOnly pointers to buffers (planes) are exchanged, the data itself is not 148c2ecf20Sopenharmony_cicopied. These pointers, together with meta-information like timestamps 158c2ecf20Sopenharmony_cior field parity, are stored in a struct :c:type:`v4l2_buffer`, 168c2ecf20Sopenharmony_ciargument to the :ref:`VIDIOC_QUERYBUF`, 178c2ecf20Sopenharmony_ci:ref:`VIDIOC_QBUF <VIDIOC_QBUF>` and 188c2ecf20Sopenharmony_ci:ref:`VIDIOC_DQBUF <VIDIOC_QBUF>` ioctl. In the multi-planar API, 198c2ecf20Sopenharmony_cisome plane-specific members of struct :c:type:`v4l2_buffer`, 208c2ecf20Sopenharmony_cisuch as pointers and sizes for each plane, are stored in 218c2ecf20Sopenharmony_cistruct :c:type:`v4l2_plane` instead. In that case, 228c2ecf20Sopenharmony_cistruct :c:type:`v4l2_buffer` contains an array of plane structures. 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ciDequeued video buffers come with timestamps. The driver decides at which 258c2ecf20Sopenharmony_cipart of the frame and with which clock the timestamp is taken. Please 268c2ecf20Sopenharmony_cisee flags in the masks ``V4L2_BUF_FLAG_TIMESTAMP_MASK`` and 278c2ecf20Sopenharmony_ci``V4L2_BUF_FLAG_TSTAMP_SRC_MASK`` in :ref:`buffer-flags`. These flags 288c2ecf20Sopenharmony_ciare always valid and constant across all buffers during the whole video 298c2ecf20Sopenharmony_cistream. Changes in these flags may take place as a side effect of 308c2ecf20Sopenharmony_ci:ref:`VIDIOC_S_INPUT <VIDIOC_G_INPUT>` or 318c2ecf20Sopenharmony_ci:ref:`VIDIOC_S_OUTPUT <VIDIOC_G_OUTPUT>` however. The 328c2ecf20Sopenharmony_ci``V4L2_BUF_FLAG_TIMESTAMP_COPY`` timestamp type which is used by e.g. on 338c2ecf20Sopenharmony_cimem-to-mem devices is an exception to the rule: the timestamp source 348c2ecf20Sopenharmony_ciflags are copied from the OUTPUT video buffer to the CAPTURE video 358c2ecf20Sopenharmony_cibuffer. 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ciInteractions between formats, controls and buffers 388c2ecf20Sopenharmony_ci================================================== 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ciV4L2 exposes parameters that influence the buffer size, or the way data is 418c2ecf20Sopenharmony_cilaid out in the buffer. Those parameters are exposed through both formats and 428c2ecf20Sopenharmony_cicontrols. One example of such a control is the ``V4L2_CID_ROTATE`` control 438c2ecf20Sopenharmony_cithat modifies the direction in which pixels are stored in the buffer, as well 448c2ecf20Sopenharmony_cias the buffer size when the selected format includes padding at the end of 458c2ecf20Sopenharmony_cilines. 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ciThe set of information needed to interpret the content of a buffer (e.g. the 488c2ecf20Sopenharmony_cipixel format, the line stride, the tiling orientation or the rotation) is 498c2ecf20Sopenharmony_cicollectively referred to in the rest of this section as the buffer layout. 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ciControls that can modify the buffer layout shall set the 528c2ecf20Sopenharmony_ci``V4L2_CTRL_FLAG_MODIFY_LAYOUT`` flag. 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ciModifying formats or controls that influence the buffer size or layout require 558c2ecf20Sopenharmony_cithe stream to be stopped. Any attempt at such a modification while the stream 568c2ecf20Sopenharmony_ciis active shall cause the ioctl setting the format or the control to return 578c2ecf20Sopenharmony_cithe ``EBUSY`` error code. In that case drivers shall also set the 588c2ecf20Sopenharmony_ci``V4L2_CTRL_FLAG_GRABBED`` flag when calling 598c2ecf20Sopenharmony_ci:c:func:`VIDIOC_QUERYCTRL` or :c:func:`VIDIOC_QUERY_EXT_CTRL` for such a 608c2ecf20Sopenharmony_cicontrol while the stream is active. 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci.. note:: 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci The :c:func:`VIDIOC_S_SELECTION` ioctl can, depending on the hardware (for 658c2ecf20Sopenharmony_ci instance if the device doesn't include a scaler), modify the format in 668c2ecf20Sopenharmony_ci addition to the selection rectangle. Similarly, the 678c2ecf20Sopenharmony_ci :c:func:`VIDIOC_S_INPUT`, :c:func:`VIDIOC_S_OUTPUT`, :c:func:`VIDIOC_S_STD` 688c2ecf20Sopenharmony_ci and :c:func:`VIDIOC_S_DV_TIMINGS` ioctls can also modify the format and 698c2ecf20Sopenharmony_ci selection rectangles. When those ioctls result in a buffer size or layout 708c2ecf20Sopenharmony_ci change, drivers shall handle that condition as they would handle it in the 718c2ecf20Sopenharmony_ci :c:func:`VIDIOC_S_FMT` ioctl in all cases described in this section. 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ciControls that only influence the buffer layout can be modified at any time 748c2ecf20Sopenharmony_ciwhen the stream is stopped. As they don't influence the buffer size, no 758c2ecf20Sopenharmony_cispecial handling is needed to synchronize those controls with buffer 768c2ecf20Sopenharmony_ciallocation and the ``V4L2_CTRL_FLAG_GRABBED`` flag is cleared once the 778c2ecf20Sopenharmony_cistream is stopped. 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ciFormats and controls that influence the buffer size interact with buffer 808c2ecf20Sopenharmony_ciallocation. The simplest way to handle this is for drivers to always require 818c2ecf20Sopenharmony_cibuffers to be reallocated in order to change those formats or controls. In 828c2ecf20Sopenharmony_cithat case, to perform such changes, userspace applications shall first stop 838c2ecf20Sopenharmony_cithe video stream with the :c:func:`VIDIOC_STREAMOFF` ioctl if it is running 848c2ecf20Sopenharmony_ciand free all buffers with the :c:func:`VIDIOC_REQBUFS` ioctl if they are 858c2ecf20Sopenharmony_ciallocated. After freeing all buffers the ``V4L2_CTRL_FLAG_GRABBED`` flag 868c2ecf20Sopenharmony_cifor controls is cleared. The format or controls can then be modified, and 878c2ecf20Sopenharmony_cibuffers shall then be reallocated and the stream restarted. A typical ioctl 888c2ecf20Sopenharmony_cisequence is 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci #. VIDIOC_STREAMOFF 918c2ecf20Sopenharmony_ci #. VIDIOC_REQBUFS(0) 928c2ecf20Sopenharmony_ci #. VIDIOC_S_EXT_CTRLS 938c2ecf20Sopenharmony_ci #. VIDIOC_S_FMT 948c2ecf20Sopenharmony_ci #. VIDIOC_REQBUFS(n) 958c2ecf20Sopenharmony_ci #. VIDIOC_QBUF 968c2ecf20Sopenharmony_ci #. VIDIOC_STREAMON 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ciThe second :c:func:`VIDIOC_REQBUFS` call will take the new format and control 998c2ecf20Sopenharmony_civalue into account to compute the buffer size to allocate. Applications can 1008c2ecf20Sopenharmony_cialso retrieve the size by calling the :c:func:`VIDIOC_G_FMT` ioctl if needed. 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci.. note:: 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci The API doesn't mandate the above order for control (3.) and format (4.) 1058c2ecf20Sopenharmony_ci changes. Format and controls can be set in a different order, or even 1068c2ecf20Sopenharmony_ci interleaved, depending on the device and use case. For instance some 1078c2ecf20Sopenharmony_ci controls might behave differently for different pixel formats, in which 1088c2ecf20Sopenharmony_ci case the format might need to be set first. 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_ciWhen reallocation is required, any attempt to modify format or controls that 1118c2ecf20Sopenharmony_ciinfluences the buffer size while buffers are allocated shall cause the format 1128c2ecf20Sopenharmony_cior control set ioctl to return the ``EBUSY`` error. Any attempt to queue a 1138c2ecf20Sopenharmony_cibuffer too small for the current format or controls shall cause the 1148c2ecf20Sopenharmony_ci:c:func:`VIDIOC_QBUF` ioctl to return a ``EINVAL`` error. 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ciBuffer reallocation is an expensive operation. To avoid that cost, drivers can 1178c2ecf20Sopenharmony_ci(and are encouraged to) allow format or controls that influence the buffer 1188c2ecf20Sopenharmony_cisize to be changed with buffers allocated. In that case, a typical ioctl 1198c2ecf20Sopenharmony_cisequence to modify format and controls is 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_ci #. VIDIOC_STREAMOFF 1228c2ecf20Sopenharmony_ci #. VIDIOC_S_EXT_CTRLS 1238c2ecf20Sopenharmony_ci #. VIDIOC_S_FMT 1248c2ecf20Sopenharmony_ci #. VIDIOC_QBUF 1258c2ecf20Sopenharmony_ci #. VIDIOC_STREAMON 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_ciFor this sequence to operate correctly, queued buffers need to be large enough 1288c2ecf20Sopenharmony_cifor the new format or controls. Drivers shall return a ``ENOSPC`` error in 1298c2ecf20Sopenharmony_ciresponse to format change (:c:func:`VIDIOC_S_FMT`) or control changes 1308c2ecf20Sopenharmony_ci(:c:func:`VIDIOC_S_CTRL` or :c:func:`VIDIOC_S_EXT_CTRLS`) if buffers too small 1318c2ecf20Sopenharmony_cifor the new format are currently queued. As a simplification, drivers are 1328c2ecf20Sopenharmony_ciallowed to return a ``EBUSY`` error from these ioctls if any buffer is 1338c2ecf20Sopenharmony_cicurrently queued, without checking the queued buffers sizes. 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_ciAdditionally, drivers shall return a ``EINVAL`` error from the 1368c2ecf20Sopenharmony_ci:c:func:`VIDIOC_QBUF` ioctl if the buffer being queued is too small for the 1378c2ecf20Sopenharmony_cicurrent format or controls. Together, these requirements ensure that queued 1388c2ecf20Sopenharmony_cibuffers will always be large enough for the configured format and controls. 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_ciUserspace applications can query the buffer size required for a given format 1418c2ecf20Sopenharmony_ciand controls by first setting the desired control values and then trying the 1428c2ecf20Sopenharmony_cidesired format. The :c:func:`VIDIOC_TRY_FMT` ioctl will return the required 1438c2ecf20Sopenharmony_cibuffer size. 1448c2ecf20Sopenharmony_ci 1458c2ecf20Sopenharmony_ci #. VIDIOC_S_EXT_CTRLS(x) 1468c2ecf20Sopenharmony_ci #. VIDIOC_TRY_FMT() 1478c2ecf20Sopenharmony_ci #. VIDIOC_S_EXT_CTRLS(y) 1488c2ecf20Sopenharmony_ci #. VIDIOC_TRY_FMT() 1498c2ecf20Sopenharmony_ci 1508c2ecf20Sopenharmony_ciThe :c:func:`VIDIOC_CREATE_BUFS` ioctl can then be used to allocate buffers 1518c2ecf20Sopenharmony_cibased on the queried sizes (for instance by allocating a set of buffers large 1528c2ecf20Sopenharmony_cienough for all the desired formats and controls, or by allocating separate set 1538c2ecf20Sopenharmony_ciof appropriately sized buffers for each use case). 1548c2ecf20Sopenharmony_ci 1558c2ecf20Sopenharmony_ci.. c:type:: v4l2_buffer 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_cistruct v4l2_buffer 1588c2ecf20Sopenharmony_ci================== 1598c2ecf20Sopenharmony_ci 1608c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{2.8cm}|p{2.5cm}|p{1.6cm}|p{10.2cm}| 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_ci.. cssclass:: longtable 1638c2ecf20Sopenharmony_ci 1648c2ecf20Sopenharmony_ci.. flat-table:: struct v4l2_buffer 1658c2ecf20Sopenharmony_ci :header-rows: 0 1668c2ecf20Sopenharmony_ci :stub-columns: 0 1678c2ecf20Sopenharmony_ci :widths: 1 2 10 1688c2ecf20Sopenharmony_ci 1698c2ecf20Sopenharmony_ci * - __u32 1708c2ecf20Sopenharmony_ci - ``index`` 1718c2ecf20Sopenharmony_ci - Number of the buffer, set by the application except when calling 1728c2ecf20Sopenharmony_ci :ref:`VIDIOC_DQBUF <VIDIOC_QBUF>`, then it is set by the 1738c2ecf20Sopenharmony_ci driver. This field can range from zero to the number of buffers 1748c2ecf20Sopenharmony_ci allocated with the :ref:`VIDIOC_REQBUFS` ioctl 1758c2ecf20Sopenharmony_ci (struct :c:type:`v4l2_requestbuffers` 1768c2ecf20Sopenharmony_ci ``count``), plus any buffers allocated with 1778c2ecf20Sopenharmony_ci :ref:`VIDIOC_CREATE_BUFS` minus one. 1788c2ecf20Sopenharmony_ci * - __u32 1798c2ecf20Sopenharmony_ci - ``type`` 1808c2ecf20Sopenharmony_ci - Type of the buffer, same as struct 1818c2ecf20Sopenharmony_ci :c:type:`v4l2_format` ``type`` or struct 1828c2ecf20Sopenharmony_ci :c:type:`v4l2_requestbuffers` ``type``, set 1838c2ecf20Sopenharmony_ci by the application. See :c:type:`v4l2_buf_type` 1848c2ecf20Sopenharmony_ci * - __u32 1858c2ecf20Sopenharmony_ci - ``bytesused`` 1868c2ecf20Sopenharmony_ci - The number of bytes occupied by the data in the buffer. It depends 1878c2ecf20Sopenharmony_ci on the negotiated data format and may change with each buffer for 1888c2ecf20Sopenharmony_ci compressed variable size data like JPEG images. Drivers must set 1898c2ecf20Sopenharmony_ci this field when ``type`` refers to a capture stream, applications 1908c2ecf20Sopenharmony_ci when it refers to an output stream. If the application sets this 1918c2ecf20Sopenharmony_ci to 0 for an output stream, then ``bytesused`` will be set to the 1928c2ecf20Sopenharmony_ci size of the buffer (see the ``length`` field of this struct) by 1938c2ecf20Sopenharmony_ci the driver. For multiplanar formats this field is ignored and the 1948c2ecf20Sopenharmony_ci ``planes`` pointer is used instead. 1958c2ecf20Sopenharmony_ci * - __u32 1968c2ecf20Sopenharmony_ci - ``flags`` 1978c2ecf20Sopenharmony_ci - Flags set by the application or driver, see :ref:`buffer-flags`. 1988c2ecf20Sopenharmony_ci * - __u32 1998c2ecf20Sopenharmony_ci - ``field`` 2008c2ecf20Sopenharmony_ci - Indicates the field order of the image in the buffer, see 2018c2ecf20Sopenharmony_ci :c:type:`v4l2_field`. This field is not used when the buffer 2028c2ecf20Sopenharmony_ci contains VBI data. Drivers must set it when ``type`` refers to a 2038c2ecf20Sopenharmony_ci capture stream, applications when it refers to an output stream. 2048c2ecf20Sopenharmony_ci * - struct timeval 2058c2ecf20Sopenharmony_ci - ``timestamp`` 2068c2ecf20Sopenharmony_ci - For capture streams this is time when the first data byte was 2078c2ecf20Sopenharmony_ci captured, as returned by the :c:func:`clock_gettime()` function 2088c2ecf20Sopenharmony_ci for the relevant clock id; see ``V4L2_BUF_FLAG_TIMESTAMP_*`` in 2098c2ecf20Sopenharmony_ci :ref:`buffer-flags`. For output streams the driver stores the 2108c2ecf20Sopenharmony_ci time at which the last data byte was actually sent out in the 2118c2ecf20Sopenharmony_ci ``timestamp`` field. This permits applications to monitor the 2128c2ecf20Sopenharmony_ci drift between the video and system clock. For output streams that 2138c2ecf20Sopenharmony_ci use ``V4L2_BUF_FLAG_TIMESTAMP_COPY`` the application has to fill 2148c2ecf20Sopenharmony_ci in the timestamp which will be copied by the driver to the capture 2158c2ecf20Sopenharmony_ci stream. 2168c2ecf20Sopenharmony_ci * - struct :c:type:`v4l2_timecode` 2178c2ecf20Sopenharmony_ci - ``timecode`` 2188c2ecf20Sopenharmony_ci - When the ``V4L2_BUF_FLAG_TIMECODE`` flag is set in ``flags``, this 2198c2ecf20Sopenharmony_ci structure contains a frame timecode. In 2208c2ecf20Sopenharmony_ci :c:type:`V4L2_FIELD_ALTERNATE <v4l2_field>` mode the top and 2218c2ecf20Sopenharmony_ci bottom field contain the same timecode. Timecodes are intended to 2228c2ecf20Sopenharmony_ci help video editing and are typically recorded on video tapes, but 2238c2ecf20Sopenharmony_ci also embedded in compressed formats like MPEG. This field is 2248c2ecf20Sopenharmony_ci independent of the ``timestamp`` and ``sequence`` fields. 2258c2ecf20Sopenharmony_ci * - __u32 2268c2ecf20Sopenharmony_ci - ``sequence`` 2278c2ecf20Sopenharmony_ci - Set by the driver, counting the frames (not fields!) in sequence. 2288c2ecf20Sopenharmony_ci This field is set for both input and output devices. 2298c2ecf20Sopenharmony_ci * - :cspan:`2` 2308c2ecf20Sopenharmony_ci 2318c2ecf20Sopenharmony_ci In :c:type:`V4L2_FIELD_ALTERNATE <v4l2_field>` mode the top and 2328c2ecf20Sopenharmony_ci bottom field have the same sequence number. The count starts at 2338c2ecf20Sopenharmony_ci zero and includes dropped or repeated frames. A dropped frame was 2348c2ecf20Sopenharmony_ci received by an input device but could not be stored due to lack of 2358c2ecf20Sopenharmony_ci free buffer space. A repeated frame was displayed again by an 2368c2ecf20Sopenharmony_ci output device because the application did not pass new data in 2378c2ecf20Sopenharmony_ci time. 2388c2ecf20Sopenharmony_ci 2398c2ecf20Sopenharmony_ci .. note:: 2408c2ecf20Sopenharmony_ci 2418c2ecf20Sopenharmony_ci This may count the frames received e.g. over USB, without 2428c2ecf20Sopenharmony_ci taking into account the frames dropped by the remote hardware due 2438c2ecf20Sopenharmony_ci to limited compression throughput or bus bandwidth. These devices 2448c2ecf20Sopenharmony_ci identify by not enumerating any video standards, see 2458c2ecf20Sopenharmony_ci :ref:`standard`. 2468c2ecf20Sopenharmony_ci 2478c2ecf20Sopenharmony_ci * - __u32 2488c2ecf20Sopenharmony_ci - ``memory`` 2498c2ecf20Sopenharmony_ci - This field must be set by applications and/or drivers in 2508c2ecf20Sopenharmony_ci accordance with the selected I/O method. See :c:type:`v4l2_memory` 2518c2ecf20Sopenharmony_ci * - union { 2528c2ecf20Sopenharmony_ci - ``m`` 2538c2ecf20Sopenharmony_ci * - __u32 2548c2ecf20Sopenharmony_ci - ``offset`` 2558c2ecf20Sopenharmony_ci - For the single-planar API and when ``memory`` is 2568c2ecf20Sopenharmony_ci ``V4L2_MEMORY_MMAP`` this is the offset of the buffer from the 2578c2ecf20Sopenharmony_ci start of the device memory. The value is returned by the driver 2588c2ecf20Sopenharmony_ci and apart of serving as parameter to the 2598c2ecf20Sopenharmony_ci :c:func:`mmap()` function not useful for applications. 2608c2ecf20Sopenharmony_ci See :ref:`mmap` for details 2618c2ecf20Sopenharmony_ci * - unsigned long 2628c2ecf20Sopenharmony_ci - ``userptr`` 2638c2ecf20Sopenharmony_ci - For the single-planar API and when ``memory`` is 2648c2ecf20Sopenharmony_ci ``V4L2_MEMORY_USERPTR`` this is a pointer to the buffer (casted to 2658c2ecf20Sopenharmony_ci unsigned long type) in virtual memory, set by the application. See 2668c2ecf20Sopenharmony_ci :ref:`userp` for details. 2678c2ecf20Sopenharmony_ci * - struct v4l2_plane 2688c2ecf20Sopenharmony_ci - ``*planes`` 2698c2ecf20Sopenharmony_ci - When using the multi-planar API, contains a userspace pointer to 2708c2ecf20Sopenharmony_ci an array of struct :c:type:`v4l2_plane`. The size of 2718c2ecf20Sopenharmony_ci the array should be put in the ``length`` field of this 2728c2ecf20Sopenharmony_ci struct :c:type:`v4l2_buffer` structure. 2738c2ecf20Sopenharmony_ci * - int 2748c2ecf20Sopenharmony_ci - ``fd`` 2758c2ecf20Sopenharmony_ci - For the single-plane API and when ``memory`` is 2768c2ecf20Sopenharmony_ci ``V4L2_MEMORY_DMABUF`` this is the file descriptor associated with 2778c2ecf20Sopenharmony_ci a DMABUF buffer. 2788c2ecf20Sopenharmony_ci * - } 2798c2ecf20Sopenharmony_ci - 2808c2ecf20Sopenharmony_ci * - __u32 2818c2ecf20Sopenharmony_ci - ``length`` 2828c2ecf20Sopenharmony_ci - Size of the buffer (not the payload) in bytes for the 2838c2ecf20Sopenharmony_ci single-planar API. This is set by the driver based on the calls to 2848c2ecf20Sopenharmony_ci :ref:`VIDIOC_REQBUFS` and/or 2858c2ecf20Sopenharmony_ci :ref:`VIDIOC_CREATE_BUFS`. For the 2868c2ecf20Sopenharmony_ci multi-planar API the application sets this to the number of 2878c2ecf20Sopenharmony_ci elements in the ``planes`` array. The driver will fill in the 2888c2ecf20Sopenharmony_ci actual number of valid elements in that array. 2898c2ecf20Sopenharmony_ci * - __u32 2908c2ecf20Sopenharmony_ci - ``reserved2`` 2918c2ecf20Sopenharmony_ci - A place holder for future extensions. Drivers and applications 2928c2ecf20Sopenharmony_ci must set this to 0. 2938c2ecf20Sopenharmony_ci * - __u32 2948c2ecf20Sopenharmony_ci - ``request_fd`` 2958c2ecf20Sopenharmony_ci - The file descriptor of the request to queue the buffer to. If the flag 2968c2ecf20Sopenharmony_ci ``V4L2_BUF_FLAG_REQUEST_FD`` is set, then the buffer will be 2978c2ecf20Sopenharmony_ci queued to this request. If the flag is not set, then this field will 2988c2ecf20Sopenharmony_ci be ignored. 2998c2ecf20Sopenharmony_ci 3008c2ecf20Sopenharmony_ci The ``V4L2_BUF_FLAG_REQUEST_FD`` flag and this field are only used by 3018c2ecf20Sopenharmony_ci :ref:`ioctl VIDIOC_QBUF <VIDIOC_QBUF>` and ignored by other ioctls that 3028c2ecf20Sopenharmony_ci take a :c:type:`v4l2_buffer` as argument. 3038c2ecf20Sopenharmony_ci 3048c2ecf20Sopenharmony_ci Applications should not set ``V4L2_BUF_FLAG_REQUEST_FD`` for any ioctls 3058c2ecf20Sopenharmony_ci other than :ref:`VIDIOC_QBUF <VIDIOC_QBUF>`. 3068c2ecf20Sopenharmony_ci 3078c2ecf20Sopenharmony_ci If the device does not support requests, then ``EBADR`` will be returned. 3088c2ecf20Sopenharmony_ci If requests are supported but an invalid request file descriptor is 3098c2ecf20Sopenharmony_ci given, then ``EINVAL`` will be returned. 3108c2ecf20Sopenharmony_ci 3118c2ecf20Sopenharmony_ci 3128c2ecf20Sopenharmony_ci.. c:type:: v4l2_plane 3138c2ecf20Sopenharmony_ci 3148c2ecf20Sopenharmony_cistruct v4l2_plane 3158c2ecf20Sopenharmony_ci================= 3168c2ecf20Sopenharmony_ci 3178c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{3.5cm}|p{3.5cm}|p{3.5cm}|p{7.0cm}| 3188c2ecf20Sopenharmony_ci 3198c2ecf20Sopenharmony_ci.. cssclass:: longtable 3208c2ecf20Sopenharmony_ci 3218c2ecf20Sopenharmony_ci.. flat-table:: 3228c2ecf20Sopenharmony_ci :header-rows: 0 3238c2ecf20Sopenharmony_ci :stub-columns: 0 3248c2ecf20Sopenharmony_ci :widths: 1 1 2 3258c2ecf20Sopenharmony_ci 3268c2ecf20Sopenharmony_ci * - __u32 3278c2ecf20Sopenharmony_ci - ``bytesused`` 3288c2ecf20Sopenharmony_ci - The number of bytes occupied by data in the plane (its payload). 3298c2ecf20Sopenharmony_ci Drivers must set this field when ``type`` refers to a capture 3308c2ecf20Sopenharmony_ci stream, applications when it refers to an output stream. If the 3318c2ecf20Sopenharmony_ci application sets this to 0 for an output stream, then 3328c2ecf20Sopenharmony_ci ``bytesused`` will be set to the size of the plane (see the 3338c2ecf20Sopenharmony_ci ``length`` field of this struct) by the driver. 3348c2ecf20Sopenharmony_ci 3358c2ecf20Sopenharmony_ci .. note:: 3368c2ecf20Sopenharmony_ci 3378c2ecf20Sopenharmony_ci Note that the actual image data starts at ``data_offset`` 3388c2ecf20Sopenharmony_ci which may not be 0. 3398c2ecf20Sopenharmony_ci * - __u32 3408c2ecf20Sopenharmony_ci - ``length`` 3418c2ecf20Sopenharmony_ci - Size in bytes of the plane (not its payload). This is set by the 3428c2ecf20Sopenharmony_ci driver based on the calls to 3438c2ecf20Sopenharmony_ci :ref:`VIDIOC_REQBUFS` and/or 3448c2ecf20Sopenharmony_ci :ref:`VIDIOC_CREATE_BUFS`. 3458c2ecf20Sopenharmony_ci * - union { 3468c2ecf20Sopenharmony_ci - ``m`` 3478c2ecf20Sopenharmony_ci * - __u32 3488c2ecf20Sopenharmony_ci - ``mem_offset`` 3498c2ecf20Sopenharmony_ci - When the memory type in the containing struct 3508c2ecf20Sopenharmony_ci :c:type:`v4l2_buffer` is ``V4L2_MEMORY_MMAP``, this 3518c2ecf20Sopenharmony_ci is the value that should be passed to :c:func:`mmap()`, 3528c2ecf20Sopenharmony_ci similar to the ``offset`` field in struct 3538c2ecf20Sopenharmony_ci :c:type:`v4l2_buffer`. 3548c2ecf20Sopenharmony_ci * - unsigned long 3558c2ecf20Sopenharmony_ci - ``userptr`` 3568c2ecf20Sopenharmony_ci - When the memory type in the containing struct 3578c2ecf20Sopenharmony_ci :c:type:`v4l2_buffer` is ``V4L2_MEMORY_USERPTR``, 3588c2ecf20Sopenharmony_ci this is a userspace pointer to the memory allocated for this plane 3598c2ecf20Sopenharmony_ci by an application. 3608c2ecf20Sopenharmony_ci * - int 3618c2ecf20Sopenharmony_ci - ``fd`` 3628c2ecf20Sopenharmony_ci - When the memory type in the containing struct 3638c2ecf20Sopenharmony_ci :c:type:`v4l2_buffer` is ``V4L2_MEMORY_DMABUF``, 3648c2ecf20Sopenharmony_ci this is a file descriptor associated with a DMABUF buffer, similar 3658c2ecf20Sopenharmony_ci to the ``fd`` field in struct :c:type:`v4l2_buffer`. 3668c2ecf20Sopenharmony_ci * - } 3678c2ecf20Sopenharmony_ci - 3688c2ecf20Sopenharmony_ci * - __u32 3698c2ecf20Sopenharmony_ci - ``data_offset`` 3708c2ecf20Sopenharmony_ci - Offset in bytes to video data in the plane. Drivers must set this 3718c2ecf20Sopenharmony_ci field when ``type`` refers to a capture stream, applications when 3728c2ecf20Sopenharmony_ci it refers to an output stream. 3738c2ecf20Sopenharmony_ci 3748c2ecf20Sopenharmony_ci .. note:: 3758c2ecf20Sopenharmony_ci 3768c2ecf20Sopenharmony_ci That data_offset is included in ``bytesused``. So the 3778c2ecf20Sopenharmony_ci size of the image in the plane is ``bytesused``-``data_offset`` 3788c2ecf20Sopenharmony_ci at offset ``data_offset`` from the start of the plane. 3798c2ecf20Sopenharmony_ci * - __u32 3808c2ecf20Sopenharmony_ci - ``reserved[11]`` 3818c2ecf20Sopenharmony_ci - Reserved for future use. Should be zeroed by drivers and 3828c2ecf20Sopenharmony_ci applications. 3838c2ecf20Sopenharmony_ci 3848c2ecf20Sopenharmony_ci 3858c2ecf20Sopenharmony_ci.. c:type:: v4l2_buf_type 3868c2ecf20Sopenharmony_ci 3878c2ecf20Sopenharmony_cienum v4l2_buf_type 3888c2ecf20Sopenharmony_ci================== 3898c2ecf20Sopenharmony_ci 3908c2ecf20Sopenharmony_ci.. cssclass:: longtable 3918c2ecf20Sopenharmony_ci 3928c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{7.8cm}|p{0.6cm}|p{9.1cm}| 3938c2ecf20Sopenharmony_ci 3948c2ecf20Sopenharmony_ci.. flat-table:: 3958c2ecf20Sopenharmony_ci :header-rows: 0 3968c2ecf20Sopenharmony_ci :stub-columns: 0 3978c2ecf20Sopenharmony_ci :widths: 4 1 9 3988c2ecf20Sopenharmony_ci 3998c2ecf20Sopenharmony_ci * - ``V4L2_BUF_TYPE_VIDEO_CAPTURE`` 4008c2ecf20Sopenharmony_ci - 1 4018c2ecf20Sopenharmony_ci - Buffer of a single-planar video capture stream, see 4028c2ecf20Sopenharmony_ci :ref:`capture`. 4038c2ecf20Sopenharmony_ci * - ``V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE`` 4048c2ecf20Sopenharmony_ci - 9 4058c2ecf20Sopenharmony_ci - Buffer of a multi-planar video capture stream, see 4068c2ecf20Sopenharmony_ci :ref:`capture`. 4078c2ecf20Sopenharmony_ci * - ``V4L2_BUF_TYPE_VIDEO_OUTPUT`` 4088c2ecf20Sopenharmony_ci - 2 4098c2ecf20Sopenharmony_ci - Buffer of a single-planar video output stream, see 4108c2ecf20Sopenharmony_ci :ref:`output`. 4118c2ecf20Sopenharmony_ci * - ``V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE`` 4128c2ecf20Sopenharmony_ci - 10 4138c2ecf20Sopenharmony_ci - Buffer of a multi-planar video output stream, see :ref:`output`. 4148c2ecf20Sopenharmony_ci * - ``V4L2_BUF_TYPE_VIDEO_OVERLAY`` 4158c2ecf20Sopenharmony_ci - 3 4168c2ecf20Sopenharmony_ci - Buffer for video overlay, see :ref:`overlay`. 4178c2ecf20Sopenharmony_ci * - ``V4L2_BUF_TYPE_VBI_CAPTURE`` 4188c2ecf20Sopenharmony_ci - 4 4198c2ecf20Sopenharmony_ci - Buffer of a raw VBI capture stream, see :ref:`raw-vbi`. 4208c2ecf20Sopenharmony_ci * - ``V4L2_BUF_TYPE_VBI_OUTPUT`` 4218c2ecf20Sopenharmony_ci - 5 4228c2ecf20Sopenharmony_ci - Buffer of a raw VBI output stream, see :ref:`raw-vbi`. 4238c2ecf20Sopenharmony_ci * - ``V4L2_BUF_TYPE_SLICED_VBI_CAPTURE`` 4248c2ecf20Sopenharmony_ci - 6 4258c2ecf20Sopenharmony_ci - Buffer of a sliced VBI capture stream, see :ref:`sliced`. 4268c2ecf20Sopenharmony_ci * - ``V4L2_BUF_TYPE_SLICED_VBI_OUTPUT`` 4278c2ecf20Sopenharmony_ci - 7 4288c2ecf20Sopenharmony_ci - Buffer of a sliced VBI output stream, see :ref:`sliced`. 4298c2ecf20Sopenharmony_ci * - ``V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY`` 4308c2ecf20Sopenharmony_ci - 8 4318c2ecf20Sopenharmony_ci - Buffer for video output overlay (OSD), see :ref:`osd`. 4328c2ecf20Sopenharmony_ci * - ``V4L2_BUF_TYPE_SDR_CAPTURE`` 4338c2ecf20Sopenharmony_ci - 11 4348c2ecf20Sopenharmony_ci - Buffer for Software Defined Radio (SDR) capture stream, see 4358c2ecf20Sopenharmony_ci :ref:`sdr`. 4368c2ecf20Sopenharmony_ci * - ``V4L2_BUF_TYPE_SDR_OUTPUT`` 4378c2ecf20Sopenharmony_ci - 12 4388c2ecf20Sopenharmony_ci - Buffer for Software Defined Radio (SDR) output stream, see 4398c2ecf20Sopenharmony_ci :ref:`sdr`. 4408c2ecf20Sopenharmony_ci * - ``V4L2_BUF_TYPE_META_CAPTURE`` 4418c2ecf20Sopenharmony_ci - 13 4428c2ecf20Sopenharmony_ci - Buffer for metadata capture, see :ref:`metadata`. 4438c2ecf20Sopenharmony_ci * - ``V4L2_BUF_TYPE_META_OUTPUT`` 4448c2ecf20Sopenharmony_ci - 14 4458c2ecf20Sopenharmony_ci - Buffer for metadata output, see :ref:`metadata`. 4468c2ecf20Sopenharmony_ci 4478c2ecf20Sopenharmony_ci 4488c2ecf20Sopenharmony_ci.. _buffer-flags: 4498c2ecf20Sopenharmony_ci 4508c2ecf20Sopenharmony_ciBuffer Flags 4518c2ecf20Sopenharmony_ci============ 4528c2ecf20Sopenharmony_ci 4538c2ecf20Sopenharmony_ci.. raw:: latex 4548c2ecf20Sopenharmony_ci 4558c2ecf20Sopenharmony_ci \small 4568c2ecf20Sopenharmony_ci 4578c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{7.0cm}|p{2.1cm}|p{8.4cm}| 4588c2ecf20Sopenharmony_ci 4598c2ecf20Sopenharmony_ci.. cssclass:: longtable 4608c2ecf20Sopenharmony_ci 4618c2ecf20Sopenharmony_ci.. flat-table:: 4628c2ecf20Sopenharmony_ci :header-rows: 0 4638c2ecf20Sopenharmony_ci :stub-columns: 0 4648c2ecf20Sopenharmony_ci :widths: 3 1 4 4658c2ecf20Sopenharmony_ci 4668c2ecf20Sopenharmony_ci * .. _`V4L2-BUF-FLAG-MAPPED`: 4678c2ecf20Sopenharmony_ci 4688c2ecf20Sopenharmony_ci - ``V4L2_BUF_FLAG_MAPPED`` 4698c2ecf20Sopenharmony_ci - 0x00000001 4708c2ecf20Sopenharmony_ci - The buffer resides in device memory and has been mapped into the 4718c2ecf20Sopenharmony_ci application's address space, see :ref:`mmap` for details. 4728c2ecf20Sopenharmony_ci Drivers set or clear this flag when the 4738c2ecf20Sopenharmony_ci :ref:`VIDIOC_QUERYBUF`, 4748c2ecf20Sopenharmony_ci :ref:`VIDIOC_QBUF` or 4758c2ecf20Sopenharmony_ci :ref:`VIDIOC_DQBUF <VIDIOC_QBUF>` ioctl is called. Set by the 4768c2ecf20Sopenharmony_ci driver. 4778c2ecf20Sopenharmony_ci * .. _`V4L2-BUF-FLAG-QUEUED`: 4788c2ecf20Sopenharmony_ci 4798c2ecf20Sopenharmony_ci - ``V4L2_BUF_FLAG_QUEUED`` 4808c2ecf20Sopenharmony_ci - 0x00000002 4818c2ecf20Sopenharmony_ci - Internally drivers maintain two buffer queues, an incoming and 4828c2ecf20Sopenharmony_ci outgoing queue. When this flag is set, the buffer is currently on 4838c2ecf20Sopenharmony_ci the incoming queue. It automatically moves to the outgoing queue 4848c2ecf20Sopenharmony_ci after the buffer has been filled (capture devices) or displayed 4858c2ecf20Sopenharmony_ci (output devices). Drivers set or clear this flag when the 4868c2ecf20Sopenharmony_ci ``VIDIOC_QUERYBUF`` ioctl is called. After (successful) calling 4878c2ecf20Sopenharmony_ci the ``VIDIOC_QBUF``\ ioctl it is always set and after 4888c2ecf20Sopenharmony_ci ``VIDIOC_DQBUF`` always cleared. 4898c2ecf20Sopenharmony_ci * .. _`V4L2-BUF-FLAG-DONE`: 4908c2ecf20Sopenharmony_ci 4918c2ecf20Sopenharmony_ci - ``V4L2_BUF_FLAG_DONE`` 4928c2ecf20Sopenharmony_ci - 0x00000004 4938c2ecf20Sopenharmony_ci - When this flag is set, the buffer is currently on the outgoing 4948c2ecf20Sopenharmony_ci queue, ready to be dequeued from the driver. Drivers set or clear 4958c2ecf20Sopenharmony_ci this flag when the ``VIDIOC_QUERYBUF`` ioctl is called. After 4968c2ecf20Sopenharmony_ci calling the ``VIDIOC_QBUF`` or ``VIDIOC_DQBUF`` it is always 4978c2ecf20Sopenharmony_ci cleared. Of course a buffer cannot be on both queues at the same 4988c2ecf20Sopenharmony_ci time, the ``V4L2_BUF_FLAG_QUEUED`` and ``V4L2_BUF_FLAG_DONE`` flag 4998c2ecf20Sopenharmony_ci are mutually exclusive. They can be both cleared however, then the 5008c2ecf20Sopenharmony_ci buffer is in "dequeued" state, in the application domain so to 5018c2ecf20Sopenharmony_ci say. 5028c2ecf20Sopenharmony_ci * .. _`V4L2-BUF-FLAG-ERROR`: 5038c2ecf20Sopenharmony_ci 5048c2ecf20Sopenharmony_ci - ``V4L2_BUF_FLAG_ERROR`` 5058c2ecf20Sopenharmony_ci - 0x00000040 5068c2ecf20Sopenharmony_ci - When this flag is set, the buffer has been dequeued successfully, 5078c2ecf20Sopenharmony_ci although the data might have been corrupted. This is recoverable, 5088c2ecf20Sopenharmony_ci streaming may continue as normal and the buffer may be reused 5098c2ecf20Sopenharmony_ci normally. Drivers set this flag when the ``VIDIOC_DQBUF`` ioctl is 5108c2ecf20Sopenharmony_ci called. 5118c2ecf20Sopenharmony_ci * .. _`V4L2-BUF-FLAG-IN-REQUEST`: 5128c2ecf20Sopenharmony_ci 5138c2ecf20Sopenharmony_ci - ``V4L2_BUF_FLAG_IN_REQUEST`` 5148c2ecf20Sopenharmony_ci - 0x00000080 5158c2ecf20Sopenharmony_ci - This buffer is part of a request that hasn't been queued yet. 5168c2ecf20Sopenharmony_ci * .. _`V4L2-BUF-FLAG-KEYFRAME`: 5178c2ecf20Sopenharmony_ci 5188c2ecf20Sopenharmony_ci - ``V4L2_BUF_FLAG_KEYFRAME`` 5198c2ecf20Sopenharmony_ci - 0x00000008 5208c2ecf20Sopenharmony_ci - Drivers set or clear this flag when calling the ``VIDIOC_DQBUF`` 5218c2ecf20Sopenharmony_ci ioctl. It may be set by video capture devices when the buffer 5228c2ecf20Sopenharmony_ci contains a compressed image which is a key frame (or field), i. e. 5238c2ecf20Sopenharmony_ci can be decompressed on its own. Also known as an I-frame. 5248c2ecf20Sopenharmony_ci Applications can set this bit when ``type`` refers to an output 5258c2ecf20Sopenharmony_ci stream. 5268c2ecf20Sopenharmony_ci * .. _`V4L2-BUF-FLAG-PFRAME`: 5278c2ecf20Sopenharmony_ci 5288c2ecf20Sopenharmony_ci - ``V4L2_BUF_FLAG_PFRAME`` 5298c2ecf20Sopenharmony_ci - 0x00000010 5308c2ecf20Sopenharmony_ci - Similar to ``V4L2_BUF_FLAG_KEYFRAME`` this flags predicted frames 5318c2ecf20Sopenharmony_ci or fields which contain only differences to a previous key frame. 5328c2ecf20Sopenharmony_ci Applications can set this bit when ``type`` refers to an output 5338c2ecf20Sopenharmony_ci stream. 5348c2ecf20Sopenharmony_ci * .. _`V4L2-BUF-FLAG-BFRAME`: 5358c2ecf20Sopenharmony_ci 5368c2ecf20Sopenharmony_ci - ``V4L2_BUF_FLAG_BFRAME`` 5378c2ecf20Sopenharmony_ci - 0x00000020 5388c2ecf20Sopenharmony_ci - Similar to ``V4L2_BUF_FLAG_KEYFRAME`` this flags a bi-directional 5398c2ecf20Sopenharmony_ci predicted frame or field which contains only the differences 5408c2ecf20Sopenharmony_ci between the current frame and both the preceding and following key 5418c2ecf20Sopenharmony_ci frames to specify its content. Applications can set this bit when 5428c2ecf20Sopenharmony_ci ``type`` refers to an output stream. 5438c2ecf20Sopenharmony_ci * .. _`V4L2-BUF-FLAG-TIMECODE`: 5448c2ecf20Sopenharmony_ci 5458c2ecf20Sopenharmony_ci - ``V4L2_BUF_FLAG_TIMECODE`` 5468c2ecf20Sopenharmony_ci - 0x00000100 5478c2ecf20Sopenharmony_ci - The ``timecode`` field is valid. Drivers set or clear this flag 5488c2ecf20Sopenharmony_ci when the ``VIDIOC_DQBUF`` ioctl is called. Applications can set 5498c2ecf20Sopenharmony_ci this bit and the corresponding ``timecode`` structure when 5508c2ecf20Sopenharmony_ci ``type`` refers to an output stream. 5518c2ecf20Sopenharmony_ci * .. _`V4L2-BUF-FLAG-PREPARED`: 5528c2ecf20Sopenharmony_ci 5538c2ecf20Sopenharmony_ci - ``V4L2_BUF_FLAG_PREPARED`` 5548c2ecf20Sopenharmony_ci - 0x00000400 5558c2ecf20Sopenharmony_ci - The buffer has been prepared for I/O and can be queued by the 5568c2ecf20Sopenharmony_ci application. Drivers set or clear this flag when the 5578c2ecf20Sopenharmony_ci :ref:`VIDIOC_QUERYBUF`, 5588c2ecf20Sopenharmony_ci :ref:`VIDIOC_PREPARE_BUF <VIDIOC_QBUF>`, 5598c2ecf20Sopenharmony_ci :ref:`VIDIOC_QBUF` or 5608c2ecf20Sopenharmony_ci :ref:`VIDIOC_DQBUF <VIDIOC_QBUF>` ioctl is called. 5618c2ecf20Sopenharmony_ci * .. _`V4L2-BUF-FLAG-NO-CACHE-INVALIDATE`: 5628c2ecf20Sopenharmony_ci 5638c2ecf20Sopenharmony_ci - ``V4L2_BUF_FLAG_NO_CACHE_INVALIDATE`` 5648c2ecf20Sopenharmony_ci - 0x00000800 5658c2ecf20Sopenharmony_ci - Caches do not have to be invalidated for this buffer. Typically 5668c2ecf20Sopenharmony_ci applications shall use this flag if the data captured in the 5678c2ecf20Sopenharmony_ci buffer is not going to be touched by the CPU, instead the buffer 5688c2ecf20Sopenharmony_ci will, probably, be passed on to a DMA-capable hardware unit for 5698c2ecf20Sopenharmony_ci further processing or output. This flag is ignored unless the 5708c2ecf20Sopenharmony_ci queue is used for :ref:`memory mapping <mmap>` streaming I/O and 5718c2ecf20Sopenharmony_ci reports :ref:`V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS 5728c2ecf20Sopenharmony_ci <V4L2-BUF-CAP-SUPPORTS-MMAP-CACHE-HINTS>` capability. 5738c2ecf20Sopenharmony_ci * .. _`V4L2-BUF-FLAG-NO-CACHE-CLEAN`: 5748c2ecf20Sopenharmony_ci 5758c2ecf20Sopenharmony_ci - ``V4L2_BUF_FLAG_NO_CACHE_CLEAN`` 5768c2ecf20Sopenharmony_ci - 0x00001000 5778c2ecf20Sopenharmony_ci - Caches do not have to be cleaned for this buffer. Typically 5788c2ecf20Sopenharmony_ci applications shall use this flag for output buffers if the data in 5798c2ecf20Sopenharmony_ci this buffer has not been created by the CPU but by some 5808c2ecf20Sopenharmony_ci DMA-capable unit, in which case caches have not been used. This flag 5818c2ecf20Sopenharmony_ci is ignored unless the queue is used for :ref:`memory mapping <mmap>` 5828c2ecf20Sopenharmony_ci streaming I/O and reports :ref:`V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS 5838c2ecf20Sopenharmony_ci <V4L2-BUF-CAP-SUPPORTS-MMAP-CACHE-HINTS>` capability. 5848c2ecf20Sopenharmony_ci * .. _`V4L2-BUF-FLAG-M2M-HOLD-CAPTURE-BUF`: 5858c2ecf20Sopenharmony_ci 5868c2ecf20Sopenharmony_ci - ``V4L2_BUF_FLAG_M2M_HOLD_CAPTURE_BUF`` 5878c2ecf20Sopenharmony_ci - 0x00000200 5888c2ecf20Sopenharmony_ci - Only valid if ``V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF`` is 5898c2ecf20Sopenharmony_ci set. It is typically used with stateless decoders where multiple 5908c2ecf20Sopenharmony_ci output buffers each decode to a slice of the decoded frame. 5918c2ecf20Sopenharmony_ci Applications can set this flag when queueing the output buffer 5928c2ecf20Sopenharmony_ci to prevent the driver from dequeueing the capture buffer after 5938c2ecf20Sopenharmony_ci the output buffer has been decoded (i.e. the capture buffer is 5948c2ecf20Sopenharmony_ci 'held'). If the timestamp of this output buffer differs from that 5958c2ecf20Sopenharmony_ci of the previous output buffer, then that indicates the start of a 5968c2ecf20Sopenharmony_ci new frame and the previously held capture buffer is dequeued. 5978c2ecf20Sopenharmony_ci * .. _`V4L2-BUF-FLAG-LAST`: 5988c2ecf20Sopenharmony_ci 5998c2ecf20Sopenharmony_ci - ``V4L2_BUF_FLAG_LAST`` 6008c2ecf20Sopenharmony_ci - 0x00100000 6018c2ecf20Sopenharmony_ci - Last buffer produced by the hardware. mem2mem codec drivers set 6028c2ecf20Sopenharmony_ci this flag on the capture queue for the last buffer when the 6038c2ecf20Sopenharmony_ci :ref:`VIDIOC_QUERYBUF` or 6048c2ecf20Sopenharmony_ci :ref:`VIDIOC_DQBUF <VIDIOC_QBUF>` ioctl is called. Due to 6058c2ecf20Sopenharmony_ci hardware limitations, the last buffer may be empty. In this case 6068c2ecf20Sopenharmony_ci the driver will set the ``bytesused`` field to 0, regardless of 6078c2ecf20Sopenharmony_ci the format. Any Any subsequent call to the 6088c2ecf20Sopenharmony_ci :ref:`VIDIOC_DQBUF <VIDIOC_QBUF>` ioctl will not block anymore, 6098c2ecf20Sopenharmony_ci but return an ``EPIPE`` error code. 6108c2ecf20Sopenharmony_ci * .. _`V4L2-BUF-FLAG-REQUEST-FD`: 6118c2ecf20Sopenharmony_ci 6128c2ecf20Sopenharmony_ci - ``V4L2_BUF_FLAG_REQUEST_FD`` 6138c2ecf20Sopenharmony_ci - 0x00800000 6148c2ecf20Sopenharmony_ci - The ``request_fd`` field contains a valid file descriptor. 6158c2ecf20Sopenharmony_ci * .. _`V4L2-BUF-FLAG-TIMESTAMP-MASK`: 6168c2ecf20Sopenharmony_ci 6178c2ecf20Sopenharmony_ci - ``V4L2_BUF_FLAG_TIMESTAMP_MASK`` 6188c2ecf20Sopenharmony_ci - 0x0000e000 6198c2ecf20Sopenharmony_ci - Mask for timestamp types below. To test the timestamp type, mask 6208c2ecf20Sopenharmony_ci out bits not belonging to timestamp type by performing a logical 6218c2ecf20Sopenharmony_ci and operation with buffer flags and timestamp mask. 6228c2ecf20Sopenharmony_ci * .. _`V4L2-BUF-FLAG-TIMESTAMP-UNKNOWN`: 6238c2ecf20Sopenharmony_ci 6248c2ecf20Sopenharmony_ci - ``V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN`` 6258c2ecf20Sopenharmony_ci - 0x00000000 6268c2ecf20Sopenharmony_ci - Unknown timestamp type. This type is used by drivers before Linux 6278c2ecf20Sopenharmony_ci 3.9 and may be either monotonic (see below) or realtime (wall 6288c2ecf20Sopenharmony_ci clock). Monotonic clock has been favoured in embedded systems 6298c2ecf20Sopenharmony_ci whereas most of the drivers use the realtime clock. Either kinds 6308c2ecf20Sopenharmony_ci of timestamps are available in user space via 6318c2ecf20Sopenharmony_ci :c:func:`clock_gettime` using clock IDs ``CLOCK_MONOTONIC`` 6328c2ecf20Sopenharmony_ci and ``CLOCK_REALTIME``, respectively. 6338c2ecf20Sopenharmony_ci * .. _`V4L2-BUF-FLAG-TIMESTAMP-MONOTONIC`: 6348c2ecf20Sopenharmony_ci 6358c2ecf20Sopenharmony_ci - ``V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC`` 6368c2ecf20Sopenharmony_ci - 0x00002000 6378c2ecf20Sopenharmony_ci - The buffer timestamp has been taken from the ``CLOCK_MONOTONIC`` 6388c2ecf20Sopenharmony_ci clock. To access the same clock outside V4L2, use 6398c2ecf20Sopenharmony_ci :c:func:`clock_gettime`. 6408c2ecf20Sopenharmony_ci * .. _`V4L2-BUF-FLAG-TIMESTAMP-COPY`: 6418c2ecf20Sopenharmony_ci 6428c2ecf20Sopenharmony_ci - ``V4L2_BUF_FLAG_TIMESTAMP_COPY`` 6438c2ecf20Sopenharmony_ci - 0x00004000 6448c2ecf20Sopenharmony_ci - The CAPTURE buffer timestamp has been taken from the corresponding 6458c2ecf20Sopenharmony_ci OUTPUT buffer. This flag applies only to mem2mem devices. 6468c2ecf20Sopenharmony_ci * .. _`V4L2-BUF-FLAG-TSTAMP-SRC-MASK`: 6478c2ecf20Sopenharmony_ci 6488c2ecf20Sopenharmony_ci - ``V4L2_BUF_FLAG_TSTAMP_SRC_MASK`` 6498c2ecf20Sopenharmony_ci - 0x00070000 6508c2ecf20Sopenharmony_ci - Mask for timestamp sources below. The timestamp source defines the 6518c2ecf20Sopenharmony_ci point of time the timestamp is taken in relation to the frame. 6528c2ecf20Sopenharmony_ci Logical 'and' operation between the ``flags`` field and 6538c2ecf20Sopenharmony_ci ``V4L2_BUF_FLAG_TSTAMP_SRC_MASK`` produces the value of the 6548c2ecf20Sopenharmony_ci timestamp source. Applications must set the timestamp source when 6558c2ecf20Sopenharmony_ci ``type`` refers to an output stream and 6568c2ecf20Sopenharmony_ci ``V4L2_BUF_FLAG_TIMESTAMP_COPY`` is set. 6578c2ecf20Sopenharmony_ci * .. _`V4L2-BUF-FLAG-TSTAMP-SRC-EOF`: 6588c2ecf20Sopenharmony_ci 6598c2ecf20Sopenharmony_ci - ``V4L2_BUF_FLAG_TSTAMP_SRC_EOF`` 6608c2ecf20Sopenharmony_ci - 0x00000000 6618c2ecf20Sopenharmony_ci - End Of Frame. The buffer timestamp has been taken when the last 6628c2ecf20Sopenharmony_ci pixel of the frame has been received or the last pixel of the 6638c2ecf20Sopenharmony_ci frame has been transmitted. In practice, software generated 6648c2ecf20Sopenharmony_ci timestamps will typically be read from the clock a small amount of 6658c2ecf20Sopenharmony_ci time after the last pixel has been received or transmitten, 6668c2ecf20Sopenharmony_ci depending on the system and other activity in it. 6678c2ecf20Sopenharmony_ci * .. _`V4L2-BUF-FLAG-TSTAMP-SRC-SOE`: 6688c2ecf20Sopenharmony_ci 6698c2ecf20Sopenharmony_ci - ``V4L2_BUF_FLAG_TSTAMP_SRC_SOE`` 6708c2ecf20Sopenharmony_ci - 0x00010000 6718c2ecf20Sopenharmony_ci - Start Of Exposure. The buffer timestamp has been taken when the 6728c2ecf20Sopenharmony_ci exposure of the frame has begun. This is only valid for the 6738c2ecf20Sopenharmony_ci ``V4L2_BUF_TYPE_VIDEO_CAPTURE`` buffer type. 6748c2ecf20Sopenharmony_ci 6758c2ecf20Sopenharmony_ci.. raw:: latex 6768c2ecf20Sopenharmony_ci 6778c2ecf20Sopenharmony_ci \normalsize 6788c2ecf20Sopenharmony_ci 6798c2ecf20Sopenharmony_ci.. _memory-flags: 6808c2ecf20Sopenharmony_ci 6818c2ecf20Sopenharmony_cienum v4l2_memory 6828c2ecf20Sopenharmony_ci================ 6838c2ecf20Sopenharmony_ci 6848c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{5.0cm}|p{0.8cm}|p{11.7cm}| 6858c2ecf20Sopenharmony_ci 6868c2ecf20Sopenharmony_ci.. flat-table:: 6878c2ecf20Sopenharmony_ci :header-rows: 0 6888c2ecf20Sopenharmony_ci :stub-columns: 0 6898c2ecf20Sopenharmony_ci :widths: 3 1 4 6908c2ecf20Sopenharmony_ci 6918c2ecf20Sopenharmony_ci * - ``V4L2_MEMORY_MMAP`` 6928c2ecf20Sopenharmony_ci - 1 6938c2ecf20Sopenharmony_ci - The buffer is used for :ref:`memory mapping <mmap>` I/O. 6948c2ecf20Sopenharmony_ci * - ``V4L2_MEMORY_USERPTR`` 6958c2ecf20Sopenharmony_ci - 2 6968c2ecf20Sopenharmony_ci - The buffer is used for :ref:`user pointer <userp>` I/O. 6978c2ecf20Sopenharmony_ci * - ``V4L2_MEMORY_OVERLAY`` 6988c2ecf20Sopenharmony_ci - 3 6998c2ecf20Sopenharmony_ci - [to do] 7008c2ecf20Sopenharmony_ci * - ``V4L2_MEMORY_DMABUF`` 7018c2ecf20Sopenharmony_ci - 4 7028c2ecf20Sopenharmony_ci - The buffer is used for :ref:`DMA shared buffer <dmabuf>` I/O. 7038c2ecf20Sopenharmony_ci 7048c2ecf20Sopenharmony_ci 7058c2ecf20Sopenharmony_ciTimecodes 7068c2ecf20Sopenharmony_ci========= 7078c2ecf20Sopenharmony_ci 7088c2ecf20Sopenharmony_ciThe :c:type:`v4l2_buffer_timecode` structure is designed to hold a 7098c2ecf20Sopenharmony_ci:ref:`smpte12m` or similar timecode. 7108c2ecf20Sopenharmony_ci(struct :c:type:`timeval` timestamps are stored in the struct 7118c2ecf20Sopenharmony_ci:c:type:`v4l2_buffer` ``timestamp`` field.) 7128c2ecf20Sopenharmony_ci 7138c2ecf20Sopenharmony_ci.. c:type:: v4l2_timecode 7148c2ecf20Sopenharmony_ci 7158c2ecf20Sopenharmony_cistruct v4l2_timecode 7168c2ecf20Sopenharmony_ci-------------------- 7178c2ecf20Sopenharmony_ci 7188c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{1.4cm}|p{2.8cm}|p{12.3cm}| 7198c2ecf20Sopenharmony_ci 7208c2ecf20Sopenharmony_ci.. flat-table:: 7218c2ecf20Sopenharmony_ci :header-rows: 0 7228c2ecf20Sopenharmony_ci :stub-columns: 0 7238c2ecf20Sopenharmony_ci :widths: 1 1 2 7248c2ecf20Sopenharmony_ci 7258c2ecf20Sopenharmony_ci * - __u32 7268c2ecf20Sopenharmony_ci - ``type`` 7278c2ecf20Sopenharmony_ci - Frame rate the timecodes are based on, see :ref:`timecode-type`. 7288c2ecf20Sopenharmony_ci * - __u32 7298c2ecf20Sopenharmony_ci - ``flags`` 7308c2ecf20Sopenharmony_ci - Timecode flags, see :ref:`timecode-flags`. 7318c2ecf20Sopenharmony_ci * - __u8 7328c2ecf20Sopenharmony_ci - ``frames`` 7338c2ecf20Sopenharmony_ci - Frame count, 0 ... 23/24/29/49/59, depending on the type of 7348c2ecf20Sopenharmony_ci timecode. 7358c2ecf20Sopenharmony_ci * - __u8 7368c2ecf20Sopenharmony_ci - ``seconds`` 7378c2ecf20Sopenharmony_ci - Seconds count, 0 ... 59. This is a binary, not BCD number. 7388c2ecf20Sopenharmony_ci * - __u8 7398c2ecf20Sopenharmony_ci - ``minutes`` 7408c2ecf20Sopenharmony_ci - Minutes count, 0 ... 59. This is a binary, not BCD number. 7418c2ecf20Sopenharmony_ci * - __u8 7428c2ecf20Sopenharmony_ci - ``hours`` 7438c2ecf20Sopenharmony_ci - Hours count, 0 ... 29. This is a binary, not BCD number. 7448c2ecf20Sopenharmony_ci * - __u8 7458c2ecf20Sopenharmony_ci - ``userbits``\ [4] 7468c2ecf20Sopenharmony_ci - The "user group" bits from the timecode. 7478c2ecf20Sopenharmony_ci 7488c2ecf20Sopenharmony_ci 7498c2ecf20Sopenharmony_ci.. _timecode-type: 7508c2ecf20Sopenharmony_ci 7518c2ecf20Sopenharmony_ciTimecode Types 7528c2ecf20Sopenharmony_ci-------------- 7538c2ecf20Sopenharmony_ci 7548c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{5.6cm}|p{0.8cm}|p{11.1cm}| 7558c2ecf20Sopenharmony_ci 7568c2ecf20Sopenharmony_ci.. flat-table:: 7578c2ecf20Sopenharmony_ci :header-rows: 0 7588c2ecf20Sopenharmony_ci :stub-columns: 0 7598c2ecf20Sopenharmony_ci :widths: 3 1 4 7608c2ecf20Sopenharmony_ci 7618c2ecf20Sopenharmony_ci * - ``V4L2_TC_TYPE_24FPS`` 7628c2ecf20Sopenharmony_ci - 1 7638c2ecf20Sopenharmony_ci - 24 frames per second, i. e. film. 7648c2ecf20Sopenharmony_ci * - ``V4L2_TC_TYPE_25FPS`` 7658c2ecf20Sopenharmony_ci - 2 7668c2ecf20Sopenharmony_ci - 25 frames per second, i. e. PAL or SECAM video. 7678c2ecf20Sopenharmony_ci * - ``V4L2_TC_TYPE_30FPS`` 7688c2ecf20Sopenharmony_ci - 3 7698c2ecf20Sopenharmony_ci - 30 frames per second, i. e. NTSC video. 7708c2ecf20Sopenharmony_ci * - ``V4L2_TC_TYPE_50FPS`` 7718c2ecf20Sopenharmony_ci - 4 7728c2ecf20Sopenharmony_ci - 7738c2ecf20Sopenharmony_ci * - ``V4L2_TC_TYPE_60FPS`` 7748c2ecf20Sopenharmony_ci - 5 7758c2ecf20Sopenharmony_ci - 7768c2ecf20Sopenharmony_ci 7778c2ecf20Sopenharmony_ci 7788c2ecf20Sopenharmony_ci.. _timecode-flags: 7798c2ecf20Sopenharmony_ci 7808c2ecf20Sopenharmony_ciTimecode Flags 7818c2ecf20Sopenharmony_ci-------------- 7828c2ecf20Sopenharmony_ci 7838c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{6.6cm}|p{1.4cm}|p{9.5cm}| 7848c2ecf20Sopenharmony_ci 7858c2ecf20Sopenharmony_ci.. flat-table:: 7868c2ecf20Sopenharmony_ci :header-rows: 0 7878c2ecf20Sopenharmony_ci :stub-columns: 0 7888c2ecf20Sopenharmony_ci :widths: 3 1 4 7898c2ecf20Sopenharmony_ci 7908c2ecf20Sopenharmony_ci * - ``V4L2_TC_FLAG_DROPFRAME`` 7918c2ecf20Sopenharmony_ci - 0x0001 7928c2ecf20Sopenharmony_ci - Indicates "drop frame" semantics for counting frames in 29.97 fps 7938c2ecf20Sopenharmony_ci material. When set, frame numbers 0 and 1 at the start of each 7948c2ecf20Sopenharmony_ci minute, except minutes 0, 10, 20, 30, 40, 50 are omitted from the 7958c2ecf20Sopenharmony_ci count. 7968c2ecf20Sopenharmony_ci * - ``V4L2_TC_FLAG_COLORFRAME`` 7978c2ecf20Sopenharmony_ci - 0x0002 7988c2ecf20Sopenharmony_ci - The "color frame" flag. 7998c2ecf20Sopenharmony_ci * - ``V4L2_TC_USERBITS_field`` 8008c2ecf20Sopenharmony_ci - 0x000C 8018c2ecf20Sopenharmony_ci - Field mask for the "binary group flags". 8028c2ecf20Sopenharmony_ci * - ``V4L2_TC_USERBITS_USERDEFINED`` 8038c2ecf20Sopenharmony_ci - 0x0000 8048c2ecf20Sopenharmony_ci - Unspecified format. 8058c2ecf20Sopenharmony_ci * - ``V4L2_TC_USERBITS_8BITCHARS`` 8068c2ecf20Sopenharmony_ci - 0x0008 8078c2ecf20Sopenharmony_ci - 8-bit ISO characters. 808