xref: /linux/Documentation/userspace-api/media/dvb/dmx-reqbufs.rst (revision cbecf716ca618fd44feda6bd9a64a8179d031fc5)
1059b1c5bSMauro Carvalho Chehab.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2*f9b2e8aaSMauro Carvalho Chehab.. c:namespace:: DTV.dmx
354f38fcaSMauro Carvalho Chehab
454f38fcaSMauro Carvalho Chehab.. _DMX_REQBUFS:
554f38fcaSMauro Carvalho Chehab
654f38fcaSMauro Carvalho Chehab*****************
754f38fcaSMauro Carvalho Chehabioctl DMX_REQBUFS
854f38fcaSMauro Carvalho Chehab*****************
954f38fcaSMauro Carvalho Chehab
1054f38fcaSMauro Carvalho ChehabName
1154f38fcaSMauro Carvalho Chehab====
1254f38fcaSMauro Carvalho Chehab
1354f38fcaSMauro Carvalho ChehabDMX_REQBUFS - Initiate Memory Mapping and/or DMA buffer I/O
1454f38fcaSMauro Carvalho Chehab
1554f38fcaSMauro Carvalho Chehab.. warning:: this API is still experimental
1654f38fcaSMauro Carvalho Chehab
1754f38fcaSMauro Carvalho ChehabSynopsis
1854f38fcaSMauro Carvalho Chehab========
1954f38fcaSMauro Carvalho Chehab
20*f9b2e8aaSMauro Carvalho Chehab.. c:macro:: DMX_REQBUFS
2154f38fcaSMauro Carvalho Chehab
22*f9b2e8aaSMauro Carvalho Chehab``int ioctl(int fd, DMX_REQBUFS, struct dmx_requestbuffers *argp)``
2354f38fcaSMauro Carvalho Chehab
2454f38fcaSMauro Carvalho ChehabArguments
2554f38fcaSMauro Carvalho Chehab=========
2654f38fcaSMauro Carvalho Chehab
2754f38fcaSMauro Carvalho Chehab``fd``
28*f9b2e8aaSMauro Carvalho Chehab    File descriptor returned by :c:func:`open()`.
2954f38fcaSMauro Carvalho Chehab
3054f38fcaSMauro Carvalho Chehab``argp``
3154f38fcaSMauro Carvalho Chehab    Pointer to struct :c:type:`dmx_requestbuffers`.
3254f38fcaSMauro Carvalho Chehab
3354f38fcaSMauro Carvalho ChehabDescription
3454f38fcaSMauro Carvalho Chehab===========
3554f38fcaSMauro Carvalho Chehab
3654f38fcaSMauro Carvalho ChehabThis ioctl is used to initiate a memory mapped or DMABUF based demux I/O.
3754f38fcaSMauro Carvalho Chehab
3854f38fcaSMauro Carvalho ChehabMemory mapped buffers are located in device memory and must be allocated
3954f38fcaSMauro Carvalho Chehabwith this ioctl before they can be mapped into the application's address
4054f38fcaSMauro Carvalho Chehabspace. User buffers are allocated by applications themselves, and this
4154f38fcaSMauro Carvalho Chehabioctl is merely used to switch the driver into user pointer I/O mode and
4254f38fcaSMauro Carvalho Chehabto setup some internal structures. Similarly, DMABUF buffers are
4354f38fcaSMauro Carvalho Chehaballocated by applications through a device driver, and this ioctl only
4454f38fcaSMauro Carvalho Chehabconfigures the driver into DMABUF I/O mode without performing any direct
4554f38fcaSMauro Carvalho Chehaballocation.
4654f38fcaSMauro Carvalho Chehab
4754f38fcaSMauro Carvalho ChehabTo allocate device buffers applications initialize all fields of the
4854f38fcaSMauro Carvalho Chehabstruct :c:type:`dmx_requestbuffers` structure. They set the  ``count`` field
4954f38fcaSMauro Carvalho Chehabto the desired number of buffers,  and ``size`` to the size of each
5054f38fcaSMauro Carvalho Chehabbuffer.
5154f38fcaSMauro Carvalho Chehab
5254f38fcaSMauro Carvalho ChehabWhen the ioctl is called with a pointer to this structure, the driver will
5354f38fcaSMauro Carvalho Chehabattempt to allocate the requested number of buffers and it stores the actual
5454f38fcaSMauro Carvalho Chehabnumber 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 larger
5554f38fcaSMauro Carvalho Chehabnumber is also possible when the driver requires more buffers to
5654f38fcaSMauro Carvalho Chehabfunction correctly. The actual allocated buffer size can is returned
5754f38fcaSMauro Carvalho Chehabat ``size``, and can be smaller than what's requested.
5854f38fcaSMauro Carvalho Chehab
5954f38fcaSMauro Carvalho ChehabWhen this I/O method is not supported, the ioctl returns an ``EOPNOTSUPP``
6054f38fcaSMauro Carvalho Chehaberror code.
6154f38fcaSMauro Carvalho Chehab
6254f38fcaSMauro Carvalho ChehabApplications can call :ref:`DMX_REQBUFS` again to change the number of
6354f38fcaSMauro Carvalho Chehabbuffers, however this cannot succeed when any buffers are still mapped.
6454f38fcaSMauro Carvalho ChehabA ``count`` value of zero frees all buffers, after aborting or finishing
6554f38fcaSMauro Carvalho Chehabany DMA in progress.
6654f38fcaSMauro Carvalho Chehab
6754f38fcaSMauro Carvalho ChehabReturn Value
6854f38fcaSMauro Carvalho Chehab============
6954f38fcaSMauro Carvalho Chehab
7054f38fcaSMauro Carvalho ChehabOn success 0 is returned, on error -1 and the ``errno`` variable is set
7154f38fcaSMauro Carvalho Chehabappropriately. The generic error codes are described at the
7254f38fcaSMauro Carvalho Chehab:ref:`Generic Error Codes <gen-errors>` chapter.
7354f38fcaSMauro Carvalho Chehab
7454f38fcaSMauro Carvalho ChehabEOPNOTSUPP
7554f38fcaSMauro Carvalho Chehab    The  the requested I/O method is not supported.
76