From 5fa65b9924fbff1e88c6ec229e8deeb687cc9a7d Mon Sep 17 00:00:00 2001 From: Tilman Sauerbeck Date: Wed, 8 Aug 2007 13:35:06 +0200 Subject: Power off the panel(s) when there's no users. --- src/mga_g_output.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/mga_g_output.c b/src/mga_g_output.c index ff8a7e6..a5cf7e0 100644 --- a/src/mga_g_output.c +++ b/src/mga_g_output.c @@ -122,6 +122,8 @@ static const xf86OutputFuncsRec output_panel2_funcs = { .destroy = output_destroy }; +static int panel_users = 0; + static void output_dac1_dpms(xf86OutputPtr output, int mode) { @@ -230,11 +232,15 @@ output_panel1_dpms(xf86OutputPtr output, int mode) pwr_ctl = inMGAdac(MGA1064_PWR_CTL); mask = MGA1064_PWR_CTL_PANEL_EN; - /* we could drop MGA1064_PWR_CTL_PANEL_EN here, - * but since that affects _both_ panels, it's somewhat useless. - */ - if (mode == DPMSModeOn) + if (mode == DPMSModeOn) { + panel_users |= 1; outMGAdac(MGA1064_PWR_CTL, pwr_ctl | mask); + } else { + panel_users &= ~1; + + if (!panel_users) + outMGAdac(MGA1064_PWR_CTL, pwr_ctl & ~mask); + } } static void @@ -247,13 +253,16 @@ output_panel2_dpms(xf86OutputPtr output, int mode) mask = MGA1064_PWR_CTL_PANEL_EN; if (mode == DPMSModeOn) { + panel_users |= 2; + outMGAdac(MGA1064_PWR_CTL, pwr_ctl | mask); outMGAdac(MGA1064_DVI_PIPE_CTL, 0x20); } else { - /* see above - * - * outMGAdac(MGA1064_PWR_CTL, pwr_ctl & ~mask); - */ + panel_users &= ~2; + + if (!panel_users) + outMGAdac(MGA1064_PWR_CTL, pwr_ctl & ~mask); + outMGAdac(MGA1064_DVI_PIPE_CTL, 0x0); } } -- cgit v1.2.3