0001 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
0002 .. c:namespace:: V4L
0003
0004 .. _VIDIOC_QUERYBUF:
0005
0006 *********************
0007 ioctl VIDIOC_QUERYBUF
0008 *********************
0009
0010 Name
0011 ====
0012
0013 VIDIOC_QUERYBUF - Query the status of a buffer
0014
0015 Synopsis
0016 ========
0017
0018 .. c:macro:: VIDIOC_QUERYBUF
0019
0020 ``int ioctl(int fd, VIDIOC_QUERYBUF, struct v4l2_buffer *argp)``
0021
0022 Arguments
0023 =========
0024
0025 ``fd``
0026 File descriptor returned by :c:func:`open()`.
0027
0028 ``argp``
0029 Pointer to struct :c:type:`v4l2_buffer`.
0030
0031 Description
0032 ===========
0033
0034 This ioctl is part of the :ref:`streaming <mmap>` I/O method. It can
0035 be used to query the status of a buffer at any time after buffers have
0036 been allocated with the :ref:`VIDIOC_REQBUFS` ioctl.
0037
0038 Applications set the ``type`` field of a struct
0039 :c:type:`v4l2_buffer` to the same buffer type as was
0040 previously used with struct :c:type:`v4l2_format` ``type``
0041 and struct :c:type:`v4l2_requestbuffers` ``type``,
0042 and the ``index`` field. Valid index numbers range from zero to the
0043 number of buffers allocated with
0044 :ref:`VIDIOC_REQBUFS` (struct
0045 :c:type:`v4l2_requestbuffers` ``count``) minus
0046 one. The ``reserved`` and ``reserved2`` fields must be set to 0. When
0047 using the :ref:`multi-planar API <planar-apis>`, the ``m.planes``
0048 field must contain a userspace pointer to an array of struct
0049 :c:type:`v4l2_plane` and the ``length`` field has to be set
0050 to the number of elements in that array. After calling
0051 :ref:`VIDIOC_QUERYBUF` with a pointer to this structure drivers return an
0052 error code or fill the rest of the structure.
0053
0054 In the ``flags`` field the ``V4L2_BUF_FLAG_MAPPED``,
0055 ``V4L2_BUF_FLAG_PREPARED``, ``V4L2_BUF_FLAG_QUEUED`` and
0056 ``V4L2_BUF_FLAG_DONE`` flags will be valid. The ``memory`` field will be
0057 set to the current I/O method. For the single-planar API, the
0058 ``m.offset`` contains the offset of the buffer from the start of the
0059 device memory, the ``length`` field its size. For the multi-planar API,
0060 fields ``m.mem_offset`` and ``length`` in the ``m.planes`` array
0061 elements will be used instead and the ``length`` field of struct
0062 :c:type:`v4l2_buffer` is set to the number of filled-in
0063 array elements. The driver may or may not set the remaining fields and
0064 flags, they are meaningless in this context.
0065
0066 The struct :c:type:`v4l2_buffer` structure is specified in
0067 :ref:`buffer`.
0068
0069 Return Value
0070 ============
0071
0072 On success 0 is returned, on error -1 and the ``errno`` variable is set
0073 appropriately. The generic error codes are described at the
0074 :ref:`Generic Error Codes <gen-errors>` chapter.
0075
0076 EINVAL
0077 The buffer ``type`` is not supported, or the ``index`` is out of
0078 bounds.