23 #define outDAC1064 matroxfb_DAC_out
24 #define inDAC1064 matroxfb_DAC_in
26 #define DAC1064_OPT_SCLK_PCI 0x00
27 #define DAC1064_OPT_SCLK_PLL 0x01
28 #define DAC1064_OPT_SCLK_EXT 0x02
29 #define DAC1064_OPT_SCLK_MASK 0x03
30 #define DAC1064_OPT_GDIV1 0x04
31 #define DAC1064_OPT_GDIV3 0x00
32 #define DAC1064_OPT_MDIV1 0x08
33 #define DAC1064_OPT_MDIV2 0x00
34 #define DAC1064_OPT_RESERVED 0x10
37 unsigned int freq,
unsigned int fmax,
38 unsigned int *
in,
unsigned int *feed,
48 fvco = PLL_calcclock(minfo, freq, fmax, in, feed, &p);
63 static
const unsigned char MGA1064_DAC_regs[] = {
74 static const unsigned char MGA1064_DAC[] = {
85 0x00, 0x00, 0xFF, 0xFF};
87 static void DAC1064_setpclk(
struct matrox_fb_info *minfo,
unsigned long fout)
93 DAC1064_calcclock(minfo, fout, minfo->max_pixel_clock, &m, &n, &p);
94 minfo->
hw.DACclk[0] = m;
95 minfo->
hw.DACclk[1] = n;
96 minfo->
hw.DACclk[2] = p;
107 if (minfo->devflags.noinit) {
117 if (oscinfo & DAC1064_OPT_GDIV1)
119 if (oscinfo & DAC1064_OPT_MDIV1)
121 if (oscinfo & DAC1064_OPT_RESERVED)
123 if ((oscinfo & DAC1064_OPT_SCLK_MASK) == DAC1064_OPT_SCLK_PLL) {
126 unsigned int m,
n,
p;
141 DAC1064_calcclock(minfo, fmem, minfo->max_pixel_clock, &m, &n, &p);
145 for (clk = 65536; clk; --clk) {
155 mx |= oscinfo & DAC1064_OPT_SCLK_MASK;
163 #ifdef CONFIG_FB_MATROX_G
172 c2_ctl = hw->
crtc2.ctl & ~0x4007;
175 pixelmnp = minfo->
crtc1.mnp;
176 videomnp = minfo->
crtc2.mnp;
180 }
else if (minfo->
crtc2.pixclock == minfo->
features.pll.ref_freq) {
182 }
else if (videomnp == pixelmnp) {
185 if (0 == ((videomnp ^ pixelmnp) & 0xFFFFFF00)) {
190 pixelmnp += 0x000100;
206 if (c2_ctl != hw->
crtc2.ctl) {
207 hw->
crtc2.ctl = c2_ctl;
211 pxc = minfo->
crtc1.pixclock;
213 pxc = minfo->
crtc2.pixclock;
218 }
else if (pxc < 55000) {
220 }
else if (pxc < 70000) {
222 }
else if (pxc < 85000) {
224 }
else if (pxc < 100000) {
226 }
else if (pxc < 115000) {
228 }
else if (pxc < 125000) {
237 }
else if (pxc < 65000) {
239 }
else if (pxc < 85000) {
241 }
else if (pxc < 105000) {
243 }
else if (pxc < 135000) {
245 }
else if (pxc < 160000) {
247 }
else if (pxc < 175000) {
263 #ifdef CONFIG_FB_MATROX_G
268 switch (minfo->
outputs[0].src) {
277 switch (minfo->
outputs[1].src) {
292 switch (minfo->
outputs[2].src) {
311 g450_set_plls(minfo);
337 outDAC1064(minfo, 0x20, 0x04);
338 outDAC1064(minfo, 0x1F, minfo->
devflags.dfp_type);
361 if (minfo->
fbcon.var.green.length == 5)
381 DAC1064_global_init(minfo);
394 for (i = 0; i < 256; i++) {
399 }
else if (minfo->
fbcon.var.bits_per_pixel > 8) {
400 if (minfo->
fbcon.var.green.length == 5) {
403 for (i = 0; i < 32; i++) {
405 hw->
DACpal[i * 3 + 0] = i << 3;
406 hw->
DACpal[i * 3 + 1] = i << 3;
407 hw->
DACpal[i * 3 + 2] = i << 3;
409 hw->
DACpal[(i + 128) * 3 + 0] = i << 3;
410 hw->
DACpal[(i + 128) * 3 + 1] = i << 3;
411 hw->
DACpal[(i + 128) * 3 + 2] = i << 3;
416 for (i = 0; i < 64; i++) {
417 hw->
DACpal[i * 3 + 0] = i << 3;
418 hw->
DACpal[i * 3 + 1] = i << 2;
419 hw->
DACpal[i * 3 + 2] = i << 3;
448 for (i = 0; i <
sizeof(MGA1064_DAC_regs); i++) {
450 outDAC1064(minfo, MGA1064_DAC_regs[i], hw->
DACreg[i]);
454 DAC1064_global_restore(minfo);
469 for (i = 0; i <
sizeof(MGA1064_DAC_regs); i++) {
470 dprintk(
"R%02X=%02X ", MGA1064_DAC_regs[i], minfo->
hw.DACreg[i]);
474 for (i = 0; i < 6; i++)
475 dprintk(
"C%02X=%02X ", i, minfo->
hw.DACclk[i]);
481 #define minfo ((struct matrox_fb_info*)out)
487 DAC1064_setpclk(minfo, m->
pixclock);
491 for (i = 0; i < 3; i++)
493 for (tmout = 500000; tmout; tmout--) {
509 .
name =
"Primary output",
510 .compute = m1064_compute,
513 #ifdef CONFIG_FB_MATROX_G
514 static int g450_compute(
void* out,
struct my_timming* m) {
515 #define minfo ((struct matrox_fb_info*)out)
527 .
name =
"Primary output",
528 .compute = g450_compute,
534 #ifdef CONFIG_FB_MATROX_MYSTIQUE
541 if (DAC1064_init_1(minfo, m))
return 1;
552 if (DAC1064_init_2(minfo, m)) return 1;
557 #ifdef CONFIG_FB_MATROX_G
564 if (DAC1064_init_1(minfo, m)) return 1;
576 if (DAC1064_init_2(minfo, m)) return 1;
581 #ifdef CONFIG_FB_MATROX_MYSTIQUE
597 DAC1064_setmclk(minfo, DAC1064_OPT_MDIV2 | DAC1064_OPT_GDIV3 | DAC1064_OPT_SCLK_PLL, 133333);
601 #ifdef CONFIG_FB_MATROX_G
603 static int x7AF4 = 0x10;
606 static int def50 = 0;
625 outDAC1064(minfo, reg++, m);
626 outDAC1064(minfo, reg++, n);
627 outDAC1064(minfo, reg, p);
632 switch (flags & 0x03) {
634 case 0x01: selClk |= 4;
break;
635 default: selClk |= 0x0C;
break;
638 for (clk = 500000; clk; clk--) {
646 switch (flags & 0x0C) {
655 static void MGAG100_setPixClock(
const struct matrox_fb_info *minfo,
int flags,
658 unsigned int m,
n,
p;
662 DAC1064_calcclock(minfo, freq, minfo->max_pixel_clock, &m, &n, &p);
663 MGAG100_progPixClock(minfo, flags, m, n, p);
667 #ifdef CONFIG_FB_MATROX_MYSTIQUE
670 static const int vxres_mystique[] = { 512, 640, 768, 800, 832, 960,
671 1024, 1152, 1280, 1600, 1664, 1920,
679 minfo->
capable.vxres = vxres_mystique;
681 minfo->outputs[0].output = &m1064;
682 minfo->outputs[0].
src = minfo->outputs[0].default_src;
683 minfo->outputs[0].
data = minfo;
686 if (minfo->devflags.noinit)
690 if (minfo->devflags.novga)
692 if (minfo->devflags.nobios)
694 if (minfo->devflags.nopciretry)
711 MGA1064_ramdac_init(minfo);
715 #ifdef CONFIG_FB_MATROX_G
723 if (((minfo->
values.reg.opt3 & 0x000003) == 0x000003) ||
724 ((minfo->
values.reg.opt3 & 0x000C00) == 0x000C00) ||
725 ((minfo->
values.reg.opt3 & 0x300000) == 0x300000)) {
748 minfo->
hw.MXoptionReg &= ~0x001F8000;
752 minfo->
hw.MXoptionReg &= ~0x00207E00;
753 minfo->
hw.MXoptionReg |= 0x00207E00 & minfo->
values.reg.opt;
768 if (minfo->
values.memory.ddr && (!minfo->
values.memory.emrswen || !minfo->
values.memory.dll)) {
775 minfo->
hw.MXoptionReg |= 0x001F8000 & minfo->
values.reg.opt;
782 if (minfo->
values.reg.mctlwtst != minfo->
values.reg.mctlwtst_core) {
795 minfo->
hw.MXoptionReg &= 0xC0000100;
796 minfo->
hw.MXoptionReg |= 0x00000020;
798 minfo->
hw.MXoptionReg &= ~0x00000100;
800 minfo->
hw.MXoptionReg &= ~0x40000000;
802 minfo->
hw.MXoptionReg |= 0x20000000;
803 minfo->
hw.MXoptionReg |= minfo->
values.reg.opt & 0x03400040;
818 g450_mclk_init(minfo);
819 g450_memory_init(minfo);
839 static const int vxres_g100[] = { 512, 640, 768, 800, 832, 960,
840 1024, 1152, 1280, 1600, 1664, 1920,
852 if (minfo->devflags.g450dac) {
853 minfo->
features.pll.vco_freq_min = 130000;
855 minfo->
features.pll.vco_freq_min = 62000;
857 if (!minfo->
features.pll.ref_freq) {
858 minfo->
features.pll.ref_freq = 27000;
860 minfo->
features.pll.feed_div_min = 7;
861 minfo->
features.pll.feed_div_max = 127;
863 minfo->
features.pll.in_div_max = 31;
864 minfo->
features.pll.post_shift_max = 3;
868 minfo->
capable.vxres = vxres_g100;
873 minfo->
outputs[0].output = &g450out;
875 minfo->
outputs[0].output = &m1064;
878 minfo->
outputs[0].data = minfo;
901 DAC1064_setmclk(minfo, DAC1064_OPT_MDIV2 | DAC1064_OPT_GDIV3 | DAC1064_OPT_SCLK_PCI, 133333);
926 mga_writeb(minfo->
video.vbase, 0x0000, 0xAA);
927 mga_writeb(minfo->
video.vbase, 0x0800, 0x55);
928 mga_writeb(minfo->
video.vbase, 0x4000, 0x55);
930 if (mga_readb(minfo->
video.vbase, 0x0000) != 0xAA) {
956 reg50 &= ~0x00000100;
987 #ifdef G100_BROKEN_IBM_82351
990 find 1014/22 (
IBM/82351);
992 if (b == minfo->
pcidev->bus->number) {
994 pci_write_config_byte(ibm, 0x41, 0xF4);
1013 DAC1064_setmclk(minfo, DAC1064_OPT_RESERVED | DAC1064_OPT_MDIV2 | DAC1064_OPT_GDIV1 | DAC1064_OPT_SCLK_PLL, 133333);
1016 if (minfo->
devflags.dfp_type == -1) {
1017 minfo->
devflags.dfp_type = inDAC1064(minfo, 0x1F);
1024 MGAG100_setPixClock(minfo, 4, 25175);
1025 MGAG100_setPixClock(minfo, 5, 28322);
1036 #ifdef CONFIG_FB_MATROX_MYSTIQUE
1054 DAC1064_restore_1(minfo);
1056 minfo->crtc1.panpos = -1;
1057 for (i = 0; i < 6; i++)
1059 DAC1064_restore_2(minfo);
1063 #ifdef CONFIG_FB_MATROX_G
1075 pci_write_config_dword(minfo->pcidev, PCI_OPTION_REG, hw->MXoptionReg);
1078 DAC1064_restore_1(minfo);
1080 if (minfo->devflags.support32MB)
1082 minfo->crtc1.panpos = -1;
1083 for (i = 0; i < 6; i++)
1084 mga_setr(M_EXTVGA_INDEX, i, hw->CRTCEXT[i]);
1085 DAC1064_restore_2(minfo);
1089 #ifdef CONFIG_FB_MATROX_MYSTIQUE
1091 MGA1064_preinit, MGA1064_reset, MGA1064_init, MGA1064_restore,
1096 #ifdef CONFIG_FB_MATROX_G
1098 MGAG100_preinit, MGAG100_reset, MGAG100_init, MGAG100_restore,