Neither overlay or blit adaptor work on G8x.
[nouveau] / src / nv_i2c.c
1
2 #include "nv_include.h"
3
4 /*
5  * DDC1 support only requires DDC_SDA_MASK,
6  * DDC2 support requires DDC_SDA_MASK and DDC_SCL_MASK
7  */
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)
12
13 static void
14 NVI2CGetBits(I2CBusPtr b, int *clock, int *data)
15 {
16     NVPtr pNv = NVPTR(xf86Screens[b->scrnIndex]);
17     unsigned char val;
18
19     /* Get the result. */
20     val = nvReadVGA(pNv, b->DriverPrivate.uval);
21
22     *clock = (val & DDC_SCL_READ_MASK) != 0;
23     *data  = (val & DDC_SDA_READ_MASK) != 0;
24 }
25
26 static void
27 NVI2CPutBits(I2CBusPtr b, int clock, int data)
28 {
29     NVPtr pNv = NVPTR(xf86Screens[b->scrnIndex]);
30     unsigned char val;
31
32     val = nvReadVGA(pNv, b->DriverPrivate.uval + 1) & 0xf0;
33     if (clock)
34         val |= DDC_SCL_WRITE_MASK;
35     else
36         val &= ~DDC_SCL_WRITE_MASK;
37
38     if (data)
39         val |= DDC_SDA_WRITE_MASK;
40     else
41         val &= ~DDC_SDA_WRITE_MASK;
42
43     nvWriteVGA(pNv, b->DriverPrivate.uval + 1, val | 0x1);
44 }
45
46 Bool
47 NV_I2CInit(ScrnInfoPtr pScrn, I2CBusPtr *bus_ptr, int i2c_reg, char *name)
48 {
49     I2CBusPtr pI2CBus;
50
51     pI2CBus = xf86CreateI2CBusRec();
52     if(!pI2CBus)
53       return FALSE;
54
55     pI2CBus->BusName    = name;
56     pI2CBus->scrnIndex  = pScrn->scrnIndex;
57     pI2CBus->I2CPutBits = NVI2CPutBits;
58     pI2CBus->I2CGetBits = NVI2CGetBits;
59     pI2CBus->AcknTimeout = 5;
60
61     pI2CBus->DriverPrivate.uval = i2c_reg;
62
63     if (!xf86I2CBusInit(pI2CBus)) {
64         return FALSE;
65     }
66
67     *bus_ptr = pI2CBus;
68     return TRUE;
69 }
70