summaryrefslogtreecommitdiff
path: root/src/geode_ddc.c
diff options
context:
space:
mode:
authorJordan Crouse <jordan.crouse@amd.com>2008-09-10 17:33:30 -0600
committerJordan Crouse <jordan.crouse@amd.com>2008-09-10 17:33:30 -0600
commitf66c9d1928ec9bcde57009c7263f6c8575ad0d0c (patch)
tree2ce0a6775393bae11547d9d9517f7168f5242698 /src/geode_ddc.c
parent85d2103a90e6ab422246b66d252dbee19c96a0d7 (diff)
parent62d2b0ede08042147ca528be9ab1e392886a10ff (diff)
Merge branch 'randr12-branch'
Conflicts: src/geode_ddc.c src/gx_randr.c src/lx_randr.c src/lx_rotate.c
Diffstat (limited to 'src/geode_ddc.c')
-rw-r--r--src/geode_ddc.c53
1 files changed, 30 insertions, 23 deletions
diff --git a/src/geode_ddc.c b/src/geode_ddc.c
index c167df7..2533488 100644
--- a/src/geode_ddc.c
+++ b/src/geode_ddc.c
@@ -65,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)
@@ -111,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
@@ -135,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;
}