1 #include <u.h> 2 #include <libc.h> 3 4 #include "vga.h" 5 6 /* 7 * Sierra SC1502[56] HiCOLOR-24 Palette. 8 */ 9 static void 10 pixmask(void) 11 { 12 inportb(PaddrW); 13 } 14 15 static void 16 commandrw(void) 17 { 18 int i; 19 20 pixmask(); 21 for(i = 0; i < 4; i++) 22 inportb(Pixmask); 23 } 24 25 static uchar 26 commandr(void) 27 { 28 uchar command; 29 30 commandrw(); 31 command = inportb(Pixmask); 32 pixmask(); 33 34 return command; 35 } 36 37 static void 38 commandw(uchar command) 39 { 40 commandrw(); 41 outportb(Pixmask, command); 42 pixmask(); 43 } 44 45 static void 46 options(Vga *vga, Ctlr *ctlr) 47 { 48 USED(vga); 49 verbose("%s->options\n", ctlr->name); 50 51 ctlr->flag |= Foptions; 52 } 53 54 static void 55 init(Vga *vga, Ctlr *ctlr) 56 { 57 ulong pclk; 58 char *p; 59 60 verbose("%s->init\n", ctlr->name); 61 /* 62 * Part comes in -125, -110, -80, and -66MHz speed-grades. 63 * Work out the part speed-grade from name. Name can have, 64 * e.g. '-110' on the end for 100MHz part. 65 */ 66 pclk = 66000000; 67 if(p = strrchr(ctlr->name, '-')) 68 pclk = strtoul(p+1, 0, 0) * 1000000; 69 70 /* 71 * If we don't already have a desired pclk, 72 * take it from the mode. 73 * Check it's within range. 74 */ 75 if(vga->f == 0) 76 vga->f = vga->mode->frequency; 77 if(vga->f > pclk) 78 error("%s: invalid pclk - %ld\n", ctlr->name, vga->f); 79 } 80 81 static void 82 load(Vga *vga, Ctlr *ctlr) 83 { 84 uchar aux, command; 85 86 verbose("%s->load\n", ctlr->name); 87 88 aux = 0x00; 89 USED(vga); 90 /* 91 if(vga->mode->z == 8) 92 aux = 0x01; 93 */ 94 commandrw(); 95 command = inportb(Pixmask); 96 outportb(Pixmask, command|0x18); 97 outportb(PaddrR, 0x08); 98 outportb(PaddrW, aux); 99 commandw(command); 100 } 101 102 static void 103 dump(Vga *vga, Ctlr *ctlr) 104 { 105 int i; 106 uchar command; 107 108 USED(vga); 109 110 printitem(ctlr->name, "command"); 111 command = commandr(); 112 printreg(command); 113 114 printitem(ctlr->name, "index08"); 115 commandw(command|0x10); 116 for(i = 0x08; i < 0x11; i++){ 117 outportb(PaddrR, i); 118 printreg(inportb(PaddrW)); 119 } 120 commandw(command); 121 } 122 123 Ctlr sc15025 = { 124 "sc15025", /* name */ 125 0, /* snarf */ 126 options, /* options */ 127 init, /* init */ 128 load, /* load */ 129 dump, /* dump */ 130 }; 131