drm/amd/display: map TRANSMITTER_UNIPHY_x to LINK_REGS_x
authorYogesh Mohan Marimuthu <yogesh.mohanmarimuthu@amd.com>
Wed, 2 Oct 2019 07:06:33 +0000 (12:36 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 25 Oct 2019 20:50:09 +0000 (16:50 -0400)
[Why]
The enum value for TRANSMITTER_UNIPHY_G is 9. In resource dc_xx_resource
file structure link_enc_regs[], the TRANSMITTER_UNIPHY_G registers are
initialized at index 6. Due to this mismatch, if monitor is attached to
port using TRANSMITTER_UNIPHY_G then the monitor blanks out.

[How]
add function map_transmitter_id_to_phy_instance() and use the function
to map enum transmitter to link regs.

Signed-off-by: Yogesh Mohan Marimuthu <yogesh.mohanmarimuthu@amd.com>
Reviewed-by: Eric Yang <eric.yang2@amd.com>
Acked-by: Leo Li <sunpeng.li@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c
drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c
drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c
drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c
drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c
drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c

index b5d6dff..a5e122c 100644 (file)
@@ -399,6 +399,37 @@ static const struct dc_plane_cap plane_cap = {
 #define CC_DC_HDMI_STRAPS__AUDIO_STREAM_NUMBER__SHIFT 0x8
 #endif
 
+static int map_transmitter_id_to_phy_instance(
+       enum transmitter transmitter)
+{
+       switch (transmitter) {
+       case TRANSMITTER_UNIPHY_A:
+               return 0;
+       break;
+       case TRANSMITTER_UNIPHY_B:
+               return 1;
+       break;
+       case TRANSMITTER_UNIPHY_C:
+               return 2;
+       break;
+       case TRANSMITTER_UNIPHY_D:
+               return 3;
+       break;
+       case TRANSMITTER_UNIPHY_E:
+               return 4;
+       break;
+       case TRANSMITTER_UNIPHY_F:
+               return 5;
+       break;
+       case TRANSMITTER_UNIPHY_G:
+               return 6;
+       break;
+       default:
+               ASSERT(0);
+               return 0;
+       }
+}
+
 static void read_dce_straps(
        struct dc_context *ctx,
        struct resource_straps *straps)
@@ -579,14 +610,18 @@ struct link_encoder *dce100_link_encoder_create(
 {
        struct dce110_link_encoder *enc110 =
                kzalloc(sizeof(struct dce110_link_encoder), GFP_KERNEL);
+       int link_regs_id;
 
        if (!enc110)
                return NULL;
 
+       link_regs_id =
+               map_transmitter_id_to_phy_instance(enc_init_data->transmitter);
+
        dce110_link_encoder_construct(enc110,
                                      enc_init_data,
                                      &link_enc_feature,
-                                     &link_enc_regs[enc_init_data->transmitter],
+                                     &link_enc_regs[link_regs_id],
                                      &link_enc_aux_regs[enc_init_data->channel - 1],
                                      &link_enc_hpd_regs[enc_init_data->hpd_source]);
        return &enc110->base;
index c651a38..83a4dbf 100644 (file)
@@ -448,6 +448,37 @@ static const struct dc_plane_cap underlay_plane_cap = {
 #define CC_DC_HDMI_STRAPS__AUDIO_STREAM_NUMBER__SHIFT 0x8
 #endif
 
+static int map_transmitter_id_to_phy_instance(
+       enum transmitter transmitter)
+{
+       switch (transmitter) {
+       case TRANSMITTER_UNIPHY_A:
+               return 0;
+       break;
+       case TRANSMITTER_UNIPHY_B:
+               return 1;
+       break;
+       case TRANSMITTER_UNIPHY_C:
+               return 2;
+       break;
+       case TRANSMITTER_UNIPHY_D:
+               return 3;
+       break;
+       case TRANSMITTER_UNIPHY_E:
+               return 4;
+       break;
+       case TRANSMITTER_UNIPHY_F:
+               return 5;
+       break;
+       case TRANSMITTER_UNIPHY_G:
+               return 6;
+       break;
+       default:
+               ASSERT(0);
+               return 0;
+       }
+}
+
 static void read_dce_straps(
        struct dc_context *ctx,
        struct resource_straps *straps)
@@ -625,14 +656,18 @@ static struct link_encoder *dce110_link_encoder_create(
 {
        struct dce110_link_encoder *enc110 =
                kzalloc(sizeof(struct dce110_link_encoder), GFP_KERNEL);
+       int link_regs_id;
 
        if (!enc110)
                return NULL;
 
+       link_regs_id =
+               map_transmitter_id_to_phy_instance(enc_init_data->transmitter);
+
        dce110_link_encoder_construct(enc110,
                                      enc_init_data,
                                      &link_enc_feature,
-                                     &link_enc_regs[enc_init_data->transmitter],
+                                     &link_enc_regs[link_regs_id],
                                      &link_enc_aux_regs[enc_init_data->channel - 1],
                                      &link_enc_hpd_regs[enc_init_data->hpd_source]);
        return &enc110->base;
index 876ed06..97dcc5d 100644 (file)
@@ -425,6 +425,37 @@ static const struct dc_plane_cap plane_cap = {
 #define CC_DC_HDMI_STRAPS__AUDIO_STREAM_NUMBER__SHIFT 0x8
 #endif
 
+static int map_transmitter_id_to_phy_instance(
+       enum transmitter transmitter)
+{
+       switch (transmitter) {
+       case TRANSMITTER_UNIPHY_A:
+               return 0;
+       break;
+       case TRANSMITTER_UNIPHY_B:
+               return 1;
+       break;
+       case TRANSMITTER_UNIPHY_C:
+               return 2;
+       break;
+       case TRANSMITTER_UNIPHY_D:
+               return 3;
+       break;
+       case TRANSMITTER_UNIPHY_E:
+               return 4;
+       break;
+       case TRANSMITTER_UNIPHY_F:
+               return 5;
+       break;
+       case TRANSMITTER_UNIPHY_G:
+               return 6;
+       break;
+       default:
+               ASSERT(0);
+               return 0;
+       }
+}
+
 static void read_dce_straps(
        struct dc_context *ctx,
        struct resource_straps *straps)
@@ -583,14 +614,18 @@ struct link_encoder *dce112_link_encoder_create(
 {
        struct dce110_link_encoder *enc110 =
                kzalloc(sizeof(struct dce110_link_encoder), GFP_KERNEL);
+       int link_regs_id;
 
        if (!enc110)
                return NULL;
 
+       link_regs_id =
+               map_transmitter_id_to_phy_instance(enc_init_data->transmitter);
+
        dce110_link_encoder_construct(enc110,
                                      enc_init_data,
                                      &link_enc_feature,
-                                     &link_enc_regs[enc_init_data->transmitter],
+                                     &link_enc_regs[link_regs_id],
                                      &link_enc_aux_regs[enc_init_data->channel - 1],
                                      &link_enc_hpd_regs[enc_init_data->hpd_source]);
        return &enc110->base;
index c30faa0..63543f6 100644 (file)
@@ -364,6 +364,37 @@ static const struct dce_audio_mask audio_mask = {
                DCE120_AUD_COMMON_MASK_SH_LIST(_MASK)
 };
 
+static int map_transmitter_id_to_phy_instance(
+       enum transmitter transmitter)
+{
+       switch (transmitter) {
+       case TRANSMITTER_UNIPHY_A:
+               return 0;
+       break;
+       case TRANSMITTER_UNIPHY_B:
+               return 1;
+       break;
+       case TRANSMITTER_UNIPHY_C:
+               return 2;
+       break;
+       case TRANSMITTER_UNIPHY_D:
+               return 3;
+       break;
+       case TRANSMITTER_UNIPHY_E:
+               return 4;
+       break;
+       case TRANSMITTER_UNIPHY_F:
+               return 5;
+       break;
+       case TRANSMITTER_UNIPHY_G:
+               return 6;
+       break;
+       default:
+               ASSERT(0);
+               return 0;
+       }
+}
+
 #define clk_src_regs(index, id)\
 [index] = {\
        CS_COMMON_REG_LIST_DCE_112(id),\
@@ -666,14 +697,18 @@ static struct link_encoder *dce120_link_encoder_create(
 {
        struct dce110_link_encoder *enc110 =
                kzalloc(sizeof(struct dce110_link_encoder), GFP_KERNEL);
+       int link_regs_id;
 
        if (!enc110)
                return NULL;
 
+       link_regs_id =
+               map_transmitter_id_to_phy_instance(enc_init_data->transmitter);
+
        dce110_link_encoder_construct(enc110,
                                      enc_init_data,
                                      &link_enc_feature,
-                                     &link_enc_regs[enc_init_data->transmitter],
+                                     &link_enc_regs[link_regs_id],
                                      &link_enc_aux_regs[enc_init_data->channel - 1],
                                      &link_enc_hpd_regs[enc_init_data->hpd_source]);
 
index 59ebd65..3e8d4b4 100644 (file)
@@ -439,6 +439,37 @@ static const struct dce_abm_mask abm_mask = {
 #define CC_DC_HDMI_STRAPS__AUDIO_STREAM_NUMBER__SHIFT 0x8
 #endif
 
+static int map_transmitter_id_to_phy_instance(
+       enum transmitter transmitter)
+{
+       switch (transmitter) {
+       case TRANSMITTER_UNIPHY_A:
+               return 0;
+       break;
+       case TRANSMITTER_UNIPHY_B:
+               return 1;
+       break;
+       case TRANSMITTER_UNIPHY_C:
+               return 2;
+       break;
+       case TRANSMITTER_UNIPHY_D:
+               return 3;
+       break;
+       case TRANSMITTER_UNIPHY_E:
+               return 4;
+       break;
+       case TRANSMITTER_UNIPHY_F:
+               return 5;
+       break;
+       case TRANSMITTER_UNIPHY_G:
+               return 6;
+       break;
+       default:
+               ASSERT(0);
+               return 0;
+       }
+}
+
 static void read_dce_straps(
        struct dc_context *ctx,
        struct resource_straps *straps)
@@ -680,14 +711,18 @@ struct link_encoder *dce80_link_encoder_create(
 {
        struct dce110_link_encoder *enc110 =
                kzalloc(sizeof(struct dce110_link_encoder), GFP_KERNEL);
+       int link_regs_id;
 
        if (!enc110)
                return NULL;
 
+       link_regs_id =
+               map_transmitter_id_to_phy_instance(enc_init_data->transmitter);
+
        dce110_link_encoder_construct(enc110,
                                      enc_init_data,
                                      &link_enc_feature,
-                                     &link_enc_regs[enc_init_data->transmitter],
+                                     &link_enc_regs[link_regs_id],
                                      &link_enc_aux_regs[enc_init_data->channel - 1],
                                      &link_enc_hpd_regs[enc_init_data->hpd_source]);
        return &enc110->base;
index e3b279f..15640ae 100644 (file)
@@ -479,6 +479,28 @@ static const struct dcn_hubbub_mask hubbub_mask = {
                HUBBUB_MASK_SH_LIST_DCN10(_MASK)
 };
 
+static int map_transmitter_id_to_phy_instance(
+       enum transmitter transmitter)
+{
+       switch (transmitter) {
+       case TRANSMITTER_UNIPHY_A:
+               return 0;
+       break;
+       case TRANSMITTER_UNIPHY_B:
+               return 1;
+       break;
+       case TRANSMITTER_UNIPHY_C:
+               return 2;
+       break;
+       case TRANSMITTER_UNIPHY_D:
+               return 3;
+       break;
+       default:
+               ASSERT(0);
+               return 0;
+       }
+}
+
 #define clk_src_regs(index, pllid)\
 [index] = {\
        CS_COMMON_REG_LIST_DCN1_0(index, pllid),\
@@ -762,14 +784,18 @@ struct link_encoder *dcn10_link_encoder_create(
 {
        struct dcn10_link_encoder *enc10 =
                kzalloc(sizeof(struct dcn10_link_encoder), GFP_KERNEL);
+       int link_regs_id;
 
        if (!enc10)
                return NULL;
 
+       link_regs_id =
+               map_transmitter_id_to_phy_instance(enc_init_data->transmitter);
+
        dcn10_link_encoder_construct(enc10,
                                      enc_init_data,
                                      &link_enc_feature,
-                                     &link_enc_regs[enc_init_data->transmitter],
+                                     &link_enc_regs[link_regs_id],
                                      &link_enc_aux_regs[enc_init_data->channel - 1],
                                      &link_enc_hpd_regs[enc_init_data->hpd_source],
                                      &le_shift,
index 25515c2..88a9386 100644 (file)
@@ -742,6 +742,33 @@ static const struct dce110_aux_registers_mask aux_mask = {
                DCN_AUX_MASK_SH_LIST(_MASK)
 };
 
+static int map_transmitter_id_to_phy_instance(
+       enum transmitter transmitter)
+{
+       switch (transmitter) {
+       case TRANSMITTER_UNIPHY_A:
+               return 0;
+       break;
+       case TRANSMITTER_UNIPHY_B:
+               return 1;
+       break;
+       case TRANSMITTER_UNIPHY_C:
+               return 2;
+       break;
+       case TRANSMITTER_UNIPHY_D:
+               return 3;
+       break;
+       case TRANSMITTER_UNIPHY_E:
+               return 4;
+       break;
+       case TRANSMITTER_UNIPHY_F:
+               return 5;
+       break;
+       default:
+               ASSERT(0);
+               return 0;
+       }
+}
 
 #ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT
 #define dsc_regsDCN20(id)\
@@ -1056,14 +1083,18 @@ struct link_encoder *dcn20_link_encoder_create(
 {
        struct dcn20_link_encoder *enc20 =
                kzalloc(sizeof(struct dcn20_link_encoder), GFP_KERNEL);
+       int link_regs_id;
 
        if (!enc20)
                return NULL;
 
+       link_regs_id =
+               map_transmitter_id_to_phy_instance(enc_init_data->transmitter);
+
        dcn20_link_encoder_construct(enc20,
                                      enc_init_data,
                                      &link_enc_feature,
-                                     &link_enc_regs[enc_init_data->transmitter],
+                                     &link_enc_regs[link_regs_id],
                                      &link_enc_aux_regs[enc_init_data->channel - 1],
                                      &link_enc_hpd_regs[enc_init_data->hpd_source],
                                      &le_shift,
index a280625..fb6991b 100644 (file)
@@ -1555,19 +1555,48 @@ static const struct dcn10_link_enc_mask le_mask = {
        LINK_ENCODER_MASK_SH_LIST_DCN20(_MASK)
 };
 
+static int map_transmitter_id_to_phy_instance(
+       enum transmitter transmitter)
+{
+       switch (transmitter) {
+       case TRANSMITTER_UNIPHY_A:
+               return 0;
+       break;
+       case TRANSMITTER_UNIPHY_B:
+               return 1;
+       break;
+       case TRANSMITTER_UNIPHY_C:
+               return 2;
+       break;
+       case TRANSMITTER_UNIPHY_D:
+               return 3;
+       break;
+       case TRANSMITTER_UNIPHY_E:
+               return 4;
+       break;
+       default:
+               ASSERT(0);
+               return 0;
+       }
+}
+
 static struct link_encoder *dcn21_link_encoder_create(
        const struct encoder_init_data *enc_init_data)
 {
        struct dcn21_link_encoder *enc21 =
                kzalloc(sizeof(struct dcn21_link_encoder), GFP_KERNEL);
+       int link_regs_id;
 
        if (!enc21)
                return NULL;
 
+       link_regs_id =
+               map_transmitter_id_to_phy_instance(enc_init_data->transmitter);
+
        dcn21_link_encoder_construct(enc21,
                                      enc_init_data,
                                      &link_enc_feature,
-                                     &link_enc_regs[enc_init_data->transmitter],
+                                     &link_enc_regs[link_regs_id],
                                      &link_enc_aux_regs[enc_init_data->channel - 1],
                                      &link_enc_hpd_regs[enc_init_data->hpd_source],
                                      &le_shift,