162306a36Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later 262306a36Sopenharmony_ci.. c:namespace:: V4L 362306a36Sopenharmony_ci 462306a36Sopenharmony_ci.. _VIDIOC_QUERYBUF: 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci********************* 762306a36Sopenharmony_ciioctl VIDIOC_QUERYBUF 862306a36Sopenharmony_ci********************* 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ciName 1162306a36Sopenharmony_ci==== 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ciVIDIOC_QUERYBUF - Query the status of a buffer 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ciSynopsis 1662306a36Sopenharmony_ci======== 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ci.. c:macro:: VIDIOC_QUERYBUF 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci``int ioctl(int fd, VIDIOC_QUERYBUF, struct v4l2_buffer *argp)`` 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ciArguments 2362306a36Sopenharmony_ci========= 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_ci``fd`` 2662306a36Sopenharmony_ci File descriptor returned by :c:func:`open()`. 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_ci``argp`` 2962306a36Sopenharmony_ci Pointer to struct :c:type:`v4l2_buffer`. 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_ciDescription 3262306a36Sopenharmony_ci=========== 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ciThis ioctl is part of the :ref:`streaming <mmap>` I/O method. It can 3562306a36Sopenharmony_cibe used to query the status of a buffer at any time after buffers have 3662306a36Sopenharmony_cibeen allocated with the :ref:`VIDIOC_REQBUFS` ioctl. 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ciApplications set the ``type`` field of a struct 3962306a36Sopenharmony_ci:c:type:`v4l2_buffer` to the same buffer type as was 4062306a36Sopenharmony_cipreviously used with struct :c:type:`v4l2_format` ``type`` 4162306a36Sopenharmony_ciand struct :c:type:`v4l2_requestbuffers` ``type``, 4262306a36Sopenharmony_ciand the ``index`` field. Valid index numbers range from zero to the 4362306a36Sopenharmony_cinumber of buffers allocated with 4462306a36Sopenharmony_ci:ref:`VIDIOC_REQBUFS` (struct 4562306a36Sopenharmony_ci:c:type:`v4l2_requestbuffers` ``count``) minus 4662306a36Sopenharmony_cione. The ``reserved`` and ``reserved2`` fields must be set to 0. When 4762306a36Sopenharmony_ciusing the :ref:`multi-planar API <planar-apis>`, the ``m.planes`` 4862306a36Sopenharmony_cifield must contain a userspace pointer to an array of struct 4962306a36Sopenharmony_ci:c:type:`v4l2_plane` and the ``length`` field has to be set 5062306a36Sopenharmony_cito the number of elements in that array. After calling 5162306a36Sopenharmony_ci:ref:`VIDIOC_QUERYBUF` with a pointer to this structure drivers return an 5262306a36Sopenharmony_cierror code or fill the rest of the structure. 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ciIn the ``flags`` field the ``V4L2_BUF_FLAG_MAPPED``, 5562306a36Sopenharmony_ci``V4L2_BUF_FLAG_PREPARED``, ``V4L2_BUF_FLAG_QUEUED`` and 5662306a36Sopenharmony_ci``V4L2_BUF_FLAG_DONE`` flags will be valid. The ``memory`` field will be 5762306a36Sopenharmony_ciset to the current I/O method. For the single-planar API, the 5862306a36Sopenharmony_ci``m.offset`` contains the offset of the buffer from the start of the 5962306a36Sopenharmony_cidevice memory, the ``length`` field its size. For the multi-planar API, 6062306a36Sopenharmony_cifields ``m.mem_offset`` and ``length`` in the ``m.planes`` array 6162306a36Sopenharmony_cielements will be used instead and the ``length`` field of struct 6262306a36Sopenharmony_ci:c:type:`v4l2_buffer` is set to the number of filled-in 6362306a36Sopenharmony_ciarray elements. The driver may or may not set the remaining fields and 6462306a36Sopenharmony_ciflags, they are meaningless in this context. 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_ciThe struct :c:type:`v4l2_buffer` structure is specified in 6762306a36Sopenharmony_ci:ref:`buffer`. 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_ciReturn Value 7062306a36Sopenharmony_ci============ 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ciOn success 0 is returned, on error -1 and the ``errno`` variable is set 7362306a36Sopenharmony_ciappropriately. The generic error codes are described at the 7462306a36Sopenharmony_ci:ref:`Generic Error Codes <gen-errors>` chapter. 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ciEINVAL 7762306a36Sopenharmony_ci The buffer ``type`` is not supported, or the ``index`` is out of 7862306a36Sopenharmony_ci bounds. 79