/*
* Clocks which require fiddling with the S3 registers
* in order to be loaded.
*/
static void
setcrt42(Vga* vga, Ctlr* ctlr, uchar index)
{
trace("%s->clock->setcrt42\n", ctlr->name);
trace("%s->clock->icd2061aload\n", ctlr->name);
/*
* The serial word to be loaded into the icd2061a is
* (2<<21)|(vga->i<<17)|((vga->n)<<10)|(vga->p<<7)|vga->d
* Always select ICD2061A REG2.
*/
sdata = (2<<21)|(vga->i[0]<<17)|((vga->n[0])<<10)|(vga->p[0]<<7)|vga->d[0];
/*
* The display should be already off to enable us to clock the
* serial data word into either MiscW or Crt42.
*
* Set the Misc register to make clock-select-out the contents of
* register Crt42. Must turn the sequencer off when changing bits
* <3:2> of Misc. Also, must set Crt42 to 0 before setting <3:2>
* of Misc due to a hardware glitch.
*/
vgao(MiscW, vga->misc & ~0x0C);
crt42 = vgaxi(Crtx, 0x42) & 0xF0;
outportb(Crtx+1, 0x00);
/*
* Unlock the ICD2061A. The unlock sequence is at least 5 low-to-high
* transitions of CLK with DATA high, followed by a single low-to-high
* transition of CLK with DATA low.
* Using Crt42, CLK is bit0, DATA is bit 1. If we used MiscW, they'd
* be bits 2 and 3 respectively.
*/
outportb(Crtx+1, crt42|0x00); /* -DATA|-CLK */
outportb(Crtx+1, crt42|0x02); /* +DATA|-CLK */
for(i = 0; i < 5; i++){
outportb(Crtx+1, crt42|0x03); /* +DATA|+CLK */
outportb(Crtx+1, crt42|0x02); /* +DATA|-CLK */
}
outportb(Crtx+1, crt42|0x00); /* -DATA|-CLK */
outportb(Crtx+1, crt42|0x01); /* -DATA|+CLK */
/*
* Now write the serial data word, framed by a start-bit and a stop-bit.
* The data is written using a modified Manchester encoding such that a
* data-bit is sampled on the rising edge of CLK and the complement of
* the data-bit is sampled on the previous falling edge of CLK.
*/
outportb(Crtx+1, crt42|0x00); /* -DATA|-CLK (start-bit) */
outportb(Crtx+1, crt42|0x01); /* -DATA|+CLK */
/*
* Crt5C bit 5 is RS4.
* Clear it to select TVP3025 registers for
* the calls to tvp302xo().
*/
crt5c = vgaxi(Crtx, 0x5C);
vgaxo(Crtx, 0x5C, crt5c & ~0x20);
/*
* If we don't already have a desired pclk,
* take it from the mode.
*/
if(vga->f[0] == 0)
vga->f[0] = vga->mode->frequency;
if(vga->f[0] != VgaFreq0 && vga->f[0] != VgaFreq1)
vga->misc |= 0x0C;