I used to have some problems with the brightness controls, but found a simple enough way to overcome them (at least in KDE).
The main problem lay in the system using the wrong interface to adjust the backlight brightness. Additionally, when using the NVidia proprietary drivers, apple-gmux.c (quite properly) unregisters all backlight interfaces other than the gmux interface, except that the system does not appropriately re-adjusts the interface it uses.
Keeping apple-gmux.c from un-registering the acpi_videoX interfaces can be done by simply commenting out the according instructions. The patch below should apply cleanly to 3.5.x and 3.6.x kernels. (Otherwise just do it by hand.)
Code:
--- a/drivers/platform/x86/apple-gmux.c 2012-09-30 19:47:46.000000000 -0400
+++ b/drivers/platform/x86/apple-gmux.c 2012-10-11 09:02:32.100752458 -0400
@@ -511,8 +511,8 @@
* Disable the other backlight choices.
*/
acpi_video_dmi_promote_vendor();
- acpi_video_unregister();
- apple_bl_unregister();
+ //acpi_video_unregister();
+ //apple_bl_unregister();
gmux_data->power_state = VGA_SWITCHEROO_ON;
Once recompiled and running, /sys/class/backlight will contain the two additional interfaces apci_video0 and acpi_video1. On the other hand, if your using the i915, then the system uses the intel_backlight interface.
Either way, synchronizing changes from the DE used interface to the gmux one, can now be done using inotify via a simple script, which works equally well, regardless of which drivers your using.
Code:
#!/bin/bash
#
# references: 2012/10/11, KDE 4.8.5, Kernel 3.6.0, NVidia drivers 304.51
# requires: inotify-tools
# patched apple-gmux.c for use with NVidia drivers
#
# On a MacbookPro 10,1 KDE has trouble adjusting the screen backlight,
# automatically (timed dimming/power-state changes) as well as manually.
#
# This results from a bug in KDE Powermanagement Tools,
# (https://bugs.kde.org/show_bug.cgi?id=296403) which apparently
# do not properly update which backlight interface to use.
#
# This script synchronises backlight adjustments/changes to
# /sys/class/backlight/gmux_backlight.
#
# NB: If i915 is used, no alterations are necessary.
# If the proprietary NVidia drivers are to be used, apple-gmux.c needs
# to be patched to stop it from disabling the acpi_videoX interfaces.
#
# KDE adjusts either via intel_backlight or acpi_videoX,
# depending on which GPU and which driver is used
if [ -f /sys/class/backlight/intel_backlight/max_brightness ]; then
# for i915 use intel_backlight
ACPI_DIR=/sys/class/backlight/intel_backlight
fi
if [ -f /sys/class/backlight/acpi_video1/max_brightness ]; then
# if NVidia drivers are used, and apple-gmux.c has been patched, use
# acpi_video0 or acpi_video1 ... whichever works
ACPI_DIR=/sys/class/backlight/acpi_video1
fi
# gmux uses a different range of backlight adjustment, so we scale ...
ACPI_MAX_BRIGHTNESS=`cat ${ACPI_DIR}/max_brightness`
GMUX_MAX_BRIGHTNESS=`cat /sys/class/backlight/gmux_backlight/max_brightness`
MULTIPLIER=$(echo "scale=5;${GMUX_MAX_BRIGHTNESS}/(${ACPI_MAX_BRIGHTNESS}+1)"|bc)
# trigger minimum/maximum screen illumination if we're close enough,
# i.e. no 2% or 99% brightness ... it's just cleaner this way
MIN_BACKLIGHT_FACTOR=.05
FULL_BACKLIGHT_FACTOR=.95
GMUX_TRIGGER_MIN=$(echo "(${MIN_BACKLIGHT_FACTOR}*${GMUX_MAX_BRIGHTNESS})/1"|bc)
ACPI_TRIGGER_FULL=$(echo "(${FULL_BACKLIGHT_FACTOR}*${ACPI_MAX_BRIGHTNESS})/1"|bc)
# now sync all changes to gmux in scale
# with cut-offs specified by min/full triggers
while inotifywait -e modify ${ACPI_DIR}/brightness >/dev/null 2>&1; do
ACPI_BRIGHTNESS=`cat ${ACPI_DIR}/brightness`
GMUX_BRIGHTNESS=$(echo "(${MULTIPLIER}*${ACPI_BRIGHTNESS})/1"|bc)
if [ ${ACPI_BRIGHTNESS} -ge ${ACPI_TRIGGER_FULL} ]; then
GMUX_BRIGHTNESS=$GMUX_MAX_BRIGHTNESS
fi
if [ ${GMUX_BRIGHTNESS} -le ${GMUX_TRIGGER_MIN} ]; then
GMUX_BRIGHTNESS=0
fi
echo ${GMUX_BRIGHTNESS} > /sys/class/backlight/gmux_backlight/brightness
done
Just start the script from /etc/rc.local, and backlight adjustment should work just fine, with one exception. On my system (12.04) the brightness will not adjust under NVidia drivers after a boot, but works just peachy after a suspend.
Bookmarks