2 * Copyright 2019 Advanced Micro Devices, Inc.
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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.
29 #if defined(_TEST_HARNESS) || defined(FPGA_USB4)
30 #include "dmub_fw_types.h"
31 #include "include_legacy/atomfirmware.h"
33 #if defined(_TEST_HARNESS)
38 #include <asm/byteorder.h>
39 #include <linux/types.h>
40 #include <linux/string.h>
41 #include <linux/delay.h>
43 #include "atomfirmware.h"
45 #endif // defined(_TEST_HARNESS) || defined(FPGA_USB4)
47 /* Firmware versioning. */
48 #ifdef DMUB_EXPOSE_VERSION
49 #define DMUB_FW_VERSION_GIT_HASH 0x7383caadc
50 #define DMUB_FW_VERSION_MAJOR 0
51 #define DMUB_FW_VERSION_MINOR 0
52 #define DMUB_FW_VERSION_REVISION 79
53 #define DMUB_FW_VERSION_TEST 0
54 #define DMUB_FW_VERSION_VBIOS 0
55 #define DMUB_FW_VERSION_HOTFIX 0
56 #define DMUB_FW_VERSION_UCODE (((DMUB_FW_VERSION_MAJOR & 0xFF) << 24) | \
57 ((DMUB_FW_VERSION_MINOR & 0xFF) << 16) | \
58 ((DMUB_FW_VERSION_REVISION & 0xFF) << 8) | \
59 ((DMUB_FW_VERSION_TEST & 0x1) << 7) | \
60 ((DMUB_FW_VERSION_VBIOS & 0x1) << 6) | \
61 (DMUB_FW_VERSION_HOTFIX & 0x3F))
65 //<DMUB_TYPES>==================================================================
66 /* Basic type definitions. */
68 #define __forceinline inline
71 * Flag from driver to indicate that ABM should be disabled gradually
72 * by slowly reversing all backlight programming and pixel compensation.
74 #define SET_ABM_PIPE_GRADUALLY_DISABLE 0
77 * Flag from driver to indicate that ABM should be disabled immediately
78 * and undo all backlight programming and pixel compensation.
80 #define SET_ABM_PIPE_IMMEDIATELY_DISABLE 255
83 * Flag from driver to indicate that ABM should be disabled immediately
84 * and keep the current backlight programming and pixel compensation.
86 #define SET_ABM_PIPE_IMMEDIATE_KEEP_GAIN_DISABLE 254
89 * Flag from driver to set the current ABM pipe index or ABM operating level.
91 #define SET_ABM_PIPE_NORMAL 1
94 * Number of ambient light levels in ABM algorithm.
96 #define NUM_AMBI_LEVEL 5
99 * Number of operating/aggression levels in ABM algorithm.
101 #define NUM_AGGR_LEVEL 4
104 * Number of segments in the gamma curve.
106 #define NUM_POWER_FN_SEGS 8
109 * Number of segments in the backlight curve.
111 #define NUM_BL_CURVE_SEGS 16
113 /* Maximum number of streams on any ASIC. */
114 #define DMUB_MAX_STREAMS 6
116 /* Maximum number of planes on any ASIC. */
117 #define DMUB_MAX_PLANES 6
119 /* Trace buffer offset for entry */
120 #define TRACE_BUFFER_ENTRY_OFFSET 16
124 * PSR control version legacy
126 #define DMUB_CMD_PSR_CONTROL_VERSION_UNKNOWN 0x0
128 * PSR control version with multi edp support
130 #define DMUB_CMD_PSR_CONTROL_VERSION_1 0x1
134 * ABM control version legacy
136 #define DMUB_CMD_ABM_CONTROL_VERSION_UNKNOWN 0x0
139 * ABM control version with multi edp support
141 #define DMUB_CMD_ABM_CONTROL_VERSION_1 0x1
144 * Physical framebuffer address location, 64-bit.
146 #ifndef PHYSICAL_ADDRESS_LOC
147 #define PHYSICAL_ADDRESS_LOC union large_integer
151 * OS/FW agnostic memcpy
154 #define dmub_memcpy(dest, source, bytes) memcpy((dest), (source), (bytes))
158 * OS/FW agnostic memset
161 #define dmub_memset(dest, val, bytes) memset((dest), (val), (bytes))
164 #if defined(__cplusplus)
169 * OS/FW agnostic udelay
172 #define dmub_udelay(microseconds) udelay(microseconds)
176 * Number of nanoseconds per DMUB tick.
177 * DMCUB_TIMER_CURRENT increments in DMUB ticks, which are 10ns by default.
178 * If DMCUB_TIMER_WINDOW is non-zero this will no longer be true.
180 #define NS_PER_DMUB_TICK 10
183 * union dmub_addr - DMUB physical/virtual 64-bit address.
187 uint32_t low_part; /**< Lower 32 bits */
188 uint32_t high_part; /**< Upper 32 bits */
189 } u; /*<< Low/high bit access */
190 uint64_t quad_part; /*<< 64 bit address */
194 * Flags that can be set by driver to change some PSR behaviour.
196 union dmub_psr_debug_flags {
202 * Enable visual confirm in FW.
204 uint32_t visual_confirm : 1;
206 * Use HW Lock Mgr object to do HW locking in FW.
208 uint32_t use_hw_lock_mgr : 1;
214 uint32_t log_line_nums : 1;
218 * Union for debug flags.
224 * DMUB feature capabilities.
225 * After DMUB init, driver will query FW capabilities prior to enabling certain features.
227 struct dmub_feature_caps {
229 * Max PSR version supported by FW.
235 #if defined(__cplusplus)
239 //==============================================================================
240 //</DMUB_TYPES>=================================================================
241 //==============================================================================
242 //< DMUB_META>==================================================================
243 //==============================================================================
244 #pragma pack(push, 1)
246 /* Magic value for identifying dmub_fw_meta_info */
247 #define DMUB_FW_META_MAGIC 0x444D5542
249 /* Offset from the end of the file to the dmub_fw_meta_info */
250 #define DMUB_FW_META_OFFSET 0x24
253 * struct dmub_fw_meta_info - metadata associated with fw binary
255 * NOTE: This should be considered a stable API. Fields should
256 * not be repurposed or reordered. New fields should be
257 * added instead to extend the structure.
259 * @magic_value: magic value identifying DMUB firmware meta info
260 * @fw_region_size: size of the firmware state region
261 * @trace_buffer_size: size of the tracebuffer region
262 * @fw_version: the firmware version information
263 * @dal_fw: 1 if the firmware is DAL
265 struct dmub_fw_meta_info {
266 uint32_t magic_value; /**< magic value identifying DMUB firmware meta info */
267 uint32_t fw_region_size; /**< size of the firmware state region */
268 uint32_t trace_buffer_size; /**< size of the tracebuffer region */
269 uint32_t fw_version; /**< the firmware version information */
270 uint8_t dal_fw; /**< 1 if the firmware is DAL */
271 uint8_t reserved[3]; /**< padding bits */
275 * union dmub_fw_meta - ensures that dmub_fw_meta_info remains 64 bytes
278 struct dmub_fw_meta_info info; /**< metadata info */
279 uint8_t reserved[64]; /**< padding bits */
284 //==============================================================================
285 //< DMUB Trace Buffer>================================================================
286 //==============================================================================
288 * dmub_trace_code_t - firmware trace code, 32-bits
290 typedef uint32_t dmub_trace_code_t;
293 * struct dmcub_trace_buf_entry - Firmware trace entry
295 struct dmcub_trace_buf_entry {
296 dmub_trace_code_t trace_code; /**< trace code for the event */
297 uint32_t tick_count; /**< the tick count at time of trace */
298 uint32_t param0; /**< trace defined parameter 0 */
299 uint32_t param1; /**< trace defined parameter 1 */
302 //==============================================================================
303 //< DMUB_STATUS>================================================================
304 //==============================================================================
307 * DMCUB scratch registers can be used to determine firmware status.
308 * Current scratch register usage is as follows:
310 * SCRATCH0: FW Boot Status register
311 * SCRATCH5: LVTMA Status Register
312 * SCRATCH15: FW Boot Options register
316 * union dmub_fw_boot_status - Status bit definitions for SCRATCH0.
318 union dmub_fw_boot_status {
320 uint32_t dal_fw : 1; /**< 1 if DAL FW */
321 uint32_t mailbox_rdy : 1; /**< 1 if mailbox ready */
322 uint32_t optimized_init_done : 1; /**< 1 if optimized init done */
323 uint32_t restore_required : 1; /**< 1 if driver should call restore */
324 uint32_t defer_load : 1; /**< 1 if VBIOS data is deferred programmed */
325 uint32_t reserved : 1;
326 uint32_t detection_required: 1; /**< if detection need to be triggered by driver */
328 } bits; /**< status bits */
329 uint32_t all; /**< 32-bit access to status bits */
333 * enum dmub_fw_boot_status_bit - Enum bit definitions for SCRATCH0.
335 enum dmub_fw_boot_status_bit {
336 DMUB_FW_BOOT_STATUS_BIT_DAL_FIRMWARE = (1 << 0), /**< 1 if DAL FW */
337 DMUB_FW_BOOT_STATUS_BIT_MAILBOX_READY = (1 << 1), /**< 1 if mailbox ready */
338 DMUB_FW_BOOT_STATUS_BIT_OPTIMIZED_INIT_DONE = (1 << 2), /**< 1 if init done */
339 DMUB_FW_BOOT_STATUS_BIT_RESTORE_REQUIRED = (1 << 3), /**< 1 if driver should call restore */
340 DMUB_FW_BOOT_STATUS_BIT_DEFERRED_LOADED = (1 << 4), /**< 1 if VBIOS data is deferred programmed */
341 DMUB_FW_BOOT_STATUS_BIT_DETECTION_REQUIRED = (1 << 6), /**< 1 if detection need to be triggered by driver*/
344 /* Register bit definition for SCRATCH5 */
345 union dmub_lvtma_status {
349 uint32_t reserved : 30;
354 enum dmub_lvtma_status_bit {
355 DMUB_LVTMA_STATUS_BIT_PSP_OK = (1 << 0),
356 DMUB_LVTMA_STATUS_BIT_EDP_ON = (1 << 1),
360 * union dmub_fw_boot_options - Boot option definitions for SCRATCH14
362 union dmub_fw_boot_options {
364 uint32_t pemu_env : 1; /**< 1 if PEMU */
365 uint32_t fpga_env : 1; /**< 1 if FPGA */
366 uint32_t optimized_init : 1; /**< 1 if optimized init */
367 uint32_t skip_phy_access : 1; /**< 1 if PHY access should be skipped */
368 uint32_t disable_clk_gate: 1; /**< 1 if clock gating should be disabled */
369 uint32_t skip_phy_init_panel_sequence: 1; /**< 1 to skip panel init seq */
370 uint32_t z10_disable: 1; /**< 1 to disable z10 */
371 uint32_t reserved2: 1; /**< reserved for an unreleased feature */
372 uint32_t reserved_unreleased1: 1; /**< reserved for an unreleased feature */
373 uint32_t invalid_vbios_data: 1; /**< 1 if VBIOS data table is invalid */
374 uint32_t reserved : 23; /**< reserved */
375 } bits; /**< boot bits */
376 uint32_t all; /**< 32-bit access to bits */
379 enum dmub_fw_boot_options_bit {
380 DMUB_FW_BOOT_OPTION_BIT_PEMU_ENV = (1 << 0), /**< 1 if PEMU */
381 DMUB_FW_BOOT_OPTION_BIT_FPGA_ENV = (1 << 1), /**< 1 if FPGA */
382 DMUB_FW_BOOT_OPTION_BIT_OPTIMIZED_INIT_DONE = (1 << 2), /**< 1 if optimized init done */
385 //==============================================================================
386 //</DMUB_STATUS>================================================================
387 //==============================================================================
388 //< DMUB_VBIOS>=================================================================
389 //==============================================================================
392 * enum dmub_cmd_vbios_type - VBIOS commands.
394 * Command IDs should be treated as stable ABI.
395 * Do not reuse or modify IDs.
397 enum dmub_cmd_vbios_type {
399 * Configures the DIG encoder.
401 DMUB_CMD__VBIOS_DIGX_ENCODER_CONTROL = 0,
405 DMUB_CMD__VBIOS_DIG1_TRANSMITTER_CONTROL = 1,
407 * Sets the pixel clock/symbol clock.
409 DMUB_CMD__VBIOS_SET_PIXEL_CLOCK = 2,
411 * Enables or disables power gating.
413 DMUB_CMD__VBIOS_ENABLE_DISP_POWER_GATING = 3,
414 DMUB_CMD__VBIOS_LVTMA_CONTROL = 15,
417 //==============================================================================
418 //</DMUB_VBIOS>=================================================================
419 //==============================================================================
420 //< DMUB_GPINT>=================================================================
421 //==============================================================================
424 * The shifts and masks below may alternatively be used to format and read
425 * the command register bits.
428 #define DMUB_GPINT_DATA_PARAM_MASK 0xFFFF
429 #define DMUB_GPINT_DATA_PARAM_SHIFT 0
431 #define DMUB_GPINT_DATA_COMMAND_CODE_MASK 0xFFF
432 #define DMUB_GPINT_DATA_COMMAND_CODE_SHIFT 16
434 #define DMUB_GPINT_DATA_STATUS_MASK 0xF
435 #define DMUB_GPINT_DATA_STATUS_SHIFT 28
442 * Return response for DMUB_GPINT__STOP_FW command.
444 #define DMUB_GPINT__STOP_FW_RESPONSE 0xDEADDEAD
447 * union dmub_gpint_data_register - Format for sending a command via the GPINT.
449 union dmub_gpint_data_register {
451 uint32_t param : 16; /**< 16-bit parameter */
452 uint32_t command_code : 12; /**< GPINT command */
453 uint32_t status : 4; /**< Command status bit */
454 } bits; /**< GPINT bit access */
455 uint32_t all; /**< GPINT 32-bit access */
459 * enum dmub_gpint_command - GPINT command to DMCUB FW
461 * Command IDs should be treated as stable ABI.
462 * Do not reuse or modify IDs.
464 enum dmub_gpint_command {
466 * Invalid command, ignored.
468 DMUB_GPINT__INVALID_COMMAND = 0,
470 * DESC: Queries the firmware version.
471 * RETURN: Firmware version.
473 DMUB_GPINT__GET_FW_VERSION = 1,
475 * DESC: Halts the firmware.
476 * RETURN: DMUB_GPINT__STOP_FW_RESPONSE (0xDEADDEAD) when halted
478 DMUB_GPINT__STOP_FW = 2,
480 * DESC: Get PSR state from FW.
481 * RETURN: PSR state enum. This enum may need to be converted to the legacy PSR state value.
483 DMUB_GPINT__GET_PSR_STATE = 7,
485 * DESC: Notifies DMCUB of the currently active streams.
486 * ARGS: Stream mask, 1 bit per active stream index.
488 DMUB_GPINT__IDLE_OPT_NOTIFY_STREAM_MASK = 8,
490 * DESC: Start PSR residency counter. Stop PSR resdiency counter and get value.
491 * ARGS: We can measure residency from various points. The argument will specify the residency mode.
492 * By default, it is measured from after we powerdown the PHY, to just before we powerup the PHY.
493 * RETURN: PSR residency in milli-percent.
495 DMUB_GPINT__PSR_RESIDENCY = 9,
498 * DESC: Notifies DMCUB detection is done so detection required can be cleared.
500 DMUB_GPINT__NOTIFY_DETECTION_DONE = 12,
504 * INBOX0 generic command definition
506 union dmub_inbox0_cmd_common {
508 uint32_t command_code: 8; /**< INBOX0 command code */
509 uint32_t param: 24; /**< 24-bit parameter */
515 * INBOX0 hw_lock command definition
517 union dmub_inbox0_cmd_lock_hw {
519 uint32_t command_code: 8;
521 /* NOTE: Must be have enough bits to match: enum hw_lock_client */
522 uint32_t hw_lock_client: 1;
524 /* NOTE: Below fields must match with: struct dmub_hw_lock_inst_flags */
525 uint32_t otg_inst: 3;
526 uint32_t opp_inst: 3;
527 uint32_t dig_inst: 3;
529 /* NOTE: Below fields must match with: union dmub_hw_lock_flags */
530 uint32_t lock_pipe: 1;
531 uint32_t lock_cursor: 1;
532 uint32_t lock_dig: 1;
533 uint32_t triple_buffer_lock: 1;
535 uint32_t lock: 1; /**< Lock */
536 uint32_t should_release: 1; /**< Release */
537 uint32_t reserved: 8; /**< Reserved for extending more clients, HW, etc. */
542 union dmub_inbox0_data_register {
543 union dmub_inbox0_cmd_common inbox0_cmd_common;
544 union dmub_inbox0_cmd_lock_hw inbox0_cmd_lock_hw;
547 enum dmub_inbox0_command {
549 * DESC: Invalid command, ignored.
551 DMUB_INBOX0_CMD__INVALID_COMMAND = 0,
553 * DESC: Notification to acquire/release HW lock
556 DMUB_INBOX0_CMD__HW_LOCK = 1,
558 //==============================================================================
559 //</DMUB_GPINT>=================================================================
560 //==============================================================================
561 //< DMUB_CMD>===================================================================
562 //==============================================================================
565 * Size in bytes of each DMUB command.
567 #define DMUB_RB_CMD_SIZE 64
570 * Maximum number of items in the DMUB ringbuffer.
572 #define DMUB_RB_MAX_ENTRY 128
575 * Ringbuffer size in bytes.
577 #define DMUB_RB_SIZE (DMUB_RB_CMD_SIZE * DMUB_RB_MAX_ENTRY)
580 * REG_SET mask for reg offload.
582 #define REG_SET_MASK 0xFFFF
585 * enum dmub_cmd_type - DMUB inbox command.
587 * Command IDs should be treated as stable ABI.
588 * Do not reuse or modify IDs.
596 * Read modify write register sequence offload.
598 DMUB_CMD__REG_SEQ_READ_MODIFY_WRITE = 1,
600 * Field update register sequence offload.
602 DMUB_CMD__REG_SEQ_FIELD_UPDATE_SEQ = 2,
604 * Burst write sequence offload.
606 DMUB_CMD__REG_SEQ_BURST_WRITE = 3,
608 * Reg wait sequence offload.
610 DMUB_CMD__REG_REG_WAIT = 4,
612 * Workaround to avoid HUBP underflow during NV12 playback.
614 DMUB_CMD__PLAT_54186_WA = 5,
616 * Command type used to query FW feature caps.
618 DMUB_CMD__QUERY_FEATURE_CAPS = 6,
620 * Command type used for all PSR commands.
624 * Command type used for all MALL commands.
628 * Command type used for all ABM commands.
632 * Command type used for HW locking in FW.
634 DMUB_CMD__HW_LOCK = 69,
636 * Command type used to access DP AUX.
638 DMUB_CMD__DP_AUX_ACCESS = 70,
640 * Command type used for OUTBOX1 notification enable
642 DMUB_CMD__OUTBOX1_ENABLE = 71,
644 * Command type used for all idle optimization commands.
646 DMUB_CMD__IDLE_OPT = 72,
648 * Command type used for all clock manager commands.
650 DMUB_CMD__CLK_MGR = 73,
652 * Command type used for all panel control commands.
654 DMUB_CMD__PANEL_CNTL = 74,
656 * Command type used for EDID CEA parsing
658 DMUB_CMD__EDID_CEA = 79,
660 * Command type used for all VBIOS interface commands.
662 DMUB_CMD__VBIOS = 128,
666 * enum dmub_out_cmd_type - DMUB outbox commands.
668 enum dmub_out_cmd_type {
670 * Invalid outbox command, ignored.
672 DMUB_OUT_CMD__NULL = 0,
674 * Command type used for DP AUX Reply data notification
676 DMUB_OUT_CMD__DP_AUX_REPLY = 1,
679 #pragma pack(push, 1)
682 * struct dmub_cmd_header - Common command header fields.
684 struct dmub_cmd_header {
685 unsigned int type : 8; /**< command type */
686 unsigned int sub_type : 8; /**< command sub type */
687 unsigned int ret_status : 1; /**< 1 if returned data, 0 otherwise */
688 unsigned int multi_cmd_pending : 1; /**< 1 if multiple commands chained together */
689 unsigned int reserved0 : 6; /**< reserved bits */
690 unsigned int payload_bytes : 6; /* payload excluding header - up to 60 bytes */
691 unsigned int reserved1 : 2; /**< reserved bits */
695 * struct dmub_cmd_read_modify_write_sequence - Read modify write
697 * 60 payload bytes can hold up to 5 sets of read modify writes,
698 * each take 3 dwords.
700 * number of sequences = header.payload_bytes / sizeof(struct dmub_cmd_read_modify_write_sequence)
702 * modify_mask = 0xffff'ffff means all fields are going to be updated. in this case
703 * command parser will skip the read and we can use modify_mask = 0xffff'ffff as reg write
705 struct dmub_cmd_read_modify_write_sequence {
706 uint32_t addr; /**< register address */
707 uint32_t modify_mask; /**< modify mask */
708 uint32_t modify_value; /**< modify value */
712 * Maximum number of ops in read modify write sequence.
714 #define DMUB_READ_MODIFY_WRITE_SEQ__MAX 5
717 * struct dmub_cmd_read_modify_write_sequence - Read modify write command.
719 struct dmub_rb_cmd_read_modify_write {
720 struct dmub_cmd_header header; /**< command header */
722 * Read modify write sequence.
724 struct dmub_cmd_read_modify_write_sequence seq[DMUB_READ_MODIFY_WRITE_SEQ__MAX];
728 * Update a register with specified masks and values sequeunce
730 * 60 payload bytes can hold address + up to 7 sets of mask/value combo, each take 2 dword
732 * number of field update sequence = (header.payload_bytes - sizeof(addr)) / sizeof(struct read_modify_write_sequence)
736 * 1. auto-increment register where additional read would update pointer and produce wrong result
737 * 2. toggle a bit without read in the middle
740 struct dmub_cmd_reg_field_update_sequence {
741 uint32_t modify_mask; /**< 0xffff'ffff to skip initial read */
742 uint32_t modify_value; /**< value to update with */
746 * Maximum number of ops in field update sequence.
748 #define DMUB_REG_FIELD_UPDATE_SEQ__MAX 7
751 * struct dmub_rb_cmd_reg_field_update_sequence - Field update command.
753 struct dmub_rb_cmd_reg_field_update_sequence {
754 struct dmub_cmd_header header; /**< command header */
755 uint32_t addr; /**< register address */
757 * Field update sequence.
759 struct dmub_cmd_reg_field_update_sequence seq[DMUB_REG_FIELD_UPDATE_SEQ__MAX];
764 * Maximum number of burst write values.
766 #define DMUB_BURST_WRITE_VALUES__MAX 14
769 * struct dmub_rb_cmd_burst_write - Burst write
771 * support use case such as writing out LUTs.
773 * 60 payload bytes can hold up to 14 values to write to given address
775 * number of payload = header.payload_bytes / sizeof(struct read_modify_write_sequence)
777 struct dmub_rb_cmd_burst_write {
778 struct dmub_cmd_header header; /**< command header */
779 uint32_t addr; /**< register start address */
781 * Burst write register values.
783 uint32_t write_values[DMUB_BURST_WRITE_VALUES__MAX];
787 * struct dmub_rb_cmd_common - Common command header
789 struct dmub_rb_cmd_common {
790 struct dmub_cmd_header header; /**< command header */
792 * Padding to RB_CMD_SIZE
794 uint8_t cmd_buffer[DMUB_RB_CMD_SIZE - sizeof(struct dmub_cmd_header)];
798 * struct dmub_cmd_reg_wait_data - Register wait data
800 struct dmub_cmd_reg_wait_data {
801 uint32_t addr; /**< Register address */
802 uint32_t mask; /**< Mask for register bits */
803 uint32_t condition_field_value; /**< Value to wait for */
804 uint32_t time_out_us; /**< Time out for reg wait in microseconds */
808 * struct dmub_rb_cmd_reg_wait - Register wait command
810 struct dmub_rb_cmd_reg_wait {
811 struct dmub_cmd_header header; /**< Command header */
812 struct dmub_cmd_reg_wait_data reg_wait; /**< Register wait data */
816 * struct dmub_cmd_PLAT_54186_wa - Underflow workaround
818 * Reprograms surface parameters to avoid underflow.
820 struct dmub_cmd_PLAT_54186_wa {
821 uint32_t DCSURF_SURFACE_CONTROL; /**< reg value */
822 uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS_HIGH; /**< reg value */
823 uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS; /**< reg value */
824 uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS_HIGH_C; /**< reg value */
825 uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS_C; /**< reg value */
827 uint8_t hubp_inst : 4; /**< HUBP instance */
828 uint8_t tmz_surface : 1; /**< TMZ enable or disable */
829 uint8_t immediate :1; /**< Immediate flip */
830 uint8_t vmid : 4; /**< VMID */
831 uint8_t grph_stereo : 1; /**< 1 if stereo */
832 uint32_t reserved : 21; /**< Reserved */
833 } flip_params; /**< Pageflip parameters */
834 uint32_t reserved[9]; /**< Reserved bits */
838 * struct dmub_rb_cmd_PLAT_54186_wa - Underflow workaround command
840 struct dmub_rb_cmd_PLAT_54186_wa {
841 struct dmub_cmd_header header; /**< Command header */
842 struct dmub_cmd_PLAT_54186_wa flip; /**< Flip data */
846 * struct dmub_rb_cmd_mall - MALL command data.
848 struct dmub_rb_cmd_mall {
849 struct dmub_cmd_header header; /**< Common command header */
850 union dmub_addr cursor_copy_src; /**< Cursor copy address */
851 union dmub_addr cursor_copy_dst; /**< Cursor copy destination */
852 uint32_t tmr_delay; /**< Timer delay */
853 uint32_t tmr_scale; /**< Timer scale */
854 uint16_t cursor_width; /**< Cursor width in pixels */
855 uint16_t cursor_pitch; /**< Cursor pitch in pixels */
856 uint16_t cursor_height; /**< Cursor height in pixels */
857 uint8_t cursor_bpp; /**< Cursor bits per pixel */
858 uint8_t debug_bits; /**< Debug bits */
860 uint8_t reserved1; /**< Reserved bits */
861 uint8_t reserved2; /**< Reserved bits */
865 * enum dmub_cmd_idle_opt_type - Idle optimization command type.
867 enum dmub_cmd_idle_opt_type {
869 * DCN hardware restore.
871 DMUB_CMD__IDLE_OPT_DCN_RESTORE = 0,
876 DMUB_CMD__IDLE_OPT_DCN_SAVE_INIT = 1
880 * struct dmub_rb_cmd_idle_opt_dcn_restore - DCN restore command data.
882 struct dmub_rb_cmd_idle_opt_dcn_restore {
883 struct dmub_cmd_header header; /**< header */
887 * struct dmub_clocks - Clock update notification.
890 uint32_t dispclk_khz; /**< dispclk kHz */
891 uint32_t dppclk_khz; /**< dppclk kHz */
892 uint32_t dcfclk_khz; /**< dcfclk kHz */
893 uint32_t dcfclk_deep_sleep_khz; /**< dcfclk deep sleep kHz */
897 * enum dmub_cmd_clk_mgr_type - Clock manager commands.
899 enum dmub_cmd_clk_mgr_type {
901 * Notify DMCUB of clock update.
903 DMUB_CMD__CLK_MGR_NOTIFY_CLOCKS = 0,
907 * struct dmub_rb_cmd_clk_mgr_notify_clocks - Clock update notification.
909 struct dmub_rb_cmd_clk_mgr_notify_clocks {
910 struct dmub_cmd_header header; /**< header */
911 struct dmub_clocks clocks; /**< clock data */
915 * struct dmub_cmd_digx_encoder_control_data - Encoder control data.
917 struct dmub_cmd_digx_encoder_control_data {
918 union dig_encoder_control_parameters_v1_5 dig; /**< payload */
922 * struct dmub_rb_cmd_digx_encoder_control - Encoder control command.
924 struct dmub_rb_cmd_digx_encoder_control {
925 struct dmub_cmd_header header; /**< header */
926 struct dmub_cmd_digx_encoder_control_data encoder_control; /**< payload */
930 * struct dmub_cmd_set_pixel_clock_data - Set pixel clock data.
932 struct dmub_cmd_set_pixel_clock_data {
933 struct set_pixel_clock_parameter_v1_7 clk; /**< payload */
937 * struct dmub_cmd_set_pixel_clock_data - Set pixel clock command.
939 struct dmub_rb_cmd_set_pixel_clock {
940 struct dmub_cmd_header header; /**< header */
941 struct dmub_cmd_set_pixel_clock_data pixel_clock; /**< payload */
945 * struct dmub_cmd_enable_disp_power_gating_data - Display power gating.
947 struct dmub_cmd_enable_disp_power_gating_data {
948 struct enable_disp_power_gating_parameters_v2_1 pwr; /**< payload */
952 * struct dmub_rb_cmd_enable_disp_power_gating - Display power command.
954 struct dmub_rb_cmd_enable_disp_power_gating {
955 struct dmub_cmd_header header; /**< header */
956 struct dmub_cmd_enable_disp_power_gating_data power_gating; /**< payload */
960 * struct dmub_dig_transmitter_control_data_v1_7 - Transmitter control.
962 struct dmub_dig_transmitter_control_data_v1_7 {
963 uint8_t phyid; /**< 0=UNIPHYA, 1=UNIPHYB, 2=UNIPHYC, 3=UNIPHYD, 4=UNIPHYE, 5=UNIPHYF */
964 uint8_t action; /**< Defined as ATOM_TRANSMITER_ACTION_xxx */
966 uint8_t digmode; /**< enum atom_encode_mode_def */
967 uint8_t dplaneset; /**< DP voltage swing and pre-emphasis value, "DP_LANE_SET__xDB_y_zV" */
969 uint8_t lanenum; /**< Number of lanes */
971 uint32_t symclk_10khz; /**< Symbol Clock in 10Khz */
973 uint8_t hpdsel; /**< =1: HPD1, =2: HPD2, ..., =6: HPD6, =0: HPD is not assigned */
974 uint8_t digfe_sel; /**< DIG front-end selection, bit0 means DIG0 FE is enabled */
975 uint8_t connobj_id; /**< Connector Object Id defined in ObjectId.h */
976 uint8_t reserved0; /**< For future use */
977 uint8_t reserved1; /**< For future use */
978 uint8_t reserved2[3]; /**< For future use */
979 uint32_t reserved3[11]; /**< For future use */
983 * union dmub_cmd_dig1_transmitter_control_data - Transmitter control data.
985 union dmub_cmd_dig1_transmitter_control_data {
986 struct dig_transmitter_control_parameters_v1_6 dig; /**< payload */
987 struct dmub_dig_transmitter_control_data_v1_7 dig_v1_7; /**< payload 1.7 */
991 * struct dmub_rb_cmd_dig1_transmitter_control - Transmitter control command.
993 struct dmub_rb_cmd_dig1_transmitter_control {
994 struct dmub_cmd_header header; /**< header */
995 union dmub_cmd_dig1_transmitter_control_data transmitter_control; /**< payload */
999 * struct dmub_rb_cmd_dpphy_init - DPPHY init.
1001 struct dmub_rb_cmd_dpphy_init {
1002 struct dmub_cmd_header header; /**< header */
1003 uint8_t reserved[60]; /**< reserved bits */
1007 * enum dp_aux_request_action - DP AUX request command listing.
1009 * 4 AUX request command bits are shifted to high nibble.
1011 enum dp_aux_request_action {
1012 /** I2C-over-AUX write request */
1013 DP_AUX_REQ_ACTION_I2C_WRITE = 0x00,
1014 /** I2C-over-AUX read request */
1015 DP_AUX_REQ_ACTION_I2C_READ = 0x10,
1016 /** I2C-over-AUX write status request */
1017 DP_AUX_REQ_ACTION_I2C_STATUS_REQ = 0x20,
1018 /** I2C-over-AUX write request with MOT=1 */
1019 DP_AUX_REQ_ACTION_I2C_WRITE_MOT = 0x40,
1020 /** I2C-over-AUX read request with MOT=1 */
1021 DP_AUX_REQ_ACTION_I2C_READ_MOT = 0x50,
1022 /** I2C-over-AUX write status request with MOT=1 */
1023 DP_AUX_REQ_ACTION_I2C_STATUS_REQ_MOT = 0x60,
1024 /** Native AUX write request */
1025 DP_AUX_REQ_ACTION_DPCD_WRITE = 0x80,
1026 /** Native AUX read request */
1027 DP_AUX_REQ_ACTION_DPCD_READ = 0x90
1031 * enum aux_return_code_type - DP AUX process return code listing.
1033 enum aux_return_code_type {
1034 /** AUX process succeeded */
1035 AUX_RET_SUCCESS = 0,
1036 /** AUX process failed with unknown reason */
1037 AUX_RET_ERROR_UNKNOWN,
1038 /** AUX process completed with invalid reply */
1039 AUX_RET_ERROR_INVALID_REPLY,
1040 /** AUX process timed out */
1041 AUX_RET_ERROR_TIMEOUT,
1042 /** HPD was low during AUX process */
1043 AUX_RET_ERROR_HPD_DISCON,
1044 /** Failed to acquire AUX engine */
1045 AUX_RET_ERROR_ENGINE_ACQUIRE,
1046 /** AUX request not supported */
1047 AUX_RET_ERROR_INVALID_OPERATION,
1048 /** AUX process not available */
1049 AUX_RET_ERROR_PROTOCOL_ERROR,
1053 * enum aux_channel_type - DP AUX channel type listing.
1055 enum aux_channel_type {
1056 /** AUX thru Legacy DP AUX */
1057 AUX_CHANNEL_LEGACY_DDC,
1058 /** AUX thru DPIA DP tunneling */
1063 * struct aux_transaction_parameters - DP AUX request transaction data
1065 struct aux_transaction_parameters {
1066 uint8_t is_i2c_over_aux; /**< 0=native AUX, 1=I2C-over-AUX */
1067 uint8_t action; /**< enum dp_aux_request_action */
1068 uint8_t length; /**< DP AUX request data length */
1069 uint8_t reserved; /**< For future use */
1070 uint32_t address; /**< DP AUX address */
1071 uint8_t data[16]; /**< DP AUX write data */
1075 * Data passed from driver to FW in a DMUB_CMD__DP_AUX_ACCESS command.
1077 struct dmub_cmd_dp_aux_control_data {
1078 uint8_t instance; /**< AUX instance or DPIA instance */
1079 uint8_t manual_acq_rel_enable; /**< manual control for acquiring or releasing AUX channel */
1080 uint8_t sw_crc_enabled; /**< Use software CRC for tunneling packet instead of hardware CRC */
1081 uint8_t reserved0; /**< For future use */
1082 uint16_t timeout; /**< timeout time in us */
1083 uint16_t reserved1; /**< For future use */
1084 enum aux_channel_type type; /**< enum aux_channel_type */
1085 struct aux_transaction_parameters dpaux; /**< struct aux_transaction_parameters */
1089 * Definition of a DMUB_CMD__DP_AUX_ACCESS command.
1091 struct dmub_rb_cmd_dp_aux_access {
1095 struct dmub_cmd_header header;
1097 * Data passed from driver to FW in a DMUB_CMD__DP_AUX_ACCESS command.
1099 struct dmub_cmd_dp_aux_control_data aux_control;
1103 * Definition of a DMUB_CMD__OUTBOX1_ENABLE command.
1105 struct dmub_rb_cmd_outbox1_enable {
1109 struct dmub_cmd_header header;
1111 * enable: 0x0 -> disable outbox1 notification (default value)
1112 * 0x1 -> enable outbox1 notification
1117 /* DP AUX Reply command - OutBox Cmd */
1119 * Data passed to driver from FW in a DMUB_OUT_CMD__DP_AUX_REPLY command.
1121 struct aux_reply_data {
1127 * Aux reply data length (max: 16 bytes)
1141 * Control Data passed to driver from FW in a DMUB_OUT_CMD__DP_AUX_REPLY command.
1143 struct aux_reply_control_data {
1145 * Reserved for future use
1153 * Aux transaction result: definition in enum aux_return_code_type
1163 * Definition of a DMUB_OUT_CMD__DP_AUX_REPLY command.
1165 struct dmub_rb_cmd_dp_aux_reply {
1169 struct dmub_cmd_header header;
1171 * Control Data passed to driver from FW in a DMUB_OUT_CMD__DP_AUX_REPLY command.
1173 struct aux_reply_control_data control;
1175 * Data passed to driver from FW in a DMUB_OUT_CMD__DP_AUX_REPLY command.
1177 struct aux_reply_data reply_data;
1180 /* DP HPD Notify command - OutBox Cmd */
1190 * DP HPD short pulse
1198 enum dp_hpd_status {
1204 * DP_HPD status high
1210 * Data passed to driver from FW in a DMUB_OUT_CMD__DP_HPD_NOTIFY command.
1212 struct dp_hpd_data {
1222 * HPD status: only for type: DP_HPD to indicate status
1232 * Definition of a DMUB_OUT_CMD__DP_HPD_NOTIFY command.
1234 struct dmub_rb_cmd_dp_hpd_notify {
1238 struct dmub_cmd_header header;
1240 * Data passed to driver from FW in a DMUB_OUT_CMD__DP_HPD_NOTIFY command.
1242 struct dp_hpd_data hpd_data;
1246 * Command IDs should be treated as stable ABI.
1247 * Do not reuse or modify IDs.
1251 * PSR command sub-types.
1253 enum dmub_cmd_psr_type {
1255 * Set PSR version support.
1257 DMUB_CMD__PSR_SET_VERSION = 0,
1259 * Copy driver-calculated parameters to PSR state.
1261 DMUB_CMD__PSR_COPY_SETTINGS = 1,
1265 DMUB_CMD__PSR_ENABLE = 2,
1270 DMUB_CMD__PSR_DISABLE = 3,
1274 * PSR level is a 16-bit value dicated by driver that
1275 * will enable/disable different functionality.
1277 DMUB_CMD__PSR_SET_LEVEL = 4,
1280 * Forces PSR enabled until an explicit PSR disable call.
1282 DMUB_CMD__PSR_FORCE_STATIC = 5,
1294 * PSR not supported.
1296 PSR_VERSION_UNSUPPORTED = 0xFFFFFFFF,
1300 * enum dmub_cmd_mall_type - MALL commands
1302 enum dmub_cmd_mall_type {
1304 * Allows display refresh from MALL.
1306 DMUB_CMD__MALL_ACTION_ALLOW = 0,
1308 * Disallows display refresh from MALL.
1310 DMUB_CMD__MALL_ACTION_DISALLOW = 1,
1312 * Cursor copy for MALL.
1314 DMUB_CMD__MALL_ACTION_COPY_CURSOR = 2,
1316 * Controls DF requests.
1318 DMUB_CMD__MALL_ACTION_NO_DF_REQ = 3,
1323 * Data passed from driver to FW in a DMUB_CMD__PSR_COPY_SETTINGS command.
1325 struct dmub_cmd_psr_copy_settings_data {
1327 * Flags that can be set by driver to change some PSR behaviour.
1329 union dmub_psr_debug_flags debug;
1331 * 16-bit value dicated by driver that will enable/disable different functionality.
1340 * Not used in dmub fw,
1341 * dmub fw will get active opp by reading odm registers.
1346 * Not used in dmub fw,
1347 * dmub fw will get active opp by reading odm registers.
1355 * DIG FE HW instance.
1359 * DIG BE HW instance.
1363 * DP PHY HW instance.
1371 * Determines if SMU optimzations are enabled/disabled.
1373 uint8_t smu_optimizations_en;
1378 uint8_t frame_delay;
1380 * If RFB setup time is greater than the total VBLANK time,
1381 * it is not possible for the sink to capture the video frame
1382 * in the same frame the SDP is sent. In this case,
1383 * the frame capture indication bit should be set and an extra
1384 * static frame should be transmitted to the sink.
1386 uint8_t frame_cap_ind;
1388 * Explicit padding to 4 byte boundary.
1392 * Multi-display optimizations are implemented on certain ASICs.
1394 uint8_t multi_disp_optimizations_en;
1396 * The last possible line SDP may be transmitted without violating
1397 * the RFB setup time or entering the active video frame.
1399 uint16_t init_sdp_deadline;
1401 * Explicit padding to 4 byte boundary.
1405 * Length of each horizontal line in us.
1407 uint32_t line_time_in_us;
1409 * FEC enable status in driver
1411 uint8_t fec_enable_status;
1413 * FEC re-enable delay when PSR exit.
1414 * unit is 100us, range form 0~255(0xFF).
1416 uint8_t fec_enable_delay_in100us;
1418 * PSR control version.
1420 uint8_t cmd_version;
1423 * Panel isntance to identify which psr_state to use
1424 * Currently the support is only for 0 or 1
1428 * Explicit padding to 4 byte boundary.
1434 * Definition of a DMUB_CMD__PSR_COPY_SETTINGS command.
1436 struct dmub_rb_cmd_psr_copy_settings {
1440 struct dmub_cmd_header header;
1442 * Data passed from driver to FW in a DMUB_CMD__PSR_COPY_SETTINGS command.
1444 struct dmub_cmd_psr_copy_settings_data psr_copy_settings_data;
1448 * Data passed from driver to FW in a DMUB_CMD__PSR_SET_LEVEL command.
1450 struct dmub_cmd_psr_set_level_data {
1452 * 16-bit value dicated by driver that will enable/disable different functionality.
1456 * PSR control version.
1458 uint8_t cmd_version;
1461 * Panel isntance to identify which psr_state to use
1462 * Currently the support is only for 0 or 1
1468 * Definition of a DMUB_CMD__PSR_SET_LEVEL command.
1470 struct dmub_rb_cmd_psr_set_level {
1474 struct dmub_cmd_header header;
1476 * Definition of a DMUB_CMD__PSR_SET_LEVEL command.
1478 struct dmub_cmd_psr_set_level_data psr_set_level_data;
1481 struct dmub_rb_cmd_psr_enable_data {
1483 * PSR control version.
1485 uint8_t cmd_version;
1488 * Panel isntance to identify which psr_state to use
1489 * Currently the support is only for 0 or 1
1493 * Explicit padding to 4 byte boundary.
1499 * Definition of a DMUB_CMD__PSR_ENABLE command.
1500 * PSR enable/disable is controlled using the sub_type.
1502 struct dmub_rb_cmd_psr_enable {
1506 struct dmub_cmd_header header;
1508 struct dmub_rb_cmd_psr_enable_data data;
1512 * Data passed from driver to FW in a DMUB_CMD__PSR_SET_VERSION command.
1514 struct dmub_cmd_psr_set_version_data {
1516 * PSR version that FW should implement.
1518 enum psr_version version;
1520 * PSR control version.
1522 uint8_t cmd_version;
1525 * Panel isntance to identify which psr_state to use
1526 * Currently the support is only for 0 or 1
1530 * Explicit padding to 4 byte boundary.
1536 * Definition of a DMUB_CMD__PSR_SET_VERSION command.
1538 struct dmub_rb_cmd_psr_set_version {
1542 struct dmub_cmd_header header;
1544 * Data passed from driver to FW in a DMUB_CMD__PSR_SET_VERSION command.
1546 struct dmub_cmd_psr_set_version_data psr_set_version_data;
1549 struct dmub_cmd_psr_force_static_data {
1551 * PSR control version.
1553 uint8_t cmd_version;
1556 * Panel isntance to identify which psr_state to use
1557 * Currently the support is only for 0 or 1
1561 * Explicit padding to 4 byte boundary.
1567 * Definition of a DMUB_CMD__PSR_FORCE_STATIC command.
1569 struct dmub_rb_cmd_psr_force_static {
1573 struct dmub_cmd_header header;
1575 * Data passed from driver to FW in a DMUB_CMD__PSR_FORCE_STATIC command.
1577 struct dmub_cmd_psr_force_static_data psr_force_static_data;
1581 * Set of HW components that can be locked.
1583 * Note: If updating with more HW components, fields
1584 * in dmub_inbox0_cmd_lock_hw must be updated to match.
1586 union dmub_hw_lock_flags {
1588 * Set of HW components that can be locked.
1592 * Lock/unlock OTG master update lock.
1594 uint8_t lock_pipe : 1;
1596 * Lock/unlock cursor.
1598 uint8_t lock_cursor : 1;
1600 * Lock/unlock global update lock.
1602 uint8_t lock_dig : 1;
1604 * Triple buffer lock requires additional hw programming to usual OTG master lock.
1606 uint8_t triple_buffer_lock : 1;
1610 * Union for HW Lock flags.
1616 * Instances of HW to be locked.
1618 * Note: If updating with more HW components, fields
1619 * in dmub_inbox0_cmd_lock_hw must be updated to match.
1621 struct dmub_hw_lock_inst_flags {
1623 * OTG HW instance for OTG master update lock.
1627 * OPP instance for cursor lock.
1631 * OTG HW instance for global update lock.
1632 * TODO: Remove, and re-use otg_inst.
1636 * Explicit pad to 4 byte boundary.
1642 * Clients that can acquire the HW Lock Manager.
1644 * Note: If updating with more clients, fields in
1645 * dmub_inbox0_cmd_lock_hw must be updated to match.
1647 enum hw_lock_client {
1649 * Driver is the client of HW Lock Manager.
1651 HW_LOCK_CLIENT_DRIVER = 0,
1655 HW_LOCK_CLIENT_INVALID = 0xFFFFFFFF,
1659 * Data passed to HW Lock Mgr in a DMUB_CMD__HW_LOCK command.
1661 struct dmub_cmd_lock_hw_data {
1663 * Specifies the client accessing HW Lock Manager.
1665 enum hw_lock_client client;
1667 * HW instances to be locked.
1669 struct dmub_hw_lock_inst_flags inst_flags;
1671 * Which components to be locked.
1673 union dmub_hw_lock_flags hw_locks;
1675 * Specifies lock/unlock.
1679 * HW can be unlocked separately from releasing the HW Lock Mgr.
1680 * This flag is set if the client wishes to release the object.
1682 uint8_t should_release;
1684 * Explicit padding to 4 byte boundary.
1690 * Definition of a DMUB_CMD__HW_LOCK command.
1691 * Command is used by driver and FW.
1693 struct dmub_rb_cmd_lock_hw {
1697 struct dmub_cmd_header header;
1699 * Data passed to HW Lock Mgr in a DMUB_CMD__HW_LOCK command.
1701 struct dmub_cmd_lock_hw_data lock_hw_data;
1705 * ABM command sub-types.
1707 enum dmub_cmd_abm_type {
1709 * Initialize parameters for ABM algorithm.
1710 * Data is passed through an indirect buffer.
1712 DMUB_CMD__ABM_INIT_CONFIG = 0,
1714 * Set OTG and panel HW instance.
1716 DMUB_CMD__ABM_SET_PIPE = 1,
1718 * Set user requested backklight level.
1720 DMUB_CMD__ABM_SET_BACKLIGHT = 2,
1722 * Set ABM operating/aggression level.
1724 DMUB_CMD__ABM_SET_LEVEL = 3,
1726 * Set ambient light level.
1728 DMUB_CMD__ABM_SET_AMBIENT_LEVEL = 4,
1730 * Enable/disable fractional duty cycle for backlight PWM.
1732 DMUB_CMD__ABM_SET_PWM_FRAC = 5,
1736 * Parameters for ABM2.4 algorithm. Passed from driver to FW via an indirect buffer.
1738 * - Padded explicitly to 32-bit boundary.
1739 * - Must ensure this structure matches the one on driver-side,
1740 * otherwise it won't be aligned.
1742 struct abm_config_table {
1744 * Gamma curve thresholds, used for crgb conversion.
1746 uint16_t crgb_thresh[NUM_POWER_FN_SEGS]; // 0B
1748 * Gamma curve offsets, used for crgb conversion.
1750 uint16_t crgb_offset[NUM_POWER_FN_SEGS]; // 16B
1752 * Gamma curve slopes, used for crgb conversion.
1754 uint16_t crgb_slope[NUM_POWER_FN_SEGS]; // 32B
1756 * Custom backlight curve thresholds.
1758 uint16_t backlight_thresholds[NUM_BL_CURVE_SEGS]; // 48B
1760 * Custom backlight curve offsets.
1762 uint16_t backlight_offsets[NUM_BL_CURVE_SEGS]; // 78B
1764 * Ambient light thresholds.
1766 uint16_t ambient_thresholds_lux[NUM_AMBI_LEVEL]; // 112B
1768 * Minimum programmable backlight.
1770 uint16_t min_abm_backlight; // 122B
1772 * Minimum reduction values.
1774 uint8_t min_reduction[NUM_AMBI_LEVEL][NUM_AGGR_LEVEL]; // 124B
1776 * Maximum reduction values.
1778 uint8_t max_reduction[NUM_AMBI_LEVEL][NUM_AGGR_LEVEL]; // 144B
1780 * Bright positive gain.
1782 uint8_t bright_pos_gain[NUM_AMBI_LEVEL][NUM_AGGR_LEVEL]; // 164B
1784 * Dark negative gain.
1786 uint8_t dark_pos_gain[NUM_AMBI_LEVEL][NUM_AGGR_LEVEL]; // 184B
1790 uint8_t hybrid_factor[NUM_AGGR_LEVEL]; // 204B
1794 uint8_t contrast_factor[NUM_AGGR_LEVEL]; // 208B
1798 uint8_t deviation_gain[NUM_AGGR_LEVEL]; // 212B
1802 uint8_t min_knee[NUM_AGGR_LEVEL]; // 216B
1806 uint8_t max_knee[NUM_AGGR_LEVEL]; // 220B
1810 uint8_t iir_curve[NUM_AMBI_LEVEL]; // 224B
1812 * Explicit padding to 4 byte boundary.
1814 uint8_t pad3[3]; // 229B
1816 * Backlight ramp reduction.
1818 uint16_t blRampReduction[NUM_AGGR_LEVEL]; // 232B
1820 * Backlight ramp start.
1822 uint16_t blRampStart[NUM_AGGR_LEVEL]; // 240B
1826 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_PIPE command.
1828 struct dmub_cmd_abm_set_pipe_data {
1835 * Panel Control HW instance.
1840 * Controls how ABM will interpret a set pipe or set level command.
1842 uint8_t set_pipe_option;
1848 uint8_t ramping_boundary;
1852 * Definition of a DMUB_CMD__ABM_SET_PIPE command.
1854 struct dmub_rb_cmd_abm_set_pipe {
1858 struct dmub_cmd_header header;
1861 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_PIPE command.
1863 struct dmub_cmd_abm_set_pipe_data abm_set_pipe_data;
1867 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_BACKLIGHT command.
1869 struct dmub_cmd_abm_set_backlight_data {
1871 * Number of frames to ramp to backlight user level.
1873 uint32_t frame_ramp;
1876 * Requested backlight level from user.
1878 uint32_t backlight_user_level;
1881 * ABM control version.
1886 * Panel Control HW instance mask.
1887 * Bit 0 is Panel Control HW instance 0.
1888 * Bit 1 is Panel Control HW instance 1.
1893 * Explicit padding to 4 byte boundary.
1899 * Definition of a DMUB_CMD__ABM_SET_BACKLIGHT command.
1901 struct dmub_rb_cmd_abm_set_backlight {
1905 struct dmub_cmd_header header;
1908 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_BACKLIGHT command.
1910 struct dmub_cmd_abm_set_backlight_data abm_set_backlight_data;
1914 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_LEVEL command.
1916 struct dmub_cmd_abm_set_level_data {
1918 * Set current ABM operating/aggression level.
1923 * ABM control version.
1928 * Panel Control HW instance mask.
1929 * Bit 0 is Panel Control HW instance 0.
1930 * Bit 1 is Panel Control HW instance 1.
1935 * Explicit padding to 4 byte boundary.
1941 * Definition of a DMUB_CMD__ABM_SET_LEVEL command.
1943 struct dmub_rb_cmd_abm_set_level {
1947 struct dmub_cmd_header header;
1950 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_LEVEL command.
1952 struct dmub_cmd_abm_set_level_data abm_set_level_data;
1956 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_AMBIENT_LEVEL command.
1958 struct dmub_cmd_abm_set_ambient_level_data {
1960 * Ambient light sensor reading from OS.
1962 uint32_t ambient_lux;
1965 * ABM control version.
1970 * Panel Control HW instance mask.
1971 * Bit 0 is Panel Control HW instance 0.
1972 * Bit 1 is Panel Control HW instance 1.
1977 * Explicit padding to 4 byte boundary.
1983 * Definition of a DMUB_CMD__ABM_SET_AMBIENT_LEVEL command.
1985 struct dmub_rb_cmd_abm_set_ambient_level {
1989 struct dmub_cmd_header header;
1992 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_AMBIENT_LEVEL command.
1994 struct dmub_cmd_abm_set_ambient_level_data abm_set_ambient_level_data;
1998 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_PWM_FRAC command.
2000 struct dmub_cmd_abm_set_pwm_frac_data {
2002 * Enable/disable fractional duty cycle for backlight PWM.
2003 * TODO: Convert to uint8_t.
2005 uint32_t fractional_pwm;
2008 * ABM control version.
2013 * Panel Control HW instance mask.
2014 * Bit 0 is Panel Control HW instance 0.
2015 * Bit 1 is Panel Control HW instance 1.
2020 * Explicit padding to 4 byte boundary.
2026 * Definition of a DMUB_CMD__ABM_SET_PWM_FRAC command.
2028 struct dmub_rb_cmd_abm_set_pwm_frac {
2032 struct dmub_cmd_header header;
2035 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_PWM_FRAC command.
2037 struct dmub_cmd_abm_set_pwm_frac_data abm_set_pwm_frac_data;
2041 * Data passed from driver to FW in a DMUB_CMD__ABM_INIT_CONFIG command.
2043 struct dmub_cmd_abm_init_config_data {
2045 * Location of indirect buffer used to pass init data to ABM.
2047 union dmub_addr src;
2050 * Indirect buffer length.
2056 * ABM control version.
2061 * Panel Control HW instance mask.
2062 * Bit 0 is Panel Control HW instance 0.
2063 * Bit 1 is Panel Control HW instance 1.
2068 * Explicit padding to 4 byte boundary.
2074 * Definition of a DMUB_CMD__ABM_INIT_CONFIG command.
2076 struct dmub_rb_cmd_abm_init_config {
2080 struct dmub_cmd_header header;
2083 * Data passed from driver to FW in a DMUB_CMD__ABM_INIT_CONFIG command.
2085 struct dmub_cmd_abm_init_config_data abm_init_config_data;
2089 * Data passed from driver to FW in a DMUB_CMD__QUERY_FEATURE_CAPS command.
2091 struct dmub_cmd_query_feature_caps_data {
2093 * DMUB feature capabilities.
2094 * After DMUB init, driver will query FW capabilities prior to enabling certain features.
2096 struct dmub_feature_caps feature_caps;
2100 * Definition of a DMUB_CMD__QUERY_FEATURE_CAPS command.
2102 struct dmub_rb_cmd_query_feature_caps {
2106 struct dmub_cmd_header header;
2108 * Data passed from driver to FW in a DMUB_CMD__QUERY_FEATURE_CAPS command.
2110 struct dmub_cmd_query_feature_caps_data query_feature_caps_data;
2113 struct dmub_optc_state {
2114 uint32_t v_total_max;
2115 uint32_t v_total_min;
2116 uint32_t v_total_mid;
2117 uint32_t v_total_mid_frame_num;
2119 uint32_t enable_manual_trigger;
2120 uint32_t clear_force_vsync;
2123 struct dmub_rb_cmd_drr_update {
2124 struct dmub_cmd_header header;
2125 struct dmub_optc_state dmub_optc_state_req;
2129 * enum dmub_cmd_panel_cntl_type - Panel control command.
2131 enum dmub_cmd_panel_cntl_type {
2133 * Initializes embedded panel hardware blocks.
2135 DMUB_CMD__PANEL_CNTL_HW_INIT = 0,
2137 * Queries backlight info for the embedded panel.
2139 DMUB_CMD__PANEL_CNTL_QUERY_BACKLIGHT_INFO = 1,
2143 * struct dmub_cmd_panel_cntl_data - Panel control data.
2145 struct dmub_cmd_panel_cntl_data {
2146 uint32_t inst; /**< panel instance */
2147 uint32_t current_backlight; /* in/out */
2148 uint32_t bl_pwm_cntl; /* in/out */
2149 uint32_t bl_pwm_period_cntl; /* in/out */
2150 uint32_t bl_pwm_ref_div1; /* in/out */
2151 uint8_t is_backlight_on : 1; /* in/out */
2152 uint8_t is_powered_on : 1; /* in/out */
2156 * struct dmub_rb_cmd_panel_cntl - Panel control command.
2158 struct dmub_rb_cmd_panel_cntl {
2159 struct dmub_cmd_header header; /**< header */
2160 struct dmub_cmd_panel_cntl_data data; /**< payload */
2164 * Data passed from driver to FW in a DMUB_CMD__VBIOS_LVTMA_CONTROL command.
2166 struct dmub_cmd_lvtma_control_data {
2167 uint8_t uc_pwr_action; /**< LVTMA_ACTION */
2168 uint8_t reserved_0[3]; /**< For future use */
2169 uint8_t panel_inst; /**< LVTMA control instance */
2170 uint8_t reserved_1[3]; /**< For future use */
2174 * Definition of a DMUB_CMD__VBIOS_LVTMA_CONTROL command.
2176 struct dmub_rb_cmd_lvtma_control {
2180 struct dmub_cmd_header header;
2182 * Data passed from driver to FW in a DMUB_CMD__VBIOS_LVTMA_CONTROL command.
2184 struct dmub_cmd_lvtma_control_data data;
2188 * Maximum number of bytes a chunk sent to DMUB for parsing
2190 #define DMUB_EDID_CEA_DATA_CHUNK_BYTES 8
2193 * Represent a chunk of CEA blocks sent to DMUB for parsing
2195 struct dmub_cmd_send_edid_cea {
2196 uint16_t offset; /**< offset into the CEA block */
2197 uint8_t length; /**< number of bytes in payload to copy as part of CEA block */
2198 uint16_t total_length; /**< total length of the CEA block */
2199 uint8_t payload[DMUB_EDID_CEA_DATA_CHUNK_BYTES]; /**< data chunk of the CEA block */
2200 uint8_t pad[3]; /**< padding and for future expansion */
2204 * Result of VSDB parsing from CEA block
2206 struct dmub_cmd_edid_cea_amd_vsdb {
2207 uint8_t vsdb_found; /**< 1 if parsing has found valid AMD VSDB */
2208 uint8_t freesync_supported; /**< 1 if Freesync is supported */
2209 uint16_t amd_vsdb_version; /**< AMD VSDB version */
2210 uint16_t min_frame_rate; /**< Maximum frame rate */
2211 uint16_t max_frame_rate; /**< Minimum frame rate */
2215 * Result of sending a CEA chunk
2217 struct dmub_cmd_edid_cea_ack {
2218 uint16_t offset; /**< offset of the chunk into the CEA block */
2219 uint8_t success; /**< 1 if this sending of chunk succeeded */
2220 uint8_t pad; /**< padding and for future expansion */
2224 * Specify whether the result is an ACK/NACK or the parsing has finished
2226 enum dmub_cmd_edid_cea_reply_type {
2227 DMUB_CMD__EDID_CEA_AMD_VSDB = 1, /**< VSDB parsing has finished */
2228 DMUB_CMD__EDID_CEA_ACK = 2, /**< acknowledges the CEA sending is OK or failing */
2232 * Definition of a DMUB_CMD__EDID_CEA command.
2234 struct dmub_rb_cmd_edid_cea {
2235 struct dmub_cmd_header header; /**< Command header */
2236 union dmub_cmd_edid_cea_data {
2237 struct dmub_cmd_send_edid_cea input; /**< input to send CEA chunks */
2238 struct dmub_cmd_edid_cea_output { /**< output with results */
2239 uint8_t type; /**< dmub_cmd_edid_cea_reply_type */
2241 struct dmub_cmd_edid_cea_amd_vsdb amd_vsdb;
2242 struct dmub_cmd_edid_cea_ack ack;
2244 } output; /**< output to retrieve ACK/NACK or VSDB parsing results */
2245 } data; /**< Command data */
2250 * union dmub_rb_cmd - DMUB inbox command.
2253 struct dmub_rb_cmd_lock_hw lock_hw;
2255 * Elements shared with all commands.
2257 struct dmub_rb_cmd_common cmd_common;
2259 * Definition of a DMUB_CMD__REG_SEQ_READ_MODIFY_WRITE command.
2261 struct dmub_rb_cmd_read_modify_write read_modify_write;
2263 * Definition of a DMUB_CMD__REG_SEQ_FIELD_UPDATE_SEQ command.
2265 struct dmub_rb_cmd_reg_field_update_sequence reg_field_update_seq;
2267 * Definition of a DMUB_CMD__REG_SEQ_BURST_WRITE command.
2269 struct dmub_rb_cmd_burst_write burst_write;
2271 * Definition of a DMUB_CMD__REG_REG_WAIT command.
2273 struct dmub_rb_cmd_reg_wait reg_wait;
2275 * Definition of a DMUB_CMD__VBIOS_DIGX_ENCODER_CONTROL command.
2277 struct dmub_rb_cmd_digx_encoder_control digx_encoder_control;
2279 * Definition of a DMUB_CMD__VBIOS_SET_PIXEL_CLOCK command.
2281 struct dmub_rb_cmd_set_pixel_clock set_pixel_clock;
2283 * Definition of a DMUB_CMD__VBIOS_ENABLE_DISP_POWER_GATING command.
2285 struct dmub_rb_cmd_enable_disp_power_gating enable_disp_power_gating;
2287 * Definition of a DMUB_CMD__VBIOS_DPPHY_INIT command.
2289 struct dmub_rb_cmd_dpphy_init dpphy_init;
2291 * Definition of a DMUB_CMD__VBIOS_DIG1_TRANSMITTER_CONTROL command.
2293 struct dmub_rb_cmd_dig1_transmitter_control dig1_transmitter_control;
2295 * Definition of a DMUB_CMD__PSR_SET_VERSION command.
2297 struct dmub_rb_cmd_psr_set_version psr_set_version;
2299 * Definition of a DMUB_CMD__PSR_COPY_SETTINGS command.
2301 struct dmub_rb_cmd_psr_copy_settings psr_copy_settings;
2303 * Definition of a DMUB_CMD__PSR_ENABLE command.
2305 struct dmub_rb_cmd_psr_enable psr_enable;
2307 * Definition of a DMUB_CMD__PSR_SET_LEVEL command.
2309 struct dmub_rb_cmd_psr_set_level psr_set_level;
2311 * Definition of a DMUB_CMD__PSR_FORCE_STATIC command.
2313 struct dmub_rb_cmd_psr_force_static psr_force_static;
2315 * Definition of a DMUB_CMD__PLAT_54186_WA command.
2317 struct dmub_rb_cmd_PLAT_54186_wa PLAT_54186_wa;
2319 * Definition of a DMUB_CMD__MALL command.
2321 struct dmub_rb_cmd_mall mall;
2323 * Definition of a DMUB_CMD__IDLE_OPT_DCN_RESTORE command.
2325 struct dmub_rb_cmd_idle_opt_dcn_restore dcn_restore;
2328 * Definition of a DMUB_CMD__CLK_MGR_NOTIFY_CLOCKS command.
2330 struct dmub_rb_cmd_clk_mgr_notify_clocks notify_clocks;
2333 * Definition of DMUB_CMD__PANEL_CNTL commands.
2335 struct dmub_rb_cmd_panel_cntl panel_cntl;
2337 * Definition of a DMUB_CMD__ABM_SET_PIPE command.
2339 struct dmub_rb_cmd_abm_set_pipe abm_set_pipe;
2342 * Definition of a DMUB_CMD__ABM_SET_BACKLIGHT command.
2344 struct dmub_rb_cmd_abm_set_backlight abm_set_backlight;
2347 * Definition of a DMUB_CMD__ABM_SET_LEVEL command.
2349 struct dmub_rb_cmd_abm_set_level abm_set_level;
2352 * Definition of a DMUB_CMD__ABM_SET_AMBIENT_LEVEL command.
2354 struct dmub_rb_cmd_abm_set_ambient_level abm_set_ambient_level;
2357 * Definition of a DMUB_CMD__ABM_SET_PWM_FRAC command.
2359 struct dmub_rb_cmd_abm_set_pwm_frac abm_set_pwm_frac;
2362 * Definition of a DMUB_CMD__ABM_INIT_CONFIG command.
2364 struct dmub_rb_cmd_abm_init_config abm_init_config;
2367 * Definition of a DMUB_CMD__DP_AUX_ACCESS command.
2369 struct dmub_rb_cmd_dp_aux_access dp_aux_access;
2372 * Definition of a DMUB_CMD__OUTBOX1_ENABLE command.
2374 struct dmub_rb_cmd_outbox1_enable outbox1_enable;
2377 * Definition of a DMUB_CMD__QUERY_FEATURE_CAPS command.
2379 struct dmub_rb_cmd_query_feature_caps query_feature_caps;
2380 struct dmub_rb_cmd_drr_update drr_update;
2382 * Definition of a DMUB_CMD__VBIOS_LVTMA_CONTROL command.
2384 struct dmub_rb_cmd_lvtma_control lvtma_control;
2386 * Definition of a DMUB_CMD__EDID_CEA command.
2388 struct dmub_rb_cmd_edid_cea edid_cea;
2392 * union dmub_rb_out_cmd - Outbox command
2394 union dmub_rb_out_cmd {
2396 * Parameters common to every command.
2398 struct dmub_rb_cmd_common cmd_common;
2400 * AUX reply command.
2402 struct dmub_rb_cmd_dp_aux_reply dp_aux_reply;
2404 * HPD notify command.
2406 struct dmub_rb_cmd_dp_hpd_notify dp_hpd_notify;
2411 //==============================================================================
2412 //</DMUB_CMD>===================================================================
2413 //==============================================================================
2414 //< DMUB_RB>====================================================================
2415 //==============================================================================
2417 #if defined(__cplusplus)
2422 * struct dmub_rb_init_params - Initialization params for DMUB ringbuffer
2424 struct dmub_rb_init_params {
2425 void *ctx; /**< Caller provided context pointer */
2426 void *base_address; /**< CPU base address for ring's data */
2427 uint32_t capacity; /**< Ringbuffer capacity in bytes */
2428 uint32_t read_ptr; /**< Initial read pointer for consumer in bytes */
2429 uint32_t write_ptr; /**< Initial write pointer for producer in bytes */
2433 * struct dmub_rb - Inbox or outbox DMUB ringbuffer
2436 void *base_address; /**< CPU address for the ring's data */
2437 uint32_t rptr; /**< Read pointer for consumer in bytes */
2438 uint32_t wrpt; /**< Write pointer for producer in bytes */
2439 uint32_t capacity; /**< Ringbuffer capacity in bytes */
2441 void *ctx; /**< Caller provided context pointer */
2442 void *dmub; /**< Pointer to the DMUB interface */
2446 * @brief Checks if the ringbuffer is empty.
2448 * @param rb DMUB Ringbuffer
2449 * @return true if empty
2450 * @return false otherwise
2452 static inline bool dmub_rb_empty(struct dmub_rb *rb)
2454 return (rb->wrpt == rb->rptr);
2458 * @brief Checks if the ringbuffer is full
2460 * @param rb DMUB Ringbuffer
2461 * @return true if full
2462 * @return false otherwise
2464 static inline bool dmub_rb_full(struct dmub_rb *rb)
2466 uint32_t data_count;
2468 if (rb->wrpt >= rb->rptr)
2469 data_count = rb->wrpt - rb->rptr;
2471 data_count = rb->capacity - (rb->rptr - rb->wrpt);
2473 return (data_count == (rb->capacity - DMUB_RB_CMD_SIZE));
2477 * @brief Pushes a command into the ringbuffer
2479 * @param rb DMUB ringbuffer
2480 * @param cmd The command to push
2481 * @return true if the ringbuffer was not full
2482 * @return false otherwise
2484 static inline bool dmub_rb_push_front(struct dmub_rb *rb,
2485 const union dmub_rb_cmd *cmd)
2487 uint8_t *dst = (uint8_t *)(rb->base_address) + rb->wrpt;
2488 const uint8_t *src = (const uint8_t *)cmd;
2490 if (dmub_rb_full(rb))
2494 dmub_memcpy(dst, src, DMUB_RB_CMD_SIZE);
2496 rb->wrpt += DMUB_RB_CMD_SIZE;
2498 if (rb->wrpt >= rb->capacity)
2499 rb->wrpt %= rb->capacity;
2505 * @brief Pushes a command into the DMUB outbox ringbuffer
2507 * @param rb DMUB outbox ringbuffer
2508 * @param cmd Outbox command
2509 * @return true if not full
2510 * @return false otherwise
2512 static inline bool dmub_rb_out_push_front(struct dmub_rb *rb,
2513 const union dmub_rb_out_cmd *cmd)
2515 uint8_t *dst = (uint8_t *)(rb->base_address) + rb->wrpt;
2516 const uint8_t *src = (const uint8_t *)cmd;
2518 if (dmub_rb_full(rb))
2521 dmub_memcpy(dst, src, DMUB_RB_CMD_SIZE);
2523 rb->wrpt += DMUB_RB_CMD_SIZE;
2525 if (rb->wrpt >= rb->capacity)
2526 rb->wrpt %= rb->capacity;
2532 * @brief Returns the next unprocessed command in the ringbuffer.
2534 * @param rb DMUB ringbuffer
2535 * @param cmd The command to return
2536 * @return true if not empty
2537 * @return false otherwise
2539 static inline bool dmub_rb_front(struct dmub_rb *rb,
2540 union dmub_rb_cmd **cmd)
2542 uint8_t *rb_cmd = (uint8_t *)(rb->base_address) + rb->rptr;
2544 if (dmub_rb_empty(rb))
2547 *cmd = (union dmub_rb_cmd *)rb_cmd;
2553 * @brief Determines the next ringbuffer offset.
2555 * @param rb DMUB inbox ringbuffer
2556 * @param num_cmds Number of commands
2557 * @param next_rptr The next offset in the ringbuffer
2559 static inline void dmub_rb_get_rptr_with_offset(struct dmub_rb *rb,
2561 uint32_t *next_rptr)
2563 *next_rptr = rb->rptr + DMUB_RB_CMD_SIZE * num_cmds;
2565 if (*next_rptr >= rb->capacity)
2566 *next_rptr %= rb->capacity;
2570 * @brief Returns a pointer to a command in the inbox.
2572 * @param rb DMUB inbox ringbuffer
2573 * @param cmd The inbox command to return
2574 * @param rptr The ringbuffer offset
2575 * @return true if not empty
2576 * @return false otherwise
2578 static inline bool dmub_rb_peek_offset(struct dmub_rb *rb,
2579 union dmub_rb_cmd **cmd,
2582 uint8_t *rb_cmd = (uint8_t *)(rb->base_address) + rptr;
2584 if (dmub_rb_empty(rb))
2587 *cmd = (union dmub_rb_cmd *)rb_cmd;
2593 * @brief Returns the next unprocessed command in the outbox.
2595 * @param rb DMUB outbox ringbuffer
2596 * @param cmd The outbox command to return
2597 * @return true if not empty
2598 * @return false otherwise
2600 static inline bool dmub_rb_out_front(struct dmub_rb *rb,
2601 union dmub_rb_out_cmd *cmd)
2603 const uint8_t *src = (const uint8_t *)(rb->base_address) + rb->rptr;
2604 uint8_t *dst = (uint8_t *)cmd;
2606 if (dmub_rb_empty(rb))
2610 dmub_memcpy(dst, src, DMUB_RB_CMD_SIZE);
2616 * @brief Removes the front entry in the ringbuffer.
2618 * @param rb DMUB ringbuffer
2619 * @return true if the command was removed
2620 * @return false if there were no commands
2622 static inline bool dmub_rb_pop_front(struct dmub_rb *rb)
2624 if (dmub_rb_empty(rb))
2627 rb->rptr += DMUB_RB_CMD_SIZE;
2629 if (rb->rptr >= rb->capacity)
2630 rb->rptr %= rb->capacity;
2636 * @brief Flushes commands in the ringbuffer to framebuffer memory.
2638 * Avoids a race condition where DMCUB accesses memory while
2639 * there are still writes in flight to framebuffer.
2641 * @param rb DMUB ringbuffer
2643 static inline void dmub_rb_flush_pending(const struct dmub_rb *rb)
2645 uint8_t buf[DMUB_RB_CMD_SIZE];
2646 uint32_t rptr = rb->rptr;
2647 uint32_t wptr = rb->wrpt;
2649 while (rptr != wptr) {
2650 const uint8_t *data = (const uint8_t *)rb->base_address + rptr;
2652 dmub_memcpy(buf, data, DMUB_RB_CMD_SIZE);
2654 rptr += DMUB_RB_CMD_SIZE;
2655 if (rptr >= rb->capacity)
2656 rptr %= rb->capacity;
2661 * @brief Initializes a DMCUB ringbuffer
2663 * @param rb DMUB ringbuffer
2664 * @param init_params initial configuration for the ringbuffer
2666 static inline void dmub_rb_init(struct dmub_rb *rb,
2667 struct dmub_rb_init_params *init_params)
2669 rb->base_address = init_params->base_address;
2670 rb->capacity = init_params->capacity;
2671 rb->rptr = init_params->read_ptr;
2672 rb->wrpt = init_params->write_ptr;
2676 * @brief Copies output data from in/out commands into the given command.
2678 * @param rb DMUB ringbuffer
2679 * @param cmd Command to copy data into
2681 static inline void dmub_rb_get_return_data(struct dmub_rb *rb,
2682 union dmub_rb_cmd *cmd)
2684 // Copy rb entry back into command
2685 uint8_t *rd_ptr = (rb->rptr == 0) ?
2686 (uint8_t *)rb->base_address + rb->capacity - DMUB_RB_CMD_SIZE :
2687 (uint8_t *)rb->base_address + rb->rptr - DMUB_RB_CMD_SIZE;
2689 dmub_memcpy(cmd, rd_ptr, DMUB_RB_CMD_SIZE);
2692 #if defined(__cplusplus)
2696 //==============================================================================
2697 //</DMUB_RB>====================================================================
2698 //==============================================================================
2700 #endif /* _DMUB_CMD_H_ */