RehabMan / OS-X-ACPI-Backlight

Updated ACPIBacklight.kext for OS X. Uses ACPI methods to control laptop backlight.
Other
49 stars 12 forks source link

ACPIBacklight on Yosemite DP2 #7

Closed tluck closed 9 years ago

tluck commented 10 years ago

i installed yosemite DP2 and i found a slight challenge upon startup or resume from sleep with brightness. ACPIBacklight does not seem to resume with same brightness after sleep. RawBrightness before sleep 1808 (max). after sleep it is 153. same thing after boot up - RawBrightness is 153 vs nvram value - which gets updated properly. nvram -p shows the right/current value. when i look at the debug output something is telling ACPI to set level 255 (it reads NVRAM and tries to set to that value) but then after a while its gets do doInteger set to 255 - which ends up RawBrigtness 153 (max is 1808).

Note: i only have mods to PNLF in DSDT for ACPI - do i need anything in _WAK? ACPIBacklight on 10.9.3 works fine on boot up or sleep/wake - meaning it seems to resume or boot with last value (which i figure it pickups up after clover reloads nvram.plist )

RehabMan commented 10 years ago

I will not look at yosemite problems until it is released. Be aware also that Clover is broken on yosemite with regard to nvram saving at shutdown.

RehabMan commented 10 years ago

You could try this patch. I still don't understand what is going on and will probably wait until final...

Admins-MacBook-Air:backlight.git Admin$ git diff
diff --git a/ACPIBacklight/ACPIBacklight.cpp b/ACPIBacklight/ACPIBacklight.cpp
index c31e3f4..62bf60b 100644
--- a/ACPIBacklight/ACPIBacklight.cpp
+++ b/ACPIBacklight/ACPIBacklight.cpp
@@ -327,6 +327,7 @@ bool ACPIBacklightPanel::doIntegerSet( OSDictionary * params, const OSSy
     if ( gIODisplayBrightnessKey->isEqualTo(paramName))
     {   
         //DbgLog("%s::%s(%s) map %d -> %d\n", this->getName(),__FUNCTION__, paramName->getC
+        if (value == 0xFF) return false; //REVIEW: workaround for Yosemite DP...
         setBrightnessLevelSmooth(value);
         return true;
     }
tluck commented 10 years ago

this fix worked on yosemite DP5. thanks.

tluck commented 10 years ago

well it worked except after display went to sleep. -- add a var to hold the last real value (lastv)

it gets a brightness sequence like:

real value like 1024 or 512 then a bogus 255 (so ignore this one and set to last) onset of sleep sets to 1 sleep sets to 0 resume from sleep - another 255 ( so again ignore and set with lastv) set to lastv

snippet added to above

if ( gIODisplayBrightnessKey->isEqualTo(paramName))
{   
    DbgLog("%s::%s(\"%s\", v=%d, lastv=%d)\n", this->getName(), __FUNCTION__, paramName->getCStringNoCopy(), value, lastv);
    if (value>1 && value!=255)  lastv=value;
    if ( value==255 ) value=lastv;
        //return false; REVIEW: workaround for Yosemite DP...
    setBrightnessLevelSmooth(value);
    return true;
}
chumdoggin commented 10 years ago

tLuck, are you allowed to post a copy of the edited kext here? As I'm not sure how to add these patches to it. Was adding all kexts by clover but s/l/e did not work either. Neither did kext dev mode. Besides that pretty good functioning for a beta! these guys are getting good.

tluck commented 10 years ago

i don't know! i did recompile it posted this kext as part of a zip bundle for the Lenovo T420 -

http://www.insanelymac.com/forum/topic/285678-lenovo-thinkpad-t420-with-uefi-only/page-25#entry1952283

chumdoggin commented 10 years ago

Thank you, works fine now. Nvram is all I see that doesn't work in XX for now.

RehabMan commented 10 years ago

Nvram is working in latest...

RehabMan commented 10 years ago

I currently have this change:

Admins-MacBook-Pro:backlight.git Admin$ git diff
diff --git a/ACPIBacklight/ACPIBacklight.cpp b/ACPIBacklight/ACPIBacklight.cpp
index c31e3f4..ac7d52a 100644
--- a/ACPIBacklight/ACPIBacklight.cpp
+++ b/ACPIBacklight/ACPIBacklight.cpp
@@ -327,6 +327,13 @@ bool ACPIBacklightPanel::doIntegerSet( OSDictionary * params, const OSS
     if ( gIODisplayBrightnessKey->isEqualTo(paramName))
     {   
         //DbgLog("%s::%s(%s) map %d -> %d\n", this->getName(),__FUNCTION__, paramName->getC
+        //REVIEW: workaround for Yosemite DP...
+        if (value == 0xFF)
+        {
+            setBrightnessLevelSmooth(_committed_value);
+            return false;
+        }
+        //REVIEW: end workaround...
         setBrightnessLevelSmooth(value);
         return true;
     }

Not working all the time as sometimes the commit doesn't arrive until later. More investigation on the true meaning of this 255 is necessary...

tluck commented 10 years ago

i can see the logic in this method. _committed_value should be the same as lastv (in my brutish method) but merit of my approach apparently was not being dependent on timing. i don't know where this 255 is coming from either? i don't fully understand the meaning and purpose of the panel parameters from AppleBacklight.kext for different panels vs default.

RehabMan commented 10 years ago

I think we'll wait until things stabilize to see if this 255 hack stays in the code. It is new and weird. Somebody in Cupertino might have //REVIEW or //HACK comment for it...

The purpose of the non-Default panel params in AppleBacklight.kext is because different panels cold/would have different response curves. The Info.plist configuration allows the kext to adjust for individual panel characteristics regarding backlight response.

tluck commented 9 years ago

This version works for me on Yosemite 10.10 final. close it as far as i am concerned. thanks.