@@ -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,
@@ -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;
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@linaro.org> --- drivers/gpu/drm/mgag200/mgag200_drv.h | 2 ++ drivers/gpu/drm/mgag200/mgag200_mode.c | 27 ++++++++++++++++++++------- 2 files changed, 22 insertions(+), 7 deletions(-)