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 val = nvReadVGA(pNv, b->DriverPrivate.uval);
22 *clock = (val & DDC_SCL_READ_MASK) != 0;
23 *data = (val & DDC_SDA_READ_MASK) != 0;
27 NVI2CPutBits(I2CBusPtr b, int clock, int data)
29 NVPtr pNv = NVPTR(xf86Screens[b->scrnIndex]);
32 val = nvReadVGA(pNv, b->DriverPrivate.uval + 1) & 0xf0;
34 val |= DDC_SCL_WRITE_MASK;
36 val &= ~DDC_SCL_WRITE_MASK;
39 val |= DDC_SDA_WRITE_MASK;
41 val &= ~DDC_SDA_WRITE_MASK;
43 nvWriteVGA(pNv, b->DriverPrivate.uval + 1, val | 0x1);
47 NV_I2CInit(ScrnInfoPtr pScrn, I2CBusPtr *bus_ptr, int i2c_reg, char *name)
51 pI2CBus = xf86CreateI2CBusRec();
55 pI2CBus->BusName = name;
56 pI2CBus->scrnIndex = pScrn->scrnIndex;
57 pI2CBus->I2CPutBits = NVI2CPutBits;
58 pI2CBus->I2CGetBits = NVI2CGetBits;
59 pI2CBus->AcknTimeout = 5;
61 pI2CBus->DriverPrivate.uval = i2c_reg;
63 if (!xf86I2CBusInit(pI2CBus)) {