1 #ifndef _INTEL_DRIVER_H_
2 #define _INTEL_DRIVER_H_
11 #include <intel_bufmgr.h>
13 #include <va/va_backend.h>
15 #include "intel_compiler.h"
17 #define BATCH_SIZE 0x80000
18 #define BATCH_RESERVED 0x10
20 #define CMD_MI (0x0 << 29)
21 #define CMD_2D (0x2 << 29)
22 #define CMD_3D (0x3 << 29)
24 #define MI_NOOP (CMD_MI | 0)
26 #define MI_BATCH_BUFFER_END (CMD_MI | (0xA << 23))
27 #define MI_BATCH_BUFFER_START (CMD_MI | (0x31 << 23))
29 #define MI_FLUSH (CMD_MI | (0x4 << 23))
30 #define MI_FLUSH_STATE_INSTRUCTION_CACHE_INVALIDATE (0x1 << 0)
32 #define MI_FLUSH_DW (CMD_MI | (0x26 << 23) | 0x2)
33 #define MI_FLUSH_DW_VIDEO_PIPELINE_CACHE_INVALIDATE (0x1 << 7)
35 #define XY_COLOR_BLT_CMD (CMD_2D | (0x50 << 22) | 0x04)
36 #define XY_COLOR_BLT_WRITE_ALPHA (1 << 21)
37 #define XY_COLOR_BLT_WRITE_RGB (1 << 20)
38 #define XY_COLOR_BLT_DST_TILED (1 << 11)
41 #define BR13_8 (0x0 << 24)
42 #define BR13_565 (0x1 << 24)
43 #define BR13_1555 (0x2 << 24)
44 #define BR13_8888 (0x3 << 24)
46 #define CMD_PIPE_CONTROL (CMD_3D | (3 << 27) | (2 << 24) | (0 << 16))
47 #define CMD_PIPE_CONTROL_NOWRITE (0 << 14)
48 #define CMD_PIPE_CONTROL_WRITE_QWORD (1 << 14)
49 #define CMD_PIPE_CONTROL_WRITE_DEPTH (2 << 14)
50 #define CMD_PIPE_CONTROL_WRITE_TIME (3 << 14)
51 #define CMD_PIPE_CONTROL_DEPTH_STALL (1 << 13)
52 #define CMD_PIPE_CONTROL_WC_FLUSH (1 << 12)
53 #define CMD_PIPE_CONTROL_IS_FLUSH (1 << 11)
54 #define CMD_PIPE_CONTROL_TC_FLUSH (1 << 10)
55 #define CMD_PIPE_CONTROL_NOTIFY_ENABLE (1 << 8)
56 #define CMD_PIPE_CONTROL_DC_FLUSH (1 << 5)
57 #define CMD_PIPE_CONTROL_GLOBAL_GTT (1 << 2)
58 #define CMD_PIPE_CONTROL_LOCAL_PGTT (0 << 2)
59 #define CMD_PIPE_CONTROL_DEPTH_CACHE_FLUSH (1 << 0)
62 struct intel_batchbuffer;
64 #define ALIGN(i, n) (((i) + (n) - 1) & ~((n) - 1))
65 #define MIN(a, b) ((a) < (b) ? (a) : (b))
66 #define MAX(a, b) ((a) > (b) ? (a) : (b))
67 #define ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0]))
73 #define SET_BLOCKED_SIGSET() do { \
75 sigfillset(&bl_mask); \
76 sigdelset(&bl_mask, SIGFPE); \
77 sigdelset(&bl_mask, SIGILL); \
78 sigdelset(&bl_mask, SIGSEGV); \
79 sigdelset(&bl_mask, SIGBUS); \
80 sigdelset(&bl_mask, SIGKILL); \
81 pthread_sigmask(SIG_SETMASK, &bl_mask, &intel->sa_mask); \
84 #define RESTORE_BLOCKED_SIGSET() do { \
85 pthread_sigmask(SIG_SETMASK, &intel->sa_mask, NULL); \
88 #define PPTHREAD_MUTEX_LOCK() do { \
89 SET_BLOCKED_SIGSET(); \
90 pthread_mutex_lock(&intel->ctxmutex); \
93 #define PPTHREAD_MUTEX_UNLOCK() do { \
94 pthread_mutex_unlock(&intel->ctxmutex); \
95 RESTORE_BLOCKED_SIGSET(); \
98 #define WARN_ONCE(...) do { \
99 static int g_once = 1; \
102 printf("WARNING: " __VA_ARGS__); \
106 struct intel_driver_data
115 pthread_mutex_t ctxmutex;
120 unsigned int has_exec2 : 1; /* Flag: has execbuffer2? */
121 unsigned int has_bsd : 1; /* Flag: has bitstream decoder for H.264? */
122 unsigned int has_blt : 1; /* Flag: has BLT unit? */
125 bool intel_driver_init(VADriverContextP ctx);
126 void intel_driver_terminate(VADriverContextP ctx);
128 static INLINE struct intel_driver_data *
129 intel_driver_data(VADriverContextP ctx)
131 return (struct intel_driver_data *)ctx->pDriverData;
143 unsigned int swizzle;
147 #define PCI_CHIP_GM45_GM 0x2A42
148 #define PCI_CHIP_IGD_E_G 0x2E02
149 #define PCI_CHIP_Q45_G 0x2E12
150 #define PCI_CHIP_G45_G 0x2E22
151 #define PCI_CHIP_G41_G 0x2E32
152 #define PCI_CHIP_B43_G 0x2E42
153 #define PCI_CHIP_B43_G1 0x2E92
155 #define PCI_CHIP_IRONLAKE_D_G 0x0042
156 #define PCI_CHIP_IRONLAKE_M_G 0x0046
158 #ifndef PCI_CHIP_SANDYBRIDGE_GT1
159 #define PCI_CHIP_SANDYBRIDGE_GT1 0x0102 /* Desktop */
160 #define PCI_CHIP_SANDYBRIDGE_GT2 0x0112
161 #define PCI_CHIP_SANDYBRIDGE_GT2_PLUS 0x0122
162 #define PCI_CHIP_SANDYBRIDGE_M_GT1 0x0106 /* Mobile */
163 #define PCI_CHIP_SANDYBRIDGE_M_GT2 0x0116
164 #define PCI_CHIP_SANDYBRIDGE_M_GT2_PLUS 0x0126
165 #define PCI_CHIP_SANDYBRIDGE_S_GT 0x010A /* Server */
168 #define PCI_CHIP_IVYBRIDGE_GT1 0x0152 /* Desktop */
169 #define PCI_CHIP_IVYBRIDGE_GT2 0x0162
170 #define PCI_CHIP_IVYBRIDGE_M_GT1 0x0156 /* Mobile */
171 #define PCI_CHIP_IVYBRIDGE_M_GT2 0x0166
172 #define PCI_CHIP_IVYBRIDGE_S_GT1 0x015a /* Server */
173 #define PCI_CHIP_IVYBRIDGE_S_GT2 0x016a
175 #define PCI_CHIP_HASWELL_GT1 0x0402 /* Desktop */
176 #define PCI_CHIP_HASWELL_GT2 0x0412
177 #define PCI_CHIP_HASWELL_GT2_PLUS 0x0422
178 #define PCI_CHIP_HASWELL_M_GT1 0x0406 /* Mobile */
179 #define PCI_CHIP_HASWELL_M_GT2 0x0416
180 #define PCI_CHIP_HASWELL_M_GT2_PLUS 0x0426
181 #define PCI_CHIP_HASWELL_S_GT1 0x040a /* Server */
182 #define PCI_CHIP_HASWELL_S_GT2 0x041a
183 #define PCI_CHIP_HASWELL_S_GT2_PLUS 0x042a
185 #define PCI_CHIP_HASWELL_SDV_GT1 0x0c02 /* Desktop */
186 #define PCI_CHIP_HASWELL_SDV_GT2 0x0c12
187 #define PCI_CHIP_HASWELL_SDV_GT2_PLUS 0x0c22
188 #define PCI_CHIP_HASWELL_SDV_M_GT1 0x0c06 /* Mobile */
189 #define PCI_CHIP_HASWELL_SDV_M_GT2 0x0c16
190 #define PCI_CHIP_HASWELL_SDV_M_GT2_PLUS 0x0c26
191 #define PCI_CHIP_HASWELL_SDV_S_GT1 0x0c0a /* Server */
192 #define PCI_CHIP_HASWELL_SDV_S_GT2 0x0c1a
193 #define PCI_CHIP_HASWELL_SDV_S_GT2_PLUS 0x0c2a
195 #define PCI_CHIP_HASWELL_ULT_GT1 0x0A02 /* Desktop */
196 #define PCI_CHIP_HASWELL_ULT_GT2 0x0A12
197 #define PCI_CHIP_HASWELL_ULT_GT2_PLUS 0x0A22
198 #define PCI_CHIP_HASWELL_ULT_M_GT1 0x0A06 /* Mobile */
199 #define PCI_CHIP_HASWELL_ULT_M_GT2 0x0A16
200 #define PCI_CHIP_HASWELL_ULT_M_GT2_PLUS 0x0A26
201 #define PCI_CHIP_HASWELL_ULT_S_GT1 0x0A0A /* Server */
202 #define PCI_CHIP_HASWELL_ULT_S_GT2 0x0A1A
203 #define PCI_CHIP_HASWELL_ULT_S_GT2_PLUS 0x0A2A
205 #define PCI_CHIP_HASWELL_CRW_GT1 0x0D02 /* Desktop */
206 #define PCI_CHIP_HASWELL_CRW_GT2 0x0D12
207 #define PCI_CHIP_HASWELL_CRW_GT2_PLUS 0x0D22
208 #define PCI_CHIP_HASWELL_CRW_M_GT1 0x0D06 /* Mobile */
209 #define PCI_CHIP_HASWELL_CRW_M_GT2 0x0D16
210 #define PCI_CHIP_HASWELL_CRW_M_GT2_PLUS 0x0D26
211 #define PCI_CHIP_HASWELL_CRW_S_GT1 0x0D0A /* Server */
212 #define PCI_CHIP_HASWELL_CRW_S_GT2 0x0D1A
213 #define PCI_CHIP_HASWELL_CRW_S_GT2_PLUS 0x0D2A
215 #define IS_G45(devid) (devid == PCI_CHIP_IGD_E_G || \
216 devid == PCI_CHIP_Q45_G || \
217 devid == PCI_CHIP_G45_G || \
218 devid == PCI_CHIP_G41_G || \
219 devid == PCI_CHIP_B43_G || \
220 devid == PCI_CHIP_B43_G1)
222 #define IS_GM45(devid) (devid == PCI_CHIP_GM45_GM)
223 #define IS_G4X(devid) (IS_G45(devid) || IS_GM45(devid))
225 #define IS_IRONLAKE_D(devid) (devid == PCI_CHIP_IRONLAKE_D_G)
226 #define IS_IRONLAKE_M(devid) (devid == PCI_CHIP_IRONLAKE_M_G)
227 #define IS_IRONLAKE(devid) (IS_IRONLAKE_D(devid) || IS_IRONLAKE_M(devid))
229 #define IS_SNB_GT1(devid) (devid == PCI_CHIP_SANDYBRIDGE_GT1 || \
230 devid == PCI_CHIP_SANDYBRIDGE_M_GT1 || \
231 devid == PCI_CHIP_SANDYBRIDGE_S_GT)
233 #define IS_SNB_GT2(devid) (devid == PCI_CHIP_SANDYBRIDGE_GT2 || \
234 devid == PCI_CHIP_SANDYBRIDGE_GT2_PLUS || \
235 devid == PCI_CHIP_SANDYBRIDGE_M_GT2 || \
236 devid == PCI_CHIP_SANDYBRIDGE_M_GT2_PLUS)
238 #define IS_GEN6(devid) (IS_SNB_GT1(devid) || \
241 #define IS_IVB_GT1(devid) (devid == PCI_CHIP_IVYBRIDGE_GT1 || \
242 devid == PCI_CHIP_IVYBRIDGE_M_GT1 || \
243 devid == PCI_CHIP_IVYBRIDGE_S_GT1)
245 #define IS_IVB_GT2(devid) (devid == PCI_CHIP_IVYBRIDGE_GT2 || \
246 devid == PCI_CHIP_IVYBRIDGE_M_GT2 || \
247 devid == PCI_CHIP_IVYBRIDGE_S_GT2)
249 #define IS_IVYBRIDGE(devid) (IS_IVB_GT1(devid) || \
252 #define IS_HSW_GT1(devid) (devid == PCI_CHIP_HASWELL_GT1 || \
253 devid == PCI_CHIP_HASWELL_M_GT1 || \
254 devid == PCI_CHIP_HASWELL_S_GT1 || \
255 devid == PCI_CHIP_HASWELL_SDV_GT1 || \
256 devid == PCI_CHIP_HASWELL_SDV_M_GT1 || \
257 devid == PCI_CHIP_HASWELL_SDV_S_GT1 || \
258 devid == PCI_CHIP_HASWELL_CRW_GT1 || \
259 devid == PCI_CHIP_HASWELL_CRW_M_GT1 || \
260 devid == PCI_CHIP_HASWELL_CRW_S_GT1 || \
261 devid == PCI_CHIP_HASWELL_ULT_GT1 || \
262 devid == PCI_CHIP_HASWELL_ULT_M_GT1 || \
263 devid == PCI_CHIP_HASWELL_ULT_S_GT1)
265 #define IS_HSW_GT2(devid) (devid == PCI_CHIP_HASWELL_GT2|| \
266 devid == PCI_CHIP_HASWELL_M_GT2|| \
267 devid == PCI_CHIP_HASWELL_S_GT2|| \
268 devid == PCI_CHIP_HASWELL_SDV_GT2|| \
269 devid == PCI_CHIP_HASWELL_SDV_M_GT2|| \
270 devid == PCI_CHIP_HASWELL_SDV_S_GT2|| \
271 devid == PCI_CHIP_HASWELL_CRW_GT2|| \
272 devid == PCI_CHIP_HASWELL_CRW_M_GT2|| \
273 devid == PCI_CHIP_HASWELL_CRW_S_GT2|| \
274 devid == PCI_CHIP_HASWELL_ULT_GT2|| \
275 devid == PCI_CHIP_HASWELL_ULT_GT2_PLUS|| \
276 devid == PCI_CHIP_HASWELL_ULT_M_GT2|| \
277 devid == PCI_CHIP_HASWELL_ULT_M_GT2_PLUS|| \
278 devid == PCI_CHIP_HASWELL_ULT_S_GT2 || \
279 devid == PCI_CHIP_HASWELL_ULT_S_GT2_PLUS || \
280 devid == PCI_CHIP_HASWELL_GT2_PLUS|| \
281 devid == PCI_CHIP_HASWELL_M_GT2_PLUS || \
282 devid == PCI_CHIP_HASWELL_S_GT2_PLUS || \
283 devid == PCI_CHIP_HASWELL_SDV_GT2_PLUS|| \
284 devid == PCI_CHIP_HASWELL_SDV_M_GT2_PLUS|| \
285 devid == PCI_CHIP_HASWELL_SDV_S_GT2_PLUS|| \
286 devid == PCI_CHIP_HASWELL_CRW_GT2_PLUS|| \
287 devid == PCI_CHIP_HASWELL_CRW_M_GT2_PLUS|| \
288 devid == PCI_CHIP_HASWELL_CRW_S_GT2_PLUS)
290 #define IS_HASWELL(devid) (IS_HSW_GT1(devid) || \
293 #define IS_GEN7(devid) (IS_IVYBRIDGE(devid) || \
296 #ifndef I915_EXEC_VEBOX
297 #define I915_EXEC_VEBOX 4
300 #endif /* _INTEL_DRIVER_H_ */