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 * Copyright (C) 2022 Rockchip Electronics Co. Ltd. 8*4882a593Smuzhiyun * Author: Simon Xue <xxm@rock-chips.com> 9*4882a593Smuzhiyun */ 10*4882a593Smuzhiyun #ifndef _UAPI_LINUX_DMABUF_POOL_H 11*4882a593Smuzhiyun #define _UAPI_LINUX_DMABUF_POOL_H 12*4882a593Smuzhiyun 13*4882a593Smuzhiyun #include <linux/ioctl.h> 14*4882a593Smuzhiyun #include <linux/types.h> 15*4882a593Smuzhiyun 16*4882a593Smuzhiyun /** 17*4882a593Smuzhiyun * DOC: DMABUF Heaps Userspace API 18*4882a593Smuzhiyun */ 19*4882a593Smuzhiyun 20*4882a593Smuzhiyun /* Valid FD_FLAGS are O_CLOEXEC, O_RDONLY, O_WRONLY, O_RDWR */ 21*4882a593Smuzhiyun #define RK_DMA_HEAP_VALID_FD_FLAGS (O_CLOEXEC | O_ACCMODE) 22*4882a593Smuzhiyun 23*4882a593Smuzhiyun /* Currently no heap flags */ 24*4882a593Smuzhiyun #define RK_DMA_HEAP_VALID_HEAP_FLAGS (0) 25*4882a593Smuzhiyun 26*4882a593Smuzhiyun /** 27*4882a593Smuzhiyun * struct rk_dma_heap_allocation_data - metadata passed from userspace for 28*4882a593Smuzhiyun * allocations 29*4882a593Smuzhiyun * @len: size of the allocation 30*4882a593Smuzhiyun * @fd: will be populated with a fd which provides the 31*4882a593Smuzhiyun * handle to the allocated dma-buf 32*4882a593Smuzhiyun * @fd_flags: file descriptor flags used when allocating 33*4882a593Smuzhiyun * @heap_flags: flags passed to heap 34*4882a593Smuzhiyun * 35*4882a593Smuzhiyun * Provided by userspace as an argument to the ioctl 36*4882a593Smuzhiyun */ 37*4882a593Smuzhiyun struct rk_dma_heap_allocation_data { 38*4882a593Smuzhiyun __u64 len; 39*4882a593Smuzhiyun __u32 fd; 40*4882a593Smuzhiyun __u32 fd_flags; 41*4882a593Smuzhiyun __u64 heap_flags; 42*4882a593Smuzhiyun }; 43*4882a593Smuzhiyun 44*4882a593Smuzhiyun #define RK_DMA_HEAP_IOC_MAGIC 'R' 45*4882a593Smuzhiyun 46*4882a593Smuzhiyun /** 47*4882a593Smuzhiyun * DOC: RK_DMA_HEAP_IOCTL_ALLOC - allocate memory from pool 48*4882a593Smuzhiyun * 49*4882a593Smuzhiyun * Takes a rk_dma_heap_allocation_data struct and returns it with the fd field 50*4882a593Smuzhiyun * populated with the dmabuf handle of the allocation. 51*4882a593Smuzhiyun */ 52*4882a593Smuzhiyun #define RK_DMA_HEAP_IOCTL_ALLOC _IOWR(RK_DMA_HEAP_IOC_MAGIC, 0x0,\ 53*4882a593Smuzhiyun struct rk_dma_heap_allocation_data) 54*4882a593Smuzhiyun 55*4882a593Smuzhiyun #endif /* _UAPI_LINUX_DMABUF_POOL_H */ 56