vidioc-querybuf.rst 2.5 KB

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