aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd
diff options
context:
space:
mode:
authorYongqiang Sun <yongqiang.sun@amd.com>2017-04-21 11:00:43 -0400
committerAlex Deucher <alexander.deucher@amd.com>2017-09-26 18:06:34 -0400
commit6c626ffb1bfa2705e71376fe20bcdc6b89aace85 (patch)
tree0ad1528d3b1538825939956aeb41a77aafe4bce1 /drivers/gpu/drm/amd
parent15350179f2fc3c3b28774b4abcd35c45a5449052 (diff)
drm/amd/display: Make sure v_total_min and max not less than v_total.
Signed-off-by: Yongqiang Sun <yongqiang.sun@amd.com> Acked-by: Harry Wentland <Harry.Wentland@amd.com> Reviewed-by: Tony Cheng <Tony.Cheng@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd')
-rw-r--r--drivers/gpu/drm/amd/display/dc/dce110/dce110_timing_generator.c4
-rw-r--r--drivers/gpu/drm/amd/display/dc/dce120/dce120_timing_generator.c4
-rw-r--r--drivers/gpu/drm/amd/display/modules/freesync/freesync.c12
3 files changed, 16 insertions, 4 deletions
diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_timing_generator.c b/drivers/gpu/drm/amd/display/dc/dce110/dce110_timing_generator.c
index 69ae3a83d2fe..7070aaf9e433 100644
--- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_timing_generator.c
+++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_timing_generator.c
@@ -393,12 +393,12 @@ void dce110_timing_generator_set_drr(
393 params->vertical_total_min > 0) { 393 params->vertical_total_min > 0) {
394 394
395 set_reg_field_value(v_total_max, 395 set_reg_field_value(v_total_max,
396 params->vertical_total_max, 396 params->vertical_total_max - 1,
397 CRTC_V_TOTAL_MAX, 397 CRTC_V_TOTAL_MAX,
398 CRTC_V_TOTAL_MAX); 398 CRTC_V_TOTAL_MAX);
399 399
400 set_reg_field_value(v_total_min, 400 set_reg_field_value(v_total_min,
401 params->vertical_total_min, 401 params->vertical_total_min - 1,
402 CRTC_V_TOTAL_MIN, 402 CRTC_V_TOTAL_MIN,
403 CRTC_V_TOTAL_MIN); 403 CRTC_V_TOTAL_MIN);
404 404
diff --git a/drivers/gpu/drm/amd/display/dc/dce120/dce120_timing_generator.c b/drivers/gpu/drm/amd/display/dc/dce120/dce120_timing_generator.c
index 6e3e7b6bc58c..1318df7ed47e 100644
--- a/drivers/gpu/drm/amd/display/dc/dce120/dce120_timing_generator.c
+++ b/drivers/gpu/drm/amd/display/dc/dce120/dce120_timing_generator.c
@@ -540,10 +540,10 @@ void dce120_timing_generator_set_drr(
540 540
541 CRTC_REG_UPDATE( 541 CRTC_REG_UPDATE(
542 CRTC0_CRTC_V_TOTAL_MIN, 542 CRTC0_CRTC_V_TOTAL_MIN,
543 CRTC_V_TOTAL_MIN, params->vertical_total_min); 543 CRTC_V_TOTAL_MIN, params->vertical_total_min - 1);
544 CRTC_REG_UPDATE( 544 CRTC_REG_UPDATE(
545 CRTC0_CRTC_V_TOTAL_MAX, 545 CRTC0_CRTC_V_TOTAL_MAX,
546 CRTC_V_TOTAL_MAX, params->vertical_total_max); 546 CRTC_V_TOTAL_MAX, params->vertical_total_max - 1);
547 CRTC_REG_SET_N(CRTC0_CRTC_V_TOTAL_CONTROL, 6, 547 CRTC_REG_SET_N(CRTC0_CRTC_V_TOTAL_CONTROL, 6,
548 FD(CRTC0_CRTC_V_TOTAL_CONTROL__CRTC_V_TOTAL_MIN_SEL), 1, 548 FD(CRTC0_CRTC_V_TOTAL_CONTROL__CRTC_V_TOTAL_MIN_SEL), 1,
549 FD(CRTC0_CRTC_V_TOTAL_CONTROL__CRTC_V_TOTAL_MAX_SEL), 1, 549 FD(CRTC0_CRTC_V_TOTAL_CONTROL__CRTC_V_TOTAL_MAX_SEL), 1,
diff --git a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
index 94566c0a0e62..5c6de723da5d 100644
--- a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
+++ b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
@@ -347,6 +347,7 @@ static void calc_vmin_vmax(struct core_freesync *core_freesync,
347{ 347{
348 unsigned int min_frame_duration_in_ns = 0, max_frame_duration_in_ns = 0; 348 unsigned int min_frame_duration_in_ns = 0, max_frame_duration_in_ns = 0;
349 unsigned int index = map_index_from_stream(core_freesync, stream); 349 unsigned int index = map_index_from_stream(core_freesync, stream);
350 uint32_t vtotal = stream->timing.v_total;
350 351
351 min_frame_duration_in_ns = ((unsigned int) (div64_u64( 352 min_frame_duration_in_ns = ((unsigned int) (div64_u64(
352 (1000000000ULL * 1000000), 353 (1000000000ULL * 1000000),
@@ -362,6 +363,17 @@ static void calc_vmin_vmax(struct core_freesync *core_freesync,
362 *vmin = div64_u64(div64_u64(((unsigned long long)( 363 *vmin = div64_u64(div64_u64(((unsigned long long)(
363 min_frame_duration_in_ns) * stream->timing.pix_clk_khz), 364 min_frame_duration_in_ns) * stream->timing.pix_clk_khz),
364 stream->timing.h_total), 1000000); 365 stream->timing.h_total), 1000000);
366
367 /* In case of 4k free sync monitor, vmin or vmax cannot be less than vtotal */
368 if (*vmin < vtotal) {
369 ASSERT(false);
370 *vmin = vtotal;
371 }
372
373 if (*vmax < vtotal) {
374 ASSERT(false);
375 *vmax = vtotal;
376 }
365} 377}
366 378
367static void calc_v_total_from_duration(const struct dc_stream *stream, 379static void calc_v_total_from_duration(const struct dc_stream *stream,