xref: /plan9/sys/src/cmd/aux/vga/att20c49x.c (revision 9a747e4fd48b9f4522c70c07e8f882a15030f964)
1 #include <u.h>
2 #include <libc.h>
3 #include <bio.h>
4 
5 #include "pci.h"
6 #include "vga.h"
7 
8 /*
9  * ATT20C490 and ATT20C49[12] True-Color CMOS RAMDACs.
10  */
11 enum {
12 	Cr0		= 0x00,		/* Control register 0 */
13 };
14 
15 static void
init(Vga * vga,Ctlr * ctlr)16 init(Vga* vga, Ctlr* ctlr)
17 {
18 	ulong pclk;
19 	char *p;
20 
21 	/*
22 	 * Part comes in -100, -80, -65 and -55MHz speed-grades.
23 	 * Work out the part speed-grade from name.  Name can have,
24 	 * e.g. '-100' on the end  for 100MHz part.
25 	 */
26 	pclk = 55000000;
27 	if(p = strrchr(ctlr->name, '-'))
28 		pclk = strtoul(p+1, 0, 0) * 1000000;
29 
30 	/*
31 	 * If we don't already have a desired pclk,
32 	 * take it from the mode.
33 	 * Check it's within range.
34 	 */
35 	if(vga->f == 0)
36 		vga->f[0] = vga->mode->frequency;
37 	if(vga->f[0] > pclk)
38 		error("%s: invalid pclk - %ld\n", ctlr->name, vga->f[0]);
39 }
40 
41 static void
load(Vga * vga,Ctlr * ctlr)42 load(Vga* vga, Ctlr* ctlr)
43 {
44 	uchar mode, x;
45 
46 	/*
47 	 * Put the chip to sleep if possible.
48 	 */
49 	if(ctlr->name[8] == '1'){
50 		x = attdaci(Cr0);
51 		attdaco(Cr0, x|0x04);
52 	}
53 
54 	/*
55 	 * Set the mode in the RAMDAC, setting 6/8-bit colour
56 	 * as appropriate and waking the chip back up.
57 	 */
58 	mode = 0x00;
59 	if(vga->mode->z == 8 && ctlr->name[8] == '1' && 0)
60 		mode |= 0x02;
61 	attdaco(Cr0, mode);
62 }
63 
64 static void
dump(Vga *,Ctlr * ctlr)65 dump(Vga*, Ctlr* ctlr)
66 {
67 	printitem(ctlr->name, "Cr0");
68 	printreg(attdaci(Cr0));
69 }
70 
71 Ctlr att20c490 = {
72 	"att20c490",			/* name */
73 	0,				/* snarf */
74 	0,				/* options */
75 	init,				/* init */
76 	load,				/* load */
77 	dump,				/* dump */
78 };
79 
80 Ctlr att20c491 = {
81 	"att20c491",			/* name */
82 	0,				/* snarf */
83 	0,				/* options */
84 	init,				/* init */
85 	load,				/* load */
86 	dump,				/* dump */
87 };
88 
89 Ctlr att20c492 = {
90 	"att20c492",			/* name */
91 	0,				/* snarf */
92 	0,				/* options */
93 	init,				/* init */
94 	load,				/* load */
95 	dump,				/* dump */
96 };
97