1 /* 2 * Copyright 2019 Advanced Micro Devices, Inc. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included in 12 * all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 * OTHER DEALINGS IN THE SOFTWARE. 21 * 22 * Authors: AMD 23 * 24 */ 25 26 #ifndef DMUB_CMD_H 27 #define DMUB_CMD_H 28 29 #if defined(_TEST_HARNESS) || defined(FPGA_USB4) 30 #include "dmub_fw_types.h" 31 #include "include_legacy/atomfirmware.h" 32 33 #if defined(_TEST_HARNESS) 34 #include <string.h> 35 #endif 36 #else 37 38 #include <asm/byteorder.h> 39 #include <linux/types.h> 40 #include <linux/string.h> 41 #include <linux/delay.h> 42 43 #include "atomfirmware.h" 44 45 #endif // defined(_TEST_HARNESS) || defined(FPGA_USB4) 46 47 //<DMUB_TYPES>================================================================== 48 /* Basic type definitions. */ 49 50 #define __forceinline inline 51 52 /** 53 * Flag from driver to indicate that ABM should be disabled gradually 54 * by slowly reversing all backlight programming and pixel compensation. 55 */ 56 #define SET_ABM_PIPE_GRADUALLY_DISABLE 0 57 58 /** 59 * Flag from driver to indicate that ABM should be disabled immediately 60 * and undo all backlight programming and pixel compensation. 61 */ 62 #define SET_ABM_PIPE_IMMEDIATELY_DISABLE 255 63 64 /** 65 * Flag from driver to indicate that ABM should be disabled immediately 66 * and keep the current backlight programming and pixel compensation. 67 */ 68 #define SET_ABM_PIPE_IMMEDIATE_KEEP_GAIN_DISABLE 254 69 70 /** 71 * Flag from driver to set the current ABM pipe index or ABM operating level. 72 */ 73 #define SET_ABM_PIPE_NORMAL 1 74 75 /** 76 * Number of ambient light levels in ABM algorithm. 77 */ 78 #define NUM_AMBI_LEVEL 5 79 80 /** 81 * Number of operating/aggression levels in ABM algorithm. 82 */ 83 #define NUM_AGGR_LEVEL 4 84 85 /** 86 * Number of segments in the gamma curve. 87 */ 88 #define NUM_POWER_FN_SEGS 8 89 90 /** 91 * Number of segments in the backlight curve. 92 */ 93 #define NUM_BL_CURVE_SEGS 16 94 95 /* Maximum number of SubVP streams */ 96 #define DMUB_MAX_SUBVP_STREAMS 2 97 98 /* Maximum number of streams on any ASIC. */ 99 #define DMUB_MAX_STREAMS 6 100 101 /* Maximum number of planes on any ASIC. */ 102 #define DMUB_MAX_PLANES 6 103 104 /* Trace buffer offset for entry */ 105 #define TRACE_BUFFER_ENTRY_OFFSET 16 106 107 /** 108 * Maximum number of dirty rects supported by FW. 109 */ 110 #define DMUB_MAX_DIRTY_RECTS 3 111 112 /** 113 * 114 * PSR control version legacy 115 */ 116 #define DMUB_CMD_PSR_CONTROL_VERSION_UNKNOWN 0x0 117 /** 118 * PSR control version with multi edp support 119 */ 120 #define DMUB_CMD_PSR_CONTROL_VERSION_1 0x1 121 122 123 /** 124 * ABM control version legacy 125 */ 126 #define DMUB_CMD_ABM_CONTROL_VERSION_UNKNOWN 0x0 127 128 /** 129 * ABM control version with multi edp support 130 */ 131 #define DMUB_CMD_ABM_CONTROL_VERSION_1 0x1 132 133 /** 134 * Physical framebuffer address location, 64-bit. 135 */ 136 #ifndef PHYSICAL_ADDRESS_LOC 137 #define PHYSICAL_ADDRESS_LOC union large_integer 138 #endif 139 140 /** 141 * OS/FW agnostic memcpy 142 */ 143 #ifndef dmub_memcpy 144 #define dmub_memcpy(dest, source, bytes) memcpy((dest), (source), (bytes)) 145 #endif 146 147 /** 148 * OS/FW agnostic memset 149 */ 150 #ifndef dmub_memset 151 #define dmub_memset(dest, val, bytes) memset((dest), (val), (bytes)) 152 #endif 153 154 #if defined(__cplusplus) 155 extern "C" { 156 #endif 157 158 /** 159 * OS/FW agnostic udelay 160 */ 161 #ifndef dmub_udelay 162 #define dmub_udelay(microseconds) udelay(microseconds) 163 #endif 164 165 /** 166 * union dmub_addr - DMUB physical/virtual 64-bit address. 167 */ 168 union dmub_addr { 169 struct { 170 uint32_t low_part; /**< Lower 32 bits */ 171 uint32_t high_part; /**< Upper 32 bits */ 172 } u; /*<< Low/high bit access */ 173 uint64_t quad_part; /*<< 64 bit address */ 174 }; 175 176 /** 177 * Dirty rect definition. 178 */ 179 struct dmub_rect { 180 /** 181 * Dirty rect x offset. 182 */ 183 uint32_t x; 184 185 /** 186 * Dirty rect y offset. 187 */ 188 uint32_t y; 189 190 /** 191 * Dirty rect width. 192 */ 193 uint32_t width; 194 195 /** 196 * Dirty rect height. 197 */ 198 uint32_t height; 199 }; 200 201 /** 202 * Flags that can be set by driver to change some PSR behaviour. 203 */ 204 union dmub_psr_debug_flags { 205 /** 206 * Debug flags. 207 */ 208 struct { 209 /** 210 * Enable visual confirm in FW. 211 */ 212 uint32_t visual_confirm : 1; 213 214 /** 215 * Force all selective updates to bw full frame updates. 216 */ 217 uint32_t force_full_frame_update : 1; 218 219 /** 220 * Use HW Lock Mgr object to do HW locking in FW. 221 */ 222 uint32_t use_hw_lock_mgr : 1; 223 224 /** 225 * Use TPS3 signal when restore main link. 226 */ 227 uint32_t force_wakeup_by_tps3 : 1; 228 229 /** 230 * Back to back flip, therefore cannot power down PHY 231 */ 232 uint32_t back_to_back_flip : 1; 233 234 } bitfields; 235 236 /** 237 * Union for debug flags. 238 */ 239 uint32_t u32All; 240 }; 241 242 /** 243 * DMUB visual confirm color 244 */ 245 struct dmub_feature_caps { 246 /** 247 * Max PSR version supported by FW. 248 */ 249 uint8_t psr; 250 uint8_t fw_assisted_mclk_switch; 251 uint8_t reserved[6]; 252 }; 253 254 struct dmub_visual_confirm_color { 255 /** 256 * Maximum 10 bits color value 257 */ 258 uint16_t color_r_cr; 259 uint16_t color_g_y; 260 uint16_t color_b_cb; 261 uint16_t panel_inst; 262 }; 263 264 #if defined(__cplusplus) 265 } 266 #endif 267 268 //============================================================================== 269 //</DMUB_TYPES>================================================================= 270 //============================================================================== 271 //< DMUB_META>================================================================== 272 //============================================================================== 273 #pragma pack(push, 1) 274 275 /* Magic value for identifying dmub_fw_meta_info */ 276 #define DMUB_FW_META_MAGIC 0x444D5542 277 278 /* Offset from the end of the file to the dmub_fw_meta_info */ 279 #define DMUB_FW_META_OFFSET 0x24 280 281 /** 282 * struct dmub_fw_meta_info - metadata associated with fw binary 283 * 284 * NOTE: This should be considered a stable API. Fields should 285 * not be repurposed or reordered. New fields should be 286 * added instead to extend the structure. 287 * 288 * @magic_value: magic value identifying DMUB firmware meta info 289 * @fw_region_size: size of the firmware state region 290 * @trace_buffer_size: size of the tracebuffer region 291 * @fw_version: the firmware version information 292 * @dal_fw: 1 if the firmware is DAL 293 */ 294 struct dmub_fw_meta_info { 295 uint32_t magic_value; /**< magic value identifying DMUB firmware meta info */ 296 uint32_t fw_region_size; /**< size of the firmware state region */ 297 uint32_t trace_buffer_size; /**< size of the tracebuffer region */ 298 uint32_t fw_version; /**< the firmware version information */ 299 uint8_t dal_fw; /**< 1 if the firmware is DAL */ 300 uint8_t reserved[3]; /**< padding bits */ 301 }; 302 303 /** 304 * union dmub_fw_meta - ensures that dmub_fw_meta_info remains 64 bytes 305 */ 306 union dmub_fw_meta { 307 struct dmub_fw_meta_info info; /**< metadata info */ 308 uint8_t reserved[64]; /**< padding bits */ 309 }; 310 311 #pragma pack(pop) 312 313 //============================================================================== 314 //< DMUB Trace Buffer>================================================================ 315 //============================================================================== 316 /** 317 * dmub_trace_code_t - firmware trace code, 32-bits 318 */ 319 typedef uint32_t dmub_trace_code_t; 320 321 /** 322 * struct dmcub_trace_buf_entry - Firmware trace entry 323 */ 324 struct dmcub_trace_buf_entry { 325 dmub_trace_code_t trace_code; /**< trace code for the event */ 326 uint32_t tick_count; /**< the tick count at time of trace */ 327 uint32_t param0; /**< trace defined parameter 0 */ 328 uint32_t param1; /**< trace defined parameter 1 */ 329 }; 330 331 //============================================================================== 332 //< DMUB_STATUS>================================================================ 333 //============================================================================== 334 335 /** 336 * DMCUB scratch registers can be used to determine firmware status. 337 * Current scratch register usage is as follows: 338 * 339 * SCRATCH0: FW Boot Status register 340 * SCRATCH5: LVTMA Status Register 341 * SCRATCH15: FW Boot Options register 342 */ 343 344 /** 345 * union dmub_fw_boot_status - Status bit definitions for SCRATCH0. 346 */ 347 union dmub_fw_boot_status { 348 struct { 349 uint32_t dal_fw : 1; /**< 1 if DAL FW */ 350 uint32_t mailbox_rdy : 1; /**< 1 if mailbox ready */ 351 uint32_t optimized_init_done : 1; /**< 1 if optimized init done */ 352 uint32_t restore_required : 1; /**< 1 if driver should call restore */ 353 uint32_t defer_load : 1; /**< 1 if VBIOS data is deferred programmed */ 354 uint32_t reserved : 1; 355 uint32_t detection_required: 1; /**< if detection need to be triggered by driver */ 356 357 } bits; /**< status bits */ 358 uint32_t all; /**< 32-bit access to status bits */ 359 }; 360 361 /** 362 * enum dmub_fw_boot_status_bit - Enum bit definitions for SCRATCH0. 363 */ 364 enum dmub_fw_boot_status_bit { 365 DMUB_FW_BOOT_STATUS_BIT_DAL_FIRMWARE = (1 << 0), /**< 1 if DAL FW */ 366 DMUB_FW_BOOT_STATUS_BIT_MAILBOX_READY = (1 << 1), /**< 1 if mailbox ready */ 367 DMUB_FW_BOOT_STATUS_BIT_OPTIMIZED_INIT_DONE = (1 << 2), /**< 1 if init done */ 368 DMUB_FW_BOOT_STATUS_BIT_RESTORE_REQUIRED = (1 << 3), /**< 1 if driver should call restore */ 369 DMUB_FW_BOOT_STATUS_BIT_DEFERRED_LOADED = (1 << 4), /**< 1 if VBIOS data is deferred programmed */ 370 DMUB_FW_BOOT_STATUS_BIT_DETECTION_REQUIRED = (1 << 6), /**< 1 if detection need to be triggered by driver*/ 371 }; 372 373 /* Register bit definition for SCRATCH5 */ 374 union dmub_lvtma_status { 375 struct { 376 uint32_t psp_ok : 1; 377 uint32_t edp_on : 1; 378 uint32_t reserved : 30; 379 } bits; 380 uint32_t all; 381 }; 382 383 enum dmub_lvtma_status_bit { 384 DMUB_LVTMA_STATUS_BIT_PSP_OK = (1 << 0), 385 DMUB_LVTMA_STATUS_BIT_EDP_ON = (1 << 1), 386 }; 387 388 /** 389 * union dmub_fw_boot_options - Boot option definitions for SCRATCH14 390 */ 391 union dmub_fw_boot_options { 392 struct { 393 uint32_t pemu_env : 1; /**< 1 if PEMU */ 394 uint32_t fpga_env : 1; /**< 1 if FPGA */ 395 uint32_t optimized_init : 1; /**< 1 if optimized init */ 396 uint32_t skip_phy_access : 1; /**< 1 if PHY access should be skipped */ 397 uint32_t disable_clk_gate: 1; /**< 1 if clock gating should be disabled */ 398 uint32_t skip_phy_init_panel_sequence: 1; /**< 1 to skip panel init seq */ 399 uint32_t z10_disable: 1; /**< 1 to disable z10 */ 400 uint32_t enable_dpia: 1; /**< 1 if DPIA should be enabled */ 401 uint32_t invalid_vbios_data: 1; /**< 1 if VBIOS data table is invalid */ 402 uint32_t dpia_supported: 1; /**< 1 if DPIA is supported on this platform */ 403 uint32_t sel_mux_phy_c_d_phy_f_g: 1; /**< 1 if PHYF/PHYG should be enabled */ 404 /**< 1 if all root clock gating is enabled and low power memory is enabled*/ 405 uint32_t power_optimization: 1; 406 uint32_t diag_env: 1; /* 1 if diagnostic environment */ 407 uint32_t gpint_scratch8: 1; /* 1 if GPINT is in scratch8*/ 408 uint32_t usb4_cm_version: 1; /**< 1 CM support */ 409 uint32_t dpia_hpd_int_enable_supported: 1; /* 1 if dpia hpd int enable supported */ 410 uint32_t usb4_dpia_bw_alloc_supported: 1; /* 1 if USB4 dpia BW allocation supported */ 411 412 uint32_t reserved : 15; /**< reserved */ 413 } bits; /**< boot bits */ 414 uint32_t all; /**< 32-bit access to bits */ 415 }; 416 417 enum dmub_fw_boot_options_bit { 418 DMUB_FW_BOOT_OPTION_BIT_PEMU_ENV = (1 << 0), /**< 1 if PEMU */ 419 DMUB_FW_BOOT_OPTION_BIT_FPGA_ENV = (1 << 1), /**< 1 if FPGA */ 420 DMUB_FW_BOOT_OPTION_BIT_OPTIMIZED_INIT_DONE = (1 << 2), /**< 1 if optimized init done */ 421 }; 422 423 //============================================================================== 424 //</DMUB_STATUS>================================================================ 425 //============================================================================== 426 //< DMUB_VBIOS>================================================================= 427 //============================================================================== 428 429 /* 430 * enum dmub_cmd_vbios_type - VBIOS commands. 431 * 432 * Command IDs should be treated as stable ABI. 433 * Do not reuse or modify IDs. 434 */ 435 enum dmub_cmd_vbios_type { 436 /** 437 * Configures the DIG encoder. 438 */ 439 DMUB_CMD__VBIOS_DIGX_ENCODER_CONTROL = 0, 440 /** 441 * Controls the PHY. 442 */ 443 DMUB_CMD__VBIOS_DIG1_TRANSMITTER_CONTROL = 1, 444 /** 445 * Sets the pixel clock/symbol clock. 446 */ 447 DMUB_CMD__VBIOS_SET_PIXEL_CLOCK = 2, 448 /** 449 * Enables or disables power gating. 450 */ 451 DMUB_CMD__VBIOS_ENABLE_DISP_POWER_GATING = 3, 452 /** 453 * Controls embedded panels. 454 */ 455 DMUB_CMD__VBIOS_LVTMA_CONTROL = 15, 456 /** 457 * Query DP alt status on a transmitter. 458 */ 459 DMUB_CMD__VBIOS_TRANSMITTER_QUERY_DP_ALT = 26, 460 }; 461 462 //============================================================================== 463 //</DMUB_VBIOS>================================================================= 464 //============================================================================== 465 //< DMUB_GPINT>================================================================= 466 //============================================================================== 467 468 /** 469 * The shifts and masks below may alternatively be used to format and read 470 * the command register bits. 471 */ 472 473 #define DMUB_GPINT_DATA_PARAM_MASK 0xFFFF 474 #define DMUB_GPINT_DATA_PARAM_SHIFT 0 475 476 #define DMUB_GPINT_DATA_COMMAND_CODE_MASK 0xFFF 477 #define DMUB_GPINT_DATA_COMMAND_CODE_SHIFT 16 478 479 #define DMUB_GPINT_DATA_STATUS_MASK 0xF 480 #define DMUB_GPINT_DATA_STATUS_SHIFT 28 481 482 /** 483 * Command responses. 484 */ 485 486 /** 487 * Return response for DMUB_GPINT__STOP_FW command. 488 */ 489 #define DMUB_GPINT__STOP_FW_RESPONSE 0xDEADDEAD 490 491 /** 492 * union dmub_gpint_data_register - Format for sending a command via the GPINT. 493 */ 494 union dmub_gpint_data_register { 495 struct { 496 uint32_t param : 16; /**< 16-bit parameter */ 497 uint32_t command_code : 12; /**< GPINT command */ 498 uint32_t status : 4; /**< Command status bit */ 499 } bits; /**< GPINT bit access */ 500 uint32_t all; /**< GPINT 32-bit access */ 501 }; 502 503 /* 504 * enum dmub_gpint_command - GPINT command to DMCUB FW 505 * 506 * Command IDs should be treated as stable ABI. 507 * Do not reuse or modify IDs. 508 */ 509 enum dmub_gpint_command { 510 /** 511 * Invalid command, ignored. 512 */ 513 DMUB_GPINT__INVALID_COMMAND = 0, 514 /** 515 * DESC: Queries the firmware version. 516 * RETURN: Firmware version. 517 */ 518 DMUB_GPINT__GET_FW_VERSION = 1, 519 /** 520 * DESC: Halts the firmware. 521 * RETURN: DMUB_GPINT__STOP_FW_RESPONSE (0xDEADDEAD) when halted 522 */ 523 DMUB_GPINT__STOP_FW = 2, 524 /** 525 * DESC: Get PSR state from FW. 526 * RETURN: PSR state enum. This enum may need to be converted to the legacy PSR state value. 527 */ 528 DMUB_GPINT__GET_PSR_STATE = 7, 529 /** 530 * DESC: Notifies DMCUB of the currently active streams. 531 * ARGS: Stream mask, 1 bit per active stream index. 532 */ 533 DMUB_GPINT__IDLE_OPT_NOTIFY_STREAM_MASK = 8, 534 /** 535 * DESC: Start PSR residency counter. Stop PSR resdiency counter and get value. 536 * ARGS: We can measure residency from various points. The argument will specify the residency mode. 537 * By default, it is measured from after we powerdown the PHY, to just before we powerup the PHY. 538 * RETURN: PSR residency in milli-percent. 539 */ 540 DMUB_GPINT__PSR_RESIDENCY = 9, 541 542 /** 543 * DESC: Notifies DMCUB detection is done so detection required can be cleared. 544 */ 545 DMUB_GPINT__NOTIFY_DETECTION_DONE = 12, 546 }; 547 548 /** 549 * INBOX0 generic command definition 550 */ 551 union dmub_inbox0_cmd_common { 552 struct { 553 uint32_t command_code: 8; /**< INBOX0 command code */ 554 uint32_t param: 24; /**< 24-bit parameter */ 555 } bits; 556 uint32_t all; 557 }; 558 559 /** 560 * INBOX0 hw_lock command definition 561 */ 562 union dmub_inbox0_cmd_lock_hw { 563 struct { 564 uint32_t command_code: 8; 565 566 /* NOTE: Must be have enough bits to match: enum hw_lock_client */ 567 uint32_t hw_lock_client: 2; 568 569 /* NOTE: Below fields must match with: struct dmub_hw_lock_inst_flags */ 570 uint32_t otg_inst: 3; 571 uint32_t opp_inst: 3; 572 uint32_t dig_inst: 3; 573 574 /* NOTE: Below fields must match with: union dmub_hw_lock_flags */ 575 uint32_t lock_pipe: 1; 576 uint32_t lock_cursor: 1; 577 uint32_t lock_dig: 1; 578 uint32_t triple_buffer_lock: 1; 579 580 uint32_t lock: 1; /**< Lock */ 581 uint32_t should_release: 1; /**< Release */ 582 uint32_t reserved: 7; /**< Reserved for extending more clients, HW, etc. */ 583 } bits; 584 uint32_t all; 585 }; 586 587 union dmub_inbox0_data_register { 588 union dmub_inbox0_cmd_common inbox0_cmd_common; 589 union dmub_inbox0_cmd_lock_hw inbox0_cmd_lock_hw; 590 }; 591 592 enum dmub_inbox0_command { 593 /** 594 * DESC: Invalid command, ignored. 595 */ 596 DMUB_INBOX0_CMD__INVALID_COMMAND = 0, 597 /** 598 * DESC: Notification to acquire/release HW lock 599 * ARGS: 600 */ 601 DMUB_INBOX0_CMD__HW_LOCK = 1, 602 }; 603 //============================================================================== 604 //</DMUB_GPINT>================================================================= 605 //============================================================================== 606 //< DMUB_CMD>=================================================================== 607 //============================================================================== 608 609 /** 610 * Size in bytes of each DMUB command. 611 */ 612 #define DMUB_RB_CMD_SIZE 64 613 614 /** 615 * Maximum number of items in the DMUB ringbuffer. 616 */ 617 #define DMUB_RB_MAX_ENTRY 128 618 619 /** 620 * Ringbuffer size in bytes. 621 */ 622 #define DMUB_RB_SIZE (DMUB_RB_CMD_SIZE * DMUB_RB_MAX_ENTRY) 623 624 /** 625 * REG_SET mask for reg offload. 626 */ 627 #define REG_SET_MASK 0xFFFF 628 629 /* 630 * enum dmub_cmd_type - DMUB inbox command. 631 * 632 * Command IDs should be treated as stable ABI. 633 * Do not reuse or modify IDs. 634 */ 635 enum dmub_cmd_type { 636 /** 637 * Invalid command. 638 */ 639 DMUB_CMD__NULL = 0, 640 /** 641 * Read modify write register sequence offload. 642 */ 643 DMUB_CMD__REG_SEQ_READ_MODIFY_WRITE = 1, 644 /** 645 * Field update register sequence offload. 646 */ 647 DMUB_CMD__REG_SEQ_FIELD_UPDATE_SEQ = 2, 648 /** 649 * Burst write sequence offload. 650 */ 651 DMUB_CMD__REG_SEQ_BURST_WRITE = 3, 652 /** 653 * Reg wait sequence offload. 654 */ 655 DMUB_CMD__REG_REG_WAIT = 4, 656 /** 657 * Workaround to avoid HUBP underflow during NV12 playback. 658 */ 659 DMUB_CMD__PLAT_54186_WA = 5, 660 /** 661 * Command type used to query FW feature caps. 662 */ 663 DMUB_CMD__QUERY_FEATURE_CAPS = 6, 664 /** 665 * Command type used to get visual confirm color. 666 */ 667 DMUB_CMD__GET_VISUAL_CONFIRM_COLOR = 8, 668 /** 669 * Command type used for all PSR commands. 670 */ 671 DMUB_CMD__PSR = 64, 672 /** 673 * Command type used for all MALL commands. 674 */ 675 DMUB_CMD__MALL = 65, 676 /** 677 * Command type used for all ABM commands. 678 */ 679 DMUB_CMD__ABM = 66, 680 /** 681 * Command type used to update dirty rects in FW. 682 */ 683 DMUB_CMD__UPDATE_DIRTY_RECT = 67, 684 /** 685 * Command type used to update cursor info in FW. 686 */ 687 DMUB_CMD__UPDATE_CURSOR_INFO = 68, 688 /** 689 * Command type used for HW locking in FW. 690 */ 691 DMUB_CMD__HW_LOCK = 69, 692 /** 693 * Command type used to access DP AUX. 694 */ 695 DMUB_CMD__DP_AUX_ACCESS = 70, 696 /** 697 * Command type used for OUTBOX1 notification enable 698 */ 699 DMUB_CMD__OUTBOX1_ENABLE = 71, 700 701 /** 702 * Command type used for all idle optimization commands. 703 */ 704 DMUB_CMD__IDLE_OPT = 72, 705 /** 706 * Command type used for all clock manager commands. 707 */ 708 DMUB_CMD__CLK_MGR = 73, 709 /** 710 * Command type used for all panel control commands. 711 */ 712 DMUB_CMD__PANEL_CNTL = 74, 713 /** 714 * Command type used for <TODO:description> 715 */ 716 DMUB_CMD__CAB_FOR_SS = 75, 717 718 DMUB_CMD__FW_ASSISTED_MCLK_SWITCH = 76, 719 720 /** 721 * Command type used for interfacing with DPIA. 722 */ 723 DMUB_CMD__DPIA = 77, 724 /** 725 * Command type used for EDID CEA parsing 726 */ 727 DMUB_CMD__EDID_CEA = 79, 728 /** 729 * Command type used for getting usbc cable ID 730 */ 731 DMUB_CMD_GET_USBC_CABLE_ID = 81, 732 /** 733 * Command type used to query HPD state. 734 */ 735 DMUB_CMD__QUERY_HPD_STATE = 82, 736 /** 737 * Command type used for all VBIOS interface commands. 738 */ 739 740 /** 741 * Command type used for all SECURE_DISPLAY commands. 742 */ 743 DMUB_CMD__SECURE_DISPLAY = 85, 744 745 /** 746 * Command type used to set DPIA HPD interrupt state 747 */ 748 DMUB_CMD__DPIA_HPD_INT_ENABLE = 86, 749 750 DMUB_CMD__VBIOS = 128, 751 }; 752 753 /** 754 * enum dmub_out_cmd_type - DMUB outbox commands. 755 */ 756 enum dmub_out_cmd_type { 757 /** 758 * Invalid outbox command, ignored. 759 */ 760 DMUB_OUT_CMD__NULL = 0, 761 /** 762 * Command type used for DP AUX Reply data notification 763 */ 764 DMUB_OUT_CMD__DP_AUX_REPLY = 1, 765 /** 766 * Command type used for DP HPD event notification 767 */ 768 DMUB_OUT_CMD__DP_HPD_NOTIFY = 2, 769 /** 770 * Command type used for SET_CONFIG Reply notification 771 */ 772 DMUB_OUT_CMD__SET_CONFIG_REPLY = 3, 773 /** 774 * Command type used for USB4 DPIA notification 775 */ 776 DMUB_OUT_CMD__DPIA_NOTIFICATION = 5, 777 }; 778 779 /* DMUB_CMD__DPIA command sub-types. */ 780 enum dmub_cmd_dpia_type { 781 DMUB_CMD__DPIA_DIG1_DPIA_CONTROL = 0, 782 DMUB_CMD__DPIA_SET_CONFIG_ACCESS = 1, 783 DMUB_CMD__DPIA_MST_ALLOC_SLOTS = 2, 784 }; 785 786 /* DMUB_OUT_CMD__DPIA_NOTIFICATION command types. */ 787 enum dmub_cmd_dpia_notification_type { 788 DPIA_NOTIFY__BW_ALLOCATION = 0, 789 }; 790 791 #pragma pack(push, 1) 792 793 /** 794 * struct dmub_cmd_header - Common command header fields. 795 */ 796 struct dmub_cmd_header { 797 unsigned int type : 8; /**< command type */ 798 unsigned int sub_type : 8; /**< command sub type */ 799 unsigned int ret_status : 1; /**< 1 if returned data, 0 otherwise */ 800 unsigned int multi_cmd_pending : 1; /**< 1 if multiple commands chained together */ 801 unsigned int reserved0 : 6; /**< reserved bits */ 802 unsigned int payload_bytes : 6; /* payload excluding header - up to 60 bytes */ 803 unsigned int reserved1 : 2; /**< reserved bits */ 804 }; 805 806 /* 807 * struct dmub_cmd_read_modify_write_sequence - Read modify write 808 * 809 * 60 payload bytes can hold up to 5 sets of read modify writes, 810 * each take 3 dwords. 811 * 812 * number of sequences = header.payload_bytes / sizeof(struct dmub_cmd_read_modify_write_sequence) 813 * 814 * modify_mask = 0xffff'ffff means all fields are going to be updated. in this case 815 * command parser will skip the read and we can use modify_mask = 0xffff'ffff as reg write 816 */ 817 struct dmub_cmd_read_modify_write_sequence { 818 uint32_t addr; /**< register address */ 819 uint32_t modify_mask; /**< modify mask */ 820 uint32_t modify_value; /**< modify value */ 821 }; 822 823 /** 824 * Maximum number of ops in read modify write sequence. 825 */ 826 #define DMUB_READ_MODIFY_WRITE_SEQ__MAX 5 827 828 /** 829 * struct dmub_cmd_read_modify_write_sequence - Read modify write command. 830 */ 831 struct dmub_rb_cmd_read_modify_write { 832 struct dmub_cmd_header header; /**< command header */ 833 /** 834 * Read modify write sequence. 835 */ 836 struct dmub_cmd_read_modify_write_sequence seq[DMUB_READ_MODIFY_WRITE_SEQ__MAX]; 837 }; 838 839 /* 840 * Update a register with specified masks and values sequeunce 841 * 842 * 60 payload bytes can hold address + up to 7 sets of mask/value combo, each take 2 dword 843 * 844 * number of field update sequence = (header.payload_bytes - sizeof(addr)) / sizeof(struct read_modify_write_sequence) 845 * 846 * 847 * USE CASE: 848 * 1. auto-increment register where additional read would update pointer and produce wrong result 849 * 2. toggle a bit without read in the middle 850 */ 851 852 struct dmub_cmd_reg_field_update_sequence { 853 uint32_t modify_mask; /**< 0xffff'ffff to skip initial read */ 854 uint32_t modify_value; /**< value to update with */ 855 }; 856 857 /** 858 * Maximum number of ops in field update sequence. 859 */ 860 #define DMUB_REG_FIELD_UPDATE_SEQ__MAX 7 861 862 /** 863 * struct dmub_rb_cmd_reg_field_update_sequence - Field update command. 864 */ 865 struct dmub_rb_cmd_reg_field_update_sequence { 866 struct dmub_cmd_header header; /**< command header */ 867 uint32_t addr; /**< register address */ 868 /** 869 * Field update sequence. 870 */ 871 struct dmub_cmd_reg_field_update_sequence seq[DMUB_REG_FIELD_UPDATE_SEQ__MAX]; 872 }; 873 874 875 /** 876 * Maximum number of burst write values. 877 */ 878 #define DMUB_BURST_WRITE_VALUES__MAX 14 879 880 /* 881 * struct dmub_rb_cmd_burst_write - Burst write 882 * 883 * support use case such as writing out LUTs. 884 * 885 * 60 payload bytes can hold up to 14 values to write to given address 886 * 887 * number of payload = header.payload_bytes / sizeof(struct read_modify_write_sequence) 888 */ 889 struct dmub_rb_cmd_burst_write { 890 struct dmub_cmd_header header; /**< command header */ 891 uint32_t addr; /**< register start address */ 892 /** 893 * Burst write register values. 894 */ 895 uint32_t write_values[DMUB_BURST_WRITE_VALUES__MAX]; 896 }; 897 898 /** 899 * struct dmub_rb_cmd_common - Common command header 900 */ 901 struct dmub_rb_cmd_common { 902 struct dmub_cmd_header header; /**< command header */ 903 /** 904 * Padding to RB_CMD_SIZE 905 */ 906 uint8_t cmd_buffer[DMUB_RB_CMD_SIZE - sizeof(struct dmub_cmd_header)]; 907 }; 908 909 /** 910 * struct dmub_cmd_reg_wait_data - Register wait data 911 */ 912 struct dmub_cmd_reg_wait_data { 913 uint32_t addr; /**< Register address */ 914 uint32_t mask; /**< Mask for register bits */ 915 uint32_t condition_field_value; /**< Value to wait for */ 916 uint32_t time_out_us; /**< Time out for reg wait in microseconds */ 917 }; 918 919 /** 920 * struct dmub_rb_cmd_reg_wait - Register wait command 921 */ 922 struct dmub_rb_cmd_reg_wait { 923 struct dmub_cmd_header header; /**< Command header */ 924 struct dmub_cmd_reg_wait_data reg_wait; /**< Register wait data */ 925 }; 926 927 /** 928 * struct dmub_cmd_PLAT_54186_wa - Underflow workaround 929 * 930 * Reprograms surface parameters to avoid underflow. 931 */ 932 struct dmub_cmd_PLAT_54186_wa { 933 uint32_t DCSURF_SURFACE_CONTROL; /**< reg value */ 934 uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS_HIGH; /**< reg value */ 935 uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS; /**< reg value */ 936 uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS_HIGH_C; /**< reg value */ 937 uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS_C; /**< reg value */ 938 struct { 939 uint8_t hubp_inst : 4; /**< HUBP instance */ 940 uint8_t tmz_surface : 1; /**< TMZ enable or disable */ 941 uint8_t immediate :1; /**< Immediate flip */ 942 uint8_t vmid : 4; /**< VMID */ 943 uint8_t grph_stereo : 1; /**< 1 if stereo */ 944 uint32_t reserved : 21; /**< Reserved */ 945 } flip_params; /**< Pageflip parameters */ 946 uint32_t reserved[9]; /**< Reserved bits */ 947 }; 948 949 /** 950 * struct dmub_rb_cmd_PLAT_54186_wa - Underflow workaround command 951 */ 952 struct dmub_rb_cmd_PLAT_54186_wa { 953 struct dmub_cmd_header header; /**< Command header */ 954 struct dmub_cmd_PLAT_54186_wa flip; /**< Flip data */ 955 }; 956 957 /** 958 * struct dmub_rb_cmd_mall - MALL command data. 959 */ 960 struct dmub_rb_cmd_mall { 961 struct dmub_cmd_header header; /**< Common command header */ 962 union dmub_addr cursor_copy_src; /**< Cursor copy address */ 963 union dmub_addr cursor_copy_dst; /**< Cursor copy destination */ 964 uint32_t tmr_delay; /**< Timer delay */ 965 uint32_t tmr_scale; /**< Timer scale */ 966 uint16_t cursor_width; /**< Cursor width in pixels */ 967 uint16_t cursor_pitch; /**< Cursor pitch in pixels */ 968 uint16_t cursor_height; /**< Cursor height in pixels */ 969 uint8_t cursor_bpp; /**< Cursor bits per pixel */ 970 uint8_t debug_bits; /**< Debug bits */ 971 972 uint8_t reserved1; /**< Reserved bits */ 973 uint8_t reserved2; /**< Reserved bits */ 974 }; 975 976 /** 977 * enum dmub_cmd_cab_type - TODO: 978 */ 979 enum dmub_cmd_cab_type { 980 DMUB_CMD__CAB_NO_IDLE_OPTIMIZATION = 0, 981 DMUB_CMD__CAB_NO_DCN_REQ = 1, 982 DMUB_CMD__CAB_DCN_SS_FIT_IN_CAB = 2, 983 }; 984 985 /** 986 * struct dmub_rb_cmd_cab_for_ss - TODO: 987 */ 988 struct dmub_rb_cmd_cab_for_ss { 989 struct dmub_cmd_header header; 990 uint8_t cab_alloc_ways; /* total number of ways */ 991 uint8_t debug_bits; /* debug bits */ 992 }; 993 994 enum mclk_switch_mode { 995 NONE = 0, 996 FPO = 1, 997 SUBVP = 2, 998 VBLANK = 3, 999 }; 1000 1001 /* Per pipe struct which stores the MCLK switch mode 1002 * data to be sent to DMUB. 1003 * Named "v2" for now -- once FPO and SUBVP are fully merged 1004 * the type name can be updated 1005 */ 1006 struct dmub_cmd_fw_assisted_mclk_switch_pipe_data_v2 { 1007 union { 1008 struct { 1009 uint32_t pix_clk_100hz; 1010 uint16_t main_vblank_start; 1011 uint16_t main_vblank_end; 1012 uint16_t mall_region_lines; 1013 uint16_t prefetch_lines; 1014 uint16_t prefetch_to_mall_start_lines; 1015 uint16_t processing_delay_lines; 1016 uint16_t htotal; // required to calculate line time for multi-display cases 1017 uint16_t vtotal; 1018 uint8_t main_pipe_index; 1019 uint8_t phantom_pipe_index; 1020 /* Since the microschedule is calculated in terms of OTG lines, 1021 * include any scaling factors to make sure when we get accurate 1022 * conversion when programming MALL_START_LINE (which is in terms 1023 * of HUBP lines). If 4K is being downscaled to 1080p, scale factor 1024 * is 1/2 (numerator = 1, denominator = 2). 1025 */ 1026 uint8_t scale_factor_numerator; 1027 uint8_t scale_factor_denominator; 1028 uint8_t is_drr; 1029 uint8_t main_split_pipe_index; 1030 uint8_t phantom_split_pipe_index; 1031 } subvp_data; 1032 1033 struct { 1034 uint32_t pix_clk_100hz; 1035 uint16_t vblank_start; 1036 uint16_t vblank_end; 1037 uint16_t vstartup_start; 1038 uint16_t vtotal; 1039 uint16_t htotal; 1040 uint8_t vblank_pipe_index; 1041 uint8_t padding[1]; 1042 struct { 1043 uint8_t drr_in_use; 1044 uint8_t drr_window_size_ms; // Indicates largest VMIN/VMAX adjustment per frame 1045 uint16_t min_vtotal_supported; // Min VTOTAL that supports switching in VBLANK 1046 uint16_t max_vtotal_supported; // Max VTOTAL that can support SubVP static scheduling 1047 uint8_t use_ramping; // Use ramping or not 1048 uint8_t drr_vblank_start_margin; 1049 } drr_info; // DRR considered as part of SubVP + VBLANK case 1050 } vblank_data; 1051 } pipe_config; 1052 1053 /* - subvp_data in the union (pipe_config) takes up 27 bytes. 1054 * - Make the "mode" field a uint8_t instead of enum so we only use 1 byte (only 1055 * for the DMCUB command, cast to enum once we populate the DMCUB subvp state). 1056 */ 1057 uint8_t mode; // enum mclk_switch_mode 1058 }; 1059 1060 /** 1061 * Config data for Sub-VP and FPO 1062 * Named "v2" for now -- once FPO and SUBVP are fully merged 1063 * the type name can be updated 1064 */ 1065 struct dmub_cmd_fw_assisted_mclk_switch_config_v2 { 1066 uint16_t watermark_a_cache; 1067 uint8_t vertical_int_margin_us; 1068 uint8_t pstate_allow_width_us; 1069 struct dmub_cmd_fw_assisted_mclk_switch_pipe_data_v2 pipe_data[DMUB_MAX_SUBVP_STREAMS]; 1070 }; 1071 1072 /** 1073 * DMUB rb command definition for Sub-VP and FPO 1074 * Named "v2" for now -- once FPO and SUBVP are fully merged 1075 * the type name can be updated 1076 */ 1077 struct dmub_rb_cmd_fw_assisted_mclk_switch_v2 { 1078 struct dmub_cmd_header header; 1079 struct dmub_cmd_fw_assisted_mclk_switch_config_v2 config_data; 1080 }; 1081 1082 /** 1083 * enum dmub_cmd_idle_opt_type - Idle optimization command type. 1084 */ 1085 enum dmub_cmd_idle_opt_type { 1086 /** 1087 * DCN hardware restore. 1088 */ 1089 DMUB_CMD__IDLE_OPT_DCN_RESTORE = 0, 1090 1091 /** 1092 * DCN hardware save. 1093 */ 1094 DMUB_CMD__IDLE_OPT_DCN_SAVE_INIT = 1 1095 }; 1096 1097 /** 1098 * struct dmub_rb_cmd_idle_opt_dcn_restore - DCN restore command data. 1099 */ 1100 struct dmub_rb_cmd_idle_opt_dcn_restore { 1101 struct dmub_cmd_header header; /**< header */ 1102 }; 1103 1104 /** 1105 * struct dmub_clocks - Clock update notification. 1106 */ 1107 struct dmub_clocks { 1108 uint32_t dispclk_khz; /**< dispclk kHz */ 1109 uint32_t dppclk_khz; /**< dppclk kHz */ 1110 uint32_t dcfclk_khz; /**< dcfclk kHz */ 1111 uint32_t dcfclk_deep_sleep_khz; /**< dcfclk deep sleep kHz */ 1112 }; 1113 1114 /** 1115 * enum dmub_cmd_clk_mgr_type - Clock manager commands. 1116 */ 1117 enum dmub_cmd_clk_mgr_type { 1118 /** 1119 * Notify DMCUB of clock update. 1120 */ 1121 DMUB_CMD__CLK_MGR_NOTIFY_CLOCKS = 0, 1122 }; 1123 1124 /** 1125 * struct dmub_rb_cmd_clk_mgr_notify_clocks - Clock update notification. 1126 */ 1127 struct dmub_rb_cmd_clk_mgr_notify_clocks { 1128 struct dmub_cmd_header header; /**< header */ 1129 struct dmub_clocks clocks; /**< clock data */ 1130 }; 1131 1132 /** 1133 * struct dmub_cmd_digx_encoder_control_data - Encoder control data. 1134 */ 1135 struct dmub_cmd_digx_encoder_control_data { 1136 union dig_encoder_control_parameters_v1_5 dig; /**< payload */ 1137 }; 1138 1139 /** 1140 * struct dmub_rb_cmd_digx_encoder_control - Encoder control command. 1141 */ 1142 struct dmub_rb_cmd_digx_encoder_control { 1143 struct dmub_cmd_header header; /**< header */ 1144 struct dmub_cmd_digx_encoder_control_data encoder_control; /**< payload */ 1145 }; 1146 1147 /** 1148 * struct dmub_cmd_set_pixel_clock_data - Set pixel clock data. 1149 */ 1150 struct dmub_cmd_set_pixel_clock_data { 1151 struct set_pixel_clock_parameter_v1_7 clk; /**< payload */ 1152 }; 1153 1154 /** 1155 * struct dmub_cmd_set_pixel_clock_data - Set pixel clock command. 1156 */ 1157 struct dmub_rb_cmd_set_pixel_clock { 1158 struct dmub_cmd_header header; /**< header */ 1159 struct dmub_cmd_set_pixel_clock_data pixel_clock; /**< payload */ 1160 }; 1161 1162 /** 1163 * struct dmub_cmd_enable_disp_power_gating_data - Display power gating. 1164 */ 1165 struct dmub_cmd_enable_disp_power_gating_data { 1166 struct enable_disp_power_gating_parameters_v2_1 pwr; /**< payload */ 1167 }; 1168 1169 /** 1170 * struct dmub_rb_cmd_enable_disp_power_gating - Display power command. 1171 */ 1172 struct dmub_rb_cmd_enable_disp_power_gating { 1173 struct dmub_cmd_header header; /**< header */ 1174 struct dmub_cmd_enable_disp_power_gating_data power_gating; /**< payload */ 1175 }; 1176 1177 /** 1178 * struct dmub_dig_transmitter_control_data_v1_7 - Transmitter control. 1179 */ 1180 struct dmub_dig_transmitter_control_data_v1_7 { 1181 uint8_t phyid; /**< 0=UNIPHYA, 1=UNIPHYB, 2=UNIPHYC, 3=UNIPHYD, 4=UNIPHYE, 5=UNIPHYF */ 1182 uint8_t action; /**< Defined as ATOM_TRANSMITER_ACTION_xxx */ 1183 union { 1184 uint8_t digmode; /**< enum atom_encode_mode_def */ 1185 uint8_t dplaneset; /**< DP voltage swing and pre-emphasis value, "DP_LANE_SET__xDB_y_zV" */ 1186 } mode_laneset; 1187 uint8_t lanenum; /**< Number of lanes */ 1188 union { 1189 uint32_t symclk_10khz; /**< Symbol Clock in 10Khz */ 1190 } symclk_units; 1191 uint8_t hpdsel; /**< =1: HPD1, =2: HPD2, ..., =6: HPD6, =0: HPD is not assigned */ 1192 uint8_t digfe_sel; /**< DIG front-end selection, bit0 means DIG0 FE is enabled */ 1193 uint8_t connobj_id; /**< Connector Object Id defined in ObjectId.h */ 1194 uint8_t HPO_instance; /**< HPO instance (0: inst0, 1: inst1) */ 1195 uint8_t reserved1; /**< For future use */ 1196 uint8_t reserved2[3]; /**< For future use */ 1197 uint32_t reserved3[11]; /**< For future use */ 1198 }; 1199 1200 /** 1201 * union dmub_cmd_dig1_transmitter_control_data - Transmitter control data. 1202 */ 1203 union dmub_cmd_dig1_transmitter_control_data { 1204 struct dig_transmitter_control_parameters_v1_6 dig; /**< payload */ 1205 struct dmub_dig_transmitter_control_data_v1_7 dig_v1_7; /**< payload 1.7 */ 1206 }; 1207 1208 /** 1209 * struct dmub_rb_cmd_dig1_transmitter_control - Transmitter control command. 1210 */ 1211 struct dmub_rb_cmd_dig1_transmitter_control { 1212 struct dmub_cmd_header header; /**< header */ 1213 union dmub_cmd_dig1_transmitter_control_data transmitter_control; /**< payload */ 1214 }; 1215 1216 /** 1217 * DPIA tunnel command parameters. 1218 */ 1219 struct dmub_cmd_dig_dpia_control_data { 1220 uint8_t enc_id; /** 0 = ENGINE_ID_DIGA, ... */ 1221 uint8_t action; /** ATOM_TRANSMITER_ACTION_DISABLE/ENABLE/SETUP_VSEMPH */ 1222 union { 1223 uint8_t digmode; /** enum atom_encode_mode_def */ 1224 uint8_t dplaneset; /** DP voltage swing and pre-emphasis value */ 1225 } mode_laneset; 1226 uint8_t lanenum; /** Lane number 1, 2, 4, 8 */ 1227 uint32_t symclk_10khz; /** Symbol Clock in 10Khz */ 1228 uint8_t hpdsel; /** =0: HPD is not assigned */ 1229 uint8_t digfe_sel; /** DIG stream( front-end ) selection, bit0 - DIG0 FE */ 1230 uint8_t dpia_id; /** Index of DPIA */ 1231 uint8_t fec_rdy : 1; 1232 uint8_t reserved : 7; 1233 uint32_t reserved1; 1234 }; 1235 1236 /** 1237 * DMUB command for DPIA tunnel control. 1238 */ 1239 struct dmub_rb_cmd_dig1_dpia_control { 1240 struct dmub_cmd_header header; 1241 struct dmub_cmd_dig_dpia_control_data dpia_control; 1242 }; 1243 1244 /** 1245 * SET_CONFIG Command Payload 1246 */ 1247 struct set_config_cmd_payload { 1248 uint8_t msg_type; /* set config message type */ 1249 uint8_t msg_data; /* set config message data */ 1250 }; 1251 1252 /** 1253 * Data passed from driver to FW in a DMUB_CMD__DPIA_SET_CONFIG_ACCESS command. 1254 */ 1255 struct dmub_cmd_set_config_control_data { 1256 struct set_config_cmd_payload cmd_pkt; 1257 uint8_t instance; /* DPIA instance */ 1258 uint8_t immed_status; /* Immediate status returned in case of error */ 1259 }; 1260 1261 /** 1262 * DMUB command structure for SET_CONFIG command. 1263 */ 1264 struct dmub_rb_cmd_set_config_access { 1265 struct dmub_cmd_header header; /* header */ 1266 struct dmub_cmd_set_config_control_data set_config_control; /* set config data */ 1267 }; 1268 1269 /** 1270 * Data passed from driver to FW in a DMUB_CMD__DPIA_MST_ALLOC_SLOTS command. 1271 */ 1272 struct dmub_cmd_mst_alloc_slots_control_data { 1273 uint8_t mst_alloc_slots; /* mst slots to be allotted */ 1274 uint8_t instance; /* DPIA instance */ 1275 uint8_t immed_status; /* Immediate status returned as there is no outbox msg posted */ 1276 uint8_t mst_slots_in_use; /* returns slots in use for error cases */ 1277 }; 1278 1279 /** 1280 * DMUB command structure for SET_ command. 1281 */ 1282 struct dmub_rb_cmd_set_mst_alloc_slots { 1283 struct dmub_cmd_header header; /* header */ 1284 struct dmub_cmd_mst_alloc_slots_control_data mst_slots_control; /* mst slots control */ 1285 }; 1286 1287 /** 1288 * DMUB command structure for DPIA HPD int enable control. 1289 */ 1290 struct dmub_rb_cmd_dpia_hpd_int_enable { 1291 struct dmub_cmd_header header; /* header */ 1292 uint32_t enable; /* dpia hpd interrupt enable */ 1293 }; 1294 1295 /** 1296 * struct dmub_rb_cmd_dpphy_init - DPPHY init. 1297 */ 1298 struct dmub_rb_cmd_dpphy_init { 1299 struct dmub_cmd_header header; /**< header */ 1300 uint8_t reserved[60]; /**< reserved bits */ 1301 }; 1302 1303 /** 1304 * enum dp_aux_request_action - DP AUX request command listing. 1305 * 1306 * 4 AUX request command bits are shifted to high nibble. 1307 */ 1308 enum dp_aux_request_action { 1309 /** I2C-over-AUX write request */ 1310 DP_AUX_REQ_ACTION_I2C_WRITE = 0x00, 1311 /** I2C-over-AUX read request */ 1312 DP_AUX_REQ_ACTION_I2C_READ = 0x10, 1313 /** I2C-over-AUX write status request */ 1314 DP_AUX_REQ_ACTION_I2C_STATUS_REQ = 0x20, 1315 /** I2C-over-AUX write request with MOT=1 */ 1316 DP_AUX_REQ_ACTION_I2C_WRITE_MOT = 0x40, 1317 /** I2C-over-AUX read request with MOT=1 */ 1318 DP_AUX_REQ_ACTION_I2C_READ_MOT = 0x50, 1319 /** I2C-over-AUX write status request with MOT=1 */ 1320 DP_AUX_REQ_ACTION_I2C_STATUS_REQ_MOT = 0x60, 1321 /** Native AUX write request */ 1322 DP_AUX_REQ_ACTION_DPCD_WRITE = 0x80, 1323 /** Native AUX read request */ 1324 DP_AUX_REQ_ACTION_DPCD_READ = 0x90 1325 }; 1326 1327 /** 1328 * enum aux_return_code_type - DP AUX process return code listing. 1329 */ 1330 enum aux_return_code_type { 1331 /** AUX process succeeded */ 1332 AUX_RET_SUCCESS = 0, 1333 /** AUX process failed with unknown reason */ 1334 AUX_RET_ERROR_UNKNOWN, 1335 /** AUX process completed with invalid reply */ 1336 AUX_RET_ERROR_INVALID_REPLY, 1337 /** AUX process timed out */ 1338 AUX_RET_ERROR_TIMEOUT, 1339 /** HPD was low during AUX process */ 1340 AUX_RET_ERROR_HPD_DISCON, 1341 /** Failed to acquire AUX engine */ 1342 AUX_RET_ERROR_ENGINE_ACQUIRE, 1343 /** AUX request not supported */ 1344 AUX_RET_ERROR_INVALID_OPERATION, 1345 /** AUX process not available */ 1346 AUX_RET_ERROR_PROTOCOL_ERROR, 1347 }; 1348 1349 /** 1350 * enum aux_channel_type - DP AUX channel type listing. 1351 */ 1352 enum aux_channel_type { 1353 /** AUX thru Legacy DP AUX */ 1354 AUX_CHANNEL_LEGACY_DDC, 1355 /** AUX thru DPIA DP tunneling */ 1356 AUX_CHANNEL_DPIA 1357 }; 1358 1359 /** 1360 * struct aux_transaction_parameters - DP AUX request transaction data 1361 */ 1362 struct aux_transaction_parameters { 1363 uint8_t is_i2c_over_aux; /**< 0=native AUX, 1=I2C-over-AUX */ 1364 uint8_t action; /**< enum dp_aux_request_action */ 1365 uint8_t length; /**< DP AUX request data length */ 1366 uint8_t reserved; /**< For future use */ 1367 uint32_t address; /**< DP AUX address */ 1368 uint8_t data[16]; /**< DP AUX write data */ 1369 }; 1370 1371 /** 1372 * Data passed from driver to FW in a DMUB_CMD__DP_AUX_ACCESS command. 1373 */ 1374 struct dmub_cmd_dp_aux_control_data { 1375 uint8_t instance; /**< AUX instance or DPIA instance */ 1376 uint8_t manual_acq_rel_enable; /**< manual control for acquiring or releasing AUX channel */ 1377 uint8_t sw_crc_enabled; /**< Use software CRC for tunneling packet instead of hardware CRC */ 1378 uint8_t reserved0; /**< For future use */ 1379 uint16_t timeout; /**< timeout time in us */ 1380 uint16_t reserved1; /**< For future use */ 1381 enum aux_channel_type type; /**< enum aux_channel_type */ 1382 struct aux_transaction_parameters dpaux; /**< struct aux_transaction_parameters */ 1383 }; 1384 1385 /** 1386 * Definition of a DMUB_CMD__DP_AUX_ACCESS command. 1387 */ 1388 struct dmub_rb_cmd_dp_aux_access { 1389 /** 1390 * Command header. 1391 */ 1392 struct dmub_cmd_header header; 1393 /** 1394 * Data passed from driver to FW in a DMUB_CMD__DP_AUX_ACCESS command. 1395 */ 1396 struct dmub_cmd_dp_aux_control_data aux_control; 1397 }; 1398 1399 /** 1400 * Definition of a DMUB_CMD__OUTBOX1_ENABLE command. 1401 */ 1402 struct dmub_rb_cmd_outbox1_enable { 1403 /** 1404 * Command header. 1405 */ 1406 struct dmub_cmd_header header; 1407 /** 1408 * enable: 0x0 -> disable outbox1 notification (default value) 1409 * 0x1 -> enable outbox1 notification 1410 */ 1411 uint32_t enable; 1412 }; 1413 1414 /* DP AUX Reply command - OutBox Cmd */ 1415 /** 1416 * Data passed to driver from FW in a DMUB_OUT_CMD__DP_AUX_REPLY command. 1417 */ 1418 struct aux_reply_data { 1419 /** 1420 * Aux cmd 1421 */ 1422 uint8_t command; 1423 /** 1424 * Aux reply data length (max: 16 bytes) 1425 */ 1426 uint8_t length; 1427 /** 1428 * Alignment only 1429 */ 1430 uint8_t pad[2]; 1431 /** 1432 * Aux reply data 1433 */ 1434 uint8_t data[16]; 1435 }; 1436 1437 /** 1438 * Control Data passed to driver from FW in a DMUB_OUT_CMD__DP_AUX_REPLY command. 1439 */ 1440 struct aux_reply_control_data { 1441 /** 1442 * Reserved for future use 1443 */ 1444 uint32_t handle; 1445 /** 1446 * Aux Instance 1447 */ 1448 uint8_t instance; 1449 /** 1450 * Aux transaction result: definition in enum aux_return_code_type 1451 */ 1452 uint8_t result; 1453 /** 1454 * Alignment only 1455 */ 1456 uint16_t pad; 1457 }; 1458 1459 /** 1460 * Definition of a DMUB_OUT_CMD__DP_AUX_REPLY command. 1461 */ 1462 struct dmub_rb_cmd_dp_aux_reply { 1463 /** 1464 * Command header. 1465 */ 1466 struct dmub_cmd_header header; 1467 /** 1468 * Control Data passed to driver from FW in a DMUB_OUT_CMD__DP_AUX_REPLY command. 1469 */ 1470 struct aux_reply_control_data control; 1471 /** 1472 * Data passed to driver from FW in a DMUB_OUT_CMD__DP_AUX_REPLY command. 1473 */ 1474 struct aux_reply_data reply_data; 1475 }; 1476 1477 /* DP HPD Notify command - OutBox Cmd */ 1478 /** 1479 * DP HPD Type 1480 */ 1481 enum dp_hpd_type { 1482 /** 1483 * Normal DP HPD 1484 */ 1485 DP_HPD = 0, 1486 /** 1487 * DP HPD short pulse 1488 */ 1489 DP_IRQ 1490 }; 1491 1492 /** 1493 * DP HPD Status 1494 */ 1495 enum dp_hpd_status { 1496 /** 1497 * DP_HPD status low 1498 */ 1499 DP_HPD_UNPLUG = 0, 1500 /** 1501 * DP_HPD status high 1502 */ 1503 DP_HPD_PLUG 1504 }; 1505 1506 /** 1507 * Data passed to driver from FW in a DMUB_OUT_CMD__DP_HPD_NOTIFY command. 1508 */ 1509 struct dp_hpd_data { 1510 /** 1511 * DP HPD instance 1512 */ 1513 uint8_t instance; 1514 /** 1515 * HPD type 1516 */ 1517 uint8_t hpd_type; 1518 /** 1519 * HPD status: only for type: DP_HPD to indicate status 1520 */ 1521 uint8_t hpd_status; 1522 /** 1523 * Alignment only 1524 */ 1525 uint8_t pad; 1526 }; 1527 1528 /** 1529 * Definition of a DMUB_OUT_CMD__DP_HPD_NOTIFY command. 1530 */ 1531 struct dmub_rb_cmd_dp_hpd_notify { 1532 /** 1533 * Command header. 1534 */ 1535 struct dmub_cmd_header header; 1536 /** 1537 * Data passed to driver from FW in a DMUB_OUT_CMD__DP_HPD_NOTIFY command. 1538 */ 1539 struct dp_hpd_data hpd_data; 1540 }; 1541 1542 /** 1543 * Definition of a SET_CONFIG reply from DPOA. 1544 */ 1545 enum set_config_status { 1546 SET_CONFIG_PENDING = 0, 1547 SET_CONFIG_ACK_RECEIVED, 1548 SET_CONFIG_RX_TIMEOUT, 1549 SET_CONFIG_UNKNOWN_ERROR, 1550 }; 1551 1552 /** 1553 * Definition of a set_config reply 1554 */ 1555 struct set_config_reply_control_data { 1556 uint8_t instance; /* DPIA Instance */ 1557 uint8_t status; /* Set Config reply */ 1558 uint16_t pad; /* Alignment */ 1559 }; 1560 1561 /** 1562 * Definition of a DMUB_OUT_CMD__SET_CONFIG_REPLY command. 1563 */ 1564 struct dmub_rb_cmd_dp_set_config_reply { 1565 struct dmub_cmd_header header; 1566 struct set_config_reply_control_data set_config_reply_control; 1567 }; 1568 1569 /** 1570 * Definition of a DPIA notification header 1571 */ 1572 struct dpia_notification_header { 1573 uint8_t instance; /**< DPIA Instance */ 1574 uint8_t reserved[3]; 1575 enum dmub_cmd_dpia_notification_type type; /**< DPIA notification type */ 1576 }; 1577 1578 /** 1579 * Definition of the common data struct of DPIA notification 1580 */ 1581 struct dpia_notification_common { 1582 uint8_t cmd_buffer[DMUB_RB_CMD_SIZE - sizeof(struct dmub_cmd_header) 1583 - sizeof(struct dpia_notification_header)]; 1584 }; 1585 1586 /** 1587 * Definition of a DPIA notification data 1588 */ 1589 struct dpia_bw_allocation_notify_data { 1590 union { 1591 struct { 1592 uint16_t cm_bw_alloc_support: 1; /**< USB4 CM BW Allocation mode support */ 1593 uint16_t bw_request_failed: 1; /**< BW_Request_Failed */ 1594 uint16_t bw_request_succeeded: 1; /**< BW_Request_Succeeded */ 1595 uint16_t est_bw_changed: 1; /**< Estimated_BW changed */ 1596 uint16_t bw_alloc_cap_changed: 1; /**< BW_Allocation_Capabiity_Changed */ 1597 uint16_t reserved: 11; /**< Reserved */ 1598 } bits; 1599 1600 uint16_t flags; 1601 }; 1602 1603 uint8_t cm_id; /**< CM ID */ 1604 uint8_t group_id; /**< Group ID */ 1605 uint8_t granularity; /**< BW Allocation Granularity */ 1606 uint8_t estimated_bw; /**< Estimated_BW */ 1607 uint8_t allocated_bw; /**< Allocated_BW */ 1608 uint8_t reserved; 1609 }; 1610 1611 /** 1612 * union dpia_notify_data_type - DPIA Notification in Outbox command 1613 */ 1614 union dpia_notification_data { 1615 /** 1616 * DPIA Notification for common data struct 1617 */ 1618 struct dpia_notification_common common_data; 1619 1620 /** 1621 * DPIA Notification for DP BW Allocation support 1622 */ 1623 struct dpia_bw_allocation_notify_data dpia_bw_alloc; 1624 }; 1625 1626 /** 1627 * Definition of a DPIA notification payload 1628 */ 1629 struct dpia_notification_payload { 1630 struct dpia_notification_header header; 1631 union dpia_notification_data data; /**< DPIA notification payload data */ 1632 }; 1633 1634 /** 1635 * Definition of a DMUB_OUT_CMD__DPIA_NOTIFICATION command. 1636 */ 1637 struct dmub_rb_cmd_dpia_notification { 1638 struct dmub_cmd_header header; /**< DPIA notification header */ 1639 struct dpia_notification_payload payload; /**< DPIA notification payload */ 1640 }; 1641 1642 /** 1643 * Data passed from driver to FW in a DMUB_CMD__QUERY_HPD_STATE command. 1644 */ 1645 struct dmub_cmd_hpd_state_query_data { 1646 uint8_t instance; /**< HPD instance or DPIA instance */ 1647 uint8_t result; /**< For returning HPD state */ 1648 uint16_t pad; /** < Alignment */ 1649 enum aux_channel_type ch_type; /**< enum aux_channel_type */ 1650 enum aux_return_code_type status; /**< for returning the status of command */ 1651 }; 1652 1653 /** 1654 * Definition of a DMUB_CMD__QUERY_HPD_STATE command. 1655 */ 1656 struct dmub_rb_cmd_query_hpd_state { 1657 /** 1658 * Command header. 1659 */ 1660 struct dmub_cmd_header header; 1661 /** 1662 * Data passed from driver to FW in a DMUB_CMD__QUERY_HPD_STATE command. 1663 */ 1664 struct dmub_cmd_hpd_state_query_data data; 1665 }; 1666 1667 /* 1668 * Command IDs should be treated as stable ABI. 1669 * Do not reuse or modify IDs. 1670 */ 1671 1672 /** 1673 * PSR command sub-types. 1674 */ 1675 enum dmub_cmd_psr_type { 1676 /** 1677 * Set PSR version support. 1678 */ 1679 DMUB_CMD__PSR_SET_VERSION = 0, 1680 /** 1681 * Copy driver-calculated parameters to PSR state. 1682 */ 1683 DMUB_CMD__PSR_COPY_SETTINGS = 1, 1684 /** 1685 * Enable PSR. 1686 */ 1687 DMUB_CMD__PSR_ENABLE = 2, 1688 1689 /** 1690 * Disable PSR. 1691 */ 1692 DMUB_CMD__PSR_DISABLE = 3, 1693 1694 /** 1695 * Set PSR level. 1696 * PSR level is a 16-bit value dicated by driver that 1697 * will enable/disable different functionality. 1698 */ 1699 DMUB_CMD__PSR_SET_LEVEL = 4, 1700 1701 /** 1702 * Forces PSR enabled until an explicit PSR disable call. 1703 */ 1704 DMUB_CMD__PSR_FORCE_STATIC = 5, 1705 /** 1706 * Set vtotal in psr active for FreeSync PSR. 1707 */ 1708 DMUB_CMD__SET_SINK_VTOTAL_IN_PSR_ACTIVE = 6, 1709 /** 1710 * Set PSR power option 1711 */ 1712 DMUB_CMD__SET_PSR_POWER_OPT = 7, 1713 }; 1714 1715 enum dmub_cmd_fams_type { 1716 DMUB_CMD__FAMS_SETUP_FW_CTRL = 0, 1717 DMUB_CMD__FAMS_DRR_UPDATE = 1, 1718 DMUB_CMD__HANDLE_SUBVP_CMD = 2, // specifically for SubVP cmd 1719 /** 1720 * For SubVP set manual trigger in FW because it 1721 * triggers DRR_UPDATE_PENDING which SubVP relies 1722 * on (for any SubVP cases that use a DRR display) 1723 */ 1724 DMUB_CMD__FAMS_SET_MANUAL_TRIGGER = 3, 1725 }; 1726 1727 /** 1728 * PSR versions. 1729 */ 1730 enum psr_version { 1731 /** 1732 * PSR version 1. 1733 */ 1734 PSR_VERSION_1 = 0, 1735 /** 1736 * Freesync PSR SU. 1737 */ 1738 PSR_VERSION_SU_1 = 1, 1739 /** 1740 * PSR not supported. 1741 */ 1742 PSR_VERSION_UNSUPPORTED = 0xFFFFFFFF, 1743 }; 1744 1745 /** 1746 * enum dmub_cmd_mall_type - MALL commands 1747 */ 1748 enum dmub_cmd_mall_type { 1749 /** 1750 * Allows display refresh from MALL. 1751 */ 1752 DMUB_CMD__MALL_ACTION_ALLOW = 0, 1753 /** 1754 * Disallows display refresh from MALL. 1755 */ 1756 DMUB_CMD__MALL_ACTION_DISALLOW = 1, 1757 /** 1758 * Cursor copy for MALL. 1759 */ 1760 DMUB_CMD__MALL_ACTION_COPY_CURSOR = 2, 1761 /** 1762 * Controls DF requests. 1763 */ 1764 DMUB_CMD__MALL_ACTION_NO_DF_REQ = 3, 1765 }; 1766 1767 /** 1768 * PHY Link rate for DP. 1769 */ 1770 enum phy_link_rate { 1771 /** 1772 * not supported. 1773 */ 1774 PHY_RATE_UNKNOWN = 0, 1775 /** 1776 * Rate_1 (RBR) - 1.62 Gbps/Lane 1777 */ 1778 PHY_RATE_162 = 1, 1779 /** 1780 * Rate_2 - 2.16 Gbps/Lane 1781 */ 1782 PHY_RATE_216 = 2, 1783 /** 1784 * Rate_3 - 2.43 Gbps/Lane 1785 */ 1786 PHY_RATE_243 = 3, 1787 /** 1788 * Rate_4 (HBR) - 2.70 Gbps/Lane 1789 */ 1790 PHY_RATE_270 = 4, 1791 /** 1792 * Rate_5 (RBR2)- 3.24 Gbps/Lane 1793 */ 1794 PHY_RATE_324 = 5, 1795 /** 1796 * Rate_6 - 4.32 Gbps/Lane 1797 */ 1798 PHY_RATE_432 = 6, 1799 /** 1800 * Rate_7 (HBR2)- 5.40 Gbps/Lane 1801 */ 1802 PHY_RATE_540 = 7, 1803 /** 1804 * Rate_8 (HBR3)- 8.10 Gbps/Lane 1805 */ 1806 PHY_RATE_810 = 8, 1807 /** 1808 * UHBR10 - 10.0 Gbps/Lane 1809 */ 1810 PHY_RATE_1000 = 9, 1811 /** 1812 * UHBR13.5 - 13.5 Gbps/Lane 1813 */ 1814 PHY_RATE_1350 = 10, 1815 /** 1816 * UHBR10 - 20.0 Gbps/Lane 1817 */ 1818 PHY_RATE_2000 = 11, 1819 }; 1820 1821 /** 1822 * enum dmub_phy_fsm_state - PHY FSM states. 1823 * PHY FSM state to transit to during PSR enable/disable. 1824 */ 1825 enum dmub_phy_fsm_state { 1826 DMUB_PHY_FSM_POWER_UP_DEFAULT = 0, 1827 DMUB_PHY_FSM_RESET, 1828 DMUB_PHY_FSM_RESET_RELEASED, 1829 DMUB_PHY_FSM_SRAM_LOAD_DONE, 1830 DMUB_PHY_FSM_INITIALIZED, 1831 DMUB_PHY_FSM_CALIBRATED, 1832 DMUB_PHY_FSM_CALIBRATED_LP, 1833 DMUB_PHY_FSM_CALIBRATED_PG, 1834 DMUB_PHY_FSM_POWER_DOWN, 1835 DMUB_PHY_FSM_PLL_EN, 1836 DMUB_PHY_FSM_TX_EN, 1837 DMUB_PHY_FSM_FAST_LP, 1838 }; 1839 1840 /** 1841 * Data passed from driver to FW in a DMUB_CMD__PSR_COPY_SETTINGS command. 1842 */ 1843 struct dmub_cmd_psr_copy_settings_data { 1844 /** 1845 * Flags that can be set by driver to change some PSR behaviour. 1846 */ 1847 union dmub_psr_debug_flags debug; 1848 /** 1849 * 16-bit value dicated by driver that will enable/disable different functionality. 1850 */ 1851 uint16_t psr_level; 1852 /** 1853 * DPP HW instance. 1854 */ 1855 uint8_t dpp_inst; 1856 /** 1857 * MPCC HW instance. 1858 * Not used in dmub fw, 1859 * dmub fw will get active opp by reading odm registers. 1860 */ 1861 uint8_t mpcc_inst; 1862 /** 1863 * OPP HW instance. 1864 * Not used in dmub fw, 1865 * dmub fw will get active opp by reading odm registers. 1866 */ 1867 uint8_t opp_inst; 1868 /** 1869 * OTG HW instance. 1870 */ 1871 uint8_t otg_inst; 1872 /** 1873 * DIG FE HW instance. 1874 */ 1875 uint8_t digfe_inst; 1876 /** 1877 * DIG BE HW instance. 1878 */ 1879 uint8_t digbe_inst; 1880 /** 1881 * DP PHY HW instance. 1882 */ 1883 uint8_t dpphy_inst; 1884 /** 1885 * AUX HW instance. 1886 */ 1887 uint8_t aux_inst; 1888 /** 1889 * Determines if SMU optimzations are enabled/disabled. 1890 */ 1891 uint8_t smu_optimizations_en; 1892 /** 1893 * Unused. 1894 * TODO: Remove. 1895 */ 1896 uint8_t frame_delay; 1897 /** 1898 * If RFB setup time is greater than the total VBLANK time, 1899 * it is not possible for the sink to capture the video frame 1900 * in the same frame the SDP is sent. In this case, 1901 * the frame capture indication bit should be set and an extra 1902 * static frame should be transmitted to the sink. 1903 */ 1904 uint8_t frame_cap_ind; 1905 /** 1906 * Granularity of Y offset supported by sink. 1907 */ 1908 uint8_t su_y_granularity; 1909 /** 1910 * Indicates whether sink should start capturing 1911 * immediately following active scan line, 1912 * or starting with the 2nd active scan line. 1913 */ 1914 uint8_t line_capture_indication; 1915 /** 1916 * Multi-display optimizations are implemented on certain ASICs. 1917 */ 1918 uint8_t multi_disp_optimizations_en; 1919 /** 1920 * The last possible line SDP may be transmitted without violating 1921 * the RFB setup time or entering the active video frame. 1922 */ 1923 uint16_t init_sdp_deadline; 1924 /** 1925 * @ rate_control_caps : Indicate FreeSync PSR Sink Capabilities 1926 */ 1927 uint8_t rate_control_caps ; 1928 /* 1929 * Force PSRSU always doing full frame update 1930 */ 1931 uint8_t force_ffu_mode; 1932 /** 1933 * Length of each horizontal line in us. 1934 */ 1935 uint32_t line_time_in_us; 1936 /** 1937 * FEC enable status in driver 1938 */ 1939 uint8_t fec_enable_status; 1940 /** 1941 * FEC re-enable delay when PSR exit. 1942 * unit is 100us, range form 0~255(0xFF). 1943 */ 1944 uint8_t fec_enable_delay_in100us; 1945 /** 1946 * PSR control version. 1947 */ 1948 uint8_t cmd_version; 1949 /** 1950 * Panel Instance. 1951 * Panel isntance to identify which psr_state to use 1952 * Currently the support is only for 0 or 1 1953 */ 1954 uint8_t panel_inst; 1955 /* 1956 * DSC enable status in driver 1957 */ 1958 uint8_t dsc_enable_status; 1959 /* 1960 * Use FSM state for PSR power up/down 1961 */ 1962 uint8_t use_phy_fsm; 1963 /** 1964 * frame delay for frame re-lock 1965 */ 1966 uint8_t relock_delay_frame_cnt; 1967 /** 1968 * Explicit padding to 2 byte boundary. 1969 */ 1970 uint8_t pad3; 1971 }; 1972 1973 /** 1974 * Definition of a DMUB_CMD__PSR_COPY_SETTINGS command. 1975 */ 1976 struct dmub_rb_cmd_psr_copy_settings { 1977 /** 1978 * Command header. 1979 */ 1980 struct dmub_cmd_header header; 1981 /** 1982 * Data passed from driver to FW in a DMUB_CMD__PSR_COPY_SETTINGS command. 1983 */ 1984 struct dmub_cmd_psr_copy_settings_data psr_copy_settings_data; 1985 }; 1986 1987 /** 1988 * Data passed from driver to FW in a DMUB_CMD__PSR_SET_LEVEL command. 1989 */ 1990 struct dmub_cmd_psr_set_level_data { 1991 /** 1992 * 16-bit value dicated by driver that will enable/disable different functionality. 1993 */ 1994 uint16_t psr_level; 1995 /** 1996 * PSR control version. 1997 */ 1998 uint8_t cmd_version; 1999 /** 2000 * Panel Instance. 2001 * Panel isntance to identify which psr_state to use 2002 * Currently the support is only for 0 or 1 2003 */ 2004 uint8_t panel_inst; 2005 }; 2006 2007 /** 2008 * Definition of a DMUB_CMD__PSR_SET_LEVEL command. 2009 */ 2010 struct dmub_rb_cmd_psr_set_level { 2011 /** 2012 * Command header. 2013 */ 2014 struct dmub_cmd_header header; 2015 /** 2016 * Definition of a DMUB_CMD__PSR_SET_LEVEL command. 2017 */ 2018 struct dmub_cmd_psr_set_level_data psr_set_level_data; 2019 }; 2020 2021 struct dmub_rb_cmd_psr_enable_data { 2022 /** 2023 * PSR control version. 2024 */ 2025 uint8_t cmd_version; 2026 /** 2027 * Panel Instance. 2028 * Panel isntance to identify which psr_state to use 2029 * Currently the support is only for 0 or 1 2030 */ 2031 uint8_t panel_inst; 2032 /** 2033 * Phy state to enter. 2034 * Values to use are defined in dmub_phy_fsm_state 2035 */ 2036 uint8_t phy_fsm_state; 2037 /** 2038 * Phy rate for DP - RBR/HBR/HBR2/HBR3. 2039 * Set this using enum phy_link_rate. 2040 * This does not support HDMI/DP2 for now. 2041 */ 2042 uint8_t phy_rate; 2043 }; 2044 2045 /** 2046 * Definition of a DMUB_CMD__PSR_ENABLE command. 2047 * PSR enable/disable is controlled using the sub_type. 2048 */ 2049 struct dmub_rb_cmd_psr_enable { 2050 /** 2051 * Command header. 2052 */ 2053 struct dmub_cmd_header header; 2054 2055 struct dmub_rb_cmd_psr_enable_data data; 2056 }; 2057 2058 /** 2059 * Data passed from driver to FW in a DMUB_CMD__PSR_SET_VERSION command. 2060 */ 2061 struct dmub_cmd_psr_set_version_data { 2062 /** 2063 * PSR version that FW should implement. 2064 */ 2065 enum psr_version version; 2066 /** 2067 * PSR control version. 2068 */ 2069 uint8_t cmd_version; 2070 /** 2071 * Panel Instance. 2072 * Panel isntance to identify which psr_state to use 2073 * Currently the support is only for 0 or 1 2074 */ 2075 uint8_t panel_inst; 2076 /** 2077 * Explicit padding to 4 byte boundary. 2078 */ 2079 uint8_t pad[2]; 2080 }; 2081 2082 /** 2083 * Definition of a DMUB_CMD__PSR_SET_VERSION command. 2084 */ 2085 struct dmub_rb_cmd_psr_set_version { 2086 /** 2087 * Command header. 2088 */ 2089 struct dmub_cmd_header header; 2090 /** 2091 * Data passed from driver to FW in a DMUB_CMD__PSR_SET_VERSION command. 2092 */ 2093 struct dmub_cmd_psr_set_version_data psr_set_version_data; 2094 }; 2095 2096 struct dmub_cmd_psr_force_static_data { 2097 /** 2098 * PSR control version. 2099 */ 2100 uint8_t cmd_version; 2101 /** 2102 * Panel Instance. 2103 * Panel isntance to identify which psr_state to use 2104 * Currently the support is only for 0 or 1 2105 */ 2106 uint8_t panel_inst; 2107 /** 2108 * Explicit padding to 4 byte boundary. 2109 */ 2110 uint8_t pad[2]; 2111 }; 2112 2113 /** 2114 * Definition of a DMUB_CMD__PSR_FORCE_STATIC command. 2115 */ 2116 struct dmub_rb_cmd_psr_force_static { 2117 /** 2118 * Command header. 2119 */ 2120 struct dmub_cmd_header header; 2121 /** 2122 * Data passed from driver to FW in a DMUB_CMD__PSR_FORCE_STATIC command. 2123 */ 2124 struct dmub_cmd_psr_force_static_data psr_force_static_data; 2125 }; 2126 2127 /** 2128 * PSR SU debug flags. 2129 */ 2130 union dmub_psr_su_debug_flags { 2131 /** 2132 * PSR SU debug flags. 2133 */ 2134 struct { 2135 /** 2136 * Update dirty rect in SW only. 2137 */ 2138 uint8_t update_dirty_rect_only : 1; 2139 /** 2140 * Reset the cursor/plane state before processing the call. 2141 */ 2142 uint8_t reset_state : 1; 2143 } bitfields; 2144 2145 /** 2146 * Union for debug flags. 2147 */ 2148 uint32_t u32All; 2149 }; 2150 2151 /** 2152 * Data passed from driver to FW in a DMUB_CMD__UPDATE_DIRTY_RECT command. 2153 * This triggers a selective update for PSR SU. 2154 */ 2155 struct dmub_cmd_update_dirty_rect_data { 2156 /** 2157 * Dirty rects from OS. 2158 */ 2159 struct dmub_rect src_dirty_rects[DMUB_MAX_DIRTY_RECTS]; 2160 /** 2161 * PSR SU debug flags. 2162 */ 2163 union dmub_psr_su_debug_flags debug_flags; 2164 /** 2165 * OTG HW instance. 2166 */ 2167 uint8_t pipe_idx; 2168 /** 2169 * Number of dirty rects. 2170 */ 2171 uint8_t dirty_rect_count; 2172 /** 2173 * PSR control version. 2174 */ 2175 uint8_t cmd_version; 2176 /** 2177 * Panel Instance. 2178 * Panel isntance to identify which psr_state to use 2179 * Currently the support is only for 0 or 1 2180 */ 2181 uint8_t panel_inst; 2182 }; 2183 2184 /** 2185 * Definition of a DMUB_CMD__UPDATE_DIRTY_RECT command. 2186 */ 2187 struct dmub_rb_cmd_update_dirty_rect { 2188 /** 2189 * Command header. 2190 */ 2191 struct dmub_cmd_header header; 2192 /** 2193 * Data passed from driver to FW in a DMUB_CMD__UPDATE_DIRTY_RECT command. 2194 */ 2195 struct dmub_cmd_update_dirty_rect_data update_dirty_rect_data; 2196 }; 2197 2198 /** 2199 * Data passed from driver to FW in a DMUB_CMD__UPDATE_CURSOR_INFO command. 2200 */ 2201 union dmub_reg_cursor_control_cfg { 2202 struct { 2203 uint32_t cur_enable: 1; 2204 uint32_t reser0: 3; 2205 uint32_t cur_2x_magnify: 1; 2206 uint32_t reser1: 3; 2207 uint32_t mode: 3; 2208 uint32_t reser2: 5; 2209 uint32_t pitch: 2; 2210 uint32_t reser3: 6; 2211 uint32_t line_per_chunk: 5; 2212 uint32_t reser4: 3; 2213 } bits; 2214 uint32_t raw; 2215 }; 2216 struct dmub_cursor_position_cache_hubp { 2217 union dmub_reg_cursor_control_cfg cur_ctl; 2218 union dmub_reg_position_cfg { 2219 struct { 2220 uint32_t cur_x_pos: 16; 2221 uint32_t cur_y_pos: 16; 2222 } bits; 2223 uint32_t raw; 2224 } position; 2225 union dmub_reg_hot_spot_cfg { 2226 struct { 2227 uint32_t hot_x: 16; 2228 uint32_t hot_y: 16; 2229 } bits; 2230 uint32_t raw; 2231 } hot_spot; 2232 union dmub_reg_dst_offset_cfg { 2233 struct { 2234 uint32_t dst_x_offset: 13; 2235 uint32_t reserved: 19; 2236 } bits; 2237 uint32_t raw; 2238 } dst_offset; 2239 }; 2240 2241 union dmub_reg_cur0_control_cfg { 2242 struct { 2243 uint32_t cur0_enable: 1; 2244 uint32_t expansion_mode: 1; 2245 uint32_t reser0: 1; 2246 uint32_t cur0_rom_en: 1; 2247 uint32_t mode: 3; 2248 uint32_t reserved: 25; 2249 } bits; 2250 uint32_t raw; 2251 }; 2252 struct dmub_cursor_position_cache_dpp { 2253 union dmub_reg_cur0_control_cfg cur0_ctl; 2254 }; 2255 struct dmub_cursor_position_cfg { 2256 struct dmub_cursor_position_cache_hubp pHubp; 2257 struct dmub_cursor_position_cache_dpp pDpp; 2258 uint8_t pipe_idx; 2259 /* 2260 * Padding is required. To be 4 Bytes Aligned. 2261 */ 2262 uint8_t padding[3]; 2263 }; 2264 2265 struct dmub_cursor_attribute_cache_hubp { 2266 uint32_t SURFACE_ADDR_HIGH; 2267 uint32_t SURFACE_ADDR; 2268 union dmub_reg_cursor_control_cfg cur_ctl; 2269 union dmub_reg_cursor_size_cfg { 2270 struct { 2271 uint32_t width: 16; 2272 uint32_t height: 16; 2273 } bits; 2274 uint32_t raw; 2275 } size; 2276 union dmub_reg_cursor_settings_cfg { 2277 struct { 2278 uint32_t dst_y_offset: 8; 2279 uint32_t chunk_hdl_adjust: 2; 2280 uint32_t reserved: 22; 2281 } bits; 2282 uint32_t raw; 2283 } settings; 2284 }; 2285 struct dmub_cursor_attribute_cache_dpp { 2286 union dmub_reg_cur0_control_cfg cur0_ctl; 2287 }; 2288 struct dmub_cursor_attributes_cfg { 2289 struct dmub_cursor_attribute_cache_hubp aHubp; 2290 struct dmub_cursor_attribute_cache_dpp aDpp; 2291 }; 2292 2293 struct dmub_cmd_update_cursor_payload0 { 2294 /** 2295 * Cursor dirty rects. 2296 */ 2297 struct dmub_rect cursor_rect; 2298 /** 2299 * PSR SU debug flags. 2300 */ 2301 union dmub_psr_su_debug_flags debug_flags; 2302 /** 2303 * Cursor enable/disable. 2304 */ 2305 uint8_t enable; 2306 /** 2307 * OTG HW instance. 2308 */ 2309 uint8_t pipe_idx; 2310 /** 2311 * PSR control version. 2312 */ 2313 uint8_t cmd_version; 2314 /** 2315 * Panel Instance. 2316 * Panel isntance to identify which psr_state to use 2317 * Currently the support is only for 0 or 1 2318 */ 2319 uint8_t panel_inst; 2320 /** 2321 * Cursor Position Register. 2322 * Registers contains Hubp & Dpp modules 2323 */ 2324 struct dmub_cursor_position_cfg position_cfg; 2325 }; 2326 2327 struct dmub_cmd_update_cursor_payload1 { 2328 struct dmub_cursor_attributes_cfg attribute_cfg; 2329 }; 2330 2331 union dmub_cmd_update_cursor_info_data { 2332 struct dmub_cmd_update_cursor_payload0 payload0; 2333 struct dmub_cmd_update_cursor_payload1 payload1; 2334 }; 2335 /** 2336 * Definition of a DMUB_CMD__UPDATE_CURSOR_INFO command. 2337 */ 2338 struct dmub_rb_cmd_update_cursor_info { 2339 /** 2340 * Command header. 2341 */ 2342 struct dmub_cmd_header header; 2343 /** 2344 * Data passed from driver to FW in a DMUB_CMD__UPDATE_CURSOR_INFO command. 2345 */ 2346 union dmub_cmd_update_cursor_info_data update_cursor_info_data; 2347 }; 2348 2349 /** 2350 * Data passed from driver to FW in a DMUB_CMD__SET_SINK_VTOTAL_IN_PSR_ACTIVE command. 2351 */ 2352 struct dmub_cmd_psr_set_vtotal_data { 2353 /** 2354 * 16-bit value dicated by driver that indicates the vtotal in PSR active requirement when screen idle.. 2355 */ 2356 uint16_t psr_vtotal_idle; 2357 /** 2358 * PSR control version. 2359 */ 2360 uint8_t cmd_version; 2361 /** 2362 * Panel Instance. 2363 * Panel isntance to identify which psr_state to use 2364 * Currently the support is only for 0 or 1 2365 */ 2366 uint8_t panel_inst; 2367 /* 2368 * 16-bit value dicated by driver that indicates the vtotal in PSR active requirement when doing SU/FFU. 2369 */ 2370 uint16_t psr_vtotal_su; 2371 /** 2372 * Explicit padding to 4 byte boundary. 2373 */ 2374 uint8_t pad2[2]; 2375 }; 2376 2377 /** 2378 * Definition of a DMUB_CMD__SET_SINK_VTOTAL_IN_PSR_ACTIVE command. 2379 */ 2380 struct dmub_rb_cmd_psr_set_vtotal { 2381 /** 2382 * Command header. 2383 */ 2384 struct dmub_cmd_header header; 2385 /** 2386 * Definition of a DMUB_CMD__SET_SINK_VTOTAL_IN_PSR_ACTIVE command. 2387 */ 2388 struct dmub_cmd_psr_set_vtotal_data psr_set_vtotal_data; 2389 }; 2390 2391 /** 2392 * Data passed from driver to FW in a DMUB_CMD__SET_PSR_POWER_OPT command. 2393 */ 2394 struct dmub_cmd_psr_set_power_opt_data { 2395 /** 2396 * PSR control version. 2397 */ 2398 uint8_t cmd_version; 2399 /** 2400 * Panel Instance. 2401 * Panel isntance to identify which psr_state to use 2402 * Currently the support is only for 0 or 1 2403 */ 2404 uint8_t panel_inst; 2405 /** 2406 * Explicit padding to 4 byte boundary. 2407 */ 2408 uint8_t pad[2]; 2409 /** 2410 * PSR power option 2411 */ 2412 uint32_t power_opt; 2413 }; 2414 2415 /** 2416 * Definition of a DMUB_CMD__SET_PSR_POWER_OPT command. 2417 */ 2418 struct dmub_rb_cmd_psr_set_power_opt { 2419 /** 2420 * Command header. 2421 */ 2422 struct dmub_cmd_header header; 2423 /** 2424 * Definition of a DMUB_CMD__SET_PSR_POWER_OPT command. 2425 */ 2426 struct dmub_cmd_psr_set_power_opt_data psr_set_power_opt_data; 2427 }; 2428 2429 /** 2430 * Set of HW components that can be locked. 2431 * 2432 * Note: If updating with more HW components, fields 2433 * in dmub_inbox0_cmd_lock_hw must be updated to match. 2434 */ 2435 union dmub_hw_lock_flags { 2436 /** 2437 * Set of HW components that can be locked. 2438 */ 2439 struct { 2440 /** 2441 * Lock/unlock OTG master update lock. 2442 */ 2443 uint8_t lock_pipe : 1; 2444 /** 2445 * Lock/unlock cursor. 2446 */ 2447 uint8_t lock_cursor : 1; 2448 /** 2449 * Lock/unlock global update lock. 2450 */ 2451 uint8_t lock_dig : 1; 2452 /** 2453 * Triple buffer lock requires additional hw programming to usual OTG master lock. 2454 */ 2455 uint8_t triple_buffer_lock : 1; 2456 } bits; 2457 2458 /** 2459 * Union for HW Lock flags. 2460 */ 2461 uint8_t u8All; 2462 }; 2463 2464 /** 2465 * Instances of HW to be locked. 2466 * 2467 * Note: If updating with more HW components, fields 2468 * in dmub_inbox0_cmd_lock_hw must be updated to match. 2469 */ 2470 struct dmub_hw_lock_inst_flags { 2471 /** 2472 * OTG HW instance for OTG master update lock. 2473 */ 2474 uint8_t otg_inst; 2475 /** 2476 * OPP instance for cursor lock. 2477 */ 2478 uint8_t opp_inst; 2479 /** 2480 * OTG HW instance for global update lock. 2481 * TODO: Remove, and re-use otg_inst. 2482 */ 2483 uint8_t dig_inst; 2484 /** 2485 * Explicit pad to 4 byte boundary. 2486 */ 2487 uint8_t pad; 2488 }; 2489 2490 /** 2491 * Clients that can acquire the HW Lock Manager. 2492 * 2493 * Note: If updating with more clients, fields in 2494 * dmub_inbox0_cmd_lock_hw must be updated to match. 2495 */ 2496 enum hw_lock_client { 2497 /** 2498 * Driver is the client of HW Lock Manager. 2499 */ 2500 HW_LOCK_CLIENT_DRIVER = 0, 2501 /** 2502 * PSR SU is the client of HW Lock Manager. 2503 */ 2504 HW_LOCK_CLIENT_PSR_SU = 1, 2505 /** 2506 * Invalid client. 2507 */ 2508 HW_LOCK_CLIENT_INVALID = 0xFFFFFFFF, 2509 }; 2510 2511 /** 2512 * Data passed to HW Lock Mgr in a DMUB_CMD__HW_LOCK command. 2513 */ 2514 struct dmub_cmd_lock_hw_data { 2515 /** 2516 * Specifies the client accessing HW Lock Manager. 2517 */ 2518 enum hw_lock_client client; 2519 /** 2520 * HW instances to be locked. 2521 */ 2522 struct dmub_hw_lock_inst_flags inst_flags; 2523 /** 2524 * Which components to be locked. 2525 */ 2526 union dmub_hw_lock_flags hw_locks; 2527 /** 2528 * Specifies lock/unlock. 2529 */ 2530 uint8_t lock; 2531 /** 2532 * HW can be unlocked separately from releasing the HW Lock Mgr. 2533 * This flag is set if the client wishes to release the object. 2534 */ 2535 uint8_t should_release; 2536 /** 2537 * Explicit padding to 4 byte boundary. 2538 */ 2539 uint8_t pad; 2540 }; 2541 2542 /** 2543 * Definition of a DMUB_CMD__HW_LOCK command. 2544 * Command is used by driver and FW. 2545 */ 2546 struct dmub_rb_cmd_lock_hw { 2547 /** 2548 * Command header. 2549 */ 2550 struct dmub_cmd_header header; 2551 /** 2552 * Data passed to HW Lock Mgr in a DMUB_CMD__HW_LOCK command. 2553 */ 2554 struct dmub_cmd_lock_hw_data lock_hw_data; 2555 }; 2556 2557 /** 2558 * ABM command sub-types. 2559 */ 2560 enum dmub_cmd_abm_type { 2561 /** 2562 * Initialize parameters for ABM algorithm. 2563 * Data is passed through an indirect buffer. 2564 */ 2565 DMUB_CMD__ABM_INIT_CONFIG = 0, 2566 /** 2567 * Set OTG and panel HW instance. 2568 */ 2569 DMUB_CMD__ABM_SET_PIPE = 1, 2570 /** 2571 * Set user requested backklight level. 2572 */ 2573 DMUB_CMD__ABM_SET_BACKLIGHT = 2, 2574 /** 2575 * Set ABM operating/aggression level. 2576 */ 2577 DMUB_CMD__ABM_SET_LEVEL = 3, 2578 /** 2579 * Set ambient light level. 2580 */ 2581 DMUB_CMD__ABM_SET_AMBIENT_LEVEL = 4, 2582 /** 2583 * Enable/disable fractional duty cycle for backlight PWM. 2584 */ 2585 DMUB_CMD__ABM_SET_PWM_FRAC = 5, 2586 2587 /** 2588 * unregister vertical interrupt after steady state is reached 2589 */ 2590 DMUB_CMD__ABM_PAUSE = 6, 2591 }; 2592 2593 /** 2594 * Parameters for ABM2.4 algorithm. Passed from driver to FW via an indirect buffer. 2595 * Requirements: 2596 * - Padded explicitly to 32-bit boundary. 2597 * - Must ensure this structure matches the one on driver-side, 2598 * otherwise it won't be aligned. 2599 */ 2600 struct abm_config_table { 2601 /** 2602 * Gamma curve thresholds, used for crgb conversion. 2603 */ 2604 uint16_t crgb_thresh[NUM_POWER_FN_SEGS]; // 0B 2605 /** 2606 * Gamma curve offsets, used for crgb conversion. 2607 */ 2608 uint16_t crgb_offset[NUM_POWER_FN_SEGS]; // 16B 2609 /** 2610 * Gamma curve slopes, used for crgb conversion. 2611 */ 2612 uint16_t crgb_slope[NUM_POWER_FN_SEGS]; // 32B 2613 /** 2614 * Custom backlight curve thresholds. 2615 */ 2616 uint16_t backlight_thresholds[NUM_BL_CURVE_SEGS]; // 48B 2617 /** 2618 * Custom backlight curve offsets. 2619 */ 2620 uint16_t backlight_offsets[NUM_BL_CURVE_SEGS]; // 78B 2621 /** 2622 * Ambient light thresholds. 2623 */ 2624 uint16_t ambient_thresholds_lux[NUM_AMBI_LEVEL]; // 112B 2625 /** 2626 * Minimum programmable backlight. 2627 */ 2628 uint16_t min_abm_backlight; // 122B 2629 /** 2630 * Minimum reduction values. 2631 */ 2632 uint8_t min_reduction[NUM_AMBI_LEVEL][NUM_AGGR_LEVEL]; // 124B 2633 /** 2634 * Maximum reduction values. 2635 */ 2636 uint8_t max_reduction[NUM_AMBI_LEVEL][NUM_AGGR_LEVEL]; // 144B 2637 /** 2638 * Bright positive gain. 2639 */ 2640 uint8_t bright_pos_gain[NUM_AMBI_LEVEL][NUM_AGGR_LEVEL]; // 164B 2641 /** 2642 * Dark negative gain. 2643 */ 2644 uint8_t dark_pos_gain[NUM_AMBI_LEVEL][NUM_AGGR_LEVEL]; // 184B 2645 /** 2646 * Hybrid factor. 2647 */ 2648 uint8_t hybrid_factor[NUM_AGGR_LEVEL]; // 204B 2649 /** 2650 * Contrast factor. 2651 */ 2652 uint8_t contrast_factor[NUM_AGGR_LEVEL]; // 208B 2653 /** 2654 * Deviation gain. 2655 */ 2656 uint8_t deviation_gain[NUM_AGGR_LEVEL]; // 212B 2657 /** 2658 * Minimum knee. 2659 */ 2660 uint8_t min_knee[NUM_AGGR_LEVEL]; // 216B 2661 /** 2662 * Maximum knee. 2663 */ 2664 uint8_t max_knee[NUM_AGGR_LEVEL]; // 220B 2665 /** 2666 * Unused. 2667 */ 2668 uint8_t iir_curve[NUM_AMBI_LEVEL]; // 224B 2669 /** 2670 * Explicit padding to 4 byte boundary. 2671 */ 2672 uint8_t pad3[3]; // 229B 2673 /** 2674 * Backlight ramp reduction. 2675 */ 2676 uint16_t blRampReduction[NUM_AGGR_LEVEL]; // 232B 2677 /** 2678 * Backlight ramp start. 2679 */ 2680 uint16_t blRampStart[NUM_AGGR_LEVEL]; // 240B 2681 }; 2682 2683 /** 2684 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_PIPE command. 2685 */ 2686 struct dmub_cmd_abm_set_pipe_data { 2687 /** 2688 * OTG HW instance. 2689 */ 2690 uint8_t otg_inst; 2691 2692 /** 2693 * Panel Control HW instance. 2694 */ 2695 uint8_t panel_inst; 2696 2697 /** 2698 * Controls how ABM will interpret a set pipe or set level command. 2699 */ 2700 uint8_t set_pipe_option; 2701 2702 /** 2703 * Unused. 2704 * TODO: Remove. 2705 */ 2706 uint8_t ramping_boundary; 2707 }; 2708 2709 /** 2710 * Definition of a DMUB_CMD__ABM_SET_PIPE command. 2711 */ 2712 struct dmub_rb_cmd_abm_set_pipe { 2713 /** 2714 * Command header. 2715 */ 2716 struct dmub_cmd_header header; 2717 2718 /** 2719 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_PIPE command. 2720 */ 2721 struct dmub_cmd_abm_set_pipe_data abm_set_pipe_data; 2722 }; 2723 2724 /** 2725 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_BACKLIGHT command. 2726 */ 2727 struct dmub_cmd_abm_set_backlight_data { 2728 /** 2729 * Number of frames to ramp to backlight user level. 2730 */ 2731 uint32_t frame_ramp; 2732 2733 /** 2734 * Requested backlight level from user. 2735 */ 2736 uint32_t backlight_user_level; 2737 2738 /** 2739 * ABM control version. 2740 */ 2741 uint8_t version; 2742 2743 /** 2744 * Panel Control HW instance mask. 2745 * Bit 0 is Panel Control HW instance 0. 2746 * Bit 1 is Panel Control HW instance 1. 2747 */ 2748 uint8_t panel_mask; 2749 2750 /** 2751 * Explicit padding to 4 byte boundary. 2752 */ 2753 uint8_t pad[2]; 2754 }; 2755 2756 /** 2757 * Definition of a DMUB_CMD__ABM_SET_BACKLIGHT command. 2758 */ 2759 struct dmub_rb_cmd_abm_set_backlight { 2760 /** 2761 * Command header. 2762 */ 2763 struct dmub_cmd_header header; 2764 2765 /** 2766 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_BACKLIGHT command. 2767 */ 2768 struct dmub_cmd_abm_set_backlight_data abm_set_backlight_data; 2769 }; 2770 2771 /** 2772 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_LEVEL command. 2773 */ 2774 struct dmub_cmd_abm_set_level_data { 2775 /** 2776 * Set current ABM operating/aggression level. 2777 */ 2778 uint32_t level; 2779 2780 /** 2781 * ABM control version. 2782 */ 2783 uint8_t version; 2784 2785 /** 2786 * Panel Control HW instance mask. 2787 * Bit 0 is Panel Control HW instance 0. 2788 * Bit 1 is Panel Control HW instance 1. 2789 */ 2790 uint8_t panel_mask; 2791 2792 /** 2793 * Explicit padding to 4 byte boundary. 2794 */ 2795 uint8_t pad[2]; 2796 }; 2797 2798 /** 2799 * Definition of a DMUB_CMD__ABM_SET_LEVEL command. 2800 */ 2801 struct dmub_rb_cmd_abm_set_level { 2802 /** 2803 * Command header. 2804 */ 2805 struct dmub_cmd_header header; 2806 2807 /** 2808 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_LEVEL command. 2809 */ 2810 struct dmub_cmd_abm_set_level_data abm_set_level_data; 2811 }; 2812 2813 /** 2814 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_AMBIENT_LEVEL command. 2815 */ 2816 struct dmub_cmd_abm_set_ambient_level_data { 2817 /** 2818 * Ambient light sensor reading from OS. 2819 */ 2820 uint32_t ambient_lux; 2821 2822 /** 2823 * ABM control version. 2824 */ 2825 uint8_t version; 2826 2827 /** 2828 * Panel Control HW instance mask. 2829 * Bit 0 is Panel Control HW instance 0. 2830 * Bit 1 is Panel Control HW instance 1. 2831 */ 2832 uint8_t panel_mask; 2833 2834 /** 2835 * Explicit padding to 4 byte boundary. 2836 */ 2837 uint8_t pad[2]; 2838 }; 2839 2840 /** 2841 * Definition of a DMUB_CMD__ABM_SET_AMBIENT_LEVEL command. 2842 */ 2843 struct dmub_rb_cmd_abm_set_ambient_level { 2844 /** 2845 * Command header. 2846 */ 2847 struct dmub_cmd_header header; 2848 2849 /** 2850 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_AMBIENT_LEVEL command. 2851 */ 2852 struct dmub_cmd_abm_set_ambient_level_data abm_set_ambient_level_data; 2853 }; 2854 2855 /** 2856 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_PWM_FRAC command. 2857 */ 2858 struct dmub_cmd_abm_set_pwm_frac_data { 2859 /** 2860 * Enable/disable fractional duty cycle for backlight PWM. 2861 * TODO: Convert to uint8_t. 2862 */ 2863 uint32_t fractional_pwm; 2864 2865 /** 2866 * ABM control version. 2867 */ 2868 uint8_t version; 2869 2870 /** 2871 * Panel Control HW instance mask. 2872 * Bit 0 is Panel Control HW instance 0. 2873 * Bit 1 is Panel Control HW instance 1. 2874 */ 2875 uint8_t panel_mask; 2876 2877 /** 2878 * Explicit padding to 4 byte boundary. 2879 */ 2880 uint8_t pad[2]; 2881 }; 2882 2883 /** 2884 * Definition of a DMUB_CMD__ABM_SET_PWM_FRAC command. 2885 */ 2886 struct dmub_rb_cmd_abm_set_pwm_frac { 2887 /** 2888 * Command header. 2889 */ 2890 struct dmub_cmd_header header; 2891 2892 /** 2893 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_PWM_FRAC command. 2894 */ 2895 struct dmub_cmd_abm_set_pwm_frac_data abm_set_pwm_frac_data; 2896 }; 2897 2898 /** 2899 * Data passed from driver to FW in a DMUB_CMD__ABM_INIT_CONFIG command. 2900 */ 2901 struct dmub_cmd_abm_init_config_data { 2902 /** 2903 * Location of indirect buffer used to pass init data to ABM. 2904 */ 2905 union dmub_addr src; 2906 2907 /** 2908 * Indirect buffer length. 2909 */ 2910 uint16_t bytes; 2911 2912 2913 /** 2914 * ABM control version. 2915 */ 2916 uint8_t version; 2917 2918 /** 2919 * Panel Control HW instance mask. 2920 * Bit 0 is Panel Control HW instance 0. 2921 * Bit 1 is Panel Control HW instance 1. 2922 */ 2923 uint8_t panel_mask; 2924 2925 /** 2926 * Explicit padding to 4 byte boundary. 2927 */ 2928 uint8_t pad[2]; 2929 }; 2930 2931 /** 2932 * Definition of a DMUB_CMD__ABM_INIT_CONFIG command. 2933 */ 2934 struct dmub_rb_cmd_abm_init_config { 2935 /** 2936 * Command header. 2937 */ 2938 struct dmub_cmd_header header; 2939 2940 /** 2941 * Data passed from driver to FW in a DMUB_CMD__ABM_INIT_CONFIG command. 2942 */ 2943 struct dmub_cmd_abm_init_config_data abm_init_config_data; 2944 }; 2945 2946 /** 2947 * Data passed from driver to FW in a DMUB_CMD__ABM_PAUSE command. 2948 */ 2949 2950 struct dmub_cmd_abm_pause_data { 2951 2952 /** 2953 * Panel Control HW instance mask. 2954 * Bit 0 is Panel Control HW instance 0. 2955 * Bit 1 is Panel Control HW instance 1. 2956 */ 2957 uint8_t panel_mask; 2958 2959 /** 2960 * OTG hw instance 2961 */ 2962 uint8_t otg_inst; 2963 2964 /** 2965 * Enable or disable ABM pause 2966 */ 2967 uint8_t enable; 2968 2969 /** 2970 * Explicit padding to 4 byte boundary. 2971 */ 2972 uint8_t pad[1]; 2973 }; 2974 2975 /** 2976 * Definition of a DMUB_CMD__ABM_PAUSE command. 2977 */ 2978 struct dmub_rb_cmd_abm_pause { 2979 /** 2980 * Command header. 2981 */ 2982 struct dmub_cmd_header header; 2983 2984 /** 2985 * Data passed from driver to FW in a DMUB_CMD__ABM_PAUSE command. 2986 */ 2987 struct dmub_cmd_abm_pause_data abm_pause_data; 2988 }; 2989 2990 /** 2991 * Data passed from driver to FW in a DMUB_CMD__QUERY_FEATURE_CAPS command. 2992 */ 2993 struct dmub_cmd_query_feature_caps_data { 2994 /** 2995 * DMUB feature capabilities. 2996 * After DMUB init, driver will query FW capabilities prior to enabling certain features. 2997 */ 2998 struct dmub_feature_caps feature_caps; 2999 }; 3000 3001 /** 3002 * Definition of a DMUB_CMD__QUERY_FEATURE_CAPS command. 3003 */ 3004 struct dmub_rb_cmd_query_feature_caps { 3005 /** 3006 * Command header. 3007 */ 3008 struct dmub_cmd_header header; 3009 /** 3010 * Data passed from driver to FW in a DMUB_CMD__QUERY_FEATURE_CAPS command. 3011 */ 3012 struct dmub_cmd_query_feature_caps_data query_feature_caps_data; 3013 }; 3014 3015 /** 3016 * Data passed from driver to FW in a DMUB_CMD__GET_VISUAL_CONFIRM_COLOR command. 3017 */ 3018 struct dmub_cmd_visual_confirm_color_data { 3019 /** 3020 * DMUB feature capabilities. 3021 * After DMUB init, driver will query FW capabilities prior to enabling certain features. 3022 */ 3023 struct dmub_visual_confirm_color visual_confirm_color; 3024 }; 3025 3026 /** 3027 * Definition of a DMUB_CMD__GET_VISUAL_CONFIRM_COLOR command. 3028 */ 3029 struct dmub_rb_cmd_get_visual_confirm_color { 3030 /** 3031 * Command header. 3032 */ 3033 struct dmub_cmd_header header; 3034 /** 3035 * Data passed from driver to FW in a DMUB_CMD__GET_VISUAL_CONFIRM_COLOR command. 3036 */ 3037 struct dmub_cmd_visual_confirm_color_data visual_confirm_color_data; 3038 }; 3039 3040 struct dmub_optc_state { 3041 uint32_t v_total_max; 3042 uint32_t v_total_min; 3043 uint32_t tg_inst; 3044 }; 3045 3046 struct dmub_rb_cmd_drr_update { 3047 struct dmub_cmd_header header; 3048 struct dmub_optc_state dmub_optc_state_req; 3049 }; 3050 3051 struct dmub_cmd_fw_assisted_mclk_switch_pipe_data { 3052 uint32_t pix_clk_100hz; 3053 uint8_t max_ramp_step; 3054 uint8_t pipes; 3055 uint8_t min_refresh_in_hz; 3056 uint8_t padding[1]; 3057 }; 3058 3059 struct dmub_cmd_fw_assisted_mclk_switch_config { 3060 uint8_t fams_enabled; 3061 uint8_t visual_confirm_enabled; 3062 uint8_t padding[2]; 3063 struct dmub_cmd_fw_assisted_mclk_switch_pipe_data pipe_data[DMUB_MAX_STREAMS]; 3064 }; 3065 3066 struct dmub_rb_cmd_fw_assisted_mclk_switch { 3067 struct dmub_cmd_header header; 3068 struct dmub_cmd_fw_assisted_mclk_switch_config config_data; 3069 }; 3070 3071 /** 3072 * enum dmub_cmd_panel_cntl_type - Panel control command. 3073 */ 3074 enum dmub_cmd_panel_cntl_type { 3075 /** 3076 * Initializes embedded panel hardware blocks. 3077 */ 3078 DMUB_CMD__PANEL_CNTL_HW_INIT = 0, 3079 /** 3080 * Queries backlight info for the embedded panel. 3081 */ 3082 DMUB_CMD__PANEL_CNTL_QUERY_BACKLIGHT_INFO = 1, 3083 }; 3084 3085 /** 3086 * struct dmub_cmd_panel_cntl_data - Panel control data. 3087 */ 3088 struct dmub_cmd_panel_cntl_data { 3089 uint32_t inst; /**< panel instance */ 3090 uint32_t current_backlight; /* in/out */ 3091 uint32_t bl_pwm_cntl; /* in/out */ 3092 uint32_t bl_pwm_period_cntl; /* in/out */ 3093 uint32_t bl_pwm_ref_div1; /* in/out */ 3094 uint8_t is_backlight_on : 1; /* in/out */ 3095 uint8_t is_powered_on : 1; /* in/out */ 3096 uint8_t padding[3]; 3097 uint32_t bl_pwm_ref_div2; /* in/out */ 3098 uint8_t reserved[4]; 3099 }; 3100 3101 /** 3102 * struct dmub_rb_cmd_panel_cntl - Panel control command. 3103 */ 3104 struct dmub_rb_cmd_panel_cntl { 3105 struct dmub_cmd_header header; /**< header */ 3106 struct dmub_cmd_panel_cntl_data data; /**< payload */ 3107 }; 3108 3109 /** 3110 * Data passed from driver to FW in a DMUB_CMD__VBIOS_LVTMA_CONTROL command. 3111 */ 3112 struct dmub_cmd_lvtma_control_data { 3113 uint8_t uc_pwr_action; /**< LVTMA_ACTION */ 3114 uint8_t bypass_panel_control_wait; 3115 uint8_t reserved_0[2]; 3116 uint8_t panel_inst; /**< LVTMA control instance */ 3117 uint8_t reserved_1[3]; /**< For future use */ 3118 }; 3119 3120 /** 3121 * Definition of a DMUB_CMD__VBIOS_LVTMA_CONTROL command. 3122 */ 3123 struct dmub_rb_cmd_lvtma_control { 3124 /** 3125 * Command header. 3126 */ 3127 struct dmub_cmd_header header; 3128 /** 3129 * Data passed from driver to FW in a DMUB_CMD__VBIOS_LVTMA_CONTROL command. 3130 */ 3131 struct dmub_cmd_lvtma_control_data data; 3132 }; 3133 3134 /** 3135 * Data passed in/out in a DMUB_CMD__VBIOS_TRANSMITTER_QUERY_DP_ALT command. 3136 */ 3137 struct dmub_rb_cmd_transmitter_query_dp_alt_data { 3138 uint8_t phy_id; /**< 0=UNIPHYA, 1=UNIPHYB, 2=UNIPHYC, 3=UNIPHYD, 4=UNIPHYE, 5=UNIPHYF */ 3139 uint8_t is_usb; /**< is phy is usb */ 3140 uint8_t is_dp_alt_disable; /**< is dp alt disable */ 3141 uint8_t is_dp4; /**< is dp in 4 lane */ 3142 }; 3143 3144 /** 3145 * Definition of a DMUB_CMD__VBIOS_TRANSMITTER_QUERY_DP_ALT command. 3146 */ 3147 struct dmub_rb_cmd_transmitter_query_dp_alt { 3148 struct dmub_cmd_header header; /**< header */ 3149 struct dmub_rb_cmd_transmitter_query_dp_alt_data data; /**< payload */ 3150 }; 3151 3152 /** 3153 * Maximum number of bytes a chunk sent to DMUB for parsing 3154 */ 3155 #define DMUB_EDID_CEA_DATA_CHUNK_BYTES 8 3156 3157 /** 3158 * Represent a chunk of CEA blocks sent to DMUB for parsing 3159 */ 3160 struct dmub_cmd_send_edid_cea { 3161 uint16_t offset; /**< offset into the CEA block */ 3162 uint8_t length; /**< number of bytes in payload to copy as part of CEA block */ 3163 uint16_t cea_total_length; /**< total length of the CEA block */ 3164 uint8_t payload[DMUB_EDID_CEA_DATA_CHUNK_BYTES]; /**< data chunk of the CEA block */ 3165 uint8_t pad[3]; /**< padding and for future expansion */ 3166 }; 3167 3168 /** 3169 * Result of VSDB parsing from CEA block 3170 */ 3171 struct dmub_cmd_edid_cea_amd_vsdb { 3172 uint8_t vsdb_found; /**< 1 if parsing has found valid AMD VSDB */ 3173 uint8_t freesync_supported; /**< 1 if Freesync is supported */ 3174 uint16_t amd_vsdb_version; /**< AMD VSDB version */ 3175 uint16_t min_frame_rate; /**< Maximum frame rate */ 3176 uint16_t max_frame_rate; /**< Minimum frame rate */ 3177 }; 3178 3179 /** 3180 * Result of sending a CEA chunk 3181 */ 3182 struct dmub_cmd_edid_cea_ack { 3183 uint16_t offset; /**< offset of the chunk into the CEA block */ 3184 uint8_t success; /**< 1 if this sending of chunk succeeded */ 3185 uint8_t pad; /**< padding and for future expansion */ 3186 }; 3187 3188 /** 3189 * Specify whether the result is an ACK/NACK or the parsing has finished 3190 */ 3191 enum dmub_cmd_edid_cea_reply_type { 3192 DMUB_CMD__EDID_CEA_AMD_VSDB = 1, /**< VSDB parsing has finished */ 3193 DMUB_CMD__EDID_CEA_ACK = 2, /**< acknowledges the CEA sending is OK or failing */ 3194 }; 3195 3196 /** 3197 * Definition of a DMUB_CMD__EDID_CEA command. 3198 */ 3199 struct dmub_rb_cmd_edid_cea { 3200 struct dmub_cmd_header header; /**< Command header */ 3201 union dmub_cmd_edid_cea_data { 3202 struct dmub_cmd_send_edid_cea input; /**< input to send CEA chunks */ 3203 struct dmub_cmd_edid_cea_output { /**< output with results */ 3204 uint8_t type; /**< dmub_cmd_edid_cea_reply_type */ 3205 union { 3206 struct dmub_cmd_edid_cea_amd_vsdb amd_vsdb; 3207 struct dmub_cmd_edid_cea_ack ack; 3208 }; 3209 } output; /**< output to retrieve ACK/NACK or VSDB parsing results */ 3210 } data; /**< Command data */ 3211 3212 }; 3213 3214 /** 3215 * struct dmub_cmd_cable_id_input - Defines the input of DMUB_CMD_GET_USBC_CABLE_ID command. 3216 */ 3217 struct dmub_cmd_cable_id_input { 3218 uint8_t phy_inst; /**< phy inst for cable id data */ 3219 }; 3220 3221 /** 3222 * struct dmub_cmd_cable_id_input - Defines the output of DMUB_CMD_GET_USBC_CABLE_ID command. 3223 */ 3224 struct dmub_cmd_cable_id_output { 3225 uint8_t UHBR10_20_CAPABILITY :2; /**< b'01 for UHBR10 support, b'10 for both UHBR10 and UHBR20 support */ 3226 uint8_t UHBR13_5_CAPABILITY :1; /**< b'1 for UHBR13.5 support */ 3227 uint8_t CABLE_TYPE :3; /**< b'01 for passive cable, b'10 for active LRD cable, b'11 for active retimer cable */ 3228 uint8_t RESERVED :2; /**< reserved means not defined */ 3229 }; 3230 3231 /** 3232 * Definition of a DMUB_CMD_GET_USBC_CABLE_ID command 3233 */ 3234 struct dmub_rb_cmd_get_usbc_cable_id { 3235 struct dmub_cmd_header header; /**< Command header */ 3236 /** 3237 * Data passed from driver to FW in a DMUB_CMD_GET_USBC_CABLE_ID command. 3238 */ 3239 union dmub_cmd_cable_id_data { 3240 struct dmub_cmd_cable_id_input input; /**< Input */ 3241 struct dmub_cmd_cable_id_output output; /**< Output */ 3242 uint8_t output_raw; /**< Raw data output */ 3243 } data; 3244 }; 3245 3246 /** 3247 * Command type of a DMUB_CMD__SECURE_DISPLAY command 3248 */ 3249 enum dmub_cmd_secure_display_type { 3250 DMUB_CMD__SECURE_DISPLAY_TEST_CMD = 0, /* test command to only check if inbox message works */ 3251 DMUB_CMD__SECURE_DISPLAY_CRC_STOP_UPDATE, 3252 DMUB_CMD__SECURE_DISPLAY_CRC_WIN_NOTIFY 3253 }; 3254 3255 /** 3256 * Definition of a DMUB_CMD__SECURE_DISPLAY command 3257 */ 3258 struct dmub_rb_cmd_secure_display { 3259 struct dmub_cmd_header header; 3260 /** 3261 * Data passed from driver to dmub firmware. 3262 */ 3263 struct dmub_cmd_roi_info { 3264 uint16_t x_start; 3265 uint16_t x_end; 3266 uint16_t y_start; 3267 uint16_t y_end; 3268 uint8_t otg_id; 3269 uint8_t phy_id; 3270 } roi_info; 3271 }; 3272 3273 /** 3274 * union dmub_rb_cmd - DMUB inbox command. 3275 */ 3276 union dmub_rb_cmd { 3277 /** 3278 * Elements shared with all commands. 3279 */ 3280 struct dmub_rb_cmd_common cmd_common; 3281 /** 3282 * Definition of a DMUB_CMD__REG_SEQ_READ_MODIFY_WRITE command. 3283 */ 3284 struct dmub_rb_cmd_read_modify_write read_modify_write; 3285 /** 3286 * Definition of a DMUB_CMD__REG_SEQ_FIELD_UPDATE_SEQ command. 3287 */ 3288 struct dmub_rb_cmd_reg_field_update_sequence reg_field_update_seq; 3289 /** 3290 * Definition of a DMUB_CMD__REG_SEQ_BURST_WRITE command. 3291 */ 3292 struct dmub_rb_cmd_burst_write burst_write; 3293 /** 3294 * Definition of a DMUB_CMD__REG_REG_WAIT command. 3295 */ 3296 struct dmub_rb_cmd_reg_wait reg_wait; 3297 /** 3298 * Definition of a DMUB_CMD__VBIOS_DIGX_ENCODER_CONTROL command. 3299 */ 3300 struct dmub_rb_cmd_digx_encoder_control digx_encoder_control; 3301 /** 3302 * Definition of a DMUB_CMD__VBIOS_SET_PIXEL_CLOCK command. 3303 */ 3304 struct dmub_rb_cmd_set_pixel_clock set_pixel_clock; 3305 /** 3306 * Definition of a DMUB_CMD__VBIOS_ENABLE_DISP_POWER_GATING command. 3307 */ 3308 struct dmub_rb_cmd_enable_disp_power_gating enable_disp_power_gating; 3309 /** 3310 * Definition of a DMUB_CMD__VBIOS_DPPHY_INIT command. 3311 */ 3312 struct dmub_rb_cmd_dpphy_init dpphy_init; 3313 /** 3314 * Definition of a DMUB_CMD__VBIOS_DIG1_TRANSMITTER_CONTROL command. 3315 */ 3316 struct dmub_rb_cmd_dig1_transmitter_control dig1_transmitter_control; 3317 /** 3318 * Definition of a DMUB_CMD__PSR_SET_VERSION command. 3319 */ 3320 struct dmub_rb_cmd_psr_set_version psr_set_version; 3321 /** 3322 * Definition of a DMUB_CMD__PSR_COPY_SETTINGS command. 3323 */ 3324 struct dmub_rb_cmd_psr_copy_settings psr_copy_settings; 3325 /** 3326 * Definition of a DMUB_CMD__PSR_ENABLE command. 3327 */ 3328 struct dmub_rb_cmd_psr_enable psr_enable; 3329 /** 3330 * Definition of a DMUB_CMD__PSR_SET_LEVEL command. 3331 */ 3332 struct dmub_rb_cmd_psr_set_level psr_set_level; 3333 /** 3334 * Definition of a DMUB_CMD__PSR_FORCE_STATIC command. 3335 */ 3336 struct dmub_rb_cmd_psr_force_static psr_force_static; 3337 /** 3338 * Definition of a DMUB_CMD__UPDATE_DIRTY_RECT command. 3339 */ 3340 struct dmub_rb_cmd_update_dirty_rect update_dirty_rect; 3341 /** 3342 * Definition of a DMUB_CMD__UPDATE_CURSOR_INFO command. 3343 */ 3344 struct dmub_rb_cmd_update_cursor_info update_cursor_info; 3345 /** 3346 * Definition of a DMUB_CMD__HW_LOCK command. 3347 * Command is used by driver and FW. 3348 */ 3349 struct dmub_rb_cmd_lock_hw lock_hw; 3350 /** 3351 * Definition of a DMUB_CMD__SET_SINK_VTOTAL_IN_PSR_ACTIVE command. 3352 */ 3353 struct dmub_rb_cmd_psr_set_vtotal psr_set_vtotal; 3354 /** 3355 * Definition of a DMUB_CMD__SET_PSR_POWER_OPT command. 3356 */ 3357 struct dmub_rb_cmd_psr_set_power_opt psr_set_power_opt; 3358 /** 3359 * Definition of a DMUB_CMD__PLAT_54186_WA command. 3360 */ 3361 struct dmub_rb_cmd_PLAT_54186_wa PLAT_54186_wa; 3362 /** 3363 * Definition of a DMUB_CMD__MALL command. 3364 */ 3365 struct dmub_rb_cmd_mall mall; 3366 /** 3367 * Definition of a DMUB_CMD__CAB command. 3368 */ 3369 struct dmub_rb_cmd_cab_for_ss cab; 3370 3371 struct dmub_rb_cmd_fw_assisted_mclk_switch_v2 fw_assisted_mclk_switch_v2; 3372 3373 /** 3374 * Definition of a DMUB_CMD__IDLE_OPT_DCN_RESTORE command. 3375 */ 3376 struct dmub_rb_cmd_idle_opt_dcn_restore dcn_restore; 3377 3378 /** 3379 * Definition of a DMUB_CMD__CLK_MGR_NOTIFY_CLOCKS command. 3380 */ 3381 struct dmub_rb_cmd_clk_mgr_notify_clocks notify_clocks; 3382 3383 /** 3384 * Definition of DMUB_CMD__PANEL_CNTL commands. 3385 */ 3386 struct dmub_rb_cmd_panel_cntl panel_cntl; 3387 /** 3388 * Definition of a DMUB_CMD__ABM_SET_PIPE command. 3389 */ 3390 struct dmub_rb_cmd_abm_set_pipe abm_set_pipe; 3391 3392 /** 3393 * Definition of a DMUB_CMD__ABM_SET_BACKLIGHT command. 3394 */ 3395 struct dmub_rb_cmd_abm_set_backlight abm_set_backlight; 3396 3397 /** 3398 * Definition of a DMUB_CMD__ABM_SET_LEVEL command. 3399 */ 3400 struct dmub_rb_cmd_abm_set_level abm_set_level; 3401 3402 /** 3403 * Definition of a DMUB_CMD__ABM_SET_AMBIENT_LEVEL command. 3404 */ 3405 struct dmub_rb_cmd_abm_set_ambient_level abm_set_ambient_level; 3406 3407 /** 3408 * Definition of a DMUB_CMD__ABM_SET_PWM_FRAC command. 3409 */ 3410 struct dmub_rb_cmd_abm_set_pwm_frac abm_set_pwm_frac; 3411 3412 /** 3413 * Definition of a DMUB_CMD__ABM_INIT_CONFIG command. 3414 */ 3415 struct dmub_rb_cmd_abm_init_config abm_init_config; 3416 3417 /** 3418 * Definition of a DMUB_CMD__ABM_PAUSE command. 3419 */ 3420 struct dmub_rb_cmd_abm_pause abm_pause; 3421 3422 /** 3423 * Definition of a DMUB_CMD__DP_AUX_ACCESS command. 3424 */ 3425 struct dmub_rb_cmd_dp_aux_access dp_aux_access; 3426 3427 /** 3428 * Definition of a DMUB_CMD__OUTBOX1_ENABLE command. 3429 */ 3430 struct dmub_rb_cmd_outbox1_enable outbox1_enable; 3431 3432 /** 3433 * Definition of a DMUB_CMD__QUERY_FEATURE_CAPS command. 3434 */ 3435 struct dmub_rb_cmd_query_feature_caps query_feature_caps; 3436 3437 /** 3438 * Definition of a DMUB_CMD__GET_VISUAL_CONFIRM_COLOR command. 3439 */ 3440 struct dmub_rb_cmd_get_visual_confirm_color visual_confirm_color; 3441 struct dmub_rb_cmd_drr_update drr_update; 3442 struct dmub_rb_cmd_fw_assisted_mclk_switch fw_assisted_mclk_switch; 3443 3444 /** 3445 * Definition of a DMUB_CMD__VBIOS_LVTMA_CONTROL command. 3446 */ 3447 struct dmub_rb_cmd_lvtma_control lvtma_control; 3448 /** 3449 * Definition of a DMUB_CMD__VBIOS_TRANSMITTER_QUERY_DP_ALT command. 3450 */ 3451 struct dmub_rb_cmd_transmitter_query_dp_alt query_dp_alt; 3452 /** 3453 * Definition of a DMUB_CMD__DPIA_DIG1_CONTROL command. 3454 */ 3455 struct dmub_rb_cmd_dig1_dpia_control dig1_dpia_control; 3456 /** 3457 * Definition of a DMUB_CMD__DPIA_SET_CONFIG_ACCESS command. 3458 */ 3459 struct dmub_rb_cmd_set_config_access set_config_access; 3460 /** 3461 * Definition of a DMUB_CMD__DPIA_MST_ALLOC_SLOTS command. 3462 */ 3463 struct dmub_rb_cmd_set_mst_alloc_slots set_mst_alloc_slots; 3464 /** 3465 * Definition of a DMUB_CMD__EDID_CEA command. 3466 */ 3467 struct dmub_rb_cmd_edid_cea edid_cea; 3468 /** 3469 * Definition of a DMUB_CMD_GET_USBC_CABLE_ID command. 3470 */ 3471 struct dmub_rb_cmd_get_usbc_cable_id cable_id; 3472 3473 /** 3474 * Definition of a DMUB_CMD__QUERY_HPD_STATE command. 3475 */ 3476 struct dmub_rb_cmd_query_hpd_state query_hpd; 3477 /** 3478 * Definition of a DMUB_CMD__SECURE_DISPLAY command. 3479 */ 3480 struct dmub_rb_cmd_secure_display secure_display; 3481 3482 /** 3483 * Definition of a DMUB_CMD__DPIA_HPD_INT_ENABLE command. 3484 */ 3485 struct dmub_rb_cmd_dpia_hpd_int_enable dpia_hpd_int_enable; 3486 }; 3487 3488 /** 3489 * union dmub_rb_out_cmd - Outbox command 3490 */ 3491 union dmub_rb_out_cmd { 3492 /** 3493 * Parameters common to every command. 3494 */ 3495 struct dmub_rb_cmd_common cmd_common; 3496 /** 3497 * AUX reply command. 3498 */ 3499 struct dmub_rb_cmd_dp_aux_reply dp_aux_reply; 3500 /** 3501 * HPD notify command. 3502 */ 3503 struct dmub_rb_cmd_dp_hpd_notify dp_hpd_notify; 3504 /** 3505 * SET_CONFIG reply command. 3506 */ 3507 struct dmub_rb_cmd_dp_set_config_reply set_config_reply; 3508 /** 3509 * DPIA notification command. 3510 */ 3511 struct dmub_rb_cmd_dpia_notification dpia_notification; 3512 }; 3513 #pragma pack(pop) 3514 3515 3516 //============================================================================== 3517 //</DMUB_CMD>=================================================================== 3518 //============================================================================== 3519 //< DMUB_RB>==================================================================== 3520 //============================================================================== 3521 3522 #if defined(__cplusplus) 3523 extern "C" { 3524 #endif 3525 3526 /** 3527 * struct dmub_rb_init_params - Initialization params for DMUB ringbuffer 3528 */ 3529 struct dmub_rb_init_params { 3530 void *ctx; /**< Caller provided context pointer */ 3531 void *base_address; /**< CPU base address for ring's data */ 3532 uint32_t capacity; /**< Ringbuffer capacity in bytes */ 3533 uint32_t read_ptr; /**< Initial read pointer for consumer in bytes */ 3534 uint32_t write_ptr; /**< Initial write pointer for producer in bytes */ 3535 }; 3536 3537 /** 3538 * struct dmub_rb - Inbox or outbox DMUB ringbuffer 3539 */ 3540 struct dmub_rb { 3541 void *base_address; /**< CPU address for the ring's data */ 3542 uint32_t rptr; /**< Read pointer for consumer in bytes */ 3543 uint32_t wrpt; /**< Write pointer for producer in bytes */ 3544 uint32_t capacity; /**< Ringbuffer capacity in bytes */ 3545 3546 void *ctx; /**< Caller provided context pointer */ 3547 void *dmub; /**< Pointer to the DMUB interface */ 3548 }; 3549 3550 /** 3551 * @brief Checks if the ringbuffer is empty. 3552 * 3553 * @param rb DMUB Ringbuffer 3554 * @return true if empty 3555 * @return false otherwise 3556 */ 3557 static inline bool dmub_rb_empty(struct dmub_rb *rb) 3558 { 3559 return (rb->wrpt == rb->rptr); 3560 } 3561 3562 /** 3563 * @brief Checks if the ringbuffer is full 3564 * 3565 * @param rb DMUB Ringbuffer 3566 * @return true if full 3567 * @return false otherwise 3568 */ 3569 static inline bool dmub_rb_full(struct dmub_rb *rb) 3570 { 3571 uint32_t data_count; 3572 3573 if (rb->wrpt >= rb->rptr) 3574 data_count = rb->wrpt - rb->rptr; 3575 else 3576 data_count = rb->capacity - (rb->rptr - rb->wrpt); 3577 3578 return (data_count == (rb->capacity - DMUB_RB_CMD_SIZE)); 3579 } 3580 3581 /** 3582 * @brief Pushes a command into the ringbuffer 3583 * 3584 * @param rb DMUB ringbuffer 3585 * @param cmd The command to push 3586 * @return true if the ringbuffer was not full 3587 * @return false otherwise 3588 */ 3589 static inline bool dmub_rb_push_front(struct dmub_rb *rb, 3590 const union dmub_rb_cmd *cmd) 3591 { 3592 uint64_t volatile *dst = (uint64_t volatile *)((uint8_t *)(rb->base_address) + rb->wrpt); 3593 const uint64_t *src = (const uint64_t *)cmd; 3594 uint8_t i; 3595 3596 if (dmub_rb_full(rb)) 3597 return false; 3598 3599 // copying data 3600 for (i = 0; i < DMUB_RB_CMD_SIZE / sizeof(uint64_t); i++) 3601 *dst++ = *src++; 3602 3603 rb->wrpt += DMUB_RB_CMD_SIZE; 3604 3605 if (rb->wrpt >= rb->capacity) 3606 rb->wrpt %= rb->capacity; 3607 3608 return true; 3609 } 3610 3611 /** 3612 * @brief Pushes a command into the DMUB outbox ringbuffer 3613 * 3614 * @param rb DMUB outbox ringbuffer 3615 * @param cmd Outbox command 3616 * @return true if not full 3617 * @return false otherwise 3618 */ 3619 static inline bool dmub_rb_out_push_front(struct dmub_rb *rb, 3620 const union dmub_rb_out_cmd *cmd) 3621 { 3622 uint8_t *dst = (uint8_t *)(rb->base_address) + rb->wrpt; 3623 const uint8_t *src = (const uint8_t *)cmd; 3624 3625 if (dmub_rb_full(rb)) 3626 return false; 3627 3628 dmub_memcpy(dst, src, DMUB_RB_CMD_SIZE); 3629 3630 rb->wrpt += DMUB_RB_CMD_SIZE; 3631 3632 if (rb->wrpt >= rb->capacity) 3633 rb->wrpt %= rb->capacity; 3634 3635 return true; 3636 } 3637 3638 /** 3639 * @brief Returns the next unprocessed command in the ringbuffer. 3640 * 3641 * @param rb DMUB ringbuffer 3642 * @param cmd The command to return 3643 * @return true if not empty 3644 * @return false otherwise 3645 */ 3646 static inline bool dmub_rb_front(struct dmub_rb *rb, 3647 union dmub_rb_cmd **cmd) 3648 { 3649 uint8_t *rb_cmd = (uint8_t *)(rb->base_address) + rb->rptr; 3650 3651 if (dmub_rb_empty(rb)) 3652 return false; 3653 3654 *cmd = (union dmub_rb_cmd *)rb_cmd; 3655 3656 return true; 3657 } 3658 3659 /** 3660 * @brief Determines the next ringbuffer offset. 3661 * 3662 * @param rb DMUB inbox ringbuffer 3663 * @param num_cmds Number of commands 3664 * @param next_rptr The next offset in the ringbuffer 3665 */ 3666 static inline void dmub_rb_get_rptr_with_offset(struct dmub_rb *rb, 3667 uint32_t num_cmds, 3668 uint32_t *next_rptr) 3669 { 3670 *next_rptr = rb->rptr + DMUB_RB_CMD_SIZE * num_cmds; 3671 3672 if (*next_rptr >= rb->capacity) 3673 *next_rptr %= rb->capacity; 3674 } 3675 3676 /** 3677 * @brief Returns a pointer to a command in the inbox. 3678 * 3679 * @param rb DMUB inbox ringbuffer 3680 * @param cmd The inbox command to return 3681 * @param rptr The ringbuffer offset 3682 * @return true if not empty 3683 * @return false otherwise 3684 */ 3685 static inline bool dmub_rb_peek_offset(struct dmub_rb *rb, 3686 union dmub_rb_cmd **cmd, 3687 uint32_t rptr) 3688 { 3689 uint8_t *rb_cmd = (uint8_t *)(rb->base_address) + rptr; 3690 3691 if (dmub_rb_empty(rb)) 3692 return false; 3693 3694 *cmd = (union dmub_rb_cmd *)rb_cmd; 3695 3696 return true; 3697 } 3698 3699 /** 3700 * @brief Returns the next unprocessed command in the outbox. 3701 * 3702 * @param rb DMUB outbox ringbuffer 3703 * @param cmd The outbox command to return 3704 * @return true if not empty 3705 * @return false otherwise 3706 */ 3707 static inline bool dmub_rb_out_front(struct dmub_rb *rb, 3708 union dmub_rb_out_cmd *cmd) 3709 { 3710 const uint64_t volatile *src = (const uint64_t volatile *)((uint8_t *)(rb->base_address) + rb->rptr); 3711 uint64_t *dst = (uint64_t *)cmd; 3712 uint8_t i; 3713 3714 if (dmub_rb_empty(rb)) 3715 return false; 3716 3717 // copying data 3718 for (i = 0; i < DMUB_RB_CMD_SIZE / sizeof(uint64_t); i++) 3719 *dst++ = *src++; 3720 3721 return true; 3722 } 3723 3724 /** 3725 * @brief Removes the front entry in the ringbuffer. 3726 * 3727 * @param rb DMUB ringbuffer 3728 * @return true if the command was removed 3729 * @return false if there were no commands 3730 */ 3731 static inline bool dmub_rb_pop_front(struct dmub_rb *rb) 3732 { 3733 if (dmub_rb_empty(rb)) 3734 return false; 3735 3736 rb->rptr += DMUB_RB_CMD_SIZE; 3737 3738 if (rb->rptr >= rb->capacity) 3739 rb->rptr %= rb->capacity; 3740 3741 return true; 3742 } 3743 3744 /** 3745 * @brief Flushes commands in the ringbuffer to framebuffer memory. 3746 * 3747 * Avoids a race condition where DMCUB accesses memory while 3748 * there are still writes in flight to framebuffer. 3749 * 3750 * @param rb DMUB ringbuffer 3751 */ 3752 static inline void dmub_rb_flush_pending(const struct dmub_rb *rb) 3753 { 3754 uint32_t rptr = rb->rptr; 3755 uint32_t wptr = rb->wrpt; 3756 3757 while (rptr != wptr) { 3758 uint64_t *data = (uint64_t *)((uint8_t *)(rb->base_address) + rptr); 3759 uint8_t i; 3760 3761 /* Don't remove this. 3762 * The contents need to actually be read from the ring buffer 3763 * for this function to be effective. 3764 */ 3765 for (i = 0; i < DMUB_RB_CMD_SIZE / sizeof(uint64_t); i++) 3766 (void)READ_ONCE(*data++); 3767 3768 rptr += DMUB_RB_CMD_SIZE; 3769 if (rptr >= rb->capacity) 3770 rptr %= rb->capacity; 3771 } 3772 } 3773 3774 /** 3775 * @brief Initializes a DMCUB ringbuffer 3776 * 3777 * @param rb DMUB ringbuffer 3778 * @param init_params initial configuration for the ringbuffer 3779 */ 3780 static inline void dmub_rb_init(struct dmub_rb *rb, 3781 struct dmub_rb_init_params *init_params) 3782 { 3783 rb->base_address = init_params->base_address; 3784 rb->capacity = init_params->capacity; 3785 rb->rptr = init_params->read_ptr; 3786 rb->wrpt = init_params->write_ptr; 3787 } 3788 3789 /** 3790 * @brief Copies output data from in/out commands into the given command. 3791 * 3792 * @param rb DMUB ringbuffer 3793 * @param cmd Command to copy data into 3794 */ 3795 static inline void dmub_rb_get_return_data(struct dmub_rb *rb, 3796 union dmub_rb_cmd *cmd) 3797 { 3798 // Copy rb entry back into command 3799 uint8_t *rd_ptr = (rb->rptr == 0) ? 3800 (uint8_t *)rb->base_address + rb->capacity - DMUB_RB_CMD_SIZE : 3801 (uint8_t *)rb->base_address + rb->rptr - DMUB_RB_CMD_SIZE; 3802 3803 dmub_memcpy(cmd, rd_ptr, DMUB_RB_CMD_SIZE); 3804 } 3805 3806 #if defined(__cplusplus) 3807 } 3808 #endif 3809 3810 //============================================================================== 3811 //</DMUB_RB>==================================================================== 3812 //============================================================================== 3813 3814 #endif /* _DMUB_CMD_H_ */ 3815