vidioc-querybuf.rst 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
  2. .. c:namespace:: V4L
  3. .. _VIDIOC_QUERYBUF:
  4. *********************
  5. ioctl VIDIOC_QUERYBUF
  6. *********************
  7. Name
  8. ====
  9. VIDIOC_QUERYBUF - Query the status of a buffer
  10. Synopsis
  11. ========
  12. .. c:macro:: VIDIOC_QUERYBUF
  13. ``int ioctl(int fd, VIDIOC_QUERYBUF, struct v4l2_buffer *argp)``
  14. Arguments
  15. =========
  16. ``fd``
  17. File descriptor returned by :c:func:`open()`.
  18. ``argp``
  19. Pointer to struct :c:type:`v4l2_buffer`.
  20. Description
  21. ===========
  22. This ioctl is part of the :ref:`streaming <mmap>` I/O method. It can
  23. be used to query the status of a buffer at any time after buffers have
  24. been allocated with the :ref:`VIDIOC_REQBUFS` ioctl.
  25. Applications set the ``type`` field of a struct
  26. :c:type:`v4l2_buffer` to the same buffer type as was
  27. previously used with struct :c:type:`v4l2_format` ``type``
  28. and struct :c:type:`v4l2_requestbuffers` ``type``,
  29. and the ``index`` field. Valid index numbers range from zero to the
  30. number of buffers allocated with
  31. :ref:`VIDIOC_REQBUFS` (struct
  32. :c:type:`v4l2_requestbuffers` ``count``) minus
  33. one. The ``reserved`` and ``reserved2`` fields must be set to 0. When
  34. using the :ref:`multi-planar API <planar-apis>`, the ``m.planes``
  35. field must contain a userspace pointer to an array of struct
  36. :c:type:`v4l2_plane` and the ``length`` field has to be set
  37. to the number of elements in that array. After calling
  38. :ref:`VIDIOC_QUERYBUF` with a pointer to this structure drivers return an
  39. error code or fill the rest of the structure.
  40. In the ``flags`` field the ``V4L2_BUF_FLAG_MAPPED``,
  41. ``V4L2_BUF_FLAG_PREPARED``, ``V4L2_BUF_FLAG_QUEUED`` and
  42. ``V4L2_BUF_FLAG_DONE`` flags will be valid. The ``memory`` field will be
  43. set to the current I/O method. For the single-planar API, the
  44. ``m.offset`` contains the offset of the buffer from the start of the
  45. device memory, the ``length`` field its size. For the multi-planar API,
  46. fields ``m.mem_offset`` and ``length`` in the ``m.planes`` array
  47. elements will be used instead and the ``length`` field of struct
  48. :c:type:`v4l2_buffer` is set to the number of filled-in
  49. array elements. The driver may or may not set the remaining fields and
  50. flags, they are meaningless in this context.
  51. The struct :c:type:`v4l2_buffer` structure is specified in
  52. :ref:`buffer`.
  53. Return Value
  54. ============
  55. On success 0 is returned, on error -1 and the ``errno`` variable is set
  56. appropriately. The generic error codes are described at the
  57. :ref:`Generic Error Codes <gen-errors>` chapter.
  58. EINVAL
  59. The buffer ``type`` is not supported, or the ``index`` is out of
  60. bounds.