Rev 4315 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4315 | Serge | 1 | |
2 | #include |
||
3 | #include |
||
4 | |||
5 | |||
6 | //#include "xf86.h" |
||
7 | #include "uxa/intel.h" |
||
8 | #include "i830_reg.h" |
||
9 | #include "i965_reg.h" |
||
10 | |||
11 | |||
12 | #include "brw_defines.h" |
||
13 | #include "brw_structs.h" |
||
14 | |||
15 | |||
16 | #include |
||
17 | #include |
||
18 | |||
19 | |||
20 | #define PictOpSrc 1 |
||
21 | #define PictOpDst 2 |
||
22 | #define PictOpOver 3 |
||
23 | #define PictOpOverReverse 4 |
||
24 | #define PictOpIn 5 |
||
25 | #define PictOpInReverse 6 |
||
26 | #define PictOpOut 7 |
||
27 | #define PictOpOutReverse 8 |
||
28 | #define PictOpAtop 9 |
||
29 | #define PictOpAtopReverse 10 |
||
30 | #define PictOpXor 11 |
||
31 | #define PictOpAdd 12 |
||
32 | #define PictOpSaturate 13 |
||
33 | #define PictOpMaximum 13 |
||
34 | |||
35 | |||
36 | |||
37 | |||
38 | __LOCK_INIT_RECURSIVE(, __uxa_lock); |
||
39 | |||
40 | |||
41 | |||
42 | |||
43 | { |
||
44 | struct list entry; |
||
45 | uint32_t width; |
||
46 | uint32_t height; |
||
47 | void *data; |
||
48 | uint32_t pitch; |
||
49 | drm_intel_bo *bo; |
||
50 | uint32_t bo_size; |
||
51 | uint32_t flags; |
||
52 | }surface_t; |
||
53 | |||
54 | |||
55 | |||
56 | |||
57 | |||
58 | |||
59 | |||
60 | |||
61 | |||
62 | |||
63 | { |
||
64 | return 0; |
||
65 | }; |
||
66 | |||
67 | |||
68 | { |
||
69 | intel_screen_private *intel = intel_get_screen_private(); |
||
70 | |||
71 | |||
72 | intel->vertex_flush(intel); |
||
73 | |||
74 | |||
75 | } |
||
76 | |||
77 | |||
78 | { |
||
79 | struct intel_screen_private *intel = intel_get_screen_private(); |
||
80 | drm_intel_bo *bo; |
||
81 | surface_t *sf; |
||
82 | unsigned int size; |
||
83 | |||
84 | |||
85 | |||
86 | |||
87 | list_for_each_entry(sf, &sf_list, entry) |
||
88 | { |
||
89 | if (sf->bo->handle == handle) |
||
90 | { |
||
91 | bitmap->handle = (uint32_t)sf; |
||
92 | break; |
||
93 | } |
||
94 | } |
||
95 | __lock_release_recursive(__uxa_lock); |
||
96 | |||
97 | |||
98 | return 0; |
||
99 | |||
100 | |||
101 | if(sf == NULL) |
||
102 | goto err_1; |
||
103 | |||
104 | |||
105 | |||
106 | |||
107 | |||
108 | |||
109 | sf->height = bitmap->height; |
||
110 | sf->data = NULL; |
||
111 | sf->pitch = bitmap->pitch; |
||
112 | sf->bo = bo; |
||
113 | sf->bo_size = size; |
||
114 | sf->flags = bitmap->flags; |
||
115 | |||
116 | |||
117 | |||
118 | |||
119 | |||
120 | |||
121 | |||
122 | |||
123 | }; |
||
124 | |||
125 | |||
126 | { |
||
127 | sna_bitmap_from_handle(bitmap, handle); |
||
128 | }; |
||
129 | |||
130 | |||
131 | |||
132 | int w, int h, int src_x, int src_y) |
||
133 | { |
||
134 | // DBG("%s\n", __FUNCTION__); |
||
4348 | Serge | 135 | |
136 | |||
4315 | Serge | 137 | struct intel_pixmap privSrc; |
138 | struct _Picture pictSrc, pictDst; |
||
139 | struct intel_screen_private *intel = intel_get_screen_private(); |
||
140 | |||
141 | |||
142 | |||
143 | |||
144 | |||
145 | |||
146 | get_proc_info(proc_info); |
||
147 | winx = *(uint32_t*)(proc_info+34); |
||
148 | winy = *(uint32_t*)(proc_info+38); |
||
149 | |||
150 | |||
151 | memset(&pixMask, 0, sizeof(pixMask)); |
||
152 | memset(&privSrc, 0, sizeof(pixSrc)); |
||
153 | |||
154 | |||
155 | memset(&pictDst, 0, sizeof(pictDst)); |
||
156 | |||
157 | |||
158 | pixSrc.drawable.width = sf->width; |
||
159 | pixSrc.drawable.height = sf->height; |
||
160 | pixSrc.devKind = sf->pitch; |
||
161 | pixSrc.private = &privSrc; |
||
162 | |||
163 | |||
164 | privSrc.bo = sf->bo; |
||
165 | privSrc.stride = sf->pitch; |
||
166 | privSrc.tiling = I915_TILING_X; |
||
167 | |||
168 | |||
169 | pictSrc.filter = PictFilterNearest; |
||
170 | pictSrc.repeatType = RepeatNone; |
||
171 | |||
172 | |||
173 | pictDst.filter = PictFilterNearest; |
||
174 | pictDst.repeatType = RepeatNone; |
||
175 | |||
176 | |||
177 | |||
178 | |||
179 | &pixSrc, NULL, &fb_pixmap); |
||
180 | |||
181 | |||
182 | dst_x+winx, dst_y+winy, w, h); |
||
4348 | Serge | 183 | |
4315 | Serge | 184 | |
185 | |||
186 | |||
187 | |||
188 | |||
4348 | Serge | 189 | |
190 | |||
4315 | Serge | 191 | }; |
192 | |||
193 | |||
194 | |||
195 | { |
||
196 | struct drm_i915_fb_info fb; |
||
197 | static struct intel_pixmap ipix; |
||
198 | int ret; |
||
199 | |||
200 | |||
201 | |||
202 | |||
203 | if( ret != 0 ) |
||
204 | return ret; |
||
205 | |||
206 | |||
207 | if(intel->front_buffer == NULL) |
||
208 | return -1; |
||
209 | |||
210 | |||
211 | list_init(&ipix.batch); |
||
212 | ipix.stride = fb.pitch; |
||
213 | ipix.tiling = fb.tiling; |
||
214 | ipix.pinned = PIN_SCANOUT; |
||
215 | |||
216 | |||
217 | printf("size %d, offset %d handle %d\n",ipix.bo->size, ipix.bo->offset, ipix.bo->handle); |
||
218 | |||
219 | |||
220 | fb_pixmap.drawable.width = fb.width; |
||
221 | fb_pixmap.drawable.height = fb.height; |
||
222 | fb_pixmap.devKind = fb.pitch; |
||
223 | fb_pixmap.private = &ipix; |
||
224 | |||
225 | |||
226 | } |
||
227 | |||
228 | |||
229 | { |
||
230 | struct drm_i915_fb_info fb; |
||
231 | struct intel_pixmap *ipix; |
||
232 | size_t size; |
||
233 | int ret; |
||
234 | |||
235 | |||
4348 | Serge | 236 | |
237 | |||
4315 | Serge | 238 | if( ret != 0 ) |
239 | return ret; |
||
240 | |||
241 | |||
242 | |||
4348 | Serge | 243 | |
244 | ipix->stride = fb.pitch; |
||
4315 | Serge | 245 | ipix->tiling = fb.tiling; |
246 | |||
247 | |||
248 | fb_pixmap.drawable.height = fb.height; |
||
249 | fb_pixmap.devKind = fb.pitch; |
||
250 | |||
251 | |||
252 | }; |
||
253 | |||
254 | |||
255 | { |
||
256 | static struct pci_device device; |
||
257 | struct intel_screen_private *intel = intel_get_screen_private(); |
||
258 | |||
259 | |||
260 | int caps = 0; |
||
261 | |||
262 | |||
263 | |||
264 | |||
265 | |||
266 | |||
267 | goto done; |
||
268 | |||
269 | |||
270 | io.io_code = SRV_GET_PCI_INFO; |
||
271 | io.input = &device; |
||
272 | io.inp_size = sizeof(device); |
||
273 | io.output = NULL; |
||
274 | io.out_size = 0; |
||
275 | |||
276 | |||
277 | goto err1; |
||
278 | |||
279 | |||
280 | if (intel == NULL) |
||
281 | goto err1; |
||
282 | |||
283 | |||
284 | |||
285 | |||
286 | memset(intel, 0, sizeof(*intel)); |
||
287 | |||
288 | |||
289 | |||
290 | |||
291 | intel->info = intel_detect_chipset(intel->PciInfo); |
||
292 | intel->scrn = service; |
||
293 | |||
294 | |||
295 | if(intel->bufmgr == NULL) |
||
296 | { |
||
297 | printf("Memory manager initialization failed\n"); |
||
298 | goto err1; |
||
299 | }; |
||
300 | |||
301 | |||
4348 | Serge | 302 | |
303 | |||
304 | intel->wa_scratch_bo = |
||
305 | drm_intel_bo_alloc(intel->bufmgr, "wa scratch", |
||
306 | 4096, 4096); |
||
307 | } |
||
308 | |||
309 | |||
4315 | Serge | 310 | goto err1; |
311 | |||
312 | |||
313 | |||
314 | |||
315 | gen4_render_state_init(); |
||
316 | |||
317 | |||
318 | printf("Hardware acceleration initialization failed\n"); |
||
319 | goto err1; |
||
320 | } |
||
321 | |||
322 | |||
323 | |||
324 | |||
325 | |||
326 | |||
327 | // caps = sna_device->render.caps; |
||
328 | |||
329 | |||
330 | __lock_release_recursive(__uxa_lock); |
||
331 | |||
332 | |||
333 | return caps; |
||
334 | } |
||
335 | |||
336 | |||
337 | |||
338 | |||
339 | gen6_context_switch(intel_screen_private *intel, |
||
340 | int new_mode) |
||
341 | { |
||
342 | intel_batch_submit(intel->scrn); |
||
343 | } |
||
344 | |||
345 | |||
346 | gen5_context_switch(intel_screen_private *intel, |
||
347 | int new_mode) |
||
348 | { |
||
349 | /* Ironlake has a limitation that a 3D or Media command can't |
||
350 | * be the first command after a BLT, unless it's |
||
351 | * non-pipelined. Instead of trying to track it and emit a |
||
352 | * command at the right time, we just emit a dummy |
||
353 | * non-pipelined 3D instruction after each blit. |
||
354 | */ |
||
355 | |||
356 | |||
357 | OUT_BATCH(MI_FLUSH | |
||
358 | MI_STATE_INSTRUCTION_CACHE_FLUSH | |
||
359 | MI_INHIBIT_RENDER_CACHE_FLUSH); |
||
360 | } else { |
||
361 | OUT_BATCH(CMD_POLY_STIPPLE_OFFSET << 16); |
||
362 | OUT_BATCH(0); |
||
363 | } |
||
364 | } |
||
365 | |||
366 | |||
367 | gen4_context_switch(intel_screen_private *intel, |
||
368 | int new_mode) |
||
369 | { |
||
370 | if (new_mode == I915_EXEC_BLT) { |
||
371 | OUT_BATCH(MI_FLUSH | |
||
372 | MI_STATE_INSTRUCTION_CACHE_FLUSH | |
||
373 | MI_INHIBIT_RENDER_CACHE_FLUSH); |
||
374 | } |
||
375 | } |
||
376 | |||
377 | |||
378 | intel_limits_init(intel_screen_private *intel) |
||
379 | { |
||
380 | /* Limits are described in the BLT engine chapter under Graphics Data Size |
||
381 | * Limitations, and the descriptions of SURFACE_STATE, 3DSTATE_BUFFER_INFO, |
||
382 | * 3DSTATE_DRAWING_RECTANGLE, 3DSTATE_MAP_INFO, and 3DSTATE_MAP_INFO. |
||
383 | * |
||
384 | * i845 through i965 limits 2D rendering to 65536 lines and pitch of 32768. |
||
385 | * |
||
386 | * i965 limits 3D surface to (2*element size)-aligned offset if un-tiled. |
||
387 | * i965 limits 3D surface to 4kB-aligned offset if tiled. |
||
388 | * i965 limits 3D surfaces to w,h of ?,8192. |
||
389 | * i965 limits 3D surface to pitch of 1B - 128kB. |
||
390 | * i965 limits 3D surface pitch alignment to 1 or 2 times the element size. |
||
391 | * i965 limits 3D surface pitch alignment to 512B if tiled. |
||
392 | * i965 limits 3D destination drawing rect to w,h of 8192,8192. |
||
393 | * |
||
394 | * i915 limits 3D textures to 4B-aligned offset if un-tiled. |
||
395 | * i915 limits 3D textures to ~4kB-aligned offset if tiled. |
||
396 | * i915 limits 3D textures to width,height of 2048,2048. |
||
397 | * i915 limits 3D textures to pitch of 16B - 8kB, in dwords. |
||
398 | * i915 limits 3D destination to ~4kB-aligned offset if tiled. |
||
399 | * i915 limits 3D destination to pitch of 16B - 8kB, in dwords, if un-tiled. |
||
400 | * i915 limits 3D destination to pitch 64B-aligned if used with depth. |
||
401 | * i915 limits 3D destination to pitch of 512B - 8kB, in tiles, if tiled. |
||
402 | * i915 limits 3D destination to POT aligned pitch if tiled. |
||
403 | * i915 limits 3D destination drawing rect to w,h of 2048,2048. |
||
404 | * |
||
405 | * i845 limits 3D textures to 4B-aligned offset if un-tiled. |
||
406 | * i845 limits 3D textures to ~4kB-aligned offset if tiled. |
||
407 | * i845 limits 3D textures to width,height of 2048,2048. |
||
408 | * i845 limits 3D textures to pitch of 4B - 8kB, in dwords. |
||
409 | * i845 limits 3D destination to 4B-aligned offset if un-tiled. |
||
410 | * i845 limits 3D destination to ~4kB-aligned offset if tiled. |
||
411 | * i845 limits 3D destination to pitch of 8B - 8kB, in dwords. |
||
412 | * i845 limits 3D destination drawing rect to w,h of 2048,2048. |
||
413 | * |
||
414 | * For the tiled issues, the only tiled buffer we draw to should be |
||
415 | * the front, which will have an appropriate pitch/offset already set up, |
||
416 | * so UXA doesn't need to worry. |
||
417 | */ |
||
418 | if (INTEL_INFO(intel)->gen >= 040) { |
||
419 | intel->accel_pixmap_offset_alignment = 4 * 2; |
||
420 | intel->accel_max_x = 8192; |
||
421 | intel->accel_max_y = 8192; |
||
422 | } else { |
||
423 | intel->accel_pixmap_offset_alignment = 4; |
||
424 | intel->accel_max_x = 2048; |
||
425 | intel->accel_max_y = 2048; |
||
426 | } |
||
427 | } |
||
428 | |||
429 | |||
430 | |||
431 | { |
||
432 | intel_screen_private *intel = intel_get_screen_private(); |
||
433 | |||
434 | |||
435 | |||
436 | |||
437 | intel->vertex_count = 0; |
||
438 | intel->vertex_offset = 0; |
||
439 | intel->vertex_used = 0; |
||
440 | intel->floats_per_vertex = 0; |
||
441 | intel->last_floats_per_vertex = 0; |
||
442 | intel->vertex_bo = NULL; |
||
443 | intel->surface_used = 0; |
||
444 | intel->surface_reloc = 0; |
||
445 | |||
446 | |||
447 | intel->uxa_driver->check_composite = i965_check_composite; |
||
448 | intel->uxa_driver->check_composite_texture = i965_check_composite_texture; |
||
449 | intel->uxa_driver->prepare_composite = i965_prepare_composite; |
||
450 | intel->uxa_driver->composite = i965_composite; |
||
451 | intel->uxa_driver->done_composite = i830_done_composite; |
||
452 | */ |
||
453 | intel->vertex_flush = i965_vertex_flush; |
||
454 | intel->batch_flush = i965_batch_flush; |
||
455 | intel->batch_commit_notify = i965_batch_commit_notify; |
||
456 | |||
457 | |||
458 | intel->context_switch = gen4_context_switch; |
||
459 | } else if (IS_GEN5(intel)) { |
||
460 | intel->context_switch = gen5_context_switch; |
||
461 | } else { |
||
462 | intel->context_switch = gen6_context_switch; |
||
463 | } |
||
464 | |||
465 | |||
466 | } |
||
467 | |||
468 | |||
469 | |||
470 | .gen = -1, |
||
471 | }; |
||
472 | |||
473 | |||
474 | .gen = 030, |
||
475 | }; |
||
476 | static const struct intel_device_info intel_i945_info = { |
||
477 | .gen = 031, |
||
478 | }; |
||
479 | |||
480 | |||
481 | .gen = 033, |
||
482 | }; |
||
483 | |||
484 | |||
485 | .gen = 040, |
||
486 | }; |
||
487 | |||
488 | |||
489 | .gen = 045, |
||
490 | }; |
||
491 | |||
492 | |||
493 | .gen = 050, |
||
494 | }; |
||
495 | |||
496 | |||
497 | .gen = 060, |
||
498 | }; |
||
499 | |||
500 | |||
501 | .gen = 070, |
||
502 | }; |
||
503 | |||
504 | |||
505 | .gen = 071, |
||
506 | }; |
||
507 | |||
508 | |||
509 | .gen = 075, |
||
510 | }; |
||
511 | |||
512 | |||
513 | { 0x8086, (d), PCI_MATCH_ANY, PCI_MATCH_ANY, 0x3 << 16, 0xff << 16, (intptr_t)(i) } |
||
514 | |||
515 | |||
516 | |||
517 | |||
518 | |||
519 | INTEL_I915GM_IDS(&intel_i915_info), |
||
520 | INTEL_I945G_IDS(&intel_i945_info), |
||
521 | INTEL_I945GM_IDS(&intel_i945_info), |
||
522 | |||
523 | |||
524 | INTEL_PINEVIEW_IDS(&intel_g33_info), |
||
525 | |||
526 | |||
527 | INTEL_I965GM_IDS(&intel_i965_info), |
||
528 | |||
529 | |||
530 | INTEL_GM45_IDS(&intel_g4x_info), |
||
531 | |||
532 | |||
533 | INTEL_IRONLAKE_M_IDS(&intel_ironlake_info), |
||
534 | |||
535 | |||
536 | INTEL_SNB_M_IDS(&intel_sandybridge_info), |
||
537 | |||
538 | |||
539 | INTEL_IVB_M_IDS(&intel_ivybridge_info), |
||
540 | |||
541 | |||
542 | INTEL_HSW_M_IDS(&intel_haswell_info), |
||
543 | |||
544 | |||
545 | INTEL_VLV_M_IDS(&intel_valleyview_info), |
||
546 | |||
547 | |||
548 | |||
549 | |||
550 | }; |
||
551 | |||
552 | |||
553 | { |
||
554 | while(list->device_id) |
||
555 | { |
||
556 | if(dev==list->device_id) |
||
557 | return list; |
||
558 | list++; |
||
559 | } |
||
560 | return NULL; |
||
561 | } |
||
562 | |||
563 | |||
564 | |||
565 | intel_detect_chipset(struct pci_device *pci) |
||
566 | { |
||
567 | const struct pci_id_match *ent = NULL; |
||
568 | |||
569 | |||
570 | |||
571 | |||
572 | return (const struct intel_device_info*)ent->match_data; |
||
573 | else |
||
574 | return &intel_generic_info; |
||
575 | }><>><>><> |
||
576 |