diff --git a/src/i830_driver.c b/src/i830_driver.c index ab42fd9..46c210a 100644 --- a/src/i830_driver.c +++ b/src/i830_driver.c @@ -333,6 +333,7 @@ static void i830AdjustFrame(int scrnIndex, int x, int y, int flags); static Bool I830CloseScreen(int scrnIndex, ScreenPtr pScreen); static Bool I830EnterVT(int scrnIndex, int flags); static CARD32 I830CheckDevicesTimer(OsTimerPtr timer, CARD32 now, pointer arg); +static void I830DisplaySwitchHotkey(ScrnInfoPtr pScrn); static Bool SaveHWState(ScrnInfoPtr pScrn); static Bool RestoreHWState(ScrnInfoPtr pScrn); @@ -3198,7 +3199,7 @@ I830PMEvent(int scrnIndex, pmEvent event, Bool undo) ErrorF("I830PMEvent: Capability change\n"); - I830CheckDevicesTimer(NULL, 0, pScrn); + I830DisplaySwitchHotkey(pScrn); SaveScreens(SCREEN_SAVER_FORCER, ScreenSaverReset); break; default: @@ -3243,6 +3244,32 @@ i830MonitorDetectDebugger(ScrnInfoPtr pScrn) } #endif +/* Process a display hotkey event */ +static void +I830DisplaySwitchHotkey(ScrnInfoPtr pScrn) +{ + I830Ptr pI830 = I830PTR(pScrn); + CARD8 gr18 = pI830->readControl(pI830, GRX, 0x18); + + /* The user has pressed the hotkey requesting a toggle or switch. + * Re-probe our connected displays and turn on whatever we find. + * + * In the future, we want the hotkey to dump down to a user app which + * implements a sensible policy using RandR-1.2. For now, all we get + * is this. + */ + + xf86ProbeOutputModes (pScrn, 0, 0); + xf86SetScrnInfoModes (pScrn); + xf86DiDGAReInit (pScrn->pScreen); + xf86SwitchMode(pScrn->pScreen, pScrn->currentMode); + + /* Clear the BIOS's hotkey press flags in case they were set */ + gr18 &= ~(HOTKEY_TOGGLE | HOTKEY_SWITCH); + pI830->writeControl(pI830, GRX, 0x18, gr18); +} + +/* Periodically check for a display hotkey event */ static CARD32 I830CheckDevicesTimer(OsTimerPtr timer, CARD32 now, pointer arg) { @@ -3259,24 +3286,8 @@ I830CheckDevicesTimer(OsTimerPtr timer, CARD32 now, pointer arg) /* Check for a hotkey press report from the BIOS. */ gr18 = pI830->readControl(pI830, GRX, 0x18); - if ((gr18 & (HOTKEY_TOGGLE | HOTKEY_SWITCH)) != 0) { - /* The user has pressed the hotkey requesting a toggle or switch. - * Re-probe our connected displays and turn on whatever we find. - * - * In the future, we want the hotkey to dump down to a user app which - * implements a sensible policy using RandR-1.2. For now, all we get - * is this. - */ - - xf86ProbeOutputModes (pScrn, 0, 0); - xf86SetScrnInfoModes (pScrn); - xf86DiDGAReInit (pScrn->pScreen); - xf86SwitchMode(pScrn->pScreen, pScrn->currentMode); - - /* Clear the BIOS's hotkey press flags */ - gr18 &= ~(HOTKEY_TOGGLE | HOTKEY_SWITCH); - pI830->writeControl(pI830, GRX, 0x18, gr18); - } + if ((gr18 & (HOTKEY_TOGGLE | HOTKEY_SWITCH)) != 0) + I830DisplaySwitchHotkey(pScrn); return 1000; }