1*059b1c5bSMauro Carvalho Chehab.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later 254f38fcaSMauro Carvalho Chehab 354f38fcaSMauro Carvalho Chehab.. _DMX_QBUF: 454f38fcaSMauro Carvalho Chehab 554f38fcaSMauro Carvalho Chehab************************* 654f38fcaSMauro Carvalho Chehabioctl DMX_QBUF, DMX_DQBUF 754f38fcaSMauro Carvalho Chehab************************* 854f38fcaSMauro Carvalho Chehab 954f38fcaSMauro Carvalho ChehabName 1054f38fcaSMauro Carvalho Chehab==== 1154f38fcaSMauro Carvalho Chehab 1254f38fcaSMauro Carvalho ChehabDMX_QBUF - DMX_DQBUF - Exchange a buffer with the driver 1354f38fcaSMauro Carvalho Chehab 1454f38fcaSMauro Carvalho Chehab.. warning:: this API is still experimental 1554f38fcaSMauro Carvalho Chehab 1654f38fcaSMauro Carvalho Chehab 1754f38fcaSMauro Carvalho ChehabSynopsis 1854f38fcaSMauro Carvalho Chehab======== 1954f38fcaSMauro Carvalho Chehab 2054f38fcaSMauro Carvalho Chehab.. c:function:: int ioctl( int fd, DMX_QBUF, struct dmx_buffer *argp ) 2154f38fcaSMauro Carvalho Chehab :name: DMX_QBUF 2254f38fcaSMauro Carvalho Chehab 2354f38fcaSMauro Carvalho Chehab.. c:function:: int ioctl( int fd, DMX_DQBUF, struct dmx_buffer *argp ) 2454f38fcaSMauro Carvalho Chehab :name: DMX_DQBUF 2554f38fcaSMauro Carvalho Chehab 2654f38fcaSMauro Carvalho Chehab 2754f38fcaSMauro Carvalho ChehabArguments 2854f38fcaSMauro Carvalho Chehab========= 2954f38fcaSMauro Carvalho Chehab 3054f38fcaSMauro Carvalho Chehab``fd`` 3154f38fcaSMauro Carvalho Chehab File descriptor returned by :ref:`open() <dmx_fopen>`. 3254f38fcaSMauro Carvalho Chehab 3354f38fcaSMauro Carvalho Chehab``argp`` 3454f38fcaSMauro Carvalho Chehab Pointer to struct :c:type:`dmx_buffer`. 3554f38fcaSMauro Carvalho Chehab 3654f38fcaSMauro Carvalho Chehab 3754f38fcaSMauro Carvalho ChehabDescription 3854f38fcaSMauro Carvalho Chehab=========== 3954f38fcaSMauro Carvalho Chehab 4054f38fcaSMauro Carvalho ChehabApplications call the ``DMX_QBUF`` ioctl to enqueue an empty 4154f38fcaSMauro Carvalho Chehab(capturing) or filled (output) buffer in the driver's incoming queue. 4254f38fcaSMauro Carvalho ChehabThe semantics depend on the selected I/O method. 4354f38fcaSMauro Carvalho Chehab 4454f38fcaSMauro Carvalho ChehabTo enqueue a buffer applications set the ``index`` field. Valid index 4554f38fcaSMauro Carvalho Chehabnumbers range from zero to the number of buffers allocated with 4654f38fcaSMauro Carvalho Chehab:ref:`DMX_REQBUFS` (struct :c:type:`dmx_requestbuffers` ``count``) minus 4754f38fcaSMauro Carvalho Chehabone. The contents of the struct :c:type:`dmx_buffer` returned 4854f38fcaSMauro Carvalho Chehabby a :ref:`DMX_QUERYBUF` ioctl will do as well. 4954f38fcaSMauro Carvalho Chehab 5054f38fcaSMauro Carvalho ChehabWhen ``DMX_QBUF`` is called with a pointer to this structure, it locks the 5154f38fcaSMauro Carvalho Chehabmemory pages of the buffer in physical memory, so they cannot be swapped 5254f38fcaSMauro Carvalho Chehabout to disk. Buffers remain locked until dequeued, until the 5354f38fcaSMauro Carvalho Chehabthe device is closed. 5454f38fcaSMauro Carvalho Chehab 5554f38fcaSMauro Carvalho ChehabApplications call the ``DMX_DQBUF`` ioctl to dequeue a filled 5654f38fcaSMauro Carvalho Chehab(capturing) buffer from the driver's outgoing queue. 5754f38fcaSMauro Carvalho ChehabThey just set the ``index`` field with the buffer ID to be queued. 5854f38fcaSMauro Carvalho ChehabWhen ``DMX_DQBUF`` is called with a pointer to struct :c:type:`dmx_buffer`, 5954f38fcaSMauro Carvalho Chehabthe driver fills the remaining fields or returns an error code. 6054f38fcaSMauro Carvalho Chehab 6154f38fcaSMauro Carvalho ChehabBy default ``DMX_DQBUF`` blocks when no buffer is in the outgoing 6254f38fcaSMauro Carvalho Chehabqueue. When the ``O_NONBLOCK`` flag was given to the 6354f38fcaSMauro Carvalho Chehab:ref:`open() <dmx_fopen>` function, ``DMX_DQBUF`` returns 6454f38fcaSMauro Carvalho Chehabimmediately with an ``EAGAIN`` error code when no buffer is available. 6554f38fcaSMauro Carvalho Chehab 6654f38fcaSMauro Carvalho ChehabThe struct :c:type:`dmx_buffer` structure is specified in 6754f38fcaSMauro Carvalho Chehab:ref:`buffer`. 6854f38fcaSMauro Carvalho Chehab 6954f38fcaSMauro Carvalho Chehab 7054f38fcaSMauro Carvalho ChehabReturn Value 7154f38fcaSMauro Carvalho Chehab============ 7254f38fcaSMauro Carvalho Chehab 7354f38fcaSMauro Carvalho ChehabOn success 0 is returned, on error -1 and the ``errno`` variable is set 7454f38fcaSMauro Carvalho Chehabappropriately. The generic error codes are described at the 7554f38fcaSMauro Carvalho Chehab:ref:`Generic Error Codes <gen-errors>` chapter. 7654f38fcaSMauro Carvalho Chehab 7754f38fcaSMauro Carvalho ChehabEAGAIN 7854f38fcaSMauro Carvalho Chehab Non-blocking I/O has been selected using ``O_NONBLOCK`` and no 7954f38fcaSMauro Carvalho Chehab buffer was in the outgoing queue. 8054f38fcaSMauro Carvalho Chehab 8154f38fcaSMauro Carvalho ChehabEINVAL 8254f38fcaSMauro Carvalho Chehab The ``index`` is out of bounds, or no buffers have been allocated yet. 8354f38fcaSMauro Carvalho Chehab 8454f38fcaSMauro Carvalho ChehabEIO 8554f38fcaSMauro Carvalho Chehab ``DMX_DQBUF`` failed due to an internal error. Can also indicate 8654f38fcaSMauro Carvalho Chehab temporary problems like signal loss or CRC errors. 87