drm/amd/display: Fix embedded panels without DDC
Subsystems (3)
cover drm/amd/display: Fix embedded panels without DDC
On some laptops, the embedded panel (eg. LVDS) doesn't have DDC (display data channel). In this case, the driver should use an EDID that is hardcoded in the VBIOS.
DC currently doesn't do that and just fails, leaving users with a blank screen.
This series fixes embedded panels without DDC, allowing this case up to DCE 8.
Timur Kristóf (6):
drm/amd/display: Allow embedded connectors without DDC drm/amd/display: Allow DCE link encoder without AUX registers drm/amd/display: Allow constructing DCE6 link encoder without DDC drm/amd/display: Allow constructing DCE8 link encoder without DDC drm/amd/display: Read EDID from VBIOS embedded panel info drm/amd/display: Use EDID from VBIOS embedded panel info
.../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 44 +++++++++++++ .../gpu/drm/amd/display/dc/bios/bios_parser.c | 62 +++++++++++++++++++ drivers/gpu/drm/amd/display/dc/dc.h | 2 +- .../drm/amd/display/dc/dce/dce_link_encoder.c | 4 +- .../drm/amd/display/dc/gpio/gpio_service.c | 3 + .../drm/amd/display/dc/link/link_factory.c | 4 +- .../dc/resource/dce60/dce60_resource.c | 3 +- .../dc/resource/dce80/dce80_resource.c | 3 +- .../display/include/grph_object_ctrl_defs.h | 4 ++ 9 files changed, 124 insertions(+), 5 deletions(-)
Signature · 1 line
2.53.0
PATCH 1/6 drm/amd/display: Allow embedded connectors without DDC
On some laptops, the embedded panel may not have
a DDC (display data channel) available. On these,
the EDID may be hardcoded in ACPI or the VBIOS.
In this case, use GPIO_DDC_LINE_UNKNOWN and don't fail.
--- drivers/gpu/drm/amd/display/dc/dc.h | 2 +- drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c | 3 +++ drivers/gpu/drm/amd/display/dc/link/link_factory.c | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/dc.h +1 -1
@@ -1683,7 +1683,7 @@ struct dc_scratch_space {struct dc_link_training_overrides preferred_training_settings;struct dp_audio_test_data audio_test_data; -uint8_t ddc_hw_inst; +enum gpio_ddc_line ddc_hw_inst;uint8_t hpd_src;
drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c +3 -0
@@ -646,6 +646,9 @@ enum gpio_result dal_ddc_change_mode(enum gpio_ddc_line dal_ddc_get_line (const struct ddc *ddc) { +if (!ddc) +return GPIO_DDC_LINE_UNKNOWN ; +return (enum gpio_ddc_line )dal_gpio_get_enum (ddc->pin_data); }
drivers/gpu/drm/amd/display/dc/link/link_factory.c +3 -1
@@ -568,7 +568,9 @@ static bool construct_phy(struct dc_link *link, goto ddc_create_fail; } -if (!link->ddc->ddc_pin) { +/* Embedded display connectors such as LVDS may not have DDC. */ +if (!link->ddc->ddc_pin && + !dc_is_embedded_signal (link->connector_signal)) {DC_ERROR ("Failed to get I2C info for connector!\n" ); goto ddc_create_fail; }
Signature · 1 line
2.53.0
PATCH 2/6 drm/amd/display: Allow DCE link encoder without AUX registers
In reply to Timur KristófAllow constructing the DCE link encoder without DDC, which means the AUX registers array will be NULL.
This is necessary to support embedded connectors without DDC.
--- drivers/gpu/drm/amd/display/dc/dce/dce_link_encoder.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dce/dce_link_encoder.c +3 -1
@@ -1102,7 +1102,9 @@ void dce110_link_encoder_hw_init(ASSERT (result ==BP_RESULT_OK ); } -aux_initialize (enc110); + +if (enc110->aux_regs) +aux_initialize (enc110);/* reinitialize HPD. * hpd_initialize() will pass DIG_FE id to HW context.
Signature · 1 line
2.53.0
PATCH 3/6 drm/amd/display: Allow constructing DCE6 link encoder without DDC
In reply to Timur KristófWhen the DDC channel ID is set to CHANNEL_ID_UNKNOWN, pass NULL to the AUX regs array.
This is necessary to support embedded connectors without DDC.
--- drivers/gpu/drm/amd/display/dc/resource/dce60/dce60_resource.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/resource/dce60/dce60_resource.c +2 -1
@@ -754,7 +754,8 @@ static struct link_encoder *dce60_link_encoder_create( enc_init_data, &link_enc_feature, &link_enc_regs[link_regs_id], - &link_enc_aux_regs[enc_init_data->channel -1 ], + enc_init_data->channel ==CHANNEL_ID_UNKNOWN ? +NULL : &link_enc_aux_regs[enc_init_data->channel -1 ], enc_init_data->hpd_source >=ARRAY_SIZE (link_enc_hpd_regs) ? NULL : &link_enc_hpd_regs[enc_init_data->hpd_source]);return &enc110->base;
Signature · 1 line
2.53.0
PATCH 5/6 drm/amd/display: Read EDID from VBIOS embedded panel info
In reply to Timur KristófSome board manufacturers hardcode the EDID for the embedded panel in the VBIOS. This EDID should be used when the panel doesn't have a DDC.
For reference, see the legacy non-DC display code:amdgpu_atombios_encoder_get_lcd_info()
This is necessary to support embedded connectors without DDC.
--- .../gpu/drm/amd/display/dc/bios/bios_parser.c | 62 +++++++++++++++++++ .../display/include/grph_object_ctrl_defs.h | 4 ++ 2 files changed, 66 insertions(+)
drivers/gpu/drm/amd/display/dc/bios/bios_parser.c +62 -0
@@ -1313,6 +1313,60 @@ static enum bp_result bios_parser_get_embedded_panel_info(return BP_RESULT_FAILURE ; } +static enum bp_result get_embedded_panel_extra_info ( +struct bios_parser *bp, +struct embedded_panel_info *info, +const uint32_t table_offset) +{ +uint8_t *record =bios_get_image (&bp->base, table_offset,1 ); +ATOM_PANEL_RESOLUTION_PATCH_RECORD *panel_res_record; +ATOM_FAKE_EDID_PATCH_RECORD *fake_edid_record; + +while (*record !=ATOM_RECORD_END_TYPE ) { +switch (*record) { +case LCD_MODE_PATCH_RECORD_MODE_TYPE : + record +=sizeof (ATOM_PATCH_RECORD_MODE ); +break ; +case LCD_RTS_RECORD_TYPE : + record +=sizeof (ATOM_LCD_RTS_RECORD ); +break ; +case LCD_CAP_RECORD_TYPE : + record +=sizeof (ATOM_LCD_MODE_CONTROL_CAP ); +break ; +case LCD_FAKE_EDID_PATCH_RECORD_TYPE : + fake_edid_record = (ATOM_FAKE_EDID_PATCH_RECORD *)record; +if (fake_edid_record->ucFakeEDIDLength) { +if (fake_edid_record->ucFakeEDIDLength ==128 ) + info->fake_edid_size = + fake_edid_record->ucFakeEDIDLength; +else + info->fake_edid_size = + fake_edid_record->ucFakeEDIDLength *128 ; + + info->fake_edid = fake_edid_record->ucFakeEDIDString; + + record +=struct_size (fake_edid_record, + ucFakeEDIDString, + info->fake_edid_size); + }else { +/* empty fake edid record must be 3 bytes long */ + record +=sizeof (ATOM_FAKE_EDID_PATCH_RECORD ) +1 ; + } +break ; +case LCD_PANEL_RESOLUTION_RECORD_TYPE : + panel_res_record = (ATOM_PANEL_RESOLUTION_PATCH_RECORD *)record; + info->panel_width_mm = panel_res_record->usHSize; + info->panel_height_mm = panel_res_record->usVSize; + record +=sizeof (ATOM_PANEL_RESOLUTION_PATCH_RECORD ); +break ; +default : +return BP_RESULT_BADBIOSTABLE ; + } + } + +return BP_RESULT_OK ; +} +static enum bp_result get_embedded_panel_info_v1_2 (struct bios_parser *bp,struct embedded_panel_info *info)
@@ -1429,6 +1483,10 @@ static enum bp_result get_embedded_panel_info_v1_2(if (ATOM_PANEL_MISC_API_ENABLED & lvds->ucLVDS_Misc) info->lcd_timing.misc_info.API_ENABLED = true; +if (lvds->usExtInfoTableOffset) +return get_embedded_panel_extra_info (bp, info, +le16_to_cpu (lvds->usExtInfoTableOffset) +DATA_TABLES (LCD_Info)); +return BP_RESULT_OK ; }
@@ -1554,6 +1612,10 @@ static enum bp_result get_embedded_panel_info_v1_3( (uint32_t ) (ATOM_PANEL_MISC_V13_GREY_LEVEL & lvds->ucLCD_Misc) >>ATOM_PANEL_MISC_V13_GREY_LEVEL_SHIFT ; +if (lvds->usExtInfoTableOffset) +return get_embedded_panel_extra_info (bp, info, +le16_to_cpu (lvds->usExtInfoTableOffset) +DATA_TABLES (LCD_Info)); +return BP_RESULT_OK ; }
drivers/gpu/drm/amd/display/include/grph_object_ctrl_defs.h +4 -0
@@ -153,6 +153,10 @@ struct embedded_panel_info {uint32_t drr_enabled;uint32_t min_drr_refresh_rate;bool realtek_eDPToLVDS; +uint16_t panel_width_mm; +uint16_t panel_height_mm; +uint16_t fake_edid_size; +const uint8_t *fake_edid; };struct dc_firmware_info {
Signature · 1 line
2.53.0
PATCH 4/6 drm/amd/display: Allow constructing DCE8 link encoder without DDC
In reply to Timur KristófWhen the DDC channel ID is set to CHANNEL_ID_UNKNOWN, pass NULL to the AUX regs array.
This is necessary to support embedded connectors without DDC.
--- drivers/gpu/drm/amd/display/dc/resource/dce80/dce80_resource.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/resource/dce80/dce80_resource.c +2 -1
@@ -761,7 +761,8 @@ static struct link_encoder *dce80_link_encoder_create( enc_init_data, &link_enc_feature, &link_enc_regs[link_regs_id], - &link_enc_aux_regs[enc_init_data->channel -1 ], + enc_init_data->channel ==CHANNEL_ID_UNKNOWN ? +NULL : &link_enc_aux_regs[enc_init_data->channel -1 ], enc_init_data->hpd_source >=ARRAY_SIZE (link_enc_hpd_regs) ? NULL : &link_enc_hpd_regs[enc_init_data->hpd_source]);return &enc110->base;
Signature · 1 line
2.53.0
PATCH 6/6 drm/amd/display: Use EDID from VBIOS embedded panel info
In reply to Timur KristófWhen an embedded panel has no DDC, read the EDID from the VBIOS embedded panel info and use that.
--- .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +44 -0
@@ -1032,6 +1032,45 @@ dm_helpers_read_acpi_edid(struct amdgpu_dm_connector *aconnector)return drm_edid_read_custom (connector, dm_helpers_probe_acpi_edid, connector); } +static const struct drm_edid * +dm_helpers_read_vbios_hardcoded_edid (struct dc_link *link,struct amdgpu_dm_connector *aconnector) +{ +struct dc_bios *bios = link->ctx->dc_bios; +struct embedded_panel_info info; +const struct drm_edid *edid; +enum bp_result r; + +if (!dc_is_embedded_signal (link->connector_signal) || + !bios->funcs->get_embedded_panel_info) +return NULL ; + +memset (&info,0 ,sizeof (info)); + r = bios->funcs->get_embedded_panel_info (bios, &info); + +if (r !=BP_RESULT_OK ) { +dm_error ("Error when reading embedded panel info: %u\n" , r); +return NULL ; + } + +if (!info.fake_edid || !info.fake_edid_size) { +dm_error ("Embedded panel info doesn't contain an EDID\n" ); +return NULL ; + } + + edid =drm_edid_alloc (info.fake_edid, info.fake_edid_size); + +if (!drm_edid_valid (edid)) { +dm_error ("EDID from embedded panel info is invalid\n" ); +drm_edid_free (edid); +return NULL ; + } + + aconnector->base.display_info.width_mm = info.panel_width_mm; + aconnector->base.display_info.height_mm = info.panel_height_mm; + +return edid; +} +void populate_hdmi_info_from_connector (struct drm_hdmi_info *hdmi,struct dc_edid_caps *edid_caps) { edid_caps->scdc_present = hdmi->scdc.supported;
@@ -1052,6 +1091,9 @@ enum dc_edid_status dm_helpers_read_local_edid(if (link->aux_mode) ddc = &aconnector->dm_dp_aux.aux.ddc; +else if (link->ddc_hw_inst ==GPIO_DDC_LINE_UNKNOWN && +dc_is_embedded_signal (link->connector_signal)) + ddc =NULL ;else ddc = &aconnector->i2c->base;
@@ -1065,6 +1107,8 @@ enum dc_edid_status dm_helpers_read_local_edid( drm_edid =dm_helpers_read_acpi_edid (aconnector);if (drm_edid)drm_info (connector->dev,"Using ACPI provided EDID for %s\n" , connector->name); +else if (!ddc) + drm_edid =dm_helpers_read_vbios_hardcoded_edid (link, aconnector);else drm_edid =drm_edid_read_ddc (connector, ddc);drm_edid_connector_update (connector, drm_edid);
Signature · 1 line
2.53.0
Re: [PATCH 6/6] drm/amd/display: Use EDID from VBIOS embedded panel info
Applied the series!
Thanks,
Alex
Quoted 83 lines · Timur Kristóf
When an embedded panel has no DDC, read the EDID from the VBIOS embedded panel info and use that.
Fixes 7c7f5b15be65 ("drm/amd/display: Refactor edid read.")Signed-off-by Timur Kristóf <[email protected]>--- .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +44
-1@@ -1032,6 +1032,45 @@ dm_helpers_read_acpi_edid(struct amdgpu_dm_connector *aconnector)return drm_edid_read_custom (connector, dm_helpers_probe_acpi_edid, connector); } +static const struct drm_edid * +dm_helpers_read_vbios_hardcoded_edid (struct dc_link *link,struct amdgpu_dm_connector *aconnector) +{ +struct dc_bios *bios = link->ctx->dc_bios; +struct embedded_panel_info info; +const struct drm_edid *edid; +enum bp_result r; + +if (!dc_is_embedded_signal (link->connector_signal) || + !bios->funcs->get_embedded_panel_info) +return NULL ; + +memset (&info,0 ,sizeof (info)); + r = bios->funcs->get_embedded_panel_info (bios, &info); + +if (r !=BP_RESULT_OK ) { +dm_error ("Error when reading embedded panel info: %u\n" , r); +return NULL ; + } + +if (!info.fake_edid || !info.fake_edid_size) { +dm_error ("Embedded panel info doesn't contain an EDID\n" ); +return NULL ; + } + + edid =drm_edid_alloc (info.fake_edid, info.fake_edid_size); + +if (!drm_edid_valid (edid)) { +dm_error ("EDID from embedded panel info is invalid\n" ); +drm_edid_free (edid); +return NULL ; + } + + aconnector->base.display_info.width_mm = info.panel_width_mm; + aconnector->base.display_info.height_mm = info.panel_height_mm; + +return edid; +} +void populate_hdmi_info_from_connector (struct drm_hdmi_info *hdmi,struct dc_edid_caps *edid_caps) { edid_caps->scdc_present = hdmi->scdc.supported;@@ -1052,6 +1091,9 @@ enum dc_edid_status dm_helpers_read_local_edid(if (link->aux_mode) ddc = &aconnector->dm_dp_aux.aux.ddc; +else if (link->ddc_hw_inst ==GPIO_DDC_LINE_UNKNOWN && +dc_is_embedded_signal (link->connector_signal)) + ddc =NULL ;else ddc = &aconnector->i2c->base;@@ -1065,6 +1107,8 @@ enum dc_edid_status dm_helpers_read_local_edid( drm_edid =dm_helpers_read_acpi_edid (aconnector);if (drm_edid)drm_info (connector->dev,"Using ACPI provided EDID for %s\n" , connector->name); +else if (!ddc) + drm_edid =dm_helpers_read_vbios_hardcoded_edid (link, aconnector);else drm_edid =drm_edid_read_ddc (connector, ddc);drm_edid_connector_update (connector, drm_edid); --2.53.0