Merge branch 'exynos-drm-next' of git://git.infradead.org/users/kmpark/linux-samsung...
[cascardo/linux.git] / drivers / gpu / drm / exynos / exynos_drm_crtc.c
index df1e34f..fce245f 100644 (file)
@@ -66,7 +66,6 @@ struct exynos_drm_crtc {
 
 static void exynos_drm_crtc_dpms(struct drm_crtc *crtc, int mode)
 {
-       struct drm_device *dev = crtc->dev;
        struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
 
        DRM_DEBUG_KMS("crtc[%d] mode[%d]\n", crtc->base.id, mode);
@@ -76,12 +75,8 @@ static void exynos_drm_crtc_dpms(struct drm_crtc *crtc, int mode)
                return;
        }
 
-       mutex_lock(&dev->struct_mutex);
-
        exynos_drm_fn_encoder(crtc, &mode, exynos_drm_encoder_crtc_dpms);
        exynos_crtc->dpms = mode;
-
-       mutex_unlock(&dev->struct_mutex);
 }
 
 static void exynos_drm_crtc_prepare(struct drm_crtc *crtc)
@@ -97,6 +92,7 @@ static void exynos_drm_crtc_commit(struct drm_crtc *crtc)
 
        DRM_DEBUG_KMS("%s\n", __FILE__);
 
+       exynos_drm_crtc_dpms(crtc, DRM_MODE_DPMS_ON);
        exynos_plane_commit(exynos_crtc->plane);
        exynos_plane_dpms(exynos_crtc->plane, DRM_MODE_DPMS_ON);
 }
@@ -126,8 +122,6 @@ exynos_drm_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode,
 
        DRM_DEBUG_KMS("%s\n", __FILE__);
 
-       exynos_drm_crtc_dpms(crtc, DRM_MODE_DPMS_ON);
-
        /*
         * copy the mode data adjusted by mode_fixup() into crtc->mode
         * so that hardware can be seet to proper mode.
@@ -161,6 +155,12 @@ static int exynos_drm_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
 
        DRM_DEBUG_KMS("%s\n", __FILE__);
 
+       /* when framebuffer changing is requested, crtc's dpms should be on */
+       if (exynos_crtc->dpms > DRM_MODE_DPMS_ON) {
+               DRM_ERROR("failed framebuffer changing request.\n");
+               return -EPERM;
+       }
+
        crtc_w = crtc->fb->width - x;
        crtc_h = crtc->fb->height - y;
 
@@ -213,6 +213,12 @@ static int exynos_drm_crtc_page_flip(struct drm_crtc *crtc,
 
        DRM_DEBUG_KMS("%s\n", __FILE__);
 
+       /* when the page flip is requested, crtc's dpms should be on */
+       if (exynos_crtc->dpms > DRM_MODE_DPMS_ON) {
+               DRM_ERROR("failed page flip request.\n");
+               return -EINVAL;
+       }
+
        mutex_lock(&dev->struct_mutex);
 
        if (event) {