diff options
author | Anthony Koo <Anthony.Koo@amd.com> | 2018-04-04 20:59:43 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2018-08-27 12:10:51 -0400 |
commit | e80e9446084168c4f186f502dd15e6241bf454a1 (patch) | |
tree | 3eaa250e263ded2b8f1838f650c4e7c181787ae3 /drivers/gpu/drm/amd/display/modules/freesync/freesync.c | |
parent | 98e6436d3af5fef7ca9b59d865dd5807ede36fb9 (diff) |
drm/amd/display: add method to check for supported range
Signed-off-by: Anthony Koo <Anthony.Koo@amd.com>
Reviewed-by: Aric Cyr <Aric.Cyr@amd.com>
Acked-by: Harry Wentland <harry.wentland@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 | 64 |
1 files changed, 58 insertions, 6 deletions
diff --git a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c index 5e12e463c06a..4af73a72b9a9 100644 --- a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c +++ b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c | |||
@@ -168,6 +168,21 @@ static unsigned int calc_v_total_from_duration( | |||
168 | return v_total; | 168 | return v_total; |
169 | } | 169 | } |
170 | 170 | ||
171 | static unsigned long long calc_nominal_field_rate(const struct dc_stream_state *stream) | ||
172 | { | ||
173 | unsigned long long nominal_field_rate_in_uhz = 0; | ||
174 | |||
175 | /* Calculate nominal field rate for stream */ | ||
176 | nominal_field_rate_in_uhz = stream->timing.pix_clk_khz; | ||
177 | nominal_field_rate_in_uhz *= 1000ULL * 1000ULL * 1000ULL; | ||
178 | nominal_field_rate_in_uhz = div_u64(nominal_field_rate_in_uhz, | ||
179 | stream->timing.h_total); | ||
180 | nominal_field_rate_in_uhz = div_u64(nominal_field_rate_in_uhz, | ||
181 | stream->timing.v_total); | ||
182 | |||
183 | return nominal_field_rate_in_uhz; | ||
184 | } | ||
185 | |||
171 | static void update_v_total_for_static_ramp( | 186 | static void update_v_total_for_static_ramp( |
172 | struct core_freesync *core_freesync, | 187 | struct core_freesync *core_freesync, |
173 | const struct dc_stream_state *stream, | 188 | const struct dc_stream_state *stream, |
@@ -623,12 +638,7 @@ void mod_freesync_build_vrr_params(struct mod_freesync *mod_freesync, | |||
623 | core_freesync = MOD_FREESYNC_TO_CORE(mod_freesync); | 638 | core_freesync = MOD_FREESYNC_TO_CORE(mod_freesync); |
624 | 639 | ||
625 | /* Calculate nominal field rate for stream */ | 640 | /* Calculate nominal field rate for stream */ |
626 | nominal_field_rate_in_uhz = stream->timing.pix_clk_khz; | 641 | nominal_field_rate_in_uhz = calc_nominal_field_rate(stream); |
627 | nominal_field_rate_in_uhz *= 1000ULL * 1000ULL * 1000ULL; | ||
628 | nominal_field_rate_in_uhz = div_u64(nominal_field_rate_in_uhz, | ||
629 | stream->timing.h_total); | ||
630 | nominal_field_rate_in_uhz = div_u64(nominal_field_rate_in_uhz, | ||
631 | stream->timing.v_total); | ||
632 | 642 | ||
633 | min_refresh_in_uhz = in_config->min_refresh_in_uhz; | 643 | min_refresh_in_uhz = in_config->min_refresh_in_uhz; |
634 | max_refresh_in_uhz = in_config->max_refresh_in_uhz; | 644 | max_refresh_in_uhz = in_config->max_refresh_in_uhz; |
@@ -878,3 +888,45 @@ void mod_freesync_get_settings(struct mod_freesync *mod_freesync, | |||
878 | } | 888 | } |
879 | } | 889 | } |
880 | 890 | ||
891 | bool mod_freesync_is_valid_range(struct mod_freesync *mod_freesync, | ||
892 | const struct dc_stream_state *stream, | ||
893 | uint32_t min_refresh_cap_in_uhz, | ||
894 | uint32_t max_refresh_cap_in_uhz, | ||
895 | uint32_t min_refresh_request_in_uhz, | ||
896 | uint32_t max_refresh_request_in_uhz) | ||
897 | { | ||
898 | /* Calculate nominal field rate for stream */ | ||
899 | unsigned long long nominal_field_rate_in_uhz = | ||
900 | calc_nominal_field_rate(stream); | ||
901 | |||
902 | // Check nominal is within range | ||
903 | if (nominal_field_rate_in_uhz > max_refresh_cap_in_uhz || | ||
904 | nominal_field_rate_in_uhz < min_refresh_cap_in_uhz) | ||
905 | return false; | ||
906 | |||
907 | // If nominal is less than max, limit the max allowed refresh rate | ||
908 | if (nominal_field_rate_in_uhz < max_refresh_cap_in_uhz) | ||
909 | max_refresh_cap_in_uhz = nominal_field_rate_in_uhz; | ||
910 | |||
911 | // Don't allow min > max | ||
912 | if (min_refresh_request_in_uhz > max_refresh_request_in_uhz) | ||
913 | return false; | ||
914 | |||
915 | // Check min is within range | ||
916 | if (min_refresh_request_in_uhz > max_refresh_cap_in_uhz || | ||
917 | min_refresh_request_in_uhz < min_refresh_cap_in_uhz) | ||
918 | return false; | ||
919 | |||
920 | // Check max is within range | ||
921 | if (max_refresh_request_in_uhz > max_refresh_cap_in_uhz || | ||
922 | max_refresh_request_in_uhz < min_refresh_cap_in_uhz) | ||
923 | return false; | ||
924 | |||
925 | // For variable range, check for at least 10 Hz range | ||
926 | if ((max_refresh_request_in_uhz != min_refresh_request_in_uhz) && | ||
927 | (max_refresh_request_in_uhz - min_refresh_request_in_uhz < 10000000)) | ||
928 | return false; | ||
929 | |||
930 | return true; | ||
931 | } | ||
932 | |||