• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2019 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 DMUB_CMD_H
27 #define DMUB_CMD_H
28 
29 #include <asm/byteorder.h>
30 #include <linux/types.h>
31 #include <linux/string.h>
32 #include <linux/delay.h>
33 
34 #include "atomfirmware.h"
35 
36 //<DMUB_TYPES>==================================================================
37 /* Basic type definitions. */
38 
39 #define __forceinline inline
40 
41 /**
42  * Flag from driver to indicate that ABM should be disabled gradually
43  * by slowly reversing all backlight programming and pixel compensation.
44  */
45 #define SET_ABM_PIPE_GRADUALLY_DISABLE           0
46 
47 /**
48  * Flag from driver to indicate that ABM should be disabled immediately
49  * and undo all backlight programming and pixel compensation.
50  */
51 #define SET_ABM_PIPE_IMMEDIATELY_DISABLE         255
52 
53 /**
54  * Flag from driver to indicate that ABM should be disabled immediately
55  * and keep the current backlight programming and pixel compensation.
56  */
57 #define SET_ABM_PIPE_IMMEDIATE_KEEP_GAIN_DISABLE 254
58 
59 /**
60  * Flag from driver to set the current ABM pipe index or ABM operating level.
61  */
62 #define SET_ABM_PIPE_NORMAL                      1
63 
64 /**
65  * Number of ambient light levels in ABM algorithm.
66  */
67 #define NUM_AMBI_LEVEL                  5
68 
69 /**
70  * Number of operating/aggression levels in ABM algorithm.
71  */
72 #define NUM_AGGR_LEVEL                  4
73 
74 /**
75  * Number of segments in the gamma curve.
76  */
77 #define NUM_POWER_FN_SEGS               8
78 
79 /**
80  * Number of segments in the backlight curve.
81  */
82 #define NUM_BL_CURVE_SEGS               16
83 
84 /**
85  * Maximum number of segments in ABM ACE curve.
86  */
87 #define ABM_MAX_NUM_OF_ACE_SEGMENTS         64
88 
89 /**
90  * Maximum number of bins in ABM histogram.
91  */
92 #define ABM_MAX_NUM_OF_HG_BINS              64
93 
94 /* Maximum number of SubVP streams */
95 #define DMUB_MAX_SUBVP_STREAMS 2
96 
97 /* Define max FPO streams as 4 for now. Current implementation today
98  * only supports 1, but could be more in the future. Reduce array
99  * size to ensure the command size remains less than 64 bytes if
100  * adding new fields.
101  */
102 #define DMUB_MAX_FPO_STREAMS 4
103 
104 /* Maximum number of streams on any ASIC. */
105 #define DMUB_MAX_STREAMS 6
106 
107 /* Maximum number of planes on any ASIC. */
108 #define DMUB_MAX_PLANES 6
109 
110 /* Maximum number of phantom planes on any ASIC */
111 #define DMUB_MAX_PHANTOM_PLANES ((DMUB_MAX_PLANES) / 2)
112 
113 /* Trace buffer offset for entry */
114 #define TRACE_BUFFER_ENTRY_OFFSET 16
115 
116 /**
117  * Maximum number of dirty rects supported by FW.
118  */
119 #define DMUB_MAX_DIRTY_RECTS 3
120 
121 /**
122  *
123  * PSR control version legacy
124  */
125 #define DMUB_CMD_PSR_CONTROL_VERSION_UNKNOWN 0x0
126 /**
127  * PSR control version with multi edp support
128  */
129 #define DMUB_CMD_PSR_CONTROL_VERSION_1 0x1
130 
131 
132 /**
133  * ABM control version legacy
134  */
135 #define DMUB_CMD_ABM_CONTROL_VERSION_UNKNOWN 0x0
136 
137 /**
138  * ABM control version with multi edp support
139  */
140 #define DMUB_CMD_ABM_CONTROL_VERSION_1 0x1
141 
142 /**
143  * Physical framebuffer address location, 64-bit.
144  */
145 #ifndef PHYSICAL_ADDRESS_LOC
146 #define PHYSICAL_ADDRESS_LOC union large_integer
147 #endif
148 
149 /**
150  * OS/FW agnostic memcpy
151  */
152 #ifndef dmub_memcpy
153 #define dmub_memcpy(dest, source, bytes) memcpy((dest), (source), (bytes))
154 #endif
155 
156 /**
157  * OS/FW agnostic memset
158  */
159 #ifndef dmub_memset
160 #define dmub_memset(dest, val, bytes) memset((dest), (val), (bytes))
161 #endif
162 
163 /**
164  * OS/FW agnostic udelay
165  */
166 #ifndef dmub_udelay
167 #define dmub_udelay(microseconds) udelay(microseconds)
168 #endif
169 
170 #pragma pack(push, 1)
171 #define ABM_NUM_OF_ACE_SEGMENTS         5
172 
173 union abm_flags {
174 	struct {
175 		/**
176 		 * @abm_enabled: Indicates if ABM is enabled.
177 		 */
178 		unsigned int abm_enabled : 1;
179 
180 		/**
181 		 * @disable_abm_requested: Indicates if driver has requested ABM to be disabled.
182 		 */
183 		unsigned int disable_abm_requested : 1;
184 
185 		/**
186 		 * @disable_abm_immediately: Indicates if driver has requested ABM to be disabled immediately.
187 		 */
188 		unsigned int disable_abm_immediately : 1;
189 
190 		/**
191 		 * @disable_abm_immediate_keep_gain: Indicates if driver has requested ABM
192 		 * to be disabled immediately and keep gain.
193 		 */
194 		unsigned int disable_abm_immediate_keep_gain : 1;
195 
196 		/**
197 		 * @fractional_pwm: Indicates if fractional duty cycle for backlight PWM is enabled.
198 		 */
199 		unsigned int fractional_pwm : 1;
200 
201 		/**
202 		 * @abm_gradual_bl_change: Indicates if algorithm has completed gradual adjustment
203 		 * of user backlight level.
204 		 */
205 		unsigned int abm_gradual_bl_change : 1;
206 
207 		/**
208 		 * @abm_new_frame: Indicates if a new frame update needed for ABM to ramp up into steady
209 		 */
210 		unsigned int abm_new_frame : 1;
211 
212 		/**
213 		 * @vb_scaling_enabled: Indicates variBright Scaling Enable
214 		 */
215 		unsigned int vb_scaling_enabled : 1;
216 	} bitfields;
217 
218 	unsigned int u32All;
219 };
220 
221 struct abm_save_restore {
222 	/**
223 	 * @flags: Misc. ABM flags.
224 	 */
225 	union abm_flags flags;
226 
227 	/**
228 	 * @pause: true:  pause ABM and get state
229 	 *         false: unpause ABM after setting state
230 	 */
231 	uint32_t pause;
232 
233 	/**
234 	 * @next_ace_slope: Next ACE slopes to be programmed in HW (u3.13)
235 	 */
236 	uint32_t next_ace_slope[ABM_NUM_OF_ACE_SEGMENTS];
237 
238 	/**
239 	 * @next_ace_thresh: Next ACE thresholds to be programmed in HW (u10.6)
240 	 */
241 	uint32_t next_ace_thresh[ABM_NUM_OF_ACE_SEGMENTS];
242 
243 	/**
244 	 * @next_ace_offset: Next ACE offsets to be programmed in HW (u10.6)
245 	 */
246 	uint32_t next_ace_offset[ABM_NUM_OF_ACE_SEGMENTS];
247 
248 
249 	/**
250 	 * @knee_threshold: Current x-position of ACE knee (u0.16).
251 	 */
252 	uint32_t knee_threshold;
253 	/**
254 	 * @current_gain: Current backlight reduction (u16.16).
255 	 */
256 	uint32_t current_gain;
257 	/**
258 	 * @curr_bl_level: Current actual backlight level converging to target backlight level.
259 	 */
260 	uint16_t curr_bl_level;
261 
262 	/**
263 	 * @curr_user_bl_level: Current nominal backlight level converging to level requested by user.
264 	 */
265 	uint16_t curr_user_bl_level;
266 
267 };
268 
269 /**
270  * union dmub_addr - DMUB physical/virtual 64-bit address.
271  */
272 union dmub_addr {
273 	struct {
274 		uint32_t low_part; /**< Lower 32 bits */
275 		uint32_t high_part; /**< Upper 32 bits */
276 	} u; /*<< Low/high bit access */
277 	uint64_t quad_part; /*<< 64 bit address */
278 };
279 #pragma pack(pop)
280 
281 /**
282  * Dirty rect definition.
283  */
284 struct dmub_rect {
285 	/**
286 	 * Dirty rect x offset.
287 	 */
288 	uint32_t x;
289 
290 	/**
291 	 * Dirty rect y offset.
292 	 */
293 	uint32_t y;
294 
295 	/**
296 	 * Dirty rect width.
297 	 */
298 	uint32_t width;
299 
300 	/**
301 	 * Dirty rect height.
302 	 */
303 	uint32_t height;
304 };
305 
306 /**
307  * Flags that can be set by driver to change some PSR behaviour.
308  */
309 union dmub_psr_debug_flags {
310 	/**
311 	 * Debug flags.
312 	 */
313 	struct {
314 		/**
315 		 * Enable visual confirm in FW.
316 		 */
317 		uint32_t visual_confirm : 1;
318 
319 		/**
320 		 * Force all selective updates to bw full frame updates.
321 		 */
322 		uint32_t force_full_frame_update : 1;
323 
324 		/**
325 		 * Use HW Lock Mgr object to do HW locking in FW.
326 		 */
327 		uint32_t use_hw_lock_mgr : 1;
328 
329 		/**
330 		 * Use TPS3 signal when restore main link.
331 		 */
332 		uint32_t force_wakeup_by_tps3 : 1;
333 
334 		/**
335 		 * Back to back flip, therefore cannot power down PHY
336 		 */
337 		uint32_t back_to_back_flip : 1;
338 
339 		/**
340 		 * Enable visual confirm for IPS
341 		 */
342 		uint32_t enable_ips_visual_confirm : 1;
343 	} bitfields;
344 
345 	/**
346 	 * Union for debug flags.
347 	 */
348 	uint32_t u32All;
349 };
350 
351 /**
352  * Flags that can be set by driver to change some Replay behaviour.
353  */
354 union replay_debug_flags {
355 	struct {
356 		/**
357 		 * 0x1 (bit 0)
358 		 * Enable visual confirm in FW.
359 		 */
360 		uint32_t visual_confirm : 1;
361 
362 		/**
363 		 * 0x2 (bit 1)
364 		 * @skip_crc: Set if need to skip CRC.
365 		 */
366 		uint32_t skip_crc : 1;
367 
368 		/**
369 		 * 0x4 (bit 2)
370 		 * @force_link_power_on: Force disable ALPM control
371 		 */
372 		uint32_t force_link_power_on : 1;
373 
374 		/**
375 		 * 0x8 (bit 3)
376 		 * @force_phy_power_on: Force phy power on
377 		 */
378 		uint32_t force_phy_power_on : 1;
379 
380 		/**
381 		 * 0x10 (bit 4)
382 		 * @timing_resync_disabled: Disabled Replay normal sleep mode timing resync
383 		 */
384 		uint32_t timing_resync_disabled : 1;
385 
386 		/**
387 		 * 0x20 (bit 5)
388 		 * @skip_crtc_disabled: CRTC disable skipped
389 		 */
390 		uint32_t skip_crtc_disabled : 1;
391 
392 		/**
393 		 * 0x40 (bit 6)
394 		 * @force_defer_one_frame_update: Force defer one frame update in ultra sleep mode
395 		 */
396 		uint32_t force_defer_one_frame_update : 1;
397 
398 		/**
399 		 * 0x80 (bit 7)
400 		 * @disable_delay_alpm_on: Force disable delay alpm on
401 		 */
402 		uint32_t disable_delay_alpm_on : 1;
403 
404 		/**
405 		 * 0x100 (bit 8)
406 		 * @disable_desync_error_check: Force disable desync error check
407 		 */
408 		uint32_t disable_desync_error_check : 1;
409 
410 		/**
411 		 * 0x200 (bit 9)
412 		 * @force_self_update_when_abm_non_steady: Force self update if abm is not steady
413 		 */
414 		uint32_t force_self_update_when_abm_non_steady : 1;
415 
416 		/**
417 		 * 0x400 (bit 10)
418 		 * @enable_ips_visual_confirm: Enable IPS visual confirm when entering IPS
419 		 * If we enter IPS2, the Visual confirm bar will change to yellow
420 		 */
421 		uint32_t enable_ips_visual_confirm : 1;
422 
423 		/**
424 		 * 0x800 (bit 11)
425 		 * @enable_ips_residency_profiling: Enable IPS residency profiling
426 		 */
427 		uint32_t enable_ips_residency_profiling : 1;
428 
429 		uint32_t reserved : 20;
430 	} bitfields;
431 
432 	uint32_t u32All;
433 };
434 
435 union replay_hw_flags {
436 	struct {
437 		/**
438 		 * @allow_alpm_fw_standby_mode: To indicate whether the
439 		 * ALPM FW standby mode is allowed
440 		 */
441 		uint32_t allow_alpm_fw_standby_mode : 1;
442 
443 		/*
444 		 * @dsc_enable_status: DSC enable status in driver
445 		 */
446 		uint32_t dsc_enable_status : 1;
447 
448 		/**
449 		 * @fec_enable_status: receive fec enable/disable status from driver
450 		 */
451 		uint32_t fec_enable_status : 1;
452 
453 		/*
454 		 * @smu_optimizations_en: SMU power optimization.
455 		 * Only when active display is Replay capable and display enters Replay.
456 		 * Trigger interrupt to SMU to powerup/down.
457 		 */
458 		uint32_t smu_optimizations_en : 1;
459 
460 		/**
461 		 * @phy_power_state: Indicates current phy power state
462 		 */
463 		uint32_t phy_power_state : 1;
464 
465 		/**
466 		 * @link_power_state: Indicates current link power state
467 		 */
468 		uint32_t link_power_state : 1;
469 		/**
470 		 * Use TPS3 signal when restore main link.
471 		 */
472 		uint32_t force_wakeup_by_tps3 : 1;
473 	} bitfields;
474 
475 	uint32_t u32All;
476 };
477 
478 /**
479  * DMUB feature capabilities.
480  * After DMUB init, driver will query FW capabilities prior to enabling certain features.
481  */
482 struct dmub_feature_caps {
483 	/**
484 	 * Max PSR version supported by FW.
485 	 */
486 	uint8_t psr;
487 	uint8_t fw_assisted_mclk_switch_ver;
488 	uint8_t reserved[4];
489 	uint8_t subvp_psr_support;
490 	uint8_t gecc_enable;
491 	uint8_t replay_supported;
492 	uint8_t replay_reserved[3];
493 };
494 
495 struct dmub_visual_confirm_color {
496 	/**
497 	 * Maximum 10 bits color value
498 	 */
499 	uint16_t color_r_cr;
500 	uint16_t color_g_y;
501 	uint16_t color_b_cb;
502 	uint16_t panel_inst;
503 };
504 
505 //==============================================================================
506 //</DMUB_TYPES>=================================================================
507 //==============================================================================
508 //< DMUB_META>==================================================================
509 //==============================================================================
510 #pragma pack(push, 1)
511 
512 /* Magic value for identifying dmub_fw_meta_info */
513 #define DMUB_FW_META_MAGIC 0x444D5542
514 
515 /* Offset from the end of the file to the dmub_fw_meta_info */
516 #define DMUB_FW_META_OFFSET 0x24
517 
518 /**
519  * union dmub_fw_meta_feature_bits - Static feature bits for pre-initialization
520  */
521 union dmub_fw_meta_feature_bits {
522 	struct {
523 		uint32_t shared_state_link_detection : 1; /**< 1 supports link detection via shared state */
524 		uint32_t reserved : 31;
525 	} bits; /**< status bits */
526 	uint32_t all; /**< 32-bit access to status bits */
527 };
528 
529 /**
530  * struct dmub_fw_meta_info - metadata associated with fw binary
531  *
532  * NOTE: This should be considered a stable API. Fields should
533  *       not be repurposed or reordered. New fields should be
534  *       added instead to extend the structure.
535  *
536  * @magic_value: magic value identifying DMUB firmware meta info
537  * @fw_region_size: size of the firmware state region
538  * @trace_buffer_size: size of the tracebuffer region
539  * @fw_version: the firmware version information
540  * @dal_fw: 1 if the firmware is DAL
541  * @shared_state_size: size of the shared state region in bytes
542  * @shared_state_features: number of shared state features
543  */
544 struct dmub_fw_meta_info {
545 	uint32_t magic_value; /**< magic value identifying DMUB firmware meta info */
546 	uint32_t fw_region_size; /**< size of the firmware state region */
547 	uint32_t trace_buffer_size; /**< size of the tracebuffer region */
548 	uint32_t fw_version; /**< the firmware version information */
549 	uint8_t dal_fw; /**< 1 if the firmware is DAL */
550 	uint8_t reserved[3]; /**< padding bits */
551 	uint32_t shared_state_size; /**< size of the shared state region in bytes */
552 	uint16_t shared_state_features; /**< number of shared state features */
553 	uint16_t reserved2; /**< padding bytes */
554 	union dmub_fw_meta_feature_bits feature_bits; /**< static feature bits */
555 };
556 
557 /**
558  * union dmub_fw_meta - ensures that dmub_fw_meta_info remains 64 bytes
559  */
560 union dmub_fw_meta {
561 	struct dmub_fw_meta_info info; /**< metadata info */
562 	uint8_t reserved[64]; /**< padding bits */
563 };
564 
565 #pragma pack(pop)
566 
567 //==============================================================================
568 //< DMUB Trace Buffer>================================================================
569 //==============================================================================
570 #if !defined(TENSILICA) && !defined(DMUB_TRACE_ENTRY_DEFINED)
571 /**
572  * dmub_trace_code_t - firmware trace code, 32-bits
573  */
574 typedef uint32_t dmub_trace_code_t;
575 
576 /**
577  * struct dmcub_trace_buf_entry - Firmware trace entry
578  */
579 struct dmcub_trace_buf_entry {
580 	dmub_trace_code_t trace_code; /**< trace code for the event */
581 	uint32_t tick_count; /**< the tick count at time of trace */
582 	uint32_t param0; /**< trace defined parameter 0 */
583 	uint32_t param1; /**< trace defined parameter 1 */
584 };
585 #endif
586 
587 //==============================================================================
588 //< DMUB_STATUS>================================================================
589 //==============================================================================
590 
591 /**
592  * DMCUB scratch registers can be used to determine firmware status.
593  * Current scratch register usage is as follows:
594  *
595  * SCRATCH0: FW Boot Status register
596  * SCRATCH5: LVTMA Status Register
597  * SCRATCH15: FW Boot Options register
598  */
599 
600 /**
601  * union dmub_fw_boot_status - Status bit definitions for SCRATCH0.
602  */
603 union dmub_fw_boot_status {
604 	struct {
605 		uint32_t dal_fw : 1; /**< 1 if DAL FW */
606 		uint32_t mailbox_rdy : 1; /**< 1 if mailbox ready */
607 		uint32_t optimized_init_done : 1; /**< 1 if optimized init done */
608 		uint32_t restore_required : 1; /**< 1 if driver should call restore */
609 		uint32_t defer_load : 1; /**< 1 if VBIOS data is deferred programmed */
610 		uint32_t fams_enabled : 1; /**< 1 if VBIOS data is deferred programmed */
611 		uint32_t detection_required: 1; /**<  if detection need to be triggered by driver */
612 		uint32_t hw_power_init_done: 1; /**< 1 if hw power init is completed */
613 		uint32_t ono_regions_enabled: 1; /**< 1 if ONO regions are enabled */
614 	} bits; /**< status bits */
615 	uint32_t all; /**< 32-bit access to status bits */
616 };
617 
618 /**
619  * enum dmub_fw_boot_status_bit - Enum bit definitions for SCRATCH0.
620  */
621 enum dmub_fw_boot_status_bit {
622 	DMUB_FW_BOOT_STATUS_BIT_DAL_FIRMWARE = (1 << 0), /**< 1 if DAL FW */
623 	DMUB_FW_BOOT_STATUS_BIT_MAILBOX_READY = (1 << 1), /**< 1 if mailbox ready */
624 	DMUB_FW_BOOT_STATUS_BIT_OPTIMIZED_INIT_DONE = (1 << 2), /**< 1 if init done */
625 	DMUB_FW_BOOT_STATUS_BIT_RESTORE_REQUIRED = (1 << 3), /**< 1 if driver should call restore */
626 	DMUB_FW_BOOT_STATUS_BIT_DEFERRED_LOADED = (1 << 4), /**< 1 if VBIOS data is deferred programmed */
627 	DMUB_FW_BOOT_STATUS_BIT_FAMS_ENABLED = (1 << 5), /**< 1 if FAMS is enabled*/
628 	DMUB_FW_BOOT_STATUS_BIT_DETECTION_REQUIRED = (1 << 6), /**< 1 if detection need to be triggered by driver*/
629 	DMUB_FW_BOOT_STATUS_BIT_HW_POWER_INIT_DONE = (1 << 7), /**< 1 if hw power init is completed */
630 	DMUB_FW_BOOT_STATUS_BIT_ONO_REGIONS_ENABLED = (1 << 8), /**< 1 if ONO regions are enabled */
631 };
632 
633 /* Register bit definition for SCRATCH5 */
634 union dmub_lvtma_status {
635 	struct {
636 		uint32_t psp_ok : 1;
637 		uint32_t edp_on : 1;
638 		uint32_t reserved : 30;
639 	} bits;
640 	uint32_t all;
641 };
642 
643 enum dmub_lvtma_status_bit {
644 	DMUB_LVTMA_STATUS_BIT_PSP_OK = (1 << 0),
645 	DMUB_LVTMA_STATUS_BIT_EDP_ON = (1 << 1),
646 };
647 
648 enum dmub_ips_disable_type {
649 	DMUB_IPS_ENABLE = 0,
650 	DMUB_IPS_DISABLE_ALL = 1,
651 	DMUB_IPS_DISABLE_IPS1 = 2,
652 	DMUB_IPS_DISABLE_IPS2 = 3,
653 	DMUB_IPS_DISABLE_IPS2_Z10 = 4,
654 	DMUB_IPS_DISABLE_DYNAMIC = 5,
655 	DMUB_IPS_RCG_IN_ACTIVE_IPS2_IN_OFF = 6,
656 };
657 
658 #define DMUB_IPS1_ALLOW_MASK 0x00000001
659 #define DMUB_IPS2_ALLOW_MASK 0x00000002
660 #define DMUB_IPS1_COMMIT_MASK 0x00000004
661 #define DMUB_IPS2_COMMIT_MASK 0x00000008
662 
663 /**
664  * union dmub_fw_boot_options - Boot option definitions for SCRATCH14
665  */
666 union dmub_fw_boot_options {
667 	struct {
668 		uint32_t pemu_env : 1; /**< 1 if PEMU */
669 		uint32_t fpga_env : 1; /**< 1 if FPGA */
670 		uint32_t optimized_init : 1; /**< 1 if optimized init */
671 		uint32_t skip_phy_access : 1; /**< 1 if PHY access should be skipped */
672 		uint32_t disable_clk_gate: 1; /**< 1 if clock gating should be disabled */
673 		uint32_t skip_phy_init_panel_sequence: 1; /**< 1 to skip panel init seq */
674 		uint32_t z10_disable: 1; /**< 1 to disable z10 */
675 		uint32_t enable_dpia: 1; /**< 1 if DPIA should be enabled */
676 		uint32_t invalid_vbios_data: 1; /**< 1 if VBIOS data table is invalid */
677 		uint32_t dpia_supported: 1; /**< 1 if DPIA is supported on this platform */
678 		uint32_t sel_mux_phy_c_d_phy_f_g: 1; /**< 1 if PHYF/PHYG should be enabled on DCN31 */
679 		/**< 1 if all root clock gating is enabled and low power memory is enabled*/
680 		uint32_t power_optimization: 1;
681 		uint32_t diag_env: 1; /* 1 if diagnostic environment */
682 		uint32_t gpint_scratch8: 1; /* 1 if GPINT is in scratch8*/
683 		uint32_t usb4_cm_version: 1; /**< 1 CM support */
684 		uint32_t dpia_hpd_int_enable_supported: 1; /* 1 if dpia hpd int enable supported */
685 		uint32_t enable_non_transparent_setconfig: 1; /* 1 if dpia use conventional dp lt flow*/
686 		uint32_t disable_clk_ds: 1; /* 1 if disallow dispclk_ds and dppclk_ds*/
687 		uint32_t disable_timeout_recovery : 1; /* 1 if timeout recovery should be disabled */
688 		uint32_t ips_pg_disable: 1; /* 1 to disable ONO domains power gating*/
689 		uint32_t ips_disable: 3; /* options to disable ips support*/
690 		uint32_t ips_sequential_ono: 1; /**< 1 to enable sequential ONO IPS sequence */
691 		uint32_t disable_sldo_opt: 1; /**< 1 to disable SLDO optimizations */
692 		uint32_t reserved : 7; /**< reserved */
693 	} bits; /**< boot bits */
694 	uint32_t all; /**< 32-bit access to bits */
695 };
696 
697 enum dmub_fw_boot_options_bit {
698 	DMUB_FW_BOOT_OPTION_BIT_PEMU_ENV = (1 << 0), /**< 1 if PEMU */
699 	DMUB_FW_BOOT_OPTION_BIT_FPGA_ENV = (1 << 1), /**< 1 if FPGA */
700 	DMUB_FW_BOOT_OPTION_BIT_OPTIMIZED_INIT_DONE = (1 << 2), /**< 1 if optimized init done */
701 };
702 
703 //==============================================================================
704 //< DMUB_SHARED_STATE>==========================================================
705 //==============================================================================
706 
707 /**
708  * Shared firmware state between driver and firmware for lockless communication
709  * in situations where the inbox/outbox may be unavailable.
710  *
711  * Each structure *must* be at most 256-bytes in size. The layout allocation is
712  * described below:
713  *
714  * [Header (256 Bytes)][Feature 1 (256 Bytes)][Feature 2 (256 Bytes)]...
715  */
716 
717 /**
718  * enum dmub_shared_state_feature_id - List of shared state features.
719  */
720 enum dmub_shared_state_feature_id {
721 	DMUB_SHARED_SHARE_FEATURE__INVALID = 0,
722 	DMUB_SHARED_SHARE_FEATURE__IPS_FW = 1,
723 	DMUB_SHARED_SHARE_FEATURE__IPS_DRIVER = 2,
724 	DMUB_SHARED_STATE_FEATURE__LAST, /* Total number of features. */
725 };
726 
727 /**
728  * struct dmub_shared_state_ips_fw - Firmware signals for IPS.
729  */
730 union dmub_shared_state_ips_fw_signals {
731 	struct {
732 		uint32_t ips1_commit : 1;  /**< 1 if in IPS1 */
733 		uint32_t ips2_commit : 1; /**< 1 if in IPS2 */
734 		uint32_t in_idle : 1; /**< 1 if DMCUB is in idle */
735 		uint32_t detection_required : 1; /**< 1 if detection is required */
736 		uint32_t reserved_bits : 28; /**< Reversed */
737 	} bits;
738 	uint32_t all;
739 };
740 
741 /**
742  * struct dmub_shared_state_ips_signals - Firmware signals for IPS.
743  */
744 union dmub_shared_state_ips_driver_signals {
745 	struct {
746 		uint32_t allow_pg : 1; /**< 1 if PG is allowed */
747 		uint32_t allow_ips1 : 1; /**< 1 is IPS1 is allowed */
748 		uint32_t allow_ips2 : 1; /**< 1 is IPS1 is allowed */
749 		uint32_t allow_z10 : 1; /**< 1 if Z10 is allowed */
750 		uint32_t allow_idle : 1; /**< 1 if driver is allowing idle */
751 		uint32_t reserved_bits : 27; /**< Reversed bits */
752 	} bits;
753 	uint32_t all;
754 };
755 
756 /**
757  * IPS FW Version
758  */
759 #define DMUB_SHARED_STATE__IPS_FW_VERSION 1
760 
761 /**
762  * struct dmub_shared_state_ips_fw - Firmware state for IPS.
763  */
764 struct dmub_shared_state_ips_fw {
765 	union dmub_shared_state_ips_fw_signals signals; /**< 4 bytes, IPS signal bits */
766 	uint32_t rcg_entry_count; /**< Entry counter for RCG */
767 	uint32_t rcg_exit_count; /**< Exit counter for RCG */
768 	uint32_t ips1_entry_count; /**< Entry counter for IPS1 */
769 	uint32_t ips1_exit_count; /**< Exit counter for IPS1 */
770 	uint32_t ips2_entry_count; /**< Entry counter for IPS2 */
771 	uint32_t ips2_exit_count; /**< Exit counter for IPS2 */
772 	uint32_t reserved[55]; /**< Reversed, to be updated when adding new fields. */
773 }; /* 248-bytes, fixed */
774 
775 /**
776  * IPS Driver Version
777  */
778 #define DMUB_SHARED_STATE__IPS_DRIVER_VERSION 1
779 
780 /**
781  * struct dmub_shared_state_ips_driver - Driver state for IPS.
782  */
783 struct dmub_shared_state_ips_driver {
784 	union dmub_shared_state_ips_driver_signals signals; /**< 4 bytes, IPS signal bits */
785 	uint32_t reserved[61]; /**< Reversed, to be updated when adding new fields. */
786 }; /* 248-bytes, fixed */
787 
788 /**
789  * enum dmub_shared_state_feature_common - Generic payload.
790  */
791 struct dmub_shared_state_feature_common {
792 	uint32_t padding[62];
793 }; /* 248-bytes, fixed */
794 
795 /**
796  * enum dmub_shared_state_feature_header - Feature description.
797  */
798 struct dmub_shared_state_feature_header {
799 	uint16_t id; /**< Feature ID */
800 	uint16_t version; /**< Feature version */
801 	uint32_t reserved; /**< Reserved bytes. */
802 }; /* 8 bytes, fixed */
803 
804 /**
805  * struct dmub_shared_state_feature_block - Feature block.
806  */
807 struct dmub_shared_state_feature_block {
808 	struct dmub_shared_state_feature_header header; /**< Shared state header. */
809 	union dmub_shared_feature_state_union {
810 		struct dmub_shared_state_feature_common common; /**< Generic data */
811 		struct dmub_shared_state_ips_fw ips_fw; /**< IPS firmware state */
812 		struct dmub_shared_state_ips_driver ips_driver; /**< IPS driver state */
813 	} data; /**< Shared state data. */
814 }; /* 256-bytes, fixed */
815 
816 /**
817  * Shared state size in bytes.
818  */
819 #define DMUB_FW_HEADER_SHARED_STATE_SIZE \
820 	((DMUB_SHARED_STATE_FEATURE__LAST + 1) * sizeof(struct dmub_shared_state_feature_block))
821 
822 //==============================================================================
823 //</DMUB_STATUS>================================================================
824 //==============================================================================
825 //< DMUB_VBIOS>=================================================================
826 //==============================================================================
827 
828 /*
829  * enum dmub_cmd_vbios_type - VBIOS commands.
830  *
831  * Command IDs should be treated as stable ABI.
832  * Do not reuse or modify IDs.
833  */
834 enum dmub_cmd_vbios_type {
835 	/**
836 	 * Configures the DIG encoder.
837 	 */
838 	DMUB_CMD__VBIOS_DIGX_ENCODER_CONTROL = 0,
839 	/**
840 	 * Controls the PHY.
841 	 */
842 	DMUB_CMD__VBIOS_DIG1_TRANSMITTER_CONTROL = 1,
843 	/**
844 	 * Sets the pixel clock/symbol clock.
845 	 */
846 	DMUB_CMD__VBIOS_SET_PIXEL_CLOCK = 2,
847 	/**
848 	 * Enables or disables power gating.
849 	 */
850 	DMUB_CMD__VBIOS_ENABLE_DISP_POWER_GATING = 3,
851 	/**
852 	 * Controls embedded panels.
853 	 */
854 	DMUB_CMD__VBIOS_LVTMA_CONTROL = 15,
855 	/**
856 	 * Query DP alt status on a transmitter.
857 	 */
858 	DMUB_CMD__VBIOS_TRANSMITTER_QUERY_DP_ALT  = 26,
859 	/**
860 	 * Control PHY FSM
861 	 */
862 	DMUB_CMD__VBIOS_TRANSMITTER_SET_PHY_FSM  = 29,
863 	/**
864 	 * Controls domain power gating
865 	 */
866 	DMUB_CMD__VBIOS_DOMAIN_CONTROL = 28,
867 };
868 
869 //==============================================================================
870 //</DMUB_VBIOS>=================================================================
871 //==============================================================================
872 //< DMUB_GPINT>=================================================================
873 //==============================================================================
874 
875 /**
876  * The shifts and masks below may alternatively be used to format and read
877  * the command register bits.
878  */
879 
880 #define DMUB_GPINT_DATA_PARAM_MASK 0xFFFF
881 #define DMUB_GPINT_DATA_PARAM_SHIFT 0
882 
883 #define DMUB_GPINT_DATA_COMMAND_CODE_MASK 0xFFF
884 #define DMUB_GPINT_DATA_COMMAND_CODE_SHIFT 16
885 
886 #define DMUB_GPINT_DATA_STATUS_MASK 0xF
887 #define DMUB_GPINT_DATA_STATUS_SHIFT 28
888 
889 /**
890  * Command responses.
891  */
892 
893 /**
894  * Return response for DMUB_GPINT__STOP_FW command.
895  */
896 #define DMUB_GPINT__STOP_FW_RESPONSE 0xDEADDEAD
897 
898 /**
899  * union dmub_gpint_data_register - Format for sending a command via the GPINT.
900  */
901 union dmub_gpint_data_register {
902 	struct {
903 		uint32_t param : 16; /**< 16-bit parameter */
904 		uint32_t command_code : 12; /**< GPINT command */
905 		uint32_t status : 4; /**< Command status bit */
906 	} bits; /**< GPINT bit access */
907 	uint32_t all; /**< GPINT  32-bit access */
908 };
909 
910 /*
911  * enum dmub_gpint_command - GPINT command to DMCUB FW
912  *
913  * Command IDs should be treated as stable ABI.
914  * Do not reuse or modify IDs.
915  */
916 enum dmub_gpint_command {
917 	/**
918 	 * Invalid command, ignored.
919 	 */
920 	DMUB_GPINT__INVALID_COMMAND = 0,
921 	/**
922 	 * DESC: Queries the firmware version.
923 	 * RETURN: Firmware version.
924 	 */
925 	DMUB_GPINT__GET_FW_VERSION = 1,
926 	/**
927 	 * DESC: Halts the firmware.
928 	 * RETURN: DMUB_GPINT__STOP_FW_RESPONSE (0xDEADDEAD) when halted
929 	 */
930 	DMUB_GPINT__STOP_FW = 2,
931 	/**
932 	 * DESC: Get PSR state from FW.
933 	 * RETURN: PSR state enum. This enum may need to be converted to the legacy PSR state value.
934 	 */
935 	DMUB_GPINT__GET_PSR_STATE = 7,
936 	/**
937 	 * DESC: Notifies DMCUB of the currently active streams.
938 	 * ARGS: Stream mask, 1 bit per active stream index.
939 	 */
940 	DMUB_GPINT__IDLE_OPT_NOTIFY_STREAM_MASK = 8,
941 	/**
942 	 * DESC: Start PSR residency counter. Stop PSR resdiency counter and get value.
943 	 * ARGS: We can measure residency from various points. The argument will specify the residency mode.
944 	 *       By default, it is measured from after we powerdown the PHY, to just before we powerup the PHY.
945 	 * RETURN: PSR residency in milli-percent.
946 	 */
947 	DMUB_GPINT__PSR_RESIDENCY = 9,
948 
949 	/**
950 	 * DESC: Notifies DMCUB detection is done so detection required can be cleared.
951 	 */
952 	DMUB_GPINT__NOTIFY_DETECTION_DONE = 12,
953 
954 	/**
955 	 * DESC: Get REPLAY state from FW.
956 	 * RETURN: REPLAY state enum. This enum may need to be converted to the legacy REPLAY state value.
957 	 */
958 	DMUB_GPINT__GET_REPLAY_STATE = 13,
959 
960 	/**
961 	 * DESC: Start REPLAY residency counter. Stop REPLAY resdiency counter and get value.
962 	 * ARGS: We can measure residency from various points. The argument will specify the residency mode.
963 	 *       By default, it is measured from after we powerdown the PHY, to just before we powerup the PHY.
964 	 * RETURN: REPLAY residency in milli-percent.
965 	 */
966 	DMUB_GPINT__REPLAY_RESIDENCY = 14,
967 
968 	/**
969 	 * DESC: Copy bounding box to the host.
970 	 * ARGS: Version of bounding box to copy
971 	 * RETURN: Result of copying bounding box
972 	 */
973 	DMUB_GPINT__BB_COPY = 96,
974 
975 	/**
976 	 * DESC: Updates the host addresses bit48~bit63 for bounding box.
977 	 * ARGS: The word3 for the 64 bit address
978 	 */
979 	DMUB_GPINT__SET_BB_ADDR_WORD3 = 97,
980 
981 	/**
982 	 * DESC: Updates the host addresses bit32~bit47 for bounding box.
983 	 * ARGS: The word2 for the 64 bit address
984 	 */
985 	DMUB_GPINT__SET_BB_ADDR_WORD2 = 98,
986 
987 	/**
988 	 * DESC: Updates the host addresses bit16~bit31 for bounding box.
989 	 * ARGS: The word1 for the 64 bit address
990 	 */
991 	DMUB_GPINT__SET_BB_ADDR_WORD1 = 99,
992 
993 	/**
994 	 * DESC: Updates the host addresses bit0~bit15 for bounding box.
995 	 * ARGS: The word0 for the 64 bit address
996 	 */
997 	DMUB_GPINT__SET_BB_ADDR_WORD0 = 100,
998 
999 	/**
1000 	 * DESC: Updates the trace buffer lower 32-bit mask.
1001 	 * ARGS: The new mask
1002 	 * RETURN: Lower 32-bit mask.
1003 	 */
1004 	DMUB_GPINT__UPDATE_TRACE_BUFFER_MASK = 101,
1005 
1006 	/**
1007 	 * DESC: Updates the trace buffer mask bit0~bit15.
1008 	 * ARGS: The new mask
1009 	 * RETURN: Lower 32-bit mask.
1010 	 */
1011 	DMUB_GPINT__SET_TRACE_BUFFER_MASK_WORD0 = 102,
1012 
1013 	/**
1014 	 * DESC: Updates the trace buffer mask bit16~bit31.
1015 	 * ARGS: The new mask
1016 	 * RETURN: Lower 32-bit mask.
1017 	 */
1018 	DMUB_GPINT__SET_TRACE_BUFFER_MASK_WORD1 = 103,
1019 
1020 	/**
1021 	 * DESC: Updates the trace buffer mask bit32~bit47.
1022 	 * ARGS: The new mask
1023 	 * RETURN: Lower 32-bit mask.
1024 	 */
1025 	DMUB_GPINT__SET_TRACE_BUFFER_MASK_WORD2 = 114,
1026 
1027 	/**
1028 	 * DESC: Updates the trace buffer mask bit48~bit63.
1029 	 * ARGS: The new mask
1030 	 * RETURN: Lower 32-bit mask.
1031 	 */
1032 	DMUB_GPINT__SET_TRACE_BUFFER_MASK_WORD3 = 115,
1033 
1034 	/**
1035 	 * DESC: Read the trace buffer mask bi0~bit15.
1036 	 */
1037 	DMUB_GPINT__GET_TRACE_BUFFER_MASK_WORD0 = 116,
1038 
1039 	/**
1040 	 * DESC: Read the trace buffer mask bit16~bit31.
1041 	 */
1042 	DMUB_GPINT__GET_TRACE_BUFFER_MASK_WORD1 = 117,
1043 
1044 	/**
1045 	 * DESC: Read the trace buffer mask bi32~bit47.
1046 	 */
1047 	DMUB_GPINT__GET_TRACE_BUFFER_MASK_WORD2 = 118,
1048 
1049 	/**
1050 	 * DESC: Updates the trace buffer mask bit32~bit63.
1051 	 */
1052 	DMUB_GPINT__GET_TRACE_BUFFER_MASK_WORD3 = 119,
1053 
1054 	/**
1055 	 * DESC: Enable measurements for various task duration
1056 	 * ARGS: 0 - Disable measurement
1057 	 *       1 - Enable measurement
1058 	 */
1059 	DMUB_GPINT__TRACE_DMUB_WAKE_ACTIVITY = 123,
1060 };
1061 
1062 /**
1063  * INBOX0 generic command definition
1064  */
1065 union dmub_inbox0_cmd_common {
1066 	struct {
1067 		uint32_t command_code: 8; /**< INBOX0 command code */
1068 		uint32_t param: 24; /**< 24-bit parameter */
1069 	} bits;
1070 	uint32_t all;
1071 };
1072 
1073 /**
1074  * INBOX0 hw_lock command definition
1075  */
1076 union dmub_inbox0_cmd_lock_hw {
1077 	struct {
1078 		uint32_t command_code: 8;
1079 
1080 		/* NOTE: Must be have enough bits to match: enum hw_lock_client */
1081 		uint32_t hw_lock_client: 2;
1082 
1083 		/* NOTE: Below fields must match with: struct dmub_hw_lock_inst_flags */
1084 		uint32_t otg_inst: 3;
1085 		uint32_t opp_inst: 3;
1086 		uint32_t dig_inst: 3;
1087 
1088 		/* NOTE: Below fields must match with: union dmub_hw_lock_flags */
1089 		uint32_t lock_pipe: 1;
1090 		uint32_t lock_cursor: 1;
1091 		uint32_t lock_dig: 1;
1092 		uint32_t triple_buffer_lock: 1;
1093 
1094 		uint32_t lock: 1;				/**< Lock */
1095 		uint32_t should_release: 1;		/**< Release */
1096 		uint32_t reserved: 7; 			/**< Reserved for extending more clients, HW, etc. */
1097 	} bits;
1098 	uint32_t all;
1099 };
1100 
1101 union dmub_inbox0_data_register {
1102 	union dmub_inbox0_cmd_common inbox0_cmd_common;
1103 	union dmub_inbox0_cmd_lock_hw inbox0_cmd_lock_hw;
1104 };
1105 
1106 enum dmub_inbox0_command {
1107 	/**
1108 	 * DESC: Invalid command, ignored.
1109 	 */
1110 	DMUB_INBOX0_CMD__INVALID_COMMAND = 0,
1111 	/**
1112 	 * DESC: Notification to acquire/release HW lock
1113 	 * ARGS:
1114 	 */
1115 	DMUB_INBOX0_CMD__HW_LOCK = 1,
1116 };
1117 //==============================================================================
1118 //</DMUB_GPINT>=================================================================
1119 //==============================================================================
1120 //< DMUB_CMD>===================================================================
1121 //==============================================================================
1122 
1123 /**
1124  * Size in bytes of each DMUB command.
1125  */
1126 #define DMUB_RB_CMD_SIZE 64
1127 
1128 /**
1129  * Maximum number of items in the DMUB ringbuffer.
1130  */
1131 #define DMUB_RB_MAX_ENTRY 128
1132 
1133 /**
1134  * Ringbuffer size in bytes.
1135  */
1136 #define DMUB_RB_SIZE (DMUB_RB_CMD_SIZE * DMUB_RB_MAX_ENTRY)
1137 
1138 /**
1139  * REG_SET mask for reg offload.
1140  */
1141 #define REG_SET_MASK 0xFFFF
1142 
1143 /*
1144  * enum dmub_cmd_type - DMUB inbox command.
1145  *
1146  * Command IDs should be treated as stable ABI.
1147  * Do not reuse or modify IDs.
1148  */
1149 enum dmub_cmd_type {
1150 	/**
1151 	 * Invalid command.
1152 	 */
1153 	DMUB_CMD__NULL = 0,
1154 	/**
1155 	 * Read modify write register sequence offload.
1156 	 */
1157 	DMUB_CMD__REG_SEQ_READ_MODIFY_WRITE = 1,
1158 	/**
1159 	 * Field update register sequence offload.
1160 	 */
1161 	DMUB_CMD__REG_SEQ_FIELD_UPDATE_SEQ = 2,
1162 	/**
1163 	 * Burst write sequence offload.
1164 	 */
1165 	DMUB_CMD__REG_SEQ_BURST_WRITE = 3,
1166 	/**
1167 	 * Reg wait sequence offload.
1168 	 */
1169 	DMUB_CMD__REG_REG_WAIT = 4,
1170 	/**
1171 	 * Workaround to avoid HUBP underflow during NV12 playback.
1172 	 */
1173 	DMUB_CMD__PLAT_54186_WA = 5,
1174 	/**
1175 	 * Command type used to query FW feature caps.
1176 	 */
1177 	DMUB_CMD__QUERY_FEATURE_CAPS = 6,
1178 	/**
1179 	 * Command type used to get visual confirm color.
1180 	 */
1181 	DMUB_CMD__GET_VISUAL_CONFIRM_COLOR = 8,
1182 	/**
1183 	 * Command type used for all PSR commands.
1184 	 */
1185 	DMUB_CMD__PSR = 64,
1186 	/**
1187 	 * Command type used for all MALL commands.
1188 	 */
1189 	DMUB_CMD__MALL = 65,
1190 	/**
1191 	 * Command type used for all ABM commands.
1192 	 */
1193 	DMUB_CMD__ABM = 66,
1194 	/**
1195 	 * Command type used to update dirty rects in FW.
1196 	 */
1197 	DMUB_CMD__UPDATE_DIRTY_RECT = 67,
1198 	/**
1199 	 * Command type used to update cursor info in FW.
1200 	 */
1201 	DMUB_CMD__UPDATE_CURSOR_INFO = 68,
1202 	/**
1203 	 * Command type used for HW locking in FW.
1204 	 */
1205 	DMUB_CMD__HW_LOCK = 69,
1206 	/**
1207 	 * Command type used to access DP AUX.
1208 	 */
1209 	DMUB_CMD__DP_AUX_ACCESS = 70,
1210 	/**
1211 	 * Command type used for OUTBOX1 notification enable
1212 	 */
1213 	DMUB_CMD__OUTBOX1_ENABLE = 71,
1214 
1215 	/**
1216 	 * Command type used for all idle optimization commands.
1217 	 */
1218 	DMUB_CMD__IDLE_OPT = 72,
1219 	/**
1220 	 * Command type used for all clock manager commands.
1221 	 */
1222 	DMUB_CMD__CLK_MGR = 73,
1223 	/**
1224 	 * Command type used for all panel control commands.
1225 	 */
1226 	DMUB_CMD__PANEL_CNTL = 74,
1227 
1228 	/**
1229 	 * Command type used for all CAB commands.
1230 	 */
1231 	DMUB_CMD__CAB_FOR_SS = 75,
1232 
1233 	DMUB_CMD__FW_ASSISTED_MCLK_SWITCH = 76,
1234 
1235 	/**
1236 	 * Command type used for interfacing with DPIA.
1237 	 */
1238 	DMUB_CMD__DPIA = 77,
1239 	/**
1240 	 * Command type used for EDID CEA parsing
1241 	 */
1242 	DMUB_CMD__EDID_CEA = 79,
1243 	/**
1244 	 * Command type used for getting usbc cable ID
1245 	 */
1246 	DMUB_CMD_GET_USBC_CABLE_ID = 81,
1247 	/**
1248 	 * Command type used to query HPD state.
1249 	 */
1250 	DMUB_CMD__QUERY_HPD_STATE = 82,
1251 	/**
1252 	 * Command type used for all VBIOS interface commands.
1253 	 */
1254 	/**
1255 	 * Command type used for all REPLAY commands.
1256 	 */
1257 	DMUB_CMD__REPLAY = 83,
1258 
1259 	/**
1260 	 * Command type used for all SECURE_DISPLAY commands.
1261 	 */
1262 	DMUB_CMD__SECURE_DISPLAY = 85,
1263 
1264 	/**
1265 	 * Command type used to set DPIA HPD interrupt state
1266 	 */
1267 	DMUB_CMD__DPIA_HPD_INT_ENABLE = 86,
1268 
1269 	/**
1270 	 * Command type used for all PSP commands.
1271 	 */
1272 	DMUB_CMD__PSP = 88,
1273 
1274 	DMUB_CMD__VBIOS = 128,
1275 };
1276 
1277 /**
1278  * enum dmub_out_cmd_type - DMUB outbox commands.
1279  */
1280 enum dmub_out_cmd_type {
1281 	/**
1282 	 * Invalid outbox command, ignored.
1283 	 */
1284 	DMUB_OUT_CMD__NULL = 0,
1285 	/**
1286 	 * Command type used for DP AUX Reply data notification
1287 	 */
1288 	DMUB_OUT_CMD__DP_AUX_REPLY = 1,
1289 	/**
1290 	 * Command type used for DP HPD event notification
1291 	 */
1292 	DMUB_OUT_CMD__DP_HPD_NOTIFY = 2,
1293 	/**
1294 	 * Command type used for SET_CONFIG Reply notification
1295 	 */
1296 	DMUB_OUT_CMD__SET_CONFIG_REPLY = 3,
1297 	/**
1298 	 * Command type used for USB4 DPIA notification
1299 	 */
1300 	DMUB_OUT_CMD__DPIA_NOTIFICATION = 5,
1301 	/**
1302 	 * Command type used for HPD redetect notification
1303 	 */
1304 	DMUB_OUT_CMD__HPD_SENSE_NOTIFY = 6,
1305 };
1306 
1307 /* DMUB_CMD__DPIA command sub-types. */
1308 enum dmub_cmd_dpia_type {
1309 	DMUB_CMD__DPIA_DIG1_DPIA_CONTROL = 0,
1310 	DMUB_CMD__DPIA_SET_CONFIG_ACCESS = 1,
1311 	DMUB_CMD__DPIA_MST_ALLOC_SLOTS = 2,
1312 	DMUB_CMD__DPIA_SET_TPS_NOTIFICATION = 3,
1313 };
1314 
1315 /* DMUB_OUT_CMD__DPIA_NOTIFICATION command types. */
1316 enum dmub_cmd_dpia_notification_type {
1317 	DPIA_NOTIFY__BW_ALLOCATION = 0,
1318 };
1319 
1320 #pragma pack(push, 1)
1321 
1322 /**
1323  * struct dmub_cmd_header - Common command header fields.
1324  */
1325 struct dmub_cmd_header {
1326 	unsigned int type : 8; /**< command type */
1327 	unsigned int sub_type : 8; /**< command sub type */
1328 	unsigned int ret_status : 1; /**< 1 if returned data, 0 otherwise */
1329 	unsigned int multi_cmd_pending : 1; /**< 1 if multiple commands chained together */
1330 	unsigned int reserved0 : 6; /**< reserved bits */
1331 	unsigned int payload_bytes : 6;  /* payload excluding header - up to 60 bytes */
1332 	unsigned int reserved1 : 2; /**< reserved bits */
1333 };
1334 
1335 /*
1336  * struct dmub_cmd_read_modify_write_sequence - Read modify write
1337  *
1338  * 60 payload bytes can hold up to 5 sets of read modify writes,
1339  * each take 3 dwords.
1340  *
1341  * number of sequences = header.payload_bytes / sizeof(struct dmub_cmd_read_modify_write_sequence)
1342  *
1343  * modify_mask = 0xffff'ffff means all fields are going to be updated.  in this case
1344  * command parser will skip the read and we can use modify_mask = 0xffff'ffff as reg write
1345  */
1346 struct dmub_cmd_read_modify_write_sequence {
1347 	uint32_t addr; /**< register address */
1348 	uint32_t modify_mask; /**< modify mask */
1349 	uint32_t modify_value; /**< modify value */
1350 };
1351 
1352 /**
1353  * Maximum number of ops in read modify write sequence.
1354  */
1355 #define DMUB_READ_MODIFY_WRITE_SEQ__MAX 5
1356 
1357 /**
1358  * struct dmub_cmd_read_modify_write_sequence - Read modify write command.
1359  */
1360 struct dmub_rb_cmd_read_modify_write {
1361 	struct dmub_cmd_header header;  /**< command header */
1362 	/**
1363 	 * Read modify write sequence.
1364 	 */
1365 	struct dmub_cmd_read_modify_write_sequence seq[DMUB_READ_MODIFY_WRITE_SEQ__MAX];
1366 };
1367 
1368 /*
1369  * Update a register with specified masks and values sequeunce
1370  *
1371  * 60 payload bytes can hold address + up to 7 sets of mask/value combo, each take 2 dword
1372  *
1373  * number of field update sequence = (header.payload_bytes - sizeof(addr)) / sizeof(struct read_modify_write_sequence)
1374  *
1375  *
1376  * USE CASE:
1377  *   1. auto-increment register where additional read would update pointer and produce wrong result
1378  *   2. toggle a bit without read in the middle
1379  */
1380 
1381 struct dmub_cmd_reg_field_update_sequence {
1382 	uint32_t modify_mask; /**< 0xffff'ffff to skip initial read */
1383 	uint32_t modify_value; /**< value to update with */
1384 };
1385 
1386 /**
1387  * Maximum number of ops in field update sequence.
1388  */
1389 #define DMUB_REG_FIELD_UPDATE_SEQ__MAX 7
1390 
1391 /**
1392  * struct dmub_rb_cmd_reg_field_update_sequence - Field update command.
1393  */
1394 struct dmub_rb_cmd_reg_field_update_sequence {
1395 	struct dmub_cmd_header header; /**< command header */
1396 	uint32_t addr; /**< register address */
1397 	/**
1398 	 * Field update sequence.
1399 	 */
1400 	struct dmub_cmd_reg_field_update_sequence seq[DMUB_REG_FIELD_UPDATE_SEQ__MAX];
1401 };
1402 
1403 
1404 /**
1405  * Maximum number of burst write values.
1406  */
1407 #define DMUB_BURST_WRITE_VALUES__MAX  14
1408 
1409 /*
1410  * struct dmub_rb_cmd_burst_write - Burst write
1411  *
1412  * support use case such as writing out LUTs.
1413  *
1414  * 60 payload bytes can hold up to 14 values to write to given address
1415  *
1416  * number of payload = header.payload_bytes / sizeof(struct read_modify_write_sequence)
1417  */
1418 struct dmub_rb_cmd_burst_write {
1419 	struct dmub_cmd_header header; /**< command header */
1420 	uint32_t addr; /**< register start address */
1421 	/**
1422 	 * Burst write register values.
1423 	 */
1424 	uint32_t write_values[DMUB_BURST_WRITE_VALUES__MAX];
1425 };
1426 
1427 /**
1428  * struct dmub_rb_cmd_common - Common command header
1429  */
1430 struct dmub_rb_cmd_common {
1431 	struct dmub_cmd_header header; /**< command header */
1432 	/**
1433 	 * Padding to RB_CMD_SIZE
1434 	 */
1435 	uint8_t cmd_buffer[DMUB_RB_CMD_SIZE - sizeof(struct dmub_cmd_header)];
1436 };
1437 
1438 /**
1439  * struct dmub_cmd_reg_wait_data - Register wait data
1440  */
1441 struct dmub_cmd_reg_wait_data {
1442 	uint32_t addr; /**< Register address */
1443 	uint32_t mask; /**< Mask for register bits */
1444 	uint32_t condition_field_value; /**< Value to wait for */
1445 	uint32_t time_out_us; /**< Time out for reg wait in microseconds */
1446 };
1447 
1448 /**
1449  * struct dmub_rb_cmd_reg_wait - Register wait command
1450  */
1451 struct dmub_rb_cmd_reg_wait {
1452 	struct dmub_cmd_header header; /**< Command header */
1453 	struct dmub_cmd_reg_wait_data reg_wait; /**< Register wait data */
1454 };
1455 
1456 /**
1457  * struct dmub_cmd_PLAT_54186_wa - Underflow workaround
1458  *
1459  * Reprograms surface parameters to avoid underflow.
1460  */
1461 struct dmub_cmd_PLAT_54186_wa {
1462 	uint32_t DCSURF_SURFACE_CONTROL; /**< reg value */
1463 	uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS_HIGH; /**< reg value */
1464 	uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS; /**< reg value */
1465 	uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS_HIGH_C; /**< reg value */
1466 	uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS_C; /**< reg value */
1467 	struct {
1468 		uint32_t hubp_inst : 4; /**< HUBP instance */
1469 		uint32_t tmz_surface : 1; /**< TMZ enable or disable */
1470 		uint32_t immediate :1; /**< Immediate flip */
1471 		uint32_t vmid : 4; /**< VMID */
1472 		uint32_t grph_stereo : 1; /**< 1 if stereo */
1473 		uint32_t reserved : 21; /**< Reserved */
1474 	} flip_params; /**< Pageflip parameters */
1475 	uint32_t reserved[9]; /**< Reserved bits */
1476 };
1477 
1478 /**
1479  * struct dmub_rb_cmd_PLAT_54186_wa - Underflow workaround command
1480  */
1481 struct dmub_rb_cmd_PLAT_54186_wa {
1482 	struct dmub_cmd_header header; /**< Command header */
1483 	struct dmub_cmd_PLAT_54186_wa flip; /**< Flip data */
1484 };
1485 
1486 /**
1487  * enum dmub_cmd_mall_type - MALL commands
1488  */
1489 enum dmub_cmd_mall_type {
1490 	/**
1491 	 * Allows display refresh from MALL.
1492 	 */
1493 	DMUB_CMD__MALL_ACTION_ALLOW = 0,
1494 	/**
1495 	 * Disallows display refresh from MALL.
1496 	 */
1497 	DMUB_CMD__MALL_ACTION_DISALLOW = 1,
1498 	/**
1499 	 * Cursor copy for MALL.
1500 	 */
1501 	DMUB_CMD__MALL_ACTION_COPY_CURSOR = 2,
1502 	/**
1503 	 * Controls DF requests.
1504 	 */
1505 	DMUB_CMD__MALL_ACTION_NO_DF_REQ = 3,
1506 };
1507 
1508 /**
1509  * struct dmub_rb_cmd_mall - MALL command data.
1510  */
1511 struct dmub_rb_cmd_mall {
1512 	struct dmub_cmd_header header; /**< Common command header */
1513 	union dmub_addr cursor_copy_src; /**< Cursor copy address */
1514 	union dmub_addr cursor_copy_dst; /**< Cursor copy destination */
1515 	uint32_t tmr_delay; /**< Timer delay */
1516 	uint32_t tmr_scale; /**< Timer scale */
1517 	uint16_t cursor_width; /**< Cursor width in pixels */
1518 	uint16_t cursor_pitch; /**< Cursor pitch in pixels */
1519 	uint16_t cursor_height; /**< Cursor height in pixels */
1520 	uint8_t cursor_bpp; /**< Cursor bits per pixel */
1521 	uint8_t debug_bits; /**< Debug bits */
1522 
1523 	uint8_t reserved1; /**< Reserved bits */
1524 	uint8_t reserved2; /**< Reserved bits */
1525 };
1526 
1527 /**
1528  * enum dmub_cmd_cab_type - CAB command data.
1529  */
1530 enum dmub_cmd_cab_type {
1531 	/**
1532 	 * No idle optimizations (i.e. no CAB)
1533 	 */
1534 	DMUB_CMD__CAB_NO_IDLE_OPTIMIZATION = 0,
1535 	/**
1536 	 * No DCN requests for memory
1537 	 */
1538 	DMUB_CMD__CAB_NO_DCN_REQ = 1,
1539 	/**
1540 	 * Fit surfaces in CAB (i.e. CAB enable)
1541 	 */
1542 	DMUB_CMD__CAB_DCN_SS_FIT_IN_CAB = 2,
1543 	/**
1544 	 * Do not fit surfaces in CAB (i.e. no CAB)
1545 	 */
1546 	DMUB_CMD__CAB_DCN_SS_NOT_FIT_IN_CAB = 3,
1547 };
1548 
1549 /**
1550  * struct dmub_rb_cmd_cab - CAB command data.
1551  */
1552 struct dmub_rb_cmd_cab_for_ss {
1553 	struct dmub_cmd_header header;
1554 	uint8_t cab_alloc_ways; /* total number of ways */
1555 	uint8_t debug_bits;     /* debug bits */
1556 };
1557 
1558 /**
1559  * Enum for indicating which MCLK switch mode per pipe
1560  */
1561 enum mclk_switch_mode {
1562 	NONE = 0,
1563 	FPO = 1,
1564 	SUBVP = 2,
1565 	VBLANK = 3,
1566 };
1567 
1568 /* Per pipe struct which stores the MCLK switch mode
1569  * data to be sent to DMUB.
1570  * Named "v2" for now -- once FPO and SUBVP are fully merged
1571  * the type name can be updated
1572  */
1573 struct dmub_cmd_fw_assisted_mclk_switch_pipe_data_v2 {
1574 	union {
1575 		struct {
1576 			uint32_t pix_clk_100hz;
1577 			uint16_t main_vblank_start;
1578 			uint16_t main_vblank_end;
1579 			uint16_t mall_region_lines;
1580 			uint16_t prefetch_lines;
1581 			uint16_t prefetch_to_mall_start_lines;
1582 			uint16_t processing_delay_lines;
1583 			uint16_t htotal; // required to calculate line time for multi-display cases
1584 			uint16_t vtotal;
1585 			uint8_t main_pipe_index;
1586 			uint8_t phantom_pipe_index;
1587 			/* Since the microschedule is calculated in terms of OTG lines,
1588 			 * include any scaling factors to make sure when we get accurate
1589 			 * conversion when programming MALL_START_LINE (which is in terms
1590 			 * of HUBP lines). If 4K is being downscaled to 1080p, scale factor
1591 			 * is 1/2 (numerator = 1, denominator = 2).
1592 			 */
1593 			uint8_t scale_factor_numerator;
1594 			uint8_t scale_factor_denominator;
1595 			uint8_t is_drr;
1596 			uint8_t main_split_pipe_index;
1597 			uint8_t phantom_split_pipe_index;
1598 		} subvp_data;
1599 
1600 		struct {
1601 			uint32_t pix_clk_100hz;
1602 			uint16_t vblank_start;
1603 			uint16_t vblank_end;
1604 			uint16_t vstartup_start;
1605 			uint16_t vtotal;
1606 			uint16_t htotal;
1607 			uint8_t vblank_pipe_index;
1608 			uint8_t padding[1];
1609 			struct {
1610 				uint8_t drr_in_use;
1611 				uint8_t drr_window_size_ms;	// Indicates largest VMIN/VMAX adjustment per frame
1612 				uint16_t min_vtotal_supported;	// Min VTOTAL that supports switching in VBLANK
1613 				uint16_t max_vtotal_supported;	// Max VTOTAL that can support SubVP static scheduling
1614 				uint8_t use_ramping;		// Use ramping or not
1615 				uint8_t drr_vblank_start_margin;
1616 			} drr_info;				// DRR considered as part of SubVP + VBLANK case
1617 		} vblank_data;
1618 	} pipe_config;
1619 
1620 	/* - subvp_data in the union (pipe_config) takes up 27 bytes.
1621 	 * - Make the "mode" field a uint8_t instead of enum so we only use 1 byte (only
1622 	 *   for the DMCUB command, cast to enum once we populate the DMCUB subvp state).
1623 	 */
1624 	uint8_t mode; // enum mclk_switch_mode
1625 };
1626 
1627 /**
1628  * Config data for Sub-VP and FPO
1629  * Named "v2" for now -- once FPO and SUBVP are fully merged
1630  * the type name can be updated
1631  */
1632 struct dmub_cmd_fw_assisted_mclk_switch_config_v2 {
1633 	uint16_t watermark_a_cache;
1634 	uint8_t vertical_int_margin_us;
1635 	uint8_t pstate_allow_width_us;
1636 	struct dmub_cmd_fw_assisted_mclk_switch_pipe_data_v2 pipe_data[DMUB_MAX_SUBVP_STREAMS];
1637 };
1638 
1639 /**
1640  * DMUB rb command definition for Sub-VP and FPO
1641  * Named "v2" for now -- once FPO and SUBVP are fully merged
1642  * the type name can be updated
1643  */
1644 struct dmub_rb_cmd_fw_assisted_mclk_switch_v2 {
1645 	struct dmub_cmd_header header;
1646 	struct dmub_cmd_fw_assisted_mclk_switch_config_v2 config_data;
1647 };
1648 
1649 struct dmub_flip_addr_info {
1650 	uint32_t surf_addr_lo;
1651 	uint32_t surf_addr_c_lo;
1652 	uint32_t meta_addr_lo;
1653 	uint32_t meta_addr_c_lo;
1654 	uint16_t surf_addr_hi;
1655 	uint16_t surf_addr_c_hi;
1656 	uint16_t meta_addr_hi;
1657 	uint16_t meta_addr_c_hi;
1658 };
1659 
1660 struct dmub_fams2_flip_info {
1661 	union {
1662 		struct {
1663 			uint8_t is_immediate: 1;
1664 		} bits;
1665 		uint8_t all;
1666 	} config;
1667 	uint8_t otg_inst;
1668 	uint8_t pipe_mask;
1669 	uint8_t pad;
1670 	struct dmub_flip_addr_info addr_info;
1671 };
1672 
1673 struct dmub_rb_cmd_fams2_flip {
1674 	struct dmub_cmd_header header;
1675 	struct dmub_fams2_flip_info flip_info;
1676 };
1677 
1678 struct dmub_optc_state_v2 {
1679 	uint32_t v_total_min;
1680 	uint32_t v_total_max;
1681 	uint32_t v_total_mid;
1682 	uint32_t v_total_mid_frame_num;
1683 	uint8_t program_manual_trigger;
1684 	uint8_t tg_inst;
1685 	uint8_t pad[2];
1686 };
1687 
1688 struct dmub_optc_position {
1689 	uint32_t vpos;
1690 	uint32_t hpos;
1691 	uint32_t frame;
1692 };
1693 
1694 struct dmub_rb_cmd_fams2_drr_update {
1695 	struct dmub_cmd_header header;
1696 	struct dmub_optc_state_v2 dmub_optc_state_req;
1697 };
1698 
1699 /* HW and FW global configuration data for FAMS2 */
1700 /* FAMS2 types and structs */
1701 enum fams2_stream_type {
1702 	FAMS2_STREAM_TYPE_NONE = 0,
1703 	FAMS2_STREAM_TYPE_VBLANK = 1,
1704 	FAMS2_STREAM_TYPE_VACTIVE = 2,
1705 	FAMS2_STREAM_TYPE_DRR = 3,
1706 	FAMS2_STREAM_TYPE_SUBVP = 4,
1707 };
1708 
1709 /* dynamic stream state */
1710 struct dmub_fams2_legacy_stream_dynamic_state {
1711 	uint8_t force_allow_at_vblank;
1712 	uint8_t pad[3];
1713 };
1714 
1715 struct dmub_fams2_subvp_stream_dynamic_state {
1716 	uint16_t viewport_start_hubp_vline;
1717 	uint16_t viewport_height_hubp_vlines;
1718 	uint16_t viewport_start_c_hubp_vline;
1719 	uint16_t viewport_height_c_hubp_vlines;
1720 	uint16_t phantom_viewport_height_hubp_vlines;
1721 	uint16_t phantom_viewport_height_c_hubp_vlines;
1722 	uint16_t microschedule_start_otg_vline;
1723 	uint16_t mall_start_otg_vline;
1724 	uint16_t mall_start_hubp_vline;
1725 	uint16_t mall_start_c_hubp_vline;
1726 	uint8_t force_allow_at_vblank_only;
1727 	uint8_t pad[3];
1728 };
1729 
1730 struct dmub_fams2_drr_stream_dynamic_state {
1731 	uint16_t stretched_vtotal;
1732 	uint8_t use_cur_vtotal;
1733 	uint8_t pad;
1734 };
1735 
1736 struct dmub_fams2_stream_dynamic_state {
1737 	uint64_t ref_tick;
1738 	uint32_t cur_vtotal;
1739 	uint16_t adjusted_allow_end_otg_vline;
1740 	uint8_t pad[2];
1741 	struct dmub_optc_position ref_otg_pos;
1742 	struct dmub_optc_position target_otg_pos;
1743 	union {
1744 		struct dmub_fams2_legacy_stream_dynamic_state legacy;
1745 		struct dmub_fams2_subvp_stream_dynamic_state subvp;
1746 		struct dmub_fams2_drr_stream_dynamic_state drr;
1747 	} sub_state;
1748 };
1749 
1750 /* static stream state */
1751 struct dmub_fams2_legacy_stream_static_state {
1752 	uint8_t vactive_det_fill_delay_otg_vlines;
1753 	uint8_t programming_delay_otg_vlines;
1754 };
1755 
1756 struct dmub_fams2_subvp_stream_static_state {
1757 	uint16_t vratio_numerator;
1758 	uint16_t vratio_denominator;
1759 	uint16_t phantom_vtotal;
1760 	uint16_t phantom_vactive;
1761 	union {
1762 		struct {
1763 			uint8_t is_multi_planar : 1;
1764 			uint8_t is_yuv420 : 1;
1765 		} bits;
1766 		uint8_t all;
1767 	} config;
1768 	uint8_t programming_delay_otg_vlines;
1769 	uint8_t prefetch_to_mall_otg_vlines;
1770 	uint8_t phantom_otg_inst;
1771 	uint8_t phantom_pipe_mask;
1772 	uint8_t phantom_plane_pipe_masks[DMUB_MAX_PHANTOM_PLANES]; // phantom pipe mask per plane (for flip passthrough)
1773 };
1774 
1775 struct dmub_fams2_drr_stream_static_state {
1776 	uint16_t nom_stretched_vtotal;
1777 	uint8_t programming_delay_otg_vlines;
1778 	uint8_t only_stretch_if_required;
1779 	uint8_t pad[2];
1780 };
1781 
1782 struct dmub_fams2_stream_static_state {
1783 	enum fams2_stream_type type;
1784 	uint32_t otg_vline_time_ns;
1785 	uint32_t otg_vline_time_ticks;
1786 	uint16_t htotal;
1787 	uint16_t vtotal; // nominal vtotal
1788 	uint16_t vblank_start;
1789 	uint16_t vblank_end;
1790 	uint16_t max_vtotal;
1791 	uint16_t allow_start_otg_vline;
1792 	uint16_t allow_end_otg_vline;
1793 	uint16_t drr_keepout_otg_vline; // after this vline, vtotal cannot be changed
1794 	uint8_t scheduling_delay_otg_vlines; // min time to budget for ready to microschedule start
1795 	uint8_t contention_delay_otg_vlines; // time to budget for contention on execution
1796 	uint8_t vline_int_ack_delay_otg_vlines; // min time to budget for vertical interrupt firing
1797 	uint8_t allow_to_target_delay_otg_vlines; // time from allow vline to target vline
1798 	union {
1799 		struct {
1800 			uint8_t is_drr: 1; // stream is DRR enabled
1801 			uint8_t clamp_vtotal_min: 1; // clamp vtotal to min instead of nominal
1802 			uint8_t min_ttu_vblank_usable: 1; // if min ttu vblank is above wm, no force pstate is needed in blank
1803 		} bits;
1804 		uint8_t all;
1805 	} config;
1806 	uint8_t otg_inst;
1807 	uint8_t pipe_mask; // pipe mask for the whole config
1808 	uint8_t num_planes;
1809 	uint8_t plane_pipe_masks[DMUB_MAX_PLANES]; // pipe mask per plane (for flip passthrough)
1810 	uint8_t pad[DMUB_MAX_PLANES % 4];
1811 	union {
1812 		struct dmub_fams2_legacy_stream_static_state legacy;
1813 		struct dmub_fams2_subvp_stream_static_state subvp;
1814 		struct dmub_fams2_drr_stream_static_state drr;
1815 	} sub_state;
1816 };
1817 
1818 /**
1819  * enum dmub_fams2_allow_delay_check_mode - macroscheduler mode for breaking on excessive
1820  * p-state request to allow latency
1821  */
1822 enum dmub_fams2_allow_delay_check_mode {
1823 	/* No check for request to allow delay */
1824 	FAMS2_ALLOW_DELAY_CHECK_NONE = 0,
1825 	/* Check for request to allow delay */
1826 	FAMS2_ALLOW_DELAY_CHECK_FROM_START = 1,
1827 	/* Check for prepare to allow delay */
1828 	FAMS2_ALLOW_DELAY_CHECK_FROM_PREPARE = 2,
1829 };
1830 
1831 union dmub_fams2_global_feature_config {
1832 	struct {
1833 		uint32_t enable: 1;
1834 		uint32_t enable_ppt_check: 1;
1835 		uint32_t enable_stall_recovery: 1;
1836 		uint32_t enable_debug: 1;
1837 		uint32_t enable_offload_flip: 1;
1838 		uint32_t enable_visual_confirm: 1;
1839 		uint32_t allow_delay_check_mode: 2;
1840 		uint32_t reserved: 24;
1841 	} bits;
1842 	uint32_t all;
1843 };
1844 
1845 struct dmub_cmd_fams2_global_config {
1846 	uint32_t max_allow_delay_us; // max delay to assert allow from uclk change begin
1847 	uint32_t lock_wait_time_us; // time to forecast acquisition of lock
1848 	uint32_t num_streams;
1849 	union dmub_fams2_global_feature_config features;
1850 	uint32_t recovery_timeout_us;
1851 	uint32_t hwfq_flip_programming_delay_us;
1852 };
1853 
1854 union dmub_cmd_fams2_config {
1855 	struct dmub_cmd_fams2_global_config global;
1856 	struct dmub_fams2_stream_static_state stream;
1857 };
1858 
1859 /**
1860  * DMUB rb command definition for FAMS2 (merged SubVP, FPO, Legacy)
1861  */
1862 struct dmub_rb_cmd_fams2 {
1863 	struct dmub_cmd_header header;
1864 	union dmub_cmd_fams2_config config;
1865 };
1866 
1867 /**
1868  * enum dmub_cmd_idle_opt_type - Idle optimization command type.
1869  */
1870 enum dmub_cmd_idle_opt_type {
1871 	/**
1872 	 * DCN hardware restore.
1873 	 */
1874 	DMUB_CMD__IDLE_OPT_DCN_RESTORE = 0,
1875 
1876 	/**
1877 	 * DCN hardware save.
1878 	 */
1879 	DMUB_CMD__IDLE_OPT_DCN_SAVE_INIT = 1,
1880 
1881 	/**
1882 	 * DCN hardware notify idle.
1883 	 */
1884 	DMUB_CMD__IDLE_OPT_DCN_NOTIFY_IDLE = 2,
1885 
1886 	/**
1887 	 * DCN hardware notify power state.
1888 	 */
1889 	DMUB_CMD__IDLE_OPT_SET_DC_POWER_STATE = 3,
1890 };
1891 
1892 /**
1893  * struct dmub_rb_cmd_idle_opt_dcn_restore - DCN restore command data.
1894  */
1895 struct dmub_rb_cmd_idle_opt_dcn_restore {
1896 	struct dmub_cmd_header header; /**< header */
1897 };
1898 
1899 /**
1900  * struct dmub_dcn_notify_idle_cntl_data - Data passed to FW in a DMUB_CMD__IDLE_OPT_DCN_NOTIFY_IDLE command.
1901  */
1902 struct dmub_dcn_notify_idle_cntl_data {
1903 	uint8_t driver_idle;
1904 	uint8_t skip_otg_disable;
1905 	uint8_t reserved[58];
1906 };
1907 
1908 /**
1909  * struct dmub_rb_cmd_idle_opt_dcn_notify_idle - Data passed to FW in a DMUB_CMD__IDLE_OPT_DCN_NOTIFY_IDLE command.
1910  */
1911 struct dmub_rb_cmd_idle_opt_dcn_notify_idle {
1912 	struct dmub_cmd_header header; /**< header */
1913 	struct dmub_dcn_notify_idle_cntl_data cntl_data;
1914 };
1915 
1916 /**
1917  * enum dmub_idle_opt_dc_power_state - DC power states.
1918  */
1919 enum dmub_idle_opt_dc_power_state {
1920 	DMUB_IDLE_OPT_DC_POWER_STATE_UNKNOWN = 0,
1921 	DMUB_IDLE_OPT_DC_POWER_STATE_D0 = 1,
1922 	DMUB_IDLE_OPT_DC_POWER_STATE_D1 = 2,
1923 	DMUB_IDLE_OPT_DC_POWER_STATE_D2 = 4,
1924 	DMUB_IDLE_OPT_DC_POWER_STATE_D3 = 8,
1925 };
1926 
1927 /**
1928  * struct dmub_idle_opt_set_dc_power_state_data - Data passed to FW in a DMUB_CMD__IDLE_OPT_SET_DC_POWER_STATE command.
1929  */
1930 struct dmub_idle_opt_set_dc_power_state_data {
1931 	uint8_t power_state; /**< power state */
1932 	uint8_t pad[3]; /**< padding */
1933 };
1934 
1935 /**
1936  * struct dmub_rb_cmd_idle_opt_set_dc_power_state - Data passed to FW in a DMUB_CMD__IDLE_OPT_SET_DC_POWER_STATE command.
1937  */
1938 struct dmub_rb_cmd_idle_opt_set_dc_power_state {
1939 	struct dmub_cmd_header header; /**< header */
1940 	struct dmub_idle_opt_set_dc_power_state_data data;
1941 };
1942 
1943 /**
1944  * struct dmub_clocks - Clock update notification.
1945  */
1946 struct dmub_clocks {
1947 	uint32_t dispclk_khz; /**< dispclk kHz */
1948 	uint32_t dppclk_khz; /**< dppclk kHz */
1949 	uint32_t dcfclk_khz; /**< dcfclk kHz */
1950 	uint32_t dcfclk_deep_sleep_khz; /**< dcfclk deep sleep kHz */
1951 };
1952 
1953 /**
1954  * enum dmub_cmd_clk_mgr_type - Clock manager commands.
1955  */
1956 enum dmub_cmd_clk_mgr_type {
1957 	/**
1958 	 * Notify DMCUB of clock update.
1959 	 */
1960 	DMUB_CMD__CLK_MGR_NOTIFY_CLOCKS = 0,
1961 };
1962 
1963 /**
1964  * struct dmub_rb_cmd_clk_mgr_notify_clocks - Clock update notification.
1965  */
1966 struct dmub_rb_cmd_clk_mgr_notify_clocks {
1967 	struct dmub_cmd_header header; /**< header */
1968 	struct dmub_clocks clocks; /**< clock data */
1969 };
1970 
1971 /**
1972  * struct dmub_cmd_digx_encoder_control_data - Encoder control data.
1973  */
1974 struct dmub_cmd_digx_encoder_control_data {
1975 	union dig_encoder_control_parameters_v1_5 dig; /**< payload */
1976 };
1977 
1978 /**
1979  * struct dmub_rb_cmd_digx_encoder_control - Encoder control command.
1980  */
1981 struct dmub_rb_cmd_digx_encoder_control {
1982 	struct dmub_cmd_header header;  /**< header */
1983 	struct dmub_cmd_digx_encoder_control_data encoder_control; /**< payload */
1984 };
1985 
1986 /**
1987  * struct dmub_cmd_set_pixel_clock_data - Set pixel clock data.
1988  */
1989 struct dmub_cmd_set_pixel_clock_data {
1990 	struct set_pixel_clock_parameter_v1_7 clk; /**< payload */
1991 };
1992 
1993 /**
1994  * struct dmub_cmd_set_pixel_clock_data - Set pixel clock command.
1995  */
1996 struct dmub_rb_cmd_set_pixel_clock {
1997 	struct dmub_cmd_header header; /**< header */
1998 	struct dmub_cmd_set_pixel_clock_data pixel_clock; /**< payload */
1999 };
2000 
2001 /**
2002  * struct dmub_cmd_enable_disp_power_gating_data - Display power gating.
2003  */
2004 struct dmub_cmd_enable_disp_power_gating_data {
2005 	struct enable_disp_power_gating_parameters_v2_1 pwr; /**< payload */
2006 };
2007 
2008 /**
2009  * struct dmub_rb_cmd_enable_disp_power_gating - Display power command.
2010  */
2011 struct dmub_rb_cmd_enable_disp_power_gating {
2012 	struct dmub_cmd_header header; /**< header */
2013 	struct dmub_cmd_enable_disp_power_gating_data power_gating;  /**< payload */
2014 };
2015 
2016 /**
2017  * struct dmub_dig_transmitter_control_data_v1_7 - Transmitter control.
2018  */
2019 struct dmub_dig_transmitter_control_data_v1_7 {
2020 	uint8_t phyid; /**< 0=UNIPHYA, 1=UNIPHYB, 2=UNIPHYC, 3=UNIPHYD, 4=UNIPHYE, 5=UNIPHYF */
2021 	uint8_t action; /**< Defined as ATOM_TRANSMITER_ACTION_xxx */
2022 	union {
2023 		uint8_t digmode; /**< enum atom_encode_mode_def */
2024 		uint8_t dplaneset; /**< DP voltage swing and pre-emphasis value, "DP_LANE_SET__xDB_y_zV" */
2025 	} mode_laneset;
2026 	uint8_t lanenum; /**< Number of lanes */
2027 	union {
2028 		uint32_t symclk_10khz; /**< Symbol Clock in 10Khz */
2029 	} symclk_units;
2030 	uint8_t hpdsel; /**< =1: HPD1, =2: HPD2, ..., =6: HPD6, =0: HPD is not assigned */
2031 	uint8_t digfe_sel; /**< DIG front-end selection, bit0 means DIG0 FE is enabled */
2032 	uint8_t connobj_id; /**< Connector Object Id defined in ObjectId.h */
2033 	uint8_t HPO_instance; /**< HPO instance (0: inst0, 1: inst1) */
2034 	uint8_t reserved1; /**< For future use */
2035 	uint8_t reserved2[3]; /**< For future use */
2036 	uint32_t reserved3[11]; /**< For future use */
2037 };
2038 
2039 /**
2040  * union dmub_cmd_dig1_transmitter_control_data - Transmitter control data.
2041  */
2042 union dmub_cmd_dig1_transmitter_control_data {
2043 	struct dig_transmitter_control_parameters_v1_6 dig; /**< payload */
2044 	struct dmub_dig_transmitter_control_data_v1_7 dig_v1_7;  /**< payload 1.7 */
2045 };
2046 
2047 /**
2048  * struct dmub_rb_cmd_dig1_transmitter_control - Transmitter control command.
2049  */
2050 struct dmub_rb_cmd_dig1_transmitter_control {
2051 	struct dmub_cmd_header header; /**< header */
2052 	union dmub_cmd_dig1_transmitter_control_data transmitter_control; /**< payload */
2053 };
2054 
2055 /**
2056  * struct dmub_rb_cmd_domain_control_data - Data for DOMAIN power control
2057  */
2058 struct dmub_rb_cmd_domain_control_data {
2059 	uint8_t inst : 6; /**< DOMAIN instance to control */
2060 	uint8_t power_gate : 1; /**< 1=power gate, 0=power up */
2061 	uint8_t reserved[3]; /**< Reserved for future use */
2062 };
2063 
2064 /**
2065  * struct dmub_rb_cmd_domain_control - Controls DOMAIN power gating
2066  */
2067 struct dmub_rb_cmd_domain_control {
2068 	struct dmub_cmd_header header; /**< header */
2069 	struct dmub_rb_cmd_domain_control_data data; /**< payload */
2070 };
2071 
2072 /**
2073  * DPIA tunnel command parameters.
2074  */
2075 struct dmub_cmd_dig_dpia_control_data {
2076 	uint8_t enc_id;         /** 0 = ENGINE_ID_DIGA, ... */
2077 	uint8_t action;         /** ATOM_TRANSMITER_ACTION_DISABLE/ENABLE/SETUP_VSEMPH */
2078 	union {
2079 		uint8_t digmode;    /** enum atom_encode_mode_def */
2080 		uint8_t dplaneset;  /** DP voltage swing and pre-emphasis value */
2081 	} mode_laneset;
2082 	uint8_t lanenum;        /** Lane number 1, 2, 4, 8 */
2083 	uint32_t symclk_10khz;  /** Symbol Clock in 10Khz */
2084 	uint8_t hpdsel;         /** =0: HPD is not assigned */
2085 	uint8_t digfe_sel;      /** DIG stream( front-end ) selection, bit0 - DIG0 FE */
2086 	uint8_t dpia_id;        /** Index of DPIA */
2087 	uint8_t fec_rdy : 1;
2088 	uint8_t reserved : 7;
2089 	uint32_t reserved1;
2090 };
2091 
2092 /**
2093  * DMUB command for DPIA tunnel control.
2094  */
2095 struct dmub_rb_cmd_dig1_dpia_control {
2096 	struct dmub_cmd_header header;
2097 	struct dmub_cmd_dig_dpia_control_data dpia_control;
2098 };
2099 
2100 /**
2101  * SET_CONFIG Command Payload
2102  */
2103 struct set_config_cmd_payload {
2104 	uint8_t msg_type; /* set config message type */
2105 	uint8_t msg_data; /* set config message data */
2106 };
2107 
2108 /**
2109  * Data passed from driver to FW in a DMUB_CMD__DPIA_SET_CONFIG_ACCESS command.
2110  */
2111 struct dmub_cmd_set_config_control_data {
2112 	struct set_config_cmd_payload cmd_pkt;
2113 	uint8_t instance; /* DPIA instance */
2114 	uint8_t immed_status; /* Immediate status returned in case of error */
2115 };
2116 
2117 /**
2118  * DMUB command structure for SET_CONFIG command.
2119  */
2120 struct dmub_rb_cmd_set_config_access {
2121 	struct dmub_cmd_header header; /* header */
2122 	struct dmub_cmd_set_config_control_data set_config_control; /* set config data */
2123 };
2124 
2125 /**
2126  * Data passed from driver to FW in a DMUB_CMD__DPIA_MST_ALLOC_SLOTS command.
2127  */
2128 struct dmub_cmd_mst_alloc_slots_control_data {
2129 	uint8_t mst_alloc_slots; /* mst slots to be allotted */
2130 	uint8_t instance; /* DPIA instance */
2131 	uint8_t immed_status; /* Immediate status returned as there is no outbox msg posted */
2132 	uint8_t mst_slots_in_use; /* returns slots in use for error cases */
2133 };
2134 
2135 /**
2136  * DMUB command structure for SET_ command.
2137  */
2138 struct dmub_rb_cmd_set_mst_alloc_slots {
2139 	struct dmub_cmd_header header; /* header */
2140 	struct dmub_cmd_mst_alloc_slots_control_data mst_slots_control; /* mst slots control */
2141 };
2142 
2143 /**
2144  * Data passed from driver to FW in a DMUB_CMD__SET_TPS_NOTIFICATION command.
2145  */
2146 struct dmub_cmd_tps_notification_data {
2147 	uint8_t instance; /* DPIA instance */
2148 	uint8_t tps; /* requested training pattern */
2149 	uint8_t reserved1;
2150 	uint8_t reserved2;
2151 };
2152 
2153 /**
2154  * DMUB command structure for SET_TPS_NOTIFICATION command.
2155  */
2156 struct dmub_rb_cmd_set_tps_notification {
2157 	struct dmub_cmd_header header; /* header */
2158 	struct dmub_cmd_tps_notification_data tps_notification; /* set tps_notification data */
2159 };
2160 
2161 /**
2162  * DMUB command structure for DPIA HPD int enable control.
2163  */
2164 struct dmub_rb_cmd_dpia_hpd_int_enable {
2165 	struct dmub_cmd_header header; /* header */
2166 	uint32_t enable; /* dpia hpd interrupt enable */
2167 };
2168 
2169 /**
2170  * struct dmub_rb_cmd_dpphy_init - DPPHY init.
2171  */
2172 struct dmub_rb_cmd_dpphy_init {
2173 	struct dmub_cmd_header header; /**< header */
2174 	uint8_t reserved[60]; /**< reserved bits */
2175 };
2176 
2177 /**
2178  * enum dp_aux_request_action - DP AUX request command listing.
2179  *
2180  * 4 AUX request command bits are shifted to high nibble.
2181  */
2182 enum dp_aux_request_action {
2183 	/** I2C-over-AUX write request */
2184 	DP_AUX_REQ_ACTION_I2C_WRITE		= 0x00,
2185 	/** I2C-over-AUX read request */
2186 	DP_AUX_REQ_ACTION_I2C_READ		= 0x10,
2187 	/** I2C-over-AUX write status request */
2188 	DP_AUX_REQ_ACTION_I2C_STATUS_REQ	= 0x20,
2189 	/** I2C-over-AUX write request with MOT=1 */
2190 	DP_AUX_REQ_ACTION_I2C_WRITE_MOT		= 0x40,
2191 	/** I2C-over-AUX read request with MOT=1 */
2192 	DP_AUX_REQ_ACTION_I2C_READ_MOT		= 0x50,
2193 	/** I2C-over-AUX write status request with MOT=1 */
2194 	DP_AUX_REQ_ACTION_I2C_STATUS_REQ_MOT	= 0x60,
2195 	/** Native AUX write request */
2196 	DP_AUX_REQ_ACTION_DPCD_WRITE		= 0x80,
2197 	/** Native AUX read request */
2198 	DP_AUX_REQ_ACTION_DPCD_READ		= 0x90
2199 };
2200 
2201 /**
2202  * enum aux_return_code_type - DP AUX process return code listing.
2203  */
2204 enum aux_return_code_type {
2205 	/** AUX process succeeded */
2206 	AUX_RET_SUCCESS = 0,
2207 	/** AUX process failed with unknown reason */
2208 	AUX_RET_ERROR_UNKNOWN,
2209 	/** AUX process completed with invalid reply */
2210 	AUX_RET_ERROR_INVALID_REPLY,
2211 	/** AUX process timed out */
2212 	AUX_RET_ERROR_TIMEOUT,
2213 	/** HPD was low during AUX process */
2214 	AUX_RET_ERROR_HPD_DISCON,
2215 	/** Failed to acquire AUX engine */
2216 	AUX_RET_ERROR_ENGINE_ACQUIRE,
2217 	/** AUX request not supported */
2218 	AUX_RET_ERROR_INVALID_OPERATION,
2219 	/** AUX process not available */
2220 	AUX_RET_ERROR_PROTOCOL_ERROR,
2221 };
2222 
2223 /**
2224  * enum aux_channel_type - DP AUX channel type listing.
2225  */
2226 enum aux_channel_type {
2227 	/** AUX thru Legacy DP AUX */
2228 	AUX_CHANNEL_LEGACY_DDC,
2229 	/** AUX thru DPIA DP tunneling */
2230 	AUX_CHANNEL_DPIA
2231 };
2232 
2233 /**
2234  * struct aux_transaction_parameters - DP AUX request transaction data
2235  */
2236 struct aux_transaction_parameters {
2237 	uint8_t is_i2c_over_aux; /**< 0=native AUX, 1=I2C-over-AUX */
2238 	uint8_t action; /**< enum dp_aux_request_action */
2239 	uint8_t length; /**< DP AUX request data length */
2240 	uint8_t reserved; /**< For future use */
2241 	uint32_t address; /**< DP AUX address */
2242 	uint8_t data[16]; /**< DP AUX write data */
2243 };
2244 
2245 /**
2246  * Data passed from driver to FW in a DMUB_CMD__DP_AUX_ACCESS command.
2247  */
2248 struct dmub_cmd_dp_aux_control_data {
2249 	uint8_t instance; /**< AUX instance or DPIA instance */
2250 	uint8_t manual_acq_rel_enable; /**< manual control for acquiring or releasing AUX channel */
2251 	uint8_t sw_crc_enabled; /**< Use software CRC for tunneling packet instead of hardware CRC */
2252 	uint8_t reserved0; /**< For future use */
2253 	uint16_t timeout; /**< timeout time in us */
2254 	uint16_t reserved1; /**< For future use */
2255 	enum aux_channel_type type; /**< enum aux_channel_type */
2256 	struct aux_transaction_parameters dpaux; /**< struct aux_transaction_parameters */
2257 };
2258 
2259 /**
2260  * Definition of a DMUB_CMD__DP_AUX_ACCESS command.
2261  */
2262 struct dmub_rb_cmd_dp_aux_access {
2263 	/**
2264 	 * Command header.
2265 	 */
2266 	struct dmub_cmd_header header;
2267 	/**
2268 	 * Data passed from driver to FW in a DMUB_CMD__DP_AUX_ACCESS command.
2269 	 */
2270 	struct dmub_cmd_dp_aux_control_data aux_control;
2271 };
2272 
2273 /**
2274  * Definition of a DMUB_CMD__OUTBOX1_ENABLE command.
2275  */
2276 struct dmub_rb_cmd_outbox1_enable {
2277 	/**
2278 	 * Command header.
2279 	 */
2280 	struct dmub_cmd_header header;
2281 	/**
2282 	 *  enable: 0x0 -> disable outbox1 notification (default value)
2283 	 *			0x1 -> enable outbox1 notification
2284 	 */
2285 	uint32_t enable;
2286 };
2287 
2288 /* DP AUX Reply command - OutBox Cmd */
2289 /**
2290  * Data passed to driver from FW in a DMUB_OUT_CMD__DP_AUX_REPLY command.
2291  */
2292 struct aux_reply_data {
2293 	/**
2294 	 * Aux cmd
2295 	 */
2296 	uint8_t command;
2297 	/**
2298 	 * Aux reply data length (max: 16 bytes)
2299 	 */
2300 	uint8_t length;
2301 	/**
2302 	 * Alignment only
2303 	 */
2304 	uint8_t pad[2];
2305 	/**
2306 	 * Aux reply data
2307 	 */
2308 	uint8_t data[16];
2309 };
2310 
2311 /**
2312  * Control Data passed to driver from FW in a DMUB_OUT_CMD__DP_AUX_REPLY command.
2313  */
2314 struct aux_reply_control_data {
2315 	/**
2316 	 * Reserved for future use
2317 	 */
2318 	uint32_t handle;
2319 	/**
2320 	 * Aux Instance
2321 	 */
2322 	uint8_t instance;
2323 	/**
2324 	 * Aux transaction result: definition in enum aux_return_code_type
2325 	 */
2326 	uint8_t result;
2327 	/**
2328 	 * Alignment only
2329 	 */
2330 	uint16_t pad;
2331 };
2332 
2333 /**
2334  * Definition of a DMUB_OUT_CMD__DP_AUX_REPLY command.
2335  */
2336 struct dmub_rb_cmd_dp_aux_reply {
2337 	/**
2338 	 * Command header.
2339 	 */
2340 	struct dmub_cmd_header header;
2341 	/**
2342 	 * Control Data passed to driver from FW in a DMUB_OUT_CMD__DP_AUX_REPLY command.
2343 	 */
2344 	struct aux_reply_control_data control;
2345 	/**
2346 	 * Data passed to driver from FW in a DMUB_OUT_CMD__DP_AUX_REPLY command.
2347 	 */
2348 	struct aux_reply_data reply_data;
2349 };
2350 
2351 /* DP HPD Notify command - OutBox Cmd */
2352 /**
2353  * DP HPD Type
2354  */
2355 enum dp_hpd_type {
2356 	/**
2357 	 * Normal DP HPD
2358 	 */
2359 	DP_HPD = 0,
2360 	/**
2361 	 * DP HPD short pulse
2362 	 */
2363 	DP_IRQ
2364 };
2365 
2366 /**
2367  * DP HPD Status
2368  */
2369 enum dp_hpd_status {
2370 	/**
2371 	 * DP_HPD status low
2372 	 */
2373 	DP_HPD_UNPLUG = 0,
2374 	/**
2375 	 * DP_HPD status high
2376 	 */
2377 	DP_HPD_PLUG
2378 };
2379 
2380 /**
2381  * Data passed to driver from FW in a DMUB_OUT_CMD__DP_HPD_NOTIFY command.
2382  */
2383 struct dp_hpd_data {
2384 	/**
2385 	 * DP HPD instance
2386 	 */
2387 	uint8_t instance;
2388 	/**
2389 	 * HPD type
2390 	 */
2391 	uint8_t hpd_type;
2392 	/**
2393 	 * HPD status: only for type: DP_HPD to indicate status
2394 	 */
2395 	uint8_t hpd_status;
2396 	/**
2397 	 * Alignment only
2398 	 */
2399 	uint8_t pad;
2400 };
2401 
2402 /**
2403  * Definition of a DMUB_OUT_CMD__DP_HPD_NOTIFY command.
2404  */
2405 struct dmub_rb_cmd_dp_hpd_notify {
2406 	/**
2407 	 * Command header.
2408 	 */
2409 	struct dmub_cmd_header header;
2410 	/**
2411 	 * Data passed to driver from FW in a DMUB_OUT_CMD__DP_HPD_NOTIFY command.
2412 	 */
2413 	struct dp_hpd_data hpd_data;
2414 };
2415 
2416 /**
2417  * Definition of a SET_CONFIG reply from DPOA.
2418  */
2419 enum set_config_status {
2420 	SET_CONFIG_PENDING = 0,
2421 	SET_CONFIG_ACK_RECEIVED,
2422 	SET_CONFIG_RX_TIMEOUT,
2423 	SET_CONFIG_UNKNOWN_ERROR,
2424 };
2425 
2426 /**
2427  * Definition of a set_config reply
2428  */
2429 struct set_config_reply_control_data {
2430 	uint8_t instance; /* DPIA Instance */
2431 	uint8_t status; /* Set Config reply */
2432 	uint16_t pad; /* Alignment */
2433 };
2434 
2435 /**
2436  * Definition of a DMUB_OUT_CMD__SET_CONFIG_REPLY command.
2437  */
2438 struct dmub_rb_cmd_dp_set_config_reply {
2439 	struct dmub_cmd_header header;
2440 	struct set_config_reply_control_data set_config_reply_control;
2441 };
2442 
2443 /**
2444  * Definition of a DPIA notification header
2445  */
2446 struct dpia_notification_header {
2447 	uint8_t instance; /**< DPIA Instance */
2448 	uint8_t reserved[3];
2449 	enum dmub_cmd_dpia_notification_type type; /**< DPIA notification type */
2450 };
2451 
2452 /**
2453  * Definition of the common data struct of DPIA notification
2454  */
2455 struct dpia_notification_common {
2456 	uint8_t cmd_buffer[DMUB_RB_CMD_SIZE - sizeof(struct dmub_cmd_header)
2457 								- sizeof(struct dpia_notification_header)];
2458 };
2459 
2460 /**
2461  * Definition of a DPIA notification data
2462  */
2463 struct dpia_bw_allocation_notify_data {
2464 	union {
2465 		struct {
2466 			uint16_t cm_bw_alloc_support: 1; /**< USB4 CM BW Allocation mode support */
2467 			uint16_t bw_request_failed: 1; /**< BW_Request_Failed */
2468 			uint16_t bw_request_succeeded: 1; /**< BW_Request_Succeeded */
2469 			uint16_t est_bw_changed: 1; /**< Estimated_BW changed */
2470 			uint16_t bw_alloc_cap_changed: 1; /**< BW_Allocation_Capabiity_Changed */
2471 			uint16_t reserved: 11; /**< Reserved */
2472 		} bits;
2473 
2474 		uint16_t flags;
2475 	};
2476 
2477 	uint8_t cm_id; /**< CM ID */
2478 	uint8_t group_id; /**< Group ID */
2479 	uint8_t granularity; /**< BW Allocation Granularity */
2480 	uint8_t estimated_bw; /**< Estimated_BW */
2481 	uint8_t allocated_bw; /**< Allocated_BW */
2482 	uint8_t reserved;
2483 };
2484 
2485 /**
2486  * union dpia_notify_data_type - DPIA Notification in Outbox command
2487  */
2488 union dpia_notification_data {
2489 	/**
2490 	 * DPIA Notification for common data struct
2491 	 */
2492 	struct dpia_notification_common common_data;
2493 
2494 	/**
2495 	 * DPIA Notification for DP BW Allocation support
2496 	 */
2497 	struct dpia_bw_allocation_notify_data dpia_bw_alloc;
2498 };
2499 
2500 /**
2501  * Definition of a DPIA notification payload
2502  */
2503 struct dpia_notification_payload {
2504 	struct dpia_notification_header header;
2505 	union dpia_notification_data data; /**< DPIA notification payload data */
2506 };
2507 
2508 /**
2509  * Definition of a DMUB_OUT_CMD__DPIA_NOTIFICATION command.
2510  */
2511 struct dmub_rb_cmd_dpia_notification {
2512 	struct dmub_cmd_header header; /**< DPIA notification header */
2513 	struct dpia_notification_payload payload; /**< DPIA notification payload */
2514 };
2515 
2516 /**
2517  * Data passed from driver to FW in a DMUB_CMD__QUERY_HPD_STATE command.
2518  */
2519 struct dmub_cmd_hpd_state_query_data {
2520 	uint8_t instance; /**< HPD instance or DPIA instance */
2521 	uint8_t result; /**< For returning HPD state */
2522 	uint16_t pad; /** < Alignment */
2523 	enum aux_channel_type ch_type; /**< enum aux_channel_type */
2524 	enum aux_return_code_type status; /**< for returning the status of command */
2525 };
2526 
2527 /**
2528  * Definition of a DMUB_CMD__QUERY_HPD_STATE command.
2529  */
2530 struct dmub_rb_cmd_query_hpd_state {
2531 	/**
2532 	 * Command header.
2533 	 */
2534 	struct dmub_cmd_header header;
2535 	/**
2536 	 * Data passed from driver to FW in a DMUB_CMD__QUERY_HPD_STATE command.
2537 	 */
2538 	struct dmub_cmd_hpd_state_query_data data;
2539 };
2540 
2541 /**
2542  * struct dmub_rb_cmd_hpd_sense_notify - HPD sense notification data.
2543  */
2544 struct dmub_rb_cmd_hpd_sense_notify_data {
2545 	uint32_t old_hpd_sense_mask; /**< Old HPD sense mask */
2546 	uint32_t new_hpd_sense_mask; /**< New HPD sense mask */
2547 };
2548 
2549 /**
2550  * struct dmub_rb_cmd_hpd_sense_notify - DMUB_OUT_CMD__HPD_SENSE_NOTIFY command.
2551  */
2552 struct dmub_rb_cmd_hpd_sense_notify {
2553 	struct dmub_cmd_header header; /**< header */
2554 	struct dmub_rb_cmd_hpd_sense_notify_data data; /**< payload */
2555 };
2556 
2557 /*
2558  * Command IDs should be treated as stable ABI.
2559  * Do not reuse or modify IDs.
2560  */
2561 
2562 /**
2563  * PSR command sub-types.
2564  */
2565 enum dmub_cmd_psr_type {
2566 	/**
2567 	 * Set PSR version support.
2568 	 */
2569 	DMUB_CMD__PSR_SET_VERSION		= 0,
2570 	/**
2571 	 * Copy driver-calculated parameters to PSR state.
2572 	 */
2573 	DMUB_CMD__PSR_COPY_SETTINGS		= 1,
2574 	/**
2575 	 * Enable PSR.
2576 	 */
2577 	DMUB_CMD__PSR_ENABLE			= 2,
2578 
2579 	/**
2580 	 * Disable PSR.
2581 	 */
2582 	DMUB_CMD__PSR_DISABLE			= 3,
2583 
2584 	/**
2585 	 * Set PSR level.
2586 	 * PSR level is a 16-bit value dicated by driver that
2587 	 * will enable/disable different functionality.
2588 	 */
2589 	DMUB_CMD__PSR_SET_LEVEL			= 4,
2590 
2591 	/**
2592 	 * Forces PSR enabled until an explicit PSR disable call.
2593 	 */
2594 	DMUB_CMD__PSR_FORCE_STATIC		= 5,
2595 	/**
2596 	 * Set vtotal in psr active for FreeSync PSR.
2597 	 */
2598 	DMUB_CMD__SET_SINK_VTOTAL_IN_PSR_ACTIVE = 6,
2599 	/**
2600 	 * Set PSR power option
2601 	 */
2602 	DMUB_CMD__SET_PSR_POWER_OPT = 7,
2603 };
2604 
2605 /**
2606  * Different PSR residency modes.
2607  * Different modes change the definition of PSR residency.
2608  */
2609 enum psr_residency_mode {
2610 	PSR_RESIDENCY_MODE_PHY = 0,
2611 	PSR_RESIDENCY_MODE_ALPM,
2612 	PSR_RESIDENCY_MODE_ENABLEMENT_PERIOD,
2613 	/* Do not add below. */
2614 	PSR_RESIDENCY_MODE_LAST_ELEMENT,
2615 };
2616 
2617 enum dmub_cmd_fams_type {
2618 	DMUB_CMD__FAMS_SETUP_FW_CTRL	= 0,
2619 	DMUB_CMD__FAMS_DRR_UPDATE		= 1,
2620 	DMUB_CMD__HANDLE_SUBVP_CMD	= 2, // specifically for SubVP cmd
2621 	/**
2622 	 * For SubVP set manual trigger in FW because it
2623 	 * triggers DRR_UPDATE_PENDING which SubVP relies
2624 	 * on (for any SubVP cases that use a DRR display)
2625 	 */
2626 	DMUB_CMD__FAMS_SET_MANUAL_TRIGGER = 3,
2627 	DMUB_CMD__FAMS2_CONFIG = 4,
2628 	DMUB_CMD__FAMS2_DRR_UPDATE = 5,
2629 	DMUB_CMD__FAMS2_FLIP = 6,
2630 };
2631 
2632 /**
2633  * PSR versions.
2634  */
2635 enum psr_version {
2636 	/**
2637 	 * PSR version 1.
2638 	 */
2639 	PSR_VERSION_1				= 0,
2640 	/**
2641 	 * Freesync PSR SU.
2642 	 */
2643 	PSR_VERSION_SU_1			= 1,
2644 	/**
2645 	 * PSR not supported.
2646 	 */
2647 	PSR_VERSION_UNSUPPORTED			= 0xFF,	// psr_version field is only 8 bits wide
2648 };
2649 
2650 /**
2651  * PHY Link rate for DP.
2652  */
2653 enum phy_link_rate {
2654 	/**
2655 	 * not supported.
2656 	 */
2657 	PHY_RATE_UNKNOWN = 0,
2658 	/**
2659 	 * Rate_1 (RBR)	- 1.62 Gbps/Lane
2660 	 */
2661 	PHY_RATE_162 = 1,
2662 	/**
2663 	 * Rate_2		- 2.16 Gbps/Lane
2664 	 */
2665 	PHY_RATE_216 = 2,
2666 	/**
2667 	 * Rate_3		- 2.43 Gbps/Lane
2668 	 */
2669 	PHY_RATE_243 = 3,
2670 	/**
2671 	 * Rate_4 (HBR)	- 2.70 Gbps/Lane
2672 	 */
2673 	PHY_RATE_270 = 4,
2674 	/**
2675 	 * Rate_5 (RBR2)- 3.24 Gbps/Lane
2676 	 */
2677 	PHY_RATE_324 = 5,
2678 	/**
2679 	 * Rate_6		- 4.32 Gbps/Lane
2680 	 */
2681 	PHY_RATE_432 = 6,
2682 	/**
2683 	 * Rate_7 (HBR2)- 5.40 Gbps/Lane
2684 	 */
2685 	PHY_RATE_540 = 7,
2686 	/**
2687 	 * Rate_8 (HBR3)- 8.10 Gbps/Lane
2688 	 */
2689 	PHY_RATE_810 = 8,
2690 	/**
2691 	 * UHBR10 - 10.0 Gbps/Lane
2692 	 */
2693 	PHY_RATE_1000 = 9,
2694 	/**
2695 	 * UHBR13.5 - 13.5 Gbps/Lane
2696 	 */
2697 	PHY_RATE_1350 = 10,
2698 	/**
2699 	 * UHBR10 - 20.0 Gbps/Lane
2700 	 */
2701 	PHY_RATE_2000 = 11,
2702 
2703 	PHY_RATE_675 = 12,
2704 	/**
2705 	 * Rate 12 - 6.75 Gbps/Lane
2706 	 */
2707 };
2708 
2709 /**
2710  * enum dmub_phy_fsm_state - PHY FSM states.
2711  * PHY FSM state to transit to during PSR enable/disable.
2712  */
2713 enum dmub_phy_fsm_state {
2714 	DMUB_PHY_FSM_POWER_UP_DEFAULT = 0,
2715 	DMUB_PHY_FSM_RESET,
2716 	DMUB_PHY_FSM_RESET_RELEASED,
2717 	DMUB_PHY_FSM_SRAM_LOAD_DONE,
2718 	DMUB_PHY_FSM_INITIALIZED,
2719 	DMUB_PHY_FSM_CALIBRATED,
2720 	DMUB_PHY_FSM_CALIBRATED_LP,
2721 	DMUB_PHY_FSM_CALIBRATED_PG,
2722 	DMUB_PHY_FSM_POWER_DOWN,
2723 	DMUB_PHY_FSM_PLL_EN,
2724 	DMUB_PHY_FSM_TX_EN,
2725 	DMUB_PHY_FSM_TX_EN_TEST_MODE,
2726 	DMUB_PHY_FSM_FAST_LP,
2727 	DMUB_PHY_FSM_P2_PLL_OFF_CPM,
2728 	DMUB_PHY_FSM_P2_PLL_OFF_PG,
2729 	DMUB_PHY_FSM_P2_PLL_OFF,
2730 	DMUB_PHY_FSM_P2_PLL_ON,
2731 };
2732 
2733 /**
2734  * Data passed from driver to FW in a DMUB_CMD__PSR_COPY_SETTINGS command.
2735  */
2736 struct dmub_cmd_psr_copy_settings_data {
2737 	/**
2738 	 * Flags that can be set by driver to change some PSR behaviour.
2739 	 */
2740 	union dmub_psr_debug_flags debug;
2741 	/**
2742 	 * 16-bit value dicated by driver that will enable/disable different functionality.
2743 	 */
2744 	uint16_t psr_level;
2745 	/**
2746 	 * DPP HW instance.
2747 	 */
2748 	uint8_t dpp_inst;
2749 	/**
2750 	 * MPCC HW instance.
2751 	 * Not used in dmub fw,
2752 	 * dmub fw will get active opp by reading odm registers.
2753 	 */
2754 	uint8_t mpcc_inst;
2755 	/**
2756 	 * OPP HW instance.
2757 	 * Not used in dmub fw,
2758 	 * dmub fw will get active opp by reading odm registers.
2759 	 */
2760 	uint8_t opp_inst;
2761 	/**
2762 	 * OTG HW instance.
2763 	 */
2764 	uint8_t otg_inst;
2765 	/**
2766 	 * DIG FE HW instance.
2767 	 */
2768 	uint8_t digfe_inst;
2769 	/**
2770 	 * DIG BE HW instance.
2771 	 */
2772 	uint8_t digbe_inst;
2773 	/**
2774 	 * DP PHY HW instance.
2775 	 */
2776 	uint8_t dpphy_inst;
2777 	/**
2778 	 * AUX HW instance.
2779 	 */
2780 	uint8_t aux_inst;
2781 	/**
2782 	 * Determines if SMU optimzations are enabled/disabled.
2783 	 */
2784 	uint8_t smu_optimizations_en;
2785 	/**
2786 	 * Unused.
2787 	 * TODO: Remove.
2788 	 */
2789 	uint8_t frame_delay;
2790 	/**
2791 	 * If RFB setup time is greater than the total VBLANK time,
2792 	 * it is not possible for the sink to capture the video frame
2793 	 * in the same frame the SDP is sent. In this case,
2794 	 * the frame capture indication bit should be set and an extra
2795 	 * static frame should be transmitted to the sink.
2796 	 */
2797 	uint8_t frame_cap_ind;
2798 	/**
2799 	 * Granularity of Y offset supported by sink.
2800 	 */
2801 	uint8_t su_y_granularity;
2802 	/**
2803 	 * Indicates whether sink should start capturing
2804 	 * immediately following active scan line,
2805 	 * or starting with the 2nd active scan line.
2806 	 */
2807 	uint8_t line_capture_indication;
2808 	/**
2809 	 * Multi-display optimizations are implemented on certain ASICs.
2810 	 */
2811 	uint8_t multi_disp_optimizations_en;
2812 	/**
2813 	 * The last possible line SDP may be transmitted without violating
2814 	 * the RFB setup time or entering the active video frame.
2815 	 */
2816 	uint16_t init_sdp_deadline;
2817 	/**
2818 	 * @ rate_control_caps : Indicate FreeSync PSR Sink Capabilities
2819 	 */
2820 	uint8_t rate_control_caps ;
2821 	/*
2822 	 * Force PSRSU always doing full frame update
2823 	 */
2824 	uint8_t force_ffu_mode;
2825 	/**
2826 	 * Length of each horizontal line in us.
2827 	 */
2828 	uint32_t line_time_in_us;
2829 	/**
2830 	 * FEC enable status in driver
2831 	 */
2832 	uint8_t fec_enable_status;
2833 	/**
2834 	 * FEC re-enable delay when PSR exit.
2835 	 * unit is 100us, range form 0~255(0xFF).
2836 	 */
2837 	uint8_t fec_enable_delay_in100us;
2838 	/**
2839 	 * PSR control version.
2840 	 */
2841 	uint8_t cmd_version;
2842 	/**
2843 	 * Panel Instance.
2844 	 * Panel instance to identify which psr_state to use
2845 	 * Currently the support is only for 0 or 1
2846 	 */
2847 	uint8_t panel_inst;
2848 	/*
2849 	 * DSC enable status in driver
2850 	 */
2851 	uint8_t dsc_enable_status;
2852 	/*
2853 	 * Use FSM state for PSR power up/down
2854 	 */
2855 	uint8_t use_phy_fsm;
2856 	/**
2857 	 * frame delay for frame re-lock
2858 	 */
2859 	uint8_t relock_delay_frame_cnt;
2860 	/**
2861 	 * esd recovery indicate.
2862 	 */
2863 	uint8_t esd_recovery;
2864 	/**
2865 	 * DSC Slice height.
2866 	 */
2867 	uint16_t dsc_slice_height;
2868 	/**
2869 	 * Some panels request main link off before xth vertical line
2870 	 */
2871 	uint16_t poweroff_before_vertical_line;
2872 	/**
2873 	 * Some panels cannot handle idle pattern during PSR entry.
2874 	 * To power down phy before disable stream to avoid sending
2875 	 * idle pattern.
2876 	 */
2877 	uint8_t power_down_phy_before_disable_stream;
2878 };
2879 
2880 /**
2881  * Definition of a DMUB_CMD__PSR_COPY_SETTINGS command.
2882  */
2883 struct dmub_rb_cmd_psr_copy_settings {
2884 	/**
2885 	 * Command header.
2886 	 */
2887 	struct dmub_cmd_header header;
2888 	/**
2889 	 * Data passed from driver to FW in a DMUB_CMD__PSR_COPY_SETTINGS command.
2890 	 */
2891 	struct dmub_cmd_psr_copy_settings_data psr_copy_settings_data;
2892 };
2893 
2894 /**
2895  * Data passed from driver to FW in a DMUB_CMD__PSR_SET_LEVEL command.
2896  */
2897 struct dmub_cmd_psr_set_level_data {
2898 	/**
2899 	 * 16-bit value dicated by driver that will enable/disable different functionality.
2900 	 */
2901 	uint16_t psr_level;
2902 	/**
2903 	 * PSR control version.
2904 	 */
2905 	uint8_t cmd_version;
2906 	/**
2907 	 * Panel Instance.
2908 	 * Panel instance to identify which psr_state to use
2909 	 * Currently the support is only for 0 or 1
2910 	 */
2911 	uint8_t panel_inst;
2912 };
2913 
2914 /**
2915  * Definition of a DMUB_CMD__PSR_SET_LEVEL command.
2916  */
2917 struct dmub_rb_cmd_psr_set_level {
2918 	/**
2919 	 * Command header.
2920 	 */
2921 	struct dmub_cmd_header header;
2922 	/**
2923 	 * Definition of a DMUB_CMD__PSR_SET_LEVEL command.
2924 	 */
2925 	struct dmub_cmd_psr_set_level_data psr_set_level_data;
2926 };
2927 
2928 struct dmub_rb_cmd_psr_enable_data {
2929 	/**
2930 	 * PSR control version.
2931 	 */
2932 	uint8_t cmd_version;
2933 	/**
2934 	 * Panel Instance.
2935 	 * Panel instance to identify which psr_state to use
2936 	 * Currently the support is only for 0 or 1
2937 	 */
2938 	uint8_t panel_inst;
2939 	/**
2940 	 * Phy state to enter.
2941 	 * Values to use are defined in dmub_phy_fsm_state
2942 	 */
2943 	uint8_t phy_fsm_state;
2944 	/**
2945 	 * Phy rate for DP - RBR/HBR/HBR2/HBR3.
2946 	 * Set this using enum phy_link_rate.
2947 	 * This does not support HDMI/DP2 for now.
2948 	 */
2949 	uint8_t phy_rate;
2950 };
2951 
2952 /**
2953  * Definition of a DMUB_CMD__PSR_ENABLE command.
2954  * PSR enable/disable is controlled using the sub_type.
2955  */
2956 struct dmub_rb_cmd_psr_enable {
2957 	/**
2958 	 * Command header.
2959 	 */
2960 	struct dmub_cmd_header header;
2961 
2962 	struct dmub_rb_cmd_psr_enable_data data;
2963 };
2964 
2965 /**
2966  * Data passed from driver to FW in a DMUB_CMD__PSR_SET_VERSION command.
2967  */
2968 struct dmub_cmd_psr_set_version_data {
2969 	/**
2970 	 * PSR version that FW should implement.
2971 	 */
2972 	enum psr_version version;
2973 	/**
2974 	 * PSR control version.
2975 	 */
2976 	uint8_t cmd_version;
2977 	/**
2978 	 * Panel Instance.
2979 	 * Panel instance to identify which psr_state to use
2980 	 * Currently the support is only for 0 or 1
2981 	 */
2982 	uint8_t panel_inst;
2983 	/**
2984 	 * Explicit padding to 4 byte boundary.
2985 	 */
2986 	uint8_t pad[2];
2987 };
2988 
2989 /**
2990  * Definition of a DMUB_CMD__PSR_SET_VERSION command.
2991  */
2992 struct dmub_rb_cmd_psr_set_version {
2993 	/**
2994 	 * Command header.
2995 	 */
2996 	struct dmub_cmd_header header;
2997 	/**
2998 	 * Data passed from driver to FW in a DMUB_CMD__PSR_SET_VERSION command.
2999 	 */
3000 	struct dmub_cmd_psr_set_version_data psr_set_version_data;
3001 };
3002 
3003 struct dmub_cmd_psr_force_static_data {
3004 	/**
3005 	 * PSR control version.
3006 	 */
3007 	uint8_t cmd_version;
3008 	/**
3009 	 * Panel Instance.
3010 	 * Panel instance to identify which psr_state to use
3011 	 * Currently the support is only for 0 or 1
3012 	 */
3013 	uint8_t panel_inst;
3014 	/**
3015 	 * Explicit padding to 4 byte boundary.
3016 	 */
3017 	uint8_t pad[2];
3018 };
3019 
3020 /**
3021  * Definition of a DMUB_CMD__PSR_FORCE_STATIC command.
3022  */
3023 struct dmub_rb_cmd_psr_force_static {
3024 	/**
3025 	 * Command header.
3026 	 */
3027 	struct dmub_cmd_header header;
3028 	/**
3029 	 * Data passed from driver to FW in a DMUB_CMD__PSR_FORCE_STATIC command.
3030 	 */
3031 	struct dmub_cmd_psr_force_static_data psr_force_static_data;
3032 };
3033 
3034 /**
3035  * PSR SU debug flags.
3036  */
3037 union dmub_psr_su_debug_flags {
3038 	/**
3039 	 * PSR SU debug flags.
3040 	 */
3041 	struct {
3042 		/**
3043 		 * Update dirty rect in SW only.
3044 		 */
3045 		uint8_t update_dirty_rect_only : 1;
3046 		/**
3047 		 * Reset the cursor/plane state before processing the call.
3048 		 */
3049 		uint8_t reset_state : 1;
3050 	} bitfields;
3051 
3052 	/**
3053 	 * Union for debug flags.
3054 	 */
3055 	uint32_t u32All;
3056 };
3057 
3058 /**
3059  * Data passed from driver to FW in a DMUB_CMD__UPDATE_DIRTY_RECT command.
3060  * This triggers a selective update for PSR SU.
3061  */
3062 struct dmub_cmd_update_dirty_rect_data {
3063 	/**
3064 	 * Dirty rects from OS.
3065 	 */
3066 	struct dmub_rect src_dirty_rects[DMUB_MAX_DIRTY_RECTS];
3067 	/**
3068 	 * PSR SU debug flags.
3069 	 */
3070 	union dmub_psr_su_debug_flags debug_flags;
3071 	/**
3072 	 * OTG HW instance.
3073 	 */
3074 	uint8_t pipe_idx;
3075 	/**
3076 	 * Number of dirty rects.
3077 	 */
3078 	uint8_t dirty_rect_count;
3079 	/**
3080 	 * PSR control version.
3081 	 */
3082 	uint8_t cmd_version;
3083 	/**
3084 	 * Panel Instance.
3085 	 * Panel instance to identify which psr_state to use
3086 	 * Currently the support is only for 0 or 1
3087 	 */
3088 	uint8_t panel_inst;
3089 };
3090 
3091 /**
3092  * Definition of a DMUB_CMD__UPDATE_DIRTY_RECT command.
3093  */
3094 struct dmub_rb_cmd_update_dirty_rect {
3095 	/**
3096 	 * Command header.
3097 	 */
3098 	struct dmub_cmd_header header;
3099 	/**
3100 	 * Data passed from driver to FW in a DMUB_CMD__UPDATE_DIRTY_RECT command.
3101 	 */
3102 	struct dmub_cmd_update_dirty_rect_data update_dirty_rect_data;
3103 };
3104 
3105 /**
3106  * Data passed from driver to FW in a DMUB_CMD__UPDATE_CURSOR_INFO command.
3107  */
3108 union dmub_reg_cursor_control_cfg {
3109 	struct {
3110 		uint32_t     cur_enable: 1;
3111 		uint32_t         reser0: 3;
3112 		uint32_t cur_2x_magnify: 1;
3113 		uint32_t         reser1: 3;
3114 		uint32_t           mode: 3;
3115 		uint32_t         reser2: 5;
3116 		uint32_t          pitch: 2;
3117 		uint32_t         reser3: 6;
3118 		uint32_t line_per_chunk: 5;
3119 		uint32_t         reser4: 3;
3120 	} bits;
3121 	uint32_t raw;
3122 };
3123 struct dmub_cursor_position_cache_hubp {
3124 	union dmub_reg_cursor_control_cfg cur_ctl;
3125 	union dmub_reg_position_cfg {
3126 		struct {
3127 			uint32_t cur_x_pos: 16;
3128 			uint32_t cur_y_pos: 16;
3129 		} bits;
3130 		uint32_t raw;
3131 	} position;
3132 	union dmub_reg_hot_spot_cfg {
3133 		struct {
3134 			uint32_t hot_x: 16;
3135 			uint32_t hot_y: 16;
3136 		} bits;
3137 		uint32_t raw;
3138 	} hot_spot;
3139 	union dmub_reg_dst_offset_cfg {
3140 		struct {
3141 			uint32_t dst_x_offset: 13;
3142 			uint32_t reserved: 19;
3143 		} bits;
3144 		uint32_t raw;
3145 	} dst_offset;
3146 };
3147 
3148 union dmub_reg_cur0_control_cfg {
3149 	struct {
3150 		uint32_t     cur0_enable: 1;
3151 		uint32_t  expansion_mode: 1;
3152 		uint32_t          reser0: 1;
3153 		uint32_t     cur0_rom_en: 1;
3154 		uint32_t            mode: 3;
3155 		uint32_t        reserved: 25;
3156 	} bits;
3157 	uint32_t raw;
3158 };
3159 struct dmub_cursor_position_cache_dpp {
3160 	union dmub_reg_cur0_control_cfg cur0_ctl;
3161 };
3162 struct dmub_cursor_position_cfg {
3163 	struct  dmub_cursor_position_cache_hubp pHubp;
3164 	struct  dmub_cursor_position_cache_dpp  pDpp;
3165 	uint8_t pipe_idx;
3166 	/*
3167 	 * Padding is required. To be 4 Bytes Aligned.
3168 	 */
3169 	uint8_t padding[3];
3170 };
3171 
3172 struct dmub_cursor_attribute_cache_hubp {
3173 	uint32_t SURFACE_ADDR_HIGH;
3174 	uint32_t SURFACE_ADDR;
3175 	union    dmub_reg_cursor_control_cfg  cur_ctl;
3176 	union    dmub_reg_cursor_size_cfg {
3177 		struct {
3178 			uint32_t width: 16;
3179 			uint32_t height: 16;
3180 		} bits;
3181 		uint32_t raw;
3182 	} size;
3183 	union    dmub_reg_cursor_settings_cfg {
3184 		struct {
3185 			uint32_t     dst_y_offset: 8;
3186 			uint32_t chunk_hdl_adjust: 2;
3187 			uint32_t         reserved: 22;
3188 		} bits;
3189 		uint32_t raw;
3190 	} settings;
3191 };
3192 struct dmub_cursor_attribute_cache_dpp {
3193 	union dmub_reg_cur0_control_cfg cur0_ctl;
3194 };
3195 struct dmub_cursor_attributes_cfg {
3196 	struct  dmub_cursor_attribute_cache_hubp aHubp;
3197 	struct  dmub_cursor_attribute_cache_dpp  aDpp;
3198 };
3199 
3200 struct dmub_cmd_update_cursor_payload0 {
3201 	/**
3202 	 * Cursor dirty rects.
3203 	 */
3204 	struct dmub_rect cursor_rect;
3205 	/**
3206 	 * PSR SU debug flags.
3207 	 */
3208 	union dmub_psr_su_debug_flags debug_flags;
3209 	/**
3210 	 * Cursor enable/disable.
3211 	 */
3212 	uint8_t enable;
3213 	/**
3214 	 * OTG HW instance.
3215 	 */
3216 	uint8_t pipe_idx;
3217 	/**
3218 	 * PSR control version.
3219 	 */
3220 	uint8_t cmd_version;
3221 	/**
3222 	 * Panel Instance.
3223 	 * Panel instance to identify which psr_state to use
3224 	 * Currently the support is only for 0 or 1
3225 	 */
3226 	uint8_t panel_inst;
3227 	/**
3228 	 * Cursor Position Register.
3229 	 * Registers contains Hubp & Dpp modules
3230 	 */
3231 	struct dmub_cursor_position_cfg position_cfg;
3232 };
3233 
3234 struct dmub_cmd_update_cursor_payload1 {
3235 	struct dmub_cursor_attributes_cfg attribute_cfg;
3236 };
3237 
3238 union dmub_cmd_update_cursor_info_data {
3239 	struct dmub_cmd_update_cursor_payload0 payload0;
3240 	struct dmub_cmd_update_cursor_payload1 payload1;
3241 };
3242 /**
3243  * Definition of a DMUB_CMD__UPDATE_CURSOR_INFO command.
3244  */
3245 struct dmub_rb_cmd_update_cursor_info {
3246 	/**
3247 	 * Command header.
3248 	 */
3249 	struct dmub_cmd_header header;
3250 	/**
3251 	 * Data passed from driver to FW in a DMUB_CMD__UPDATE_CURSOR_INFO command.
3252 	 */
3253 	union dmub_cmd_update_cursor_info_data update_cursor_info_data;
3254 };
3255 
3256 /**
3257  * Data passed from driver to FW in a DMUB_CMD__SET_SINK_VTOTAL_IN_PSR_ACTIVE command.
3258  */
3259 struct dmub_cmd_psr_set_vtotal_data {
3260 	/**
3261 	 * 16-bit value dicated by driver that indicates the vtotal in PSR active requirement when screen idle..
3262 	 */
3263 	uint16_t psr_vtotal_idle;
3264 	/**
3265 	 * PSR control version.
3266 	 */
3267 	uint8_t cmd_version;
3268 	/**
3269 	 * Panel Instance.
3270 	 * Panel instance to identify which psr_state to use
3271 	 * Currently the support is only for 0 or 1
3272 	 */
3273 	uint8_t panel_inst;
3274 	/*
3275 	 * 16-bit value dicated by driver that indicates the vtotal in PSR active requirement when doing SU/FFU.
3276 	 */
3277 	uint16_t psr_vtotal_su;
3278 	/**
3279 	 * Explicit padding to 4 byte boundary.
3280 	 */
3281 	uint8_t pad2[2];
3282 };
3283 
3284 /**
3285  * Definition of a DMUB_CMD__SET_SINK_VTOTAL_IN_PSR_ACTIVE command.
3286  */
3287 struct dmub_rb_cmd_psr_set_vtotal {
3288 	/**
3289 	 * Command header.
3290 	 */
3291 	struct dmub_cmd_header header;
3292 	/**
3293 	 * Definition of a DMUB_CMD__SET_SINK_VTOTAL_IN_PSR_ACTIVE command.
3294 	 */
3295 	struct dmub_cmd_psr_set_vtotal_data psr_set_vtotal_data;
3296 };
3297 
3298 /**
3299  * Data passed from driver to FW in a DMUB_CMD__SET_PSR_POWER_OPT command.
3300  */
3301 struct dmub_cmd_psr_set_power_opt_data {
3302 	/**
3303 	 * PSR control version.
3304 	 */
3305 	uint8_t cmd_version;
3306 	/**
3307 	 * Panel Instance.
3308 	 * Panel instance to identify which psr_state to use
3309 	 * Currently the support is only for 0 or 1
3310 	 */
3311 	uint8_t panel_inst;
3312 	/**
3313 	 * Explicit padding to 4 byte boundary.
3314 	 */
3315 	uint8_t pad[2];
3316 	/**
3317 	 * PSR power option
3318 	 */
3319 	uint32_t power_opt;
3320 };
3321 
3322 /**
3323  * Definition of a DMUB_CMD__SET_PSR_POWER_OPT command.
3324  */
3325 struct dmub_rb_cmd_psr_set_power_opt {
3326 	/**
3327 	 * Command header.
3328 	 */
3329 	struct dmub_cmd_header header;
3330 	/**
3331 	 * Definition of a DMUB_CMD__SET_PSR_POWER_OPT command.
3332 	 */
3333 	struct dmub_cmd_psr_set_power_opt_data psr_set_power_opt_data;
3334 };
3335 
3336 /**
3337  * Definition of Replay Residency GPINT command.
3338  * Bit[0] - Residency mode for Revision 0
3339  * Bit[1] - Enable/Disable state
3340  * Bit[2-3] - Revision number
3341  * Bit[4-7] - Residency mode for Revision 1
3342  * Bit[8] - Panel instance
3343  * Bit[9-15] - Reserved
3344  */
3345 
3346 enum pr_residency_mode {
3347 	PR_RESIDENCY_MODE_PHY = 0x0,
3348 	PR_RESIDENCY_MODE_ALPM,
3349 	PR_RESIDENCY_MODE_IPS2,
3350 	PR_RESIDENCY_MODE_FRAME_CNT,
3351 	PR_RESIDENCY_MODE_ENABLEMENT_PERIOD,
3352 };
3353 
3354 #define REPLAY_RESIDENCY_MODE_SHIFT            (0)
3355 #define REPLAY_RESIDENCY_ENABLE_SHIFT          (1)
3356 #define REPLAY_RESIDENCY_REVISION_SHIFT        (2)
3357 #define REPLAY_RESIDENCY_MODE2_SHIFT           (4)
3358 
3359 #define REPLAY_RESIDENCY_MODE_MASK             (0x1 << REPLAY_RESIDENCY_MODE_SHIFT)
3360 # define REPLAY_RESIDENCY_FIELD_MODE_PHY       (0x0 << REPLAY_RESIDENCY_MODE_SHIFT)
3361 # define REPLAY_RESIDENCY_FIELD_MODE_ALPM      (0x1 << REPLAY_RESIDENCY_MODE_SHIFT)
3362 
3363 #define REPLAY_RESIDENCY_MODE2_MASK            (0xF << REPLAY_RESIDENCY_MODE2_SHIFT)
3364 # define REPLAY_RESIDENCY_FIELD_MODE2_IPS      (0x1 << REPLAY_RESIDENCY_MODE2_SHIFT)
3365 # define REPLAY_RESIDENCY_FIELD_MODE2_FRAME_CNT    (0x2 << REPLAY_RESIDENCY_MODE2_SHIFT)
3366 # define REPLAY_RESIDENCY_FIELD_MODE2_EN_PERIOD	(0x3 << REPLAY_RESIDENCY_MODE2_SHIFT)
3367 
3368 #define REPLAY_RESIDENCY_ENABLE_MASK           (0x1 << REPLAY_RESIDENCY_ENABLE_SHIFT)
3369 # define REPLAY_RESIDENCY_DISABLE              (0x0 << REPLAY_RESIDENCY_ENABLE_SHIFT)
3370 # define REPLAY_RESIDENCY_ENABLE               (0x1 << REPLAY_RESIDENCY_ENABLE_SHIFT)
3371 
3372 #define REPLAY_RESIDENCY_REVISION_MASK         (0x3 << REPLAY_RESIDENCY_REVISION_SHIFT)
3373 # define REPLAY_RESIDENCY_REVISION_0           (0x0 << REPLAY_RESIDENCY_REVISION_SHIFT)
3374 # define REPLAY_RESIDENCY_REVISION_1           (0x1 << REPLAY_RESIDENCY_REVISION_SHIFT)
3375 
3376 /**
3377  * Definition of a replay_state.
3378  */
3379 enum replay_state {
3380 	REPLAY_STATE_0			= 0x0,
3381 	REPLAY_STATE_1			= 0x10,
3382 	REPLAY_STATE_1A			= 0x11,
3383 	REPLAY_STATE_2			= 0x20,
3384 	REPLAY_STATE_2A			= 0x21,
3385 	REPLAY_STATE_3			= 0x30,
3386 	REPLAY_STATE_3INIT		= 0x31,
3387 	REPLAY_STATE_4			= 0x40,
3388 	REPLAY_STATE_4A			= 0x41,
3389 	REPLAY_STATE_4B			= 0x42,
3390 	REPLAY_STATE_4C			= 0x43,
3391 	REPLAY_STATE_4D			= 0x44,
3392 	REPLAY_STATE_4E			= 0x45,
3393 	REPLAY_STATE_4B_LOCKED		= 0x4A,
3394 	REPLAY_STATE_4C_UNLOCKED	= 0x4B,
3395 	REPLAY_STATE_5			= 0x50,
3396 	REPLAY_STATE_5A			= 0x51,
3397 	REPLAY_STATE_5B			= 0x52,
3398 	REPLAY_STATE_5A_LOCKED		= 0x5A,
3399 	REPLAY_STATE_5B_UNLOCKED	= 0x5B,
3400 	REPLAY_STATE_6			= 0x60,
3401 	REPLAY_STATE_6A			= 0x61,
3402 	REPLAY_STATE_6B			= 0x62,
3403 	REPLAY_STATE_INVALID		= 0xFF,
3404 };
3405 
3406 /**
3407  * Replay command sub-types.
3408  */
3409 enum dmub_cmd_replay_type {
3410 	/**
3411 	 * Copy driver-calculated parameters to REPLAY state.
3412 	 */
3413 	DMUB_CMD__REPLAY_COPY_SETTINGS		= 0,
3414 	/**
3415 	 * Enable REPLAY.
3416 	 */
3417 	DMUB_CMD__REPLAY_ENABLE			= 1,
3418 	/**
3419 	 * Set Replay power option.
3420 	 */
3421 	DMUB_CMD__SET_REPLAY_POWER_OPT		= 2,
3422 	/**
3423 	 * Set coasting vtotal.
3424 	 */
3425 	DMUB_CMD__REPLAY_SET_COASTING_VTOTAL	= 3,
3426 	/**
3427 	 * Set power opt and coasting vtotal.
3428 	 */
3429 	DMUB_CMD__REPLAY_SET_POWER_OPT_AND_COASTING_VTOTAL	= 4,
3430 	/**
3431 	 * Set disabled iiming sync.
3432 	 */
3433 	DMUB_CMD__REPLAY_SET_TIMING_SYNC_SUPPORTED	= 5,
3434 	/**
3435 	 * Set Residency Frameupdate Timer.
3436 	 */
3437 	DMUB_CMD__REPLAY_SET_RESIDENCY_FRAMEUPDATE_TIMER = 6,
3438 	/**
3439 	 * Set pseudo vtotal
3440 	 */
3441 	DMUB_CMD__REPLAY_SET_PSEUDO_VTOTAL = 7,
3442 	/**
3443 	 * Set adaptive sync sdp enabled
3444 	 */
3445 	DMUB_CMD__REPLAY_DISABLED_ADAPTIVE_SYNC_SDP = 8,
3446 	/**
3447 	 * Set Replay General command.
3448 	 */
3449 	DMUB_CMD__REPLAY_SET_GENERAL_CMD = 16,
3450 };
3451 
3452 /**
3453  * Replay general command sub-types.
3454  */
3455 enum dmub_cmd_replay_general_subtype {
3456 	REPLAY_GENERAL_CMD_NOT_SUPPORTED = -1,
3457 	/**
3458 	 * TODO: For backward compatible, allow new command only.
3459 	 * REPLAY_GENERAL_CMD_SET_TIMING_SYNC_SUPPORTED,
3460 	 * REPLAY_GENERAL_CMD_SET_RESIDENCY_FRAMEUPDATE_TIMER,
3461 	 * REPLAY_GENERAL_CMD_SET_PSEUDO_VTOTAL,
3462 	 */
3463 	REPLAY_GENERAL_CMD_DISABLED_ADAPTIVE_SYNC_SDP,
3464 	REPLAY_GENERAL_CMD_DISABLED_DESYNC_ERROR_DETECTION,
3465 };
3466 
3467 /**
3468  * Data passed from driver to FW in a DMUB_CMD__REPLAY_COPY_SETTINGS command.
3469  */
3470 struct dmub_cmd_replay_copy_settings_data {
3471 	/**
3472 	 * Flags that can be set by driver to change some replay behaviour.
3473 	 */
3474 	union replay_debug_flags debug;
3475 
3476 	/**
3477 	 * @flags: Flags used to determine feature functionality.
3478 	 */
3479 	union replay_hw_flags flags;
3480 
3481 	/**
3482 	 * DPP HW instance.
3483 	 */
3484 	uint8_t dpp_inst;
3485 	/**
3486 	 * OTG HW instance.
3487 	 */
3488 	uint8_t otg_inst;
3489 	/**
3490 	 * DIG FE HW instance.
3491 	 */
3492 	uint8_t digfe_inst;
3493 	/**
3494 	 * DIG BE HW instance.
3495 	 */
3496 	uint8_t digbe_inst;
3497 	/**
3498 	 * AUX HW instance.
3499 	 */
3500 	uint8_t aux_inst;
3501 	/**
3502 	 * Panel Instance.
3503 	 * Panel isntance to identify which psr_state to use
3504 	 * Currently the support is only for 0 or 1
3505 	 */
3506 	uint8_t panel_inst;
3507 	/**
3508 	 * @pixel_deviation_per_line: Indicate the maximum pixel deviation per line compare
3509 	 * to Source timing when Sink maintains coasting vtotal during the Replay normal sleep mode
3510 	 */
3511 	uint8_t pixel_deviation_per_line;
3512 	/**
3513 	 * @max_deviation_line: The max number of deviation line that can keep the timing
3514 	 * synchronized between the Source and Sink during Replay normal sleep mode.
3515 	 */
3516 	uint8_t max_deviation_line;
3517 	/**
3518 	 * Length of each horizontal line in ns.
3519 	 */
3520 	uint32_t line_time_in_ns;
3521 	/**
3522 	 * PHY instance.
3523 	 */
3524 	uint8_t dpphy_inst;
3525 	/**
3526 	 * Determines if SMU optimzations are enabled/disabled.
3527 	 */
3528 	uint8_t smu_optimizations_en;
3529 	/**
3530 	 * Determines if timing sync are enabled/disabled.
3531 	 */
3532 	uint8_t replay_timing_sync_supported;
3533 	/*
3534 	 * Use FSM state for Replay power up/down
3535 	 */
3536 	uint8_t use_phy_fsm;
3537 };
3538 
3539 /**
3540  * Definition of a DMUB_CMD__REPLAY_COPY_SETTINGS command.
3541  */
3542 struct dmub_rb_cmd_replay_copy_settings {
3543 	/**
3544 	 * Command header.
3545 	 */
3546 	struct dmub_cmd_header header;
3547 	/**
3548 	 * Data passed from driver to FW in a DMUB_CMD__REPLAY_COPY_SETTINGS command.
3549 	 */
3550 	struct dmub_cmd_replay_copy_settings_data replay_copy_settings_data;
3551 };
3552 
3553 /**
3554  * Replay disable / enable state for dmub_rb_cmd_replay_enable_data.enable
3555  */
3556 enum replay_enable {
3557 	/**
3558 	 * Disable REPLAY.
3559 	 */
3560 	REPLAY_DISABLE				= 0,
3561 	/**
3562 	 * Enable REPLAY.
3563 	 */
3564 	REPLAY_ENABLE				= 1,
3565 };
3566 
3567 /**
3568  * Data passed from driver to FW in a DMUB_CMD__REPLAY_ENABLE command.
3569  */
3570 struct dmub_rb_cmd_replay_enable_data {
3571 	/**
3572 	 * Replay enable or disable.
3573 	 */
3574 	uint8_t enable;
3575 	/**
3576 	 * Panel Instance.
3577 	 * Panel isntance to identify which replay_state to use
3578 	 * Currently the support is only for 0 or 1
3579 	 */
3580 	uint8_t panel_inst;
3581 	/**
3582 	 * Phy state to enter.
3583 	 * Values to use are defined in dmub_phy_fsm_state
3584 	 */
3585 	uint8_t phy_fsm_state;
3586 	/**
3587 	 * Phy rate for DP - RBR/HBR/HBR2/HBR3.
3588 	 * Set this using enum phy_link_rate.
3589 	 * This does not support HDMI/DP2 for now.
3590 	 */
3591 	uint8_t phy_rate;
3592 };
3593 
3594 /**
3595  * Definition of a DMUB_CMD__REPLAY_ENABLE command.
3596  * Replay enable/disable is controlled using action in data.
3597  */
3598 struct dmub_rb_cmd_replay_enable {
3599 	/**
3600 	 * Command header.
3601 	 */
3602 	struct dmub_cmd_header header;
3603 
3604 	struct dmub_rb_cmd_replay_enable_data data;
3605 };
3606 
3607 /**
3608  * Data passed from driver to FW in a DMUB_CMD__SET_REPLAY_POWER_OPT command.
3609  */
3610 struct dmub_cmd_replay_set_power_opt_data {
3611 	/**
3612 	 * Panel Instance.
3613 	 * Panel isntance to identify which replay_state to use
3614 	 * Currently the support is only for 0 or 1
3615 	 */
3616 	uint8_t panel_inst;
3617 	/**
3618 	 * Explicit padding to 4 byte boundary.
3619 	 */
3620 	uint8_t pad[3];
3621 	/**
3622 	 * REPLAY power option
3623 	 */
3624 	uint32_t power_opt;
3625 };
3626 
3627 /**
3628  * Data passed from driver to FW in a DMUB_CMD__REPLAY_SET_TIMING_SYNC_SUPPORTED command.
3629  */
3630 struct dmub_cmd_replay_set_timing_sync_data {
3631 	/**
3632 	 * Panel Instance.
3633 	 * Panel isntance to identify which replay_state to use
3634 	 * Currently the support is only for 0 or 1
3635 	 */
3636 	uint8_t panel_inst;
3637 	/**
3638 	 * REPLAY set_timing_sync
3639 	 */
3640 	uint8_t timing_sync_supported;
3641 	/**
3642 	 * Explicit padding to 4 byte boundary.
3643 	 */
3644 	uint8_t pad[2];
3645 };
3646 
3647 /**
3648  * Data passed from driver to FW in a DMUB_CMD__REPLAY_SET_PSEUDO_VTOTAL command.
3649  */
3650 struct dmub_cmd_replay_set_pseudo_vtotal {
3651 	/**
3652 	 * Panel Instance.
3653 	 * Panel isntance to identify which replay_state to use
3654 	 * Currently the support is only for 0 or 1
3655 	 */
3656 	uint8_t panel_inst;
3657 	/**
3658 	 * Source Vtotal that Replay + IPS + ABM full screen video src vtotal
3659 	 */
3660 	uint16_t vtotal;
3661 	/**
3662 	 * Explicit padding to 4 byte boundary.
3663 	 */
3664 	uint8_t pad;
3665 };
3666 struct dmub_cmd_replay_disabled_adaptive_sync_sdp_data {
3667 	/**
3668 	 * Panel Instance.
3669 	 * Panel isntance to identify which replay_state to use
3670 	 * Currently the support is only for 0 or 1
3671 	 */
3672 	uint8_t panel_inst;
3673 	/**
3674 	 * enabled: set adaptive sync sdp enabled
3675 	 */
3676 	uint8_t force_disabled;
3677 
3678 	uint8_t pad[2];
3679 };
3680 struct dmub_cmd_replay_set_general_cmd_data {
3681 	/**
3682 	 * Panel Instance.
3683 	 * Panel isntance to identify which replay_state to use
3684 	 * Currently the support is only for 0 or 1
3685 	 */
3686 	uint8_t panel_inst;
3687 	/**
3688 	 * subtype: replay general cmd sub type
3689 	 */
3690 	uint8_t subtype;
3691 
3692 	uint8_t pad[2];
3693 	/**
3694 	 * config data with param1 and param2
3695 	 */
3696 	uint32_t param1;
3697 
3698 	uint32_t param2;
3699 };
3700 
3701 /**
3702  * Definition of a DMUB_CMD__SET_REPLAY_POWER_OPT command.
3703  */
3704 struct dmub_rb_cmd_replay_set_power_opt {
3705 	/**
3706 	 * Command header.
3707 	 */
3708 	struct dmub_cmd_header header;
3709 	/**
3710 	 * Definition of a DMUB_CMD__SET_REPLAY_POWER_OPT command.
3711 	 */
3712 	struct dmub_cmd_replay_set_power_opt_data replay_set_power_opt_data;
3713 };
3714 
3715 /**
3716  * Data passed from driver to FW in a DMUB_CMD__REPLAY_SET_COASTING_VTOTAL command.
3717  */
3718 struct dmub_cmd_replay_set_coasting_vtotal_data {
3719 	/**
3720 	 * 16-bit value dicated by driver that indicates the coasting vtotal.
3721 	 */
3722 	uint16_t coasting_vtotal;
3723 	/**
3724 	 * REPLAY control version.
3725 	 */
3726 	uint8_t cmd_version;
3727 	/**
3728 	 * Panel Instance.
3729 	 * Panel isntance to identify which replay_state to use
3730 	 * Currently the support is only for 0 or 1
3731 	 */
3732 	uint8_t panel_inst;
3733 	/**
3734 	 * 16-bit value dicated by driver that indicates the coasting vtotal high byte part.
3735 	 */
3736 	uint16_t coasting_vtotal_high;
3737 	/**
3738 	 * Explicit padding to 4 byte boundary.
3739 	 */
3740 	uint8_t pad[2];
3741 };
3742 
3743 /**
3744  * Definition of a DMUB_CMD__REPLAY_SET_COASTING_VTOTAL command.
3745  */
3746 struct dmub_rb_cmd_replay_set_coasting_vtotal {
3747 	/**
3748 	 * Command header.
3749 	 */
3750 	struct dmub_cmd_header header;
3751 	/**
3752 	 * Definition of a DMUB_CMD__REPLAY_SET_COASTING_VTOTAL command.
3753 	 */
3754 	struct dmub_cmd_replay_set_coasting_vtotal_data replay_set_coasting_vtotal_data;
3755 };
3756 
3757 /**
3758  * Definition of a DMUB_CMD__REPLAY_SET_POWER_OPT_AND_COASTING_VTOTAL command.
3759  */
3760 struct dmub_rb_cmd_replay_set_power_opt_and_coasting_vtotal {
3761 	/**
3762 	 * Command header.
3763 	 */
3764 	struct dmub_cmd_header header;
3765 	/**
3766 	 * Definition of a DMUB_CMD__SET_REPLAY_POWER_OPT command.
3767 	 */
3768 	struct dmub_cmd_replay_set_power_opt_data replay_set_power_opt_data;
3769 	/**
3770 	 * Definition of a DMUB_CMD__REPLAY_SET_COASTING_VTOTAL command.
3771 	 */
3772 	struct dmub_cmd_replay_set_coasting_vtotal_data replay_set_coasting_vtotal_data;
3773 };
3774 
3775 /**
3776  * Definition of a DMUB_CMD__REPLAY_SET_TIMING_SYNC_SUPPORTED command.
3777  */
3778 struct dmub_rb_cmd_replay_set_timing_sync {
3779 	/**
3780 	 * Command header.
3781 	 */
3782 	struct dmub_cmd_header header;
3783 	/**
3784 	 * Definition of DMUB_CMD__REPLAY_SET_TIMING_SYNC_SUPPORTED command.
3785 	 */
3786 	struct dmub_cmd_replay_set_timing_sync_data replay_set_timing_sync_data;
3787 };
3788 
3789 /**
3790  * Definition of a DMUB_CMD__REPLAY_SET_PSEUDO_VTOTAL command.
3791  */
3792 struct dmub_rb_cmd_replay_set_pseudo_vtotal {
3793 	/**
3794 	 * Command header.
3795 	 */
3796 	struct dmub_cmd_header header;
3797 	/**
3798 	 * Definition of DMUB_CMD__REPLAY_SET_PSEUDO_VTOTAL command.
3799 	 */
3800 	struct dmub_cmd_replay_set_pseudo_vtotal data;
3801 };
3802 
3803 /**
3804  * Definition of a DMUB_CMD__REPLAY_DISABLED_ADAPTIVE_SYNC_SDP command.
3805  */
3806 struct dmub_rb_cmd_replay_disabled_adaptive_sync_sdp {
3807 	/**
3808 	 * Command header.
3809 	 */
3810 	struct dmub_cmd_header header;
3811 	/**
3812 	 * Definition of DMUB_CMD__REPLAY_DISABLED_ADAPTIVE_SYNC_SDP command.
3813 	 */
3814 	struct dmub_cmd_replay_disabled_adaptive_sync_sdp_data data;
3815 };
3816 
3817 /**
3818  * Definition of a DMUB_CMD__REPLAY_SET_GENERAL_CMD command.
3819  */
3820 struct dmub_rb_cmd_replay_set_general_cmd {
3821 	/**
3822 	 * Command header.
3823 	 */
3824 	struct dmub_cmd_header header;
3825 	/**
3826 	 * Definition of DMUB_CMD__REPLAY_SET_GENERAL_CMD command.
3827 	 */
3828 	struct dmub_cmd_replay_set_general_cmd_data data;
3829 };
3830 
3831 /**
3832  * Data passed from driver to FW in  DMUB_CMD__REPLAY_SET_RESIDENCY_FRAMEUPDATE_TIMER command.
3833  */
3834 struct dmub_cmd_replay_frameupdate_timer_data {
3835 	/**
3836 	 * Panel Instance.
3837 	 * Panel isntance to identify which replay_state to use
3838 	 * Currently the support is only for 0 or 1
3839 	 */
3840 	uint8_t panel_inst;
3841 	/**
3842 	 * Replay Frameupdate Timer Enable or not
3843 	 */
3844 	uint8_t enable;
3845 	/**
3846 	 * REPLAY force reflash frame update number
3847 	 */
3848 	uint16_t frameupdate_count;
3849 };
3850 /**
3851  * Definition of DMUB_CMD__REPLAY_SET_RESIDENCY_FRAMEUPDATE_TIMER
3852  */
3853 struct dmub_rb_cmd_replay_set_frameupdate_timer {
3854 	/**
3855 	 * Command header.
3856 	 */
3857 	struct dmub_cmd_header header;
3858 	/**
3859 	 * Definition of a DMUB_CMD__SET_REPLAY_POWER_OPT command.
3860 	 */
3861 	struct dmub_cmd_replay_frameupdate_timer_data data;
3862 };
3863 
3864 /**
3865  * Definition union of replay command set
3866  */
3867 union dmub_replay_cmd_set {
3868 	/**
3869 	 * Panel Instance.
3870 	 * Panel isntance to identify which replay_state to use
3871 	 * Currently the support is only for 0 or 1
3872 	 */
3873 	uint8_t panel_inst;
3874 	/**
3875 	 * Definition of DMUB_CMD__REPLAY_SET_TIMING_SYNC_SUPPORTED command data.
3876 	 */
3877 	struct dmub_cmd_replay_set_timing_sync_data sync_data;
3878 	/**
3879 	 * Definition of DMUB_CMD__REPLAY_SET_RESIDENCY_FRAMEUPDATE_TIMER command data.
3880 	 */
3881 	struct dmub_cmd_replay_frameupdate_timer_data timer_data;
3882 	/**
3883 	 * Definition of DMUB_CMD__REPLAY_SET_PSEUDO_VTOTAL command data.
3884 	 */
3885 	struct dmub_cmd_replay_set_pseudo_vtotal pseudo_vtotal_data;
3886 	/**
3887 	 * Definition of DMUB_CMD__REPLAY_DISABLED_ADAPTIVE_SYNC_SDP command data.
3888 	 */
3889 	struct dmub_cmd_replay_disabled_adaptive_sync_sdp_data disabled_adaptive_sync_sdp_data;
3890 	/**
3891 	 * Definition of DMUB_CMD__REPLAY_SET_GENERAL_CMD command data.
3892 	 */
3893 	struct dmub_cmd_replay_set_general_cmd_data set_general_cmd_data;
3894 };
3895 
3896 /**
3897  * Set of HW components that can be locked.
3898  *
3899  * Note: If updating with more HW components, fields
3900  * in dmub_inbox0_cmd_lock_hw must be updated to match.
3901  */
3902 union dmub_hw_lock_flags {
3903 	/**
3904 	 * Set of HW components that can be locked.
3905 	 */
3906 	struct {
3907 		/**
3908 		 * Lock/unlock OTG master update lock.
3909 		 */
3910 		uint8_t lock_pipe   : 1;
3911 		/**
3912 		 * Lock/unlock cursor.
3913 		 */
3914 		uint8_t lock_cursor : 1;
3915 		/**
3916 		 * Lock/unlock global update lock.
3917 		 */
3918 		uint8_t lock_dig    : 1;
3919 		/**
3920 		 * Triple buffer lock requires additional hw programming to usual OTG master lock.
3921 		 */
3922 		uint8_t triple_buffer_lock : 1;
3923 	} bits;
3924 
3925 	/**
3926 	 * Union for HW Lock flags.
3927 	 */
3928 	uint8_t u8All;
3929 };
3930 
3931 /**
3932  * Instances of HW to be locked.
3933  *
3934  * Note: If updating with more HW components, fields
3935  * in dmub_inbox0_cmd_lock_hw must be updated to match.
3936  */
3937 struct dmub_hw_lock_inst_flags {
3938 	/**
3939 	 * OTG HW instance for OTG master update lock.
3940 	 */
3941 	uint8_t otg_inst;
3942 	/**
3943 	 * OPP instance for cursor lock.
3944 	 */
3945 	uint8_t opp_inst;
3946 	/**
3947 	 * OTG HW instance for global update lock.
3948 	 * TODO: Remove, and re-use otg_inst.
3949 	 */
3950 	uint8_t dig_inst;
3951 	/**
3952 	 * Explicit pad to 4 byte boundary.
3953 	 */
3954 	uint8_t pad;
3955 };
3956 
3957 /**
3958  * Clients that can acquire the HW Lock Manager.
3959  *
3960  * Note: If updating with more clients, fields in
3961  * dmub_inbox0_cmd_lock_hw must be updated to match.
3962  */
3963 enum hw_lock_client {
3964 	/**
3965 	 * Driver is the client of HW Lock Manager.
3966 	 */
3967 	HW_LOCK_CLIENT_DRIVER = 0,
3968 	/**
3969 	 * PSR SU is the client of HW Lock Manager.
3970 	 */
3971 	HW_LOCK_CLIENT_PSR_SU		= 1,
3972 	HW_LOCK_CLIENT_SUBVP = 3,
3973 	/**
3974 	 * Replay is the client of HW Lock Manager.
3975 	 */
3976 	HW_LOCK_CLIENT_REPLAY		= 4,
3977 	HW_LOCK_CLIENT_FAMS2 = 5,
3978 	/**
3979 	 * Invalid client.
3980 	 */
3981 	HW_LOCK_CLIENT_INVALID = 0xFFFFFFFF,
3982 };
3983 
3984 /**
3985  * Data passed to HW Lock Mgr in a DMUB_CMD__HW_LOCK command.
3986  */
3987 struct dmub_cmd_lock_hw_data {
3988 	/**
3989 	 * Specifies the client accessing HW Lock Manager.
3990 	 */
3991 	enum hw_lock_client client;
3992 	/**
3993 	 * HW instances to be locked.
3994 	 */
3995 	struct dmub_hw_lock_inst_flags inst_flags;
3996 	/**
3997 	 * Which components to be locked.
3998 	 */
3999 	union dmub_hw_lock_flags hw_locks;
4000 	/**
4001 	 * Specifies lock/unlock.
4002 	 */
4003 	uint8_t lock;
4004 	/**
4005 	 * HW can be unlocked separately from releasing the HW Lock Mgr.
4006 	 * This flag is set if the client wishes to release the object.
4007 	 */
4008 	uint8_t should_release;
4009 	/**
4010 	 * Explicit padding to 4 byte boundary.
4011 	 */
4012 	uint8_t pad;
4013 };
4014 
4015 /**
4016  * Definition of a DMUB_CMD__HW_LOCK command.
4017  * Command is used by driver and FW.
4018  */
4019 struct dmub_rb_cmd_lock_hw {
4020 	/**
4021 	 * Command header.
4022 	 */
4023 	struct dmub_cmd_header header;
4024 	/**
4025 	 * Data passed to HW Lock Mgr in a DMUB_CMD__HW_LOCK command.
4026 	 */
4027 	struct dmub_cmd_lock_hw_data lock_hw_data;
4028 };
4029 
4030 /**
4031  * ABM command sub-types.
4032  */
4033 enum dmub_cmd_abm_type {
4034 	/**
4035 	 * Initialize parameters for ABM algorithm.
4036 	 * Data is passed through an indirect buffer.
4037 	 */
4038 	DMUB_CMD__ABM_INIT_CONFIG	= 0,
4039 	/**
4040 	 * Set OTG and panel HW instance.
4041 	 */
4042 	DMUB_CMD__ABM_SET_PIPE		= 1,
4043 	/**
4044 	 * Set user requested backklight level.
4045 	 */
4046 	DMUB_CMD__ABM_SET_BACKLIGHT	= 2,
4047 	/**
4048 	 * Set ABM operating/aggression level.
4049 	 */
4050 	DMUB_CMD__ABM_SET_LEVEL		= 3,
4051 	/**
4052 	 * Set ambient light level.
4053 	 */
4054 	DMUB_CMD__ABM_SET_AMBIENT_LEVEL	= 4,
4055 	/**
4056 	 * Enable/disable fractional duty cycle for backlight PWM.
4057 	 */
4058 	DMUB_CMD__ABM_SET_PWM_FRAC	= 5,
4059 
4060 	/**
4061 	 * unregister vertical interrupt after steady state is reached
4062 	 */
4063 	DMUB_CMD__ABM_PAUSE	= 6,
4064 
4065 	/**
4066 	 * Save and Restore ABM state. On save we save parameters, and
4067 	 * on restore we update state with passed in data.
4068 	 */
4069 	DMUB_CMD__ABM_SAVE_RESTORE	= 7,
4070 
4071 	/**
4072 	 * Query ABM caps.
4073 	 */
4074 	DMUB_CMD__ABM_QUERY_CAPS	= 8,
4075 
4076 	/**
4077 	 * Set ABM Events
4078 	 */
4079 	DMUB_CMD__ABM_SET_EVENT	= 9,
4080 
4081 	/**
4082 	 * Get the current ACE curve.
4083 	 */
4084 	DMUB_CMD__ABM_GET_ACE_CURVE = 10,
4085 };
4086 
4087 struct abm_ace_curve {
4088 	/**
4089 	 * @offsets: ACE curve offsets.
4090 	 */
4091 	uint32_t offsets[ABM_MAX_NUM_OF_ACE_SEGMENTS];
4092 
4093 	/**
4094 	 * @thresholds: ACE curve thresholds.
4095 	 */
4096 	uint32_t thresholds[ABM_MAX_NUM_OF_ACE_SEGMENTS];
4097 
4098 	/**
4099 	 * @slopes: ACE curve slopes.
4100 	 */
4101 	uint32_t slopes[ABM_MAX_NUM_OF_ACE_SEGMENTS];
4102 };
4103 
4104 struct fixed_pt_format {
4105 	/**
4106 	 * @sign_bit: Indicates whether one bit is reserved for the sign.
4107 	 */
4108 	bool sign_bit;
4109 
4110 	/**
4111 	 * @num_int_bits: Number of bits used for integer part.
4112 	 */
4113 	uint8_t num_int_bits;
4114 
4115 	/**
4116 	 * @num_frac_bits: Number of bits used for fractional part.
4117 	 */
4118 	uint8_t num_frac_bits;
4119 
4120 	/**
4121 	 * @pad: Explicit padding to 4 byte boundary.
4122 	 */
4123 	uint8_t pad;
4124 };
4125 
4126 struct abm_caps {
4127 	/**
4128 	 * @num_hg_bins: Number of histogram bins.
4129 	 */
4130 	uint8_t num_hg_bins;
4131 
4132 	/**
4133 	 * @num_ace_segments: Number of ACE curve segments.
4134 	 */
4135 	uint8_t num_ace_segments;
4136 
4137 	/**
4138 	 * @pad: Explicit padding to 4 byte boundary.
4139 	 */
4140 	uint8_t pad[2];
4141 
4142 	/**
4143 	 * @ace_thresholds_format: Format of the ACE thresholds. If not programmable, it is set to 0.
4144 	 */
4145 	struct fixed_pt_format ace_thresholds_format;
4146 
4147 	/**
4148 	 * @ace_offsets_format: Format of the ACE offsets. If not programmable, it is set to 0.
4149 	 */
4150 	struct fixed_pt_format ace_offsets_format;
4151 
4152 	/**
4153 	 * @ace_slopes_format: Format of the ACE slopes.
4154 	 */
4155 	struct fixed_pt_format ace_slopes_format;
4156 };
4157 
4158 /**
4159  * Parameters for ABM2.4 algorithm. Passed from driver to FW via an indirect buffer.
4160  * Requirements:
4161  *  - Padded explicitly to 32-bit boundary.
4162  *  - Must ensure this structure matches the one on driver-side,
4163  *    otherwise it won't be aligned.
4164  */
4165 struct abm_config_table {
4166 	/**
4167 	 * Gamma curve thresholds, used for crgb conversion.
4168 	 */
4169 	uint16_t crgb_thresh[NUM_POWER_FN_SEGS];                 // 0B
4170 	/**
4171 	 * Gamma curve offsets, used for crgb conversion.
4172 	 */
4173 	uint16_t crgb_offset[NUM_POWER_FN_SEGS];                 // 16B
4174 	/**
4175 	 * Gamma curve slopes, used for crgb conversion.
4176 	 */
4177 	uint16_t crgb_slope[NUM_POWER_FN_SEGS];                  // 32B
4178 	/**
4179 	 * Custom backlight curve thresholds.
4180 	 */
4181 	uint16_t backlight_thresholds[NUM_BL_CURVE_SEGS];        // 48B
4182 	/**
4183 	 * Custom backlight curve offsets.
4184 	 */
4185 	uint16_t backlight_offsets[NUM_BL_CURVE_SEGS];           // 78B
4186 	/**
4187 	 * Ambient light thresholds.
4188 	 */
4189 	uint16_t ambient_thresholds_lux[NUM_AMBI_LEVEL];         // 112B
4190 	/**
4191 	 * Minimum programmable backlight.
4192 	 */
4193 	uint16_t min_abm_backlight;                              // 122B
4194 	/**
4195 	 * Minimum reduction values.
4196 	 */
4197 	uint8_t min_reduction[NUM_AMBI_LEVEL][NUM_AGGR_LEVEL];   // 124B
4198 	/**
4199 	 * Maximum reduction values.
4200 	 */
4201 	uint8_t max_reduction[NUM_AMBI_LEVEL][NUM_AGGR_LEVEL];   // 144B
4202 	/**
4203 	 * Bright positive gain.
4204 	 */
4205 	uint8_t bright_pos_gain[NUM_AMBI_LEVEL][NUM_AGGR_LEVEL]; // 164B
4206 	/**
4207 	 * Dark negative gain.
4208 	 */
4209 	uint8_t dark_pos_gain[NUM_AMBI_LEVEL][NUM_AGGR_LEVEL];   // 184B
4210 	/**
4211 	 * Hybrid factor.
4212 	 */
4213 	uint8_t hybrid_factor[NUM_AGGR_LEVEL];                   // 204B
4214 	/**
4215 	 * Contrast factor.
4216 	 */
4217 	uint8_t contrast_factor[NUM_AGGR_LEVEL];                 // 208B
4218 	/**
4219 	 * Deviation gain.
4220 	 */
4221 	uint8_t deviation_gain[NUM_AGGR_LEVEL];                  // 212B
4222 	/**
4223 	 * Minimum knee.
4224 	 */
4225 	uint8_t min_knee[NUM_AGGR_LEVEL];                        // 216B
4226 	/**
4227 	 * Maximum knee.
4228 	 */
4229 	uint8_t max_knee[NUM_AGGR_LEVEL];                        // 220B
4230 	/**
4231 	 * Unused.
4232 	 */
4233 	uint8_t iir_curve[NUM_AMBI_LEVEL];                       // 224B
4234 	/**
4235 	 * Explicit padding to 4 byte boundary.
4236 	 */
4237 	uint8_t pad3[3];                                         // 229B
4238 	/**
4239 	 * Backlight ramp reduction.
4240 	 */
4241 	uint16_t blRampReduction[NUM_AGGR_LEVEL];                // 232B
4242 	/**
4243 	 * Backlight ramp start.
4244 	 */
4245 	uint16_t blRampStart[NUM_AGGR_LEVEL];                    // 240B
4246 };
4247 
4248 /**
4249  * Data passed from driver to FW in a DMUB_CMD__ABM_SET_PIPE command.
4250  */
4251 struct dmub_cmd_abm_set_pipe_data {
4252 	/**
4253 	 * OTG HW instance.
4254 	 */
4255 	uint8_t otg_inst;
4256 
4257 	/**
4258 	 * Panel Control HW instance.
4259 	 */
4260 	uint8_t panel_inst;
4261 
4262 	/**
4263 	 * Controls how ABM will interpret a set pipe or set level command.
4264 	 */
4265 	uint8_t set_pipe_option;
4266 
4267 	/**
4268 	 * Unused.
4269 	 * TODO: Remove.
4270 	 */
4271 	uint8_t ramping_boundary;
4272 
4273 	/**
4274 	 * PwrSeq HW Instance.
4275 	 */
4276 	uint8_t pwrseq_inst;
4277 
4278 	/**
4279 	 * Explicit padding to 4 byte boundary.
4280 	 */
4281 	uint8_t pad[3];
4282 };
4283 
4284 /**
4285  * Definition of a DMUB_CMD__ABM_SET_PIPE command.
4286  */
4287 struct dmub_rb_cmd_abm_set_pipe {
4288 	/**
4289 	 * Command header.
4290 	 */
4291 	struct dmub_cmd_header header;
4292 
4293 	/**
4294 	 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_PIPE command.
4295 	 */
4296 	struct dmub_cmd_abm_set_pipe_data abm_set_pipe_data;
4297 };
4298 
4299 /**
4300  * Data passed from driver to FW in a DMUB_CMD__ABM_SET_BACKLIGHT command.
4301  */
4302 struct dmub_cmd_abm_set_backlight_data {
4303 	/**
4304 	 * Number of frames to ramp to backlight user level.
4305 	 */
4306 	uint32_t frame_ramp;
4307 
4308 	/**
4309 	 * Requested backlight level from user.
4310 	 */
4311 	uint32_t backlight_user_level;
4312 
4313 	/**
4314 	 * ABM control version.
4315 	 */
4316 	uint8_t version;
4317 
4318 	/**
4319 	 * Panel Control HW instance mask.
4320 	 * Bit 0 is Panel Control HW instance 0.
4321 	 * Bit 1 is Panel Control HW instance 1.
4322 	 */
4323 	uint8_t panel_mask;
4324 
4325 	/**
4326 	 * Explicit padding to 4 byte boundary.
4327 	 */
4328 	uint8_t pad[2];
4329 };
4330 
4331 /**
4332  * Definition of a DMUB_CMD__ABM_SET_BACKLIGHT command.
4333  */
4334 struct dmub_rb_cmd_abm_set_backlight {
4335 	/**
4336 	 * Command header.
4337 	 */
4338 	struct dmub_cmd_header header;
4339 
4340 	/**
4341 	 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_BACKLIGHT command.
4342 	 */
4343 	struct dmub_cmd_abm_set_backlight_data abm_set_backlight_data;
4344 };
4345 
4346 /**
4347  * Data passed from driver to FW in a DMUB_CMD__ABM_SET_LEVEL command.
4348  */
4349 struct dmub_cmd_abm_set_level_data {
4350 	/**
4351 	 * Set current ABM operating/aggression level.
4352 	 */
4353 	uint32_t level;
4354 
4355 	/**
4356 	 * ABM control version.
4357 	 */
4358 	uint8_t version;
4359 
4360 	/**
4361 	 * Panel Control HW instance mask.
4362 	 * Bit 0 is Panel Control HW instance 0.
4363 	 * Bit 1 is Panel Control HW instance 1.
4364 	 */
4365 	uint8_t panel_mask;
4366 
4367 	/**
4368 	 * Explicit padding to 4 byte boundary.
4369 	 */
4370 	uint8_t pad[2];
4371 };
4372 
4373 /**
4374  * Definition of a DMUB_CMD__ABM_SET_LEVEL command.
4375  */
4376 struct dmub_rb_cmd_abm_set_level {
4377 	/**
4378 	 * Command header.
4379 	 */
4380 	struct dmub_cmd_header header;
4381 
4382 	/**
4383 	 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_LEVEL command.
4384 	 */
4385 	struct dmub_cmd_abm_set_level_data abm_set_level_data;
4386 };
4387 
4388 /**
4389  * Data passed from driver to FW in a DMUB_CMD__ABM_SET_AMBIENT_LEVEL command.
4390  */
4391 struct dmub_cmd_abm_set_ambient_level_data {
4392 	/**
4393 	 * Ambient light sensor reading from OS.
4394 	 */
4395 	uint32_t ambient_lux;
4396 
4397 	/**
4398 	 * ABM control version.
4399 	 */
4400 	uint8_t version;
4401 
4402 	/**
4403 	 * Panel Control HW instance mask.
4404 	 * Bit 0 is Panel Control HW instance 0.
4405 	 * Bit 1 is Panel Control HW instance 1.
4406 	 */
4407 	uint8_t panel_mask;
4408 
4409 	/**
4410 	 * Explicit padding to 4 byte boundary.
4411 	 */
4412 	uint8_t pad[2];
4413 };
4414 
4415 /**
4416  * Definition of a DMUB_CMD__ABM_SET_AMBIENT_LEVEL command.
4417  */
4418 struct dmub_rb_cmd_abm_set_ambient_level {
4419 	/**
4420 	 * Command header.
4421 	 */
4422 	struct dmub_cmd_header header;
4423 
4424 	/**
4425 	 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_AMBIENT_LEVEL command.
4426 	 */
4427 	struct dmub_cmd_abm_set_ambient_level_data abm_set_ambient_level_data;
4428 };
4429 
4430 /**
4431  * Data passed from driver to FW in a DMUB_CMD__ABM_SET_PWM_FRAC command.
4432  */
4433 struct dmub_cmd_abm_set_pwm_frac_data {
4434 	/**
4435 	 * Enable/disable fractional duty cycle for backlight PWM.
4436 	 * TODO: Convert to uint8_t.
4437 	 */
4438 	uint32_t fractional_pwm;
4439 
4440 	/**
4441 	 * ABM control version.
4442 	 */
4443 	uint8_t version;
4444 
4445 	/**
4446 	 * Panel Control HW instance mask.
4447 	 * Bit 0 is Panel Control HW instance 0.
4448 	 * Bit 1 is Panel Control HW instance 1.
4449 	 */
4450 	uint8_t panel_mask;
4451 
4452 	/**
4453 	 * Explicit padding to 4 byte boundary.
4454 	 */
4455 	uint8_t pad[2];
4456 };
4457 
4458 /**
4459  * Definition of a DMUB_CMD__ABM_SET_PWM_FRAC command.
4460  */
4461 struct dmub_rb_cmd_abm_set_pwm_frac {
4462 	/**
4463 	 * Command header.
4464 	 */
4465 	struct dmub_cmd_header header;
4466 
4467 	/**
4468 	 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_PWM_FRAC command.
4469 	 */
4470 	struct dmub_cmd_abm_set_pwm_frac_data abm_set_pwm_frac_data;
4471 };
4472 
4473 /**
4474  * Data passed from driver to FW in a DMUB_CMD__ABM_INIT_CONFIG command.
4475  */
4476 struct dmub_cmd_abm_init_config_data {
4477 	/**
4478 	 * Location of indirect buffer used to pass init data to ABM.
4479 	 */
4480 	union dmub_addr src;
4481 
4482 	/**
4483 	 * Indirect buffer length.
4484 	 */
4485 	uint16_t bytes;
4486 
4487 
4488 	/**
4489 	 * ABM control version.
4490 	 */
4491 	uint8_t version;
4492 
4493 	/**
4494 	 * Panel Control HW instance mask.
4495 	 * Bit 0 is Panel Control HW instance 0.
4496 	 * Bit 1 is Panel Control HW instance 1.
4497 	 */
4498 	uint8_t panel_mask;
4499 
4500 	/**
4501 	 * Explicit padding to 4 byte boundary.
4502 	 */
4503 	uint8_t pad[2];
4504 };
4505 
4506 /**
4507  * Definition of a DMUB_CMD__ABM_INIT_CONFIG command.
4508  */
4509 struct dmub_rb_cmd_abm_init_config {
4510 	/**
4511 	 * Command header.
4512 	 */
4513 	struct dmub_cmd_header header;
4514 
4515 	/**
4516 	 * Data passed from driver to FW in a DMUB_CMD__ABM_INIT_CONFIG command.
4517 	 */
4518 	struct dmub_cmd_abm_init_config_data abm_init_config_data;
4519 };
4520 
4521 /**
4522  * Data passed from driver to FW in a DMUB_CMD__ABM_PAUSE command.
4523  */
4524 
4525 struct dmub_cmd_abm_pause_data {
4526 
4527 	/**
4528 	 * Panel Control HW instance mask.
4529 	 * Bit 0 is Panel Control HW instance 0.
4530 	 * Bit 1 is Panel Control HW instance 1.
4531 	 */
4532 	uint8_t panel_mask;
4533 
4534 	/**
4535 	 * OTG hw instance
4536 	 */
4537 	uint8_t otg_inst;
4538 
4539 	/**
4540 	 * Enable or disable ABM pause
4541 	 */
4542 	uint8_t enable;
4543 
4544 	/**
4545 	 * Explicit padding to 4 byte boundary.
4546 	 */
4547 	uint8_t pad[1];
4548 };
4549 
4550 /**
4551  * Definition of a DMUB_CMD__ABM_PAUSE command.
4552  */
4553 struct dmub_rb_cmd_abm_pause {
4554 	/**
4555 	 * Command header.
4556 	 */
4557 	struct dmub_cmd_header header;
4558 
4559 	/**
4560 	 * Data passed from driver to FW in a DMUB_CMD__ABM_PAUSE command.
4561 	 */
4562 	struct dmub_cmd_abm_pause_data abm_pause_data;
4563 };
4564 
4565 /**
4566  * Data passed from driver to FW in a DMUB_CMD__ABM_QUERY_CAPS command.
4567  */
4568 struct dmub_cmd_abm_query_caps_in {
4569 	/**
4570 	 * Panel instance.
4571 	 */
4572 	uint8_t panel_inst;
4573 
4574 	/**
4575 	 * Explicit padding to 4 byte boundary.
4576 	 */
4577 	uint8_t pad[3];
4578 };
4579 
4580 /**
4581  * Data passed from FW to driver in a DMUB_CMD__ABM_QUERY_CAPS command.
4582  */
4583 struct dmub_cmd_abm_query_caps_out {
4584 	/**
4585 	 * SW Algorithm caps.
4586 	 */
4587 	struct abm_caps sw_caps;
4588 
4589 	/**
4590 	 * ABM HW caps.
4591 	 */
4592 	struct abm_caps hw_caps;
4593 };
4594 
4595 /**
4596  * Definition of a DMUB_CMD__ABM_QUERY_CAPS command.
4597  */
4598 struct dmub_rb_cmd_abm_query_caps {
4599 	/**
4600 	 * Command header.
4601 	 */
4602 	struct dmub_cmd_header header;
4603 
4604 	/**
4605 	 * Data passed between FW and driver in a DMUB_CMD__ABM_QUERY_CAPS command.
4606 	 */
4607 	union {
4608 		struct dmub_cmd_abm_query_caps_in  abm_query_caps_in;
4609 		struct dmub_cmd_abm_query_caps_out abm_query_caps_out;
4610 	} data;
4611 };
4612 
4613 /**
4614  * enum dmub_abm_ace_curve_type - ACE curve type.
4615  */
4616 enum dmub_abm_ace_curve_type {
4617 	/**
4618 	 * ACE curve as defined by the SW layer.
4619 	 */
4620 	ABM_ACE_CURVE_TYPE__SW = 0,
4621 	/**
4622 	 * ACE curve as defined by the SW to HW translation interface layer.
4623 	 */
4624 	ABM_ACE_CURVE_TYPE__SW_IF = 1,
4625 };
4626 
4627 /**
4628  * Definition of a DMUB_CMD__ABM_GET_ACE_CURVE command.
4629  */
4630 struct dmub_rb_cmd_abm_get_ace_curve {
4631 	/**
4632 	 * Command header.
4633 	 */
4634 	struct dmub_cmd_header header;
4635 
4636 	/**
4637 	 * Address where ACE curve should be copied.
4638 	 */
4639 	union dmub_addr dest;
4640 
4641 	/**
4642 	 * Type of ACE curve being queried.
4643 	 */
4644 	enum dmub_abm_ace_curve_type ace_type;
4645 
4646 	/**
4647 	 * Indirect buffer length.
4648 	 */
4649 	uint16_t bytes;
4650 
4651 	/**
4652 	 * eDP panel instance.
4653 	 */
4654 	uint8_t panel_inst;
4655 
4656 	/**
4657 	 * Explicit padding to 4 byte boundary.
4658 	 */
4659 	uint8_t pad;
4660 };
4661 
4662 /**
4663  * Definition of a DMUB_CMD__ABM_SAVE_RESTORE command.
4664  */
4665 struct dmub_rb_cmd_abm_save_restore {
4666 	/**
4667 	 * Command header.
4668 	 */
4669 	struct dmub_cmd_header header;
4670 
4671 	/**
4672 	 * OTG hw instance
4673 	 */
4674 	uint8_t otg_inst;
4675 
4676 	/**
4677 	 * Enable or disable ABM pause
4678 	 */
4679 	uint8_t freeze;
4680 
4681 	/**
4682 	 * Explicit padding to 4 byte boundary.
4683 	 */
4684 	uint8_t debug;
4685 
4686 	/**
4687 	 * Data passed from driver to FW in a DMUB_CMD__ABM_INIT_CONFIG command.
4688 	 */
4689 	struct dmub_cmd_abm_init_config_data abm_init_config_data;
4690 };
4691 
4692 /**
4693  * Data passed from driver to FW in a DMUB_CMD__ABM_SET_EVENT command.
4694  */
4695 
4696 struct dmub_cmd_abm_set_event_data {
4697 
4698 	/**
4699 	 * VB Scaling Init. Strength Mapping
4700 	 * Byte 0: 0~255 for VB level 0
4701 	 * Byte 1: 0~255 for VB level 1
4702 	 * Byte 2: 0~255 for VB level 2
4703 	 * Byte 3: 0~255 for VB level 3
4704 	 */
4705 	uint32_t vb_scaling_strength_mapping;
4706 	/**
4707 	 * VariBright Scaling Enable
4708 	 */
4709 	uint8_t vb_scaling_enable;
4710 	/**
4711 	 * Panel Control HW instance mask.
4712 	 * Bit 0 is Panel Control HW instance 0.
4713 	 * Bit 1 is Panel Control HW instance 1.
4714 	 */
4715 	uint8_t panel_mask;
4716 
4717 	/**
4718 	 * Explicit padding to 4 byte boundary.
4719 	 */
4720 	uint8_t pad[2];
4721 };
4722 
4723 /**
4724  * Definition of a DMUB_CMD__ABM_SET_EVENT command.
4725  */
4726 struct dmub_rb_cmd_abm_set_event {
4727 	/**
4728 	 * Command header.
4729 	 */
4730 	struct dmub_cmd_header header;
4731 
4732 	/**
4733 	 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_EVENT command.
4734 	 */
4735 	struct dmub_cmd_abm_set_event_data abm_set_event_data;
4736 };
4737 
4738 /**
4739  * Data passed from driver to FW in a DMUB_CMD__QUERY_FEATURE_CAPS command.
4740  */
4741 struct dmub_cmd_query_feature_caps_data {
4742 	/**
4743 	 * DMUB feature capabilities.
4744 	 * After DMUB init, driver will query FW capabilities prior to enabling certain features.
4745 	 */
4746 	struct dmub_feature_caps feature_caps;
4747 };
4748 
4749 /**
4750  * Definition of a DMUB_CMD__QUERY_FEATURE_CAPS command.
4751  */
4752 struct dmub_rb_cmd_query_feature_caps {
4753 	/**
4754 	 * Command header.
4755 	 */
4756 	struct dmub_cmd_header header;
4757 	/**
4758 	 * Data passed from driver to FW in a DMUB_CMD__QUERY_FEATURE_CAPS command.
4759 	 */
4760 	struct dmub_cmd_query_feature_caps_data query_feature_caps_data;
4761 };
4762 
4763 /**
4764  * Data passed from driver to FW in a DMUB_CMD__GET_VISUAL_CONFIRM_COLOR command.
4765  */
4766 struct dmub_cmd_visual_confirm_color_data {
4767 	/**
4768 	 * DMUB visual confirm color
4769 	 */
4770 	struct dmub_visual_confirm_color visual_confirm_color;
4771 };
4772 
4773 /**
4774  * Definition of a DMUB_CMD__GET_VISUAL_CONFIRM_COLOR command.
4775  */
4776 struct dmub_rb_cmd_get_visual_confirm_color {
4777 	/**
4778 	 * Command header.
4779 	 */
4780 	struct dmub_cmd_header header;
4781 	/**
4782 	 * Data passed from driver to FW in a DMUB_CMD__GET_VISUAL_CONFIRM_COLOR command.
4783 	 */
4784 	struct dmub_cmd_visual_confirm_color_data visual_confirm_color_data;
4785 };
4786 
4787 /**
4788  * enum dmub_cmd_panel_cntl_type - Panel control command.
4789  */
4790 enum dmub_cmd_panel_cntl_type {
4791 	/**
4792 	 * Initializes embedded panel hardware blocks.
4793 	 */
4794 	DMUB_CMD__PANEL_CNTL_HW_INIT = 0,
4795 	/**
4796 	 * Queries backlight info for the embedded panel.
4797 	 */
4798 	DMUB_CMD__PANEL_CNTL_QUERY_BACKLIGHT_INFO = 1,
4799 	/**
4800 	 * Sets the PWM Freq as per user's requirement.
4801 	 */
4802 	DMUB_CMD__PANEL_DEBUG_PWM_FREQ = 2,
4803 };
4804 
4805 /**
4806  * struct dmub_cmd_panel_cntl_data - Panel control data.
4807  */
4808 struct dmub_cmd_panel_cntl_data {
4809 	uint32_t pwrseq_inst; /**< pwrseq instance */
4810 	uint32_t current_backlight; /* in/out */
4811 	uint32_t bl_pwm_cntl; /* in/out */
4812 	uint32_t bl_pwm_period_cntl; /* in/out */
4813 	uint32_t bl_pwm_ref_div1; /* in/out */
4814 	uint8_t is_backlight_on : 1; /* in/out */
4815 	uint8_t is_powered_on : 1; /* in/out */
4816 	uint8_t padding[3];
4817 	uint32_t bl_pwm_ref_div2; /* in/out */
4818 	uint8_t reserved[4];
4819 };
4820 
4821 /**
4822  * struct dmub_rb_cmd_panel_cntl - Panel control command.
4823  */
4824 struct dmub_rb_cmd_panel_cntl {
4825 	struct dmub_cmd_header header; /**< header */
4826 	struct dmub_cmd_panel_cntl_data data; /**< payload */
4827 };
4828 
4829 struct dmub_optc_state {
4830 	uint32_t v_total_max;
4831 	uint32_t v_total_min;
4832 	uint32_t tg_inst;
4833 };
4834 
4835 struct dmub_rb_cmd_drr_update {
4836 	struct dmub_cmd_header header;
4837 	struct dmub_optc_state dmub_optc_state_req;
4838 };
4839 
4840 struct dmub_cmd_fw_assisted_mclk_switch_pipe_data {
4841 	uint32_t pix_clk_100hz;
4842 	uint8_t max_ramp_step;
4843 	uint8_t pipes;
4844 	uint8_t min_refresh_in_hz;
4845 	uint8_t pipe_count;
4846 	uint8_t pipe_index[4];
4847 };
4848 
4849 struct dmub_cmd_fw_assisted_mclk_switch_config {
4850 	uint8_t fams_enabled;
4851 	uint8_t visual_confirm_enabled;
4852 	uint16_t vactive_stretch_margin_us; // Extra vblank stretch required when doing FPO + Vactive
4853 	struct dmub_cmd_fw_assisted_mclk_switch_pipe_data pipe_data[DMUB_MAX_FPO_STREAMS];
4854 };
4855 
4856 struct dmub_rb_cmd_fw_assisted_mclk_switch {
4857 	struct dmub_cmd_header header;
4858 	struct dmub_cmd_fw_assisted_mclk_switch_config config_data;
4859 };
4860 
4861 /**
4862  * Data passed from driver to FW in a DMUB_CMD__VBIOS_LVTMA_CONTROL command.
4863  */
4864 struct dmub_cmd_lvtma_control_data {
4865 	uint8_t uc_pwr_action; /**< LVTMA_ACTION */
4866 	uint8_t bypass_panel_control_wait;
4867 	uint8_t reserved_0[2]; /**< For future use */
4868 	uint8_t pwrseq_inst; /**< LVTMA control instance */
4869 	uint8_t reserved_1[3]; /**< For future use */
4870 };
4871 
4872 /**
4873  * Definition of a DMUB_CMD__VBIOS_LVTMA_CONTROL command.
4874  */
4875 struct dmub_rb_cmd_lvtma_control {
4876 	/**
4877 	 * Command header.
4878 	 */
4879 	struct dmub_cmd_header header;
4880 	/**
4881 	 * Data passed from driver to FW in a DMUB_CMD__VBIOS_LVTMA_CONTROL command.
4882 	 */
4883 	struct dmub_cmd_lvtma_control_data data;
4884 };
4885 
4886 /**
4887  * Data passed in/out in a DMUB_CMD__VBIOS_TRANSMITTER_QUERY_DP_ALT command.
4888  */
4889 struct dmub_rb_cmd_transmitter_query_dp_alt_data {
4890 	uint8_t phy_id; /**< 0=UNIPHYA, 1=UNIPHYB, 2=UNIPHYC, 3=UNIPHYD, 4=UNIPHYE, 5=UNIPHYF */
4891 	uint8_t is_usb; /**< is phy is usb */
4892 	uint8_t is_dp_alt_disable; /**< is dp alt disable */
4893 	uint8_t is_dp4; /**< is dp in 4 lane */
4894 };
4895 
4896 /**
4897  * Definition of a DMUB_CMD__VBIOS_TRANSMITTER_QUERY_DP_ALT command.
4898  */
4899 struct dmub_rb_cmd_transmitter_query_dp_alt {
4900 	struct dmub_cmd_header header; /**< header */
4901 	struct dmub_rb_cmd_transmitter_query_dp_alt_data data; /**< payload */
4902 };
4903 
4904 struct phy_test_mode {
4905 	uint8_t mode;
4906 	uint8_t pat0;
4907 	uint8_t pad[2];
4908 };
4909 
4910 /**
4911  * Data passed in/out in a DMUB_CMD__VBIOS_TRANSMITTER_SET_PHY_FSM command.
4912  */
4913 struct dmub_rb_cmd_transmitter_set_phy_fsm_data {
4914 	uint8_t phy_id; /**< 0=UNIPHYA, 1=UNIPHYB, 2=UNIPHYC, 3=UNIPHYD, 4=UNIPHYE, 5=UNIPHYF */
4915 	uint8_t mode; /**< HDMI/DP/DP2 etc */
4916 	uint8_t lane_num; /**< Number of lanes */
4917 	uint32_t symclk_100Hz; /**< PLL symclock in 100hz */
4918 	struct phy_test_mode test_mode;
4919 	enum dmub_phy_fsm_state state;
4920 	uint32_t status;
4921 	uint8_t pad;
4922 };
4923 
4924 /**
4925  * Definition of a DMUB_CMD__VBIOS_TRANSMITTER_SET_PHY_FSM command.
4926  */
4927 struct dmub_rb_cmd_transmitter_set_phy_fsm {
4928 	struct dmub_cmd_header header; /**< header */
4929 	struct dmub_rb_cmd_transmitter_set_phy_fsm_data data; /**< payload */
4930 };
4931 
4932 /**
4933  * Maximum number of bytes a chunk sent to DMUB for parsing
4934  */
4935 #define DMUB_EDID_CEA_DATA_CHUNK_BYTES 8
4936 
4937 /**
4938  *  Represent a chunk of CEA blocks sent to DMUB for parsing
4939  */
4940 struct dmub_cmd_send_edid_cea {
4941 	uint16_t offset;	/**< offset into the CEA block */
4942 	uint8_t length;	/**< number of bytes in payload to copy as part of CEA block */
4943 	uint16_t cea_total_length;  /**< total length of the CEA block */
4944 	uint8_t payload[DMUB_EDID_CEA_DATA_CHUNK_BYTES]; /**< data chunk of the CEA block */
4945 	uint8_t pad[3]; /**< padding and for future expansion */
4946 };
4947 
4948 /**
4949  * Result of VSDB parsing from CEA block
4950  */
4951 struct dmub_cmd_edid_cea_amd_vsdb {
4952 	uint8_t vsdb_found;		/**< 1 if parsing has found valid AMD VSDB */
4953 	uint8_t freesync_supported;	/**< 1 if Freesync is supported */
4954 	uint16_t amd_vsdb_version;	/**< AMD VSDB version */
4955 	uint16_t min_frame_rate;	/**< Maximum frame rate */
4956 	uint16_t max_frame_rate;	/**< Minimum frame rate */
4957 };
4958 
4959 /**
4960  * Result of sending a CEA chunk
4961  */
4962 struct dmub_cmd_edid_cea_ack {
4963 	uint16_t offset;	/**< offset of the chunk into the CEA block */
4964 	uint8_t success;	/**< 1 if this sending of chunk succeeded */
4965 	uint8_t pad;		/**< padding and for future expansion */
4966 };
4967 
4968 /**
4969  * Specify whether the result is an ACK/NACK or the parsing has finished
4970  */
4971 enum dmub_cmd_edid_cea_reply_type {
4972 	DMUB_CMD__EDID_CEA_AMD_VSDB	= 1, /**< VSDB parsing has finished */
4973 	DMUB_CMD__EDID_CEA_ACK		= 2, /**< acknowledges the CEA sending is OK or failing */
4974 };
4975 
4976 /**
4977  * Definition of a DMUB_CMD__EDID_CEA command.
4978  */
4979 struct dmub_rb_cmd_edid_cea {
4980 	struct dmub_cmd_header header;	/**< Command header */
4981 	union dmub_cmd_edid_cea_data {
4982 		struct dmub_cmd_send_edid_cea input; /**< input to send CEA chunks */
4983 		struct dmub_cmd_edid_cea_output { /**< output with results */
4984 			uint8_t type;	/**< dmub_cmd_edid_cea_reply_type */
4985 			union {
4986 				struct dmub_cmd_edid_cea_amd_vsdb amd_vsdb;
4987 				struct dmub_cmd_edid_cea_ack ack;
4988 			};
4989 		} output;	/**< output to retrieve ACK/NACK or VSDB parsing results */
4990 	} data;	/**< Command data */
4991 
4992 };
4993 
4994 /**
4995  * struct dmub_cmd_cable_id_input - Defines the input of DMUB_CMD_GET_USBC_CABLE_ID command.
4996  */
4997 struct dmub_cmd_cable_id_input {
4998 	uint8_t phy_inst;  /**< phy inst for cable id data */
4999 };
5000 
5001 /**
5002  * struct dmub_cmd_cable_id_input - Defines the output of DMUB_CMD_GET_USBC_CABLE_ID command.
5003  */
5004 struct dmub_cmd_cable_id_output {
5005 	uint8_t UHBR10_20_CAPABILITY	:2; /**< b'01 for UHBR10 support, b'10 for both UHBR10 and UHBR20 support */
5006 	uint8_t UHBR13_5_CAPABILITY	:1; /**< b'1 for UHBR13.5 support */
5007 	uint8_t CABLE_TYPE		:3; /**< b'01 for passive cable, b'10 for active LRD cable, b'11 for active retimer cable */
5008 	uint8_t RESERVED		:2; /**< reserved means not defined */
5009 };
5010 
5011 /**
5012  * Definition of a DMUB_CMD_GET_USBC_CABLE_ID command
5013  */
5014 struct dmub_rb_cmd_get_usbc_cable_id {
5015 	struct dmub_cmd_header header; /**< Command header */
5016 	/**
5017 	 * Data passed from driver to FW in a DMUB_CMD_GET_USBC_CABLE_ID command.
5018 	 */
5019 	union dmub_cmd_cable_id_data {
5020 		struct dmub_cmd_cable_id_input input; /**< Input */
5021 		struct dmub_cmd_cable_id_output output; /**< Output */
5022 		uint8_t output_raw; /**< Raw data output */
5023 	} data;
5024 };
5025 
5026 /**
5027  * Command type of a DMUB_CMD__SECURE_DISPLAY command
5028  */
5029 enum dmub_cmd_secure_display_type {
5030 	DMUB_CMD__SECURE_DISPLAY_TEST_CMD = 0,		/* test command to only check if inbox message works */
5031 	DMUB_CMD__SECURE_DISPLAY_CRC_STOP_UPDATE,
5032 	DMUB_CMD__SECURE_DISPLAY_CRC_WIN_NOTIFY
5033 };
5034 
5035 /**
5036  * Definition of a DMUB_CMD__SECURE_DISPLAY command
5037  */
5038 struct dmub_rb_cmd_secure_display {
5039 	struct dmub_cmd_header header;
5040 	/**
5041 	 * Data passed from driver to dmub firmware.
5042 	 */
5043 	struct dmub_cmd_roi_info {
5044 		uint16_t x_start;
5045 		uint16_t x_end;
5046 		uint16_t y_start;
5047 		uint16_t y_end;
5048 		uint8_t otg_id;
5049 		uint8_t phy_id;
5050 	} roi_info;
5051 };
5052 
5053 /**
5054  * Command type of a DMUB_CMD__PSP command
5055  */
5056 enum dmub_cmd_psp_type {
5057 	DMUB_CMD__PSP_ASSR_ENABLE = 0
5058 };
5059 
5060 /**
5061  * Data passed from driver to FW in a DMUB_CMD__PSP_ASSR_ENABLE command.
5062  */
5063 struct dmub_cmd_assr_enable_data {
5064 	/**
5065 	 * ASSR enable or disable.
5066 	 */
5067 	uint8_t enable;
5068 	/**
5069 	 * PHY port type.
5070 	 * Indicates eDP / non-eDP port type
5071 	 */
5072 	uint8_t phy_port_type;
5073 	/**
5074 	 * PHY port ID.
5075 	 */
5076 	uint8_t phy_port_id;
5077 	/**
5078 	 * Link encoder index.
5079 	 */
5080 	uint8_t link_enc_index;
5081 	/**
5082 	 * HPO mode.
5083 	 */
5084 	uint8_t hpo_mode;
5085 
5086 	/**
5087 	 * Reserved field.
5088 	 */
5089 	uint8_t reserved[7];
5090 };
5091 
5092 /**
5093  * Definition of a DMUB_CMD__PSP_ASSR_ENABLE command.
5094  */
5095 struct dmub_rb_cmd_assr_enable {
5096 	/**
5097 	 * Command header.
5098 	 */
5099 	struct dmub_cmd_header header;
5100 
5101 	/**
5102 	 * Assr data.
5103 	 */
5104 	struct dmub_cmd_assr_enable_data assr_data;
5105 
5106 	/**
5107 	 * Reserved field.
5108 	 */
5109 	uint32_t reserved[3];
5110 };
5111 
5112 /**
5113  * union dmub_rb_cmd - DMUB inbox command.
5114  */
5115 union dmub_rb_cmd {
5116 	/**
5117 	 * Elements shared with all commands.
5118 	 */
5119 	struct dmub_rb_cmd_common cmd_common;
5120 	/**
5121 	 * Definition of a DMUB_CMD__REG_SEQ_READ_MODIFY_WRITE command.
5122 	 */
5123 	struct dmub_rb_cmd_read_modify_write read_modify_write;
5124 	/**
5125 	 * Definition of a DMUB_CMD__REG_SEQ_FIELD_UPDATE_SEQ command.
5126 	 */
5127 	struct dmub_rb_cmd_reg_field_update_sequence reg_field_update_seq;
5128 	/**
5129 	 * Definition of a DMUB_CMD__REG_SEQ_BURST_WRITE command.
5130 	 */
5131 	struct dmub_rb_cmd_burst_write burst_write;
5132 	/**
5133 	 * Definition of a DMUB_CMD__REG_REG_WAIT command.
5134 	 */
5135 	struct dmub_rb_cmd_reg_wait reg_wait;
5136 	/**
5137 	 * Definition of a DMUB_CMD__VBIOS_DIGX_ENCODER_CONTROL command.
5138 	 */
5139 	struct dmub_rb_cmd_digx_encoder_control digx_encoder_control;
5140 	/**
5141 	 * Definition of a DMUB_CMD__VBIOS_SET_PIXEL_CLOCK command.
5142 	 */
5143 	struct dmub_rb_cmd_set_pixel_clock set_pixel_clock;
5144 	/**
5145 	 * Definition of a DMUB_CMD__VBIOS_ENABLE_DISP_POWER_GATING command.
5146 	 */
5147 	struct dmub_rb_cmd_enable_disp_power_gating enable_disp_power_gating;
5148 	/**
5149 	 * Definition of a DMUB_CMD__VBIOS_DPPHY_INIT command.
5150 	 */
5151 	struct dmub_rb_cmd_dpphy_init dpphy_init;
5152 	/**
5153 	 * Definition of a DMUB_CMD__VBIOS_DIG1_TRANSMITTER_CONTROL command.
5154 	 */
5155 	struct dmub_rb_cmd_dig1_transmitter_control dig1_transmitter_control;
5156 	/**
5157 	 * Definition of a DMUB_CMD__VBIOS_DOMAIN_CONTROL command.
5158 	 */
5159 	struct dmub_rb_cmd_domain_control domain_control;
5160 	/**
5161 	 * Definition of a DMUB_CMD__PSR_SET_VERSION command.
5162 	 */
5163 	struct dmub_rb_cmd_psr_set_version psr_set_version;
5164 	/**
5165 	 * Definition of a DMUB_CMD__PSR_COPY_SETTINGS command.
5166 	 */
5167 	struct dmub_rb_cmd_psr_copy_settings psr_copy_settings;
5168 	/**
5169 	 * Definition of a DMUB_CMD__PSR_ENABLE command.
5170 	 */
5171 	struct dmub_rb_cmd_psr_enable psr_enable;
5172 	/**
5173 	 * Definition of a DMUB_CMD__PSR_SET_LEVEL command.
5174 	 */
5175 	struct dmub_rb_cmd_psr_set_level psr_set_level;
5176 	/**
5177 	 * Definition of a DMUB_CMD__PSR_FORCE_STATIC command.
5178 	 */
5179 	struct dmub_rb_cmd_psr_force_static psr_force_static;
5180 	/**
5181 	 * Definition of a DMUB_CMD__UPDATE_DIRTY_RECT command.
5182 	 */
5183 	struct dmub_rb_cmd_update_dirty_rect update_dirty_rect;
5184 	/**
5185 	 * Definition of a DMUB_CMD__UPDATE_CURSOR_INFO command.
5186 	 */
5187 	struct dmub_rb_cmd_update_cursor_info update_cursor_info;
5188 	/**
5189 	 * Definition of a DMUB_CMD__HW_LOCK command.
5190 	 * Command is used by driver and FW.
5191 	 */
5192 	struct dmub_rb_cmd_lock_hw lock_hw;
5193 	/**
5194 	 * Definition of a DMUB_CMD__SET_SINK_VTOTAL_IN_PSR_ACTIVE command.
5195 	 */
5196 	struct dmub_rb_cmd_psr_set_vtotal psr_set_vtotal;
5197 	/**
5198 	 * Definition of a DMUB_CMD__SET_PSR_POWER_OPT command.
5199 	 */
5200 	struct dmub_rb_cmd_psr_set_power_opt psr_set_power_opt;
5201 	/**
5202 	 * Definition of a DMUB_CMD__PLAT_54186_WA command.
5203 	 */
5204 	struct dmub_rb_cmd_PLAT_54186_wa PLAT_54186_wa;
5205 	/**
5206 	 * Definition of a DMUB_CMD__MALL command.
5207 	 */
5208 	struct dmub_rb_cmd_mall mall;
5209 
5210 	/**
5211 	 * Definition of a DMUB_CMD__CAB command.
5212 	 */
5213 	struct dmub_rb_cmd_cab_for_ss cab;
5214 
5215 	struct dmub_rb_cmd_fw_assisted_mclk_switch_v2 fw_assisted_mclk_switch_v2;
5216 
5217 	/**
5218 	 * Definition of a DMUB_CMD__IDLE_OPT_DCN_RESTORE command.
5219 	 */
5220 	struct dmub_rb_cmd_idle_opt_dcn_restore dcn_restore;
5221 
5222 	/**
5223 	 * Definition of a DMUB_CMD__CLK_MGR_NOTIFY_CLOCKS command.
5224 	 */
5225 	struct dmub_rb_cmd_clk_mgr_notify_clocks notify_clocks;
5226 
5227 	/**
5228 	 * Definition of DMUB_CMD__PANEL_CNTL commands.
5229 	 */
5230 	struct dmub_rb_cmd_panel_cntl panel_cntl;
5231 
5232 	/**
5233 	 * Definition of a DMUB_CMD__ABM_SET_PIPE command.
5234 	 */
5235 	struct dmub_rb_cmd_abm_set_pipe abm_set_pipe;
5236 
5237 	/**
5238 	 * Definition of a DMUB_CMD__ABM_SET_BACKLIGHT command.
5239 	 */
5240 	struct dmub_rb_cmd_abm_set_backlight abm_set_backlight;
5241 
5242 	/**
5243 	 * Definition of a DMUB_CMD__ABM_SET_LEVEL command.
5244 	 */
5245 	struct dmub_rb_cmd_abm_set_level abm_set_level;
5246 
5247 	/**
5248 	 * Definition of a DMUB_CMD__ABM_SET_AMBIENT_LEVEL command.
5249 	 */
5250 	struct dmub_rb_cmd_abm_set_ambient_level abm_set_ambient_level;
5251 
5252 	/**
5253 	 * Definition of a DMUB_CMD__ABM_SET_PWM_FRAC command.
5254 	 */
5255 	struct dmub_rb_cmd_abm_set_pwm_frac abm_set_pwm_frac;
5256 
5257 	/**
5258 	 * Definition of a DMUB_CMD__ABM_INIT_CONFIG command.
5259 	 */
5260 	struct dmub_rb_cmd_abm_init_config abm_init_config;
5261 
5262 	/**
5263 	 * Definition of a DMUB_CMD__ABM_PAUSE command.
5264 	 */
5265 	struct dmub_rb_cmd_abm_pause abm_pause;
5266 
5267 	/**
5268 	 * Definition of a DMUB_CMD__ABM_SAVE_RESTORE command.
5269 	 */
5270 	struct dmub_rb_cmd_abm_save_restore abm_save_restore;
5271 
5272 	/**
5273 	 * Definition of a DMUB_CMD__ABM_QUERY_CAPS command.
5274 	 */
5275 	struct dmub_rb_cmd_abm_query_caps abm_query_caps;
5276 
5277 	/**
5278 	 * Definition of a DMUB_CMD__ABM_GET_ACE_CURVE command.
5279 	 */
5280 	struct dmub_rb_cmd_abm_get_ace_curve abm_get_ace_curve;
5281 
5282 	/**
5283 	 * Definition of a DMUB_CMD__ABM_SET_EVENT command.
5284 	 */
5285 	struct dmub_rb_cmd_abm_set_event abm_set_event;
5286 
5287 	/**
5288 	 * Definition of a DMUB_CMD__DP_AUX_ACCESS command.
5289 	 */
5290 	struct dmub_rb_cmd_dp_aux_access dp_aux_access;
5291 
5292 	/**
5293 	 * Definition of a DMUB_CMD__OUTBOX1_ENABLE command.
5294 	 */
5295 	struct dmub_rb_cmd_outbox1_enable outbox1_enable;
5296 
5297 	/**
5298 	 * Definition of a DMUB_CMD__QUERY_FEATURE_CAPS command.
5299 	 */
5300 	struct dmub_rb_cmd_query_feature_caps query_feature_caps;
5301 
5302 	/**
5303 	 * Definition of a DMUB_CMD__GET_VISUAL_CONFIRM_COLOR command.
5304 	 */
5305 	struct dmub_rb_cmd_get_visual_confirm_color visual_confirm_color;
5306 	struct dmub_rb_cmd_drr_update drr_update;
5307 	struct dmub_rb_cmd_fw_assisted_mclk_switch fw_assisted_mclk_switch;
5308 
5309 	/**
5310 	 * Definition of a DMUB_CMD__VBIOS_LVTMA_CONTROL command.
5311 	 */
5312 	struct dmub_rb_cmd_lvtma_control lvtma_control;
5313 	/**
5314 	 * Definition of a DMUB_CMD__VBIOS_TRANSMITTER_QUERY_DP_ALT command.
5315 	 */
5316 	struct dmub_rb_cmd_transmitter_query_dp_alt query_dp_alt;
5317 	/**
5318 	 * Definition of a DMUB_CMD__VBIOS_TRANSMITTER_SET_PHY_FSM command.
5319 	 */
5320 	struct dmub_rb_cmd_transmitter_set_phy_fsm set_phy_fsm;
5321 	/**
5322 	 * Definition of a DMUB_CMD__DPIA_DIG1_CONTROL command.
5323 	 */
5324 	struct dmub_rb_cmd_dig1_dpia_control dig1_dpia_control;
5325 	/**
5326 	 * Definition of a DMUB_CMD__DPIA_SET_CONFIG_ACCESS command.
5327 	 */
5328 	struct dmub_rb_cmd_set_config_access set_config_access;
5329 	/**
5330 	 * Definition of a DMUB_CMD__DPIA_MST_ALLOC_SLOTS command.
5331 	 */
5332 	struct dmub_rb_cmd_set_mst_alloc_slots set_mst_alloc_slots;
5333 	/**
5334 	 * Definition of a DMUB_CMD__DPIA_SET_TPS_NOTIFICATION command.
5335 	 */
5336 	struct dmub_rb_cmd_set_tps_notification set_tps_notification;
5337 	/**
5338 	 * Definition of a DMUB_CMD__EDID_CEA command.
5339 	 */
5340 	struct dmub_rb_cmd_edid_cea edid_cea;
5341 	/**
5342 	 * Definition of a DMUB_CMD_GET_USBC_CABLE_ID command.
5343 	 */
5344 	struct dmub_rb_cmd_get_usbc_cable_id cable_id;
5345 
5346 	/**
5347 	 * Definition of a DMUB_CMD__QUERY_HPD_STATE command.
5348 	 */
5349 	struct dmub_rb_cmd_query_hpd_state query_hpd;
5350 	/**
5351 	 * Definition of a DMUB_CMD__SECURE_DISPLAY command.
5352 	 */
5353 	struct dmub_rb_cmd_secure_display secure_display;
5354 
5355 	/**
5356 	 * Definition of a DMUB_CMD__DPIA_HPD_INT_ENABLE command.
5357 	 */
5358 	struct dmub_rb_cmd_dpia_hpd_int_enable dpia_hpd_int_enable;
5359 	/**
5360 	 * Definition of a DMUB_CMD__IDLE_OPT_DCN_NOTIFY_IDLE command.
5361 	 */
5362 	struct dmub_rb_cmd_idle_opt_dcn_notify_idle idle_opt_notify_idle;
5363 	/**
5364 	 * Definition of a DMUB_CMD__IDLE_OPT_SET_DC_POWER_STATE command.
5365 	 */
5366 	struct dmub_rb_cmd_idle_opt_set_dc_power_state idle_opt_set_dc_power_state;
5367 	/*
5368 	 * Definition of a DMUB_CMD__REPLAY_COPY_SETTINGS command.
5369 	 */
5370 	struct dmub_rb_cmd_replay_copy_settings replay_copy_settings;
5371 	/**
5372 	 * Definition of a DMUB_CMD__REPLAY_ENABLE command.
5373 	 */
5374 	struct dmub_rb_cmd_replay_enable replay_enable;
5375 	/**
5376 	 * Definition of a DMUB_CMD__SET_REPLAY_POWER_OPT command.
5377 	 */
5378 	struct dmub_rb_cmd_replay_set_power_opt replay_set_power_opt;
5379 	/**
5380 	 * Definition of a DMUB_CMD__REPLAY_SET_COASTING_VTOTAL command.
5381 	 */
5382 	struct dmub_rb_cmd_replay_set_coasting_vtotal replay_set_coasting_vtotal;
5383 	/**
5384 	 * Definition of a DMUB_CMD__REPLAY_SET_POWER_OPT_AND_COASTING_VTOTAL command.
5385 	 */
5386 	struct dmub_rb_cmd_replay_set_power_opt_and_coasting_vtotal replay_set_power_opt_and_coasting_vtotal;
5387 
5388 	struct dmub_rb_cmd_replay_set_timing_sync replay_set_timing_sync;
5389 	/**
5390 	 * Definition of a DMUB_CMD__REPLAY_SET_RESIDENCY_FRAMEUPDATE_TIMER command.
5391 	 */
5392 	struct dmub_rb_cmd_replay_set_frameupdate_timer replay_set_frameupdate_timer;
5393 	/**
5394 	 * Definition of a DMUB_CMD__REPLAY_SET_PSEUDO_VTOTAL command.
5395 	 */
5396 	struct dmub_rb_cmd_replay_set_pseudo_vtotal replay_set_pseudo_vtotal;
5397 	/**
5398 	 * Definition of a DMUB_CMD__REPLAY_DISABLED_ADAPTIVE_SYNC_SDP command.
5399 	 */
5400 	struct dmub_rb_cmd_replay_disabled_adaptive_sync_sdp replay_disabled_adaptive_sync_sdp;
5401 	/**
5402 	 * Definition of a DMUB_CMD__REPLAY_SET_GENERAL_CMD command.
5403 	 */
5404 	struct dmub_rb_cmd_replay_set_general_cmd replay_set_general_cmd;
5405 	/**
5406 	 * Definition of a DMUB_CMD__PSP_ASSR_ENABLE command.
5407 	 */
5408 	struct dmub_rb_cmd_assr_enable assr_enable;
5409 	struct dmub_rb_cmd_fams2 fams2_config;
5410 
5411 	struct dmub_rb_cmd_fams2_drr_update fams2_drr_update;
5412 
5413 	struct dmub_rb_cmd_fams2_flip fams2_flip;
5414 };
5415 
5416 /**
5417  * union dmub_rb_out_cmd - Outbox command
5418  */
5419 union dmub_rb_out_cmd {
5420 	/**
5421 	 * Parameters common to every command.
5422 	 */
5423 	struct dmub_rb_cmd_common cmd_common;
5424 	/**
5425 	 * AUX reply command.
5426 	 */
5427 	struct dmub_rb_cmd_dp_aux_reply dp_aux_reply;
5428 	/**
5429 	 * HPD notify command.
5430 	 */
5431 	struct dmub_rb_cmd_dp_hpd_notify dp_hpd_notify;
5432 	/**
5433 	 * SET_CONFIG reply command.
5434 	 */
5435 	struct dmub_rb_cmd_dp_set_config_reply set_config_reply;
5436 	/**
5437 	 * DPIA notification command.
5438 	 */
5439 	struct dmub_rb_cmd_dpia_notification dpia_notification;
5440 	/**
5441 	 * HPD sense notification command.
5442 	 */
5443 	struct dmub_rb_cmd_hpd_sense_notify hpd_sense_notify;
5444 };
5445 #pragma pack(pop)
5446 
5447 
5448 //==============================================================================
5449 //</DMUB_CMD>===================================================================
5450 //==============================================================================
5451 //< DMUB_RB>====================================================================
5452 //==============================================================================
5453 
5454 /**
5455  * struct dmub_rb_init_params - Initialization params for DMUB ringbuffer
5456  */
5457 struct dmub_rb_init_params {
5458 	void *ctx; /**< Caller provided context pointer */
5459 	void *base_address; /**< CPU base address for ring's data */
5460 	uint32_t capacity; /**< Ringbuffer capacity in bytes */
5461 	uint32_t read_ptr; /**< Initial read pointer for consumer in bytes */
5462 	uint32_t write_ptr; /**< Initial write pointer for producer in bytes */
5463 };
5464 
5465 /**
5466  * struct dmub_rb - Inbox or outbox DMUB ringbuffer
5467  */
5468 struct dmub_rb {
5469 	void *base_address; /**< CPU address for the ring's data */
5470 	uint32_t rptr; /**< Read pointer for consumer in bytes */
5471 	uint32_t wrpt; /**< Write pointer for producer in bytes */
5472 	uint32_t capacity; /**< Ringbuffer capacity in bytes */
5473 
5474 	void *ctx; /**< Caller provided context pointer */
5475 	void *dmub; /**< Pointer to the DMUB interface */
5476 };
5477 
5478 /**
5479  * @brief Checks if the ringbuffer is empty.
5480  *
5481  * @param rb DMUB Ringbuffer
5482  * @return true if empty
5483  * @return false otherwise
5484  */
dmub_rb_empty(struct dmub_rb * rb)5485 static inline bool dmub_rb_empty(struct dmub_rb *rb)
5486 {
5487 	return (rb->wrpt == rb->rptr);
5488 }
5489 
5490 /**
5491  * @brief Checks if the ringbuffer is full
5492  *
5493  * @param rb DMUB Ringbuffer
5494  * @return true if full
5495  * @return false otherwise
5496  */
dmub_rb_full(struct dmub_rb * rb)5497 static inline bool dmub_rb_full(struct dmub_rb *rb)
5498 {
5499 	uint32_t data_count;
5500 
5501 	if (rb->wrpt >= rb->rptr)
5502 		data_count = rb->wrpt - rb->rptr;
5503 	else
5504 		data_count = rb->capacity - (rb->rptr - rb->wrpt);
5505 
5506 	return (data_count == (rb->capacity - DMUB_RB_CMD_SIZE));
5507 }
5508 
5509 /**
5510  * @brief Pushes a command into the ringbuffer
5511  *
5512  * @param rb DMUB ringbuffer
5513  * @param cmd The command to push
5514  * @return true if the ringbuffer was not full
5515  * @return false otherwise
5516  */
dmub_rb_push_front(struct dmub_rb * rb,const union dmub_rb_cmd * cmd)5517 static inline bool dmub_rb_push_front(struct dmub_rb *rb,
5518 				      const union dmub_rb_cmd *cmd)
5519 {
5520 	uint64_t volatile *dst = (uint64_t volatile *)((uint8_t *)(rb->base_address) + rb->wrpt);
5521 	const uint64_t *src = (const uint64_t *)cmd;
5522 	uint8_t i;
5523 
5524 	if (dmub_rb_full(rb))
5525 		return false;
5526 
5527 	// copying data
5528 	for (i = 0; i < DMUB_RB_CMD_SIZE / sizeof(uint64_t); i++)
5529 		*dst++ = *src++;
5530 
5531 	rb->wrpt += DMUB_RB_CMD_SIZE;
5532 
5533 	if (rb->wrpt >= rb->capacity)
5534 		rb->wrpt %= rb->capacity;
5535 
5536 	return true;
5537 }
5538 
5539 /**
5540  * @brief Pushes a command into the DMUB outbox ringbuffer
5541  *
5542  * @param rb DMUB outbox ringbuffer
5543  * @param cmd Outbox command
5544  * @return true if not full
5545  * @return false otherwise
5546  */
dmub_rb_out_push_front(struct dmub_rb * rb,const union dmub_rb_out_cmd * cmd)5547 static inline bool dmub_rb_out_push_front(struct dmub_rb *rb,
5548 				      const union dmub_rb_out_cmd *cmd)
5549 {
5550 	uint8_t *dst = (uint8_t *)(rb->base_address) + rb->wrpt;
5551 	const uint8_t *src = (const uint8_t *)cmd;
5552 
5553 	if (dmub_rb_full(rb))
5554 		return false;
5555 
5556 	dmub_memcpy(dst, src, DMUB_RB_CMD_SIZE);
5557 
5558 	rb->wrpt += DMUB_RB_CMD_SIZE;
5559 
5560 	if (rb->wrpt >= rb->capacity)
5561 		rb->wrpt %= rb->capacity;
5562 
5563 	return true;
5564 }
5565 
5566 /**
5567  * @brief Returns the next unprocessed command in the ringbuffer.
5568  *
5569  * @param rb DMUB ringbuffer
5570  * @param cmd The command to return
5571  * @return true if not empty
5572  * @return false otherwise
5573  */
dmub_rb_front(struct dmub_rb * rb,union dmub_rb_cmd ** cmd)5574 static inline bool dmub_rb_front(struct dmub_rb *rb,
5575 				 union dmub_rb_cmd  **cmd)
5576 {
5577 	uint8_t *rb_cmd = (uint8_t *)(rb->base_address) + rb->rptr;
5578 
5579 	if (dmub_rb_empty(rb))
5580 		return false;
5581 
5582 	*cmd = (union dmub_rb_cmd *)rb_cmd;
5583 
5584 	return true;
5585 }
5586 
5587 /**
5588  * @brief Determines the next ringbuffer offset.
5589  *
5590  * @param rb DMUB inbox ringbuffer
5591  * @param num_cmds Number of commands
5592  * @param next_rptr The next offset in the ringbuffer
5593  */
dmub_rb_get_rptr_with_offset(struct dmub_rb * rb,uint32_t num_cmds,uint32_t * next_rptr)5594 static inline void dmub_rb_get_rptr_with_offset(struct dmub_rb *rb,
5595 				  uint32_t num_cmds,
5596 				  uint32_t *next_rptr)
5597 {
5598 	*next_rptr = rb->rptr + DMUB_RB_CMD_SIZE * num_cmds;
5599 
5600 	if (*next_rptr >= rb->capacity)
5601 		*next_rptr %= rb->capacity;
5602 }
5603 
5604 /**
5605  * @brief Returns a pointer to a command in the inbox.
5606  *
5607  * @param rb DMUB inbox ringbuffer
5608  * @param cmd The inbox command to return
5609  * @param rptr The ringbuffer offset
5610  * @return true if not empty
5611  * @return false otherwise
5612  */
dmub_rb_peek_offset(struct dmub_rb * rb,union dmub_rb_cmd ** cmd,uint32_t rptr)5613 static inline bool dmub_rb_peek_offset(struct dmub_rb *rb,
5614 				 union dmub_rb_cmd  **cmd,
5615 				 uint32_t rptr)
5616 {
5617 	uint8_t *rb_cmd = (uint8_t *)(rb->base_address) + rptr;
5618 
5619 	if (dmub_rb_empty(rb))
5620 		return false;
5621 
5622 	*cmd = (union dmub_rb_cmd *)rb_cmd;
5623 
5624 	return true;
5625 }
5626 
5627 /**
5628  * @brief Returns the next unprocessed command in the outbox.
5629  *
5630  * @param rb DMUB outbox ringbuffer
5631  * @param cmd The outbox command to return
5632  * @return true if not empty
5633  * @return false otherwise
5634  */
dmub_rb_out_front(struct dmub_rb * rb,union dmub_rb_out_cmd * cmd)5635 static inline bool dmub_rb_out_front(struct dmub_rb *rb,
5636 				 union dmub_rb_out_cmd *cmd)
5637 {
5638 	const uint64_t volatile *src = (const uint64_t volatile *)((uint8_t *)(rb->base_address) + rb->rptr);
5639 	uint64_t *dst = (uint64_t *)cmd;
5640 	uint8_t i;
5641 
5642 	if (dmub_rb_empty(rb))
5643 		return false;
5644 
5645 	// copying data
5646 	for (i = 0; i < DMUB_RB_CMD_SIZE / sizeof(uint64_t); i++)
5647 		*dst++ = *src++;
5648 
5649 	return true;
5650 }
5651 
5652 /**
5653  * @brief Removes the front entry in the ringbuffer.
5654  *
5655  * @param rb DMUB ringbuffer
5656  * @return true if the command was removed
5657  * @return false if there were no commands
5658  */
dmub_rb_pop_front(struct dmub_rb * rb)5659 static inline bool dmub_rb_pop_front(struct dmub_rb *rb)
5660 {
5661 	if (dmub_rb_empty(rb))
5662 		return false;
5663 
5664 	rb->rptr += DMUB_RB_CMD_SIZE;
5665 
5666 	if (rb->rptr >= rb->capacity)
5667 		rb->rptr %= rb->capacity;
5668 
5669 	return true;
5670 }
5671 
5672 /**
5673  * @brief Flushes commands in the ringbuffer to framebuffer memory.
5674  *
5675  * Avoids a race condition where DMCUB accesses memory while
5676  * there are still writes in flight to framebuffer.
5677  *
5678  * @param rb DMUB ringbuffer
5679  */
dmub_rb_flush_pending(const struct dmub_rb * rb)5680 static inline void dmub_rb_flush_pending(const struct dmub_rb *rb)
5681 {
5682 	uint32_t rptr = rb->rptr;
5683 	uint32_t wptr = rb->wrpt;
5684 
5685 	while (rptr != wptr) {
5686 		uint64_t *data = (uint64_t *)((uint8_t *)(rb->base_address) + rptr);
5687 		uint8_t i;
5688 
5689 		for (i = 0; i < DMUB_RB_CMD_SIZE / sizeof(uint64_t); i++)
5690 			(void)READ_ONCE(*data++);
5691 
5692 		rptr += DMUB_RB_CMD_SIZE;
5693 		if (rptr >= rb->capacity)
5694 			rptr %= rb->capacity;
5695 	}
5696 }
5697 
5698 /**
5699  * @brief Initializes a DMCUB ringbuffer
5700  *
5701  * @param rb DMUB ringbuffer
5702  * @param init_params initial configuration for the ringbuffer
5703  */
dmub_rb_init(struct dmub_rb * rb,struct dmub_rb_init_params * init_params)5704 static inline void dmub_rb_init(struct dmub_rb *rb,
5705 				struct dmub_rb_init_params *init_params)
5706 {
5707 	rb->base_address = init_params->base_address;
5708 	rb->capacity = init_params->capacity;
5709 	rb->rptr = init_params->read_ptr;
5710 	rb->wrpt = init_params->write_ptr;
5711 }
5712 
5713 /**
5714  * @brief Copies output data from in/out commands into the given command.
5715  *
5716  * @param rb DMUB ringbuffer
5717  * @param cmd Command to copy data into
5718  */
dmub_rb_get_return_data(struct dmub_rb * rb,union dmub_rb_cmd * cmd)5719 static inline void dmub_rb_get_return_data(struct dmub_rb *rb,
5720 					   union dmub_rb_cmd *cmd)
5721 {
5722 	// Copy rb entry back into command
5723 	uint8_t *rd_ptr = (rb->rptr == 0) ?
5724 		(uint8_t *)rb->base_address + rb->capacity - DMUB_RB_CMD_SIZE :
5725 		(uint8_t *)rb->base_address + rb->rptr - DMUB_RB_CMD_SIZE;
5726 
5727 	dmub_memcpy(cmd, rd_ptr, DMUB_RB_CMD_SIZE);
5728 }
5729 
5730 //==============================================================================
5731 //</DMUB_RB>====================================================================
5732 //==============================================================================
5733 #endif /* _DMUB_CMD_H_ */
5734