summaryrefslogtreecommitdiff
path: root/src/radeon_pm.c
diff options
context:
space:
mode:
authorAlex Deucher <alexdeucher@gmail.com>2009-04-01 16:22:02 -0400
committerAlex Deucher <alexdeucher@gmail.com>2009-04-15 11:45:52 -0400
commit63cb57c5eb0d6bc083f54eb100cb972b0e7bca69 (patch)
treecccada8790b2cd91d4b2ab52c6450fad400d3a51 /src/radeon_pm.c
parenta34a8b37afbea6ed4bf8ca42364195e174250c48 (diff)
Add DynamicPM Option
Dyanmically switch between power states. Switch to a low power state when the system is idle (DPMS off).
Diffstat (limited to 'src/radeon_pm.c')
-rw-r--r--src/radeon_pm.c68
1 files changed, 63 insertions, 5 deletions
diff --git a/src/radeon_pm.c b/src/radeon_pm.c
index ac6b972b..41b797a8 100644
--- a/src/radeon_pm.c
+++ b/src/radeon_pm.c
@@ -575,6 +575,68 @@ RADEONSetClockGating(ScrnInfoPtr pScrn, Bool enable)
enable ? "En" : "Dis");
}
+void RADEONDynamicLowPowerMode(ScrnInfoPtr pScrn, Bool enable)
+{
+ RADEONInfoPtr info = RADEONPTR(pScrn);
+ int sclk = (int)info->sclk * 100; /* 10 khz */
+
+ if (enable && info->low_power_active)
+ return;
+
+ if (!enable && !info->low_power_active)
+ return;
+
+ RADEONWaitForIdleMMIO(pScrn);
+
+ if (enable) {
+ if (info->IsAtomBios)
+ atombios_set_engine_clock(pScrn, sclk/4);
+ else
+ RADEONSetEngineClock(pScrn, sclk/4);
+
+ if (info->cardType == CARD_PCIE)
+ RADEONSetPCIELanes(pScrn, 1);
+
+ info->low_power_active = TRUE;
+ } else {
+ if (info->IsAtomBios)
+ atombios_set_engine_clock(pScrn, sclk);
+ else
+ RADEONSetEngineClock(pScrn, sclk);
+
+ if (info->cardType == CARD_PCIE)
+ RADEONSetPCIELanes(pScrn, 16);
+
+ info->low_power_active = FALSE;
+ }
+
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Low Power Mode %sabled\n",
+ enable ? "En" : "Dis");
+}
+
+void RADEONPMBlockHandler(ScrnInfoPtr pScrn)
+{
+ RADEONInfoPtr info = RADEONPTR(pScrn);
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
+ int i;
+
+ for (i = 0; i < xf86_config->num_crtc; i++) {
+ xf86CrtcPtr crtc = xf86_config->crtc[i];
+ RADEONCrtcPrivatePtr radeon_crtc = crtc->driver_private;
+
+ if (radeon_crtc->enabled)
+ break;
+ }
+
+ if (i == xf86_config->num_crtc) {
+ if (!info->low_power_active)
+ RADEONDynamicLowPowerMode(pScrn, TRUE);
+ } else {
+ if (info->low_power_active)
+ RADEONDynamicLowPowerMode(pScrn, FALSE);
+ }
+}
+
void RADEONStaticLowPowerMode(ScrnInfoPtr pScrn, Bool enable)
{
RADEONInfoPtr info = RADEONPTR(pScrn);
@@ -590,8 +652,6 @@ void RADEONStaticLowPowerMode(ScrnInfoPtr pScrn, Bool enable)
if (info->cardType == CARD_PCIE)
RADEONSetPCIELanes(pScrn, 2);
-
- info->low_power_mode = TRUE;
} else {
if (info->IsAtomBios)
atombios_set_engine_clock(pScrn, sclk);
@@ -600,10 +660,8 @@ void RADEONStaticLowPowerMode(ScrnInfoPtr pScrn, Bool enable)
if (info->cardType == CARD_PCIE)
RADEONSetPCIELanes(pScrn, 16);
-
- info->low_power_mode = FALSE;
}
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Low Power Mode %sabled\n",
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Static Low Power Mode %sabled\n",
enable ? "En" : "Dis");
}