1059b1c5bSMauro Carvalho Chehab.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later 2f9b2e8aaSMauro Carvalho Chehab.. c:namespace:: DTV.dmx 354f38fcaSMauro Carvalho Chehab 454f38fcaSMauro Carvalho Chehab.. _DMX_QBUF: 554f38fcaSMauro Carvalho Chehab 654f38fcaSMauro Carvalho Chehab************************* 754f38fcaSMauro Carvalho Chehabioctl DMX_QBUF, DMX_DQBUF 854f38fcaSMauro Carvalho Chehab************************* 954f38fcaSMauro Carvalho Chehab 1054f38fcaSMauro Carvalho ChehabName 1154f38fcaSMauro Carvalho Chehab==== 1254f38fcaSMauro Carvalho Chehab 1354f38fcaSMauro Carvalho ChehabDMX_QBUF - DMX_DQBUF - Exchange a buffer with the driver 1454f38fcaSMauro Carvalho Chehab 1554f38fcaSMauro Carvalho Chehab.. warning:: this API is still experimental 1654f38fcaSMauro Carvalho Chehab 1754f38fcaSMauro Carvalho ChehabSynopsis 1854f38fcaSMauro Carvalho Chehab======== 1954f38fcaSMauro Carvalho Chehab 20f9b2e8aaSMauro Carvalho Chehab.. c:macro:: DMX_QBUF 2154f38fcaSMauro Carvalho Chehab 22f9b2e8aaSMauro Carvalho Chehab``int ioctl(int fd, DMX_QBUF, struct dmx_buffer *argp)`` 2354f38fcaSMauro Carvalho Chehab 24f9b2e8aaSMauro Carvalho Chehab.. c:macro:: DMX_DQBUF 25f9b2e8aaSMauro Carvalho Chehab 26f9b2e8aaSMauro Carvalho Chehab``int ioctl(int fd, DMX_DQBUF, struct dmx_buffer *argp)`` 2754f38fcaSMauro Carvalho Chehab 2854f38fcaSMauro Carvalho ChehabArguments 2954f38fcaSMauro Carvalho Chehab========= 3054f38fcaSMauro Carvalho Chehab 3154f38fcaSMauro Carvalho Chehab``fd`` 32f9b2e8aaSMauro Carvalho Chehab File descriptor returned by :c:func:`open()`. 3354f38fcaSMauro Carvalho Chehab 3454f38fcaSMauro Carvalho Chehab``argp`` 3554f38fcaSMauro Carvalho Chehab Pointer to struct :c:type:`dmx_buffer`. 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 53*08bbe2d8SRandy Dunlapdevice 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 63f9b2e8aaSMauro Carvalho Chehab:c:func:`open()` 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 ChehabReturn Value 7054f38fcaSMauro Carvalho Chehab============ 7154f38fcaSMauro Carvalho Chehab 7254f38fcaSMauro Carvalho ChehabOn success 0 is returned, on error -1 and the ``errno`` variable is set 7354f38fcaSMauro Carvalho Chehabappropriately. The generic error codes are described at the 7454f38fcaSMauro Carvalho Chehab:ref:`Generic Error Codes <gen-errors>` chapter. 7554f38fcaSMauro Carvalho Chehab 7654f38fcaSMauro Carvalho ChehabEAGAIN 7754f38fcaSMauro Carvalho Chehab Non-blocking I/O has been selected using ``O_NONBLOCK`` and no 7854f38fcaSMauro Carvalho Chehab buffer was in the outgoing queue. 7954f38fcaSMauro Carvalho Chehab 8054f38fcaSMauro Carvalho ChehabEINVAL 8154f38fcaSMauro Carvalho Chehab The ``index`` is out of bounds, or no buffers have been allocated yet. 8254f38fcaSMauro Carvalho Chehab 8354f38fcaSMauro Carvalho ChehabEIO 8454f38fcaSMauro Carvalho Chehab ``DMX_DQBUF`` failed due to an internal error. Can also indicate 8554f38fcaSMauro Carvalho Chehab temporary problems like signal loss or CRC errors. 86