Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 263945b9 authored by Veera Sundaram Sankaran's avatar Veera Sundaram Sankaran Committed by Gerrit - the friendly Code Review server
Browse files

drm/msm/sde: fix excl_rect overlap validation



Allow layer with exclusion rect, if there is an overlapping
layer above or below, covering the entire exclusion
rect region. Add more information for failure cases to help
in debugging.

Change-Id: If1b4eff8f99db354e6fc08180f6ac06adfe43705
Signed-off-by: default avatarVeera Sundaram Sankaran <veeras@codeaurora.org>
parent 550dfae1
Loading
Loading
Loading
Loading
+21 −8
Original line number Original line Diff line number Diff line
@@ -4493,28 +4493,41 @@ static int pstate_cmp(const void *a, const void *b)
}
}


static int _sde_crtc_excl_rect_overlap_check(struct plane_state pstates[],
static int _sde_crtc_excl_rect_overlap_check(struct plane_state pstates[],
	int cnt, int curr_cnt, struct sde_rect *excl_rect, int z_pos)
	int cnt, int curr_cnt, struct sde_rect *excl_rect)
{
{
	struct sde_rect dst_rect, intersect;
	struct sde_rect dst_rect, intersect;
	int i, rc = -EINVAL;
	int i, rc = -EINVAL;
	const struct drm_plane_state *pstate;
	const struct drm_plane_state *pstate;


	/* start checking from next plane */
	for (i = 0; i < cnt; i++) {
	for (i = curr_cnt; i < cnt; i++) {
		if (i == curr_cnt)
			continue;

		pstate = pstates[i].drm_pstate;
		pstate = pstates[i].drm_pstate;
		POPULATE_RECT(&dst_rect, pstate->crtc_x, pstate->crtc_y,
		POPULATE_RECT(&dst_rect, pstate->crtc_x, pstate->crtc_y,
				pstate->crtc_w, pstate->crtc_h, false);
				pstate->crtc_w, pstate->crtc_h, false);
		sde_kms_rect_intersect(&dst_rect, excl_rect, &intersect);
		sde_kms_rect_intersect(&dst_rect, excl_rect, &intersect);


		/* complete intersection of excl_rect is required */
		if (intersect.w == excl_rect->w && intersect.h == excl_rect->h
		if (intersect.w == excl_rect->w && intersect.h == excl_rect->h
				/* next plane may be on same z-order */
			    /* intersecting rect should be in another z_order */
				&& z_pos != pstates[i].stage) {
			    && pstates[curr_cnt].stage != pstates[i].stage) {
			rc = 0;
			rc = 0;
			goto end;
			goto end;
		}
		}
	}
	}


	SDE_ERROR("excl rect does not find top overlapping rect\n");
	SDE_ERROR(
	    "no overlapping rect for [%d] z_pos:%d, excl_rect:{%d,%d,%d,%d}\n",
			i, pstates[curr_cnt].stage,
			excl_rect->x, excl_rect->y, excl_rect->w, excl_rect->h);
	for (i = 0; i < cnt; i++) {
		pstate = pstates[i].drm_pstate;
		SDE_ERROR("[%d] p:%d, z_pos:%d, src:{%d,%d,%d,%d}\n",
				i, pstate->plane->base.id, pstates[i].stage,
				pstate->crtc_x, pstate->crtc_y,
				pstate->crtc_w, pstate->crtc_h);
	}
end:
end:
	return rc;
	return rc;
}
}
@@ -4556,9 +4569,9 @@ static int _sde_crtc_excl_dim_layer_check(struct drm_crtc_state *state,
		pstate = pstates[i].drm_pstate;
		pstate = pstates[i].drm_pstate;
		sde_pstate = to_sde_plane_state(pstate);
		sde_pstate = to_sde_plane_state(pstate);
		if (sde_pstate->excl_rect.w && sde_pstate->excl_rect.h) {
		if (sde_pstate->excl_rect.w && sde_pstate->excl_rect.h) {
			/* check overlap on all top z-order */
			/* check overlap on any other z-order */
			rc = _sde_crtc_excl_rect_overlap_check(pstates, cnt,
			rc = _sde_crtc_excl_rect_overlap_check(pstates, cnt,
			     i + 1, &sde_pstate->excl_rect, pstates[i].stage);
			     i, &sde_pstate->excl_rect);
			if (rc)
			if (rc)
				goto end;
				goto end;
		}
		}