1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 #ifndef __AMDGPU_DM_H__
27 #define __AMDGPU_DM_H__
28
29 #include <drm/drm_atomic.h>
30 #include <drm/drm_connector.h>
31 #include <drm/drm_crtc.h>
32 #include <drm/drm_dp_mst_helper.h>
33 #include <drm/drm_plane.h>
34
35
36
37
38
39
40
41
42
43
44
45 #define AMDGPU_DM_MAX_DISPLAY_INDEX 31
46
47
48
49
50
51 #include "irq_types.h"
52 #include "signal_types.h"
53 #include "amdgpu_dm_crc.h"
54
55
56 struct amdgpu_device;
57 struct drm_device;
58 struct amdgpu_dm_irq_handler_data;
59 struct dc;
60
61 struct common_irq_params {
62 struct amdgpu_device *adev;
63 enum dc_irq_source irq_src;
64 };
65
66
67
68
69
70
71
72 struct irq_list_head {
73 struct list_head head;
74
75 struct work_struct work;
76 };
77
78
79
80
81
82
83
84 struct dm_comressor_info {
85 void *cpu_addr;
86 struct amdgpu_bo *bo_ptr;
87 uint64_t gpu_addr;
88 };
89
90
91
92
93
94
95
96 struct amdgpu_dm_backlight_caps {
97 int min_input_signal;
98 int max_input_signal;
99 bool caps_valid;
100 };
101
102
103
104
105
106
107
108
109
110
111
112
113
114 struct amdgpu_display_manager {
115
116 struct dc *dc;
117
118
119
120
121
122
123
124 struct cgs_device *cgs_device;
125
126 struct amdgpu_device *adev;
127 struct drm_device *ddev;
128 u16 display_indexes_num;
129
130
131
132
133
134
135
136
137 struct drm_private_obj atomic_obj;
138
139
140
141
142
143
144
145 struct mutex dc_lock;
146
147
148
149
150
151
152 struct mutex audio_lock;
153
154
155
156
157
158
159 struct drm_audio_component *audio_component;
160
161
162
163
164
165
166
167 bool audio_registered;
168
169
170
171
172
173
174
175
176
177
178
179
180
181 struct irq_list_head irq_handler_list_low_tab[DAL_IRQ_SOURCES_NUMBER];
182
183
184
185
186
187
188
189
190
191 struct list_head irq_handler_list_high_tab[DAL_IRQ_SOURCES_NUMBER];
192
193
194
195
196
197
198
199 struct common_irq_params
200 pflip_params[DC_IRQ_SOURCE_PFLIP_LAST - DC_IRQ_SOURCE_PFLIP_FIRST + 1];
201
202
203
204
205
206
207
208 struct common_irq_params
209 vblank_params[DC_IRQ_SOURCE_VBLANK6 - DC_IRQ_SOURCE_VBLANK1 + 1];
210
211
212
213
214
215
216
217 struct common_irq_params
218 vupdate_params[DC_IRQ_SOURCE_VUPDATE6 - DC_IRQ_SOURCE_VUPDATE1 + 1];
219
220 spinlock_t irq_handler_list_table_lock;
221
222 struct backlight_device *backlight_dev;
223
224 const struct dc_link *backlight_link;
225 struct amdgpu_dm_backlight_caps backlight_caps;
226
227 struct mod_freesync *freesync_module;
228
229 struct drm_atomic_state *cached_state;
230
231 struct dm_comressor_info compressor;
232
233 const struct firmware *fw_dmcu;
234 uint32_t dmcu_fw_version;
235 #ifdef CONFIG_DRM_AMD_DC_DCN2_0
236
237
238
239
240 const struct gpu_info_soc_bounding_box_v1_0 *soc_bounding_box;
241 #endif
242 };
243
244 struct amdgpu_dm_connector {
245
246 struct drm_connector base;
247 uint32_t connector_id;
248
249
250
251 struct edid *edid;
252
253
254 struct amdgpu_hpd hpd;
255
256
257 int num_modes;
258
259
260
261 struct dc_sink *dc_sink;
262 struct dc_link *dc_link;
263 struct dc_sink *dc_em_sink;
264
265
266 struct drm_dp_mst_topology_mgr mst_mgr;
267 struct amdgpu_dm_dp_aux dm_dp_aux;
268 struct drm_dp_mst_port *port;
269 struct amdgpu_dm_connector *mst_port;
270 struct amdgpu_encoder *mst_encoder;
271
272
273 struct amdgpu_i2c_adapter *i2c;
274
275
276 int min_vfreq ;
277 int max_vfreq ;
278 int pixel_clock_mhz;
279
280
281 int audio_inst;
282
283 struct mutex hpd_lock;
284
285 bool fake_enable;
286 #ifdef CONFIG_DEBUG_FS
287 uint32_t debugfs_dpcd_address;
288 uint32_t debugfs_dpcd_size;
289 #endif
290 };
291
292 #define to_amdgpu_dm_connector(x) container_of(x, struct amdgpu_dm_connector, base)
293
294 extern const struct amdgpu_ip_block_version dm_ip_block;
295
296 struct amdgpu_framebuffer;
297 struct amdgpu_display_manager;
298 struct dc_validation_set;
299 struct dc_plane_state;
300
301 struct dm_plane_state {
302 struct drm_plane_state base;
303 struct dc_plane_state *dc_state;
304 };
305
306 struct dm_crtc_state {
307 struct drm_crtc_state base;
308 struct dc_stream_state *stream;
309
310 bool cm_has_degamma;
311 bool cm_is_degamma_srgb;
312
313 int update_type;
314 int active_planes;
315 bool interrupts_enabled;
316
317 int crc_skip_count;
318 enum amdgpu_dm_pipe_crc_source crc_src;
319
320 bool freesync_timing_changed;
321 bool freesync_vrr_info_changed;
322
323 bool vrr_supported;
324 struct mod_freesync_config freesync_config;
325 struct mod_vrr_params vrr_params;
326 struct dc_info_packet vrr_infopacket;
327
328 int abm_level;
329 };
330
331 #define to_dm_crtc_state(x) container_of(x, struct dm_crtc_state, base)
332
333 struct dm_atomic_state {
334 struct drm_private_state base;
335
336 struct dc_state *context;
337 };
338
339 #define to_dm_atomic_state(x) container_of(x, struct dm_atomic_state, base)
340
341 struct dm_connector_state {
342 struct drm_connector_state base;
343
344 enum amdgpu_rmx_type scaling;
345 uint8_t underscan_vborder;
346 uint8_t underscan_hborder;
347 bool underscan_enable;
348 bool freesync_capable;
349 uint8_t abm_level;
350 };
351
352 #define to_dm_connector_state(x)\
353 container_of((x), struct dm_connector_state, base)
354
355 void amdgpu_dm_connector_funcs_reset(struct drm_connector *connector);
356 struct drm_connector_state *
357 amdgpu_dm_connector_atomic_duplicate_state(struct drm_connector *connector);
358 int amdgpu_dm_connector_atomic_set_property(struct drm_connector *connector,
359 struct drm_connector_state *state,
360 struct drm_property *property,
361 uint64_t val);
362
363 int amdgpu_dm_connector_atomic_get_property(struct drm_connector *connector,
364 const struct drm_connector_state *state,
365 struct drm_property *property,
366 uint64_t *val);
367
368 int amdgpu_dm_get_encoder_crtc_mask(struct amdgpu_device *adev);
369
370 void amdgpu_dm_connector_init_helper(struct amdgpu_display_manager *dm,
371 struct amdgpu_dm_connector *aconnector,
372 int connector_type,
373 struct dc_link *link,
374 int link_index);
375
376 enum drm_mode_status amdgpu_dm_connector_mode_valid(struct drm_connector *connector,
377 struct drm_display_mode *mode);
378
379 void dm_restore_drm_connector_state(struct drm_device *dev,
380 struct drm_connector *connector);
381
382 void amdgpu_dm_update_freesync_caps(struct drm_connector *connector,
383 struct edid *edid);
384
385 #define MAX_COLOR_LUT_ENTRIES 4096
386
387 #define MAX_COLOR_LEGACY_LUT_ENTRIES 256
388
389 void amdgpu_dm_init_color_mod(void);
390 int amdgpu_dm_update_crtc_color_mgmt(struct dm_crtc_state *crtc);
391 int amdgpu_dm_update_plane_color_mgmt(struct dm_crtc_state *crtc,
392 struct dc_plane_state *dc_plane_state);
393
394 extern const struct drm_encoder_helper_funcs amdgpu_dm_encoder_helper_funcs;
395
396 #endif