xref: /openbmc/linux/Documentation/userspace-api/media/dvb/dmx-qbuf.rst (revision 54f38fcae536ea202ce7d6a359521492fba30c1f)
1*54f38fcaSMauro Carvalho Chehab.. Permission is granted to copy, distribute and/or modify this
2*54f38fcaSMauro Carvalho Chehab.. document under the terms of the GNU Free Documentation License,
3*54f38fcaSMauro Carvalho Chehab.. Version 1.1 or any later version published by the Free Software
4*54f38fcaSMauro Carvalho Chehab.. Foundation, with no Invariant Sections, no Front-Cover Texts
5*54f38fcaSMauro Carvalho Chehab.. and no Back-Cover Texts. A copy of the license is included at
6*54f38fcaSMauro Carvalho Chehab.. Documentation/userspace-api/media/fdl-appendix.rst.
7*54f38fcaSMauro Carvalho Chehab..
8*54f38fcaSMauro Carvalho Chehab.. TODO: replace it to GFDL-1.1-or-later WITH no-invariant-sections
9*54f38fcaSMauro Carvalho Chehab
10*54f38fcaSMauro Carvalho Chehab.. _DMX_QBUF:
11*54f38fcaSMauro Carvalho Chehab
12*54f38fcaSMauro Carvalho Chehab*************************
13*54f38fcaSMauro Carvalho Chehabioctl DMX_QBUF, DMX_DQBUF
14*54f38fcaSMauro Carvalho Chehab*************************
15*54f38fcaSMauro Carvalho Chehab
16*54f38fcaSMauro Carvalho ChehabName
17*54f38fcaSMauro Carvalho Chehab====
18*54f38fcaSMauro Carvalho Chehab
19*54f38fcaSMauro Carvalho ChehabDMX_QBUF - DMX_DQBUF - Exchange a buffer with the driver
20*54f38fcaSMauro Carvalho Chehab
21*54f38fcaSMauro Carvalho Chehab.. warning:: this API is still experimental
22*54f38fcaSMauro Carvalho Chehab
23*54f38fcaSMauro Carvalho Chehab
24*54f38fcaSMauro Carvalho ChehabSynopsis
25*54f38fcaSMauro Carvalho Chehab========
26*54f38fcaSMauro Carvalho Chehab
27*54f38fcaSMauro Carvalho Chehab.. c:function:: int ioctl( int fd, DMX_QBUF, struct dmx_buffer *argp )
28*54f38fcaSMauro Carvalho Chehab    :name: DMX_QBUF
29*54f38fcaSMauro Carvalho Chehab
30*54f38fcaSMauro Carvalho Chehab.. c:function:: int ioctl( int fd, DMX_DQBUF, struct dmx_buffer *argp )
31*54f38fcaSMauro Carvalho Chehab    :name: DMX_DQBUF
32*54f38fcaSMauro Carvalho Chehab
33*54f38fcaSMauro Carvalho Chehab
34*54f38fcaSMauro Carvalho ChehabArguments
35*54f38fcaSMauro Carvalho Chehab=========
36*54f38fcaSMauro Carvalho Chehab
37*54f38fcaSMauro Carvalho Chehab``fd``
38*54f38fcaSMauro Carvalho Chehab    File descriptor returned by :ref:`open() <dmx_fopen>`.
39*54f38fcaSMauro Carvalho Chehab
40*54f38fcaSMauro Carvalho Chehab``argp``
41*54f38fcaSMauro Carvalho Chehab    Pointer to struct :c:type:`dmx_buffer`.
42*54f38fcaSMauro Carvalho Chehab
43*54f38fcaSMauro Carvalho Chehab
44*54f38fcaSMauro Carvalho ChehabDescription
45*54f38fcaSMauro Carvalho Chehab===========
46*54f38fcaSMauro Carvalho Chehab
47*54f38fcaSMauro Carvalho ChehabApplications call the ``DMX_QBUF`` ioctl to enqueue an empty
48*54f38fcaSMauro Carvalho Chehab(capturing) or filled (output) buffer in the driver's incoming queue.
49*54f38fcaSMauro Carvalho ChehabThe semantics depend on the selected I/O method.
50*54f38fcaSMauro Carvalho Chehab
51*54f38fcaSMauro Carvalho ChehabTo enqueue a buffer applications set the ``index`` field. Valid index
52*54f38fcaSMauro Carvalho Chehabnumbers range from zero to the number of buffers allocated with
53*54f38fcaSMauro Carvalho Chehab:ref:`DMX_REQBUFS` (struct :c:type:`dmx_requestbuffers` ``count``) minus
54*54f38fcaSMauro Carvalho Chehabone. The contents of the struct :c:type:`dmx_buffer` returned
55*54f38fcaSMauro Carvalho Chehabby a :ref:`DMX_QUERYBUF` ioctl will do as well.
56*54f38fcaSMauro Carvalho Chehab
57*54f38fcaSMauro Carvalho ChehabWhen ``DMX_QBUF`` is called with a pointer to this structure, it locks the
58*54f38fcaSMauro Carvalho Chehabmemory pages of the buffer in physical memory, so they cannot be swapped
59*54f38fcaSMauro Carvalho Chehabout to disk. Buffers remain locked until dequeued, until the
60*54f38fcaSMauro Carvalho Chehabthe device is closed.
61*54f38fcaSMauro Carvalho Chehab
62*54f38fcaSMauro Carvalho ChehabApplications call the ``DMX_DQBUF`` ioctl to dequeue a filled
63*54f38fcaSMauro Carvalho Chehab(capturing) buffer from the driver's outgoing queue.
64*54f38fcaSMauro Carvalho ChehabThey just set the ``index`` field with the buffer ID to be queued.
65*54f38fcaSMauro Carvalho ChehabWhen ``DMX_DQBUF`` is called with a pointer to struct :c:type:`dmx_buffer`,
66*54f38fcaSMauro Carvalho Chehabthe driver fills the remaining fields or returns an error code.
67*54f38fcaSMauro Carvalho Chehab
68*54f38fcaSMauro Carvalho ChehabBy default ``DMX_DQBUF`` blocks when no buffer is in the outgoing
69*54f38fcaSMauro Carvalho Chehabqueue. When the ``O_NONBLOCK`` flag was given to the
70*54f38fcaSMauro Carvalho Chehab:ref:`open() <dmx_fopen>` function, ``DMX_DQBUF`` returns
71*54f38fcaSMauro Carvalho Chehabimmediately with an ``EAGAIN`` error code when no buffer is available.
72*54f38fcaSMauro Carvalho Chehab
73*54f38fcaSMauro Carvalho ChehabThe struct :c:type:`dmx_buffer` structure is specified in
74*54f38fcaSMauro Carvalho Chehab:ref:`buffer`.
75*54f38fcaSMauro Carvalho Chehab
76*54f38fcaSMauro Carvalho Chehab
77*54f38fcaSMauro Carvalho ChehabReturn Value
78*54f38fcaSMauro Carvalho Chehab============
79*54f38fcaSMauro Carvalho Chehab
80*54f38fcaSMauro Carvalho ChehabOn success 0 is returned, on error -1 and the ``errno`` variable is set
81*54f38fcaSMauro Carvalho Chehabappropriately. The generic error codes are described at the
82*54f38fcaSMauro Carvalho Chehab:ref:`Generic Error Codes <gen-errors>` chapter.
83*54f38fcaSMauro Carvalho Chehab
84*54f38fcaSMauro Carvalho ChehabEAGAIN
85*54f38fcaSMauro Carvalho Chehab    Non-blocking I/O has been selected using ``O_NONBLOCK`` and no
86*54f38fcaSMauro Carvalho Chehab    buffer was in the outgoing queue.
87*54f38fcaSMauro Carvalho Chehab
88*54f38fcaSMauro Carvalho ChehabEINVAL
89*54f38fcaSMauro Carvalho Chehab    The ``index`` is out of bounds, or no buffers have been allocated yet.
90*54f38fcaSMauro Carvalho Chehab
91*54f38fcaSMauro Carvalho ChehabEIO
92*54f38fcaSMauro Carvalho Chehab    ``DMX_DQBUF`` failed due to an internal error. Can also indicate
93*54f38fcaSMauro Carvalho Chehab    temporary problems like signal loss or CRC errors.
94