Skip to content

Commit b867570

Browse files
jannaumarcan
authored andcommitted
drm/apple: Set backlight level indirectly if no mode is set
Fixes following warning when systemd-backlight restores the backlight level on boot before a mode is set: Call trace: drm_atomic_helper_crtc_duplicate_state+0x58/0x74 drm_atomic_get_crtc_state+0x84/0x120 dcp_set_brightness+0xd8/0x21c [apple_dcp] backlight_device_set_brightness+0x78/0x130 ... Signed-off-by: Janne Grunau <j@jannau.net>
1 parent 94a27df commit b867570

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

drivers/gpu/drm/apple/dcp_backlight.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,21 +165,30 @@ static int drm_crtc_set_brightness(struct drm_crtc *crtc,
165165

166166
static int dcp_set_brightness(struct backlight_device *bd)
167167
{
168-
int ret;
168+
int ret = 0;
169169
struct apple_dcp *dcp = bl_get_data(bd);
170170
struct drm_modeset_acquire_ctx ctx;
171171

172172
if (bd->props.state & BL_CORE_SUSPENDED)
173173
return 0;
174174

175-
if (!dcp->crtc)
176-
return -EAGAIN;
175+
DRM_MODESET_LOCK_ALL_BEGIN(dcp->crtc->base.dev, ctx, 0, ret);
177176

178177
dcp->brightness.dac = calculate_dac(dcp, bd->props.brightness);
179178
dcp->brightness.update = true;
180179

181-
DRM_MODESET_LOCK_ALL_BEGIN(dcp->crtc->base.dev, ctx, 0, ret);
180+
/*
181+
* Do not actively try to change brightness if no mode is set.
182+
* TODO: should this be reflected the in backlight's power property?
183+
* defer this hopefully until it becomes irrelevant due to proper
184+
* drm integrated backlight handling
185+
*/
186+
if (!dcp->valid_mode)
187+
goto out;
188+
182189
ret = drm_crtc_set_brightness(&dcp->crtc->base, &ctx);
190+
191+
out:
183192
DRM_MODESET_LOCK_ALL_END(dcp->crtc->base.dev, ctx, ret);
184193

185194
return ret;

0 commit comments

Comments
 (0)