From 2edabfb2562a8899b7f00194f536a6f6bef0cc8b Mon Sep 17 00:00:00 2001 From: Damon Ding Date: Tue, 13 Dec 2022 11:04:42 +0800 Subject: [PATCH] drm/rockchip: vop: Use clipped src/dst coordinates Some linux app(cusor) may set negative coordinates(crtc_x/y) And some linux app(mpv) may set coordinates outside the screen. These are both unsupported on rockchip vop. so we use clipped coordinates here. Signed-off-by: Andy Yan Signed-off-by: Damon Ding Change-Id: Id2322113f0973271997575678cda478a9987266b --- drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 35 ++++++++++++--------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c index d7ea1f80ea12..96099755633f 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c @@ -1758,14 +1758,6 @@ static int vop_plane_atomic_check(struct drm_plane *plane, if (WARN_ON(!crtc_state)) return -EINVAL; - src->x1 = state->src_x; - src->y1 = state->src_y; - src->x2 = state->src_x + state->src_w; - src->y2 = state->src_y + state->src_h; - dest->x1 = state->crtc_x; - dest->y1 = state->crtc_y; - dest->x2 = state->crtc_x + state->crtc_w; - dest->y2 = state->crtc_y + state->crtc_h; vop_plane_state->zpos = state->zpos; vop_plane_state->blend_mode = state->pixel_blend_mode; @@ -1775,8 +1767,22 @@ static int vop_plane_atomic_check(struct drm_plane *plane, if (ret) return ret; - if (!state->visible) + if (!state->visible) { + DRM_ERROR("%s is invisible(src: pos[%d, %d] rect[%d x %d] dst: pos[%d, %d] rect[%d x %d]\n", + plane->name, state->src_x >> 16, state->src_y >> 16, state->src_w >> 16, + state->src_h >> 16, state->crtc_x, state->crtc_y, state->crtc_w, + state->crtc_h); return 0; + } + + src->x1 = state->src.x1; + src->y1 = state->src.y1; + src->x2 = state->src.x2; + src->y2 = state->src.y2; + dest->x1 = state->dst.x1; + dest->y1 = state->dst.y1; + dest->x2 = state->dst.x2; + dest->y2 = state->dst.y2; vop_plane_state->format = vop_convert_format(fb->format->format); if (vop_plane_state->format < 0) @@ -1785,12 +1791,13 @@ static int vop_plane_atomic_check(struct drm_plane *plane, vop = to_vop(crtc); vop_data = vop->data; - if (state->src_w >> 16 < 4 || state->src_h >> 16 < 4 || - state->crtc_w < 4 || state->crtc_h < 4) { + if (drm_rect_width(src) >> 16 < 4 || drm_rect_height(src) >> 16 < 4 || + drm_rect_width(dest) < 4 || drm_rect_width(dest) < 4) { DRM_ERROR("Invalid size: %dx%d->%dx%d, min size is 4x4\n", - state->src_w >> 16, state->src_h >> 16, - state->crtc_w, state->crtc_h); - return -EINVAL; + drm_rect_width(src) >> 16, drm_rect_height(src) >> 16, + drm_rect_width(dest), drm_rect_height(dest)); + state->visible = false; + return 0; } if (drm_rect_width(src) >> 16 > vop_data->max_input.width ||