Skip to content

Commit

Permalink
drm/apple: Set backlight level indirectly if no mode is set
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
jannau committed Jan 22, 2023
1 parent ff8f2dd commit ed3e81d
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions drivers/gpu/drm/apple/dcp_backlight.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,19 +165,28 @@ static int drm_crtc_set_brightness(struct drm_crtc *crtc,

static int dcp_set_brightness(struct backlight_device *bd)
{
int ret;
int ret = 0;
struct apple_dcp *dcp = bl_get_data(bd);
struct drm_modeset_acquire_ctx ctx;
int brightness = backlight_get_brightness(bd);

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

dcp->brightness.dac = calculate_dac(dcp, brightness);
dcp->brightness.update = true;

DRM_MODESET_LOCK_ALL_BEGIN(dcp->crtc->base.dev, ctx, 0, ret);
/*
* Do not actively try to change brightness if no mode is set.
* TODO: should this be reflected the in backlight's power property?
* defer this hopefully until it becomes irrelevant due to proper
* drm integrated backlight handling
*/
if (!dcp->valid_mode)
goto out;

ret = drm_crtc_set_brightness(&dcp->crtc->base, &ctx);

out:
DRM_MODESET_LOCK_ALL_END(dcp->crtc->base.dev, ctx, ret);

return ret;
Expand Down

0 comments on commit ed3e81d

Please sign in to comment.