Skip to content

Commit 8afb7e6

Browse files
Mikita Lipskialexdeucher
authored andcommitted
drm/dp_mst: Add DSC enablement helpers to DRM
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 <[email protected]> Signed-off-by: Mikita Lipski <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 1c6c1cb commit 8afb7e6

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

drivers/gpu/drm/drm_dp_mst_topology.c

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4789,6 +4789,67 @@ drm_dp_mst_atomic_check_topology_state(struct drm_dp_mst_topology_mgr *mgr,
47894789
return 0;
47904790
}
47914791

4792+
/**
4793+
* drm_dp_mst_atomic_enable_dsc - Set DSC Enable Flag to On/Off
4794+
* @state: Pointer to the new drm_atomic_state
4795+
* @port: Pointer to the affected MST Port
4796+
* @pbn: Newly recalculated bw required for link with DSC enabled
4797+
* @pbn_div: Divider to calculate correct number of pbn per slot
4798+
* @enable: Boolean flag to enable or disable DSC on the port
4799+
*
4800+
* This function enables DSC on the given Port
4801+
* by recalculating its vcpi from pbn provided
4802+
* and sets dsc_enable flag to keep track of which
4803+
* ports have DSC enabled
4804+
*
4805+
*/
4806+
int drm_dp_mst_atomic_enable_dsc(struct drm_atomic_state *state,
4807+
struct drm_dp_mst_port *port,
4808+
int pbn, int pbn_div,
4809+
bool enable)
4810+
{
4811+
struct drm_dp_mst_topology_state *mst_state;
4812+
struct drm_dp_vcpi_allocation *pos;
4813+
bool found = false;
4814+
int vcpi = 0;
4815+
4816+
mst_state = drm_atomic_get_mst_topology_state(state, port->mgr);
4817+
4818+
if (IS_ERR(mst_state))
4819+
return PTR_ERR(mst_state);
4820+
4821+
list_for_each_entry(pos, &mst_state->vcpis, next) {
4822+
if (pos->port == port) {
4823+
found = true;
4824+
break;
4825+
}
4826+
}
4827+
4828+
if (!found) {
4829+
DRM_DEBUG_ATOMIC("[MST PORT:%p] Couldn't find VCPI allocation in mst state %p\n",
4830+
port, mst_state);
4831+
return -EINVAL;
4832+
}
4833+
4834+
if (pos->dsc_enabled == enable) {
4835+
DRM_DEBUG_ATOMIC("[MST PORT:%p] DSC flag is already set to %d, returning %d VCPI slots\n",
4836+
port, enable, pos->vcpi);
4837+
vcpi = pos->vcpi;
4838+
}
4839+
4840+
if (enable) {
4841+
vcpi = drm_dp_atomic_find_vcpi_slots(state, port->mgr, port, pbn, pbn_div);
4842+
DRM_DEBUG_ATOMIC("[MST PORT:%p] Enabling DSC flag, reallocating %d VCPI slots on the port\n",
4843+
port, vcpi);
4844+
if (vcpi < 0)
4845+
return -EINVAL;
4846+
}
4847+
4848+
pos->dsc_enabled = enable;
4849+
4850+
return vcpi;
4851+
}
4852+
EXPORT_SYMBOL(drm_dp_mst_atomic_enable_dsc);
47924853
/**
47934854
* drm_dp_mst_atomic_check - Check that the new state of an MST topology in an
47944855
* atomic update is valid

include/drm/drm_dp_mst_helper.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ struct drm_dp_payload {
502502
struct drm_dp_vcpi_allocation {
503503
struct drm_dp_mst_port *port;
504504
int vcpi;
505+
bool dsc_enabled;
505506
struct list_head next;
506507
};
507508

@@ -781,6 +782,10 @@ drm_dp_atomic_find_vcpi_slots(struct drm_atomic_state *state,
781782
struct drm_dp_mst_topology_mgr *mgr,
782783
struct drm_dp_mst_port *port, int pbn,
783784
int pbn_div);
785+
int drm_dp_mst_atomic_enable_dsc(struct drm_atomic_state *state,
786+
struct drm_dp_mst_port *port,
787+
int pbn, int pbn_div,
788+
bool enable);
784789
int __must_check
785790
drm_dp_atomic_release_vcpi_slots(struct drm_atomic_state *state,
786791
struct drm_dp_mst_topology_mgr *mgr,

0 commit comments

Comments
 (0)