For the mgag200 driver if the format of the plane changes, then the PLL rate needs to be changed. This requires performing a full CRTC modeset. Current code sets drm_crtc_state.mode_changed from the plane's atomic_check() callback and then doesn't call drm_atomic_helper_check() again. It works for the mgag200 driver, but it breaks calling convention of the drm_atomic_helper_check() function. Move the check to the new atomic_needs_modeset() callback, removing the need to set the flag in the atomic_check(). Note: this also checks the check to compare format to the old_plane_state->fb->format instead of using plane->state->fb->format. Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@xxxxxxxxxx> --- drivers/gpu/drm/mgag200/mgag200_drv.h | 2 ++ drivers/gpu/drm/mgag200/mgag200_mode.c | 27 ++++++++++++++++++++------- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.h b/drivers/gpu/drm/mgag200/mgag200_drv.h index 0608fc63e588bb60f1b087d263a34cfd11624b52..42cf0826ed14e0e9e4ed1b7920486bda008a0f99 100644 --- a/drivers/gpu/drm/mgag200/mgag200_drv.h +++ b/drivers/gpu/drm/mgag200/mgag200_drv.h @@ -354,6 +354,8 @@ extern const uint32_t mgag200_primary_plane_formats[]; extern const size_t mgag200_primary_plane_formats_size; extern const uint64_t mgag200_primary_plane_fmtmods[]; +bool mgag200_primary_plane_helper_atomic_needs_modeset(struct drm_plane *plane, + struct drm_atomic_state *new_state); int mgag200_primary_plane_helper_atomic_check(struct drm_plane *plane, struct drm_atomic_state *new_state); void mgag200_primary_plane_helper_atomic_update(struct drm_plane *plane, diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index fb71658c3117b25311f19276d6f4ffdee157ac17..63285b356326a13b465387e5d7ac90ec9fe867cf 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c @@ -463,12 +463,31 @@ const uint64_t mgag200_primary_plane_fmtmods[] = { DRM_FORMAT_MOD_INVALID }; +bool mgag200_primary_plane_helper_atomic_needs_modeset(struct drm_plane *plane, + struct drm_atomic_state *new_state) +{ + struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(new_state, plane); + struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(new_state, plane); + struct drm_framebuffer *new_fb = new_plane_state->fb; + struct drm_framebuffer *fb = NULL; + + if (old_plane_state) + fb = old_plane_state->fb; + + if (!new_fb) + return false; + + if (!fb || (fb->format != new_fb->format)) + return true; + + return false; +} + int mgag200_primary_plane_helper_atomic_check(struct drm_plane *plane, struct drm_atomic_state *new_state) { struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(new_state, plane); struct drm_framebuffer *new_fb = new_plane_state->fb; - struct drm_framebuffer *fb = NULL; struct drm_crtc *new_crtc = new_plane_state->crtc; struct drm_crtc_state *new_crtc_state = NULL; struct mgag200_crtc_state *new_mgag200_crtc_state; @@ -486,12 +505,6 @@ int mgag200_primary_plane_helper_atomic_check(struct drm_plane *plane, else if (!new_plane_state->visible) return 0; - if (plane->state) - fb = plane->state->fb; - - if (!fb || (fb->format != new_fb->format)) - new_crtc_state->mode_changed = true; /* update PLL settings */ - new_mgag200_crtc_state = to_mgag200_crtc_state(new_crtc_state); new_mgag200_crtc_state->format = new_fb->format; -- 2.39.5