From 5d5fa1b86e5179b061f0db47fe0227d1b84c37f8 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 4 Dec 2006 18:53:33 +1100 Subject: update radeon driver to Intel driver xf86Crtc interfaces --- src/Makefile.am | 3 +- src/radeon.h | 7 +- src/radeon_display.c | 297 +++++++++++++++++++++++++++++++++-------------- src/radeon_driver.c | 54 ++++----- src/radeon_modes.c | 30 ++--- src/radeon_probe.h | 53 +++++---- src/radeon_randr.c | 28 ++--- src/radeon_xf86Crtc.c | 140 ++++++++++++++++++++++ src/radeon_xf86Crtc.h | 316 ++++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 758 insertions(+), 170 deletions(-) create mode 100644 src/radeon_xf86Crtc.c create mode 100644 src/radeon_xf86Crtc.h diff --git a/src/Makefile.am b/src/Makefile.am index 459a9ae..788e4a9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -82,7 +82,7 @@ radeon_drv_la_SOURCES = \ radeon_accel.c radeon_mergedfb.c radeon_cursor.c radeon_dga.c \ radeon_driver.c radeon_video.c radeon_bios.c radeon_mm_i2c.c \ radeon_vip.c radeon_misc.c radeon_display.c radeon_modes.c \ - radeon_xf86Modes.c radeon_randr.c \ + radeon_xf86Crtc.c radeon_xf86Modes.c radeon_randr.c \ $(RADEON_DRI_SRCS) $(RADEON_EXA_SOURCES) theatre_detect_drv_la_LTLIBRARIES = theatre_detect_drv.la @@ -193,6 +193,7 @@ EXTRA_DIST = \ radeon_version.h \ radeon_video.h \ radeon_xf86Modes.h \ + radeon_xf86Crtc.h \ theatre200.h \ theatre_detect.h \ theatre.h \ diff --git a/src/radeon.h b/src/radeon.h index f6a0227..e40905a 100644 --- a/src/radeon.h +++ b/src/radeon.h @@ -77,6 +77,8 @@ #endif #endif +#include "radeon_xf86Crtc.h" + /* Render support */ #ifdef RENDER #include "picturestr.h" @@ -405,6 +407,7 @@ typedef struct { }RADEONTMDSPll; typedef struct { + xf86CrtcConfigRec xf86_config; EntityInfoPtr pEnt; pciVideoPtr PciInfo; PCITAG PciTag; @@ -897,7 +900,7 @@ extern Bool RADEONI2cInit(ScrnInfoPtr pScrn); extern void RADEONSetSyncRangeFromEdid(ScrnInfoPtr pScrn, int flag); extern void RADEONSetupConnectors(ScrnInfoPtr pScrn); extern Bool RADEONMapControllers(ScrnInfoPtr pScrn); -extern void RADEONEnableDisplay(ScrnInfoPtr pScrn, RADEONConnector* pPort, BOOL bEnable); +extern void RADEONEnableDisplay(ScrnInfoPtr pScrn, xf86OutputPtr pPort, BOOL bEnable); extern void RADEONDisableDisplays(ScrnInfoPtr pScrn); extern void RADEONGetPanelInfo(ScrnInfoPtr pScrn); extern void RADEONGetTVDacAdjInfo(ScrnInfoPtr pScrn); @@ -908,7 +911,7 @@ extern void RADEONDisplayPowerManagementSet(ScrnInfoPtr pScrn, int flags); extern Bool RADEONAllocateControllers(ScrnInfoPtr pScrn); extern Bool RADEONAllocateConnectors(ScrnInfoPtr pScrn); -extern RADEONConnector *RADEONGetCrtcConnector(ScrnInfoPtr pScrn, int crtc_num); +extern xf86OutputPtr RADEONGetCrtcConnector(ScrnInfoPtr pScrn, int crtc_num); extern int RADEONValidateMergeModes(ScrnInfoPtr pScrn); extern int RADEONValidateDDCModes(ScrnInfoPtr pScrn1, char **ppModeName, RADEONMonitorType DisplayType, int crtc2); diff --git a/src/radeon_display.c b/src/radeon_display.c index a248428..2521e31 100644 --- a/src/radeon_display.c +++ b/src/radeon_display.c @@ -538,13 +538,14 @@ RADEONCrtIsPhysicallyConnected(ScrnInfoPtr pScrn, int IsCrtDac) } -static RADEONMonitorType RADEONDisplayDDCConnected(ScrnInfoPtr pScrn, RADEONDDCType DDCType, RADEONConnector* port) +static RADEONMonitorType RADEONDisplayDDCConnected(ScrnInfoPtr pScrn, RADEONDDCType DDCType, xf86OutputPtr port) { RADEONInfoPtr info = RADEONPTR(pScrn); unsigned char *RADEONMMIO = info->MMIO; unsigned long DDCReg; RADEONMonitorType MonType = MT_NONE; xf86MonPtr* MonInfo = &port->MonInfo; + RADEONOutputPrivatePtr pRPort = port->driver_private; int i, j; DDCReg = info->DDCReg; @@ -639,7 +640,7 @@ static RADEONMonitorType RADEONDisplayDDCConnected(ScrnInfoPtr pScrn, RADEONDDCT * Also for laptop, when X starts with lid closed (no DVI connection) * both LDVS and TMDS are disable, we still need to treat it as a LVDS panel. */ - if (port->TMDSType == TMDS_EXT) MonType = MT_DFP; + if (pRPort->TMDSType == TMDS_EXT) MonType = MT_DFP; else { if ((INREG(RADEON_FP_GEN_CNTL) & RADEON_FP_EN_TMDS) || !info->IsMobility) MonType = MT_DFP; @@ -850,7 +851,7 @@ static Bool RADEONGetLVDSInfo (ScrnInfoPtr pScrn) tmp_mode = tmp_mode->next; } } - if ((info->DotClock == 0) && !pRADEONEnt->PortInfo[0]->MonInfo) { + if ((info->DotClock == 0) && !pRADEONEnt->pOutput[0]->MonInfo) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Panel size is not correctly detected.\n" "Please try to use PanelSize option for correct settings.\n"); @@ -919,6 +920,20 @@ void RADEONGetTVDacAdjInfo(ScrnInfoPtr pScrn) } } +static void RADEONSwapOutputs(ScrnInfoPtr pScrn) +{ + RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn); + xf86OutputPtr connector; + RADEONOutputPrivatePtr conn_priv; + + connector = pRADEONEnt->pOutput[0]; + pRADEONEnt->pOutput[0] = pRADEONEnt->pOutput[1]; + pRADEONEnt->pOutput[1] = connector; + + conn_priv = pRADEONEnt->PortInfo[0]; + pRADEONEnt->PortInfo[0] = pRADEONEnt->PortInfo[1]; + pRADEONEnt->PortInfo[1] = conn_priv; +} /* * initialise the static data sos we don't have to re-do at randr change */ void RADEONSetupConnectors(ScrnInfoPtr pScrn) @@ -936,7 +951,7 @@ void RADEONSetupConnectors(ScrnInfoPtr pScrn) */ for (i = 0; i < 2; i++) { pRADEONEnt->PortInfo[i]->MonType = MT_UNKNOWN; - pRADEONEnt->PortInfo[i]->MonInfo = NULL; + pRADEONEnt->pOutput[i]->MonInfo = NULL; pRADEONEnt->PortInfo[i]->DDCType = DDC_NONE_DETECTED; pRADEONEnt->PortInfo[i]->DACType = DAC_UNKNOWN; pRADEONEnt->PortInfo[i]->TMDSType = TMDS_UNKNOWN; @@ -952,14 +967,14 @@ void RADEONSetupConnectors(ScrnInfoPtr pScrn) (pRADEONEnt->PortInfo[1]->DDCType == 0))) { /* Below is the most common setting, but may not be true */ pRADEONEnt->PortInfo[0]->MonType = MT_UNKNOWN; - pRADEONEnt->PortInfo[0]->MonInfo = NULL; + pRADEONEnt->pOutput[0]->MonInfo = NULL; pRADEONEnt->PortInfo[0]->DDCType = DDC_DVI; pRADEONEnt->PortInfo[0]->DACType = DAC_TVDAC; pRADEONEnt->PortInfo[0]->TMDSType = TMDS_INT; pRADEONEnt->PortInfo[0]->ConnectorType = CONNECTOR_DVI_I; pRADEONEnt->PortInfo[1]->MonType = MT_UNKNOWN; - pRADEONEnt->PortInfo[1]->MonInfo = NULL; + pRADEONEnt->pOutput[1]->MonInfo = NULL; pRADEONEnt->PortInfo[1]->DDCType = DDC_VGA; pRADEONEnt->PortInfo[1]->DACType = DAC_PRIMARY; pRADEONEnt->PortInfo[1]->TMDSType = TMDS_EXT; @@ -977,10 +992,7 @@ void RADEONSetupConnectors(ScrnInfoPtr pScrn) /* always make TMDS_INT port first*/ if (pRADEONEnt->PortInfo[1]->TMDSType == TMDS_INT) { - RADEONConnector *connector; - connector = pRADEONEnt->PortInfo[0]; - pRADEONEnt->PortInfo[0] = pRADEONEnt->PortInfo[1]; - pRADEONEnt->PortInfo[1] = connector; + RADEONSwapOutputs(pScrn); } else if ((pRADEONEnt->PortInfo[0]->TMDSType != TMDS_INT && pRADEONEnt->PortInfo[1]->TMDSType != TMDS_INT)) { /* no TMDS_INT port, make primary DAC port first */ @@ -989,10 +1001,7 @@ void RADEONSetupConnectors(ScrnInfoPtr pScrn) swap when the first port is not DAC_PRIMARY */ if ((!(pRADEONEnt->PortInfo[0]->ConnectorType == CONNECTOR_PROPRIETARY)) && (pRADEONEnt->PortInfo[1]->DACType == DAC_PRIMARY) && (pRADEONEnt->PortInfo[0]->DACType != DAC_PRIMARY)) { - RADEONConnector *connector; - connector = pRADEONEnt->PortInfo[0]; - pRADEONEnt->PortInfo[0] = pRADEONEnt->PortInfo[1]; - pRADEONEnt->PortInfo[1] = connector; + RADEONSwapOutputs(pScrn); } } @@ -1172,15 +1181,16 @@ void RADEONConnectorFindMonitor(ScrnInfoPtr pScrn, int connector) { RADEONInfoPtr info = RADEONPTR(pScrn); RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn); - RADEONConnector *pPort = pRADEONEnt->PortInfo[connector]; + xf86OutputPtr pPort = pRADEONEnt->pOutput[connector]; + RADEONOutputPrivatePtr pRPort = pPort->driver_private; - if (pPort->MonType == MT_UNKNOWN) { - if ((pPort->MonType = RADEONDisplayDDCConnected(pScrn, - pPort->DDCType, + if (pRPort->MonType == MT_UNKNOWN) { + if ((pRPort->MonType = RADEONDisplayDDCConnected(pScrn, + pRPort->DDCType, pPort))); - else if((pPort->MonType = RADEONPortCheckNonDDC(pScrn, connector))); + else if((pRPort->MonType = RADEONPortCheckNonDDC(pScrn, connector))); else - pPort->MonType = RADEONCrtIsPhysicallyConnected(pScrn, !(pPort->DACType)); + pRPort->MonType = RADEONCrtIsPhysicallyConnected(pScrn, !(pRPort->DACType)); } } @@ -1210,11 +1220,11 @@ static void RADEONQueryConnectedDisplays(ScrnInfoPtr pScrn) if ((pRADEONEnt->PortInfo[0]->MonType > MT_NONE) && (pRADEONEnt->PortInfo[0]->MonType < MT_STV)) RADEONDisplayDDCConnected(pScrn, pRADEONEnt->PortInfo[0]->DDCType, - pRADEONEnt->PortInfo[0]); + pRADEONEnt->pOutput[0]); if ((pRADEONEnt->PortInfo[1]->MonType > MT_NONE) && (pRADEONEnt->PortInfo[1]->MonType < MT_STV)) RADEONDisplayDDCConnected(pScrn, pRADEONEnt->PortInfo[1]->DDCType, - pRADEONEnt->PortInfo[1]); + pRADEONEnt->pOutput[1]); } } else { @@ -1228,24 +1238,24 @@ static void RADEONQueryConnectedDisplays(ScrnInfoPtr pScrn) if ((!pRADEONEnt->HasCRTC2) && (pRADEONEnt->PortInfo[0]->MonType == MT_UNKNOWN)) { if((pRADEONEnt->PortInfo[0]->MonType = RADEONDisplayDDCConnected(pScrn, DDC_DVI, - pRADEONEnt->PortInfo[0]))); + pRADEONEnt->pOutput[0]))); else if((pRADEONEnt->PortInfo[0]->MonType = RADEONDisplayDDCConnected(pScrn, DDC_VGA, - pRADEONEnt->PortInfo[0]))); + pRADEONEnt->pOutput[0]))); else if((pRADEONEnt->PortInfo[0]->MonType = RADEONDisplayDDCConnected(pScrn, DDC_CRT2, - pRADEONEnt->PortInfo[0]))); + pRADEONEnt->pOutput[0]))); else pRADEONEnt->PortInfo[0]->MonType = MT_CRT; if (!ignore_edid) { - if (pRADEONEnt->PortInfo[0]->MonInfo) { + if (pRADEONEnt->pOutput[0]->MonInfo) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Monitor1 EDID data ---------------------------\n"); - xf86PrintEDID(pRADEONEnt->PortInfo[0]->MonInfo ); + xf86PrintEDID(pRADEONEnt->pOutput[0]->MonInfo ); xf86DrvMsg(pScrn->scrnIndex, X_INFO, "End of Monitor1 EDID data --------------------\n"); } } pRADEONEnt->PortInfo[1]->MonType = MT_NONE; - pRADEONEnt->PortInfo[1]->MonInfo = NULL; + pRADEONEnt->pOutput[1]->MonInfo = NULL; pRADEONEnt->PortInfo[1]->DDCType = DDC_NONE_DETECTED; pRADEONEnt->PortInfo[1]->DACType = DAC_UNKNOWN; pRADEONEnt->PortInfo[1]->TMDSType = TMDS_UNKNOWN; @@ -1263,17 +1273,17 @@ static void RADEONQueryConnectedDisplays(ScrnInfoPtr pScrn) } if(ignore_edid) { - pRADEONEnt->PortInfo[0]->MonInfo = NULL; - pRADEONEnt->PortInfo[1]->MonInfo = NULL; + pRADEONEnt->pOutput[0]->MonInfo = NULL; + pRADEONEnt->pOutput[1]->MonInfo = NULL; } else { - if (pRADEONEnt->PortInfo[0]->MonInfo) { + if (pRADEONEnt->pOutput[0]->MonInfo) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, "EDID data from the display on 1st port ----------------------\n"); - xf86PrintEDID( pRADEONEnt->PortInfo[0]->MonInfo ); + xf86PrintEDID( pRADEONEnt->pOutput[0]->MonInfo ); } - if (pRADEONEnt->PortInfo[1]->MonInfo) { + if (pRADEONEnt->pOutput[1]->MonInfo) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, "EDID data from the display on 2nd port -----------------------\n"); - xf86PrintEDID( pRADEONEnt->PortInfo[1]->MonInfo ); + xf86PrintEDID( pRADEONEnt->pOutput[1]->MonInfo ); } } @@ -1288,7 +1298,8 @@ Bool RADEONMapControllers(ScrnInfoPtr pScrn) RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn); unsigned char *RADEONMMIO = info->MMIO; Bool head_reversed = FALSE; - RADEONConnector *connector; + xf86OutputPtr connector; + RADEONOutputPrivatePtr pRPort; info->MergeType = MT_NONE; @@ -1368,45 +1379,51 @@ Bool RADEONMapControllers(ScrnInfoPtr pScrn) if(pRADEONEnt->HasCRTC2) { if(info->IsSecondary) { connector = RADEONGetCrtcConnector(pScrn, 2); + pRPort = connector->driver_private; pRADEONEnt->Controller[1]->binding = 2; if (connector) { - info->DisplayType = connector->MonType; + info->DisplayType = pRPort->MonType; pScrn->monitor->DDC = connector->MonInfo; } } else { connector = RADEONGetCrtcConnector(pScrn, 1); + pRPort = connector->driver_private; pRADEONEnt->Controller[0]->binding = 1; if (connector) { - info->DisplayType = connector->MonType; + info->DisplayType = pRPort->MonType; pScrn->monitor->DDC = connector->MonInfo; } } if(!pRADEONEnt->HasSecondary) { connector = RADEONGetCrtcConnector(pScrn, 2); + pRPort = connector->driver_private; if (connector) - info->MergeType = connector->MonType; + info->MergeType = pRPort->MonType; if (info->MergeType) pRADEONEnt->Controller[1]->binding = 1; } } else { connector = RADEONGetCrtcConnector(pScrn, 1); + pRPort = connector->driver_private; if (connector) { - if (connector->MonType == MT_NONE) - connector->MonType = MT_CRT; - info->DisplayType = connector->MonType; + if (pRPort->MonType == MT_NONE) + pRPort->MonType = MT_CRT; + info->DisplayType = pRPort->MonType; pScrn->monitor->DDC = connector->MonInfo; } connector = RADEONGetCrtcConnector(pScrn, 2); + pRPort = connector->driver_private; if (connector) - connector->MonType = MT_NONE; + pRPort->MonType = MT_NONE; pRADEONEnt->Controller[1]->binding = 1; } if (!info->IsSecondary) { connector = RADEONGetCrtcConnector(pScrn, 2); + pRPort = connector->driver_private; xf86DrvMsg(pScrn->scrnIndex, X_INFO, "---- Primary Head: Port%d ---- \n", head_reversed?2:1); - if (connector->MonType != MT_NONE) + if (pRPort->MonType != MT_NONE) xf86DrvMsg(pScrn->scrnIndex, X_INFO, "---- Secondary Head: Port%d ----\n", head_reversed?1:2); else xf86DrvMsg(pScrn->scrnIndex, X_INFO, "---- Secondary Head: Not used ----\n"); @@ -1560,21 +1577,23 @@ void RADEONDisableDisplays(ScrnInfoPtr pScrn) { } /* This is to be used enable/disable displays dynamically */ -void RADEONEnableDisplay(ScrnInfoPtr pScrn, RADEONConnector* pPort, BOOL bEnable) +void RADEONEnableDisplay(ScrnInfoPtr pScrn, xf86OutputPtr pPort, BOOL bEnable) { RADEONInfoPtr info = RADEONPTR(pScrn); RADEONSavePtr save = &info->ModeReg; unsigned char * RADEONMMIO = info->MMIO; unsigned long tmp; + RADEONOutputPrivatePtr pRPort; + pRPort = pPort->driver_private; if (bEnable) { - if (pPort->MonType == MT_CRT) { - if (pPort->DACType == DAC_PRIMARY) { + if (pRPort->MonType == MT_CRT) { + if (pRPort->DACType == DAC_PRIMARY) { tmp = INREG(RADEON_CRTC_EXT_CNTL); tmp |= RADEON_CRTC_CRT_ON; OUTREG(RADEON_CRTC_EXT_CNTL, tmp); save->crtc_ext_cntl |= RADEON_CRTC_CRT_ON; - } else if (pPort->DACType == DAC_TVDAC) { + } else if (pRPort->DACType == DAC_TVDAC) { if (info->ChipFamily == CHIP_FAMILY_R200) { tmp = INREG(RADEON_FP2_GEN_CNTL); tmp |= (RADEON_FP2_ON | RADEON_FP2_DVO_EN); @@ -1587,20 +1606,20 @@ void RADEONEnableDisplay(ScrnInfoPtr pScrn, RADEONConnector* pPort, BOOL bEnable save->crtc2_gen_cntl |= RADEON_CRTC2_CRT2_ON; } } - RADEONDacPowerSet(pScrn, bEnable, (pPort->DACType == DAC_PRIMARY)); - } else if (pPort->MonType == MT_DFP) { - if (pPort->TMDSType == TMDS_INT) { + RADEONDacPowerSet(pScrn, bEnable, (pRPort->DACType == DAC_PRIMARY)); + } else if (pRPort->MonType == MT_DFP) { + if (pRPort->TMDSType == TMDS_INT) { tmp = INREG(RADEON_FP_GEN_CNTL); tmp |= (RADEON_FP_FPON | RADEON_FP_TMDS_EN); OUTREG(RADEON_FP_GEN_CNTL, tmp); save->fp_gen_cntl |= (RADEON_FP_FPON | RADEON_FP_TMDS_EN); - } else if (pPort->TMDSType == TMDS_EXT) { + } else if (pRPort->TMDSType == TMDS_EXT) { tmp = INREG(RADEON_FP2_GEN_CNTL); tmp |= (RADEON_FP2_ON | RADEON_FP2_DVO_EN); OUTREG(RADEON_FP2_GEN_CNTL, tmp); save->fp2_gen_cntl |= (RADEON_FP2_ON | RADEON_FP2_DVO_EN); } - } else if (pPort->MonType == MT_LCD) { + } else if (pRPort->MonType == MT_LCD) { tmp = INREG(RADEON_LVDS_GEN_CNTL); tmp |= (RADEON_LVDS_ON | RADEON_LVDS_BLON); tmp &= ~(RADEON_LVDS_DISPLAY_DIS); @@ -1610,13 +1629,13 @@ void RADEONEnableDisplay(ScrnInfoPtr pScrn, RADEONConnector* pPort, BOOL bEnable save->lvds_gen_cntl &= ~(RADEON_LVDS_DISPLAY_DIS); } } else { - if (pPort->MonType == MT_CRT || pPort->MonType == NONE) { - if (pPort->DACType == DAC_PRIMARY) { + if (pRPort->MonType == MT_CRT || pRPort->MonType == NONE) { + if (pRPort->DACType == DAC_PRIMARY) { tmp = INREG(RADEON_CRTC_EXT_CNTL); tmp &= ~RADEON_CRTC_CRT_ON; OUTREG(RADEON_CRTC_EXT_CNTL, tmp); save->crtc_ext_cntl &= ~RADEON_CRTC_CRT_ON; - } else if (pPort->DACType == DAC_TVDAC) { + } else if (pRPort->DACType == DAC_TVDAC) { if (info->ChipFamily == CHIP_FAMILY_R200) { tmp = INREG(RADEON_FP2_GEN_CNTL); tmp &= ~(RADEON_FP2_ON | RADEON_FP2_DVO_EN); @@ -1629,16 +1648,16 @@ void RADEONEnableDisplay(ScrnInfoPtr pScrn, RADEONConnector* pPort, BOOL bEnable save->crtc2_gen_cntl &= ~RADEON_CRTC2_CRT2_ON; } } - RADEONDacPowerSet(pScrn, bEnable, (pPort->DACType == DAC_PRIMARY)); + RADEONDacPowerSet(pScrn, bEnable, (pRPort->DACType == DAC_PRIMARY)); } - if (pPort->MonType == MT_DFP || pPort->MonType == NONE) { - if (pPort->TMDSType == TMDS_INT) { + if (pRPort->MonType == MT_DFP || pRPort->MonType == NONE) { + if (pRPort->TMDSType == TMDS_INT) { tmp = INREG(RADEON_FP_GEN_CNTL); tmp &= ~(RADEON_FP_FPON | RADEON_FP_TMDS_EN); OUTREG(RADEON_FP_GEN_CNTL, tmp); save->fp_gen_cntl &= ~(RADEON_FP_FPON | RADEON_FP_TMDS_EN); - } else if (pPort->TMDSType == TMDS_EXT) { + } else if (pRPort->TMDSType == TMDS_EXT) { tmp = INREG(RADEON_FP2_GEN_CNTL); tmp &= ~(RADEON_FP2_ON | RADEON_FP2_DVO_EN); OUTREG(RADEON_FP2_GEN_CNTL, tmp); @@ -1646,8 +1665,8 @@ void RADEONEnableDisplay(ScrnInfoPtr pScrn, RADEONConnector* pPort, BOOL bEnable } } - if (pPort->MonType == MT_LCD || - (pPort->MonType == NONE && pPort->ConnectorType == CONNECTOR_PROPRIETARY)) { + if (pRPort->MonType == MT_LCD || + (pRPort->MonType == NONE && pRPort->ConnectorType == CONNECTOR_PROPRIETARY)) { unsigned long tmpPixclksCntl = INPLL(pScrn, RADEON_PIXCLKS_CNTL); if (info->IsMobility || info->IsIGP) { /* Asic bug, when turning off LVDS_ON, we have to make sure @@ -2006,25 +2025,27 @@ void RADEONInitDispBandwidth(ScrnInfoPtr pScrn) RADEONInitDispBandwidth2(pScrn, info, info2, mode1, mode2); } -static void RADEONBlankSet(ScrnInfoPtr pScrn, RADEONConnector *pPort) +static void RADEONBlankSet(ScrnInfoPtr pScrn, xf86OutputPtr pPort) { RADEONInfoPtr info = RADEONPTR(pScrn); unsigned char *RADEONMMIO = info->MMIO; RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn); + RADEONOutputPrivatePtr pRPort; + pRPort = pPort->driver_private; - switch(pPort->MonType) { + switch(pRPort->MonType) { case MT_LCD: OUTREGP(RADEON_LVDS_GEN_CNTL, RADEON_LVDS_DISPLAY_DIS, ~RADEON_LVDS_DISPLAY_DIS); break; case MT_CRT: if ((info->ChipFamily == CHIP_FAMILY_R200) && - (pPort->DACType == DAC_TVDAC)) + (pRPort->DACType == DAC_TVDAC)) OUTREGP(RADEON_FP2_GEN_CNTL, RADEON_FP2_BLANK_EN, ~RADEON_FP2_BLANK_EN); break; case MT_DFP: - if (pPort->TMDSType == TMDS_EXT) + if (pRPort->TMDSType == TMDS_EXT) OUTREGP(RADEON_FP2_GEN_CNTL, RADEON_FP2_BLANK_EN, ~RADEON_FP2_BLANK_EN); else OUTREGP(RADEON_FP_GEN_CNTL, RADEON_FP_BLANK_EN, ~RADEON_FP_BLANK_EN); @@ -2042,7 +2063,7 @@ void RADEONBlank(ScrnInfoPtr pScrn) RADEONInfoPtr info = RADEONPTR(pScrn); unsigned char *RADEONMMIO = info->MMIO; RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn); - RADEONConnector *pPort; + xf86OutputPtr pPort; if (!pRADEONEnt->HasSecondary || (pRADEONEnt->HasSecondary && !info->IsSwitching) || @@ -2089,23 +2110,24 @@ void RADEONBlank(ScrnInfoPtr pScrn) } } -static void RADEONUnblankSet(ScrnInfoPtr pScrn, RADEONConnector *pPort) +static void RADEONUnblankSet(ScrnInfoPtr pScrn, xf86OutputPtr pPort) { RADEONInfoPtr info = RADEONPTR (pScrn); unsigned char *RADEONMMIO = info->MMIO; RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn); + RADEONOutputPrivatePtr pRPort = pPort->driver_private; - switch(pPort->MonType) { + switch(pRPort->MonType) { case MT_LCD: OUTREGP(RADEON_LVDS_GEN_CNTL, 0, ~RADEON_LVDS_DISPLAY_DIS); break; case MT_CRT: if ((info->ChipFamily == CHIP_FAMILY_R200) && - (pPort->DACType == DAC_TVDAC)) + (pRPort->DACType == DAC_TVDAC)) OUTREGP(RADEON_FP2_GEN_CNTL, 0, ~RADEON_FP2_BLANK_EN); break; case MT_DFP: - if (pPort->TMDSType == TMDS_EXT) + if (pRPort->TMDSType == TMDS_EXT) OUTREGP(RADEON_FP2_GEN_CNTL, 0, ~RADEON_FP2_BLANK_EN); else OUTREGP(RADEON_FP_GEN_CNTL, 0, ~RADEON_FP_BLANK_EN); @@ -2122,7 +2144,7 @@ void RADEONUnblank(ScrnInfoPtr pScrn) RADEONInfoPtr info = RADEONPTR(pScrn); unsigned char *RADEONMMIO = info->MMIO; RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn); - RADEONConnector *pPort; + xf86OutputPtr pPort; if (!pRADEONEnt->HasSecondary || (info->IsSwitching && !info->IsSecondary)) { pPort = RADEONGetCrtcConnector(pScrn, 1); @@ -2158,7 +2180,7 @@ void RADEONUnblank(ScrnInfoPtr pScrn) } } -static void RADEONDPMSSetOn(ScrnInfoPtr pScrn, RADEONConnector *pPort) +static void RADEONDPMSSetOn(ScrnInfoPtr pScrn, xf86OutputPtr pPort) { RADEONInfoPtr info = RADEONPTR(pScrn); RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn); @@ -2166,10 +2188,11 @@ static void RADEONDPMSSetOn(ScrnInfoPtr pScrn, RADEONConnector *pPort) RADEONMonitorType MonType; RADEONTmdsType TmdsType; RADEONDacType DacType; + RADEONOutputPrivatePtr pRPort = pPort->driver_private; - MonType = pPort->MonType; - TmdsType = pPort->TMDSType; - DacType = pPort->DACType; + MonType = pRPort->MonType; + TmdsType = pRPort->TMDSType; + DacType = pRPort->DACType; switch(MonType) { case MT_LCD: @@ -2196,7 +2219,7 @@ static void RADEONDPMSSetOn(ScrnInfoPtr pScrn, RADEONConnector *pPort) } } -static void RADEONDPMSSetOff(ScrnInfoPtr pScrn, RADEONConnector *pPort) +static void RADEONDPMSSetOff(ScrnInfoPtr pScrn, xf86OutputPtr pPort) { RADEONInfoPtr info = RADEONPTR(pScrn); RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn); @@ -2205,10 +2228,11 @@ static void RADEONDPMSSetOff(ScrnInfoPtr pScrn, RADEONConnector *pPort) RADEONTmdsType TmdsType; RADEONDacType DacType; unsigned long tmpPixclksCntl; + RADEONOutputPrivatePtr pRPort = pPort->driver_private; - MonType = pPort->MonType; - TmdsType = pPort->TMDSType; - DacType = pPort->DACType; + MonType = pRPort->MonType; + TmdsType = pRPort->TMDSType; + DacType = pRPort->DACType; switch(MonType) { case MT_LCD: @@ -2251,7 +2275,7 @@ void RADEONDisplayPowerManagementSet(ScrnInfoPtr pScrn, RADEONInfoPtr info = RADEONPTR(pScrn); RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn); unsigned char *RADEONMMIO = info->MMIO; - RADEONConnector *pPort; + xf86OutputPtr pPort; if (!pScrn->vtSema) return; RADEONTRACE(("RADEONDisplayPowerManagementSet(%d,0x%x)\n", PowerManagementMode, flags)); @@ -2355,6 +2379,86 @@ void RADEONDisplayPowerManagementSet(ScrnInfoPtr pScrn, #endif } +static const xf86CrtcFuncsRec radeon_crtc_funcs = { +}; + +static void +radeon_dpms(xf86OutputPtr output, int mode) +{ + ScrnInfoPtr pScrn = output->scrn; + +} + +static void +radeon_save(xf86OutputPtr output) +{ + +} + +static void +radeon_restore(xf86OutputPtr restore) +{ + +} + +static int +radeon_mode_valid(xf86OutputPtr output, DisplayModePtr pMode) +{ + return MODE_OK; +} + +static void +radeon_pre_set_mode(xf86OutputPtr output, DisplayModePtr pMode) +{ + +} + +static void +radeon_post_set_mode(xf86OutputPtr output, DisplayModePtr pMode) +{ +} + + +static enum detect_status +radeon_detect(xf86OutputPtr output) +{ + ScrnInfoPtr pScrn = output->scrn; + RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn); + RADEONOutputPrivatePtr radeon_output = output->driver_private; +#if 0 + // RADEONConnectorFindMonitor(pScrn, id); + if (pRADEONEnt->PortInfo[id].MonType == MT_UNKNOWN) + return OUTPUT_STATUS_UNKNOWN; + else if (pRADEONEnt->PortInfo[id].MonType == MT_NONE) + return OUTPUT_STATUS_DISCONNECTED; + else + return OUTPUT_STATUS_CONNECTED; +#endif +} + +static DisplayModePtr +radeon_get_modes(xf86OutputPtr output) +{ + +} + +static void +radeon_destroy (xf86OutputPtr output) +{ +} + +static const xf86OutputFuncsRec radeon_output_funcs = { + .dpms = radeon_dpms, + .save = radeon_save, + .restore = radeon_restore, + .mode_valid = radeon_mode_valid, + .pre_set_mode = radeon_pre_set_mode, + .post_set_mode = radeon_post_set_mode, + .detect = radeon_detect, + .get_modes = radeon_get_modes, + .destroy = radeon_destroy +}; + Bool RADEONAllocateControllers(ScrnInfoPtr pScrn) { RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn); @@ -2363,20 +2467,31 @@ Bool RADEONAllocateControllers(ScrnInfoPtr pScrn) if (pRADEONEnt->Controller[0]) return TRUE; - pRADEONEnt->Controller[0] = xcalloc(sizeof(RADEONController), 1); + pRADEONEnt->pCrtc[0] = xf86CrtcCreate(pScrn, &radeon_crtc_funcs); + if (!pRADEONEnt->pCrtc[0]) + return FALSE; + + pRADEONEnt->Controller[0] = xnfcalloc(sizeof(xf86CrtcRec), 1); if (!pRADEONEnt->Controller[0]) return FALSE; + + pRADEONEnt->pCrtc[0]->driver_private = pRADEONEnt->Controller[0]; if (!pRADEONEnt->HasCRTC2) return TRUE; - pRADEONEnt->Controller[1] = xcalloc(sizeof(RADEONController), 1); + pRADEONEnt->pCrtc[1] = xf86CrtcCreate(pScrn, &radeon_crtc_funcs); + if (!pRADEONEnt->pCrtc[1]) + return FALSE; + + pRADEONEnt->Controller[1] = xnfcalloc(sizeof(xf86CrtcRec), 1); if (!pRADEONEnt->Controller[1]) { xfree(pRADEONEnt->Controller[0]); return FALSE; } + pRADEONEnt->pCrtc[1]->driver_private = pRADEONEnt->Controller[1]; return TRUE; } @@ -2391,21 +2506,31 @@ Bool RADEONAllocateConnectors(ScrnInfoPtr pScrn) /* for now always allocate max connectors */ for (i = 0 ; i < RADEON_MAX_CONNECTOR; i++) { - pRADEONEnt->PortInfo[i] = xcalloc(sizeof(RADEONConnector), 1); + + pRADEONEnt->pOutput[i] = xf86OutputCreate(pScrn, &radeon_output_funcs, "VGA"); + if (!pRADEONEnt->pOutput[i]) + return FALSE; + + pRADEONEnt->PortInfo[i] = xnfcalloc(sizeof(RADEONOutputPrivateRec), 1); if (!pRADEONEnt->PortInfo[i]) return FALSE; + + pRADEONEnt->PortInfo[i]->type = OUTPUT_VGA; + pRADEONEnt->pOutput[i]->driver_private = pRADEONEnt->PortInfo[i]; } return TRUE; } -RADEONConnector *RADEONGetCrtcConnector(ScrnInfoPtr pScrn, int crtc_num) + + +xf86OutputPtr RADEONGetCrtcConnector(ScrnInfoPtr pScrn, int crtc_num) { RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn); if (pRADEONEnt->PortInfo[0]->crtc_num == crtc_num) - return pRADEONEnt->PortInfo[0]; + return pRADEONEnt->pOutput[0]; else if (pRADEONEnt->PortInfo[1]->crtc_num == crtc_num) - return pRADEONEnt->PortInfo[1]; + return pRADEONEnt->pOutput[1]; return NULL; } diff --git a/src/radeon_driver.c b/src/radeon_driver.c index ccd0e1b..0724fe7 100644 --- a/src/radeon_driver.c +++ b/src/radeon_driver.c @@ -1996,7 +1996,7 @@ static Bool RADEONPreInitModes(ScrnInfoPtr pScrn, xf86Int10InfoPtr pInt10) int modesFound; RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn); char *s; - RADEONConnector *connector; + xf86OutputPtr connector; /* This option has two purposes: * * 1. For CRT, if this option is on, xf86ValidateModes (to @@ -2037,9 +2037,11 @@ static Bool RADEONPreInitModes(ScrnInfoPtr pScrn, xf86Int10InfoPtr pInt10) /* don't use RMX if we have a dual-tmds panels */ - if ((connector = RADEONGetCrtcConnector(pScrn, 2))) - if (connector->MonType == MT_DFP) + if ((connector = RADEONGetCrtcConnector(pScrn, 2))) { + RADEONOutputPrivatePtr radconnector = connector->driver_private; + if (radconnector->MonType == MT_DFP) info->ddc_mode = TRUE; + } /* don't use RMX if we are Dell Server */ if (info->IsDellServer) { @@ -2049,7 +2051,7 @@ static Bool RADEONPreInitModes(ScrnInfoPtr pScrn, xf86Int10InfoPtr pInt10) "Validating modes on %s head ---------\n", info->IsSecondary ? "Secondary" : "Primary"); - if (!pRADEONEnt->PortInfo[0]->MonInfo && !pRADEONEnt->PortInfo[1]->MonInfo && info->ddc_mode) { + if (!pRADEONEnt->pOutput[0]->MonInfo && !pRADEONEnt->pOutput[1]->MonInfo && info->ddc_mode) { info->ddc_mode = FALSE; xf86DrvMsg(pScrn->scrnIndex, X_INFO, "No DDC data available, DDCMode option is dismissed\n"); @@ -5103,9 +5105,9 @@ static void RADEONRestoreMode(ScrnInfoPtr pScrn, RADEONSavePtr restore) { RADEONInfoPtr info = RADEONPTR(pScrn); RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn); - RADEONController* pCRTC1 = pRADEONEnt->Controller[0]; - RADEONController* pCRTC2 = pRADEONEnt->Controller[1]; - RADEONConnector *pPort; + RADEONCrtcPrivatePtr pCRTC1 = pRADEONEnt->Controller[0]; + RADEONCrtcPrivatePtr pCRTC2 = pRADEONEnt->Controller[1]; + xf86OutputPtr pPort; RADEONTRACE(("RADEONRestoreMode(%p)\n", restore)); /* For Non-dual head card, we don't have private field in the Entity */ @@ -5840,24 +5842,24 @@ static void RADEONInitDAC2Registers(ScrnInfoPtr pScrn, RADEONSavePtr save, } } -static void RADEONInitOutputRegisters(ScrnInfoPtr pScrn, RADEONSavePtr save, DisplayModePtr mode, RADEONConnector *pPort, int crtc_num) +static void RADEONInitOutputRegisters(ScrnInfoPtr pScrn, RADEONSavePtr save, DisplayModePtr mode, xf86OutputPtr pPort, int crtc_num) { Bool IsPrimary = crtc_num == 1 ? TRUE : FALSE; - - if (pPort->MonType == MT_CRT) { - if (pPort->DACType == DAC_PRIMARY) { + RADEONOutputPrivatePtr pRPort = pPort->driver_private; + if (pRPort->MonType == MT_CRT) { + if (pRPort->DACType == DAC_PRIMARY) { RADEONInitDACRegisters(pScrn, save, mode, IsPrimary); } else { RADEONInitDAC2Registers(pScrn, save, mode, IsPrimary); } - } else if (pPort->MonType == MT_LCD) { + } else if (pRPort->MonType == MT_LCD) { if (crtc_num == 1) RADEONInitRMXRegisters(pScrn, save, mode); RADEONInitLVDSRegisters(pScrn, save, mode, IsPrimary); - } else if (pPort->MonType == MT_DFP) { + } else if (pRPort->MonType == MT_DFP) { if (crtc_num == 1) RADEONInitRMXRegisters(pScrn, save, mode); - if (pPort->TMDSType == TMDS_INT) { + if (pRPort->TMDSType == TMDS_INT) { RADEONInitFPRegisters(pScrn, save, mode, IsPrimary); } else { RADEONInitFP2Registers(pScrn, save, mode, IsPrimary); @@ -5874,11 +5876,11 @@ static Bool RADEONInitCrtcRegisters(ScrnInfoPtr pScrn, RADEONSavePtr save, int hsync_wid; int vsync_wid; RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn); - RADEONConnector *connector; + xf86OutputPtr connector; pRADEONEnt->Controller[0]->IsUsed = TRUE; pRADEONEnt->Controller[0]->IsActive = TRUE; - pRADEONEnt->Controller[0]->pCurMode = mode; + pRADEONEnt->pCrtc[0]->curMode = *mode; switch (info->CurrentLayout.pixel_code) { case 4: format = 1; break; @@ -6025,9 +6027,9 @@ static Bool RADEONInitCrtcRegisters(ScrnInfoPtr pScrn, RADEONSavePtr save, /* get the output connected to this CRTC */ if (pRADEONEnt->PortInfo[0]->crtc_num == 1) { - RADEONInitOutputRegisters(pScrn, save, mode, pRADEONEnt->PortInfo[0], 1); + RADEONInitOutputRegisters(pScrn, save, mode, pRADEONEnt->pOutput[0], 1); } else if (pRADEONEnt->PortInfo[1]->crtc_num == 1) { - RADEONInitOutputRegisters(pScrn, save, mode, pRADEONEnt->PortInfo[1], 1); + RADEONInitOutputRegisters(pScrn, save, mode, pRADEONEnt->pOutput[1], 1); } if (info->IsDellServer) { @@ -6066,7 +6068,7 @@ static Bool RADEONInitCrtc2Registers(ScrnInfoPtr pScrn, RADEONSavePtr save, pRADEONEnt->Controller[1]->IsUsed = TRUE; pRADEONEnt->Controller[1]->IsActive = TRUE; - pRADEONEnt->Controller[1]->pCurMode = mode; + pRADEONEnt->pCrtc[1]->curMode = *mode; switch (info->CurrentLayout.pixel_code) { case 4: format = 1; break; @@ -6160,9 +6162,9 @@ static Bool RADEONInitCrtc2Registers(ScrnInfoPtr pScrn, RADEONSavePtr save, /* get the output connected to this CRTC */ if (pRADEONEnt->PortInfo[0]->crtc_num == 2) { - RADEONInitOutputRegisters(pScrn, save, mode, pRADEONEnt->PortInfo[0], 2); + RADEONInitOutputRegisters(pScrn, save, mode, pRADEONEnt->pOutput[0], 2); } else if (pRADEONEnt->PortInfo[1]->crtc_num == 2) { - RADEONInitOutputRegisters(pScrn, save, mode, pRADEONEnt->PortInfo[1], 2); + RADEONInitOutputRegisters(pScrn, save, mode, pRADEONEnt->pOutput[1], 2); } /* We must set SURFACE_CNTL properly on the second screen too */ @@ -7043,7 +7045,7 @@ RADEONGetMergedFBOptions(ScrnInfoPtr pScrn) { RADEONInfoPtr info = RADEONPTR(pScrn); RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn); - RADEONConnector *connector; + xf86OutputPtr pOutput; char *strptr; char *default_hsync = "28-33"; char *default_vrefresh = "43-72"; @@ -7081,8 +7083,8 @@ RADEONGetMergedFBOptions(ScrnInfoPtr pScrn) info->MergedFB = FALSE; xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Failed to detect secondary monitor, MergedFB/Clone mode disabled\n"); - } else if ((connector = RADEONGetCrtcConnector(pScrn, 2))) { - if (!connector->MonInfo) { + } else if ((pOutput = RADEONGetCrtcConnector(pScrn, 2))) { + if (!pOutput->MonInfo) { xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Failed to detect secondary monitor DDC, default HSync and VRefresh used\n"); default_range = TRUE; @@ -7249,8 +7251,8 @@ RADEONGetMergedFBOptions(ScrnInfoPtr pScrn) } /* xf86SetDDCproperties(info->CRT2pScrn, pRADEONEnt->MonInfo2); */ - if (connector = RADEONGetCrtcConnector(pScrn, 2)) - info->CRT2pScrn->monitor->DDC = connector->MonInfo; + if (pOutput = RADEONGetCrtcConnector(pScrn, 2)) + info->CRT2pScrn->monitor->DDC = pOutput->MonInfo; else info->CRT2pScrn->monitor->DDC = NULL; if (default_range) { diff --git a/src/radeon_modes.c b/src/radeon_modes.c index c70f5e0..6654afe 100644 --- a/src/radeon_modes.c +++ b/src/radeon_modes.c @@ -603,24 +603,24 @@ RADEONProbeOutputModes(ScrnInfoPtr pScrn) for (i = 0; i < RADEON_MAX_CONNECTOR; i++) { - test = pRADEONEnt->PortInfo[i]->probed_modes; + test = pRADEONEnt->pOutput[i]->probed_modes; while(test != NULL) { xf86DeleteMode(&test, test); } - pRADEONEnt->PortInfo[i]->probed_modes = test; + pRADEONEnt->pOutput[i]->probed_modes = test; /* force reprobe */ pRADEONEnt->PortInfo[i]->MonType = MT_UNKNOWN; RADEONConnectorFindMonitor(pScrn, i); /* okay we got DDC info */ - if (pRADEONEnt->PortInfo[i]->MonInfo) { + if (pRADEONEnt->pOutput[i]->MonInfo) { /* Debug info for now, at least */ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "EDID for output %d\n", i); - xf86PrintEDID(pRADEONEnt->PortInfo[i]->MonInfo); + xf86PrintEDID(pRADEONEnt->pOutput[i]->MonInfo); - ddc_modes = RADEONGetDDCModes(pScrn, pRADEONEnt->PortInfo[i]->MonInfo); + ddc_modes = RADEONGetDDCModes(pScrn, pRADEONEnt->pOutput[i]->MonInfo); for (mode = ddc_modes; mode != NULL; mode = mode->next) { if (mode->Flags & V_DBLSCAN) { @@ -634,7 +634,7 @@ RADEONProbeOutputModes(ScrnInfoPtr pScrn) } - if (pRADEONEnt->PortInfo[i]->probed_modes == NULL) { + if (pRADEONEnt->pOutput[i]->probed_modes == NULL) { MonRec fixed_mon; DisplayModePtr modes; @@ -657,26 +657,26 @@ RADEONProbeOutputModes(ScrnInfoPtr pScrn) RADEONxf86ValidateModesSync(pScrn, modes, &fixed_mon); RADEONxf86PruneInvalidModes(pScrn, &modes, TRUE); /* fill out CRT of FP mode table */ - pRADEONEnt->PortInfo[i]->probed_modes = modes; + pRADEONEnt->pOutput[i]->probed_modes = modes; break; case MT_LCD: - RADEONValidateFPModes(pScrn, pScrn->display->modes, &pRADEONEnt->PortInfo[i]->probed_modes); + RADEONValidateFPModes(pScrn, pScrn->display->modes, &pRADEONEnt->pOutput[i]->probed_modes); break; default: break; } } - if (pRADEONEnt->PortInfo[i]->probed_modes) { + if (pRADEONEnt->pOutput[i]->probed_modes) { RADEONxf86ValidateModesUserConfig(pScrn, - pRADEONEnt->PortInfo[i]->probed_modes); - RADEONxf86PruneInvalidModes(pScrn, &pRADEONEnt->PortInfo[i]->probed_modes, + pRADEONEnt->pOutput[i]->probed_modes); + RADEONxf86PruneInvalidModes(pScrn, &pRADEONEnt->pOutput[i]->probed_modes, FALSE); } - for (mode = pRADEONEnt->PortInfo[i]->probed_modes; mode != NULL; + for (mode = pRADEONEnt->pOutput[i]->probed_modes; mode != NULL; mode = mode->next) { /* The code to choose the best mode per pipe later on will require @@ -727,9 +727,9 @@ RADEON_set_xf86_modes_from_outputs(ScrnInfoPtr pScrn) * care about enough to make some sort of unioned list. */ for (i = 0; i < RADEON_MAX_CONNECTOR; i++) { - if (pRADEONEnt->PortInfo[i]->probed_modes != NULL) { + if (pRADEONEnt->pOutput[i]->probed_modes != NULL) { pScrn->modes = - RADEONxf86DuplicateModes(pScrn, pRADEONEnt->PortInfo[i]->probed_modes); + RADEONxf86DuplicateModes(pScrn, pRADEONEnt->pOutput[i]->probed_modes); break; } } @@ -789,7 +789,7 @@ RADEON_set_default_screen_size(ScrnInfoPtr pScrn) for (i = 0; i < RADEON_MAX_CONNECTOR; i++) { DisplayModePtr mode; - for (mode = pRADEONEnt->PortInfo[i]->probed_modes; mode != NULL; + for (mode = pRADEONEnt->pOutput[i]->probed_modes; mode != NULL; mode = mode->next) { if (mode->HDisplay > maxX) diff --git a/src/radeon_probe.h b/src/radeon_probe.h index ebd4bab..a717504 100644 --- a/src/radeon_probe.h +++ b/src/radeon_probe.h @@ -43,8 +43,7 @@ #define _XF86MISC_SERVER_ #include -#define RADEON_MAX_CRTC 2 -#define RADEON_MAX_CONNECTOR 2 +#include "radeon_xf86Crtc.h" typedef enum { @@ -106,38 +105,34 @@ typedef enum TMDS_EXT = 1 } RADEONTmdsType; -typedef struct +typedef enum { - Bool IsUsed; + OUTPUT_NONE, + OUTPUT_VGA, + OUTPUT_DVI, + OUTPUT_LVDS, + OUTPUT_STV, + OUTPUT_CTX, +} RADEONOutputType; + +typedef struct _RADEONCrtcPrivateRec { + int crtc; + int crtc_id; + int binding; Bool IsActive; - int binding; // which instance of the driver "owns" this controller - DisplayModePtr pCurMode; - -#ifdef RANDR_12_INTERFACE - RRCrtcPtr randr_crtc; -#endif -} RADEONController; + Bool IsUsed; +} RADEONCrtcPrivateRec, *RADEONCrtcPrivatePtr; -typedef struct -{ +typedef struct _RADEONOutputPrivateRec { + RADEONOutputType type; + void *dev_priv; RADEONDDCType DDCType; RADEONDacType DACType; RADEONTmdsType TMDSType; RADEONConnectorType ConnectorType; RADEONMonitorType MonType; - xf86MonPtr MonInfo; - - /* one connector can be bound to one CRTC */ int crtc_num; - - /* a list of probed modes on this connector */ - DisplayModePtr probed_modes; -#ifdef RANDR_12_INTERFACE - RROutputPtr randr_output; -#endif -} RADEONConnector; - - +} RADEONOutputPrivateRec, *RADEONOutputPrivatePtr; #define RADEON_MAX_CONNECTOR 2 #define RADEON_MAX_CRTC 2 @@ -158,8 +153,12 @@ typedef struct Bool ReversedDAC; /* TVDAC used as primary dac */ Bool ReversedTMDS; /* DDC_DVI is used for external TMDS */ - RADEONConnector *PortInfo[RADEON_MAX_CONNECTOR]; - RADEONController *Controller[RADEON_MAX_CRTC]; /* pointer to a controller */ + xf86OutputPtr pOutput[RADEON_MAX_CONNECTOR]; + RADEONOutputPrivatePtr PortInfo[RADEON_MAX_CONNECTOR]; + + xf86CrtcPtr pCrtc[RADEON_MAX_CRTC]; + RADEONCrtcPrivatePtr Controller[RADEON_MAX_CRTC]; + } RADEONEntRec, *RADEONEntPtr; /* radeon_probe.c */ diff --git a/src/radeon_randr.c b/src/radeon_randr.c index 2fc012a..fc09075 100644 --- a/src/radeon_randr.c +++ b/src/radeon_randr.c @@ -133,7 +133,7 @@ RADEONRandRCrtcNotify (RRCrtcPtr crtc) for (i = 0; iPortInfo[i]->randr_output; + rrout = pRADEONEnt->pOutput[i]->randr_output; outputs[numOutputs++] = rrout; for (j = 0; jnumModes; j++) { @@ -252,16 +252,18 @@ RADEONRandRSetInfo12 (ScrnInfoPtr pScrn) int connection; int subpixel = SubPixelNone; RRCrtcPtr randr_crtc; - RADEONConnector *connector; + xf86OutputPtr connector; + RADEONOutputPrivatePtr pRPort; for (i = 0; i < RADEON_MAX_CONNECTOR; i++) { ncrtc = 0; crtc = NULL; - connector = pRADEONEnt->PortInfo[i]; + connector = pRADEONEnt->pOutput[i]; + pRPort = pRADEONEnt->PortInfo[i]; - if (connector->MonType) { - crtc = pRADEONEnt->Controller[i]->randr_crtc; + if (pRPort->MonType) { + crtc = pRADEONEnt->pCrtc[i]->randr_crtc; crtcs[ncrtc++] = crtc; randr_crtc = crtc; } else @@ -282,7 +284,7 @@ RADEONRandRSetInfo12 (ScrnInfoPtr pScrn) } connection = RR_Disconnected; - if (connector->MonType > MT_NONE) + if (pRPort->MonType > MT_NONE) connection = RR_Connected; RROutputSetConnection(connector->randr_output, connection); @@ -338,7 +340,7 @@ RADEONRandRCreateObjects12(ScrnInfoPtr pScrn) return FALSE; RRCrtcGammaSetSize(randr_crtc, 256); - pRADEONEnt->Controller[i]->randr_crtc = randr_crtc; + pRADEONEnt->pCrtc[i]->randr_crtc = randr_crtc; } for (i = 0; i < 2; i++) @@ -351,7 +353,7 @@ RADEONRandRCreateObjects12(ScrnInfoPtr pScrn) if (!randr_output) return FALSE; - pRADEONEnt->PortInfo[i]->randr_output = randr_output; + pRADEONEnt->pOutput[i]->randr_output = randr_output; } return TRUE; } @@ -369,12 +371,12 @@ RADEONRandRCreateScreenResources12 (ScreenPtr pScreen) for (i = 0; i < 2; i++) { - if (!RRCrtcAttachScreen(pRADEONEnt->Controller[i]->randr_crtc, pScreen)) + if (!RRCrtcAttachScreen(pRADEONEnt->pCrtc[i]->randr_crtc, pScreen)) return FALSE; } for (i = 0; i < 2; i++) { - if (!RROutputAttachScreen(pRADEONEnt->PortInfo[i]->randr_output, pScreen)) + if (!RROutputAttachScreen(pRADEONEnt->pOutput[i]->randr_output, pScreen)) return FALSE; } @@ -400,7 +402,7 @@ RADEONRandRCreateScreenResources12 (ScreenPtr pScreen) } for (i = 0; i < RADEON_MAX_CRTC; i++) - RADEONRandRCrtcNotify (pRADEONEnt->Controller[i]->randr_crtc); + RADEONRandRCrtcNotify (pRADEONEnt->pCrtc[i]->randr_crtc); if (randrp->virtualX == -1 || randrp->virtualY == -1) { @@ -770,9 +772,9 @@ RADEONRandRPreInit(ScrnInfoPtr pScrn) * the initial configuration */ for (o = 0; o < RADEON_MAX_CONNECTOR; o++) - outputs[o] = pRADEONEnt->PortInfo[o]->randr_output; + outputs[o] = pRADEONEnt->pOutput[o]->randr_output; for (c = 0; c < RADEON_MAX_CRTC; c++) - crtcs[c] = pRADEONEnt->Controller[c]->randr_crtc; + crtcs[c] = pRADEONEnt->pCrtc[c]->randr_crtc; if (!RADEONRRInitialConfiguration (outputs, output_crtcs, output_modes, RADEON_MAX_CONNECTOR)) diff --git a/src/radeon_xf86Crtc.c b/src/radeon_xf86Crtc.c new file mode 100644 index 0000000..41d6f86 --- /dev/null +++ b/src/radeon_xf86Crtc.c @@ -0,0 +1,140 @@ +/* + * $Id: $ + * + * Copyright © 2006 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include + +#include "xf86.h" +#include "radeon_xf86Crtc.h" + +/* + * Crtc functions + */ +xf86CrtcPtr +xf86CrtcCreate (ScrnInfoPtr scrn, + const xf86CrtcFuncsRec *funcs) +{ + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + xf86CrtcPtr crtc; + + crtc = xcalloc (sizeof (xf86CrtcRec), 1); + if (!crtc) + return NULL; + crtc->scrn = scrn; + crtc->funcs = funcs; +#ifdef RANDR_12_INTERFACE + crtc->randr_crtc = RRCrtcCreate (crtc); + if (!crtc->randr_crtc) + { + xfree (crtc); + return NULL; + } +#endif + xf86_config->crtc[xf86_config->num_crtc++] = crtc; + return crtc; +} + +void +xf86CrtcDestroy (xf86CrtcPtr crtc) +{ + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn); + int c; + + (*crtc->funcs->destroy) (crtc); +#ifdef RANDR_12_INTERFACE + RRCrtcDestroy (crtc->randr_crtc); +#endif + for (c = 0; c < xf86_config->num_crtc; c++) + if (xf86_config->crtc[c] == crtc) + { + memmove (&xf86_config->crtc[c], + &xf86_config->crtc[c+1], + xf86_config->num_crtc - (c + 1)); + xf86_config->num_crtc--; + break; + } + xfree (crtc); +} + +/* + * Output functions + */ +xf86OutputPtr +xf86OutputCreate (ScrnInfoPtr scrn, + const xf86OutputFuncsRec *funcs, + const char *name) +{ + xf86OutputPtr output; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + int len = strlen (name); + + output = xcalloc (sizeof (xf86OutputRec) + len + 1, 1); + if (!output) + return NULL; + output->scrn = scrn; + output->funcs = funcs; + output->name = (char *) (output + 1); + strcpy (output->name, name); +#ifdef RANDR_12_INTERFACE + output->randr_output = RROutputCreate (name, strlen (name), output); + if (!output->randr_output) + { + xfree (output); + return NULL; + } +#endif + xf86_config->output[xf86_config->num_output++] = output; + return output; +} + +void +xf86OutputDestroy (xf86OutputPtr output) +{ + ScrnInfoPtr scrn = output->scrn; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + int o; + + (*output->funcs->destroy) (output); +#ifdef RANDR_12_INTERFACE + RROutputDestroy (output->randr_output); +#endif + while (output->probed_modes) + xf86DeleteMode (&output->probed_modes, output->probed_modes); + for (o = 0; o < xf86_config->num_output; o++) + if (xf86_config->output[o] == output) + { + memmove (&xf86_config->output[o], + &xf86_config->output[o+1], + xf86_config->num_output - (o + 1)); + xf86_config->num_output--; + break; + } + xfree (output); +} + diff --git a/src/radeon_xf86Crtc.h b/src/radeon_xf86Crtc.h new file mode 100644 index 0000000..36311d0 --- /dev/null +++ b/src/radeon_xf86Crtc.h @@ -0,0 +1,316 @@ +/* + * Copyright © 2006 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ +#ifndef _XF86CRTC_H_ +#define _XF86CRTC_H_ + +#include +#include "randrstr.h" +//#include "xf86Modes.h" + +enum detect_status { + OUTPUT_STATUS_CONNECTED, + OUTPUT_STATUS_DISCONNECTED, + OUTPUT_STATUS_UNKNOWN +}; + +typedef struct _xf86Crtc xf86CrtcRec, *xf86CrtcPtr; + +typedef struct _xf86CrtcFuncs { + /** + * Turns the crtc on/off, or sets intermediate power levels if available. + * + * Unsupported intermediate modes drop to the lower power setting. If the + * mode is DPMSModeOff, the crtc must be disabled, as the DPLL may be + * disabled afterwards. + */ + void + (*dpms)(xf86CrtcPtr crtc, + int mode); + + /** + * Saves the crtc's state for restoration on VT switch. + */ + void + (*save)(xf86CrtcPtr crtc); + + /** + * Restore's the crtc's state at VT switch. + */ + void + (*restore)(xf86CrtcPtr crtc); + + /** + * Clean up driver-specific bits of the crtc + */ + void + (*destroy) (xf86CrtcPtr crtc); +} xf86CrtcFuncsRec, *xf86CrtcFuncsPtr; + +struct _xf86Crtc { + /** + * Associated ScrnInfo + */ + ScrnInfoPtr scrn; + + /** + * Active state of this CRTC + * + * Set when this CRTC is driving one or more outputs + */ + Bool enabled; + + /** + * Position on screen + * + * Locates this CRTC within the frame buffer + */ + int x, y; + + /** Track whether cursor is within CRTC range */ + Bool cursorInRange; + + /** Track state of cursor associated with this CRTC */ + Bool cursorShown; + + /** + * Active mode + * + * This reflects the mode as set in the CRTC currently + * It will be cleared when the VT is not active or + * during server startup + */ + DisplayModeRec curMode; + + /** + * Desired mode + * + * This is set to the requested mode, independent of + * whether the VT is active. In particular, it receives + * the startup configured mode and saves the active mode + * on VT switch. + */ + DisplayModeRec desiredMode; + + /** crtc-specific functions */ + const xf86CrtcFuncsRec *funcs; + + /** + * Driver private + * + * Holds driver-private information + */ + void *driver_private; + +#ifdef RANDR_12_INTERFACE + /** + * RandR crtc + * + * When RandR 1.2 is available, this + * points at the associated crtc object + */ + RRCrtcPtr randr_crtc; +#else + void *randr_crtc; +#endif +}; + +typedef struct _xf86Output xf86OutputRec, *xf86OutputPtr; + +typedef struct _xf86OutputFuncs { + /** + * Turns the output on/off, or sets intermediate power levels if available. + * + * Unsupported intermediate modes drop to the lower power setting. If the + * mode is DPMSModeOff, the output must be disabled, as the DPLL may be + * disabled afterwards. + */ + void + (*dpms)(xf86OutputPtr output, + int mode); + + /** + * Saves the output's state for restoration on VT switch. + */ + void + (*save)(xf86OutputPtr output); + + /** + * Restore's the output's state at VT switch. + */ + void + (*restore)(xf86OutputPtr output); + + /** + * Callback for testing a video mode for a given output. + * + * This function should only check for cases where a mode can't be supported + * on the pipe specifically, and not represent generic CRTC limitations. + * + * \return MODE_OK if the mode is valid, or another MODE_* otherwise. + */ + int + (*mode_valid)(xf86OutputPtr output, + DisplayModePtr pMode); + + /** + * Callback for setting up a video mode before any crtc/dpll changes. + * + * \param pMode the mode that will be set, or NULL if the mode to be set is + * unknown (such as the restore path of VT switching). + */ + void + (*pre_set_mode)(xf86OutputPtr output, + DisplayModePtr pMode); + + /** + * Callback for setting up a video mode after the DPLL update but before + * the plane is enabled. + */ + void + (*post_set_mode)(xf86OutputPtr output, + DisplayModePtr pMode); + + /** + * Probe for a connected output, and return detect_status. + */ + enum detect_status + (*detect)(xf86OutputPtr output); + + /** + * Query the device for the modes it provides. + * + * This function may also update MonInfo, mm_width, and mm_height. + * + * \return singly-linked list of modes or NULL if no modes found. + */ + DisplayModePtr + (*get_modes)(xf86OutputPtr output); + + /** + * Clean up driver-specific bits of the output + */ + void + (*destroy) (xf86OutputPtr output); +} xf86OutputFuncsRec, *xf86OutputFuncsPtr; + +struct _xf86Output { + /** + * Associated ScrnInfo + */ + ScrnInfoPtr scrn; + /** + * Currently connected crtc (if any) + * + * If this output is not in use, this field will be NULL. + */ + xf86CrtcPtr crtc; + /** + * List of available modes on this output. + * + * This should be the list from get_modes(), plus perhaps additional + * compatible modes added later. + */ + DisplayModePtr probed_modes; + + /** EDID monitor information */ + xf86MonPtr MonInfo; + + /** Physical size of the currently attached output device. */ + int mm_width, mm_height; + + /** Output name */ + char *name; + + /** output-specific functions */ + const xf86OutputFuncsRec *funcs; + + /** driver private information */ + void *driver_private; + +#ifdef RANDR_12_INTERFACE + /** + * RandR 1.2 output structure. + * + * When RandR 1.2 is available, this points at the associated + * RandR output structure and is created when this output is created + */ + RROutputPtr randr_output; +#else + void *randr_output; +#endif +}; + +#define XF86_MAX_CRTC 4 +#define XF86_MAX_OUTPUT 16 + +typedef struct _xf86CrtcConfig { + int num_output; + xf86OutputPtr output[XF86_MAX_OUTPUT]; + + int num_crtc; + xf86CrtcPtr crtc[XF86_MAX_CRTC]; +} xf86CrtcConfigRec, *xf86CrtcConfigPtr; + +#define XF86_CRTC_CONFIG_PTR(p) ((xf86CrtcConfigPtr) ((p)->driverPrivate)) + +/* + * Crtc functions + */ +xf86CrtcPtr +xf86CrtcCreate (ScrnInfoPtr scrn, + const xf86CrtcFuncsRec *funcs); + +void +xf86CrtcDestroy (xf86CrtcPtr crtc); + + +/** + * Allocate a crtc for the specified output + * + * Find a currently unused CRTC which is suitable for + * the specified output + */ + +xf86CrtcPtr +xf86AllocCrtc (xf86OutputPtr output); + +/** + * Free a crtc + * + * Mark the crtc as unused by any outputs + */ + +void +xf86FreeCrtc (xf86CrtcPtr crtc); + +/* + * Output functions + */ +xf86OutputPtr +xf86OutputCreate (ScrnInfoPtr scrn, + const xf86OutputFuncsRec *funcs, + const char *name); + +void +xf86OutputDestroy (xf86OutputPtr output); + +#endif /* _XF86CRTC_H_ */ -- cgit v1.2.3