Scren brightness follow a quatratic progression
Needs RevisionPublic

Authored by thsurrel on May 24 2018, 12:16 PM.

Details

Reviewers
broulik
ngraham
Group Reviewers
Plasma
Summary

Modern hardware allow to adjust the screen brightness very precisely,
with more than hundreds or thousands different possible levels. When
modifying the screen brightness through the keyboard shortcuts, we
are not making the best use of this very fine grain possibility,
notably when in low light conditions. As of today, the progression
is linear, so for a maximum brightness level of 1000 we are making
20 steps of 50. This is not great since jumping from 0 to 50 can be
already too bright when using a laptop in the dark. And when in full
light, going from 950 to 1000 is barely noticeable.

This patch tries to improve the situation by switching from a
linear to a quadratic progression, offering smaller steps in the
low level brightness.

The switch to the quadratic progression is done in
powerdevilbrightnesslogic.cpp, the other modifications ensure that
the OSD still displays equal steps when giving a visual feedback,
otherwise the lower steps are barely distinguishible.

BUG: 362830

Diff Detail

Repository
R122 Powerdevil
Lint
Lint Skipped
Unit
Unit Tests Skipped
thsurrel created this revision.May 24 2018, 12:16 PM
Restricted Application added a project: Plasma. · View Herald TranscriptMay 24 2018, 12:16 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
thsurrel requested review of this revision.May 24 2018, 12:16 PM

Pls add context and reviewer Plasma.

thsurrel updated this revision to Diff 34825.May 24 2018, 3:14 PM
thsurrel added a reviewer: Plasma.

Added context

ngraham requested changes to this revision.May 28 2018, 9:29 PM
ngraham added a subscriber: ngraham.

I gave this a whirl. In general it seems nicer, but on my hardware there's a regression: from the lowest brightness setting, it now takes two presses of the increase brightness key to make the backlight turn on. That doesn't seem like it's something we want.

This revision now requires changes to proceed.May 28 2018, 9:29 PM
zzag added a subscriber: zzag.May 28 2018, 9:48 PM
zzag added inline comments.
daemon/powerdevilbrightnesslogic.cpp
135

Coding style nitpick: don't use "else" after a return statement. Same down below.

Kdelibs/Frameworks coding style doesn't say anything about early returns so here are links to other coding styles

Could you provide the value of the system brightness after each key press (cat /sys/class/backlight/*/brightness) as well as the maximun brightness of your hardware (cat /sys/class/backlight/*/max_brightness) ?
I know, I'm asking you to work with a black screen ...

Max brightness: 937

Individual brightness levels per key-press:

0 (lowest setting)
2
9
21
37
59
84
115
150
190
234
283
337
396
459
527
600
677
759
846
937 (highest setting)

Thanks Nate. If your screen does not turn on while passing from 0 to 2, than this patch is in trouble ...
Could you tell me at what value your screen does turn on for the first time, starting from 0 (by writing values directly in /sys/class/backlight/<your hardware>/brightness) ?

My backlight turns on at 6. It's off at 5.

Hi Nate, sorry I'm asking you one more thing before giving up on this patch (even though I find it really useful for my personal use).
When your screen is off, with a brightness value of 4 for example, could you tell me what is the value reported in /sys/class/backlight/<your hardware>/actual_brightness ?

sharvey added a subscriber: sharvey.EditedJun 13 2018, 8:12 PM

Hope you don't mind me jumping in - I'm another one of Nate's protegees... here's some data for you. These values are before your patch. Let me know if you'd like me to apply your patch and redo the testing.

0 (lowest)
75 (backlight on)
150
225
300
375
450
525
600
675
750
825
900
975
1050
1125
1200
1275
1350
1425
1500 (highest)

1500 matches what's in the max_brightness file.

Hi Scott, thanks for the help!
If you can apply the patch, we could see if you have the same behavior than Nate with his hardware: when setting a very low value (for him, it's in the range 1 to 5) to /sys/class/backlight/<hardware>/brightness his screen does not turn on at all. I would like to know if /sys/class/backlight/<hardware>/actual_brightness is then saying something different than /sys/class/backlight/<your hardware>/brightness.
On my computer the backlight goes on as soon as I put 1 to /sys/class/backlight/<hardware>/brightness, so I cannot reproduce this.
I hope I'm clear enough :)

Hi Scott, thanks for the help!
If you can apply the patch, we could see if you have the same behavior than Nate with his hardware: when setting a very low value (for him, it's in the range 1 to 5) to /sys/class/backlight/<hardware>/brightness his screen does not turn on at all. I would like to know if /sys/class/backlight/<hardware>/actual_brightness is then saying something different than /sys/class/backlight/<your hardware>/brightness.
On my computer the backlight goes on as soon as I put 1 to /sys/class/backlight/<hardware>/brightness, so I cannot reproduce this.
I hope I'm clear enough :)

Makes sense. I'll get it patched and repost in a couple of hours.

FYI: this where a remote control app like NoMachine comes in handy - you can issue commands on your tablet (or phone!) and watch what happens on the big screen.

It seems I have some system rebuilding to do first. I'm not up for tackling it tonight. I'll work on it in the morning and try to get you some more data.

Lowest setting:
$ cat /sys/class/backlight/intel_backlight/actual_brightness 
0
Next setting:
$ cat /sys/class/backlight/intel_backlight/actual_brightness 
2

Same values as /sys/class/backlight/*/brightness, in other words.

Same values as /sys/class/backlight/*/brightness, in other words.

Thanks Nate, even if that's not the answer I was hoping for ...
The future of this patch:

  • accept to break some systems (but who wants that ?)
  • add an option for this quadratic progression somehwere
  • drop it

What do you think ? (the question is for anybody interested!)

I don't think we want the possibility of breaking anyone. A setting doesn't seem ideal either; who would ever find and change this?

Rather, let's focus on the issue that's hurting us here to see if we can resolve it somehow. Is there any way to programmatically detect the minimum brightness before the backlight turns off? Or could it be a kernel bug that there are ever any non-zero brightness values that still have the backlight off?

A couple of random ideas:

  • The Arch Wiki has a lengthy page on screen brightness. Maybe there's something there that can help.
  • Is there a valid use case for going all the way to zero? Minimum doesn't necessarily need to equal "off". If it's an external screen, it's got a power button. The only complex situation I can imagine is a laptop + monitor dual screen setup. Thoughts?
  • Perhaps, when starting from zero, move two steps instead of just one. That would fix the "Nate Problem", and i doubt anyone would say "okay, my screen is really dim, but I wanted it even dimmer."
kjslag added a subscriber: kjslag.May 21 2019, 5:24 AM

I like the idea of this patch. I just reassigned my brightness hotkeys to a small script that does almost exactly what this patch does before I discovered this patch.

In order to deal with Nate's problem, perhaps instead of starting with brightness=0, we could just start with the next increment of brightness, which happens to be 2 for Nate. Nate's situation would be similar to before the patch was applied: only the lowest brightness setting turns off his screen. So there wouldn't be a regression for Nate.

On my laptop, brightness=0 turns the screen off and brightness 1 through 46 correspond to the minimum brightness, and max_brightness=24242. My proposal would also be better for me since then my screen wouldn't turn off with the minimum brightness.

romangg added a comment.EditedMay 21 2019, 8:07 AM
  • accept to break some systems (but who wants that ?)

If these systems' breakage is because of an erroneous kernel driver, we can accept it. My system goes with brightness from 0 to 7500, and screen is activated at 1. It going dark at some higher value than 0 seems buggy to me. Is there some kernel directive on how it is supposed to work, i.e. if a display should be on at 1? @ngraham: what laptop model do you have?

In order to deal with Nate's problem, perhaps instead of starting with brightness=0, we could just start with the next increment of brightness, which happens to be 2 for Nate. Nate's situation would be similar to before the patch was applied: only the lowest brightness setting turns off his screen. So there wouldn't be a regression for Nate.

How do we know what's the common "next" brightness? What if there is another laptop, where it starts at 3?

On my laptop, brightness=0 turns the screen off and brightness 1 through 46 correspond to the minimum brightness, and max_brightness=24242. My proposal would also be better for me since then my screen wouldn't turn off with the minimum brightness.

Moving the brightness slider all the way down is supposed to turn off the screen as long as we don't have another ux-friendly way for that.

@romangg The current code selects from a discrete set of brightness levels which starts at zero. I was suggesting just removing the zero brightness level and using the next level as the minimum brightness level.

I didn't realize turning off the screen at the lowest brightness level was an intended feature. My past 3 laptops didn't do that, and I've never seen a laptop do that on any operating system. It seems like an unintuitive feature and could confuse someone who doesn't realize that their screen is black because the brightness is all the way down. Perhaps it would be better to add a different hotkey for this function. (That's what I did.)

Also note that setting brightness=0 probably isn't a power efficient way to turn the screen off. My laptop uses 4W less energy when I turn the screen off with
xset dpms force off
than when I set brightness=0.

Moving the brightness to zero is supposed to turn the backlight off, not the screen right?

  • accept to break some systems (but who wants that ?)

If these systems' breakage is because of an erroneous kernel driver, we can accept it. My system goes with brightness from 0 to 7500, and screen is activated at 1. It going dark at some higher value than 0 seems buggy to me. Is there some kernel directive on how it is supposed to work, i.e. if a display should be on at 1? @ngraham: what laptop model do you have?

HP Spectre x360, late 2016 model

Moving the brightness to zero is supposed to turn the backlight off, not the screen right?

I don't see why. It seems better to put the screen into a low energy mode than to just turn off the backlight in order to save more watts. It also seems strange for the brightness slider to go all the way down to zero brightness. Do any other desktop environments or operating systems do that?

In order to deal with Nate's problem, perhaps instead of starting with brightness=0, we could just start with the next increment of brightness, which happens to be 2 for Nate. Nate's situation would be similar to before the patch was applied: only the lowest brightness setting turns off his screen. So there wouldn't be a regression for Nate.

Are there still any objections to this solution?

Moving the brightness to zero is supposed to turn the backlight off, not the screen right?

I don't see why. It seems better to put the screen into a low energy mode than to just turn off the backlight in order to save more watts. It also seems strange for the brightness slider to go all the way down to zero brightness. Do any other desktop environments or operating systems do that?

On macOS, it turns the backlight off but keeps the screen on. But yeah, I can see how this isn't exactly very useful. I think I'm okay with the bottom level turning off the screen entirely.

In order to deal with Nate's problem, perhaps instead of starting with brightness=0, we could just start with the next increment of brightness, which happens to be 2 for Nate. Nate's situation would be similar to before the patch was applied: only the lowest brightness setting turns off his screen. So there wouldn't be a regression for Nate.

Are there still any objections to this solution?

Well it's not me that matters; it's all the other people with weird screens like mine, as well as the prople whose screens don't do this. We need to wither come up with a solution that works for everyone, or else mark some class of screen as misconfigured so we can tell those people to file kernel bugs.

kjslag added a comment.Jun 4 2019, 7:29 AM

Well it's not me that matters; it's all the other people with weird screens like mine, as well as the prople whose screens don't do this. We need to wither come up with a solution that works for everyone, or else mark some class of screen as misconfigured so we can tell those people to file kernel bugs.

My goal was to propose a solution that should work for everyone. For your laptop and the solution I proposed, the lowest brightness would still turn off the backlight, and the next brightness would turn it on, just as it currently does. For screens like mine where only brightness=0 turns off the display, the solution I proposed would never turn off the backlight. In both cases, it doesn't seem like there would be a regression.

Well it's not me that matters; it's all the other people with weird screens like mine, as well as the prople whose screens don't do this. We need to wither come up with a solution that works for everyone, or else mark some class of screen as misconfigured so we can tell those people to file kernel bugs.

My goal was to propose a solution that should work for everyone. For your laptop and the solution I proposed, the lowest brightness would still turn off the backlight, and the next brightness would turn it on, just as it currently does. For screens like mine where only brightness=0 turns off the display, the solution I proposed would never turn off the backlight. In both cases, it doesn't seem like there would be a regression.

All right, sounds good enough to me!

Please create a table with what would happen when. To me it sounds like something would not work out in the end, but I can be wrong.