[PATCH 13/14] drm/amd/display: Recalculate VCPI slots for new DSC connectors

mikita.lipski at amd.com mikita.lipski at amd.com
Tue Oct 1 16:17:20 UTC 2019


From: Mikita Lipski <mikita.lipski at amd.com>

Since for DSC MST connector's PBN is claculated differently
due to compression, we have to recalculate both PBN and
VCPI slots for that connector.

This patch proposes to use similair logic as in
dm_encoder_helper_atomic_chek, but since we do not know which
connectors will have DSC enabled we have to recalculate PBN only
after that's determined, which is done in
compute_mst_dsc_configs_for_state.

Cc: Jerry Zuo <Jerry.Zuo at amd.com>
Cc: Harry Wentland <harry.wentland at amd.com>
Cc: Lyude Paul <lyude at redhat.com>
Signed-off-by: Mikita Lipski <mikita.lipski at amd.com>
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 64 +++++++++++++++++--
 .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c |  6 --
 2 files changed, 59 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 81e30918f9ec..7501ce2233ed 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -4569,6 +4569,27 @@ static void dm_encoder_helper_disable(struct drm_encoder *encoder)
 
 }
 
+static int convert_dc_color_depth_into_bpc (enum dc_color_depth display_color_depth)
+{
+	switch (display_color_depth) {
+		case COLOR_DEPTH_666:
+			return 6;
+		case COLOR_DEPTH_888:
+			return 8;
+		case COLOR_DEPTH_101010:
+			return 10;
+		case COLOR_DEPTH_121212:
+			return 12;
+		case COLOR_DEPTH_141414:
+			return 14;
+		case COLOR_DEPTH_161616:
+			return 16;
+		default:
+			break;
+		}
+	return 0;
+}
+
 static int dm_encoder_helper_atomic_check(struct drm_encoder *encoder,
 					  struct drm_crtc_state *crtc_state,
 					  struct drm_connector_state *conn_state)
@@ -4616,6 +4637,36 @@ const struct drm_encoder_helper_funcs amdgpu_dm_encoder_helper_funcs = {
 	.atomic_check = dm_encoder_helper_atomic_check
 };
 
+#ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT
+static int dm_update_mst_vcpi_slots_for_dsc(struct drm_atomic_state *state,
+					    struct dc_state *dc_state)
+{
+	struct dc_stream_state *stream;
+	struct amdgpu_dm_connector *aconnector;
+	int i, clock = 0, bpp = 0;
+
+	for (i = 0; i < dc_state->stream_count; i++) {
+		stream = dc_state->streams[i];
+		aconnector = (struct amdgpu_dm_connector *)stream->dm_stream_context;
+
+		if (stream && stream->timing.flags.DSC == 1) {
+			bpp = convert_dc_color_depth_into_bpc(stream->timing.display_color_depth)* 3;
+			clock = stream->timing.pix_clk_100hz / 10;
+
+			aconnector->pbn = drm_dp_calc_pbn_mode(clock, bpp, true);
+
+			aconnector->vcpi_slots = drm_dp_atomic_find_vcpi_slots(state,
+							  &aconnector->mst_port->mst_mgr,
+							  aconnector->port,
+							  aconnector->pbn);
+			if (aconnector->vcpi_slots < 0)
+				return aconnector->vcpi_slots;
+		}
+	}
+	return 0;
+}
+#endif
+
 static void dm_drm_plane_reset(struct drm_plane *plane)
 {
 	struct dm_plane_state *amdgpu_state = NULL;
@@ -7629,11 +7680,6 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
 	if (ret)
 		goto fail;
 
-	/* Perform validation of MST topology in the state*/
-	ret = drm_dp_mst_atomic_check(state);
-	if (ret)
-		goto fail;
-
 	if (state->legacy_cursor_update) {
 		/*
 		 * This is a fast cursor update coming from the plane update
@@ -7705,6 +7751,10 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
 #ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT
 		if (!compute_mst_dsc_configs_for_state(dm_state->context))
 			goto fail;
+
+		ret = dm_update_mst_vcpi_slots_for_dsc(state, dm_state->context);
+		if (ret)
+			goto fail;
 #endif
 		if (dc_validate_global_state(dc, dm_state->context, false) != DC_OK) {
 			ret = -EINVAL;
@@ -7734,6 +7784,10 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
 				dc_retain_state(old_dm_state->context);
 		}
 	}
+	/* Perform validation of MST topology in the state*/
+	ret = drm_dp_mst_atomic_check(state);
+	if (ret)
+		goto fail;
 
 	/* Store the overall update type for use later in atomic check. */
 	for_each_new_crtc_in_state (state, crtc, new_crtc_state, i) {
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
index bd694499e3de..3e44e2da2d0d 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
@@ -201,12 +201,6 @@ bool dm_helpers_dp_mst_write_payload_allocation_table(
 	mst_port = aconnector->port;
 
 	if (enable) {
-
-		/* Convert kilobits per second / 64 (for 64 timeslots) to pbn (54/64 megabytes per second) */
-		pbn_per_timeslot = dc_link_bandwidth_kbps(
-				stream->link, dc_link_get_link_cap(stream->link)) / (8 * 1000 * 54);
-		aconnector->vcpi_slots = DIV_ROUND_UP(aconnector->pbn, pbn_per_timeslot);
-
 		ret = drm_dp_mst_allocate_vcpi(mst_mgr, mst_port,
 					       aconnector->pbn,
 					       aconnector->vcpi_slots);
-- 
2.17.1



More information about the dri-devel mailing list