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 36 /* 37 * 38 * DAL logger functionality 39 * 40 */ 41 42 struct dal_logger *dal_logger_create(struct dc_context *ctx); 43 44 uint32_t dal_logger_destroy(struct dal_logger **logger); 45 46 void dm_logger_write( 47 struct dal_logger *logger, 48 enum dc_log_type log_type, 49 const char *msg, 50 ...); 51 52 void dm_logger_append( 53 struct log_entry *entry, 54 const char *msg, 55 ...); 56 57 void dm_logger_open( 58 struct dal_logger *logger, 59 struct log_entry *entry, 60 enum dc_log_type log_type); 61 62 void dm_logger_close(struct log_entry *entry); 63 64 void dc_conn_log(struct dc_context *ctx, 65 const struct dc_link *link, 66 uint8_t *hex_data, 67 int hex_data_count, 68 enum dc_log_type event, 69 const char *msg, 70 ...); 71 72 void logger_write(struct dal_logger *logger, 73 enum dc_log_type log_type, 74 const char *msg, 75 void *paralist); 76 77 void pre_surface_trace( 78 const struct dc *dc, 79 const struct dc_surface *const *surfaces, 80 int surface_count); 81 82 void update_surface_trace( 83 const struct dc *dc, 84 const struct dc_surface_update *updates, 85 int surface_count); 86 87 void post_surface_trace(const struct dc *dc); 88 89 void context_timing_trace( 90 const struct dc *dc, 91 struct resource_context *res_ctx); 92 93 94 /* Any function which is empty or have incomplete implementation should be 95 * marked by this macro. 96 * Note that the message will be printed exactly once for every function 97 * it is used in order to avoid repeating of the same message. */ 98 #define DAL_LOGGER_NOT_IMPL(fmt, ...) \ 99 { \ 100 static bool print_not_impl = true; \ 101 \ 102 if (print_not_impl == true) { \ 103 print_not_impl = false; \ 104 dm_logger_write(ctx->logger, LOG_WARNING, \ 105 "DAL_NOT_IMPL: " fmt, ##__VA_ARGS__); \ 106 } \ 107 } 108 109 /****************************************************************************** 110 * Convenience macros to save on typing. 111 *****************************************************************************/ 112 113 #define DC_ERROR(...) \ 114 dm_logger_write(dc_ctx->logger, LOG_ERROR, \ 115 __VA_ARGS__); 116 117 #define DC_SYNC_INFO(...) \ 118 dm_logger_write(dc_ctx->logger, LOG_SYNC, \ 119 __VA_ARGS__); 120 121 122 /* Connectivity log format: 123 * [time stamp] [drm] [Major_minor] [connector name] message..... 124 * eg: 125 * [ 26.590965] [drm] [Conn_LKTN] [DP-1] HBRx4 pass VS=0, PE=0^ 126 * [ 26.881060] [drm] [Conn_Mode] [DP-1] {2560x1080, 2784x1111@185580Khz}^ 127 */ 128 129 #define CONN_DATA_DETECT(link, hex_data, hex_len, ...) \ 130 dc_conn_log(link->ctx, &link->public, hex_data, hex_len, \ 131 LOG_EVENT_DETECTION, ##__VA_ARGS__) 132 133 #define CONN_DATA_LINK_LOSS(link, hex_data, hex_len, ...) \ 134 dc_conn_log(link->ctx, &link->public, hex_data, hex_len, \ 135 LOG_EVENT_LINK_LOSS, ##__VA_ARGS__) 136 137 #define CONN_MSG_LT(link, ...) \ 138 dc_conn_log(link->ctx, &link->public, NULL, 0, \ 139 LOG_EVENT_LINK_TRAINING, ##__VA_ARGS__) 140 141 #define CONN_MSG_MODE(link, ...) \ 142 dc_conn_log(link->ctx, &link->public, NULL, 0, \ 143 LOG_EVENT_MODE_SET, ##__VA_ARGS__) 144 145 #endif /* __DAL_LOGGER_INTERFACE_H__ */ 146