Commit 9f658b7b authored by Daniel Stone's avatar Daniel Stone Committed by Daniel Vetter

drm/crtc_helper: Replace open-coded CRTC state helpers

Rather than open-coding our own CRTC state helpers, use the atomic helpers
added in f5e7840b, and make our freeing behaviour consistent as well.
Signed-off-by: default avatarDaniel Stone <daniels@collabora.com>
Tested-by: default avatarSean Paul <seanpaul@chromium.org>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent f102c16e
...@@ -927,14 +927,15 @@ int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mod ...@@ -927,14 +927,15 @@ int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mod
if (crtc->funcs->atomic_duplicate_state) if (crtc->funcs->atomic_duplicate_state)
crtc_state = crtc->funcs->atomic_duplicate_state(crtc); crtc_state = crtc->funcs->atomic_duplicate_state(crtc);
else if (crtc->state) else {
crtc_state = kmemdup(crtc->state, sizeof(*crtc_state),
GFP_KERNEL);
else
crtc_state = kzalloc(sizeof(*crtc_state), GFP_KERNEL); crtc_state = kzalloc(sizeof(*crtc_state), GFP_KERNEL);
if (!crtc_state) if (!crtc_state)
return -ENOMEM; return -ENOMEM;
crtc_state->crtc = crtc; if (crtc->state)
__drm_atomic_helper_crtc_duplicate_state(crtc, crtc_state);
else
crtc_state->crtc = crtc;
}
crtc_state->enable = true; crtc_state->enable = true;
crtc_state->planes_changed = true; crtc_state->planes_changed = true;
...@@ -944,30 +945,25 @@ int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mod ...@@ -944,30 +945,25 @@ int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mod
if (crtc_funcs->atomic_check) { if (crtc_funcs->atomic_check) {
ret = crtc_funcs->atomic_check(crtc, crtc_state); ret = crtc_funcs->atomic_check(crtc, crtc_state);
if (ret) { if (ret)
if (crtc->funcs->atomic_destroy_state) { goto out;
crtc->funcs->atomic_destroy_state(crtc,
crtc_state);
} else {
kfree(crtc_state);
}
return ret;
}
} }
swap(crtc->state, crtc_state); swap(crtc->state, crtc_state);
crtc_funcs->mode_set_nofb(crtc); crtc_funcs->mode_set_nofb(crtc);
if (crtc_state) { ret = drm_helper_crtc_mode_set_base(crtc, x, y, old_fb);
if (crtc->funcs->atomic_destroy_state)
crtc->funcs->atomic_destroy_state(crtc, crtc_state); out:
else if (crtc->funcs->atomic_destroy_state)
kfree(crtc_state); crtc->funcs->atomic_destroy_state(crtc, crtc_state);
else {
__drm_atomic_helper_crtc_destroy_state(crtc, crtc_state);
kfree(crtc_state);
} }
return drm_helper_crtc_mode_set_base(crtc, x, y, old_fb); return ret;
} }
EXPORT_SYMBOL(drm_helper_crtc_mode_set); EXPORT_SYMBOL(drm_helper_crtc_mode_set);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment