1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
/* (c) Itai Nahshon */
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_i2c.c,v 1.4 2000/12/06 15:35:17 eich Exp $ */
#include "xf86.h"
#include "xf86_OSproc.h"
#include "xf86_ansic.h"
#include "compiler.h"
#include "xf86Pci.h"
#include "xf86PciInfo.h"
#include "vgaHW.h"
#include "cir.h"
#define _LG_PRIVATE_
#include "lg.h"
static void
LgI2CPutBits(I2CBusPtr b, int clock, int data)
{
unsigned int regval, regno;
CirPtr pCir = ((CirPtr)b->DriverPrivate.ptr);
if (b == pCir->I2CPtr1)
regno = 0x280;
else if (b == pCir->I2CPtr2)
regno = 0x282;
else
return;
regval = 0xff7e;
if (clock) regval |= 0x0080;
if (data) regval |= 0x0001;
memww(regno, regval);
/* ErrorF("LgI2CPutBits: %d %d\n", clock, data); */
}
static void
LgI2CGetBits(I2CBusPtr b, int *clock, int *data)
{
unsigned int regval, regno;
CirPtr pCir = ((CirPtr)b->DriverPrivate.ptr);
if (b == pCir->I2CPtr1)
regno = 0x280;
else if (b == pCir->I2CPtr2)
regno = 0x282;
else
return;
regval = memrw(regno);
*clock = (regval & 0x8000) != 0;
*data = (regval & 0x0100) != 0;
/* ErrorF("LgI2CGetBits: %d %d\n", *clock, *data); */
}
Bool
LgI2CInit(ScrnInfoPtr pScrn)
{
CirPtr pCir = CIRPTR(pScrn);
I2CBusPtr I2CPtr;
#ifdef LG_DEBUG
ErrorF("LgI2CInit\n");
#endif
I2CPtr = xf86CreateI2CBusRec();
if (!I2CPtr) return FALSE;
pCir->I2CPtr1 = I2CPtr;
I2CPtr->BusName = "I2C bus 1";
I2CPtr->scrnIndex = pScrn->scrnIndex;
I2CPtr->I2CPutBits = LgI2CPutBits;
I2CPtr->I2CGetBits = LgI2CGetBits;
I2CPtr->DriverPrivate.ptr = pCir;
if (!xf86I2CBusInit(I2CPtr))
return FALSE;
I2CPtr = xf86CreateI2CBusRec();
if (!I2CPtr) return FALSE;
pCir->I2CPtr2 = I2CPtr;
I2CPtr->BusName = "I2C bus 2";
I2CPtr->scrnIndex = pScrn->scrnIndex;
I2CPtr->I2CPutBits = LgI2CPutBits;
I2CPtr->I2CGetBits = LgI2CGetBits;
I2CPtr->DriverPrivate.ptr = pCir;
if (!xf86I2CBusInit(I2CPtr))
return FALSE;
return TRUE;
}
|