Repository navigation
drm/apple: hold brightness requests at the panel's floor #3105
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
Changes from all commits
2e4d9c8
040c06c
0c42db3
08ea507
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,8 @@ | |
| */ | ||
| struct dcp_backlight_state { | ||
| u32 maximum; | ||
| /* Lowest level a request can reach, 0 for none: dcp_bl_set_minimum(). */ | ||
| u32 minimum; | ||
| u32 target; | ||
| u32 level; | ||
| u32 fade_from; | ||
|
|
@@ -99,6 +101,29 @@ static inline int dcp_bl_init(struct dcp_backlight_state *state, u32 maximum, | |
| return 0; | ||
| } | ||
|
|
||
| /* | ||
| * A panel node may name the lowest level a brightness request can reach | ||
| * (apple,min-brightness, in nits). A request below it, zero included, is | ||
| * raised to it, so a brightness write alone cannot darken such a panel. | ||
| * Blanking, DPMS off and suspend are not requests and still present zero. | ||
| * A loader level below the floor stays until the first request. | ||
| */ | ||
| static inline int dcp_bl_set_minimum(struct dcp_backlight_state *state, u32 minimum) | ||
| { | ||
| if (!state->ready) | ||
| return -ENODATA; | ||
| if (minimum >= state->maximum) | ||
| return -ERANGE; | ||
| state->minimum = minimum; | ||
| return 0; | ||
| } | ||
|
|
||
| /* The level a request for @nits reaches on this panel. */ | ||
| static inline u32 dcp_bl_floor(const struct dcp_backlight_state *state, u32 nits) | ||
| { | ||
| return nits < state->minimum ? state->minimum : nits; | ||
| } | ||
|
|
||
| /* | ||
| * A decoded powerlog sample can seed takeover only before Linux control. | ||
| * It reports the level the panel shows, so the level is then known. | ||
|
|
@@ -170,6 +195,13 @@ static inline int dcp_bl_request(struct dcp_backlight_state *state, u32 nits, | |
| return -ENODATA; | ||
| if (nits > state->maximum) | ||
| return -ERANGE; | ||
| /* | ||
| * A blank or suspend change arrives with the level unchanged: it is not | ||
| * a request, so a loader level below the floor stays. | ||
| */ | ||
| if (nits != state->target || (state->core_blank == core_blank && | ||
| state->suspended == suspended)) | ||
| nits = dcp_bl_floor(state, nits); | ||
|
Comment on lines
+202
to
+204
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
On the firmware-27 wake path when no FB blank remains, Useful? React with 👍 / 👎. |
||
| /* Save/restore clients may echo the reporting default without a change. */ | ||
| if (state->preserve_inherited && !state->controlled && !state->level_known && | ||
| state->target == nits) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
apple,min-brightnessis valid but greater than 120 on an M4 panel,iomfb_m4_configure_backlight()initializes the non-inherited target to 120 and this call only stores the minimum; the immediately following M4dcp_bl_jump()marks 120 dirty, andiomfb_m4_swap()presents it. The driver therefore drives the panel below its declared lowest lit level before userspace writes brightness, potentially leaving startup black; floor non-inherited defaults before the M4 jump while retaining the below-floor exception only for loader-inherited levels.Useful? React with 👍 / 👎.