···11+.. _DMX_EXPBUF:22+33+****************44+ioctl DMX_EXPBUF55+****************66+77+Name88+====99+1010+DMX_EXPBUF - Export a buffer as a DMABUF file descriptor.1111+1212+.. warning:: this API is still experimental1313+1414+1515+Synopsis1616+========1717+1818+.. c:function:: int ioctl( int fd, DMX_EXPBUF, struct dmx_exportbuffer *argp )1919+ :name: DMX_EXPBUF2020+2121+2222+Arguments2323+=========2424+2525+``fd``2626+ File descriptor returned by :ref:`open() <dmx_fopen>`.2727+2828+``argp``2929+ Pointer to struct :c:type:`dmx_exportbuffer`.3030+3131+3232+Description3333+===========3434+3535+This ioctl is an extension to the memory mapping I/O method.3636+It can be used to export a buffer as a DMABUF file at any time after3737+buffers have been allocated with the :ref:`DMX_REQBUFS` ioctl.3838+3939+The ``reserved`` array must be zeroed before calling it.4040+4141+To export a buffer, applications fill struct :c:type:`dmx_exportbuffer`.4242+Applications must set the ``index`` field. Valid index numbers4343+range from zero to the number of buffers allocated with :ref:`DMX_REQBUFS`4444+(struct :c:type:`dmx_requestbuffers` ``count``) minus one.4545+Additional flags may be posted in the ``flags`` field. Refer to a manual4646+for open() for details. Currently only O_CLOEXEC, O_RDONLY, O_WRONLY,4747+and O_RDWR are supported.4848+All other fields must be set to zero. In the4949+case of multi-planar API, every plane is exported separately using5050+multiple :ref:`DMX_EXPBUF` calls.5151+5252+After calling :ref:`DMX_EXPBUF` the ``fd`` field will be set by a5353+driver, on success. This is a DMABUF file descriptor. The application may5454+pass it to other DMABUF-aware devices. It is recommended to close a DMABUF5555+file when it is no longer used to allow the associated memory to be reclaimed.5656+5757+5858+Examples5959+========6060+6161+6262+.. code-block:: c6363+6464+ int buffer_export(int v4lfd, enum dmx_buf_type bt, int index, int *dmafd)6565+ {6666+ struct dmx_exportbuffer expbuf;6767+6868+ memset(&expbuf, 0, sizeof(expbuf));6969+ expbuf.type = bt;7070+ expbuf.index = index;7171+ if (ioctl(v4lfd, DMX_EXPBUF, &expbuf) == -1) {7272+ perror("DMX_EXPBUF");7373+ return -1;7474+ }7575+7676+ *dmafd = expbuf.fd;7777+7878+ return 0;7979+ }8080+8181+Return Value8282+============8383+8484+On success 0 is returned, on error -1 and the ``errno`` variable is set8585+appropriately. The generic error codes are described at the8686+:ref:`Generic Error Codes <gen-errors>` chapter.8787+8888+EINVAL8989+ A queue is not in MMAP mode or DMABUF exporting is not supported or9090+ ``flags`` or ``index`` fields are invalid.
+85
Documentation/media/uapi/dvb/dmx-qbuf.rst
···11+.. _DMX_QBUF:22+33+*************************44+ioctl DMX_QBUF, DMX_DQBUF55+*************************66+77+Name88+====99+1010+DMX_QBUF - DMX_DQBUF - Exchange a buffer with the driver1111+1212+.. warning:: this API is still experimental1313+1414+1515+Synopsis1616+========1717+1818+.. c:function:: int ioctl( int fd, DMX_QBUF, struct dmx_buffer *argp )1919+ :name: DMX_QBUF2020+2121+.. c:function:: int ioctl( int fd, DMX_DQBUF, struct dmx_buffer *argp )2222+ :name: DMX_DQBUF2323+2424+2525+Arguments2626+=========2727+2828+``fd``2929+ File descriptor returned by :ref:`open() <dmx_fopen>`.3030+3131+``argp``3232+ Pointer to struct :c:type:`dmx_buffer`.3333+3434+3535+Description3636+===========3737+3838+Applications call the ``DMX_QBUF`` ioctl to enqueue an empty3939+(capturing) or filled (output) buffer in the driver's incoming queue.4040+The semantics depend on the selected I/O method.4141+4242+To enqueue a buffer applications set the ``index`` field. Valid index4343+numbers range from zero to the number of buffers allocated with4444+:ref:`DMX_REQBUFS` (struct :c:type:`dmx_requestbuffers` ``count``) minus4545+one. The contents of the struct :c:type:`dmx_buffer` returned4646+by a :ref:`DMX_QUERYBUF` ioctl will do as well.4747+4848+The and ``reserved`` field must be set to 0.4949+5050+When ``DMX_QBUF`` is called with a pointer to this structure, it locks the5151+memory pages of the buffer in physical memory, so they cannot be swapped5252+out to disk. Buffers remain locked until dequeued, until the5353+the device is closed.5454+5555+Applications call the ``DMX_DQBUF`` ioctl to dequeue a filled5656+(capturing) buffer from the driver's outgoing queue. They just set the ``reserved`` field array to zero. When ``DMX_DQBUF`` is called with a5757+pointer to this structure, the driver fills the remaining fields or5858+returns an error code.5959+6060+By default ``DMX_DQBUF`` blocks when no buffer is in the outgoing6161+queue. When the ``O_NONBLOCK`` flag was given to the6262+:ref:`open() <dmx_fopen>` function, ``DMX_DQBUF`` returns6363+immediately with an ``EAGAIN`` error code when no buffer is available.6464+6565+The struct :c:type:`dmx_buffer` structure is specified in6666+:ref:`buffer`.6767+6868+6969+Return Value7070+============7171+7272+On success 0 is returned, on error -1 and the ``errno`` variable is set7373+appropriately. The generic error codes are described at the7474+:ref:`Generic Error Codes <gen-errors>` chapter.7575+7676+EAGAIN7777+ Non-blocking I/O has been selected using ``O_NONBLOCK`` and no7878+ buffer was in the outgoing queue.7979+8080+EINVAL8181+ The ``index`` is out of bounds, or no buffers have been allocated yet.8282+8383+EIO8484+ ``DMX_DQBUF`` failed due to an internal error. Can also indicate8585+ temporary problems like signal loss or CRC errors.
+65
Documentation/media/uapi/dvb/dmx-querybuf.rst
···11+.. _DMX_QUERYBUF:22+33+******************44+ioctl DMX_QUERYBUF55+******************66+77+Name88+====99+1010+DMX_QUERYBUF - Query the status of a buffer1111+1212+.. warning:: this API is still experimental1313+1414+1515+Synopsis1616+========1717+1818+.. c:function:: int ioctl( int fd, DMX_QUERYBUF, struct dvb_buffer *argp )1919+ :name: DMX_QUERYBUF2020+2121+2222+Arguments2323+=========2424+2525+``fd``2626+ File descriptor returned by :ref:`open() <dmx_fopen>`.2727+2828+``argp``2929+ Pointer to struct :c:type:`dvb_buffer`.3030+3131+3232+Description3333+===========3434+3535+This ioctl is part of the mmap streaming I/O method. It can3636+be used to query the status of a buffer at any time after buffers have3737+been allocated with the :ref:`DMX_REQBUFS` ioctl.3838+3939+The ``reserved`` array must be zeroed before calling it.4040+4141+Applications set the ``index`` field. Valid index numbers range from zero4242+to the number of buffers allocated with :ref:`DMX_REQBUFS`4343+(struct :c:type:`dvb_requestbuffers` ``count``) minus one.4444+4545+After calling :ref:`DMX_QUERYBUF` with a pointer to this structure,4646+drivers return an error code or fill the rest of the structure.4747+4848+On success, the ``offset`` will contain the offset of the buffer from the4949+start of the device memory, the ``length`` field its size, and the5050+``bytesused`` the number of bytes occupied by data in the buffer (payload).5151+5252+Return Value5353+============5454+5555+On success 0 is returned, the ``offset`` will contain the offset of the5656+buffer from the start of the device memory, the ``length`` field its size,5757+and the ``bytesused`` the number of bytes occupied by data in the buffer5858+(payload).5959+6060+On error it returns -1 and the ``errno`` variable is set6161+appropriately. The generic error codes are described at the6262+:ref:`Generic Error Codes <gen-errors>` chapter.6363+6464+EINVAL6565+ The ``index`` is out of bounds.
+76
Documentation/media/uapi/dvb/dmx-reqbufs.rst
···11+.. _DMX_REQBUFS:22+33+*****************44+ioctl DMX_REQBUFS55+*****************66+77+Name88+====99+1010+DMX_REQBUFS - Initiate Memory Mapping and/or DMA buffer I/O1111+1212+.. warning:: this API is still experimental1313+1414+1515+Synopsis1616+========1717+1818+.. c:function:: int ioctl( int fd, DMX_REQBUFS, struct dmx_requestbuffers *argp )1919+ :name: DMX_REQBUFS2020+2121+2222+Arguments2323+=========2424+2525+``fd``2626+ File descriptor returned by :ref:`open() <dmx_fopen>`.2727+2828+``argp``2929+ Pointer to struct :c:type:`dmx_requestbuffers`.3030+3131+Description3232+===========3333+3434+This ioctl is used to initiate a memory mapped or DMABUF based demux I/O.3535+3636+Memory mapped buffers are located in device memory and must be allocated3737+with this ioctl before they can be mapped into the application's address3838+space. User buffers are allocated by applications themselves, and this3939+ioctl is merely used to switch the driver into user pointer I/O mode and4040+to setup some internal structures. Similarly, DMABUF buffers are4141+allocated by applications through a device driver, and this ioctl only4242+configures the driver into DMABUF I/O mode without performing any direct4343+allocation.4444+4545+The ``reserved`` array must be zeroed before calling it.4646+4747+To allocate device buffers applications initialize all fields of the4848+struct :c:type:`dmx_requestbuffers` structure. They set the ``count`` field4949+to the desired number of buffers, and ``size`` to the size of each5050+buffer.5151+5252+When the ioctl is called with a pointer to this structure, the driver will5353+attempt to allocate the requested number of buffers and it stores the actual5454+number allocated in the ``count`` field. The ``count`` can be smaller than the number requested, even zero, when the driver runs out of free memory. A larger5555+number is also possible when the driver requires more buffers to5656+function correctly. The actual allocated buffer size can is returned5757+at ``size``, and can be smaller than what's requested.5858+5959+When this I/O method is not supported, the ioctl returns an ``EOPNOTSUPP``6060+error code.6161+6262+Applications can call :ref:`DMX_REQBUFS` again to change the number of6363+buffers, however this cannot succeed when any buffers are still mapped.6464+A ``count`` value of zero frees all buffers, after aborting or finishing6565+any DMA in progress.6666+6767+6868+Return Value6969+============7070+7171+On success 0 is returned, on error -1 and the ``errno`` variable is set7272+appropriately. The generic error codes are described at the7373+:ref:`Generic Error Codes <gen-errors>` chapter.7474+7575+EOPNOTSUPP7676+ The the requested I/O method is not supported.