xf86-video-ati: Branch 'randr-1.2' - 6 commits

Alex Deucher agd5f at kemper.freedesktop.org
Wed May 9 23:24:10 EEST 2007


 src/radeon.h         |    2 
 src/radeon_display.c |  156 +++++++++++++++++++++++++++++++++++----------------
 src/radeon_driver.c  |   89 ++++++++++++++++++++---------
 src/radeon_modes.c   |    4 +
 src/radeon_probe.h   |    2 
 5 files changed, 178 insertions(+), 75 deletions(-)

New commits:
diff-tree d2497009e395800fbde5777465f3087a54b94418 (from 4488f0737d5268168eab41440b7a3b5732efb15e)
Author: Alex Deucher <alex at t41p.hsd1.va.comcast.net>
Date:   Wed May 9 22:23:45 2007 +0200

    randr checkpoint
    
    - server still hangs if you start with external monitor connected
    - RMX not working
    - more than 2 outputs now possible (untested)

diff --git a/src/radeon.h b/src/radeon.h
index 671c87e..6afed66 100644
--- a/src/radeon.h
+++ b/src/radeon.h
@@ -765,6 +765,8 @@ typedef struct {
 
     CARD32            tv_dac_adj;
 
+  int               max_connectors;
+
     CreateScreenResourcesProcPtr CreateScreenResources;
 } RADEONInfoRec, *RADEONInfoPtr;
 
diff --git a/src/radeon_display.c b/src/radeon_display.c
index e379099..1039209 100644
--- a/src/radeon_display.c
+++ b/src/radeon_display.c
@@ -655,16 +655,16 @@ static RADEONMonitorType RADEONDisplayDD
 	     */
 	    if (radeon_output->TMDSType == TMDS_EXT) MonType = MT_DFP;
 	    else {
-		if ((INREG(RADEON_FP_GEN_CNTL) & RADEON_FP_EN_TMDS) || !info->IsMobility)
+		if (INREG(RADEON_FP_GEN_CNTL) & RADEON_FP_EN_TMDS)
 		    MonType = MT_DFP;
-		else 
+		else
 		    MonType = MT_LCD;
 	    }
 	} else MonType = MT_CRT;
     } else MonType = MT_NONE;
 
     xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-	       "DDC Type: %d, Detected Type: %d\n", DDCType, MonType);
+	       "DDC Type: %d, Detected Monitor Type: %d\n", DDCType, MonType);
 
     return MonType;
 }
@@ -943,7 +943,7 @@ void RADEONSetupConnectors(ScrnInfoPtr p
      * The information should be correct even on a OEM card.
      * If not, we may have problem -- need to use MonitorLayout option.
      */
-    for (i = 0; i < RADEON_MAX_CONNECTOR; i++) {
+    for (i = 0; i < info->max_connectors; i++) {
 	pRADEONEnt->PortInfo[i]->MonType = MT_UNKNOWN;
 	pRADEONEnt->PortInfo[i]->DDCType = DDC_NONE_DETECTED;
 	pRADEONEnt->PortInfo[i]->DACType = DAC_UNKNOWN;
@@ -1122,11 +1122,26 @@ void RADEONSetupConnectors(ScrnInfoPtr p
 	}
     }
 
-    for (i = 0; i < 2; i++) {
+#if 1
+    if (info->IsMobility) {
+        pRADEONEnt->PortInfo[2]->DDCType = DDC_DVI;
+        pRADEONEnt->PortInfo[2]->TMDSType = TMDS_INT;
+        pRADEONEnt->PortInfo[2]->ConnectorType = CONNECTOR_DVI_D;
+        pRADEONEnt->PortInfo[0]->TMDSType = TMDS_UNKNOWN;
+	if (pRADEONEnt->PortInfo[0]->DDCType == DDC_DVI) {
+	    pRADEONEnt->PortInfo[0]->DDCType = DDC_MONID;
+	}
+	if (pRADEONEnt->PortInfo[0]->TMDSType == TMDS_INT) {
+	    pRADEONEnt->PortInfo[0]->TMDSType = TMDS_UNKNOWN;
+	}
+    }
+#endif
+
+    for (i = 0; i < info->max_connectors; i++) {
       RADEONOutputPrivatePtr radeon_output = pRADEONEnt->PortInfo[i];
 
       int DDCReg = 0;
-      char *names[] = { "DDC1", "DDC2" };
+      char *names[] = { "DDC1", "DDC2", "DDC3" };
 
       RADEONSetOutputType(pScrn, radeon_output);
       switch(radeon_output->DDCType) {
@@ -1152,7 +1167,7 @@ void RADEONSetupConnectors(ScrnInfoPtr p
 	if (i == 0)
 		RADEONGetHardCodedEDIDFromBIOS(pScrn);
 
-	RADEONUpdatePanelSize(pScrn);
+	/*RADEONUpdatePanelSize(pScrn);*/
 
       }
 
@@ -1167,24 +1182,25 @@ static RADEONMonitorType RADEONPortCheck
     RADEONInfoPtr info       = RADEONPTR(pScrn);
     unsigned char *RADEONMMIO = info->MMIO;
     RADEONOutputPrivatePtr radeon_output = output->driver_private;
+    RADEONMonitorType MonType = MT_NONE;
+
 
     if (info->IsMobility) {
-      switch(radeon_output->num) {
-      case 0:
-	/* non-DDC laptop panel connected on primary */
-	if (INREG(RADEON_BIOS_4_SCRATCH) & 4)
-	  return MT_LCD;
-	break;
-      case 1:
+        if ((info->IsAtomBios && radeon_output->ConnectorType == CONNECTOR_LVDS_ATOM) ||
+	     radeon_output->ConnectorType == CONNECTOR_PROPRIETARY) {
+	     if (INREG(RADEON_BIOS_4_SCRATCH) & 4)
+	         MonType =  MT_LCD;
+        }
 	/* non-DDC TMDS panel connected through DVO */
 	if (INREG(RADEON_FP2_GEN_CNTL) & RADEON_FP2_ON)
-	  return MT_DFP;
-	break;
-      default:
-	break;
-      }
+	  MonType = MT_DFP;
     }
-    return MT_NONE;
+
+    xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+	       "Detected Monitor Type: %d\n", MonType);
+
+    return MonType;
+
 }
 
 /* Primary Head (DVI or Laptop Int. panel)*/
@@ -1201,8 +1217,8 @@ void RADEONConnectorFindMonitor(ScrnInfo
 						     radeon_output->DDCType,
 						     output)));
       else if((radeon_output->MonType = RADEONPortCheckNonDDC(pScrn, output)));
-      else
-	radeon_output->MonType = RADEONCrtIsPhysicallyConnected(pScrn, !(radeon_output->DACType));
+      else if (radeon_output->DACType == DAC_PRIMARY) 
+	  radeon_output->MonType = RADEONCrtIsPhysicallyConnected(pScrn, !(radeon_output->DACType));
     }
 
     if (output->MonInfo) {
@@ -1322,6 +1338,8 @@ Bool RADEONMapControllers(ScrnInfoPtr pS
     xf86OutputPtr output;
     int o;
 
+    pRADEONEnt->Controller[0]->binding = 1;
+    pRADEONEnt->Controller[1]->binding = 1;
 
     for (o = 0; o < xf86_config->num_output; o++) {
       output = xf86_config->output[o];
@@ -1477,7 +1495,6 @@ static void RADEONDacPowerSet(ScrnInfoPt
 			       RADEON_DAC_PDWN_G |
 			       RADEON_DAC_PDWN_B);
 	}
-	ErrorF("Setting IsOn %d DAC CNTL %08X and DAC MACRO_CNTL %08X\n", IsOn, dac_cntl, dac_macro_cntl);
 	OUTREG(RADEON_DAC_CNTL, dac_cntl);
 	OUTREG(RADEON_DAC_MACRO_CNTL, dac_macro_cntl);
     } else {
@@ -1594,6 +1611,8 @@ void RADEONEnableDisplay(ScrnInfoPtr pSc
     RADEONOutputPrivatePtr radeon_output;
     radeon_output = output->driver_private;
 
+    ErrorF("montype: %d\n", radeon_output->MonType);
+
     if (bEnable) {
         if (radeon_output->MonType == MT_CRT) {
             if (radeon_output->DACType == DAC_PRIMARY) {
@@ -1629,10 +1648,12 @@ void RADEONEnableDisplay(ScrnInfoPtr pSc
             }
         } else if (radeon_output->MonType == MT_LCD) {
             tmp = INREG(RADEON_LVDS_GEN_CNTL);
+	    ErrorF("read in LVDS reg\n");
             tmp |= (RADEON_LVDS_ON | RADEON_LVDS_BLON);
             tmp &= ~(RADEON_LVDS_DISPLAY_DIS);
 	    usleep (info->PanelPwrDly * 1000);
             OUTREG(RADEON_LVDS_GEN_CNTL, tmp);
+	    ErrorF("wrote out LVDS reg\n");
             save->lvds_gen_cntl |= (RADEON_LVDS_ON | RADEON_LVDS_BLON);
             save->lvds_gen_cntl &= ~(RADEON_LVDS_DISPLAY_DIS);
         } 
@@ -1693,6 +1714,7 @@ void RADEONEnableDisplay(ScrnInfoPtr pSc
 	    }
         }
     }
+    ErrorF("finished output enable\n");
 }
 
 /* Calculate display buffer watermark to prevent buffer underflow */
@@ -2260,6 +2282,7 @@ radeon_crtc_mode_set(xf86CrtcPtr crtc, D
       if (output->crtc == crtc) {
 	montype = radeon_output->MonType;
 	radeon_output->crtc_num = radeon_crtc->crtc_id + 1;
+	ErrorF("using crtc: %d on output %s montype: %d\n", radeon_output->crtc_num, OutputType[radeon_output->type], montype);
       }
     }
     
@@ -2275,14 +2298,20 @@ radeon_crtc_mode_set(xf86CrtcPtr crtc, D
     RADEONBlank(pScrn);
     RADEONRestoreMode(pScrn, &info->ModeReg);
 
+    ErrorF("mode restored\n");
+
     if (radeon_crtc->crtc_id == 0)
 	RADEONDoAdjustFrame(pScrn, x, y, FALSE);
     else if (radeon_crtc->crtc_id == 1)
 	RADEONDoAdjustFrame(pScrn, x, y, TRUE);
 
+    ErrorF("frame adjusted\n");
+
     if (info->DispPriority)
         RADEONInitDispBandwidth(pScrn);
+    ErrorF("bandwidth set\n");
     RADEONUnblank(pScrn);
+    ErrorF("unblank\n");
 }
 
 static void
@@ -2530,6 +2559,7 @@ Bool RADEONAllocateControllers(ScrnInfoP
 
 Bool RADEONAllocatePortInfo(ScrnInfoPtr pScrn)
 {
+    RADEONInfoPtr      info = RADEONPTR(pScrn);
     RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
     int num_connectors;
     int i;
@@ -2537,8 +2567,16 @@ Bool RADEONAllocatePortInfo(ScrnInfoPtr 
     if (pRADEONEnt->PortInfo[0])
 	return TRUE;
 
+    /* when we support TV, this should be incremented */
+    if (info->IsMobility) {
+      /* DVI on docks */
+      info->max_connectors = 3;
+    } else {
+      info->max_connectors = 2;
+    }
+
     /* for now always allocate max connectors */
-    for (i = 0 ; i < RADEON_MAX_CONNECTOR; i++) {
+    for (i = 0 ; i < info->max_connectors; i++) {
 
 	pRADEONEnt->PortInfo[i] = xnfcalloc(sizeof(RADEONOutputPrivateRec), 1);
 	if (!pRADEONEnt->PortInfo[i])
@@ -2584,6 +2622,7 @@ void RADEONSetOutputType(ScrnInfoPtr pSc
 
 Bool RADEONAllocateConnectors(ScrnInfoPtr pScrn)
 {
+    RADEONInfoPtr      info = RADEONPTR(pScrn);
     RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
     int i;
 
@@ -2591,7 +2630,7 @@ Bool RADEONAllocateConnectors(ScrnInfoPt
         return TRUE;
     
     /* for now always allocate max connectors */
-    for (i = 0 ; i < RADEON_MAX_CONNECTOR; i++) {
+    for (i = 0 ; i < info->max_connectors; i++) {
 
 	pRADEONEnt->pOutput[i] = xf86OutputCreate(pScrn, &radeon_output_funcs, OutputType[pRADEONEnt->PortInfo[i]->type]);
 	if (!pRADEONEnt->pOutput[i])
@@ -2604,7 +2643,7 @@ Bool RADEONAllocateConnectors(ScrnInfoPt
 	if (pRADEONEnt->PortInfo[i]->type != OUTPUT_LVDS)
  	    pRADEONEnt->pOutput[i]->possible_crtcs |= 2;
 
-	pRADEONEnt->pOutput[i]->possible_clones = 1|2;
+	pRADEONEnt->pOutput[i]->possible_clones = 0 /*1|2*/;
     }
 
     return TRUE;
@@ -2614,10 +2653,11 @@ Bool RADEONAllocateConnectors(ScrnInfoPt
 #if 0
 xf86OutputPtr RADEONGetCrtcConnector(ScrnInfoPtr pScrn, int crtc_num)
 {
+    RADEONInfoPtr      info = RADEONPTR(pScrn);
     RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
     int i;
 
-    for (i = 0; i < RADEON_MAX_CONNECTOR; i++) {
+    for (i = 0; i < info->max_connectors; i++) {
         if (pRADEONEnt->PortInfo[i]->crtc_num == crtc_num)
 	    return pRADEONEnt->pOutput[i];
     }
diff --git a/src/radeon_driver.c b/src/radeon_driver.c
index 0624ae6..df644d8 100644
--- a/src/radeon_driver.c
+++ b/src/radeon_driver.c
@@ -2555,7 +2555,9 @@ static Bool RADEONPreInitControllers(Scr
       xf86OutputPtr	      output = config->output[i];
       
       output->status = (*output->funcs->detect) (output);
+      ErrorF("finished output detect: %d\n", i);
     }
+    ErrorF("finished all detect\n");
     return TRUE;
 }
 
@@ -2819,12 +2821,16 @@ _X_EXPORT Bool RADEONPreInit(ScrnInfoPtr
        goto fail;
 
 
+    ErrorF("before xf86InitialConfiguration\n");
+
     if (!xf86InitialConfiguration (pScrn, FALSE))
    {
       xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes.\n");
       goto fail;
    }
 
+    ErrorF("after xf86InitialConfiguration\n");
+
    pScrn->displayWidth = (pScrn->virtualX + 63) & ~63;
 
    /* Set display resolution */
@@ -4370,6 +4376,9 @@ static void RADEONRestorePLLRegisters(Sc
     OUTPLLP(pScrn, RADEON_VCLK_ECP_CNTL,
 	    RADEON_VCLK_SRC_SEL_PPLLCLK,
 	    ~(RADEON_VCLK_SRC_SEL_MASK));
+
+    ErrorF("finished PLL1\n");
+
 }
 
 
@@ -4429,6 +4438,9 @@ static void RADEONRestorePLL2Registers(S
     OUTPLLP(pScrn, RADEON_PIXCLKS_CNTL,
 	    RADEON_PIX2CLK_SRC_SEL_P2PLLCLK,
 	    ~(RADEON_PIX2CLK_SRC_SEL_MASK));
+
+    ErrorF("finished PLL2\n");
+
 }
 
 
@@ -4616,13 +4628,14 @@ void RADEONChangeSurfaces(ScrnInfoPtr pS
 }
 
 static void
-RADEONEnableOuputs(ScrnInfoPtr pScrn, int crtc_num)
+RADEONEnableOutputs(ScrnInfoPtr pScrn, int crtc_num)
 {
+    RADEONInfoPtr      info = RADEONPTR(pScrn);
     RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
     int i;
     xf86OutputPtr output;
 
-    for (i = 0; i < RADEON_MAX_CONNECTOR; i++) {
+    for (i = 0; i < info->max_connectors; i++) {
         if (pRADEONEnt->PortInfo[i]->crtc_num == crtc_num) {
 	    output = pRADEONEnt->pOutput[i];
             RADEONEnableDisplay(pScrn, output, TRUE);
@@ -4655,7 +4668,7 @@ void RADEONRestoreMode(ScrnInfoPtr pScrn
        get set by RADEONEnableDisplay()
      */
     if (!info->IsSwitching && !info->IsSecondary)
-	RADEONDisableDisplays(pScrn);
+        RADEONDisableDisplays(pScrn);
 
     /* When changing mode with Dual-head card, care must be taken for
      * the special order in setting registers. CRTC2 has to be set
@@ -4704,14 +4717,19 @@ void RADEONRestoreMode(ScrnInfoPtr pScrn
 	RADEONRestoreCrtcRegisters(pScrn, restore);
 	RADEONRestorePLLRegisters(pScrn, restore);
 	RADEONRestoreFPRegisters(pScrn, restore);
+	ErrorF("finished FP restore\n");
 
-	RADEONEnableOuputs(pScrn, 1);
+	RADEONEnableOutputs(pScrn, 1);
+	ErrorF("enable output1 done\n");
 
 	if ((pCRTC2->binding == 1) || pRADEONEnt->HasSecondary) {
-	    RADEONEnableOuputs(pScrn, 2);
+	    RADEONEnableOutputs(pScrn, 2);
+	    ErrorF("enable output2 done\n");
 	}
     }
 
+    ErrorF("finished modeset\n");
+
 #if 0
     RADEONRestorePalette(pScrn, &info->SavedReg);
 #endif
@@ -5570,9 +5588,11 @@ static Bool RADEONInitCrtcRegisters(Scrn
     }
 
     /* get the output connected to this CRTC */
-    for (i = 0; i < RADEON_MAX_CONNECTOR; i++) {
-      if (pRADEONEnt->PortInfo[i]->crtc_num == 1)
+    for (i = 0; i < info->max_connectors; i++) {
+      if (pRADEONEnt->PortInfo[i]->crtc_num == 1) {
+	ErrorF("init output for crtc1\n");
         RADEONInitOutputRegisters(pScrn, save, mode, pRADEONEnt->pOutput[i], 1);
+      }
     }
 #if 0
     if (pRADEONEnt->PortInfo[0]->crtc_num == 1) {
@@ -5708,9 +5728,11 @@ static Bool RADEONInitCrtc2Registers(Scr
     save->fp_v2_sync_strt_wid = save->crtc2_v_sync_strt_wid;
 
     /* get the output connected to this CRTC */
-    for (i = 0; i < RADEON_MAX_CONNECTOR; i++) {
-      if (pRADEONEnt->PortInfo[i]->crtc_num == 2)
-        RADEONInitOutputRegisters(pScrn, save, mode, pRADEONEnt->pOutput[i], 1);
+    for (i = 0; i < info->max_connectors; i++) {
+      if (pRADEONEnt->PortInfo[i]->crtc_num == 2) {
+	ErrorF("init output for crtc2\n");
+        RADEONInitOutputRegisters(pScrn, save, mode, pRADEONEnt->pOutput[i], 2);
+      }
     }
 #if 0
     if (pRADEONEnt->PortInfo[0]->crtc_num == 2) {
diff --git a/src/radeon_modes.c b/src/radeon_modes.c
index 4d7251f..46680e3 100644
--- a/src/radeon_modes.c
+++ b/src/radeon_modes.c
@@ -270,10 +270,14 @@ RADEONProbeOutputModes(xf86OutputPtr out
     xf86MonPtr		    edid_mon;
     DisplayModePtr	    modes = NULL;
 
+#if 0
     /* force reprobe */
     radeon_output->MonType = MT_UNKNOWN;
 	
     RADEONConnectorFindMonitor(pScrn, output);
+#endif
+    ErrorF("in RADEONProbeOutputModes\n");
+
 
     if (radeon_output->type == OUTPUT_DVI || radeon_output->type == OUTPUT_VGA) {
       edid_mon = xf86OutputGetEDID (output, radeon_output->pI2CBus);
diff --git a/src/radeon_probe.h b/src/radeon_probe.h
index cbe9e74..541a910 100644
--- a/src/radeon_probe.h
+++ b/src/radeon_probe.h
@@ -137,7 +137,7 @@ typedef struct _RADEONOutputPrivateRec {
     I2CBusPtr         pI2CBus;
 } RADEONOutputPrivateRec, *RADEONOutputPrivatePtr;
 
-#define RADEON_MAX_CONNECTOR 2
+#define RADEON_MAX_CONNECTOR 3 /* actually 4: DVI/VGA, DVI on docks, TV, LVDS */
 #define RADEON_MAX_CRTC 2
 
 typedef struct
diff-tree 4488f0737d5268168eab41440b7a3b5732efb15e (from 4d992386e2ab9d8c50f0484445564325dfb42930)
Author: Alex Deucher <alex at t41p.hsd1.va.comcast.net>
Date:   Wed May 9 16:41:13 2007 +0200

    more randr re-work
    
    - remove RADEONQueryConnectedDisplays(); randr takes care of this now
    - print edid after randr detection

diff --git a/src/radeon_display.c b/src/radeon_display.c
index e79895f..e379099 100644
--- a/src/radeon_display.c
+++ b/src/radeon_display.c
@@ -1192,6 +1192,7 @@ static RADEONMonitorType RADEONPortCheck
 /* Secondary Head (mostly VGA, can be DVI on some OEM boards)*/
 void RADEONConnectorFindMonitor(ScrnInfoPtr pScrn, xf86OutputPtr output)
 {
+    RADEONInfoPtr info       = RADEONPTR(pScrn);
     RADEONEntPtr pRADEONEnt  = RADEONEntPriv(pScrn);
     RADEONOutputPrivatePtr radeon_output = output->driver_private;
     
@@ -1203,6 +1204,15 @@ void RADEONConnectorFindMonitor(ScrnInfo
       else
 	radeon_output->MonType = RADEONCrtIsPhysicallyConnected(pScrn, !(radeon_output->DACType));
     }
+
+    if (output->MonInfo) {
+      xf86DrvMsg(pScrn->scrnIndex, X_INFO, "EDID data from the display on connector: %s ----------------------\n",
+		 info->IsAtomBios ?
+		 ConnectorTypeNameATOM[radeon_output->ConnectorType]:
+		 ConnectorTypeName[radeon_output->ConnectorType]
+		 );
+      xf86PrintEDID( output->MonInfo );
+    }
 }
 
 void RADEONQueryConnectedDisplays(ScrnInfoPtr pScrn)
@@ -1312,10 +1322,7 @@ Bool RADEONMapControllers(ScrnInfoPtr pS
     xf86OutputPtr output;
     int o;
 
-    /*
-      pRADEONEnt->PortInfo[0]->crtc_num = 1;
-      pRADEONEnt->PortInfo[1]->crtc_num = 2;
-    */
+
     for (o = 0; o < xf86_config->num_output; o++) {
       output = xf86_config->output[o];
       radeon_output = output->driver_private;
@@ -2604,7 +2611,7 @@ Bool RADEONAllocateConnectors(ScrnInfoPt
 }
 
 
-
+#if 0
 xf86OutputPtr RADEONGetCrtcConnector(ScrnInfoPtr pScrn, int crtc_num)
 {
     RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
@@ -2616,7 +2623,7 @@ xf86OutputPtr RADEONGetCrtcConnector(Scr
     }
     return NULL;
 }
-
+#endif
 
 /**
  * In the current world order, there are lists of modes per output, which may
diff --git a/src/radeon_driver.c b/src/radeon_driver.c
index e16c183..0624ae6 100644
--- a/src/radeon_driver.c
+++ b/src/radeon_driver.c
@@ -2543,10 +2543,6 @@ static Bool RADEONPreInitControllers(Scr
       if (!RADEONAllocateConnectors(pScrn))
 	return FALSE;
     }
-
-    if (!info->IsSecondary) {
-      RADEONQueryConnectedDisplays(pScrn);
-    }
       
     RADEONMapControllers(pScrn);
 
diff-tree 4d992386e2ab9d8c50f0484445564325dfb42930 (from 2618cf2aa8ed76411b943eb90c95869814c2f151)
Author: Alex Deucher <alex at t41p.hsd1.va.comcast.net>
Date:   Wed May 9 16:12:21 2007 +0200

    enable all outputs on each crtc on mode restore

diff --git a/src/radeon_driver.c b/src/radeon_driver.c
index d05d9f7..e16c183 100644
--- a/src/radeon_driver.c
+++ b/src/radeon_driver.c
@@ -4619,6 +4619,22 @@ void RADEONChangeSurfaces(ScrnInfoPtr pS
     RADEONSaveSurfaces(pScrn, &info->ModeReg);
 }
 
+static void
+RADEONEnableOuputs(ScrnInfoPtr pScrn, int crtc_num)
+{
+    RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
+    int i;
+    xf86OutputPtr output;
+
+    for (i = 0; i < RADEON_MAX_CONNECTOR; i++) {
+        if (pRADEONEnt->PortInfo[i]->crtc_num == crtc_num) {
+	    output = pRADEONEnt->pOutput[i];
+            RADEONEnableDisplay(pScrn, output, TRUE);
+        }
+    }
+
+}
+
 /* Write out state to define a new video mode */
 void RADEONRestoreMode(ScrnInfoPtr pScrn, RADEONSavePtr restore)
 {
@@ -4664,10 +4680,7 @@ void RADEONRestoreMode(ScrnInfoPtr pScrn
 	    RADEONRestoreCrtc2Registers(pScrn, restore);
 	    RADEONRestorePLL2Registers(pScrn, restore);
 	    RADEONRestoreFPRegisters(pScrn, restore);
-	    output = RADEONGetCrtcConnector(pScrn, 2);
-	    if (output) {
-		RADEONEnableDisplay(pScrn, output, TRUE);
-	    }
+	    RADEONEnableOuputs(pScrn, 2);
 	} else {
 	    RADEONRestoreMemMapRegisters(pScrn, restore);
 	    RADEONRestoreCommonRegisters(pScrn, restore);
@@ -4679,15 +4692,9 @@ void RADEONRestoreMode(ScrnInfoPtr pScrn
             RADEONRestoreCrtcRegisters(pScrn, restore);
             RADEONRestorePLLRegisters(pScrn, restore);
 	    RADEONRestoreFPRegisters(pScrn, restore);
-	    output = RADEONGetCrtcConnector(pScrn, 1);
-	    if (output) {
-		RADEONEnableDisplay(pScrn, output, TRUE);
-	    }
+	    RADEONEnableOuputs(pScrn, 1);
 	    if (pCRTC2->binding == 1) {
-		output = RADEONGetCrtcConnector(pScrn, 2);
-		if (output) {
-		    RADEONEnableDisplay(pScrn, output, TRUE);
-		}
+	      RADEONEnableOuputs(pScrn, 2);
 	    }
 	}
     } else {
@@ -4701,15 +4708,11 @@ void RADEONRestoreMode(ScrnInfoPtr pScrn
 	RADEONRestoreCrtcRegisters(pScrn, restore);
 	RADEONRestorePLLRegisters(pScrn, restore);
 	RADEONRestoreFPRegisters(pScrn, restore);
-	output = RADEONGetCrtcConnector(pScrn, 1);
-	if (output) {
-	    RADEONEnableDisplay(pScrn, output, TRUE);
-	}
+
+	RADEONEnableOuputs(pScrn, 1);
+
 	if ((pCRTC2->binding == 1) || pRADEONEnt->HasSecondary) {
-	    output = RADEONGetCrtcConnector(pScrn, 2);
-	    if (output) {
-		RADEONEnableDisplay(pScrn, output, TRUE);
-	    }
+	    RADEONEnableOuputs(pScrn, 2);
 	}
     }
 
diff-tree 2618cf2aa8ed76411b943eb90c95869814c2f151 (from 61b9e79cbeee6f735a4c82ec8a802aee85d8b890)
Author: Alex Deucher <alex at t41p.hsd1.va.comcast.net>
Date:   Wed May 9 15:48:40 2007 +0200

    More re-org to allow more than 2 outputs
    
    - Move radeon output crtc map into crtc_set_mode
    - in modeinit, set up all outputs attached to crtc

diff --git a/src/radeon_display.c b/src/radeon_display.c
index 7d31a52..e79895f 100644
--- a/src/radeon_display.c
+++ b/src/radeon_display.c
@@ -1312,9 +1312,10 @@ Bool RADEONMapControllers(ScrnInfoPtr pS
     xf86OutputPtr output;
     int o;
 
+    /*
       pRADEONEnt->PortInfo[0]->crtc_num = 1;
       pRADEONEnt->PortInfo[1]->crtc_num = 2;
-
+    */
     for (o = 0; o < xf86_config->num_output; o++) {
       output = xf86_config->output[o];
       radeon_output = output->driver_private;
@@ -2251,6 +2252,7 @@ radeon_crtc_mode_set(xf86CrtcPtr crtc, D
 
       if (output->crtc == crtc) {
 	montype = radeon_output->MonType;
+	radeon_output->crtc_num = radeon_crtc->crtc_id + 1;
       }
     }
     
diff --git a/src/radeon_driver.c b/src/radeon_driver.c
index 1875244..d05d9f7 100644
--- a/src/radeon_driver.c
+++ b/src/radeon_driver.c
@@ -5420,8 +5420,9 @@ static Bool RADEONInitCrtcRegisters(Scrn
     int    hsync_start;
     int    hsync_wid;
     int    vsync_wid;
+    int i;
     RADEONEntPtr pRADEONEnt   = RADEONEntPriv(pScrn);
-    xf86OutputPtr connector;
+
 
     switch (info->CurrentLayout.pixel_code) {
     case 4:  format = 1; break;
@@ -5570,11 +5571,17 @@ static Bool RADEONInitCrtcRegisters(Scrn
     }
 
     /* get the output connected to this CRTC */
+    for (i = 0; i < RADEON_MAX_CONNECTOR; i++) {
+      if (pRADEONEnt->PortInfo[i]->crtc_num == 1)
+        RADEONInitOutputRegisters(pScrn, save, mode, pRADEONEnt->pOutput[i], 1);
+    }
+#if 0
     if (pRADEONEnt->PortInfo[0]->crtc_num == 1) {
 	RADEONInitOutputRegisters(pScrn, save, mode, pRADEONEnt->pOutput[0], 1);
     } else if (pRADEONEnt->PortInfo[1]->crtc_num == 1) {
 	RADEONInitOutputRegisters(pScrn, save, mode, pRADEONEnt->pOutput[1], 1);
     }
+#endif
 
     if (info->IsDellServer) {
 	save->dac2_cntl = info->SavedReg.dac2_cntl;
@@ -5604,9 +5611,10 @@ static Bool RADEONInitCrtc2Registers(Scr
     int    hsync_start;
     int    hsync_wid;
     int    vsync_wid;
-
+    int i;
     RADEONEntPtr pRADEONEnt   = RADEONEntPriv(pScrn);
     RADEONInfoPtr info0 = NULL;
+
     if (info->IsSecondary)
 	info0 = RADEONPTR(pRADEONEnt->pPrimaryScrn);
 
@@ -5701,11 +5709,17 @@ static Bool RADEONInitCrtc2Registers(Scr
     save->fp_v2_sync_strt_wid = save->crtc2_v_sync_strt_wid;
 
     /* get the output connected to this CRTC */
+    for (i = 0; i < RADEON_MAX_CONNECTOR; i++) {
+      if (pRADEONEnt->PortInfo[i]->crtc_num == 2)
+        RADEONInitOutputRegisters(pScrn, save, mode, pRADEONEnt->pOutput[i], 1);
+    }
+#if 0
     if (pRADEONEnt->PortInfo[0]->crtc_num == 2) {
 	RADEONInitOutputRegisters(pScrn, save, mode, pRADEONEnt->pOutput[0], 2);
     } else if (pRADEONEnt->PortInfo[1]->crtc_num == 2) {
 	RADEONInitOutputRegisters(pScrn, save, mode, pRADEONEnt->pOutput[1], 2);
     }
+#endif
 
     /* We must set SURFACE_CNTL properly on the second screen too */
     save->surface_cntl = 0;
diff-tree 61b9e79cbeee6f735a4c82ec8a802aee85d8b890 (from 6a724dd798c1a7b461672993c02be83a7bccded6)
Author: Alex Deucher <alex at t41p.hsd1.va.comcast.net>
Date:   Wed May 9 15:11:23 2007 +0200

    start to clean up MapControllers

diff --git a/src/radeon_display.c b/src/radeon_display.c
index c0750eb..7d31a52 100644
--- a/src/radeon_display.c
+++ b/src/radeon_display.c
@@ -1307,23 +1307,36 @@ Bool RADEONMapControllers(ScrnInfoPtr pS
     RADEONInfoPtr info       = RADEONPTR(pScrn);
     RADEONEntPtr pRADEONEnt   = RADEONEntPriv(pScrn);
     unsigned char *RADEONMMIO = info->MMIO;
-    Bool head_reversed = FALSE;
-    xf86OutputPtr output;
+    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
     RADEONOutputPrivatePtr radeon_output;
+    xf86OutputPtr output;
+    int o;
 
-    if (!info->IsSecondary) {
       pRADEONEnt->PortInfo[0]->crtc_num = 1;
       pRADEONEnt->PortInfo[1]->crtc_num = 2;
 
+    for (o = 0; o < xf86_config->num_output; o++) {
+      output = xf86_config->output[o];
+      radeon_output = output->driver_private;
+
       xf86DrvMsg(pScrn->scrnIndex, X_INFO, 
-		 "Port1:\n Monitor   -- %s\n Connector -- %s\n DAC Type  -- %s\n TMDS Type -- %s\n DDC Type  -- %s\n", 
-		 MonTypeName[pRADEONEnt->PortInfo[0]->MonType+1], 
-		 info->IsAtomBios ? 
-		 ConnectorTypeNameATOM[pRADEONEnt->PortInfo[0]->ConnectorType]:
-		 ConnectorTypeName[pRADEONEnt->PortInfo[0]->ConnectorType],
-		 DACTypeName[pRADEONEnt->PortInfo[0]->DACType+1],
-		 TMDSTypeName[pRADEONEnt->PortInfo[0]->TMDSType+1],
-		 DDCTypeName[pRADEONEnt->PortInfo[0]->DDCType]);
+		 "Port%d:\n Monitor   -- %s\n Connector -- %s\n DAC Type  -- %s\n TMDS Type -- %s\n DDC Type  -- %s\n", 
+	  o,
+	  MonTypeName[radeon_output->MonType+1],
+	  info->IsAtomBios ? 
+	  ConnectorTypeNameATOM[radeon_output->ConnectorType]:
+	  ConnectorTypeName[radeon_output->ConnectorType],
+	  DACTypeName[radeon_output->DACType+1],
+	  TMDSTypeName[radeon_output->TMDSType+1],
+	  DDCTypeName[radeon_output->DDCType]);
+
+    }
+
+#if 0
+    if (!info->IsSecondary) {
+      pRADEONEnt->PortInfo[0]->crtc_num = 1;
+      pRADEONEnt->PortInfo[1]->crtc_num = 2;
+
 
       xf86DrvMsg(pScrn->scrnIndex, X_INFO, 
 		 "Port2:\n Monitor   -- %s\n Connector -- %s\n DAC Type  -- %s\n TMDS Type -- %s\n DDC Type  -- %s\n", 
@@ -1426,7 +1439,7 @@ Bool RADEONMapControllers(ScrnInfoPtr pS
  	else
             xf86DrvMsg(pScrn->scrnIndex, X_INFO, "---- Secondary Head: Not used ----\n");
     }
-
+#endif
 
     return TRUE;
 }
diff-tree 6a724dd798c1a7b461672993c02be83a7bccded6 (from 03860fed24b4f76cc7f1f4210ec8f8040fa04777)
Author: Alex Deucher <alex at t41p.hsd1.va.comcast.net>
Date:   Wed May 9 14:48:17 2007 +0200

    minor cleanup

diff --git a/src/radeon_display.c b/src/radeon_display.c
index 5c84591..c0750eb 100644
--- a/src/radeon_display.c
+++ b/src/radeon_display.c
@@ -943,7 +943,7 @@ void RADEONSetupConnectors(ScrnInfoPtr p
      * The information should be correct even on a OEM card.
      * If not, we may have problem -- need to use MonitorLayout option.
      */
-    for (i = 0; i < 2; i++) {
+    for (i = 0; i < RADEON_MAX_CONNECTOR; i++) {
 	pRADEONEnt->PortInfo[i]->MonType = MT_UNKNOWN;
 	pRADEONEnt->PortInfo[i]->DDCType = DDC_NONE_DETECTED;
 	pRADEONEnt->PortInfo[i]->DACType = DAC_UNKNOWN;
@@ -2571,7 +2571,6 @@ Bool RADEONAllocateConnectors(ScrnInfoPt
     /* for now always allocate max connectors */
     for (i = 0 ; i < RADEON_MAX_CONNECTOR; i++) {
 
-
 	pRADEONEnt->pOutput[i] = xf86OutputCreate(pScrn, &radeon_output_funcs, OutputType[pRADEONEnt->PortInfo[i]->type]);
 	if (!pRADEONEnt->pOutput[i])
 	    return FALSE;
@@ -2579,11 +2578,11 @@ Bool RADEONAllocateConnectors(ScrnInfoPt
 	pRADEONEnt->pOutput[i]->driver_private = pRADEONEnt->PortInfo[i];
 	pRADEONEnt->PortInfo[i]->num = i;
 
-	pRADEONEnt->pOutput[i]->possible_crtcs = (1<<0);
+	pRADEONEnt->pOutput[i]->possible_crtcs = 1;
 	if (pRADEONEnt->PortInfo[i]->type != OUTPUT_LVDS)
- 	    pRADEONEnt->pOutput[i]->possible_crtcs |= (1<<1);
+ 	    pRADEONEnt->pOutput[i]->possible_crtcs |= 2;
 
-	pRADEONEnt->pOutput[i]->possible_clones = 0;
+	pRADEONEnt->pOutput[i]->possible_clones = 1|2;
     }
 
     return TRUE;
@@ -2594,11 +2593,12 @@ Bool RADEONAllocateConnectors(ScrnInfoPt
 xf86OutputPtr RADEONGetCrtcConnector(ScrnInfoPtr pScrn, int crtc_num)
 {
     RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
+    int i;
 
-    if (pRADEONEnt->PortInfo[0]->crtc_num == crtc_num)
-      return pRADEONEnt->pOutput[0];
-    else if (pRADEONEnt->PortInfo[1]->crtc_num == crtc_num)
-      return pRADEONEnt->pOutput[1];
+    for (i = 0; i < RADEON_MAX_CONNECTOR; i++) {
+        if (pRADEONEnt->PortInfo[i]->crtc_num == crtc_num)
+	    return pRADEONEnt->pOutput[i];
+    }
     return NULL;
 }
 


More information about the xorg-commit mailing list