MLK-17543-1: drm/mxsfb: Signal mode changed when bpp changed
authorMirela Rabulea <mirela.rabulea@nxp.com>
Mon, 19 Mar 2018 13:25:46 +0000 (15:25 +0200)
committerHaibo Chen <haibo.chen@nxp.com>
Thu, 12 Apr 2018 10:45:52 +0000 (18:45 +0800)
Add mxsfb_atomic_helper_check to signal mode changed when bpp changed.
This will trigger the execution of disable/enable on
a modeset with different bpp than the current one.

Signed-off-by: Mirela Rabulea <mirela.rabulea@nxp.com>
drivers/gpu/drm/mxsfb/mxsfb_drv.c

index 65b909f..96536bf 100644 (file)
@@ -115,9 +115,55 @@ void mxsfb_disable_axi_clk(struct mxsfb_drm_private *mxsfb)
                clk_disable_unprepare(mxsfb->clk_axi);
 }
 
+/**
+ * mxsfb_atomic_helper_check - validate state object
+ * @dev: DRM device
+ * @state: the driver state object
+ *
+ * On top of the drm imlementation drm_atomic_helper_check,
+ * check if the bpp is changed, if so, signal mode_changed,
+ * this will trigger disable/enable
+ *
+ * RETURNS:
+ * Zero for success or -errno
+ */
+static int mxsfb_atomic_helper_check(struct drm_device *dev,
+                           struct drm_atomic_state *state)
+{
+       struct drm_crtc *crtc;
+       struct drm_crtc_state *crtc_state;
+       int i, ret;
+
+       ret = drm_atomic_helper_check(dev, state);
+       if (ret)
+               return ret;
+
+       for_each_crtc_in_state(state, crtc, crtc_state, i) {
+               struct drm_plane_state *primary_state;
+               int old_bpp = 0;
+               int new_bpp = 0;
+
+               if (!crtc->primary || !crtc->primary->old_fb)
+                       continue;
+               primary_state =
+                       drm_atomic_get_plane_state(state, crtc->primary);
+               if (!primary_state || !primary_state->fb)
+                       continue;
+               old_bpp = crtc->primary->old_fb->bits_per_pixel;
+               new_bpp = primary_state->fb->bits_per_pixel;
+               if (old_bpp != new_bpp) {
+                       crtc_state->mode_changed = true;
+                       DRM_DEBUG_ATOMIC(
+                               "[CRTC:%d:%s] mode changed, bpp %d->%d\n",
+                               crtc->base.id, crtc->name, old_bpp, new_bpp);
+               }
+       }
+       return ret;
+}
+
 static const struct drm_mode_config_funcs mxsfb_mode_config_funcs = {
        .fb_create              = drm_fb_cma_create,
-       .atomic_check           = drm_atomic_helper_check,
+       .atomic_check           = mxsfb_atomic_helper_check,
        .atomic_commit          = drm_atomic_helper_commit,
 };