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

Commit 1d69a535 authored by Jeykumar Sankaran's avatar Jeykumar Sankaran
Browse files

msm: mdss: Parse fixed MMB's for VIG pipes



Similar to RGB fixed MMB's, msm8994 reserves fixed MMB's for VIG pipes too.
Parse fixed MMB allocation for VIG pipes from device tree and update
MMB alloc map.

Change-Id: Ie7c7dea77fe8a2afc6bfeffdb5d7f69c48b802cd
Signed-off-by: default avatarJeykumar Sankaran <jsanka@codeaurora.org>
parent 38fb8d37
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -289,6 +289,11 @@ Optional properties:
				total numbers of MMBs per pipe while values, if
				any, following first one denotes indexes of MMBs
				to that RGB pipe.
- qcom,mdss-pipe-vig-fixed-mmb: Array of indexes describing fixed Memory Macro
				Blocks (MMBs) for vig pipes. First value denotes
				total numbers of MMBs per pipe while values, if
				any, following first one denotes indexes of MMBs
				to that VIG pipe.
- qcom,mdss-pipe-sw-reset-off: Property to indicate offset to the register which
			       holds sw_reset bitmap for different MDSS
			       components.
@@ -472,6 +477,10 @@ Example:
						<2 2 3>,
						<2 4 5>,
						<2 6 7>;
		qcom,mdss-pipe-vig-fixed-mmb =	<1 8>,
						<1 9>,
						<1 10>,
						<1 11>;
		qcom,mdss-smp-data = <22 4096>;
		qcom,mdss-rot-block-size = <64>;
		qcom,mdss-rotator-ot-limit = <2>;
+57 −35
Original line number Diff line number Diff line
@@ -2215,6 +2215,50 @@ parse_fail:
	return rc;
}

static int mdss_mdp_update_smp_map(struct platform_device *pdev,
		const u32 *data, int len, int pipe_cnt,
		struct mdss_mdp_pipe *pipes)
{
	struct mdss_data_type *mdata = platform_get_drvdata(pdev);
	int i, j, k;
	u32 cnt, mmb;

	len /= sizeof(u32);
	for (i = 0, k = 0; i < len; k++) {
		struct mdss_mdp_pipe *pipe = NULL;

		if (k >= pipe_cnt) {
			pr_err("invalid fixed mmbs\n");
			return -EINVAL;
		}

		pipe = &pipes[k];

		cnt = be32_to_cpu(data[i++]);
		if (cnt == 0)
			continue;

		for (j = 0; j < cnt; j++) {
			mmb = be32_to_cpu(data[i++]);
			if (mmb > mdata->smp_mb_cnt) {
				pr_err("overflow mmb:%d pipe:%d: max:%d\n",
						mmb, k, mdata->smp_mb_cnt);
				return -EINVAL;
			}
			set_bit(mmb, pipe->smp_map[0].fixed);
		}
		if (bitmap_intersects(pipe->smp_map[0].fixed,
					mdata->mmb_alloc_map,
					mdata->smp_mb_cnt)) {
			pr_err("overlapping fixed mmb map\n");
			return -EINVAL;
		}
		bitmap_or(mdata->mmb_alloc_map, pipe->smp_map[0].fixed,
				mdata->mmb_alloc_map, mdata->smp_mb_cnt);
	}
	return 0;
}

static int mdss_mdp_parse_dt_smp(struct platform_device *pdev)
{
	struct mdss_data_type *mdata = platform_get_drvdata(pdev);
@@ -2247,44 +2291,22 @@ static int mdss_mdp_parse_dt_smp(struct platform_device *pdev)
	arr = of_get_property(pdev->dev.of_node,
			"qcom,mdss-pipe-rgb-fixed-mmb", &len);
	if (arr) {
		int i, j, k;
		u32 cnt, mmb;

		len /= sizeof(u32);
		for (i = 0, k = 0; i < len; k++) {
			struct mdss_mdp_pipe *pipe = NULL;
		rc = mdss_mdp_update_smp_map(pdev, arr, len,
				mdata->nrgb_pipes, mdata->rgb_pipes);

			if (k >= mdata->nrgb_pipes) {
				pr_err("invalid fixed mmbs for rgb pipes\n");
				return -EINVAL;
		if (rc)
			pr_warn("unable to update smp map for RGB pipes\n");
	}

			pipe = &mdata->rgb_pipes[k];

			cnt = be32_to_cpu(arr[i++]);
			if (cnt == 0)
				continue;
	arr = of_get_property(pdev->dev.of_node,
			"qcom,mdss-pipe-vig-fixed-mmb", &len);
	if (arr) {
		rc = mdss_mdp_update_smp_map(pdev, arr, len,
				mdata->nvig_pipes, mdata->vig_pipes);

			for (j = 0; j < cnt; j++) {
				mmb = be32_to_cpu(arr[i++]);
				if (mmb > mdata->smp_mb_cnt) {
					pr_err("overflow mmb%d: rgb%d: max%d\n",
						mmb, k, mdata->smp_mb_cnt);
					return -EINVAL;
				}
				/* rgb pipes fetches only single plane */
				set_bit(mmb, pipe->smp_map[0].fixed);
			}
			if (bitmap_intersects(pipe->smp_map[0].fixed,
				mdata->mmb_alloc_map, mdata->smp_mb_cnt)) {
				pr_err("overlapping fixed mmb map\n");
				return -EINVAL;
			}
			bitmap_or(mdata->mmb_alloc_map, pipe->smp_map[0].fixed,
				mdata->mmb_alloc_map, mdata->smp_mb_cnt);
		}
		if (rc)
			pr_warn("unable to update smp map for VIG pipes\n");
	}

	return rc;
}