Merge tag 'topic/drm-misc-2015-10-19' of git://anongit.freedesktop.org/drm-intel...
[linux-drm-fsl-dcu.git] / drivers / gpu / drm / drm_fb_helper.c
index bd6d4ab2751250ab9af68f0aa9f91e0cb44463ce..e673c13c7391153d6c7f3c54b7c56a0e17d26bca 100644 (file)
@@ -360,11 +360,7 @@ retry:
                        goto fail;
                }
 
-               ret = drm_atomic_plane_set_property(plane, plane_state,
-                               dev->mode_config.rotation_property,
-                               BIT(DRM_ROTATE_0));
-               if (ret != 0)
-                       goto fail;
+               plane_state->rotation = BIT(DRM_ROTATE_0);
 
                /* disable non-primary: */
                if (plane->type == DRM_PLANE_TYPE_PRIMARY)
@@ -1235,7 +1231,7 @@ int drm_fb_helper_set_par(struct fb_info *info)
 EXPORT_SYMBOL(drm_fb_helper_set_par);
 
 static int pan_display_atomic(struct fb_var_screeninfo *var,
-               struct fb_info *info)
+                             struct fb_info *info)
 {
        struct drm_fb_helper *fb_helper = info->par;
        struct drm_device *dev = fb_helper->dev;
@@ -1253,6 +1249,8 @@ retry:
 
                mode_set = &fb_helper->crtc_info[i].mode_set;
 
+               mode_set->crtc->primary->old_fb = mode_set->crtc->primary->fb;
+
                mode_set->x = var->xoffset;
                mode_set->y = var->yoffset;
 
@@ -1268,13 +1266,34 @@ retry:
        info->var.xoffset = var->xoffset;
        info->var.yoffset = var->yoffset;
 
-       return 0;
 
 fail:
+       for(i = 0; i < fb_helper->crtc_count; i++) {
+               struct drm_mode_set *mode_set;
+               struct drm_plane *plane;
+
+               mode_set = &fb_helper->crtc_info[i].mode_set;
+               plane = mode_set->crtc->primary;
+
+               if (ret == 0) {
+                       struct drm_framebuffer *new_fb = plane->state->fb;
+
+                       if (new_fb)
+                               drm_framebuffer_reference(new_fb);
+                       plane->fb = new_fb;
+                       plane->crtc = plane->state->crtc;
+
+                       if (plane->old_fb)
+                               drm_framebuffer_unreference(plane->old_fb);
+               }
+               plane->old_fb = NULL;
+       }
+
        if (ret == -EDEADLK)
                goto backoff;
 
-       drm_atomic_state_free(state);
+       if (ret != 0)
+               drm_atomic_state_free(state);
 
        return ret;