summaryrefslogtreecommitdiff
path: root/drivers/gpu/msm/kgsl_compat.h
blob: 7681d74fb108e1449b94eaa9ab7acc5043d4524e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
/* Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 */
#ifndef __KGSL_COMPAT_H
#define __KGSL_COMPAT_H

#ifdef CONFIG_COMPAT
#include <linux/compat.h>
#include "kgsl.h"
#include "kgsl_device.h"

struct kgsl_ibdesc_compat {
	compat_ulong_t gpuaddr;
	unsigned int __pad;
	compat_size_t sizedwords;
	unsigned int ctrl;
};

struct kgsl_cmd_syncpoint_compat {
	int type;
	compat_uptr_t priv;
	compat_size_t size;
};

struct kgsl_devinfo_compat {
	unsigned int device_id;
	unsigned int chip_id;
	unsigned int mmu_enabled;
	compat_ulong_t gmem_gpubaseaddr;
	unsigned int gpu_id;
	compat_size_t gmem_sizebytes;
};

struct kgsl_shadowprop_compat {
	compat_ulong_t gpuaddr;
	compat_size_t size;
	unsigned int flags;
};

struct kgsl_device_constraint_compat {
	unsigned int type;
	unsigned int context_id;
	compat_uptr_t data;
	compat_size_t size;
};

struct kgsl_device_getproperty_compat {
	unsigned int type;
	compat_uptr_t value;
	compat_size_t sizebytes;
};

#define IOCTL_KGSL_DEVICE_GETPROPERTY_COMPAT \
	_IOWR(KGSL_IOC_TYPE, 0x2, struct kgsl_device_getproperty_compat)

#define IOCTL_KGSL_SETPROPERTY_COMPAT \
	_IOW(KGSL_IOC_TYPE, 0x32, struct kgsl_device_getproperty_compat)


struct kgsl_submit_commands_compat {
	unsigned int context_id;
	unsigned int flags;
	compat_uptr_t cmdlist;
	unsigned int numcmds;
	compat_uptr_t synclist;
	unsigned int numsyncs;
	unsigned int timestamp;
/* private: reserved for future use */
	unsigned int __pad[4];
};

#define IOCTL_KGSL_SUBMIT_COMMANDS_COMPAT \
	_IOWR(KGSL_IOC_TYPE, 0x3D, struct kgsl_submit_commands_compat)

struct kgsl_ringbuffer_issueibcmds_compat {
	unsigned int drawctxt_id;
	compat_ulong_t ibdesc_addr;
	unsigned int numibs;
	unsigned int timestamp; /* output param */
	unsigned int flags;
};

#define IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS_COMPAT \
	_IOWR(KGSL_IOC_TYPE, 0x10, struct kgsl_ringbuffer_issueibcmds_compat)

struct kgsl_cmdstream_freememontimestamp_ctxtid_compat {
	unsigned int context_id;
	compat_ulong_t gpuaddr;
	unsigned int type;
	unsigned int timestamp;
};

#define IOCTL_KGSL_CMDSTREAM_FREEMEMONTIMESTAMP_CTXTID_COMPAT \
	_IOW(KGSL_IOC_TYPE, 0x17, \
	struct kgsl_cmdstream_freememontimestamp_ctxtid_compat)

struct kgsl_map_user_mem_compat {
	int fd;
	compat_ulong_t gpuaddr;
	compat_size_t len;
	compat_size_t offset;
	compat_ulong_t hostptr;
	enum kgsl_user_mem_type memtype;
	unsigned int flags;
};

#define IOCTL_KGSL_MAP_USER_MEM_COMPAT \
	_IOWR(KGSL_IOC_TYPE, 0x15, struct kgsl_map_user_mem_compat)

struct kgsl_sharedmem_free_compat {
	compat_ulong_t gpuaddr;
};

#define IOCTL_KGSL_SHAREDMEM_FLUSH_CACHE_COMPAT \
	_IOW(KGSL_IOC_TYPE, 0x24, struct kgsl_sharedmem_free_compat)

#define IOCTL_KGSL_SHAREDMEM_FREE_COMPAT \
	_IOW(KGSL_IOC_TYPE, 0x21, struct kgsl_sharedmem_free_compat)

struct kgsl_gpumem_alloc_compat {
	compat_ulong_t gpuaddr; /* output param */
	compat_size_t size;
	unsigned int flags;
};

#define IOCTL_KGSL_GPUMEM_ALLOC_COMPAT \
	_IOWR(KGSL_IOC_TYPE, 0x2f, struct kgsl_gpumem_alloc_compat)

struct kgsl_cff_syncmem_compat {
	compat_ulong_t gpuaddr;
	compat_size_t len;
	unsigned int __pad[2]; /* For future binary compatibility */
};

#define IOCTL_KGSL_CFF_SYNCMEM_COMPAT \
	_IOW(KGSL_IOC_TYPE, 0x30, struct kgsl_cff_syncmem_compat)

struct kgsl_timestamp_event_compat {
	int type;                /* Type of event (see list below) */
	unsigned int timestamp;  /* Timestamp to trigger event on */
	unsigned int context_id; /* Context for the timestamp */
	compat_uptr_t priv;      /* Pointer to the event specific blob */
	compat_size_t len;       /* Size of the event specific blob */
};

#define IOCTL_KGSL_TIMESTAMP_EVENT_COMPAT \
	_IOWR(KGSL_IOC_TYPE, 0x33, struct kgsl_timestamp_event_compat)

struct kgsl_gpumem_alloc_id_compat {
	unsigned int id;
	unsigned int flags;
	compat_size_t size;
	compat_size_t mmapsize;
	compat_ulong_t gpuaddr;
/* private: reserved for future use*/
	unsigned int __pad[2];
};

#define IOCTL_KGSL_GPUMEM_ALLOC_ID_COMPAT \
	_IOWR(KGSL_IOC_TYPE, 0x34, struct kgsl_gpumem_alloc_id_compat)

struct kgsl_gpumem_get_info_compat {
	compat_ulong_t gpuaddr;
	unsigned int id;
	unsigned int flags;
	compat_size_t size;
	compat_size_t mmapsize;
	compat_ulong_t useraddr;
/* private: reserved for future use*/
	unsigned int __pad[4];
};

#define IOCTL_KGSL_GPUMEM_GET_INFO_COMPAT \
	_IOWR(KGSL_IOC_TYPE, 0x36, struct kgsl_gpumem_get_info_compat)

struct kgsl_gpumem_sync_cache_compat {
	compat_ulong_t gpuaddr;
	unsigned int id;
	unsigned int op;
	compat_size_t offset;
	compat_size_t length;
};

#define IOCTL_KGSL_GPUMEM_SYNC_CACHE_COMPAT \
	_IOW(KGSL_IOC_TYPE, 0x37, struct kgsl_gpumem_sync_cache_compat)

struct kgsl_gpumem_sync_cache_bulk_compat {
	compat_uptr_t id_list;
	unsigned int count;
	unsigned int op;
/* private: reserved for future use */
	unsigned int __pad[2]; /* For future binary compatibility */
};

#define IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK_COMPAT \
	_IOWR(KGSL_IOC_TYPE, 0x3C, struct kgsl_gpumem_sync_cache_bulk_compat)

struct kgsl_perfcounter_query_compat {
	unsigned int groupid;
	compat_uptr_t countables;
	unsigned int count;
	unsigned int max_counters;
	unsigned int __pad[2];
};

#define IOCTL_KGSL_PERFCOUNTER_QUERY_COMPAT \
	_IOWR(KGSL_IOC_TYPE, 0x3A, struct kgsl_perfcounter_query_compat)

struct kgsl_perfcounter_read_compat {
	compat_uptr_t reads;
	unsigned int count;
	unsigned int __pad[2];
};

#define IOCTL_KGSL_PERFCOUNTER_READ_COMPAT \
	_IOWR(KGSL_IOC_TYPE, 0x3B, struct kgsl_perfcounter_read_compat)

static inline compat_ulong_t gpuaddr_to_compat(unsigned long gpuaddr)
{
	WARN(gpuaddr >> 32, "Top 32 bits of gpuaddr have been set\n");
	return (compat_ulong_t)gpuaddr;
}

static inline compat_size_t sizet_to_compat(size_t size)
{
	WARN(size >> 32, "Size greater than 4G\n");
	return (compat_size_t)size;
}

int kgsl_drawobj_create_compat(struct kgsl_device *device, unsigned int flags,
			struct kgsl_drawobj *drawobj, void __user *cmdlist,
			unsigned int numcmds, void __user *synclist,
			unsigned int numsyncs);

long kgsl_compat_ioctl(struct file *filep, unsigned int cmd,
			unsigned long arg);

#else
static inline int kgsl_drawobj_create_compat(struct kgsl_device *device,
			unsigned int flags, struct kgsl_drawobj *drawobj,
			void __user *cmdlist, unsigned int numcmds,
			void __user *synclist, unsigned int numsyncs)
{
	BUG();
}

static inline long kgsl_compat_ioctl(struct file *filep, unsigned int cmd,
			unsigned long arg)
{
	BUG();
}

#endif /* CONFIG_COMPAT */
#endif /* __KGSL_COMPAT_H */