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 /* Firmware versioning. */ 48 #ifdef DMUB_EXPOSE_VERSION 49 #define DMUB_FW_VERSION_GIT_HASH 0xbaf06b95 50 #define DMUB_FW_VERSION_MAJOR 0 51 #define DMUB_FW_VERSION_MINOR 0 52 #define DMUB_FW_VERSION_REVISION 98 53 #define DMUB_FW_VERSION_TEST 0 54 #define DMUB_FW_VERSION_VBIOS 0 55 #define DMUB_FW_VERSION_HOTFIX 0 56 #define DMUB_FW_VERSION_UCODE (((DMUB_FW_VERSION_MAJOR & 0xFF) << 24) | \ 57 ((DMUB_FW_VERSION_MINOR & 0xFF) << 16) | \ 58 ((DMUB_FW_VERSION_REVISION & 0xFF) << 8) | \ 59 ((DMUB_FW_VERSION_TEST & 0x1) << 7) | \ 60 ((DMUB_FW_VERSION_VBIOS & 0x1) << 6) | \ 61 (DMUB_FW_VERSION_HOTFIX & 0x3F)) 62 63 #endif 64 65 //<DMUB_TYPES>================================================================== 66 /* Basic type definitions. */ 67 68 #define __forceinline inline 69 70 /** 71 * Flag from driver to indicate that ABM should be disabled gradually 72 * by slowly reversing all backlight programming and pixel compensation. 73 */ 74 #define SET_ABM_PIPE_GRADUALLY_DISABLE 0 75 76 /** 77 * Flag from driver to indicate that ABM should be disabled immediately 78 * and undo all backlight programming and pixel compensation. 79 */ 80 #define SET_ABM_PIPE_IMMEDIATELY_DISABLE 255 81 82 /** 83 * Flag from driver to indicate that ABM should be disabled immediately 84 * and keep the current backlight programming and pixel compensation. 85 */ 86 #define SET_ABM_PIPE_IMMEDIATE_KEEP_GAIN_DISABLE 254 87 88 /** 89 * Flag from driver to set the current ABM pipe index or ABM operating level. 90 */ 91 #define SET_ABM_PIPE_NORMAL 1 92 93 /** 94 * Number of ambient light levels in ABM algorithm. 95 */ 96 #define NUM_AMBI_LEVEL 5 97 98 /** 99 * Number of operating/aggression levels in ABM algorithm. 100 */ 101 #define NUM_AGGR_LEVEL 4 102 103 /** 104 * Number of segments in the gamma curve. 105 */ 106 #define NUM_POWER_FN_SEGS 8 107 108 /** 109 * Number of segments in the backlight curve. 110 */ 111 #define NUM_BL_CURVE_SEGS 16 112 113 /* Maximum number of streams on any ASIC. */ 114 #define DMUB_MAX_STREAMS 6 115 116 /* Maximum number of planes on any ASIC. */ 117 #define DMUB_MAX_PLANES 6 118 119 /* Trace buffer offset for entry */ 120 #define TRACE_BUFFER_ENTRY_OFFSET 16 121 122 /** 123 * 124 * PSR control version legacy 125 */ 126 #define DMUB_CMD_PSR_CONTROL_VERSION_UNKNOWN 0x0 127 /** 128 * PSR control version with multi edp support 129 */ 130 #define DMUB_CMD_PSR_CONTROL_VERSION_1 0x1 131 132 133 /** 134 * ABM control version legacy 135 */ 136 #define DMUB_CMD_ABM_CONTROL_VERSION_UNKNOWN 0x0 137 138 /** 139 * ABM control version with multi edp support 140 */ 141 #define DMUB_CMD_ABM_CONTROL_VERSION_1 0x1 142 143 /** 144 * Physical framebuffer address location, 64-bit. 145 */ 146 #ifndef PHYSICAL_ADDRESS_LOC 147 #define PHYSICAL_ADDRESS_LOC union large_integer 148 #endif 149 150 /** 151 * OS/FW agnostic memcpy 152 */ 153 #ifndef dmub_memcpy 154 #define dmub_memcpy(dest, source, bytes) memcpy((dest), (source), (bytes)) 155 #endif 156 157 /** 158 * OS/FW agnostic memset 159 */ 160 #ifndef dmub_memset 161 #define dmub_memset(dest, val, bytes) memset((dest), (val), (bytes)) 162 #endif 163 164 #if defined(__cplusplus) 165 extern "C" { 166 #endif 167 168 /** 169 * OS/FW agnostic udelay 170 */ 171 #ifndef dmub_udelay 172 #define dmub_udelay(microseconds) udelay(microseconds) 173 #endif 174 175 /** 176 * union dmub_addr - DMUB physical/virtual 64-bit address. 177 */ 178 union dmub_addr { 179 struct { 180 uint32_t low_part; /**< Lower 32 bits */ 181 uint32_t high_part; /**< Upper 32 bits */ 182 } u; /*<< Low/high bit access */ 183 uint64_t quad_part; /*<< 64 bit address */ 184 }; 185 186 /** 187 * Flags that can be set by driver to change some PSR behaviour. 188 */ 189 union dmub_psr_debug_flags { 190 /** 191 * Debug flags. 192 */ 193 struct { 194 /** 195 * Enable visual confirm in FW. 196 */ 197 uint32_t visual_confirm : 1; 198 /** 199 * Use HW Lock Mgr object to do HW locking in FW. 200 */ 201 uint32_t use_hw_lock_mgr : 1; 202 203 /** 204 * Use TPS3 signal when restore main link. 205 */ 206 uint32_t force_wakeup_by_tps3 : 1; 207 } bitfields; 208 209 /** 210 * Union for debug flags. 211 */ 212 uint32_t u32All; 213 }; 214 215 /** 216 * DMUB feature capabilities. 217 * After DMUB init, driver will query FW capabilities prior to enabling certain features. 218 */ 219 struct dmub_feature_caps { 220 /** 221 * Max PSR version supported by FW. 222 */ 223 uint8_t psr; 224 uint8_t reserved[7]; 225 }; 226 227 #if defined(__cplusplus) 228 } 229 #endif 230 231 //============================================================================== 232 //</DMUB_TYPES>================================================================= 233 //============================================================================== 234 //< DMUB_META>================================================================== 235 //============================================================================== 236 #pragma pack(push, 1) 237 238 /* Magic value for identifying dmub_fw_meta_info */ 239 #define DMUB_FW_META_MAGIC 0x444D5542 240 241 /* Offset from the end of the file to the dmub_fw_meta_info */ 242 #define DMUB_FW_META_OFFSET 0x24 243 244 /** 245 * struct dmub_fw_meta_info - metadata associated with fw binary 246 * 247 * NOTE: This should be considered a stable API. Fields should 248 * not be repurposed or reordered. New fields should be 249 * added instead to extend the structure. 250 * 251 * @magic_value: magic value identifying DMUB firmware meta info 252 * @fw_region_size: size of the firmware state region 253 * @trace_buffer_size: size of the tracebuffer region 254 * @fw_version: the firmware version information 255 * @dal_fw: 1 if the firmware is DAL 256 */ 257 struct dmub_fw_meta_info { 258 uint32_t magic_value; /**< magic value identifying DMUB firmware meta info */ 259 uint32_t fw_region_size; /**< size of the firmware state region */ 260 uint32_t trace_buffer_size; /**< size of the tracebuffer region */ 261 uint32_t fw_version; /**< the firmware version information */ 262 uint8_t dal_fw; /**< 1 if the firmware is DAL */ 263 uint8_t reserved[3]; /**< padding bits */ 264 }; 265 266 /** 267 * union dmub_fw_meta - ensures that dmub_fw_meta_info remains 64 bytes 268 */ 269 union dmub_fw_meta { 270 struct dmub_fw_meta_info info; /**< metadata info */ 271 uint8_t reserved[64]; /**< padding bits */ 272 }; 273 274 #pragma pack(pop) 275 276 //============================================================================== 277 //< DMUB Trace Buffer>================================================================ 278 //============================================================================== 279 /** 280 * dmub_trace_code_t - firmware trace code, 32-bits 281 */ 282 typedef uint32_t dmub_trace_code_t; 283 284 /** 285 * struct dmcub_trace_buf_entry - Firmware trace entry 286 */ 287 struct dmcub_trace_buf_entry { 288 dmub_trace_code_t trace_code; /**< trace code for the event */ 289 uint32_t tick_count; /**< the tick count at time of trace */ 290 uint32_t param0; /**< trace defined parameter 0 */ 291 uint32_t param1; /**< trace defined parameter 1 */ 292 }; 293 294 //============================================================================== 295 //< DMUB_STATUS>================================================================ 296 //============================================================================== 297 298 /** 299 * DMCUB scratch registers can be used to determine firmware status. 300 * Current scratch register usage is as follows: 301 * 302 * SCRATCH0: FW Boot Status register 303 * SCRATCH5: LVTMA Status Register 304 * SCRATCH15: FW Boot Options register 305 */ 306 307 /** 308 * union dmub_fw_boot_status - Status bit definitions for SCRATCH0. 309 */ 310 union dmub_fw_boot_status { 311 struct { 312 uint32_t dal_fw : 1; /**< 1 if DAL FW */ 313 uint32_t mailbox_rdy : 1; /**< 1 if mailbox ready */ 314 uint32_t optimized_init_done : 1; /**< 1 if optimized init done */ 315 uint32_t restore_required : 1; /**< 1 if driver should call restore */ 316 uint32_t defer_load : 1; /**< 1 if VBIOS data is deferred programmed */ 317 uint32_t reserved : 1; 318 uint32_t detection_required: 1; /**< if detection need to be triggered by driver */ 319 320 } bits; /**< status bits */ 321 uint32_t all; /**< 32-bit access to status bits */ 322 }; 323 324 /** 325 * enum dmub_fw_boot_status_bit - Enum bit definitions for SCRATCH0. 326 */ 327 enum dmub_fw_boot_status_bit { 328 DMUB_FW_BOOT_STATUS_BIT_DAL_FIRMWARE = (1 << 0), /**< 1 if DAL FW */ 329 DMUB_FW_BOOT_STATUS_BIT_MAILBOX_READY = (1 << 1), /**< 1 if mailbox ready */ 330 DMUB_FW_BOOT_STATUS_BIT_OPTIMIZED_INIT_DONE = (1 << 2), /**< 1 if init done */ 331 DMUB_FW_BOOT_STATUS_BIT_RESTORE_REQUIRED = (1 << 3), /**< 1 if driver should call restore */ 332 DMUB_FW_BOOT_STATUS_BIT_DEFERRED_LOADED = (1 << 4), /**< 1 if VBIOS data is deferred programmed */ 333 DMUB_FW_BOOT_STATUS_BIT_DETECTION_REQUIRED = (1 << 6), /**< 1 if detection need to be triggered by driver*/ 334 }; 335 336 /* Register bit definition for SCRATCH5 */ 337 union dmub_lvtma_status { 338 struct { 339 uint32_t psp_ok : 1; 340 uint32_t edp_on : 1; 341 uint32_t reserved : 30; 342 } bits; 343 uint32_t all; 344 }; 345 346 enum dmub_lvtma_status_bit { 347 DMUB_LVTMA_STATUS_BIT_PSP_OK = (1 << 0), 348 DMUB_LVTMA_STATUS_BIT_EDP_ON = (1 << 1), 349 }; 350 351 /** 352 * union dmub_fw_boot_options - Boot option definitions for SCRATCH14 353 */ 354 union dmub_fw_boot_options { 355 struct { 356 uint32_t pemu_env : 1; /**< 1 if PEMU */ 357 uint32_t fpga_env : 1; /**< 1 if FPGA */ 358 uint32_t optimized_init : 1; /**< 1 if optimized init */ 359 uint32_t skip_phy_access : 1; /**< 1 if PHY access should be skipped */ 360 uint32_t disable_clk_gate: 1; /**< 1 if clock gating should be disabled */ 361 uint32_t skip_phy_init_panel_sequence: 1; /**< 1 to skip panel init seq */ 362 uint32_t z10_disable: 1; /**< 1 to disable z10 */ 363 uint32_t enable_dpia: 1; /**< 1 if DPIA should be enabled */ 364 uint32_t invalid_vbios_data: 1; /**< 1 if VBIOS data table is invalid */ 365 uint32_t dpia_supported: 1; /**< 1 if DPIA is supported on this platform */ 366 uint32_t sel_mux_phy_c_d_phy_f_g: 1; /**< 1 if PHYF/PHYG should be enabled */ 367 /**< 1 if all root clock gating is enabled and low power memory is enabled*/ 368 uint32_t power_optimization: 1; 369 uint32_t diag_env: 1; /* 1 if diagnostic environment */ 370 371 uint32_t reserved : 19; /**< reserved */ 372 } bits; /**< boot bits */ 373 uint32_t all; /**< 32-bit access to bits */ 374 }; 375 376 enum dmub_fw_boot_options_bit { 377 DMUB_FW_BOOT_OPTION_BIT_PEMU_ENV = (1 << 0), /**< 1 if PEMU */ 378 DMUB_FW_BOOT_OPTION_BIT_FPGA_ENV = (1 << 1), /**< 1 if FPGA */ 379 DMUB_FW_BOOT_OPTION_BIT_OPTIMIZED_INIT_DONE = (1 << 2), /**< 1 if optimized init done */ 380 }; 381 382 //============================================================================== 383 //</DMUB_STATUS>================================================================ 384 //============================================================================== 385 //< DMUB_VBIOS>================================================================= 386 //============================================================================== 387 388 /* 389 * enum dmub_cmd_vbios_type - VBIOS commands. 390 * 391 * Command IDs should be treated as stable ABI. 392 * Do not reuse or modify IDs. 393 */ 394 enum dmub_cmd_vbios_type { 395 /** 396 * Configures the DIG encoder. 397 */ 398 DMUB_CMD__VBIOS_DIGX_ENCODER_CONTROL = 0, 399 /** 400 * Controls the PHY. 401 */ 402 DMUB_CMD__VBIOS_DIG1_TRANSMITTER_CONTROL = 1, 403 /** 404 * Sets the pixel clock/symbol clock. 405 */ 406 DMUB_CMD__VBIOS_SET_PIXEL_CLOCK = 2, 407 /** 408 * Enables or disables power gating. 409 */ 410 DMUB_CMD__VBIOS_ENABLE_DISP_POWER_GATING = 3, 411 /** 412 * Controls embedded panels. 413 */ 414 DMUB_CMD__VBIOS_LVTMA_CONTROL = 15, 415 /** 416 * Query DP alt status on a transmitter. 417 */ 418 DMUB_CMD__VBIOS_TRANSMITTER_QUERY_DP_ALT = 26, 419 }; 420 421 //============================================================================== 422 //</DMUB_VBIOS>================================================================= 423 //============================================================================== 424 //< DMUB_GPINT>================================================================= 425 //============================================================================== 426 427 /** 428 * The shifts and masks below may alternatively be used to format and read 429 * the command register bits. 430 */ 431 432 #define DMUB_GPINT_DATA_PARAM_MASK 0xFFFF 433 #define DMUB_GPINT_DATA_PARAM_SHIFT 0 434 435 #define DMUB_GPINT_DATA_COMMAND_CODE_MASK 0xFFF 436 #define DMUB_GPINT_DATA_COMMAND_CODE_SHIFT 16 437 438 #define DMUB_GPINT_DATA_STATUS_MASK 0xF 439 #define DMUB_GPINT_DATA_STATUS_SHIFT 28 440 441 /** 442 * Command responses. 443 */ 444 445 /** 446 * Return response for DMUB_GPINT__STOP_FW command. 447 */ 448 #define DMUB_GPINT__STOP_FW_RESPONSE 0xDEADDEAD 449 450 /** 451 * union dmub_gpint_data_register - Format for sending a command via the GPINT. 452 */ 453 union dmub_gpint_data_register { 454 struct { 455 uint32_t param : 16; /**< 16-bit parameter */ 456 uint32_t command_code : 12; /**< GPINT command */ 457 uint32_t status : 4; /**< Command status bit */ 458 } bits; /**< GPINT bit access */ 459 uint32_t all; /**< GPINT 32-bit access */ 460 }; 461 462 /* 463 * enum dmub_gpint_command - GPINT command to DMCUB FW 464 * 465 * Command IDs should be treated as stable ABI. 466 * Do not reuse or modify IDs. 467 */ 468 enum dmub_gpint_command { 469 /** 470 * Invalid command, ignored. 471 */ 472 DMUB_GPINT__INVALID_COMMAND = 0, 473 /** 474 * DESC: Queries the firmware version. 475 * RETURN: Firmware version. 476 */ 477 DMUB_GPINT__GET_FW_VERSION = 1, 478 /** 479 * DESC: Halts the firmware. 480 * RETURN: DMUB_GPINT__STOP_FW_RESPONSE (0xDEADDEAD) when halted 481 */ 482 DMUB_GPINT__STOP_FW = 2, 483 /** 484 * DESC: Get PSR state from FW. 485 * RETURN: PSR state enum. This enum may need to be converted to the legacy PSR state value. 486 */ 487 DMUB_GPINT__GET_PSR_STATE = 7, 488 /** 489 * DESC: Notifies DMCUB of the currently active streams. 490 * ARGS: Stream mask, 1 bit per active stream index. 491 */ 492 DMUB_GPINT__IDLE_OPT_NOTIFY_STREAM_MASK = 8, 493 /** 494 * DESC: Start PSR residency counter. Stop PSR resdiency counter and get value. 495 * ARGS: We can measure residency from various points. The argument will specify the residency mode. 496 * By default, it is measured from after we powerdown the PHY, to just before we powerup the PHY. 497 * RETURN: PSR residency in milli-percent. 498 */ 499 DMUB_GPINT__PSR_RESIDENCY = 9, 500 501 /** 502 * DESC: Notifies DMCUB detection is done so detection required can be cleared. 503 */ 504 DMUB_GPINT__NOTIFY_DETECTION_DONE = 12, 505 }; 506 507 /** 508 * INBOX0 generic command definition 509 */ 510 union dmub_inbox0_cmd_common { 511 struct { 512 uint32_t command_code: 8; /**< INBOX0 command code */ 513 uint32_t param: 24; /**< 24-bit parameter */ 514 } bits; 515 uint32_t all; 516 }; 517 518 /** 519 * INBOX0 hw_lock command definition 520 */ 521 union dmub_inbox0_cmd_lock_hw { 522 struct { 523 uint32_t command_code: 8; 524 525 /* NOTE: Must be have enough bits to match: enum hw_lock_client */ 526 uint32_t hw_lock_client: 1; 527 528 /* NOTE: Below fields must match with: struct dmub_hw_lock_inst_flags */ 529 uint32_t otg_inst: 3; 530 uint32_t opp_inst: 3; 531 uint32_t dig_inst: 3; 532 533 /* NOTE: Below fields must match with: union dmub_hw_lock_flags */ 534 uint32_t lock_pipe: 1; 535 uint32_t lock_cursor: 1; 536 uint32_t lock_dig: 1; 537 uint32_t triple_buffer_lock: 1; 538 539 uint32_t lock: 1; /**< Lock */ 540 uint32_t should_release: 1; /**< Release */ 541 uint32_t reserved: 8; /**< Reserved for extending more clients, HW, etc. */ 542 } bits; 543 uint32_t all; 544 }; 545 546 union dmub_inbox0_data_register { 547 union dmub_inbox0_cmd_common inbox0_cmd_common; 548 union dmub_inbox0_cmd_lock_hw inbox0_cmd_lock_hw; 549 }; 550 551 enum dmub_inbox0_command { 552 /** 553 * DESC: Invalid command, ignored. 554 */ 555 DMUB_INBOX0_CMD__INVALID_COMMAND = 0, 556 /** 557 * DESC: Notification to acquire/release HW lock 558 * ARGS: 559 */ 560 DMUB_INBOX0_CMD__HW_LOCK = 1, 561 }; 562 //============================================================================== 563 //</DMUB_GPINT>================================================================= 564 //============================================================================== 565 //< DMUB_CMD>=================================================================== 566 //============================================================================== 567 568 /** 569 * Size in bytes of each DMUB command. 570 */ 571 #define DMUB_RB_CMD_SIZE 64 572 573 /** 574 * Maximum number of items in the DMUB ringbuffer. 575 */ 576 #define DMUB_RB_MAX_ENTRY 128 577 578 /** 579 * Ringbuffer size in bytes. 580 */ 581 #define DMUB_RB_SIZE (DMUB_RB_CMD_SIZE * DMUB_RB_MAX_ENTRY) 582 583 /** 584 * REG_SET mask for reg offload. 585 */ 586 #define REG_SET_MASK 0xFFFF 587 588 /* 589 * enum dmub_cmd_type - DMUB inbox command. 590 * 591 * Command IDs should be treated as stable ABI. 592 * Do not reuse or modify IDs. 593 */ 594 enum dmub_cmd_type { 595 /** 596 * Invalid command. 597 */ 598 DMUB_CMD__NULL = 0, 599 /** 600 * Read modify write register sequence offload. 601 */ 602 DMUB_CMD__REG_SEQ_READ_MODIFY_WRITE = 1, 603 /** 604 * Field update register sequence offload. 605 */ 606 DMUB_CMD__REG_SEQ_FIELD_UPDATE_SEQ = 2, 607 /** 608 * Burst write sequence offload. 609 */ 610 DMUB_CMD__REG_SEQ_BURST_WRITE = 3, 611 /** 612 * Reg wait sequence offload. 613 */ 614 DMUB_CMD__REG_REG_WAIT = 4, 615 /** 616 * Workaround to avoid HUBP underflow during NV12 playback. 617 */ 618 DMUB_CMD__PLAT_54186_WA = 5, 619 /** 620 * Command type used to query FW feature caps. 621 */ 622 DMUB_CMD__QUERY_FEATURE_CAPS = 6, 623 /** 624 * Command type used for all PSR commands. 625 */ 626 DMUB_CMD__PSR = 64, 627 /** 628 * Command type used for all MALL commands. 629 */ 630 DMUB_CMD__MALL = 65, 631 /** 632 * Command type used for all ABM commands. 633 */ 634 DMUB_CMD__ABM = 66, 635 /** 636 * Command type used for HW locking in FW. 637 */ 638 DMUB_CMD__HW_LOCK = 69, 639 /** 640 * Command type used to access DP AUX. 641 */ 642 DMUB_CMD__DP_AUX_ACCESS = 70, 643 /** 644 * Command type used for OUTBOX1 notification enable 645 */ 646 DMUB_CMD__OUTBOX1_ENABLE = 71, 647 /** 648 * Command type used for all idle optimization commands. 649 */ 650 DMUB_CMD__IDLE_OPT = 72, 651 /** 652 * Command type used for all clock manager commands. 653 */ 654 DMUB_CMD__CLK_MGR = 73, 655 /** 656 * Command type used for all panel control commands. 657 */ 658 DMUB_CMD__PANEL_CNTL = 74, 659 /** 660 * Command type used for interfacing with DPIA. 661 */ 662 DMUB_CMD__DPIA = 77, 663 /** 664 * Command type used for EDID CEA parsing 665 */ 666 DMUB_CMD__EDID_CEA = 79, 667 /** 668 * Command type used for all VBIOS interface commands. 669 */ 670 DMUB_CMD__VBIOS = 128, 671 }; 672 673 /** 674 * enum dmub_out_cmd_type - DMUB outbox commands. 675 */ 676 enum dmub_out_cmd_type { 677 /** 678 * Invalid outbox command, ignored. 679 */ 680 DMUB_OUT_CMD__NULL = 0, 681 /** 682 * Command type used for DP AUX Reply data notification 683 */ 684 DMUB_OUT_CMD__DP_AUX_REPLY = 1, 685 /** 686 * Command type used for DP HPD event notification 687 */ 688 DMUB_OUT_CMD__DP_HPD_NOTIFY = 2, 689 /** 690 * Command type used for SET_CONFIG Reply notification 691 */ 692 DMUB_OUT_CMD__SET_CONFIG_REPLY = 3, 693 }; 694 695 /* DMUB_CMD__DPIA command sub-types. */ 696 enum dmub_cmd_dpia_type { 697 DMUB_CMD__DPIA_DIG1_DPIA_CONTROL = 0, 698 DMUB_CMD__DPIA_SET_CONFIG_ACCESS = 1, 699 DMUB_CMD__DPIA_MST_ALLOC_SLOTS = 2, 700 }; 701 702 #pragma pack(push, 1) 703 704 /** 705 * struct dmub_cmd_header - Common command header fields. 706 */ 707 struct dmub_cmd_header { 708 unsigned int type : 8; /**< command type */ 709 unsigned int sub_type : 8; /**< command sub type */ 710 unsigned int ret_status : 1; /**< 1 if returned data, 0 otherwise */ 711 unsigned int multi_cmd_pending : 1; /**< 1 if multiple commands chained together */ 712 unsigned int reserved0 : 6; /**< reserved bits */ 713 unsigned int payload_bytes : 6; /* payload excluding header - up to 60 bytes */ 714 unsigned int reserved1 : 2; /**< reserved bits */ 715 }; 716 717 /* 718 * struct dmub_cmd_read_modify_write_sequence - Read modify write 719 * 720 * 60 payload bytes can hold up to 5 sets of read modify writes, 721 * each take 3 dwords. 722 * 723 * number of sequences = header.payload_bytes / sizeof(struct dmub_cmd_read_modify_write_sequence) 724 * 725 * modify_mask = 0xffff'ffff means all fields are going to be updated. in this case 726 * command parser will skip the read and we can use modify_mask = 0xffff'ffff as reg write 727 */ 728 struct dmub_cmd_read_modify_write_sequence { 729 uint32_t addr; /**< register address */ 730 uint32_t modify_mask; /**< modify mask */ 731 uint32_t modify_value; /**< modify value */ 732 }; 733 734 /** 735 * Maximum number of ops in read modify write sequence. 736 */ 737 #define DMUB_READ_MODIFY_WRITE_SEQ__MAX 5 738 739 /** 740 * struct dmub_cmd_read_modify_write_sequence - Read modify write command. 741 */ 742 struct dmub_rb_cmd_read_modify_write { 743 struct dmub_cmd_header header; /**< command header */ 744 /** 745 * Read modify write sequence. 746 */ 747 struct dmub_cmd_read_modify_write_sequence seq[DMUB_READ_MODIFY_WRITE_SEQ__MAX]; 748 }; 749 750 /* 751 * Update a register with specified masks and values sequeunce 752 * 753 * 60 payload bytes can hold address + up to 7 sets of mask/value combo, each take 2 dword 754 * 755 * number of field update sequence = (header.payload_bytes - sizeof(addr)) / sizeof(struct read_modify_write_sequence) 756 * 757 * 758 * USE CASE: 759 * 1. auto-increment register where additional read would update pointer and produce wrong result 760 * 2. toggle a bit without read in the middle 761 */ 762 763 struct dmub_cmd_reg_field_update_sequence { 764 uint32_t modify_mask; /**< 0xffff'ffff to skip initial read */ 765 uint32_t modify_value; /**< value to update with */ 766 }; 767 768 /** 769 * Maximum number of ops in field update sequence. 770 */ 771 #define DMUB_REG_FIELD_UPDATE_SEQ__MAX 7 772 773 /** 774 * struct dmub_rb_cmd_reg_field_update_sequence - Field update command. 775 */ 776 struct dmub_rb_cmd_reg_field_update_sequence { 777 struct dmub_cmd_header header; /**< command header */ 778 uint32_t addr; /**< register address */ 779 /** 780 * Field update sequence. 781 */ 782 struct dmub_cmd_reg_field_update_sequence seq[DMUB_REG_FIELD_UPDATE_SEQ__MAX]; 783 }; 784 785 786 /** 787 * Maximum number of burst write values. 788 */ 789 #define DMUB_BURST_WRITE_VALUES__MAX 14 790 791 /* 792 * struct dmub_rb_cmd_burst_write - Burst write 793 * 794 * support use case such as writing out LUTs. 795 * 796 * 60 payload bytes can hold up to 14 values to write to given address 797 * 798 * number of payload = header.payload_bytes / sizeof(struct read_modify_write_sequence) 799 */ 800 struct dmub_rb_cmd_burst_write { 801 struct dmub_cmd_header header; /**< command header */ 802 uint32_t addr; /**< register start address */ 803 /** 804 * Burst write register values. 805 */ 806 uint32_t write_values[DMUB_BURST_WRITE_VALUES__MAX]; 807 }; 808 809 /** 810 * struct dmub_rb_cmd_common - Common command header 811 */ 812 struct dmub_rb_cmd_common { 813 struct dmub_cmd_header header; /**< command header */ 814 /** 815 * Padding to RB_CMD_SIZE 816 */ 817 uint8_t cmd_buffer[DMUB_RB_CMD_SIZE - sizeof(struct dmub_cmd_header)]; 818 }; 819 820 /** 821 * struct dmub_cmd_reg_wait_data - Register wait data 822 */ 823 struct dmub_cmd_reg_wait_data { 824 uint32_t addr; /**< Register address */ 825 uint32_t mask; /**< Mask for register bits */ 826 uint32_t condition_field_value; /**< Value to wait for */ 827 uint32_t time_out_us; /**< Time out for reg wait in microseconds */ 828 }; 829 830 /** 831 * struct dmub_rb_cmd_reg_wait - Register wait command 832 */ 833 struct dmub_rb_cmd_reg_wait { 834 struct dmub_cmd_header header; /**< Command header */ 835 struct dmub_cmd_reg_wait_data reg_wait; /**< Register wait data */ 836 }; 837 838 /** 839 * struct dmub_cmd_PLAT_54186_wa - Underflow workaround 840 * 841 * Reprograms surface parameters to avoid underflow. 842 */ 843 struct dmub_cmd_PLAT_54186_wa { 844 uint32_t DCSURF_SURFACE_CONTROL; /**< reg value */ 845 uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS_HIGH; /**< reg value */ 846 uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS; /**< reg value */ 847 uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS_HIGH_C; /**< reg value */ 848 uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS_C; /**< reg value */ 849 struct { 850 uint8_t hubp_inst : 4; /**< HUBP instance */ 851 uint8_t tmz_surface : 1; /**< TMZ enable or disable */ 852 uint8_t immediate :1; /**< Immediate flip */ 853 uint8_t vmid : 4; /**< VMID */ 854 uint8_t grph_stereo : 1; /**< 1 if stereo */ 855 uint32_t reserved : 21; /**< Reserved */ 856 } flip_params; /**< Pageflip parameters */ 857 uint32_t reserved[9]; /**< Reserved bits */ 858 }; 859 860 /** 861 * struct dmub_rb_cmd_PLAT_54186_wa - Underflow workaround command 862 */ 863 struct dmub_rb_cmd_PLAT_54186_wa { 864 struct dmub_cmd_header header; /**< Command header */ 865 struct dmub_cmd_PLAT_54186_wa flip; /**< Flip data */ 866 }; 867 868 /** 869 * struct dmub_rb_cmd_mall - MALL command data. 870 */ 871 struct dmub_rb_cmd_mall { 872 struct dmub_cmd_header header; /**< Common command header */ 873 union dmub_addr cursor_copy_src; /**< Cursor copy address */ 874 union dmub_addr cursor_copy_dst; /**< Cursor copy destination */ 875 uint32_t tmr_delay; /**< Timer delay */ 876 uint32_t tmr_scale; /**< Timer scale */ 877 uint16_t cursor_width; /**< Cursor width in pixels */ 878 uint16_t cursor_pitch; /**< Cursor pitch in pixels */ 879 uint16_t cursor_height; /**< Cursor height in pixels */ 880 uint8_t cursor_bpp; /**< Cursor bits per pixel */ 881 uint8_t debug_bits; /**< Debug bits */ 882 883 uint8_t reserved1; /**< Reserved bits */ 884 uint8_t reserved2; /**< Reserved bits */ 885 }; 886 887 /** 888 * enum dmub_cmd_idle_opt_type - Idle optimization command type. 889 */ 890 enum dmub_cmd_idle_opt_type { 891 /** 892 * DCN hardware restore. 893 */ 894 DMUB_CMD__IDLE_OPT_DCN_RESTORE = 0, 895 896 /** 897 * DCN hardware save. 898 */ 899 DMUB_CMD__IDLE_OPT_DCN_SAVE_INIT = 1 900 }; 901 902 /** 903 * struct dmub_rb_cmd_idle_opt_dcn_restore - DCN restore command data. 904 */ 905 struct dmub_rb_cmd_idle_opt_dcn_restore { 906 struct dmub_cmd_header header; /**< header */ 907 }; 908 909 /** 910 * struct dmub_clocks - Clock update notification. 911 */ 912 struct dmub_clocks { 913 uint32_t dispclk_khz; /**< dispclk kHz */ 914 uint32_t dppclk_khz; /**< dppclk kHz */ 915 uint32_t dcfclk_khz; /**< dcfclk kHz */ 916 uint32_t dcfclk_deep_sleep_khz; /**< dcfclk deep sleep kHz */ 917 }; 918 919 /** 920 * enum dmub_cmd_clk_mgr_type - Clock manager commands. 921 */ 922 enum dmub_cmd_clk_mgr_type { 923 /** 924 * Notify DMCUB of clock update. 925 */ 926 DMUB_CMD__CLK_MGR_NOTIFY_CLOCKS = 0, 927 }; 928 929 /** 930 * struct dmub_rb_cmd_clk_mgr_notify_clocks - Clock update notification. 931 */ 932 struct dmub_rb_cmd_clk_mgr_notify_clocks { 933 struct dmub_cmd_header header; /**< header */ 934 struct dmub_clocks clocks; /**< clock data */ 935 }; 936 937 /** 938 * struct dmub_cmd_digx_encoder_control_data - Encoder control data. 939 */ 940 struct dmub_cmd_digx_encoder_control_data { 941 union dig_encoder_control_parameters_v1_5 dig; /**< payload */ 942 }; 943 944 /** 945 * struct dmub_rb_cmd_digx_encoder_control - Encoder control command. 946 */ 947 struct dmub_rb_cmd_digx_encoder_control { 948 struct dmub_cmd_header header; /**< header */ 949 struct dmub_cmd_digx_encoder_control_data encoder_control; /**< payload */ 950 }; 951 952 /** 953 * struct dmub_cmd_set_pixel_clock_data - Set pixel clock data. 954 */ 955 struct dmub_cmd_set_pixel_clock_data { 956 struct set_pixel_clock_parameter_v1_7 clk; /**< payload */ 957 }; 958 959 /** 960 * struct dmub_cmd_set_pixel_clock_data - Set pixel clock command. 961 */ 962 struct dmub_rb_cmd_set_pixel_clock { 963 struct dmub_cmd_header header; /**< header */ 964 struct dmub_cmd_set_pixel_clock_data pixel_clock; /**< payload */ 965 }; 966 967 /** 968 * struct dmub_cmd_enable_disp_power_gating_data - Display power gating. 969 */ 970 struct dmub_cmd_enable_disp_power_gating_data { 971 struct enable_disp_power_gating_parameters_v2_1 pwr; /**< payload */ 972 }; 973 974 /** 975 * struct dmub_rb_cmd_enable_disp_power_gating - Display power command. 976 */ 977 struct dmub_rb_cmd_enable_disp_power_gating { 978 struct dmub_cmd_header header; /**< header */ 979 struct dmub_cmd_enable_disp_power_gating_data power_gating; /**< payload */ 980 }; 981 982 /** 983 * struct dmub_dig_transmitter_control_data_v1_7 - Transmitter control. 984 */ 985 struct dmub_dig_transmitter_control_data_v1_7 { 986 uint8_t phyid; /**< 0=UNIPHYA, 1=UNIPHYB, 2=UNIPHYC, 3=UNIPHYD, 4=UNIPHYE, 5=UNIPHYF */ 987 uint8_t action; /**< Defined as ATOM_TRANSMITER_ACTION_xxx */ 988 union { 989 uint8_t digmode; /**< enum atom_encode_mode_def */ 990 uint8_t dplaneset; /**< DP voltage swing and pre-emphasis value, "DP_LANE_SET__xDB_y_zV" */ 991 } mode_laneset; 992 uint8_t lanenum; /**< Number of lanes */ 993 union { 994 uint32_t symclk_10khz; /**< Symbol Clock in 10Khz */ 995 } symclk_units; 996 uint8_t hpdsel; /**< =1: HPD1, =2: HPD2, ..., =6: HPD6, =0: HPD is not assigned */ 997 uint8_t digfe_sel; /**< DIG front-end selection, bit0 means DIG0 FE is enabled */ 998 uint8_t connobj_id; /**< Connector Object Id defined in ObjectId.h */ 999 uint8_t HPO_instance; /**< HPO instance (0: inst0, 1: inst1) */ 1000 uint8_t reserved1; /**< For future use */ 1001 uint8_t reserved2[3]; /**< For future use */ 1002 uint32_t reserved3[11]; /**< For future use */ 1003 }; 1004 1005 /** 1006 * union dmub_cmd_dig1_transmitter_control_data - Transmitter control data. 1007 */ 1008 union dmub_cmd_dig1_transmitter_control_data { 1009 struct dig_transmitter_control_parameters_v1_6 dig; /**< payload */ 1010 struct dmub_dig_transmitter_control_data_v1_7 dig_v1_7; /**< payload 1.7 */ 1011 }; 1012 1013 /** 1014 * struct dmub_rb_cmd_dig1_transmitter_control - Transmitter control command. 1015 */ 1016 struct dmub_rb_cmd_dig1_transmitter_control { 1017 struct dmub_cmd_header header; /**< header */ 1018 union dmub_cmd_dig1_transmitter_control_data transmitter_control; /**< payload */ 1019 }; 1020 1021 /** 1022 * DPIA tunnel command parameters. 1023 */ 1024 struct dmub_cmd_dig_dpia_control_data { 1025 uint8_t enc_id; /** 0 = ENGINE_ID_DIGA, ... */ 1026 uint8_t action; /** ATOM_TRANSMITER_ACTION_DISABLE/ENABLE/SETUP_VSEMPH */ 1027 union { 1028 uint8_t digmode; /** enum atom_encode_mode_def */ 1029 uint8_t dplaneset; /** DP voltage swing and pre-emphasis value */ 1030 } mode_laneset; 1031 uint8_t lanenum; /** Lane number 1, 2, 4, 8 */ 1032 uint32_t symclk_10khz; /** Symbol Clock in 10Khz */ 1033 uint8_t hpdsel; /** =0: HPD is not assigned */ 1034 uint8_t digfe_sel; /** DIG stream( front-end ) selection, bit0 - DIG0 FE */ 1035 uint8_t dpia_id; /** Index of DPIA */ 1036 uint8_t fec_rdy : 1; 1037 uint8_t reserved : 7; 1038 uint32_t reserved1; 1039 }; 1040 1041 /** 1042 * DMUB command for DPIA tunnel control. 1043 */ 1044 struct dmub_rb_cmd_dig1_dpia_control { 1045 struct dmub_cmd_header header; 1046 struct dmub_cmd_dig_dpia_control_data dpia_control; 1047 }; 1048 1049 /** 1050 * SET_CONFIG Command Payload 1051 */ 1052 struct set_config_cmd_payload { 1053 uint8_t msg_type; /* set config message type */ 1054 uint8_t msg_data; /* set config message data */ 1055 }; 1056 1057 /** 1058 * Data passed from driver to FW in a DMUB_CMD__DPIA_SET_CONFIG_ACCESS command. 1059 */ 1060 struct dmub_cmd_set_config_control_data { 1061 struct set_config_cmd_payload cmd_pkt; 1062 uint8_t instance; /* DPIA instance */ 1063 uint8_t immed_status; /* Immediate status returned in case of error */ 1064 }; 1065 1066 /** 1067 * DMUB command structure for SET_CONFIG command. 1068 */ 1069 struct dmub_rb_cmd_set_config_access { 1070 struct dmub_cmd_header header; /* header */ 1071 struct dmub_cmd_set_config_control_data set_config_control; /* set config data */ 1072 }; 1073 1074 /** 1075 * Data passed from driver to FW in a DMUB_CMD__DPIA_MST_ALLOC_SLOTS command. 1076 */ 1077 struct dmub_cmd_mst_alloc_slots_control_data { 1078 uint8_t mst_alloc_slots; /* mst slots to be allotted */ 1079 uint8_t instance; /* DPIA instance */ 1080 uint8_t immed_status; /* Immediate status returned as there is no outbox msg posted */ 1081 uint8_t mst_slots_in_use; /* returns slots in use for error cases */ 1082 }; 1083 1084 /** 1085 * DMUB command structure for SET_ command. 1086 */ 1087 struct dmub_rb_cmd_set_mst_alloc_slots { 1088 struct dmub_cmd_header header; /* header */ 1089 struct dmub_cmd_mst_alloc_slots_control_data mst_slots_control; /* mst slots control */ 1090 }; 1091 1092 /** 1093 * struct dmub_rb_cmd_dpphy_init - DPPHY init. 1094 */ 1095 struct dmub_rb_cmd_dpphy_init { 1096 struct dmub_cmd_header header; /**< header */ 1097 uint8_t reserved[60]; /**< reserved bits */ 1098 }; 1099 1100 /** 1101 * enum dp_aux_request_action - DP AUX request command listing. 1102 * 1103 * 4 AUX request command bits are shifted to high nibble. 1104 */ 1105 enum dp_aux_request_action { 1106 /** I2C-over-AUX write request */ 1107 DP_AUX_REQ_ACTION_I2C_WRITE = 0x00, 1108 /** I2C-over-AUX read request */ 1109 DP_AUX_REQ_ACTION_I2C_READ = 0x10, 1110 /** I2C-over-AUX write status request */ 1111 DP_AUX_REQ_ACTION_I2C_STATUS_REQ = 0x20, 1112 /** I2C-over-AUX write request with MOT=1 */ 1113 DP_AUX_REQ_ACTION_I2C_WRITE_MOT = 0x40, 1114 /** I2C-over-AUX read request with MOT=1 */ 1115 DP_AUX_REQ_ACTION_I2C_READ_MOT = 0x50, 1116 /** I2C-over-AUX write status request with MOT=1 */ 1117 DP_AUX_REQ_ACTION_I2C_STATUS_REQ_MOT = 0x60, 1118 /** Native AUX write request */ 1119 DP_AUX_REQ_ACTION_DPCD_WRITE = 0x80, 1120 /** Native AUX read request */ 1121 DP_AUX_REQ_ACTION_DPCD_READ = 0x90 1122 }; 1123 1124 /** 1125 * enum aux_return_code_type - DP AUX process return code listing. 1126 */ 1127 enum aux_return_code_type { 1128 /** AUX process succeeded */ 1129 AUX_RET_SUCCESS = 0, 1130 /** AUX process failed with unknown reason */ 1131 AUX_RET_ERROR_UNKNOWN, 1132 /** AUX process completed with invalid reply */ 1133 AUX_RET_ERROR_INVALID_REPLY, 1134 /** AUX process timed out */ 1135 AUX_RET_ERROR_TIMEOUT, 1136 /** HPD was low during AUX process */ 1137 AUX_RET_ERROR_HPD_DISCON, 1138 /** Failed to acquire AUX engine */ 1139 AUX_RET_ERROR_ENGINE_ACQUIRE, 1140 /** AUX request not supported */ 1141 AUX_RET_ERROR_INVALID_OPERATION, 1142 /** AUX process not available */ 1143 AUX_RET_ERROR_PROTOCOL_ERROR, 1144 }; 1145 1146 /** 1147 * enum aux_channel_type - DP AUX channel type listing. 1148 */ 1149 enum aux_channel_type { 1150 /** AUX thru Legacy DP AUX */ 1151 AUX_CHANNEL_LEGACY_DDC, 1152 /** AUX thru DPIA DP tunneling */ 1153 AUX_CHANNEL_DPIA 1154 }; 1155 1156 /** 1157 * struct aux_transaction_parameters - DP AUX request transaction data 1158 */ 1159 struct aux_transaction_parameters { 1160 uint8_t is_i2c_over_aux; /**< 0=native AUX, 1=I2C-over-AUX */ 1161 uint8_t action; /**< enum dp_aux_request_action */ 1162 uint8_t length; /**< DP AUX request data length */ 1163 uint8_t reserved; /**< For future use */ 1164 uint32_t address; /**< DP AUX address */ 1165 uint8_t data[16]; /**< DP AUX write data */ 1166 }; 1167 1168 /** 1169 * Data passed from driver to FW in a DMUB_CMD__DP_AUX_ACCESS command. 1170 */ 1171 struct dmub_cmd_dp_aux_control_data { 1172 uint8_t instance; /**< AUX instance or DPIA instance */ 1173 uint8_t manual_acq_rel_enable; /**< manual control for acquiring or releasing AUX channel */ 1174 uint8_t sw_crc_enabled; /**< Use software CRC for tunneling packet instead of hardware CRC */ 1175 uint8_t reserved0; /**< For future use */ 1176 uint16_t timeout; /**< timeout time in us */ 1177 uint16_t reserved1; /**< For future use */ 1178 enum aux_channel_type type; /**< enum aux_channel_type */ 1179 struct aux_transaction_parameters dpaux; /**< struct aux_transaction_parameters */ 1180 }; 1181 1182 /** 1183 * Definition of a DMUB_CMD__DP_AUX_ACCESS command. 1184 */ 1185 struct dmub_rb_cmd_dp_aux_access { 1186 /** 1187 * Command header. 1188 */ 1189 struct dmub_cmd_header header; 1190 /** 1191 * Data passed from driver to FW in a DMUB_CMD__DP_AUX_ACCESS command. 1192 */ 1193 struct dmub_cmd_dp_aux_control_data aux_control; 1194 }; 1195 1196 /** 1197 * Definition of a DMUB_CMD__OUTBOX1_ENABLE command. 1198 */ 1199 struct dmub_rb_cmd_outbox1_enable { 1200 /** 1201 * Command header. 1202 */ 1203 struct dmub_cmd_header header; 1204 /** 1205 * enable: 0x0 -> disable outbox1 notification (default value) 1206 * 0x1 -> enable outbox1 notification 1207 */ 1208 uint32_t enable; 1209 }; 1210 1211 /* DP AUX Reply command - OutBox Cmd */ 1212 /** 1213 * Data passed to driver from FW in a DMUB_OUT_CMD__DP_AUX_REPLY command. 1214 */ 1215 struct aux_reply_data { 1216 /** 1217 * Aux cmd 1218 */ 1219 uint8_t command; 1220 /** 1221 * Aux reply data length (max: 16 bytes) 1222 */ 1223 uint8_t length; 1224 /** 1225 * Alignment only 1226 */ 1227 uint8_t pad[2]; 1228 /** 1229 * Aux reply data 1230 */ 1231 uint8_t data[16]; 1232 }; 1233 1234 /** 1235 * Control Data passed to driver from FW in a DMUB_OUT_CMD__DP_AUX_REPLY command. 1236 */ 1237 struct aux_reply_control_data { 1238 /** 1239 * Reserved for future use 1240 */ 1241 uint32_t handle; 1242 /** 1243 * Aux Instance 1244 */ 1245 uint8_t instance; 1246 /** 1247 * Aux transaction result: definition in enum aux_return_code_type 1248 */ 1249 uint8_t result; 1250 /** 1251 * Alignment only 1252 */ 1253 uint16_t pad; 1254 }; 1255 1256 /** 1257 * Definition of a DMUB_OUT_CMD__DP_AUX_REPLY command. 1258 */ 1259 struct dmub_rb_cmd_dp_aux_reply { 1260 /** 1261 * Command header. 1262 */ 1263 struct dmub_cmd_header header; 1264 /** 1265 * Control Data passed to driver from FW in a DMUB_OUT_CMD__DP_AUX_REPLY command. 1266 */ 1267 struct aux_reply_control_data control; 1268 /** 1269 * Data passed to driver from FW in a DMUB_OUT_CMD__DP_AUX_REPLY command. 1270 */ 1271 struct aux_reply_data reply_data; 1272 }; 1273 1274 /* DP HPD Notify command - OutBox Cmd */ 1275 /** 1276 * DP HPD Type 1277 */ 1278 enum dp_hpd_type { 1279 /** 1280 * Normal DP HPD 1281 */ 1282 DP_HPD = 0, 1283 /** 1284 * DP HPD short pulse 1285 */ 1286 DP_IRQ 1287 }; 1288 1289 /** 1290 * DP HPD Status 1291 */ 1292 enum dp_hpd_status { 1293 /** 1294 * DP_HPD status low 1295 */ 1296 DP_HPD_UNPLUG = 0, 1297 /** 1298 * DP_HPD status high 1299 */ 1300 DP_HPD_PLUG 1301 }; 1302 1303 /** 1304 * Data passed to driver from FW in a DMUB_OUT_CMD__DP_HPD_NOTIFY command. 1305 */ 1306 struct dp_hpd_data { 1307 /** 1308 * DP HPD instance 1309 */ 1310 uint8_t instance; 1311 /** 1312 * HPD type 1313 */ 1314 uint8_t hpd_type; 1315 /** 1316 * HPD status: only for type: DP_HPD to indicate status 1317 */ 1318 uint8_t hpd_status; 1319 /** 1320 * Alignment only 1321 */ 1322 uint8_t pad; 1323 }; 1324 1325 /** 1326 * Definition of a DMUB_OUT_CMD__DP_HPD_NOTIFY command. 1327 */ 1328 struct dmub_rb_cmd_dp_hpd_notify { 1329 /** 1330 * Command header. 1331 */ 1332 struct dmub_cmd_header header; 1333 /** 1334 * Data passed to driver from FW in a DMUB_OUT_CMD__DP_HPD_NOTIFY command. 1335 */ 1336 struct dp_hpd_data hpd_data; 1337 }; 1338 1339 /** 1340 * Definition of a SET_CONFIG reply from DPOA. 1341 */ 1342 enum set_config_status { 1343 SET_CONFIG_PENDING = 0, 1344 SET_CONFIG_ACK_RECEIVED, 1345 SET_CONFIG_RX_TIMEOUT, 1346 SET_CONFIG_UNKNOWN_ERROR, 1347 }; 1348 1349 /** 1350 * Definition of a set_config reply 1351 */ 1352 struct set_config_reply_control_data { 1353 uint8_t instance; /* DPIA Instance */ 1354 uint8_t status; /* Set Config reply */ 1355 uint16_t pad; /* Alignment */ 1356 }; 1357 1358 /** 1359 * Definition of a DMUB_OUT_CMD__SET_CONFIG_REPLY command. 1360 */ 1361 struct dmub_rb_cmd_dp_set_config_reply { 1362 struct dmub_cmd_header header; 1363 struct set_config_reply_control_data set_config_reply_control; 1364 }; 1365 1366 /* 1367 * Command IDs should be treated as stable ABI. 1368 * Do not reuse or modify IDs. 1369 */ 1370 1371 /** 1372 * PSR command sub-types. 1373 */ 1374 enum dmub_cmd_psr_type { 1375 /** 1376 * Set PSR version support. 1377 */ 1378 DMUB_CMD__PSR_SET_VERSION = 0, 1379 /** 1380 * Copy driver-calculated parameters to PSR state. 1381 */ 1382 DMUB_CMD__PSR_COPY_SETTINGS = 1, 1383 /** 1384 * Enable PSR. 1385 */ 1386 DMUB_CMD__PSR_ENABLE = 2, 1387 1388 /** 1389 * Disable PSR. 1390 */ 1391 DMUB_CMD__PSR_DISABLE = 3, 1392 1393 /** 1394 * Set PSR level. 1395 * PSR level is a 16-bit value dicated by driver that 1396 * will enable/disable different functionality. 1397 */ 1398 DMUB_CMD__PSR_SET_LEVEL = 4, 1399 1400 /** 1401 * Forces PSR enabled until an explicit PSR disable call. 1402 */ 1403 DMUB_CMD__PSR_FORCE_STATIC = 5, 1404 /** 1405 * Set PSR power option 1406 */ 1407 DMUB_CMD__SET_PSR_POWER_OPT = 7, 1408 }; 1409 1410 /** 1411 * PSR versions. 1412 */ 1413 enum psr_version { 1414 /** 1415 * PSR version 1. 1416 */ 1417 PSR_VERSION_1 = 0, 1418 /** 1419 * PSR not supported. 1420 */ 1421 PSR_VERSION_UNSUPPORTED = 0xFFFFFFFF, 1422 }; 1423 1424 /** 1425 * enum dmub_cmd_mall_type - MALL commands 1426 */ 1427 enum dmub_cmd_mall_type { 1428 /** 1429 * Allows display refresh from MALL. 1430 */ 1431 DMUB_CMD__MALL_ACTION_ALLOW = 0, 1432 /** 1433 * Disallows display refresh from MALL. 1434 */ 1435 DMUB_CMD__MALL_ACTION_DISALLOW = 1, 1436 /** 1437 * Cursor copy for MALL. 1438 */ 1439 DMUB_CMD__MALL_ACTION_COPY_CURSOR = 2, 1440 /** 1441 * Controls DF requests. 1442 */ 1443 DMUB_CMD__MALL_ACTION_NO_DF_REQ = 3, 1444 }; 1445 1446 1447 /** 1448 * Data passed from driver to FW in a DMUB_CMD__PSR_COPY_SETTINGS command. 1449 */ 1450 struct dmub_cmd_psr_copy_settings_data { 1451 /** 1452 * Flags that can be set by driver to change some PSR behaviour. 1453 */ 1454 union dmub_psr_debug_flags debug; 1455 /** 1456 * 16-bit value dicated by driver that will enable/disable different functionality. 1457 */ 1458 uint16_t psr_level; 1459 /** 1460 * DPP HW instance. 1461 */ 1462 uint8_t dpp_inst; 1463 /** 1464 * MPCC HW instance. 1465 * Not used in dmub fw, 1466 * dmub fw will get active opp by reading odm registers. 1467 */ 1468 uint8_t mpcc_inst; 1469 /** 1470 * OPP HW instance. 1471 * Not used in dmub fw, 1472 * dmub fw will get active opp by reading odm registers. 1473 */ 1474 uint8_t opp_inst; 1475 /** 1476 * OTG HW instance. 1477 */ 1478 uint8_t otg_inst; 1479 /** 1480 * DIG FE HW instance. 1481 */ 1482 uint8_t digfe_inst; 1483 /** 1484 * DIG BE HW instance. 1485 */ 1486 uint8_t digbe_inst; 1487 /** 1488 * DP PHY HW instance. 1489 */ 1490 uint8_t dpphy_inst; 1491 /** 1492 * AUX HW instance. 1493 */ 1494 uint8_t aux_inst; 1495 /** 1496 * Determines if SMU optimzations are enabled/disabled. 1497 */ 1498 uint8_t smu_optimizations_en; 1499 /** 1500 * Unused. 1501 * TODO: Remove. 1502 */ 1503 uint8_t frame_delay; 1504 /** 1505 * If RFB setup time is greater than the total VBLANK time, 1506 * it is not possible for the sink to capture the video frame 1507 * in the same frame the SDP is sent. In this case, 1508 * the frame capture indication bit should be set and an extra 1509 * static frame should be transmitted to the sink. 1510 */ 1511 uint8_t frame_cap_ind; 1512 /** 1513 * Explicit padding to 4 byte boundary. 1514 */ 1515 uint8_t pad[2]; 1516 /** 1517 * Multi-display optimizations are implemented on certain ASICs. 1518 */ 1519 uint8_t multi_disp_optimizations_en; 1520 /** 1521 * The last possible line SDP may be transmitted without violating 1522 * the RFB setup time or entering the active video frame. 1523 */ 1524 uint16_t init_sdp_deadline; 1525 /** 1526 * Explicit padding to 4 byte boundary. 1527 */ 1528 uint16_t pad2; 1529 /** 1530 * Length of each horizontal line in us. 1531 */ 1532 uint32_t line_time_in_us; 1533 /** 1534 * FEC enable status in driver 1535 */ 1536 uint8_t fec_enable_status; 1537 /** 1538 * FEC re-enable delay when PSR exit. 1539 * unit is 100us, range form 0~255(0xFF). 1540 */ 1541 uint8_t fec_enable_delay_in100us; 1542 /** 1543 * PSR control version. 1544 */ 1545 uint8_t cmd_version; 1546 /** 1547 * Panel Instance. 1548 * Panel isntance to identify which psr_state to use 1549 * Currently the support is only for 0 or 1 1550 */ 1551 uint8_t panel_inst; 1552 /* 1553 * DSC enable status in driver 1554 */ 1555 uint8_t dsc_enable_status; 1556 /** 1557 * Explicit padding to 3 byte boundary. 1558 */ 1559 uint8_t pad3[3]; 1560 }; 1561 1562 /** 1563 * Definition of a DMUB_CMD__PSR_COPY_SETTINGS command. 1564 */ 1565 struct dmub_rb_cmd_psr_copy_settings { 1566 /** 1567 * Command header. 1568 */ 1569 struct dmub_cmd_header header; 1570 /** 1571 * Data passed from driver to FW in a DMUB_CMD__PSR_COPY_SETTINGS command. 1572 */ 1573 struct dmub_cmd_psr_copy_settings_data psr_copy_settings_data; 1574 }; 1575 1576 /** 1577 * Data passed from driver to FW in a DMUB_CMD__PSR_SET_LEVEL command. 1578 */ 1579 struct dmub_cmd_psr_set_level_data { 1580 /** 1581 * 16-bit value dicated by driver that will enable/disable different functionality. 1582 */ 1583 uint16_t psr_level; 1584 /** 1585 * PSR control version. 1586 */ 1587 uint8_t cmd_version; 1588 /** 1589 * Panel Instance. 1590 * Panel isntance to identify which psr_state to use 1591 * Currently the support is only for 0 or 1 1592 */ 1593 uint8_t panel_inst; 1594 }; 1595 1596 /** 1597 * Definition of a DMUB_CMD__PSR_SET_LEVEL command. 1598 */ 1599 struct dmub_rb_cmd_psr_set_level { 1600 /** 1601 * Command header. 1602 */ 1603 struct dmub_cmd_header header; 1604 /** 1605 * Definition of a DMUB_CMD__PSR_SET_LEVEL command. 1606 */ 1607 struct dmub_cmd_psr_set_level_data psr_set_level_data; 1608 }; 1609 1610 struct dmub_rb_cmd_psr_enable_data { 1611 /** 1612 * PSR control version. 1613 */ 1614 uint8_t cmd_version; 1615 /** 1616 * Panel Instance. 1617 * Panel isntance to identify which psr_state to use 1618 * Currently the support is only for 0 or 1 1619 */ 1620 uint8_t panel_inst; 1621 /** 1622 * Explicit padding to 4 byte boundary. 1623 */ 1624 uint8_t pad[2]; 1625 }; 1626 1627 /** 1628 * Definition of a DMUB_CMD__PSR_ENABLE command. 1629 * PSR enable/disable is controlled using the sub_type. 1630 */ 1631 struct dmub_rb_cmd_psr_enable { 1632 /** 1633 * Command header. 1634 */ 1635 struct dmub_cmd_header header; 1636 1637 struct dmub_rb_cmd_psr_enable_data data; 1638 }; 1639 1640 /** 1641 * Data passed from driver to FW in a DMUB_CMD__PSR_SET_VERSION command. 1642 */ 1643 struct dmub_cmd_psr_set_version_data { 1644 /** 1645 * PSR version that FW should implement. 1646 */ 1647 enum psr_version version; 1648 /** 1649 * PSR control version. 1650 */ 1651 uint8_t cmd_version; 1652 /** 1653 * Panel Instance. 1654 * Panel isntance to identify which psr_state to use 1655 * Currently the support is only for 0 or 1 1656 */ 1657 uint8_t panel_inst; 1658 /** 1659 * Explicit padding to 4 byte boundary. 1660 */ 1661 uint8_t pad[2]; 1662 }; 1663 1664 /** 1665 * Definition of a DMUB_CMD__PSR_SET_VERSION command. 1666 */ 1667 struct dmub_rb_cmd_psr_set_version { 1668 /** 1669 * Command header. 1670 */ 1671 struct dmub_cmd_header header; 1672 /** 1673 * Data passed from driver to FW in a DMUB_CMD__PSR_SET_VERSION command. 1674 */ 1675 struct dmub_cmd_psr_set_version_data psr_set_version_data; 1676 }; 1677 1678 struct dmub_cmd_psr_force_static_data { 1679 /** 1680 * PSR control version. 1681 */ 1682 uint8_t cmd_version; 1683 /** 1684 * Panel Instance. 1685 * Panel isntance to identify which psr_state to use 1686 * Currently the support is only for 0 or 1 1687 */ 1688 uint8_t panel_inst; 1689 /** 1690 * Explicit padding to 4 byte boundary. 1691 */ 1692 uint8_t pad[2]; 1693 }; 1694 1695 /** 1696 * Definition of a DMUB_CMD__PSR_FORCE_STATIC command. 1697 */ 1698 struct dmub_rb_cmd_psr_force_static { 1699 /** 1700 * Command header. 1701 */ 1702 struct dmub_cmd_header header; 1703 /** 1704 * Data passed from driver to FW in a DMUB_CMD__PSR_FORCE_STATIC command. 1705 */ 1706 struct dmub_cmd_psr_force_static_data psr_force_static_data; 1707 }; 1708 1709 /** 1710 * Data passed from driver to FW in a DMUB_CMD__SET_PSR_POWER_OPT command. 1711 */ 1712 struct dmub_cmd_psr_set_power_opt_data { 1713 /** 1714 * PSR control version. 1715 */ 1716 uint8_t cmd_version; 1717 /** 1718 * Panel Instance. 1719 * Panel isntance to identify which psr_state to use 1720 * Currently the support is only for 0 or 1 1721 */ 1722 uint8_t panel_inst; 1723 /** 1724 * Explicit padding to 4 byte boundary. 1725 */ 1726 uint8_t pad[2]; 1727 /** 1728 * PSR power option 1729 */ 1730 uint32_t power_opt; 1731 }; 1732 1733 /** 1734 * Definition of a DMUB_CMD__SET_PSR_POWER_OPT command. 1735 */ 1736 struct dmub_rb_cmd_psr_set_power_opt { 1737 /** 1738 * Command header. 1739 */ 1740 struct dmub_cmd_header header; 1741 /** 1742 * Definition of a DMUB_CMD__SET_PSR_POWER_OPT command. 1743 */ 1744 struct dmub_cmd_psr_set_power_opt_data psr_set_power_opt_data; 1745 }; 1746 1747 /** 1748 * Set of HW components that can be locked. 1749 * 1750 * Note: If updating with more HW components, fields 1751 * in dmub_inbox0_cmd_lock_hw must be updated to match. 1752 */ 1753 union dmub_hw_lock_flags { 1754 /** 1755 * Set of HW components that can be locked. 1756 */ 1757 struct { 1758 /** 1759 * Lock/unlock OTG master update lock. 1760 */ 1761 uint8_t lock_pipe : 1; 1762 /** 1763 * Lock/unlock cursor. 1764 */ 1765 uint8_t lock_cursor : 1; 1766 /** 1767 * Lock/unlock global update lock. 1768 */ 1769 uint8_t lock_dig : 1; 1770 /** 1771 * Triple buffer lock requires additional hw programming to usual OTG master lock. 1772 */ 1773 uint8_t triple_buffer_lock : 1; 1774 } bits; 1775 1776 /** 1777 * Union for HW Lock flags. 1778 */ 1779 uint8_t u8All; 1780 }; 1781 1782 /** 1783 * Instances of HW to be locked. 1784 * 1785 * Note: If updating with more HW components, fields 1786 * in dmub_inbox0_cmd_lock_hw must be updated to match. 1787 */ 1788 struct dmub_hw_lock_inst_flags { 1789 /** 1790 * OTG HW instance for OTG master update lock. 1791 */ 1792 uint8_t otg_inst; 1793 /** 1794 * OPP instance for cursor lock. 1795 */ 1796 uint8_t opp_inst; 1797 /** 1798 * OTG HW instance for global update lock. 1799 * TODO: Remove, and re-use otg_inst. 1800 */ 1801 uint8_t dig_inst; 1802 /** 1803 * Explicit pad to 4 byte boundary. 1804 */ 1805 uint8_t pad; 1806 }; 1807 1808 /** 1809 * Clients that can acquire the HW Lock Manager. 1810 * 1811 * Note: If updating with more clients, fields in 1812 * dmub_inbox0_cmd_lock_hw must be updated to match. 1813 */ 1814 enum hw_lock_client { 1815 /** 1816 * Driver is the client of HW Lock Manager. 1817 */ 1818 HW_LOCK_CLIENT_DRIVER = 0, 1819 /** 1820 * Invalid client. 1821 */ 1822 HW_LOCK_CLIENT_INVALID = 0xFFFFFFFF, 1823 }; 1824 1825 /** 1826 * Data passed to HW Lock Mgr in a DMUB_CMD__HW_LOCK command. 1827 */ 1828 struct dmub_cmd_lock_hw_data { 1829 /** 1830 * Specifies the client accessing HW Lock Manager. 1831 */ 1832 enum hw_lock_client client; 1833 /** 1834 * HW instances to be locked. 1835 */ 1836 struct dmub_hw_lock_inst_flags inst_flags; 1837 /** 1838 * Which components to be locked. 1839 */ 1840 union dmub_hw_lock_flags hw_locks; 1841 /** 1842 * Specifies lock/unlock. 1843 */ 1844 uint8_t lock; 1845 /** 1846 * HW can be unlocked separately from releasing the HW Lock Mgr. 1847 * This flag is set if the client wishes to release the object. 1848 */ 1849 uint8_t should_release; 1850 /** 1851 * Explicit padding to 4 byte boundary. 1852 */ 1853 uint8_t pad; 1854 }; 1855 1856 /** 1857 * Definition of a DMUB_CMD__HW_LOCK command. 1858 * Command is used by driver and FW. 1859 */ 1860 struct dmub_rb_cmd_lock_hw { 1861 /** 1862 * Command header. 1863 */ 1864 struct dmub_cmd_header header; 1865 /** 1866 * Data passed to HW Lock Mgr in a DMUB_CMD__HW_LOCK command. 1867 */ 1868 struct dmub_cmd_lock_hw_data lock_hw_data; 1869 }; 1870 1871 /** 1872 * ABM command sub-types. 1873 */ 1874 enum dmub_cmd_abm_type { 1875 /** 1876 * Initialize parameters for ABM algorithm. 1877 * Data is passed through an indirect buffer. 1878 */ 1879 DMUB_CMD__ABM_INIT_CONFIG = 0, 1880 /** 1881 * Set OTG and panel HW instance. 1882 */ 1883 DMUB_CMD__ABM_SET_PIPE = 1, 1884 /** 1885 * Set user requested backklight level. 1886 */ 1887 DMUB_CMD__ABM_SET_BACKLIGHT = 2, 1888 /** 1889 * Set ABM operating/aggression level. 1890 */ 1891 DMUB_CMD__ABM_SET_LEVEL = 3, 1892 /** 1893 * Set ambient light level. 1894 */ 1895 DMUB_CMD__ABM_SET_AMBIENT_LEVEL = 4, 1896 /** 1897 * Enable/disable fractional duty cycle for backlight PWM. 1898 */ 1899 DMUB_CMD__ABM_SET_PWM_FRAC = 5, 1900 1901 /** 1902 * unregister vertical interrupt after steady state is reached 1903 */ 1904 DMUB_CMD__ABM_PAUSE = 6, 1905 }; 1906 1907 /** 1908 * Parameters for ABM2.4 algorithm. Passed from driver to FW via an indirect buffer. 1909 * Requirements: 1910 * - Padded explicitly to 32-bit boundary. 1911 * - Must ensure this structure matches the one on driver-side, 1912 * otherwise it won't be aligned. 1913 */ 1914 struct abm_config_table { 1915 /** 1916 * Gamma curve thresholds, used for crgb conversion. 1917 */ 1918 uint16_t crgb_thresh[NUM_POWER_FN_SEGS]; // 0B 1919 /** 1920 * Gamma curve offsets, used for crgb conversion. 1921 */ 1922 uint16_t crgb_offset[NUM_POWER_FN_SEGS]; // 16B 1923 /** 1924 * Gamma curve slopes, used for crgb conversion. 1925 */ 1926 uint16_t crgb_slope[NUM_POWER_FN_SEGS]; // 32B 1927 /** 1928 * Custom backlight curve thresholds. 1929 */ 1930 uint16_t backlight_thresholds[NUM_BL_CURVE_SEGS]; // 48B 1931 /** 1932 * Custom backlight curve offsets. 1933 */ 1934 uint16_t backlight_offsets[NUM_BL_CURVE_SEGS]; // 78B 1935 /** 1936 * Ambient light thresholds. 1937 */ 1938 uint16_t ambient_thresholds_lux[NUM_AMBI_LEVEL]; // 112B 1939 /** 1940 * Minimum programmable backlight. 1941 */ 1942 uint16_t min_abm_backlight; // 122B 1943 /** 1944 * Minimum reduction values. 1945 */ 1946 uint8_t min_reduction[NUM_AMBI_LEVEL][NUM_AGGR_LEVEL]; // 124B 1947 /** 1948 * Maximum reduction values. 1949 */ 1950 uint8_t max_reduction[NUM_AMBI_LEVEL][NUM_AGGR_LEVEL]; // 144B 1951 /** 1952 * Bright positive gain. 1953 */ 1954 uint8_t bright_pos_gain[NUM_AMBI_LEVEL][NUM_AGGR_LEVEL]; // 164B 1955 /** 1956 * Dark negative gain. 1957 */ 1958 uint8_t dark_pos_gain[NUM_AMBI_LEVEL][NUM_AGGR_LEVEL]; // 184B 1959 /** 1960 * Hybrid factor. 1961 */ 1962 uint8_t hybrid_factor[NUM_AGGR_LEVEL]; // 204B 1963 /** 1964 * Contrast factor. 1965 */ 1966 uint8_t contrast_factor[NUM_AGGR_LEVEL]; // 208B 1967 /** 1968 * Deviation gain. 1969 */ 1970 uint8_t deviation_gain[NUM_AGGR_LEVEL]; // 212B 1971 /** 1972 * Minimum knee. 1973 */ 1974 uint8_t min_knee[NUM_AGGR_LEVEL]; // 216B 1975 /** 1976 * Maximum knee. 1977 */ 1978 uint8_t max_knee[NUM_AGGR_LEVEL]; // 220B 1979 /** 1980 * Unused. 1981 */ 1982 uint8_t iir_curve[NUM_AMBI_LEVEL]; // 224B 1983 /** 1984 * Explicit padding to 4 byte boundary. 1985 */ 1986 uint8_t pad3[3]; // 229B 1987 /** 1988 * Backlight ramp reduction. 1989 */ 1990 uint16_t blRampReduction[NUM_AGGR_LEVEL]; // 232B 1991 /** 1992 * Backlight ramp start. 1993 */ 1994 uint16_t blRampStart[NUM_AGGR_LEVEL]; // 240B 1995 }; 1996 1997 /** 1998 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_PIPE command. 1999 */ 2000 struct dmub_cmd_abm_set_pipe_data { 2001 /** 2002 * OTG HW instance. 2003 */ 2004 uint8_t otg_inst; 2005 2006 /** 2007 * Panel Control HW instance. 2008 */ 2009 uint8_t panel_inst; 2010 2011 /** 2012 * Controls how ABM will interpret a set pipe or set level command. 2013 */ 2014 uint8_t set_pipe_option; 2015 2016 /** 2017 * Unused. 2018 * TODO: Remove. 2019 */ 2020 uint8_t ramping_boundary; 2021 }; 2022 2023 /** 2024 * Definition of a DMUB_CMD__ABM_SET_PIPE command. 2025 */ 2026 struct dmub_rb_cmd_abm_set_pipe { 2027 /** 2028 * Command header. 2029 */ 2030 struct dmub_cmd_header header; 2031 2032 /** 2033 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_PIPE command. 2034 */ 2035 struct dmub_cmd_abm_set_pipe_data abm_set_pipe_data; 2036 }; 2037 2038 /** 2039 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_BACKLIGHT command. 2040 */ 2041 struct dmub_cmd_abm_set_backlight_data { 2042 /** 2043 * Number of frames to ramp to backlight user level. 2044 */ 2045 uint32_t frame_ramp; 2046 2047 /** 2048 * Requested backlight level from user. 2049 */ 2050 uint32_t backlight_user_level; 2051 2052 /** 2053 * ABM control version. 2054 */ 2055 uint8_t version; 2056 2057 /** 2058 * Panel Control HW instance mask. 2059 * Bit 0 is Panel Control HW instance 0. 2060 * Bit 1 is Panel Control HW instance 1. 2061 */ 2062 uint8_t panel_mask; 2063 2064 /** 2065 * Explicit padding to 4 byte boundary. 2066 */ 2067 uint8_t pad[2]; 2068 }; 2069 2070 /** 2071 * Definition of a DMUB_CMD__ABM_SET_BACKLIGHT command. 2072 */ 2073 struct dmub_rb_cmd_abm_set_backlight { 2074 /** 2075 * Command header. 2076 */ 2077 struct dmub_cmd_header header; 2078 2079 /** 2080 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_BACKLIGHT command. 2081 */ 2082 struct dmub_cmd_abm_set_backlight_data abm_set_backlight_data; 2083 }; 2084 2085 /** 2086 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_LEVEL command. 2087 */ 2088 struct dmub_cmd_abm_set_level_data { 2089 /** 2090 * Set current ABM operating/aggression level. 2091 */ 2092 uint32_t level; 2093 2094 /** 2095 * ABM control version. 2096 */ 2097 uint8_t version; 2098 2099 /** 2100 * Panel Control HW instance mask. 2101 * Bit 0 is Panel Control HW instance 0. 2102 * Bit 1 is Panel Control HW instance 1. 2103 */ 2104 uint8_t panel_mask; 2105 2106 /** 2107 * Explicit padding to 4 byte boundary. 2108 */ 2109 uint8_t pad[2]; 2110 }; 2111 2112 /** 2113 * Definition of a DMUB_CMD__ABM_SET_LEVEL command. 2114 */ 2115 struct dmub_rb_cmd_abm_set_level { 2116 /** 2117 * Command header. 2118 */ 2119 struct dmub_cmd_header header; 2120 2121 /** 2122 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_LEVEL command. 2123 */ 2124 struct dmub_cmd_abm_set_level_data abm_set_level_data; 2125 }; 2126 2127 /** 2128 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_AMBIENT_LEVEL command. 2129 */ 2130 struct dmub_cmd_abm_set_ambient_level_data { 2131 /** 2132 * Ambient light sensor reading from OS. 2133 */ 2134 uint32_t ambient_lux; 2135 2136 /** 2137 * ABM control version. 2138 */ 2139 uint8_t version; 2140 2141 /** 2142 * Panel Control HW instance mask. 2143 * Bit 0 is Panel Control HW instance 0. 2144 * Bit 1 is Panel Control HW instance 1. 2145 */ 2146 uint8_t panel_mask; 2147 2148 /** 2149 * Explicit padding to 4 byte boundary. 2150 */ 2151 uint8_t pad[2]; 2152 }; 2153 2154 /** 2155 * Definition of a DMUB_CMD__ABM_SET_AMBIENT_LEVEL command. 2156 */ 2157 struct dmub_rb_cmd_abm_set_ambient_level { 2158 /** 2159 * Command header. 2160 */ 2161 struct dmub_cmd_header header; 2162 2163 /** 2164 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_AMBIENT_LEVEL command. 2165 */ 2166 struct dmub_cmd_abm_set_ambient_level_data abm_set_ambient_level_data; 2167 }; 2168 2169 /** 2170 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_PWM_FRAC command. 2171 */ 2172 struct dmub_cmd_abm_set_pwm_frac_data { 2173 /** 2174 * Enable/disable fractional duty cycle for backlight PWM. 2175 * TODO: Convert to uint8_t. 2176 */ 2177 uint32_t fractional_pwm; 2178 2179 /** 2180 * ABM control version. 2181 */ 2182 uint8_t version; 2183 2184 /** 2185 * Panel Control HW instance mask. 2186 * Bit 0 is Panel Control HW instance 0. 2187 * Bit 1 is Panel Control HW instance 1. 2188 */ 2189 uint8_t panel_mask; 2190 2191 /** 2192 * Explicit padding to 4 byte boundary. 2193 */ 2194 uint8_t pad[2]; 2195 }; 2196 2197 /** 2198 * Definition of a DMUB_CMD__ABM_SET_PWM_FRAC command. 2199 */ 2200 struct dmub_rb_cmd_abm_set_pwm_frac { 2201 /** 2202 * Command header. 2203 */ 2204 struct dmub_cmd_header header; 2205 2206 /** 2207 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_PWM_FRAC command. 2208 */ 2209 struct dmub_cmd_abm_set_pwm_frac_data abm_set_pwm_frac_data; 2210 }; 2211 2212 /** 2213 * Data passed from driver to FW in a DMUB_CMD__ABM_INIT_CONFIG command. 2214 */ 2215 struct dmub_cmd_abm_init_config_data { 2216 /** 2217 * Location of indirect buffer used to pass init data to ABM. 2218 */ 2219 union dmub_addr src; 2220 2221 /** 2222 * Indirect buffer length. 2223 */ 2224 uint16_t bytes; 2225 2226 2227 /** 2228 * ABM control version. 2229 */ 2230 uint8_t version; 2231 2232 /** 2233 * Panel Control HW instance mask. 2234 * Bit 0 is Panel Control HW instance 0. 2235 * Bit 1 is Panel Control HW instance 1. 2236 */ 2237 uint8_t panel_mask; 2238 2239 /** 2240 * Explicit padding to 4 byte boundary. 2241 */ 2242 uint8_t pad[2]; 2243 }; 2244 2245 /** 2246 * Definition of a DMUB_CMD__ABM_INIT_CONFIG command. 2247 */ 2248 struct dmub_rb_cmd_abm_init_config { 2249 /** 2250 * Command header. 2251 */ 2252 struct dmub_cmd_header header; 2253 2254 /** 2255 * Data passed from driver to FW in a DMUB_CMD__ABM_INIT_CONFIG command. 2256 */ 2257 struct dmub_cmd_abm_init_config_data abm_init_config_data; 2258 }; 2259 2260 /** 2261 * Data passed from driver to FW in a DMUB_CMD__ABM_PAUSE command. 2262 */ 2263 2264 struct dmub_cmd_abm_pause_data { 2265 2266 /** 2267 * Panel Control HW instance mask. 2268 * Bit 0 is Panel Control HW instance 0. 2269 * Bit 1 is Panel Control HW instance 1. 2270 */ 2271 uint8_t panel_mask; 2272 2273 /** 2274 * OTG hw instance 2275 */ 2276 uint8_t otg_inst; 2277 2278 /** 2279 * Enable or disable ABM pause 2280 */ 2281 uint8_t enable; 2282 2283 /** 2284 * Explicit padding to 4 byte boundary. 2285 */ 2286 uint8_t pad[1]; 2287 }; 2288 2289 /** 2290 * Definition of a DMUB_CMD__ABM_PAUSE command. 2291 */ 2292 struct dmub_rb_cmd_abm_pause { 2293 /** 2294 * Command header. 2295 */ 2296 struct dmub_cmd_header header; 2297 2298 /** 2299 * Data passed from driver to FW in a DMUB_CMD__ABM_PAUSE command. 2300 */ 2301 struct dmub_cmd_abm_pause_data abm_pause_data; 2302 }; 2303 2304 /** 2305 * Data passed from driver to FW in a DMUB_CMD__QUERY_FEATURE_CAPS command. 2306 */ 2307 struct dmub_cmd_query_feature_caps_data { 2308 /** 2309 * DMUB feature capabilities. 2310 * After DMUB init, driver will query FW capabilities prior to enabling certain features. 2311 */ 2312 struct dmub_feature_caps feature_caps; 2313 }; 2314 2315 /** 2316 * Definition of a DMUB_CMD__QUERY_FEATURE_CAPS command. 2317 */ 2318 struct dmub_rb_cmd_query_feature_caps { 2319 /** 2320 * Command header. 2321 */ 2322 struct dmub_cmd_header header; 2323 /** 2324 * Data passed from driver to FW in a DMUB_CMD__QUERY_FEATURE_CAPS command. 2325 */ 2326 struct dmub_cmd_query_feature_caps_data query_feature_caps_data; 2327 }; 2328 2329 struct dmub_optc_state { 2330 uint32_t v_total_max; 2331 uint32_t v_total_min; 2332 uint32_t v_total_mid; 2333 uint32_t v_total_mid_frame_num; 2334 uint32_t tg_inst; 2335 uint32_t enable_manual_trigger; 2336 uint32_t clear_force_vsync; 2337 }; 2338 2339 struct dmub_rb_cmd_drr_update { 2340 struct dmub_cmd_header header; 2341 struct dmub_optc_state dmub_optc_state_req; 2342 }; 2343 2344 /** 2345 * enum dmub_cmd_panel_cntl_type - Panel control command. 2346 */ 2347 enum dmub_cmd_panel_cntl_type { 2348 /** 2349 * Initializes embedded panel hardware blocks. 2350 */ 2351 DMUB_CMD__PANEL_CNTL_HW_INIT = 0, 2352 /** 2353 * Queries backlight info for the embedded panel. 2354 */ 2355 DMUB_CMD__PANEL_CNTL_QUERY_BACKLIGHT_INFO = 1, 2356 }; 2357 2358 /** 2359 * struct dmub_cmd_panel_cntl_data - Panel control data. 2360 */ 2361 struct dmub_cmd_panel_cntl_data { 2362 uint32_t inst; /**< panel instance */ 2363 uint32_t current_backlight; /* in/out */ 2364 uint32_t bl_pwm_cntl; /* in/out */ 2365 uint32_t bl_pwm_period_cntl; /* in/out */ 2366 uint32_t bl_pwm_ref_div1; /* in/out */ 2367 uint8_t is_backlight_on : 1; /* in/out */ 2368 uint8_t is_powered_on : 1; /* in/out */ 2369 }; 2370 2371 /** 2372 * struct dmub_rb_cmd_panel_cntl - Panel control command. 2373 */ 2374 struct dmub_rb_cmd_panel_cntl { 2375 struct dmub_cmd_header header; /**< header */ 2376 struct dmub_cmd_panel_cntl_data data; /**< payload */ 2377 }; 2378 2379 /** 2380 * Data passed from driver to FW in a DMUB_CMD__VBIOS_LVTMA_CONTROL command. 2381 */ 2382 struct dmub_cmd_lvtma_control_data { 2383 uint8_t uc_pwr_action; /**< LVTMA_ACTION */ 2384 uint8_t reserved_0[3]; /**< For future use */ 2385 uint8_t panel_inst; /**< LVTMA control instance */ 2386 uint8_t reserved_1[3]; /**< For future use */ 2387 }; 2388 2389 /** 2390 * Definition of a DMUB_CMD__VBIOS_LVTMA_CONTROL command. 2391 */ 2392 struct dmub_rb_cmd_lvtma_control { 2393 /** 2394 * Command header. 2395 */ 2396 struct dmub_cmd_header header; 2397 /** 2398 * Data passed from driver to FW in a DMUB_CMD__VBIOS_LVTMA_CONTROL command. 2399 */ 2400 struct dmub_cmd_lvtma_control_data data; 2401 }; 2402 2403 /** 2404 * Data passed in/out in a DMUB_CMD__VBIOS_TRANSMITTER_QUERY_DP_ALT command. 2405 */ 2406 struct dmub_rb_cmd_transmitter_query_dp_alt_data { 2407 uint8_t phy_id; /**< 0=UNIPHYA, 1=UNIPHYB, 2=UNIPHYC, 3=UNIPHYD, 4=UNIPHYE, 5=UNIPHYF */ 2408 uint8_t is_usb; /**< is phy is usb */ 2409 uint8_t is_dp_alt_disable; /**< is dp alt disable */ 2410 uint8_t is_dp4; /**< is dp in 4 lane */ 2411 }; 2412 2413 /** 2414 * Definition of a DMUB_CMD__VBIOS_TRANSMITTER_QUERY_DP_ALT command. 2415 */ 2416 struct dmub_rb_cmd_transmitter_query_dp_alt { 2417 struct dmub_cmd_header header; /**< header */ 2418 struct dmub_rb_cmd_transmitter_query_dp_alt_data data; /**< payload */ 2419 }; 2420 2421 /** 2422 * Maximum number of bytes a chunk sent to DMUB for parsing 2423 */ 2424 #define DMUB_EDID_CEA_DATA_CHUNK_BYTES 8 2425 2426 /** 2427 * Represent a chunk of CEA blocks sent to DMUB for parsing 2428 */ 2429 struct dmub_cmd_send_edid_cea { 2430 uint16_t offset; /**< offset into the CEA block */ 2431 uint8_t length; /**< number of bytes in payload to copy as part of CEA block */ 2432 uint16_t cea_total_length; /**< total length of the CEA block */ 2433 uint8_t payload[DMUB_EDID_CEA_DATA_CHUNK_BYTES]; /**< data chunk of the CEA block */ 2434 uint8_t pad[3]; /**< padding and for future expansion */ 2435 }; 2436 2437 /** 2438 * Result of VSDB parsing from CEA block 2439 */ 2440 struct dmub_cmd_edid_cea_amd_vsdb { 2441 uint8_t vsdb_found; /**< 1 if parsing has found valid AMD VSDB */ 2442 uint8_t freesync_supported; /**< 1 if Freesync is supported */ 2443 uint16_t amd_vsdb_version; /**< AMD VSDB version */ 2444 uint16_t min_frame_rate; /**< Maximum frame rate */ 2445 uint16_t max_frame_rate; /**< Minimum frame rate */ 2446 }; 2447 2448 /** 2449 * Result of sending a CEA chunk 2450 */ 2451 struct dmub_cmd_edid_cea_ack { 2452 uint16_t offset; /**< offset of the chunk into the CEA block */ 2453 uint8_t success; /**< 1 if this sending of chunk succeeded */ 2454 uint8_t pad; /**< padding and for future expansion */ 2455 }; 2456 2457 /** 2458 * Specify whether the result is an ACK/NACK or the parsing has finished 2459 */ 2460 enum dmub_cmd_edid_cea_reply_type { 2461 DMUB_CMD__EDID_CEA_AMD_VSDB = 1, /**< VSDB parsing has finished */ 2462 DMUB_CMD__EDID_CEA_ACK = 2, /**< acknowledges the CEA sending is OK or failing */ 2463 }; 2464 2465 /** 2466 * Definition of a DMUB_CMD__EDID_CEA command. 2467 */ 2468 struct dmub_rb_cmd_edid_cea { 2469 struct dmub_cmd_header header; /**< Command header */ 2470 union dmub_cmd_edid_cea_data { 2471 struct dmub_cmd_send_edid_cea input; /**< input to send CEA chunks */ 2472 struct dmub_cmd_edid_cea_output { /**< output with results */ 2473 uint8_t type; /**< dmub_cmd_edid_cea_reply_type */ 2474 union { 2475 struct dmub_cmd_edid_cea_amd_vsdb amd_vsdb; 2476 struct dmub_cmd_edid_cea_ack ack; 2477 }; 2478 } output; /**< output to retrieve ACK/NACK or VSDB parsing results */ 2479 } data; /**< Command data */ 2480 2481 }; 2482 2483 /** 2484 * union dmub_rb_cmd - DMUB inbox command. 2485 */ 2486 union dmub_rb_cmd { 2487 struct dmub_rb_cmd_lock_hw lock_hw; 2488 /** 2489 * Elements shared with all commands. 2490 */ 2491 struct dmub_rb_cmd_common cmd_common; 2492 /** 2493 * Definition of a DMUB_CMD__REG_SEQ_READ_MODIFY_WRITE command. 2494 */ 2495 struct dmub_rb_cmd_read_modify_write read_modify_write; 2496 /** 2497 * Definition of a DMUB_CMD__REG_SEQ_FIELD_UPDATE_SEQ command. 2498 */ 2499 struct dmub_rb_cmd_reg_field_update_sequence reg_field_update_seq; 2500 /** 2501 * Definition of a DMUB_CMD__REG_SEQ_BURST_WRITE command. 2502 */ 2503 struct dmub_rb_cmd_burst_write burst_write; 2504 /** 2505 * Definition of a DMUB_CMD__REG_REG_WAIT command. 2506 */ 2507 struct dmub_rb_cmd_reg_wait reg_wait; 2508 /** 2509 * Definition of a DMUB_CMD__VBIOS_DIGX_ENCODER_CONTROL command. 2510 */ 2511 struct dmub_rb_cmd_digx_encoder_control digx_encoder_control; 2512 /** 2513 * Definition of a DMUB_CMD__VBIOS_SET_PIXEL_CLOCK command. 2514 */ 2515 struct dmub_rb_cmd_set_pixel_clock set_pixel_clock; 2516 /** 2517 * Definition of a DMUB_CMD__VBIOS_ENABLE_DISP_POWER_GATING command. 2518 */ 2519 struct dmub_rb_cmd_enable_disp_power_gating enable_disp_power_gating; 2520 /** 2521 * Definition of a DMUB_CMD__VBIOS_DPPHY_INIT command. 2522 */ 2523 struct dmub_rb_cmd_dpphy_init dpphy_init; 2524 /** 2525 * Definition of a DMUB_CMD__VBIOS_DIG1_TRANSMITTER_CONTROL command. 2526 */ 2527 struct dmub_rb_cmd_dig1_transmitter_control dig1_transmitter_control; 2528 /** 2529 * Definition of a DMUB_CMD__PSR_SET_VERSION command. 2530 */ 2531 struct dmub_rb_cmd_psr_set_version psr_set_version; 2532 /** 2533 * Definition of a DMUB_CMD__PSR_COPY_SETTINGS command. 2534 */ 2535 struct dmub_rb_cmd_psr_copy_settings psr_copy_settings; 2536 /** 2537 * Definition of a DMUB_CMD__PSR_ENABLE command. 2538 */ 2539 struct dmub_rb_cmd_psr_enable psr_enable; 2540 /** 2541 * Definition of a DMUB_CMD__PSR_SET_LEVEL command. 2542 */ 2543 struct dmub_rb_cmd_psr_set_level psr_set_level; 2544 /** 2545 * Definition of a DMUB_CMD__PSR_FORCE_STATIC command. 2546 */ 2547 struct dmub_rb_cmd_psr_force_static psr_force_static; 2548 /** 2549 * Definition of a DMUB_CMD__SET_PSR_POWER_OPT command. 2550 */ 2551 struct dmub_rb_cmd_psr_set_power_opt psr_set_power_opt; 2552 /** 2553 * Definition of a DMUB_CMD__PLAT_54186_WA command. 2554 */ 2555 struct dmub_rb_cmd_PLAT_54186_wa PLAT_54186_wa; 2556 /** 2557 * Definition of a DMUB_CMD__MALL command. 2558 */ 2559 struct dmub_rb_cmd_mall mall; 2560 /** 2561 * Definition of a DMUB_CMD__IDLE_OPT_DCN_RESTORE command. 2562 */ 2563 struct dmub_rb_cmd_idle_opt_dcn_restore dcn_restore; 2564 2565 /** 2566 * Definition of a DMUB_CMD__CLK_MGR_NOTIFY_CLOCKS command. 2567 */ 2568 struct dmub_rb_cmd_clk_mgr_notify_clocks notify_clocks; 2569 2570 /** 2571 * Definition of DMUB_CMD__PANEL_CNTL commands. 2572 */ 2573 struct dmub_rb_cmd_panel_cntl panel_cntl; 2574 /** 2575 * Definition of a DMUB_CMD__ABM_SET_PIPE command. 2576 */ 2577 struct dmub_rb_cmd_abm_set_pipe abm_set_pipe; 2578 2579 /** 2580 * Definition of a DMUB_CMD__ABM_SET_BACKLIGHT command. 2581 */ 2582 struct dmub_rb_cmd_abm_set_backlight abm_set_backlight; 2583 2584 /** 2585 * Definition of a DMUB_CMD__ABM_SET_LEVEL command. 2586 */ 2587 struct dmub_rb_cmd_abm_set_level abm_set_level; 2588 2589 /** 2590 * Definition of a DMUB_CMD__ABM_SET_AMBIENT_LEVEL command. 2591 */ 2592 struct dmub_rb_cmd_abm_set_ambient_level abm_set_ambient_level; 2593 2594 /** 2595 * Definition of a DMUB_CMD__ABM_SET_PWM_FRAC command. 2596 */ 2597 struct dmub_rb_cmd_abm_set_pwm_frac abm_set_pwm_frac; 2598 2599 /** 2600 * Definition of a DMUB_CMD__ABM_INIT_CONFIG command. 2601 */ 2602 struct dmub_rb_cmd_abm_init_config abm_init_config; 2603 2604 /** 2605 * Definition of a DMUB_CMD__ABM_PAUSE command. 2606 */ 2607 struct dmub_rb_cmd_abm_pause abm_pause; 2608 2609 /** 2610 * Definition of a DMUB_CMD__DP_AUX_ACCESS command. 2611 */ 2612 struct dmub_rb_cmd_dp_aux_access dp_aux_access; 2613 2614 /** 2615 * Definition of a DMUB_CMD__OUTBOX1_ENABLE command. 2616 */ 2617 struct dmub_rb_cmd_outbox1_enable outbox1_enable; 2618 2619 /** 2620 * Definition of a DMUB_CMD__QUERY_FEATURE_CAPS command. 2621 */ 2622 struct dmub_rb_cmd_query_feature_caps query_feature_caps; 2623 struct dmub_rb_cmd_drr_update drr_update; 2624 /** 2625 * Definition of a DMUB_CMD__VBIOS_LVTMA_CONTROL command. 2626 */ 2627 struct dmub_rb_cmd_lvtma_control lvtma_control; 2628 /** 2629 * Definition of a DMUB_CMD__VBIOS_TRANSMITTER_QUERY_DP_ALT command. 2630 */ 2631 struct dmub_rb_cmd_transmitter_query_dp_alt query_dp_alt; 2632 /** 2633 * Definition of a DMUB_CMD__DPIA_DIG1_CONTROL command. 2634 */ 2635 struct dmub_rb_cmd_dig1_dpia_control dig1_dpia_control; 2636 /** 2637 * Definition of a DMUB_CMD__DPIA_SET_CONFIG_ACCESS command. 2638 */ 2639 struct dmub_rb_cmd_set_config_access set_config_access; 2640 /** 2641 * Definition of a DMUB_CMD__DPIA_MST_ALLOC_SLOTS command. 2642 */ 2643 struct dmub_rb_cmd_set_mst_alloc_slots set_mst_alloc_slots; 2644 /** 2645 * Definition of a DMUB_CMD__EDID_CEA command. 2646 */ 2647 struct dmub_rb_cmd_edid_cea edid_cea; 2648 }; 2649 2650 /** 2651 * union dmub_rb_out_cmd - Outbox command 2652 */ 2653 union dmub_rb_out_cmd { 2654 /** 2655 * Parameters common to every command. 2656 */ 2657 struct dmub_rb_cmd_common cmd_common; 2658 /** 2659 * AUX reply command. 2660 */ 2661 struct dmub_rb_cmd_dp_aux_reply dp_aux_reply; 2662 /** 2663 * HPD notify command. 2664 */ 2665 struct dmub_rb_cmd_dp_hpd_notify dp_hpd_notify; 2666 /** 2667 * SET_CONFIG reply command. 2668 */ 2669 struct dmub_rb_cmd_dp_set_config_reply set_config_reply; 2670 }; 2671 #pragma pack(pop) 2672 2673 2674 //============================================================================== 2675 //</DMUB_CMD>=================================================================== 2676 //============================================================================== 2677 //< DMUB_RB>==================================================================== 2678 //============================================================================== 2679 2680 #if defined(__cplusplus) 2681 extern "C" { 2682 #endif 2683 2684 /** 2685 * struct dmub_rb_init_params - Initialization params for DMUB ringbuffer 2686 */ 2687 struct dmub_rb_init_params { 2688 void *ctx; /**< Caller provided context pointer */ 2689 void *base_address; /**< CPU base address for ring's data */ 2690 uint32_t capacity; /**< Ringbuffer capacity in bytes */ 2691 uint32_t read_ptr; /**< Initial read pointer for consumer in bytes */ 2692 uint32_t write_ptr; /**< Initial write pointer for producer in bytes */ 2693 }; 2694 2695 /** 2696 * struct dmub_rb - Inbox or outbox DMUB ringbuffer 2697 */ 2698 struct dmub_rb { 2699 void *base_address; /**< CPU address for the ring's data */ 2700 uint32_t rptr; /**< Read pointer for consumer in bytes */ 2701 uint32_t wrpt; /**< Write pointer for producer in bytes */ 2702 uint32_t capacity; /**< Ringbuffer capacity in bytes */ 2703 2704 void *ctx; /**< Caller provided context pointer */ 2705 void *dmub; /**< Pointer to the DMUB interface */ 2706 }; 2707 2708 /** 2709 * @brief Checks if the ringbuffer is empty. 2710 * 2711 * @param rb DMUB Ringbuffer 2712 * @return true if empty 2713 * @return false otherwise 2714 */ 2715 static inline bool dmub_rb_empty(struct dmub_rb *rb) 2716 { 2717 return (rb->wrpt == rb->rptr); 2718 } 2719 2720 /** 2721 * @brief Checks if the ringbuffer is full 2722 * 2723 * @param rb DMUB Ringbuffer 2724 * @return true if full 2725 * @return false otherwise 2726 */ 2727 static inline bool dmub_rb_full(struct dmub_rb *rb) 2728 { 2729 uint32_t data_count; 2730 2731 if (rb->wrpt >= rb->rptr) 2732 data_count = rb->wrpt - rb->rptr; 2733 else 2734 data_count = rb->capacity - (rb->rptr - rb->wrpt); 2735 2736 return (data_count == (rb->capacity - DMUB_RB_CMD_SIZE)); 2737 } 2738 2739 /** 2740 * @brief Pushes a command into the ringbuffer 2741 * 2742 * @param rb DMUB ringbuffer 2743 * @param cmd The command to push 2744 * @return true if the ringbuffer was not full 2745 * @return false otherwise 2746 */ 2747 static inline bool dmub_rb_push_front(struct dmub_rb *rb, 2748 const union dmub_rb_cmd *cmd) 2749 { 2750 uint64_t volatile *dst = (uint64_t volatile *)((uint8_t *)(rb->base_address) + rb->wrpt); 2751 const uint64_t *src = (const uint64_t *)cmd; 2752 uint8_t i; 2753 2754 if (dmub_rb_full(rb)) 2755 return false; 2756 2757 // copying data 2758 for (i = 0; i < DMUB_RB_CMD_SIZE / sizeof(uint64_t); i++) 2759 *dst++ = *src++; 2760 2761 rb->wrpt += DMUB_RB_CMD_SIZE; 2762 2763 if (rb->wrpt >= rb->capacity) 2764 rb->wrpt %= rb->capacity; 2765 2766 return true; 2767 } 2768 2769 /** 2770 * @brief Pushes a command into the DMUB outbox ringbuffer 2771 * 2772 * @param rb DMUB outbox ringbuffer 2773 * @param cmd Outbox command 2774 * @return true if not full 2775 * @return false otherwise 2776 */ 2777 static inline bool dmub_rb_out_push_front(struct dmub_rb *rb, 2778 const union dmub_rb_out_cmd *cmd) 2779 { 2780 uint8_t *dst = (uint8_t *)(rb->base_address) + rb->wrpt; 2781 const uint8_t *src = (const uint8_t *)cmd; 2782 2783 if (dmub_rb_full(rb)) 2784 return false; 2785 2786 dmub_memcpy(dst, src, DMUB_RB_CMD_SIZE); 2787 2788 rb->wrpt += DMUB_RB_CMD_SIZE; 2789 2790 if (rb->wrpt >= rb->capacity) 2791 rb->wrpt %= rb->capacity; 2792 2793 return true; 2794 } 2795 2796 /** 2797 * @brief Returns the next unprocessed command in the ringbuffer. 2798 * 2799 * @param rb DMUB ringbuffer 2800 * @param cmd The command to return 2801 * @return true if not empty 2802 * @return false otherwise 2803 */ 2804 static inline bool dmub_rb_front(struct dmub_rb *rb, 2805 union dmub_rb_cmd **cmd) 2806 { 2807 uint8_t *rb_cmd = (uint8_t *)(rb->base_address) + rb->rptr; 2808 2809 if (dmub_rb_empty(rb)) 2810 return false; 2811 2812 *cmd = (union dmub_rb_cmd *)rb_cmd; 2813 2814 return true; 2815 } 2816 2817 /** 2818 * @brief Determines the next ringbuffer offset. 2819 * 2820 * @param rb DMUB inbox ringbuffer 2821 * @param num_cmds Number of commands 2822 * @param next_rptr The next offset in the ringbuffer 2823 */ 2824 static inline void dmub_rb_get_rptr_with_offset(struct dmub_rb *rb, 2825 uint32_t num_cmds, 2826 uint32_t *next_rptr) 2827 { 2828 *next_rptr = rb->rptr + DMUB_RB_CMD_SIZE * num_cmds; 2829 2830 if (*next_rptr >= rb->capacity) 2831 *next_rptr %= rb->capacity; 2832 } 2833 2834 /** 2835 * @brief Returns a pointer to a command in the inbox. 2836 * 2837 * @param rb DMUB inbox ringbuffer 2838 * @param cmd The inbox command to return 2839 * @param rptr The ringbuffer offset 2840 * @return true if not empty 2841 * @return false otherwise 2842 */ 2843 static inline bool dmub_rb_peek_offset(struct dmub_rb *rb, 2844 union dmub_rb_cmd **cmd, 2845 uint32_t rptr) 2846 { 2847 uint8_t *rb_cmd = (uint8_t *)(rb->base_address) + rptr; 2848 2849 if (dmub_rb_empty(rb)) 2850 return false; 2851 2852 *cmd = (union dmub_rb_cmd *)rb_cmd; 2853 2854 return true; 2855 } 2856 2857 /** 2858 * @brief Returns the next unprocessed command in the outbox. 2859 * 2860 * @param rb DMUB outbox ringbuffer 2861 * @param cmd The outbox command to return 2862 * @return true if not empty 2863 * @return false otherwise 2864 */ 2865 static inline bool dmub_rb_out_front(struct dmub_rb *rb, 2866 union dmub_rb_out_cmd *cmd) 2867 { 2868 const uint64_t volatile *src = (const uint64_t volatile *)((uint8_t *)(rb->base_address) + rb->rptr); 2869 uint64_t *dst = (uint64_t *)cmd; 2870 uint8_t i; 2871 2872 if (dmub_rb_empty(rb)) 2873 return false; 2874 2875 // copying data 2876 for (i = 0; i < DMUB_RB_CMD_SIZE / sizeof(uint64_t); i++) 2877 *dst++ = *src++; 2878 2879 return true; 2880 } 2881 2882 /** 2883 * @brief Removes the front entry in the ringbuffer. 2884 * 2885 * @param rb DMUB ringbuffer 2886 * @return true if the command was removed 2887 * @return false if there were no commands 2888 */ 2889 static inline bool dmub_rb_pop_front(struct dmub_rb *rb) 2890 { 2891 if (dmub_rb_empty(rb)) 2892 return false; 2893 2894 rb->rptr += DMUB_RB_CMD_SIZE; 2895 2896 if (rb->rptr >= rb->capacity) 2897 rb->rptr %= rb->capacity; 2898 2899 return true; 2900 } 2901 2902 /** 2903 * @brief Flushes commands in the ringbuffer to framebuffer memory. 2904 * 2905 * Avoids a race condition where DMCUB accesses memory while 2906 * there are still writes in flight to framebuffer. 2907 * 2908 * @param rb DMUB ringbuffer 2909 */ 2910 static inline void dmub_rb_flush_pending(const struct dmub_rb *rb) 2911 { 2912 uint32_t rptr = rb->rptr; 2913 uint32_t wptr = rb->wrpt; 2914 2915 while (rptr != wptr) { 2916 uint64_t volatile *data = (uint64_t volatile *)((uint8_t *)(rb->base_address) + rptr); 2917 //uint64_t volatile *p = (uint64_t volatile *)data; 2918 uint64_t temp; 2919 uint8_t i; 2920 2921 for (i = 0; i < DMUB_RB_CMD_SIZE / sizeof(uint64_t); i++) 2922 temp = *data++; 2923 2924 rptr += DMUB_RB_CMD_SIZE; 2925 if (rptr >= rb->capacity) 2926 rptr %= rb->capacity; 2927 } 2928 } 2929 2930 /** 2931 * @brief Initializes a DMCUB ringbuffer 2932 * 2933 * @param rb DMUB ringbuffer 2934 * @param init_params initial configuration for the ringbuffer 2935 */ 2936 static inline void dmub_rb_init(struct dmub_rb *rb, 2937 struct dmub_rb_init_params *init_params) 2938 { 2939 rb->base_address = init_params->base_address; 2940 rb->capacity = init_params->capacity; 2941 rb->rptr = init_params->read_ptr; 2942 rb->wrpt = init_params->write_ptr; 2943 } 2944 2945 /** 2946 * @brief Copies output data from in/out commands into the given command. 2947 * 2948 * @param rb DMUB ringbuffer 2949 * @param cmd Command to copy data into 2950 */ 2951 static inline void dmub_rb_get_return_data(struct dmub_rb *rb, 2952 union dmub_rb_cmd *cmd) 2953 { 2954 // Copy rb entry back into command 2955 uint8_t *rd_ptr = (rb->rptr == 0) ? 2956 (uint8_t *)rb->base_address + rb->capacity - DMUB_RB_CMD_SIZE : 2957 (uint8_t *)rb->base_address + rb->rptr - DMUB_RB_CMD_SIZE; 2958 2959 dmub_memcpy(cmd, rd_ptr, DMUB_RB_CMD_SIZE); 2960 } 2961 2962 #if defined(__cplusplus) 2963 } 2964 #endif 2965 2966 //============================================================================== 2967 //</DMUB_RB>==================================================================== 2968 //============================================================================== 2969 2970 #endif /* _DMUB_CMD_H_ */ 2971