Skip to content

Commit 688486a

Browse files
committed
Merge tag 'amd-drm-next-5.6-2020-01-10-dp-mst-dsc' of git://people.freedesktop.org/~agd5f/linux into drm-next
amd-drm-next-5.6-2020-01-10-dp-mst-dsc: drm: - Add MST helper for PBN calculation of DSC modes - Parse FEC caps on MST ports - Add MST DPCD R/W functions - Add MST helpers for virtual DPCD aux - Add MST HUB quirk - Add MST DSC enablement helpers amdgpu: - Enable MST DSC - Add fair share algo for DSC bandwidth calcs - Fix for 32 bit builds Signed-off-by: Dave Airlie <[email protected]> From: Alex Deucher <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2 parents d5d88cd + 485b747 commit 688486a

File tree

18 files changed

+1031
-51
lines changed

18 files changed

+1031
-51
lines changed

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

Lines changed: 114 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4933,12 +4933,13 @@ static int dm_encoder_helper_atomic_check(struct drm_encoder *encoder,
49334933
is_y420);
49344934
bpp = convert_dc_color_depth_into_bpc(color_depth) * 3;
49354935
clock = adjusted_mode->clock;
4936-
dm_new_connector_state->pbn = drm_dp_calc_pbn_mode(clock, bpp);
4936+
dm_new_connector_state->pbn = drm_dp_calc_pbn_mode(clock, bpp, false);
49374937
}
49384938
dm_new_connector_state->vcpi_slots = drm_dp_atomic_find_vcpi_slots(state,
49394939
mst_mgr,
49404940
mst_port,
4941-
dm_new_connector_state->pbn);
4941+
dm_new_connector_state->pbn,
4942+
0);
49424943
if (dm_new_connector_state->vcpi_slots < 0) {
49434944
DRM_DEBUG_ATOMIC("failed finding vcpi slots: %d\n", (int)dm_new_connector_state->vcpi_slots);
49444945
return dm_new_connector_state->vcpi_slots;
@@ -4951,6 +4952,71 @@ const struct drm_encoder_helper_funcs amdgpu_dm_encoder_helper_funcs = {
49514952
.atomic_check = dm_encoder_helper_atomic_check
49524953
};
49534954

4955+
#if defined(CONFIG_DRM_AMD_DC_DCN)
4956+
static int dm_update_mst_vcpi_slots_for_dsc(struct drm_atomic_state *state,
4957+
struct dc_state *dc_state)
4958+
{
4959+
struct dc_stream_state *stream = NULL;
4960+
struct drm_connector *connector;
4961+
struct drm_connector_state *new_con_state, *old_con_state;
4962+
struct amdgpu_dm_connector *aconnector;
4963+
struct dm_connector_state *dm_conn_state;
4964+
int i, j, clock, bpp;
4965+
int vcpi, pbn_div, pbn = 0;
4966+
4967+
for_each_oldnew_connector_in_state(state, connector, old_con_state, new_con_state, i) {
4968+
4969+
aconnector = to_amdgpu_dm_connector(connector);
4970+
4971+
if (!aconnector->port)
4972+
continue;
4973+
4974+
if (!new_con_state || !new_con_state->crtc)
4975+
continue;
4976+
4977+
dm_conn_state = to_dm_connector_state(new_con_state);
4978+
4979+
for (j = 0; j < dc_state->stream_count; j++) {
4980+
stream = dc_state->streams[j];
4981+
if (!stream)
4982+
continue;
4983+
4984+
if ((struct amdgpu_dm_connector*)stream->dm_stream_context == aconnector)
4985+
break;
4986+
4987+
stream = NULL;
4988+
}
4989+
4990+
if (!stream)
4991+
continue;
4992+
4993+
if (stream->timing.flags.DSC != 1) {
4994+
drm_dp_mst_atomic_enable_dsc(state,
4995+
aconnector->port,
4996+
dm_conn_state->pbn,
4997+
0,
4998+
false);
4999+
continue;
5000+
}
5001+
5002+
pbn_div = dm_mst_get_pbn_divider(stream->link);
5003+
bpp = stream->timing.dsc_cfg.bits_per_pixel;
5004+
clock = stream->timing.pix_clk_100hz / 10;
5005+
pbn = drm_dp_calc_pbn_mode(clock, bpp, true);
5006+
vcpi = drm_dp_mst_atomic_enable_dsc(state,
5007+
aconnector->port,
5008+
pbn, pbn_div,
5009+
true);
5010+
if (vcpi < 0)
5011+
return vcpi;
5012+
5013+
dm_conn_state->pbn = pbn;
5014+
dm_conn_state->vcpi_slots = vcpi;
5015+
}
5016+
return 0;
5017+
}
5018+
#endif
5019+
49545020
static void dm_drm_plane_reset(struct drm_plane *plane)
49555021
{
49565022
struct dm_plane_state *amdgpu_state = NULL;
@@ -7829,6 +7895,29 @@ dm_determine_update_type_for_commit(struct amdgpu_display_manager *dm,
78297895
return ret;
78307896
}
78317897

7898+
static int add_affected_mst_dsc_crtcs(struct drm_atomic_state *state, struct drm_crtc *crtc)
7899+
{
7900+
struct drm_connector *connector;
7901+
struct drm_connector_state *conn_state;
7902+
struct amdgpu_dm_connector *aconnector = NULL;
7903+
int i;
7904+
for_each_new_connector_in_state(state, connector, conn_state, i) {
7905+
if (conn_state->crtc != crtc)
7906+
continue;
7907+
7908+
aconnector = to_amdgpu_dm_connector(connector);
7909+
if (!aconnector->port || !aconnector->mst_port)
7910+
aconnector = NULL;
7911+
else
7912+
break;
7913+
}
7914+
7915+
if (!aconnector)
7916+
return 0;
7917+
7918+
return drm_dp_mst_add_affected_dsc_crtcs(state, &aconnector->mst_port->mst_mgr);
7919+
}
7920+
78327921
/**
78337922
* amdgpu_dm_atomic_check() - Atomic check implementation for AMDgpu DM.
78347923
* @dev: The DRM device
@@ -7881,6 +7970,16 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
78817970
if (ret)
78827971
goto fail;
78837972

7973+
if (adev->asic_type >= CHIP_NAVI10) {
7974+
for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
7975+
if (drm_atomic_crtc_needs_modeset(new_crtc_state)) {
7976+
ret = add_affected_mst_dsc_crtcs(state, crtc);
7977+
if (ret)
7978+
goto fail;
7979+
}
7980+
}
7981+
}
7982+
78847983
for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
78857984
if (!drm_atomic_crtc_needs_modeset(new_crtc_state) &&
78867985
!new_crtc_state->color_mgmt_changed &&
@@ -7984,11 +8083,6 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
79848083
if (ret)
79858084
goto fail;
79868085

7987-
/* Perform validation of MST topology in the state*/
7988-
ret = drm_dp_mst_atomic_check(state);
7989-
if (ret)
7990-
goto fail;
7991-
79928086
if (state->legacy_cursor_update) {
79938087
/*
79948088
* This is a fast cursor update coming from the plane update
@@ -8057,6 +8151,15 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
80578151
if (ret)
80588152
goto fail;
80598153

8154+
#if defined(CONFIG_DRM_AMD_DC_DCN)
8155+
if (!compute_mst_dsc_configs_for_state(state, dm_state->context))
8156+
goto fail;
8157+
8158+
ret = dm_update_mst_vcpi_slots_for_dsc(state, dm_state->context);
8159+
if (ret)
8160+
goto fail;
8161+
#endif
8162+
80608163
if (dc_validate_global_state(dc, dm_state->context, false) != DC_OK) {
80618164
ret = -EINVAL;
80628165
goto fail;
@@ -8085,6 +8188,10 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
80858188
dc_retain_state(old_dm_state->context);
80868189
}
80878190
}
8191+
/* Perform validation of MST topology in the state*/
8192+
ret = drm_dp_mst_atomic_check(state);
8193+
if (ret)
8194+
goto fail;
80888195

80898196
/* Store the overall update type for use later in atomic check. */
80908197
for_each_new_crtc_in_state (state, crtc, new_crtc_state, i) {

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ struct amdgpu_dm_connector {
330330
struct drm_dp_mst_port *port;
331331
struct amdgpu_dm_connector *mst_port;
332332
struct amdgpu_encoder *mst_encoder;
333+
struct drm_dp_aux *dsc_aux;
333334

334335
/* TODO see if we can merge with ddc_bus or make a dm_connector */
335336
struct amdgpu_i2c_adapter *i2c;

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "dc.h"
3838
#include "amdgpu_dm.h"
3939
#include "amdgpu_dm_irq.h"
40+
#include "amdgpu_dm_mst_types.h"
4041

4142
#include "dm_helpers.h"
4243

@@ -516,8 +517,24 @@ bool dm_helpers_dp_write_dsc_enable(
516517
)
517518
{
518519
uint8_t enable_dsc = enable ? 1 : 0;
520+
struct amdgpu_dm_connector *aconnector;
521+
522+
if (!stream)
523+
return false;
524+
525+
if (stream->signal == SIGNAL_TYPE_DISPLAY_PORT_MST) {
526+
aconnector = (struct amdgpu_dm_connector *)stream->dm_stream_context;
527+
528+
if (!aconnector->dsc_aux)
529+
return false;
530+
531+
return (drm_dp_dpcd_write(aconnector->dsc_aux, DP_DSC_ENABLE, &enable_dsc, 1) >= 0);
532+
}
533+
534+
if (stream->signal == SIGNAL_TYPE_DISPLAY_PORT)
535+
return dm_helpers_dp_write_dpcd(ctx, stream->link, DP_DSC_ENABLE, &enable_dsc, 1);
519536

520-
return dm_helpers_dp_write_dpcd(ctx, stream->sink->link, DP_DSC_ENABLE, &enable_dsc, 1);
537+
return false;
521538
}
522539

523540
bool dm_helpers_is_dp_sink_present(struct dc_link *link)

0 commit comments

Comments
 (0)