Skip to content

fix(backlight2): signal smooth adjustment completion explicitly instead of zeroing target_pct - #124

Open
dmanam wants to merge 1 commit into
FedeDP:masterfrom
dmanam:flicker-fix
Open

fix(backlight2): signal smooth adjustment completion explicitly instead of zeroing target_pct#124
dmanam wants to merge 1 commit into
FedeDP:masterfrom
dmanam:flicker-fix

Conversation

@dmanam

@dmanam dmanam commented Aug 21, 2026

Copy link
Copy Markdown

This adds an extra return value reached to set_backlight_value() which explicitly tracks whether the target value has been reached, so that we no longer need to track it by zeroing target_pct.

This fixes two bugs:

  1. [BUG] Clight changes the backlight level twice every capture Clight#293: If a call to Backlight2.Set reaches its target within a single step, it ends up zeroing target_pct but then continuing to smooth for one more step, erroneously taking an extra step towards 0. This ends up causing the backlight to flicker, since this repeats every update (since we're never at the desired percentage). This is mitigated in many cases by Fix backlight flickering and suspend/resume state machine Clight#317, but the underlying cause is here. This bug was introduced in 2e8c6ff (off by just one from what @3cky found here).
  2. A call to Backlight2.Lower which tries to lower to 0 never makes it, since target_pct being 0 causes the smoothing to stop.

There's also a third (seeming) bug which is now easily fixed: if the target backlight for Set is 0, then we currently jump to it immediately, even if smoothing is on. I didn't implement the fix, since it's possible this is the intended behavior, but doing so just requires removing && params->target_pct > 0 from is_smooth(). Once we're tracking completion separately, this doesn't introduce any issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant