1 /*
2  * Copyright (C) 2015-2020 Advanced Micro Devices, Inc. All rights reserved.
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 __AMDGPU_DM_H__
27 #define __AMDGPU_DM_H__
28 
29 #include <drm/display/drm_dp_mst_helper.h>
30 #include <drm/drm_atomic.h>
31 #include <drm/drm_connector.h>
32 #include <drm/drm_crtc.h>
33 #include <drm/drm_plane.h>
34 #include "link_service_types.h"
35 
36 /*
37  * This file contains the definition for amdgpu_display_manager
38  * and its API for amdgpu driver's use.
39  * This component provides all the display related functionality
40  * and this is the only component that calls DAL API.
41  * The API contained here intended for amdgpu driver use.
42  * The API that is called directly from KMS framework is located
43  * in amdgpu_dm_kms.h file
44  */
45 
46 #define AMDGPU_DM_MAX_DISPLAY_INDEX 31
47 
48 #define AMDGPU_DM_MAX_CRTC 6
49 
50 #define AMDGPU_DM_MAX_NUM_EDP 2
51 
52 #define AMDGPU_DMUB_NOTIFICATION_MAX 5
53 
54 /*
55 #include "include/amdgpu_dal_power_if.h"
56 #include "amdgpu_dm_irq.h"
57 */
58 
59 #include "irq_types.h"
60 #include "signal_types.h"
61 #include "amdgpu_dm_crc.h"
62 #include "mod_info_packet.h"
63 struct aux_payload;
64 struct set_config_cmd_payload;
65 enum aux_return_code_type;
66 enum set_config_status;
67 
68 /* Forward declarations */
69 struct amdgpu_device;
70 struct amdgpu_crtc;
71 struct drm_device;
72 struct dc;
73 struct amdgpu_bo;
74 struct dmub_srv;
75 struct dc_plane_state;
76 struct dmub_notification;
77 
78 struct common_irq_params {
79 	struct amdgpu_device *adev;
80 	enum dc_irq_source irq_src;
81 	atomic64_t previous_timestamp;
82 };
83 
84 /**
85  * struct dm_compressor_info - Buffer info used by frame buffer compression
86  * @cpu_addr: MMIO cpu addr
87  * @bo_ptr: Pointer to the buffer object
88  * @gpu_addr: MMIO gpu addr
89  */
90 struct dm_compressor_info {
91 	void *cpu_addr;
92 	struct amdgpu_bo *bo_ptr;
93 	uint64_t gpu_addr;
94 };
95 
96 typedef void (*dmub_notify_interrupt_callback_t)(struct amdgpu_device *adev, struct dmub_notification *notify);
97 
98 /**
99  * struct dmub_hpd_work - Handle time consuming work in low priority outbox IRQ
100  *
101  * @handle_hpd_work: Work to be executed in a separate thread to handle hpd_low_irq
102  * @dmub_notify:  notification for callback function
103  * @adev: amdgpu_device pointer
104  */
105 struct dmub_hpd_work {
106 	struct work_struct handle_hpd_work;
107 	struct dmub_notification *dmub_notify;
108 	struct amdgpu_device *adev;
109 };
110 
111 /**
112  * struct vblank_control_work - Work data for vblank control
113  * @work: Kernel work data for the work event
114  * @dm: amdgpu display manager device
115  * @acrtc: amdgpu CRTC instance for which the event has occurred
116  * @stream: DC stream for which the event has occurred
117  * @enable: true if enabling vblank
118  */
119 struct vblank_control_work {
120 	struct work_struct work;
121 	struct amdgpu_display_manager *dm;
122 	struct amdgpu_crtc *acrtc;
123 	struct dc_stream_state *stream;
124 	bool enable;
125 };
126 
127 /**
128  * struct amdgpu_dm_backlight_caps - Information about backlight
129  *
130  * Describe the backlight support for ACPI or eDP AUX.
131  */
132 struct amdgpu_dm_backlight_caps {
133 	/**
134 	 * @ext_caps: Keep the data struct with all the information about the
135 	 * display support for HDR.
136 	 */
137 	union dpcd_sink_ext_caps *ext_caps;
138 	/**
139 	 * @aux_min_input_signal: Min brightness value supported by the display
140 	 */
141 	u32 aux_min_input_signal;
142 	/**
143 	 * @aux_max_input_signal: Max brightness value supported by the display
144 	 * in nits.
145 	 */
146 	u32 aux_max_input_signal;
147 	/**
148 	 * @min_input_signal: minimum possible input in range 0-255.
149 	 */
150 	int min_input_signal;
151 	/**
152 	 * @max_input_signal: maximum possible input in range 0-255.
153 	 */
154 	int max_input_signal;
155 	/**
156 	 * @caps_valid: true if these values are from the ACPI interface.
157 	 */
158 	bool caps_valid;
159 	/**
160 	 * @aux_support: Describes if the display supports AUX backlight.
161 	 */
162 	bool aux_support;
163 };
164 
165 /**
166  * struct dal_allocation - Tracks mapped FB memory for SMU communication
167  * @list: list of dal allocations
168  * @bo: GPU buffer object
169  * @cpu_ptr: CPU virtual address of the GPU buffer object
170  * @gpu_addr: GPU virtual address of the GPU buffer object
171  */
172 struct dal_allocation {
173 	struct list_head list;
174 	struct amdgpu_bo *bo;
175 	void *cpu_ptr;
176 	u64 gpu_addr;
177 };
178 
179 /**
180  * struct hpd_rx_irq_offload_work_queue - Work queue to handle hpd_rx_irq
181  * offload work
182  */
183 struct hpd_rx_irq_offload_work_queue {
184 	/**
185 	 * @wq: workqueue structure to queue offload work.
186 	 */
187 	struct workqueue_struct *wq;
188 	/**
189 	 * @offload_lock: To protect fields of offload work queue.
190 	 */
191 	spinlock_t offload_lock;
192 	/**
193 	 * @is_handling_link_loss: Used to prevent inserting link loss event when
194 	 * we're handling link loss
195 	 */
196 	bool is_handling_link_loss;
197 	/**
198 	 * @aconnector: The aconnector that this work queue is attached to
199 	 */
200 	struct amdgpu_dm_connector *aconnector;
201 };
202 
203 /**
204  * struct hpd_rx_irq_offload_work - hpd_rx_irq offload work structure
205  */
206 struct hpd_rx_irq_offload_work {
207 	/**
208 	 * @work: offload work
209 	 */
210 	struct work_struct work;
211 	/**
212 	 * @data: reference irq data which is used while handling offload work
213 	 */
214 	union hpd_irq_data data;
215 	/**
216 	 * @offload_wq: offload work queue that this work is queued to
217 	 */
218 	struct hpd_rx_irq_offload_work_queue *offload_wq;
219 };
220 
221 /**
222  * struct amdgpu_display_manager - Central amdgpu display manager device
223  *
224  * @dc: Display Core control structure
225  * @adev: AMDGPU base driver structure
226  * @ddev: DRM base driver structure
227  * @display_indexes_num: Max number of display streams supported
228  * @irq_handler_list_table_lock: Synchronizes access to IRQ tables
229  * @backlight_dev: Backlight control device
230  * @backlight_link: Link on which to control backlight
231  * @backlight_caps: Capabilities of the backlight device
232  * @freesync_module: Module handling freesync calculations
233  * @hdcp_workqueue: AMDGPU content protection queue
234  * @fw_dmcu: Reference to DMCU firmware
235  * @dmcu_fw_version: Version of the DMCU firmware
236  * @soc_bounding_box: SOC bounding box values provided by gpu_info FW
237  * @cached_state: Caches device atomic state for suspend/resume
238  * @cached_dc_state: Cached state of content streams
239  * @compressor: Frame buffer compression buffer. See &struct dm_compressor_info
240  * @force_timing_sync: set via debugfs. When set, indicates that all connected
241  *		       displays will be forced to synchronize.
242  * @dmcub_trace_event_en: enable dmcub trace events
243  * @dmub_outbox_params: DMUB Outbox parameters
244  * @num_of_edps: number of backlight eDPs
245  * @disable_hpd_irq: disables all HPD and HPD RX interrupt handling in the
246  *		     driver when true
247  * @dmub_aux_transfer_done: struct completion used to indicate when DMUB
248  * 			    transfers are done
249  * @delayed_hpd_wq: work queue used to delay DMUB HPD work
250  */
251 struct amdgpu_display_manager {
252 
253 	struct dc *dc;
254 
255 	/**
256 	 * @dmub_srv:
257 	 *
258 	 * DMUB service, used for controlling the DMUB on hardware
259 	 * that supports it. The pointer to the dmub_srv will be
260 	 * NULL on hardware that does not support it.
261 	 */
262 	struct dmub_srv *dmub_srv;
263 
264 	/**
265 	 * @dmub_notify:
266 	 *
267 	 * Notification from DMUB.
268 	 */
269 
270 	struct dmub_notification *dmub_notify;
271 
272 	/**
273 	 * @dmub_callback:
274 	 *
275 	 * Callback functions to handle notification from DMUB.
276 	 */
277 
278 	dmub_notify_interrupt_callback_t dmub_callback[AMDGPU_DMUB_NOTIFICATION_MAX];
279 
280 	/**
281 	 * @dmub_thread_offload:
282 	 *
283 	 * Flag to indicate if callback is offload.
284 	 */
285 
286 	bool dmub_thread_offload[AMDGPU_DMUB_NOTIFICATION_MAX];
287 
288 	/**
289 	 * @dmub_fb_info:
290 	 *
291 	 * Framebuffer regions for the DMUB.
292 	 */
293 	struct dmub_srv_fb_info *dmub_fb_info;
294 
295 	/**
296 	 * @dmub_fw:
297 	 *
298 	 * DMUB firmware, required on hardware that has DMUB support.
299 	 */
300 	const struct firmware *dmub_fw;
301 
302 	/**
303 	 * @dmub_bo:
304 	 *
305 	 * Buffer object for the DMUB.
306 	 */
307 	struct amdgpu_bo *dmub_bo;
308 
309 	/**
310 	 * @dmub_bo_gpu_addr:
311 	 *
312 	 * GPU virtual address for the DMUB buffer object.
313 	 */
314 	u64 dmub_bo_gpu_addr;
315 
316 	/**
317 	 * @dmub_bo_cpu_addr:
318 	 *
319 	 * CPU address for the DMUB buffer object.
320 	 */
321 	void *dmub_bo_cpu_addr;
322 
323 	/**
324 	 * @dmcub_fw_version:
325 	 *
326 	 * DMCUB firmware version.
327 	 */
328 	uint32_t dmcub_fw_version;
329 
330 	/**
331 	 * @cgs_device:
332 	 *
333 	 * The Common Graphics Services device. It provides an interface for
334 	 * accessing registers.
335 	 */
336 	struct cgs_device *cgs_device;
337 
338 	struct amdgpu_device *adev;
339 	struct drm_device *ddev;
340 	u16 display_indexes_num;
341 
342 	/**
343 	 * @atomic_obj:
344 	 *
345 	 * In combination with &dm_atomic_state it helps manage
346 	 * global atomic state that doesn't map cleanly into existing
347 	 * drm resources, like &dc_context.
348 	 */
349 	struct drm_private_obj atomic_obj;
350 
351 	/**
352 	 * @dc_lock:
353 	 *
354 	 * Guards access to DC functions that can issue register write
355 	 * sequences.
356 	 */
357 	struct mutex dc_lock;
358 
359 	/**
360 	 * @audio_lock:
361 	 *
362 	 * Guards access to audio instance changes.
363 	 */
364 	struct mutex audio_lock;
365 
366 	/**
367 	 * @audio_component:
368 	 *
369 	 * Used to notify ELD changes to sound driver.
370 	 */
371 	struct drm_audio_component *audio_component;
372 
373 	/**
374 	 * @audio_registered:
375 	 *
376 	 * True if the audio component has been registered
377 	 * successfully, false otherwise.
378 	 */
379 	bool audio_registered;
380 
381 	/**
382 	 * @irq_handler_list_low_tab:
383 	 *
384 	 * Low priority IRQ handler table.
385 	 *
386 	 * It is a n*m table consisting of n IRQ sources, and m handlers per IRQ
387 	 * source. Low priority IRQ handlers are deferred to a workqueue to be
388 	 * processed. Hence, they can sleep.
389 	 *
390 	 * Note that handlers are called in the same order as they were
391 	 * registered (FIFO).
392 	 */
393 	struct list_head irq_handler_list_low_tab[DAL_IRQ_SOURCES_NUMBER];
394 
395 	/**
396 	 * @irq_handler_list_high_tab:
397 	 *
398 	 * High priority IRQ handler table.
399 	 *
400 	 * It is a n*m table, same as &irq_handler_list_low_tab. However,
401 	 * handlers in this table are not deferred and are called immediately.
402 	 */
403 	struct list_head irq_handler_list_high_tab[DAL_IRQ_SOURCES_NUMBER];
404 
405 	/**
406 	 * @pflip_params:
407 	 *
408 	 * Page flip IRQ parameters, passed to registered handlers when
409 	 * triggered.
410 	 */
411 	struct common_irq_params
412 	pflip_params[DC_IRQ_SOURCE_PFLIP_LAST - DC_IRQ_SOURCE_PFLIP_FIRST + 1];
413 
414 	/**
415 	 * @vblank_params:
416 	 *
417 	 * Vertical blanking IRQ parameters, passed to registered handlers when
418 	 * triggered.
419 	 */
420 	struct common_irq_params
421 	vblank_params[DC_IRQ_SOURCE_VBLANK6 - DC_IRQ_SOURCE_VBLANK1 + 1];
422 
423 	/**
424 	 * @vline0_params:
425 	 *
426 	 * OTG vertical interrupt0 IRQ parameters, passed to registered
427 	 * handlers when triggered.
428 	 */
429 	struct common_irq_params
430 	vline0_params[DC_IRQ_SOURCE_DC6_VLINE0 - DC_IRQ_SOURCE_DC1_VLINE0 + 1];
431 
432 	/**
433 	 * @vupdate_params:
434 	 *
435 	 * Vertical update IRQ parameters, passed to registered handlers when
436 	 * triggered.
437 	 */
438 	struct common_irq_params
439 	vupdate_params[DC_IRQ_SOURCE_VUPDATE6 - DC_IRQ_SOURCE_VUPDATE1 + 1];
440 
441 	/**
442 	 * @dmub_trace_params:
443 	 *
444 	 * DMUB trace event IRQ parameters, passed to registered handlers when
445 	 * triggered.
446 	 */
447 	struct common_irq_params
448 	dmub_trace_params[1];
449 
450 	struct common_irq_params
451 	dmub_outbox_params[1];
452 
453 	spinlock_t irq_handler_list_table_lock;
454 
455 	struct backlight_device *backlight_dev[AMDGPU_DM_MAX_NUM_EDP];
456 
457 	const struct dc_link *backlight_link[AMDGPU_DM_MAX_NUM_EDP];
458 
459 	uint8_t num_of_edps;
460 
461 	struct amdgpu_dm_backlight_caps backlight_caps[AMDGPU_DM_MAX_NUM_EDP];
462 
463 	struct mod_freesync *freesync_module;
464 	struct hdcp_workqueue *hdcp_workqueue;
465 
466 	/**
467 	 * @vblank_control_workqueue:
468 	 *
469 	 * Deferred work for vblank control events.
470 	 */
471 	struct workqueue_struct *vblank_control_workqueue;
472 
473 	struct drm_atomic_state *cached_state;
474 	struct dc_state *cached_dc_state;
475 
476 	struct dm_compressor_info compressor;
477 
478 	const struct firmware *fw_dmcu;
479 	uint32_t dmcu_fw_version;
480 	/**
481 	 * @soc_bounding_box:
482 	 *
483 	 * gpu_info FW provided soc bounding box struct or 0 if not
484 	 * available in FW
485 	 */
486 	const struct gpu_info_soc_bounding_box_v1_0 *soc_bounding_box;
487 
488 	/**
489 	 * @active_vblank_irq_count:
490 	 *
491 	 * number of currently active vblank irqs
492 	 */
493 	uint32_t active_vblank_irq_count;
494 
495 #if defined(CONFIG_DRM_AMD_SECURE_DISPLAY)
496 	/**
497 	 * @secure_display_ctxs:
498 	 *
499 	 * Store the ROI information and the work_struct to command dmub and psp for
500 	 * all crtcs.
501 	 */
502 	struct secure_display_context *secure_display_ctxs;
503 #endif
504 	/**
505 	 * @hpd_rx_offload_wq:
506 	 *
507 	 * Work queue to offload works of hpd_rx_irq
508 	 */
509 	struct hpd_rx_irq_offload_work_queue *hpd_rx_offload_wq;
510 	/**
511 	 * @mst_encoders:
512 	 *
513 	 * fake encoders used for DP MST.
514 	 */
515 	struct amdgpu_encoder mst_encoders[AMDGPU_DM_MAX_CRTC];
516 	bool force_timing_sync;
517 	bool disable_hpd_irq;
518 	bool dmcub_trace_event_en;
519 	/**
520 	 * @da_list:
521 	 *
522 	 * DAL fb memory allocation list, for communication with SMU.
523 	 */
524 	struct list_head da_list;
525 	struct completion dmub_aux_transfer_done;
526 	struct workqueue_struct *delayed_hpd_wq;
527 
528 	/**
529 	 * @brightness:
530 	 *
531 	 * cached backlight values.
532 	 */
533 	u32 brightness[AMDGPU_DM_MAX_NUM_EDP];
534 	/**
535 	 * @actual_brightness:
536 	 *
537 	 * last successfully applied backlight values.
538 	 */
539 	u32 actual_brightness[AMDGPU_DM_MAX_NUM_EDP];
540 
541 	/**
542 	 * @aux_hpd_discon_quirk:
543 	 *
544 	 * quirk for hpd discon while aux is on-going.
545 	 * occurred on certain intel platform
546 	 */
547 	bool aux_hpd_discon_quirk;
548 
549 	/**
550 	 * @dpia_aux_lock:
551 	 *
552 	 * Guards access to DPIA AUX
553 	 */
554 	struct mutex dpia_aux_lock;
555 };
556 
557 enum dsc_clock_force_state {
558 	DSC_CLK_FORCE_DEFAULT = 0,
559 	DSC_CLK_FORCE_ENABLE,
560 	DSC_CLK_FORCE_DISABLE,
561 };
562 
563 struct dsc_preferred_settings {
564 	enum dsc_clock_force_state dsc_force_enable;
565 	uint32_t dsc_num_slices_v;
566 	uint32_t dsc_num_slices_h;
567 	uint32_t dsc_bits_per_pixel;
568 	bool dsc_force_disable_passthrough;
569 };
570 
571 enum mst_progress_status {
572 	MST_STATUS_DEFAULT = 0,
573 	MST_PROBE = BIT(0),
574 	MST_REMOTE_EDID = BIT(1),
575 	MST_ALLOCATE_NEW_PAYLOAD = BIT(2),
576 	MST_CLEAR_ALLOCATED_PAYLOAD = BIT(3),
577 };
578 
579 /**
580  * struct amdgpu_hdmi_vsdb_info - Keep track of the VSDB info
581  *
582  * AMDGPU supports FreeSync over HDMI by using the VSDB section, and this
583  * struct is useful to keep track of the display-specific information about
584  * FreeSync.
585  */
586 struct amdgpu_hdmi_vsdb_info {
587 	/**
588 	 * @amd_vsdb_version: Vendor Specific Data Block Version, should be
589 	 * used to determine which Vendor Specific InfoFrame (VSIF) to send.
590 	 */
591 	unsigned int amd_vsdb_version;
592 
593 	/**
594 	 * @freesync_supported: FreeSync Supported.
595 	 */
596 	bool freesync_supported;
597 
598 	/**
599 	 * @min_refresh_rate_hz: FreeSync Minimum Refresh Rate in Hz.
600 	 */
601 	unsigned int min_refresh_rate_hz;
602 
603 	/**
604 	 * @max_refresh_rate_hz: FreeSync Maximum Refresh Rate in Hz
605 	 */
606 	unsigned int max_refresh_rate_hz;
607 };
608 
609 struct amdgpu_dm_connector {
610 
611 	struct drm_connector base;
612 	uint32_t connector_id;
613 	int bl_idx;
614 
615 	/* we need to mind the EDID between detect
616 	   and get modes due to analog/digital/tvencoder */
617 	struct edid *edid;
618 
619 	/* shared with amdgpu */
620 	struct amdgpu_hpd hpd;
621 
622 	/* number of modes generated from EDID at 'dc_sink' */
623 	int num_modes;
624 
625 	/* The 'old' sink - before an HPD.
626 	 * The 'current' sink is in dc_link->sink. */
627 	struct dc_sink *dc_sink;
628 	struct dc_link *dc_link;
629 
630 	/**
631 	 * @dc_em_sink: Reference to the emulated (virtual) sink.
632 	 */
633 	struct dc_sink *dc_em_sink;
634 
635 	/* DM only */
636 	struct drm_dp_mst_topology_mgr mst_mgr;
637 	struct amdgpu_dm_dp_aux dm_dp_aux;
638 	struct drm_dp_mst_port *mst_output_port;
639 	struct amdgpu_dm_connector *mst_root;
640 	struct drm_dp_aux *dsc_aux;
641 	/* TODO see if we can merge with ddc_bus or make a dm_connector */
642 	struct amdgpu_i2c_adapter *i2c;
643 
644 	/* Monitor range limits */
645 	/**
646 	 * @min_vfreq: Minimal frequency supported by the display in Hz. This
647 	 * value is set to zero when there is no FreeSync support.
648 	 */
649 	int min_vfreq;
650 
651 	/**
652 	 * @max_vfreq: Maximum frequency supported by the display in Hz. This
653 	 * value is set to zero when there is no FreeSync support.
654 	 */
655 	int max_vfreq ;
656 	int pixel_clock_mhz;
657 
658 	/* Audio instance - protected by audio_lock. */
659 	int audio_inst;
660 
661 	struct mutex hpd_lock;
662 
663 	bool fake_enable;
664 #ifdef CONFIG_DEBUG_FS
665 	uint32_t debugfs_dpcd_address;
666 	uint32_t debugfs_dpcd_size;
667 #endif
668 	bool force_yuv420_output;
669 	struct dsc_preferred_settings dsc_settings;
670 	union dp_downstream_port_present mst_downstream_port_present;
671 	/* Cached display modes */
672 	struct drm_display_mode freesync_vid_base;
673 
674 	int psr_skip_count;
675 
676 	/* Record progress status of mst*/
677 	uint8_t mst_status;
678 
679 	/* Automated testing */
680 	bool timing_changed;
681 	struct dc_crtc_timing *timing_requested;
682 
683 	/* Adaptive Sync */
684 	bool pack_sdp_v1_3;
685 	enum adaptive_sync_type as_type;
686 	struct amdgpu_hdmi_vsdb_info vsdb_info;
687 };
688 
689 static inline void amdgpu_dm_set_mst_status(uint8_t *status,
690 		uint8_t flags, bool set)
691 {
692 	if (set)
693 		*status |= flags;
694 	else
695 		*status &= ~flags;
696 }
697 
698 #define to_amdgpu_dm_connector(x) container_of(x, struct amdgpu_dm_connector, base)
699 
700 extern const struct amdgpu_ip_block_version dm_ip_block;
701 
702 struct dm_plane_state {
703 	struct drm_plane_state base;
704 	struct dc_plane_state *dc_state;
705 };
706 
707 struct dm_crtc_state {
708 	struct drm_crtc_state base;
709 	struct dc_stream_state *stream;
710 
711 	bool cm_has_degamma;
712 	bool cm_is_degamma_srgb;
713 
714 	bool mpo_requested;
715 
716 	int update_type;
717 	int active_planes;
718 
719 	int crc_skip_count;
720 
721 	bool freesync_vrr_info_changed;
722 
723 	bool dsc_force_changed;
724 	bool vrr_supported;
725 	struct mod_freesync_config freesync_config;
726 	struct dc_info_packet vrr_infopacket;
727 
728 	int abm_level;
729 };
730 
731 #define to_dm_crtc_state(x) container_of(x, struct dm_crtc_state, base)
732 
733 struct dm_atomic_state {
734 	struct drm_private_state base;
735 
736 	struct dc_state *context;
737 };
738 
739 #define to_dm_atomic_state(x) container_of(x, struct dm_atomic_state, base)
740 
741 struct dm_connector_state {
742 	struct drm_connector_state base;
743 
744 	enum amdgpu_rmx_type scaling;
745 	uint8_t underscan_vborder;
746 	uint8_t underscan_hborder;
747 	bool underscan_enable;
748 	bool freesync_capable;
749 	bool update_hdcp;
750 	uint8_t abm_level;
751 	int vcpi_slots;
752 	uint64_t pbn;
753 };
754 
755 #define to_dm_connector_state(x)\
756 	container_of((x), struct dm_connector_state, base)
757 
758 void amdgpu_dm_connector_funcs_reset(struct drm_connector *connector);
759 struct drm_connector_state *
760 amdgpu_dm_connector_atomic_duplicate_state(struct drm_connector *connector);
761 int amdgpu_dm_connector_atomic_set_property(struct drm_connector *connector,
762 					    struct drm_connector_state *state,
763 					    struct drm_property *property,
764 					    uint64_t val);
765 
766 int amdgpu_dm_connector_atomic_get_property(struct drm_connector *connector,
767 					    const struct drm_connector_state *state,
768 					    struct drm_property *property,
769 					    uint64_t *val);
770 
771 int amdgpu_dm_get_encoder_crtc_mask(struct amdgpu_device *adev);
772 
773 void amdgpu_dm_connector_init_helper(struct amdgpu_display_manager *dm,
774 				     struct amdgpu_dm_connector *aconnector,
775 				     int connector_type,
776 				     struct dc_link *link,
777 				     int link_index);
778 
779 enum drm_mode_status amdgpu_dm_connector_mode_valid(struct drm_connector *connector,
780 				   struct drm_display_mode *mode);
781 
782 void dm_restore_drm_connector_state(struct drm_device *dev,
783 				    struct drm_connector *connector);
784 
785 void amdgpu_dm_update_freesync_caps(struct drm_connector *connector,
786 					struct edid *edid);
787 
788 void amdgpu_dm_trigger_timing_sync(struct drm_device *dev);
789 
790 #define MAX_COLOR_LUT_ENTRIES 4096
791 /* Legacy gamm LUT users such as X doesn't like large LUT sizes */
792 #define MAX_COLOR_LEGACY_LUT_ENTRIES 256
793 
794 void amdgpu_dm_init_color_mod(void);
795 int amdgpu_dm_verify_lut_sizes(const struct drm_crtc_state *crtc_state);
796 int amdgpu_dm_update_crtc_color_mgmt(struct dm_crtc_state *crtc);
797 int amdgpu_dm_update_plane_color_mgmt(struct dm_crtc_state *crtc,
798 				      struct dc_plane_state *dc_plane_state);
799 
800 void amdgpu_dm_update_connector_after_detect(
801 		struct amdgpu_dm_connector *aconnector);
802 
803 extern const struct drm_encoder_helper_funcs amdgpu_dm_encoder_helper_funcs;
804 
805 int amdgpu_dm_process_dmub_aux_transfer_sync(struct dc_context *ctx, unsigned int link_index,
806 					struct aux_payload *payload, enum aux_return_code_type *operation_result);
807 
808 int amdgpu_dm_process_dmub_set_config_sync(struct dc_context *ctx, unsigned int link_index,
809 					struct set_config_cmd_payload *payload, enum set_config_status *operation_result);
810 
811 bool check_seamless_boot_capability(struct amdgpu_device *adev);
812 
813 struct dc_stream_state *
814 	create_validate_stream_for_sink(struct amdgpu_dm_connector *aconnector,
815 					const struct drm_display_mode *drm_mode,
816 					const struct dm_connector_state *dm_state,
817 					const struct dc_stream_state *old_stream);
818 
819 int dm_atomic_get_state(struct drm_atomic_state *state,
820 			struct dm_atomic_state **dm_state);
821 
822 struct amdgpu_dm_connector *
823 amdgpu_dm_find_first_crtc_matching_connector(struct drm_atomic_state *state,
824 					     struct drm_crtc *crtc);
825 
826 int convert_dc_color_depth_into_bpc(enum dc_color_depth display_color_depth);
827 #endif /* __AMDGPU_DM_H__ */
828