[PATCH 01/15] drm/amdgpu: Add encoder atomic check

mikita.lipski at amd.com mikita.lipski at amd.com
Wed Sep 18 20:26:38 UTC 2019


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

[why]
In order to comply with new MST atomic check
we have to find and add VCPI slots to the state
during atomic check whenever their is a change on
mode or connector.
[how]
- Verify that it is a MST connection
- Convert new stream's clock and bpp
- Calculate PBN based on stream parameters
- Find and add VCPI slots to the state

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 | 59 +++++++++++++++++++
 1 file changed, 59 insertions(+)

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 7b0ca2e1ed8b..d700b962d338 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -4432,6 +4432,65 @@ static int dm_encoder_helper_atomic_check(struct drm_encoder *encoder,
 					  struct drm_crtc_state *crtc_state,
 					  struct drm_connector_state *conn_state)
 {
+	struct drm_atomic_state *state = crtc_state->state;
+	struct drm_connector *connector = conn_state->connector;
+	struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector);
+	struct dm_crtc_state *dm_new_crtc_state = to_dm_crtc_state(crtc_state);
+	const struct drm_display_mode *adjusted_mode = &crtc_state->adjusted_mode;
+	struct drm_dp_mst_topology_mgr *mst_mgr;
+	struct drm_dp_mst_port *mst_port;
+	int pbn, slots,clock, bpp = 0;
+
+	if (!dm_new_crtc_state)
+		return 0;
+
+	if (!aconnector || !aconnector->port)
+		return 0;
+
+	mst_port = aconnector->port;
+	mst_mgr = &aconnector->mst_port->mst_mgr;
+
+	if (!mst_mgr->mst_state)
+		return 0;
+
+	if (!crtc_state->connectors_changed && !crtc_state->mode_changed)
+		return 0;
+
+	switch (convert_color_depth_from_display_info(connector, conn_state)) {
+	case COLOR_DEPTH_666:
+		bpp = 6;
+		break;
+	case COLOR_DEPTH_888:
+		bpp = 8;
+		break;
+	case COLOR_DEPTH_101010:
+		bpp = 10;
+		break;
+	case COLOR_DEPTH_121212:
+		bpp = 12;
+		break;
+	case COLOR_DEPTH_141414:
+		bpp = 14;
+		break;
+	case COLOR_DEPTH_161616:
+		bpp = 16;
+		break;
+	default:
+		ASSERT(bpp != 0);
+		break;
+	}
+
+	bpp *= 3;
+	clock = adjusted_mode->clock;
+	pbn = drm_dp_calc_pbn_mode(clock, bpp);
+	slots = drm_dp_atomic_find_vcpi_slots(state,
+						mst_mgr,
+						mst_port,
+						pbn);
+	if (slots < 0) {
+		DRM_DEBUG_KMS("failed finding vcpi slots:%d\n", slots);
+		return slots;
+	}
 	return 0;
 }
 
-- 
2.17.1



More information about the amd-gfx mailing list