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

Commit 16ce5906 authored by Ingrid Gallardo's avatar Ingrid Gallardo Committed by Kyle Yan
Browse files

msm: mdss: fix amortized prefill calculations



Fix wrong calculation for the amortized prefill
parameters to use destination coordiates as well
as adjust ts_count denominators for the correct
units, also make sure vsync clock is enabled.
It was causing problem when feature was enabled.

Change-Id: I62a3bd31997be05181de98307089e2a69d98ab7b
Signed-off-by: default avatarIngrid Gallardo <ingridg@codeaurora.org>
parent 7d2526e5
Loading
Loading
Loading
Loading
+25 −10
Original line number Diff line number Diff line
@@ -45,6 +45,8 @@
#define QSEED3_DEFAULT_PRELAOD_H  0x4
#define QSEED3_DEFAULT_PRELAOD_V  0x3

#define TS_CLK 19200000

static DEFINE_MUTEX(mdss_mdp_sspp_lock);
static DEFINE_MUTEX(mdss_mdp_smp_lock);

@@ -2375,7 +2377,7 @@ bool mdss_mdp_is_amortizable_pipe(struct mdss_mdp_pipe *pipe,
	struct mdss_mdp_mixer *mixer, struct mdss_data_type *mdata)
{
	/* do not apply for rotator or WB */
	return ((pipe->src.y > mdata->prefill_data.ts_threshold) &&
	return ((pipe->dst.y > mdata->prefill_data.ts_threshold) &&
		(mixer->type == MDSS_MDP_MIXER_TYPE_INTF));
}

@@ -2393,7 +2395,7 @@ static inline void __get_ordered_rects(struct mdss_mdp_pipe *pipe,
	*high_pipe = pipe->multirect.next;

	/* if pipes are not in order, order them according to position */
	if ((*low_pipe)->src.y > (*high_pipe)->src.y) {
	if ((*low_pipe)->dst.y > (*high_pipe)->dst.y) {
		*low_pipe = pipe->multirect.next;
		*high_pipe = pipe;
	}
@@ -2403,7 +2405,7 @@ static u32 __get_ts_count(struct mdss_mdp_pipe *pipe,
	struct mdss_mdp_mixer *mixer, bool is_low_pipe)
{
	struct mdss_data_type *mdata = mdss_mdp_get_mdata();
	u32 ts_diff, ts_ypos;
	u32 ts_diff, ts_ypos, rate_factor;
	struct mdss_mdp_pipe *low_pipe, *high_pipe;
	u32 ts_count = 0;
	u32 v_total, fps, h_total, xres;
@@ -2419,8 +2421,10 @@ static u32 __get_ts_count(struct mdss_mdp_pipe *pipe,
		if (mdss_mdp_is_amortizable_pipe(pipe, mixer, mdata)) {
			ts_diff = mdata->prefill_data.ts_threshold -
					mdata->prefill_data.ts_end;
			ts_ypos = pipe->src.y - ts_diff;
			ts_count = mult_frac(ts_ypos, 19200000, fps * v_total);
			ts_ypos = pipe->dst.y - ts_diff;
			rate_factor = TS_CLK / fps;
			ts_count = mult_frac(ts_ypos, rate_factor, v_total);
			MDSS_XLOG(ts_diff, ts_ypos, rate_factor, ts_count);
		}
	} else { /* high pipe */

@@ -2428,8 +2432,10 @@ static u32 __get_ts_count(struct mdss_mdp_pipe *pipe,
		if (pipe &&
		    pipe->multirect.mode == MDSS_MDP_PIPE_MULTIRECT_SERIAL) {
			__get_ordered_rects(pipe, &low_pipe, &high_pipe);
			ts_count = high_pipe->src.y - low_pipe->src.y - 1;
			ts_count = mult_frac(ts_count, 19200000, fps * v_total);
			ts_ypos = high_pipe->dst.y - low_pipe->dst.y - 1;
			rate_factor = TS_CLK / fps;
			ts_count = mult_frac(ts_ypos, rate_factor, v_total);
			MDSS_XLOG(ts_ypos, rate_factor, ts_count);
		}
	}

@@ -2446,7 +2452,14 @@ static u32 __calc_ts_bytes(struct mdss_rect *src, u32 fps, u32 bpp)
	ts_bytes = mult_frac(ts_bytes,
		mdata->prefill_data.ts_rate.numer,
		mdata->prefill_data.ts_rate.denom);
	ts_bytes /= 19200000;
	ts_bytes = DIV_ROUND_UP(ts_bytes, TS_CLK);

	pr_debug("ts:%d, w:%d h:%d fps:%d bpp:%d\n", ts_bytes,
		src->w, src->h, fps, bpp);
	MDSS_XLOG(ts_bytes, src->w, src->h, fps, bpp);

	if (ts_bytes == 0)
		ts_bytes = 1;

	return ts_bytes;
}
@@ -2513,9 +2526,9 @@ static u32 __get_ts_bytes(struct mdss_mdp_pipe *pipe,
		/* amortize depending on the lower pipe amortization */
		if (mdss_mdp_is_amortizable_pipe(low_pipe, mixer, mdata))
			ts_bytes = DIV_ROUND_UP_ULL(max(low_pipe_bw,
				high_pipe_bw), 19200000);
				high_pipe_bw), TS_CLK);
		else
			ts_bytes = DIV_ROUND_UP_ULL(high_pipe_bw, 19200000);
			ts_bytes = DIV_ROUND_UP_ULL(high_pipe_bw, TS_CLK);
		break;
	default:
		pr_err("unknown multirect mode!\n");
@@ -2570,6 +2583,8 @@ static int mdss_mdp_set_ts_pipe(struct mdss_mdp_pipe *pipe)
		ts_rec1 = ts_count_low;
	}

	mdss_mdp_vsync_clk_enable(1, false);

	mdss_mdp_pipe_qos_ctrl(pipe, false, MDSS_MDP_PIPE_QOS_VBLANK_AMORTIZE);
	mdss_mdp_pipe_write(pipe, MDSS_MDP_REG_SSPP_TRAFFIC_SHAPER, ts_bytes);
	mdss_mdp_pipe_write(pipe, MDSS_MDP_REG_SSPP_TRAFFIC_SHAPER_PREFILL,