1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54#ifndef MOD_FREESYNC_H_
55#define MOD_FREESYNC_H_
56
57#include "mod_shared.h"
58
59
60struct mod_freesync {
61 int dummy;
62};
63
64
65struct mod_freesync_caps {
66 bool supported;
67 unsigned int min_refresh_in_micro_hz;
68 unsigned int max_refresh_in_micro_hz;
69};
70
71enum 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
77};
78
79struct 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;
87
88};
89
90struct 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};
99
100struct 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};
107
108struct mod_vrr_params {
109 bool supported;
110 bool send_info_frame;
111 enum mod_vrr_state state;
112
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;
118
119 struct dc_crtc_timing_adjust adjust;
120
121 struct mod_vrr_params_fixed_refresh fixed;
122
123 struct mod_vrr_params_btr btr;
124};
125
126struct mod_freesync *mod_freesync_create(struct dc *dc);
127void mod_freesync_destroy(struct mod_freesync *mod_freesync);
128
129bool mod_freesync_get_vmin_vmax(struct mod_freesync *mod_freesync,
130 const struct dc_stream_state *stream,
131 unsigned int *vmin,
132 unsigned int *vmax);
133
134bool mod_freesync_get_v_position(struct mod_freesync *mod_freesync,
135 struct dc_stream_state *stream,
136 unsigned int *nom_v_pos,
137 unsigned int *v_pos);
138
139void mod_freesync_get_settings(struct mod_freesync *mod_freesync,
140 const struct mod_vrr_params *vrr,
141 unsigned int *v_total_min, unsigned int *v_total_max,
142 unsigned int *event_triggers,
143 unsigned int *window_min, unsigned int *window_max,
144 unsigned int *lfc_mid_point_in_us,
145 unsigned int *inserted_frames,
146 unsigned int *inserted_duration_in_us);
147
148void 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 bool pack_sdp_v1_3);
155
156void mod_freesync_build_vrr_params(struct mod_freesync *mod_freesync,
157 const struct dc_stream_state *stream,
158 struct mod_freesync_config *in_config,
159 struct mod_vrr_params *in_out_vrr);
160
161void mod_freesync_handle_preflip(struct mod_freesync *mod_freesync,
162 const struct dc_plane_state *plane,
163 const struct dc_stream_state *stream,
164 unsigned int curr_time_stamp_in_us,
165 struct mod_vrr_params *in_out_vrr);
166
167void mod_freesync_handle_v_update(struct mod_freesync *mod_freesync,
168 const struct dc_stream_state *stream,
169 struct mod_vrr_params *in_out_vrr);
170
171unsigned long long mod_freesync_calc_nominal_field_rate(
172 const struct dc_stream_state *stream);
173
174unsigned long long mod_freesync_calc_field_rate_from_timing(
175 unsigned int vtotal, unsigned int htotal, unsigned int pix_clk);
176
177bool mod_freesync_is_valid_range(uint32_t min_refresh_cap_in_uhz,
178 uint32_t max_refresh_cap_in_uhz,
179 uint32_t nominal_field_rate_in_uhz);
180
181unsigned int mod_freesync_calc_v_total_from_refresh(
182 const struct dc_stream_state *stream,
183 unsigned int refresh_in_uhz);
184
185#endif
186