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