.. | .. |
---|
54 | 54 | #ifndef MOD_FREESYNC_H_ |
---|
55 | 55 | #define MOD_FREESYNC_H_ |
---|
56 | 56 | |
---|
57 | | -#include "dm_services.h" |
---|
| 57 | +#include "mod_shared.h" |
---|
58 | 58 | |
---|
59 | | -struct mod_freesync *mod_freesync_create(struct dc *dc); |
---|
60 | | -void mod_freesync_destroy(struct mod_freesync *mod_freesync); |
---|
61 | | - |
---|
| 59 | +// Access structures |
---|
62 | 60 | struct mod_freesync { |
---|
63 | 61 | int dummy; |
---|
64 | 62 | }; |
---|
65 | 63 | |
---|
66 | | -enum mod_freesync_state { |
---|
67 | | - FREESYNC_STATE_NONE, |
---|
68 | | - FREESYNC_STATE_FULLSCREEN, |
---|
69 | | - FREESYNC_STATE_STATIC_SCREEN, |
---|
70 | | - FREESYNC_STATE_VIDEO |
---|
71 | | -}; |
---|
72 | | - |
---|
73 | | -enum mod_freesync_user_enable_mask { |
---|
74 | | - FREESYNC_USER_ENABLE_STATIC = 0x1, |
---|
75 | | - FREESYNC_USER_ENABLE_VIDEO = 0x2, |
---|
76 | | - FREESYNC_USER_ENABLE_GAMING = 0x4 |
---|
77 | | -}; |
---|
78 | | - |
---|
79 | | -struct mod_freesync_user_enable { |
---|
80 | | - bool enable_for_static; |
---|
81 | | - bool enable_for_video; |
---|
82 | | - bool enable_for_gaming; |
---|
83 | | -}; |
---|
84 | | - |
---|
| 64 | +// TODO: References to this should be removed |
---|
85 | 65 | struct mod_freesync_caps { |
---|
86 | 66 | bool supported; |
---|
87 | 67 | unsigned int min_refresh_in_micro_hz; |
---|
88 | 68 | unsigned int max_refresh_in_micro_hz; |
---|
89 | | - |
---|
90 | | - bool btr_supported; |
---|
91 | 69 | }; |
---|
92 | 70 | |
---|
93 | | -struct mod_freesync_params { |
---|
94 | | - enum mod_freesync_state state; |
---|
95 | | - bool enable; |
---|
96 | | - unsigned int update_duration_in_ns; |
---|
97 | | - bool windowed_fullscreen; |
---|
| 71 | +enum mod_vrr_state { |
---|
| 72 | + VRR_STATE_UNSUPPORTED = 0, |
---|
| 73 | + VRR_STATE_DISABLED, |
---|
| 74 | + VRR_STATE_INACTIVE, |
---|
| 75 | + VRR_STATE_ACTIVE_VARIABLE, |
---|
| 76 | + VRR_STATE_ACTIVE_FIXED |
---|
98 | 77 | }; |
---|
99 | 78 | |
---|
100 | | -/* |
---|
101 | | - * Add stream to be tracked by module |
---|
102 | | - */ |
---|
103 | | -bool mod_freesync_add_stream(struct mod_freesync *mod_freesync, |
---|
104 | | - struct dc_stream_state *stream, struct mod_freesync_caps *caps); |
---|
| 79 | +struct mod_freesync_config { |
---|
| 80 | + enum mod_vrr_state state; |
---|
| 81 | + bool vsif_supported; |
---|
| 82 | + bool ramping; |
---|
| 83 | + bool btr; |
---|
| 84 | + unsigned int min_refresh_in_uhz; |
---|
| 85 | + unsigned int max_refresh_in_uhz; |
---|
| 86 | + unsigned int fixed_refresh_in_uhz; |
---|
105 | 87 | |
---|
106 | | -/* |
---|
107 | | - * Remove stream to be tracked by module |
---|
108 | | - */ |
---|
109 | | -bool mod_freesync_remove_stream(struct mod_freesync *mod_freesync, |
---|
110 | | - struct dc_stream_state *stream); |
---|
| 88 | +}; |
---|
111 | 89 | |
---|
112 | | -/* |
---|
113 | | - * Update the freesync state flags for each display and program |
---|
114 | | - * freesync accordingly |
---|
115 | | - */ |
---|
116 | | -void mod_freesync_update_state(struct mod_freesync *mod_freesync, |
---|
117 | | - struct dc_stream_state **streams, int num_streams, |
---|
118 | | - struct mod_freesync_params *freesync_params); |
---|
| 90 | +struct mod_vrr_params_btr { |
---|
| 91 | + bool btr_enabled; |
---|
| 92 | + bool btr_active; |
---|
| 93 | + uint32_t mid_point_in_us; |
---|
| 94 | + uint32_t inserted_duration_in_us; |
---|
| 95 | + uint32_t frames_to_insert; |
---|
| 96 | + uint32_t frame_counter; |
---|
| 97 | + uint32_t margin_in_us; |
---|
| 98 | +}; |
---|
119 | 99 | |
---|
120 | | -bool mod_freesync_get_state(struct mod_freesync *mod_freesync, |
---|
121 | | - struct dc_stream_state *stream, |
---|
122 | | - struct mod_freesync_params *freesync_params); |
---|
| 100 | +struct mod_vrr_params_fixed_refresh { |
---|
| 101 | + bool fixed_active; |
---|
| 102 | + bool ramping_active; |
---|
| 103 | + bool ramping_done; |
---|
| 104 | + uint32_t target_refresh_in_uhz; |
---|
| 105 | + uint32_t frame_counter; |
---|
| 106 | +}; |
---|
123 | 107 | |
---|
124 | | -bool mod_freesync_set_user_enable(struct mod_freesync *mod_freesync, |
---|
125 | | - struct dc_stream_state **streams, int num_streams, |
---|
126 | | - struct mod_freesync_user_enable *user_enable); |
---|
| 108 | +struct mod_vrr_params { |
---|
| 109 | + bool supported; |
---|
| 110 | + bool send_info_frame; |
---|
| 111 | + enum mod_vrr_state state; |
---|
127 | 112 | |
---|
128 | | -bool mod_freesync_get_user_enable(struct mod_freesync *mod_freesync, |
---|
129 | | - struct dc_stream_state *stream, |
---|
130 | | - struct mod_freesync_user_enable *user_enable); |
---|
| 113 | + uint32_t min_refresh_in_uhz; |
---|
| 114 | + uint32_t max_duration_in_us; |
---|
| 115 | + uint32_t max_refresh_in_uhz; |
---|
| 116 | + uint32_t min_duration_in_us; |
---|
| 117 | + uint32_t fixed_refresh_in_uhz; |
---|
131 | 118 | |
---|
132 | | -bool mod_freesync_get_static_ramp_active(struct mod_freesync *mod_freesync, |
---|
133 | | - struct dc_stream_state *stream, |
---|
134 | | - bool *is_ramp_active); |
---|
| 119 | + struct dc_crtc_timing_adjust adjust; |
---|
135 | 120 | |
---|
136 | | -bool mod_freesync_override_min_max(struct mod_freesync *mod_freesync, |
---|
137 | | - struct dc_stream_state *streams, |
---|
138 | | - unsigned int min_refresh, |
---|
139 | | - unsigned int max_refresh, |
---|
140 | | - struct mod_freesync_caps *caps); |
---|
| 121 | + struct mod_vrr_params_fixed_refresh fixed; |
---|
141 | 122 | |
---|
142 | | -bool mod_freesync_get_min_max(struct mod_freesync *mod_freesync, |
---|
143 | | - struct dc_stream_state *stream, |
---|
144 | | - unsigned int *min_refresh, |
---|
145 | | - unsigned int *max_refresh); |
---|
| 123 | + struct mod_vrr_params_btr btr; |
---|
| 124 | +}; |
---|
| 125 | + |
---|
| 126 | +struct mod_freesync *mod_freesync_create(struct dc *dc); |
---|
| 127 | +void mod_freesync_destroy(struct mod_freesync *mod_freesync); |
---|
146 | 128 | |
---|
147 | 129 | bool mod_freesync_get_vmin_vmax(struct mod_freesync *mod_freesync, |
---|
148 | | - struct dc_stream_state *stream, |
---|
| 130 | + const struct dc_stream_state *stream, |
---|
149 | 131 | unsigned int *vmin, |
---|
150 | 132 | unsigned int *vmax); |
---|
151 | 133 | |
---|
.. | .. |
---|
154 | 136 | unsigned int *nom_v_pos, |
---|
155 | 137 | unsigned int *v_pos); |
---|
156 | 138 | |
---|
157 | | -void mod_freesync_handle_v_update(struct mod_freesync *mod_freesync, |
---|
158 | | - struct dc_stream_state **streams, int num_streams); |
---|
159 | | - |
---|
160 | | -void mod_freesync_notify_mode_change(struct mod_freesync *mod_freesync, |
---|
161 | | - struct dc_stream_state **streams, int num_streams); |
---|
162 | | - |
---|
163 | | -void mod_freesync_pre_update_plane_addresses(struct mod_freesync *mod_freesync, |
---|
164 | | - struct dc_stream_state **streams, int num_streams, |
---|
165 | | - unsigned int curr_time_stamp); |
---|
166 | | - |
---|
167 | 139 | void mod_freesync_get_settings(struct mod_freesync *mod_freesync, |
---|
168 | | - struct dc_stream_state **streams, int num_streams, |
---|
| 140 | + const struct mod_vrr_params *vrr, |
---|
169 | 141 | unsigned int *v_total_min, unsigned int *v_total_max, |
---|
170 | 142 | unsigned int *event_triggers, |
---|
171 | 143 | unsigned int *window_min, unsigned int *window_max, |
---|
.. | .. |
---|
173 | 145 | unsigned int *inserted_frames, |
---|
174 | 146 | unsigned int *inserted_duration_in_us); |
---|
175 | 147 | |
---|
| 148 | +void mod_freesync_build_vrr_infopacket(struct mod_freesync *mod_freesync, |
---|
| 149 | + const struct dc_stream_state *stream, |
---|
| 150 | + const struct mod_vrr_params *vrr, |
---|
| 151 | + enum vrr_packet_type packet_type, |
---|
| 152 | + enum color_transfer_func app_tf, |
---|
| 153 | + struct dc_info_packet *infopacket); |
---|
| 154 | + |
---|
| 155 | +void mod_freesync_build_vrr_params(struct mod_freesync *mod_freesync, |
---|
| 156 | + const struct dc_stream_state *stream, |
---|
| 157 | + struct mod_freesync_config *in_config, |
---|
| 158 | + struct mod_vrr_params *in_out_vrr); |
---|
| 159 | + |
---|
| 160 | +void mod_freesync_handle_preflip(struct mod_freesync *mod_freesync, |
---|
| 161 | + const struct dc_plane_state *plane, |
---|
| 162 | + const struct dc_stream_state *stream, |
---|
| 163 | + unsigned int curr_time_stamp_in_us, |
---|
| 164 | + struct mod_vrr_params *in_out_vrr); |
---|
| 165 | + |
---|
| 166 | +void mod_freesync_handle_v_update(struct mod_freesync *mod_freesync, |
---|
| 167 | + const struct dc_stream_state *stream, |
---|
| 168 | + struct mod_vrr_params *in_out_vrr); |
---|
| 169 | + |
---|
| 170 | +unsigned long long mod_freesync_calc_nominal_field_rate( |
---|
| 171 | + const struct dc_stream_state *stream); |
---|
| 172 | + |
---|
| 173 | +bool mod_freesync_is_valid_range(uint32_t min_refresh_cap_in_uhz, |
---|
| 174 | + uint32_t max_refresh_cap_in_uhz, |
---|
| 175 | + uint32_t nominal_field_rate_in_uhz); |
---|
| 176 | + |
---|
| 177 | + |
---|
| 178 | + |
---|
176 | 179 | #endif |
---|