Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright 2016 Advanced Micro Devices, Inc.
0003  *
0004  * Permission is hereby granted, free of charge, to any person obtaining a
0005  * copy of this software and associated documentation files (the "Software"),
0006  * to deal in the Software without restriction, including without limitation
0007  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0008  * and/or sell copies of the Software, and to permit persons to whom the
0009  * Software is furnished to do so, subject to the following conditions:
0010  *
0011  * The above copyright notice and this permission notice shall be included in
0012  * all copies or substantial portions of the Software.
0013  *
0014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0015  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0016  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
0017  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
0018  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0019  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0020  * OTHER DEALINGS IN THE SOFTWARE.
0021  *
0022  * Authors: AMD
0023  *
0024  */
0025 
0026 
0027 
0028 
0029 /*
0030  * Copyright 2016 Advanced Micro Devices, Inc.
0031  *
0032  * Permission is hereby granted, free of charge, to any person obtaining a
0033  * copy of this software and associated documentation files (the "Software"),
0034  * to deal in the Software without restriction, including without limitation
0035  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0036  * and/or sell copies of the Software, and to permit persons to whom the
0037  * Software is furnished to do so, subject to the following conditions:
0038  *
0039  * The above copyright notice and this permission notice shall be included in
0040  * all copies or substantial portions of the Software.
0041  *
0042  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0043  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0044  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
0045  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
0046  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0047  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0048  * OTHER DEALINGS IN THE SOFTWARE.
0049  *
0050  * Authors: AMD
0051  *
0052  */
0053 
0054 #ifndef MOD_FREESYNC_H_
0055 #define MOD_FREESYNC_H_
0056 
0057 #include "mod_shared.h"
0058 
0059 // Access structures
0060 struct mod_freesync {
0061     int dummy;
0062 };
0063 
0064 // TODO: References to this should be removed
0065 struct mod_freesync_caps {
0066     bool supported;
0067     unsigned int min_refresh_in_micro_hz;
0068     unsigned int max_refresh_in_micro_hz;
0069 };
0070 
0071 enum mod_vrr_state {
0072     VRR_STATE_UNSUPPORTED = 0,
0073     VRR_STATE_DISABLED,
0074     VRR_STATE_INACTIVE,
0075     VRR_STATE_ACTIVE_VARIABLE,
0076     VRR_STATE_ACTIVE_FIXED
0077 };
0078 
0079 struct mod_freesync_config {
0080     enum mod_vrr_state state;
0081     bool vsif_supported;
0082     bool ramping;
0083     bool btr;
0084     unsigned int min_refresh_in_uhz;
0085     unsigned int max_refresh_in_uhz;
0086     unsigned int fixed_refresh_in_uhz;
0087 
0088 };
0089 
0090 struct mod_vrr_params_btr {
0091     bool btr_enabled;
0092     bool btr_active;
0093     uint32_t mid_point_in_us;
0094     uint32_t inserted_duration_in_us;
0095     uint32_t frames_to_insert;
0096     uint32_t frame_counter;
0097     uint32_t margin_in_us;
0098 };
0099 
0100 struct mod_vrr_params_fixed_refresh {
0101     bool fixed_active;
0102     bool ramping_active;
0103     bool ramping_done;
0104     uint32_t target_refresh_in_uhz;
0105     uint32_t frame_counter;
0106 };
0107 
0108 struct mod_vrr_params_flip_interval {
0109     bool flip_interval_workaround_active;
0110     bool program_flip_interval_workaround;
0111     bool do_flip_interval_workaround_cleanup;
0112     uint32_t flip_interval_detect_counter;
0113     uint32_t vsyncs_between_flip;
0114     uint32_t vsync_to_flip_in_us;
0115     uint32_t v_update_timestamp_in_us;
0116 };
0117 
0118 struct mod_vrr_params {
0119     bool supported;
0120     bool send_info_frame;
0121     enum mod_vrr_state state;
0122 
0123     uint32_t min_refresh_in_uhz;
0124     uint32_t max_duration_in_us;
0125     uint32_t max_refresh_in_uhz;
0126     uint32_t min_duration_in_us;
0127     uint32_t fixed_refresh_in_uhz;
0128 
0129     struct dc_crtc_timing_adjust adjust;
0130 
0131     struct mod_vrr_params_fixed_refresh fixed;
0132 
0133     struct mod_vrr_params_btr btr;
0134 
0135     struct mod_vrr_params_flip_interval flip_interval;
0136 };
0137 
0138 struct mod_freesync *mod_freesync_create(struct dc *dc);
0139 void mod_freesync_destroy(struct mod_freesync *mod_freesync);
0140 
0141 bool mod_freesync_get_vmin_vmax(struct mod_freesync *mod_freesync,
0142         const struct dc_stream_state *stream,
0143         unsigned int *vmin,
0144         unsigned int *vmax);
0145 
0146 bool mod_freesync_get_v_position(struct mod_freesync *mod_freesync,
0147         struct dc_stream_state *stream,
0148         unsigned int *nom_v_pos,
0149         unsigned int *v_pos);
0150 
0151 void mod_freesync_get_settings(struct mod_freesync *mod_freesync,
0152         const struct mod_vrr_params *vrr,
0153         unsigned int *v_total_min, unsigned int *v_total_max,
0154         unsigned int *event_triggers,
0155         unsigned int *window_min, unsigned int *window_max,
0156         unsigned int *lfc_mid_point_in_us,
0157         unsigned int *inserted_frames,
0158         unsigned int *inserted_duration_in_us);
0159 
0160 void mod_freesync_build_vrr_infopacket(struct mod_freesync *mod_freesync,
0161         const struct dc_stream_state *stream,
0162         const struct mod_vrr_params *vrr,
0163         enum vrr_packet_type packet_type,
0164         enum color_transfer_func app_tf,
0165         struct dc_info_packet *infopacket,
0166         bool pack_sdp_v1_3);
0167 
0168 void mod_freesync_build_vrr_params(struct mod_freesync *mod_freesync,
0169         const struct dc_stream_state *stream,
0170         struct mod_freesync_config *in_config,
0171         struct mod_vrr_params *in_out_vrr);
0172 
0173 void mod_freesync_handle_preflip(struct mod_freesync *mod_freesync,
0174         const struct dc_plane_state *plane,
0175         const struct dc_stream_state *stream,
0176         unsigned int curr_time_stamp_in_us,
0177         struct mod_vrr_params *in_out_vrr);
0178 
0179 void mod_freesync_handle_v_update(struct mod_freesync *mod_freesync,
0180         const struct dc_stream_state *stream,
0181         struct mod_vrr_params *in_out_vrr);
0182 
0183 unsigned long long mod_freesync_calc_nominal_field_rate(
0184             const struct dc_stream_state *stream);
0185 
0186 unsigned long long mod_freesync_calc_field_rate_from_timing(
0187         unsigned int vtotal, unsigned int htotal, unsigned int pix_clk);
0188 
0189 bool mod_freesync_is_valid_range(uint32_t min_refresh_cap_in_uhz,
0190         uint32_t max_refresh_cap_in_uhz,
0191         uint32_t nominal_field_rate_in_uhz);
0192 
0193 unsigned int mod_freesync_calc_v_total_from_refresh(
0194         const struct dc_stream_state *stream,
0195         unsigned int refresh_in_uhz);
0196 
0197 // Returns true when FreeSync is supported and enabled (even if it is inactive)
0198 bool mod_freesync_get_freesync_enabled(struct mod_vrr_params *pVrr);
0199 
0200 #endif