1 /**
2  * Copyright (C) 2021 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #define KGSL_MEMFLAGS_USE_CPU_MAP 0x10000000ULL
17 #define KGSL_MEMFLAGS_GPUREADONLY 0x01000000U
18 #define KGSL_IOC_TYPE 0x09
19 #define KGSL_MEMTYPE_COMMAND 16
20 
21 enum kgsl_user_mem_type {
22   KGSL_USER_MEM_TYPE_PMEM = 0x00000000,
23   KGSL_USER_MEM_TYPE_ASHMEM = 0x00000001,
24   KGSL_USER_MEM_TYPE_ADDR = 0x00000002,
25   KGSL_USER_MEM_TYPE_ION = 0x00000003,
26   KGSL_USER_MEM_TYPE_DMABUF = 0x00000003,
27   KGSL_USER_MEM_TYPE_MAX = 0x00000007,
28 };
29 
30 struct kgsl_drawctxt_create {
31   unsigned int flags;
32   unsigned int drawctxt_id;
33 };
34 
35 #define IOCTL_KGSL_DRAWCTXT_CREATE \
36   _IOWR(KGSL_IOC_TYPE, 0x13, struct kgsl_drawctxt_create)
37 
38 struct kgsl_map_user_mem {
39   int fd;
40   unsigned long gpuaddr;
41   size_t len;
42   size_t offset;
43   unsigned long hostptr;
44   enum kgsl_user_mem_type memtype;
45   unsigned int flags;
46 };
47 
48 #define IOCTL_KGSL_MAP_USER_MEM \
49   _IOWR(KGSL_IOC_TYPE, 0x15, struct kgsl_map_user_mem)
50 
51 struct kgsl_sharedmem_free {
52   unsigned long gpuaddr;
53 };
54 
55 #define IOCTL_KGSL_SHAREDMEM_FREE \
56   _IOW(KGSL_IOC_TYPE, 0x21, struct kgsl_sharedmem_free)
57 
58 struct kgsl_gpumem_alloc {
59   unsigned long gpuaddr;
60   size_t size;
61   unsigned int flags;
62 };
63 
64 #define IOCTL_KGSL_GPUMEM_ALLOC \
65   _IOWR(KGSL_IOC_TYPE, 0x2f, struct kgsl_gpumem_alloc)
66 
67 struct kgsl_gpumem_alloc_id {
68   unsigned int id;
69   unsigned int flags;
70   size_t size;
71   size_t mmapsize;
72   unsigned long gpuaddr;
73   unsigned long __pad[2];
74 };
75 
76 #define IOCTL_KGSL_GPUMEM_ALLOC_ID \
77   _IOWR(KGSL_IOC_TYPE, 0x34, struct kgsl_gpumem_alloc_id)
78 
79 struct kgsl_gpumem_get_info {
80   unsigned long gpuaddr;
81   unsigned int id;
82   unsigned int flags;
83   size_t size;
84   size_t mmapsize;
85   unsigned long useraddr;
86   unsigned long __pad[4];
87 };
88 
89 #define IOCTL_KGSL_GPUMEM_GET_INFO \
90   _IOWR(KGSL_IOC_TYPE, 0x36, struct kgsl_gpumem_get_info)
91