Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Linux/drivers/gpu/drm/amd/display/dmub/inc/   (Open Source Betriebssystem Version 6.17.9©)  Datei vom 24.10.2025 mit Größe 161 kB image not shown  

Quelle  dmub_cmd.h   Sprache: C

 
/*
 * Copyright 2019 Advanced Micro Devices, Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 *
 * Authors: AMD
 *
 */


#ifndef DMUB_CMD_H
#define DMUB_CMD_H

#include <asm/byteorder.h>
#include <linux/types.h>
#include <linux/string.h>
#include <linux/delay.h>

#include "atomfirmware.h"

//<DMUB_TYPES>==================================================================
/* Basic type definitions. */

#ifdef __forceinline
#undef __forceinline
#endif
#define __forceinline inline

/**
 * Flag from driver to indicate that ABM should be disabled gradually
 * by slowly reversing all backlight programming and pixel compensation.
 */

#define SET_ABM_PIPE_GRADUALLY_DISABLE           0

/**
 * Flag from driver to indicate that ABM should be disabled immediately
 * and undo all backlight programming and pixel compensation.
 */

#define SET_ABM_PIPE_IMMEDIATELY_DISABLE         255

/**
 * Flag from driver to indicate that ABM should be disabled immediately
 * and keep the current backlight programming and pixel compensation.
 */

#define SET_ABM_PIPE_IMMEDIATE_KEEP_GAIN_DISABLE 254

/**
 * Flag from driver to set the current ABM pipe index or ABM operating level.
 */

#define SET_ABM_PIPE_NORMAL                      1

/**
 * Number of ambient light levels in ABM algorithm.
 */

#define NUM_AMBI_LEVEL                  5

/**
 * Number of operating/aggression levels in ABM algorithm.
 */

#define NUM_AGGR_LEVEL                  4

/**
 * Number of segments in the gamma curve.
 */

#define NUM_POWER_FN_SEGS               8

/**
 * Number of segments in the backlight curve.
 */

#define NUM_BL_CURVE_SEGS               16

/**
 * Maximum number of segments in ABM ACE curve.
 */

#define ABM_MAX_NUM_OF_ACE_SEGMENTS         64

/**
 * Maximum number of bins in ABM histogram.
 */

#define ABM_MAX_NUM_OF_HG_BINS              64

/* Maximum number of SubVP streams */
#define DMUB_MAX_SUBVP_STREAMS 2

/* Define max FPO streams as 4 for now. Current implementation today
 * only supports 1, but could be more in the future. Reduce array
 * size to ensure the command size remains less than 64 bytes if
 * adding new fields.
 */

#define DMUB_MAX_FPO_STREAMS 4

/* Define to ensure that the "common" members always appear in the same
 * order in different structs for back compat purposes
 */

#define COMMON_STREAM_STATIC_SUB_STATE \
    struct dmub_fams2_cmd_legacy_stream_static_state legacy; \
    struct dmub_fams2_cmd_subvp_stream_static_state subvp; \
    struct dmub_fams2_cmd_drr_stream_static_state drr;

/* Maximum number of streams on any ASIC. */
#define DMUB_MAX_STREAMS 6

/* Maximum number of planes on any ASIC. */
#define DMUB_MAX_PLANES 6

/* Maximum number of phantom planes on any ASIC */
#define DMUB_MAX_PHANTOM_PLANES ((DMUB_MAX_PLANES) / 2)

/* Trace buffer offset for entry */
#define TRACE_BUFFER_ENTRY_OFFSET 16

/**
 * Maximum number of dirty rects supported by FW.
 */

#define DMUB_MAX_DIRTY_RECTS 3

/**
 *
 * PSR control version legacy
 */

#define DMUB_CMD_PSR_CONTROL_VERSION_UNKNOWN 0x0
/**
 * PSR control version with multi edp support
 */

#define DMUB_CMD_PSR_CONTROL_VERSION_1 0x1


/**
 * ABM control version legacy
 */

#define DMUB_CMD_ABM_CONTROL_VERSION_UNKNOWN 0x0

/**
 * ABM control version with multi edp support
 */

#define DMUB_CMD_ABM_CONTROL_VERSION_1 0x1

/**
 * Physical framebuffer address location, 64-bit.
 */

#ifndef PHYSICAL_ADDRESS_LOC
#define PHYSICAL_ADDRESS_LOC union large_integer
#endif

/**
 * OS/FW agnostic memcpy
 */

#ifndef dmub_memcpy
#define dmub_memcpy(dest, source, bytes) memcpy((dest), (source), (bytes))
#endif

/**
 * OS/FW agnostic memset
 */

#ifndef dmub_memset
#define dmub_memset(dest, val, bytes) memset((dest), (val), (bytes))
#endif

/**
 * OS/FW agnostic memcmp
 */

#ifndef dmub_memcmp
#define dmub_memcmp(lhs, rhs, bytes) memcmp((lhs), (rhs), (bytes))
#endif

/**
 * OS/FW agnostic udelay
 */

#ifndef dmub_udelay
#define dmub_udelay(microseconds) udelay(microseconds)
#endif

#pragma pack(push, 1)
#define ABM_NUM_OF_ACE_SEGMENTS         5

/**
 * Debug FW state offset
 */

#define DMUB_DEBUG_FW_STATE_OFFSET 0x300

union abm_flags {
 struct {
  /**
 * @abm_enabled: Indicates if ABM is enabled.
 */

  unsigned int abm_enabled : 1;

  /**
 * @disable_abm_requested: Indicates if driver has requested ABM to be disabled.
 */

  unsigned int disable_abm_requested : 1;

  /**
 * @disable_abm_immediately: Indicates if driver has requested ABM to be disabled immediately.
 */

  unsigned int disable_abm_immediately : 1;

  /**
 * @disable_abm_immediate_keep_gain: Indicates if driver has requested ABM
 * to be disabled immediately and keep gain.
 */

  unsigned int disable_abm_immediate_keep_gain : 1;

  /**
 * @fractional_pwm: Indicates if fractional duty cycle for backlight PWM is enabled.
 */

  unsigned int fractional_pwm : 1;

  /**
 * @abm_gradual_bl_change: Indicates if algorithm has completed gradual adjustment
 * of user backlight level.
 */

  unsigned int abm_gradual_bl_change : 1;

  /**
 * @abm_new_frame: Indicates if a new frame update needed for ABM to ramp up into steady
 */

  unsigned int abm_new_frame : 1;

  /**
 * @vb_scaling_enabled: Indicates variBright Scaling Enable
 */

  unsigned int vb_scaling_enabled : 1;
 } bitfields;

 unsigned int u32All;
};

struct abm_save_restore {
 /**
 * @flags: Misc. ABM flags.
 */

 union abm_flags flags;

 /**
 * @pause: true:  pause ABM and get state
 *         false: unpause ABM after setting state
 */

 uint32_t pause;

 /**
 * @next_ace_slope: Next ACE slopes to be programmed in HW (u3.13)
 */

 uint32_t next_ace_slope[ABM_NUM_OF_ACE_SEGMENTS];

 /**
 * @next_ace_thresh: Next ACE thresholds to be programmed in HW (u10.6)
 */

 uint32_t next_ace_thresh[ABM_NUM_OF_ACE_SEGMENTS];

 /**
 * @next_ace_offset: Next ACE offsets to be programmed in HW (u10.6)
 */

 uint32_t next_ace_offset[ABM_NUM_OF_ACE_SEGMENTS];


 /**
 * @knee_threshold: Current x-position of ACE knee (u0.16).
 */

 uint32_t knee_threshold;
 /**
 * @current_gain: Current backlight reduction (u16.16).
 */

 uint32_t current_gain;
 /**
 * @curr_bl_level: Current actual backlight level converging to target backlight level.
 */

 uint16_t curr_bl_level;

 /**
 * @curr_user_bl_level: Current nominal backlight level converging to level requested by user.
 */

 uint16_t curr_user_bl_level;

};

/**
 * union dmub_addr - DMUB physical/virtual 64-bit address.
 */

union dmub_addr {
 struct {
  uint32_t low_part; /**< Lower 32 bits */
  uint32_t high_part; /**< Upper 32 bits */
 } u; /*<< Low/high bit access */
 uint64_t quad_part; /*<< 64 bit address */
};

/* Flattened structure containing SOC BB parameters stored in the VBIOS
 * It is not practical to store the entire bounding box in VBIOS since the bounding box struct can gain new parameters.
 * This also prevents alighment issues when new parameters are added to the SoC BB.
 * The following parameters should be added since these values can't be obtained elsewhere:
 * -dml2_soc_power_management_parameters
 * -dml2_soc_vmin_clock_limits
 */

struct dmub_soc_bb_params {
 uint32_t dram_clk_change_blackout_ns;
 uint32_t dram_clk_change_read_only_ns;
 uint32_t dram_clk_change_write_only_ns;
 uint32_t fclk_change_blackout_ns;
 uint32_t g7_ppt_blackout_ns;
 uint32_t stutter_enter_plus_exit_latency_ns;
 uint32_t stutter_exit_latency_ns;
 uint32_t z8_stutter_enter_plus_exit_latency_ns;
 uint32_t z8_stutter_exit_latency_ns;
 uint32_t z8_min_idle_time_ns;
 uint32_t type_b_dram_clk_change_blackout_ns;
 uint32_t type_b_ppt_blackout_ns;
 uint32_t vmin_limit_dispclk_khz;
 uint32_t vmin_limit_dcfclk_khz;
 uint32_t g7_temperature_read_blackout_ns;
};
#pragma pack(pop)

/**
 * Dirty rect definition.
 */

struct dmub_rect {
 /**
 * Dirty rect x offset.
 */

 uint32_t x;

 /**
 * Dirty rect y offset.
 */

 uint32_t y;

 /**
 * Dirty rect width.
 */

 uint32_t width;

 /**
 * Dirty rect height.
 */

 uint32_t height;
};

/**
 * Flags that can be set by driver to change some PSR behaviour.
 */

union dmub_psr_debug_flags {
 /**
 * Debug flags.
 */

 struct {
  /**
 * Enable visual confirm in FW.
 */

  uint32_t visual_confirm : 1;

  /**
 * Force all selective updates to bw full frame updates.
 */

  uint32_t force_full_frame_update : 1;

  /**
 * Use HW Lock Mgr object to do HW locking in FW.
 */

  uint32_t use_hw_lock_mgr : 1;

  /**
 * Use TPS3 signal when restore main link.
 */

  uint32_t force_wakeup_by_tps3 : 1;

  /**
 * Back to back flip, therefore cannot power down PHY
 */

  uint32_t back_to_back_flip : 1;

  /**
 * Enable visual confirm for IPS
 */

  uint32_t enable_ips_visual_confirm : 1;
 } bitfields;

 /**
 * Union for debug flags.
 */

 uint32_t u32All;
};

/**
 * Flags that can be set by driver to change some Replay behaviour.
 */

union replay_debug_flags {
 struct {
  /**
 * 0x1 (bit 0)
 * Enable visual confirm in FW.
 */

  uint32_t visual_confirm : 1;

  /**
 * 0x2 (bit 1)
 * @skip_crc: Set if need to skip CRC.
 */

  uint32_t skip_crc : 1;

  /**
 * 0x4 (bit 2)
 * @force_link_power_on: Force disable ALPM control
 */

  uint32_t force_link_power_on : 1;

  /**
 * 0x8 (bit 3)
 * @force_phy_power_on: Force phy power on
 */

  uint32_t force_phy_power_on : 1;

  /**
 * 0x10 (bit 4)
 * @timing_resync_disabled: Disabled Replay normal sleep mode timing resync
 */

  uint32_t timing_resync_disabled : 1;

  /**
 * 0x20 (bit 5)
 * @skip_crtc_disabled: CRTC disable skipped
 */

  uint32_t skip_crtc_disabled : 1;

  /**
 * 0x40 (bit 6)
 * @force_defer_one_frame_update: Force defer one frame update in ultra sleep mode
 */

  uint32_t force_defer_one_frame_update : 1;

  /**
 * 0x80 (bit 7)
 * @disable_delay_alpm_on: Force disable delay alpm on
 */

  uint32_t disable_delay_alpm_on : 1;

  /**
 * 0x100 (bit 8)
 * @disable_desync_error_check: Force disable desync error check
 */

  uint32_t disable_desync_error_check : 1;

  /**
 * 0x200 (bit 9)
 * @force_self_update_when_abm_non_steady: Force self update if abm is not steady
 */

  uint32_t force_self_update_when_abm_non_steady : 1;

  /**
 * 0x400 (bit 10)
 * @enable_ips_visual_confirm: Enable IPS visual confirm when entering IPS
 * If we enter IPS2, the Visual confirm bar will change to yellow
 */

  uint32_t enable_ips_visual_confirm : 1;

  /**
 * 0x800 (bit 11)
 * @enable_ips_residency_profiling: Enable IPS residency profiling
 */

  uint32_t enable_ips_residency_profiling : 1;

  /**
 * 0x1000 (bit 12)
 * @enable_coasting_vtotal_check: Enable Coasting_vtotal_check
 */

  uint32_t enable_coasting_vtotal_check : 1;
  /**
 * 0x2000 (bit 13)
 * @enable_visual_confirm_debug: Enable Visual Confirm Debug
 */

  uint32_t enable_visual_confirm_debug : 1;

  uint32_t reserved : 18;
 } bitfields;

 uint32_t u32All;
};

/**
 * Flags record error state.
 */

union replay_visual_confirm_error_state_flags {
 struct {
  /**
 * 0x1 (bit 0) - Desync Error flag.
 */

  uint32_t desync_error : 1;

  /**
 * 0x2 (bit 1) - State Transition Error flag.
 */

  uint32_t state_transition_error : 1;

  /**
 * 0x4 (bit 2) - Crc Error flag
 */

  uint32_t crc_error : 1;

  /**
 * 0x8 (bit 3) - Reserved
 */

  uint32_t reserved_3 : 1;

  /**
 * 0x10 (bit 4) - Incorrect Coasting vtotal checking --> use debug flag to control DPCD write.
 * Added new debug flag to control DPCD.
 */

  uint32_t incorrect_vtotal_in_static_screen : 1;

  /**
 * 0x20 (bit 5) - No doubled Refresh Rate.
 */

  uint32_t no_double_rr : 1;

  /**
 * Reserved bit 6-7
 */

  uint32_t reserved_6_7 : 2;

  /**
 * Reserved bit 9-31
 */

  uint32_t reserved_9_31 : 24;
 } bitfields;

 uint32_t u32All;
};

union replay_hw_flags {
 struct {
  /**
 * @allow_alpm_fw_standby_mode: To indicate whether the
 * ALPM FW standby mode is allowed
 */

  uint32_t allow_alpm_fw_standby_mode : 1;

  /*
 * @dsc_enable_status: DSC enable status in driver
 */

  uint32_t dsc_enable_status : 1;

  /**
 * @fec_enable_status: receive fec enable/disable status from driver
 */

  uint32_t fec_enable_status : 1;

  /*
 * @smu_optimizations_en: SMU power optimization.
 * Only when active display is Replay capable and display enters Replay.
 * Trigger interrupt to SMU to powerup/down.
 */

  uint32_t smu_optimizations_en : 1;

  /**
 * @phy_power_state: Indicates current phy power state
 */

  uint32_t phy_power_state : 1;

  /**
 * @link_power_state: Indicates current link power state
 */

  uint32_t link_power_state : 1;
  /**
 * Use TPS3 signal when restore main link.
 */

  uint32_t force_wakeup_by_tps3 : 1;
  /**
 * @is_alpm_initialized: Indicates whether ALPM is initialized
 */

  uint32_t is_alpm_initialized : 1;

  /**
 * @alpm_mode: Indicates ALPM mode selected
 */

  uint32_t alpm_mode : 2;
 } bitfields;

 uint32_t u32All;
};

union fw_assisted_mclk_switch_version {
 struct {
  uint8_t minor : 5;
  uint8_t major : 3;
 };
 uint8_t ver;
};

/**
 * DMUB feature capabilities.
 * After DMUB init, driver will query FW capabilities prior to enabling certain features.
 */

struct dmub_feature_caps {
 /**
 * Max PSR version supported by FW.
 */

 uint8_t psr;
 uint8_t fw_assisted_mclk_switch_ver;
 uint8_t reserved[4];
 uint8_t subvp_psr_support;
 uint8_t gecc_enable;
 uint8_t replay_supported;
 uint8_t replay_reserved[3];
 uint8_t abm_aux_backlight_support;
};

struct dmub_visual_confirm_color {
 /**
 * Maximum 10 bits color value
 */

 uint16_t color_r_cr;
 uint16_t color_g_y;
 uint16_t color_b_cb;
 uint16_t panel_inst;
};

//==============================================================================
//</DMUB_TYPES>=================================================================
//==============================================================================
//< DMUB_META>==================================================================
//==============================================================================
#pragma pack(push, 1)

/* Magic value for identifying dmub_fw_meta_info */
#define DMUB_FW_META_MAGIC 0x444D5542

/* Offset from the end of the file to the dmub_fw_meta_info */
#define DMUB_FW_META_OFFSET 0x24

/**
 * union dmub_fw_meta_feature_bits - Static feature bits for pre-initialization
 */

union dmub_fw_meta_feature_bits {
 struct {
  uint32_t shared_state_link_detection : 1; /**< 1 supports link detection via shared state */
  uint32_t reserved : 31;
 } bits; /**< status bits */
 uint32_t all; /**< 32-bit access to status bits */
};

/**
 * struct dmub_fw_meta_info - metadata associated with fw binary
 *
 * NOTE: This should be considered a stable API. Fields should
 *       not be repurposed or reordered. New fields should be
 *       added instead to extend the structure.
 *
 * @magic_value: magic value identifying DMUB firmware meta info
 * @fw_region_size: size of the firmware state region
 * @trace_buffer_size: size of the tracebuffer region
 * @fw_version: the firmware version information
 * @dal_fw: 1 if the firmware is DAL
 * @shared_state_size: size of the shared state region in bytes
 * @shared_state_features: number of shared state features
 */

struct dmub_fw_meta_info {
 uint32_t magic_value; /**< magic value identifying DMUB firmware meta info */
 uint32_t fw_region_size; /**< size of the firmware state region */
 uint32_t trace_buffer_size; /**< size of the tracebuffer region */
 uint32_t fw_version; /**< the firmware version information */
 uint8_t dal_fw; /**< 1 if the firmware is DAL */
 uint8_t reserved[3]; /**< padding bits */
 uint32_t shared_state_size; /**< size of the shared state region in bytes */
 uint16_t shared_state_features; /**< number of shared state features */
 uint16_t reserved2; /**< padding bytes */
 union dmub_fw_meta_feature_bits feature_bits; /**< static feature bits */
};

/**
 * union dmub_fw_meta - ensures that dmub_fw_meta_info remains 64 bytes
 */

union dmub_fw_meta {
 struct dmub_fw_meta_info info; /**< metadata info */
 uint8_t reserved[64]; /**< padding bits */
};

#pragma pack(pop)

//==============================================================================
//< DMUB Trace Buffer>================================================================
//==============================================================================
#if !defined(TENSILICA) && !defined(DMUB_TRACE_ENTRY_DEFINED)
/**
 * dmub_trace_code_t - firmware trace code, 32-bits
 */

typedef uint32_t dmub_trace_code_t;

/**
 * struct dmcub_trace_buf_entry - Firmware trace entry
 */

struct dmcub_trace_buf_entry {
 dmub_trace_code_t trace_code; /**< trace code for the event */
 uint32_t tick_count; /**< the tick count at time of trace */
 uint32_t param0; /**< trace defined parameter 0 */
 uint32_t param1; /**< trace defined parameter 1 */
};
#endif

//==============================================================================
//< DMUB_STATUS>================================================================
//==============================================================================

/**
 * DMCUB scratch registers can be used to determine firmware status.
 * Current scratch register usage is as follows:
 *
 * SCRATCH0: FW Boot Status register
 * SCRATCH5: LVTMA Status Register
 * SCRATCH15: FW Boot Options register
 */


/**
 * union dmub_fw_boot_status - Status bit definitions for SCRATCH0.
 */

union dmub_fw_boot_status {
 struct {
  uint32_t dal_fw : 1; /**< 1 if DAL FW */
  uint32_t mailbox_rdy : 1; /**< 1 if mailbox ready */
  uint32_t optimized_init_done : 1; /**< 1 if optimized init done */
  uint32_t restore_required : 1; /**< 1 if driver should call restore */
  uint32_t defer_load : 1; /**< 1 if VBIOS data is deferred programmed */
  uint32_t fams_enabled : 1; /**< 1 if VBIOS data is deferred programmed */
  uint32_t detection_required: 1; /**<  if detection need to be triggered by driver */
  uint32_t hw_power_init_done: 1; /**< 1 if hw power init is completed */
  uint32_t ono_regions_enabled: 1; /**< 1 if ONO regions are enabled */
 } bits; /**< status bits */
 uint32_t all; /**< 32-bit access to status bits */
};

/**
 * enum dmub_fw_boot_status_bit - Enum bit definitions for SCRATCH0.
 */

enum dmub_fw_boot_status_bit {
 DMUB_FW_BOOT_STATUS_BIT_DAL_FIRMWARE = (1 << 0), /**< 1 if DAL FW */
 DMUB_FW_BOOT_STATUS_BIT_MAILBOX_READY = (1 << 1), /**< 1 if mailbox ready */
 DMUB_FW_BOOT_STATUS_BIT_OPTIMIZED_INIT_DONE = (1 << 2), /**< 1 if init done */
 DMUB_FW_BOOT_STATUS_BIT_RESTORE_REQUIRED = (1 << 3), /**< 1 if driver should call restore */
 DMUB_FW_BOOT_STATUS_BIT_DEFERRED_LOADED = (1 << 4), /**< 1 if VBIOS data is deferred programmed */
 DMUB_FW_BOOT_STATUS_BIT_FAMS_ENABLED = (1 << 5), /**< 1 if FAMS is enabled*/
 DMUB_FW_BOOT_STATUS_BIT_DETECTION_REQUIRED = (1 << 6), /**< 1 if detection need to be triggered by driver*/
 DMUB_FW_BOOT_STATUS_BIT_HW_POWER_INIT_DONE = (1 << 7), /**< 1 if hw power init is completed */
 DMUB_FW_BOOT_STATUS_BIT_ONO_REGIONS_ENABLED = (1 << 8), /**< 1 if ONO regions are enabled */
};

/* Register bit definition for SCRATCH5 */
union dmub_lvtma_status {
 struct {
  uint32_t psp_ok : 1;
  uint32_t edp_on : 1;
  uint32_t reserved : 30;
 } bits;
 uint32_t all;
};

enum dmub_lvtma_status_bit {
 DMUB_LVTMA_STATUS_BIT_PSP_OK = (1 << 0),
 DMUB_LVTMA_STATUS_BIT_EDP_ON = (1 << 1),
};

enum dmub_ips_disable_type {
 DMUB_IPS_ENABLE = 0,
 DMUB_IPS_DISABLE_ALL = 1,
 DMUB_IPS_DISABLE_IPS1 = 2,
 DMUB_IPS_DISABLE_IPS2 = 3,
 DMUB_IPS_DISABLE_IPS2_Z10 = 4,
 DMUB_IPS_DISABLE_DYNAMIC = 5,
 DMUB_IPS_RCG_IN_ACTIVE_IPS2_IN_OFF = 6,
 DMUB_IPS_DISABLE_Z8_RETENTION = 7,
};

enum dmub_ips_rcg_disable_type {
 DMUB_IPS_RCG_ENABLE = 0,
 DMUB_IPS0_RCG_DISABLE = 1,
 DMUB_IPS1_RCG_DISABLE = 2,
 DMUB_IPS_RCG_DISABLE = 3
};

enum dmub_ips_in_vpb_disable_type {
 DMUB_IPS_VPB_RCG_ONLY = 0, // Legacy behaviour
 DMUB_IPS_VPB_DISABLE_ALL = 1,
 DMUB_IPS_VPB_ENABLE_IPS1_AND_RCG = 2,
 DMUB_IPS_VPB_ENABLE_ALL = 3 // Enable IPS1 Z8, IPS1 and RCG
};

#define DMUB_IPS1_ALLOW_MASK 0x00000001
#define DMUB_IPS2_ALLOW_MASK 0x00000002
#define DMUB_IPS1_COMMIT_MASK 0x00000004
#define DMUB_IPS2_COMMIT_MASK 0x00000008

enum dmub_ips_comand_type {
 /**
 * Start/stop IPS residency measurements for a given IPS mode
 */

 DMUB_CMD__IPS_RESIDENCY_CNTL = 0,
 /**
 * Query IPS residency information for a given IPS mode
 */

 DMUB_CMD__IPS_QUERY_RESIDENCY_INFO = 1,
};

/**
 * union dmub_fw_boot_options - Boot option definitions for SCRATCH14
 */

union dmub_fw_boot_options {
 struct {
  uint32_t pemu_env : 1; /**< 1 if PEMU */
  uint32_t fpga_env : 1; /**< 1 if FPGA */
  uint32_t optimized_init : 1; /**< 1 if optimized init */
  uint32_t skip_phy_access : 1; /**< 1 if PHY access should be skipped */
  uint32_t disable_clk_gate: 1; /**< 1 if clock gating should be disabled */
  uint32_t skip_phy_init_panel_sequence: 1; /**< 1 to skip panel init seq */
  uint32_t z10_disable: 1; /**< 1 to disable z10 */
  uint32_t enable_dpia: 1; /**< 1 if DPIA should be enabled */
  uint32_t invalid_vbios_data: 1; /**< 1 if VBIOS data table is invalid */
  uint32_t dpia_supported: 1; /**< 1 if DPIA is supported on this platform */
  uint32_t sel_mux_phy_c_d_phy_f_g: 1; /**< 1 if PHYF/PHYG should be enabled on DCN31 */
  /**< 1 if all root clock gating is enabled and low power memory is enabled*/
  uint32_t power_optimization: 1;
  uint32_t diag_env: 1; /* 1 if diagnostic environment */
  uint32_t gpint_scratch8: 1; /* 1 if GPINT is in scratch8*/
  uint32_t usb4_cm_version: 1; /**< 1 CM support */
  uint32_t dpia_hpd_int_enable_supported: 1; /* 1 if dpia hpd int enable supported */
  uint32_t enable_non_transparent_setconfig: 1; /* 1 if dpia use conventional dp lt flow*/
  uint32_t disable_clk_ds: 1; /* 1 if disallow dispclk_ds and dppclk_ds*/
  uint32_t disable_timeout_recovery : 1; /* 1 if timeout recovery should be disabled */
  uint32_t ips_pg_disable: 1; /* 1 to disable ONO domains power gating*/
  uint32_t ips_disable: 3; /* options to disable ips support*/
  uint32_t ips_sequential_ono: 1; /**< 1 to enable sequential ONO IPS sequence */
  uint32_t disable_sldo_opt: 1; /**< 1 to disable SLDO optimizations */
  uint32_t lower_hbr3_phy_ssc: 1; /**< 1 to lower hbr3 phy ssc to 0.125 percent */
  uint32_t reserved : 6; /**< reserved */
 } bits; /**< boot bits */
 uint32_t all; /**< 32-bit access to bits */
};

enum dmub_fw_boot_options_bit {
 DMUB_FW_BOOT_OPTION_BIT_PEMU_ENV = (1 << 0), /**< 1 if PEMU */
 DMUB_FW_BOOT_OPTION_BIT_FPGA_ENV = (1 << 1), /**< 1 if FPGA */
 DMUB_FW_BOOT_OPTION_BIT_OPTIMIZED_INIT_DONE = (1 << 2), /**< 1 if optimized init done */
};

//==============================================================================
//< DMUB_SHARED_STATE>==========================================================
//==============================================================================

/**
 * Shared firmware state between driver and firmware for lockless communication
 * in situations where the inbox/outbox may be unavailable.
 *
 * Each structure *must* be at most 256-bytes in size. The layout allocation is
 * described below:
 *
 * [Header (256 Bytes)][Feature 1 (256 Bytes)][Feature 2 (256 Bytes)]...
 */


/**
 * enum dmub_shared_state_feature_id - List of shared state features.
 */

enum dmub_shared_state_feature_id {
 DMUB_SHARED_SHARE_FEATURE__INVALID = 0,
 DMUB_SHARED_SHARE_FEATURE__IPS_FW = 1,
 DMUB_SHARED_SHARE_FEATURE__IPS_DRIVER = 2,
 DMUB_SHARED_SHARE_FEATURE__DEBUG_SETUP = 3,
 DMUB_SHARED_STATE_FEATURE__LAST, /* Total number of features. */
};

/**
 * struct dmub_shared_state_ips_fw - Firmware signals for IPS.
 */

 union dmub_shared_state_ips_fw_signals {
 struct {
  uint32_t ips1_commit : 1;  /**< 1 if in IPS1 or IPS0 RCG */
  uint32_t ips2_commit : 1; /**< 1 if in IPS2 */
  uint32_t in_idle : 1; /**< 1 if DMCUB is in idle */
  uint32_t detection_required : 1; /**< 1 if detection is required */
  uint32_t ips1z8_commit: 1; /**< 1 if in IPS1 Z8 Retention */
  uint32_t reserved_bits : 27; /**< Reversed */
 } bits;
 uint32_t all;
};

/**
 * struct dmub_shared_state_ips_signals - Firmware signals for IPS.
 */

 union dmub_shared_state_ips_driver_signals {
 struct {
  uint32_t allow_pg : 1; /**< 1 if PG is allowed */
  uint32_t allow_ips1 : 1; /**< 1 is IPS1 is allowed */
  uint32_t allow_ips2 : 1; /**< 1 is IPS1 is allowed */
  uint32_t allow_z10 : 1; /**< 1 if Z10 is allowed */
  uint32_t allow_idle: 1; /**< 1 if driver is allowing idle */
  uint32_t allow_ips0_rcg : 1; /**< 1 is IPS0 RCG is allowed */
  uint32_t allow_ips1_rcg : 1; /**< 1 is IPS1 RCG is allowed */
  uint32_t allow_ips1z8 : 1; /**< 1 is IPS1 Z8 Retention is allowed */
  uint32_t allow_dynamic_ips1 : 1; /**< 1 if IPS1 is allowed in dynamic use cases such as VPB */
  uint32_t allow_dynamic_ips1_z8: 1; /**< 1 if IPS1 z8 ret is allowed in dynamic use cases such as VPB */
  uint32_t reserved_bits : 22; /**< Reversed bits */
 } bits;
 uint32_t all;
};

/**
 * IPS FW Version
 */

#define DMUB_SHARED_STATE__IPS_FW_VERSION 1

struct dmub_shared_state_debug_setup {
 union {
  struct {
   uint32_t exclude_points[62];
  } profile_mode;
 };
};

/**
 * struct dmub_shared_state_ips_fw - Firmware state for IPS.
 */

struct dmub_shared_state_ips_fw {
 union dmub_shared_state_ips_fw_signals signals; /**< 4 bytes, IPS signal bits */
 uint32_t rcg_entry_count; /**< Entry counter for RCG */
 uint32_t rcg_exit_count; /**< Exit counter for RCG */
 uint32_t ips1_entry_count; /**< Entry counter for IPS1 */
 uint32_t ips1_exit_count; /**< Exit counter for IPS1 */
 uint32_t ips2_entry_count; /**< Entry counter for IPS2 */
 uint32_t ips2_exit_count; /**< Exit counter for IPS2 */
 uint32_t ips1_z8ret_entry_count; /**< Entry counter for IPS1 Z8 Retention */
 uint32_t ips1_z8ret_exit_count; /**< Exit counter for IPS1 Z8 Retention */
 uint32_t reserved[53]; /**< Reversed, to be updated when adding new fields. */
}; /* 248-bytes, fixed */

/**
 * IPS Driver Version
 */

#define DMUB_SHARED_STATE__IPS_DRIVER_VERSION 1

/**
 * struct dmub_shared_state_ips_driver - Driver state for IPS.
 */

struct dmub_shared_state_ips_driver {
 union dmub_shared_state_ips_driver_signals signals; /**< 4 bytes, IPS signal bits */
 uint32_t reserved[61]; /**< Reversed, to be updated when adding new fields. */
}; /* 248-bytes, fixed */

/**
 * enum dmub_shared_state_feature_common - Generic payload.
 */

struct dmub_shared_state_feature_common {
 uint32_t padding[62];
}; /* 248-bytes, fixed */

/**
 * enum dmub_shared_state_feature_header - Feature description.
 */

struct dmub_shared_state_feature_header {
 uint16_t id; /**< Feature ID */
 uint16_t version; /**< Feature version */
 uint32_t reserved; /**< Reserved bytes. */
}; /* 8 bytes, fixed */

/**
 * struct dmub_shared_state_feature_block - Feature block.
 */

struct dmub_shared_state_feature_block {
 struct dmub_shared_state_feature_header header; /**< Shared state header. */
 union dmub_shared_feature_state_union {
  struct dmub_shared_state_feature_common common; /**< Generic data */
  struct dmub_shared_state_ips_fw ips_fw; /**< IPS firmware state */
  struct dmub_shared_state_ips_driver ips_driver; /**< IPS driver state */
  struct dmub_shared_state_debug_setup debug_setup; /**< Debug setup */
 } data; /**< Shared state data. */
}; /* 256-bytes, fixed */

/**
 * Shared state size in bytes.
 */

#define DMUB_FW_HEADER_SHARED_STATE_SIZE \
 ((DMUB_SHARED_STATE_FEATURE__LAST + 1) * sizeof(struct dmub_shared_state_feature_block))

//==============================================================================
//</DMUB_STATUS>================================================================
//==============================================================================
//< DMUB_VBIOS>=================================================================
//==============================================================================

/*
 * enum dmub_cmd_vbios_type - VBIOS commands.
 *
 * Command IDs should be treated as stable ABI.
 * Do not reuse or modify IDs.
 */

enum dmub_cmd_vbios_type {
 /**
 * Configures the DIG encoder.
 */

 DMUB_CMD__VBIOS_DIGX_ENCODER_CONTROL = 0,
 /**
 * Controls the PHY.
 */

 DMUB_CMD__VBIOS_DIG1_TRANSMITTER_CONTROL = 1,
 /**
 * Sets the pixel clock/symbol clock.
 */

 DMUB_CMD__VBIOS_SET_PIXEL_CLOCK = 2,
 /**
 * Enables or disables power gating.
 */

 DMUB_CMD__VBIOS_ENABLE_DISP_POWER_GATING = 3,
 /**
 * Controls embedded panels.
 */

 DMUB_CMD__VBIOS_LVTMA_CONTROL = 15,
 /**
 * Query DP alt status on a transmitter.
 */

 DMUB_CMD__VBIOS_TRANSMITTER_QUERY_DP_ALT  = 26,
 /**
 * Control PHY FSM
 */

 DMUB_CMD__VBIOS_TRANSMITTER_SET_PHY_FSM  = 29,
 /**
 * Controls domain power gating
 */

 DMUB_CMD__VBIOS_DOMAIN_CONTROL = 28,
};

//==============================================================================
//</DMUB_VBIOS>=================================================================
//==============================================================================
//< DMUB_GPINT>=================================================================
//==============================================================================

/**
 * The shifts and masks below may alternatively be used to format and read
 * the command register bits.
 */


#define DMUB_GPINT_DATA_PARAM_MASK 0xFFFF
#define DMUB_GPINT_DATA_PARAM_SHIFT 0

#define DMUB_GPINT_DATA_COMMAND_CODE_MASK 0xFFF
#define DMUB_GPINT_DATA_COMMAND_CODE_SHIFT 16

#define DMUB_GPINT_DATA_STATUS_MASK 0xF
#define DMUB_GPINT_DATA_STATUS_SHIFT 28

/**
 * Command responses.
 */


/**
 * Return response for DMUB_GPINT__STOP_FW command.
 */

#define DMUB_GPINT__STOP_FW_RESPONSE 0xDEADDEAD

/**
 * union dmub_gpint_data_register - Format for sending a command via the GPINT.
 */

union dmub_gpint_data_register {
 struct {
  uint32_t param : 16; /**< 16-bit parameter */
  uint32_t command_code : 12; /**< GPINT command */
  uint32_t status : 4; /**< Command status bit */
 } bits; /**< GPINT bit access */
 uint32_t all; /**< GPINT  32-bit access */
};

/*
 * enum dmub_gpint_command - GPINT command to DMCUB FW
 *
 * Command IDs should be treated as stable ABI.
 * Do not reuse or modify IDs.
 */

enum dmub_gpint_command {
 /**
 * Invalid command, ignored.
 */

 DMUB_GPINT__INVALID_COMMAND = 0,
 /**
 * DESC: Queries the firmware version.
 * RETURN: Firmware version.
 */

 DMUB_GPINT__GET_FW_VERSION = 1,
 /**
 * DESC: Halts the firmware.
 * RETURN: DMUB_GPINT__STOP_FW_RESPONSE (0xDEADDEAD) when halted
 */

 DMUB_GPINT__STOP_FW = 2,
 /**
 * DESC: Get PSR state from FW.
 * RETURN: PSR state enum. This enum may need to be converted to the legacy PSR state value.
 */

 DMUB_GPINT__GET_PSR_STATE = 7,
 /**
 * DESC: Notifies DMCUB of the currently active streams.
 * ARGS: Stream mask, 1 bit per active stream index.
 */

 DMUB_GPINT__IDLE_OPT_NOTIFY_STREAM_MASK = 8,
 /**
 * DESC: Start PSR residency counter. Stop PSR resdiency counter and get value.
 * ARGS: We can measure residency from various points. The argument will specify the residency mode.
 *       By default, it is measured from after we powerdown the PHY, to just before we powerup the PHY.
 * RETURN: PSR residency in milli-percent.
 */

 DMUB_GPINT__PSR_RESIDENCY = 9,

 /**
 * DESC: Notifies DMCUB detection is done so detection required can be cleared.
 */

 DMUB_GPINT__NOTIFY_DETECTION_DONE = 12,

 /**
 * DESC: Get REPLAY state from FW.
 * RETURN: REPLAY state enum. This enum may need to be converted to the legacy REPLAY state value.
 */

 DMUB_GPINT__GET_REPLAY_STATE = 13,

 /**
 * DESC: Start REPLAY residency counter. Stop REPLAY resdiency counter and get value.
 * ARGS: We can measure residency from various points. The argument will specify the residency mode.
 *       By default, it is measured from after we powerdown the PHY, to just before we powerup the PHY.
 * RETURN: REPLAY residency in milli-percent.
 */

 DMUB_GPINT__REPLAY_RESIDENCY = 14,

 /**
 * DESC: Copy bounding box to the host.
 * ARGS: Version of bounding box to copy
 * RETURN: Result of copying bounding box
 */

 DMUB_GPINT__BB_COPY = 96,

 /**
 * DESC: Updates the host addresses bit48~bit63 for bounding box.
 * ARGS: The word3 for the 64 bit address
 */

 DMUB_GPINT__SET_BB_ADDR_WORD3 = 97,

 /**
 * DESC: Updates the host addresses bit32~bit47 for bounding box.
 * ARGS: The word2 for the 64 bit address
 */

 DMUB_GPINT__SET_BB_ADDR_WORD2 = 98,

 /**
 * DESC: Updates the host addresses bit16~bit31 for bounding box.
 * ARGS: The word1 for the 64 bit address
 */

 DMUB_GPINT__SET_BB_ADDR_WORD1 = 99,

 /**
 * DESC: Updates the host addresses bit0~bit15 for bounding box.
 * ARGS: The word0 for the 64 bit address
 */

 DMUB_GPINT__SET_BB_ADDR_WORD0 = 100,

 /**
 * DESC: Updates the trace buffer lower 32-bit mask.
 * ARGS: The new mask
 * RETURN: Lower 32-bit mask.
 */

 DMUB_GPINT__UPDATE_TRACE_BUFFER_MASK = 101,

 /**
 * DESC: Updates the trace buffer mask bit0~bit15.
 * ARGS: The new mask
 * RETURN: Lower 32-bit mask.
 */

 DMUB_GPINT__SET_TRACE_BUFFER_MASK_WORD0 = 102,

 /**
 * DESC: Updates the trace buffer mask bit16~bit31.
 * ARGS: The new mask
 * RETURN: Lower 32-bit mask.
 */

 DMUB_GPINT__SET_TRACE_BUFFER_MASK_WORD1 = 103,

 /**
 * DESC: Updates the trace buffer mask bit32~bit47.
 * ARGS: The new mask
 * RETURN: Lower 32-bit mask.
 */

 DMUB_GPINT__SET_TRACE_BUFFER_MASK_WORD2 = 114,

 /**
 * DESC: Updates the trace buffer mask bit48~bit63.
 * ARGS: The new mask
 * RETURN: Lower 32-bit mask.
 */

 DMUB_GPINT__SET_TRACE_BUFFER_MASK_WORD3 = 115,

 /**
 * DESC: Read the trace buffer mask bi0~bit15.
 */

 DMUB_GPINT__GET_TRACE_BUFFER_MASK_WORD0 = 116,

 /**
 * DESC: Read the trace buffer mask bit16~bit31.
 */

 DMUB_GPINT__GET_TRACE_BUFFER_MASK_WORD1 = 117,

 /**
 * DESC: Read the trace buffer mask bi32~bit47.
 */

 DMUB_GPINT__GET_TRACE_BUFFER_MASK_WORD2 = 118,

 /**
 * DESC: Updates the trace buffer mask bit32~bit63.
 */

 DMUB_GPINT__GET_TRACE_BUFFER_MASK_WORD3 = 119,

 /**
 * DESC: Set IPS residency measurement
 * ARGS: 0 - Disable ips measurement
 *       1 - Enable ips measurement
 */

 DMUB_GPINT__IPS_RESIDENCY = 121,

 /**
 * DESC: Enable measurements for various task duration
 * ARGS: 0 - Disable measurement
 *       1 - Enable measurement
 */

 DMUB_GPINT__TRACE_DMUB_WAKE_ACTIVITY = 123,

 /**
 * DESC: Gets IPS residency in microseconds
 * ARGS: 0 - Return IPS1 residency
 *       1 - Return IPS2 residency
 *       2 - Return IPS1_RCG residency
 *       3 - Return IPS1_ONO2_ON residency
 * RETURN: Total residency in microseconds - lower 32 bits
 */

 DMUB_GPINT__GET_IPS_RESIDENCY_DURATION_US_LO = 124,

 /**
 * DESC: Gets IPS1 histogram counts
 * ARGS: Bucket index
 * RETURN: Total count for the bucket
 */

 DMUB_GPINT__GET_IPS1_HISTOGRAM_COUNTER = 125,

 /**
 * DESC: Gets IPS2 histogram counts
 * ARGS: Bucket index
 * RETURN: Total count for the bucket
 */

 DMUB_GPINT__GET_IPS2_HISTOGRAM_COUNTER = 126,

 /**
 * DESC: Gets IPS residency
 * ARGS: 0 - Return IPS1 residency
 *       1 - Return IPS2 residency
 *       2 - Return IPS1_RCG residency
 *       3 - Return IPS1_ONO2_ON residency
 * RETURN: Total residency in milli-percent.
 */

 DMUB_GPINT__GET_IPS_RESIDENCY_PERCENT = 127,

 /**
 * DESC: Gets IPS1_RCG histogram counts
 * ARGS: Bucket index
 * RETURN: Total count for the bucket
 */

 DMUB_GPINT__GET_IPS1_RCG_HISTOGRAM_COUNTER = 128,

 /**
 * DESC: Gets IPS1_ONO2_ON histogram counts
 * ARGS: Bucket index
 * RETURN: Total count for the bucket
 */

 DMUB_GPINT__GET_IPS1_ONO2_ON_HISTOGRAM_COUNTER = 129,

 /**
 * DESC: Gets IPS entry counter during residency measurement
 * ARGS: 0 - Return IPS1 entry counts
 *       1 - Return IPS2 entry counts
 *       2 - Return IPS1_RCG entry counts
 *       3 - Return IPS2_ONO2_ON entry counts
 * RETURN: Entry counter for selected IPS mode
 */

 DMUB_GPINT__GET_IPS_RESIDENCY_ENTRY_COUNTER = 130,

 /**
 * DESC: Gets IPS inactive residency in microseconds
 * ARGS: 0 - Return IPS1_MAX residency
 *       1 - Return IPS2 residency
 *       2 - Return IPS1_RCG residency
 *       3 - Return IPS1_ONO2_ON residency
 * RETURN: Total inactive residency in microseconds - lower 32 bits
 */

 DMUB_GPINT__GET_IPS_INACTIVE_RESIDENCY_DURATION_US_LO = 131,

 /**
 * DESC: Gets IPS inactive residency in microseconds
 * ARGS: 0 - Return IPS1_MAX residency
 *       1 - Return IPS2 residency
 *       2 - Return IPS1_RCG residency
 *       3 - Return IPS1_ONO2_ON residency
 * RETURN: Total inactive residency in microseconds - upper 32 bits
 */

 DMUB_GPINT__GET_IPS_INACTIVE_RESIDENCY_DURATION_US_HI = 132,

 /**
 * DESC: Gets IPS residency in microseconds
 * ARGS: 0 - Return IPS1 residency
 *       1 - Return IPS2 residency
 *       2 - Return IPS1_RCG residency
 *       3 - Return IPS1_ONO2_ON residency
 * RETURN: Total residency in microseconds - upper 32 bits
 */

 DMUB_GPINT__GET_IPS_RESIDENCY_DURATION_US_HI = 133,
 /**
 * DESC: Setup debug configs.
 */

 DMUB_GPINT__SETUP_DEBUG_MODE = 136,
 /**
 * DESC: Initiates IPS wake sequence.
 */

 DMUB_GPINT__IPS_DEBUG_WAKE = 137,
};

/**
 * INBOX0 generic command definition
 */

union dmub_inbox0_cmd_common {
 struct {
  uint32_t command_code: 8; /**< INBOX0 command code */
  uint32_t param: 24; /**< 24-bit parameter */
 } bits;
 uint32_t all;
};

/**
 * INBOX0 hw_lock command definition
 */

union dmub_inbox0_cmd_lock_hw {
 struct {
  uint32_t command_code: 8;

  /* NOTE: Must be have enough bits to match: enum hw_lock_client */
  uint32_t hw_lock_client: 2;

  /* NOTE: Below fields must match with: struct dmub_hw_lock_inst_flags */
  uint32_t otg_inst: 3;
  uint32_t opp_inst: 3;
  uint32_t dig_inst: 3;

  /* NOTE: Below fields must match with: union dmub_hw_lock_flags */
  uint32_t lock_pipe: 1;
  uint32_t lock_cursor: 1;
  uint32_t lock_dig: 1;
  uint32_t triple_buffer_lock: 1;

  uint32_t lock: 1;    /**< Lock */
  uint32_t should_release: 1;  /**< Release */
  uint32_t reserved: 7;    /**< Reserved for extending more clients, HW, etc. */
 } bits;
 uint32_t all;
};

union dmub_inbox0_data_register {
 union dmub_inbox0_cmd_common inbox0_cmd_common;
 union dmub_inbox0_cmd_lock_hw inbox0_cmd_lock_hw;
};

enum dmub_inbox0_command {
 /**
 * DESC: Invalid command, ignored.
 */

 DMUB_INBOX0_CMD__INVALID_COMMAND = 0,
 /**
 * DESC: Notification to acquire/release HW lock
 * ARGS:
 */

 DMUB_INBOX0_CMD__HW_LOCK = 1,
};
//==============================================================================
//</DMUB_GPINT>=================================================================
//==============================================================================
//< DMUB_CMD>===================================================================
//==============================================================================

/**
 * Size in bytes of each DMUB command.
 */

#define DMUB_RB_CMD_SIZE 64

/**
 * Maximum number of items in the DMUB ringbuffer.
 */

#define DMUB_RB_MAX_ENTRY 128

/**
 * Ringbuffer size in bytes.
 */

#define DMUB_RB_SIZE (DMUB_RB_CMD_SIZE * DMUB_RB_MAX_ENTRY)

/**
 * Maximum number of items in the DMUB REG INBOX0 internal ringbuffer.
 */

#define DMUB_REG_INBOX0_RB_MAX_ENTRY 16

/**
 * Ringbuffer size in bytes.
 */

#define DMUB_REG_INBOX0_RB_SIZE (DMUB_RB_CMD_SIZE * DMUB_REG_INBOX0_RB_MAX_ENTRY)

/**
 * REG_SET mask for reg offload.
 */

#define REG_SET_MASK 0xFFFF

/*
 * enum dmub_cmd_type - DMUB inbox command.
 *
 * Command IDs should be treated as stable ABI.
 * Do not reuse or modify IDs.
 */

enum dmub_cmd_type {
 /**
 * Invalid command.
 */

 DMUB_CMD__NULL = 0,
 /**
 * Read modify write register sequence offload.
 */

 DMUB_CMD__REG_SEQ_READ_MODIFY_WRITE = 1,
 /**
 * Field update register sequence offload.
 */

 DMUB_CMD__REG_SEQ_FIELD_UPDATE_SEQ = 2,
 /**
 * Burst write sequence offload.
 */

 DMUB_CMD__REG_SEQ_BURST_WRITE = 3,
 /**
 * Reg wait sequence offload.
 */

 DMUB_CMD__REG_REG_WAIT = 4,
 /**
 * Workaround to avoid HUBP underflow during NV12 playback.
 */

 DMUB_CMD__PLAT_54186_WA = 5,
 /**
 * Command type used to query FW feature caps.
 */

 DMUB_CMD__QUERY_FEATURE_CAPS = 6,
 /**
 * Command type used to get visual confirm color.
 */

 DMUB_CMD__GET_VISUAL_CONFIRM_COLOR = 8,
 /**
 * Command type used for all PSR commands.
 */

 DMUB_CMD__PSR = 64,
 /**
 * Command type used for all MALL commands.
 */

 DMUB_CMD__MALL = 65,
 /**
 * Command type used for all ABM commands.
 */

 DMUB_CMD__ABM = 66,
 /**
 * Command type used to update dirty rects in FW.
 */

 DMUB_CMD__UPDATE_DIRTY_RECT = 67,
 /**
 * Command type used to update cursor info in FW.
 */

 DMUB_CMD__UPDATE_CURSOR_INFO = 68,
 /**
 * Command type used for HW locking in FW.
 */

 DMUB_CMD__HW_LOCK = 69,
 /**
 * Command type used to access DP AUX.
 */

 DMUB_CMD__DP_AUX_ACCESS = 70,
 /**
 * Command type used for OUTBOX1 notification enable
 */

 DMUB_CMD__OUTBOX1_ENABLE = 71,

 /**
 * Command type used for all idle optimization commands.
 */

 DMUB_CMD__IDLE_OPT = 72,
 /**
 * Command type used for all clock manager commands.
 */

 DMUB_CMD__CLK_MGR = 73,
 /**
 * Command type used for all panel control commands.
 */

 DMUB_CMD__PANEL_CNTL = 74,

 /**
 * Command type used for all CAB commands.
 */

 DMUB_CMD__CAB_FOR_SS = 75,

 DMUB_CMD__FW_ASSISTED_MCLK_SWITCH = 76,

 /**
 * Command type used for interfacing with DPIA.
 */

 DMUB_CMD__DPIA = 77,
 /**
 * Command type used for EDID CEA parsing
 */

 DMUB_CMD__EDID_CEA = 79,
 /**
 * Command type used for getting usbc cable ID
 */

 DMUB_CMD_GET_USBC_CABLE_ID = 81,
 /**
 * Command type used to query HPD state.
 */

 DMUB_CMD__QUERY_HPD_STATE = 82,
 /**
 * Command type used for all VBIOS interface commands.
 */

 /**
 * Command type used for all REPLAY commands.
 */

 DMUB_CMD__REPLAY = 83,

 /**
 * Command type used for all SECURE_DISPLAY commands.
 */

 DMUB_CMD__SECURE_DISPLAY = 85,

 /**
 * Command type used to set DPIA HPD interrupt state
 */

 DMUB_CMD__DPIA_HPD_INT_ENABLE = 86,

 /**
 * Command type used for all PSP commands.
 */

 DMUB_CMD__PSP = 88,

 /**
 * Command type used for all Fused IO commands.
 */

 DMUB_CMD__FUSED_IO = 89,

 /**
 * Command type used for all LSDMA commands.
 */

 DMUB_CMD__LSDMA = 90,

 /**
 * Command type use for all IPS commands.
 */

 DMUB_CMD__IPS = 91,

 DMUB_CMD__VBIOS = 128,
};

/**
 * enum dmub_out_cmd_type - DMUB outbox commands.
 */

enum dmub_out_cmd_type {
 /**
 * Invalid outbox command, ignored.
 */

 DMUB_OUT_CMD__NULL = 0,
 /**
 * Command type used for DP AUX Reply data notification
 */

 DMUB_OUT_CMD__DP_AUX_REPLY = 1,
 /**
 * Command type used for DP HPD event notification
 */

 DMUB_OUT_CMD__DP_HPD_NOTIFY = 2,
 /**
 * Command type used for SET_CONFIG Reply notification
 */

 DMUB_OUT_CMD__SET_CONFIG_REPLY = 3,
 /**
 * Command type used for USB4 DPIA notification
 */

 DMUB_OUT_CMD__DPIA_NOTIFICATION = 5,
 /**
 * Command type used for HPD redetect notification
 */

 DMUB_OUT_CMD__HPD_SENSE_NOTIFY = 6,
 /**
 * Command type used for Fused IO notification
 */

 DMUB_OUT_CMD__FUSED_IO = 7,
};

/* DMUB_CMD__DPIA command sub-types. */
enum dmub_cmd_dpia_type {
 DMUB_CMD__DPIA_DIG1_DPIA_CONTROL = 0,
 DMUB_CMD__DPIA_SET_CONFIG_ACCESS = 1, // will be replaced by DPIA_SET_CONFIG_REQUEST
 DMUB_CMD__DPIA_MST_ALLOC_SLOTS = 2,
 DMUB_CMD__DPIA_SET_TPS_NOTIFICATION = 3,
 DMUB_CMD__DPIA_SET_CONFIG_REQUEST = 4,
};

/* DMUB_OUT_CMD__DPIA_NOTIFICATION command types. */
enum dmub_cmd_dpia_notification_type {
 DPIA_NOTIFY__BW_ALLOCATION = 0,
};

#pragma pack(push, 1)

/**
 * struct dmub_cmd_header - Common command header fields.
 */

struct dmub_cmd_header {
 unsigned int type : 8; /**< command type */
 unsigned int sub_type : 8; /**< command sub type */
 unsigned int ret_status : 1; /**< 1 if returned data, 0 otherwise */
 unsigned int multi_cmd_pending : 1; /**< 1 if multiple commands chained together */
 unsigned int is_reg_based : 1; /**< 1 if register based mailbox cmd, 0 if FB based cmd */
 unsigned int reserved0 : 5; /**< reserved bits */
 unsigned int payload_bytes : 6;  /* payload excluding header - up to 60 bytes */
 unsigned int reserved1 : 2; /**< reserved bits */
};

/*
 * struct dmub_cmd_read_modify_write_sequence - Read modify write
 *
 * 60 payload bytes can hold up to 5 sets of read modify writes,
 * each take 3 dwords.
 *
 * number of sequences = header.payload_bytes / sizeof(struct dmub_cmd_read_modify_write_sequence)
 *
 * modify_mask = 0xffff'ffff means all fields are going to be updated.  in this case
 * command parser will skip the read and we can use modify_mask = 0xffff'ffff as reg write
 */

struct dmub_cmd_read_modify_write_sequence {
 uint32_t addr; /**< register address */
 uint32_t modify_mask; /**< modify mask */
 uint32_t modify_value; /**< modify value */
};

/**
 * Maximum number of ops in read modify write sequence.
 */

#define DMUB_READ_MODIFY_WRITE_SEQ__MAX 5

/**
 * struct dmub_cmd_read_modify_write_sequence - Read modify write command.
 */

struct dmub_rb_cmd_read_modify_write {
 struct dmub_cmd_header header;  /**< command header */
 /**
 * Read modify write sequence.
 */

 struct dmub_cmd_read_modify_write_sequence seq[DMUB_READ_MODIFY_WRITE_SEQ__MAX];
};

/*
 * Update a register with specified masks and values sequeunce
 *
 * 60 payload bytes can hold address + up to 7 sets of mask/value combo, each take 2 dword
 *
 * number of field update sequence = (header.payload_bytes - sizeof(addr)) / sizeof(struct read_modify_write_sequence)
 *
 *
 * USE CASE:
 *   1. auto-increment register where additional read would update pointer and produce wrong result
 *   2. toggle a bit without read in the middle
 */


struct dmub_cmd_reg_field_update_sequence {
 uint32_t modify_mask; /**< 0xffff'ffff to skip initial read */
 uint32_t modify_value; /**< value to update with */
};

/**
 * Maximum number of ops in field update sequence.
 */

#define DMUB_REG_FIELD_UPDATE_SEQ__MAX 7

/**
 * struct dmub_rb_cmd_reg_field_update_sequence - Field update command.
 */

struct dmub_rb_cmd_reg_field_update_sequence {
 struct dmub_cmd_header header; /**< command header */
 uint32_t addr; /**< register address */
 /**
 * Field update sequence.
 */

 struct dmub_cmd_reg_field_update_sequence seq[DMUB_REG_FIELD_UPDATE_SEQ__MAX];
};


/**
 * Maximum number of burst write values.
 */

#define DMUB_BURST_WRITE_VALUES__MAX  14

/*
 * struct dmub_rb_cmd_burst_write - Burst write
 *
 * support use case such as writing out LUTs.
 *
 * 60 payload bytes can hold up to 14 values to write to given address
 *
 * number of payload = header.payload_bytes / sizeof(struct read_modify_write_sequence)
 */

struct dmub_rb_cmd_burst_write {
 struct dmub_cmd_header header; /**< command header */
 uint32_t addr; /**< register start address */
 /**
 * Burst write register values.
 */

 uint32_t write_values[DMUB_BURST_WRITE_VALUES__MAX];
};

/**
 * struct dmub_rb_cmd_common - Common command header
 */

struct dmub_rb_cmd_common {
 struct dmub_cmd_header header; /**< command header */
 /**
 * Padding to RB_CMD_SIZE
 */

 uint8_t cmd_buffer[DMUB_RB_CMD_SIZE - sizeof(struct dmub_cmd_header)];
};

/**
 * struct dmub_cmd_reg_wait_data - Register wait data
 */

struct dmub_cmd_reg_wait_data {
 uint32_t addr; /**< Register address */
 uint32_t mask; /**< Mask for register bits */
 uint32_t condition_field_value; /**< Value to wait for */
 uint32_t time_out_us; /**< Time out for reg wait in microseconds */
};

/**
 * struct dmub_rb_cmd_reg_wait - Register wait command
 */

struct dmub_rb_cmd_reg_wait {
 struct dmub_cmd_header header; /**< Command header */
 struct dmub_cmd_reg_wait_data reg_wait; /**< Register wait data */
};

/**
 * struct dmub_cmd_PLAT_54186_wa - Underflow workaround
 *
 * Reprograms surface parameters to avoid underflow.
 */

struct dmub_cmd_PLAT_54186_wa {
 uint32_t DCSURF_SURFACE_CONTROL; /**< reg value */
 uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS_HIGH; /**< reg value */
 uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS; /**< reg value */
 uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS_HIGH_C; /**< reg value */
 uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS_C; /**< reg value */
 struct {
  uint32_t hubp_inst : 4; /**< HUBP instance */
  uint32_t tmz_surface : 1; /**< TMZ enable or disable */
  uint32_t immediate :1; /**< Immediate flip */
  uint32_t vmid : 4; /**< VMID */
  uint32_t grph_stereo : 1; /**< 1 if stereo */
  uint32_t reserved : 21; /**< Reserved */
 } flip_params; /**< Pageflip parameters */
 uint32_t reserved[9]; /**< Reserved bits */
};

/**
 * struct dmub_rb_cmd_PLAT_54186_wa - Underflow workaround command
 */

struct dmub_rb_cmd_PLAT_54186_wa {
 struct dmub_cmd_header header; /**< Command header */
 struct dmub_cmd_PLAT_54186_wa flip; /**< Flip data */
};

/**
 * enum dmub_cmd_mall_type - MALL commands
 */

enum dmub_cmd_mall_type {
 /**
 * Allows display refresh from MALL.
 */

 DMUB_CMD__MALL_ACTION_ALLOW = 0,
 /**
 * Disallows display refresh from MALL.
 */

 DMUB_CMD__MALL_ACTION_DISALLOW = 1,
 /**
 * Cursor copy for MALL.
 */

 DMUB_CMD__MALL_ACTION_COPY_CURSOR = 2,
 /**
 * Controls DF requests.
 */

 DMUB_CMD__MALL_ACTION_NO_DF_REQ = 3,
};

/**
 * struct dmub_rb_cmd_mall - MALL command data.
 */

struct dmub_rb_cmd_mall {
 struct dmub_cmd_header header; /**< Common command header */
 union dmub_addr cursor_copy_src; /**< Cursor copy address */
 union dmub_addr cursor_copy_dst; /**< Cursor copy destination */
 uint32_t tmr_delay; /**< Timer delay */
 uint32_t tmr_scale; /**< Timer scale */
 uint16_t cursor_width; /**< Cursor width in pixels */
 uint16_t cursor_pitch; /**< Cursor pitch in pixels */
 uint16_t cursor_height; /**< Cursor height in pixels */
 uint8_t cursor_bpp; /**< Cursor bits per pixel */
 uint8_t debug_bits; /**< Debug bits */

 uint8_t reserved1; /**< Reserved bits */
 uint8_t reserved2; /**< Reserved bits */
};

/**
 * enum dmub_cmd_cab_type - CAB command data.
 */

enum dmub_cmd_cab_type {
 /**
 * No idle optimizations (i.e. no CAB)
 */

 DMUB_CMD__CAB_NO_IDLE_OPTIMIZATION = 0,
 /**
 * No DCN requests for memory
 */

 DMUB_CMD__CAB_NO_DCN_REQ = 1,
 /**
 * Fit surfaces in CAB (i.e. CAB enable)
 */

 DMUB_CMD__CAB_DCN_SS_FIT_IN_CAB = 2,
 /**
 * Do not fit surfaces in CAB (i.e. no CAB)
 */

 DMUB_CMD__CAB_DCN_SS_NOT_FIT_IN_CAB = 3,
};

/**
 * struct dmub_rb_cmd_cab - CAB command data.
 */

struct dmub_rb_cmd_cab_for_ss {
 struct dmub_cmd_header header;
 uint8_t cab_alloc_ways; /* total number of ways */
 uint8_t debug_bits;     /* debug bits */
};

/**
 * Enum for indicating which MCLK switch mode per pipe
 */

enum mclk_switch_mode {
 NONE = 0,
 FPO = 1,
 SUBVP = 2,
 VBLANK = 3,
};

/* Per pipe struct which stores the MCLK switch mode
 * data to be sent to DMUB.
 * Named "v2" for now -- once FPO and SUBVP are fully merged
 * the type name can be updated
 */

struct dmub_cmd_fw_assisted_mclk_switch_pipe_data_v2 {
 union {
  struct {
   uint32_t pix_clk_100hz;
   uint16_t main_vblank_start;
   uint16_t main_vblank_end;
   uint16_t mall_region_lines;
   uint16_t prefetch_lines;
   uint16_t prefetch_to_mall_start_lines;
   uint16_t processing_delay_lines;
   uint16_t htotal; // required to calculate line time for multi-display cases
   uint16_t vtotal;
   uint8_t main_pipe_index;
   uint8_t phantom_pipe_index;
   /* Since the microschedule is calculated in terms of OTG lines,
 * include any scaling factors to make sure when we get accurate
 * conversion when programming MALL_START_LINE (which is in terms
 * of HUBP lines). If 4K is being downscaled to 1080p, scale factor
 * is 1/2 (numerator = 1, denominator = 2).
 */

   uint8_t scale_factor_numerator;
   uint8_t scale_factor_denominator;
   uint8_t is_drr;
   uint8_t main_split_pipe_index;
   uint8_t phantom_split_pipe_index;
  } subvp_data;

  struct {
   uint32_t pix_clk_100hz;
   uint16_t vblank_start;
   uint16_t vblank_end;
   uint16_t vstartup_start;
   uint16_t vtotal;
   uint16_t htotal;
   uint8_t vblank_pipe_index;
   uint8_t padding[1];
   struct {
    uint8_t drr_in_use;
    uint8_t drr_window_size_ms; // Indicates largest VMIN/VMAX adjustment per frame
    uint16_t min_vtotal_supported; // Min VTOTAL that supports switching in VBLANK
    uint16_t max_vtotal_supported; // Max VTOTAL that can support SubVP static scheduling
    uint8_t use_ramping;  // Use ramping or not
    uint8_t drr_vblank_start_margin;
   } drr_info;    // DRR considered as part of SubVP + VBLANK case
  } vblank_data;
 } pipe_config;

 /* - subvp_data in the union (pipe_config) takes up 27 bytes.
 * - Make the "mode" field a uint8_t instead of enum so we only use 1 byte (only
 *   for the DMCUB command, cast to enum once we populate the DMCUB subvp state).
 */

 uint8_t mode; // enum mclk_switch_mode
};

/**
 * Config data for Sub-VP and FPO
 * Named "v2" for now -- once FPO and SUBVP are fully merged
 * the type name can be updated
 */

struct dmub_cmd_fw_assisted_mclk_switch_config_v2 {
 uint16_t watermark_a_cache;
 uint8_t vertical_int_margin_us;
 uint8_t pstate_allow_width_us;
 struct dmub_cmd_fw_assisted_mclk_switch_pipe_data_v2 pipe_data[DMUB_MAX_SUBVP_STREAMS];
};

/**
 * DMUB rb command definition for Sub-VP and FPO
 * Named "v2" for now -- once FPO and SUBVP are fully merged
 * the type name can be updated
 */

struct dmub_rb_cmd_fw_assisted_mclk_switch_v2 {
 struct dmub_cmd_header header;
 struct dmub_cmd_fw_assisted_mclk_switch_config_v2 config_data;
};

struct dmub_flip_addr_info {
 uint32_t surf_addr_lo;
 uint32_t surf_addr_c_lo;
 uint32_t meta_addr_lo;
 uint32_t meta_addr_c_lo;
 uint16_t surf_addr_hi;
 uint16_t surf_addr_c_hi;
 uint16_t meta_addr_hi;
 uint16_t meta_addr_c_hi;
};

struct dmub_fams2_flip_info {
 union {
  struct {
   uint8_t is_immediate: 1;
  } bits;
  uint8_t all;
 } config;
 uint8_t otg_inst;
 uint8_t pipe_mask;
 uint8_t pad;
 struct dmub_flip_addr_info addr_info;
};

struct dmub_rb_cmd_fams2_flip {
 struct dmub_cmd_header header;
 struct dmub_fams2_flip_info flip_info;
};

struct dmub_cmd_lsdma_data {
 union {
  struct lsdma_init_data {
   union dmub_addr gpu_addr_base;
   uint32_t ring_size;
  } init_data;
  struct lsdma_tiled_copy_data {
   uint32_t src_addr_lo;
   uint32_t src_addr_hi;
   uint32_t dst_addr_lo;
   uint32_t dst_addr_hi;

   uint32_t src_x            : 16;
   uint32_t src_y            : 16;

   uint32_t src_width        : 16;
   uint32_t src_height       : 16;

   uint32_t dst_x            : 16;
   uint32_t dst_y            : 16;

   uint32_t dst_width        : 16;
   uint32_t dst_height       : 16;

   uint32_t rect_x           : 16;
   uint32_t rect_y           : 16;

   uint32_t src_swizzle_mode : 5;
   uint32_t src_mip_max      : 5;
   uint32_t src_mip_id       : 5;
   uint32_t dst_mip_max      : 5;
   uint32_t dst_swizzle_mode : 5;
   uint32_t dst_mip_id       : 5;
   uint32_t tmz              : 1;
   uint32_t dcc              : 1;

   uint32_t data_format      : 6;
   uint32_t padding1         : 4;
   uint32_t dst_element_size : 3;
   uint32_t num_type         : 3;
   uint32_t src_element_size : 3;
   uint32_t write_compress   : 2;
   uint32_t cache_policy_dst : 2;
   uint32_t cache_policy_src : 2;
   uint32_t read_compress    : 2;
   uint32_t src_dim          : 2;
   uint32_t dst_dim          : 2;
   uint32_t max_uncom        : 1;

   uint32_t max_com          : 2;
   uint32_t padding          : 30;
  } tiled_copy_data;
  struct lsdma_linear_copy_data {
   uint32_t count            : 30;
   uint32_t cache_policy_dst : 2;

   uint32_t tmz              : 1;
   uint32_t cache_policy_src : 2;
   uint32_t padding          : 29;

   uint32_t src_lo;
   uint32_t src_hi;
   uint32_t dst_lo;
   uint32_t dst_hi;
  } linear_copy_data;
  struct lsdma_reg_write_data {
   uint32_t reg_addr;
   uint32_t reg_data;
  } reg_write_data;
  struct lsdma_pio_copy_data {
   union {
    struct {
     uint32_t byte_count      : 26;
     uint32_t src_loc         : 1;
     uint32_t dst_loc         : 1;
     uint32_t src_addr_inc    : 1;
     uint32_t dst_addr_inc    : 1;
     uint32_t overlap_disable : 1;
     uint32_t constant_fill   : 1;
    } fields;
    uint32_t raw;
   } packet;
   uint32_t src_lo;
   uint32_t src_hi;
   uint32_t dst_lo;
   uint32_t dst_hi;
  } pio_copy_data;
  struct lsdma_pio_constfill_data {
   union {
    struct {
     uint32_t byte_count      : 26;
     uint32_t src_loc         : 1;
     uint32_t dst_loc         : 1;
     uint32_t src_addr_inc    : 1;
     uint32_t dst_addr_inc    : 1;
     uint32_t overlap_disable : 1;
     uint32_t constant_fill   : 1;
    } fields;
    uint32_t raw;
   } packet;
   uint32_t dst_lo;
   uint32_t dst_hi;
   uint32_t data;
  } pio_constfill_data;

  uint32_t all[14];
 } u;

};

struct dmub_rb_cmd_lsdma {
 struct dmub_cmd_header header;
 struct dmub_cmd_lsdma_data lsdma_data;
};

struct dmub_optc_state_v2 {
 uint32_t v_total_min;
 uint32_t v_total_max;
 uint32_t v_total_mid;
 uint32_t v_total_mid_frame_num;
 uint8_t program_manual_trigger;
 uint8_t tg_inst;
 uint8_t pad[2];
};

struct dmub_optc_position {
 uint32_t vpos;
 uint32_t hpos;
 uint32_t frame;
};

struct dmub_rb_cmd_fams2_drr_update {
 struct dmub_cmd_header header;
 struct dmub_optc_state_v2 dmub_optc_state_req;
};

/* HW and FW global configuration data for FAMS2 */
/* FAMS2 types and structs */
enum fams2_stream_type {
 FAMS2_STREAM_TYPE_NONE = 0,
 FAMS2_STREAM_TYPE_VBLANK = 1,
 FAMS2_STREAM_TYPE_VACTIVE = 2,
 FAMS2_STREAM_TYPE_DRR = 3,
 FAMS2_STREAM_TYPE_SUBVP = 4,
};

struct dmub_rect16 {
 /**
 * Dirty rect x offset.
 */

 uint16_t x;

 /**
 * Dirty rect y offset.
 */

 uint16_t y;

 /**
 * Dirty rect width.
 */

 uint16_t width;

 /**
 * Dirty rect height.
 */

 uint16_t height;
};

/* static stream state */
struct dmub_fams2_legacy_stream_static_state {
 uint8_t vactive_det_fill_delay_otg_vlines;
 uint8_t programming_delay_otg_vlines;
}; //v0

struct dmub_fams2_subvp_stream_static_state {
 uint16_t vratio_numerator;
 uint16_t vratio_denominator;
 uint16_t phantom_vtotal;
 uint16_t phantom_vactive;
 union {
  struct {
   uint8_t is_multi_planar : 1;
   uint8_t is_yuv420 : 1;
  } bits;
  uint8_t all;
 } config;
 uint8_t programming_delay_otg_vlines;
 uint8_t prefetch_to_mall_otg_vlines;
 uint8_t phantom_otg_inst;
 uint8_t phantom_pipe_mask;
 uint8_t phantom_plane_pipe_masks[DMUB_MAX_PHANTOM_PLANES]; // phantom pipe mask per plane (for flip passthrough)
}; //v0

struct dmub_fams2_drr_stream_static_state {
 uint16_t nom_stretched_vtotal;
 uint8_t programming_delay_otg_vlines;
 uint8_t only_stretch_if_required;
 uint8_t pad[2];
}; //v0

struct dmub_fams2_cmd_legacy_stream_static_state {
 uint16_t vactive_det_fill_delay_otg_vlines;
 uint16_t programming_delay_otg_vlines;
}; //v1

struct dmub_fams2_cmd_subvp_stream_static_state {
 uint16_t vratio_numerator;
 uint16_t vratio_denominator;
 uint16_t phantom_vtotal;
 uint16_t phantom_vactive;
 uint16_t programming_delay_otg_vlines;
 uint16_t prefetch_to_mall_otg_vlines;
 union {
  struct {
   uint8_t is_multi_planar : 1;
   uint8_t is_yuv420 : 1;
  } bits;
  uint8_t all;
 } config;
 uint8_t phantom_otg_inst;
 uint8_t phantom_pipe_mask;
 uint8_t pad0;
 uint8_t phantom_plane_pipe_masks[DMUB_MAX_PHANTOM_PLANES]; // phantom pipe mask per plane (for flip passthrough)
 uint8_t pad1[4 - (DMUB_MAX_PHANTOM_PLANES % 4)];
}; //v1

struct dmub_fams2_cmd_drr_stream_static_state {
 uint16_t nom_stretched_vtotal;
 uint16_t programming_delay_otg_vlines;
 uint8_t only_stretch_if_required;
 uint8_t pad[3];
}; //v1

union dmub_fams2_stream_static_sub_state {
 struct dmub_fams2_legacy_stream_static_state legacy;
 struct dmub_fams2_subvp_stream_static_state subvp;
 struct dmub_fams2_drr_stream_static_state drr;
}; //v0

union dmub_fams2_cmd_stream_static_sub_state {
 COMMON_STREAM_STATIC_SUB_STATE
}; //v1

union dmub_fams2_stream_static_sub_state_v2 {
 COMMON_STREAM_STATIC_SUB_STATE
}; //v2

struct dmub_fams2_stream_static_state {
 enum fams2_stream_type type;
 uint32_t otg_vline_time_ns;
 uint32_t otg_vline_time_ticks;
 uint16_t htotal;
 uint16_t vtotal; // nominal vtotal
 uint16_t vblank_start;
 uint16_t vblank_end;
 uint16_t max_vtotal;
 uint16_t allow_start_otg_vline;
 uint16_t allow_end_otg_vline;
 uint16_t drr_keepout_otg_vline; // after this vline, vtotal cannot be changed
 uint8_t scheduling_delay_otg_vlines; // min time to budget for ready to microschedule start
 uint8_t contention_delay_otg_vlines; // time to budget for contention on execution
 uint8_t vline_int_ack_delay_otg_vlines; // min time to budget for vertical interrupt firing
 uint8_t allow_to_target_delay_otg_vlines; // time from allow vline to target vline
 union {
  struct {
   uint8_t is_drr: 1; // stream is DRR enabled
   uint8_t clamp_vtotal_min: 1; // clamp vtotal to min instead of nominal
   uint8_t min_ttu_vblank_usable: 1; // if min ttu vblank is above wm, no force pstate is needed in blank
  } bits;
  uint8_t all;
 } config;
 uint8_t otg_inst;
 uint8_t pipe_mask; // pipe mask for the whole config
 uint8_t num_planes;
 uint8_t plane_pipe_masks[DMUB_MAX_PLANES]; // pipe mask per plane (for flip passthrough)
 uint8_t pad[4 - (DMUB_MAX_PLANES % 4)];
 union dmub_fams2_stream_static_sub_state sub_state;
}; //v0

struct dmub_fams2_cmd_stream_static_base_state {
 enum fams2_stream_type type;
 uint32_t otg_vline_time_ns;
 uint32_t otg_vline_time_ticks;
 uint16_t htotal;
 uint16_t vtotal; // nominal vtotal
 uint16_t vblank_start;
 uint16_t vblank_end;
 uint16_t max_vtotal;
 uint16_t allow_start_otg_vline;
 uint16_t allow_end_otg_vline;
 uint16_t drr_keepout_otg_vline; // after this vline, vtotal cannot be changed
 uint16_t scheduling_delay_otg_vlines; // min time to budget for ready to microschedule start
 uint16_t contention_delay_otg_vlines; // time to budget for contention on execution
 uint16_t vline_int_ack_delay_otg_vlines; // min time to budget for vertical interrupt firing
 uint16_t allow_to_target_delay_otg_vlines; // time from allow vline to target vline
 union {
  struct {
   uint8_t is_drr : 1; // stream is DRR enabled
   uint8_t clamp_vtotal_min : 1; // clamp vtotal to min instead of nominal
   uint8_t min_ttu_vblank_usable : 1; // if min ttu vblank is above wm, no force pstate is needed in blank
  } bits;
  uint8_t all;
 } config;
 uint8_t otg_inst;
 uint8_t pipe_mask; // pipe mask for the whole config
 uint8_t num_planes;
 uint8_t plane_pipe_masks[DMUB_MAX_PLANES]; // pipe mask per plane (for flip passthrough)
 uint8_t pad[4 - (DMUB_MAX_PLANES % 4)];
}; //v1

struct dmub_fams2_stream_static_state_v1 {
 struct dmub_fams2_cmd_stream_static_base_state base;
 union dmub_fams2_stream_static_sub_state_v2 sub_state;
}; //v1

/**
 * enum dmub_fams2_allow_delay_check_mode - macroscheduler mode for breaking on excessive
 * p-state request to allow latency
 */

enum dmub_fams2_allow_delay_check_mode {
 /* No check for request to allow delay */
 FAMS2_ALLOW_DELAY_CHECK_NONE = 0,
 /* Check for request to allow delay */
 FAMS2_ALLOW_DELAY_CHECK_FROM_START = 1,
 /* Check for prepare to allow delay */
 FAMS2_ALLOW_DELAY_CHECK_FROM_PREPARE = 2,
};

union dmub_fams2_global_feature_config {
 struct {
  uint32_t enable: 1;
  uint32_t enable_ppt_check: 1;
  uint32_t enable_stall_recovery: 1;
  uint32_t enable_debug: 1;
  uint32_t enable_offload_flip: 1;
  uint32_t enable_visual_confirm: 1;
  uint32_t allow_delay_check_mode: 2;
  uint32_t reserved: 24;
 } bits;
 uint32_t all;
};

struct dmub_cmd_fams2_global_config {
 uint32_t max_allow_delay_us; // max delay to assert allow from uclk change begin
 uint32_t lock_wait_time_us; // time to forecast acquisition of lock
 uint32_t num_streams;
 union dmub_fams2_global_feature_config features;
 uint32_t recovery_timeout_us;
 uint32_t hwfq_flip_programming_delay_us;
};

union dmub_cmd_fams2_config {
 struct dmub_cmd_fams2_global_config global;
 struct dmub_fams2_stream_static_state stream; //v0
 union {
  struct dmub_fams2_cmd_stream_static_base_state base;
  union dmub_fams2_cmd_stream_static_sub_state sub_state;
 } stream_v1; //v1
};

struct dmub_fams2_config_v2 {
 struct dmub_cmd_fams2_global_config global;
 struct dmub_fams2_stream_static_state_v1 stream_v1[DMUB_MAX_STREAMS]; //v1
};

/**
 * DMUB rb command definition for FAMS2 (merged SubVP, FPO, Legacy)
 */

struct dmub_rb_cmd_fams2 {
 struct dmub_cmd_header header;
 union dmub_cmd_fams2_config config;
};

/**
 * Indirect buffer descriptor
 */

struct dmub_ib_data {
 union dmub_addr src; // location of indirect buffer in memory
 uint16_t size; // indirect buffer size in bytes
};

/**
--> --------------------

--> maximum size reached

--> --------------------

Messung V0.5
C=85 H=96 G=90

¤ Dauer der Verarbeitung: 0.21 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.