dmx-qbuf.rst 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
  2. .. c:namespace:: DTV.dmx
  3. .. _DMX_QBUF:
  4. *************************
  5. ioctl DMX_QBUF, DMX_DQBUF
  6. *************************
  7. Name
  8. ====
  9. DMX_QBUF - DMX_DQBUF - Exchange a buffer with the driver
  10. .. warning:: this API is still experimental
  11. Synopsis
  12. ========
  13. .. c:macro:: DMX_QBUF
  14. ``int ioctl(int fd, DMX_QBUF, struct dmx_buffer *argp)``
  15. .. c:macro:: DMX_DQBUF
  16. ``int ioctl(int fd, DMX_DQBUF, struct dmx_buffer *argp)``
  17. Arguments
  18. =========
  19. ``fd``
  20. File descriptor returned by :c:func:`open()`.
  21. ``argp``
  22. Pointer to struct :c:type:`dmx_buffer`.
  23. Description
  24. ===========
  25. Applications call the ``DMX_QBUF`` ioctl to enqueue an empty
  26. (capturing) or filled (output) buffer in the driver's incoming queue.
  27. The semantics depend on the selected I/O method.
  28. To enqueue a buffer applications set the ``index`` field. Valid index
  29. numbers range from zero to the number of buffers allocated with
  30. :ref:`DMX_REQBUFS` (struct :c:type:`dmx_requestbuffers` ``count``) minus
  31. one. The contents of the struct :c:type:`dmx_buffer` returned
  32. by a :ref:`DMX_QUERYBUF` ioctl will do as well.
  33. When ``DMX_QBUF`` is called with a pointer to this structure, it locks the
  34. memory pages of the buffer in physical memory, so they cannot be swapped
  35. out to disk. Buffers remain locked until dequeued, until the
  36. device is closed.
  37. Applications call the ``DMX_DQBUF`` ioctl to dequeue a filled
  38. (capturing) buffer from the driver's outgoing queue.
  39. They just set the ``index`` field with the buffer ID to be queued.
  40. When ``DMX_DQBUF`` is called with a pointer to struct :c:type:`dmx_buffer`,
  41. the driver fills the remaining fields or returns an error code.
  42. By default ``DMX_DQBUF`` blocks when no buffer is in the outgoing
  43. queue. When the ``O_NONBLOCK`` flag was given to the
  44. :c:func:`open()` function, ``DMX_DQBUF`` returns
  45. immediately with an ``EAGAIN`` error code when no buffer is available.
  46. The struct :c:type:`dmx_buffer` structure is specified in
  47. :ref:`buffer`.
  48. Return Value
  49. ============
  50. On success 0 is returned, on error -1 and the ``errno`` variable is set
  51. appropriately. The generic error codes are described at the
  52. :ref:`Generic Error Codes <gen-errors>` chapter.
  53. EAGAIN
  54. Non-blocking I/O has been selected using ``O_NONBLOCK`` and no
  55. buffer was in the outgoing queue.
  56. EINVAL
  57. The ``index`` is out of bounds, or no buffers have been allocated yet.
  58. EIO
  59. ``DMX_DQBUF`` failed due to an internal error. Can also indicate
  60. temporary problems like signal loss or CRC errors.