changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > plan9front / changeset: igfx: determine amount of preallocated stolen graphics memory for hw cursor

changeset 4216: c6b239f2aac5
parent 4215: 4a09496c5f5f
child 4217: 0c812f72386d
author: cinap_lenrek@felloff.net
date: Fri, 16 Jan 2015 13:38:52 +0100
files: sys/src/9/pc/vgaigfx.c sys/src/cmd/aux/vga/igfx.c
description: igfx: determine amount of preallocated stolen graphics memory for hw cursor

allocate the hardware cursor plane at the end of
preallocated stolen graphics memory.
     1.1--- a/sys/src/9/pc/vgaigfx.c
     1.2+++ b/sys/src/9/pc/vgaigfx.c
     1.3@@ -12,6 +12,48 @@
     1.4 #include <cursor.h>
     1.5 #include "screen.h"
     1.6 
     1.7+#define MB	0x100000
     1.8+
     1.9+static ulong
    1.10+preallocsize(Pcidev *p)
    1.11+{
    1.12+	switch(p->did){
    1.13+	case 0x0166:	/* Ivy Bridge */
    1.14+		switch((pcicfgr16(p, 0x50) >> 3) & 0x1f){
    1.15+		case 0x01:	return 32*MB	- 2*MB;
    1.16+		case 0x02:	return 64*MB	- 2*MB;
    1.17+		case 0x03:	return 96*MB	- 2*MB;
    1.18+		case 0x04:	return 128*MB	- 2*MB;
    1.19+		case 0x05:	return 32*MB	- 2*MB;
    1.20+		case 0x06:	return 48*MB	- 2*MB;
    1.21+		case 0x07:	return 64*MB	- 2*MB;
    1.22+		case 0x08:	return 128*MB	- 2*MB;
    1.23+		case 0x09:	return 256*MB	- 2*MB;
    1.24+		case 0x0A:	return 96*MB	- 2*MB;
    1.25+		case 0x0B:	return 160*MB	- 2*MB;
    1.26+		case 0x0C:	return 224*MB	- 2*MB;
    1.27+		case 0x0D:	return 352*MB	- 2*MB;
    1.28+		case 0x0E:	return 448*MB	- 2*MB;
    1.29+		case 0x0F:	return 480*MB	- 2*MB;
    1.30+		case 0x10:	return 512*MB	- 2*MB;
    1.31+		}
    1.32+		break;
    1.33+	case 0x27a2:	/* X60t */
    1.34+	case 0x2a42:	/* X200 */
    1.35+		switch((pcicfgr16(p, 0x52) >> 4) & 7){
    1.36+		case 0x01:	return 1*MB;
    1.37+		case 0x02:	return 4*MB;
    1.38+		case 0x03:	return 8*MB;
    1.39+		case 0x04:	return 16*MB;
    1.40+		case 0x05:	return 32*MB;
    1.41+		case 0x06:	return 48*MB;
    1.42+		case 0x07:	return 64*MB;
    1.43+		}
    1.44+		break;
    1.45+	}
    1.46+	return 0;
    1.47+}
    1.48+
    1.49 static void
    1.50 igfxenable(VGAscr* scr)
    1.51 {
    1.52@@ -30,9 +72,11 @@ igfxenable(VGAscr* scr)
    1.53 		vgalinearpci(scr);
    1.54 	if(scr->apsize){
    1.55 		addvgaseg("igfxscreen", scr->paddr, scr->apsize);
    1.56-		scr->storage = (scr->apsize - 64*64*4) & ~(BY2PG-1);
    1.57-		if(scr->storage > 0x1000000)
    1.58-			scr->storage = 0x1000000;
    1.59+		scr->storage = preallocsize(p);
    1.60+		if(scr->storage > scr->apsize)
    1.61+			scr->storage = scr->apsize;
    1.62+		if(scr->storage != 0)
    1.63+			scr->storage -= PGROUND(64*64*4);
    1.64 	}
    1.65 }
    1.66 
    1.67@@ -48,6 +92,8 @@ igfxcurload(VGAscr* scr, Cursor* curs)
    1.68 	u32int *p;
    1.69 	int i, j;
    1.70 
    1.71+	if(scr->storage == 0)
    1.72+		return;
    1.73 	p = (u32int*)((uchar*)scr->vaddr + scr->storage);
    1.74 	memset(p, 0, 64*64*4);
    1.75 	for(i=0;i<32;i++) {
    1.76@@ -84,10 +130,20 @@ igfxcurregs(VGAscr* scr, int pipe)
    1.77 	/* check PIPExCONF if enabled */
    1.78 	if((scr->mmio[(0x70008 | o)/4] & (1<<31)) == 0)
    1.79 		return nil;
    1.80-	if(scr->pci->did == 0x2a42){	/* G45 */
    1.81+	switch(scr->pci->did){
    1.82+	case 0x0116:	/* Ivy Bridge */
    1.83+		if(pipe > 2)
    1.84+			return nil;
    1.85+		break;
    1.86+	case 0x27a2:	/* X60t */
    1.87+	case 0x2a42:	/* X200 */
    1.88 		if(pipe > 1)
    1.89 			return nil;
    1.90 		o = pipe*0x40;
    1.91+		break;
    1.92+	default:
    1.93+		if(pipe > 0)
    1.94+			return nil;
    1.95 	}
    1.96 	return (u32int*)((uchar*)scr->mmio + (0x70080 + o));
    1.97 }
     2.1--- a/sys/src/cmd/aux/vga/igfx.c
     2.2+++ b/sys/src/cmd/aux/vga/igfx.c
     2.3@@ -251,7 +251,7 @@ snarfpipe(Igfx *igfx, int x)
     2.4 
     2.5 	p = &igfx->pipe[x];
     2.6 
     2.7-	o = 0x60000 | x*0x1000;
     2.8+	o = 0x60000 + x*0x1000;
     2.9 	snarftrans(igfx, p, o);
    2.10 
    2.11 	p->src = snarfreg(igfx, o + 0x0001C);
    2.12@@ -278,26 +278,26 @@ snarfpipe(Igfx *igfx, int x)
    2.13 	}
    2.14 
    2.15 	/* display plane */
    2.16-	p->dsp->cntr		= snarfreg(igfx, 0x70180 | x*0x1000);
    2.17-	p->dsp->linoff		= snarfreg(igfx, 0x70184 | x*0x1000);
    2.18-	p->dsp->stride		= snarfreg(igfx, 0x70188 | x*0x1000);
    2.19-	p->dsp->tileoff		= snarfreg(igfx, 0x701A4 | x*0x1000);
    2.20-	p->dsp->surf		= snarfreg(igfx, 0x7019C | x*0x1000);
    2.21+	p->dsp->cntr		= snarfreg(igfx, 0x70180 + x*0x1000);
    2.22+	p->dsp->linoff		= snarfreg(igfx, 0x70184 + x*0x1000);
    2.23+	p->dsp->stride		= snarfreg(igfx, 0x70188 + x*0x1000);
    2.24+	p->dsp->tileoff		= snarfreg(igfx, 0x701A4 + x*0x1000);
    2.25+	p->dsp->surf		= snarfreg(igfx, 0x7019C + x*0x1000);
    2.26 
    2.27 	/* cursor plane */
    2.28 	switch(igfx->type){
    2.29 	case TypeIVB:
    2.30-		p->cur->cntr	= snarfreg(igfx, 0x70080 | x*0x1000);
    2.31-		p->cur->base	= snarfreg(igfx, 0x70084 | x*0x1000);
    2.32-		p->cur->pos	= snarfreg(igfx, 0x70088 | x*0x1000);
    2.33+		p->cur->cntr	= snarfreg(igfx, 0x70080 + x*0x1000);
    2.34+		p->cur->base	= snarfreg(igfx, 0x70084 + x*0x1000);
    2.35+		p->cur->pos	= snarfreg(igfx, 0x70088 + x*0x1000);
    2.36 		break;
    2.37 	case TypeG45:
    2.38-		p->dsp->pos	= snarfreg(igfx, 0x7018C | x*0x1000);
    2.39-		p->dsp->size	= snarfreg(igfx, 0x70190 | x*0x1000);
    2.40+		p->dsp->pos	= snarfreg(igfx, 0x7018C + x*0x1000);
    2.41+		p->dsp->size	= snarfreg(igfx, 0x70190 + x*0x1000);
    2.42 
    2.43-		p->cur->cntr	= snarfreg(igfx, 0x70080 | x*0x40);
    2.44-		p->cur->base	= snarfreg(igfx, 0x70084 | x*0x40);
    2.45-		p->cur->pos	= snarfreg(igfx, 0x7008C | x*0x40);
    2.46+		p->cur->cntr	= snarfreg(igfx, 0x70080 + x*0x40);
    2.47+		p->cur->base	= snarfreg(igfx, 0x70084 + x*0x40);
    2.48+		p->cur->pos	= snarfreg(igfx, 0x7008C + x*0x40);
    2.49 		break;
    2.50 	}
    2.51 }