2 * Copyright 2016 Advanced Micro Devices, Inc.
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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.
30 * Copyright 2016 Advanced Micro Devices, Inc.
32 * Permission is hereby granted, free of charge, to any person obtaining a
33 * copy of this software and associated documentation files (the "Software"),
34 * to deal in the Software without restriction, including without limitation
35 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
36 * and/or sell copies of the Software, and to permit persons to whom the
37 * Software is furnished to do so, subject to the following conditions:
39 * The above copyright notice and this permission notice shall be included in
40 * all copies or substantial portions of the Software.
42 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
43 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
44 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
45 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
46 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
47 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
48 * OTHER DEALINGS IN THE SOFTWARE.
54 #ifndef MOD_FREESYNC_H_
55 #define MOD_FREESYNC_H_
57 #include "dm_services.h"
59 struct mod_freesync *mod_freesync_create(struct dc *dc);
60 void mod_freesync_destroy(struct mod_freesync *mod_freesync);
66 enum mod_freesync_state {
68 FREESYNC_STATE_FULLSCREEN,
69 FREESYNC_STATE_STATIC_SCREEN,
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
79 struct mod_freesync_user_enable {
80 bool enable_for_static;
81 bool enable_for_video;
82 bool enable_for_gaming;
85 struct mod_freesync_caps {
87 unsigned int min_refresh_in_micro_hz;
88 unsigned int max_refresh_in_micro_hz;
93 struct mod_freesync_params {
94 enum mod_freesync_state state;
96 unsigned int update_duration_in_ns;
97 bool windowed_fullscreen;
101 * Add stream to be tracked by module
103 bool mod_freesync_add_stream(struct mod_freesync *mod_freesync,
104 struct dc_stream_state *stream, struct mod_freesync_caps *caps);
107 * Remove stream to be tracked by module
109 bool mod_freesync_remove_stream(struct mod_freesync *mod_freesync,
110 struct dc_stream_state *stream);
113 * Update the freesync state flags for each display and program
114 * freesync accordingly
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);
120 bool mod_freesync_get_state(struct mod_freesync *mod_freesync,
121 struct dc_stream_state *stream,
122 struct mod_freesync_params *freesync_params);
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);
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);
132 bool mod_freesync_get_static_ramp_active(struct mod_freesync *mod_freesync,
133 struct dc_stream_state *stream,
134 bool *is_ramp_active);
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);
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);
147 bool mod_freesync_get_vmin_vmax(struct mod_freesync *mod_freesync,
148 struct dc_stream_state *stream,
152 bool mod_freesync_get_v_position(struct mod_freesync *mod_freesync,
153 struct dc_stream_state *stream,
154 unsigned int *nom_v_pos,
155 unsigned int *v_pos);
157 void mod_freesync_handle_v_update(struct mod_freesync *mod_freesync,
158 struct dc_stream_state **streams, int num_streams);
160 void mod_freesync_notify_mode_change(struct mod_freesync *mod_freesync,
161 struct dc_stream_state **streams, int num_streams);
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);