From 6aa09171f55bdc2f10b20d3565af26b068579737 Mon Sep 17 00:00:00 2001 From: Kevin Brace Date: Thu, 3 Dec 2015 23:13:51 -0800 Subject: [PATCH 10/10] Added a new function called VIASetDFPBackLight to via_lvds.c. This function turns the DFP (Digital Flat Panel) back light on or off. Previously, DFP back light was not being turned off when the computer turns the screen off, leading to unnecessary consumption of power. This improvement is especially helpful in a mobile environment where conserving power is key to extending battery life. The compiled device driver was tested on the following computer. - Epic 1314 laptop (MSI VR321 laptop equivalent, VN896 chipset) with Lubuntu 12.04 i386 --- src/via_lvds.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/via_lvds.c b/src/via_lvds.c index ed5bd79..fbb2299 100644 --- a/src/via_lvds.c +++ b/src/via_lvds.c @@ -386,12 +386,35 @@ ViaLCDPower(xf86OutputPtr output, Bool On) usleep(1); } -static void -via_lvds_dpms(xf86OutputPtr output, int mode) +static void VIASetDFPBackLight(ScrnInfoPtr pScrn, Bool on) +{ + + vgaHWPtr hwp = VGAHWPTR(pScrn); + + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Entered VIASetDFPBackLight.\n")); + + if (on) { + +/* Turn on LVDS-based DFP back light. */ + ViaCrtcMask(hwp, 0xd3, 0x00, 0x40); + + } else { + +/* Turn off LVDS-based DFP back light. */ + ViaCrtcMask(hwp, 0xd3, 0x40, 0x40); + + } + + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Exiting VIASetDFPBackLight.\n")); +} + +static void via_lvds_dpms(xf86OutputPtr output, int mode) { ScrnInfoPtr pScrn = output->scrn; VIAPtr pVia = VIAPTR(pScrn); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Entered via_lvds_dpms.\n")); + if (pVia->pVbe) { ViaVbePanelPower(pVia->pVbe, (mode == DPMSModeOn)); } else { @@ -404,6 +427,7 @@ via_lvds_dpms(xf86OutputPtr output, int mode) case VIA_VX855: case VIA_VX900: ViaLVDSPower(pScrn, TRUE); + VIASetDFPBackLight(pScrn, TRUE); break; } ViaLCDPower(output, TRUE); @@ -419,12 +443,15 @@ via_lvds_dpms(xf86OutputPtr output, int mode) case VIA_VX855: case VIA_VX900: ViaLVDSPower(pScrn, FALSE); + VIASetDFPBackLight(pScrn, FALSE); break; } ViaLCDPower(output, FALSE); break; } } + + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Exiting via_lvds_dpm.\n")); } static void -- 1.7.9.5