1*4882a593Smuzhiyun.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later 2*4882a593Smuzhiyun.. c:namespace:: V4L 3*4882a593Smuzhiyun 4*4882a593Smuzhiyun.. _buffer: 5*4882a593Smuzhiyun 6*4882a593Smuzhiyun******* 7*4882a593SmuzhiyunBuffers 8*4882a593Smuzhiyun******* 9*4882a593Smuzhiyun 10*4882a593SmuzhiyunA buffer contains data exchanged by application and driver using one of 11*4882a593Smuzhiyunthe Streaming I/O methods. In the multi-planar API, the data is held in 12*4882a593Smuzhiyunplanes, while the buffer structure acts as a container for the planes. 13*4882a593SmuzhiyunOnly pointers to buffers (planes) are exchanged, the data itself is not 14*4882a593Smuzhiyuncopied. These pointers, together with meta-information like timestamps 15*4882a593Smuzhiyunor field parity, are stored in a struct :c:type:`v4l2_buffer`, 16*4882a593Smuzhiyunargument to the :ref:`VIDIOC_QUERYBUF`, 17*4882a593Smuzhiyun:ref:`VIDIOC_QBUF <VIDIOC_QBUF>` and 18*4882a593Smuzhiyun:ref:`VIDIOC_DQBUF <VIDIOC_QBUF>` ioctl. In the multi-planar API, 19*4882a593Smuzhiyunsome plane-specific members of struct :c:type:`v4l2_buffer`, 20*4882a593Smuzhiyunsuch as pointers and sizes for each plane, are stored in 21*4882a593Smuzhiyunstruct :c:type:`v4l2_plane` instead. In that case, 22*4882a593Smuzhiyunstruct :c:type:`v4l2_buffer` contains an array of plane structures. 23*4882a593Smuzhiyun 24*4882a593SmuzhiyunDequeued video buffers come with timestamps. The driver decides at which 25*4882a593Smuzhiyunpart of the frame and with which clock the timestamp is taken. Please 26*4882a593Smuzhiyunsee flags in the masks ``V4L2_BUF_FLAG_TIMESTAMP_MASK`` and 27*4882a593Smuzhiyun``V4L2_BUF_FLAG_TSTAMP_SRC_MASK`` in :ref:`buffer-flags`. These flags 28*4882a593Smuzhiyunare always valid and constant across all buffers during the whole video 29*4882a593Smuzhiyunstream. Changes in these flags may take place as a side effect of 30*4882a593Smuzhiyun:ref:`VIDIOC_S_INPUT <VIDIOC_G_INPUT>` or 31*4882a593Smuzhiyun:ref:`VIDIOC_S_OUTPUT <VIDIOC_G_OUTPUT>` however. The 32*4882a593Smuzhiyun``V4L2_BUF_FLAG_TIMESTAMP_COPY`` timestamp type which is used by e.g. on 33*4882a593Smuzhiyunmem-to-mem devices is an exception to the rule: the timestamp source 34*4882a593Smuzhiyunflags are copied from the OUTPUT video buffer to the CAPTURE video 35*4882a593Smuzhiyunbuffer. 36*4882a593Smuzhiyun 37*4882a593SmuzhiyunInteractions between formats, controls and buffers 38*4882a593Smuzhiyun================================================== 39*4882a593Smuzhiyun 40*4882a593SmuzhiyunV4L2 exposes parameters that influence the buffer size, or the way data is 41*4882a593Smuzhiyunlaid out in the buffer. Those parameters are exposed through both formats and 42*4882a593Smuzhiyuncontrols. One example of such a control is the ``V4L2_CID_ROTATE`` control 43*4882a593Smuzhiyunthat modifies the direction in which pixels are stored in the buffer, as well 44*4882a593Smuzhiyunas the buffer size when the selected format includes padding at the end of 45*4882a593Smuzhiyunlines. 46*4882a593Smuzhiyun 47*4882a593SmuzhiyunThe set of information needed to interpret the content of a buffer (e.g. the 48*4882a593Smuzhiyunpixel format, the line stride, the tiling orientation or the rotation) is 49*4882a593Smuzhiyuncollectively referred to in the rest of this section as the buffer layout. 50*4882a593Smuzhiyun 51*4882a593SmuzhiyunControls that can modify the buffer layout shall set the 52*4882a593Smuzhiyun``V4L2_CTRL_FLAG_MODIFY_LAYOUT`` flag. 53*4882a593Smuzhiyun 54*4882a593SmuzhiyunModifying formats or controls that influence the buffer size or layout require 55*4882a593Smuzhiyunthe stream to be stopped. Any attempt at such a modification while the stream 56*4882a593Smuzhiyunis active shall cause the ioctl setting the format or the control to return 57*4882a593Smuzhiyunthe ``EBUSY`` error code. In that case drivers shall also set the 58*4882a593Smuzhiyun``V4L2_CTRL_FLAG_GRABBED`` flag when calling 59*4882a593Smuzhiyun:c:func:`VIDIOC_QUERYCTRL` or :c:func:`VIDIOC_QUERY_EXT_CTRL` for such a 60*4882a593Smuzhiyuncontrol while the stream is active. 61*4882a593Smuzhiyun 62*4882a593Smuzhiyun.. note:: 63*4882a593Smuzhiyun 64*4882a593Smuzhiyun The :c:func:`VIDIOC_S_SELECTION` ioctl can, depending on the hardware (for 65*4882a593Smuzhiyun instance if the device doesn't include a scaler), modify the format in 66*4882a593Smuzhiyun addition to the selection rectangle. Similarly, the 67*4882a593Smuzhiyun :c:func:`VIDIOC_S_INPUT`, :c:func:`VIDIOC_S_OUTPUT`, :c:func:`VIDIOC_S_STD` 68*4882a593Smuzhiyun and :c:func:`VIDIOC_S_DV_TIMINGS` ioctls can also modify the format and 69*4882a593Smuzhiyun selection rectangles. When those ioctls result in a buffer size or layout 70*4882a593Smuzhiyun change, drivers shall handle that condition as they would handle it in the 71*4882a593Smuzhiyun :c:func:`VIDIOC_S_FMT` ioctl in all cases described in this section. 72*4882a593Smuzhiyun 73*4882a593SmuzhiyunControls that only influence the buffer layout can be modified at any time 74*4882a593Smuzhiyunwhen the stream is stopped. As they don't influence the buffer size, no 75*4882a593Smuzhiyunspecial handling is needed to synchronize those controls with buffer 76*4882a593Smuzhiyunallocation and the ``V4L2_CTRL_FLAG_GRABBED`` flag is cleared once the 77*4882a593Smuzhiyunstream is stopped. 78*4882a593Smuzhiyun 79*4882a593SmuzhiyunFormats and controls that influence the buffer size interact with buffer 80*4882a593Smuzhiyunallocation. The simplest way to handle this is for drivers to always require 81*4882a593Smuzhiyunbuffers to be reallocated in order to change those formats or controls. In 82*4882a593Smuzhiyunthat case, to perform such changes, userspace applications shall first stop 83*4882a593Smuzhiyunthe video stream with the :c:func:`VIDIOC_STREAMOFF` ioctl if it is running 84*4882a593Smuzhiyunand free all buffers with the :c:func:`VIDIOC_REQBUFS` ioctl if they are 85*4882a593Smuzhiyunallocated. After freeing all buffers the ``V4L2_CTRL_FLAG_GRABBED`` flag 86*4882a593Smuzhiyunfor controls is cleared. The format or controls can then be modified, and 87*4882a593Smuzhiyunbuffers shall then be reallocated and the stream restarted. A typical ioctl 88*4882a593Smuzhiyunsequence is 89*4882a593Smuzhiyun 90*4882a593Smuzhiyun #. VIDIOC_STREAMOFF 91*4882a593Smuzhiyun #. VIDIOC_REQBUFS(0) 92*4882a593Smuzhiyun #. VIDIOC_S_EXT_CTRLS 93*4882a593Smuzhiyun #. VIDIOC_S_FMT 94*4882a593Smuzhiyun #. VIDIOC_REQBUFS(n) 95*4882a593Smuzhiyun #. VIDIOC_QBUF 96*4882a593Smuzhiyun #. VIDIOC_STREAMON 97*4882a593Smuzhiyun 98*4882a593SmuzhiyunThe second :c:func:`VIDIOC_REQBUFS` call will take the new format and control 99*4882a593Smuzhiyunvalue into account to compute the buffer size to allocate. Applications can 100*4882a593Smuzhiyunalso retrieve the size by calling the :c:func:`VIDIOC_G_FMT` ioctl if needed. 101*4882a593Smuzhiyun 102*4882a593Smuzhiyun.. note:: 103*4882a593Smuzhiyun 104*4882a593Smuzhiyun The API doesn't mandate the above order for control (3.) and format (4.) 105*4882a593Smuzhiyun changes. Format and controls can be set in a different order, or even 106*4882a593Smuzhiyun interleaved, depending on the device and use case. For instance some 107*4882a593Smuzhiyun controls might behave differently for different pixel formats, in which 108*4882a593Smuzhiyun case the format might need to be set first. 109*4882a593Smuzhiyun 110*4882a593SmuzhiyunWhen reallocation is required, any attempt to modify format or controls that 111*4882a593Smuzhiyuninfluences the buffer size while buffers are allocated shall cause the format 112*4882a593Smuzhiyunor control set ioctl to return the ``EBUSY`` error. Any attempt to queue a 113*4882a593Smuzhiyunbuffer too small for the current format or controls shall cause the 114*4882a593Smuzhiyun:c:func:`VIDIOC_QBUF` ioctl to return a ``EINVAL`` error. 115*4882a593Smuzhiyun 116*4882a593SmuzhiyunBuffer reallocation is an expensive operation. To avoid that cost, drivers can 117*4882a593Smuzhiyun(and are encouraged to) allow format or controls that influence the buffer 118*4882a593Smuzhiyunsize to be changed with buffers allocated. In that case, a typical ioctl 119*4882a593Smuzhiyunsequence to modify format and controls is 120*4882a593Smuzhiyun 121*4882a593Smuzhiyun #. VIDIOC_STREAMOFF 122*4882a593Smuzhiyun #. VIDIOC_S_EXT_CTRLS 123*4882a593Smuzhiyun #. VIDIOC_S_FMT 124*4882a593Smuzhiyun #. VIDIOC_QBUF 125*4882a593Smuzhiyun #. VIDIOC_STREAMON 126*4882a593Smuzhiyun 127*4882a593SmuzhiyunFor this sequence to operate correctly, queued buffers need to be large enough 128*4882a593Smuzhiyunfor the new format or controls. Drivers shall return a ``ENOSPC`` error in 129*4882a593Smuzhiyunresponse to format change (:c:func:`VIDIOC_S_FMT`) or control changes 130*4882a593Smuzhiyun(:c:func:`VIDIOC_S_CTRL` or :c:func:`VIDIOC_S_EXT_CTRLS`) if buffers too small 131*4882a593Smuzhiyunfor the new format are currently queued. As a simplification, drivers are 132*4882a593Smuzhiyunallowed to return a ``EBUSY`` error from these ioctls if any buffer is 133*4882a593Smuzhiyuncurrently queued, without checking the queued buffers sizes. 134*4882a593Smuzhiyun 135*4882a593SmuzhiyunAdditionally, drivers shall return a ``EINVAL`` error from the 136*4882a593Smuzhiyun:c:func:`VIDIOC_QBUF` ioctl if the buffer being queued is too small for the 137*4882a593Smuzhiyuncurrent format or controls. Together, these requirements ensure that queued 138*4882a593Smuzhiyunbuffers will always be large enough for the configured format and controls. 139*4882a593Smuzhiyun 140*4882a593SmuzhiyunUserspace applications can query the buffer size required for a given format 141*4882a593Smuzhiyunand controls by first setting the desired control values and then trying the 142*4882a593Smuzhiyundesired format. The :c:func:`VIDIOC_TRY_FMT` ioctl will return the required 143*4882a593Smuzhiyunbuffer size. 144*4882a593Smuzhiyun 145*4882a593Smuzhiyun #. VIDIOC_S_EXT_CTRLS(x) 146*4882a593Smuzhiyun #. VIDIOC_TRY_FMT() 147*4882a593Smuzhiyun #. VIDIOC_S_EXT_CTRLS(y) 148*4882a593Smuzhiyun #. VIDIOC_TRY_FMT() 149*4882a593Smuzhiyun 150*4882a593SmuzhiyunThe :c:func:`VIDIOC_CREATE_BUFS` ioctl can then be used to allocate buffers 151*4882a593Smuzhiyunbased on the queried sizes (for instance by allocating a set of buffers large 152*4882a593Smuzhiyunenough for all the desired formats and controls, or by allocating separate set 153*4882a593Smuzhiyunof appropriately sized buffers for each use case). 154*4882a593Smuzhiyun 155*4882a593Smuzhiyun.. c:type:: v4l2_buffer 156*4882a593Smuzhiyun 157*4882a593Smuzhiyunstruct v4l2_buffer 158*4882a593Smuzhiyun================== 159*4882a593Smuzhiyun 160*4882a593Smuzhiyun.. tabularcolumns:: |p{2.8cm}|p{2.5cm}|p{1.6cm}|p{10.2cm}| 161*4882a593Smuzhiyun 162*4882a593Smuzhiyun.. cssclass:: longtable 163*4882a593Smuzhiyun 164*4882a593Smuzhiyun.. flat-table:: struct v4l2_buffer 165*4882a593Smuzhiyun :header-rows: 0 166*4882a593Smuzhiyun :stub-columns: 0 167*4882a593Smuzhiyun :widths: 1 2 10 168*4882a593Smuzhiyun 169*4882a593Smuzhiyun * - __u32 170*4882a593Smuzhiyun - ``index`` 171*4882a593Smuzhiyun - Number of the buffer, set by the application except when calling 172*4882a593Smuzhiyun :ref:`VIDIOC_DQBUF <VIDIOC_QBUF>`, then it is set by the 173*4882a593Smuzhiyun driver. This field can range from zero to the number of buffers 174*4882a593Smuzhiyun allocated with the :ref:`VIDIOC_REQBUFS` ioctl 175*4882a593Smuzhiyun (struct :c:type:`v4l2_requestbuffers` 176*4882a593Smuzhiyun ``count``), plus any buffers allocated with 177*4882a593Smuzhiyun :ref:`VIDIOC_CREATE_BUFS` minus one. 178*4882a593Smuzhiyun * - __u32 179*4882a593Smuzhiyun - ``type`` 180*4882a593Smuzhiyun - Type of the buffer, same as struct 181*4882a593Smuzhiyun :c:type:`v4l2_format` ``type`` or struct 182*4882a593Smuzhiyun :c:type:`v4l2_requestbuffers` ``type``, set 183*4882a593Smuzhiyun by the application. See :c:type:`v4l2_buf_type` 184*4882a593Smuzhiyun * - __u32 185*4882a593Smuzhiyun - ``bytesused`` 186*4882a593Smuzhiyun - The number of bytes occupied by the data in the buffer. It depends 187*4882a593Smuzhiyun on the negotiated data format and may change with each buffer for 188*4882a593Smuzhiyun compressed variable size data like JPEG images. Drivers must set 189*4882a593Smuzhiyun this field when ``type`` refers to a capture stream, applications 190*4882a593Smuzhiyun when it refers to an output stream. If the application sets this 191*4882a593Smuzhiyun to 0 for an output stream, then ``bytesused`` will be set to the 192*4882a593Smuzhiyun size of the buffer (see the ``length`` field of this struct) by 193*4882a593Smuzhiyun the driver. For multiplanar formats this field is ignored and the 194*4882a593Smuzhiyun ``planes`` pointer is used instead. 195*4882a593Smuzhiyun * - __u32 196*4882a593Smuzhiyun - ``flags`` 197*4882a593Smuzhiyun - Flags set by the application or driver, see :ref:`buffer-flags`. 198*4882a593Smuzhiyun * - __u32 199*4882a593Smuzhiyun - ``field`` 200*4882a593Smuzhiyun - Indicates the field order of the image in the buffer, see 201*4882a593Smuzhiyun :c:type:`v4l2_field`. This field is not used when the buffer 202*4882a593Smuzhiyun contains VBI data. Drivers must set it when ``type`` refers to a 203*4882a593Smuzhiyun capture stream, applications when it refers to an output stream. 204*4882a593Smuzhiyun * - struct timeval 205*4882a593Smuzhiyun - ``timestamp`` 206*4882a593Smuzhiyun - For capture streams this is time when the first data byte was 207*4882a593Smuzhiyun captured, as returned by the :c:func:`clock_gettime()` function 208*4882a593Smuzhiyun for the relevant clock id; see ``V4L2_BUF_FLAG_TIMESTAMP_*`` in 209*4882a593Smuzhiyun :ref:`buffer-flags`. For output streams the driver stores the 210*4882a593Smuzhiyun time at which the last data byte was actually sent out in the 211*4882a593Smuzhiyun ``timestamp`` field. This permits applications to monitor the 212*4882a593Smuzhiyun drift between the video and system clock. For output streams that 213*4882a593Smuzhiyun use ``V4L2_BUF_FLAG_TIMESTAMP_COPY`` the application has to fill 214*4882a593Smuzhiyun in the timestamp which will be copied by the driver to the capture 215*4882a593Smuzhiyun stream. 216*4882a593Smuzhiyun * - struct :c:type:`v4l2_timecode` 217*4882a593Smuzhiyun - ``timecode`` 218*4882a593Smuzhiyun - When the ``V4L2_BUF_FLAG_TIMECODE`` flag is set in ``flags``, this 219*4882a593Smuzhiyun structure contains a frame timecode. In 220*4882a593Smuzhiyun :c:type:`V4L2_FIELD_ALTERNATE <v4l2_field>` mode the top and 221*4882a593Smuzhiyun bottom field contain the same timecode. Timecodes are intended to 222*4882a593Smuzhiyun help video editing and are typically recorded on video tapes, but 223*4882a593Smuzhiyun also embedded in compressed formats like MPEG. This field is 224*4882a593Smuzhiyun independent of the ``timestamp`` and ``sequence`` fields. 225*4882a593Smuzhiyun * - __u32 226*4882a593Smuzhiyun - ``sequence`` 227*4882a593Smuzhiyun - Set by the driver, counting the frames (not fields!) in sequence. 228*4882a593Smuzhiyun This field is set for both input and output devices. 229*4882a593Smuzhiyun * - :cspan:`2` 230*4882a593Smuzhiyun 231*4882a593Smuzhiyun In :c:type:`V4L2_FIELD_ALTERNATE <v4l2_field>` mode the top and 232*4882a593Smuzhiyun bottom field have the same sequence number. The count starts at 233*4882a593Smuzhiyun zero and includes dropped or repeated frames. A dropped frame was 234*4882a593Smuzhiyun received by an input device but could not be stored due to lack of 235*4882a593Smuzhiyun free buffer space. A repeated frame was displayed again by an 236*4882a593Smuzhiyun output device because the application did not pass new data in 237*4882a593Smuzhiyun time. 238*4882a593Smuzhiyun 239*4882a593Smuzhiyun .. note:: 240*4882a593Smuzhiyun 241*4882a593Smuzhiyun This may count the frames received e.g. over USB, without 242*4882a593Smuzhiyun taking into account the frames dropped by the remote hardware due 243*4882a593Smuzhiyun to limited compression throughput or bus bandwidth. These devices 244*4882a593Smuzhiyun identify by not enumerating any video standards, see 245*4882a593Smuzhiyun :ref:`standard`. 246*4882a593Smuzhiyun 247*4882a593Smuzhiyun * - __u32 248*4882a593Smuzhiyun - ``memory`` 249*4882a593Smuzhiyun - This field must be set by applications and/or drivers in 250*4882a593Smuzhiyun accordance with the selected I/O method. See :c:type:`v4l2_memory` 251*4882a593Smuzhiyun * - union { 252*4882a593Smuzhiyun - ``m`` 253*4882a593Smuzhiyun * - __u32 254*4882a593Smuzhiyun - ``offset`` 255*4882a593Smuzhiyun - For the single-planar API and when ``memory`` is 256*4882a593Smuzhiyun ``V4L2_MEMORY_MMAP`` this is the offset of the buffer from the 257*4882a593Smuzhiyun start of the device memory. The value is returned by the driver 258*4882a593Smuzhiyun and apart of serving as parameter to the 259*4882a593Smuzhiyun :c:func:`mmap()` function not useful for applications. 260*4882a593Smuzhiyun See :ref:`mmap` for details 261*4882a593Smuzhiyun * - unsigned long 262*4882a593Smuzhiyun - ``userptr`` 263*4882a593Smuzhiyun - For the single-planar API and when ``memory`` is 264*4882a593Smuzhiyun ``V4L2_MEMORY_USERPTR`` this is a pointer to the buffer (casted to 265*4882a593Smuzhiyun unsigned long type) in virtual memory, set by the application. See 266*4882a593Smuzhiyun :ref:`userp` for details. 267*4882a593Smuzhiyun * - struct v4l2_plane 268*4882a593Smuzhiyun - ``*planes`` 269*4882a593Smuzhiyun - When using the multi-planar API, contains a userspace pointer to 270*4882a593Smuzhiyun an array of struct :c:type:`v4l2_plane`. The size of 271*4882a593Smuzhiyun the array should be put in the ``length`` field of this 272*4882a593Smuzhiyun struct :c:type:`v4l2_buffer` structure. 273*4882a593Smuzhiyun * - int 274*4882a593Smuzhiyun - ``fd`` 275*4882a593Smuzhiyun - For the single-plane API and when ``memory`` is 276*4882a593Smuzhiyun ``V4L2_MEMORY_DMABUF`` this is the file descriptor associated with 277*4882a593Smuzhiyun a DMABUF buffer. 278*4882a593Smuzhiyun * - } 279*4882a593Smuzhiyun - 280*4882a593Smuzhiyun * - __u32 281*4882a593Smuzhiyun - ``length`` 282*4882a593Smuzhiyun - Size of the buffer (not the payload) in bytes for the 283*4882a593Smuzhiyun single-planar API. This is set by the driver based on the calls to 284*4882a593Smuzhiyun :ref:`VIDIOC_REQBUFS` and/or 285*4882a593Smuzhiyun :ref:`VIDIOC_CREATE_BUFS`. For the 286*4882a593Smuzhiyun multi-planar API the application sets this to the number of 287*4882a593Smuzhiyun elements in the ``planes`` array. The driver will fill in the 288*4882a593Smuzhiyun actual number of valid elements in that array. 289*4882a593Smuzhiyun * - __u32 290*4882a593Smuzhiyun - ``reserved2`` 291*4882a593Smuzhiyun - A place holder for future extensions. Drivers and applications 292*4882a593Smuzhiyun must set this to 0. 293*4882a593Smuzhiyun * - __u32 294*4882a593Smuzhiyun - ``request_fd`` 295*4882a593Smuzhiyun - The file descriptor of the request to queue the buffer to. If the flag 296*4882a593Smuzhiyun ``V4L2_BUF_FLAG_REQUEST_FD`` is set, then the buffer will be 297*4882a593Smuzhiyun queued to this request. If the flag is not set, then this field will 298*4882a593Smuzhiyun be ignored. 299*4882a593Smuzhiyun 300*4882a593Smuzhiyun The ``V4L2_BUF_FLAG_REQUEST_FD`` flag and this field are only used by 301*4882a593Smuzhiyun :ref:`ioctl VIDIOC_QBUF <VIDIOC_QBUF>` and ignored by other ioctls that 302*4882a593Smuzhiyun take a :c:type:`v4l2_buffer` as argument. 303*4882a593Smuzhiyun 304*4882a593Smuzhiyun Applications should not set ``V4L2_BUF_FLAG_REQUEST_FD`` for any ioctls 305*4882a593Smuzhiyun other than :ref:`VIDIOC_QBUF <VIDIOC_QBUF>`. 306*4882a593Smuzhiyun 307*4882a593Smuzhiyun If the device does not support requests, then ``EBADR`` will be returned. 308*4882a593Smuzhiyun If requests are supported but an invalid request file descriptor is 309*4882a593Smuzhiyun given, then ``EINVAL`` will be returned. 310*4882a593Smuzhiyun 311*4882a593Smuzhiyun 312*4882a593Smuzhiyun.. c:type:: v4l2_plane 313*4882a593Smuzhiyun 314*4882a593Smuzhiyunstruct v4l2_plane 315*4882a593Smuzhiyun================= 316*4882a593Smuzhiyun 317*4882a593Smuzhiyun.. tabularcolumns:: |p{3.5cm}|p{3.5cm}|p{3.5cm}|p{7.0cm}| 318*4882a593Smuzhiyun 319*4882a593Smuzhiyun.. cssclass:: longtable 320*4882a593Smuzhiyun 321*4882a593Smuzhiyun.. flat-table:: 322*4882a593Smuzhiyun :header-rows: 0 323*4882a593Smuzhiyun :stub-columns: 0 324*4882a593Smuzhiyun :widths: 1 1 2 325*4882a593Smuzhiyun 326*4882a593Smuzhiyun * - __u32 327*4882a593Smuzhiyun - ``bytesused`` 328*4882a593Smuzhiyun - The number of bytes occupied by data in the plane (its payload). 329*4882a593Smuzhiyun Drivers must set this field when ``type`` refers to a capture 330*4882a593Smuzhiyun stream, applications when it refers to an output stream. If the 331*4882a593Smuzhiyun application sets this to 0 for an output stream, then 332*4882a593Smuzhiyun ``bytesused`` will be set to the size of the plane (see the 333*4882a593Smuzhiyun ``length`` field of this struct) by the driver. 334*4882a593Smuzhiyun 335*4882a593Smuzhiyun .. note:: 336*4882a593Smuzhiyun 337*4882a593Smuzhiyun Note that the actual image data starts at ``data_offset`` 338*4882a593Smuzhiyun which may not be 0. 339*4882a593Smuzhiyun * - __u32 340*4882a593Smuzhiyun - ``length`` 341*4882a593Smuzhiyun - Size in bytes of the plane (not its payload). This is set by the 342*4882a593Smuzhiyun driver based on the calls to 343*4882a593Smuzhiyun :ref:`VIDIOC_REQBUFS` and/or 344*4882a593Smuzhiyun :ref:`VIDIOC_CREATE_BUFS`. 345*4882a593Smuzhiyun * - union { 346*4882a593Smuzhiyun - ``m`` 347*4882a593Smuzhiyun * - __u32 348*4882a593Smuzhiyun - ``mem_offset`` 349*4882a593Smuzhiyun - When the memory type in the containing struct 350*4882a593Smuzhiyun :c:type:`v4l2_buffer` is ``V4L2_MEMORY_MMAP``, this 351*4882a593Smuzhiyun is the value that should be passed to :c:func:`mmap()`, 352*4882a593Smuzhiyun similar to the ``offset`` field in struct 353*4882a593Smuzhiyun :c:type:`v4l2_buffer`. 354*4882a593Smuzhiyun * - unsigned long 355*4882a593Smuzhiyun - ``userptr`` 356*4882a593Smuzhiyun - When the memory type in the containing struct 357*4882a593Smuzhiyun :c:type:`v4l2_buffer` is ``V4L2_MEMORY_USERPTR``, 358*4882a593Smuzhiyun this is a userspace pointer to the memory allocated for this plane 359*4882a593Smuzhiyun by an application. 360*4882a593Smuzhiyun * - int 361*4882a593Smuzhiyun - ``fd`` 362*4882a593Smuzhiyun - When the memory type in the containing struct 363*4882a593Smuzhiyun :c:type:`v4l2_buffer` is ``V4L2_MEMORY_DMABUF``, 364*4882a593Smuzhiyun this is a file descriptor associated with a DMABUF buffer, similar 365*4882a593Smuzhiyun to the ``fd`` field in struct :c:type:`v4l2_buffer`. 366*4882a593Smuzhiyun * - } 367*4882a593Smuzhiyun - 368*4882a593Smuzhiyun * - __u32 369*4882a593Smuzhiyun - ``data_offset`` 370*4882a593Smuzhiyun - Offset in bytes to video data in the plane. Drivers must set this 371*4882a593Smuzhiyun field when ``type`` refers to a capture stream, applications when 372*4882a593Smuzhiyun it refers to an output stream. 373*4882a593Smuzhiyun 374*4882a593Smuzhiyun .. note:: 375*4882a593Smuzhiyun 376*4882a593Smuzhiyun That data_offset is included in ``bytesused``. So the 377*4882a593Smuzhiyun size of the image in the plane is ``bytesused``-``data_offset`` 378*4882a593Smuzhiyun at offset ``data_offset`` from the start of the plane. 379*4882a593Smuzhiyun * - __u32 380*4882a593Smuzhiyun - ``reserved[11]`` 381*4882a593Smuzhiyun - Reserved for future use. Should be zeroed by drivers and 382*4882a593Smuzhiyun applications. 383*4882a593Smuzhiyun 384*4882a593Smuzhiyun 385*4882a593Smuzhiyun.. c:type:: v4l2_buf_type 386*4882a593Smuzhiyun 387*4882a593Smuzhiyunenum v4l2_buf_type 388*4882a593Smuzhiyun================== 389*4882a593Smuzhiyun 390*4882a593Smuzhiyun.. cssclass:: longtable 391*4882a593Smuzhiyun 392*4882a593Smuzhiyun.. tabularcolumns:: |p{7.8cm}|p{0.6cm}|p{9.1cm}| 393*4882a593Smuzhiyun 394*4882a593Smuzhiyun.. flat-table:: 395*4882a593Smuzhiyun :header-rows: 0 396*4882a593Smuzhiyun :stub-columns: 0 397*4882a593Smuzhiyun :widths: 4 1 9 398*4882a593Smuzhiyun 399*4882a593Smuzhiyun * - ``V4L2_BUF_TYPE_VIDEO_CAPTURE`` 400*4882a593Smuzhiyun - 1 401*4882a593Smuzhiyun - Buffer of a single-planar video capture stream, see 402*4882a593Smuzhiyun :ref:`capture`. 403*4882a593Smuzhiyun * - ``V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE`` 404*4882a593Smuzhiyun - 9 405*4882a593Smuzhiyun - Buffer of a multi-planar video capture stream, see 406*4882a593Smuzhiyun :ref:`capture`. 407*4882a593Smuzhiyun * - ``V4L2_BUF_TYPE_VIDEO_OUTPUT`` 408*4882a593Smuzhiyun - 2 409*4882a593Smuzhiyun - Buffer of a single-planar video output stream, see 410*4882a593Smuzhiyun :ref:`output`. 411*4882a593Smuzhiyun * - ``V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE`` 412*4882a593Smuzhiyun - 10 413*4882a593Smuzhiyun - Buffer of a multi-planar video output stream, see :ref:`output`. 414*4882a593Smuzhiyun * - ``V4L2_BUF_TYPE_VIDEO_OVERLAY`` 415*4882a593Smuzhiyun - 3 416*4882a593Smuzhiyun - Buffer for video overlay, see :ref:`overlay`. 417*4882a593Smuzhiyun * - ``V4L2_BUF_TYPE_VBI_CAPTURE`` 418*4882a593Smuzhiyun - 4 419*4882a593Smuzhiyun - Buffer of a raw VBI capture stream, see :ref:`raw-vbi`. 420*4882a593Smuzhiyun * - ``V4L2_BUF_TYPE_VBI_OUTPUT`` 421*4882a593Smuzhiyun - 5 422*4882a593Smuzhiyun - Buffer of a raw VBI output stream, see :ref:`raw-vbi`. 423*4882a593Smuzhiyun * - ``V4L2_BUF_TYPE_SLICED_VBI_CAPTURE`` 424*4882a593Smuzhiyun - 6 425*4882a593Smuzhiyun - Buffer of a sliced VBI capture stream, see :ref:`sliced`. 426*4882a593Smuzhiyun * - ``V4L2_BUF_TYPE_SLICED_VBI_OUTPUT`` 427*4882a593Smuzhiyun - 7 428*4882a593Smuzhiyun - Buffer of a sliced VBI output stream, see :ref:`sliced`. 429*4882a593Smuzhiyun * - ``V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY`` 430*4882a593Smuzhiyun - 8 431*4882a593Smuzhiyun - Buffer for video output overlay (OSD), see :ref:`osd`. 432*4882a593Smuzhiyun * - ``V4L2_BUF_TYPE_SDR_CAPTURE`` 433*4882a593Smuzhiyun - 11 434*4882a593Smuzhiyun - Buffer for Software Defined Radio (SDR) capture stream, see 435*4882a593Smuzhiyun :ref:`sdr`. 436*4882a593Smuzhiyun * - ``V4L2_BUF_TYPE_SDR_OUTPUT`` 437*4882a593Smuzhiyun - 12 438*4882a593Smuzhiyun - Buffer for Software Defined Radio (SDR) output stream, see 439*4882a593Smuzhiyun :ref:`sdr`. 440*4882a593Smuzhiyun * - ``V4L2_BUF_TYPE_META_CAPTURE`` 441*4882a593Smuzhiyun - 13 442*4882a593Smuzhiyun - Buffer for metadata capture, see :ref:`metadata`. 443*4882a593Smuzhiyun * - ``V4L2_BUF_TYPE_META_OUTPUT`` 444*4882a593Smuzhiyun - 14 445*4882a593Smuzhiyun - Buffer for metadata output, see :ref:`metadata`. 446*4882a593Smuzhiyun 447*4882a593Smuzhiyun 448*4882a593Smuzhiyun.. _buffer-flags: 449*4882a593Smuzhiyun 450*4882a593SmuzhiyunBuffer Flags 451*4882a593Smuzhiyun============ 452*4882a593Smuzhiyun 453*4882a593Smuzhiyun.. raw:: latex 454*4882a593Smuzhiyun 455*4882a593Smuzhiyun \small 456*4882a593Smuzhiyun 457*4882a593Smuzhiyun.. tabularcolumns:: |p{7.0cm}|p{2.1cm}|p{8.4cm}| 458*4882a593Smuzhiyun 459*4882a593Smuzhiyun.. cssclass:: longtable 460*4882a593Smuzhiyun 461*4882a593Smuzhiyun.. flat-table:: 462*4882a593Smuzhiyun :header-rows: 0 463*4882a593Smuzhiyun :stub-columns: 0 464*4882a593Smuzhiyun :widths: 3 1 4 465*4882a593Smuzhiyun 466*4882a593Smuzhiyun * .. _`V4L2-BUF-FLAG-MAPPED`: 467*4882a593Smuzhiyun 468*4882a593Smuzhiyun - ``V4L2_BUF_FLAG_MAPPED`` 469*4882a593Smuzhiyun - 0x00000001 470*4882a593Smuzhiyun - The buffer resides in device memory and has been mapped into the 471*4882a593Smuzhiyun application's address space, see :ref:`mmap` for details. 472*4882a593Smuzhiyun Drivers set or clear this flag when the 473*4882a593Smuzhiyun :ref:`VIDIOC_QUERYBUF`, 474*4882a593Smuzhiyun :ref:`VIDIOC_QBUF` or 475*4882a593Smuzhiyun :ref:`VIDIOC_DQBUF <VIDIOC_QBUF>` ioctl is called. Set by the 476*4882a593Smuzhiyun driver. 477*4882a593Smuzhiyun * .. _`V4L2-BUF-FLAG-QUEUED`: 478*4882a593Smuzhiyun 479*4882a593Smuzhiyun - ``V4L2_BUF_FLAG_QUEUED`` 480*4882a593Smuzhiyun - 0x00000002 481*4882a593Smuzhiyun - Internally drivers maintain two buffer queues, an incoming and 482*4882a593Smuzhiyun outgoing queue. When this flag is set, the buffer is currently on 483*4882a593Smuzhiyun the incoming queue. It automatically moves to the outgoing queue 484*4882a593Smuzhiyun after the buffer has been filled (capture devices) or displayed 485*4882a593Smuzhiyun (output devices). Drivers set or clear this flag when the 486*4882a593Smuzhiyun ``VIDIOC_QUERYBUF`` ioctl is called. After (successful) calling 487*4882a593Smuzhiyun the ``VIDIOC_QBUF``\ ioctl it is always set and after 488*4882a593Smuzhiyun ``VIDIOC_DQBUF`` always cleared. 489*4882a593Smuzhiyun * .. _`V4L2-BUF-FLAG-DONE`: 490*4882a593Smuzhiyun 491*4882a593Smuzhiyun - ``V4L2_BUF_FLAG_DONE`` 492*4882a593Smuzhiyun - 0x00000004 493*4882a593Smuzhiyun - When this flag is set, the buffer is currently on the outgoing 494*4882a593Smuzhiyun queue, ready to be dequeued from the driver. Drivers set or clear 495*4882a593Smuzhiyun this flag when the ``VIDIOC_QUERYBUF`` ioctl is called. After 496*4882a593Smuzhiyun calling the ``VIDIOC_QBUF`` or ``VIDIOC_DQBUF`` it is always 497*4882a593Smuzhiyun cleared. Of course a buffer cannot be on both queues at the same 498*4882a593Smuzhiyun time, the ``V4L2_BUF_FLAG_QUEUED`` and ``V4L2_BUF_FLAG_DONE`` flag 499*4882a593Smuzhiyun are mutually exclusive. They can be both cleared however, then the 500*4882a593Smuzhiyun buffer is in "dequeued" state, in the application domain so to 501*4882a593Smuzhiyun say. 502*4882a593Smuzhiyun * .. _`V4L2-BUF-FLAG-ERROR`: 503*4882a593Smuzhiyun 504*4882a593Smuzhiyun - ``V4L2_BUF_FLAG_ERROR`` 505*4882a593Smuzhiyun - 0x00000040 506*4882a593Smuzhiyun - When this flag is set, the buffer has been dequeued successfully, 507*4882a593Smuzhiyun although the data might have been corrupted. This is recoverable, 508*4882a593Smuzhiyun streaming may continue as normal and the buffer may be reused 509*4882a593Smuzhiyun normally. Drivers set this flag when the ``VIDIOC_DQBUF`` ioctl is 510*4882a593Smuzhiyun called. 511*4882a593Smuzhiyun * .. _`V4L2-BUF-FLAG-IN-REQUEST`: 512*4882a593Smuzhiyun 513*4882a593Smuzhiyun - ``V4L2_BUF_FLAG_IN_REQUEST`` 514*4882a593Smuzhiyun - 0x00000080 515*4882a593Smuzhiyun - This buffer is part of a request that hasn't been queued yet. 516*4882a593Smuzhiyun * .. _`V4L2-BUF-FLAG-KEYFRAME`: 517*4882a593Smuzhiyun 518*4882a593Smuzhiyun - ``V4L2_BUF_FLAG_KEYFRAME`` 519*4882a593Smuzhiyun - 0x00000008 520*4882a593Smuzhiyun - Drivers set or clear this flag when calling the ``VIDIOC_DQBUF`` 521*4882a593Smuzhiyun ioctl. It may be set by video capture devices when the buffer 522*4882a593Smuzhiyun contains a compressed image which is a key frame (or field), i. e. 523*4882a593Smuzhiyun can be decompressed on its own. Also known as an I-frame. 524*4882a593Smuzhiyun Applications can set this bit when ``type`` refers to an output 525*4882a593Smuzhiyun stream. 526*4882a593Smuzhiyun * .. _`V4L2-BUF-FLAG-PFRAME`: 527*4882a593Smuzhiyun 528*4882a593Smuzhiyun - ``V4L2_BUF_FLAG_PFRAME`` 529*4882a593Smuzhiyun - 0x00000010 530*4882a593Smuzhiyun - Similar to ``V4L2_BUF_FLAG_KEYFRAME`` this flags predicted frames 531*4882a593Smuzhiyun or fields which contain only differences to a previous key frame. 532*4882a593Smuzhiyun Applications can set this bit when ``type`` refers to an output 533*4882a593Smuzhiyun stream. 534*4882a593Smuzhiyun * .. _`V4L2-BUF-FLAG-BFRAME`: 535*4882a593Smuzhiyun 536*4882a593Smuzhiyun - ``V4L2_BUF_FLAG_BFRAME`` 537*4882a593Smuzhiyun - 0x00000020 538*4882a593Smuzhiyun - Similar to ``V4L2_BUF_FLAG_KEYFRAME`` this flags a bi-directional 539*4882a593Smuzhiyun predicted frame or field which contains only the differences 540*4882a593Smuzhiyun between the current frame and both the preceding and following key 541*4882a593Smuzhiyun frames to specify its content. Applications can set this bit when 542*4882a593Smuzhiyun ``type`` refers to an output stream. 543*4882a593Smuzhiyun * .. _`V4L2-BUF-FLAG-TIMECODE`: 544*4882a593Smuzhiyun 545*4882a593Smuzhiyun - ``V4L2_BUF_FLAG_TIMECODE`` 546*4882a593Smuzhiyun - 0x00000100 547*4882a593Smuzhiyun - The ``timecode`` field is valid. Drivers set or clear this flag 548*4882a593Smuzhiyun when the ``VIDIOC_DQBUF`` ioctl is called. Applications can set 549*4882a593Smuzhiyun this bit and the corresponding ``timecode`` structure when 550*4882a593Smuzhiyun ``type`` refers to an output stream. 551*4882a593Smuzhiyun * .. _`V4L2-BUF-FLAG-PREPARED`: 552*4882a593Smuzhiyun 553*4882a593Smuzhiyun - ``V4L2_BUF_FLAG_PREPARED`` 554*4882a593Smuzhiyun - 0x00000400 555*4882a593Smuzhiyun - The buffer has been prepared for I/O and can be queued by the 556*4882a593Smuzhiyun application. Drivers set or clear this flag when the 557*4882a593Smuzhiyun :ref:`VIDIOC_QUERYBUF`, 558*4882a593Smuzhiyun :ref:`VIDIOC_PREPARE_BUF <VIDIOC_QBUF>`, 559*4882a593Smuzhiyun :ref:`VIDIOC_QBUF` or 560*4882a593Smuzhiyun :ref:`VIDIOC_DQBUF <VIDIOC_QBUF>` ioctl is called. 561*4882a593Smuzhiyun * .. _`V4L2-BUF-FLAG-NO-CACHE-INVALIDATE`: 562*4882a593Smuzhiyun 563*4882a593Smuzhiyun - ``V4L2_BUF_FLAG_NO_CACHE_INVALIDATE`` 564*4882a593Smuzhiyun - 0x00000800 565*4882a593Smuzhiyun - Caches do not have to be invalidated for this buffer. Typically 566*4882a593Smuzhiyun applications shall use this flag if the data captured in the 567*4882a593Smuzhiyun buffer is not going to be touched by the CPU, instead the buffer 568*4882a593Smuzhiyun will, probably, be passed on to a DMA-capable hardware unit for 569*4882a593Smuzhiyun further processing or output. This flag is ignored unless the 570*4882a593Smuzhiyun queue is used for :ref:`memory mapping <mmap>` streaming I/O and 571*4882a593Smuzhiyun reports :ref:`V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS 572*4882a593Smuzhiyun <V4L2-BUF-CAP-SUPPORTS-MMAP-CACHE-HINTS>` capability. 573*4882a593Smuzhiyun * .. _`V4L2-BUF-FLAG-NO-CACHE-CLEAN`: 574*4882a593Smuzhiyun 575*4882a593Smuzhiyun - ``V4L2_BUF_FLAG_NO_CACHE_CLEAN`` 576*4882a593Smuzhiyun - 0x00001000 577*4882a593Smuzhiyun - Caches do not have to be cleaned for this buffer. Typically 578*4882a593Smuzhiyun applications shall use this flag for output buffers if the data in 579*4882a593Smuzhiyun this buffer has not been created by the CPU but by some 580*4882a593Smuzhiyun DMA-capable unit, in which case caches have not been used. This flag 581*4882a593Smuzhiyun is ignored unless the queue is used for :ref:`memory mapping <mmap>` 582*4882a593Smuzhiyun streaming I/O and reports :ref:`V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS 583*4882a593Smuzhiyun <V4L2-BUF-CAP-SUPPORTS-MMAP-CACHE-HINTS>` capability. 584*4882a593Smuzhiyun * .. _`V4L2-BUF-FLAG-M2M-HOLD-CAPTURE-BUF`: 585*4882a593Smuzhiyun 586*4882a593Smuzhiyun - ``V4L2_BUF_FLAG_M2M_HOLD_CAPTURE_BUF`` 587*4882a593Smuzhiyun - 0x00000200 588*4882a593Smuzhiyun - Only valid if ``V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF`` is 589*4882a593Smuzhiyun set. It is typically used with stateless decoders where multiple 590*4882a593Smuzhiyun output buffers each decode to a slice of the decoded frame. 591*4882a593Smuzhiyun Applications can set this flag when queueing the output buffer 592*4882a593Smuzhiyun to prevent the driver from dequeueing the capture buffer after 593*4882a593Smuzhiyun the output buffer has been decoded (i.e. the capture buffer is 594*4882a593Smuzhiyun 'held'). If the timestamp of this output buffer differs from that 595*4882a593Smuzhiyun of the previous output buffer, then that indicates the start of a 596*4882a593Smuzhiyun new frame and the previously held capture buffer is dequeued. 597*4882a593Smuzhiyun * .. _`V4L2-BUF-FLAG-LAST`: 598*4882a593Smuzhiyun 599*4882a593Smuzhiyun - ``V4L2_BUF_FLAG_LAST`` 600*4882a593Smuzhiyun - 0x00100000 601*4882a593Smuzhiyun - Last buffer produced by the hardware. mem2mem codec drivers set 602*4882a593Smuzhiyun this flag on the capture queue for the last buffer when the 603*4882a593Smuzhiyun :ref:`VIDIOC_QUERYBUF` or 604*4882a593Smuzhiyun :ref:`VIDIOC_DQBUF <VIDIOC_QBUF>` ioctl is called. Due to 605*4882a593Smuzhiyun hardware limitations, the last buffer may be empty. In this case 606*4882a593Smuzhiyun the driver will set the ``bytesused`` field to 0, regardless of 607*4882a593Smuzhiyun the format. Any Any subsequent call to the 608*4882a593Smuzhiyun :ref:`VIDIOC_DQBUF <VIDIOC_QBUF>` ioctl will not block anymore, 609*4882a593Smuzhiyun but return an ``EPIPE`` error code. 610*4882a593Smuzhiyun * .. _`V4L2-BUF-FLAG-REQUEST-FD`: 611*4882a593Smuzhiyun 612*4882a593Smuzhiyun - ``V4L2_BUF_FLAG_REQUEST_FD`` 613*4882a593Smuzhiyun - 0x00800000 614*4882a593Smuzhiyun - The ``request_fd`` field contains a valid file descriptor. 615*4882a593Smuzhiyun * .. _`V4L2-BUF-FLAG-TIMESTAMP-MASK`: 616*4882a593Smuzhiyun 617*4882a593Smuzhiyun - ``V4L2_BUF_FLAG_TIMESTAMP_MASK`` 618*4882a593Smuzhiyun - 0x0000e000 619*4882a593Smuzhiyun - Mask for timestamp types below. To test the timestamp type, mask 620*4882a593Smuzhiyun out bits not belonging to timestamp type by performing a logical 621*4882a593Smuzhiyun and operation with buffer flags and timestamp mask. 622*4882a593Smuzhiyun * .. _`V4L2-BUF-FLAG-TIMESTAMP-UNKNOWN`: 623*4882a593Smuzhiyun 624*4882a593Smuzhiyun - ``V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN`` 625*4882a593Smuzhiyun - 0x00000000 626*4882a593Smuzhiyun - Unknown timestamp type. This type is used by drivers before Linux 627*4882a593Smuzhiyun 3.9 and may be either monotonic (see below) or realtime (wall 628*4882a593Smuzhiyun clock). Monotonic clock has been favoured in embedded systems 629*4882a593Smuzhiyun whereas most of the drivers use the realtime clock. Either kinds 630*4882a593Smuzhiyun of timestamps are available in user space via 631*4882a593Smuzhiyun :c:func:`clock_gettime` using clock IDs ``CLOCK_MONOTONIC`` 632*4882a593Smuzhiyun and ``CLOCK_REALTIME``, respectively. 633*4882a593Smuzhiyun * .. _`V4L2-BUF-FLAG-TIMESTAMP-MONOTONIC`: 634*4882a593Smuzhiyun 635*4882a593Smuzhiyun - ``V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC`` 636*4882a593Smuzhiyun - 0x00002000 637*4882a593Smuzhiyun - The buffer timestamp has been taken from the ``CLOCK_MONOTONIC`` 638*4882a593Smuzhiyun clock. To access the same clock outside V4L2, use 639*4882a593Smuzhiyun :c:func:`clock_gettime`. 640*4882a593Smuzhiyun * .. _`V4L2-BUF-FLAG-TIMESTAMP-COPY`: 641*4882a593Smuzhiyun 642*4882a593Smuzhiyun - ``V4L2_BUF_FLAG_TIMESTAMP_COPY`` 643*4882a593Smuzhiyun - 0x00004000 644*4882a593Smuzhiyun - The CAPTURE buffer timestamp has been taken from the corresponding 645*4882a593Smuzhiyun OUTPUT buffer. This flag applies only to mem2mem devices. 646*4882a593Smuzhiyun * .. _`V4L2-BUF-FLAG-TSTAMP-SRC-MASK`: 647*4882a593Smuzhiyun 648*4882a593Smuzhiyun - ``V4L2_BUF_FLAG_TSTAMP_SRC_MASK`` 649*4882a593Smuzhiyun - 0x00070000 650*4882a593Smuzhiyun - Mask for timestamp sources below. The timestamp source defines the 651*4882a593Smuzhiyun point of time the timestamp is taken in relation to the frame. 652*4882a593Smuzhiyun Logical 'and' operation between the ``flags`` field and 653*4882a593Smuzhiyun ``V4L2_BUF_FLAG_TSTAMP_SRC_MASK`` produces the value of the 654*4882a593Smuzhiyun timestamp source. Applications must set the timestamp source when 655*4882a593Smuzhiyun ``type`` refers to an output stream and 656*4882a593Smuzhiyun ``V4L2_BUF_FLAG_TIMESTAMP_COPY`` is set. 657*4882a593Smuzhiyun * .. _`V4L2-BUF-FLAG-TSTAMP-SRC-EOF`: 658*4882a593Smuzhiyun 659*4882a593Smuzhiyun - ``V4L2_BUF_FLAG_TSTAMP_SRC_EOF`` 660*4882a593Smuzhiyun - 0x00000000 661*4882a593Smuzhiyun - End Of Frame. The buffer timestamp has been taken when the last 662*4882a593Smuzhiyun pixel of the frame has been received or the last pixel of the 663*4882a593Smuzhiyun frame has been transmitted. In practice, software generated 664*4882a593Smuzhiyun timestamps will typically be read from the clock a small amount of 665*4882a593Smuzhiyun time after the last pixel has been received or transmitten, 666*4882a593Smuzhiyun depending on the system and other activity in it. 667*4882a593Smuzhiyun * .. _`V4L2-BUF-FLAG-TSTAMP-SRC-SOE`: 668*4882a593Smuzhiyun 669*4882a593Smuzhiyun - ``V4L2_BUF_FLAG_TSTAMP_SRC_SOE`` 670*4882a593Smuzhiyun - 0x00010000 671*4882a593Smuzhiyun - Start Of Exposure. The buffer timestamp has been taken when the 672*4882a593Smuzhiyun exposure of the frame has begun. This is only valid for the 673*4882a593Smuzhiyun ``V4L2_BUF_TYPE_VIDEO_CAPTURE`` buffer type. 674*4882a593Smuzhiyun 675*4882a593Smuzhiyun.. raw:: latex 676*4882a593Smuzhiyun 677*4882a593Smuzhiyun \normalsize 678*4882a593Smuzhiyun 679*4882a593Smuzhiyun.. _memory-flags: 680*4882a593Smuzhiyun 681*4882a593Smuzhiyunenum v4l2_memory 682*4882a593Smuzhiyun================ 683*4882a593Smuzhiyun 684*4882a593Smuzhiyun.. tabularcolumns:: |p{5.0cm}|p{0.8cm}|p{11.7cm}| 685*4882a593Smuzhiyun 686*4882a593Smuzhiyun.. flat-table:: 687*4882a593Smuzhiyun :header-rows: 0 688*4882a593Smuzhiyun :stub-columns: 0 689*4882a593Smuzhiyun :widths: 3 1 4 690*4882a593Smuzhiyun 691*4882a593Smuzhiyun * - ``V4L2_MEMORY_MMAP`` 692*4882a593Smuzhiyun - 1 693*4882a593Smuzhiyun - The buffer is used for :ref:`memory mapping <mmap>` I/O. 694*4882a593Smuzhiyun * - ``V4L2_MEMORY_USERPTR`` 695*4882a593Smuzhiyun - 2 696*4882a593Smuzhiyun - The buffer is used for :ref:`user pointer <userp>` I/O. 697*4882a593Smuzhiyun * - ``V4L2_MEMORY_OVERLAY`` 698*4882a593Smuzhiyun - 3 699*4882a593Smuzhiyun - [to do] 700*4882a593Smuzhiyun * - ``V4L2_MEMORY_DMABUF`` 701*4882a593Smuzhiyun - 4 702*4882a593Smuzhiyun - The buffer is used for :ref:`DMA shared buffer <dmabuf>` I/O. 703*4882a593Smuzhiyun 704*4882a593Smuzhiyun 705*4882a593SmuzhiyunTimecodes 706*4882a593Smuzhiyun========= 707*4882a593Smuzhiyun 708*4882a593SmuzhiyunThe :c:type:`v4l2_buffer_timecode` structure is designed to hold a 709*4882a593Smuzhiyun:ref:`smpte12m` or similar timecode. 710*4882a593Smuzhiyun(struct :c:type:`timeval` timestamps are stored in the struct 711*4882a593Smuzhiyun:c:type:`v4l2_buffer` ``timestamp`` field.) 712*4882a593Smuzhiyun 713*4882a593Smuzhiyun.. c:type:: v4l2_timecode 714*4882a593Smuzhiyun 715*4882a593Smuzhiyunstruct v4l2_timecode 716*4882a593Smuzhiyun-------------------- 717*4882a593Smuzhiyun 718*4882a593Smuzhiyun.. tabularcolumns:: |p{1.4cm}|p{2.8cm}|p{12.3cm}| 719*4882a593Smuzhiyun 720*4882a593Smuzhiyun.. flat-table:: 721*4882a593Smuzhiyun :header-rows: 0 722*4882a593Smuzhiyun :stub-columns: 0 723*4882a593Smuzhiyun :widths: 1 1 2 724*4882a593Smuzhiyun 725*4882a593Smuzhiyun * - __u32 726*4882a593Smuzhiyun - ``type`` 727*4882a593Smuzhiyun - Frame rate the timecodes are based on, see :ref:`timecode-type`. 728*4882a593Smuzhiyun * - __u32 729*4882a593Smuzhiyun - ``flags`` 730*4882a593Smuzhiyun - Timecode flags, see :ref:`timecode-flags`. 731*4882a593Smuzhiyun * - __u8 732*4882a593Smuzhiyun - ``frames`` 733*4882a593Smuzhiyun - Frame count, 0 ... 23/24/29/49/59, depending on the type of 734*4882a593Smuzhiyun timecode. 735*4882a593Smuzhiyun * - __u8 736*4882a593Smuzhiyun - ``seconds`` 737*4882a593Smuzhiyun - Seconds count, 0 ... 59. This is a binary, not BCD number. 738*4882a593Smuzhiyun * - __u8 739*4882a593Smuzhiyun - ``minutes`` 740*4882a593Smuzhiyun - Minutes count, 0 ... 59. This is a binary, not BCD number. 741*4882a593Smuzhiyun * - __u8 742*4882a593Smuzhiyun - ``hours`` 743*4882a593Smuzhiyun - Hours count, 0 ... 29. This is a binary, not BCD number. 744*4882a593Smuzhiyun * - __u8 745*4882a593Smuzhiyun - ``userbits``\ [4] 746*4882a593Smuzhiyun - The "user group" bits from the timecode. 747*4882a593Smuzhiyun 748*4882a593Smuzhiyun 749*4882a593Smuzhiyun.. _timecode-type: 750*4882a593Smuzhiyun 751*4882a593SmuzhiyunTimecode Types 752*4882a593Smuzhiyun-------------- 753*4882a593Smuzhiyun 754*4882a593Smuzhiyun.. tabularcolumns:: |p{5.6cm}|p{0.8cm}|p{11.1cm}| 755*4882a593Smuzhiyun 756*4882a593Smuzhiyun.. flat-table:: 757*4882a593Smuzhiyun :header-rows: 0 758*4882a593Smuzhiyun :stub-columns: 0 759*4882a593Smuzhiyun :widths: 3 1 4 760*4882a593Smuzhiyun 761*4882a593Smuzhiyun * - ``V4L2_TC_TYPE_24FPS`` 762*4882a593Smuzhiyun - 1 763*4882a593Smuzhiyun - 24 frames per second, i. e. film. 764*4882a593Smuzhiyun * - ``V4L2_TC_TYPE_25FPS`` 765*4882a593Smuzhiyun - 2 766*4882a593Smuzhiyun - 25 frames per second, i. e. PAL or SECAM video. 767*4882a593Smuzhiyun * - ``V4L2_TC_TYPE_30FPS`` 768*4882a593Smuzhiyun - 3 769*4882a593Smuzhiyun - 30 frames per second, i. e. NTSC video. 770*4882a593Smuzhiyun * - ``V4L2_TC_TYPE_50FPS`` 771*4882a593Smuzhiyun - 4 772*4882a593Smuzhiyun - 773*4882a593Smuzhiyun * - ``V4L2_TC_TYPE_60FPS`` 774*4882a593Smuzhiyun - 5 775*4882a593Smuzhiyun - 776*4882a593Smuzhiyun 777*4882a593Smuzhiyun 778*4882a593Smuzhiyun.. _timecode-flags: 779*4882a593Smuzhiyun 780*4882a593SmuzhiyunTimecode Flags 781*4882a593Smuzhiyun-------------- 782*4882a593Smuzhiyun 783*4882a593Smuzhiyun.. tabularcolumns:: |p{6.6cm}|p{1.4cm}|p{9.5cm}| 784*4882a593Smuzhiyun 785*4882a593Smuzhiyun.. flat-table:: 786*4882a593Smuzhiyun :header-rows: 0 787*4882a593Smuzhiyun :stub-columns: 0 788*4882a593Smuzhiyun :widths: 3 1 4 789*4882a593Smuzhiyun 790*4882a593Smuzhiyun * - ``V4L2_TC_FLAG_DROPFRAME`` 791*4882a593Smuzhiyun - 0x0001 792*4882a593Smuzhiyun - Indicates "drop frame" semantics for counting frames in 29.97 fps 793*4882a593Smuzhiyun material. When set, frame numbers 0 and 1 at the start of each 794*4882a593Smuzhiyun minute, except minutes 0, 10, 20, 30, 40, 50 are omitted from the 795*4882a593Smuzhiyun count. 796*4882a593Smuzhiyun * - ``V4L2_TC_FLAG_COLORFRAME`` 797*4882a593Smuzhiyun - 0x0002 798*4882a593Smuzhiyun - The "color frame" flag. 799*4882a593Smuzhiyun * - ``V4L2_TC_USERBITS_field`` 800*4882a593Smuzhiyun - 0x000C 801*4882a593Smuzhiyun - Field mask for the "binary group flags". 802*4882a593Smuzhiyun * - ``V4L2_TC_USERBITS_USERDEFINED`` 803*4882a593Smuzhiyun - 0x0000 804*4882a593Smuzhiyun - Unspecified format. 805*4882a593Smuzhiyun * - ``V4L2_TC_USERBITS_8BITCHARS`` 806*4882a593Smuzhiyun - 0x0008 807*4882a593Smuzhiyun - 8-bit ISO characters. 808