Merge branch 'fixes-v3.15-rc1'; commit '390403fd79821bbd0c3a0d83307df2be87047b36...
[cascardo/linux.git] / drivers / gpu / drm / exynos / exynos_drm_crtc.c
index 5067bf4..e930d4f 100644 (file)
@@ -105,7 +105,12 @@ exynos_drm_crtc_mode_fixup(struct drm_crtc *crtc,
                            const struct drm_display_mode *mode,
                            struct drm_display_mode *adjusted_mode)
 {
-       /* drm framework doesn't check NULL */
+       struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
+       struct exynos_drm_manager *manager = exynos_crtc->manager;
+
+       if (manager->ops->mode_fixup)
+               return manager->ops->mode_fixup(manager, mode, adjusted_mode);
+
        return true;
 }
 
@@ -115,6 +120,7 @@ exynos_drm_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode,
                          struct drm_framebuffer *old_fb)
 {
        struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
+       struct exynos_drm_manager *manager = exynos_crtc->manager;
        struct drm_plane *plane = exynos_crtc->plane;
        unsigned int crtc_w;
        unsigned int crtc_h;
@@ -126,16 +132,19 @@ exynos_drm_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode,
         */
        memcpy(&crtc->mode, adjusted_mode, sizeof(*adjusted_mode));
 
-       crtc_w = crtc->fb->width - x;
-       crtc_h = crtc->fb->height - y;
+       crtc_w = crtc->primary->fb->width - x;
+       crtc_h = crtc->primary->fb->height - y;
+
+       if (manager->ops->mode_set)
+               manager->ops->mode_set(manager, &crtc->mode);
 
-       ret = exynos_plane_mode_set(plane, crtc, crtc->fb, 0, 0, crtc_w, crtc_h,
+       ret = exynos_plane_mode_set(plane, crtc, crtc->primary->fb, 0, 0, crtc_w, crtc_h,
                                    x, y, crtc_w, crtc_h);
        if (ret)
                return ret;
 
        plane->crtc = crtc;
-       plane->fb = crtc->fb;
+       plane->fb = crtc->primary->fb;
 
        return 0;
 }
@@ -155,10 +164,10 @@ static int exynos_drm_crtc_mode_set_commit(struct drm_crtc *crtc, int x, int y,
                return -EPERM;
        }
 
-       crtc_w = crtc->fb->width - x;
-       crtc_h = crtc->fb->height - y;
+       crtc_w = crtc->primary->fb->width - x;
+       crtc_h = crtc->primary->fb->height - y;
 
-       ret = exynos_plane_mode_set(plane, crtc, crtc->fb, 0, 0, crtc_w, crtc_h,
+       ret = exynos_plane_mode_set(plane, crtc, crtc->primary->fb, 0, 0, crtc_w, crtc_h,
                                    x, y, crtc_w, crtc_h);
        if (ret)
                return ret;
@@ -176,10 +185,19 @@ static int exynos_drm_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
 
 static void exynos_drm_crtc_disable(struct drm_crtc *crtc)
 {
-       struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
+       struct drm_plane *plane;
+       int ret;
 
-       exynos_plane_dpms(exynos_crtc->plane, DRM_MODE_DPMS_OFF);
        exynos_drm_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
+
+       drm_for_each_legacy_plane(plane, &crtc->dev->mode_config.plane_list) {
+               if (plane->crtc != crtc)
+                       continue;
+
+               ret = plane->funcs->disable_plane(plane);
+               if (ret)
+                       DRM_ERROR("Failed to disable plane %d\n", ret);
+       }
 }
 
 static struct drm_crtc_helper_funcs exynos_crtc_helper_funcs = {
@@ -200,7 +218,7 @@ static int exynos_drm_crtc_page_flip(struct drm_crtc *crtc,
        struct drm_device *dev = crtc->dev;
        struct exynos_drm_private *dev_priv = dev->dev_private;
        struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
-       struct drm_framebuffer *old_fb = crtc->fb;
+       struct drm_framebuffer *old_fb = crtc->primary->fb;
        int ret = -EINVAL;
 
        /* when the page flip is requested, crtc's dpms should be on */
@@ -231,11 +249,11 @@ static int exynos_drm_crtc_page_flip(struct drm_crtc *crtc,
                atomic_set(&exynos_crtc->pending_flip, 1);
                spin_unlock_irq(&dev->event_lock);
 
-               crtc->fb = fb;
+               crtc->primary->fb = fb;
                ret = exynos_drm_crtc_mode_set_commit(crtc, crtc->x, crtc->y,
                                                    NULL);
                if (ret) {
-                       crtc->fb = old_fb;
+                       crtc->primary->fb = old_fb;
 
                        spin_lock_irq(&dev->event_lock);
                        drm_vblank_put(dev, exynos_crtc->pipe);