2 * Copyright 2012-15 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.
26 #ifndef __DAL_LOGGER_INTERFACE_H__
27 #define __DAL_LOGGER_INTERFACE_H__
29 #include "logger_types.h"
33 struct dc_surface_update;
34 struct resource_context;
39 * DAL logger functionality
43 struct dal_logger *dal_logger_create(struct dc_context *ctx, uint32_t log_mask);
45 uint32_t dal_logger_destroy(struct dal_logger **logger);
47 void dm_logger_flush_buffer(struct dal_logger *logger, bool should_warn);
50 struct dal_logger *logger,
51 enum dc_log_type log_type,
55 void dm_logger_append(
56 struct log_entry *entry,
61 struct dal_logger *logger,
62 struct log_entry *entry,
63 enum dc_log_type log_type);
65 void dm_logger_close(struct log_entry *entry);
67 void dc_conn_log(struct dc_context *ctx,
68 const struct dc_link *link,
71 enum dc_log_type event,
75 void logger_write(struct dal_logger *logger,
76 enum dc_log_type log_type,
80 void pre_surface_trace(
82 const struct dc_plane_state *const *plane_states,
85 void update_surface_trace(
87 const struct dc_surface_update *updates,
90 void post_surface_trace(struct dc *dc);
92 void context_timing_trace(
94 struct resource_context *res_ctx);
96 void context_clock_trace(
98 struct dc_state *context);
100 /* Any function which is empty or have incomplete implementation should be
101 * marked by this macro.
102 * Note that the message will be printed exactly once for every function
103 * it is used in order to avoid repeating of the same message. */
104 #define DAL_LOGGER_NOT_IMPL(fmt, ...) \
106 static bool print_not_impl = true; \
108 if (print_not_impl == true) { \
109 print_not_impl = false; \
110 dm_logger_write(ctx->logger, LOG_WARNING, \
111 "DAL_NOT_IMPL: " fmt, ##__VA_ARGS__); \
115 /******************************************************************************
116 * Convenience macros to save on typing.
117 *****************************************************************************/
119 #define DC_ERROR(...) \
120 dm_logger_write(dc_ctx->logger, LOG_ERROR, \
123 #define DC_SYNC_INFO(...) \
124 dm_logger_write(dc_ctx->logger, LOG_SYNC, \
127 /* Connectivity log format:
128 * [time stamp] [drm] [Major_minor] [connector name] message.....
130 * [ 26.590965] [drm] [Conn_LKTN] [DP-1] HBRx4 pass VS=0, PE=0^
131 * [ 26.881060] [drm] [Conn_Mode] [DP-1] {2560x1080, 2784x1111@185580Khz}^
134 #define CONN_DATA_DETECT(link, hex_data, hex_len, ...) \
135 dc_conn_log(link->ctx, link, hex_data, hex_len, \
136 LOG_EVENT_DETECTION, ##__VA_ARGS__)
138 #define CONN_DATA_LINK_LOSS(link, hex_data, hex_len, ...) \
139 dc_conn_log(link->ctx, link, hex_data, hex_len, \
140 LOG_EVENT_LINK_LOSS, ##__VA_ARGS__)
142 #define CONN_MSG_LT(link, ...) \
143 dc_conn_log(link->ctx, link, NULL, 0, \
144 LOG_EVENT_LINK_TRAINING, ##__VA_ARGS__)
146 #define CONN_MSG_MODE(link, ...) \
147 dc_conn_log(link->ctx, link, NULL, 0, \
148 LOG_EVENT_MODE_SET, ##__VA_ARGS__)
151 * Display Test Next logging
153 #define DTN_INFO_BEGIN() \
154 dm_dtn_log_begin(dc_ctx)
156 #define DTN_INFO(msg, ...) \
157 dm_dtn_log_append_v(dc_ctx, msg, ##__VA_ARGS__)
159 #define DTN_INFO_END() \
160 dm_dtn_log_end(dc_ctx)
162 #define PERFORMANCE_TRACE_START() \
163 unsigned long long perf_trc_start_stmp = dm_get_timestamp(dc->ctx); \
164 unsigned long long perf_trc_start_log_msk = dc->ctx->logger->mask; \
165 unsigned int perf_trc_start_log_flags = dc->ctx->logger->flags.value; \
166 if (dc->debug.performance_trace) {\
167 dm_logger_flush_buffer(dc->ctx->logger, false);\
168 dc->ctx->logger->mask = 1<<LOG_PERF_TRACE;\
169 dc->ctx->logger->flags.bits.ENABLE_CONSOLE = 0;\
170 dc->ctx->logger->flags.bits.ENABLE_BUFFER = 1;\
173 #define PERFORMANCE_TRACE_END() do {\
174 unsigned long long perf_trc_end_stmp = dm_get_timestamp(dc->ctx);\
175 if (dc->debug.performance_trace) {\
176 dm_logger_write(dc->ctx->logger, \
178 "%s duration: %d ticks\n", __func__,\
179 perf_trc_end_stmp - perf_trc_start_stmp); \
180 if (perf_trc_start_log_msk != 1<<LOG_PERF_TRACE) {\
181 dc->ctx->logger->mask = perf_trc_start_log_msk;\
182 dc->ctx->logger->flags.value = perf_trc_start_log_flags;\
183 dm_logger_flush_buffer(dc->ctx->logger, false);\
188 #endif /* __DAL_LOGGER_INTERFACE_H__ */