From 9cb0f46a5e64124c6a977cd60543acac06013d94 Mon Sep 17 00:00:00 2001 From: jsg Date: Fri, 12 May 2023 10:57:58 +0000 Subject: [PATCH] drm/amd/display: fix PSR-SU/DSC interoperability support From Hamza Mahfooz 09c41688b6e5c038df5baacdb0f4e23c8a10ebdb in linux-6.1.y/6.1.28 13b90cf900ab69dd5cab3cc5035bc7614037e64e in mainline linux --- .../drm/amd/display/amdgpu_dm/amdgpu_dm_psr.c | 3 ++ .../amd/display/modules/power/power_helpers.c | 31 +++++++++++++++++++ .../amd/display/modules/power/power_helpers.h | 3 ++ 3 files changed, 37 insertions(+) diff --git a/sys/dev/pci/drm/amd/display/amdgpu_dm/amdgpu_dm_psr.c b/sys/dev/pci/drm/amd/display/amdgpu_dm/amdgpu_dm_psr.c index 26291db0a3c..872d06fe143 100644 --- a/sys/dev/pci/drm/amd/display/amdgpu_dm/amdgpu_dm_psr.c +++ b/sys/dev/pci/drm/amd/display/amdgpu_dm/amdgpu_dm_psr.c @@ -122,6 +122,9 @@ bool amdgpu_dm_link_setup_psr(struct dc_stream_state *stream) psr_config.allow_multi_disp_optimizations = (amdgpu_dc_feature_mask & DC_PSR_ALLOW_MULTI_DISP_OPT); + if (!psr_su_set_y_granularity(dc, link, stream, &psr_config)) + return false; + ret = dc_link_setup_psr(link, stream, &psr_config, &psr_context); } diff --git a/sys/dev/pci/drm/amd/display/modules/power/power_helpers.c b/sys/dev/pci/drm/amd/display/modules/power/power_helpers.c index 235259d6c5a..01fc6a368d2 100644 --- a/sys/dev/pci/drm/amd/display/modules/power/power_helpers.c +++ b/sys/dev/pci/drm/amd/display/modules/power/power_helpers.c @@ -907,3 +907,34 @@ bool mod_power_only_edp(const struct dc_state *context, const struct dc_stream_s { return context && context->stream_count == 1 && dc_is_embedded_signal(stream->signal); } + +bool psr_su_set_y_granularity(struct dc *dc, struct dc_link *link, + struct dc_stream_state *stream, + struct psr_config *config) +{ + uint16_t pic_height; + uint8_t slice_height; + + if ((link->connector_signal & SIGNAL_TYPE_EDP) && + (!dc->caps.edp_dsc_support || + link->panel_config.dsc.disable_dsc_edp || + !link->dpcd_caps.dsc_caps.dsc_basic_caps.fields.dsc_support.DSC_SUPPORT || + !stream->timing.dsc_cfg.num_slices_v)) + return true; + + pic_height = stream->timing.v_addressable + + stream->timing.v_border_top + stream->timing.v_border_bottom; + slice_height = pic_height / stream->timing.dsc_cfg.num_slices_v; + + if (slice_height) { + if (config->su_y_granularity && + (slice_height % config->su_y_granularity)) { + ASSERT(0); + return false; + } + + config->su_y_granularity = slice_height; + } + + return true; +} diff --git a/sys/dev/pci/drm/amd/display/modules/power/power_helpers.h b/sys/dev/pci/drm/amd/display/modules/power/power_helpers.h index 316452e9dbc..bb16b37b83d 100644 --- a/sys/dev/pci/drm/amd/display/modules/power/power_helpers.h +++ b/sys/dev/pci/drm/amd/display/modules/power/power_helpers.h @@ -59,4 +59,7 @@ void mod_power_calc_psr_configs(struct psr_config *psr_config, const struct dc_stream_state *stream); bool mod_power_only_edp(const struct dc_state *context, const struct dc_stream_state *stream); +bool psr_su_set_y_granularity(struct dc *dc, struct dc_link *link, + struct dc_stream_state *stream, + struct psr_config *config); #endif /* MODULES_POWER_POWER_HELPERS_H_ */ -- 2.20.1