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

Commit 6494f48c authored by Adrian Salido-Moreno's avatar Adrian Salido-Moreno
Browse files

msm: mdss: refactor pipe type checks



There are multiple places in code where pipe type checks are being
done based on the pipe number. With the ids not being sequential this
can be tricky, so add some helper functions to correctly identify pipe
types and use these instead.

CRs-Fixed: 987777
Change-Id: Ie3e5bdd905527dc1e572ca91399b4686d21ae266
Signed-off-by: default avatarAdrian Salido-Moreno <adrianm@codeaurora.org>
parent 8c0206a3
Loading
Loading
Loading
Loading
+59 −1
Original line number Diff line number Diff line
@@ -113,13 +113,71 @@ enum mdss_mdp_mixer_mux {
};

enum mdss_mdp_pipe_type {
	MDSS_MDP_PIPE_TYPE_UNUSED,
	MDSS_MDP_PIPE_TYPE_INVALID,
	MDSS_MDP_PIPE_TYPE_VIG,
	MDSS_MDP_PIPE_TYPE_RGB,
	MDSS_MDP_PIPE_TYPE_DMA,
	MDSS_MDP_PIPE_TYPE_CURSOR,
};

static inline enum mdss_mdp_sspp_index get_pipe_num_from_ndx(u32 ndx)
{
	u32 id;

	if (unlikely(!ndx))
		return MDSS_MDP_MAX_SSPP;

	id = fls(ndx) - 1;

	if (unlikely(ndx ^ BIT(id)))
		return MDSS_MDP_MAX_SSPP;

	return id;
}

static inline enum mdss_mdp_pipe_type
get_pipe_type_from_num(enum mdss_mdp_sspp_index pnum)
{
	enum mdss_mdp_pipe_type ptype;

	switch (pnum) {
	case MDSS_MDP_SSPP_VIG0:
	case MDSS_MDP_SSPP_VIG1:
	case MDSS_MDP_SSPP_VIG2:
	case MDSS_MDP_SSPP_VIG3:
		ptype = MDSS_MDP_PIPE_TYPE_VIG;
		break;
	case MDSS_MDP_SSPP_RGB0:
	case MDSS_MDP_SSPP_RGB1:
	case MDSS_MDP_SSPP_RGB2:
	case MDSS_MDP_SSPP_RGB3:
		ptype = MDSS_MDP_PIPE_TYPE_RGB;
		break;
	case MDSS_MDP_SSPP_DMA0:
	case MDSS_MDP_SSPP_DMA1:
		ptype = MDSS_MDP_PIPE_TYPE_DMA;
		break;
	case MDSS_MDP_SSPP_CURSOR0:
	case MDSS_MDP_SSPP_CURSOR1:
		ptype = MDSS_MDP_PIPE_TYPE_CURSOR;
		break;
	default:
		ptype = MDSS_MDP_PIPE_TYPE_INVALID;
		break;
	}

	return ptype;
}

static inline enum mdss_mdp_pipe_type get_pipe_type_from_ndx(u32 ndx)
{
	enum mdss_mdp_sspp_index pnum;

	pnum = get_pipe_num_from_ndx(ndx);

	return get_pipe_type_from_num(pnum);
}

enum mdss_mdp_block_type {
	MDSS_MDP_BLOCK_UNUSED,
	MDSS_MDP_BLOCK_SSPP,
+11 −25
Original line number Diff line number Diff line
@@ -36,16 +36,9 @@
#define CHECK_LAYER_BOUNDS(offset, size, max_size) \
	(((size) > (max_size)) || ((offset) > ((max_size) - (size))))

#define IS_PIPE_TYPE_CURSOR(pipe_ndx) \
	((pipe_ndx >= (1 << MDSS_MDP_SSPP_CURSOR0)) &&\
	(pipe_ndx <= (1 << MDSS_MDP_SSPP_CURSOR1)))

#define IS_PIPE_TYPE_DMA(pipe_ndx) \
	((pipe_ndx >= (1 << MDSS_MDP_SSPP_DMA0)) &&\
	(pipe_ndx <= (1 << MDSS_MDP_SSPP_DMA1)))

#define SCALER_ENABLED \
	(MDP_LAYER_ENABLE_PIXEL_EXT | MDP_LAYER_ENABLE_QSEED3_SCALE)

enum {
	MDSS_MDP_RELEASE_FENCE = 0,
	MDSS_MDP_RETIRE_FENCE,
@@ -75,18 +68,6 @@ static bool __layer_needs_src_split(struct mdp_input_layer *layer)
	return layer->flags & MDP_LAYER_ASYNC;
}

static bool is_pipe_type_vig(struct mdss_data_type *mdata, u32 ndx)
{
	u32 i;

	for (i = 0; i < mdata->nvig_pipes; i++) {
		if (mdata->vig_pipes[i].ndx == ndx)
			break;
	}

	return i < mdata->nvig_pipes;
}

static int __async_update_position_check(struct msm_fb_data_type *mfd,
		struct mdss_mdp_pipe *pipe, struct mdp_point *src,
		struct mdp_point *dst)
@@ -370,11 +351,16 @@ static int __validate_single_layer(struct msm_fb_data_type *mfd,
	u32 bwc_enabled;
	int ret;
	bool is_vig_needed = false;

	struct mdss_mdp_format_params *fmt;
	struct mdss_mdp_mixer *mixer = NULL;
	struct mdss_overlay_private *mdp5_data = mfd_to_mdp5_data(mfd);
	struct mdss_data_type *mdata = mfd_to_mdata(mfd);
	int ptype = get_pipe_type_from_ndx(layer->pipe_ndx);

	if (ptype == MDSS_MDP_PIPE_TYPE_INVALID) {
		pr_err("Invalid pipe ndx=%d\n", layer->pipe_ndx);
		return -EINVAL;
	}

	if ((layer->dst_rect.w > mdata->max_mixer_width) ||
		(layer->dst_rect.h > MAX_DST_H)) {
@@ -416,7 +402,7 @@ static int __validate_single_layer(struct msm_fb_data_type *mfd,
		}
	}

	if (IS_PIPE_TYPE_CURSOR(layer->pipe_ndx)) {
	if (ptype == MDSS_MDP_PIPE_TYPE_CURSOR) {
		ret = __cursor_layer_check(mfd, layer);
		if (ret)
			goto exit_fail;
@@ -444,14 +430,14 @@ static int __validate_single_layer(struct msm_fb_data_type *mfd,
			(layer->src_rect.h != layer->dst_rect.h))))
		is_vig_needed = true;

	if (is_vig_needed && !is_pipe_type_vig(mdata, layer->pipe_ndx)) {
	if (is_vig_needed && ptype != MDSS_MDP_PIPE_TYPE_VIG) {
		pr_err("pipe is non-scalar ndx=%x\n", layer->pipe_ndx);
		ret = -EINVAL;
		goto exit_fail;
	}

	if ((IS_PIPE_TYPE_DMA(layer->pipe_ndx) ||
		IS_PIPE_TYPE_CURSOR(layer->pipe_ndx)) &&
	if (((ptype == MDSS_MDP_PIPE_TYPE_DMA) ||
		(ptype == MDSS_MDP_PIPE_TYPE_CURSOR)) &&
		(layer->dst_rect.h != layer->src_rect.h ||
		 layer->dst_rect.w != layer->src_rect.w)) {
		pr_err("no scaling supported on dma/cursor pipe, pipe num:%d\n",
+29 −37
Original line number Diff line number Diff line
@@ -529,6 +529,26 @@ inline int linear_map(int in, int *out, int in_max, int out_max)

}

/**
 * __get_hist_pipe() - get a pipe only if histogram is supported on it
 * @pnum: pipe number desired
 *
 * returns the pipe with id only if the pipe supports sspp histogram
 */
static inline struct mdss_mdp_pipe *__get_hist_pipe(int pnum)
{
	struct mdss_data_type *mdata = mdss_mdp_get_mdata();
	enum mdss_mdp_pipe_type ptype;

	ptype = get_pipe_type_from_num(pnum);

	/* only VIG pipes support histogram */
	if (ptype != MDSS_MDP_PIPE_TYPE_VIG)
		return NULL;

	return mdss_mdp_pipe_get(mdata, BIT(pnum));
}

int mdss_mdp_csc_setup_data(u32 block, u32 blk_idx, struct mdp_csc_cfg *data)
{
	int i, ret = 0;
@@ -2028,10 +2048,10 @@ static int pp_hist_setup(u32 *op, u32 block, struct mdss_mdp_mixer *mix)
		}
	} else if (PP_LOCAT(block) == MDSS_PP_SSPP_CFG &&
		(pp_driver_ops.is_sspp_hist_supp())) {
		pipe = mdss_mdp_pipe_get(mdata, BIT(PP_BLOCK(block)));
		pipe = __get_hist_pipe(PP_BLOCK(block));
		if (IS_ERR_OR_NULL(pipe)) {
			pr_debug("pipe DNE (%d)\n",
					(u32) BIT(PP_BLOCK(block)));
					(u32) PP_BLOCK(block));
			ret = -ENODEV;
			goto error;
		}
@@ -4643,16 +4663,9 @@ int mdss_mdp_hist_start(struct mdp_histogram_start_req *req)
		for (i = 0; i < MDSS_PP_ARG_NUM; i++) {
			if (!PP_ARG(i, req->block))
				continue;
			pipe = mdss_mdp_pipe_get(mdata, BIT(i));
			pipe = __get_hist_pipe(i);
			if (IS_ERR_OR_NULL(pipe))
				continue;
			if ((pipe->num > MDSS_MDP_SSPP_VIG2) &&
				(pipe->num != MDSS_MDP_SSPP_VIG3)) {
				ret = -EINVAL;
				pr_warn("Invalid Hist pipe (%d)\n", i);
				mdss_mdp_pipe_unmap(pipe);
				goto hist_stop_clk;
			}
			hist_info = &pipe->pp_res.hist;
			ret = pp_hist_enable(hist_info, req, NULL);
			intr_mask = 1 << hist_info->intr_shift;
@@ -4777,16 +4790,10 @@ int mdss_mdp_hist_stop(u32 block)
		for (i = 0; i < MDSS_PP_ARG_NUM; i++) {
			if (!PP_ARG(i, block))
				continue;
			pipe = mdss_mdp_pipe_get(mdata, BIT(i));
			pipe = __get_hist_pipe(i);
			if (IS_ERR_OR_NULL(pipe)) {
				pr_warn("Invalid Hist pipe (%d)\n", i);
				continue;
			} else if ((pipe->num > MDSS_MDP_SSPP_VIG2) &&
				(pipe->num != MDSS_MDP_SSPP_VIG3)) {
				mdss_mdp_pipe_unmap(pipe);
				pr_warn("Invalid Hist pipe (%d) pipe->num (%d)\n",
					i, pipe->num);
				continue;
			}
			hist_info = &pipe->pp_res.hist;
			ret = pp_hist_disable(hist_info);
@@ -5139,7 +5146,7 @@ int mdss_mdp_hist_collect(struct mdp_histogram_data *hist)
			}
		}

		pipe = mdss_mdp_pipe_get(mdata, BIT(pipe_num));
		pipe = __get_hist_pipe(pipe_num);
		if (IS_ERR_OR_NULL(pipe)) {
			pr_warn("Invalid starting hist pipe, %d\n", pipe_num);
			ret = -ENODEV;
@@ -5151,15 +5158,10 @@ int mdss_mdp_hist_collect(struct mdp_histogram_data *hist)
			if (!PP_ARG(i, hist->block))
				continue;
			pipe_cnt++;
			pipe = mdss_mdp_pipe_get(mdata, BIT(i));
			pipe = __get_hist_pipe(i);
			if (IS_ERR_OR_NULL(pipe)) {
				pr_warn("Invalid Hist pipe (%d)\n", i);
				continue;
			} else if ((pipe->num > MDSS_MDP_SSPP_VIG2) &&
				(pipe->num != MDSS_MDP_SSPP_VIG3)) {
				mdss_mdp_pipe_unmap(pipe);
				pr_warn("Invalid Hist pipe (%d)\n", i);
				continue;
			}
			hist_info = &pipe->pp_res.hist;
			mdss_mdp_pipe_unmap(pipe);
@@ -5168,15 +5170,10 @@ int mdss_mdp_hist_collect(struct mdp_histogram_data *hist)
			if (!PP_ARG(i, hist->block))
				continue;
			pipe_cnt++;
			pipe = mdss_mdp_pipe_get(mdata, BIT(i));
			pipe = __get_hist_pipe(i);
			if (IS_ERR_OR_NULL(pipe)) {
				pr_warn("Invalid Hist pipe (%d)\n", i);
				continue;
			} else if ((pipe->num > MDSS_MDP_SSPP_VIG2) &&
				(pipe->num != MDSS_MDP_SSPP_VIG3)) {
				mdss_mdp_pipe_unmap(pipe);
				pr_warn("Invalid Hist pipe (%d)\n", i);
				continue;
			}
			hist_info = &pipe->pp_res.hist;
			ctl_base = pipe->base;
@@ -5194,15 +5191,10 @@ int mdss_mdp_hist_collect(struct mdp_histogram_data *hist)
			if (!PP_ARG(i, hist->block))
				continue;
			pipe_cnt++;
			pipe = mdss_mdp_pipe_get(mdata, BIT(i));
			pipe = __get_hist_pipe(i);
			if (IS_ERR_OR_NULL(pipe)) {
				pr_warn("Invalid Hist pipe (%d)\n", i);
				continue;
			} else if ((pipe->num > MDSS_MDP_SSPP_VIG2) &&
				(pipe->num != MDSS_MDP_SSPP_VIG3)) {
				mdss_mdp_pipe_unmap(pipe);
				pr_warn("Invalid Hist pipe (%d)\n", i);
				continue;
			}
			hist_info = &pipe->pp_res.hist;
			mdss_mdp_pipe_unmap(pipe);
@@ -5230,7 +5222,7 @@ int mdss_mdp_hist_collect(struct mdp_histogram_data *hist)
			for (i = pipe_num; i < MDSS_PP_ARG_NUM; i++) {
				if (!PP_ARG(i, hist->block))
					continue;
				pipe = mdss_mdp_pipe_get(mdata, BIT(i));
				pipe = __get_hist_pipe(i);
				if (IS_ERR_OR_NULL(pipe)) {
					pr_warn("Invalid Hist pipe (%d)\n", i);
					continue;