Commit 5a27528a authored by Daniel Stone's avatar Daniel Stone Committed by Daniel Vetter

drm: crtc_helper: Update hwmode before mode_set call

Just as we provide crtc->mode pre-populated with the requested mode,
move adjusted_mode into hwmode before we call the crtc's mode_set,
making sure to restore it on failure.

Allows drivers which thoughtlessly discard adjusted_mode in their
mode_set hooks (e.g. Exynos) to use hwmode directly, and also provides
some neat symmetry with crtc->mode.
Signed-off-by: default avatarDaniel Stone <daniels@collabora.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 54270952
...@@ -270,7 +270,7 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc, ...@@ -270,7 +270,7 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
struct drm_framebuffer *old_fb) struct drm_framebuffer *old_fb)
{ {
struct drm_device *dev = crtc->dev; struct drm_device *dev = crtc->dev;
struct drm_display_mode *adjusted_mode, saved_mode; struct drm_display_mode *adjusted_mode, saved_mode, saved_hwmode;
struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
struct drm_encoder_helper_funcs *encoder_funcs; struct drm_encoder_helper_funcs *encoder_funcs;
int saved_x, saved_y; int saved_x, saved_y;
...@@ -292,6 +292,7 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc, ...@@ -292,6 +292,7 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
} }
saved_mode = crtc->mode; saved_mode = crtc->mode;
saved_hwmode = crtc->hwmode;
saved_x = crtc->x; saved_x = crtc->x;
saved_y = crtc->y; saved_y = crtc->y;
...@@ -334,6 +335,8 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc, ...@@ -334,6 +335,8 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
} }
DRM_DEBUG_KMS("[CRTC:%d]\n", crtc->base.id); DRM_DEBUG_KMS("[CRTC:%d]\n", crtc->base.id);
crtc->hwmode = *adjusted_mode;
/* Prepare the encoders and CRTCs before setting the mode. */ /* Prepare the encoders and CRTCs before setting the mode. */
list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
...@@ -396,9 +399,6 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc, ...@@ -396,9 +399,6 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
encoder->bridge->funcs->enable(encoder->bridge); encoder->bridge->funcs->enable(encoder->bridge);
} }
/* Store real post-adjustment hardware mode. */
crtc->hwmode = *adjusted_mode;
/* Calculate and store various constants which /* Calculate and store various constants which
* are later needed by vblank and swap-completion * are later needed by vblank and swap-completion
* timestamping. They are derived from true hwmode. * timestamping. They are derived from true hwmode.
...@@ -411,6 +411,7 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc, ...@@ -411,6 +411,7 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
if (!ret) { if (!ret) {
crtc->enabled = saved_enabled; crtc->enabled = saved_enabled;
crtc->mode = saved_mode; crtc->mode = saved_mode;
crtc->hwmode = saved_hwmode;
crtc->x = saved_x; crtc->x = saved_x;
crtc->y = saved_y; crtc->y = saved_y;
} }
......
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