All of lore.kernel.org
 help / color / mirror / Atom feed
From: <mikita.lipski@amd.com>
To: amd-gfx@lists.freedesktop.org
Cc: Jerry Zuo <Jerry.Zuo@amd.com>,
	Mikita Lipski <mikita.lipski@amd.com>,
	dri-devel@lists.freedesktop.org
Subject: [PATCH 13/13] drm/amd/display: Recalculate VCPI slots for new DSC connectors
Date: Tue, 29 Oct 2019 09:52:45 -0400	[thread overview]
Message-ID: <20191029135245.31152-14-mikita.lipski@amd.com> (raw)
In-Reply-To: <20191029135245.31152-1-mikita.lipski@amd.com>

From: Mikita Lipski <mikita.lipski@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.

The function iterates through all the active streams to
find, which have DSC enabled, then recalculates PBN for
it and calls drm_dp_helper_update_vcpi_slots_for_dsc to
update connector's VCPI slots.

Cc: Jerry Zuo <Jerry.Zuo@amd.com>
Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Lyude Paul <lyude@redhat.com>
Signed-off-by: Mikita Lipski <mikita.lipski@amd.com>
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 71 +++++++++++++++++--
 1 file changed, 66 insertions(+), 5 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 adbd28e17947..664def4e4652 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -4608,6 +4608,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)
@@ -4651,6 +4672,43 @@ const struct drm_encoder_helper_funcs amdgpu_dm_encoder_helper_funcs = {
 	.atomic_check = dm_encoder_helper_atomic_check
 };
 
+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;
+	struct dm_connector_state *dm_conn_state;
+	int i = 0, clock = 0, bpp = 0;
+
+	for (i = 0; i < dc_state->stream_count; i++) {
+
+		stream = dc_state->streams[i];
+
+		if (!stream)
+			continue;
+
+		aconnector = (struct amdgpu_dm_connector *)stream->dm_stream_context;
+		dm_conn_state = to_dm_connector_state(aconnector->base.state);
+
+		if (!aconnector->port)
+			continue;
+
+		if (stream->timing.flags.DSC != 1)
+			continue;
+
+		bpp = convert_dc_color_depth_into_bpc(stream->timing.display_color_depth)* 3;
+		clock = stream->timing.pix_clk_100hz / 10;
+
+		dm_conn_state->pbn =  drm_dp_calc_pbn_mode(clock, bpp, true);
+
+		dm_conn_state->vcpi_slots = drm_dp_helper_update_vcpi_slots_for_dsc(state, aconnector->port, dm_conn_state->pbn);
+
+		if (dm_conn_state->vcpi_slots < 0)
+			return dm_conn_state->vcpi_slots;
+	}
+	return 0;
+}
+
 static void dm_drm_plane_reset(struct drm_plane *plane)
 {
 	struct dm_plane_state *amdgpu_state = NULL;
@@ -7684,11 +7742,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
@@ -7760,6 +7813,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;
@@ -7789,6 +7846,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) {
-- 
2.17.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

WARNING: multiple messages have this Message-ID (diff)
From: <mikita.lipski@amd.com>
To: <amd-gfx@lists.freedesktop.org>
Cc: Jerry Zuo <Jerry.Zuo@amd.com>,
	Mikita Lipski <mikita.lipski@amd.com>,
	dri-devel@lists.freedesktop.org
Subject: [PATCH 13/13] drm/amd/display: Recalculate VCPI slots for new DSC connectors
Date: Tue, 29 Oct 2019 09:52:45 -0400	[thread overview]
Message-ID: <20191029135245.31152-14-mikita.lipski@amd.com> (raw)
Message-ID: <20191029135245.3YEZqsHpGo9AUuRXi141QaffiwcVGeT1ll73ffaOY3U@z> (raw)
In-Reply-To: <20191029135245.31152-1-mikita.lipski@amd.com>

From: Mikita Lipski <mikita.lipski@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.

The function iterates through all the active streams to
find, which have DSC enabled, then recalculates PBN for
it and calls drm_dp_helper_update_vcpi_slots_for_dsc to
update connector's VCPI slots.

Cc: Jerry Zuo <Jerry.Zuo@amd.com>
Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Lyude Paul <lyude@redhat.com>
Signed-off-by: Mikita Lipski <mikita.lipski@amd.com>
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 71 +++++++++++++++++--
 1 file changed, 66 insertions(+), 5 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 adbd28e17947..664def4e4652 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -4608,6 +4608,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)
@@ -4651,6 +4672,43 @@ const struct drm_encoder_helper_funcs amdgpu_dm_encoder_helper_funcs = {
 	.atomic_check = dm_encoder_helper_atomic_check
 };
 
+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;
+	struct dm_connector_state *dm_conn_state;
+	int i = 0, clock = 0, bpp = 0;
+
+	for (i = 0; i < dc_state->stream_count; i++) {
+
+		stream = dc_state->streams[i];
+
+		if (!stream)
+			continue;
+
+		aconnector = (struct amdgpu_dm_connector *)stream->dm_stream_context;
+		dm_conn_state = to_dm_connector_state(aconnector->base.state);
+
+		if (!aconnector->port)
+			continue;
+
+		if (stream->timing.flags.DSC != 1)
+			continue;
+
+		bpp = convert_dc_color_depth_into_bpc(stream->timing.display_color_depth)* 3;
+		clock = stream->timing.pix_clk_100hz / 10;
+
+		dm_conn_state->pbn =  drm_dp_calc_pbn_mode(clock, bpp, true);
+
+		dm_conn_state->vcpi_slots = drm_dp_helper_update_vcpi_slots_for_dsc(state, aconnector->port, dm_conn_state->pbn);
+
+		if (dm_conn_state->vcpi_slots < 0)
+			return dm_conn_state->vcpi_slots;
+	}
+	return 0;
+}
+
 static void dm_drm_plane_reset(struct drm_plane *plane)
 {
 	struct dm_plane_state *amdgpu_state = NULL;
@@ -7684,11 +7742,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
@@ -7760,6 +7813,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;
@@ -7789,6 +7846,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) {
-- 
2.17.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

WARNING: multiple messages have this Message-ID (diff)
From: <mikita.lipski@amd.com>
To: <amd-gfx@lists.freedesktop.org>
Cc: Harry Wentland <harry.wentland@amd.com>,
	Jerry Zuo <Jerry.Zuo@amd.com>,
	Mikita Lipski <mikita.lipski@amd.com>,
	dri-devel@lists.freedesktop.org
Subject: [PATCH 13/13] drm/amd/display: Recalculate VCPI slots for new DSC connectors
Date: Tue, 29 Oct 2019 09:52:45 -0400	[thread overview]
Message-ID: <20191029135245.31152-14-mikita.lipski@amd.com> (raw)
Message-ID: <20191029135245.05Q7NsYHZGSR8ZFT6bOJGZ9ONOr7_adSHUw1SuSMOYg@z> (raw)
In-Reply-To: <20191029135245.31152-1-mikita.lipski@amd.com>

From: Mikita Lipski <mikita.lipski@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.

The function iterates through all the active streams to
find, which have DSC enabled, then recalculates PBN for
it and calls drm_dp_helper_update_vcpi_slots_for_dsc to
update connector's VCPI slots.

Cc: Jerry Zuo <Jerry.Zuo@amd.com>
Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Lyude Paul <lyude@redhat.com>
Signed-off-by: Mikita Lipski <mikita.lipski@amd.com>
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 71 +++++++++++++++++--
 1 file changed, 66 insertions(+), 5 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 adbd28e17947..664def4e4652 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -4608,6 +4608,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)
@@ -4651,6 +4672,43 @@ const struct drm_encoder_helper_funcs amdgpu_dm_encoder_helper_funcs = {
 	.atomic_check = dm_encoder_helper_atomic_check
 };
 
+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;
+	struct dm_connector_state *dm_conn_state;
+	int i = 0, clock = 0, bpp = 0;
+
+	for (i = 0; i < dc_state->stream_count; i++) {
+
+		stream = dc_state->streams[i];
+
+		if (!stream)
+			continue;
+
+		aconnector = (struct amdgpu_dm_connector *)stream->dm_stream_context;
+		dm_conn_state = to_dm_connector_state(aconnector->base.state);
+
+		if (!aconnector->port)
+			continue;
+
+		if (stream->timing.flags.DSC != 1)
+			continue;
+
+		bpp = convert_dc_color_depth_into_bpc(stream->timing.display_color_depth)* 3;
+		clock = stream->timing.pix_clk_100hz / 10;
+
+		dm_conn_state->pbn =  drm_dp_calc_pbn_mode(clock, bpp, true);
+
+		dm_conn_state->vcpi_slots = drm_dp_helper_update_vcpi_slots_for_dsc(state, aconnector->port, dm_conn_state->pbn);
+
+		if (dm_conn_state->vcpi_slots < 0)
+			return dm_conn_state->vcpi_slots;
+	}
+	return 0;
+}
+
 static void dm_drm_plane_reset(struct drm_plane *plane)
 {
 	struct dm_plane_state *amdgpu_state = NULL;
@@ -7684,11 +7742,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
@@ -7760,6 +7813,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;
@@ -7789,6 +7846,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) {
-- 
2.17.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2019-10-29 13:52 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-29 13:52 [PATCH v3 00/13] DSC MST support for AMDGPU mikita.lipski-5C7GfCeVMHo
2019-10-29 13:52 ` mikita.lipski
2019-10-29 13:52 ` mikita.lipski
2019-10-29 13:52 ` [PATCH 02/13] drm/dp_mst: Add PBN calculation for DSC modes mikita.lipski
2019-10-29 13:52   ` mikita.lipski
2019-10-29 13:52   ` mikita.lipski
2019-10-29 13:52 ` [PATCH 04/13] drm/dp_mst: Add MST support to DP DPCD R/W functions mikita.lipski
2019-10-29 13:52   ` mikita.lipski
2019-10-29 13:52   ` mikita.lipski
2019-10-29 13:52 ` [PATCH 05/13] drm/dp_mst: Fill branch->num_ports mikita.lipski
2019-10-29 13:52   ` mikita.lipski
2019-10-29 13:52   ` mikita.lipski
2019-10-29 13:52 ` [PATCH 07/13] drm/dp_mst: Add new quirk for Synaptics MST hubs mikita.lipski
2019-10-29 13:52   ` mikita.lipski
2019-10-29 13:52   ` mikita.lipski
2019-10-29 13:52 ` [PATCH 11/13] drm/amd/display: MST DSC compute fair share mikita.lipski
2019-10-29 13:52   ` mikita.lipski
2019-10-29 13:52   ` mikita.lipski
     [not found] ` <20191029135245.31152-1-mikita.lipski-5C7GfCeVMHo@public.gmane.org>
2019-10-29 13:52   ` [PATCH 01/13] drm/amd/display: Add MST atomic routines mikita.lipski-5C7GfCeVMHo
2019-10-29 13:52     ` mikita.lipski
2019-10-29 13:52     ` mikita.lipski
2019-10-29 13:52   ` [PATCH 03/13] drm/dp_mst: Parse FEC capability on MST ports mikita.lipski-5C7GfCeVMHo
2019-10-29 13:52     ` mikita.lipski
2019-10-29 13:52     ` mikita.lipski
2019-10-29 13:52   ` [PATCH 06/13] drm/dp_mst: Add helpers for MST DSC and virtual DPCD aux mikita.lipski-5C7GfCeVMHo
2019-10-29 13:52     ` mikita.lipski
2019-10-29 13:52     ` mikita.lipski
2019-10-29 13:52   ` [PATCH 08/13] drm/amd/display: Initialize DSC PPS variables to 0 mikita.lipski-5C7GfCeVMHo
2019-10-29 13:52     ` mikita.lipski
2019-10-29 13:52     ` mikita.lipski
2019-10-29 13:52   ` [PATCH 09/13] drm/amd/display: Validate DSC caps on MST endpoints mikita.lipski-5C7GfCeVMHo
2019-10-29 13:52     ` mikita.lipski
2019-10-29 13:52     ` mikita.lipski
2019-10-29 13:52   ` [PATCH 10/13] drm/amd/display: Write DSC enable to MST DPCD mikita.lipski-5C7GfCeVMHo
2019-10-29 13:52     ` mikita.lipski
2019-10-29 13:52     ` mikita.lipski
2019-10-29 13:52   ` [PATCH 12/13] drm/dp_mst: Add DSC enablement helpers to DRM mikita.lipski-5C7GfCeVMHo
2019-10-29 13:52     ` mikita.lipski
2019-10-29 13:52     ` mikita.lipski
2019-10-29 13:52 ` mikita.lipski [this message]
2019-10-29 13:52   ` [PATCH 13/13] drm/amd/display: Recalculate VCPI slots for new DSC connectors mikita.lipski
2019-10-29 13:52   ` mikita.lipski
2019-10-30 19:24 [PATCH v4 00/13] DSC MST support for AMDGPU mikita.lipski-5C7GfCeVMHo
2019-10-30 19:24 ` [PATCH 13/13] drm/amd/display: Recalculate VCPI slots for new DSC connectors mikita.lipski
2019-10-30 19:24   ` mikita.lipski
2019-10-30 19:24   ` mikita.lipski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191029135245.31152-14-mikita.lipski@amd.com \
    --to=mikita.lipski@amd.com \
    --cc=Jerry.Zuo@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=dri-devel@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.