Selaa lähdekoodia

disp: msm: modify stage for dim layer during atomic set

Stage property is modified for dimlayer during atomic
set property phase. This avoids any commit failure occurred due
to dimlayer checks during atomic check phase.

Change-Id: I4ff3d83a5aa9d6446fd4955f6c29854acf93bc68
Signed-off-by: Prashant Singh <[email protected]>
Signed-off-by: Krishna Manikandan <[email protected]>
Krishna Manikandan 5 vuotta sitten
vanhempi
sitoutus
1b0fa415a0
1 muutettua tiedostoa jossa 29 lisäystä ja 12 poistoa
  1. 29 12
      msm/sde/sde_crtc.c

+ 29 - 12
msm/sde/sde_crtc.c

@@ -2441,16 +2441,17 @@ static void _sde_crtc_clear_dim_layers_v1(struct sde_crtc_state *cstate)
  * @cstate:      Pointer to sde crtc state
  * @user_ptr:    User ptr for sde_drm_dim_layer_v1 struct
  */
-static void _sde_crtc_set_dim_layer_v1(struct sde_crtc_state *cstate,
-		void __user *usr_ptr)
+static void _sde_crtc_set_dim_layer_v1(struct drm_crtc *crtc,
+	struct sde_crtc_state *cstate, void __user *usr_ptr)
 {
 	struct sde_drm_dim_layer_v1 dim_layer_v1;
 	struct sde_drm_dim_layer_cfg *user_cfg;
 	struct sde_hw_dim_layer *dim_layer;
 	u32 count, i;
+	struct sde_kms *kms;
 
-	if (!cstate) {
-		SDE_ERROR("invalid cstate\n");
+	if (!crtc || !cstate) {
+		SDE_ERROR("invalid crtc or cstate\n");
 		return;
 	}
 	dim_layer = cstate->dim_layer;
@@ -2462,6 +2463,12 @@ static void _sde_crtc_set_dim_layer_v1(struct sde_crtc_state *cstate,
 		return;
 	}
 
+	kms = _sde_crtc_get_kms(crtc);
+	if (!kms || !kms->catalog) {
+		SDE_ERROR("invalid kms\n");
+		return;
+	}
+
 	if (copy_from_user(&dim_layer_v1, usr_ptr, sizeof(dim_layer_v1))) {
 		SDE_ERROR("failed to copy dim_layer data\n");
 		return;
@@ -2479,7 +2486,9 @@ static void _sde_crtc_set_dim_layer_v1(struct sde_crtc_state *cstate,
 		user_cfg = &dim_layer_v1.layer_cfg[i];
 
 		dim_layer[i].flags = user_cfg->flags;
-		dim_layer[i].stage = user_cfg->stage;
+		dim_layer[i].stage = (kms->catalog->has_base_layer) ?
+					user_cfg->stage : user_cfg->stage +
+					SDE_STAGE_0;
 
 		dim_layer[i].rect.x = user_cfg->rect.x1;
 		dim_layer[i].rect.y = user_cfg->rect.y1;
@@ -4122,7 +4131,7 @@ static void sde_crtc_enable(struct drm_crtc *crtc,
 
 /* no input validation - caller API has all the checks */
 static int _sde_crtc_excl_dim_layer_check(struct drm_crtc_state *state,
-		struct plane_state pstates[], int cnt, bool base_layer_staged)
+		struct plane_state pstates[], int cnt)
 {
 	struct sde_crtc_state *cstate = to_sde_crtc_state(state);
 	struct drm_display_mode *mode = &state->adjusted_mode;
@@ -4149,8 +4158,6 @@ static int _sde_crtc_excl_dim_layer_check(struct drm_crtc_state *state,
 					mode->vdisplay);
 			rc = -E2BIG;
 			goto end;
-		} else if (!base_layer_staged) {
-			cstate->dim_layer[i].stage += SDE_STAGE_0;
 		}
 	}
 
@@ -4402,10 +4409,18 @@ static int _sde_crtc_check_get_pstates(struct drm_crtc *crtc,
 	const struct drm_plane_state *pstate;
 	const struct drm_plane_state *pipe_staged[SSPP_MAX];
 	int rc = 0, multirect_count = 0, i, mixer_width, mixer_height;
+	int inc_sde_stage = 0;
+	struct sde_kms *kms;
 
 	sde_crtc = to_sde_crtc(crtc);
 	cstate = to_sde_crtc_state(state);
 
+	kms = _sde_crtc_get_kms(crtc);
+	if (!kms || !kms->catalog) {
+		SDE_ERROR("invalid kms\n");
+		return -EINVAL;
+	}
+
 	memset(pipe_staged, 0, sizeof(pipe_staged));
 
 	mixer_width = sde_crtc_get_mixer_width(sde_crtc, cstate, mode);
@@ -4431,10 +4446,13 @@ static int _sde_crtc_check_get_pstates(struct drm_crtc *crtc,
 				pstates[*cnt].sde_pstate, PLANE_PROP_ZPOS);
 		pstates[*cnt].pipe_id = sde_plane_pipe(plane);
 
+		if (!kms->catalog->has_base_layer)
+			inc_sde_stage = SDE_STAGE_0;
+
 		/* check dim layer stage with every plane */
 		for (i = 0; i < cstate->num_dim_layers; i++) {
 			if (cstate->dim_layer[i].stage ==
-					pstates[*cnt].stage) {
+				(pstates[*cnt].stage + inc_sde_stage)) {
 				SDE_ERROR(
 					"plane:%d/dim_layer:%i-same stage:%d\n",
 					plane->base.id, i,
@@ -4523,8 +4541,7 @@ static int _sde_crtc_check_zpos(struct drm_crtc_state *state,
 
 	sort(pstates, cnt, sizeof(pstates[0]), pstate_cmp, NULL);
 
-	rc = _sde_crtc_excl_dim_layer_check(state, pstates, cnt,
-				kms->catalog->has_base_layer);
+	rc = _sde_crtc_excl_dim_layer_check(state, pstates, cnt);
 	if (rc)
 		return rc;
 
@@ -5171,7 +5188,7 @@ static int sde_crtc_atomic_set_property(struct drm_crtc *crtc,
 		_sde_crtc_set_input_fence_timeout(cstate);
 		break;
 	case CRTC_PROP_DIM_LAYER_V1:
-		_sde_crtc_set_dim_layer_v1(cstate,
+		_sde_crtc_set_dim_layer_v1(crtc, cstate,
 					(void __user *)(uintptr_t)val);
 		break;
 	case CRTC_PROP_ROI_V1: