Linux Audio

Check our new training course

Loading...
v6.9.4
  1/*
  2 * Copyright 2016 Advanced Micro Devices, Inc.
  3 *
  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:
 10 *
 11 * The above copyright notice and this permission notice shall be included in
 12 * all copies or substantial portions of the Software.
 13 *
 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.
 21 *
 22 * Authors: AMD
 23 *
 24 */
 25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 26#ifndef MOD_FREESYNC_H_
 27#define MOD_FREESYNC_H_
 28
 29#include "mod_shared.h"
 
 
 
 30
 31// Access structures
 32struct mod_freesync {
 33	int dummy;
 34};
 35
 36// TODO: References to this should be removed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 37struct mod_freesync_caps {
 38	bool supported;
 39	unsigned int min_refresh_in_micro_hz;
 40	unsigned int max_refresh_in_micro_hz;
 41};
 42
 43enum mod_vrr_state {
 44	VRR_STATE_UNSUPPORTED = 0,
 45	VRR_STATE_DISABLED,
 46	VRR_STATE_INACTIVE,
 47	VRR_STATE_ACTIVE_VARIABLE,
 48	VRR_STATE_ACTIVE_FIXED
 49};
 50
 51struct mod_freesync_config {
 52	enum mod_vrr_state state;
 53	bool vsif_supported;
 54	bool ramping;
 55	bool btr;
 56	unsigned int min_refresh_in_uhz;
 57	unsigned int max_refresh_in_uhz;
 58	unsigned int fixed_refresh_in_uhz;
 59
 60};
 61
 62struct mod_vrr_params_btr {
 63	bool btr_enabled;
 64	bool btr_active;
 65	uint32_t mid_point_in_us;
 66	uint32_t inserted_duration_in_us;
 67	uint32_t frames_to_insert;
 68	uint32_t frame_counter;
 69	uint32_t margin_in_us;
 70};
 71
 72struct mod_vrr_params_fixed_refresh {
 73	bool fixed_active;
 74	bool ramping_active;
 75	bool ramping_done;
 76	uint32_t target_refresh_in_uhz;
 77	uint32_t frame_counter;
 78};
 79
 80struct mod_vrr_params_flip_interval {
 81	bool flip_interval_workaround_active;
 82	bool program_flip_interval_workaround;
 83	bool do_flip_interval_workaround_cleanup;
 84	uint32_t flip_interval_detect_counter;
 85	uint32_t vsyncs_between_flip;
 86	uint32_t vsync_to_flip_in_us;
 87	uint32_t v_update_timestamp_in_us;
 88};
 89
 90struct mod_vrr_params {
 91	bool supported;
 92	bool send_info_frame;
 93	enum mod_vrr_state state;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 94
 95	uint32_t min_refresh_in_uhz;
 96	uint32_t max_duration_in_us;
 97	uint32_t max_refresh_in_uhz;
 98	uint32_t min_duration_in_us;
 99	uint32_t fixed_refresh_in_uhz;
100
101	struct dc_crtc_timing_adjust adjust;
 
 
102
103	struct mod_vrr_params_fixed_refresh fixed;
 
 
104
105	struct mod_vrr_params_btr btr;
 
 
106
107	struct mod_vrr_params_flip_interval flip_interval;
108};
 
 
 
109
110struct mod_freesync *mod_freesync_create(struct dc *dc);
111void mod_freesync_destroy(struct mod_freesync *mod_freesync);
 
 
112
113bool mod_freesync_get_vmin_vmax(struct mod_freesync *mod_freesync,
114		const struct dc_stream_state *stream,
115		unsigned int *vmin,
116		unsigned int *vmax);
117
118bool mod_freesync_get_v_position(struct mod_freesync *mod_freesync,
119		struct dc_stream_state *stream,
120		unsigned int *nom_v_pos,
121		unsigned int *v_pos);
122
 
 
 
 
 
 
 
 
 
 
123void mod_freesync_get_settings(struct mod_freesync *mod_freesync,
124		const struct mod_vrr_params *vrr,
125		unsigned int *v_total_min, unsigned int *v_total_max,
126		unsigned int *event_triggers,
127		unsigned int *window_min, unsigned int *window_max,
128		unsigned int *lfc_mid_point_in_us,
129		unsigned int *inserted_frames,
130		unsigned int *inserted_duration_in_us);
131
132void mod_freesync_build_vrr_infopacket(struct mod_freesync *mod_freesync,
133		const struct dc_stream_state *stream,
134		const struct mod_vrr_params *vrr,
135		enum vrr_packet_type packet_type,
136		enum color_transfer_func app_tf,
137		struct dc_info_packet *infopacket,
138		bool pack_sdp_v1_3);
139
140void mod_freesync_build_vrr_params(struct mod_freesync *mod_freesync,
141		const struct dc_stream_state *stream,
142		struct mod_freesync_config *in_config,
143		struct mod_vrr_params *in_out_vrr);
144
145void mod_freesync_handle_preflip(struct mod_freesync *mod_freesync,
146		const struct dc_plane_state *plane,
147		const struct dc_stream_state *stream,
148		unsigned int curr_time_stamp_in_us,
149		struct mod_vrr_params *in_out_vrr);
150
151void mod_freesync_handle_v_update(struct mod_freesync *mod_freesync,
152		const struct dc_stream_state *stream,
153		struct mod_vrr_params *in_out_vrr);
154
155unsigned long long mod_freesync_calc_nominal_field_rate(
156			const struct dc_stream_state *stream);
157
158unsigned long long mod_freesync_calc_field_rate_from_timing(
159		unsigned int vtotal, unsigned int htotal, unsigned int pix_clk);
160
161bool mod_freesync_is_valid_range(uint32_t min_refresh_cap_in_uhz,
162		uint32_t max_refresh_cap_in_uhz,
163		uint32_t nominal_field_rate_in_uhz);
164
165unsigned int mod_freesync_calc_v_total_from_refresh(
166		const struct dc_stream_state *stream,
167		unsigned int refresh_in_uhz);
168
169// Returns true when FreeSync is supported and enabled (even if it is inactive)
170bool mod_freesync_get_freesync_enabled(struct mod_vrr_params *pVrr);
171
172#endif
v4.17
  1/*
  2 * Copyright 2016 Advanced Micro Devices, Inc.
  3 *
  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:
 10 *
 11 * The above copyright notice and this permission notice shall be included in
 12 * all copies or substantial portions of the Software.
 13 *
 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.
 21 *
 22 * Authors: AMD
 23 *
 24 */
 25
 26
 27
 28
 29/*
 30 * Copyright 2016 Advanced Micro Devices, Inc.
 31 *
 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:
 38 *
 39 * The above copyright notice and this permission notice shall be included in
 40 * all copies or substantial portions of the Software.
 41 *
 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.
 49 *
 50 * Authors: AMD
 51 *
 52 */
 53
 54#ifndef MOD_FREESYNC_H_
 55#define MOD_FREESYNC_H_
 56
 57#include "dm_services.h"
 58
 59struct mod_freesync *mod_freesync_create(struct dc *dc);
 60void mod_freesync_destroy(struct mod_freesync *mod_freesync);
 61
 
 62struct mod_freesync {
 63	int dummy;
 64};
 65
 66enum mod_freesync_state {
 67	FREESYNC_STATE_NONE,
 68	FREESYNC_STATE_FULLSCREEN,
 69	FREESYNC_STATE_STATIC_SCREEN,
 70	FREESYNC_STATE_VIDEO
 71};
 72
 73enum 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
 79struct mod_freesync_user_enable {
 80	bool enable_for_static;
 81	bool enable_for_video;
 82	bool enable_for_gaming;
 83};
 84
 85struct mod_freesync_caps {
 86	bool supported;
 87	unsigned int min_refresh_in_micro_hz;
 88	unsigned int max_refresh_in_micro_hz;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 89
 90	bool btr_supported;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 91};
 92
 93struct mod_freesync_params {
 94	enum mod_freesync_state state;
 95	bool enable;
 96	unsigned int update_duration_in_ns;
 97	bool windowed_fullscreen;
 98};
 99
100/*
101 * Add stream to be tracked by module
102 */
103bool mod_freesync_add_stream(struct mod_freesync *mod_freesync,
104		struct dc_stream_state *stream, struct mod_freesync_caps *caps);
105
106/*
107 * Remove stream to be tracked by module
108 */
109bool mod_freesync_remove_stream(struct mod_freesync *mod_freesync,
110		struct dc_stream_state *stream);
111
112/*
113 * Update the freesync state flags for each display and program
114 * freesync accordingly
115 */
116void 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);
119
120bool mod_freesync_get_state(struct mod_freesync *mod_freesync,
121		struct dc_stream_state *stream,
122		struct mod_freesync_params *freesync_params);
 
 
123
124bool 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);
127
128bool mod_freesync_get_user_enable(struct mod_freesync *mod_freesync,
129		struct dc_stream_state *stream,
130		struct mod_freesync_user_enable *user_enable);
131
132bool mod_freesync_get_static_ramp_active(struct mod_freesync *mod_freesync,
133		struct dc_stream_state *stream,
134		bool *is_ramp_active);
135
136bool 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);
141
142bool 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);
146
147bool mod_freesync_get_vmin_vmax(struct mod_freesync *mod_freesync,
148		struct dc_stream_state *stream,
149		unsigned int *vmin,
150		unsigned int *vmax);
151
152bool 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);
156
157void mod_freesync_handle_v_update(struct mod_freesync *mod_freesync,
158		struct dc_stream_state **streams, int num_streams);
159
160void mod_freesync_notify_mode_change(struct mod_freesync *mod_freesync,
161		struct dc_stream_state **streams, int num_streams);
162
163void 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
167void mod_freesync_get_settings(struct mod_freesync *mod_freesync,
168		struct dc_stream_state **streams, int num_streams,
169		unsigned int *v_total_min, unsigned int *v_total_max,
170		unsigned int *event_triggers,
171		unsigned int *window_min, unsigned int *window_max,
172		unsigned int *lfc_mid_point_in_us,
173		unsigned int *inserted_frames,
174		unsigned int *inserted_duration_in_us);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
176#endif