summaryrefslogtreecommitdiff
path: root/src/geode_ddc.c
diff options
context:
space:
mode:
authorJordan Crouse <jordan.crouse@amd.com>2008-08-07 11:21:48 -0600
committerJordan Crouse <jordan.crouse@amd.com>2008-08-07 11:21:48 -0600
commitd681a844e448712a9a419d2a4dca81930d39a80a (patch)
tree09079ad5f93174e991a1da09a38d2aad53515cf9 /src/geode_ddc.c
parente98927f2c60acd9262cfb6fca2491fe0decc7aa5 (diff)
[LX] - Add RandR 1.2 support
A wholesale update to Randr 1.2 for LX accompanied by massive cleanup.
Diffstat (limited to 'src/geode_ddc.c')
-rw-r--r--src/geode_ddc.c62
1 files changed, 37 insertions, 25 deletions
diff --git a/src/geode_ddc.c b/src/geode_ddc.c
index 419c93b..feabcf6 100644
--- a/src/geode_ddc.c
+++ b/src/geode_ddc.c
@@ -56,6 +56,7 @@
#define DDC_CLK_LOW (DDC_SCL_PIN << 16)
#define CS5536_ISA_DEVICE 0x20901022
+#define CS5535_ISA_DEVICE 0x002b100b
static unsigned short
geode_gpio_iobase(void)
@@ -64,6 +65,8 @@ geode_gpio_iobase(void)
struct pci_device *pci;
/* The CS5536 GPIO device is always in the same slot: 00:0f.0 */
+ /* The CS5535 device should be in same slot as well */
+
pci = pci_device_find_by_slot(0, 0, 0xF, 0x0);
if (pci == NULL)
@@ -76,8 +79,12 @@ geode_gpio_iobase(void)
Tag = pciFindFirst(CS5536_ISA_DEVICE, 0xFFFFFFFF);
- if (Tag == PCI_NOT_FOUND)
- return 0;
+ if (Tag == PCI_NOT_FOUND) {
+ Tag = pciFindFirst(CS5535_ISA_DEVICE, 0xFFFFFFFF);
+
+ if (Tag == PCI_NOT_FOUND)
+ return 0;
+ }
/* The GPIO I/O address is in resource 1 */
return (unsigned short)(pciReadLong(Tag, 0x14) & ~1);
@@ -106,19 +113,18 @@ geode_ddc_getbits(I2CBusPtr b, int *scl, int *sda)
*sda = (dat & DDC_DATA_HIGH) ? 1 : 0;
}
-static xf86MonPtr
-GeodeGetDDC(ScrnInfoPtr pScrni)
+Bool
+GeodeI2CInit(ScrnInfoPtr pScrni, I2CBusPtr * ptr, char *name)
{
- xf86MonPtr mon = NULL;
I2CBusPtr bus;
- unsigned long ddciobase;
+ unsigned int ddciobase;
ddciobase = geode_gpio_iobase();
if (ddciobase == 0) {
xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
"Could not find the GPIO I/O base\n");
- return NULL;
+ return FALSE;
}
/* The GPIO pins for DDC are multiplexed with a
@@ -130,43 +136,49 @@ GeodeGetDDC(ScrnInfoPtr pScrni)
(inl(ddciobase + GPIO_OUT_AUX1) & DDC_DATA_HIGH)) {
xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
"GPIO pins are in serial mode. Assuming no DDC\n");
- return NULL;
+ return FALSE;
}
- /* Set up the pins */
-
outl(ddciobase + GPIO_OUT_ENABLE, DDC_DATA_HIGH | DDC_CLK_HIGH);
outl(ddciobase + GPIO_IN_ENABLE, DDC_DATA_HIGH | DDC_CLK_HIGH);
bus = xf86CreateI2CBusRec();
- if (bus == NULL) {
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
- "Could not create the I2C structre\n");
- goto err;
- }
+ if (!bus)
+ return FALSE;
- bus->BusName = "CS5536 DDC BUS";
+ bus->BusName = name;
bus->scrnIndex = pScrni->scrnIndex;
+
bus->I2CGetBits = geode_ddc_getbits;
bus->I2CPutBits = geode_ddc_putbits;
bus->DriverPrivate.ptr = (void *)(ddciobase);
- if (xf86I2CBusInit(bus)) {
- mon = xf86DoEDID_DDC2(pScrni->scrnIndex, bus);
+ if (!xf86I2CBusInit(bus))
+ return FALSE;
+
+ *ptr = bus;
+ return TRUE;
+}
+
+static xf86MonPtr
+GeodeGetDDC(ScrnInfoPtr pScrni)
+{
+ xf86MonPtr mon = NULL;
+ I2CBusPtr bus;
+
+ if (!GeodeI2CInit(pScrni, &bus, "CS5536 DDC BUS"))
+ return NULL;
+
+ mon = xf86DoEDID_DDC2(pScrni->scrnIndex, bus);
#if (XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,4,99,0,0))
- if (mon)
- xf86DDCApplyQuirks(pScrni->scrnIndex, mon);
+ if (mon)
+ xf86DDCApplyQuirks(pScrni->scrnIndex, mon);
#endif
- }
xf86DestroyI2CBusRec(bus, FALSE, FALSE);
- err:
- outl(ddciobase + GPIO_OUT_ENABLE, DDC_DATA_LOW | DDC_CLK_LOW);
- outl(ddciobase + GPIO_IN_ENABLE, DDC_DATA_LOW | DDC_CLK_LOW);
-
return mon;
}