summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerome Glisse <glisse@freedesktop.org>2007-07-18 18:53:51 +0200
committerJerome Glisse <glisse@freedesktop.org>2007-07-18 18:53:51 +0200
commitd779065b5ad8d3b30e4c91c8a3ad8935292e05c1 (patch)
treeff743492a844406e5b3b1886a9ca742a1c47f138
parentd3564fe5f01a924018f206b9b911348ab6b0a3bb (diff)
avivo: properly handle GPIO 0 (0x7E30) for i2c.
-rw-r--r--avivotool/avivotool.c11
-rw-r--r--include/avivo.h9
-rw-r--r--include/radeon_reg.h7
-rw-r--r--xorg/avivo_output.c37
4 files changed, 28 insertions, 36 deletions
diff --git a/avivotool/avivotool.c b/avivotool/avivotool.c
index 0f0dba8..bb06c72 100644
--- a/avivotool/avivotool.c
+++ b/avivotool/avivotool.c
@@ -1588,6 +1588,7 @@ static void radeon_rom_atom_connectors(unsigned char *bios, int master)
for (i = 0; i < 8; i++) {
if (tmp & (1 << i)) {
+ int gpio;
int portinfo = BIOS16(offset + 6 + i * 2);
crtc = (portinfo >> 8) & 0xf;
@@ -1596,16 +1597,17 @@ static void radeon_rom_atom_connectors(unsigned char *bios, int master)
tmp0 = BIOS16(master + 24);
if (1 /* crtc */) {
- int gpio = BIOS16(tmp0 + 4 + 27 * crtc) * 4;
+ gpio = BIOS16(tmp0 + 4 + 27 * crtc) * 4;
switch(gpio)
{
case RADEON_GPIO_MONID: ddc = 1; break;
case RADEON_GPIO_DVI_DDC: ddc = 2; break;
case RADEON_GPIO_VGA_DDC: ddc = 3; break;
case RADEON_GPIO_CRT2_DDC: ddc = 4; break;
- case AVIVO_GPIO_CONNECTOR_0: ddc = 5; break;
- case AVIVO_GPIO_CONNECTOR_1: ddc = 6; break;
- case AVIVO_GPIO_LVDS: ddc = 7; break;
+ case AVIVO_GPIO_0: ddc = 7; break;
+ case AVIVO_GPIO_1: ddc = 5; break;
+ case AVIVO_GPIO_2: ddc = 6; break;
+ case AVIVO_GPIO_3: ddc = 7; break;
default: ddc = 0; break;
}
}
@@ -1619,6 +1621,7 @@ static void radeon_rom_atom_connectors(unsigned char *bios, int master)
/* On AVIVO cards, the DAC is unset for TMDS */
if (dac >= 0 || (i != 3 && i != 7))
printf(", DAC: %s", radeon_valname(ldac_type_name, dac));
+ printf(", GPIO: 0x%04X", gpio);
if (i == 3)
printf(" TMDS: Internal\n");
else if (i == 7)
diff --git a/include/avivo.h b/include/avivo.h
index 083b572..4b39b2e 100644
--- a/include/avivo.h
+++ b/include/avivo.h
@@ -69,6 +69,7 @@ struct avivo_crtc_private {
struct avivo_output_private {
xf86ConnectorType type;
I2CBusPtr i2c;
+ unsigned long gpio;
unsigned long output_offset;
int number;
char *name;
@@ -283,4 +284,12 @@ FBLinearPtr avivo_xf86AllocateOffscreenLinear(ScreenPtr screen, int length,
RemoveLinearCallbackProcPtr removeCB,
pointer priv_data);
+/*
+ * avivo i2c
+ */
+void avivo_i2c_gpio0_get_bits(I2CBusPtr b, int *Clock, int *data);
+void avivo_i2c_gpio0_put_bits(I2CBusPtr b, int Clock, int data);
+void avivo_i2c_gpio123_get_bits(I2CBusPtr b, int *Clock, int *data);
+void avivo_i2c_gpio123_put_bits(I2CBusPtr b, int Clock, int data);
+
#endif /* _AVIVO_H_ */
diff --git a/include/radeon_reg.h b/include/radeon_reg.h
index 936e5a3..5dc370e 100644
--- a/include/radeon_reg.h
+++ b/include/radeon_reg.h
@@ -3390,9 +3390,10 @@
# define AVIVO_LVDS_BACKLIGHT_LEVEL_SHIFT 8
/* The BIOS says so, anyway ... */
-#define AVIVO_GPIO_CONNECTOR_0 0x7e40
-#define AVIVO_GPIO_CONNECTOR_1 0x7e50
-#define AVIVO_GPIO_LVDS 0x7e60
+#define AVIVO_GPIO_0 0x7e30
+#define AVIVO_GPIO_1 0x7e40
+#define AVIVO_GPIO_2 0x7e50
+#define AVIVO_GPIO_3 0x7e60
#define AVIVO_TMDS_STATUS 0x7e9c
# define AVIVO_TMDS1_CONNECTED (1 << 0)
diff --git a/xorg/avivo_output.c b/xorg/avivo_output.c
index 4e2a5d5..3406805 100644
--- a/xorg/avivo_output.c
+++ b/xorg/avivo_output.c
@@ -32,33 +32,6 @@
#include "avivo.h"
#include "radeon_reg.h"
-static void
-avivo_i2c_get_bits(I2CBusPtr b, int *Clock, int *data)
-{
- ScrnInfoPtr screen_info = xf86Screens[b->scrnIndex];
- struct avivo_info *avivo = avivo_get_info(screen_info);
- unsigned long val;
-
- /* Get the result */
- val = INREG(b->DriverPrivate.uval + 0xC);
- *Clock = (val & (1<<0)) != 0;
- *data = (val & (1<<8)) != 0;
-}
-
-static void
-avivo_i2c_put_bits(I2CBusPtr b, int Clock, int data)
-{
- ScrnInfoPtr screen_info = xf86Screens[b->scrnIndex];
- struct avivo_info *avivo = avivo_get_info(screen_info);
- unsigned long val;
-
- val = 0;
- val |= (Clock ? 0:(1<<0));
- val |= (data ? 0:(1<<8));
- OUTREG(b->DriverPrivate.uval + 0x8, val);
- /* read back to improve reliability on some cards. */
- val = INREG(b->DriverPrivate.uval + 0x8);
-}
static void
avivo_output_dpms(xf86OutputPtr output, int mode)
@@ -337,8 +310,13 @@ avivo_output_init(ScrnInfoPtr screen_info, xf86ConnectorType type,
}
avivo_output->i2c->BusName = avivo_output->name;
avivo_output->i2c->scrnIndex = screen_info->scrnIndex;
- avivo_output->i2c->I2CPutBits = avivo_i2c_put_bits;
- avivo_output->i2c->I2CGetBits = avivo_i2c_get_bits;
+ if (ddc_reg == AVIVO_GPIO_0) {
+ avivo_output->i2c->I2CPutBits = avivo_i2c_gpio0_put_bits;
+ avivo_output->i2c->I2CGetBits = avivo_i2c_gpio0_get_bits;
+ } else {
+ avivo_output->i2c->I2CPutBits = avivo_i2c_gpio123_put_bits;
+ avivo_output->i2c->I2CGetBits = avivo_i2c_gpio123_get_bits;
+ }
avivo_output->i2c->AcknTimeout = 5;
avivo_output->i2c->DriverPrivate.uval = ddc_reg;
if (!xf86I2CBusInit(avivo_output->i2c)) {
@@ -347,6 +325,7 @@ avivo_output_init(ScrnInfoPtr screen_info, xf86ConnectorType type,
xf86ConnectorGetName(type), number);
return FALSE;
}
+ avivo_output->gpio = ddc_reg;
avivo_output->type = type;
avivo_output->number = number;
avivo_output->output_offset = 0;