]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - drivers/gpu/drm/amd/display/modules/inc/mod_freesync.h
Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
[mirror_ubuntu-jammy-kernel.git] / drivers / gpu / drm / amd / display / modules / inc / mod_freesync.h
CommitLineData
4562236b
HW
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
c2791297 57#include "mod_shared.h"
4562236b 58
98e6436d 59// Access structures
4562236b
HW
60struct mod_freesync {
61 int dummy;
62};
63
98e6436d 64// TODO: References to this should be removed
4562236b
HW
65struct mod_freesync_caps {
66 bool supported;
67 unsigned int min_refresh_in_micro_hz;
68 unsigned int max_refresh_in_micro_hz;
4562236b
HW
69};
70
98e6436d
AK
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
4562236b
HW
77};
78
98e6436d
AK
79struct mod_freesync_config {
80 enum mod_vrr_state state;
69ff8845 81 bool vsif_supported;
98e6436d
AK
82 bool ramping;
83 bool btr;
84 unsigned int min_refresh_in_uhz;
85 unsigned int max_refresh_in_uhz;
86};
4562236b 87
98e6436d
AK
88struct mod_vrr_params_btr {
89 bool btr_enabled;
90 bool btr_active;
91 uint32_t mid_point_in_us;
92 uint32_t inserted_duration_in_us;
93 uint32_t frames_to_insert;
94 uint32_t frame_counter;
95};
4562236b 96
98e6436d
AK
97struct mod_vrr_params_fixed_refresh {
98 bool fixed_active;
99 bool ramping_active;
100 bool ramping_done;
101 uint32_t target_refresh_in_uhz;
102 uint32_t frame_counter;
103};
4562236b 104
98e6436d
AK
105struct mod_vrr_params {
106 bool supported;
ca35899c 107 bool send_info_frame;
98e6436d 108 enum mod_vrr_state state;
4562236b 109
98e6436d
AK
110 uint32_t min_refresh_in_uhz;
111 uint32_t max_duration_in_us;
112 uint32_t max_refresh_in_uhz;
113 uint32_t min_duration_in_us;
4562236b 114
98e6436d 115 struct dc_crtc_timing_adjust adjust;
4562236b 116
98e6436d 117 struct mod_vrr_params_fixed_refresh fixed;
1a87fbfe 118
98e6436d
AK
119 struct mod_vrr_params_btr btr;
120};
72ada5f7 121
98e6436d
AK
122struct mod_freesync *mod_freesync_create(struct dc *dc);
123void mod_freesync_destroy(struct mod_freesync *mod_freesync);
72ada5f7
EC
124
125bool mod_freesync_get_vmin_vmax(struct mod_freesync *mod_freesync,
98e6436d 126 const struct dc_stream_state *stream,
72ada5f7
EC
127 unsigned int *vmin,
128 unsigned int *vmax);
129
130bool mod_freesync_get_v_position(struct mod_freesync *mod_freesync,
0971c40e 131 struct dc_stream_state *stream,
72ada5f7
EC
132 unsigned int *nom_v_pos,
133 unsigned int *v_pos);
134
a3e1737e 135void mod_freesync_get_settings(struct mod_freesync *mod_freesync,
98e6436d 136 const struct mod_vrr_params *vrr,
a3e1737e
AK
137 unsigned int *v_total_min, unsigned int *v_total_max,
138 unsigned int *event_triggers,
139 unsigned int *window_min, unsigned int *window_max,
140 unsigned int *lfc_mid_point_in_us,
141 unsigned int *inserted_frames,
142 unsigned int *inserted_duration_in_us);
143
98e6436d
AK
144void mod_freesync_build_vrr_infopacket(struct mod_freesync *mod_freesync,
145 const struct dc_stream_state *stream,
146 const struct mod_vrr_params *vrr,
c2791297 147 enum vrr_packet_type packet_type,
672e78ca 148 enum color_transfer_func app_tf,
98e6436d
AK
149 struct dc_info_packet *infopacket);
150
151void mod_freesync_build_vrr_params(struct mod_freesync *mod_freesync,
152 const struct dc_stream_state *stream,
153 struct mod_freesync_config *in_config,
154 struct mod_vrr_params *in_out_vrr);
155
156void mod_freesync_handle_preflip(struct mod_freesync *mod_freesync,
157 const struct dc_plane_state *plane,
158 const struct dc_stream_state *stream,
159 unsigned int curr_time_stamp_in_us,
160 struct mod_vrr_params *in_out_vrr);
161
162void mod_freesync_handle_v_update(struct mod_freesync *mod_freesync,
163 const struct dc_stream_state *stream,
164 struct mod_vrr_params *in_out_vrr);
165
ff6014d6
AK
166unsigned long long mod_freesync_calc_nominal_field_rate(
167 const struct dc_stream_state *stream);
168
e80e9446
AK
169bool mod_freesync_is_valid_range(struct mod_freesync *mod_freesync,
170 const struct dc_stream_state *stream,
171 uint32_t min_refresh_cap_in_uhz,
172 uint32_t max_refresh_cap_in_uhz,
173 uint32_t min_refresh_request_in_uhz,
174 uint32_t max_refresh_request_in_uhz);
175
a9f54ce3
AO
176
177
4562236b 178#endif