Subversion Repositories Kolibri OS

Rev

Rev 4368 | Rev 4374 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4368 Rev 4372
Line 54... Line 54...
54
    int t;
54
    int t;
55
    int r;
55
    int r;
56
    int b;
56
    int b;
57
} rect_t;
57
} rect_t;
Line -... Line 58...
-
 
58
 
-
 
59
struct pix_driver
-
 
60
{
-
 
61
    char *name;
-
 
62
 
-
 
63
    int (*create_bitmap)(bitmap_t * bitmap);
-
 
64
    int (*destroy_bitmap)(bitmap_t * bitmap);
-
 
65
    int (*lock_bitmap)(bitmap_t * bitmap);
-
 
66
    int (*blit)(bitmap_t * bitmap, bool scale, int dst_x, int dst_y,
-
 
67
                int w, int h, int src_x, int src_y);
-
 
68
    int (*resize_bitmap)(bitmap_t * bitmap);
-
 
69
    void (*fini)(void);
-
 
70
};
-
 
71
 
58
 
72
 
59
static struct sna_fb sna_fb;
73
static struct sna_fb sna_fb;
Line 60... Line 74...
60
static int    tls_mask;
74
static int    tls_mask;
Line 208... Line 222...
208
    sna_device = sna;
222
    sna_device = sna;
Line 209... Line 223...
209
 
223
 
210
    return kgem_init_fb(&sna->kgem, &sna_fb);
224
    return kgem_init_fb(&sna->kgem, &sna_fb);
Line 211... Line -...
211
}
-
 
212
 
-
 
213
int sna_init(uint32_t service)
-
 
214
{
-
 
215
    ioctl_t   io;
-
 
216
    int caps = 0;
-
 
217
 
-
 
218
    static struct pci_device device;
-
 
219
    struct sna *sna;
-
 
220
 
-
 
221
    DBG(("%s\n", __FUNCTION__));
-
 
222
 
-
 
223
    __lock_acquire_recursive(__sna_lock);
-
 
224
 
-
 
225
    if(sna_device)
-
 
226
        goto done;
-
 
227
 
-
 
228
    io.handle   = service;
-
 
229
    io.io_code  = SRV_GET_PCI_INFO;
-
 
230
    io.input    = &device;
-
 
231
    io.inp_size = sizeof(device);
-
 
232
    io.output   = NULL;
-
 
233
    io.out_size = 0;
-
 
234
 
-
 
235
    if (call_service(&io)!=0)
-
 
236
        goto err1;
-
 
237
 
-
 
238
    sna = malloc(sizeof(*sna));
-
 
239
    if (sna == NULL)
-
 
240
        goto err1;
-
 
241
 
-
 
242
    memset(sna, 0, sizeof(*sna));
-
 
243
 
-
 
244
    sna->cpu_features = sna_cpu_detect();
-
 
245
 
-
 
246
    sna->PciInfo = &device;
-
 
247
  	sna->info = intel_detect_chipset(sna->PciInfo);
-
 
248
    sna->scrn = service;
-
 
249
 
-
 
250
    kgem_init(&sna->kgem, service, sna->PciInfo, sna->info->gen);
-
 
251
 
-
 
252
 
-
 
253
    /* Disable tiling by default */
-
 
254
    sna->tiling = 0;
-
 
255
 
-
 
256
    /* Default fail-safe value of 75 Hz */
-
 
257
//    sna->vblank_interval = 1000 * 1000 * 1000 / 75;
-
 
258
 
-
 
259
    sna->flags = 0;
-
 
260
 
-
 
261
    sna_accel_init(sna);
-
 
262
 
-
 
263
    tls_mask = tls_alloc();
-
 
264
 
-
 
265
//    printf("tls mask %x\n", tls_mask);
-
 
266
 
-
 
267
done:
-
 
268
    caps = sna_device->render.caps;
-
 
269
 
-
 
270
err1:
-
 
271
    __lock_release_recursive(__sna_lock);
-
 
272
 
-
 
273
    return caps;
-
 
274
}
-
 
275
 
-
 
276
void sna_fini()
-
 
277
{
-
 
278
    ENTER();
-
 
279
 
-
 
280
    if( sna_device )
-
 
281
    {
-
 
282
        struct kgem_bo *mask;
-
 
283
 
-
 
284
        __lock_acquire_recursive(__sna_lock);
-
 
285
 
-
 
286
        mask = tls_get(tls_mask);
-
 
287
 
-
 
288
        sna_device->render.fini(sna_device);
-
 
289
        if(mask)
-
 
290
            kgem_bo_destroy(&sna_device->kgem, mask);
-
 
291
//        kgem_close_batches(&sna_device->kgem);
-
 
292
   	    kgem_cleanup_cache(&sna_device->kgem);
-
 
293
 
-
 
294
   	    sna_device = NULL;
-
 
295
        __lock_release_recursive(__sna_lock);
-
 
296
    };
-
 
Line 297... Line 225...
297
    LEAVE();
225
}
Line 298... Line 226...
298
}
226
 
299
 
227
 
Line 487... Line 415...
487
    uint32_t        flags;
415
    uint32_t        flags;
488
}surface_t;
416
}surface_t;
Line -... Line 417...
-
 
417
 
-
 
418
 
-
 
419
 
-
 
420
 
-
 
421
#define MI_LOAD_REGISTER_IMM		(0x22<<23)
-
 
422
#define MI_WAIT_FOR_EVENT			(0x03<<23)
-
 
423
 
-
 
424
static bool sna_emit_wait_for_scanline_gen6(struct sna *sna,
-
 
425
                        rect_t *crtc,
-
 
426
					    int pipe, int y1, int y2,
-
 
427
					    bool full_height)
-
 
428
{
-
 
429
	uint32_t *b;
-
 
430
	uint32_t event;
-
 
431
 
-
 
432
//	if (!sna->kgem.has_secure_batches)
-
 
433
//		return false;
-
 
434
 
-
 
435
	assert(y1 >= 0);
-
 
436
	assert(y2 > y1);
-
 
437
	assert(sna->kgem.mode == KGEM_RENDER);
-
 
438
 
-
 
439
	/* Always program one less than the desired value */
-
 
440
	if (--y1 < 0)
-
 
441
		y1 = crtc->b;
-
 
442
	y2--;
-
 
443
 
-
 
444
	/* The scanline granularity is 3 bits */
-
 
445
	y1 &= ~7;
-
 
446
	y2 &= ~7;
-
 
447
	if (y2 == y1)
-
 
448
		return false;
-
 
449
 
-
 
450
	event = 1 << (3*full_height + pipe*8);
-
 
451
 
-
 
452
	b = kgem_get_batch(&sna->kgem);
-
 
453
	sna->kgem.nbatch += 10;
-
 
454
 
-
 
455
	b[0] = MI_LOAD_REGISTER_IMM | 1;
-
 
456
	b[1] = 0x44050; /* DERRMR */
-
 
457
	b[2] = ~event;
-
 
458
	b[3] = MI_LOAD_REGISTER_IMM | 1;
-
 
459
	b[4] = 0x4f100; /* magic */
-
 
460
	b[5] = (1 << 31) | (1 << 30) | pipe << 29 | (y1 << 16) | y2;
-
 
461
	b[6] = MI_WAIT_FOR_EVENT | event;
-
 
462
	b[7] = MI_LOAD_REGISTER_IMM | 1;
-
 
463
	b[8] = 0x44050; /* DERRMR */
-
 
464
	b[9] = ~0;
-
 
465
 
-
 
466
	sna->kgem.batch_flags |= I915_EXEC_SECURE;
-
 
467
 
-
 
468
	return true;
-
 
469
}
-
 
470
 
-
 
471
bool
-
 
472
sna_wait_for_scanline(struct sna *sna,
-
 
473
		      rect_t *crtc,
-
 
474
		      rect_t *clip)
-
 
475
{
-
 
476
	bool full_height;
-
 
477
	int y1, y2, pipe;
-
 
478
	bool ret;
-
 
479
 
-
 
480
//	if (sna->flags & SNA_NO_VSYNC)
-
 
481
//		return false;
-
 
482
 
-
 
483
	/*
-
 
484
	 * Make sure we don't wait for a scanline that will
-
 
485
	 * never occur
-
 
486
	 */
-
 
487
	y1 = clip->t - crtc->t;
-
 
488
	if (y1 < 0)
-
 
489
		y1 = 0;
-
 
490
	y2 = clip->b - crtc->t;
-
 
491
	if (y2 > crtc->b - crtc->t)
-
 
492
		y2 = crtc->b - crtc->t;
-
 
493
//	DBG(("%s: clipped range = %d, %d\n", __FUNCTION__, y1, y2));
-
 
494
//	printf("%s: clipped range = %d, %d\n", __FUNCTION__, y1, y2);
-
 
495
 
-
 
496
	if (y2 <= y1 + 4)
-
 
497
		return false;
-
 
498
 
-
 
499
	full_height = y1 == 0 && y2 == crtc->b - crtc->t;
-
 
500
 
-
 
501
	pipe = 0;
-
 
502
	DBG(("%s: pipe=%d, y1=%d, y2=%d, full_height?=%d\n",
-
 
503
	     __FUNCTION__, pipe, y1, y2, full_height));
-
 
504
 
-
 
505
	if (sna->kgem.gen >= 0100)
-
 
506
		ret = false;
-
 
507
//	else if (sna->kgem.gen >= 075)
-
 
508
//		ret = sna_emit_wait_for_scanline_hsw(sna, crtc, pipe, y1, y2, full_height);
-
 
509
//	else if (sna->kgem.gen >= 070)
-
 
510
//		ret = sna_emit_wait_for_scanline_ivb(sna, crtc, pipe, y1, y2, full_height);
-
 
511
	else if (sna->kgem.gen >= 060)
-
 
512
		ret =sna_emit_wait_for_scanline_gen6(sna, crtc, pipe, y1, y2, full_height);
-
 
513
//	else if (sna->kgem.gen >= 040)
-
 
514
//		ret = sna_emit_wait_for_scanline_gen4(sna, crtc, pipe, y1, y2, full_height);
-
 
515
 
-
 
516
	return ret;
-
 
517
}
-
 
518
 
-
 
519
 
-
 
520
 
-
 
521
 
-
 
522
 
-
 
523
 
-
 
524
 
-
 
525
 
-
 
526
 
-
 
527
static const struct intel_device_info intel_generic_info = {
-
 
528
	.gen = -1,
-
 
529
};
-
 
530
 
-
 
531
static const struct intel_device_info intel_i915_info = {
-
 
532
	.gen = 030,
-
 
533
};
-
 
534
static const struct intel_device_info intel_i945_info = {
-
 
535
	.gen = 031,
-
 
536
};
-
 
537
 
-
 
538
static const struct intel_device_info intel_g33_info = {
-
 
539
	.gen = 033,
-
 
540
};
-
 
541
 
-
 
542
static const struct intel_device_info intel_i965_info = {
-
 
543
	.gen = 040,
-
 
544
};
-
 
545
 
-
 
546
static const struct intel_device_info intel_g4x_info = {
-
 
547
	.gen = 045,
-
 
548
};
-
 
549
 
-
 
550
static const struct intel_device_info intel_ironlake_info = {
-
 
551
	.gen = 050,
-
 
552
};
-
 
553
 
-
 
554
static const struct intel_device_info intel_sandybridge_info = {
-
 
555
	.gen = 060,
-
 
556
};
-
 
557
 
-
 
558
static const struct intel_device_info intel_ivybridge_info = {
-
 
559
	.gen = 070,
-
 
560
};
-
 
561
 
-
 
562
static const struct intel_device_info intel_valleyview_info = {
-
 
563
	.gen = 071,
-
 
564
};
-
 
565
 
-
 
566
static const struct intel_device_info intel_haswell_info = {
-
 
567
	.gen = 075,
-
 
568
};
-
 
569
 
-
 
570
#define INTEL_DEVICE_MATCH(d,i) \
-
 
571
    { 0x8086, (d), PCI_MATCH_ANY, PCI_MATCH_ANY, 0x3 << 16, 0xff << 16, (intptr_t)(i) }
-
 
572
 
-
 
573
 
-
 
574
static const struct pci_id_match intel_device_match[] = {
-
 
575
 
-
 
576
	INTEL_I915G_IDS(&intel_i915_info),
-
 
577
	INTEL_I915GM_IDS(&intel_i915_info),
-
 
578
	INTEL_I945G_IDS(&intel_i945_info),
-
 
579
	INTEL_I945GM_IDS(&intel_i945_info),
-
 
580
 
-
 
581
	INTEL_G33_IDS(&intel_g33_info),
-
 
582
	INTEL_PINEVIEW_IDS(&intel_g33_info),
-
 
583
 
-
 
584
	INTEL_I965G_IDS(&intel_i965_info),
-
 
585
	INTEL_I965GM_IDS(&intel_i965_info),
-
 
586
 
-
 
587
	INTEL_G45_IDS(&intel_g4x_info),
-
 
588
	INTEL_GM45_IDS(&intel_g4x_info),
-
 
589
 
-
 
590
	INTEL_IRONLAKE_D_IDS(&intel_ironlake_info),
-
 
591
	INTEL_IRONLAKE_M_IDS(&intel_ironlake_info),
-
 
592
 
-
 
593
	INTEL_SNB_D_IDS(&intel_sandybridge_info),
-
 
594
	INTEL_SNB_M_IDS(&intel_sandybridge_info),
-
 
595
 
-
 
596
	INTEL_IVB_D_IDS(&intel_ivybridge_info),
-
 
597
	INTEL_IVB_M_IDS(&intel_ivybridge_info),
-
 
598
 
-
 
599
	INTEL_HSW_D_IDS(&intel_haswell_info),
-
 
600
	INTEL_HSW_M_IDS(&intel_haswell_info),
-
 
601
 
-
 
602
	INTEL_VLV_D_IDS(&intel_valleyview_info),
-
 
603
	INTEL_VLV_M_IDS(&intel_valleyview_info),
-
 
604
 
-
 
605
	INTEL_VGA_DEVICE(PCI_MATCH_ANY, &intel_generic_info),
-
 
606
 
-
 
607
	{ 0, 0, 0 },
-
 
608
};
-
 
609
 
-
 
610
const struct pci_id_match *PciDevMatch(uint16_t dev,const struct pci_id_match *list)
-
 
611
{
-
 
612
    while(list->device_id)
-
 
613
    {
-
 
614
        if(dev==list->device_id)
-
 
615
            return list;
-
 
616
        list++;
-
 
617
    }
-
 
618
    return NULL;
-
 
619
}
-
 
620
 
-
 
621
const struct intel_device_info *
-
 
622
intel_detect_chipset(struct pci_device *pci)
-
 
623
{
-
 
624
    const struct pci_id_match *ent = NULL;
-
 
625
 
-
 
626
    ent = PciDevMatch(pci->device_id, intel_device_match);
-
 
627
 
-
 
628
    if(ent != NULL)
-
 
629
        return (const struct intel_device_info*)ent->match_data;
-
 
630
    else
-
 
631
        return &intel_generic_info;
-
 
632
}
-
 
633
 
-
 
634
int intel_get_device_id(int fd)
-
 
635
{
-
 
636
	struct drm_i915_getparam gp;
-
 
637
	int devid = 0;
-
 
638
 
-
 
639
	memset(&gp, 0, sizeof(gp));
-
 
640
	gp.param = I915_PARAM_CHIPSET_ID;
-
 
641
	gp.value = &devid;
-
 
642
 
-
 
643
	if (drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp))
-
 
644
		return 0;
-
 
645
 
-
 
646
	return devid;
-
 
647
}
-
 
648
 
-
 
649
int drmIoctl(int fd, unsigned long request, void *arg)
-
 
650
{
-
 
651
    ioctl_t  io;
-
 
652
 
-
 
653
    io.handle   = fd;
-
 
654
    io.io_code  = request;
-
 
655
    io.input    = arg;
-
 
656
    io.inp_size = 64;
-
 
657
    io.output   = NULL;
-
 
658
    io.out_size = 0;
-
 
659
 
-
 
660
    return call_service(&io);
-
 
661
}
-
 
662
 
-
 
663
 
-
 
664
 
-
 
665
bool
-
 
666
gen6_composite(struct sna *sna,
-
 
667
              uint8_t op,
-
 
668
              PixmapPtr src, struct kgem_bo *src_bo,
-
 
669
              PixmapPtr mask,struct kgem_bo *mask_bo,
-
 
670
              PixmapPtr dst, struct kgem_bo *dst_bo,
-
 
671
              int32_t src_x, int32_t src_y,
-
 
672
              int32_t msk_x, int32_t msk_y,
-
 
673
              int32_t dst_x, int32_t dst_y,
-
 
674
              int32_t width, int32_t height,
-
 
675
              struct sna_composite_op *tmp);
-
 
676
 
489
 
677
//#define MAP(ptr) ((void*)((uintptr_t)(ptr) & ~3))
490
 
678
 
491
 
679
 
492
int sna_create_bitmap(bitmap_t *bitmap)
680
int sna_bitmap_from_handle(bitmap_t *bitmap, uint32_t handle)
Line 493... Line 681...
493
{
681
{
494
    surface_t *sf;
682
    surface_t *sf;
495
	struct kgem_bo *bo;
683
    struct kgem_bo *bo;
Line 496... Line 684...
496
 
684
 
Line 497... Line 685...
497
    sf = malloc(sizeof(*sf));
685
    sf = malloc(sizeof(*sf));
498
    if(sf == NULL)
-
 
499
        goto err_1;
-
 
500
 
-
 
501
    __lock_acquire_recursive(__sna_lock);
-
 
Line 502... Line 686...
502
 
686
    if(sf == NULL)
503
    bo = kgem_create_2d(&sna_device->kgem, bitmap->width, bitmap->height,
-
 
504
                        32,I915_TILING_NONE, CREATE_CPU_MAP);
-
 
Line 505... Line 687...
505
 
687
        goto err_1;
506
    if(bo == NULL)
688
 
507
        goto err_2;
689
    __lock_acquire_recursive(__sna_lock);
508
 
690
 
509
    void *map = kgem_bo_map(&sna_device->kgem, bo);
691
    bo = kgem_bo_from_handle(&sna_device->kgem, handle, bitmap->pitch, bitmap->height);
510
    if(map == NULL)
692
 
511
        goto err_3;
693
    __lock_release_recursive(__sna_lock);
Line 512... Line 694...
512
 
694
 
513
    sf->width   = bitmap->width;
-
 
Line 514... Line 695...
514
    sf->height  = bitmap->height;
695
    sf->width   = bitmap->width;
Line 515... Line -...
515
    sf->data    = map;
-
 
516
    sf->pitch   = bo->pitch;
-
 
517
    sf->bo      = bo;
696
    sf->height  = bitmap->height;
518
    sf->bo_size = PAGE_SIZE * bo->size.pages.count;
697
    sf->data    = NULL;
519
    sf->flags   = bitmap->flags;
698
    sf->pitch   = bo->pitch;
520
 
699
    sf->bo      = bo;
521
    bitmap->handle = (uint32_t)sf;
700
    sf->bo_size = PAGE_SIZE * bo->size.pages.count;
522
    __lock_release_recursive(__sna_lock);
701
    sf->flags   = bitmap->flags;
Line 523... Line 702...
523
 
702
 
-
 
703
    bitmap->handle = (uint32_t)sf;
-
 
704
 
-
 
705
    return 0;
-
 
706
 
-
 
707
err_2:
-
 
708
    __lock_release_recursive(__sna_lock);
-
 
709
    free(sf);
524
    return 0;
710
err_1:
525
 
711
    return -1;
526
err_3:
712
};
Line 527... Line 713...
527
    kgem_bo_destroy(&sna_device->kgem, bo);
713
 
528
err_2:
714
void sna_set_bo_handle(bitmap_t *bitmap, int handle)
529
    __lock_release_recursive(__sna_lock);
715
{
Line 530... Line 716...
530
    free(sf);
716
    surface_t *sf = to_surface(bitmap);
Line 531... Line 717...
531
err_1:
717
    struct kgem_bo *bo = sf->bo;
-
 
718
    bo->handle = handle;
Line -... Line 719...
-
 
719
}
-
 
720
 
-
 
721
static int sna_create_bitmap(bitmap_t *bitmap)
532
    return -1;
722
{
-
 
723
    surface_t *sf;
-
 
724
    struct kgem_bo *bo;
Line 533... Line 725...
533
};
725
 
534
 
726
    sf = malloc(sizeof(*sf));
535
int sna_bitmap_from_handle(bitmap_t *bitmap, uint32_t handle)
727
    if(sf == NULL)
536
{
728
        goto err_1;
537
    surface_t *sf;
729
 
538
	struct kgem_bo *bo;
730
    __lock_acquire_recursive(__sna_lock);
539
 
731
 
Line 540... Line 732...
540
    sf = malloc(sizeof(*sf));
732
    bo = kgem_create_2d(&sna_device->kgem, bitmap->width, bitmap->height,
-
 
733
                        32,I915_TILING_NONE, CREATE_CPU_MAP);
Line 541... Line 734...
541
    if(sf == NULL)
734
 
Line -... Line 735...
-
 
735
    if(bo == NULL)
-
 
736
        goto err_2;
542
        goto err_1;
737
 
543
 
738
    void *map = kgem_bo_map(&sna_device->kgem, bo);
544
    __lock_acquire_recursive(__sna_lock);
739
    if(map == NULL)
545
 
740
        goto err_3;
546
    bo = kgem_bo_from_handle(&sna_device->kgem, handle, bitmap->pitch, bitmap->height);
741
 
547
 
742
    sf->width   = bitmap->width;
Line 548... Line -...
548
    __lock_release_recursive(__sna_lock);
-
 
549
 
-
 
550
    sf->width   = bitmap->width;
-
 
551
    sf->height  = bitmap->height;
-
 
552
    sf->data    = NULL;
-
 
553
    sf->pitch   = bo->pitch;
-
 
554
    sf->bo      = bo;
-
 
555
    sf->bo_size = PAGE_SIZE * bo->size.pages.count;
743
    sf->height  = bitmap->height;
556
    sf->flags   = bitmap->flags;
744
    sf->data    = map;
557
 
745
    sf->pitch   = bo->pitch;
Line 558... Line 746...
558
    bitmap->handle = (uint32_t)sf;
746
    sf->bo      = bo;
Line 590... Line 778...
590
    bitmap->pitch  = -1;
778
    bitmap->pitch  = -1;
Line 591... Line 779...
591
 
779
 
592
    return 0;
780
    return 0;
Line 593... Line 781...
593
};
781
};
594
 
782
 
595
int sna_lock_bitmap(bitmap_t *bitmap)
783
static int sna_lock_bitmap(bitmap_t *bitmap)
Line 596... Line 784...
596
{
784
{
597
    surface_t *sf = to_surface(bitmap);
785
    surface_t *sf = to_surface(bitmap);
Line 607... Line 795...
607
    bitmap->pitch = sf->pitch;
795
    bitmap->pitch = sf->pitch;
Line 608... Line 796...
608
 
796
 
609
    return 0;
797
    return 0;
Line 610... Line 798...
610
};
798
};
611
 
799
 
612
int sna_resize_bitmap(bitmap_t *bitmap)
800
static int sna_resize_bitmap(bitmap_t *bitmap)
613
{
801
{
614
    surface_t *sf = to_surface(bitmap);
802
    surface_t *sf = to_surface(bitmap);
Line 705... Line 893...
705
err_1:
893
err_1:
706
    __lock_release_recursive(__sna_lock);
894
    __lock_release_recursive(__sna_lock);
707
    return -1;
895
    return -1;
708
};
896
};
Line 709... Line -...
709
 
-
 
710
#define MI_LOAD_REGISTER_IMM		(0x22<<23)
-
 
711
#define MI_WAIT_FOR_EVENT			(0x03<<23)
-
 
712
 
-
 
713
static bool sna_emit_wait_for_scanline_gen6(struct sna *sna,
-
 
714
                        rect_t *crtc,
-
 
715
					    int pipe, int y1, int y2,
-
 
716
					    bool full_height)
-
 
717
{
-
 
718
	uint32_t *b;
-
 
719
	uint32_t event;
-
 
720
 
-
 
721
//	if (!sna->kgem.has_secure_batches)
-
 
722
//		return false;
-
 
723
 
-
 
724
	assert(y1 >= 0);
-
 
725
	assert(y2 > y1);
-
 
726
	assert(sna->kgem.mode == KGEM_RENDER);
-
 
727
 
-
 
728
	/* Always program one less than the desired value */
-
 
729
	if (--y1 < 0)
-
 
730
		y1 = crtc->b;
-
 
731
	y2--;
-
 
732
 
-
 
733
	/* The scanline granularity is 3 bits */
-
 
734
	y1 &= ~7;
-
 
735
	y2 &= ~7;
-
 
736
	if (y2 == y1)
-
 
737
		return false;
-
 
738
 
-
 
739
	event = 1 << (3*full_height + pipe*8);
-
 
740
 
-
 
741
	b = kgem_get_batch(&sna->kgem);
-
 
742
	sna->kgem.nbatch += 10;
-
 
743
 
-
 
744
	b[0] = MI_LOAD_REGISTER_IMM | 1;
-
 
745
	b[1] = 0x44050; /* DERRMR */
-
 
746
	b[2] = ~event;
-
 
747
	b[3] = MI_LOAD_REGISTER_IMM | 1;
-
 
748
	b[4] = 0x4f100; /* magic */
-
 
749
	b[5] = (1 << 31) | (1 << 30) | pipe << 29 | (y1 << 16) | y2;
-
 
750
	b[6] = MI_WAIT_FOR_EVENT | event;
-
 
751
	b[7] = MI_LOAD_REGISTER_IMM | 1;
-
 
752
	b[8] = 0x44050; /* DERRMR */
-
 
753
	b[9] = ~0;
-
 
754
 
-
 
755
	sna->kgem.batch_flags |= I915_EXEC_SECURE;
-
 
756
 
-
 
757
	return true;
-
 
758
}
-
 
759
 
-
 
760
bool
-
 
761
sna_wait_for_scanline(struct sna *sna,
-
 
762
		      rect_t *crtc,
-
 
763
		      rect_t *clip)
-
 
764
{
-
 
765
	bool full_height;
-
 
766
	int y1, y2, pipe;
-
 
767
	bool ret;
-
 
768
 
-
 
769
//	if (sna->flags & SNA_NO_VSYNC)
-
 
770
//		return false;
-
 
771
 
-
 
772
	/*
-
 
773
	 * Make sure we don't wait for a scanline that will
-
 
774
	 * never occur
-
 
775
	 */
-
 
776
	y1 = clip->t - crtc->t;
-
 
777
	if (y1 < 0)
-
 
778
		y1 = 0;
-
 
779
	y2 = clip->b - crtc->t;
-
 
780
	if (y2 > crtc->b - crtc->t)
-
 
781
		y2 = crtc->b - crtc->t;
-
 
782
//	DBG(("%s: clipped range = %d, %d\n", __FUNCTION__, y1, y2));
-
 
783
//	printf("%s: clipped range = %d, %d\n", __FUNCTION__, y1, y2);
-
 
784
 
-
 
785
	if (y2 <= y1 + 4)
-
 
786
		return false;
-
 
787
 
-
 
788
	full_height = y1 == 0 && y2 == crtc->b - crtc->t;
-
 
789
 
-
 
790
	pipe = 0;
-
 
791
	DBG(("%s: pipe=%d, y1=%d, y2=%d, full_height?=%d\n",
-
 
792
	     __FUNCTION__, pipe, y1, y2, full_height));
-
 
793
 
-
 
794
	if (sna->kgem.gen >= 0100)
-
 
795
		ret = false;
-
 
796
//	else if (sna->kgem.gen >= 075)
-
 
797
//		ret = sna_emit_wait_for_scanline_hsw(sna, crtc, pipe, y1, y2, full_height);
-
 
798
//	else if (sna->kgem.gen >= 070)
-
 
799
//		ret = sna_emit_wait_for_scanline_ivb(sna, crtc, pipe, y1, y2, full_height);
-
 
800
	else if (sna->kgem.gen >= 060)
-
 
801
		ret =sna_emit_wait_for_scanline_gen6(sna, crtc, pipe, y1, y2, full_height);
-
 
802
//	else if (sna->kgem.gen >= 040)
-
 
803
//		ret = sna_emit_wait_for_scanline_gen4(sna, crtc, pipe, y1, y2, full_height);
-
 
804
 
-
 
805
	return ret;
-
 
806
}
-
 
807
 
-
 
808
 
-
 
809
bool
-
 
810
gen6_composite(struct sna *sna,
-
 
811
              uint8_t op,
-
 
812
		      PixmapPtr src, struct kgem_bo *src_bo,
-
 
813
		      PixmapPtr mask,struct kgem_bo *mask_bo,
-
 
814
		      PixmapPtr dst, struct kgem_bo *dst_bo,
-
 
815
              int32_t src_x, int32_t src_y,
-
 
816
              int32_t msk_x, int32_t msk_y,
-
 
817
              int32_t dst_x, int32_t dst_y,
-
 
818
              int32_t width, int32_t height,
-
 
819
              struct sna_composite_op *tmp);
-
 
Line 820... Line -...
820
 
-
 
Line 821... Line 897...
821
 
897
 
822
#define MAP(ptr) ((void*)((uintptr_t)(ptr) & ~3))
898
 
Line 823... Line 899...
823
 
899
 
Line 946... Line 1022...
946
 
1022
 
947
    return 0;
1023
    return 0;
Line -... Line 1024...
-
 
1024
}
-
 
1025
 
-
 
1026
 
Line -... Line 1027...
-
 
1027
static void sna_fini()
-
 
1028
{
-
 
1029
    ENTER();
Line -... Line 1030...
-
 
1030
 
Line -... Line 1031...
-
 
1031
    if( sna_device )
Line -... Line 1032...
-
 
1032
    {
-
 
1033
        struct kgem_bo *mask;
-
 
1034
 
-
 
1035
        __lock_acquire_recursive(__sna_lock);
-
 
1036
 
Line 948... Line -...
948
}
-
 
949
 
-
 
950
 
-
 
951
 
-
 
952
 
-
 
953
 
-
 
954
 
-
 
955
 
-
 
956
static const struct intel_device_info intel_generic_info = {
-
 
957
	.gen = -1,
-
 
958
};
-
 
959
 
1037
        mask = tls_get(tls_mask);
960
static const struct intel_device_info intel_i915_info = {
-
 
961
	.gen = 030,
-
 
962
};
-
 
963
static const struct intel_device_info intel_i945_info = {
1038
 
964
	.gen = 031,
-
 
965
};
-
 
966
 
-
 
967
static const struct intel_device_info intel_g33_info = {
-
 
968
	.gen = 033,
-
 
969
};
-
 
970
 
-
 
971
static const struct intel_device_info intel_i965_info = {
-
 
972
	.gen = 040,
-
 
973
};
-
 
974
 
-
 
975
static const struct intel_device_info intel_g4x_info = {
-
 
976
	.gen = 045,
-
 
977
};
-
 
978
 
-
 
979
static const struct intel_device_info intel_ironlake_info = {
-
 
980
	.gen = 050,
-
 
981
};
-
 
982
 
-
 
983
static const struct intel_device_info intel_sandybridge_info = {
-
 
984
	.gen = 060,
-
 
985
};
-
 
986
 
-
 
987
static const struct intel_device_info intel_ivybridge_info = {
-
 
988
	.gen = 070,
-
 
989
};
1039
        sna_device->render.fini(sna_device);
-
 
1040
        if(mask)
-
 
1041
            kgem_bo_destroy(&sna_device->kgem, mask);
Line 990... Line -...
990
 
-
 
991
static const struct intel_device_info intel_valleyview_info = {
-
 
992
	.gen = 071,
-
 
993
};
-
 
994
 
1042
//        kgem_close_batches(&sna_device->kgem);
995
static const struct intel_device_info intel_haswell_info = {
1043
        kgem_cleanup_cache(&sna_device->kgem);
996
	.gen = 075,
-
 
997
};
-
 
998
 
1044
 
999
#define INTEL_DEVICE_MATCH(d,i) \
-
 
1000
    { 0x8086, (d), PCI_MATCH_ANY, PCI_MATCH_ANY, 0x3 << 16, 0xff << 16, (intptr_t)(i) }
-
 
1001
 
1045
        sna_device = NULL;
1002
 
-
 
Line 1003... Line 1046...
1003
static const struct pci_id_match intel_device_match[] = {
1046
        __lock_release_recursive(__sna_lock);
1004
 
1047
    };
Line 1005... Line -...
1005
	INTEL_I915G_IDS(&intel_i915_info),
-
 
1006
	INTEL_I915GM_IDS(&intel_i915_info),
1048
    LEAVE();
Line 1007... Line -...
1007
	INTEL_I945G_IDS(&intel_i945_info),
-
 
1008
	INTEL_I945GM_IDS(&intel_i945_info),
1049
}
Line 1009... Line 1050...
1009
 
1050
 
1010
	INTEL_G33_IDS(&intel_g33_info),
1051
uint32_t DrvInit(uint32_t service, struct pix_driver *driver)
Line -... Line 1052...
-
 
1052
{
1011
	INTEL_PINEVIEW_IDS(&intel_g33_info),
1053
    ioctl_t   io;
-
 
1054
    int caps = 0;
1012
 
1055
 
-
 
1056
    static struct pci_device device;
-
 
1057
    struct sna *sna;
Line 1013... Line 1058...
1013
	INTEL_I965G_IDS(&intel_i965_info),
1058
 
1014
	INTEL_I965GM_IDS(&intel_i965_info),
1059
    DBG(("%s\n", __FUNCTION__));
Line 1015... Line 1060...
1015
 
1060
 
1016
	INTEL_G45_IDS(&intel_g4x_info),
1061
    __lock_acquire_recursive(__sna_lock);
-
 
1062
 
Line 1017... Line 1063...
1017
	INTEL_GM45_IDS(&intel_g4x_info),
1063
    if(sna_device)
Line 1018... Line 1064...
1018
 
1064
        goto done;
1019
	INTEL_IRONLAKE_D_IDS(&intel_ironlake_info),
-
 
Line 1020... Line -...
1020
	INTEL_IRONLAKE_M_IDS(&intel_ironlake_info),
-
 
1021
 
-
 
1022
	INTEL_SNB_D_IDS(&intel_sandybridge_info),
1065
 
1023
	INTEL_SNB_M_IDS(&intel_sandybridge_info),
-
 
1024
 
1066
    io.handle   = service;
1025
	INTEL_IVB_D_IDS(&intel_ivybridge_info),
1067
    io.io_code  = SRV_GET_PCI_INFO;
1026
	INTEL_IVB_M_IDS(&intel_ivybridge_info),
-
 
1027
 
-
 
1028
	INTEL_HSW_D_IDS(&intel_haswell_info),
-
 
1029
	INTEL_HSW_M_IDS(&intel_haswell_info),
-
 
Line 1030... Line -...
1030
 
-
 
1031
	INTEL_VLV_D_IDS(&intel_valleyview_info),
-
 
1032
	INTEL_VLV_M_IDS(&intel_valleyview_info),
-
 
1033
 
1068
    io.input    = &device;
Line 1034... Line 1069...
1034
	INTEL_VGA_DEVICE(PCI_MATCH_ANY, &intel_generic_info),
1069
    io.inp_size = sizeof(device);
-
 
1070
    io.output   = NULL;
Line 1035... Line -...
1035
 
-
 
1036
	{ 0, 0, 0 },
1071
    io.out_size = 0;
1037
};
-
 
1038
 
1072
 
1039
const struct pci_id_match *PciDevMatch(uint16_t dev,const struct pci_id_match *list)
-
 
Line 1040... Line -...
1040
{
-
 
1041
    while(list->device_id)
-
 
1042
    {
-
 
1043
        if(dev==list->device_id)
1073
    if (call_service(&io)!=0)
Line 1044... Line 1074...
1044
            return list;
1074
        goto err1;
1045
        list++;
-
 
1046
    }
-
 
Line 1047... Line 1075...
1047
    return NULL;
1075
 
1048
}
-
 
Line 1049... Line 1076...
1049
 
1076
    sna = malloc(sizeof(*sna));
1050
const struct intel_device_info *
-
 
Line -... Line 1077...
-
 
1077
    if (sna == NULL)
1051
intel_detect_chipset(struct pci_device *pci)
1078
        goto err1;
-
 
1079
 
-
 
1080
    memset(sna, 0, sizeof(*sna));
-
 
1081
 
-
 
1082
    sna->cpu_features = sna_cpu_detect();
1052
{
1083
 
1053
    const struct pci_id_match *ent = NULL;
1084
    sna->PciInfo = &device;
Line 1054... Line 1085...
1054
 
1085
    sna->info = intel_detect_chipset(sna->PciInfo);
1055
    ent = PciDevMatch(pci->device_id, intel_device_match);
1086
    sna->scrn = service;
1056
 
-
 
1057
    if(ent != NULL)
-
 
1058
        return (const struct intel_device_info*)ent->match_data;
-
 
1059
    else
-
 
Line 1060... Line 1087...
1060
        return &intel_generic_info;
1087
 
1061
}
1088
    kgem_init(&sna->kgem, service, sna->PciInfo, sna->info->gen);