xref: /OK3568_Linux_fs/kernel/Documentation/userspace-api/media/dvb/dmx-reqbufs.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2*4882a593Smuzhiyun.. c:namespace:: DTV.dmx
3*4882a593Smuzhiyun
4*4882a593Smuzhiyun.. _DMX_REQBUFS:
5*4882a593Smuzhiyun
6*4882a593Smuzhiyun*****************
7*4882a593Smuzhiyunioctl DMX_REQBUFS
8*4882a593Smuzhiyun*****************
9*4882a593Smuzhiyun
10*4882a593SmuzhiyunName
11*4882a593Smuzhiyun====
12*4882a593Smuzhiyun
13*4882a593SmuzhiyunDMX_REQBUFS - Initiate Memory Mapping and/or DMA buffer I/O
14*4882a593Smuzhiyun
15*4882a593Smuzhiyun.. warning:: this API is still experimental
16*4882a593Smuzhiyun
17*4882a593SmuzhiyunSynopsis
18*4882a593Smuzhiyun========
19*4882a593Smuzhiyun
20*4882a593Smuzhiyun.. c:macro:: DMX_REQBUFS
21*4882a593Smuzhiyun
22*4882a593Smuzhiyun``int ioctl(int fd, DMX_REQBUFS, struct dmx_requestbuffers *argp)``
23*4882a593Smuzhiyun
24*4882a593SmuzhiyunArguments
25*4882a593Smuzhiyun=========
26*4882a593Smuzhiyun
27*4882a593Smuzhiyun``fd``
28*4882a593Smuzhiyun    File descriptor returned by :c:func:`open()`.
29*4882a593Smuzhiyun
30*4882a593Smuzhiyun``argp``
31*4882a593Smuzhiyun    Pointer to struct :c:type:`dmx_requestbuffers`.
32*4882a593Smuzhiyun
33*4882a593SmuzhiyunDescription
34*4882a593Smuzhiyun===========
35*4882a593Smuzhiyun
36*4882a593SmuzhiyunThis ioctl is used to initiate a memory mapped or DMABUF based demux I/O.
37*4882a593Smuzhiyun
38*4882a593SmuzhiyunMemory mapped buffers are located in device memory and must be allocated
39*4882a593Smuzhiyunwith this ioctl before they can be mapped into the application's address
40*4882a593Smuzhiyunspace. User buffers are allocated by applications themselves, and this
41*4882a593Smuzhiyunioctl is merely used to switch the driver into user pointer I/O mode and
42*4882a593Smuzhiyunto setup some internal structures. Similarly, DMABUF buffers are
43*4882a593Smuzhiyunallocated by applications through a device driver, and this ioctl only
44*4882a593Smuzhiyunconfigures the driver into DMABUF I/O mode without performing any direct
45*4882a593Smuzhiyunallocation.
46*4882a593Smuzhiyun
47*4882a593SmuzhiyunTo allocate device buffers applications initialize all fields of the
48*4882a593Smuzhiyunstruct :c:type:`dmx_requestbuffers` structure. They set the  ``count`` field
49*4882a593Smuzhiyunto the desired number of buffers,  and ``size`` to the size of each
50*4882a593Smuzhiyunbuffer.
51*4882a593Smuzhiyun
52*4882a593SmuzhiyunWhen the ioctl is called with a pointer to this structure, the driver will
53*4882a593Smuzhiyunattempt to allocate the requested number of buffers and it stores the actual
54*4882a593Smuzhiyunnumber 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
55*4882a593Smuzhiyunnumber is also possible when the driver requires more buffers to
56*4882a593Smuzhiyunfunction correctly. The actual allocated buffer size can is returned
57*4882a593Smuzhiyunat ``size``, and can be smaller than what's requested.
58*4882a593Smuzhiyun
59*4882a593SmuzhiyunWhen this I/O method is not supported, the ioctl returns an ``EOPNOTSUPP``
60*4882a593Smuzhiyunerror code.
61*4882a593Smuzhiyun
62*4882a593SmuzhiyunApplications can call :ref:`DMX_REQBUFS` again to change the number of
63*4882a593Smuzhiyunbuffers, however this cannot succeed when any buffers are still mapped.
64*4882a593SmuzhiyunA ``count`` value of zero frees all buffers, after aborting or finishing
65*4882a593Smuzhiyunany DMA in progress.
66*4882a593Smuzhiyun
67*4882a593SmuzhiyunReturn Value
68*4882a593Smuzhiyun============
69*4882a593Smuzhiyun
70*4882a593SmuzhiyunOn success 0 is returned, on error -1 and the ``errno`` variable is set
71*4882a593Smuzhiyunappropriately. The generic error codes are described at the
72*4882a593Smuzhiyun:ref:`Generic Error Codes <gen-errors>` chapter.
73*4882a593Smuzhiyun
74*4882a593SmuzhiyunEOPNOTSUPP
75*4882a593Smuzhiyun    The  the requested I/O method is not supported.
76