1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * DMABUF Heaps Userspace API 4*4882a593Smuzhiyun * 5*4882a593Smuzhiyun * Copyright (C) 2011 Google, Inc. 6*4882a593Smuzhiyun * Copyright (C) 2019 Linaro Ltd. 7*4882a593Smuzhiyun */ 8*4882a593Smuzhiyun #ifndef _UAPI_LINUX_DMABUF_POOL_H 9*4882a593Smuzhiyun #define _UAPI_LINUX_DMABUF_POOL_H 10*4882a593Smuzhiyun 11*4882a593Smuzhiyun #include <linux/ioctl.h> 12*4882a593Smuzhiyun #include <linux/types.h> 13*4882a593Smuzhiyun 14*4882a593Smuzhiyun /** 15*4882a593Smuzhiyun * DOC: DMABUF Heaps Userspace API 16*4882a593Smuzhiyun */ 17*4882a593Smuzhiyun 18*4882a593Smuzhiyun /* Valid FD_FLAGS are O_CLOEXEC, O_RDONLY, O_WRONLY, O_RDWR */ 19*4882a593Smuzhiyun #define DMA_HEAP_VALID_FD_FLAGS (O_CLOEXEC | O_ACCMODE) 20*4882a593Smuzhiyun 21*4882a593Smuzhiyun /* Currently no heap flags */ 22*4882a593Smuzhiyun #define DMA_HEAP_VALID_HEAP_FLAGS (0) 23*4882a593Smuzhiyun 24*4882a593Smuzhiyun /** 25*4882a593Smuzhiyun * struct dma_heap_allocation_data - metadata passed from userspace for 26*4882a593Smuzhiyun * allocations 27*4882a593Smuzhiyun * @len: size of the allocation 28*4882a593Smuzhiyun * @fd: will be populated with a fd which provides the 29*4882a593Smuzhiyun * handle to the allocated dma-buf 30*4882a593Smuzhiyun * @fd_flags: file descriptor flags used when allocating 31*4882a593Smuzhiyun * @heap_flags: flags passed to heap 32*4882a593Smuzhiyun * 33*4882a593Smuzhiyun * Provided by userspace as an argument to the ioctl 34*4882a593Smuzhiyun */ 35*4882a593Smuzhiyun struct dma_heap_allocation_data { 36*4882a593Smuzhiyun __u64 len; 37*4882a593Smuzhiyun __u32 fd; 38*4882a593Smuzhiyun __u32 fd_flags; 39*4882a593Smuzhiyun __u64 heap_flags; 40*4882a593Smuzhiyun }; 41*4882a593Smuzhiyun 42*4882a593Smuzhiyun #define DMA_HEAP_IOC_MAGIC 'H' 43*4882a593Smuzhiyun 44*4882a593Smuzhiyun /** 45*4882a593Smuzhiyun * DOC: DMA_HEAP_IOCTL_ALLOC - allocate memory from pool 46*4882a593Smuzhiyun * 47*4882a593Smuzhiyun * Takes a dma_heap_allocation_data struct and returns it with the fd field 48*4882a593Smuzhiyun * populated with the dmabuf handle of the allocation. 49*4882a593Smuzhiyun */ 50*4882a593Smuzhiyun #define DMA_HEAP_IOCTL_ALLOC _IOWR(DMA_HEAP_IOC_MAGIC, 0x0,\ 51*4882a593Smuzhiyun struct dma_heap_allocation_data) 52*4882a593Smuzhiyun 53*4882a593Smuzhiyun #endif /* _UAPI_LINUX_DMABUF_POOL_H */ 54