From 41444183b59ed84c09749ca89afbef036d42ec5f Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 12 Dec 2006 18:08:57 -0800 Subject: [PATCH] Replace custom, partially broken DPMS implementation with a generic one. --- src/i830_display.c | 6 +++++ src/i830_driver.c | 53 +-------------------------------------------- src/i830_xf86Crtc.c | 35 ++++++++++++++++++++++++++++++ src/i830_xf86Crtc.h | 3 +++ 4 files changed, 45 insertions(+), 52 deletions(-) diff --git a/src/i830_display.c b/src/i830_display.c index f0aac15c..8da51313 100644 --- a/src/i830_display.c +++ b/src/i830_display.c @@ -478,6 +478,12 @@ i830PipeInUse (xf86CrtcPtr crtc) return FALSE; } +/** + * Sets the power management mode of the pipe and plane. + * + * This code should probably grow support for turning the cursor off and back + * on appropriately at the same time as we're turning the pipe off/on. + */ static void i830_crtc_dpms(xf86CrtcPtr crtc, int mode) { diff --git a/src/i830_driver.c b/src/i830_driver.c index d8a9c9bc..7ec5559f 100644 --- a/src/i830_driver.c +++ b/src/i830_driver.c @@ -314,8 +314,6 @@ const char *i830_output_type_names[] = { "TVOUT", }; -static void I830DisplayPowerManagementSet(ScrnInfoPtr pScrn, - int PowerManagementMode, int flags); static void i830AdjustFrame(int scrnIndex, int x, int y, int flags); static Bool I830CloseScreen(int scrnIndex, ScreenPtr pScreen); static Bool I830SaveScreen(ScreenPtr pScreen, int unblack); @@ -2863,7 +2861,7 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) return FALSE; } - xf86DPMSInit(pScreen, I830DisplayPowerManagementSet, 0); + xf86DPMSInit(pScreen, xf86DPMSSet, 0); #ifdef I830_XV /* Init video */ @@ -3319,55 +3317,6 @@ I830SaveScreen(ScreenPtr pScreen, int mode) return TRUE; } -/* Use the VBE version when available. */ -static void -I830DisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode, - int flags) -{ - I830Ptr pI830 = I830PTR(pScrn); - int i; - CARD32 temp, ctrl, base; - - for (i = 0; i < pI830->xf86_config.num_output; i++) { - xf86OutputPtr output = pI830->xf86_config.output[i]; - - (*output->funcs->dpms) (output, PowerManagementMode); - } - - for (i = 0; i < pI830->xf86_config.num_crtc; i++) - { - xf86CrtcPtr crtc = pI830->xf86_config.crtc[i]; - - if (i == 0) { - ctrl = DSPACNTR; - base = DSPABASE; - } else { - ctrl = DSPBCNTR; - base = DSPBADDR; - } - /* XXX pipe disable too? */ - if (crtc->enabled) { - temp = INREG(ctrl); - if (PowerManagementMode == DPMSModeOn) - temp |= DISPLAY_PLANE_ENABLE; - else - temp &= ~DISPLAY_PLANE_ENABLE; - OUTREG(ctrl, temp); - /* Flush changes */ - temp = INREG(base); - OUTREG(base, temp); - } - } - - if (pI830->CursorInfoRec && !pI830->SWCursor && pI830->cursorOn) { - if (PowerManagementMode == DPMSModeOn) - pI830->CursorInfoRec->ShowCursor(pScrn); - else - pI830->CursorInfoRec->HideCursor(pScrn); - pI830->cursorOn = TRUE; - } -} - static Bool I830CloseScreen(int scrnIndex, ScreenPtr pScreen) { diff --git a/src/i830_xf86Crtc.c b/src/i830_xf86Crtc.c index 448d4f94..a222382d 100644 --- a/src/i830_xf86Crtc.c +++ b/src/i830_xf86Crtc.c @@ -590,3 +590,38 @@ xf86InitialConfiguration (ScrnInfoPtr pScrn) xfree (modes); return TRUE; } + +/** + * Set the DPMS power mode of all outputs and CRTCs. + * + * If the new mode is off, it will turn off outputs and then CRTCs. + * Otherwise, it will affect CRTCs before outputs. + */ +void +xf86DPMSSet(ScrnInfoPtr pScrn, int mode, int flags) +{ + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); + int i; + + if (mode == DPMSModeOff) { + for (i = 0; i < config->num_output; i++) { + xf86OutputPtr output = config->output[i]; + if (output->crtc != NULL) + (*output->funcs->dpms) (output, mode); + } + } + + for (i = 0; i < config->num_crtc; i++) { + xf86CrtcPtr crtc = config->crtc[i]; + if (crtc->enabled) + (*crtc->funcs->dpms) (crtc, mode); + } + + if (mode != DPMSModeOff) { + for (i = 0; i < config->num_output; i++) { + xf86OutputPtr output = config->output[i]; + if (output->crtc != NULL) + (*output->funcs->dpms) (output, mode); + } + } +} diff --git a/src/i830_xf86Crtc.h b/src/i830_xf86Crtc.h index 21fc244e..042cb2f0 100644 --- a/src/i830_xf86Crtc.h +++ b/src/i830_xf86Crtc.h @@ -378,4 +378,7 @@ xf86SetScrnInfoModes (ScrnInfoPtr pScrn); Bool xf86InitialConfiguration (ScrnInfoPtr pScrn); +void +xf86DPMSSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags); + #endif /* _XF86CRTC_H_ */