Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amd/display: unhard code link to phy idx mapping in dc link and clean up

[why]
1. Current code hard codes link to PHY mapping in dc link level per asic
per revision.
This is not scalable. In long term the mapping will be obatined from
DMUB and store in dc resource.

2. Depending on DCN revision and endpoint type, the definition of
dio_output_idx dio_output_type and phy_idx are not consistent. We need
to unify the meaning of these hardware indices across different system
configuration.

[how]
1. Temporarly move the hardcoded mapping to dc_resource level, which
should have full awareness of asic specific configuration and add a TODO
comment to move the mapping to DMUB.

2. populate dio_output_idx/phy_idx for all configuration, define
usb4_enabled bit instead of dio_output_type as an external enum.

Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Reviewed-by: Eric Yang <Eric.Yang2@amd.com>
Acked-by: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Signed-off-by: Wenjing Liu <wenjing.liu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Wenjing Liu and committed by
Alex Deucher
580013b2 771ced73

+99 -94
+62 -91
drivers/gpu/drm/amd/display/dc/core/dc_link.c
··· 3971 3971 static void update_psp_stream_config(struct pipe_ctx *pipe_ctx, bool dpms_off) 3972 3972 { 3973 3973 struct cp_psp *cp_psp = &pipe_ctx->stream->ctx->cp_psp; 3974 - #if defined(CONFIG_DRM_AMD_DC_DCN) 3975 3974 struct link_encoder *link_enc = NULL; 3976 - #endif 3975 + struct cp_psp_stream_config config = {0}; 3976 + enum dp_panel_mode panel_mode = 3977 + dp_get_panel_mode(pipe_ctx->stream->link); 3977 3978 3978 - if (cp_psp && cp_psp->funcs.update_stream_config) { 3979 - struct cp_psp_stream_config config = {0}; 3980 - enum dp_panel_mode panel_mode = 3981 - dp_get_panel_mode(pipe_ctx->stream->link); 3979 + if (cp_psp == NULL || cp_psp->funcs.update_stream_config == NULL) 3980 + return; 3982 3981 3983 - config.otg_inst = (uint8_t) pipe_ctx->stream_res.tg->inst; 3984 - /*stream_enc_inst*/ 3985 - config.dig_fe = (uint8_t) pipe_ctx->stream_res.stream_enc->stream_enc_inst; 3986 - config.dig_be = pipe_ctx->stream->link->link_enc_hw_inst; 3982 + if (pipe_ctx->stream->link->ep_type == DISPLAY_ENDPOINT_PHY) 3983 + link_enc = pipe_ctx->stream->link->link_enc; 3984 + else if (pipe_ctx->stream->link->ep_type == DISPLAY_ENDPOINT_USB4_DPIA && 3985 + pipe_ctx->stream->link->dc->res_pool->funcs->link_encs_assign) 3986 + link_enc = link_enc_cfg_get_link_enc_used_by_stream( 3987 + pipe_ctx->stream->ctx->dc, 3988 + pipe_ctx->stream); 3989 + ASSERT(link_enc); 3990 + if (link_enc == NULL) 3991 + return; 3992 + 3993 + /* otg instance */ 3994 + config.otg_inst = (uint8_t) pipe_ctx->stream_res.tg->inst; 3995 + 3996 + /* dig front end */ 3997 + config.dig_fe = (uint8_t) pipe_ctx->stream_res.stream_enc->stream_enc_inst; 3998 + 3999 + /* stream encoder index */ 4000 + config.stream_enc_idx = pipe_ctx->stream_res.stream_enc->id - ENGINE_ID_DIGA; 3987 4001 #if defined(CONFIG_DRM_AMD_DC_DCN) 3988 - config.stream_enc_idx = pipe_ctx->stream_res.stream_enc->id - ENGINE_ID_DIGA; 3989 - 3990 - if (pipe_ctx->stream->link->ep_type == DISPLAY_ENDPOINT_PHY || 3991 - pipe_ctx->stream->link->ep_type == DISPLAY_ENDPOINT_USB4_DPIA) { 3992 - if (pipe_ctx->stream->link->ep_type == DISPLAY_ENDPOINT_PHY) 3993 - link_enc = pipe_ctx->stream->link->link_enc; 3994 - else if (pipe_ctx->stream->link->ep_type == DISPLAY_ENDPOINT_USB4_DPIA) 3995 - if (pipe_ctx->stream->link->dc->res_pool->funcs->link_encs_assign) { 3996 - link_enc = link_enc_cfg_get_link_enc_used_by_stream( 3997 - pipe_ctx->stream->ctx->dc, 3998 - pipe_ctx->stream); 3999 - } 4000 - ASSERT(link_enc); 4001 - 4002 - // Initialize PHY ID with ABCDE - 01234 mapping except when it is B0 4003 - config.phy_idx = link_enc->transmitter - TRANSMITTER_UNIPHY_A; 4004 - 4005 - // Add flag to guard new A0 DIG mapping 4006 - if (pipe_ctx->stream->ctx->dc->enable_c20_dtm_b0 == true && 4007 - pipe_ctx->stream->link->dc->ctx->dce_version == DCN_VERSION_3_1) { 4008 - config.dig_be = link_enc->preferred_engine; 4009 - config.dio_output_type = pipe_ctx->stream->link->ep_type; 4010 - config.dio_output_idx = link_enc->transmitter - TRANSMITTER_UNIPHY_A; 4011 - } else { 4012 - config.dio_output_type = 0; 4013 - config.dio_output_idx = 0; 4014 - } 4015 - 4016 - // Add flag to guard B0 implementation 4017 - if (pipe_ctx->stream->ctx->dc->enable_c20_dtm_b0 == true && 4018 - link_enc->ctx->asic_id.hw_internal_rev == YELLOW_CARP_B0) { 4019 - if (pipe_ctx->stream->link->ep_type == DISPLAY_ENDPOINT_USB4_DPIA) { 4020 - // enum ID 1-4 maps to DPIA PHY ID 0-3 4021 - config.phy_idx = pipe_ctx->stream->link->link_id.enum_id - ENUM_ID_1; 4022 - } else { // for non DPIA mode over B0, ABCDE maps to 01564 4023 - 4024 - switch (link_enc->transmitter) { 4025 - case TRANSMITTER_UNIPHY_A: 4026 - config.phy_idx = 0; 4027 - break; 4028 - case TRANSMITTER_UNIPHY_B: 4029 - config.phy_idx = 1; 4030 - break; 4031 - case TRANSMITTER_UNIPHY_C: 4032 - config.phy_idx = 5; 4033 - break; 4034 - case TRANSMITTER_UNIPHY_D: 4035 - config.phy_idx = 6; 4036 - break; 4037 - case TRANSMITTER_UNIPHY_E: 4038 - config.phy_idx = 4; 4039 - break; 4040 - default: 4041 - config.phy_idx = 0; 4042 - break; 4043 - } 4044 - 4045 - } 4046 - } 4047 - } else if (pipe_ctx->stream->link->dc->res_pool->funcs->link_encs_assign) { 4048 - link_enc = link_enc_cfg_get_link_enc_used_by_stream( 4049 - pipe_ctx->stream->ctx->dc, 4050 - pipe_ctx->stream); 4051 - config.phy_idx = 0; /* Clear phy_idx for non-physical display endpoints. */ 4052 - } 4053 - ASSERT(link_enc); 4054 - if (link_enc) 4055 - config.link_enc_idx = link_enc->transmitter - TRANSMITTER_UNIPHY_A; 4056 - if (is_dp_128b_132b_signal(pipe_ctx)) { 4057 - config.stream_enc_idx = pipe_ctx->stream_res.hpo_dp_stream_enc->id - ENGINE_ID_HPO_DP_0; 4058 - 4059 - config.link_enc_idx = pipe_ctx->link_res.hpo_dp_link_enc->inst; 4060 - config.dp2_enabled = 1; 4061 - } 4002 + if (is_dp_128b_132b_signal(pipe_ctx)) 4003 + config.stream_enc_idx = 4004 + pipe_ctx->stream_res.hpo_dp_stream_enc->id - ENGINE_ID_HPO_DP_0; 4062 4005 #endif 4063 - config.dpms_off = dpms_off; 4064 - config.dm_stream_ctx = pipe_ctx->stream->dm_stream_context; 4065 - config.assr_enabled = (panel_mode == DP_PANEL_MODE_EDP); 4066 - config.mst_enabled = (pipe_ctx->stream->signal == 4067 - SIGNAL_TYPE_DISPLAY_PORT_MST); 4068 - cp_psp->funcs.update_stream_config(cp_psp->handle, &config); 4069 - } 4006 + 4007 + /* dig back end */ 4008 + config.dig_be = pipe_ctx->stream->link->link_enc_hw_inst; 4009 + 4010 + /* link encoder index */ 4011 + config.link_enc_idx = link_enc->transmitter - TRANSMITTER_UNIPHY_A; 4012 + #if defined(CONFIG_DRM_AMD_DC_DCN) 4013 + if (is_dp_128b_132b_signal(pipe_ctx)) 4014 + config.link_enc_idx = pipe_ctx->link_res.hpo_dp_link_enc->inst; 4015 + #endif 4016 + /* dio output index */ 4017 + config.dio_output_idx = link_enc->transmitter - TRANSMITTER_UNIPHY_A; 4018 + 4019 + /* phy index */ 4020 + config.phy_idx = resource_transmitter_to_phy_idx( 4021 + pipe_ctx->stream->link->dc, link_enc->transmitter); 4022 + if (pipe_ctx->stream->link->ep_type == DISPLAY_ENDPOINT_USB4_DPIA) 4023 + /* USB4 DPIA doesn't use PHY in our soc, initialize it to 0 */ 4024 + config.phy_idx = 0; 4025 + 4026 + /* stream properties */ 4027 + config.assr_enabled = (panel_mode == DP_PANEL_MODE_EDP) ? 1 : 0; 4028 + config.mst_enabled = (pipe_ctx->stream->signal == 4029 + SIGNAL_TYPE_DISPLAY_PORT_MST) ? 1 : 0; 4030 + #if defined(CONFIG_DRM_AMD_DC_DCN) 4031 + config.dp2_enabled = is_dp_128b_132b_signal(pipe_ctx) ? 1 : 0; 4032 + #endif 4033 + config.usb4_enabled = (pipe_ctx->stream->link->ep_type == DISPLAY_ENDPOINT_USB4_DPIA) ? 4034 + 1 : 0; 4035 + config.dpms_off = dpms_off; 4036 + 4037 + /* dm stream context */ 4038 + config.dm_stream_ctx = pipe_ctx->stream->dm_stream_context; 4039 + 4040 + cp_psp->funcs.update_stream_config(cp_psp->handle, &config); 4070 4041 } 4071 4042 #endif 4072 4043
+33
drivers/gpu/drm/amd/display/dc/core/dc_resource.c
··· 3270 3270 i, disabled_master_pipe_idx); 3271 3271 } 3272 3272 } 3273 + 3274 + uint8_t resource_transmitter_to_phy_idx(const struct dc *dc, enum transmitter transmitter) 3275 + { 3276 + /* TODO - get transmitter to phy idx mapping from DMUB */ 3277 + uint8_t phy_idx = transmitter - TRANSMITTER_UNIPHY_A; 3278 + 3279 + #if defined(CONFIG_DRM_AMD_DC_DCN) 3280 + if (dc->ctx->dce_version == DCN_VERSION_3_1 && 3281 + dc->ctx->asic_id.hw_internal_rev == YELLOW_CARP_B0) { 3282 + switch (transmitter) { 3283 + case TRANSMITTER_UNIPHY_A: 3284 + phy_idx = 0; 3285 + break; 3286 + case TRANSMITTER_UNIPHY_B: 3287 + phy_idx = 1; 3288 + break; 3289 + case TRANSMITTER_UNIPHY_C: 3290 + phy_idx = 5; 3291 + break; 3292 + case TRANSMITTER_UNIPHY_D: 3293 + phy_idx = 6; 3294 + break; 3295 + case TRANSMITTER_UNIPHY_E: 3296 + phy_idx = 4; 3297 + break; 3298 + default: 3299 + phy_idx = 0; 3300 + break; 3301 + } 3302 + } 3303 + #endif 3304 + return phy_idx; 3305 + }
+2 -2
drivers/gpu/drm/amd/display/dc/dm_cp_psp.h
··· 34 34 uint8_t dig_fe; 35 35 uint8_t link_enc_idx; 36 36 uint8_t stream_enc_idx; 37 - uint8_t phy_idx; 38 37 uint8_t dio_output_idx; 39 - uint8_t dio_output_type; 38 + uint8_t phy_idx; 40 39 uint8_t assr_enabled; 41 40 uint8_t mst_enabled; 42 41 uint8_t dp2_enabled; 42 + uint8_t usb4_enabled; 43 43 void *dm_stream_ctx; 44 44 bool dpms_off; 45 45 };
+1
drivers/gpu/drm/amd/display/dc/inc/resource.h
··· 218 218 void check_syncd_pipes_for_disabled_master_pipe(struct dc *dc, 219 219 struct dc_state *context, 220 220 uint8_t disabled_master_pipe_idx); 221 + uint8_t resource_transmitter_to_phy_idx(const struct dc *dc, enum transmitter transmitter); 221 222 222 223 #endif /* DRIVERS_GPU_DRM_AMD_DC_DEV_DC_INC_RESOURCE_H_ */
+1 -1
drivers/gpu/drm/amd/display/modules/inc/mod_hdcp.h
··· 104 104 uint8_t rev; 105 105 uint8_t assr_enabled; 106 106 uint8_t mst_enabled; 107 + uint8_t usb4_enabled; 107 108 }; 108 109 109 110 struct mod_hdcp_hdmi { ··· 250 249 uint8_t ddc_line; 251 250 uint8_t link_enc_idx; 252 251 uint8_t phy_idx; 253 - uint8_t dio_output_type; 254 252 uint8_t dio_output_id; 255 253 uint8_t hdcp_supported_informational; 256 254 union {