Skip to content
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

DCP: backlight/parser fixes #106

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions drivers/gpu/drm/apple/dcp_backlight.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,21 +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 (bd->props.state & BL_CORE_SUSPENDED)
return 0;

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

dcp->brightness.dac = calculate_dac(dcp, bd->props.brightness);
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
14 changes: 13 additions & 1 deletion drivers/gpu/drm/apple/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ static int parse_dimension(struct dcp_parse_ctx *handle, struct dimension *dim)
char *key = parse_string(it.handle);

if (IS_ERR(key))
ret = PTR_ERR(handle);
ret = PTR_ERR(key);
else if (!strcmp(key, "Active"))
ret = parse_int(it.handle, &dim->active);
else if (!strcmp(key, "Total"))
Expand All @@ -243,6 +243,9 @@ static int parse_dimension(struct dcp_parse_ctx *handle, struct dimension *dim)
else
skip(it.handle);

if (!IS_ERR_OR_NULL(key))
kfree(key);

if (ret)
return ret;
}
Expand Down Expand Up @@ -298,6 +301,9 @@ static int parse_color_modes(struct dcp_parse_ctx *handle, s64 *preferred_id)
else
skip(it.handle);

if (!IS_ERR_OR_NULL(key))
kfree(key);

if (ret)
return ret;
}
Expand Down Expand Up @@ -381,6 +387,9 @@ static int parse_mode(struct dcp_parse_ctx *handle,
else
skip(it.handle);

if (!IS_ERR_OR_NULL(key))
kfree(key);

if (ret)
return ret;
}
Expand Down Expand Up @@ -511,6 +520,9 @@ int parse_display_attributes(struct dcp_parse_ctx *handle, int *width_mm,
else
skip(it.handle);

if (!IS_ERR_OR_NULL(key))
kfree(key);

if (ret)
return ret;
}
Expand Down