drm/rockchip: vop2: 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.

Change-Id: I63288cf9120cea75e784d49bc88b591f243e7d8d
Signed-off-by: Andy Yan <andy.yan@rock-chips.com>
This commit is contained in:
Andy Yan
2021-08-25 09:55:32 +08:00
committed by Tao Huang
parent e0354482bd
commit 1d9acc4e67

View File

@@ -2804,15 +2804,6 @@ static int vop2_plane_atomic_check(struct drm_plane *plane, struct drm_plane_sta
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;
ret = drm_atomic_helper_check_plane_state(state, cstate,
min_scale, max_scale,
@@ -2820,8 +2811,22 @@ static int vop2_plane_atomic_check(struct drm_plane *plane, struct drm_plane_sta
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;
vpstate->zpos = state->zpos;
vpstate->global_alpha = state->alpha >> 8;
@@ -2830,12 +2835,13 @@ static int vop2_plane_atomic_check(struct drm_plane *plane, struct drm_plane_sta
if (vpstate->format < 0)
return vpstate->format;
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 > vop2_data->max_input.width ||