MLK-19152-3 drm/imx: lcdif: add horizontal crop support to plane update
authorFancy Fang <chen.fang@nxp.com>
Tue, 7 Aug 2018 10:37:06 +0000 (18:37 +0800)
committerLeonard Crestez <leonard.crestez@nxp.com>
Wed, 17 Apr 2019 23:51:34 +0000 (02:51 +0300)
Add horizontal cropping support when atomic plane update is
running, and if the attached CRTC needs modeset. And if the
width of visible portion of plane is equal to the fb surface
width, the Pigeon Mode will be disabled, so cropping will be
disabled.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
(cherry picked from commit 30672b2b18a07a2926979cc533cbb84ea4a642dd)
(cherry picked from commit 3bdf9efa9f1ebb995c79a60da4d579d21310670d)

drivers/gpu/drm/imx/lcdif/lcdif-plane.c

index 550e632..8b5988e 100644 (file)
@@ -110,7 +110,8 @@ static void lcdif_plane_atomic_update(struct drm_plane *plane,
        struct drm_plane_state *state = plane->state;
        struct drm_framebuffer *fb = state->fb;
        struct drm_gem_cma_object *gem_obj = NULL;
-       u32 fb_addr, src_off, fb_idx;
+       u32 fb_addr, src_off, src_w, fb_idx;
+       bool crop;
 
        /* plane and crtc is disabling */
        if (!fb)
@@ -139,6 +140,15 @@ static void lcdif_plane_atomic_update(struct drm_plane *plane,
 
        lcdif_set_fb_addr(lcdif, fb_idx, fb_addr);
 
+       /* config horizontal cropping if crtc needs modeset */
+       if (unlikely(drm_atomic_crtc_needs_modeset(state->crtc->state))) {
+               src_w = state->src_w >> 16;
+               WARN_ON(src_w > fb->width);
+
+               crop  = src_w != fb->width ? true : false;
+               lcdif_set_fb_hcrop(lcdif, src_w, fb->width, crop);
+       }
+
        lcdif_enable_controller(lcdif);
 }