diff options
author | Harmanprit Tatla <htatla@amd.com> | 2018-09-24 16:46:38 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2018-11-05 14:20:41 -0500 |
commit | de801062bf2c4216c1884d3707ff3f1f3533c4d9 (patch) | |
tree | efd83bfef3637b5a6ba83a596ff6dba43d508651 /drivers/gpu/drm/amd/display/modules/freesync/freesync.c | |
parent | 9566b67586fb1d96c36207fd975087d68296755c (diff) |
drm/amd/display: Freesync does not engage on some displays
[Why]
Current render margin time is not sufficient to compute exit frame
time for most monitors.
[How]
Declared render margin in FPS to compute a exit frame rate that is
4 FPS above the minimum FPS required to engage FreeSync.
Also did code clean-up to remove redundancies.
Signed-off-by: Harmanprit Tatla <htatla@amd.com>
Reviewed-by: Anthony Koo <Anthony.Koo@amd.com>
Acked-by: Bhawanpreet Lakha <Bhawanpreet.Lakha@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/display/modules/freesync/freesync.c')
-rw-r--r-- | drivers/gpu/drm/amd/display/modules/freesync/freesync.c | 37 |
1 files changed, 9 insertions, 28 deletions
diff --git a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c index 4018c7180d00..620a171620ee 100644 --- a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c +++ b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c | |||
@@ -37,6 +37,8 @@ | |||
37 | #define RENDER_TIMES_MAX_COUNT 10 | 37 | #define RENDER_TIMES_MAX_COUNT 10 |
38 | /* Threshold to exit BTR (to avoid frequent enter-exits at the lower limit) */ | 38 | /* Threshold to exit BTR (to avoid frequent enter-exits at the lower limit) */ |
39 | #define BTR_EXIT_MARGIN 2000 | 39 | #define BTR_EXIT_MARGIN 2000 |
40 | /*Threshold to exit fixed refresh rate*/ | ||
41 | #define FIXED_REFRESH_EXIT_MARGIN_IN_HZ 4 | ||
40 | /* Number of consecutive frames to check before entering/exiting fixed refresh*/ | 42 | /* Number of consecutive frames to check before entering/exiting fixed refresh*/ |
41 | #define FIXED_REFRESH_ENTER_FRAME_COUNT 5 | 43 | #define FIXED_REFRESH_ENTER_FRAME_COUNT 5 |
42 | #define FIXED_REFRESH_EXIT_FRAME_COUNT 5 | 44 | #define FIXED_REFRESH_EXIT_FRAME_COUNT 5 |
@@ -257,40 +259,14 @@ static void apply_below_the_range(struct core_freesync *core_freesync, | |||
257 | if (in_out_vrr->btr.btr_active) { | 259 | if (in_out_vrr->btr.btr_active) { |
258 | in_out_vrr->btr.frame_counter = 0; | 260 | in_out_vrr->btr.frame_counter = 0; |
259 | in_out_vrr->btr.btr_active = false; | 261 | in_out_vrr->btr.btr_active = false; |
260 | |||
261 | /* Exit Fixed Refresh mode */ | ||
262 | } else if (in_out_vrr->fixed.fixed_active) { | ||
263 | |||
264 | in_out_vrr->fixed.frame_counter++; | ||
265 | |||
266 | if (in_out_vrr->fixed.frame_counter > | ||
267 | FIXED_REFRESH_EXIT_FRAME_COUNT) { | ||
268 | in_out_vrr->fixed.frame_counter = 0; | ||
269 | in_out_vrr->fixed.fixed_active = false; | ||
270 | } | ||
271 | } | 262 | } |
272 | } else if (last_render_time_in_us > max_render_time_in_us) { | 263 | } else if (last_render_time_in_us > max_render_time_in_us) { |
273 | /* Enter Below the Range */ | 264 | /* Enter Below the Range */ |
274 | if (!in_out_vrr->btr.btr_active && | 265 | in_out_vrr->btr.btr_active = true; |
275 | in_out_vrr->btr.btr_enabled) { | ||
276 | in_out_vrr->btr.btr_active = true; | ||
277 | |||
278 | /* Enter Fixed Refresh mode */ | ||
279 | } else if (!in_out_vrr->fixed.fixed_active && | ||
280 | !in_out_vrr->btr.btr_enabled) { | ||
281 | in_out_vrr->fixed.frame_counter++; | ||
282 | |||
283 | if (in_out_vrr->fixed.frame_counter > | ||
284 | FIXED_REFRESH_ENTER_FRAME_COUNT) { | ||
285 | in_out_vrr->fixed.frame_counter = 0; | ||
286 | in_out_vrr->fixed.fixed_active = true; | ||
287 | } | ||
288 | } | ||
289 | } | 266 | } |
290 | 267 | ||
291 | /* BTR set to "not active" so disengage */ | 268 | /* BTR set to "not active" so disengage */ |
292 | if (!in_out_vrr->btr.btr_active) { | 269 | if (!in_out_vrr->btr.btr_active) { |
293 | in_out_vrr->btr.btr_active = false; | ||
294 | in_out_vrr->btr.inserted_duration_in_us = 0; | 270 | in_out_vrr->btr.inserted_duration_in_us = 0; |
295 | in_out_vrr->btr.frames_to_insert = 0; | 271 | in_out_vrr->btr.frames_to_insert = 0; |
296 | in_out_vrr->btr.frame_counter = 0; | 272 | in_out_vrr->btr.frame_counter = 0; |
@@ -375,7 +351,12 @@ static void apply_fixed_refresh(struct core_freesync *core_freesync, | |||
375 | bool update = false; | 351 | bool update = false; |
376 | unsigned int max_render_time_in_us = in_out_vrr->max_duration_in_us; | 352 | unsigned int max_render_time_in_us = in_out_vrr->max_duration_in_us; |
377 | 353 | ||
378 | if (last_render_time_in_us + BTR_EXIT_MARGIN < max_render_time_in_us) { | 354 | //Compute the exit refresh rate and exit frame duration |
355 | unsigned int exit_refresh_rate_in_milli_hz = ((1000000000/max_render_time_in_us) | ||
356 | + (1000*FIXED_REFRESH_EXIT_MARGIN_IN_HZ)); | ||
357 | unsigned int exit_frame_duration_in_us = 1000000000/exit_refresh_rate_in_milli_hz; | ||
358 | |||
359 | if (last_render_time_in_us < exit_frame_duration_in_us) { | ||
379 | /* Exit Fixed Refresh mode */ | 360 | /* Exit Fixed Refresh mode */ |
380 | if (in_out_vrr->fixed.fixed_active) { | 361 | if (in_out_vrr->fixed.fixed_active) { |
381 | in_out_vrr->fixed.frame_counter++; | 362 | in_out_vrr->fixed.frame_counter++; |