dma_util.h 729 B

123456789101112131415161718192021
  1. #ifndef __DMA_UTIL_H__
  2. #define __DMA_UTIL_H__
  3. #include <stddef.h>
  4. #include <stdint.h>
  5. #include <sys/ioctl.h>
  6. #include <linux/dma-buf.h>
  7. /* Allocate one dma-buf from /dev/dma_heap/<heap_name>, falling back to
  8. * "system-uncached" when the named heap does not exist. Returns 0 and sets
  9. * *fd on success, -1 on failure. Shared by main/decoder/display/detector. */
  10. int dma_heap_alloc(const char *heap_name, size_t size, int *fd);
  11. /* Convenience wrapper for the DMA_BUF_IOCTL_SYNC START/END handshake,
  12. * e.g. dmabuf_sync(fd, DMA_BUF_SYNC_START | DMA_BUF_SYNC_WRITE). */
  13. static inline void dmabuf_sync(int fd, int flags) {
  14. struct dma_buf_sync s = { .flags = (uint64_t)flags };
  15. ioctl(fd, DMA_BUF_IOCTL_SYNC, &s);
  16. }
  17. #endif