Browse Source

disp: msm: dp: update DSC resource book keeping for mst

Currently in an MST scenario, DSC resources are updated in
bookkeeping only when the corresponding stream is enabled.
This would lead to assigning already reserved DSC blocks to the
2nd stream, if 2nd stream is validated before the 1st stream is
enabled. This change would update the bookkeeping as soon as the
mode is validated.

Change-Id: I7f89a16639efcde3e5dfdf423715ed354e1de66a
Signed-off-by: Sandeep Gangadharaiah <[email protected]>
Sandeep Gangadharaiah 3 years ago
parent
commit
bbe2404b91
1 changed files with 19 additions and 27 deletions
  1. 19 27
      msm/dp/dp_display.c

+ 19 - 27
msm/dp/dp_display.c

@@ -1476,29 +1476,11 @@ static int dp_display_usbpd_configure_cb(struct device *dev)
 	return 0;
 }
 
-static void dp_display_update_dsc_resources(struct dp_display_private *dp,
-		struct dp_panel *panel, bool enable)
+static void dp_display_clear_dsc_resources(struct dp_display_private *dp,
+		struct dp_panel *panel)
 {
-	int rc;
-	u32 dsc_blk_cnt = 0;
-	struct msm_drm_private *priv = dp->priv;
-
-	if (enable) {
-		if (panel->pinfo.comp_info.comp_type == MSM_DISPLAY_COMPRESSION_DSC &&
-				(panel->pinfo.comp_info.enabled)) {
-			rc = msm_get_dsc_count(priv, panel->pinfo.h_active,
-					&dsc_blk_cnt);
-			if (rc) {
-				DP_ERR("error getting dsc count. rc:%d\n", rc);
-				return;
-			}
-		}
-		dp->tot_dsc_blks_in_use += dsc_blk_cnt;
-		panel->dsc_blks_in_use += dsc_blk_cnt;
-	} else {
-		dp->tot_dsc_blks_in_use -= panel->dsc_blks_in_use;
-		panel->dsc_blks_in_use = 0;
-	}
+	dp->tot_dsc_blks_in_use -= panel->dsc_blks_in_use;
+	panel->dsc_blks_in_use = 0;
 }
 
 static int dp_display_stream_pre_disable(struct dp_display_private *dp,
@@ -1530,7 +1512,7 @@ static void dp_display_stream_disable(struct dp_display_private *dp,
 		return;
 	}
 
-	dp_display_update_dsc_resources(dp, dp_panel, false);
+	dp_display_clear_dsc_resources(dp, dp_panel);
 
 	DP_DEBUG("stream_id=%d, active_stream_cnt=%d, tot_dsc_blks_in_use=%d\n",
 			dp_panel->stream_id, dp->active_stream_cnt,
@@ -1703,7 +1685,6 @@ static int dp_display_stream_enable(struct dp_display_private *dp,
 		dp->active_stream_cnt++;
 	}
 
-	dp_display_update_dsc_resources(dp, dp_panel, true);
 
 	DP_DEBUG("dp active_stream_cnt:%d, tot_dsc_blks_in_use=%d\n",
 			dp->active_stream_cnt, dp->tot_dsc_blks_in_use);
@@ -3050,7 +3031,7 @@ static void dp_display_convert_to_dp_mode(struct dp_display *dp_display,
 	int rc;
 	struct dp_display_private *dp;
 	struct dp_panel *dp_panel;
-	u32 free_dsc_blks = 0, required_dsc_blks = 0;
+	u32 free_dsc_blks = 0, required_dsc_blks = 0, curr_dsc = 0, new_dsc = 0;
 
 	if (!dp_display || !drm_mode || !dp_mode || !panel) {
 		DP_ERR("invalid input\n");
@@ -3065,6 +3046,9 @@ static void dp_display_convert_to_dp_mode(struct dp_display *dp_display,
 	free_dsc_blks = dp_display->max_dsc_count -
 				dp->tot_dsc_blks_in_use +
 				dp_panel->dsc_blks_in_use;
+	DP_DEBUG("Before: in_use:%d, max:%d, free:%d\n",
+				dp->tot_dsc_blks_in_use,
+				dp_display->max_dsc_count, free_dsc_blks);
 
 	rc = msm_get_dsc_count(dp->priv, drm_mode->hdisplay,
 			&required_dsc_blks);
@@ -3073,11 +3057,19 @@ static void dp_display_convert_to_dp_mode(struct dp_display *dp_display,
 		return;
 	}
 
-	if (free_dsc_blks >= required_dsc_blks)
+	curr_dsc = dp_panel->dsc_blks_in_use;
+	dp->tot_dsc_blks_in_use -= dp_panel->dsc_blks_in_use;
+	dp_panel->dsc_blks_in_use = 0;
+
+	if (free_dsc_blks >= required_dsc_blks) {
 		dp_mode->capabilities |= DP_PANEL_CAPS_DSC;
+		new_dsc = max(curr_dsc, required_dsc_blks);
+		dp_panel->dsc_blks_in_use = new_dsc;
+		dp->tot_dsc_blks_in_use += new_dsc;
+	}
 
 	if (dp_mode->capabilities & DP_PANEL_CAPS_DSC)
-		DP_DEBUG("in_use:%d, max:%d, free:%d, req:%d, caps:0x%x\n",
+		DP_DEBUG("After: in_use:%d, max:%d, free:%d, req:%d, caps:0x%x\n",
 				dp->tot_dsc_blks_in_use,
 				dp_display->max_dsc_count,
 				free_dsc_blks, required_dsc_blks,