| 1 | |
| 2 | * Copyright 2016 Advanced Micro Devices, Inc.
|
| 3 | *
|
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a
|
| 5 | * copy of this software and associated documentation files (the "Software"),
|
| 6 | * to deal in the Software without restriction, including without limitation
|
| 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
| 8 | * and/or sell copies of the Software, and to permit persons to whom the
|
| 9 | * Software is furnished to do so, subject to the following conditions:
|
| 10 | *
|
| 11 | * The above copyright notice and this permission notice shall be included in
|
| 12 | * all copies or substantial portions of the Software.
|
| 13 | *
|
| 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
| 17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
| 18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
| 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 20 | * OTHER DEALINGS IN THE SOFTWARE.
|
| 21 | *
|
| 22 | * Authors: AMD
|
| 23 | *
|
| 24 |
|
| 25 |
|
| 26 | #ifndef MOD_FREESYNC_H_
|
| 27 | #define MOD_FREESYNC_H_
|
| 28 |
|
| 29 | #include "mod_shared.h"
|
| 30 |
|
| 31 | |
| 32 | struct mod_freesync {
|
| 33 | int dummy;
|
| 34 | };
|
| 35 |
|
| 36 | |
| 37 | struct mod_freesync_caps {
|
| 38 | bool supported;
|
| 39 | unsigned int min_refresh_in_micro_hz;
|
| 40 | unsigned int max_refresh_in_micro_hz;
|
| 41 | };
|
| 42 |
|
| 43 | enum mod_vrr_state {
|
| 44 | VRR_STATE_UNSUPPORTED = 0,
|
| 45 | VRR_STATE_DISABLED,
|
| 46 | VRR_STATE_INACTIVE,
|
| 47 | VRR_STATE_ACTIVE_VARIABLE,
|
| 48 | VRR_STATE_ACTIVE_FIXED
|
| 49 | };
|
| 50 |
|
| 51 | struct mod_freesync_config {
|
| 52 | enum mod_vrr_state state;
|
| 53 | bool vsif_supported;
|
| 54 | bool ramping;
|
| 55 | bool btr;
|
| 56 | unsigned int min_refresh_in_uhz;
|
| 57 | unsigned int max_refresh_in_uhz;
|
| 58 | unsigned int fixed_refresh_in_uhz;
|
| 59 |
|
| 60 | };
|
| 61 |
|
| 62 | struct mod_vrr_params_btr {
|
| 63 | bool btr_enabled;
|
| 64 | bool btr_active;
|
| 65 | uint32_t mid_point_in_us;
|
| 66 | uint32_t inserted_duration_in_us;
|
| 67 | uint32_t frames_to_insert;
|
| 68 | uint32_t frame_counter;
|
| 69 | uint32_t margin_in_us;
|
| 70 | };
|
| 71 |
|
| 72 | struct mod_vrr_params_fixed_refresh {
|
| 73 | bool fixed_active;
|
| 74 | bool ramping_active;
|
| 75 | bool ramping_done;
|
| 76 | uint32_t target_refresh_in_uhz;
|
| 77 | uint32_t frame_counter;
|
| 78 | };
|
| 79 |
|
| 80 | struct mod_vrr_params_flip_interval {
|
| 81 | bool flip_interval_workaround_active;
|
| 82 | bool program_flip_interval_workaround;
|
| 83 | bool do_flip_interval_workaround_cleanup;
|
| 84 | uint32_t flip_interval_detect_counter;
|
| 85 | uint32_t vsyncs_between_flip;
|
| 86 | uint32_t vsync_to_flip_in_us;
|
| 87 | uint32_t v_update_timestamp_in_us;
|
| 88 | };
|
| 89 |
|
| 90 | struct mod_vrr_params {
|
| 91 | bool supported;
|
| 92 | bool send_info_frame;
|
| 93 | bool m_const_engaged; |
| 94 | enum mod_vrr_state state;
|
| 95 |
|
| 96 | uint32_t min_refresh_in_uhz;
|
| 97 | uint32_t max_duration_in_us;
|
| 98 | uint32_t max_refresh_in_uhz;
|
| 99 | uint32_t min_duration_in_us;
|
| 100 | uint32_t fixed_refresh_in_uhz;
|
| 101 |
|
| 102 | uint32_t m_const;
|
| 103 |
|
| 104 | struct dc_crtc_timing_adjust adjust;
|
| 105 |
|
| 106 | struct mod_vrr_params_fixed_refresh fixed;
|
| 107 |
|
| 108 | struct mod_vrr_params_btr btr;
|
| 109 |
|
| 110 | struct mod_vrr_params_flip_interval flip_interval;
|
| 111 | };
|
| 112 |
|
| 113 | struct mod_freesync *mod_freesync_create(struct dc *dc);
|
| 114 | void mod_freesync_destroy(struct mod_freesync *mod_freesync);
|
| 115 |
|
| 116 | void mod_freesync_build_vrr_infopacket(struct mod_freesync *mod_freesync,
|
| 117 | const struct dc_stream_state *stream,
|
| 118 | const struct mod_vrr_params *vrr,
|
| 119 | enum vrr_packet_type packet_type,
|
| 120 | enum color_transfer_func app_tf,
|
| 121 | struct dc_info_packet *infopacket,
|
| 122 | bool pack_sdp_v1_3);
|
| 123 |
|
| 124 | void mod_freesync_build_vrr_params(struct mod_freesync *mod_freesync,
|
| 125 | const struct dc_stream_state *stream,
|
| 126 | struct mod_freesync_config *in_config,
|
| 127 | struct mod_vrr_params *in_out_vrr);
|
| 128 |
|
| 129 | void mod_freesync_handle_preflip(struct mod_freesync *mod_freesync,
|
| 130 | const struct dc_plane_state *plane,
|
| 131 | const struct dc_stream_state *stream,
|
| 132 | unsigned int curr_time_stamp_in_us,
|
| 133 | struct mod_vrr_params *in_out_vrr);
|
| 134 |
|
| 135 | void mod_freesync_handle_v_update(struct mod_freesync *mod_freesync,
|
| 136 | const struct dc_stream_state *stream,
|
| 137 | struct mod_vrr_params *in_out_vrr);
|
| 138 |
|
| 139 | unsigned long long mod_freesync_calc_nominal_field_rate(
|
| 140 | const struct dc_stream_state *stream);
|
| 141 |
|
| 142 | unsigned int mod_freesync_calc_v_total_from_refresh(
|
| 143 | const struct dc_stream_state *stream,
|
| 144 | unsigned int refresh_in_uhz);
|
| 145 |
|
| 146 | |
| 147 | bool mod_freesync_get_freesync_enabled(struct mod_vrr_params *pVrr);
|
| 148 |
|
| 149 | #endif
|