Ever since I got Linux 3.15 booting on the Chromebook, the one thing that has bothered me the most was that the backlight brightness was always at 100%. This caused eye strain, especially at night.
Little did I know that a working /sys/class/backlight/ entry was two simple kernel patches away…
In menuconfig:
[*] Backlight & LCD device support --->
<*> Lowlevel LCD controls
<*> Platform LCD controls
<*> Lowlevel Backlight controls
<*> Generic PWM based Backlight Driver
<*> Generic GPIO based Backlight Driver
Next, apply a combination of a subset of the following patches:
ARM: dts: enable pwm backlight for exynos5250-snow (62ffa706d89925427096f419b70d0416aca255c8)
ARM: dts: Add pwmX_out pinctrl nodes to exynos5250 (235a1976d868d3e992223e4a7475ac7fa01e35a6)
Here is the full patch (11-chromebook-backlight.patch on GitHub):
diff --git arch/arm/boot/dts/exynos5250-pinctrl.dtsi arch/arm/boot/dts/exynos5250-pinctrl.dtsi
index 9a49e68..b0b46cd 100644
--- arch/arm/boot/dts/exynos5250-pinctrl.dtsi
+++ arch/arm/boot/dts/exynos5250-pinctrl.dtsi
@@ -351,6 +351,13 @@
samsung,pin-drv = <0>;
};
+ pwm0_out: pwm0-out {
+ samsung,pins = "gpb2-0";
+ samsung,pin-function = <2>;
+ samsung,pin-pud = <0>;
+ samsung,pin-drv = <0>;
+ };
+
i2c7_bus: i2c7-bus {
samsung,pins = "gpb2-2", "gpb2-3";
samsung,pin-function = <3>;
diff --git arch/arm/boot/dts/exynos5250-snow.dts arch/arm/boot/dts/exynos5250-snow.dts
index 87e37f4..d9a550e 100644
--- arch/arm/boot/dts/exynos5250-snow.dts
+++ arch/arm/boot/dts/exynos5250-snow.dts
@@ -215,4 +215,13 @@
clock-frequency = <24000000>;
};
};
+
+ backlight {
+ compatible = "pwm-backlight";
+ pwms = <&pwm 0 1000000 0>;
+ brightness-levels = <0 100 500 1000 1500 2000 2500 2800>;
+ default-brightness-level = <7>;
+ pinctrl-0 = <&pwm0_out>;
+ pinctrl-names = "default";
+ };
};
And that’s it :) Recompile, reboot, and you should see something similar to:
$ ls /sys/class/backlight/backlight.8
actual_brightness brightness max_brightness subsystem uevent
bl_power device power type
Change brightness by echoing a value from 0 to 7 into /sys/class/backlight/backlight.8/brightness.