2 #include "nv_include.h"
5 * DDC1 support only requires DDC_SDA_MASK,
6 * DDC2 support requires DDC_SDA_MASK and DDC_SCL_MASK
8 #define DDC_SDA_READ_MASK (1 << 3)
9 #define DDC_SCL_READ_MASK (1 << 2)
10 #define DDC_SDA_WRITE_MASK (1 << 4)
11 #define DDC_SCL_WRITE_MASK (1 << 5)
14 NVI2CGetBits(I2CBusPtr b, int *clock, int *data)
16 NVPtr pNv = NVPTR(xf86Screens[b->scrnIndex]);
20 /* Doing this on head 0 seems fine. */
21 val = NVReadVgaCrtc(pNv, 0, b->DriverPrivate.uval);
23 *clock = (val & DDC_SCL_READ_MASK) != 0;
24 *data = (val & DDC_SDA_READ_MASK) != 0;
28 NVI2CPutBits(I2CBusPtr b, int clock, int data)
30 NVPtr pNv = NVPTR(xf86Screens[b->scrnIndex]);
33 /* Doing this on head 0 seems fine. */
34 val = NVReadVgaCrtc(pNv, 0, b->DriverPrivate.uval + 1) & 0xf0;
36 val |= DDC_SCL_WRITE_MASK;
38 val &= ~DDC_SCL_WRITE_MASK;
41 val |= DDC_SDA_WRITE_MASK;
43 val &= ~DDC_SDA_WRITE_MASK;
45 /* Doing this on head 0 seems fine. */
46 NVWriteVgaCrtc(pNv, 0, b->DriverPrivate.uval + 1, val | 0x1);
50 NV_I2CInit(ScrnInfoPtr pScrn, I2CBusPtr *bus_ptr, int i2c_reg, char *name)
54 pI2CBus = xf86CreateI2CBusRec();
58 pI2CBus->BusName = name;
59 pI2CBus->scrnIndex = pScrn->scrnIndex;
60 pI2CBus->I2CPutBits = NVI2CPutBits;
61 pI2CBus->I2CGetBits = NVI2CGetBits;
62 pI2CBus->AcknTimeout = 5;
64 pI2CBus->DriverPrivate.uval = i2c_reg;
66 if (!xf86I2CBusInit(pI2CBus)) {