Skip to content

Commit 585b2f6

Browse files
Timur Kristófalexdeucher
authored andcommitted
drm/amdgpu: Respect max pixel clock for HDMI and DVI-D (v2)
Update the legacy (non-DC) display code to respect the maximum pixel clock for HDMI and DVI-D. Reject modes that would require a higher pixel clock than can be supported. Also update the maximum supported HDMI clock value depending on the ASIC type. For reference, see the DC code: check max_hdmi_pixel_clock in dce*_resource.c v2: Fix maximum clocks for DVI-D and DVI/HDMI adapters. Reviewed-by: Alex Deucher <[email protected]> Signed-off-by: Timur Kristóf <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 220b2bd commit 585b2f6

File tree

1 file changed

+44
-13
lines changed

1 file changed

+44
-13
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,29 +1195,60 @@ static void amdgpu_connector_dvi_force(struct drm_connector *connector)
11951195
amdgpu_connector->use_digital = true;
11961196
}
11971197

1198+
/**
1199+
* Returns the maximum supported HDMI (TMDS) pixel clock in KHz.
1200+
*/
1201+
static int amdgpu_max_hdmi_pixel_clock(const struct amdgpu_device *adev)
1202+
{
1203+
if (adev->asic_type >= CHIP_POLARIS10)
1204+
return 600000;
1205+
else if (adev->asic_type >= CHIP_TONGA)
1206+
return 300000;
1207+
else
1208+
return 297000;
1209+
}
1210+
1211+
/**
1212+
* Validates the given display mode on DVI and HDMI connectors,
1213+
* including analog signals on DVI-I.
1214+
*/
11981215
static enum drm_mode_status amdgpu_connector_dvi_mode_valid(struct drm_connector *connector,
11991216
const struct drm_display_mode *mode)
12001217
{
12011218
struct drm_device *dev = connector->dev;
12021219
struct amdgpu_device *adev = drm_to_adev(dev);
12031220
struct amdgpu_connector *amdgpu_connector = to_amdgpu_connector(connector);
1221+
const int max_hdmi_pixel_clock = amdgpu_max_hdmi_pixel_clock(adev);
1222+
const int max_dvi_single_link_pixel_clock = 165000;
1223+
int max_digital_pixel_clock_khz;
12041224

12051225
/* XXX check mode bandwidth */
12061226

1207-
if (amdgpu_connector->use_digital && (mode->clock > 165000)) {
1208-
if ((amdgpu_connector->connector_object_id == CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I) ||
1209-
(amdgpu_connector->connector_object_id == CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D) ||
1210-
(amdgpu_connector->connector_object_id == CONNECTOR_OBJECT_ID_HDMI_TYPE_B)) {
1211-
return MODE_OK;
1212-
} else if (connector->display_info.is_hdmi) {
1213-
/* HDMI 1.3+ supports max clock of 340 Mhz */
1214-
if (mode->clock > 340000)
1215-
return MODE_CLOCK_HIGH;
1216-
else
1217-
return MODE_OK;
1218-
} else {
1219-
return MODE_CLOCK_HIGH;
1227+
if (amdgpu_connector->use_digital) {
1228+
switch (amdgpu_connector->connector_object_id) {
1229+
case CONNECTOR_OBJECT_ID_HDMI_TYPE_A:
1230+
max_digital_pixel_clock_khz = max_hdmi_pixel_clock;
1231+
break;
1232+
case CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I:
1233+
case CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D:
1234+
max_digital_pixel_clock_khz = max_dvi_single_link_pixel_clock;
1235+
break;
1236+
case CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I:
1237+
case CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D:
1238+
case CONNECTOR_OBJECT_ID_HDMI_TYPE_B:
1239+
max_digital_pixel_clock_khz = max_dvi_single_link_pixel_clock * 2;
1240+
break;
12201241
}
1242+
1243+
/* When the display EDID claims that it's an HDMI display,
1244+
* we use the HDMI encoder mode of the display HW,
1245+
* so we should verify against the max HDMI clock here.
1246+
*/
1247+
if (connector->display_info.is_hdmi)
1248+
max_digital_pixel_clock_khz = max_hdmi_pixel_clock;
1249+
1250+
if (mode->clock > max_digital_pixel_clock_khz)
1251+
return MODE_CLOCK_HIGH;
12211252
}
12221253

12231254
/* check against the max pixel clock */

0 commit comments

Comments
 (0)