amd-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: <mikita.lipski@amd.com>
To: <amd-gfx@lists.freedesktop.org>
Cc: Mikita Lipski <mikita.lipski@amd.com>, dri-devel@lists.freedesktop.org
Subject: [PATCH v9 11/18] drm/dp_mst: Add DSC enablement helpers to DRM
Date: Fri, 13 Dec 2019 15:08:47 -0500	[thread overview]
Message-ID: <20191213200854.31545-12-mikita.lipski@amd.com> (raw)
In-Reply-To: <20191213200854.31545-1-mikita.lipski@amd.com>

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

Adding a helper function to be called by
drivers outside of DRM to enable DSC on
the MST ports.

Function is called to recalculate VCPI allocation
if DSC is enabled and raise the DSC flag to enable.
In case of disabling DSC the flag is set to false
and recalculation of VCPI slots is expected to be done
in encoder's atomic_check.

v2: squash separate functions into one and call it per
port
v3: Fix comment typos

Reviewed-by: Lyude Paul <lyude@redhat.com>
Signed-off-by: Mikita Lipski <mikita.lipski@amd.com>
---
 drivers/gpu/drm/drm_dp_mst_topology.c | 61 +++++++++++++++++++++++++++
 include/drm/drm_dp_mst_helper.h       |  5 +++
 2 files changed, 66 insertions(+)

diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
index bb0844dfb3d2..7cd505e771ff 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -4716,6 +4716,67 @@ drm_dp_mst_atomic_check_topology_state(struct drm_dp_mst_topology_mgr *mgr,
 	return 0;
 }
 
+/**
+ * drm_dp_mst_atomic_enable_dsc - Set DSC Enable Flag to On/Off
+ * @state: Pointer to the new drm_atomic_state
+ * @port: Pointer to the affected MST Port
+ * @pbn: Newly recalculated bw required for link with DSC enabled
+ * @pbn_div: Divider to calculate correct number of pbn per slot
+ * @enable: Boolean flag to enable or disable DSC on the port
+ *
+ * This function enables DSC on the given Port
+ * by recalculating its vcpi from pbn provided
+ * and sets dsc_enable flag to keep track of which
+ * ports have DSC enabled
+ *
+ */
+int drm_dp_mst_atomic_enable_dsc(struct drm_atomic_state *state,
+				 struct drm_dp_mst_port *port,
+				 int pbn, int pbn_div,
+				 bool enable)
+{
+	struct drm_dp_mst_topology_state *mst_state;
+	struct drm_dp_vcpi_allocation *pos;
+	bool found = false;
+	int vcpi = 0;
+
+	mst_state = drm_atomic_get_mst_topology_state(state, port->mgr);
+
+	if (IS_ERR(mst_state))
+		return PTR_ERR(mst_state);
+
+	list_for_each_entry(pos, &mst_state->vcpis, next) {
+		if (pos->port == port) {
+			found = true;
+			break;
+		}
+	}
+
+	if (!found) {
+		DRM_DEBUG_ATOMIC("[MST PORT:%p] Couldn't find VCPI allocation in mst state %p\n",
+				 port, mst_state);
+		return -EINVAL;
+	}
+
+	if (pos->dsc_enabled == enable) {
+		DRM_DEBUG_ATOMIC("[MST PORT:%p] DSC flag is already set to %d, returning %d VCPI slots\n",
+				 port, enable, pos->vcpi);
+		vcpi = pos->vcpi;
+	}
+
+	if (enable) {
+		vcpi = drm_dp_atomic_find_vcpi_slots(state, port->mgr, port, pbn, pbn_div);
+		DRM_DEBUG_ATOMIC("[MST PORT:%p] Enabling DSC flag, reallocating %d VCPI slots on the port\n",
+				 port, vcpi);
+		if (vcpi < 0)
+			return -EINVAL;
+	}
+
+	pos->dsc_enabled = enable;
+
+	return vcpi;
+}
+EXPORT_SYMBOL(drm_dp_mst_atomic_enable_dsc);
 /**
  * drm_dp_mst_atomic_check - Check that the new state of an MST topology in an
  * atomic update is valid
diff --git a/include/drm/drm_dp_mst_helper.h b/include/drm/drm_dp_mst_helper.h
index 0f813d6346aa..830c94b7f45d 100644
--- a/include/drm/drm_dp_mst_helper.h
+++ b/include/drm/drm_dp_mst_helper.h
@@ -502,6 +502,7 @@ struct drm_dp_payload {
 struct drm_dp_vcpi_allocation {
 	struct drm_dp_mst_port *port;
 	int vcpi;
+	bool dsc_enabled;
 	struct list_head next;
 };
 
@@ -773,6 +774,10 @@ drm_dp_atomic_find_vcpi_slots(struct drm_atomic_state *state,
 			      struct drm_dp_mst_topology_mgr *mgr,
 			      struct drm_dp_mst_port *port, int pbn,
 			      int pbn_div);
+int drm_dp_mst_atomic_enable_dsc(struct drm_atomic_state *state,
+				 struct drm_dp_mst_port *port,
+				 int pbn, int pbn_div,
+				 bool enable);
 int __must_check
 drm_dp_atomic_release_vcpi_slots(struct drm_atomic_state *state,
 				 struct drm_dp_mst_topology_mgr *mgr,
-- 
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-12-13 21:04 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-13 20:08 [PATCH v9 00/18] DSC MST support for DRM and AMDGPU mikita.lipski
2019-12-13 20:08 ` [PATCH v9 01/18] drm/dp_mst: Add PBN calculation for DSC modes mikita.lipski
2019-12-20 21:35   ` Lyude Paul
2019-12-13 20:08 ` [PATCH v9 02/18] drm/dp_mst: Parse FEC capability on MST ports mikita.lipski
2019-12-13 20:08 ` [PATCH v9 03/18] drm/dp_mst: Add MST support to DP DPCD R/W functions mikita.lipski
2019-12-13 20:08 ` [PATCH v9 04/18] drm/dp_mst: Fill branch->num_ports mikita.lipski
2019-12-13 20:08 ` [PATCH v9 05/18] drm/dp_mst: Add helpers for MST DSC and virtual DPCD aux mikita.lipski
2019-12-13 20:08 ` [PATCH v9 06/18] drm/dp_mst: Add new quirk for Synaptics MST hubs mikita.lipski
2019-12-13 20:08 ` [PATCH v9 07/18] drm/amd/display: Initialize DSC PPS variables to 0 mikita.lipski
2019-12-13 20:08 ` [PATCH v9 08/18] drm/amd/display: Validate DSC caps on MST endpoints mikita.lipski
2019-12-13 20:08 ` [PATCH v9 09/18] drm/amd/display: Write DSC enable to MST DPCD mikita.lipski
2019-12-13 20:08 ` [PATCH v9 10/18] drm/dp_mst: Manually overwrite PBN divider for calculating timeslots mikita.lipski
2019-12-20 21:45   ` Lyude Paul
2019-12-13 20:08 ` mikita.lipski [this message]
2019-12-13 20:08 ` [PATCH v9 12/18] drm/dp_mst: Add branch bandwidth validation to MST atomic check mikita.lipski
2020-01-17 15:09   ` Sean Paul
2020-01-17 15:26     ` Mikita Lipski
2020-01-17 15:39       ` Sean Paul
2020-01-17 20:26         ` Lyude Paul
2019-12-13 20:08 ` [PATCH v9 13/18] drm/dp_mst: Rename drm_dp_mst_atomic_check_topology_state mikita.lipski
2019-12-13 20:08 ` [PATCH v9 14/18] drm/amd/display: Add PBN per slot calculation for DSC mikita.lipski
2019-12-20 21:44   ` Lyude Paul
2019-12-20 22:50   ` Leo
2019-12-13 20:08 ` [PATCH v9 15/18] drm/amd/display: MST DSC compute fair share mikita.lipski
2019-12-20 21:44   ` Lyude Paul
2019-12-13 20:08 ` [PATCH v9 16/18] drm/amd/display: Recalculate VCPI slots for new DSC connectors mikita.lipski
2019-12-20 21:41   ` Lyude Paul
2019-12-23 19:05     ` Mikita Lipski
2019-12-13 20:08 ` [PATCH v9 17/18] drm/dp_mst: Add helper to trigger modeset on affected DSC MST CRTCs mikita.lipski
2019-12-13 20:08 ` [PATCH v9 18/18] drm/amd/display: Trigger modesets on MST DSC connectors 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=20191213200854.31545-12-mikita.lipski@amd.com \
    --to=mikita.lipski@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).