18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * ion.h 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2011 Google, Inc. 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci/* This file is copied from drivers/staging/android/uapi/ion.h 98c2ecf20Sopenharmony_ci * This local copy is required for the selftest to pass, when build 108c2ecf20Sopenharmony_ci * outside the kernel source tree. 118c2ecf20Sopenharmony_ci * Please keep this file in sync with its original file until the 128c2ecf20Sopenharmony_ci * ion driver is moved outside the staging tree. 138c2ecf20Sopenharmony_ci */ 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#ifndef _UAPI_LINUX_ION_H 168c2ecf20Sopenharmony_ci#define _UAPI_LINUX_ION_H 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#include <linux/ioctl.h> 198c2ecf20Sopenharmony_ci#include <linux/types.h> 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci/** 228c2ecf20Sopenharmony_ci * enum ion_heap_types - list of all possible types of heaps 238c2ecf20Sopenharmony_ci * @ION_HEAP_TYPE_SYSTEM: memory allocated via vmalloc 248c2ecf20Sopenharmony_ci * @ION_HEAP_TYPE_SYSTEM_CONTIG: memory allocated via kmalloc 258c2ecf20Sopenharmony_ci * @ION_HEAP_TYPE_CARVEOUT: memory allocated from a prereserved 268c2ecf20Sopenharmony_ci * carveout heap, allocations are physically 278c2ecf20Sopenharmony_ci * contiguous 288c2ecf20Sopenharmony_ci * @ION_HEAP_TYPE_DMA: memory allocated via DMA API 298c2ecf20Sopenharmony_ci * @ION_NUM_HEAPS: helper for iterating over heaps, a bit mask 308c2ecf20Sopenharmony_ci * is used to identify the heaps, so only 32 318c2ecf20Sopenharmony_ci * total heap types are supported 328c2ecf20Sopenharmony_ci */ 338c2ecf20Sopenharmony_cienum ion_heap_type { 348c2ecf20Sopenharmony_ci ION_HEAP_TYPE_SYSTEM, 358c2ecf20Sopenharmony_ci ION_HEAP_TYPE_SYSTEM_CONTIG, 368c2ecf20Sopenharmony_ci ION_HEAP_TYPE_CARVEOUT, 378c2ecf20Sopenharmony_ci ION_HEAP_TYPE_CHUNK, 388c2ecf20Sopenharmony_ci ION_HEAP_TYPE_DMA, 398c2ecf20Sopenharmony_ci ION_HEAP_TYPE_CUSTOM, /* 408c2ecf20Sopenharmony_ci * must be last so device specific heaps always 418c2ecf20Sopenharmony_ci * are at the end of this enum 428c2ecf20Sopenharmony_ci */ 438c2ecf20Sopenharmony_ci}; 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci#define ION_NUM_HEAP_IDS (sizeof(unsigned int) * 8) 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci/** 488c2ecf20Sopenharmony_ci * allocation flags - the lower 16 bits are used by core ion, the upper 16 498c2ecf20Sopenharmony_ci * bits are reserved for use by the heaps themselves. 508c2ecf20Sopenharmony_ci */ 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci/* 538c2ecf20Sopenharmony_ci * mappings of this buffer should be cached, ion will do cache maintenance 548c2ecf20Sopenharmony_ci * when the buffer is mapped for dma 558c2ecf20Sopenharmony_ci */ 568c2ecf20Sopenharmony_ci#define ION_FLAG_CACHED 1 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci/** 598c2ecf20Sopenharmony_ci * DOC: Ion Userspace API 608c2ecf20Sopenharmony_ci * 618c2ecf20Sopenharmony_ci * create a client by opening /dev/ion 628c2ecf20Sopenharmony_ci * most operations handled via following ioctls 638c2ecf20Sopenharmony_ci * 648c2ecf20Sopenharmony_ci */ 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci/** 678c2ecf20Sopenharmony_ci * struct ion_allocation_data - metadata passed from userspace for allocations 688c2ecf20Sopenharmony_ci * @len: size of the allocation 698c2ecf20Sopenharmony_ci * @heap_id_mask: mask of heap ids to allocate from 708c2ecf20Sopenharmony_ci * @flags: flags passed to heap 718c2ecf20Sopenharmony_ci * @handle: pointer that will be populated with a cookie to use to 728c2ecf20Sopenharmony_ci * refer to this allocation 738c2ecf20Sopenharmony_ci * 748c2ecf20Sopenharmony_ci * Provided by userspace as an argument to the ioctl 758c2ecf20Sopenharmony_ci */ 768c2ecf20Sopenharmony_cistruct ion_allocation_data { 778c2ecf20Sopenharmony_ci __u64 len; 788c2ecf20Sopenharmony_ci __u32 heap_id_mask; 798c2ecf20Sopenharmony_ci __u32 flags; 808c2ecf20Sopenharmony_ci __u32 fd; 818c2ecf20Sopenharmony_ci __u32 unused; 828c2ecf20Sopenharmony_ci}; 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci#define MAX_HEAP_NAME 32 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci/** 878c2ecf20Sopenharmony_ci * struct ion_heap_data - data about a heap 888c2ecf20Sopenharmony_ci * @name - first 32 characters of the heap name 898c2ecf20Sopenharmony_ci * @type - heap type 908c2ecf20Sopenharmony_ci * @heap_id - heap id for the heap 918c2ecf20Sopenharmony_ci */ 928c2ecf20Sopenharmony_cistruct ion_heap_data { 938c2ecf20Sopenharmony_ci char name[MAX_HEAP_NAME]; 948c2ecf20Sopenharmony_ci __u32 type; 958c2ecf20Sopenharmony_ci __u32 heap_id; 968c2ecf20Sopenharmony_ci __u32 reserved0; 978c2ecf20Sopenharmony_ci __u32 reserved1; 988c2ecf20Sopenharmony_ci __u32 reserved2; 998c2ecf20Sopenharmony_ci}; 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ci/** 1028c2ecf20Sopenharmony_ci * struct ion_heap_query - collection of data about all heaps 1038c2ecf20Sopenharmony_ci * @cnt - total number of heaps to be copied 1048c2ecf20Sopenharmony_ci * @heaps - buffer to copy heap data 1058c2ecf20Sopenharmony_ci */ 1068c2ecf20Sopenharmony_cistruct ion_heap_query { 1078c2ecf20Sopenharmony_ci __u32 cnt; /* Total number of heaps to be copied */ 1088c2ecf20Sopenharmony_ci __u32 reserved0; /* align to 64bits */ 1098c2ecf20Sopenharmony_ci __u64 heaps; /* buffer to be populated */ 1108c2ecf20Sopenharmony_ci __u32 reserved1; 1118c2ecf20Sopenharmony_ci __u32 reserved2; 1128c2ecf20Sopenharmony_ci}; 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_ci#define ION_IOC_MAGIC 'I' 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ci/** 1178c2ecf20Sopenharmony_ci * DOC: ION_IOC_ALLOC - allocate memory 1188c2ecf20Sopenharmony_ci * 1198c2ecf20Sopenharmony_ci * Takes an ion_allocation_data struct and returns it with the handle field 1208c2ecf20Sopenharmony_ci * populated with the opaque handle for the allocation. 1218c2ecf20Sopenharmony_ci */ 1228c2ecf20Sopenharmony_ci#define ION_IOC_ALLOC _IOWR(ION_IOC_MAGIC, 0, \ 1238c2ecf20Sopenharmony_ci struct ion_allocation_data) 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_ci/** 1268c2ecf20Sopenharmony_ci * DOC: ION_IOC_HEAP_QUERY - information about available heaps 1278c2ecf20Sopenharmony_ci * 1288c2ecf20Sopenharmony_ci * Takes an ion_heap_query structure and populates information about 1298c2ecf20Sopenharmony_ci * available Ion heaps. 1308c2ecf20Sopenharmony_ci */ 1318c2ecf20Sopenharmony_ci#define ION_IOC_HEAP_QUERY _IOWR(ION_IOC_MAGIC, 8, \ 1328c2ecf20Sopenharmony_ci struct ion_heap_query) 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_ci#endif /* _UAPI_LINUX_ION_H */ 135