Subversion Repositories Kolibri OS

Rev

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

Rev 4374 Rev 4375
Line 41... Line 41...
41
#include 
41
#include 
42
#include "i915_pciids.h"
42
#include "i915_pciids.h"
Line 43... Line 43...
43
 
43
 
44
#include "compiler.h"
44
#include "compiler.h"
-
 
45
#include "sna.h"
Line 45... Line 46...
45
#include "sna.h"
46
#include "sna_reg.h"
46
 
47
 
Line 47... Line 48...
47
#include 
48
#include 
Line 419... Line 420...
419
 
420
 
420
 
421
 
Line -... Line 422...
-
 
422
#define MI_LOAD_REGISTER_IMM		(0x22<<23)
-
 
423
#define MI_WAIT_FOR_EVENT			(0x03<<23)
-
 
424
 
-
 
425
static bool sna_emit_wait_for_scanline_hsw(struct sna *sna,
-
 
426
                        rect_t *crtc,
-
 
427
                        int pipe, int y1, int y2,
-
 
428
                        bool full_height)
-
 
429
{
-
 
430
    uint32_t event;
-
 
431
    uint32_t *b;
-
 
432
 
-
 
433
    if (!sna->kgem.has_secure_batches)
-
 
434
        return false;
-
 
435
 
-
 
436
    b = kgem_get_batch(&sna->kgem);
-
 
437
    sna->kgem.nbatch += 17;
-
 
438
 
-
 
439
    switch (pipe) {
-
 
440
    default: assert(0);
-
 
441
    case 0: event = 1 << 0; break;
-
 
442
    case 1: event = 1 << 8; break;
-
 
443
    case 2: event = 1 << 14; break;
-
 
444
    }
-
 
445
 
-
 
446
    b[0] = MI_LOAD_REGISTER_IMM | 1;
-
 
447
    b[1] = 0x44050; /* DERRMR */
-
 
448
    b[2] = ~event;
-
 
449
    b[3] = MI_LOAD_REGISTER_IMM | 1;
-
 
450
    b[4] = 0xa188; /* FORCEWAKE_MT */
-
 
451
    b[5] = 2 << 16 | 2;
-
 
452
 
-
 
453
    /* The documentation says that the LOAD_SCAN_LINES command
-
 
454
     * always comes in pairs. Don't ask me why. */
-
 
455
    switch (pipe) {
-
 
456
    default: assert(0);
-
 
457
    case 0: event = 0 << 19; break;
-
 
458
    case 1: event = 1 << 19; break;
-
 
459
    case 2: event = 4 << 19; break;
-
 
460
    }
-
 
461
    b[8] = b[6] = MI_LOAD_SCAN_LINES_INCL | event;
-
 
462
    b[9] = b[7] = (y1 << 16) | (y2-1);
-
 
463
 
-
 
464
    switch (pipe) {
-
 
465
    default: assert(0);
-
 
466
    case 0: event = 1 << 0; break;
-
 
467
    case 1: event = 1 << 8; break;
-
 
468
    case 2: event = 1 << 14; break;
-
 
469
    }
-
 
470
    b[10] = MI_WAIT_FOR_EVENT | event;
-
 
471
 
-
 
472
    b[11] = MI_LOAD_REGISTER_IMM | 1;
-
 
473
    b[12] = 0xa188; /* FORCEWAKE_MT */
-
 
474
    b[13] = 2 << 16;
-
 
475
    b[14] = MI_LOAD_REGISTER_IMM | 1;
-
 
476
    b[15] = 0x44050; /* DERRMR */
-
 
477
    b[16] = ~0;
-
 
478
 
-
 
479
    sna->kgem.batch_flags |= I915_EXEC_SECURE;
-
 
480
    return true;
-
 
481
}
-
 
482
 
-
 
483
 
-
 
484
static bool sna_emit_wait_for_scanline_ivb(struct sna *sna,
-
 
485
                        rect_t *crtc,
-
 
486
                        int pipe, int y1, int y2,
-
 
487
                        bool full_height)
-
 
488
{
-
 
489
    uint32_t *b;
-
 
490
    uint32_t event;
-
 
491
    uint32_t forcewake;
-
 
492
 
-
 
493
    if (!sna->kgem.has_secure_batches)
-
 
494
        return false;
-
 
495
 
-
 
496
    assert(y1 >= 0);
-
 
497
    assert(y2 > y1);
-
 
498
    assert(sna->kgem.mode);
-
 
499
 
-
 
500
    /* Always program one less than the desired value */
-
 
501
    if (--y1 < 0)
-
 
502
        y1 = crtc->b;
-
 
503
    y2--;
-
 
504
 
-
 
505
    switch (pipe) {
-
 
506
    default:
-
 
507
        assert(0);
-
 
508
    case 0:
-
 
509
        event = 1 << (full_height ? 3 : 0);
-
 
510
        break;
-
 
511
    case 1:
-
 
512
        event = 1 << (full_height ? 11 : 8);
-
 
513
        break;
-
 
514
    case 2:
-
 
515
        event = 1 << (full_height ? 21 : 14);
-
 
516
        break;
-
 
517
    }
-
 
518
 
-
 
519
    if (sna->kgem.gen == 071)
-
 
520
        forcewake = 0x1300b0; /* FORCEWAKE_VLV */
-
 
521
    else
-
 
522
        forcewake = 0xa188; /* FORCEWAKE_MT */
-
 
523
 
-
 
524
    b = kgem_get_batch(&sna->kgem);
-
 
525
 
-
 
526
    /* Both the LRI and WAIT_FOR_EVENT must be in the same cacheline */
-
 
527
    if (((sna->kgem.nbatch + 6) >> 4) != (sna->kgem.nbatch + 10) >> 4) {
-
 
528
        int dw = sna->kgem.nbatch + 6;
-
 
529
        dw = ALIGN(dw, 16) - dw;
-
 
530
        while (dw--)
-
 
531
            *b++ = MI_NOOP;
-
 
532
    }
-
 
533
 
-
 
534
    b[0] = MI_LOAD_REGISTER_IMM | 1;
-
 
535
    b[1] = 0x44050; /* DERRMR */
-
 
536
    b[2] = ~event;
-
 
537
    b[3] = MI_LOAD_REGISTER_IMM | 1;
-
 
538
    b[4] = forcewake;
-
 
539
    b[5] = 2 << 16 | 2;
-
 
540
    b[6] = MI_LOAD_REGISTER_IMM | 1;
-
 
541
    b[7] = 0x70068 + 0x1000 * pipe;
-
 
542
    b[8] = (1 << 31) | (1 << 30) | (y1 << 16) | y2;
-
 
543
    b[9] = MI_WAIT_FOR_EVENT | event;
-
 
544
    b[10] = MI_LOAD_REGISTER_IMM | 1;
-
 
545
    b[11] = forcewake;
-
 
546
    b[12] = 2 << 16;
-
 
547
    b[13] = MI_LOAD_REGISTER_IMM | 1;
-
 
548
    b[14] = 0x44050; /* DERRMR */
-
 
549
    b[15] = ~0;
-
 
550
 
-
 
551
    sna->kgem.nbatch = b - sna->kgem.batch + 16;
-
 
552
 
-
 
553
    sna->kgem.batch_flags |= I915_EXEC_SECURE;
-
 
554
    return true;
421
#define MI_LOAD_REGISTER_IMM		(0x22<<23)
555
}
422
#define MI_WAIT_FOR_EVENT			(0x03<<23)
556
 
423
 
557
 
424
static bool sna_emit_wait_for_scanline_gen6(struct sna *sna,
558
static bool sna_emit_wait_for_scanline_gen6(struct sna *sna,
425
                        rect_t *crtc,
559
                        rect_t *crtc,
Line 466... Line 600...
466
	sna->kgem.batch_flags |= I915_EXEC_SECURE;
600
	sna->kgem.batch_flags |= I915_EXEC_SECURE;
Line 467... Line 601...
467
 
601
 
468
	return true;
602
	return true;
Line -... Line 603...
-
 
603
}
-
 
604
 
-
 
605
static bool sna_emit_wait_for_scanline_gen4(struct sna *sna,
-
 
606
                        rect_t *crtc,
-
 
607
                        int pipe, int y1, int y2,
-
 
608
                        bool full_height)
-
 
609
{
-
 
610
    uint32_t event;
-
 
611
    uint32_t *b;
-
 
612
 
-
 
613
    if (pipe == 0) {
-
 
614
        if (full_height)
-
 
615
            event = MI_WAIT_FOR_PIPEA_SVBLANK;
-
 
616
        else
-
 
617
            event = MI_WAIT_FOR_PIPEA_SCAN_LINE_WINDOW;
-
 
618
    } else {
-
 
619
        if (full_height)
-
 
620
            event = MI_WAIT_FOR_PIPEB_SVBLANK;
-
 
621
        else
-
 
622
            event = MI_WAIT_FOR_PIPEB_SCAN_LINE_WINDOW;
-
 
623
    }
-
 
624
 
-
 
625
    b = kgem_get_batch(&sna->kgem);
-
 
626
    sna->kgem.nbatch += 5;
-
 
627
 
-
 
628
    /* The documentation says that the LOAD_SCAN_LINES command
-
 
629
     * always comes in pairs. Don't ask me why. */
-
 
630
    b[2] = b[0] = MI_LOAD_SCAN_LINES_INCL | pipe << 20;
-
 
631
    b[3] = b[1] = (y1 << 16) | (y2-1);
-
 
632
    b[4] = MI_WAIT_FOR_EVENT | event;
-
 
633
 
-
 
634
    return true;
-
 
635
}
-
 
636
 
-
 
637
static bool sna_emit_wait_for_scanline_gen2(struct sna *sna,
-
 
638
                        rect_t *crtc,
-
 
639
                        int pipe, int y1, int y2,
-
 
640
                        bool full_height)
-
 
641
{
-
 
642
    uint32_t *b;
-
 
643
 
-
 
644
    /*
-
 
645
     * Pre-965 doesn't have SVBLANK, so we need a bit
-
 
646
     * of extra time for the blitter to start up and
-
 
647
     * do its job for a full height blit
-
 
648
     */
-
 
649
    if (full_height)
-
 
650
        y2 -= 2;
-
 
651
 
-
 
652
    b = kgem_get_batch(&sna->kgem);
-
 
653
    sna->kgem.nbatch += 5;
-
 
654
 
-
 
655
    /* The documentation says that the LOAD_SCAN_LINES command
-
 
656
     * always comes in pairs. Don't ask me why. */
-
 
657
    b[2] = b[0] = MI_LOAD_SCAN_LINES_INCL | pipe << 20;
-
 
658
    b[3] = b[1] = (y1 << 16) | (y2-1);
-
 
659
    b[4] = MI_WAIT_FOR_EVENT | 1 << (1 + 4*pipe);
-
 
660
 
-
 
661
    return true;
469
}
662
}
470
 
663
 
471
bool
664
bool
472
sna_wait_for_scanline(struct sna *sna,
665
sna_wait_for_scanline(struct sna *sna,
473
		      rect_t *crtc,
666
		      rect_t *crtc,
Line 502... Line 695...
502
	DBG(("%s: pipe=%d, y1=%d, y2=%d, full_height?=%d\n",
695
	DBG(("%s: pipe=%d, y1=%d, y2=%d, full_height?=%d\n",
503
	     __FUNCTION__, pipe, y1, y2, full_height));
696
	     __FUNCTION__, pipe, y1, y2, full_height));
Line 504... Line 697...
504
 
697
 
505
	if (sna->kgem.gen >= 0100)
698
	if (sna->kgem.gen >= 0100)
506
		ret = false;
699
		ret = false;
507
//	else if (sna->kgem.gen >= 075)
700
    else if (sna->kgem.gen >= 075)
508
//		ret = sna_emit_wait_for_scanline_hsw(sna, crtc, pipe, y1, y2, full_height);
701
        ret = sna_emit_wait_for_scanline_hsw(sna, crtc, pipe, y1, y2, full_height);
509
//	else if (sna->kgem.gen >= 070)
702
    else if (sna->kgem.gen >= 070)
510
//		ret = sna_emit_wait_for_scanline_ivb(sna, crtc, pipe, y1, y2, full_height);
703
        ret = sna_emit_wait_for_scanline_ivb(sna, crtc, pipe, y1, y2, full_height);
511
	else if (sna->kgem.gen >= 060)
704
	else if (sna->kgem.gen >= 060)
512
		ret =sna_emit_wait_for_scanline_gen6(sna, crtc, pipe, y1, y2, full_height);
705
		ret =sna_emit_wait_for_scanline_gen6(sna, crtc, pipe, y1, y2, full_height);
513
//	else if (sna->kgem.gen >= 040)
706
    else if (sna->kgem.gen >= 040)
-
 
707
        ret = sna_emit_wait_for_scanline_gen4(sna, crtc, pipe, y1, y2, full_height);
-
 
708
    else
Line 514... Line 709...
514
//		ret = sna_emit_wait_for_scanline_gen4(sna, crtc, pipe, y1, y2, full_height);
709
        ret = sna_emit_wait_for_scanline_gen2(sna, crtc, pipe, y1, y2, full_height);
515
 
710
 
Line 968... Line 1163...
968
 
1163
 
Line 969... Line 1164...
969
    src_bo = sf->bo;
1164
    src_bo = sf->bo;
Line 970... Line 1165...
970
 
1165
 
971
    __lock_acquire_recursive(__sna_lock);
1166
    __lock_acquire_recursive(__sna_lock);
972
 
1167
 
Line 973... Line 1168...
973
#if 1
1168
#if 0
974
    {
1169
    {