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#define AMDGPU_DM_MAX_CRTC 6
48
49#define AMDGPU_DM_MAX_NUM_EDP 2
50
51
52
53
54
55#include "irq_types.h"
56#include "signal_types.h"
57#include "amdgpu_dm_crc.h"
58struct aux_payload;
59enum aux_return_code_type;
60
61
62struct amdgpu_device;
63struct amdgpu_crtc;
64struct drm_device;
65struct dc;
66struct amdgpu_bo;
67struct dmub_srv;
68struct dc_plane_state;
69struct dmub_notification;
70
71struct common_irq_params {
72 struct amdgpu_device *adev;
73 enum dc_irq_source irq_src;
74 atomic64_t previous_timestamp;
75};
76
77
78
79
80
81
82
83struct dm_compressor_info {
84 void *cpu_addr;
85 struct amdgpu_bo *bo_ptr;
86 uint64_t gpu_addr;
87};
88
89
90
91
92
93
94
95
96
97struct vblank_control_work {
98 struct work_struct work;
99 struct amdgpu_display_manager *dm;
100 struct amdgpu_crtc *acrtc;
101 struct dc_stream_state *stream;
102 bool enable;
103};
104
105
106
107
108
109
110struct amdgpu_dm_backlight_caps {
111
112
113
114
115 union dpcd_sink_ext_caps *ext_caps;
116
117
118
119 u32 aux_min_input_signal;
120
121
122
123
124 u32 aux_max_input_signal;
125
126
127
128 int min_input_signal;
129
130
131
132 int max_input_signal;
133
134
135
136 bool caps_valid;
137
138
139
140 bool aux_support;
141};
142
143
144
145
146
147
148
149
150struct dal_allocation {
151 struct list_head list;
152 struct amdgpu_bo *bo;
153 void *cpu_ptr;
154 u64 gpu_addr;
155};
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180struct amdgpu_display_manager {
181
182 struct dc *dc;
183
184
185
186
187
188
189
190
191 struct dmub_srv *dmub_srv;
192
193 struct dmub_notification *dmub_notify;
194
195
196
197
198
199
200 struct dmub_srv_fb_info *dmub_fb_info;
201
202
203
204
205
206
207 const struct firmware *dmub_fw;
208
209
210
211
212
213
214 struct amdgpu_bo *dmub_bo;
215
216
217
218
219
220
221 u64 dmub_bo_gpu_addr;
222
223
224
225
226
227
228 void *dmub_bo_cpu_addr;
229
230
231
232
233
234
235 uint32_t dmcub_fw_version;
236
237
238
239
240
241
242
243 struct cgs_device *cgs_device;
244
245 struct amdgpu_device *adev;
246 struct drm_device *ddev;
247 u16 display_indexes_num;
248
249
250
251
252
253
254
255
256 struct drm_private_obj atomic_obj;
257
258
259
260
261
262
263
264 struct mutex dc_lock;
265
266
267
268
269
270
271 struct mutex audio_lock;
272
273#if defined(CONFIG_DRM_AMD_DC_DCN)
274
275
276
277
278
279 spinlock_t vblank_lock;
280#endif
281
282
283
284
285
286
287 struct drm_audio_component *audio_component;
288
289
290
291
292
293
294
295 bool audio_registered;
296
297
298
299
300
301
302
303
304
305
306
307
308
309 struct list_head irq_handler_list_low_tab[DAL_IRQ_SOURCES_NUMBER];
310
311
312
313
314
315
316
317
318
319 struct list_head irq_handler_list_high_tab[DAL_IRQ_SOURCES_NUMBER];
320
321
322
323
324
325
326
327 struct common_irq_params
328 pflip_params[DC_IRQ_SOURCE_PFLIP_LAST - DC_IRQ_SOURCE_PFLIP_FIRST + 1];
329
330
331
332
333
334
335
336 struct common_irq_params
337 vblank_params[DC_IRQ_SOURCE_VBLANK6 - DC_IRQ_SOURCE_VBLANK1 + 1];
338
339
340
341
342
343
344
345 struct common_irq_params
346 vline0_params[DC_IRQ_SOURCE_DC6_VLINE0 - DC_IRQ_SOURCE_DC1_VLINE0 + 1];
347
348
349
350
351
352
353
354 struct common_irq_params
355 vupdate_params[DC_IRQ_SOURCE_VUPDATE6 - DC_IRQ_SOURCE_VUPDATE1 + 1];
356
357
358
359
360
361
362
363 struct common_irq_params
364 dmub_trace_params[1];
365
366 struct common_irq_params
367 dmub_outbox_params[1];
368
369 spinlock_t irq_handler_list_table_lock;
370
371 struct backlight_device *backlight_dev[AMDGPU_DM_MAX_NUM_EDP];
372
373 const struct dc_link *backlight_link[AMDGPU_DM_MAX_NUM_EDP];
374
375 uint8_t num_of_edps;
376
377 struct amdgpu_dm_backlight_caps backlight_caps[AMDGPU_DM_MAX_NUM_EDP];
378
379 struct mod_freesync *freesync_module;
380#ifdef CONFIG_DRM_AMD_DC_HDCP
381 struct hdcp_workqueue *hdcp_workqueue;
382#endif
383
384#if defined(CONFIG_DRM_AMD_DC_DCN)
385
386
387
388
389
390 struct workqueue_struct *vblank_control_workqueue;
391#endif
392
393 struct drm_atomic_state *cached_state;
394 struct dc_state *cached_dc_state;
395
396 struct dm_compressor_info compressor;
397
398 const struct firmware *fw_dmcu;
399 uint32_t dmcu_fw_version;
400
401
402
403
404
405
406 const struct gpu_info_soc_bounding_box_v1_0 *soc_bounding_box;
407
408#if defined(CONFIG_DRM_AMD_DC_DCN)
409
410
411
412
413
414 uint32_t active_vblank_irq_count;
415#endif
416
417#if defined(CONFIG_DRM_AMD_SECURE_DISPLAY)
418
419
420
421
422
423 struct crc_rd_work *crc_rd_wrk;
424#endif
425
426
427
428
429
430
431 struct amdgpu_encoder mst_encoders[AMDGPU_DM_MAX_CRTC];
432 bool force_timing_sync;
433 bool disable_hpd_irq;
434 bool dmcub_trace_event_en;
435
436
437
438
439
440 struct list_head da_list;
441 struct completion dmub_aux_transfer_done;
442
443
444
445
446
447
448 u32 brightness[AMDGPU_DM_MAX_NUM_EDP];
449};
450
451enum dsc_clock_force_state {
452 DSC_CLK_FORCE_DEFAULT = 0,
453 DSC_CLK_FORCE_ENABLE,
454 DSC_CLK_FORCE_DISABLE,
455};
456
457struct dsc_preferred_settings {
458 enum dsc_clock_force_state dsc_force_enable;
459 uint32_t dsc_num_slices_v;
460 uint32_t dsc_num_slices_h;
461 uint32_t dsc_bits_per_pixel;
462 bool dsc_force_disable_passthrough;
463};
464
465struct amdgpu_dm_connector {
466
467 struct drm_connector base;
468 uint32_t connector_id;
469
470
471
472 struct edid *edid;
473
474
475 struct amdgpu_hpd hpd;
476
477
478 int num_modes;
479
480
481
482 struct dc_sink *dc_sink;
483 struct dc_link *dc_link;
484 struct dc_sink *dc_em_sink;
485
486
487 struct drm_dp_mst_topology_mgr mst_mgr;
488 struct amdgpu_dm_dp_aux dm_dp_aux;
489 struct drm_dp_mst_port *port;
490 struct amdgpu_dm_connector *mst_port;
491 struct drm_dp_aux *dsc_aux;
492
493
494 struct amdgpu_i2c_adapter *i2c;
495
496
497 int min_vfreq ;
498 int max_vfreq ;
499 int pixel_clock_mhz;
500
501
502 int audio_inst;
503
504 struct mutex hpd_lock;
505
506 bool fake_enable;
507#ifdef CONFIG_DEBUG_FS
508 uint32_t debugfs_dpcd_address;
509 uint32_t debugfs_dpcd_size;
510#endif
511 bool force_yuv420_output;
512 struct dsc_preferred_settings dsc_settings;
513
514 struct drm_display_mode freesync_vid_base;
515
516 int psr_skip_count;
517};
518
519#define to_amdgpu_dm_connector(x) container_of(x, struct amdgpu_dm_connector, base)
520
521extern const struct amdgpu_ip_block_version dm_ip_block;
522
523struct dm_plane_state {
524 struct drm_plane_state base;
525 struct dc_plane_state *dc_state;
526};
527
528struct dm_crtc_state {
529 struct drm_crtc_state base;
530 struct dc_stream_state *stream;
531
532 bool cm_has_degamma;
533 bool cm_is_degamma_srgb;
534
535 int update_type;
536 int active_planes;
537
538 int crc_skip_count;
539
540 bool freesync_timing_changed;
541 bool freesync_vrr_info_changed;
542
543 bool dsc_force_changed;
544 bool vrr_supported;
545 struct mod_freesync_config freesync_config;
546 struct dc_info_packet vrr_infopacket;
547
548 int abm_level;
549};
550
551#define to_dm_crtc_state(x) container_of(x, struct dm_crtc_state, base)
552
553struct dm_atomic_state {
554 struct drm_private_state base;
555
556 struct dc_state *context;
557};
558
559#define to_dm_atomic_state(x) container_of(x, struct dm_atomic_state, base)
560
561struct dm_connector_state {
562 struct drm_connector_state base;
563
564 enum amdgpu_rmx_type scaling;
565 uint8_t underscan_vborder;
566 uint8_t underscan_hborder;
567 bool underscan_enable;
568 bool freesync_capable;
569#ifdef CONFIG_DRM_AMD_DC_HDCP
570 bool update_hdcp;
571#endif
572 uint8_t abm_level;
573 int vcpi_slots;
574 uint64_t pbn;
575};
576
577struct amdgpu_hdmi_vsdb_info {
578 unsigned int amd_vsdb_version;
579 bool freesync_supported;
580 unsigned int min_refresh_rate_hz;
581 unsigned int max_refresh_rate_hz;
582};
583
584
585#define to_dm_connector_state(x)\
586 container_of((x), struct dm_connector_state, base)
587
588void amdgpu_dm_connector_funcs_reset(struct drm_connector *connector);
589struct drm_connector_state *
590amdgpu_dm_connector_atomic_duplicate_state(struct drm_connector *connector);
591int amdgpu_dm_connector_atomic_set_property(struct drm_connector *connector,
592 struct drm_connector_state *state,
593 struct drm_property *property,
594 uint64_t val);
595
596int amdgpu_dm_connector_atomic_get_property(struct drm_connector *connector,
597 const struct drm_connector_state *state,
598 struct drm_property *property,
599 uint64_t *val);
600
601int amdgpu_dm_get_encoder_crtc_mask(struct amdgpu_device *adev);
602
603void amdgpu_dm_connector_init_helper(struct amdgpu_display_manager *dm,
604 struct amdgpu_dm_connector *aconnector,
605 int connector_type,
606 struct dc_link *link,
607 int link_index);
608
609enum drm_mode_status amdgpu_dm_connector_mode_valid(struct drm_connector *connector,
610 struct drm_display_mode *mode);
611
612void dm_restore_drm_connector_state(struct drm_device *dev,
613 struct drm_connector *connector);
614
615void amdgpu_dm_update_freesync_caps(struct drm_connector *connector,
616 struct edid *edid);
617
618void amdgpu_dm_trigger_timing_sync(struct drm_device *dev);
619
620#define MAX_COLOR_LUT_ENTRIES 4096
621
622#define MAX_COLOR_LEGACY_LUT_ENTRIES 256
623
624void amdgpu_dm_init_color_mod(void);
625int amdgpu_dm_verify_lut_sizes(const struct drm_crtc_state *crtc_state);
626int amdgpu_dm_update_crtc_color_mgmt(struct dm_crtc_state *crtc);
627int amdgpu_dm_update_plane_color_mgmt(struct dm_crtc_state *crtc,
628 struct dc_plane_state *dc_plane_state);
629
630void amdgpu_dm_update_connector_after_detect(
631 struct amdgpu_dm_connector *aconnector);
632
633extern const struct drm_encoder_helper_funcs amdgpu_dm_encoder_helper_funcs;
634
635int amdgpu_dm_process_dmub_aux_transfer_sync(struct dc_context *ctx, unsigned int linkIndex,
636 struct aux_payload *payload, enum aux_return_code_type *operation_result);
637#endif
638