diff options
author | Mario Kleiner <mario.kleiner.de@gmail.com> | 2017-03-29 16:09:11 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-05-25 09:44:35 -0400 |
commit | ebf3cf5b9a67c694070ba93d8c31469aeb793266 (patch) | |
tree | bfa2207da0aee368472b857d6da56ee3084f7e43 | |
parent | adc6647c4f0f6f7f3d838d1ccd7398695b6b0702 (diff) |
drm/amdgpu: Make display watermark calculations more accurate
commit d63c277dc672e0c568481af043359420fa9d4736 upstream.
Avoid big roundoff errors in scanline/hactive durations for
high pixel clocks, especially for >= 500 Mhz, and thereby
program more accurate display fifo watermarks.
Implemented here for DCE 6,8,10,11.
Successfully tested on DCE 10 with AMD R9 380 Tonga.
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/dce_v10_0.c | 10 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/dce_v11_0.c | 10 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | 10 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/dce_v8_0.c | 10 |
4 files changed, 20 insertions, 20 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c index 882404cefbc2..eda2d56d2f2f 100644 --- a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +++ b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c | |||
@@ -1297,14 +1297,14 @@ static void dce_v10_0_program_watermarks(struct amdgpu_device *adev, | |||
1297 | { | 1297 | { |
1298 | struct drm_display_mode *mode = &amdgpu_crtc->base.mode; | 1298 | struct drm_display_mode *mode = &amdgpu_crtc->base.mode; |
1299 | struct dce10_wm_params wm_low, wm_high; | 1299 | struct dce10_wm_params wm_low, wm_high; |
1300 | u32 pixel_period; | 1300 | u32 active_time; |
1301 | u32 line_time = 0; | 1301 | u32 line_time = 0; |
1302 | u32 latency_watermark_a = 0, latency_watermark_b = 0; | 1302 | u32 latency_watermark_a = 0, latency_watermark_b = 0; |
1303 | u32 tmp, wm_mask, lb_vblank_lead_lines = 0; | 1303 | u32 tmp, wm_mask, lb_vblank_lead_lines = 0; |
1304 | 1304 | ||
1305 | if (amdgpu_crtc->base.enabled && num_heads && mode) { | 1305 | if (amdgpu_crtc->base.enabled && num_heads && mode) { |
1306 | pixel_period = 1000000 / (u32)mode->clock; | 1306 | active_time = 1000000UL * (u32)mode->crtc_hdisplay / (u32)mode->clock; |
1307 | line_time = min((u32)mode->crtc_htotal * pixel_period, (u32)65535); | 1307 | line_time = min((u32) (1000000UL * (u32)mode->crtc_htotal / (u32)mode->clock), (u32)65535); |
1308 | 1308 | ||
1309 | /* watermark for high clocks */ | 1309 | /* watermark for high clocks */ |
1310 | if (adev->pm.dpm_enabled) { | 1310 | if (adev->pm.dpm_enabled) { |
@@ -1319,7 +1319,7 @@ static void dce_v10_0_program_watermarks(struct amdgpu_device *adev, | |||
1319 | 1319 | ||
1320 | wm_high.disp_clk = mode->clock; | 1320 | wm_high.disp_clk = mode->clock; |
1321 | wm_high.src_width = mode->crtc_hdisplay; | 1321 | wm_high.src_width = mode->crtc_hdisplay; |
1322 | wm_high.active_time = mode->crtc_hdisplay * pixel_period; | 1322 | wm_high.active_time = active_time; |
1323 | wm_high.blank_time = line_time - wm_high.active_time; | 1323 | wm_high.blank_time = line_time - wm_high.active_time; |
1324 | wm_high.interlaced = false; | 1324 | wm_high.interlaced = false; |
1325 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) | 1325 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) |
@@ -1358,7 +1358,7 @@ static void dce_v10_0_program_watermarks(struct amdgpu_device *adev, | |||
1358 | 1358 | ||
1359 | wm_low.disp_clk = mode->clock; | 1359 | wm_low.disp_clk = mode->clock; |
1360 | wm_low.src_width = mode->crtc_hdisplay; | 1360 | wm_low.src_width = mode->crtc_hdisplay; |
1361 | wm_low.active_time = mode->crtc_hdisplay * pixel_period; | 1361 | wm_low.active_time = active_time; |
1362 | wm_low.blank_time = line_time - wm_low.active_time; | 1362 | wm_low.blank_time = line_time - wm_low.active_time; |
1363 | wm_low.interlaced = false; | 1363 | wm_low.interlaced = false; |
1364 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) | 1364 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) |
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c index 64a1df62cc65..3b610fb405b6 100644 --- a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +++ b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c | |||
@@ -1264,14 +1264,14 @@ static void dce_v11_0_program_watermarks(struct amdgpu_device *adev, | |||
1264 | { | 1264 | { |
1265 | struct drm_display_mode *mode = &amdgpu_crtc->base.mode; | 1265 | struct drm_display_mode *mode = &amdgpu_crtc->base.mode; |
1266 | struct dce10_wm_params wm_low, wm_high; | 1266 | struct dce10_wm_params wm_low, wm_high; |
1267 | u32 pixel_period; | 1267 | u32 active_time; |
1268 | u32 line_time = 0; | 1268 | u32 line_time = 0; |
1269 | u32 latency_watermark_a = 0, latency_watermark_b = 0; | 1269 | u32 latency_watermark_a = 0, latency_watermark_b = 0; |
1270 | u32 tmp, wm_mask, lb_vblank_lead_lines = 0; | 1270 | u32 tmp, wm_mask, lb_vblank_lead_lines = 0; |
1271 | 1271 | ||
1272 | if (amdgpu_crtc->base.enabled && num_heads && mode) { | 1272 | if (amdgpu_crtc->base.enabled && num_heads && mode) { |
1273 | pixel_period = 1000000 / (u32)mode->clock; | 1273 | active_time = 1000000UL * (u32)mode->crtc_hdisplay / (u32)mode->clock; |
1274 | line_time = min((u32)mode->crtc_htotal * pixel_period, (u32)65535); | 1274 | line_time = min((u32) (1000000UL * (u32)mode->crtc_htotal / (u32)mode->clock), (u32)65535); |
1275 | 1275 | ||
1276 | /* watermark for high clocks */ | 1276 | /* watermark for high clocks */ |
1277 | if (adev->pm.dpm_enabled) { | 1277 | if (adev->pm.dpm_enabled) { |
@@ -1286,7 +1286,7 @@ static void dce_v11_0_program_watermarks(struct amdgpu_device *adev, | |||
1286 | 1286 | ||
1287 | wm_high.disp_clk = mode->clock; | 1287 | wm_high.disp_clk = mode->clock; |
1288 | wm_high.src_width = mode->crtc_hdisplay; | 1288 | wm_high.src_width = mode->crtc_hdisplay; |
1289 | wm_high.active_time = mode->crtc_hdisplay * pixel_period; | 1289 | wm_high.active_time = active_time; |
1290 | wm_high.blank_time = line_time - wm_high.active_time; | 1290 | wm_high.blank_time = line_time - wm_high.active_time; |
1291 | wm_high.interlaced = false; | 1291 | wm_high.interlaced = false; |
1292 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) | 1292 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) |
@@ -1325,7 +1325,7 @@ static void dce_v11_0_program_watermarks(struct amdgpu_device *adev, | |||
1325 | 1325 | ||
1326 | wm_low.disp_clk = mode->clock; | 1326 | wm_low.disp_clk = mode->clock; |
1327 | wm_low.src_width = mode->crtc_hdisplay; | 1327 | wm_low.src_width = mode->crtc_hdisplay; |
1328 | wm_low.active_time = mode->crtc_hdisplay * pixel_period; | 1328 | wm_low.active_time = active_time; |
1329 | wm_low.blank_time = line_time - wm_low.active_time; | 1329 | wm_low.blank_time = line_time - wm_low.active_time; |
1330 | wm_low.interlaced = false; | 1330 | wm_low.interlaced = false; |
1331 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) | 1331 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) |
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c index fde6ee1f6f2b..06fc40083151 100644 --- a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +++ b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | |||
@@ -1057,7 +1057,7 @@ static void dce_v6_0_program_watermarks(struct amdgpu_device *adev, | |||
1057 | struct drm_display_mode *mode = &amdgpu_crtc->base.mode; | 1057 | struct drm_display_mode *mode = &amdgpu_crtc->base.mode; |
1058 | struct dce6_wm_params wm_low, wm_high; | 1058 | struct dce6_wm_params wm_low, wm_high; |
1059 | u32 dram_channels; | 1059 | u32 dram_channels; |
1060 | u32 pixel_period; | 1060 | u32 active_time; |
1061 | u32 line_time = 0; | 1061 | u32 line_time = 0; |
1062 | u32 latency_watermark_a = 0, latency_watermark_b = 0; | 1062 | u32 latency_watermark_a = 0, latency_watermark_b = 0; |
1063 | u32 priority_a_mark = 0, priority_b_mark = 0; | 1063 | u32 priority_a_mark = 0, priority_b_mark = 0; |
@@ -1067,8 +1067,8 @@ static void dce_v6_0_program_watermarks(struct amdgpu_device *adev, | |||
1067 | fixed20_12 a, b, c; | 1067 | fixed20_12 a, b, c; |
1068 | 1068 | ||
1069 | if (amdgpu_crtc->base.enabled && num_heads && mode) { | 1069 | if (amdgpu_crtc->base.enabled && num_heads && mode) { |
1070 | pixel_period = 1000000 / (u32)mode->clock; | 1070 | active_time = 1000000UL * (u32)mode->crtc_hdisplay / (u32)mode->clock; |
1071 | line_time = min((u32)mode->crtc_htotal * pixel_period, (u32)65535); | 1071 | line_time = min((u32) (1000000UL * (u32)mode->crtc_htotal / (u32)mode->clock), (u32)65535); |
1072 | priority_a_cnt = 0; | 1072 | priority_a_cnt = 0; |
1073 | priority_b_cnt = 0; | 1073 | priority_b_cnt = 0; |
1074 | 1074 | ||
@@ -1087,7 +1087,7 @@ static void dce_v6_0_program_watermarks(struct amdgpu_device *adev, | |||
1087 | 1087 | ||
1088 | wm_high.disp_clk = mode->clock; | 1088 | wm_high.disp_clk = mode->clock; |
1089 | wm_high.src_width = mode->crtc_hdisplay; | 1089 | wm_high.src_width = mode->crtc_hdisplay; |
1090 | wm_high.active_time = mode->crtc_hdisplay * pixel_period; | 1090 | wm_high.active_time = active_time; |
1091 | wm_high.blank_time = line_time - wm_high.active_time; | 1091 | wm_high.blank_time = line_time - wm_high.active_time; |
1092 | wm_high.interlaced = false; | 1092 | wm_high.interlaced = false; |
1093 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) | 1093 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) |
@@ -1114,7 +1114,7 @@ static void dce_v6_0_program_watermarks(struct amdgpu_device *adev, | |||
1114 | 1114 | ||
1115 | wm_low.disp_clk = mode->clock; | 1115 | wm_low.disp_clk = mode->clock; |
1116 | wm_low.src_width = mode->crtc_hdisplay; | 1116 | wm_low.src_width = mode->crtc_hdisplay; |
1117 | wm_low.active_time = mode->crtc_hdisplay * pixel_period; | 1117 | wm_low.active_time = active_time; |
1118 | wm_low.blank_time = line_time - wm_low.active_time; | 1118 | wm_low.blank_time = line_time - wm_low.active_time; |
1119 | wm_low.interlaced = false; | 1119 | wm_low.interlaced = false; |
1120 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) | 1120 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) |
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c index 7d9ffde0a628..ac88c589be32 100644 --- a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +++ b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c | |||
@@ -1218,14 +1218,14 @@ static void dce_v8_0_program_watermarks(struct amdgpu_device *adev, | |||
1218 | { | 1218 | { |
1219 | struct drm_display_mode *mode = &amdgpu_crtc->base.mode; | 1219 | struct drm_display_mode *mode = &amdgpu_crtc->base.mode; |
1220 | struct dce8_wm_params wm_low, wm_high; | 1220 | struct dce8_wm_params wm_low, wm_high; |
1221 | u32 pixel_period; | 1221 | u32 active_time; |
1222 | u32 line_time = 0; | 1222 | u32 line_time = 0; |
1223 | u32 latency_watermark_a = 0, latency_watermark_b = 0; | 1223 | u32 latency_watermark_a = 0, latency_watermark_b = 0; |
1224 | u32 tmp, wm_mask, lb_vblank_lead_lines = 0; | 1224 | u32 tmp, wm_mask, lb_vblank_lead_lines = 0; |
1225 | 1225 | ||
1226 | if (amdgpu_crtc->base.enabled && num_heads && mode) { | 1226 | if (amdgpu_crtc->base.enabled && num_heads && mode) { |
1227 | pixel_period = 1000000 / (u32)mode->clock; | 1227 | active_time = 1000000UL * (u32)mode->crtc_hdisplay / (u32)mode->clock; |
1228 | line_time = min((u32)mode->crtc_htotal * pixel_period, (u32)65535); | 1228 | line_time = min((u32) (1000000UL * (u32)mode->crtc_htotal / (u32)mode->clock), (u32)65535); |
1229 | 1229 | ||
1230 | /* watermark for high clocks */ | 1230 | /* watermark for high clocks */ |
1231 | if (adev->pm.dpm_enabled) { | 1231 | if (adev->pm.dpm_enabled) { |
@@ -1240,7 +1240,7 @@ static void dce_v8_0_program_watermarks(struct amdgpu_device *adev, | |||
1240 | 1240 | ||
1241 | wm_high.disp_clk = mode->clock; | 1241 | wm_high.disp_clk = mode->clock; |
1242 | wm_high.src_width = mode->crtc_hdisplay; | 1242 | wm_high.src_width = mode->crtc_hdisplay; |
1243 | wm_high.active_time = mode->crtc_hdisplay * pixel_period; | 1243 | wm_high.active_time = active_time; |
1244 | wm_high.blank_time = line_time - wm_high.active_time; | 1244 | wm_high.blank_time = line_time - wm_high.active_time; |
1245 | wm_high.interlaced = false; | 1245 | wm_high.interlaced = false; |
1246 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) | 1246 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) |
@@ -1279,7 +1279,7 @@ static void dce_v8_0_program_watermarks(struct amdgpu_device *adev, | |||
1279 | 1279 | ||
1280 | wm_low.disp_clk = mode->clock; | 1280 | wm_low.disp_clk = mode->clock; |
1281 | wm_low.src_width = mode->crtc_hdisplay; | 1281 | wm_low.src_width = mode->crtc_hdisplay; |
1282 | wm_low.active_time = mode->crtc_hdisplay * pixel_period; | 1282 | wm_low.active_time = active_time; |
1283 | wm_low.blank_time = line_time - wm_low.active_time; | 1283 | wm_low.blank_time = line_time - wm_low.active_time; |
1284 | wm_low.interlaced = false; | 1284 | wm_low.interlaced = false; |
1285 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) | 1285 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) |