Lines Matching +full:fixed +full:- +full:rate
2 * Copyright 2016-2023 Advanced Micro Devices, Inc.
34 /* Refresh rate ramp at a fixed rate of 65 Hz/second */
38 /* Threshold to exit/exit BTR (to avoid frequent enter-exits at the lower limit) */
42 /* Threshold to exit fixed refresh rate */
44 /* Number of consecutive frames to check before entering/exiting fixed refresh */
71 core_freesync->dc = dc; in mod_freesync_create()
72 return &core_freesync->public; in mod_freesync_create()
118 * 10000) * stream->timing.h_total, in calc_duration_in_us_from_v_total()
119 stream->timing.pix_clk_100hz)); in calc_duration_in_us_from_v_total()
136 frame_duration_in_ns) * (stream->timing.pix_clk_100hz / 10)), in mod_freesync_calc_v_total_from_refresh()
137 stream->timing.h_total) + 500000, 1000000); in mod_freesync_calc_v_total_from_refresh()
140 if (v_total < stream->timing.v_total) { in mod_freesync_calc_v_total_from_refresh()
141 ASSERT(v_total < stream->timing.v_total); in mod_freesync_calc_v_total_from_refresh()
142 v_total = stream->timing.v_total; in mod_freesync_calc_v_total_from_refresh()
155 if (duration_in_us < vrr->min_duration_in_us) in calc_v_total_from_duration()
156 duration_in_us = vrr->min_duration_in_us; in calc_v_total_from_duration()
158 if (duration_in_us > vrr->max_duration_in_us) in calc_v_total_from_duration()
159 duration_in_us = vrr->max_duration_in_us; in calc_v_total_from_duration()
161 if (dc_is_hdmi_signal(stream->signal)) { // change for HDMI to comply with spec in calc_v_total_from_duration()
164 h_total_up_scaled = stream->timing.h_total * 10000; in calc_v_total_from_duration()
166 * stream->timing.pix_clk_100hz + (h_total_up_scaled - 1), in calc_v_total_from_duration()
170 duration_in_us) * (stream->timing.pix_clk_100hz / 10)), in calc_v_total_from_duration()
171 stream->timing.h_total), 1000); in calc_v_total_from_duration()
175 if (v_total < stream->timing.v_total) { in calc_v_total_from_duration()
176 ASSERT(v_total < stream->timing.v_total); in calc_v_total_from_duration()
177 v_total = stream->timing.v_total; in calc_v_total_from_duration()
192 in_out_vrr->adjust.v_total_max); in update_v_total_for_static_ramp()
195 in_out_vrr->fixed.target_refresh_in_uhz); in update_v_total_for_static_ramp()
209 (1000 - frame_duration_ratio)), 1000); in update_v_total_for_static_ramp()
212 * standard frame duration (frame duration at 60 Hz refresh rate). in update_v_total_for_static_ramp()
217 /* Going to a higher refresh rate (lower frame duration) */ in update_v_total_for_static_ramp()
220 current_duration_in_us -= ramp_rate_interpolated; in update_v_total_for_static_ramp()
224 in_out_vrr->fixed.ramping_active = false; in update_v_total_for_static_ramp()
225 in_out_vrr->fixed.ramping_done = true; in update_v_total_for_static_ramp()
228 in_out_vrr->fixed.target_refresh_in_uhz); in update_v_total_for_static_ramp()
230 /* Going to a lower refresh rate (larger frame duration) */ in update_v_total_for_static_ramp()
237 in_out_vrr->fixed.ramping_active = false; in update_v_total_for_static_ramp()
238 in_out_vrr->fixed.ramping_done = true; in update_v_total_for_static_ramp()
241 in_out_vrr->fixed.target_refresh_in_uhz); in update_v_total_for_static_ramp()
246 current_duration_in_us) * (stream->timing.pix_clk_100hz / 10)), in update_v_total_for_static_ramp()
247 stream->timing.h_total), 1000); in update_v_total_for_static_ramp()
250 if (v_total < stream->timing.v_total) in update_v_total_for_static_ramp()
251 v_total = stream->timing.v_total; in update_v_total_for_static_ramp()
253 in_out_vrr->adjust.v_total_min = v_total; in update_v_total_for_static_ramp()
254 in_out_vrr->adjust.v_total_max = v_total; in update_v_total_for_static_ramp()
271 in_out_vrr->max_duration_in_us - in_out_vrr->btr.margin_in_us; in apply_below_the_range()
274 if ((last_render_time_in_us + in_out_vrr->btr.margin_in_us / 2) < max_render_time_in_us) { in apply_below_the_range()
276 if (in_out_vrr->btr.btr_active) { in apply_below_the_range()
277 in_out_vrr->btr.frame_counter = 0; in apply_below_the_range()
278 in_out_vrr->btr.btr_active = false; in apply_below_the_range()
280 } else if (last_render_time_in_us > (max_render_time_in_us + in_out_vrr->btr.margin_in_us / 2)) { in apply_below_the_range()
282 if (!in_out_vrr->btr.btr_active) in apply_below_the_range()
283 in_out_vrr->btr.btr_active = true; in apply_below_the_range()
287 if (!in_out_vrr->btr.btr_active) { in apply_below_the_range()
288 in_out_vrr->btr.inserted_duration_in_us = 0; in apply_below_the_range()
289 in_out_vrr->btr.frames_to_insert = 0; in apply_below_the_range()
290 in_out_vrr->btr.frame_counter = 0; in apply_below_the_range()
293 in_out_vrr->adjust.v_total_min = in apply_below_the_range()
295 in_out_vrr->max_refresh_in_uhz); in apply_below_the_range()
296 in_out_vrr->adjust.v_total_max = in apply_below_the_range()
298 in_out_vrr->min_refresh_in_uhz); in apply_below_the_range()
303 * the render time interval - take ceil of this value in apply_below_the_range()
306 in_out_vrr->btr.mid_point_in_us - 1) / in apply_below_the_range()
307 in_out_vrr->btr.mid_point_in_us; in apply_below_the_range()
313 (in_out_vrr->btr.mid_point_in_us > in apply_below_the_range()
315 (in_out_vrr->btr.mid_point_in_us - frame_time_in_us) : in apply_below_the_range()
316 (frame_time_in_us - in_out_vrr->btr.mid_point_in_us); in apply_below_the_range()
320 * the render time interval - take floor of this value in apply_below_the_range()
323 in_out_vrr->btr.mid_point_in_us; in apply_below_the_range()
330 (in_out_vrr->btr.mid_point_in_us > in apply_below_the_range()
332 (in_out_vrr->btr.mid_point_in_us - frame_time_in_us) : in apply_below_the_range()
333 (frame_time_in_us - in_out_vrr->btr.mid_point_in_us); in apply_below_the_range()
338 * - Delta for CEIL: delta_from_mid_point_in_us_1 in apply_below_the_range()
339 * - Delta for FLOOR: delta_from_mid_point_in_us_2 in apply_below_the_range()
343 in_out_vrr->min_duration_in_us) { in apply_below_the_range()
350 /* Check if FLOOR would result in non-LFC. In this case in apply_below_the_range()
372 delta_from_mid_point_delta_in_us = delta_from_mid_point_in_us_2 - in apply_below_the_range()
375 delta_from_mid_point_delta_in_us = delta_from_mid_point_in_us_1 - in apply_below_the_range()
378 if (in_out_vrr->btr.frames_to_insert != 0 && in apply_below_the_range()
380 if (((last_render_time_in_us / in_out_vrr->btr.frames_to_insert) < in apply_below_the_range()
382 ((last_render_time_in_us / in_out_vrr->btr.frames_to_insert) > in apply_below_the_range()
383 in_out_vrr->min_duration_in_us)) in apply_below_the_range()
384 frames_to_insert = in_out_vrr->btr.frames_to_insert; in apply_below_the_range()
392 in_out_vrr->min_duration_in_us){ in apply_below_the_range()
393 frames_to_insert -= (frames_to_insert > 1) ? in apply_below_the_range()
401 if (inserted_frame_duration_in_us < in_out_vrr->min_duration_in_us) in apply_below_the_range()
402 inserted_frame_duration_in_us = in_out_vrr->min_duration_in_us; in apply_below_the_range()
405 in_out_vrr->btr.inserted_duration_in_us = in apply_below_the_range()
407 in_out_vrr->btr.frames_to_insert = frames_to_insert; in apply_below_the_range()
408 in_out_vrr->btr.frame_counter = frames_to_insert; in apply_below_the_range()
418 unsigned int max_render_time_in_us = in_out_vrr->max_duration_in_us; in apply_fixed_refresh()
420 /* Compute the exit refresh rate and exit frame duration */ in apply_fixed_refresh()
426 /* Exit Fixed Refresh mode */ in apply_fixed_refresh()
427 if (in_out_vrr->fixed.fixed_active) { in apply_fixed_refresh()
428 in_out_vrr->fixed.frame_counter++; in apply_fixed_refresh()
430 if (in_out_vrr->fixed.frame_counter > in apply_fixed_refresh()
432 in_out_vrr->fixed.frame_counter = 0; in apply_fixed_refresh()
433 in_out_vrr->fixed.fixed_active = false; in apply_fixed_refresh()
434 in_out_vrr->fixed.target_refresh_in_uhz = 0; in apply_fixed_refresh()
438 in_out_vrr->fixed.frame_counter = 0; in apply_fixed_refresh()
440 /* Enter Fixed Refresh mode */ in apply_fixed_refresh()
441 if (!in_out_vrr->fixed.fixed_active) { in apply_fixed_refresh()
442 in_out_vrr->fixed.frame_counter++; in apply_fixed_refresh()
444 if (in_out_vrr->fixed.frame_counter > in apply_fixed_refresh()
446 in_out_vrr->fixed.frame_counter = 0; in apply_fixed_refresh()
447 in_out_vrr->fixed.fixed_active = true; in apply_fixed_refresh()
448 in_out_vrr->fixed.target_refresh_in_uhz = in apply_fixed_refresh()
449 in_out_vrr->max_refresh_in_uhz; in apply_fixed_refresh()
453 in_out_vrr->fixed.frame_counter = 0; in apply_fixed_refresh()
457 if (in_out_vrr->fixed.fixed_active) { in apply_fixed_refresh()
458 in_out_vrr->adjust.v_total_min = in apply_fixed_refresh()
460 stream, in_out_vrr->max_refresh_in_uhz); in apply_fixed_refresh()
461 in_out_vrr->adjust.v_total_max = in apply_fixed_refresh()
462 in_out_vrr->adjust.v_total_min; in apply_fixed_refresh()
464 in_out_vrr->adjust.v_total_min = in apply_fixed_refresh()
466 in_out_vrr->max_refresh_in_uhz); in apply_fixed_refresh()
467 in_out_vrr->adjust.v_total_max = in apply_fixed_refresh()
469 in_out_vrr->min_refresh_in_uhz); in apply_fixed_refresh()
477 in_vrr->flip_interval.vsync_to_flip_in_us = curr_time_stamp_in_us - in determine_flip_interval_workaround_req()
478 in_vrr->flip_interval.v_update_timestamp_in_us; in determine_flip_interval_workaround_req()
481 if (in_vrr->flip_interval.flip_interval_workaround_active && in determine_flip_interval_workaround_req()
482 in_vrr->flip_interval.vsyncs_between_flip < VSYNCS_BETWEEN_FLIP_THRESHOLD && in determine_flip_interval_workaround_req()
483 in_vrr->flip_interval.vsync_to_flip_in_us > FREESYNC_VSYNC_TO_FLIP_DELTA_IN_US) { in determine_flip_interval_workaround_req()
484 in_vrr->flip_interval.flip_interval_detect_counter = 0; in determine_flip_interval_workaround_req()
485 in_vrr->flip_interval.program_flip_interval_workaround = true; in determine_flip_interval_workaround_req()
486 in_vrr->flip_interval.flip_interval_workaround_active = false; in determine_flip_interval_workaround_req()
489 if (in_vrr->flip_interval.vsyncs_between_flip >= VSYNCS_BETWEEN_FLIP_THRESHOLD && in determine_flip_interval_workaround_req()
490 in_vrr->flip_interval.vsync_to_flip_in_us < FREESYNC_VSYNC_TO_FLIP_DELTA_IN_US) { in determine_flip_interval_workaround_req()
494 in_vrr->flip_interval.flip_interval_detect_counter++; in determine_flip_interval_workaround_req()
495 if (in_vrr->flip_interval.flip_interval_detect_counter > FREESYNC_CONSEC_FLIP_AFTER_VSYNC) { in determine_flip_interval_workaround_req()
497 in_vrr->flip_interval.program_flip_interval_workaround = true; in determine_flip_interval_workaround_req()
498 in_vrr->flip_interval.flip_interval_workaround_active = true; in determine_flip_interval_workaround_req()
502 in_vrr->flip_interval.flip_interval_detect_counter = 0; in determine_flip_interval_workaround_req()
506 in_vrr->flip_interval.vsyncs_between_flip = 0; in determine_flip_interval_workaround_req()
515 if (in_vrr->state != in_config->state) { in vrr_settings_require_update()
517 } else if (in_vrr->state == VRR_STATE_ACTIVE_FIXED && in vrr_settings_require_update()
518 in_vrr->fixed.target_refresh_in_uhz != in vrr_settings_require_update()
519 in_config->fixed_refresh_in_uhz) { in vrr_settings_require_update()
521 } else if (in_vrr->min_refresh_in_uhz != min_refresh_in_uhz) { in vrr_settings_require_update()
523 } else if (in_vrr->max_refresh_in_uhz != max_refresh_in_uhz) { in vrr_settings_require_update()
535 *vmin = stream->adjust.v_total_min; in mod_freesync_get_vmin_vmax()
536 *vmax = stream->adjust.v_total_max; in mod_freesync_get_vmin_vmax()
554 if (dc_stream_get_crtc_position(core_freesync->dc, &stream, 1, in mod_freesync_get_v_position()
571 /* PB1 = 0x1A (24bit AMD IEEE OUI (0x00001A) - Byte 0) */ in build_vrr_infopacket_data_v1()
572 infopacket->sb[1] = 0x1A; in build_vrr_infopacket_data_v1()
574 /* PB2 = 0x00 (24bit AMD IEEE OUI (0x00001A) - Byte 1) */ in build_vrr_infopacket_data_v1()
575 infopacket->sb[2] = 0x00; in build_vrr_infopacket_data_v1()
577 /* PB3 = 0x00 (24bit AMD IEEE OUI (0x00001A) - Byte 2) */ in build_vrr_infopacket_data_v1()
578 infopacket->sb[3] = 0x00; in build_vrr_infopacket_data_v1()
587 if (vrr->state != VRR_STATE_UNSUPPORTED) in build_vrr_infopacket_data_v1()
588 infopacket->sb[6] |= 0x01; in build_vrr_infopacket_data_v1()
591 if (vrr->state != VRR_STATE_DISABLED && in build_vrr_infopacket_data_v1()
592 vrr->state != VRR_STATE_UNSUPPORTED) in build_vrr_infopacket_data_v1()
593 infopacket->sb[6] |= 0x02; in build_vrr_infopacket_data_v1()
597 if (vrr->state != VRR_STATE_DISABLED && in build_vrr_infopacket_data_v1()
598 vrr->state != VRR_STATE_UNSUPPORTED) in build_vrr_infopacket_data_v1()
599 infopacket->sb[6] |= 0x04; in build_vrr_infopacket_data_v1()
601 if (vrr->state == VRR_STATE_ACTIVE_VARIABLE || in build_vrr_infopacket_data_v1()
602 vrr->state == VRR_STATE_ACTIVE_FIXED) in build_vrr_infopacket_data_v1()
603 infopacket->sb[6] |= 0x04; in build_vrr_infopacket_data_v1()
606 // For v1 & 2 infoframes program nominal if non-fs mode, otherwise full range in build_vrr_infopacket_data_v1()
607 /* PB7 = FreeSync Minimum refresh rate (Hz) */ in build_vrr_infopacket_data_v1()
608 if (vrr->state == VRR_STATE_ACTIVE_VARIABLE || in build_vrr_infopacket_data_v1()
609 vrr->state == VRR_STATE_ACTIVE_FIXED) { in build_vrr_infopacket_data_v1()
610 infopacket->sb[7] = (unsigned char)((vrr->min_refresh_in_uhz + 500000) / 1000000); in build_vrr_infopacket_data_v1()
612 infopacket->sb[7] = (unsigned char)((vrr->max_refresh_in_uhz + 500000) / 1000000); in build_vrr_infopacket_data_v1()
615 /* PB8 = FreeSync Maximum refresh rate (Hz) in build_vrr_infopacket_data_v1()
616 * Note: We should never go above the field rate of the mode timing set. in build_vrr_infopacket_data_v1()
618 infopacket->sb[8] = (unsigned char)((vrr->max_refresh_in_uhz + 500000) / 1000000); in build_vrr_infopacket_data_v1()
630 /* PB1 = 0x1A (24bit AMD IEEE OUI (0x00001A) - Byte 0) */ in build_vrr_infopacket_data_v3()
631 infopacket->sb[1] = 0x1A; in build_vrr_infopacket_data_v3()
633 /* PB2 = 0x00 (24bit AMD IEEE OUI (0x00001A) - Byte 1) */ in build_vrr_infopacket_data_v3()
634 infopacket->sb[2] = 0x00; in build_vrr_infopacket_data_v3()
636 /* PB3 = 0x00 (24bit AMD IEEE OUI (0x00001A) - Byte 2) */ in build_vrr_infopacket_data_v3()
637 infopacket->sb[3] = 0x00; in build_vrr_infopacket_data_v3()
646 if (vrr->state != VRR_STATE_UNSUPPORTED) in build_vrr_infopacket_data_v3()
647 infopacket->sb[6] |= 0x01; in build_vrr_infopacket_data_v3()
650 if (vrr->state != VRR_STATE_DISABLED && in build_vrr_infopacket_data_v3()
651 vrr->state != VRR_STATE_UNSUPPORTED) in build_vrr_infopacket_data_v3()
652 infopacket->sb[6] |= 0x02; in build_vrr_infopacket_data_v3()
656 if (vrr->state != VRR_STATE_DISABLED && in build_vrr_infopacket_data_v3()
657 vrr->state != VRR_STATE_UNSUPPORTED) in build_vrr_infopacket_data_v3()
658 infopacket->sb[6] |= 0x04; in build_vrr_infopacket_data_v3()
660 if (vrr->state == VRR_STATE_ACTIVE_VARIABLE || in build_vrr_infopacket_data_v3()
661 vrr->state == VRR_STATE_ACTIVE_FIXED) in build_vrr_infopacket_data_v3()
662 infopacket->sb[6] |= 0x04; in build_vrr_infopacket_data_v3()
665 min_refresh = (vrr->min_refresh_in_uhz + 500000) / 1000000; in build_vrr_infopacket_data_v3()
666 max_refresh = (vrr->max_refresh_in_uhz + 500000) / 1000000; in build_vrr_infopacket_data_v3()
667 fixed_refresh = (vrr->fixed_refresh_in_uhz + 500000) / 1000000; in build_vrr_infopacket_data_v3()
669 min_programmed = (vrr->state == VRR_STATE_ACTIVE_FIXED) ? fixed_refresh : in build_vrr_infopacket_data_v3()
670 (vrr->state == VRR_STATE_ACTIVE_VARIABLE) ? min_refresh : in build_vrr_infopacket_data_v3()
671 (vrr->state == VRR_STATE_INACTIVE) ? min_refresh : in build_vrr_infopacket_data_v3()
672 max_refresh; // Non-fs case, program nominal range in build_vrr_infopacket_data_v3()
674 /* PB7 = FreeSync Minimum refresh rate (Hz) */ in build_vrr_infopacket_data_v3()
675 infopacket->sb[7] = min_programmed & 0xFF; in build_vrr_infopacket_data_v3()
677 /* PB8 = FreeSync Maximum refresh rate (Hz) */ in build_vrr_infopacket_data_v3()
678 infopacket->sb[8] = max_refresh & 0xFF; in build_vrr_infopacket_data_v3()
680 /* PB11 : MSB FreeSync Minimum refresh rate [Hz] - bits 9:8 */ in build_vrr_infopacket_data_v3()
681 infopacket->sb[11] = (min_programmed >> 8) & 0x03; in build_vrr_infopacket_data_v3()
683 /* PB12 : MSB FreeSync Maximum refresh rate [Hz] - bits 9:8 */ in build_vrr_infopacket_data_v3()
684 infopacket->sb[12] = (max_refresh >> 8) & 0x03; in build_vrr_infopacket_data_v3()
687 infopacket->sb[16] = (vrr->state == VRR_STATE_ACTIVE_FIXED) ? 1 : 0; in build_vrr_infopacket_data_v3()
694 infopacket->valid = true; in build_vrr_infopacket_fs2_data()
697 infopacket->sb[9] |= 0x20; // PB9 = [Bit 5 = PQ EOTF Active] in build_vrr_infopacket_fs2_data()
699 infopacket->sb[6] |= 0x08; // PB6 = [Bit 3 = Native Color Active] in build_vrr_infopacket_fs2_data()
701 infopacket->sb[9] |= 0x04; // PB9 = [Bit 2 = Gamma 2.2 EOTF Active] in build_vrr_infopacket_fs2_data()
717 infopacket->hb0 = DC_HDMI_INFOFRAME_TYPE_SPD; in build_vrr_infopacket_header_v1()
720 infopacket->hb1 = 0x01; in build_vrr_infopacket_header_v1()
723 infopacket->hb2 = 0x08; in build_vrr_infopacket_header_v1()
731 /* HB0 = Secondary-data Packet ID = 0 - Only non-zero in build_vrr_infopacket_header_v1()
734 infopacket->hb0 = 0x00; in build_vrr_infopacket_header_v1()
739 infopacket->hb1 = DC_HDMI_INFOFRAME_TYPE_SPD; in build_vrr_infopacket_header_v1()
741 /* HB2 = [Bits 7:0 = Least significant eight bits - in build_vrr_infopacket_header_v1()
744 infopacket->hb2 = 0x1B; in build_vrr_infopacket_header_v1()
749 infopacket->hb3 = 0x04; in build_vrr_infopacket_header_v1()
766 infopacket->hb0 = DC_HDMI_INFOFRAME_TYPE_SPD; in build_vrr_infopacket_header_v2()
769 infopacket->hb1 = 0x02; in build_vrr_infopacket_header_v2()
772 infopacket->hb2 = 0x09; in build_vrr_infopacket_header_v2()
779 /* HB0 = Secondary-data Packet ID = 0 - Only non-zero in build_vrr_infopacket_header_v2()
782 infopacket->hb0 = 0x00; in build_vrr_infopacket_header_v2()
787 infopacket->hb1 = DC_HDMI_INFOFRAME_TYPE_SPD; in build_vrr_infopacket_header_v2()
789 /* HB2 = [Bits 7:0 = Least significant eight bits - in build_vrr_infopacket_header_v2()
792 infopacket->hb2 = 0x1B; in build_vrr_infopacket_header_v2()
797 infopacket->hb3 = 0x08; in build_vrr_infopacket_header_v2()
817 infopacket->hb0 = DC_HDMI_INFOFRAME_TYPE_SPD; in build_vrr_infopacket_header_v3()
820 infopacket->hb1 = version; in build_vrr_infopacket_header_v3()
823 infopacket->hb2 = 0x10; in build_vrr_infopacket_header_v3()
830 /* HB0 = Secondary-data Packet ID = 0 - Only non-zero in build_vrr_infopacket_header_v3()
833 infopacket->hb0 = 0x00; in build_vrr_infopacket_header_v3()
838 infopacket->hb1 = DC_HDMI_INFOFRAME_TYPE_SPD; in build_vrr_infopacket_header_v3()
840 /* HB2 = [Bits 7:0 = Least significant eight bits - in build_vrr_infopacket_header_v3()
843 infopacket->hb2 = 0x1B; in build_vrr_infopacket_header_v3()
849 infopacket->hb3 = (version & 0x3F) << 2; in build_vrr_infopacket_header_v3()
862 checksum += infopacket->hb0; in build_vrr_infopacket_checksum()
863 checksum += infopacket->hb1; in build_vrr_infopacket_checksum()
864 checksum += infopacket->hb2; in build_vrr_infopacket_checksum()
865 checksum += infopacket->hb3; in build_vrr_infopacket_checksum()
868 checksum += infopacket->sb[idx]; in build_vrr_infopacket_checksum()
871 infopacket->sb[0] = (unsigned char)(0x100 - checksum); in build_vrr_infopacket_checksum()
873 infopacket->valid = true; in build_vrr_infopacket_checksum()
888 infopacket->valid = true; in build_vrr_infopacket_v1()
906 infopacket->valid = true; in build_vrr_infopacket_v2()
924 infopacket->valid = true; in build_vrr_infopacket_v3()
936 for (idx = infopacket->hb2; idx > 1; idx--) // Data Byte Count: 0x1B in build_vrr_infopacket_sdp_v1_3()
937 infopacket->sb[idx] = infopacket->sb[idx-1]; in build_vrr_infopacket_sdp_v1_3()
939 infopacket->sb[1] = size; // Length in build_vrr_infopacket_sdp_v1_3()
940 infopacket->sb[0] = (infopacket->hb3 >> 2) & 0x3F;//Version in build_vrr_infopacket_sdp_v1_3()
941 infopacket->hb3 = (0x13 << 2); // Header,SDP 1.3 in build_vrr_infopacket_sdp_v1_3()
942 infopacket->hb2 = 0x1D; in build_vrr_infopacket_sdp_v1_3()
958 if (!vrr->send_info_frame) in mod_freesync_build_vrr_infopacket()
963 build_vrr_infopacket_v3(stream->signal, vrr, app_tf, infopacket, stream->freesync_on_desktop); in mod_freesync_build_vrr_infopacket()
966 build_vrr_infopacket_v2(stream->signal, vrr, app_tf, infopacket, stream->freesync_on_desktop); in mod_freesync_build_vrr_infopacket()
971 build_vrr_infopacket_v1(stream->signal, vrr, infopacket, stream->freesync_on_desktop); in mod_freesync_build_vrr_infopacket()
975 true == dc_is_dp_signal(stream->signal) && in mod_freesync_build_vrr_infopacket()
999 /* Calculate nominal field rate for stream */ in mod_freesync_build_vrr_params()
1003 if (stream->ctx->dc->caps.max_v_total != 0 && stream->timing.h_total != 0) { in mod_freesync_build_vrr_params()
1004 min_hardware_refresh_in_uhz = div64_u64((stream->timing.pix_clk_100hz * 100000000ULL), in mod_freesync_build_vrr_params()
1005 (stream->timing.h_total * (long long)stream->ctx->dc->caps.max_v_total)); in mod_freesync_build_vrr_params()
1007 /* Limit minimum refresh rate to what can be supported by hardware */ in mod_freesync_build_vrr_params()
1008 min_refresh_in_uhz = min_hardware_refresh_in_uhz > in_config->min_refresh_in_uhz ? in mod_freesync_build_vrr_params()
1009 min_hardware_refresh_in_uhz : in_config->min_refresh_in_uhz; in mod_freesync_build_vrr_params()
1010 max_refresh_in_uhz = in_config->max_refresh_in_uhz; in mod_freesync_build_vrr_params()
1023 if (in_config->max_refresh_in_uhz == (2 * in_config->min_refresh_in_uhz) && in mod_freesync_build_vrr_params()
1024 in_config->max_refresh_in_uhz == rounded_nominal_in_uhz) in mod_freesync_build_vrr_params()
1032 in_out_vrr->state = in_config->state; in mod_freesync_build_vrr_params()
1033 in_out_vrr->send_info_frame = in_config->vsif_supported; in mod_freesync_build_vrr_params()
1035 if (in_config->state == VRR_STATE_UNSUPPORTED) { in mod_freesync_build_vrr_params()
1036 in_out_vrr->state = VRR_STATE_UNSUPPORTED; in mod_freesync_build_vrr_params()
1037 in_out_vrr->supported = false; in mod_freesync_build_vrr_params()
1038 in_out_vrr->adjust.v_total_min = stream->timing.v_total; in mod_freesync_build_vrr_params()
1039 in_out_vrr->adjust.v_total_max = stream->timing.v_total; in mod_freesync_build_vrr_params()
1044 in_out_vrr->min_refresh_in_uhz = (unsigned int)min_refresh_in_uhz; in mod_freesync_build_vrr_params()
1045 in_out_vrr->max_duration_in_us = in mod_freesync_build_vrr_params()
1049 in_out_vrr->max_refresh_in_uhz = (unsigned int)max_refresh_in_uhz; in mod_freesync_build_vrr_params()
1050 in_out_vrr->min_duration_in_us = in mod_freesync_build_vrr_params()
1054 if (in_config->state == VRR_STATE_ACTIVE_FIXED) in mod_freesync_build_vrr_params()
1055 in_out_vrr->fixed_refresh_in_uhz = in_config->fixed_refresh_in_uhz; in mod_freesync_build_vrr_params()
1057 in_out_vrr->fixed_refresh_in_uhz = 0; in mod_freesync_build_vrr_params()
1059 refresh_range = div_u64(in_out_vrr->max_refresh_in_uhz + 500000, 1000000) - in mod_freesync_build_vrr_params()
1060 div_u64(in_out_vrr->min_refresh_in_uhz + 500000, 1000000); in mod_freesync_build_vrr_params()
1062 in_out_vrr->supported = true; in mod_freesync_build_vrr_params()
1065 in_out_vrr->fixed.ramping_active = in_config->ramping; in mod_freesync_build_vrr_params()
1067 in_out_vrr->btr.btr_enabled = in_config->btr; in mod_freesync_build_vrr_params()
1069 if (in_out_vrr->max_refresh_in_uhz < (2 * in_out_vrr->min_refresh_in_uhz)) in mod_freesync_build_vrr_params()
1070 in_out_vrr->btr.btr_enabled = false; in mod_freesync_build_vrr_params()
1072 in_out_vrr->btr.margin_in_us = in_out_vrr->max_duration_in_us - in mod_freesync_build_vrr_params()
1073 2 * in_out_vrr->min_duration_in_us; in mod_freesync_build_vrr_params()
1074 if (in_out_vrr->btr.margin_in_us > BTR_MAX_MARGIN) in mod_freesync_build_vrr_params()
1075 in_out_vrr->btr.margin_in_us = BTR_MAX_MARGIN; in mod_freesync_build_vrr_params()
1078 in_out_vrr->btr.btr_active = false; in mod_freesync_build_vrr_params()
1079 in_out_vrr->btr.inserted_duration_in_us = 0; in mod_freesync_build_vrr_params()
1080 in_out_vrr->btr.frames_to_insert = 0; in mod_freesync_build_vrr_params()
1081 in_out_vrr->btr.frame_counter = 0; in mod_freesync_build_vrr_params()
1082 in_out_vrr->fixed.fixed_active = false; in mod_freesync_build_vrr_params()
1083 in_out_vrr->fixed.target_refresh_in_uhz = 0; in mod_freesync_build_vrr_params()
1085 in_out_vrr->btr.mid_point_in_us = in mod_freesync_build_vrr_params()
1086 (in_out_vrr->min_duration_in_us + in mod_freesync_build_vrr_params()
1087 in_out_vrr->max_duration_in_us) / 2; in mod_freesync_build_vrr_params()
1089 if (in_out_vrr->state == VRR_STATE_UNSUPPORTED) { in mod_freesync_build_vrr_params()
1090 in_out_vrr->adjust.v_total_min = stream->timing.v_total; in mod_freesync_build_vrr_params()
1091 in_out_vrr->adjust.v_total_max = stream->timing.v_total; in mod_freesync_build_vrr_params()
1092 } else if (in_out_vrr->state == VRR_STATE_DISABLED) { in mod_freesync_build_vrr_params()
1093 in_out_vrr->adjust.v_total_min = stream->timing.v_total; in mod_freesync_build_vrr_params()
1094 in_out_vrr->adjust.v_total_max = stream->timing.v_total; in mod_freesync_build_vrr_params()
1095 } else if (in_out_vrr->state == VRR_STATE_INACTIVE) { in mod_freesync_build_vrr_params()
1096 in_out_vrr->adjust.v_total_min = stream->timing.v_total; in mod_freesync_build_vrr_params()
1097 in_out_vrr->adjust.v_total_max = stream->timing.v_total; in mod_freesync_build_vrr_params()
1098 } else if (in_out_vrr->state == VRR_STATE_ACTIVE_VARIABLE && in mod_freesync_build_vrr_params()
1101 in_out_vrr->adjust.v_total_min = in mod_freesync_build_vrr_params()
1103 in_out_vrr->max_refresh_in_uhz); in mod_freesync_build_vrr_params()
1104 in_out_vrr->adjust.v_total_max = in mod_freesync_build_vrr_params()
1106 in_out_vrr->min_refresh_in_uhz); in mod_freesync_build_vrr_params()
1107 } else if (in_out_vrr->state == VRR_STATE_ACTIVE_FIXED) { in mod_freesync_build_vrr_params()
1108 in_out_vrr->fixed.target_refresh_in_uhz = in mod_freesync_build_vrr_params()
1109 in_out_vrr->fixed_refresh_in_uhz; in mod_freesync_build_vrr_params()
1110 if (in_out_vrr->fixed.ramping_active && in mod_freesync_build_vrr_params()
1111 in_out_vrr->fixed.fixed_active) { in mod_freesync_build_vrr_params()
1115 in_out_vrr->fixed.fixed_active = true; in mod_freesync_build_vrr_params()
1117 in_out_vrr->fixed.fixed_active = true; in mod_freesync_build_vrr_params()
1118 in_out_vrr->adjust.v_total_min = in mod_freesync_build_vrr_params()
1120 in_out_vrr->fixed.target_refresh_in_uhz); in mod_freesync_build_vrr_params()
1121 in_out_vrr->adjust.v_total_max = in mod_freesync_build_vrr_params()
1122 in_out_vrr->adjust.v_total_min; in mod_freesync_build_vrr_params()
1125 in_out_vrr->state = VRR_STATE_INACTIVE; in mod_freesync_build_vrr_params()
1126 in_out_vrr->adjust.v_total_min = stream->timing.v_total; in mod_freesync_build_vrr_params()
1127 in_out_vrr->adjust.v_total_max = stream->timing.v_total; in mod_freesync_build_vrr_params()
1130 …in_out_vrr->adjust.allow_otg_v_count_halt = (in_config->state == VRR_STATE_ACTIVE_FIXED) ? true : … in mod_freesync_build_vrr_params()
1147 if (in_out_vrr->supported && in mod_freesync_handle_preflip()
1148 in_out_vrr->state == VRR_STATE_ACTIVE_VARIABLE) { in mod_freesync_handle_preflip()
1150 last_render_time_in_us = curr_time_stamp_in_us - in mod_freesync_handle_preflip()
1151 plane->time.prev_update_time_in_us; in mod_freesync_handle_preflip()
1153 if (in_out_vrr->btr.btr_enabled) { in mod_freesync_handle_preflip()
1184 if (in_out_vrr->supported == false) in mod_freesync_handle_v_update()
1187 cur_tick = dm_get_timestamp(core_freesync->dc->ctx); in mod_freesync_handle_v_update()
1189 div_u64(dm_get_elapse_time_in_ns(core_freesync->dc->ctx, cur_tick, 0), 1000); in mod_freesync_handle_v_update()
1191 in_out_vrr->flip_interval.vsyncs_between_flip++; in mod_freesync_handle_v_update()
1192 in_out_vrr->flip_interval.v_update_timestamp_in_us = cur_timestamp_in_us; in mod_freesync_handle_v_update()
1194 if (in_out_vrr->state == VRR_STATE_ACTIVE_VARIABLE && in mod_freesync_handle_v_update()
1195 (in_out_vrr->flip_interval.flip_interval_workaround_active || in mod_freesync_handle_v_update()
1196 (!in_out_vrr->flip_interval.flip_interval_workaround_active && in mod_freesync_handle_v_update()
1197 in_out_vrr->flip_interval.program_flip_interval_workaround))) { in mod_freesync_handle_v_update()
1199 in_out_vrr->adjust.v_total_min = in mod_freesync_handle_v_update()
1201 stream, in_out_vrr->max_refresh_in_uhz); in mod_freesync_handle_v_update()
1202 in_out_vrr->adjust.v_total_max = in mod_freesync_handle_v_update()
1203 in_out_vrr->adjust.v_total_min; in mod_freesync_handle_v_update()
1204 in_out_vrr->flip_interval.program_flip_interval_workaround = false; in mod_freesync_handle_v_update()
1205 in_out_vrr->flip_interval.do_flip_interval_workaround_cleanup = true; in mod_freesync_handle_v_update()
1209 if (in_out_vrr->state != VRR_STATE_ACTIVE_VARIABLE && in mod_freesync_handle_v_update()
1210 in_out_vrr->flip_interval.do_flip_interval_workaround_cleanup) { in mod_freesync_handle_v_update()
1211 in_out_vrr->flip_interval.do_flip_interval_workaround_cleanup = false; in mod_freesync_handle_v_update()
1212 in_out_vrr->flip_interval.flip_interval_detect_counter = 0; in mod_freesync_handle_v_update()
1213 in_out_vrr->flip_interval.vsyncs_between_flip = 0; in mod_freesync_handle_v_update()
1214 in_out_vrr->flip_interval.vsync_to_flip_in_us = 0; in mod_freesync_handle_v_update()
1220 if (in_out_vrr->state == VRR_STATE_ACTIVE_VARIABLE && in mod_freesync_handle_v_update()
1221 in_out_vrr->btr.btr_active) { in mod_freesync_handle_v_update()
1222 /* TODO: pass in flag for Pre-DCE12 ASIC in mod_freesync_handle_v_update()
1229 if (in_out_vrr->btr.frames_to_insert == in mod_freesync_handle_v_update()
1230 in_out_vrr->btr.frame_counter) { in mod_freesync_handle_v_update()
1231 in_out_vrr->adjust.v_total_min = in mod_freesync_handle_v_update()
1234 in_out_vrr->btr.inserted_duration_in_us); in mod_freesync_handle_v_update()
1235 in_out_vrr->adjust.v_total_max = in mod_freesync_handle_v_update()
1236 in_out_vrr->adjust.v_total_min; in mod_freesync_handle_v_update()
1239 if (in_out_vrr->btr.frame_counter > 0) in mod_freesync_handle_v_update()
1240 in_out_vrr->btr.frame_counter--; in mod_freesync_handle_v_update()
1243 if (in_out_vrr->btr.frame_counter == 0) { in mod_freesync_handle_v_update()
1244 in_out_vrr->adjust.v_total_min = in mod_freesync_handle_v_update()
1246 in_out_vrr->max_refresh_in_uhz); in mod_freesync_handle_v_update()
1247 in_out_vrr->adjust.v_total_max = in mod_freesync_handle_v_update()
1249 in_out_vrr->min_refresh_in_uhz); in mod_freesync_handle_v_update()
1256 if (in_out_vrr->state == VRR_STATE_ACTIVE_VARIABLE) in mod_freesync_handle_v_update()
1257 in_out_vrr->fixed.ramping_active = false; in mod_freesync_handle_v_update()
1262 if (in_out_vrr->state == VRR_STATE_ACTIVE_FIXED && in mod_freesync_handle_v_update()
1263 in_out_vrr->fixed.ramping_active) { in mod_freesync_handle_v_update()
1281 if (vrr->supported) { in mod_freesync_get_settings()
1282 *v_total_min = vrr->adjust.v_total_min; in mod_freesync_get_settings()
1283 *v_total_max = vrr->adjust.v_total_max; in mod_freesync_get_settings()
1285 *lfc_mid_point_in_us = vrr->btr.mid_point_in_us; in mod_freesync_get_settings()
1286 *inserted_frames = vrr->btr.frames_to_insert; in mod_freesync_get_settings()
1287 *inserted_duration_in_us = vrr->btr.inserted_duration_in_us; in mod_freesync_get_settings()
1295 unsigned int total = stream->timing.h_total * stream->timing.v_total; in mod_freesync_calc_nominal_field_rate()
1297 /* Calculate nominal field rate for stream, rounded up to nearest integer */ in mod_freesync_calc_nominal_field_rate()
1298 nominal_field_rate_in_uhz = stream->timing.pix_clk_100hz; in mod_freesync_calc_nominal_field_rate()
1312 /* Calculate nominal field rate for stream, rounded up to nearest integer */ in mod_freesync_calc_field_rate_from_timing()
1323 return (pVrr->state != VRR_STATE_UNSUPPORTED) && (pVrr->state != VRR_STATE_DISABLED); in mod_freesync_get_freesync_enabled()
1333 * of caps and request. Round the nominal refresh rate. in mod_freesync_is_valid_range()
1374 /* If nominal is less than max, limit the max allowed refresh rate */ in mod_freesync_is_valid_range()
1383 if (nominal_field_rate_in_uhz - min_refresh_cap_in_uhz < 10) in mod_freesync_is_valid_range()