trident_i2c.c revision ff89ac2b
1 2#ifdef HAVE_CONFIG_H 3#include "config.h" 4#endif 5 6#include "xf86.h" 7#include "xf86_OSproc.h" 8#include "compiler.h" 9 10#include "xf86Pci.h" 11#include "xf86PciInfo.h" 12 13#include "vgaHW.h" 14 15#include "trident.h" 16#include "trident_regs.h" 17 18static void 19TRIDENTI2CPutBits(I2CBusPtr b, int clock, int data) { 20 unsigned int reg = 0x0C; 21 TRIDENTPtr pTrident = ((TRIDENTPtr)b->DriverPrivate.ptr); 22 int vgaIOBase = VGAHWPTR(pTrident->pScrn)->IOBase; 23 24#if 0 25 if(!TRIDENTI2CSwitchToBus(b)) 26 return FALSE; 27#endif 28 29 if(clock) reg |= 2; 30 if(data) reg |= 1; 31 OUTB(vgaIOBase + 4, I2C); 32 OUTB(vgaIOBase + 5, reg); 33#if 0 34 ErrorF("TRIDENTI2CPutBits: %d %d\n", clock, data); 35#endif 36} 37 38static void 39TRIDENTI2CGetBits(I2CBusPtr b, int *clock, int *data) { 40 unsigned int reg; 41 TRIDENTPtr pTrident = ((TRIDENTPtr)b->DriverPrivate.ptr); 42 int vgaIOBase = VGAHWPTR(pTrident->pScrn)->IOBase; 43 44#if 0 45 if(!TRIDENTI2CSwitchToBus(b)) 46 return FALSE; 47#endif 48 49 OUTB(vgaIOBase + 4, I2C); 50 reg = INB(vgaIOBase + 5); 51 *clock = (reg & 0x02) != 0; 52 *data = (reg & 0x01) != 0; 53#if 0 54 ErrorF("TRIDENTI2CGetBits: %d %d\n", *clock, *data); 55#endif 56} 57 58Bool 59TRIDENTI2CInit(ScreenPtr pScreen) 60{ 61 ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; 62 TRIDENTPtr pTrident = TRIDENTPTR(pScrn); 63 I2CBusPtr I2CPtr; 64 65 I2CPtr = xf86CreateI2CBusRec(); 66 67 pTrident->DDC = I2CPtr; 68 69 I2CPtr->BusName = "DDC"; 70 I2CPtr->scrnIndex = pScrn->scrnIndex; 71 I2CPtr->I2CPutBits = TRIDENTI2CPutBits; 72 I2CPtr->I2CGetBits = TRIDENTI2CGetBits; 73 I2CPtr->DriverPrivate.ptr = pTrident; 74 75 if(!xf86I2CBusInit(I2CPtr)) 76 return FALSE; 77 78 return TRUE; 79} 80