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