18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later 28c2ecf20Sopenharmony_ci.. c:namespace:: DTV.dmx 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci.. _DMX_REQBUFS: 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci***************** 78c2ecf20Sopenharmony_ciioctl DMX_REQBUFS 88c2ecf20Sopenharmony_ci***************** 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ciName 118c2ecf20Sopenharmony_ci==== 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ciDMX_REQBUFS - Initiate Memory Mapping and/or DMA buffer I/O 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci.. warning:: this API is still experimental 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ciSynopsis 188c2ecf20Sopenharmony_ci======== 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci.. c:macro:: DMX_REQBUFS 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci``int ioctl(int fd, DMX_REQBUFS, struct dmx_requestbuffers *argp)`` 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ciArguments 258c2ecf20Sopenharmony_ci========= 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci``fd`` 288c2ecf20Sopenharmony_ci File descriptor returned by :c:func:`open()`. 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci``argp`` 318c2ecf20Sopenharmony_ci Pointer to struct :c:type:`dmx_requestbuffers`. 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ciDescription 348c2ecf20Sopenharmony_ci=========== 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ciThis ioctl is used to initiate a memory mapped or DMABUF based demux I/O. 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ciMemory mapped buffers are located in device memory and must be allocated 398c2ecf20Sopenharmony_ciwith this ioctl before they can be mapped into the application's address 408c2ecf20Sopenharmony_cispace. User buffers are allocated by applications themselves, and this 418c2ecf20Sopenharmony_ciioctl is merely used to switch the driver into user pointer I/O mode and 428c2ecf20Sopenharmony_cito setup some internal structures. Similarly, DMABUF buffers are 438c2ecf20Sopenharmony_ciallocated by applications through a device driver, and this ioctl only 448c2ecf20Sopenharmony_ciconfigures the driver into DMABUF I/O mode without performing any direct 458c2ecf20Sopenharmony_ciallocation. 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ciTo allocate device buffers applications initialize all fields of the 488c2ecf20Sopenharmony_cistruct :c:type:`dmx_requestbuffers` structure. They set the ``count`` field 498c2ecf20Sopenharmony_cito the desired number of buffers, and ``size`` to the size of each 508c2ecf20Sopenharmony_cibuffer. 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ciWhen the ioctl is called with a pointer to this structure, the driver will 538c2ecf20Sopenharmony_ciattempt to allocate the requested number of buffers and it stores the actual 548c2ecf20Sopenharmony_cinumber 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 558c2ecf20Sopenharmony_cinumber is also possible when the driver requires more buffers to 568c2ecf20Sopenharmony_cifunction correctly. The actual allocated buffer size can is returned 578c2ecf20Sopenharmony_ciat ``size``, and can be smaller than what's requested. 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ciWhen this I/O method is not supported, the ioctl returns an ``EOPNOTSUPP`` 608c2ecf20Sopenharmony_cierror code. 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ciApplications can call :ref:`DMX_REQBUFS` again to change the number of 638c2ecf20Sopenharmony_cibuffers, however this cannot succeed when any buffers are still mapped. 648c2ecf20Sopenharmony_ciA ``count`` value of zero frees all buffers, after aborting or finishing 658c2ecf20Sopenharmony_ciany DMA in progress. 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ciReturn Value 688c2ecf20Sopenharmony_ci============ 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ciOn success 0 is returned, on error -1 and the ``errno`` variable is set 718c2ecf20Sopenharmony_ciappropriately. The generic error codes are described at the 728c2ecf20Sopenharmony_ci:ref:`Generic Error Codes <gen-errors>` chapter. 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ciEOPNOTSUPP 758c2ecf20Sopenharmony_ci The the requested I/O method is not supported. 76