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

Eric Anholt anholt at kemper.freedesktop.org
Mon Apr 24 21:26:01 EEST 2006


 .gitignore        |    1 
 src/i810_reg.h    |    8 +
 src/i830.h        |   11 ++
 src/i830_driver.c |  115 +++++++++++++++++++++-------
 src/i830_i2c.c    |  217 ++++--------------------------------------------------
 5 files changed, 120 insertions(+), 232 deletions(-)

New commits:
diff-tree bcb441225d1365435bc3373901180de944298e86 (from 47bd9059431eadfd8824e496eb91bb50efa0e282)
Author: Eric Anholt <anholt at FreeBSD.org>
Date:   Mon Apr 24 10:54:45 2006 -0700

    Simplify the i2c code by using the GetBits/PutBits interface rather than
    reimplementing it.

diff --git a/src/i810_reg.h b/src/i810_reg.h
index c790e8b..dee39ce 100644
--- a/src/i810_reg.h
+++ b/src/i810_reg.h
@@ -267,12 +267,12 @@ 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			(1 << 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			(1 << 9)
+# define GPIO_DATA_DIR_OUT		(1 << 9)
 # define GPIO_DATA_VAL_MASK		(1 << 10)
 # define GPIO_DATA_VAL_OUT		(1 << 11)
 # define GPIO_DATA_VAL_IN		(1 << 12)
diff --git a/src/i830_i2c.c b/src/i830_i2c.c
index 8c80a0a..fa0ca30 100644
--- a/src/i830_i2c.c
+++ b/src/i830_i2c.c
@@ -49,215 +49,35 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "shadow.h"
 #include "i830.h"
 
-#define I2C_TIMEOUT(x)	/*(x)*/  /* Report timeouts */
-#define I2C_TRACE(x)    /*(x)*/  /* Report progress */
-
-static void i830_setscl(I2CBusPtr b, int state)
+static void
+i830I2CGetBits(I2CBusPtr b, int *clock, int *data)
 {
-    ScrnInfoPtr    pScrn      = xf86Screens[b->scrnIndex];
+    ScrnInfoPtr pScrn = xf86Screens[b->scrnIndex];
     I830Ptr pI830 = I830PTR(pScrn);
     CARD32 val;
 
-    OUTREG(b->DriverPrivate.uval,
-	(state ? GPIO_CLOCK_VAL_OUT : 0) |
-	GPIO_CLOCK_DIR |
-	GPIO_CLOCK_DIR_MASK |
-	GPIO_CLOCK_VAL_MASK);
     val = INREG(b->DriverPrivate.uval);
+    *data = (val & GPIO_DATA_VAL_IN) != 0;
+    *clock = (val & GPIO_CLOCK_VAL_IN) != 0;
 }
 
-static void i830_setsda(I2CBusPtr b, int state)
+static void
+i830I2CPutBits(I2CBusPtr b, int clock, int data)
 {
-    ScrnInfoPtr    pScrn      = xf86Screens[b->scrnIndex];
+    ScrnInfoPtr pScrn = xf86Screens[b->scrnIndex];
     I830Ptr pI830 = I830PTR(pScrn);
-    CARD32 val;
 
-    OUTREG(b->DriverPrivate.uval, (state ? GPIO_DATA_VAL_OUT : 0) |
-	GPIO_DATA_DIR |
+    OUTREG(b->DriverPrivate.uval,
+	(data ? GPIO_DATA_VAL_OUT : 0) |
+	(clock ? GPIO_CLOCK_VAL_OUT : 0) |
+	GPIO_CLOCK_DIR_OUT |
+	GPIO_DATA_DIR_OUT |
+	GPIO_CLOCK_DIR_MASK |
+	GPIO_CLOCK_VAL_MASK |
 	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_MASK);
-    OUTREG(b->DriverPrivate.uval, 0);
-    val = INREG(b->DriverPrivate.uval);
-    *state = ((val & GPIO_CLOCK_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_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;
-    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)
-{
-    int i;
-    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;
-}
-
-
 /* the i830 has a number of I2C Buses */
 Bool
 I830I2CInit(ScrnInfoPtr pScrn, I2CBusPtr *bus_ptr, int i2c_reg, char *name)
@@ -271,11 +91,8 @@ I830I2CInit(ScrnInfoPtr pScrn, I2CBusPtr
 
     pI2CBus->BusName = name;
     pI2CBus->scrnIndex = pScrn->scrnIndex;
-    pI2CBus->I2CGetByte = I830I2CGetByte;
-    pI2CBus->I2CPutByte = I830I2CPutByte;
-    pI2CBus->I2CStart = I830I2CStart;
-    pI2CBus->I2CStop = I830I2CStop;
-    pI2CBus->I2CAddress = I830I2CAddress;
+    pI2CBus->I2CGetBits = i830I2CGetBits;
+    pI2CBus->I2CPutBits = i830I2CPutBits;
     pI2CBus->DriverPrivate.uval = i2c_reg;
 
     if (!xf86I2CBusInit(pI2CBus))
diff-tree 47bd9059431eadfd8824e496eb91bb50efa0e282 (from parents)
Merge: 729c373121ce2bbb0d813cc923f1254e8b37a025 32a0ad570d9c010e7d26d980830f719782d9f2f3
Author: Eric Anholt <anholt at FreeBSD.org>
Date:   Mon Apr 24 10:36:24 2006 -0700

    Merge branch 'lukas-resume'

diff-tree 32a0ad570d9c010e7d26d980830f719782d9f2f3 (from a371a04a57620b7128e3c4395bc7c2ac55effe19)
Author: Lukáš Hejtmanek <xhejtman at mail.muni.cz>
Date:   Wed Apr 19 19:43:45 2006 -0300

    Add  more registers to save/restore. Save/restore palette as well

diff --git a/.gitignore b/.gitignore
index c7bcbee..094379b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,7 @@ Makefile
 Makefile.in
 *.la
 *.lo
+*.o
 aclocal.m4
 autom4te.cache
 compile
diff --git a/src/i810_reg.h b/src/i810_reg.h
index 92d9cf9..14327eb 100644
--- a/src/i810_reg.h
+++ b/src/i810_reg.h
@@ -681,6 +681,10 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN
 #define PP_CONTROL	0x61204
 # define POWER_TARGET_ON			(1 << 0)
 
+#define LVDSPP_ON       0x61208
+#define LVDSPP_OFF      0x6120c
+#define PP_CYCLE        0x61210
+
 #define PFIT_CONTROL	0x61230
 # define PFIT_ENABLE				(1 << 31)
 # define VERT_INTERP_DISABLE			(0 << 10)
diff --git a/src/i830.h b/src/i830.h
index babbe08..9fe7099 100644
--- a/src/i830.h
+++ b/src/i830.h
@@ -481,7 +481,18 @@ typedef struct _I830Rec {
    CARD32 saveVCLK_POST_DIV;
    CARD32 saveVGACNTRL;
    CARD32 saveADPA;
+   CARD32 saveLVDS;
+   CARD32 saveDVOA;
+   CARD32 saveDVOB;
+   CARD32 saveDVOC;
+   CARD32 savePP_ON;
+   CARD32 savePP_OFF;
+   CARD32 savePP_CONTROL;
+   CARD32 savePP_CYCLE;
    CARD32 savePFIT_CONTROL;
+   CARD32 savePaletteA[256];
+   CARD32 savePaletteB[256];
+   CARD32 saveSWF[17];
 
 } I830Rec;
 
diff --git a/src/i830_driver.c b/src/i830_driver.c
index 8930db0..37829e9 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -3201,6 +3201,7 @@ SaveHWState(ScrnInfoPtr pScrn)
    vgaHWPtr hwp = VGAHWPTR(pScrn);
    vgaRegPtr vgaReg = &hwp->SavedReg;
    CARD32 temp;
+   int i;
 
    /*
     * Print out the PIPEACONF and PIPEBCONF registers.
@@ -3218,11 +3219,8 @@ SaveHWState(ScrnInfoPtr pScrn)
 
    /* Save video mode information for native mode-setting. */
    pI830->saveDSPACNTR = INREG(DSPACNTR);
-   pI830->saveDSPBCNTR = INREG(DSPBCNTR);
    pI830->savePIPEACONF = INREG(PIPEACONF);
-   pI830->savePIPEBCONF = INREG(PIPEBCONF);
    pI830->savePIPEASRC = INREG(PIPEASRC);
-   pI830->savePIPEBSRC = INREG(PIPEBSRC);
    pI830->saveFPA0 = INREG(FPA0);
    pI830->saveFPA1 = INREG(FPA1);
    pI830->saveDPLL_A = INREG(DPLL_A);
@@ -3237,19 +3235,31 @@ SaveHWState(ScrnInfoPtr pScrn)
    pI830->saveDSPAPOS = INREG(DSPAPOS);
    pI830->saveDSPABASE = INREG(DSPABASE);
 
-   pI830->saveFPB0 = INREG(FPB0);
-   pI830->saveFPB1 = INREG(FPB1);
-   pI830->saveDPLL_B = INREG(DPLL_B);
-   pI830->saveHTOTAL_B = INREG(HTOTAL_B);
-   pI830->saveHBLANK_B = INREG(HBLANK_B);
-   pI830->saveHSYNC_B = INREG(HSYNC_B);
-   pI830->saveVTOTAL_B = INREG(VTOTAL_B);
-   pI830->saveVBLANK_B = INREG(VBLANK_B);
-   pI830->saveVSYNC_B = INREG(VSYNC_B);
-   pI830->saveDSPBSTRIDE = INREG(DSPBSTRIDE);
-   pI830->saveDSPBSIZE = INREG(DSPBSIZE);
-   pI830->saveDSPBPOS = INREG(DSPBPOS);
-   pI830->saveDSPBBASE = INREG(DSPBBASE);
+   for(i= 0; i < 256; i++) {
+      pI830->savePaletteA[i] = INREG(PALETTE_A + (i << 2));
+   }
+
+   if(pI830->availablePipes == 2) {
+      pI830->savePIPEBCONF = INREG(PIPEBCONF);
+      pI830->savePIPEBSRC = INREG(PIPEBSRC);
+      pI830->saveDSPBCNTR = INREG(DSPBCNTR);
+      pI830->saveFPB0 = INREG(FPB0);
+      pI830->saveFPB1 = INREG(FPB1);
+      pI830->saveDPLL_B = INREG(DPLL_B);
+      pI830->saveHTOTAL_B = INREG(HTOTAL_B);
+      pI830->saveHBLANK_B = INREG(HBLANK_B);
+      pI830->saveHSYNC_B = INREG(HSYNC_B);
+      pI830->saveVTOTAL_B = INREG(VTOTAL_B);
+      pI830->saveVBLANK_B = INREG(VBLANK_B);
+      pI830->saveVSYNC_B = INREG(VSYNC_B);
+      pI830->saveDSPBSTRIDE = INREG(DSPBSTRIDE);
+      pI830->saveDSPBSIZE = INREG(DSPBSIZE);
+      pI830->saveDSPBPOS = INREG(DSPBPOS);
+      pI830->saveDSPBBASE = INREG(DSPBBASE);
+      for(i= 0; i < 256; i++) {
+         pI830->savePaletteB[i] = INREG(PALETTE_B + (i << 2));
+      }
+   }
 
    pI830->saveVCLK_DIVISOR_VGA0 = INREG(VCLK_DIVISOR_VGA0);
    pI830->saveVCLK_DIVISOR_VGA1 = INREG(VCLK_DIVISOR_VGA1);
@@ -3259,6 +3269,23 @@ SaveHWState(ScrnInfoPtr pScrn)
    pI830->saveADPA = INREG(ADPA);
 
    pI830->savePFIT_CONTROL = INREG(PFIT_CONTROL);
+   pI830->savePP_ON = INREG(LVDSPP_ON);
+   pI830->savePP_OFF = INREG(LVDSPP_OFF);
+   pI830->saveLVDS = INREG(LVDS);
+   pI830->savePP_CONTROL = INREG(PP_CONTROL);
+   pI830->savePP_CYCLE = INREG(PP_CYCLE);
+
+   pI830->saveDVOA = INREG(DVOA);
+   pI830->saveDVOB = INREG(DVOB);
+   pI830->saveDVOC = INREG(DVOC);
+
+   for(i = 0; i < 7; i++) {
+      pI830->saveSWF[i] = INREG(SWF0 + (i << 2));
+      pI830->saveSWF[i+7] = INREG(SWF00 + (i << 2));
+   }
+   pI830->saveSWF[14] = INREG(SWF30);
+   pI830->saveSWF[15] = INREG(SWF31);
+   pI830->saveSWF[16] = INREG(SWF32);
    
    vgaHWUnlock(hwp);
    vgaHWSave(pScrn, vgaReg, VGA_SR_ALL);
@@ -3273,6 +3300,7 @@ RestoreHWState(ScrnInfoPtr pScrn)
    vgaHWPtr hwp = VGAHWPTR(pScrn);
    vgaRegPtr vgaReg = &hwp->SavedReg;
    CARD32 temp;
+   int i;
 
    DPRINTF(PFX, "RestoreHWState\n");
 
@@ -3294,6 +3322,8 @@ RestoreHWState(ScrnInfoPtr pScrn)
    /* XXX: Wait for a vblank */
    sleep(1);
 
+   i830SetLVDSPanelPower(pScrn, FALSE);
+
    OUTREG(FPA0, pI830->saveFPA0);
    OUTREG(FPA1, pI830->saveFPA1);
    OUTREG(DPLL_A, pI830->saveDPLL_A);
@@ -3308,22 +3338,33 @@ RestoreHWState(ScrnInfoPtr pScrn)
    OUTREG(DSPAPOS, pI830->saveDSPAPOS);
    OUTREG(DSPABASE, pI830->saveDSPABASE);
    OUTREG(PIPEASRC, pI830->savePIPEASRC);
+   for(i = 0; i < 256; i++) {
+         OUTREG(PALETTE_A + (i << 2), pI830->savePaletteA[i]);
+   }
 
-   OUTREG(FPB0, pI830->saveFPB0);
-   OUTREG(FPB1, pI830->saveFPB1);
-   OUTREG(DPLL_B, pI830->saveDPLL_B);
-   OUTREG(HTOTAL_B, pI830->saveHTOTAL_B);
-   OUTREG(HBLANK_B, pI830->saveHBLANK_B);
-   OUTREG(HSYNC_B, pI830->saveHSYNC_B);
-   OUTREG(VTOTAL_B, pI830->saveVTOTAL_B);
-   OUTREG(VBLANK_B, pI830->saveVBLANK_B);
-   OUTREG(VSYNC_B, pI830->saveVSYNC_B);
-   OUTREG(DSPBSTRIDE, pI830->saveDSPBSTRIDE);
-   OUTREG(DSPBSIZE, pI830->saveDSPBSIZE);
-   OUTREG(DSPBPOS, pI830->saveDSPBPOS);
-   OUTREG(DSPBBASE, pI830->saveDSPBBASE);
-   OUTREG(PIPEBSRC, pI830->savePIPEBSRC);
+   if(pI830->availablePipes == 2) {
+      OUTREG(FPB0, pI830->saveFPB0);
+      OUTREG(FPB1, pI830->saveFPB1);
+      OUTREG(DPLL_B, pI830->saveDPLL_B);
+      OUTREG(HTOTAL_B, pI830->saveHTOTAL_B);
+      OUTREG(HBLANK_B, pI830->saveHBLANK_B);
+      OUTREG(HSYNC_B, pI830->saveHSYNC_B);
+      OUTREG(VTOTAL_B, pI830->saveVTOTAL_B);
+      OUTREG(VBLANK_B, pI830->saveVBLANK_B);
+      OUTREG(VSYNC_B, pI830->saveVSYNC_B);
+      OUTREG(DSPBSTRIDE, pI830->saveDSPBSTRIDE);
+      OUTREG(DSPBSIZE, pI830->saveDSPBSIZE);
+      OUTREG(DSPBPOS, pI830->saveDSPBPOS);
+      OUTREG(DSPBBASE, pI830->saveDSPBBASE);
+      OUTREG(PIPEBSRC, pI830->savePIPEBSRC);
+      for(i= 0; i < 256; i++) {
+         OUTREG(PALETTE_B + (i << 2), pI830->savePaletteB[i]);
+      }
+   }
 
+   OUTREG(LVDSPP_ON, pI830->savePP_ON);
+   OUTREG(LVDSPP_OFF, pI830->savePP_OFF);
+   OUTREG(PP_CYCLE, pI830->savePP_CYCLE);
    OUTREG(PFIT_CONTROL, pI830->savePFIT_CONTROL);
    
    OUTREG(VCLK_DIVISOR_VGA0, pI830->saveVCLK_DIVISOR_VGA0);
@@ -3338,6 +3379,20 @@ RestoreHWState(ScrnInfoPtr pScrn)
    OUTREG(DSPBCNTR, pI830->saveDSPBCNTR);
 
    OUTREG(ADPA, pI830->saveADPA);
+   OUTREG(LVDS, pI830->saveLVDS);
+   OUTREG(DVOA, pI830->saveDVOA);
+   OUTREG(DVOB, pI830->saveDVOB);
+   OUTREG(DVOC, pI830->saveDVOC);
+   OUTREG(PP_CONTROL, pI830->savePP_CONTROL);
+
+   for(i = 0; i < 7; i++) {
+	   OUTREG(SWF0 + (i << 2), pI830->saveSWF[i]);
+	   OUTREG(SWF00 + (i << 2), pI830->saveSWF[i+7]);
+   }
+
+   OUTREG(SWF30, pI830->saveSWF[14]);
+   OUTREG(SWF31, pI830->saveSWF[15]);
+   OUTREG(SWF32, pI830->saveSWF[16]);
 
    i830CompareRegsToSnapshot(pScrn);
 



More information about the xorg-commit mailing list