nvhost: Throttle low-priority tasks
[linux-2.6.git] / include / linux / nvhost_ioctl.h
1 /*
2  * include/linux/nvhost_ioctl.h
3  *
4  * Tegra graphics host driver
5  *
6  * Copyright (c) 2009-2011, NVIDIA Corporation.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
16  * more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21  */
22
23 #ifndef __LINUX_NVHOST_IOCTL_H
24 #define __LINUX_NVHOST_IOCTL_H
25
26 #include <linux/ioctl.h>
27 #include <linux/types.h>
28
29 #if !defined(__KERNEL__)
30 #define __user
31 #endif
32
33 #define NVHOST_INVALID_SYNCPOINT 0xFFFFFFFF
34 #define NVHOST_NO_TIMEOUT (-1)
35 #define NVHOST_NO_CONTEXT 0x0
36 #define NVHOST_IOCTL_MAGIC 'H'
37 #define NVHOST_PRIORITY_LOW 50
38 #define NVHOST_PRIORITY_MEDIUM 100
39 #define NVHOST_PRIORITY_HIGH 150
40
41 /* version 0 header (used with write() submit interface) */
42 struct nvhost_submit_hdr {
43         __u32 syncpt_id;
44         __u32 syncpt_incrs;
45         __u32 num_cmdbufs;
46         __u32 num_relocs;
47 };
48
49 #define NVHOST_SUBMIT_VERSION_V0                0x0
50 #define NVHOST_SUBMIT_VERSION_V1                0x1
51 #define NVHOST_SUBMIT_VERSION_MAX_SUPPORTED     NVHOST_SUBMIT_VERSION_V1
52
53 /* version 1 header (used with ioctl() submit interface) */
54 struct nvhost_submit_hdr_ext {
55         __u32 syncpt_id;        /* version 0 fields */
56         __u32 syncpt_incrs;
57         __u32 num_cmdbufs;
58         __u32 num_relocs;
59         __u32 submit_version;   /* version 1 fields */
60         __u32 num_waitchks;
61         __u32 waitchk_mask;
62         __u32 pad[5];           /* future expansion */
63 };
64
65 struct nvhost_cmdbuf {
66         __u32 mem;
67         __u32 offset;
68         __u32 words;
69 };
70
71 struct nvhost_reloc {
72         __u32 cmdbuf_mem;
73         __u32 cmdbuf_offset;
74         __u32 target;
75         __u32 target_offset;
76 };
77
78 struct nvhost_waitchk {
79         __u32 mem;
80         __u32 offset;
81         __u32 syncpt_id;
82         __u32 thresh;
83 };
84
85 struct nvhost_get_param_args {
86         __u32 value;
87 };
88
89 struct nvhost_set_nvmap_fd_args {
90         __u32 fd;
91 };
92
93 struct nvhost_read_3d_reg_args {
94         __u32 offset;
95         __u32 value;
96 };
97
98 struct nvhost_clk_rate_args {
99         __u64 rate;
100 };
101
102 struct nvhost_set_timeout_args {
103         __u32 timeout;
104 };
105
106 struct nvhost_set_priority_args {
107         __u32 priority;
108 };
109
110 #define NVHOST_IOCTL_CHANNEL_FLUSH              \
111         _IOR(NVHOST_IOCTL_MAGIC, 1, struct nvhost_get_param_args)
112 #define NVHOST_IOCTL_CHANNEL_GET_SYNCPOINTS     \
113         _IOR(NVHOST_IOCTL_MAGIC, 2, struct nvhost_get_param_args)
114 #define NVHOST_IOCTL_CHANNEL_GET_WAITBASES      \
115         _IOR(NVHOST_IOCTL_MAGIC, 3, struct nvhost_get_param_args)
116 #define NVHOST_IOCTL_CHANNEL_GET_MODMUTEXES     \
117         _IOR(NVHOST_IOCTL_MAGIC, 4, struct nvhost_get_param_args)
118 #define NVHOST_IOCTL_CHANNEL_SET_NVMAP_FD       \
119         _IOW(NVHOST_IOCTL_MAGIC, 5, struct nvhost_set_nvmap_fd_args)
120 #define NVHOST_IOCTL_CHANNEL_NULL_KICKOFF       \
121         _IOR(NVHOST_IOCTL_MAGIC, 6, struct nvhost_get_param_args)
122 #define NVHOST_IOCTL_CHANNEL_SUBMIT_EXT         \
123         _IOW(NVHOST_IOCTL_MAGIC, 7, struct nvhost_submit_hdr_ext)
124 #define NVHOST_IOCTL_CHANNEL_READ_3D_REG \
125         _IOWR(NVHOST_IOCTL_MAGIC, 8, struct nvhost_read_3d_reg_args)
126 #define NVHOST_IOCTL_CHANNEL_GET_CLK_RATE               \
127         _IOR(NVHOST_IOCTL_MAGIC, 9, struct nvhost_clk_rate_args)
128 #define NVHOST_IOCTL_CHANNEL_SET_CLK_RATE               \
129         _IOW(NVHOST_IOCTL_MAGIC, 10, struct nvhost_clk_rate_args)
130 #define NVHOST_IOCTL_CHANNEL_SET_TIMEOUT        \
131         _IOW(NVHOST_IOCTL_MAGIC, 11, struct nvhost_set_timeout_args)
132 #define NVHOST_IOCTL_CHANNEL_GET_TIMEDOUT       \
133         _IOR(NVHOST_IOCTL_MAGIC, 12, struct nvhost_get_param_args)
134 #define NVHOST_IOCTL_CHANNEL_SET_PRIORITY       \
135         _IOW(NVHOST_IOCTL_MAGIC, 13, struct nvhost_set_priority_args)
136 #define NVHOST_IOCTL_CHANNEL_LAST               \
137         _IOC_NR(NVHOST_IOCTL_CHANNEL_SET_PRIORITY)
138 #define NVHOST_IOCTL_CHANNEL_MAX_ARG_SIZE sizeof(struct nvhost_submit_hdr_ext)
139
140 struct nvhost_ctrl_syncpt_read_args {
141         __u32 id;
142         __u32 value;
143 };
144
145 struct nvhost_ctrl_syncpt_incr_args {
146         __u32 id;
147 };
148
149 struct nvhost_ctrl_syncpt_wait_args {
150         __u32 id;
151         __u32 thresh;
152         __s32 timeout;
153 };
154
155 struct nvhost_ctrl_syncpt_waitex_args {
156         __u32 id;
157         __u32 thresh;
158         __s32 timeout;
159         __u32 value;
160 };
161
162 struct nvhost_ctrl_module_mutex_args {
163         __u32 id;
164         __u32 lock;
165 };
166
167 struct nvhost_ctrl_module_regrdwr_args {
168         __u32 id;
169         __u32 num_offsets;
170         __u32 block_size;
171         __u32 *offsets;
172         __u32 *values;
173         __u32 write;
174 };
175
176 #define NVHOST_IOCTL_CTRL_SYNCPT_READ           \
177         _IOWR(NVHOST_IOCTL_MAGIC, 1, struct nvhost_ctrl_syncpt_read_args)
178 #define NVHOST_IOCTL_CTRL_SYNCPT_INCR           \
179         _IOW(NVHOST_IOCTL_MAGIC, 2, struct nvhost_ctrl_syncpt_incr_args)
180 #define NVHOST_IOCTL_CTRL_SYNCPT_WAIT           \
181         _IOW(NVHOST_IOCTL_MAGIC, 3, struct nvhost_ctrl_syncpt_wait_args)
182
183 #define NVHOST_IOCTL_CTRL_MODULE_MUTEX          \
184         _IOWR(NVHOST_IOCTL_MAGIC, 4, struct nvhost_ctrl_module_mutex_args)
185 #define NVHOST_IOCTL_CTRL_MODULE_REGRDWR        \
186         _IOWR(NVHOST_IOCTL_MAGIC, 5, struct nvhost_ctrl_module_regrdwr_args)
187
188 #define NVHOST_IOCTL_CTRL_SYNCPT_WAITEX         \
189         _IOWR(NVHOST_IOCTL_MAGIC, 6, struct nvhost_ctrl_syncpt_waitex_args)
190
191 #define NVHOST_IOCTL_CTRL_LAST                  \
192         _IOC_NR(NVHOST_IOCTL_CTRL_SYNCPT_WAITEX)
193 #define NVHOST_IOCTL_CTRL_MAX_ARG_SIZE  \
194         sizeof(struct nvhost_ctrl_module_regrdwr_args)
195
196 #endif