📄 s3ramdacs.c
字号:
16-bit color, 1 VCLK/pixel */ xf86setdaccomm(tmp | 0x30); /* set mode 3 */ } delay_blank = 2; break; case 32: /* set Mode 11: 24/32-bit color, 2 VCLK/pixel */ outb(vgaCRReg, 0x70 | invert_vclk); xf86setdaccomm(tmp | 0x50); /* set mode 5 */ if (mode->HDisplay > 640) /* why not for 640 ? tsk */ delay_blank = 2; break; default: ; } outb(vgaCRIndex, 0x6d); outb(vgaCRReg, delay_blank); } else { /* don't know */ } } /* end of s3PixelMultiplexing */ outb(0x3C4, 1); outb(0x3C5, tmp2); /* unblank the screen */ return 1;}/********************************************************\ SC15025_DAC \********************************************************/static Bool SC15025_Probe(){ /* What chipsets use this? so we can do a quick check */ Bool found = FALSE; int i; unsigned char c,id[4]; c = xf86getdaccomm(); xf86setdaccomm(c | 0x10); for (i=0; i<4; i++) { outb(0x3C7, 0x9+i); id[i] = inb(0x3C8); } xf86setdaccomm(c); xf86dactopel(); if (id[0] == 'S' && ((id[1]<<8)|id[2]) == 15025) { /* unique for the SC 15025/26 */ if (id[3] != 'A') { /* version number */ ErrorF( "%s %s: ==> New Sierra SC 15025/26 version (0x%x) found,\n", XCONFIG_PROBED, s3InfoRec.name, id[3]); ErrorF("\tplease report!\n"); } ErrorF("%s %s: Detected a Sierra SC 15025/26 RAMDAC\n", XCONFIG_PROBED, s3InfoRec.name); found = TRUE; } return found; }static int SC15025_PreInit(){ int doubleEdgeLimit; /* Verify that depth is supported by ramdac */ /* all are supported */ /* Set cursor options */ /* none */ /* Check if PixMux is supported and set the PixMux related flags and variables */ /* no PixMux */ /* let OtherClocksSetup() take care of the clock options */ OtherClocksSetup(); /* Make any necessary clock alterations due to multiplexing, clock doubling, etc... s3Probe will do some last minute clock sanity checks when we return */ if (s3InfoRec.dacSpeeds[0] >= 125000) /* -125 */ doubleEdgeLimit = 85000; else if (s3InfoRec.dacSpeeds[0] >= 110000) /* -110 */ doubleEdgeLimit = 65000; else /* -80, -66 */ doubleEdgeLimit = 50000; switch (s3Bpp) { case 1: s3InfoRec.maxClock = s3InfoRec.dacSpeeds[0]; break; case 2: s3InfoRec.maxClock = doubleEdgeLimit; maxRawClock /= 2; break; case 4: s3InfoRec.maxClock = doubleEdgeLimit / 2; maxRawClock /= 4; break; } return 1;}static void SC15025_Restore(){ unsigned char c; c=xf86getdaccomm(); xf86setdaccomm( c | 0x10 ); /* set internal register access */ (void)xf86dactocomm(); outb(0x3c7, 0x8); /* Auxiliary Control Register */ outb(0x3c8, s3DacRegs[1]); outb(0x3c7, 0x10); /* Pixel Repack Register */ outb(0x3c8, s3DacRegs[2]); xf86setdaccomm( c ); xf86setdaccomm(s3DacRegs[0]);}static void SC15025_Save(){ LOCK_SYS_REGS; s3DacRegs[0] = xf86getdaccomm(); xf86setdaccomm((s3DacRegs[0] | 0x10)); (void)xf86dactocomm(); outb(0x3c7,0x8); /* Auxiliary Control Register */ s3DacRegs[1] = inb(0x3c8); outb(0x3c7,0x10); /* Pixel Repack Register */ s3DacRegs[2] = inb(0x3c8); xf86setdaccomm(s3DacRegs[0]); UNLOCK_SYS_REGS;}static int SC15025_Init(DisplayModePtr mode){ unsigned char aux=0, comm=0, prr=0; LOCK_SYS_REGS; if (s3DAC8Bit || s3InfoRec.bitsPerPixel > 8) aux=1; switch (s3InfoRec.bitsPerPixel) { case 8: comm = 0; /* repack mode 0, color mode 0 */ break; case 16: if (s3Weight == RGB16_555) { comm = 0x80; /* repack mode 1a using both clock edges */ } else { /* RGB16_565 */ comm = 0xc0; /* repack mode 1a using both clock edges */ } break; case 32: comm = 0x40; /* repack mode 3a using both clock edges */ prr = 1; break; default: return 0; } comm |= 0x08; /* enable LUT for gamma correction */ xf86setdaccomm(comm | 0x10); outb(0x3c7,0x8); outb(0x3c8,aux); outb(0x3c7,0x10); outb(0x3c8,prr); xf86setdaccomm(comm); return 1;}/*********************************************************\ STG1700_DAC STG1703_DAC \*********************************************************/static Bool STG17xx_Probe(int type){ int found = 0; int cid, did, daccomm, readmask; if (!S3_86x_SERIES(s3ChipId) && !S3_805_I_SERIES(s3ChipId)) return FALSE; readmask = inb(0x3c6); xf86dactopel(); daccomm = xf86getdaccomm(); xf86setdaccommbit(0x10); xf86dactocomm(); inb(0x3c6); outb(0x3c6, 0x00); outb(0x3c6, 0x00); cid = inb(0x3c6); /* company ID */ did = inb(0x3c6); /* device ID */ xf86dactopel(); outb(0x3c6,readmask); if ((cid == 0x44) && (did == 0x00)) { found = STG1700_DAC; } else if ((cid == 0x44) && (did == 0x03)) { found = STG1703_DAC; if (!OFLG_ISSET(CLOCK_OPTION_PROGRAMABLE,&s3InfoRec.clockOptions)) { OFLG_SET(CLOCK_OPTION_STG1703, &s3InfoRec.clockOptions); OFLG_SET(CLOCK_OPTION_PROGRAMABLE, &s3InfoRec.clockOptions); clockchip_probed = XCONFIG_PROBED; } } xf86setdaccomm(daccomm); return (found == type);}static Bool STG1700_Probe(){ if(STG17xx_Probe(STG1700_DAC)) { ErrorF("%s %s: Detected an STG1700 RAMDAC\n", XCONFIG_PROBED, s3InfoRec.name); return TRUE; } else return FALSE;}static Bool STG1703_Probe(){ if(STG17xx_Probe(STG1703_DAC)) { ErrorF("%s %s: Detected an STG1703 RAMDAC\n", XCONFIG_PROBED, s3InfoRec.name); return TRUE; } else return FALSE;}static int STG17xx_PreInit(){ /* Verify that depth is supported by ramdac */ /* all are supported */ /* Set cursor options */ /* none */ /* Check if PixMux is supported and set the PixMux related flags and variables */ if((xf86bpp <= 8) && (S3_x64_SERIES(s3ChipId) || S3_805_I_SERIES(s3ChipId))) { s3ATT498PixMux = TRUE; nonMuxMaxClock = 67500; pixMuxMinClock = 67500; allowPixMuxInterlace = TRUE; allowPixMuxSwitching = TRUE; pixMuxLimitedWidths = FALSE; pixMuxMinWidth = 0; } /* If there is an internal clock, set s3ClockSelectFunc, maxRawClock numClocks and whatever options need to be set. For external clocks, pass the job to OtherClocksSetup() */ if (OFLG_ISSET(CLOCK_OPTION_STG1703, &s3InfoRec.clockOptions)) { unsigned char mi, ml, mh, tmp; int mclk; outb(vgaCRIndex, 0x43); tmp = inb(vgaCRReg); outb(vgaCRReg, tmp & ~0x02); outb(vgaCRIndex, 0x55); tmp = inb(vgaCRReg) & ~0x03; outb(vgaCRReg, tmp | 1); /* set RS2 */ outb(0x3c7, 0x00); /* index high */ outb(0x3c8, 0x48); /* index low */ mi = (inb(0x3c9) >> 4) & 0x03; outb(0x3c8, 0x40 + 2*mi); /* index low */ ml = inb(0x3c9); mh = inb(0x3c9); outb(vgaCRReg, tmp); /* reset RS2 */ mclk = ((((1431818 * ((ml&0x7f) + 2)) / ((mh&0x1f) + 2)) >> ((mh>>5)&0x03)) + 50) / 100; s3ClockSelectFunc = STG1703ClockSelect; numClocks = 3; maxRawClock = 135000; if (xf86Verbose) ErrorF("%s %s: Using STG1703 programmable clock(MCLK%d %02x %02x " "%1.3f MHz)\n",XCONFIG_GIVEN, s3InfoRec.name, mi, ml,mh, mclk/1e3); if (s3InfoRec.s3MClk > 0) { if (xf86Verbose) ErrorF("%s %s: using specified MCLK value of %1.3f MHz for DRAM " "timings\n",XCONFIG_GIVEN, s3InfoRec.name, s3InfoRec.s3MClk / 1000.0); } else s3InfoRec.s3MClk = mclk; } else OtherClocksSetup(); /* Make any necessary clock alterations due to multiplexing, clock doubling, etc... s3Probe will do some last minute clock sanity checks when we return */ if (s3ATT498PixMux) { s3InfoRec.maxClock = s3InfoRec.dacSpeeds[0]; if (s3Bpp == 1) /* XXXX is this right?? */ clockDoublingPossible = TRUE; } else { if (s3InfoRec.dacSpeeds[0] >= 135000) /* 20C498 -13, -15, -17 */ s3InfoRec.maxClock = 110000; else /* 20C498 -11 */ s3InfoRec.maxClock = 80000; /* Halve it for 32bpp */ if (s3Bpp == 4) { s3InfoRec.maxClock /= 2; maxRawClock /= 2; } } return 1;}static void STG17xx_Restore(){ xf86dactopel(); xf86setdaccommbit(0x10); /* enable extended registers */ xf86dactocomm(); inb(0x3c6); /* command reg */ outb(0x3c6, 0x03); /* index low */ outb(0x3c6, 0x00); /* index high */ outb(0x3c6, s3DacRegs[1]); /* primary pixel mode */ outb(0x3c6, s3DacRegs[2]); /* secondary pixel mode */ outb(0x3c6, s3DacRegs[3]); /* PLL control */ usleep(500); /* PLL settling time */ xf86dactopel(); xf86setdaccomm(s3DacRegs[0]);}static void STG17xx_Save(){ xf86dactopel(); s3DacRegs[0] = xf86getdaccomm(); xf86setdaccommbit(0x10); /* enable extended registers */ xf86dactocomm(); inb(0x3c6); /* command reg */ outb(0x3c6, 0x03); /* index low */ outb(0x3c6, 0x00); /* index high */ s3DacRegs[1] = inb(0x3c6); /* primary pixel mode */ s3DacRegs[2] = inb(0x3c6); /* secondary pixel mode */ s3DacRegs[3] = inb(0x3c6); /* PLL control */ xf86dactopel();}static int STG17xx_Init(DisplayModePtr mode){ unsigned char tmp, tmp2; int daccomm; if (s3DAC8Bit) xf86setdaccommbit(0x02); else xf86clrdaccommbit(0x02); daccomm = (xf86getdaccomm() & 0x06) | 0x10; outb(0x3C4, 1); tmp2 = inb(0x3C5); outb(0x3C5, tmp2 | 0x20); /* blank the screen */ if (s3PixelMultiplexing) { /* x64:pixmux */ /* pixmux with 16/32 bpp not possible for 864 ==> only 8bit mode */ daccomm |= 0x08; /* enable extended pixel modes */ xf86setdaccomm(daccomm); /* pixel multiplexing on */ xf86dactocomm(); inb(0x3c6); /* command reg */ outb(0x3c6, 0x03); /* index low */ outb(0x3c6, 0x00); /* index high */ outb(0x3c6, 0x05); /* primary pixel mode */ outb(0x3c6, 0x05); /* secondary pixel mode */ outb(0x3c6, 0x02); /* PLL control for 64-135 MHz pixclk */ uslee
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -