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

Commit f76e6695 authored by Ramakant Singh's avatar Ramakant Singh
Browse files

msm: mdss: fix IOMMU fault in smart blit



Fix IOMMU falut in BG layer access when updown flip is enabled on
FG layer in smart blit. Adjust BG address using mdp_bg_adjust_rot_addr
function.

Change-Id: Ifbfdf1b10a7896a1e397d7f84b055b3719d4982c
Signed-off-by: default avatarRamakant Singh <ramaka@codeaurora.org>
parent c155f22a
Loading
Loading
Loading
Loading
+42 −24
Original line number Original line Diff line number Diff line
@@ -33,6 +33,13 @@
#define PQF_PLUS_5_PLUS_2     (PQF_PLUS_5 + 2)
#define PQF_PLUS_5_PLUS_2     (PQF_PLUS_5 + 2)
#define PQF_PLUS_5_MINUS_2    (PQF_PLUS_5 - 2)
#define PQF_PLUS_5_MINUS_2    (PQF_PLUS_5 - 2)


enum {
	LAYER_FG = 0,
	LAYER_BG,
	LAYER_FB,
	LAYER_MAX,
};

static long long mdp_do_div(long long num, long long den)
static long long mdp_do_div(long long num, long long den)
{
{
	do_div(num, den);
	do_div(num, den);
@@ -362,27 +369,37 @@ bool check_if_rgb(int color)
	return rgb;
	return rgb;
}
}


uint8_t *mdp_dst_adjust_rot_addr(struct ppp_blit_op *iBuf,
uint8_t *mdp_adjust_rot_addr(struct ppp_blit_op *iBuf,
	uint8_t *addr, uint32_t bpp, uint32_t uv)
	uint8_t *addr, uint32_t bpp, uint32_t uv, uint32_t layer)
{
{
	uint32_t dest_ystride = iBuf->dst.prop.width * bpp;
	uint32_t ystride = 0;
	uint32_t h_slice = 1;
	uint32_t h_slice = 1;

	uint32_t roi_width = 0;
	if (uv && ((iBuf->dst.color_fmt == MDP_Y_CBCR_H2V2) ||
	uint32_t roi_height = 0;
		(iBuf->dst.color_fmt == MDP_Y_CRCB_H2V2)))
	uint32_t color_fmt = 0;

	if (layer == LAYER_BG) {
		ystride = iBuf->bg.prop.width * bpp;
		roi_width =  iBuf->bg.roi.width;
		roi_height = iBuf->bg.roi.height;
		color_fmt = iBuf->bg.color_fmt;
	} else {
		ystride = iBuf->dst.prop.width * bpp;
		roi_width =  iBuf->dst.roi.width;
		roi_height = iBuf->dst.roi.height;
		color_fmt = iBuf->dst.color_fmt;
	}
	if (uv && ((color_fmt == MDP_Y_CBCR_H2V2) ||
		(color_fmt == MDP_Y_CRCB_H2V2)))
		h_slice = 2;
		h_slice = 2;


	if (((iBuf->mdp_op & MDPOP_ROT90) == MDPOP_ROT90) ^
	if (((iBuf->mdp_op & MDPOP_ROT90) == MDPOP_ROT90) ^
		((iBuf->mdp_op & MDPOP_LR) == MDPOP_LR)) {
		((iBuf->mdp_op & MDPOP_LR) == MDPOP_LR)) {
		addr +=
		addr += (roi_width - MIN(16, roi_width)) * bpp;
		    (iBuf->dst.roi.width -
			    MIN(16, iBuf->dst.roi.width)) * bpp;
	}
	}
	if ((iBuf->mdp_op & MDPOP_UD) == MDPOP_UD) {
	if ((iBuf->mdp_op & MDPOP_UD) == MDPOP_UD) {
		addr +=
		addr += ((roi_height - MIN(16, roi_height))/h_slice) *
			((iBuf->dst.roi.height -
			ystride;
			MIN(16, iBuf->dst.roi.height))/h_slice) *
			dest_ystride;
	}
	}


	return addr;
	return addr;
@@ -390,7 +407,7 @@ uint8_t *mdp_dst_adjust_rot_addr(struct ppp_blit_op *iBuf,


void mdp_adjust_start_addr(struct ppp_blit_op *blit_op,
void mdp_adjust_start_addr(struct ppp_blit_op *blit_op,
	struct ppp_img_desc *img, int v_slice,
	struct ppp_img_desc *img, int v_slice,
	int h_slice, int layer)
	int h_slice, uint32_t layer)
{
{
	uint32_t bpp = ppp_bpp(img->color_fmt);
	uint32_t bpp = ppp_bpp(img->color_fmt);
	int x = img->roi.x;
	int x = img->roi.x;
@@ -403,8 +420,8 @@ void mdp_adjust_start_addr(struct ppp_blit_op *blit_op,
		img->p0 += (x + y * ALIGN(width, 128)) * bpp;
		img->p0 += (x + y * ALIGN(width, 128)) * bpp;
	else
	else
		img->p0 += (x + y * width) * bpp;
		img->p0 += (x + y * width) * bpp;
	if (layer != 0)
	if (layer != LAYER_FG)
		img->p0 = mdp_dst_adjust_rot_addr(blit_op, img->p0, bpp, 0);
		img->p0 = mdp_adjust_rot_addr(blit_op, img->p0, bpp, 0, layer);


	if (img->p1) {
	if (img->p1) {
		/*
		/*
@@ -421,9 +438,9 @@ void mdp_adjust_start_addr(struct ppp_blit_op *blit_op,
			img->p1 += ((x / h_slice) * h_slice +
			img->p1 += ((x / h_slice) * h_slice +
			((y == 0) ? 0 : ((y + 1) / v_slice - 1) * width)) * bpp;
			((y == 0) ? 0 : ((y + 1) / v_slice - 1) * width)) * bpp;


		if (layer != 0)
		if (layer != LAYER_FG)
			img->p0 = mdp_dst_adjust_rot_addr(blit_op,
			img->p0 = mdp_adjust_rot_addr(blit_op,
					img->p0, bpp, 0);
					img->p0, bpp, 0, layer);
	}
	}
}
}


@@ -1202,11 +1219,12 @@ int config_ppp_op_mode(struct ppp_blit_op *blit_op)
	}
	}
	/* Jumping from Y-Plane to Chroma Plane */
	/* Jumping from Y-Plane to Chroma Plane */
	/* first pixel addr calculation */
	/* first pixel addr calculation */
	mdp_adjust_start_addr(blit_op, &blit_op->src, sv_slice, sh_slice, 0);
	mdp_adjust_start_addr(blit_op, &blit_op->src, sv_slice,
	/* Adjust BG start address for Non SMART Blit*/
			      sh_slice, LAYER_FG);
	if (blit_op->bg.p0 == blit_op->dst.p0)
	mdp_adjust_start_addr(blit_op, &blit_op->bg, dv_slice,
		mdp_adjust_start_addr(blit_op, &blit_op->bg, dv_slice, dh_slice, 1);
			      dh_slice, LAYER_BG);
	mdp_adjust_start_addr(blit_op, &blit_op->dst, dv_slice, dh_slice, 2);
	mdp_adjust_start_addr(blit_op, &blit_op->dst, dv_slice,
			      dh_slice, LAYER_FB);


        /* Cache smart blit BG layer info */
        /* Cache smart blit BG layer info */
	if (blit_op->mdp_op & MDPOP_SMART_BLIT)
	if (blit_op->mdp_op & MDPOP_SMART_BLIT)