18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later 28c2ecf20Sopenharmony_ci.. c:namespace:: DTV.dmx 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci.. _DMX_EXPBUF: 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci**************** 78c2ecf20Sopenharmony_ciioctl DMX_EXPBUF 88c2ecf20Sopenharmony_ci**************** 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ciName 118c2ecf20Sopenharmony_ci==== 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ciDMX_EXPBUF - Export a buffer as a DMABUF file descriptor. 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci.. warning:: this API is still experimental 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ciSynopsis 188c2ecf20Sopenharmony_ci======== 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci.. c:macro:: DMX_EXPBUF 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci``int ioctl(int fd, DMX_EXPBUF, struct dmx_exportbuffer *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_exportbuffer`. 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ciDescription 348c2ecf20Sopenharmony_ci=========== 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ciThis ioctl is an extension to the memory mapping I/O method. 378c2ecf20Sopenharmony_ciIt can be used to export a buffer as a DMABUF file at any time after 388c2ecf20Sopenharmony_cibuffers have been allocated with the :ref:`DMX_REQBUFS` ioctl. 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ciTo export a buffer, applications fill struct :c:type:`dmx_exportbuffer`. 418c2ecf20Sopenharmony_ciApplications must set the ``index`` field. Valid index numbers 428c2ecf20Sopenharmony_cirange from zero to the number of buffers allocated with :ref:`DMX_REQBUFS` 438c2ecf20Sopenharmony_ci(struct :c:type:`dmx_requestbuffers` ``count``) minus one. 448c2ecf20Sopenharmony_ciAdditional flags may be posted in the ``flags`` field. Refer to a manual 458c2ecf20Sopenharmony_cifor open() for details. Currently only O_CLOEXEC, O_RDONLY, O_WRONLY, 468c2ecf20Sopenharmony_ciand O_RDWR are supported. 478c2ecf20Sopenharmony_ciAll other fields must be set to zero. In the 488c2ecf20Sopenharmony_cicase of multi-planar API, every plane is exported separately using 498c2ecf20Sopenharmony_cimultiple :ref:`DMX_EXPBUF` calls. 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ciAfter calling :ref:`DMX_EXPBUF` the ``fd`` field will be set by a 528c2ecf20Sopenharmony_cidriver, on success. This is a DMABUF file descriptor. The application may 538c2ecf20Sopenharmony_cipass it to other DMABUF-aware devices. It is recommended to close a DMABUF 548c2ecf20Sopenharmony_cifile when it is no longer used to allow the associated memory to be reclaimed. 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ciExamples 578c2ecf20Sopenharmony_ci======== 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci.. code-block:: c 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci int buffer_export(int v4lfd, enum dmx_buf_type bt, int index, int *dmafd) 628c2ecf20Sopenharmony_ci { 638c2ecf20Sopenharmony_ci struct dmx_exportbuffer expbuf; 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci memset(&expbuf, 0, sizeof(expbuf)); 668c2ecf20Sopenharmony_ci expbuf.type = bt; 678c2ecf20Sopenharmony_ci expbuf.index = index; 688c2ecf20Sopenharmony_ci if (ioctl(v4lfd, DMX_EXPBUF, &expbuf) == -1) { 698c2ecf20Sopenharmony_ci perror("DMX_EXPBUF"); 708c2ecf20Sopenharmony_ci return -1; 718c2ecf20Sopenharmony_ci } 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ci *dmafd = expbuf.fd; 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci return 0; 768c2ecf20Sopenharmony_ci } 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ciReturn Value 798c2ecf20Sopenharmony_ci============ 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ciOn success 0 is returned, on error -1 and the ``errno`` variable is set 828c2ecf20Sopenharmony_ciappropriately. The generic error codes are described at the 838c2ecf20Sopenharmony_ci:ref:`Generic Error Codes <gen-errors>` chapter. 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ciEINVAL 868c2ecf20Sopenharmony_ci A queue is not in MMAP mode or DMABUF exporting is not supported or 878c2ecf20Sopenharmony_ci ``flags`` or ``index`` fields are invalid. 88