xref: /linux/drivers/gpu/drm/amd/display/include/logger_interface.h (revision 4b4193256c8d3bc3a5397b5cd9494c2ad386317d)
14562236bSHarry Wentland /*
24562236bSHarry Wentland  * Copyright 2012-15 Advanced Micro Devices, Inc.
34562236bSHarry Wentland  *
44562236bSHarry Wentland  * Permission is hereby granted, free of charge, to any person obtaining a
54562236bSHarry Wentland  * copy of this software and associated documentation files (the "Software"),
64562236bSHarry Wentland  * to deal in the Software without restriction, including without limitation
74562236bSHarry Wentland  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
84562236bSHarry Wentland  * and/or sell copies of the Software, and to permit persons to whom the
94562236bSHarry Wentland  * Software is furnished to do so, subject to the following conditions:
104562236bSHarry Wentland  *
114562236bSHarry Wentland  * The above copyright notice and this permission notice shall be included in
124562236bSHarry Wentland  * all copies or substantial portions of the Software.
134562236bSHarry Wentland  *
144562236bSHarry Wentland  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
154562236bSHarry Wentland  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
164562236bSHarry Wentland  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
174562236bSHarry Wentland  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
184562236bSHarry Wentland  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
194562236bSHarry Wentland  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
204562236bSHarry Wentland  * OTHER DEALINGS IN THE SOFTWARE.
214562236bSHarry Wentland  *
224562236bSHarry Wentland  * Authors: AMD
234562236bSHarry Wentland  *
244562236bSHarry Wentland  */
254562236bSHarry Wentland 
264562236bSHarry Wentland #ifndef __DAL_LOGGER_INTERFACE_H__
274562236bSHarry Wentland #define __DAL_LOGGER_INTERFACE_H__
284562236bSHarry Wentland 
294562236bSHarry Wentland #include "logger_types.h"
304562236bSHarry Wentland 
314562236bSHarry Wentland struct dc_context;
324562236bSHarry Wentland struct dc_link;
334562236bSHarry Wentland struct dc_surface_update;
349474980aSYongqiang Sun struct resource_context;
35608ac7bbSJerry Zuo struct dc_state;
364562236bSHarry Wentland 
374562236bSHarry Wentland /*
384562236bSHarry Wentland  *
394562236bSHarry Wentland  * DAL logger functionality
404562236bSHarry Wentland  *
414562236bSHarry Wentland  */
424562236bSHarry Wentland 
434562236bSHarry Wentland void pre_surface_trace(
44fb3466a4SBhawanpreet Lakha 		struct dc *dc,
453be5262eSHarry Wentland 		const struct dc_plane_state *const *plane_states,
464562236bSHarry Wentland 		int surface_count);
474562236bSHarry Wentland 
484562236bSHarry Wentland void update_surface_trace(
49fb3466a4SBhawanpreet Lakha 		struct dc *dc,
504562236bSHarry Wentland 		const struct dc_surface_update *updates,
514562236bSHarry Wentland 		int surface_count);
524562236bSHarry Wentland 
53fb3466a4SBhawanpreet Lakha void post_surface_trace(struct dc *dc);
544562236bSHarry Wentland 
559474980aSYongqiang Sun void context_timing_trace(
56fb3466a4SBhawanpreet Lakha 		struct dc *dc,
579474980aSYongqiang Sun 		struct resource_context *res_ctx);
589474980aSYongqiang Sun 
59c9742685SDmytro Laktyushkin void context_clock_trace(
60fb3466a4SBhawanpreet Lakha 		struct dc *dc,
61608ac7bbSJerry Zuo 		struct dc_state *context);
624562236bSHarry Wentland 
634562236bSHarry Wentland /* Any function which is empty or have incomplete implementation should be
644562236bSHarry Wentland  * marked by this macro.
654562236bSHarry Wentland  * Note that the message will be printed exactly once for every function
664562236bSHarry Wentland  * it is used in order to avoid repeating of the same message. */
67e1cb3e48SNicholas Kazlauskas 
684562236bSHarry Wentland #define DAL_LOGGER_NOT_IMPL(fmt, ...) \
69e1cb3e48SNicholas Kazlauskas 	do { \
704562236bSHarry Wentland 		static bool print_not_impl = true; \
714562236bSHarry Wentland 		if (print_not_impl == true) { \
724562236bSHarry Wentland 			print_not_impl = false; \
73e1cb3e48SNicholas Kazlauskas 			DRM_WARN("DAL_NOT_IMPL: " fmt, ##__VA_ARGS__); \
744562236bSHarry Wentland 		} \
75e1cb3e48SNicholas Kazlauskas 	} while (0)
764562236bSHarry Wentland 
774562236bSHarry Wentland /******************************************************************************
784562236bSHarry Wentland  * Convenience macros to save on typing.
794562236bSHarry Wentland  *****************************************************************************/
804562236bSHarry Wentland 
814562236bSHarry Wentland #define DC_ERROR(...) \
82e1cb3e48SNicholas Kazlauskas 		do { \
83e1cb3e48SNicholas Kazlauskas 			(void)(dc_ctx); \
84e1cb3e48SNicholas Kazlauskas 			DC_LOG_ERROR(__VA_ARGS__); \
85e1cb3e48SNicholas Kazlauskas 		} while (0)
866d244be8STony Cheng 
874562236bSHarry Wentland #define DC_SYNC_INFO(...) \
88e1cb3e48SNicholas Kazlauskas 		do { \
89e1cb3e48SNicholas Kazlauskas 			(void)(dc_ctx); \
90e1cb3e48SNicholas Kazlauskas 			DC_LOG_SYNC(__VA_ARGS__); \
91e1cb3e48SNicholas Kazlauskas 		} while (0)
924562236bSHarry Wentland 
934562236bSHarry Wentland /* Connectivity log format:
944562236bSHarry Wentland  * [time stamp]   [drm] [Major_minor] [connector name] message.....
954562236bSHarry Wentland  * eg:
964562236bSHarry Wentland  * [   26.590965] [drm] [Conn_LKTN]	  [DP-1] HBRx4 pass VS=0, PE=0^
974562236bSHarry Wentland  * [   26.881060] [drm] [Conn_Mode]	  [DP-1] {2560x1080, 2784x1111@185580Khz}^
984562236bSHarry Wentland  */
994562236bSHarry Wentland 
1004562236bSHarry Wentland #define CONN_DATA_DETECT(link, hex_data, hex_len, ...) \
101e1cb3e48SNicholas Kazlauskas 		do { \
102e1cb3e48SNicholas Kazlauskas 			(void)(link); \
103e1cb3e48SNicholas Kazlauskas 			DC_LOG_EVENT_DETECTION(__VA_ARGS__); \
104e1cb3e48SNicholas Kazlauskas 		} while (0)
1054562236bSHarry Wentland 
1064562236bSHarry Wentland #define CONN_DATA_LINK_LOSS(link, hex_data, hex_len, ...) \
107e1cb3e48SNicholas Kazlauskas 		do { \
108e1cb3e48SNicholas Kazlauskas 			(void)(link); \
109e1cb3e48SNicholas Kazlauskas 			DC_LOG_EVENT_LINK_LOSS(__VA_ARGS__); \
110e1cb3e48SNicholas Kazlauskas 		} while (0)
1114562236bSHarry Wentland 
1124562236bSHarry Wentland #define CONN_MSG_LT(link, ...) \
113e1cb3e48SNicholas Kazlauskas 		do { \
114e1cb3e48SNicholas Kazlauskas 			(void)(link); \
115e1cb3e48SNicholas Kazlauskas 			DC_LOG_EVENT_LINK_TRAINING(__VA_ARGS__); \
116e1cb3e48SNicholas Kazlauskas 		} while (0)
1174562236bSHarry Wentland 
1184562236bSHarry Wentland #define CONN_MSG_MODE(link, ...) \
119e1cb3e48SNicholas Kazlauskas 		do { \
120e1cb3e48SNicholas Kazlauskas 			(void)(link); \
121e1cb3e48SNicholas Kazlauskas 			DC_LOG_EVENT_MODE_SET(__VA_ARGS__); \
122e1cb3e48SNicholas Kazlauskas 		} while (0)
1234562236bSHarry Wentland 
1242248eb6bSTony Cheng /*
1252248eb6bSTony Cheng  * Display Test Next logging
1262248eb6bSTony Cheng  */
1272248eb6bSTony Cheng #define DTN_INFO_BEGIN() \
12846659a83SNicholas Kazlauskas 	dm_dtn_log_begin(dc_ctx, log_ctx)
1292248eb6bSTony Cheng 
1302248eb6bSTony Cheng #define DTN_INFO(msg, ...) \
13146659a83SNicholas Kazlauskas 	dm_dtn_log_append_v(dc_ctx, log_ctx, msg, ##__VA_ARGS__)
1322248eb6bSTony Cheng 
1332248eb6bSTony Cheng #define DTN_INFO_END() \
13446659a83SNicholas Kazlauskas 	dm_dtn_log_end(dc_ctx, log_ctx)
1352248eb6bSTony Cheng 
136215a6f05SDmytro Laktyushkin #define PERFORMANCE_TRACE_START() \
137e1cb3e48SNicholas Kazlauskas 	unsigned long long perf_trc_start_stmp = dm_get_timestamp(dc->ctx)
138215a6f05SDmytro Laktyushkin 
139e1cb3e48SNicholas Kazlauskas #define PERFORMANCE_TRACE_END() \
140e1cb3e48SNicholas Kazlauskas 	do { \
141215a6f05SDmytro Laktyushkin 		unsigned long long perf_trc_end_stmp = dm_get_timestamp(dc->ctx); \
142215a6f05SDmytro Laktyushkin 		if (dc->debug.performance_trace) { \
143e1cb3e48SNicholas Kazlauskas 			DC_LOG_PERF_TRACE("%s duration: %lld ticks\n", __func__, \
144215a6f05SDmytro Laktyushkin 				perf_trc_end_stmp - perf_trc_start_stmp); \
145215a6f05SDmytro Laktyushkin 		} \
146215a6f05SDmytro Laktyushkin 	} while (0)
147215a6f05SDmytro Laktyushkin 
148e1cb3e48SNicholas Kazlauskas #define DISPLAY_STATS_BEGIN(entry) (void)(entry)
1495103c568SAnthony Koo 
150e1cb3e48SNicholas Kazlauskas #define DISPLAY_STATS(msg, ...) DC_LOG_PERF_TRACE(msg, __VA_ARGS__)
1515103c568SAnthony Koo 
152e1cb3e48SNicholas Kazlauskas #define DISPLAY_STATS_END(entry) (void)(entry)
1535103c568SAnthony Koo 
154*bbdd620dSWyatt Wood #define LOG_GAMMA_WRITE(msg, ...)
155*bbdd620dSWyatt Wood 
1564562236bSHarry Wentland #endif /* __DAL_LOGGER_INTERFACE_H__ */
157