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

Commit 46658a13 authored by Jayant Shekhar's avatar Jayant Shekhar Committed by Gerrit - the friendly Code Review server
Browse files

msm: mdss: Generalize per pipe bw limit implementation



Currently per pipe bandwidth limit implementation takes
care of only HFLip and VFLip case. Make it generic such
that it takes care of Camera usecase as well.

Change-Id: I6642bdb0611aa973a7563df019bf2dcdd5e4e584
Signed-off-by: default avatarJayant Shekhar <jshekhar@codeaurora.org>
parent ac6766f8
Loading
Loading
Loading
Loading
+23 −37
Original line number Diff line number Diff line
@@ -1475,29 +1475,20 @@ int mdss_mdp_perf_bw_check(struct mdss_mdp_ctl *ctl,
	return 0;
}

static u32 mdss_mdp_get_bw_by_mode(struct mdss_max_bw_settings *settings,
					int count, int key)
{
	u32 value = 0, i = 0;

	while (i < count) {
		if (settings[i].mdss_max_bw_mode == key) {
			value = settings[i].mdss_max_bw_val;
			break;
		}
		++i;
	}
	return value;
}

static u32 mdss_mdp_get_max_pipe_bw(struct mdss_mdp_pipe *pipe)
{

	struct mdss_data_type *mdata = pipe->mixer_left->ctl->mdata;
	struct mdss_mdp_ctl *ctl = pipe->mixer_left->ctl;
	struct mdss_max_bw_settings *max_per_pipe_bw_settings;
	u32 flags = 0, threshold = 0, panel_orientation;
	u32 i, max = INT_MAX;

	if (!ctl->mdata->mdss_per_pipe_bw_cnt
			&& !ctl->mdata->max_per_pipe_bw_settings)
		return 0;

	panel_orientation = ctl->mfd->panel_orientation;
	max_per_pipe_bw_settings = ctl->mdata->max_per_pipe_bw_settings;

	/* Check for panel orienatation */
	panel_orientation = ctl->mfd->panel_orientation;
@@ -1512,22 +1503,17 @@ static u32 mdss_mdp_get_max_pipe_bw(struct mdss_mdp_pipe *pipe)
	if (pipe->flags & MDP_FLIP_UD)
		flags |= MDSS_MAX_BW_LIMIT_VFLIP;

	if ((flags & MDSS_MAX_BW_LIMIT_HFLIP) &&
			(flags &  MDSS_MAX_BW_LIMIT_VFLIP)) {
		threshold = mdata->min_bw_per_pipe;
	} else if (flags & MDSS_MAX_BW_LIMIT_HFLIP) {
		threshold = mdss_mdp_get_bw_by_mode(
					mdata->max_per_pipe_bw_settings,
					mdata->mdss_per_pipe_bw_cnt,
					MDSS_MAX_BW_LIMIT_HFLIP);
	} else if (flags & MDSS_MAX_BW_LIMIT_VFLIP) {
		threshold = mdss_mdp_get_bw_by_mode(
					mdata->max_per_pipe_bw_settings,
					mdata->mdss_per_pipe_bw_cnt,
					MDSS_MAX_BW_LIMIT_VFLIP);
	flags |= ctl->mdata->bw_mode_bitmap;

	for (i = 0; i < ctl->mdata->mdss_per_pipe_bw_cnt; i++) {
		if (max_per_pipe_bw_settings[i].mdss_max_bw_mode & flags) {
			threshold = max_per_pipe_bw_settings[i].mdss_max_bw_val;
			if (threshold < max)
				max = threshold;
		}
	}

	return threshold ? threshold : mdata->max_bw_per_pipe;
	return max;
}

int mdss_mdp_perf_bw_check_pipe(struct mdss_mdp_perf_params *perf,
@@ -1536,7 +1522,7 @@ int mdss_mdp_perf_bw_check_pipe(struct mdss_mdp_perf_params *perf,
	struct mdss_data_type *mdata = pipe->mixer_left->ctl->mdata;
	struct mdss_mdp_ctl *ctl = pipe->mixer_left->ctl;
	u32 vbp_fac, threshold;
	u64 prefill_bw, pipe_bw;
	u64 prefill_bw, pipe_bw, max_pipe_bw;

	/* we only need bandwidth check on real-time clients (interfaces) */
	if (ctl->intf_type == MDSS_MDP_NO_INTF)
@@ -1555,11 +1541,11 @@ int mdss_mdp_perf_bw_check_pipe(struct mdss_mdp_perf_params *perf,
	/* convert bandwidth to kb */
	pipe_bw = DIV_ROUND_UP_ULL(pipe_bw, 1000);


	if (!mdata->max_per_pipe_bw_settings)
	threshold = mdata->max_bw_per_pipe;
	else
		threshold = mdss_mdp_get_max_pipe_bw(pipe);
	max_pipe_bw = mdss_mdp_get_max_pipe_bw(pipe);

	if (max_pipe_bw && (max_pipe_bw < threshold))
		threshold = max_pipe_bw;

	pr_debug("bw=%llu threshold=%u\n", pipe_bw, threshold);