1*b843c749SSergey Zigachev /* 2*b843c749SSergey Zigachev * Copyright 2016 Advanced Micro Devices, Inc. 3*b843c749SSergey Zigachev * 4*b843c749SSergey Zigachev * Permission is hereby granted, free of charge, to any person obtaining a 5*b843c749SSergey Zigachev * copy of this software and associated documentation files (the "Software"), 6*b843c749SSergey Zigachev * to deal in the Software without restriction, including without limitation 7*b843c749SSergey Zigachev * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8*b843c749SSergey Zigachev * and/or sell copies of the Software, and to permit persons to whom the 9*b843c749SSergey Zigachev * Software is furnished to do so, subject to the following conditions: 10*b843c749SSergey Zigachev * 11*b843c749SSergey Zigachev * The above copyright notice and this permission notice shall be included in 12*b843c749SSergey Zigachev * all copies or substantial portions of the Software. 13*b843c749SSergey Zigachev * 14*b843c749SSergey Zigachev * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15*b843c749SSergey Zigachev * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16*b843c749SSergey Zigachev * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17*b843c749SSergey Zigachev * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18*b843c749SSergey Zigachev * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19*b843c749SSergey Zigachev * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20*b843c749SSergey Zigachev * OTHER DEALINGS IN THE SOFTWARE. 21*b843c749SSergey Zigachev * 22*b843c749SSergey Zigachev * Authors: AMD 23*b843c749SSergey Zigachev * 24*b843c749SSergey Zigachev */ 25*b843c749SSergey Zigachev 26*b843c749SSergey Zigachev 27*b843c749SSergey Zigachev 28*b843c749SSergey Zigachev 29*b843c749SSergey Zigachev /* 30*b843c749SSergey Zigachev * Copyright 2016 Advanced Micro Devices, Inc. 31*b843c749SSergey Zigachev * 32*b843c749SSergey Zigachev * Permission is hereby granted, free of charge, to any person obtaining a 33*b843c749SSergey Zigachev * copy of this software and associated documentation files (the "Software"), 34*b843c749SSergey Zigachev * to deal in the Software without restriction, including without limitation 35*b843c749SSergey Zigachev * the rights to use, copy, modify, merge, publish, distribute, sublicense, 36*b843c749SSergey Zigachev * and/or sell copies of the Software, and to permit persons to whom the 37*b843c749SSergey Zigachev * Software is furnished to do so, subject to the following conditions: 38*b843c749SSergey Zigachev * 39*b843c749SSergey Zigachev * The above copyright notice and this permission notice shall be included in 40*b843c749SSergey Zigachev * all copies or substantial portions of the Software. 41*b843c749SSergey Zigachev * 42*b843c749SSergey Zigachev * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 43*b843c749SSergey Zigachev * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 44*b843c749SSergey Zigachev * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 45*b843c749SSergey Zigachev * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 46*b843c749SSergey Zigachev * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 47*b843c749SSergey Zigachev * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 48*b843c749SSergey Zigachev * OTHER DEALINGS IN THE SOFTWARE. 49*b843c749SSergey Zigachev * 50*b843c749SSergey Zigachev * Authors: AMD 51*b843c749SSergey Zigachev * 52*b843c749SSergey Zigachev */ 53*b843c749SSergey Zigachev 54*b843c749SSergey Zigachev #ifndef MOD_FREESYNC_H_ 55*b843c749SSergey Zigachev #define MOD_FREESYNC_H_ 56*b843c749SSergey Zigachev 57*b843c749SSergey Zigachev #include "dm_services.h" 58*b843c749SSergey Zigachev 59*b843c749SSergey Zigachev struct mod_freesync *mod_freesync_create(struct dc *dc); 60*b843c749SSergey Zigachev void mod_freesync_destroy(struct mod_freesync *mod_freesync); 61*b843c749SSergey Zigachev 62*b843c749SSergey Zigachev struct mod_freesync { 63*b843c749SSergey Zigachev int dummy; 64*b843c749SSergey Zigachev }; 65*b843c749SSergey Zigachev 66*b843c749SSergey Zigachev enum mod_freesync_state { 67*b843c749SSergey Zigachev FREESYNC_STATE_NONE, 68*b843c749SSergey Zigachev FREESYNC_STATE_FULLSCREEN, 69*b843c749SSergey Zigachev FREESYNC_STATE_STATIC_SCREEN, 70*b843c749SSergey Zigachev FREESYNC_STATE_VIDEO 71*b843c749SSergey Zigachev }; 72*b843c749SSergey Zigachev 73*b843c749SSergey Zigachev enum mod_freesync_user_enable_mask { 74*b843c749SSergey Zigachev FREESYNC_USER_ENABLE_STATIC = 0x1, 75*b843c749SSergey Zigachev FREESYNC_USER_ENABLE_VIDEO = 0x2, 76*b843c749SSergey Zigachev FREESYNC_USER_ENABLE_GAMING = 0x4 77*b843c749SSergey Zigachev }; 78*b843c749SSergey Zigachev 79*b843c749SSergey Zigachev struct mod_freesync_user_enable { 80*b843c749SSergey Zigachev bool enable_for_static; 81*b843c749SSergey Zigachev bool enable_for_video; 82*b843c749SSergey Zigachev bool enable_for_gaming; 83*b843c749SSergey Zigachev }; 84*b843c749SSergey Zigachev 85*b843c749SSergey Zigachev struct mod_freesync_caps { 86*b843c749SSergey Zigachev bool supported; 87*b843c749SSergey Zigachev unsigned int min_refresh_in_micro_hz; 88*b843c749SSergey Zigachev unsigned int max_refresh_in_micro_hz; 89*b843c749SSergey Zigachev 90*b843c749SSergey Zigachev bool btr_supported; 91*b843c749SSergey Zigachev }; 92*b843c749SSergey Zigachev 93*b843c749SSergey Zigachev struct mod_freesync_params { 94*b843c749SSergey Zigachev enum mod_freesync_state state; 95*b843c749SSergey Zigachev bool enable; 96*b843c749SSergey Zigachev unsigned int update_duration_in_ns; 97*b843c749SSergey Zigachev bool windowed_fullscreen; 98*b843c749SSergey Zigachev }; 99*b843c749SSergey Zigachev 100*b843c749SSergey Zigachev /* 101*b843c749SSergey Zigachev * Add stream to be tracked by module 102*b843c749SSergey Zigachev */ 103*b843c749SSergey Zigachev bool mod_freesync_add_stream(struct mod_freesync *mod_freesync, 104*b843c749SSergey Zigachev struct dc_stream_state *stream, struct mod_freesync_caps *caps); 105*b843c749SSergey Zigachev 106*b843c749SSergey Zigachev /* 107*b843c749SSergey Zigachev * Remove stream to be tracked by module 108*b843c749SSergey Zigachev */ 109*b843c749SSergey Zigachev bool mod_freesync_remove_stream(struct mod_freesync *mod_freesync, 110*b843c749SSergey Zigachev struct dc_stream_state *stream); 111*b843c749SSergey Zigachev 112*b843c749SSergey Zigachev /* 113*b843c749SSergey Zigachev * Update the freesync state flags for each display and program 114*b843c749SSergey Zigachev * freesync accordingly 115*b843c749SSergey Zigachev */ 116*b843c749SSergey Zigachev void mod_freesync_update_state(struct mod_freesync *mod_freesync, 117*b843c749SSergey Zigachev struct dc_stream_state **streams, int num_streams, 118*b843c749SSergey Zigachev struct mod_freesync_params *freesync_params); 119*b843c749SSergey Zigachev 120*b843c749SSergey Zigachev bool mod_freesync_get_state(struct mod_freesync *mod_freesync, 121*b843c749SSergey Zigachev struct dc_stream_state *stream, 122*b843c749SSergey Zigachev struct mod_freesync_params *freesync_params); 123*b843c749SSergey Zigachev 124*b843c749SSergey Zigachev bool mod_freesync_set_user_enable(struct mod_freesync *mod_freesync, 125*b843c749SSergey Zigachev struct dc_stream_state **streams, int num_streams, 126*b843c749SSergey Zigachev struct mod_freesync_user_enable *user_enable); 127*b843c749SSergey Zigachev 128*b843c749SSergey Zigachev bool mod_freesync_get_user_enable(struct mod_freesync *mod_freesync, 129*b843c749SSergey Zigachev struct dc_stream_state *stream, 130*b843c749SSergey Zigachev struct mod_freesync_user_enable *user_enable); 131*b843c749SSergey Zigachev 132*b843c749SSergey Zigachev bool mod_freesync_get_static_ramp_active(struct mod_freesync *mod_freesync, 133*b843c749SSergey Zigachev struct dc_stream_state *stream, 134*b843c749SSergey Zigachev bool *is_ramp_active); 135*b843c749SSergey Zigachev 136*b843c749SSergey Zigachev bool mod_freesync_override_min_max(struct mod_freesync *mod_freesync, 137*b843c749SSergey Zigachev struct dc_stream_state *streams, 138*b843c749SSergey Zigachev unsigned int min_refresh, 139*b843c749SSergey Zigachev unsigned int max_refresh, 140*b843c749SSergey Zigachev struct mod_freesync_caps *caps); 141*b843c749SSergey Zigachev 142*b843c749SSergey Zigachev bool mod_freesync_get_min_max(struct mod_freesync *mod_freesync, 143*b843c749SSergey Zigachev struct dc_stream_state *stream, 144*b843c749SSergey Zigachev unsigned int *min_refresh, 145*b843c749SSergey Zigachev unsigned int *max_refresh); 146*b843c749SSergey Zigachev 147*b843c749SSergey Zigachev bool mod_freesync_get_vmin_vmax(struct mod_freesync *mod_freesync, 148*b843c749SSergey Zigachev struct dc_stream_state *stream, 149*b843c749SSergey Zigachev unsigned int *vmin, 150*b843c749SSergey Zigachev unsigned int *vmax); 151*b843c749SSergey Zigachev 152*b843c749SSergey Zigachev bool mod_freesync_get_v_position(struct mod_freesync *mod_freesync, 153*b843c749SSergey Zigachev struct dc_stream_state *stream, 154*b843c749SSergey Zigachev unsigned int *nom_v_pos, 155*b843c749SSergey Zigachev unsigned int *v_pos); 156*b843c749SSergey Zigachev 157*b843c749SSergey Zigachev void mod_freesync_handle_v_update(struct mod_freesync *mod_freesync, 158*b843c749SSergey Zigachev struct dc_stream_state **streams, int num_streams); 159*b843c749SSergey Zigachev 160*b843c749SSergey Zigachev void mod_freesync_notify_mode_change(struct mod_freesync *mod_freesync, 161*b843c749SSergey Zigachev struct dc_stream_state **streams, int num_streams); 162*b843c749SSergey Zigachev 163*b843c749SSergey Zigachev void mod_freesync_pre_update_plane_addresses(struct mod_freesync *mod_freesync, 164*b843c749SSergey Zigachev struct dc_stream_state **streams, int num_streams, 165*b843c749SSergey Zigachev unsigned int curr_time_stamp); 166*b843c749SSergey Zigachev 167*b843c749SSergey Zigachev void mod_freesync_get_settings(struct mod_freesync *mod_freesync, 168*b843c749SSergey Zigachev struct dc_stream_state **streams, int num_streams, 169*b843c749SSergey Zigachev unsigned int *v_total_min, unsigned int *v_total_max, 170*b843c749SSergey Zigachev unsigned int *event_triggers, 171*b843c749SSergey Zigachev unsigned int *window_min, unsigned int *window_max, 172*b843c749SSergey Zigachev unsigned int *lfc_mid_point_in_us, 173*b843c749SSergey Zigachev unsigned int *inserted_frames, 174*b843c749SSergey Zigachev unsigned int *inserted_duration_in_us); 175*b843c749SSergey Zigachev 176*b843c749SSergey Zigachev #endif 177