Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – planix.SVN – Blame – /os/branches/feature_posix/sys/src/cmd/aux/vga/ics2494.c – Rev 2

Subversion Repositories planix.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
/*
2
 * Integrated Circuit Systems, Inc.
3
 * ICS2494[A] Dual Video/Memory Clock Generator.
4
 */
5
#include <u.h>
6
#include <libc.h>
7
#include <bio.h>
8
 
9
#include "pci.h"
10
#include "vga.h"
11
 
12
typedef struct {
13
	char*	name[2];
14
	ulong	frequency[16];
15
} Pattern;
16
 
17
static Pattern patterns[] = {
18
	{ "237", "304",
19
	 50350000,  56644000,  65000000,  72000000,  80000000,  89800000,  63000000,  75000000,
20
	 25175000,  28322000,  31500000,  36000000,  40000000,  44900000,  50000000,  65000000,
21
	},
22
 
23
	{ "324", 0,
24
	 50350000,  56644000,  65000000,  72000000,  80000000,  89800000,  63000000,  75000000,
25
	 83078000,  93463000, 100000000, 104000000, 108000000, 120000000, 130000000, 134700000,
26
	},
27
 
28
	{ 0,
29
	},
30
};
31
 
32
static void
33
init(Vga* vga, Ctlr* ctlr)
34
{
35
	Pattern *pattern;
36
	char *p;
37
	int f, index, divisor, maxdivisor;
38
 
39
	if(ctlr->flag & Finit)
40
		return;
41
 
42
	if(vga->f[0] == 0)
43
		vga->f[0] = vga->mode->frequency;
44
 
45
	if((p = strchr(ctlr->name, '-')) == 0)
46
		error("%s: unknown pattern\n", ctlr->name);
47
	p++;
48
 
49
	for(pattern = patterns; pattern->name[0]; pattern++){
50
		if(strcmp(pattern->name[0], p) == 0)
51
			break;
52
		if(pattern->name[1] && strcmp(pattern->name[1], p) == 0)
53
			break;
54
	}
55
	if(pattern->name[0] == 0)
56
		error("%s: unknown pattern\n", ctlr->name);
57
 
58
	maxdivisor = 1;
59
	if(vga->ctlr && (vga->ctlr->flag & Hclkdiv))
60
		maxdivisor = 8;
61
	for(index = 0; index < 16; index++){
62
		for(divisor = 1; divisor <= maxdivisor; divisor <<= 1){
63
			f = vga->f[0] - pattern->frequency[index]/divisor;
64
			if(f < 0)
65
				f = -f;
66
			if(f < 1000000){
67
				/*vga->f = pattern->frequency[index];*/
68
				vga->d[0] = divisor;
69
				vga->i[0] = index;
70
 
71
				ctlr->flag |= Finit;
72
				return;
73
			}
74
		}
75
	}
76
	error("%s: can't find frequency %ld\n", ctlr->name, vga->f[0]);
77
}
78
 
79
Ctlr ics2494 = {
80
	"ics2494",			/* name */
81
	0,				/* snarf */
82
	0,				/* options */
83
	init,				/* init */
84
	0,				/* load */
85
	0,				/* dump */
86
};
87
 
88
Ctlr ics2494a = {
89
	"ics2494a",			/* name */
90
	0,				/* snarf */
91
	0,				/* options */
92
	init,				/* init */
93
	0,				/* load */
94
	0,				/* dump */
95
};