Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn off Backlight on Shutdown #103

Closed
iglesiasmarianod opened this issue Aug 8, 2020 · 12 comments · Fixed by #105
Closed

Turn off Backlight on Shutdown #103

iglesiasmarianod opened this issue Aug 8, 2020 · 12 comments · Fixed by #105
Labels
bug Something isn't working
Milestone

Comments

@iglesiasmarianod
Copy link
Contributor

iglesiasmarianod commented Aug 8, 2020

Hi guys, Is there a way to turn off the backlight before the cubieboard shuts down?
My image shows a strange fading screen on shutdown. If the backlight was off it would not show.
It is something similar to what happened at satrtup before @kedder fixed the logo sequence.

Thanks!

@kedder
Copy link
Member

kedder commented Aug 8, 2020

It used to work on kernel 5.2 (backlight turned off on shutdown), but after upgrading to 5.7 it is no longer happening (in fact, it backlight turns of sometimes, but not always)

@iglesiasmarianod
Copy link
Contributor Author

Thanks again @kedder!
Do you think adding these lines to the .dts file might help?

	backlight: lcd {
		compatible = "pwm-backlight";
		pinctrl-names = "default";
		pwms = <&pwm 0 5000000 0>;
		brightness-levels = <0 8 16 32 64 128 255 384 512 768 1024>;
		default-brightness-level = <10>;
		post-pwm-on-delay-ms = <10>;
		pwm-off-delay-ms = <10>;
	};

@kedder
Copy link
Member

kedder commented Aug 10, 2020

Hm, I believe backlight: lcd is already on the .dts, except post-pwm-on-delay-ms and pwm-off-delay-ms. TBH, I have no idea whether they might help or not. Do you want me to try? Did you try?

@iglesiasmarianod
Copy link
Contributor Author

iglesiasmarianod commented Aug 10, 2020

Just asked perhaps you knew before trying.
I added both lines

post-pwm-on-delay-ms = <10>;
pwm-off-delay-ms = <10>;

I'm building the image. No errors so far.
I'll let you know if it works when I load it to the OpenVario.

@iglesiasmarianod
Copy link
Contributor Author

It did not help.
I'll keep looking in case I find something useful.

@kedder
Copy link
Member

kedder commented Aug 26, 2020

I've discovered something funny in relation to this issue:

The backlight power can be controlled by writing 0 or 4 to /sys/devices/platform/lcd/backlight/lcd/bl_power file. 0 means "power on", 4 means "power off" (according to https://www.kernel.org/doc/Documentation/ABI/stable/sysfs-class-backlight).

So, if you do echo 4 > /sys/devices/platform/lcd/backlight/lcd/bl_power the screen is supposed to go dark, and with echo 0 > ... screen should go back bright.

However, this is not what happens on my openvario. The backlight turns off only sometimes. And the probability of it turning off seems to correlate with screen brightness itself: the higher the brightness, the less often screen goes dark when I write 4 to bl_power. When I set the screen to full brightness, it never goes dar. On 50% of the brightness it goes dark about half of the times. Interestingly, when screen does not go dark, it goes to full brightness.

I assume, when system shuts down, it effectively does the same as writing 4 to bl_power, so screen does not turn dark.

This all feels like a bug, just not clear where exactly.

@kedder
Copy link
Member

kedder commented Aug 26, 2020

It feels like the line, controlled by pwm stays in whatever state it was the moment backlight was turned down - either full 1 or 0. Even though the pwm backlight driver explicitly asks to set the duty cycle to 0:

https://github.com/torvalds/linux/blob/master/drivers/video/backlight/pwm_bl.c#L81-L83

It might be that pwm-sun4i module does not execute that instruction very precisely. Sigh, where can I even discuss that? :(

@iglesiasmarianod
Copy link
Contributor Author

iglesiasmarianod commented Aug 26, 2020 via email

@kedder
Copy link
Member

kedder commented Aug 26, 2020

I'm not a huge fan of that, because one day the screen will simply not turn on (for whatever reason). I'd rather live with the screen that does not turn off on shutdown. But I still think this can be fixed or worked around somehow.

@iglesiasmarianod
Copy link
Contributor Author

iglesiasmarianod commented Aug 26, 2020 via email

@kedder
Copy link
Member

kedder commented Aug 27, 2020

Submitted the bug report to linux devs: https://www.spinics.net/lists/linux-pwm/msg13689.html

@kedder
Copy link
Member

kedder commented Sep 2, 2020

It looks like we have a fix for this: http://lists.infradead.org/pipermail/linux-arm-kernel/2020-September/597482.html, going to submit a PR soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants