diff options
author | Fancy Fang <chen.fang@nxp.com> | 2018-08-10 12:22:18 +0800 |
---|---|---|
committer | Dong Aisheng <aisheng.dong@nxp.com> | 2019-11-25 15:59:23 +0800 |
commit | 730377db70f760bb4ca2e1267eaf11f3fd08badc (patch) | |
tree | a034d371352ae00e18e8afcfa3bf969ee6a51c11 /drivers | |
parent | 9f54662720967973a21f2f9f721823aa888fa031 (diff) |
MLK-19199 drm/imx: lcdif: replace FB width usage for cropping
According to the comments of 'struct drm_framebuffer', its
'width' field refers to the logical width of the visible
area of the framebuffer. This may be unequal to the total
pixels number of a line. So use the 'pitches' field to
replace 'width' for the horizontal cropping feature.
Signed-off-by: Fancy Fang <chen.fang@nxp.com>
(cherry picked from commit 9a2bbbf971ed79b32ae1c7da2d62b8a72f3ccffd)
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/drm/imx/lcdif/lcdif-plane.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/drivers/gpu/drm/imx/lcdif/lcdif-plane.c b/drivers/gpu/drm/imx/lcdif/lcdif-plane.c index 370d46c407b6..13e690c98acb 100644 --- a/drivers/gpu/drm/imx/lcdif/lcdif-plane.c +++ b/drivers/gpu/drm/imx/lcdif/lcdif-plane.c @@ -95,12 +95,12 @@ static int lcdif_plane_atomic_check(struct drm_plane *plane, if (!plane_state->visible) return -EINVAL; - /* force 'mode_changed' when fb width changed, since + /* force 'mode_changed' when fb pitches changed, since * the pitch related registers configuration of LCDIF * can not be done when LCDIF is running. */ if (old_fb && likely(!crtc_state->mode_changed)) { - if (old_fb->width != fb->width) + if (old_fb->pitches[0] != fb->pitches[0]) crtc_state->mode_changed = true; } @@ -115,7 +115,7 @@ 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, src_w, fb_idx; + u32 fb_addr, src_off, src_w, fb_idx, cpp, stride; bool crop; /* plane and crtc is disabling */ @@ -147,11 +147,14 @@ static void lcdif_plane_atomic_update(struct drm_plane *plane, /* config horizontal cropping if crtc needs modeset */ if (unlikely(drm_atomic_crtc_needs_modeset(state->crtc->state))) { + cpp = fb->format->cpp[0]; + stride = DIV_ROUND_UP(fb->pitches[0], cpp); + 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); + crop = src_w != stride ? true : false; + lcdif_set_fb_hcrop(lcdif, src_w, stride, crop); } lcdif_enable_controller(lcdif); |