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)
This commit is contained in:
Fancy Fang 2018-08-10 12:22:18 +08:00 committed by Dong Aisheng
parent 9f54662720
commit 730377db70

View File

@ -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);