xref: /openbmc/linux/Documentation/userspace-api/media/dvb/dmx-querybuf.rst (revision 059b1c5b15579b09c3787c3a3f843574233ab976)
1*059b1c5bSMauro Carvalho Chehab.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
254f38fcaSMauro Carvalho Chehab
354f38fcaSMauro Carvalho Chehab.. _DMX_QUERYBUF:
454f38fcaSMauro Carvalho Chehab
554f38fcaSMauro Carvalho Chehab******************
654f38fcaSMauro Carvalho Chehabioctl DMX_QUERYBUF
754f38fcaSMauro Carvalho Chehab******************
854f38fcaSMauro Carvalho Chehab
954f38fcaSMauro Carvalho ChehabName
1054f38fcaSMauro Carvalho Chehab====
1154f38fcaSMauro Carvalho Chehab
1254f38fcaSMauro Carvalho ChehabDMX_QUERYBUF - Query the status of a buffer
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_QUERYBUF, struct dvb_buffer *argp )
2154f38fcaSMauro Carvalho Chehab    :name: DMX_QUERYBUF
2254f38fcaSMauro Carvalho Chehab
2354f38fcaSMauro Carvalho Chehab
2454f38fcaSMauro Carvalho ChehabArguments
2554f38fcaSMauro Carvalho Chehab=========
2654f38fcaSMauro Carvalho Chehab
2754f38fcaSMauro Carvalho Chehab``fd``
2854f38fcaSMauro Carvalho Chehab    File descriptor returned by :ref:`open() <dmx_fopen>`.
2954f38fcaSMauro Carvalho Chehab
3054f38fcaSMauro Carvalho Chehab``argp``
3154f38fcaSMauro Carvalho Chehab    Pointer to struct :c:type:`dvb_buffer`.
3254f38fcaSMauro Carvalho Chehab
3354f38fcaSMauro Carvalho Chehab
3454f38fcaSMauro Carvalho ChehabDescription
3554f38fcaSMauro Carvalho Chehab===========
3654f38fcaSMauro Carvalho Chehab
3754f38fcaSMauro Carvalho ChehabThis ioctl is part of the mmap streaming I/O method. It can
3854f38fcaSMauro Carvalho Chehabbe used to query the status of a buffer at any time after buffers have
3954f38fcaSMauro Carvalho Chehabbeen allocated with the :ref:`DMX_REQBUFS` ioctl.
4054f38fcaSMauro Carvalho Chehab
4154f38fcaSMauro Carvalho ChehabApplications set the ``index`` field. Valid index numbers range from zero
4254f38fcaSMauro Carvalho Chehabto the number of buffers allocated with :ref:`DMX_REQBUFS`
4354f38fcaSMauro Carvalho Chehab(struct :c:type:`dvb_requestbuffers` ``count``) minus one.
4454f38fcaSMauro Carvalho Chehab
4554f38fcaSMauro Carvalho ChehabAfter calling :ref:`DMX_QUERYBUF` with a pointer to this structure,
4654f38fcaSMauro Carvalho Chehabdrivers return an error code or fill the rest of the structure.
4754f38fcaSMauro Carvalho Chehab
4854f38fcaSMauro Carvalho ChehabOn success, the ``offset`` will contain the offset of the buffer from the
4954f38fcaSMauro Carvalho Chehabstart of the device memory, the ``length`` field its size, and the
5054f38fcaSMauro Carvalho Chehab``bytesused`` the number of bytes occupied by data in the buffer (payload).
5154f38fcaSMauro Carvalho Chehab
5254f38fcaSMauro Carvalho ChehabReturn Value
5354f38fcaSMauro Carvalho Chehab============
5454f38fcaSMauro Carvalho Chehab
5554f38fcaSMauro Carvalho ChehabOn success 0 is returned, the ``offset`` will contain the offset of the
5654f38fcaSMauro Carvalho Chehabbuffer from the start of the device memory, the ``length`` field its size,
5754f38fcaSMauro Carvalho Chehaband the ``bytesused`` the number of bytes occupied by data in the buffer
5854f38fcaSMauro Carvalho Chehab(payload).
5954f38fcaSMauro Carvalho Chehab
6054f38fcaSMauro Carvalho ChehabOn error it returns -1 and the ``errno`` variable is set
6154f38fcaSMauro Carvalho Chehabappropriately. The generic error codes are described at the
6254f38fcaSMauro Carvalho Chehab:ref:`Generic Error Codes <gen-errors>` chapter.
6354f38fcaSMauro Carvalho Chehab
6454f38fcaSMauro Carvalho ChehabEINVAL
6554f38fcaSMauro Carvalho Chehab    The ``index`` is out of bounds.
66