Rev 3280 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3280 | Rev 3291 | ||
---|---|---|---|
Line 8... | Line 8... | ||
8 | #include |
8 | #include |
Line 9... | Line 9... | ||
9 | 9 | ||
10 | static struct sna_fb sna_fb; |
10 | static struct sna_fb sna_fb; |
Line -... | Line 11... | ||
- | 11 | static struct kgem_bo *mask_bo; |
|
- | 12 | ||
- | 13 | static int mask_width, mask_height; |
|
- | 14 | ||
- | 15 | static inline void delay(uint32_t time) |
|
- | 16 | { |
|
- | 17 | __asm__ __volatile__( |
|
- | 18 | "int $0x40" |
|
- | 19 | ::"a"(5), "b"(time) |
|
- | 20 | :"memory"); |
|
11 | static struct kgem_bo *mask_bo; |
21 | }; |
12 | 22 | ||
13 | typedef struct __attribute__((packed)) |
23 | typedef struct __attribute__((packed)) |
14 | { |
24 | { |
15 | unsigned handle; |
25 | unsigned handle; |
Line 94... | Line 104... | ||
94 | // pthread_mutex_init(&sna->render.lock, NULL); |
104 | // pthread_mutex_init(&sna->render.lock, NULL); |
95 | // pthread_cond_init(&sna->render.wait, NULL); |
105 | // pthread_cond_init(&sna->render.wait, NULL); |
96 | sna->render.active = 0; |
106 | sna->render.active = 0; |
97 | } |
107 | } |
Line 98... | Line 108... | ||
98 | 108 | ||
99 | bool sna_accel_init(struct sna *sna) |
109 | int sna_accel_init(struct sna *sna) |
100 | { |
110 | { |
Line 101... | Line 111... | ||
101 | const char *backend; |
111 | const char *backend; |
102 | 112 | ||
Line 120... | Line 130... | ||
120 | if (gen6_render_init(sna)) |
130 | if (gen6_render_init(sna)) |
121 | backend = "SandyBridge"; |
131 | backend = "SandyBridge"; |
122 | } else if (sna->info->gen >= 050) { |
132 | } else if (sna->info->gen >= 050) { |
123 | if (gen5_render_init(sna)) |
133 | if (gen5_render_init(sna)) |
124 | backend = "Ironlake"; |
134 | backend = "Ironlake"; |
125 | /* } else if (sna->info->gen >= 040) { |
135 | } else if (sna->info->gen >= 040) { |
126 | if (gen4_render_init(sna)) |
136 | if (gen4_render_init(sna)) |
127 | backend = "Broadwater/Crestline"; |
137 | backend = "Broadwater/Crestline"; |
128 | } else if (sna->info->gen >= 030) { |
138 | /* } else if (sna->info->gen >= 030) { |
129 | if (gen3_render_init(sna)) |
139 | if (gen3_render_init(sna)) |
130 | backend = "gen3"; |
- | |
131 | } else if (sna->info->gen >= 020) { |
- | |
132 | if (gen2_render_init(sna)) |
- | |
133 | backend = "gen2"; */ |
140 | backend = "gen3"; */ |
134 | } |
141 | } |
Line 135... | Line 142... | ||
135 | 142 | ||
136 | DBG(("%s(backend=%s, prefer_gpu=%x)\n", |
143 | DBG(("%s(backend=%s, prefer_gpu=%x)\n", |
Line 154... | Line 161... | ||
154 | static struct pci_device device; |
161 | static struct pci_device device; |
155 | struct sna *sna; |
162 | struct sna *sna; |
Line 156... | Line 163... | ||
156 | 163 | ||
Line 157... | Line 164... | ||
157 | DBG(("%s\n", __FUNCTION__)); |
164 | DBG(("%s\n", __FUNCTION__)); |
158 | 165 | ||
159 | sna = malloc(sizeof(struct sna)); |
166 | sna = malloc(sizeof(*sna)); |
Line -... | Line 167... | ||
- | 167 | if (sna == NULL) |
|
- | 168 | return 0; |
|
160 | if (sna == NULL) |
169 | |
161 | return false; |
170 | memset(sna, 0, sizeof(*sna)); |
162 | 171 | ||
163 | io.handle = service; |
172 | io.handle = service; |
164 | io.io_code = SRV_GET_PCI_INFO; |
173 | io.io_code = SRV_GET_PCI_INFO; |
165 | io.input = &device; |
174 | io.input = &device; |
Line 166... | Line 175... | ||
166 | io.inp_size = sizeof(device); |
175 | io.inp_size = sizeof(device); |
- | 176 | io.output = NULL; |
|
- | 177 | io.out_size = 0; |
|
167 | io.output = NULL; |
178 | |
- | 179 | if (call_service(&io)!=0) |
|
168 | io.out_size = 0; |
180 | { |
169 | 181 | free(sna); |
|
Line 170... | Line 182... | ||
170 | if (call_service(&io)!=0) |
182 | return 0; |
Line 171... | Line 183... | ||
171 | return false; |
183 | }; |
- | 184 | ||
- | 185 | sna->PciInfo = &device; |
|
172 | 186 | ||
173 | sna->PciInfo = &device; |
187 | sna->info = intel_detect_chipset(sna->PciInfo); |
174 | 188 | ||
175 | sna->info = intel_detect_chipset(sna->PciInfo); |
189 | kgem_init(&sna->kgem, service, sna->PciInfo, sna->info->gen); |
176 | 190 | ||
Line 200... | Line 214... | ||
200 | /* Default fail-safe value of 75 Hz */ |
214 | /* Default fail-safe value of 75 Hz */ |
201 | // sna->vblank_interval = 1000 * 1000 * 1000 / 75; |
215 | // sna->vblank_interval = 1000 * 1000 * 1000 / 75; |
Line 202... | Line 216... | ||
202 | 216 | ||
Line 203... | Line 217... | ||
203 | sna->flags = 0; |
217 | sna->flags = 0; |
- | 218 | ||
- | 219 | sna_accel_init(sna); |
|
- | 220 | ||
- | 221 | delay(10); |
|
- | 222 | ||
- | 223 | return sna->render.caps; |
|
- | 224 | } |
|
- | 225 | ||
- | 226 | void sna_fini() |
|
- | 227 | { |
|
- | 228 | if( sna_device ) |
|
- | 229 | { |
|
- | 230 | sna_device->render.fini(sna_device); |
|
- | 231 | kgem_bo_destroy(&sna_device->kgem, mask_bo); |
|
- | 232 | kgem_close_batches(&sna_device->kgem); |
|
204 | 233 | kgem_cleanup_cache(&sna_device->kgem); |
|
Line 205... | Line 234... | ||
205 | return sna_accel_init(sna); |
234 | }; |
Line 206... | Line 235... | ||
206 | } |
235 | } |
Line 360... | Line 389... | ||
360 | src.drawable.height = src_bitmap->height; |
389 | src.drawable.height = src_bitmap->height; |
Line 361... | Line 390... | ||
361 | 390 | ||
362 | dst.drawable.bitsPerPixel = 32; |
391 | dst.drawable.bitsPerPixel = 32; |
363 | dst.drawable.width = sna_fb.width; |
392 | dst.drawable.width = sna_fb.width; |
364 | dst.drawable.height = sna_fb.height; |
393 | dst.drawable.height = sna_fb.height; |
365 | 394 | ||
Line 366... | Line 395... | ||
366 | memset(©, 0, sizeof(copy)); |
395 | memset(©, 0, sizeof(copy)); |
Line 367... | Line 396... | ||
367 | 396 | ||
368 | src_bo = (struct kgem_bo*)src_bitmap->handle; |
397 | src_bo = (struct kgem_bo*)src_bitmap->handle; |
369 | 398 | ||
370 | if( sna_device->render.copy(sna_device, GXcopy, |
399 | if( sna_device->render.copy(sna_device, GXcopy, |
371 | &src, src_bo, |
400 | &src, src_bo, |
372 | &dst, sna_fb.fb_bo, ©) ) |
401 | &dst, sna_fb.fb_bo, ©) ) |
373 | { |
402 | { |
Line 374... | Line 403... | ||
374 | copy.blt(sna_device, ©, src_x, src_y, w, h, winx+dst_x, winy+dst_y); |
403 | copy.blt(sna_device, ©, src_x, src_y, w, h, winx+dst_x, winy+dst_y); |
375 | copy.done(sna_device, ©); |
404 | copy.done(sna_device, ©); |
376 | } |
405 | } |
377 | 406 | ||
378 | kgem_submit(&sna_device->kgem); |
407 | kgem_submit(&sna_device->kgem); |
379 | 408 | ||
Line 380... | Line 409... | ||
380 | // __asm__ __volatile__("int3"); |
409 | // __asm__ __volatile__("int3"); |
381 | 410 | ||
382 | }; |
411 | }; |
383 | #endif |
412 | #endif |
384 | 413 | ||
385 | 414 | ||
386 | int sna_create_bitmap(bitmap_t *bitmap) |
415 | int sna_create_bitmap(bitmap_t *bitmap) |
387 | { |
416 | { |
388 | struct kgem_bo *bo; |
417 | struct kgem_bo *bo; |
Line 389... | Line 418... | ||
389 | 418 | ||
390 | bo = kgem_create_2d(&sna_device->kgem, bitmap->width, bitmap->height, |
419 | bo = kgem_create_2d(&sna_device->kgem, bitmap->width, bitmap->height, |
Line 405... | Line 434... | ||
405 | 434 | ||
406 | err_2: |
435 | err_2: |
Line 407... | Line 436... | ||
407 | kgem_bo_destroy(&sna_device->kgem, bo); |
436 | kgem_bo_destroy(&sna_device->kgem, bo); |
408 | 437 | ||
Line 409... | Line 438... | ||
409 | err_1: |
438 | err_1: |
Line -... | Line 439... | ||
- | 439 | return -1; |
|
- | 440 | ||
- | 441 | }; |
|
- | 442 | ||
- | 443 | void sna_destroy_bitmap(bitmap_t *bitmap) |
|
- | 444 | { |
|
- | 445 | struct kgem_bo *bo; |
|
- | 446 | ||
- | 447 | bo = (struct kgem_bo *)bitmap->handle; |
|
- | 448 | ||
410 | return -1; |
449 | kgem_bo_destroy(&sna_device->kgem, bo); |
411 | 450 | ||
412 | }; |
451 | }; |
Line 413... | Line 452... | ||
413 | 452 | ||
Line 422... | Line 461... | ||
422 | }; |
461 | }; |
Line 423... | Line 462... | ||
423 | 462 | ||
424 | int sna_create_mask() |
463 | int sna_create_mask() |
425 | { |
464 | { |
426 | struct kgem_bo *bo; |
- | |
427 | char proc_info[1024]; |
465 | struct kgem_bo *bo; |
428 | int width, height; |
466 | int width, height; |
Line 429... | Line -... | ||
429 | int i; |
- | |
430 | - | ||
431 | get_proc_info(proc_info); |
467 | int i; |
432 | - | ||
Line 433... | Line -... | ||
433 | width = *(uint32_t*)(proc_info+42)+1; |
- | |
434 | height = *(uint32_t*)(proc_info+46)+1; |
- | |
435 | 468 | ||
436 | printf("%s width %d height %d\n", __FUNCTION__, width, height); |
469 | printf("%s width %d height %d\n", __FUNCTION__, sna_fb.width, sna_fb.height); |
Line 437... | Line 470... | ||
437 | 470 | ||
438 | bo = kgem_create_2d(&sna_device->kgem, width, height, |
471 | bo = kgem_create_2d(&sna_device->kgem, sna_fb.width, sna_fb.height, |
Line 445... | Line 478... | ||
445 | if(map == NULL) |
478 | if(map == NULL) |
446 | goto err_2; |
479 | goto err_2; |
Line 447... | Line 480... | ||
447 | 480 | ||
Line 448... | Line 481... | ||
448 | memset(map, 0, bo->pitch * height); |
481 | memset(map, 0, bo->pitch * height); |
- | 482 | ||
- | 483 | mask_bo = bo; |
|
449 | 484 | mask_width = width; |
|
450 | mask_bo = bo; |
485 | mask_height = height; |
Line 451... | Line 486... | ||
451 | 486 | ||
452 | return 0; |
487 | return 0; |
Line 458... | Line 493... | ||
458 | return -1; |
493 | return -1; |
Line 459... | Line 494... | ||
459 | 494 | ||
Line 460... | Line 495... | ||
460 | }; |
495 | }; |
461 | 496 | ||
462 | 497 | ||
463 | bool |
498 | bool |
464 | gen6_composite(struct sna *sna, |
499 | gen6_composite(struct sna *sna, |
465 | uint8_t op, |
500 | uint8_t op, |
466 | PixmapPtr src, struct kgem_bo *src_bo, |
501 | PixmapPtr src, struct kgem_bo *src_bo, |
467 | PixmapPtr mask,struct kgem_bo *mask_bo, |
502 | PixmapPtr mask,struct kgem_bo *mask_bo, |
468 | PixmapPtr dst, struct kgem_bo *dst_bo, |
503 | PixmapPtr dst, struct kgem_bo *dst_bo, |
469 | int32_t src_x, int32_t src_y, |
504 | int32_t src_x, int32_t src_y, |
470 | int32_t msk_x, int32_t msk_y, |
505 | int32_t msk_x, int32_t msk_y, |
Line 471... | Line 506... | ||
471 | int32_t dst_x, int32_t dst_y, |
506 | int32_t dst_x, int32_t dst_y, |
Line 472... | Line 507... | ||
472 | int32_t width, int32_t height, |
507 | int32_t width, int32_t height, |
Line 502... | Line 537... | ||
502 | winx = *(uint32_t*)(proc_info+34); |
537 | winx = *(uint32_t*)(proc_info+34); |
503 | winy = *(uint32_t*)(proc_info+38); |
538 | winy = *(uint32_t*)(proc_info+38); |
504 | winw = *(uint32_t*)(proc_info+42)+1; |
539 | winw = *(uint32_t*)(proc_info+42)+1; |
505 | winh = *(uint32_t*)(proc_info+46)+1; |
540 | winh = *(uint32_t*)(proc_info+46)+1; |
Line -... | Line 541... | ||
- | 541 | ||
- | 542 | VG_CLEAR(update); |
|
- | 543 | update.handle = mask_bo->handle; |
|
- | 544 | // update.bo_size = __kgem_bo_size(mask_bo); |
|
- | 545 | // update.bo_pitch = mask_bo->pitch; |
|
- | 546 | update.bo_map = (__u32)MAP(mask_bo->map); |
|
- | 547 | drmIoctl(sna_device->kgem.fd, SRV_MASK_UPDATE, &update); |
|
- | 548 | mask_bo->pitch = update.bo_pitch; |
|
506 | 549 | ||
507 | memset(&src, 0, sizeof(src)); |
550 | memset(&src, 0, sizeof(src)); |
508 | memset(&dst, 0, sizeof(dst)); |
551 | memset(&dst, 0, sizeof(dst)); |
Line 509... | Line 552... | ||
509 | memset(&mask, 0, sizeof(dst)); |
552 | memset(&mask, 0, sizeof(dst)); |
Line 515... | Line 558... | ||
515 | dst.drawable.bitsPerPixel = 32; |
558 | dst.drawable.bitsPerPixel = 32; |
516 | dst.drawable.width = sna_fb.width; |
559 | dst.drawable.width = sna_fb.width; |
517 | dst.drawable.height = sna_fb.height; |
560 | dst.drawable.height = sna_fb.height; |
Line 518... | Line 561... | ||
518 | 561 | ||
519 | mask.drawable.bitsPerPixel = 8; |
562 | mask.drawable.bitsPerPixel = 8; |
520 | mask.drawable.width = winw; |
563 | mask.drawable.width = update.width; |
Line 521... | Line 564... | ||
521 | mask.drawable.height = winh; |
564 | mask.drawable.height = update.height; |
Line 522... | Line 565... | ||
522 | 565 | ||
Line 523... | Line 566... | ||
523 | memset(&composite, 0, sizeof(composite)); |
566 | memset(&composite, 0, sizeof(composite)); |
524 | 567 | ||
525 | src_bo = (struct kgem_bo*)src_bitmap->handle; |
568 | src_bo = (struct kgem_bo*)src_bitmap->handle; |
526 | 569 | ||
527 | 570 | ||
528 | if( sna_device->render.blit_tex(sna_device, PictOpSrc, |
571 | if( sna_device->render.blit_tex(sna_device, PictOpSrc, |
529 | &src, src_bo, |
572 | &src, src_bo, |
530 | &mask, mask_bo, |
573 | &mask, mask_bo, |
531 | &dst, sna_fb.fb_bo, |
574 | &dst, sna_fb.fb_bo, |
532 | src_x, src_y, |
575 | src_x, src_y, |
533 | dst_x, dst_y, |
576 | dst_x, dst_y, |
Line 534... | Line 577... | ||
534 | winx+dst_x, winy+dst_y, |
577 | winx+dst_x, winy+dst_y, |
535 | w, h, |
578 | w, h, |
536 | &composite) ) |
579 | &composite) ) |
537 | { |
580 | { |
538 | struct sna_composite_rectangles r; |
581 | struct sna_composite_rectangles r; |
539 | 582 | ||
540 | r.src.x = src_x; |
583 | r.src.x = src_x; |
541 | r.src.y = src_y; |
584 | r.src.y = src_y; |
Line 542... | Line 585... | ||
542 | r.mask.x = dst_x; |
585 | r.mask.x = dst_x; |
543 | r.mask.y = dst_y; |
586 | r.mask.y = dst_y; |
544 | r.dst.x = winx+dst_x; |
587 | r.dst.x = winx+dst_x; |
Line 545... | Line -... | ||
545 | r.dst.y = winy+dst_y; |
- | |
546 | r.width = w; |
- | |
547 | r.height = h; |
- | |
548 | - | ||
549 | composite.blt(sna_device, &composite, &r); |
- | |
550 | composite.done(sna_device, &composite); |
- | |
551 | }; |
- | |
552 | 588 | r.dst.y = winy+dst_y; |
|
Line 553... | Line 589... | ||
553 | VG_CLEAR(update); |
589 | r.width = w; |
554 | update.handle = mask_bo->handle; |
590 | r.height = h; |