| .. | .. |
|---|
| 31 | 31 | |
|---|
| 32 | 32 | #define __DM_SERVICES_H__ |
|---|
| 33 | 33 | |
|---|
| 34 | +#include "amdgpu_dm_trace.h" |
|---|
| 35 | + |
|---|
| 34 | 36 | /* TODO: remove when DC is complete. */ |
|---|
| 35 | 37 | #include "dm_services_types.h" |
|---|
| 36 | 38 | #include "logger_interface.h" |
|---|
| 37 | 39 | #include "link_service_types.h" |
|---|
| 38 | 40 | |
|---|
| 39 | 41 | #undef DEPRECATED |
|---|
| 42 | + |
|---|
| 43 | +struct dmub_srv; |
|---|
| 44 | +struct dc_dmub_srv; |
|---|
| 40 | 45 | |
|---|
| 41 | 46 | irq_handler_idx dm_register_interrupt( |
|---|
| 42 | 47 | struct dc_context *ctx, |
|---|
| .. | .. |
|---|
| 50 | 55 | * GPU registers access |
|---|
| 51 | 56 | * |
|---|
| 52 | 57 | */ |
|---|
| 53 | | - |
|---|
| 58 | +uint32_t dm_read_reg_func( |
|---|
| 59 | + const struct dc_context *ctx, |
|---|
| 60 | + uint32_t address, |
|---|
| 61 | + const char *func_name); |
|---|
| 54 | 62 | /* enable for debugging new code, this adds 50k to the driver size. */ |
|---|
| 55 | 63 | /* #define DM_CHECK_ADDR_0 */ |
|---|
| 56 | 64 | |
|---|
| 57 | 65 | #define dm_read_reg(ctx, address) \ |
|---|
| 58 | 66 | dm_read_reg_func(ctx, address, __func__) |
|---|
| 59 | 67 | |
|---|
| 60 | | -static inline uint32_t dm_read_reg_func( |
|---|
| 61 | | - const struct dc_context *ctx, |
|---|
| 62 | | - uint32_t address, |
|---|
| 63 | | - const char *func_name) |
|---|
| 64 | | -{ |
|---|
| 65 | | - uint32_t value; |
|---|
| 66 | | -#ifdef DM_CHECK_ADDR_0 |
|---|
| 67 | | - if (address == 0) { |
|---|
| 68 | | - DC_ERR("invalid register read; address = 0\n"); |
|---|
| 69 | | - return 0; |
|---|
| 70 | | - } |
|---|
| 71 | | -#endif |
|---|
| 72 | | - value = cgs_read_register(ctx->cgs_device, address); |
|---|
| 73 | 68 | |
|---|
| 74 | | - return value; |
|---|
| 75 | | -} |
|---|
| 76 | 69 | |
|---|
| 77 | 70 | #define dm_write_reg(ctx, address, value) \ |
|---|
| 78 | 71 | dm_write_reg_func(ctx, address, value, __func__) |
|---|
| .. | .. |
|---|
| 90 | 83 | } |
|---|
| 91 | 84 | #endif |
|---|
| 92 | 85 | cgs_write_register(ctx->cgs_device, address, value); |
|---|
| 86 | + trace_amdgpu_dc_wreg(&ctx->perf_trace->write_count, address, value); |
|---|
| 93 | 87 | } |
|---|
| 94 | 88 | |
|---|
| 95 | 89 | static inline uint32_t dm_read_index_reg( |
|---|
| .. | .. |
|---|
| 140 | 134 | reg_name ## __ ## reg_field ## _MASK,\ |
|---|
| 141 | 135 | reg_name ## __ ## reg_field ## __SHIFT) |
|---|
| 142 | 136 | |
|---|
| 143 | | -uint32_t generic_reg_update_ex(const struct dc_context *ctx, |
|---|
| 137 | +uint32_t generic_reg_set_ex(const struct dc_context *ctx, |
|---|
| 144 | 138 | uint32_t addr, uint32_t reg_val, int n, |
|---|
| 145 | 139 | uint8_t shift1, uint32_t mask1, uint32_t field_value1, ...); |
|---|
| 140 | + |
|---|
| 141 | +uint32_t generic_reg_update_ex(const struct dc_context *ctx, |
|---|
| 142 | + uint32_t addr, int n, |
|---|
| 143 | + uint8_t shift1, uint32_t mask1, uint32_t field_value1, ...); |
|---|
| 144 | + |
|---|
| 145 | +struct dc_dmub_srv *dc_dmub_srv_create(struct dc *dc, struct dmub_srv *dmub); |
|---|
| 146 | +void dc_dmub_srv_destroy(struct dc_dmub_srv **dmub_srv); |
|---|
| 147 | + |
|---|
| 148 | +void reg_sequence_start_gather(const struct dc_context *ctx); |
|---|
| 149 | +void reg_sequence_start_execute(const struct dc_context *ctx); |
|---|
| 150 | +void reg_sequence_wait_done(const struct dc_context *ctx); |
|---|
| 146 | 151 | |
|---|
| 147 | 152 | #define FD(reg_field) reg_field ## __SHIFT, \ |
|---|
| 148 | 153 | reg_field ## _MASK |
|---|
| .. | .. |
|---|
| 151 | 156 | * return number of poll before condition is met |
|---|
| 152 | 157 | * return 0 if condition is not meet after specified time out tries |
|---|
| 153 | 158 | */ |
|---|
| 154 | | -unsigned int generic_reg_wait(const struct dc_context *ctx, |
|---|
| 159 | +void generic_reg_wait(const struct dc_context *ctx, |
|---|
| 155 | 160 | uint32_t addr, uint32_t mask, uint32_t shift, uint32_t condition_value, |
|---|
| 156 | 161 | unsigned int delay_between_poll_us, unsigned int time_out_num_tries, |
|---|
| 157 | 162 | const char *func_name, int line); |
|---|
| 158 | 163 | |
|---|
| 164 | +unsigned int snprintf_count(char *pBuf, unsigned int bufSize, char *fmt, ...); |
|---|
| 159 | 165 | |
|---|
| 160 | 166 | /* These macros need to be used with soc15 registers in order to retrieve |
|---|
| 161 | 167 | * the actual offset. |
|---|
| .. | .. |
|---|
| 168 | 174 | |
|---|
| 169 | 175 | #define generic_reg_update_soc15(ctx, inst_offset, reg_name, n, ...)\ |
|---|
| 170 | 176 | generic_reg_update_ex(ctx, DCE_BASE.instance[0].segment[mm##reg_name##_BASE_IDX] + mm##reg_name + inst_offset, \ |
|---|
| 171 | | - dm_read_reg_func(ctx, mm##reg_name + DCE_BASE.instance[0].segment[mm##reg_name##_BASE_IDX] + inst_offset, __func__), \ |
|---|
| 172 | 177 | n, __VA_ARGS__) |
|---|
| 173 | 178 | |
|---|
| 174 | 179 | #define generic_reg_set_soc15(ctx, inst_offset, reg_name, n, ...)\ |
|---|
| 175 | | - generic_reg_update_ex(ctx, DCE_BASE.instance[0].segment[mm##reg_name##_BASE_IDX] + mm##reg_name + inst_offset, 0, \ |
|---|
| 180 | + generic_reg_set_ex(ctx, DCE_BASE.instance[0].segment[mm##reg_name##_BASE_IDX] + mm##reg_name + inst_offset, 0, \ |
|---|
| 176 | 181 | n, __VA_ARGS__) |
|---|
| 177 | 182 | |
|---|
| 178 | 183 | #define get_reg_field_value_soc15(reg_value, block, reg_num, reg_name, reg_field)\ |
|---|
| .. | .. |
|---|
| 219 | 224 | const struct dc_context *ctx, |
|---|
| 220 | 225 | struct dm_pp_wm_sets_with_clock_ranges *wm_with_clock_ranges); |
|---|
| 221 | 226 | |
|---|
| 222 | | -void dm_pp_get_funcs_rv(struct dc_context *ctx, |
|---|
| 223 | | - struct pp_smu_funcs_rv *funcs); |
|---|
| 227 | +void dm_pp_get_funcs(struct dc_context *ctx, |
|---|
| 228 | + struct pp_smu_funcs *funcs); |
|---|
| 224 | 229 | |
|---|
| 225 | 230 | /* DAL calls this function to notify PP about completion of Mode Set. |
|---|
| 226 | 231 | * For PP it means that current DCE clocks are those which were returned |
|---|
| .. | .. |
|---|
| 256 | 261 | bool save_per_edid; |
|---|
| 257 | 262 | }; |
|---|
| 258 | 263 | |
|---|
| 259 | | -/* Call to write data in registry editor for persistent data storage. |
|---|
| 260 | | - * |
|---|
| 261 | | - * \inputs sink - identify edid/link for registry folder creation |
|---|
| 262 | | - * module name - identify folders for registry |
|---|
| 263 | | - * key name - identify keys within folders for registry |
|---|
| 264 | | - * params - value to write in defined folder/key |
|---|
| 265 | | - * size - size of the input params |
|---|
| 266 | | - * flag - determine whether to save by link or edid |
|---|
| 267 | | - * |
|---|
| 268 | | - * \returns true - call is successful |
|---|
| 269 | | - * false - call failed |
|---|
| 270 | | - * |
|---|
| 271 | | - * sink module key |
|---|
| 272 | | - * ----------------------------------------------------------------------------- |
|---|
| 273 | | - * NULL NULL NULL - failure |
|---|
| 274 | | - * NULL NULL - - create key with param value |
|---|
| 275 | | - * under base folder |
|---|
| 276 | | - * NULL - NULL - create module folder under base folder |
|---|
| 277 | | - * - NULL NULL - failure |
|---|
| 278 | | - * NULL - - - create key under module folder |
|---|
| 279 | | - * with no edid/link identification |
|---|
| 280 | | - * - NULL - - create key with param value |
|---|
| 281 | | - * under base folder |
|---|
| 282 | | - * - - NULL - create module folder under base folder |
|---|
| 283 | | - * - - - - create key under module folder |
|---|
| 284 | | - * with edid/link identification |
|---|
| 285 | | - */ |
|---|
| 286 | | -bool dm_write_persistent_data(struct dc_context *ctx, |
|---|
| 287 | | - const struct dc_sink *sink, |
|---|
| 288 | | - const char *module_name, |
|---|
| 289 | | - const char *key_name, |
|---|
| 290 | | - void *params, |
|---|
| 291 | | - unsigned int size, |
|---|
| 292 | | - struct persistent_data_flag *flag); |
|---|
| 293 | | - |
|---|
| 294 | | - |
|---|
| 295 | | -/* Call to read data in registry editor for persistent data storage. |
|---|
| 296 | | - * |
|---|
| 297 | | - * \inputs sink - identify edid/link for registry folder creation |
|---|
| 298 | | - * module name - identify folders for registry |
|---|
| 299 | | - * key name - identify keys within folders for registry |
|---|
| 300 | | - * size - size of the output params |
|---|
| 301 | | - * flag - determine whether it was save by link or edid |
|---|
| 302 | | - * |
|---|
| 303 | | - * \returns params - value read from defined folder/key |
|---|
| 304 | | - * true - call is successful |
|---|
| 305 | | - * false - call failed |
|---|
| 306 | | - * |
|---|
| 307 | | - * sink module key |
|---|
| 308 | | - * ----------------------------------------------------------------------------- |
|---|
| 309 | | - * NULL NULL NULL - failure |
|---|
| 310 | | - * NULL NULL - - read key under base folder |
|---|
| 311 | | - * NULL - NULL - failure |
|---|
| 312 | | - * - NULL NULL - failure |
|---|
| 313 | | - * NULL - - - read key under module folder |
|---|
| 314 | | - * with no edid/link identification |
|---|
| 315 | | - * - NULL - - read key under base folder |
|---|
| 316 | | - * - - NULL - failure |
|---|
| 317 | | - * - - - - read key under module folder |
|---|
| 318 | | - * with edid/link identification |
|---|
| 319 | | - */ |
|---|
| 320 | | -bool dm_read_persistent_data(struct dc_context *ctx, |
|---|
| 321 | | - const struct dc_sink *sink, |
|---|
| 322 | | - const char *module_name, |
|---|
| 323 | | - const char *key_name, |
|---|
| 324 | | - void *params, |
|---|
| 325 | | - unsigned int size, |
|---|
| 326 | | - struct persistent_data_flag *flag); |
|---|
| 327 | | - |
|---|
| 328 | 264 | bool dm_query_extended_brightness_caps |
|---|
| 329 | 265 | (struct dc_context *ctx, enum dm_acpi_display_type display, |
|---|
| 330 | 266 | struct dm_acpi_atif_backlight_caps *pCaps); |
|---|
| .. | .. |
|---|
| 351 | 287 | /* |
|---|
| 352 | 288 | * performance tracing |
|---|
| 353 | 289 | */ |
|---|
| 354 | | -void dm_perf_trace_timestamp(const char *func_name, unsigned int line); |
|---|
| 355 | | -#define PERF_TRACE() dm_perf_trace_timestamp(__func__, __LINE__) |
|---|
| 290 | +#define PERF_TRACE() trace_amdgpu_dc_performance(CTX->perf_trace->read_count,\ |
|---|
| 291 | + CTX->perf_trace->write_count, &CTX->perf_trace->last_entry_read,\ |
|---|
| 292 | + &CTX->perf_trace->last_entry_write, __func__, __LINE__) |
|---|
| 293 | +#define PERF_TRACE_CTX(__CTX) trace_amdgpu_dc_performance(__CTX->perf_trace->read_count,\ |
|---|
| 294 | + __CTX->perf_trace->write_count, &__CTX->perf_trace->last_entry_read,\ |
|---|
| 295 | + &__CTX->perf_trace->last_entry_write, __func__, __LINE__) |
|---|
| 356 | 296 | |
|---|
| 357 | 297 | |
|---|
| 358 | 298 | /* |
|---|
| 359 | 299 | * Debug and verification hooks |
|---|
| 360 | 300 | */ |
|---|
| 361 | 301 | |
|---|
| 362 | | -void dm_dtn_log_begin(struct dc_context *ctx); |
|---|
| 363 | | -void dm_dtn_log_append_v(struct dc_context *ctx, const char *msg, ...); |
|---|
| 364 | | -void dm_dtn_log_end(struct dc_context *ctx); |
|---|
| 302 | +void dm_dtn_log_begin(struct dc_context *ctx, |
|---|
| 303 | + struct dc_log_buffer_ctx *log_ctx); |
|---|
| 304 | +void dm_dtn_log_append_v(struct dc_context *ctx, |
|---|
| 305 | + struct dc_log_buffer_ctx *log_ctx, |
|---|
| 306 | + const char *msg, ...); |
|---|
| 307 | +void dm_dtn_log_end(struct dc_context *ctx, |
|---|
| 308 | + struct dc_log_buffer_ctx *log_ctx); |
|---|
| 365 | 309 | |
|---|
| 366 | 310 | #endif /* __DM_SERVICES_H__ */ |
|---|