/* * VT1625/VT1625S sense connected TV outputs. * * The lower six bits of the return byte stand for each of the six DACs: * - bit 0: DACf (Cb) * - bit 1: DACe (Cr) * - bit 2: DACd (Y) * - bit 3: DACc (Composite) * - bit 4: DACb (S-Video C) * - bit 5: DACa (S-Video Y) * * If a bit is 0 it means a cable is connected. Note the VT1625S only has * four DACs, corresponding to bit 0-3 above. */ static CARD8 VT1625DACSenseI2C(I2CDevPtr pDev) { CARD8 power, status, overflow, dacPresent; xf86I2CReadByte(pDev, 0x0E, &power); // save power state // VT1625S will always report 0 for bits 4 and 5 of the status register as // it only has four DACs instead of six. This will result in a false // positive for the S-Video cable. It will also do this on the power // register, which is abused to check which DACs are actually present. xf86I2CWriteByte(pDev, 0x0E, 0xFF); xf86I2CReadByte(pDev, 0x0E, &dacPresent); xf86I2CWriteByte(pDev, 0x0E, 0x00); // power on DACs/circuits xf86I2CReadByte(pDev, 0x1C, &overflow); // save overflow reg // (DAC sense bit should be off) xf86I2CWriteByte(pDev, 0x1C, 0x80); // enable DAC sense bit xf86I2CWriteByte(pDev, 0x1C, overflow); // disable DAC sense bit xf86I2CReadByte(pDev, 0x0F, &status); // read connection status xf86I2CWriteByte(pDev, 0x0E, power); // restore power state status |= ~dacPresent; return (status & 0x3F); }
static void VT1625Power(ScrnInfoPtr pScrn, Bool On) { VIABIOSInfoPtr pBIOSInfo = VIAPTR(pScrn)->pBIOSInfo; DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VT1625Power\n")); if (On) xf86I2CWriteByte(pBIOSInfo->TVI2CDev, 0x0E, 0x00); else xf86I2CWriteByte(pBIOSInfo->TVI2CDev, 0x0E, 0x3F); }
/* * For VT1621 the same as for VT1622/VT1622A/VT1623, but result is different. * Still needs testing on VT1621, of course. */ static CARD8 VT162xDACSenseI2C(I2CDevPtr pDev) { CARD8 save, sense; xf86I2CReadByte(pDev, 0x0E, &save); xf86I2CWriteByte(pDev, 0x0E, 0x00); xf86I2CWriteByte(pDev, 0x0E, 0x80); xf86I2CWriteByte(pDev, 0x0E, 0x00); xf86I2CReadByte(pDev, 0x0F, &sense); xf86I2CWriteByte(pDev, 0x0E, save); return (sense & 0x0F); }
static void VT162xSetSubCarrier(I2CDevPtr pDev, CARD32 SubCarrier) { xf86I2CWriteByte(pDev, 0x16, SubCarrier & 0xFF); xf86I2CWriteByte(pDev, 0x17, (SubCarrier >> 8) & 0xFF); xf86I2CWriteByte(pDev, 0x18, (SubCarrier >> 16) & 0xFF); xf86I2CWriteByte(pDev, 0x19, (SubCarrier >> 24) & 0xFF); }
int adt7473_set_fanspeed_pwm(I2CDevPtr dev, float speed) { I2CByte value = (int)speed * 255/100; I2CByte cfg, max_dutycycle; xf86I2CReadByte(dev, ADT7473_REG_PWM1_CFG, &cfg); cfg |= 0xe0; /* Put PWM1 in manual mode; this disables automatic control */ xf86I2CWriteByte(dev, ADT7473_REG_PWM1_CFG, cfg); /* If the MAX dutycycle is lower than 0xff (100%), set it to 0xff */ xf86I2CReadByte(dev, ADT7473_REG_PWM1_MAX_DUTYCYCLE, &max_dutycycle); if(max_dutycycle < 0xff) xf86I2CWriteByte(dev, ADT7473_REG_PWM1_MAX_DUTYCYCLE, 0xff); xf86I2CWriteByte(dev, ADT7473_REG_PWM1_DUTYCYCLE, value); return 1; }
static void VT1621ModeI2C(ScrnInfoPtr pScrn, DisplayModePtr mode) { VIABIOSInfoPtr pBIOSInfo = VIAPTR(pScrn)->pBIOSInfo; struct VT1621TableRec Table = VT1621Table[VT1621ModeIndex(pScrn, mode)]; CARD8 i; DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VT1621ModeI2C\n")); for (i = 0; i < 0x16; i++) xf86I2CWriteByte(pBIOSInfo->TVI2CDev, i, Table.TV[i]); VT162xSetSubCarrier(pBIOSInfo->TVI2CDev, Table.SubCarrier); /* Skip reserved (1A) and version ID (1B). */ xf86I2CWriteByte(pBIOSInfo->TVI2CDev, 0x1C, Table.TV[0x1C]); /* Skip software reset (1D). */ for (i = 0x1E; i < 0x24; i++) xf86I2CWriteByte(pBIOSInfo->TVI2CDev, i, Table.TV[i]); /* Write some zeroes? */ xf86I2CWriteByte(pBIOSInfo->TVI2CDev, 0x24, 0x00); for (i = 0; i < 0x08; i++) xf86I2CWriteByte(pBIOSInfo->TVI2CDev, 0x4A + i, 0x00); if (pBIOSInfo->TVOutput == TVOUTPUT_COMPOSITE) for (i = 0; i < 0x10; i++) xf86I2CWriteByte(pBIOSInfo->TVI2CDev, 0x52 + i, Table.TVC[i]); else for (i = 0; i < 0x10; i++) xf86I2CWriteByte(pBIOSInfo->TVI2CDev, 0x52 + i, Table.TVS[i]); /* Turn on all Composite and S-Video output. */ xf86I2CWriteByte(pBIOSInfo->TVI2CDev, 0x0E, 0x00); if (pBIOSInfo->TVDotCrawl) { if (Table.DotCrawlSubCarrier) { xf86I2CReadByte(pBIOSInfo->TVI2CDev, 0x11, &i); xf86I2CWriteByte(pBIOSInfo->TVI2CDev, 0x11, i | 0x08); VT162xSetSubCarrier(pBIOSInfo->TVI2CDev, Table.DotCrawlSubCarrier); } else xf86DrvMsg(pScrn->scrnIndex, X_INFO, "This mode does not currently " "support DotCrawl suppression.\n"); } }
static void VT162xRestore(ScrnInfoPtr pScrn) { VIABIOSInfoPtr pBIOSInfo = VIAPTR(pScrn)->pBIOSInfo; int i; DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VT162xRestore\n")); for (i = 0; i < pBIOSInfo->TVNumRegs; i++) xf86I2CWriteByte(pBIOSInfo->TVI2CDev, i, pBIOSInfo->TVRegs[i]); }
void adt7473_set_fanspeed_mode(I2CDevPtr dev, int mode) { I2CByte cfg; xf86I2CReadByte(dev, ADT7473_REG_PWM1_CFG, &cfg); /* Clear the pwm1 config bits */ cfg&=~(0xF << 5); if(mode==1) cfg|=0x7 << 5; /* manual */ else cfg|=0x6 << 5; /* auto */ xf86I2CWriteByte(dev, ADT7473_REG_PWM1_CFG, cfg); }
/* * Also suited for VT1622A, VT1623, VT1625. */ static void VT1622ModeI2C(ScrnInfoPtr pScrn, DisplayModePtr mode) { VIABIOSInfoPtr pBIOSInfo = VIAPTR(pScrn)->pBIOSInfo; struct VT162XTableRec Table; CARD8 save, i; DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VT1622ModeI2C\n")); if (pBIOSInfo->TVEncoder == VIA_VT1622) Table = VT1622Table[VT1622ModeIndex(pScrn, mode)]; else if (pBIOSInfo->TVEncoder == VIA_VT1625) Table = VT1625Table[VT1622ModeIndex(pScrn, mode)]; else /* VT1622A/VT1623 */ Table = VT1623Table[VT1622ModeIndex(pScrn, mode)]; /* TV reset. */ xf86I2CWriteByte(pBIOSInfo->TVI2CDev, 0x1D, 0x00); xf86I2CWriteByte(pBIOSInfo->TVI2CDev, 0x1D, 0x80); for (i = 0; i < 0x16; i++) xf86I2CWriteByte(pBIOSInfo->TVI2CDev, i, Table.TV1[i]); VT162xSetSubCarrier(pBIOSInfo->TVI2CDev, Table.SubCarrier); xf86I2CWriteByte(pBIOSInfo->TVI2CDev, 0x1A, Table.TV1[0x1A]); /* Skip version ID. */ xf86I2CWriteByte(pBIOSInfo->TVI2CDev, 0x1C, Table.TV1[0x1C]); /* Skip software reset. */ for (i = 0x1E; i < 0x30; i++) xf86I2CWriteByte(pBIOSInfo->TVI2CDev, i, Table.TV1[i]); for (i = 0; i < 0x1B; i++) xf86I2CWriteByte(pBIOSInfo->TVI2CDev, 0x4A + i, Table.TV2[i]); /* Turn on all Composite and S-Video output. */ xf86I2CWriteByte(pBIOSInfo->TVI2CDev, 0x0E, 0x00); if (pBIOSInfo->TVDotCrawl) { if (Table.DotCrawlSubCarrier) { xf86I2CReadByte(pBIOSInfo->TVI2CDev, 0x11, &save); xf86I2CWriteByte(pBIOSInfo->TVI2CDev, 0x11, save | 0x08); VT162xSetSubCarrier(pBIOSInfo->TVI2CDev, Table.DotCrawlSubCarrier); } else xf86DrvMsg(pScrn->scrnIndex, X_INFO, "This mode does not currently " "support DotCrawl suppression.\n"); } if (pBIOSInfo->TVOutput == TVOUTPUT_RGB) { xf86I2CWriteByte(pBIOSInfo->TVI2CDev, 0x02, 0x2A); xf86I2CWriteByte(pBIOSInfo->TVI2CDev, 0x65, Table.RGB[0]); xf86I2CWriteByte(pBIOSInfo->TVI2CDev, 0x66, Table.RGB[1]); xf86I2CWriteByte(pBIOSInfo->TVI2CDev, 0x67, Table.RGB[2]); if (Table.RGB[3]) xf86I2CWriteByte(pBIOSInfo->TVI2CDev, 0x27, Table.RGB[3]); if (Table.RGB[4]) xf86I2CWriteByte(pBIOSInfo->TVI2CDev, 0x2B, Table.RGB[4]); if (Table.RGB[5]) xf86I2CWriteByte(pBIOSInfo->TVI2CDev, 0x2C, Table.RGB[5]); if (pBIOSInfo->TVEncoder == VIA_VT1625) { if (pBIOSInfo->TVType < TVTYPE_480P) { xf86I2CWriteByte(pBIOSInfo->TVI2CDev, 0x02, 0x12); xf86I2CWriteByte(pBIOSInfo->TVI2CDev, 0x23, 0x7E); xf86I2CWriteByte(pBIOSInfo->TVI2CDev, 0x4A, 0x85); xf86I2CWriteByte(pBIOSInfo->TVI2CDev, 0x4B, 0x0A); xf86I2CWriteByte(pBIOSInfo->TVI2CDev, 0x4E, 0x00); } else { xf86I2CWriteByte(pBIOSInfo->TVI2CDev, 0x02, 0x12); xf86I2CWriteByte(pBIOSInfo->TVI2CDev, 0x4A, 0x85); xf86I2CWriteByte(pBIOSInfo->TVI2CDev, 0x4B, 0x0A); } } } else if (pBIOSInfo->TVOutput == TVOUTPUT_YCBCR) { xf86I2CWriteByte(pBIOSInfo->TVI2CDev, 0x02, 0x03); xf86I2CWriteByte(pBIOSInfo->TVI2CDev, 0x65, Table.YCbCr[0]); xf86I2CWriteByte(pBIOSInfo->TVI2CDev, 0x66, Table.YCbCr[1]); xf86I2CWriteByte(pBIOSInfo->TVI2CDev, 0x67, Table.YCbCr[2]); if (pBIOSInfo->TVEncoder == VIA_VT1625) { if (pBIOSInfo->TVType < TVTYPE_480P) { xf86I2CWriteByte(pBIOSInfo->TVI2CDev, 0x23, 0x7E); xf86I2CWriteByte(pBIOSInfo->TVI2CDev, 0x4E, 0x00); } } } /* Configure flicker filter. */ xf86I2CReadByte(pBIOSInfo->TVI2CDev, 0x03, &save); save &= 0xFC; if (pBIOSInfo->TVDeflicker == 1) save |= 0x01; else if (pBIOSInfo->TVDeflicker == 2) save |= 0x02; xf86I2CWriteByte(pBIOSInfo->TVI2CDev, 0x03, save); }