crt55 = vgaxi(Crtx, 0x55) & 0xFC;
if((reg & 0x0F) == Status){
/*
* 1,2: Set indirect addressing for Status or
* Cmd[34] - set bit7 of Cr0.
*/
vgaxo(Crtx, 0x55, crt55|((Cmd0>>2) & 0x03));
cr0 = vgai(dacxreg[Cmd0 & 0x03])|0x80;
vgao(dacxreg[Cmd0 & 0x03], cr0);
/*
* 3,4: Set the index into the Write register,
* index == 0x00 for Status, 0x01 for Cmd3,
* 0x02 for Cmd4.
*/
vgaxo(Crtx, 0x55, crt55|((AddrW>>2) & 0x03));
vgao(dacxreg[AddrW & 0x03], (reg>>4) & 0x0F);
/*
* 5,6: Get the contents of the appropriate
* register at 0x0A.
*/
}
/*
* Work out the part speed-grade from name. Name can have,
* e.g. '-135' on the end for 135MHz part.
*/
grade = 110000000;
if(p = strrchr(ctlr->name, '-'))
grade = strtoul(p+1, 0, 0) * 1000000;
/*
* If we don't already have a desired pclk,
* take it from the mode.
* Check it's within range.
*/
if(vga->f[0] == 0)
vga->f[0] = vga->mode->frequency;
if(vga->f[0] > grade)
error("%s: invalid pclk - %ld\n", ctlr->name, vga->f[0]);
/*
* Determine whether to use clock-doubler or not.
*/
if((ctlr->flag & Uclk2) == 0 && vga->f[0] > 67500000){
vga->f[0] /= 2;
resyncinit(vga, ctlr, Uclk2, 0);
}
ctlr->flag |= Finit;
}
static void
load(Vga*, Ctlr* ctlr)
{
uchar x;
/*
* Put the chip to sleep before (possibly) changing the clock-source
* to ensure the integrity of the palette.
*/
x = bt485i(Cmd0);
bt485o(Cmd0, x|0x01); /* sleep mode */
/*
* Set the clock-source, clock-doubler and frequency
* appropriately:
* if using the pixel-port, use Pclock1;
* use the doubler if fvco > 67.5MHz.
* set the frequency.
*/
x = bt485i(Cmd2);
if(ctlr->flag & Uenhanced)
x |= 0x10; /* Pclock1 */
else
x &= ~0x10;
bt485o(Cmd2, x);
x = bt485i(Cmd3);
if(ctlr->flag & Uclk2)
x |= 0x08; /* clock-doubler */
else
x &= ~0x08;
bt485o(Cmd3, x);
/*
* Set 4:1 multiplex and portselect bits on the
* Bt485 appropriately for using the pixel-port.
*/
x = bt485i(Cmd2);
if(ctlr->flag & Uenhanced){
bt485o(Cmd1, 0x40); /* 4:1 multiplex */
x |= 0x20; /* portselect */
}
else{
bt485o(Cmd1, 0x00);
x &= ~0x20;
}
bt485o(Cmd2, x);
x = bt485i(Cmd4);
if(ctlr->flag & Uenhanced)
x |= 0x01;
else
x &= ~0x01;
bt485o(Cmd4, x);
/*
* All done, wake the chip back up.
* Set 6/8-bit colour as appropriate.
*/
x = bt485i(Cmd0) & ~0x01;
/*if(vga->mode.z == 8)
x |= 0x02;
else*/
x &= ~0x02;
bt485o(Cmd0, x);