• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  ion_uapi.h
3  *
4  *   Copyright 2018 Samsung Electronics Co., Ltd.
5  *
6  *  Licensed under the Apache License, Version 2.0 (the "License");
7  *  you may not use this file except in compliance with the License.
8  *  You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  *  Unless required by applicable law or agreed to in writing, software
13  *  distributed under the License is distributed on an "AS IS" BASIS,
14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  *  See the License for the specific language governing permissions and
16  *  limitations under the License.
17  */
18 
19 #ifndef __EXYNOS_ION_H__
20 #define __EXYNOS_ION_H__
21 
22 #include <linux/ioctl.h>
23 #include <linux/types.h>
24 
25 enum ion_heap_type {
26     ION_HEAP_TYPE_SYSTEM,
27     ION_HEAP_TYPE_SYSTEM_CONTIG,
28     ION_HEAP_TYPE_CARVEOUT,
29     ION_HEAP_TYPE_CHUNK,
30     ION_HEAP_TYPE_DMA,
31     ION_HEAP_TYPE_HPA
32 };
33 
34 #define ION_NUM_HEAP_IDS (sizeof(unsigned int) * 8)
35 
36 /*
37  * ION LEGACY UAPI
38  */
39 struct ion_allocation_data_legacy {
40     size_t len;
41     size_t align;
42     unsigned int heap_id_mask;
43     unsigned int flags;
44     int handle;
45 };
46 
47 struct ion_fd_data {
48     int handle;
49     int fd;
50 };
51 
52 struct ion_fd_partial_data {
53     int handle;
54     int fd;
55     off_t offset;
56     size_t len;
57 };
58 
59 struct ion_handle_data {
60     int handle;
61 };
62 
63 struct ion_custom_data {
64     unsigned int cmd;
65     unsigned long arg;
66 };
67 
68 /*
69  * ION MODERN UAPI
70  */
71 
72 struct ion_allocation_data_modern {
73     __u64 len;
74     __u32 heap_id_mask;
75     __u32 flags;
76     __u32 fd;
77     __u32 unused;
78 };
79 
80 #define MAX_HEAP_NAME 32
81 
82 #define ION_HEAPDATA_FLAGS_DEFER_FREE		1
83 #define ION_HEAPDATA_FLAGS_ALLOW_PROTECTION	2
84 #define ION_HEAPDATA_FLAGS_UNTOUCHABLE		4
85 
86 struct ion_heap_data {
87     char name[MAX_HEAP_NAME];
88     __u32 type;
89     __u32 heap_id;
90     __u32 size;       /* reserved 0 */
91     __u32 heap_flags; /* reserved 1 */
92     __u32 reserved2;
93 };
94 
95 struct ion_heap_query {
96     __u32 cnt;
97     __u32 reserved0;
98     __u64 heaps;
99     __u32 reserved1;
100     __u32 reserved2;
101 };
102 
103 #define ION_IOC_MAGIC		'I'
104 
105 #define ION_IOC_ALLOC_LEGACY _IOWR(ION_IOC_MAGIC, 0, struct ion_allocation_data_legacy)
106 #define ION_IOC_ALLOC_MODERN _IOWR(ION_IOC_MAGIC, 0, struct ion_allocation_data_modern)
107 #define ION_IOC_FREE         _IOWR(ION_IOC_MAGIC, 1, struct ion_handle_data)
108 #define ION_IOC_MAP          _IOWR(ION_IOC_MAGIC, 2, struct ion_fd_data)
109 #define ION_IOC_SHARE        _IOWR(ION_IOC_MAGIC, 4, struct ion_fd_data)
110 #define ION_IOC_IMPORT       _IOWR(ION_IOC_MAGIC, 5, struct ion_fd_data)
111 #define ION_IOC_SYNC         _IOWR(ION_IOC_MAGIC, 7, struct ion_fd_data)
112 #define ION_IOC_CUSTOM       _IOWR(ION_IOC_MAGIC, 6, struct ion_custom_data)
113 #define ION_IOC_HEAP_QUERY   _IOWR(ION_IOC_MAGIC, 8, struct ion_heap_query)
114 #define ION_IOC_SYNC_PARTIAL _IOWR(ION_IOC_MAGIC, 9, struct ion_fd_partial_data)
115 
116 
117 #endif /* __EXYNOS_ION_H__ */
118