MLK-17115: drm/mxsfb: Add support for vblank
authorRobert Chiras <robert.chiras@nxp.com>
Fri, 8 Dec 2017 08:23:15 +0000 (10:23 +0200)
committerNitin Garg <nitin.garg@nxp.com>
Tue, 20 Mar 2018 19:51:02 +0000 (14:51 -0500)
Currently, the vblank support is not correctly implemented in MXSFB_DRM
driver. Thix patch addresses this issue, so that vblank will be
supported by MXSFB_DRM driver.

Signed-off-by: Robert Chiras <robert.chiras@nxp.com>
drivers/gpu/drm/mxsfb/mxsfb_drv.c

index 571119d..a8280d1 100644 (file)
@@ -44,6 +44,9 @@
 #include "mxsfb_drv.h"
 #include "mxsfb_regs.h"
 
+/* The eLCDIF max possible CRTCs */
+#define MAX_CRTCS 1
+
 enum mxsfb_devtype {
        MXSFB_V3,
        MXSFB_V4,
@@ -134,6 +137,8 @@ static void mxsfb_pipe_enable(struct drm_simple_display_pipe *pipe,
                mxsfb->connector = &mxsfb->panel_connector;
        }
 
+       drm_crtc_vblank_on(&mxsfb->pipe.crtc);
+
        mxsfb_crtc_enable(mxsfb);
        pm_runtime_get_sync(mxsfb->dev);
 }
@@ -141,6 +146,14 @@ static void mxsfb_pipe_enable(struct drm_simple_display_pipe *pipe,
 static void mxsfb_pipe_disable(struct drm_simple_display_pipe *pipe)
 {
        struct mxsfb_drm_private *mxsfb = drm_pipe_to_mxsfb_drm_private(pipe);
+       struct drm_crtc *crtc = &pipe->crtc;
+
+       spin_lock_irq(&crtc->dev->event_lock);
+       if (crtc->state->event) {
+               drm_crtc_send_vblank_event(crtc, crtc->state->event);
+               crtc->state->event = NULL;
+       }
+       spin_unlock_irq(&crtc->dev->event_lock);
 
        mxsfb_crtc_disable(mxsfb);
        pm_runtime_put_sync(mxsfb->dev);
@@ -215,7 +228,7 @@ static int mxsfb_load(struct drm_device *drm, unsigned long flags)
 
        pm_runtime_enable(drm->dev);
 
-       ret = drm_vblank_init(drm, drm->mode_config.num_crtc);
+       ret = drm_vblank_init(drm, MAX_CRTCS);
        if (ret < 0) {
                dev_err(drm->dev, "Failed to initialise vblank\n");
                goto err_vblank;
@@ -238,6 +251,8 @@ static int mxsfb_load(struct drm_device *drm, unsigned long flags)
                goto err_vblank;
        }
 
+       drm_crtc_vblank_off(&mxsfb->pipe.crtc);
+
        /*
         * Attach panel only if there is one.
         * If there is no panel attach, it must be a bridge. In this case, we