1 /* 2 * Copyright 2012-15 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 __DAL_LOGGER_INTERFACE_H__ 27 #define __DAL_LOGGER_INTERFACE_H__ 28 29 #include "logger_types.h" 30 31 struct dc_context; 32 struct dc_link; 33 struct dc_surface_update; 34 struct resource_context; 35 struct dc_state; 36 37 /* 38 * 39 * DAL logger functionality 40 * 41 */ 42 43 struct dal_logger *dal_logger_create(struct dc_context *ctx, uint32_t log_mask); 44 45 uint32_t dal_logger_destroy(struct dal_logger **logger); 46 47 void dm_logger_flush_buffer(struct dal_logger *logger, bool should_warn); 48 49 void dm_logger_write( 50 struct dal_logger *logger, 51 enum dc_log_type log_type, 52 const char *msg, 53 ...); 54 55 void dm_logger_append( 56 struct log_entry *entry, 57 const char *msg, 58 ...); 59 60 void dm_logger_append_va( 61 struct log_entry *entry, 62 const char *msg, 63 va_list args); 64 65 void dm_logger_append_heading(struct log_entry *entry); 66 67 void dm_logger_open( 68 struct dal_logger *logger, 69 struct log_entry *entry, 70 enum dc_log_type log_type); 71 72 void dm_logger_close(struct log_entry *entry); 73 74 void dc_conn_log(struct dc_context *ctx, 75 const struct dc_link *link, 76 uint8_t *hex_data, 77 int hex_data_count, 78 enum dc_log_type event, 79 const char *msg, 80 ...); 81 82 void logger_write(struct dal_logger *logger, 83 enum dc_log_type log_type, 84 const char *msg, 85 void *paralist); 86 87 void pre_surface_trace( 88 struct dc *dc, 89 const struct dc_plane_state *const *plane_states, 90 int surface_count); 91 92 void update_surface_trace( 93 struct dc *dc, 94 const struct dc_surface_update *updates, 95 int surface_count); 96 97 void post_surface_trace(struct dc *dc); 98 99 void context_timing_trace( 100 struct dc *dc, 101 struct resource_context *res_ctx); 102 103 void context_clock_trace( 104 struct dc *dc, 105 struct dc_state *context); 106 107 /* Any function which is empty or have incomplete implementation should be 108 * marked by this macro. 109 * Note that the message will be printed exactly once for every function 110 * it is used in order to avoid repeating of the same message. */ 111 #define DAL_LOGGER_NOT_IMPL(fmt, ...) \ 112 { \ 113 static bool print_not_impl = true; \ 114 \ 115 if (print_not_impl == true) { \ 116 print_not_impl = false; \ 117 dm_logger_write(ctx->logger, LOG_WARNING, \ 118 "DAL_NOT_IMPL: " fmt, ##__VA_ARGS__); \ 119 } \ 120 } 121 122 /****************************************************************************** 123 * Convenience macros to save on typing. 124 *****************************************************************************/ 125 126 #define DC_ERROR(...) \ 127 dm_logger_write(dc_ctx->logger, LOG_ERROR, \ 128 __VA_ARGS__) 129 130 #define DC_SYNC_INFO(...) \ 131 dm_logger_write(dc_ctx->logger, LOG_SYNC, \ 132 __VA_ARGS__) 133 134 /* Connectivity log format: 135 * [time stamp] [drm] [Major_minor] [connector name] message..... 136 * eg: 137 * [ 26.590965] [drm] [Conn_LKTN] [DP-1] HBRx4 pass VS=0, PE=0^ 138 * [ 26.881060] [drm] [Conn_Mode] [DP-1] {2560x1080, 2784x1111@185580Khz}^ 139 */ 140 141 #define CONN_DATA_DETECT(link, hex_data, hex_len, ...) \ 142 dc_conn_log(link->ctx, link, hex_data, hex_len, \ 143 LOG_EVENT_DETECTION, ##__VA_ARGS__) 144 145 #define CONN_DATA_LINK_LOSS(link, hex_data, hex_len, ...) \ 146 dc_conn_log(link->ctx, link, hex_data, hex_len, \ 147 LOG_EVENT_LINK_LOSS, ##__VA_ARGS__) 148 149 #define CONN_MSG_LT(link, ...) \ 150 dc_conn_log(link->ctx, link, NULL, 0, \ 151 LOG_EVENT_LINK_TRAINING, ##__VA_ARGS__) 152 153 #define CONN_MSG_MODE(link, ...) \ 154 dc_conn_log(link->ctx, link, NULL, 0, \ 155 LOG_EVENT_MODE_SET, ##__VA_ARGS__) 156 157 /* 158 * Display Test Next logging 159 */ 160 #define DTN_INFO_BEGIN() \ 161 dm_dtn_log_begin(dc_ctx) 162 163 #define DTN_INFO(msg, ...) \ 164 dm_dtn_log_append_v(dc_ctx, msg, ##__VA_ARGS__) 165 166 #define DTN_INFO_END() \ 167 dm_dtn_log_end(dc_ctx) 168 169 #define PERFORMANCE_TRACE_START() \ 170 unsigned long long perf_trc_start_stmp = dm_get_timestamp(dc->ctx); \ 171 unsigned long long perf_trc_start_log_msk = dc->ctx->logger->mask; \ 172 unsigned int perf_trc_start_log_flags = dc->ctx->logger->flags.value; \ 173 if (dc->debug.performance_trace) {\ 174 dm_logger_flush_buffer(dc->ctx->logger, false);\ 175 dc->ctx->logger->mask = 1<<LOG_PERF_TRACE;\ 176 dc->ctx->logger->flags.bits.ENABLE_CONSOLE = 0;\ 177 dc->ctx->logger->flags.bits.ENABLE_BUFFER = 1;\ 178 } 179 180 #define PERFORMANCE_TRACE_END() do {\ 181 unsigned long long perf_trc_end_stmp = dm_get_timestamp(dc->ctx);\ 182 if (dc->debug.performance_trace) {\ 183 dm_logger_write(dc->ctx->logger, \ 184 LOG_PERF_TRACE, \ 185 "%s duration: %d ticks\n", __func__,\ 186 perf_trc_end_stmp - perf_trc_start_stmp); \ 187 if (perf_trc_start_log_msk != 1<<LOG_PERF_TRACE) {\ 188 dc->ctx->logger->mask = perf_trc_start_log_msk;\ 189 dc->ctx->logger->flags.value = perf_trc_start_log_flags;\ 190 dm_logger_flush_buffer(dc->ctx->logger, false);\ 191 } \ 192 } \ 193 } while (0) 194 195 #define DISPLAY_STATS_BEGIN(entry) \ 196 dm_logger_open(dc->ctx->logger, &entry, LOG_DISPLAYSTATS) 197 198 #define DISPLAY_STATS(msg, ...) \ 199 dm_logger_append(&log_entry, msg, ##__VA_ARGS__) 200 201 #define DISPLAY_STATS_END(entry) \ 202 dm_logger_close(&entry) 203 204 #endif /* __DAL_LOGGER_INTERFACE_H__ */ 205