2 * Copyright 2019 Advanced Micro Devices, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
29 #include <asm/byteorder.h>
30 #include <linux/types.h>
31 #include <linux/string.h>
32 #include <linux/delay.h>
35 #include "atomfirmware.h"
37 /* Firmware versioning. */
38 #ifdef DMUB_EXPOSE_VERSION
39 #define DMUB_FW_VERSION_GIT_HASH 0xf675c6448
40 #define DMUB_FW_VERSION_MAJOR 0
41 #define DMUB_FW_VERSION_MINOR 0
42 #define DMUB_FW_VERSION_REVISION 24
43 #define DMUB_FW_VERSION_UCODE ((DMUB_FW_VERSION_MAJOR << 24) | (DMUB_FW_VERSION_MINOR << 16) | DMUB_FW_VERSION_REVISION)
46 //<DMUB_TYPES>==================================================================
47 /* Basic type definitions. */
49 #define SET_ABM_PIPE_GRADUALLY_DISABLE 0
50 #define SET_ABM_PIPE_IMMEDIATELY_DISABLE 255
51 #define SET_ABM_PIPE_NORMAL 1
53 /* Maximum number of streams on any ASIC. */
54 #define DMUB_MAX_STREAMS 6
56 /* Maximum number of planes on any ASIC. */
57 #define DMUB_MAX_PLANES 6
59 #ifndef PHYSICAL_ADDRESS_LOC
60 #define PHYSICAL_ADDRESS_LOC union large_integer
63 #if defined(__cplusplus)
68 #define dmub_memcpy(dest, source, bytes) memcpy((dest), (source), (bytes))
72 #define dmub_memset(dest, val, bytes) memset((dest), (val), (bytes))
76 #define dmub_udelay(microseconds) udelay(microseconds)
87 union dmub_psr_debug_flags {
89 uint32_t visual_confirm : 1;
90 uint32_t use_hw_lock_mgr : 1;
96 #if defined(__cplusplus)
102 //==============================================================================
103 //</DMUB_TYPES>=================================================================
104 //==============================================================================
105 //< DMUB_META>==================================================================
106 //==============================================================================
107 #pragma pack(push, 1)
109 /* Magic value for identifying dmub_fw_meta_info */
110 #define DMUB_FW_META_MAGIC 0x444D5542
112 /* Offset from the end of the file to the dmub_fw_meta_info */
113 #define DMUB_FW_META_OFFSET 0x24
116 * struct dmub_fw_meta_info - metadata associated with fw binary
118 * NOTE: This should be considered a stable API. Fields should
119 * not be repurposed or reordered. New fields should be
120 * added instead to extend the structure.
122 * @magic_value: magic value identifying DMUB firmware meta info
123 * @fw_region_size: size of the firmware state region
124 * @trace_buffer_size: size of the tracebuffer region
125 * @fw_version: the firmware version information
126 * @dal_fw: 1 if the firmware is DAL
128 struct dmub_fw_meta_info {
129 uint32_t magic_value;
130 uint32_t fw_region_size;
131 uint32_t trace_buffer_size;
137 /* Ensure that the structure remains 64 bytes. */
139 struct dmub_fw_meta_info info;
140 uint8_t reserved[64];
145 //==============================================================================
146 //< DMUB_STATUS>================================================================
147 //==============================================================================
150 * DMCUB scratch registers can be used to determine firmware status.
151 * Current scratch register usage is as follows:
153 * SCRATCH0: FW Boot Status register
154 * SCRATCH15: FW Boot Options register
157 /* Register bit definition for SCRATCH0 */
158 union dmub_fw_boot_status {
161 uint32_t mailbox_rdy : 1;
162 uint32_t optimized_init_done : 1;
163 uint32_t reserved : 29;
168 enum dmub_fw_boot_status_bit {
169 DMUB_FW_BOOT_STATUS_BIT_DAL_FIRMWARE = (1 << 0),
170 DMUB_FW_BOOT_STATUS_BIT_MAILBOX_READY = (1 << 1),
171 DMUB_FW_BOOT_STATUS_BIT_OPTIMIZED_INIT_DONE = (1 << 2),
174 /* Register bit definition for SCRATCH15 */
175 union dmub_fw_boot_options {
177 uint32_t pemu_env : 1;
178 uint32_t fpga_env : 1;
179 uint32_t optimized_init : 1;
180 uint32_t reserved : 29;
185 enum dmub_fw_boot_options_bit {
186 DMUB_FW_BOOT_OPTION_BIT_PEMU_ENV = (1 << 0),
187 DMUB_FW_BOOT_OPTION_BIT_FPGA_ENV = (1 << 1),
188 DMUB_FW_BOOT_OPTION_BIT_OPTIMIZED_INIT_DONE = (1 << 2),
191 //==============================================================================
192 //</DMUB_STATUS>================================================================
193 //==============================================================================
194 //< DMUB_VBIOS>=================================================================
195 //==============================================================================
198 * Command IDs should be treated as stable ABI.
199 * Do not reuse or modify IDs.
202 enum dmub_cmd_vbios_type {
203 DMUB_CMD__VBIOS_DIGX_ENCODER_CONTROL = 0,
204 DMUB_CMD__VBIOS_DIG1_TRANSMITTER_CONTROL = 1,
205 DMUB_CMD__VBIOS_SET_PIXEL_CLOCK = 2,
206 DMUB_CMD__VBIOS_ENABLE_DISP_POWER_GATING = 3,
209 //==============================================================================
210 //</DMUB_VBIOS>=================================================================
211 //==============================================================================
212 //< DMUB_GPINT>=================================================================
213 //==============================================================================
216 * The shifts and masks below may alternatively be used to format and read
217 * the command register bits.
220 #define DMUB_GPINT_DATA_PARAM_MASK 0xFFFF
221 #define DMUB_GPINT_DATA_PARAM_SHIFT 0
223 #define DMUB_GPINT_DATA_COMMAND_CODE_MASK 0xFFF
224 #define DMUB_GPINT_DATA_COMMAND_CODE_SHIFT 16
226 #define DMUB_GPINT_DATA_STATUS_MASK 0xF
227 #define DMUB_GPINT_DATA_STATUS_SHIFT 28
233 #define DMUB_GPINT__STOP_FW_RESPONSE 0xDEADDEAD
236 * The register format for sending a command via the GPINT.
238 union dmub_gpint_data_register {
241 uint32_t command_code : 12;
248 * Command IDs should be treated as stable ABI.
249 * Do not reuse or modify IDs.
252 enum dmub_gpint_command {
253 DMUB_GPINT__INVALID_COMMAND = 0,
254 DMUB_GPINT__GET_FW_VERSION = 1,
255 DMUB_GPINT__STOP_FW = 2,
256 DMUB_GPINT__GET_PSR_STATE = 7,
258 * DESC: Notifies DMCUB of the currently active streams.
259 * ARGS: Stream mask, 1 bit per active stream index.
261 DMUB_GPINT__IDLE_OPT_NOTIFY_STREAM_MASK = 8,
264 //==============================================================================
265 //</DMUB_GPINT>=================================================================
266 //==============================================================================
267 //< DMUB_CMD>===================================================================
268 //==============================================================================
270 #define DMUB_RB_CMD_SIZE 64
271 #define DMUB_RB_MAX_ENTRY 128
272 #define DMUB_RB_SIZE (DMUB_RB_CMD_SIZE * DMUB_RB_MAX_ENTRY)
273 #define REG_SET_MASK 0xFFFF
276 * Command IDs should be treated as stable ABI.
277 * Do not reuse or modify IDs.
282 DMUB_CMD__REG_SEQ_READ_MODIFY_WRITE = 1,
283 DMUB_CMD__REG_SEQ_FIELD_UPDATE_SEQ = 2,
284 DMUB_CMD__REG_SEQ_BURST_WRITE = 3,
285 DMUB_CMD__REG_REG_WAIT = 4,
286 DMUB_CMD__PLAT_54186_WA = 5,
289 DMUB_CMD__HW_LOCK = 69,
290 DMUB_CMD__VBIOS = 128,
293 #pragma pack(push, 1)
295 struct dmub_cmd_header {
296 unsigned int type : 8;
297 unsigned int sub_type : 8;
298 unsigned int reserved0 : 8;
299 unsigned int payload_bytes : 6; /* up to 60 bytes */
300 unsigned int reserved1 : 2;
306 * 60 payload bytes can hold up to 5 sets of read modify writes,
307 * each take 3 dwords.
309 * number of sequences = header.payload_bytes / sizeof(struct dmub_cmd_read_modify_write_sequence)
311 * modify_mask = 0xffff'ffff means all fields are going to be updated. in this case
312 * command parser will skip the read and we can use modify_mask = 0xffff'ffff as reg write
314 struct dmub_cmd_read_modify_write_sequence {
316 uint32_t modify_mask;
317 uint32_t modify_value;
320 #define DMUB_READ_MODIFY_WRITE_SEQ__MAX 5
321 struct dmub_rb_cmd_read_modify_write {
322 struct dmub_cmd_header header; // type = DMUB_CMD__REG_SEQ_READ_MODIFY_WRITE
323 struct dmub_cmd_read_modify_write_sequence seq[DMUB_READ_MODIFY_WRITE_SEQ__MAX];
327 * Update a register with specified masks and values sequeunce
329 * 60 payload bytes can hold address + up to 7 sets of mask/value combo, each take 2 dword
331 * number of field update sequence = (header.payload_bytes - sizeof(addr)) / sizeof(struct read_modify_write_sequence)
335 * 1. auto-increment register where additional read would update pointer and produce wrong result
336 * 2. toggle a bit without read in the middle
339 struct dmub_cmd_reg_field_update_sequence {
340 uint32_t modify_mask; // 0xffff'ffff to skip initial read
341 uint32_t modify_value;
344 #define DMUB_REG_FIELD_UPDATE_SEQ__MAX 7
345 struct dmub_rb_cmd_reg_field_update_sequence {
346 struct dmub_cmd_header header;
348 struct dmub_cmd_reg_field_update_sequence seq[DMUB_REG_FIELD_UPDATE_SEQ__MAX];
354 * support use case such as writing out LUTs.
356 * 60 payload bytes can hold up to 14 values to write to given address
358 * number of payload = header.payload_bytes / sizeof(struct read_modify_write_sequence)
360 #define DMUB_BURST_WRITE_VALUES__MAX 14
361 struct dmub_rb_cmd_burst_write {
362 struct dmub_cmd_header header; // type = DMUB_CMD__REG_SEQ_BURST_WRITE
364 uint32_t write_values[DMUB_BURST_WRITE_VALUES__MAX];
368 struct dmub_rb_cmd_common {
369 struct dmub_cmd_header header;
370 uint8_t cmd_buffer[DMUB_RB_CMD_SIZE - sizeof(struct dmub_cmd_header)];
373 struct dmub_cmd_reg_wait_data {
376 uint32_t condition_field_value;
377 uint32_t time_out_us;
380 struct dmub_rb_cmd_reg_wait {
381 struct dmub_cmd_header header;
382 struct dmub_cmd_reg_wait_data reg_wait;
385 struct dmub_cmd_PLAT_54186_wa {
386 uint32_t DCSURF_SURFACE_CONTROL;
387 uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS_HIGH;
388 uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS;
389 uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS_HIGH_C;
390 uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS_C;
392 uint8_t hubp_inst : 4;
393 uint8_t tmz_surface : 1;
394 uint8_t immediate :1;
396 uint8_t grph_stereo : 1;
397 uint32_t reserved : 21;
399 uint32_t reserved[9];
402 struct dmub_rb_cmd_PLAT_54186_wa {
403 struct dmub_cmd_header header;
404 struct dmub_cmd_PLAT_54186_wa flip;
407 struct dmub_cmd_digx_encoder_control_data {
408 union dig_encoder_control_parameters_v1_5 dig;
411 struct dmub_rb_cmd_digx_encoder_control {
412 struct dmub_cmd_header header;
413 struct dmub_cmd_digx_encoder_control_data encoder_control;
416 struct dmub_cmd_set_pixel_clock_data {
417 struct set_pixel_clock_parameter_v1_7 clk;
420 struct dmub_rb_cmd_set_pixel_clock {
421 struct dmub_cmd_header header;
422 struct dmub_cmd_set_pixel_clock_data pixel_clock;
425 struct dmub_cmd_enable_disp_power_gating_data {
426 struct enable_disp_power_gating_parameters_v2_1 pwr;
429 struct dmub_rb_cmd_enable_disp_power_gating {
430 struct dmub_cmd_header header;
431 struct dmub_cmd_enable_disp_power_gating_data power_gating;
434 struct dmub_cmd_dig1_transmitter_control_data {
435 struct dig_transmitter_control_parameters_v1_6 dig;
438 struct dmub_rb_cmd_dig1_transmitter_control {
439 struct dmub_cmd_header header;
440 struct dmub_cmd_dig1_transmitter_control_data transmitter_control;
443 struct dmub_rb_cmd_dpphy_init {
444 struct dmub_cmd_header header;
445 uint8_t reserved[60];
449 * Command IDs should be treated as stable ABI.
450 * Do not reuse or modify IDs.
453 enum dmub_cmd_psr_type {
454 DMUB_CMD__PSR_SET_VERSION = 0,
455 DMUB_CMD__PSR_COPY_SETTINGS = 1,
456 DMUB_CMD__PSR_ENABLE = 2,
457 DMUB_CMD__PSR_DISABLE = 3,
458 DMUB_CMD__PSR_SET_LEVEL = 4,
463 PSR_VERSION_UNSUPPORTED = 0xFFFFFFFF,
466 struct dmub_cmd_psr_copy_settings_data {
467 union dmub_psr_debug_flags debug;
477 uint8_t smu_optimizations_en;
479 uint8_t frame_cap_ind;
481 uint16_t init_sdp_deadline;
485 struct dmub_rb_cmd_psr_copy_settings {
486 struct dmub_cmd_header header;
487 struct dmub_cmd_psr_copy_settings_data psr_copy_settings_data;
490 struct dmub_cmd_psr_set_level_data {
495 struct dmub_rb_cmd_psr_set_level {
496 struct dmub_cmd_header header;
497 struct dmub_cmd_psr_set_level_data psr_set_level_data;
500 struct dmub_rb_cmd_psr_enable {
501 struct dmub_cmd_header header;
504 struct dmub_cmd_psr_set_version_data {
505 enum psr_version version; // PSR version 1 or 2
508 struct dmub_rb_cmd_psr_set_version {
509 struct dmub_cmd_header header;
510 struct dmub_cmd_psr_set_version_data psr_set_version_data;
513 union dmub_hw_lock_flags {
515 uint8_t lock_pipe : 1;
516 uint8_t lock_cursor : 1;
517 uint8_t lock_dig : 1;
518 uint8_t triple_buffer_lock : 1;
524 struct dmub_hw_lock_inst_flags {
531 enum hw_lock_client {
532 HW_LOCK_CLIENT_DRIVER = 0,
534 HW_LOCK_CLIENT_INVALID = 0xFFFFFFFF,
537 struct dmub_cmd_lock_hw_data {
538 enum hw_lock_client client;
539 struct dmub_hw_lock_inst_flags inst_flags;
540 union dmub_hw_lock_flags hw_locks;
542 uint8_t should_release;
546 struct dmub_rb_cmd_lock_hw {
547 struct dmub_cmd_header header;
548 struct dmub_cmd_lock_hw_data lock_hw_data;
551 enum dmub_cmd_abm_type {
552 DMUB_CMD__ABM_INIT_CONFIG = 0,
553 DMUB_CMD__ABM_SET_PIPE = 1,
554 DMUB_CMD__ABM_SET_BACKLIGHT = 2,
555 DMUB_CMD__ABM_SET_LEVEL = 3,
556 DMUB_CMD__ABM_SET_AMBIENT_LEVEL = 4,
557 DMUB_CMD__ABM_SET_PWM_FRAC = 5,
560 #define NUM_AMBI_LEVEL 5
561 #define NUM_AGGR_LEVEL 4
562 #define NUM_POWER_FN_SEGS 8
563 #define NUM_BL_CURVE_SEGS 16
566 * Parameters for ABM2.4 algorithm.
567 * Padded explicitly to 32-bit boundary.
569 struct abm_config_table {
570 /* Parameters for crgb conversion */
571 uint16_t crgb_thresh[NUM_POWER_FN_SEGS]; // 0B
572 uint16_t crgb_offset[NUM_POWER_FN_SEGS]; // 15B
573 uint16_t crgb_slope[NUM_POWER_FN_SEGS]; // 31B
575 /* Parameters for custom curve */
576 uint16_t backlight_thresholds[NUM_BL_CURVE_SEGS]; // 47B
577 uint16_t backlight_offsets[NUM_BL_CURVE_SEGS]; // 79B
579 uint16_t ambient_thresholds_lux[NUM_AMBI_LEVEL]; // 111B
580 uint16_t min_abm_backlight; // 121B
582 uint8_t min_reduction[NUM_AMBI_LEVEL][NUM_AGGR_LEVEL]; // 123B
583 uint8_t max_reduction[NUM_AMBI_LEVEL][NUM_AGGR_LEVEL]; // 143B
584 uint8_t bright_pos_gain[NUM_AMBI_LEVEL][NUM_AGGR_LEVEL]; // 163B
585 uint8_t dark_pos_gain[NUM_AMBI_LEVEL][NUM_AGGR_LEVEL]; // 183B
586 uint8_t hybrid_factor[NUM_AGGR_LEVEL]; // 203B
587 uint8_t contrast_factor[NUM_AGGR_LEVEL]; // 207B
588 uint8_t deviation_gain[NUM_AGGR_LEVEL]; // 211B
589 uint8_t min_knee[NUM_AGGR_LEVEL]; // 215B
590 uint8_t max_knee[NUM_AGGR_LEVEL]; // 219B
591 uint8_t iir_curve[NUM_AMBI_LEVEL]; // 223B
592 uint8_t pad3[3]; // 228B
595 struct dmub_cmd_abm_set_pipe_data {
598 uint8_t set_pipe_option;
599 uint8_t ramping_boundary; // TODO: Remove this
602 struct dmub_rb_cmd_abm_set_pipe {
603 struct dmub_cmd_header header;
604 struct dmub_cmd_abm_set_pipe_data abm_set_pipe_data;
607 struct dmub_cmd_abm_set_backlight_data {
609 uint32_t backlight_user_level;
612 struct dmub_rb_cmd_abm_set_backlight {
613 struct dmub_cmd_header header;
614 struct dmub_cmd_abm_set_backlight_data abm_set_backlight_data;
617 struct dmub_cmd_abm_set_level_data {
621 struct dmub_rb_cmd_abm_set_level {
622 struct dmub_cmd_header header;
623 struct dmub_cmd_abm_set_level_data abm_set_level_data;
626 struct dmub_cmd_abm_set_ambient_level_data {
627 uint32_t ambient_lux;
630 struct dmub_rb_cmd_abm_set_ambient_level {
631 struct dmub_cmd_header header;
632 struct dmub_cmd_abm_set_ambient_level_data abm_set_ambient_level_data;
635 struct dmub_cmd_abm_set_pwm_frac_data {
636 uint32_t fractional_pwm;
639 struct dmub_rb_cmd_abm_set_pwm_frac {
640 struct dmub_cmd_header header;
641 struct dmub_cmd_abm_set_pwm_frac_data abm_set_pwm_frac_data;
644 struct dmub_cmd_abm_init_config_data {
649 struct dmub_rb_cmd_abm_init_config {
650 struct dmub_cmd_header header;
651 struct dmub_cmd_abm_init_config_data abm_init_config_data;
655 struct dmub_rb_cmd_lock_hw lock_hw;
656 struct dmub_rb_cmd_read_modify_write read_modify_write;
657 struct dmub_rb_cmd_reg_field_update_sequence reg_field_update_seq;
658 struct dmub_rb_cmd_burst_write burst_write;
659 struct dmub_rb_cmd_reg_wait reg_wait;
660 struct dmub_rb_cmd_common cmd_common;
661 struct dmub_rb_cmd_digx_encoder_control digx_encoder_control;
662 struct dmub_rb_cmd_set_pixel_clock set_pixel_clock;
663 struct dmub_rb_cmd_enable_disp_power_gating enable_disp_power_gating;
664 struct dmub_rb_cmd_dpphy_init dpphy_init;
665 struct dmub_rb_cmd_dig1_transmitter_control dig1_transmitter_control;
666 struct dmub_rb_cmd_psr_set_version psr_set_version;
667 struct dmub_rb_cmd_psr_copy_settings psr_copy_settings;
668 struct dmub_rb_cmd_psr_enable psr_enable;
669 struct dmub_rb_cmd_psr_set_level psr_set_level;
670 struct dmub_rb_cmd_PLAT_54186_wa PLAT_54186_wa;
671 struct dmub_rb_cmd_abm_set_pipe abm_set_pipe;
672 struct dmub_rb_cmd_abm_set_backlight abm_set_backlight;
673 struct dmub_rb_cmd_abm_set_level abm_set_level;
674 struct dmub_rb_cmd_abm_set_ambient_level abm_set_ambient_level;
675 struct dmub_rb_cmd_abm_set_pwm_frac abm_set_pwm_frac;
676 struct dmub_rb_cmd_abm_init_config abm_init_config;
682 //==============================================================================
683 //</DMUB_CMD>===================================================================
684 //==============================================================================
685 //< DMUB_RB>====================================================================
686 //==============================================================================
688 #if defined(__cplusplus)
692 struct dmub_rb_init_params {
712 static inline bool dmub_rb_empty(struct dmub_rb *rb)
714 return (rb->wrpt == rb->rptr);
717 static inline bool dmub_rb_full(struct dmub_rb *rb)
721 if (rb->wrpt >= rb->rptr)
722 data_count = rb->wrpt - rb->rptr;
724 data_count = rb->capacity - (rb->rptr - rb->wrpt);
726 return (data_count == (rb->capacity - DMUB_RB_CMD_SIZE));
729 static inline bool dmub_rb_push_front(struct dmub_rb *rb,
730 const union dmub_rb_cmd *cmd)
732 uint64_t volatile *dst = (uint64_t volatile *)(rb->base_address) + rb->wrpt / sizeof(uint64_t);
733 const uint64_t *src = (const uint64_t *)cmd;
736 if (dmub_rb_full(rb))
740 for (i = 0; i < DMUB_RB_CMD_SIZE / sizeof(uint64_t); i++)
743 rb->wrpt += DMUB_RB_CMD_SIZE;
745 if (rb->wrpt >= rb->capacity)
746 rb->wrpt %= rb->capacity;
751 static inline bool dmub_rb_front(struct dmub_rb *rb,
752 union dmub_rb_cmd *cmd)
754 uint8_t *rd_ptr = (uint8_t *)rb->base_address + rb->rptr;
756 if (dmub_rb_empty(rb))
759 dmub_memcpy(cmd, rd_ptr, DMUB_RB_CMD_SIZE);
764 static inline bool dmub_rb_pop_front(struct dmub_rb *rb)
766 if (dmub_rb_empty(rb))
769 rb->rptr += DMUB_RB_CMD_SIZE;
771 if (rb->rptr >= rb->capacity)
772 rb->rptr %= rb->capacity;
777 static inline void dmub_rb_flush_pending(const struct dmub_rb *rb)
779 uint32_t rptr = rb->rptr;
780 uint32_t wptr = rb->wrpt;
782 while (rptr != wptr) {
783 uint64_t volatile *data = (uint64_t volatile *)rb->base_address + rptr / sizeof(uint64_t);
784 //uint64_t volatile *p = (uint64_t volatile *)data;
788 for (i = 0; i < DMUB_RB_CMD_SIZE / sizeof(uint64_t); i++)
791 rptr += DMUB_RB_CMD_SIZE;
792 if (rptr >= rb->capacity)
793 rptr %= rb->capacity;
797 static inline void dmub_rb_init(struct dmub_rb *rb,
798 struct dmub_rb_init_params *init_params)
800 rb->base_address = init_params->base_address;
801 rb->capacity = init_params->capacity;
802 rb->rptr = init_params->read_ptr;
803 rb->wrpt = init_params->write_ptr;
806 #if defined(__cplusplus)
810 //==============================================================================
811 //</DMUB_RB>====================================================================
812 //==============================================================================
814 #endif /* _DMUB_CMD_H_ */