Colibri iMX6 Backlight (Linux)

I want to configure the PWM_A (backlight) with custom values:

f=10Khz

brightness-levels = 0 4 8 16 32 64 128 255;

default-brightness-level = 64;

max-brightness = 255;

Therefore I change the backlight on device-tree section:

&backlight {
	pwms = <&pwm3 0 100000>;
	brightness-levels = <0 4 8 16 32 64 128 255>;
	default-brightness-level = <8>;
	max-brightness = <255>;
	status = "okay";
};

After update I found these values on backlight Linux parameters:

root@colibri-imx6:~# cat /sys/class/backlight/backlight.15/brightness
4
root@colibri-imx6:~# cat /sys/class/backlight/backlight.15/max_brightness
7

PWM_A frequency is 10Khz, measured with osciloscope.

Why read values are different from programmed on device-tree?.

Something is wrong in my device tree?.

Hi

I don’t think that max-brightness is a device tree property for the PWM backlight driver. Compare with the driver’s binding description.

I guess you missed that brightness-levels is a list of duty-cycles used for the PWM. To set one of these duty cycles you use the zero based index into this list.

So, assuming you want the duty cycle to be 8/255 by default you want the third element in the list, i.e. a zero base index of 2 resulting in a device tree node of:

&backlight {
	pwms = <&pwm3 0 100000>;
	brightness-levels = <0 4 8 16 32 64 128 255>;
	default-brightness-level = <2>;
	status = "okay";
};

Note that /sys/class/backlight/backlight.15/max_brightness is the highest index you can write into the brightness file, i.e. the number of levels in brightness-levels minus 1.
Note that the default-brightness-level is set to the maximum allowed if you specify something bigger in the device tree.

If Linux is regularly shut down systemd preserves the the last active brightness level across boots. So I guess you did do a shutdown with before using a new device tree and thus you see a brightness level of ‘4’ after boot.

Max

Now yes, brightness is an index.
Than you max.tx for your good clarification.