xf86-video-intel: Branch 'modesetting' - 3 commits - src/i810_reg.h src/i830_debug.c src/i830_driver.c src/i830.h src/i830_i2c.c

Eric Anholt anholt at kemper.freedesktop.org
Thu Nov 2 23:25:15 EET 2006


 src/i810_reg.h    |   16 ---
 src/i830.h        |    1 
 src/i830_debug.c  |    5 -
 src/i830_driver.c |    2 
 src/i830_i2c.c    |  222 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 226 insertions(+), 20 deletions(-)

New commits:
diff-tree a9eac38bcdb49df2ce1122b49bd8b1eb19e8cae5 (from 7887c76062b7c79e14fb8e4f13486aa592dcbce8)
Author: Eric Anholt <eric at anholt.net>
Date:   Thu Nov 2 13:24:54 2006 -0800

    Remove duplicated register defs that were just added.

diff --git a/src/i810_reg.h b/src/i810_reg.h
index 11c0659..d6f7147 100644
--- a/src/i810_reg.h
+++ b/src/i810_reg.h
@@ -853,20 +853,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN
 # define DPLL_MD_VGA_UDI_MULTIPLIER_SHIFT	0
 /** @} */
 
-/* SDVO/UDI Multiplier/Divisor register */
-#define DPLLAMD			0x601c
-#define DPLLBMD			0x6020
-
-/* Hi res source UDI divider (-1), non-zeor for UDI fixed freq mode */
-# define DPLLMD_UDI_DIVIDER_HIRES_MASK		(0x3f << 24)
-# define DPLLMD_UDI_DIVIDER_HIRES_SHIFT		24
-# define DPLLMD_UDI_DIVIDER_VGA_MASK		(0x3f << 16)
-# define DPLLMD_UDI_DIVIDER_VGA_SHIFT		16
-# define DPLLMD_SDVOUDI_MULTIPLIER_HIRES_MASK	(0x3f << 8)
-# define DPLLMD_SDVOUDI_MULTIPLIER_HIRES_SHIFT	8
-# define DPLLMD_SDVOUDI_MULTIPLIER_VGA_MASK	(0x3f << 0)
-# define DPLLMD_SDVOUDI_MULTIPLIER_VGA_SHIFT	0
-
 #define DPLL_TEST		0x606c
 
 #define D_STATE			0x6104
diff --git a/src/i830_debug.c b/src/i830_debug.c
index 802330e..7922af0 100644
--- a/src/i830_debug.c
+++ b/src/i830_debug.c
@@ -59,7 +59,6 @@ static struct i830SnapshotRec {
     DEFINEREG(DSPFW1),
     DEFINEREG(DSPFW2),
     DEFINEREG(DSPFW3),
-    
 
     DEFINEREG(ADPA),
     DEFINEREG(LVDS),
@@ -90,7 +89,7 @@ static struct i830SnapshotRec {
     DEFINEREG(FPA0),
     DEFINEREG(FPA1),
     DEFINEREG(DPLL_A),
-    DEFINEREG(DPLLAMD),
+    DEFINEREG(DPLL_A_MD),
     DEFINEREG(HTOTAL_A),
     DEFINEREG(HBLANK_A),
     DEFINEREG(HSYNC_A),
@@ -113,7 +112,7 @@ static struct i830SnapshotRec {
     DEFINEREG(FPB0),
     DEFINEREG(FPB1),
     DEFINEREG(DPLL_B),
-    DEFINEREG(DPLLBMD),
+    DEFINEREG(DPLL_B_MD),
     DEFINEREG(HTOTAL_B),
     DEFINEREG(HBLANK_B),
     DEFINEREG(HSYNC_B),
diff-tree 7887c76062b7c79e14fb8e4f13486aa592dcbce8 (from 87b15cfbf762468d4b8728b3e7a39c76654017de)
Author: Eric Anholt <eric at anholt.net>
Date:   Thu Nov 2 12:27:21 2006 -0800

    Add airlied's I2C code, ifdeffed out.
    
    I've gone back to compare our behavior to it several times, so I'll just keep
    the code in tree for now.

diff --git a/src/i810_reg.h b/src/i810_reg.h
index 31f8885..11c0659 100644
--- a/src/i810_reg.h
+++ b/src/i810_reg.h
@@ -276,11 +276,13 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN
 #define GPIOG			0x5028
 #define GPIOH			0x502c
 # define GPIO_CLOCK_DIR_MASK		(1 << 0)
+# define GPIO_CLOCK_DIR_IN		(0 << 1)
 # define GPIO_CLOCK_DIR_OUT		(1 << 1)
 # define GPIO_CLOCK_VAL_MASK		(1 << 2)
 # define GPIO_CLOCK_VAL_OUT		(1 << 3)
 # define GPIO_CLOCK_VAL_IN		(1 << 4)
 # define GPIO_DATA_DIR_MASK		(1 << 8)
+# define GPIO_DATA_DIR_IN		(0 << 9)
 # define GPIO_DATA_DIR_OUT		(1 << 9)
 # define GPIO_DATA_VAL_MASK		(1 << 10)
 # define GPIO_DATA_VAL_OUT		(1 << 11)
diff --git a/src/i830_i2c.c b/src/i830_i2c.c
index cee7bb5..8b93c8e 100644
--- a/src/i830_i2c.c
+++ b/src/i830_i2c.c
@@ -48,6 +48,219 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "shadow.h"
 #include "i830.h"
 
+#define AIRLIED_I2C	0
+
+#if AIRLIED_I2C
+
+#define I2C_TIMEOUT(x)	/*(x)*/  /* Report timeouts */
+#define I2C_TRACE(x)    /*(x)*/  /* Report progress */
+
+static void i830_setscl(I2CBusPtr b, int state)
+{
+    ScrnInfoPtr pScrn = xf86Screens[b->scrnIndex];
+    I830Ptr pI830 = I830PTR(pScrn);
+    CARD32 val;
+
+    OUTREG(b->DriverPrivate.uval,
+	   (state ? GPIO_CLOCK_VAL_OUT : 0) | GPIO_CLOCK_DIR_OUT |
+	   GPIO_CLOCK_DIR_MASK | GPIO_CLOCK_VAL_MASK);
+    val = INREG(b->DriverPrivate.uval);
+}
+
+static void i830_setsda(I2CBusPtr b, int state)
+{
+    ScrnInfoPtr pScrn = xf86Screens[b->scrnIndex];
+    I830Ptr pI830 = I830PTR(pScrn);
+    CARD32 val;
+
+    OUTREG(b->DriverPrivate.uval,
+	   (state ? GPIO_DATA_VAL_OUT : 0) | GPIO_DATA_DIR_OUT |
+	   GPIO_DATA_DIR_MASK | GPIO_DATA_VAL_MASK);
+    val = INREG(b->DriverPrivate.uval);
+}
+
+static void i830_getscl(I2CBusPtr b, int *state)
+{
+    ScrnInfoPtr pScrn = xf86Screens[b->scrnIndex];
+    I830Ptr pI830 = I830PTR(pScrn);
+    CARD32 val;
+
+    OUTREG(b->DriverPrivate.uval, GPIO_CLOCK_DIR_IN | GPIO_CLOCK_DIR_MASK);
+    OUTREG(b->DriverPrivate.uval, 0);
+    val = INREG(b->DriverPrivate.uval);
+    *state = ((val & GPIO_DATA_VAL_IN) != 0);
+}
+
+static int i830_getsda(I2CBusPtr b)
+ {
+     ScrnInfoPtr pScrn = xf86Screens[b->scrnIndex];
+     I830Ptr pI830 = I830PTR(pScrn);
+     CARD32 val;
+
+     OUTREG(b->DriverPrivate.uval, GPIO_DATA_DIR_IN | GPIO_DATA_DIR_MASK);
+     OUTREG(b->DriverPrivate.uval, 0);
+     val = INREG(b->DriverPrivate.uval);
+     return ((val & GPIO_DATA_VAL_IN) != 0);
+}
+
+static inline void sdalo(I2CBusPtr b)
+{
+    i830_setsda(b, 0);
+    b->I2CUDelay(b, b->RiseFallTime);
+}
+
+static inline void sdahi(I2CBusPtr b)
+{
+    i830_setsda(b, 1);
+    b->I2CUDelay(b, b->RiseFallTime);
+}
+
+static inline void scllo(I2CBusPtr b)
+{
+    i830_setscl(b, 0);
+    b->I2CUDelay(b, b->RiseFallTime);
+}
+
+static inline int sclhi(I2CBusPtr b, int timeout)
+{
+    int scl = 0;
+    int i;
+
+    i830_setscl(b, 1);
+    b->I2CUDelay(b, b->RiseFallTime);
+
+    for (i = timeout; i > 0; i -= b->RiseFallTime) {
+	i830_getscl(b, &scl);
+	if (scl) break;
+	b->I2CUDelay(b, b->RiseFallTime);
+    }
+
+    if (i <= 0) {
+	I2C_TIMEOUT(ErrorF("[I2CRaiseSCL(<%s>, %d) timeout]",
+			   b->BusName, timeout));
+	return FALSE;
+    }
+    return TRUE;
+}
+
+static Bool
+I830I2CGetByte(I2CDevPtr d, I2CByte *data, Bool last)
+{
+    I2CBusPtr b = d->pI2CBus;
+    int i, sda;
+    unsigned char indata = 0;
+
+    sdahi(b);
+
+    for (i = 0; i < 8; i++) {
+	if (sclhi(b, d->BitTimeout) == FALSE) {
+	    I2C_TRACE(ErrorF("timeout at bit #%d\n", 7-i));
+	    return FALSE;
+	};
+	indata *= 2;
+	if (i830_getsda(b))
+	    indata |= 0x01;
+	scllo(b);
+    }
+
+    if (last) {
+	sdahi(b);
+    } else {
+	sdalo(b);
+    }
+
+    if (sclhi(b, d->BitTimeout) == FALSE) {
+	sdahi(b);
+	return FALSE;
+    };
+
+    scllo(b);
+    sdahi(b);
+
+    *data = indata & 0xff;
+    I2C_TRACE(ErrorF("R%02x ", (int) *data));
+
+    return TRUE;
+}
+
+static Bool
+I830I2CPutByte(I2CDevPtr d, I2CByte c)
+{
+    Bool r;
+    int i, scl, sda;
+    int sb, ack;
+    I2CBusPtr b = d->pI2CBus;
+
+    for (i = 7; i >= 0; i--) {
+	sb = c & (1 << i);
+	i830_setsda(b, sb);
+	b->I2CUDelay(b, b->RiseFallTime);
+
+	if (sclhi(b, d->ByteTimeout) == FALSE) {
+	    sdahi(b);
+	    return FALSE;
+	}
+
+	i830_setscl(b, 0);
+	b->I2CUDelay(b, b->RiseFallTime);
+    }
+    sdahi(b);
+    if (sclhi(b, d->ByteTimeout) == FALSE) {
+	I2C_TIMEOUT(ErrorF("[I2CPutByte(<%s>, 0x%02x, %d, %d, %d) timeout]",
+			   b->BusName, c, d->BitTimeout,
+			   d->ByteTimeout, d->AcknTimeout));
+	return FALSE;
+    }
+    ack = i830_getsda(b);
+    I2C_TRACE(ErrorF("Put byte 0x%02x , getsda() = %d\n", c & 0xff, ack));
+
+    scllo(b);
+    return (0 == ack);
+}
+
+static Bool
+I830I2CStart(I2CBusPtr b, int timeout)
+{
+    if (sclhi(b, timeout) == FALSE)
+	return FALSE;
+
+    sdalo(b);
+    scllo(b);
+
+    return TRUE;
+}
+
+static void
+I830I2CStop(I2CDevPtr d)
+{
+    I2CBusPtr b = d->pI2CBus;
+
+    sdalo(b);
+    sclhi(b, d->ByteTimeout);
+    sdahi(b);
+}
+
+static Bool
+I830I2CAddress(I2CDevPtr d, I2CSlaveAddr addr)
+{
+    if (I830I2CStart(d->pI2CBus, d->StartTimeout)) {
+	if (I830I2CPutByte(d, addr & 0xFF)) {
+	    if ((addr & 0xF8) != 0xF0 &&
+		(addr & 0xFE) != 0x00)
+		return TRUE;
+
+	    if (I830I2CPutByte(d, (addr >> 8) & 0xFF))
+		return TRUE;
+	}
+
+	I830I2CStop(d);
+    }
+
+    return FALSE;
+}
+
+#else
+
 static void
 i830I2CGetBits(I2CBusPtr b, int *clock, int *data)
 {
@@ -76,6 +289,7 @@ i830I2CPutBits(I2CBusPtr b, int clock, i
 	GPIO_DATA_DIR_MASK |
 	GPIO_DATA_VAL_MASK);
 }
+#endif
 
 /* the i830 has a number of I2C Buses */
 Bool
@@ -90,8 +304,16 @@ I830I2CInit(ScrnInfoPtr pScrn, I2CBusPtr
 
     pI2CBus->BusName = name;
     pI2CBus->scrnIndex = pScrn->scrnIndex;
+#if AIRLIED_I2C
+    pI2CBus->I2CGetByte = I830I2CGetByte;
+    pI2CBus->I2CPutByte = I830I2CPutByte;
+    pI2CBus->I2CStart = I830I2CStart;
+    pI2CBus->I2CStop = I830I2CStop;
+    pI2CBus->I2CAddress = I830I2CAddress;
+#else
     pI2CBus->I2CGetBits = i830I2CGetBits;
     pI2CBus->I2CPutBits = i830I2CPutBits;
+#endif
     pI2CBus->DriverPrivate.uval = i2c_reg;
 
     if (!xf86I2CBusInit(pI2CBus))
diff-tree 87b15cfbf762468d4b8728b3e7a39c76654017de (from 2636d68663a02f6d9eaf36971706b67036ebf56c)
Author: Eric Anholt <eric at anholt.net>
Date:   Thu Nov 2 11:30:21 2006 -0800

    Remove dead specifiedMonitor field.

diff --git a/src/i830.h b/src/i830.h
index a07ba8e..bb17f3f 100644
--- a/src/i830.h
+++ b/src/i830.h
@@ -397,7 +397,6 @@ typedef struct _I830Rec {
 
    int MonType1;
    int MonType2;
-   Bool specifiedMonitor;
 
    DGAModePtr DGAModes;
    int numDGAModes;
diff --git a/src/i830_driver.c b/src/i830_driver.c
index 3612af7..779037b 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -1279,7 +1279,6 @@ I830PreInit(ScrnInfoPtr pScrn, int flags
 
    pI830->MonType1 = PIPE_NONE;
    pI830->MonType2 = PIPE_NONE;
-   pI830->specifiedMonitor = FALSE;
 
    if ((s = xf86GetOptValString(pI830->Options, OPTION_MONITOR_LAYOUT)) &&
       I830IsPrimary(pScrn)) {
@@ -1366,7 +1365,6 @@ I830PreInit(ScrnInfoPtr pScrn, int flags
 	 pI830->pipe = 1;
 
       pI830->operatingDevices = (pI830->MonType2 << 8) | pI830->MonType1;
-      pI830->specifiedMonitor = TRUE;
    } else if (I830IsPrimary(pScrn)) {
       /* Choose a default set of outputs to use based on what we've detected.
        *



More information about the xorg-commit mailing list