diff options
| author | cinap_lenrek <cinap_lenrek@felloff.net> | 2015-01-02 15:29:15 +0100 |
|---|---|---|
| committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2015-01-02 15:29:15 +0100 |
| commit | 9aec87c46c483ca1cf560e0e8a929cdf72447371 (patch) | |
| tree | d8a01bc7852d52012468de3c0c225cbfdee053d4 | |
| parent | 7848fe597006ecc6ee0605341ada08b7dea42f2a (diff) | |
| download | plan9front-9aec87c46c483ca1cf560e0e8a929cdf72447371.tar.xz | |
vgavesa: get rid of the vesa kproc
in 9front, screen blanking is always initiated from process context,
so there is no need for a kproc anymore.
care has been taken for the race between vesadisable() and vesablank()
by acquiering the drawlock prior calling scr->dev->enable() and
scr->dev->disable(). this also has the side effect of accelerated
fills and scrolls not being called during device disable.
| -rw-r--r-- | sys/src/9/pc/devvga.c | 7 | ||||
| -rw-r--r-- | sys/src/9/pc/vgavesa.c | 96 |
2 files changed, 33 insertions, 70 deletions
diff --git a/sys/src/9/pc/devvga.c b/sys/src/9/pc/devvga.c index 3867d36dc..5d2ec72c8 100644 --- a/sys/src/9/pc/devvga.c +++ b/sys/src/9/pc/devvga.c @@ -309,6 +309,11 @@ vgactl(Cmdbuf *cb) for(i = 0; vgadev[i]; i++){ if(strcmp(cb->f[1], vgadev[i]->name)) continue; + qlock(&drawlock); + if(waserror()){ + qunlock(&drawlock); + nexterror(); + } if(scr->dev){ if(scr->dev->disable) scr->dev->disable(scr); @@ -319,6 +324,8 @@ vgactl(Cmdbuf *cb) scr->dev = vgadev[i]; if(scr->dev->enable) scr->dev->enable(scr); + qunlock(&drawlock); + poperror(); return; } break; diff --git a/sys/src/9/pc/vgavesa.c b/sys/src/9/pc/vgavesa.c index 794533a9d..ceca04406 100644 --- a/sys/src/9/pc/vgavesa.c +++ b/sys/src/9/pc/vgavesa.c @@ -20,18 +20,11 @@ typedef struct Ureg386 Ureg386; #include "screen.h" enum { - Cdisable = 0, - Cenable, - Cblank, - RealModeBuf = 0x9000, }; static uchar modebuf[0x1000]; static Chan *creg, *cmem; -static QLock vesaq; -static Rendez vesar; -static int vesactl; #define WORD(p) ((p)[0] | ((p)[1]<<8)) #define LONG(p) ((p)[0] | ((p)[1]<<8) | ((p)[2]<<16) | ((p)[3]<<24)) @@ -165,59 +158,9 @@ vesalinear(VGAscr *scr, int, int) scr->softscreen = 1; } -static int -gotctl(void *arg) -{ - return vesactl != *((int*)arg); -} - -static void -vesaproc(void*) -{ - Ureg386 u; - int ctl; - - ctl = Cenable; - while(ctl != Cdisable){ - if(!waserror()){ - sleep(&vesar, gotctl, &ctl); - ctl = vesactl; - - vbesetup(&u, 0x4f10); - if(ctl == Cblank) - u.bx = 0x0101; - else - u.bx = 0x0001; - - /* - * dont wait forever here. some BIOS get stuck - * in i/o poll loop after blank/unblank for some - * reason. (Thinkpad A22p) - */ - procalarm(10000); - vbecall(&u); - - poperror(); - } - procalarm(0); - up->notepending = 0; - } - cclose(cmem); - cclose(creg); - cmem = creg = nil; - qunlock(&vesaq); - - pexit("", 1); -} - static void vesaenable(VGAscr *) { - eqlock(&vesaq); - if(waserror()){ - qunlock(&vesaq); - nexterror(); - } cmem = namec("/dev/realmodemem", Aopen, ORDWR, 0); if(waserror()){ cclose(cmem); @@ -226,29 +169,42 @@ vesaenable(VGAscr *) } creg = namec("/dev/realmode", Aopen, ORDWR, 0); poperror(); - poperror(); - - vesactl = Cenable; - kproc("vesa", vesaproc, nil); } static void vesadisable(VGAscr *) { - vesactl = Cdisable; - wakeup(&vesar); - - /* wait for vesaproc to finish */ - qlock(&vesaq); - qunlock(&vesaq); + if(cmem != nil) + cclose(cmem); + if(creg != nil) + cclose(creg); + cmem = creg = nil; } static void vesablank(VGAscr *, int blank) { - if(vesactl != Cdisable){ - vesactl = blank ? Cblank : Cenable; - wakeup(&vesar); + Ureg386 u; + + vbesetup(&u, 0x4f10); + u.bx = blank ? 0x0101 : 0x0001; + + /* + * dont wait forever when called from mouse kproc. + * some BIOS get stuck in i/o poll loop after + * blank/unblank for some reason. (Thinkpad A22p) + */ + if(up->kp) + procalarm(10000); + + if(!waserror()){ + vbecall(&u); + poperror(); + } + + if(up->kp){ + procalarm(0); + up->notepending = 0; } } |
