• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2019 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 MOD_HDCP_LOG_H_
27 #define MOD_HDCP_LOG_H_
28 
29 #ifdef CONFIG_DRM_AMD_DC_HDCP
30 #define HDCP_LOG_ERR(hdcp, ...) DRM_DEBUG_KMS(__VA_ARGS__)
31 #define HDCP_LOG_VER(hdcp, ...) DRM_DEBUG_KMS(__VA_ARGS__)
32 #define HDCP_LOG_FSM(hdcp, ...) DRM_DEBUG_KMS(__VA_ARGS__)
33 #define HDCP_LOG_TOP(hdcp, ...) pr_debug("[HDCP_TOP]:"__VA_ARGS__)
34 #define HDCP_LOG_DDC(hdcp, ...) pr_debug("[HDCP_DDC]:"__VA_ARGS__)
35 #endif
36 
37 /* default logs */
38 #define HDCP_ERROR_TRACE(hdcp, status) \
39 		HDCP_LOG_ERR(hdcp, \
40 			"[Link %d] WARNING %s IN STATE %s STAY COUNT %d", \
41 			hdcp->config.index, \
42 			mod_hdcp_status_to_str(status), \
43 			mod_hdcp_state_id_to_str(hdcp->state.id), \
44 			hdcp->state.stay_count)
45 #define HDCP_HDCP1_ENABLED_TRACE(hdcp, displayIndex) \
46 		HDCP_LOG_VER(hdcp, \
47 			"[Link %d] HDCP 1.4 enabled on display %d", \
48 			hdcp->config.index, displayIndex)
49 #define HDCP_HDCP2_ENABLED_TRACE(hdcp, displayIndex) \
50 		HDCP_LOG_VER(hdcp, \
51 			"[Link %d] HDCP 2.2 enabled on display %d", \
52 			hdcp->config.index, displayIndex)
53 #define HDCP_HDCP1_DISABLED_TRACE(hdcp, displayIndex) \
54 		HDCP_LOG_VER(hdcp, \
55 			"[Link %d] HDCP 1.4 disabled on display %d", \
56 			hdcp->config.index, displayIndex)
57 #define HDCP_HDCP2_DISABLED_TRACE(hdcp, displayIndex) \
58 		HDCP_LOG_VER(hdcp, \
59 			"[Link %d] HDCP 2.2 disabled on display %d", \
60 			hdcp->config.index, displayIndex)
61 
62 /* state machine logs */
63 #define HDCP_REMOVE_DISPLAY_TRACE(hdcp, displayIndex) \
64 		HDCP_LOG_FSM(hdcp, \
65 			"[Link %d] HDCP_REMOVE_DISPLAY index %d", \
66 			hdcp->config.index, displayIndex)
67 #define HDCP_INPUT_PASS_TRACE(hdcp, str) \
68 		HDCP_LOG_FSM(hdcp, \
69 			"[Link %d]\tPASS %s", \
70 			hdcp->config.index, str)
71 #define HDCP_INPUT_FAIL_TRACE(hdcp, str) \
72 		HDCP_LOG_FSM(hdcp, \
73 			"[Link %d]\tFAIL %s", \
74 			hdcp->config.index, str)
75 #define HDCP_NEXT_STATE_TRACE(hdcp, id, output) do { \
76 		if (output->watchdog_timer_needed) \
77 			HDCP_LOG_FSM(hdcp, \
78 				"[Link %d] > %s with %d ms watchdog", \
79 				hdcp->config.index, \
80 				mod_hdcp_state_id_to_str(id), output->watchdog_timer_delay); \
81 		else \
82 			HDCP_LOG_FSM(hdcp, \
83 				"[Link %d] > %s", hdcp->config.index, \
84 				mod_hdcp_state_id_to_str(id)); \
85 } while (0)
86 #define HDCP_TIMEOUT_TRACE(hdcp) \
87 		HDCP_LOG_FSM(hdcp, "[Link %d] --> TIMEOUT", hdcp->config.index)
88 #define HDCP_CPIRQ_TRACE(hdcp) \
89 		HDCP_LOG_FSM(hdcp, "[Link %d] --> CPIRQ", hdcp->config.index)
90 #define HDCP_EVENT_TRACE(hdcp, event) \
91 		if (event == MOD_HDCP_EVENT_WATCHDOG_TIMEOUT) \
92 			HDCP_TIMEOUT_TRACE(hdcp); \
93 		else if (event == MOD_HDCP_EVENT_CPIRQ) \
94 			HDCP_CPIRQ_TRACE(hdcp)
95 /* TODO: find some way to tell if logging is off to save time */
96 #define HDCP_DDC_READ_TRACE(hdcp, msg_name, msg, msg_size) do { \
97 		mod_hdcp_dump_binary_message(msg, msg_size, hdcp->buf, \
98 				sizeof(hdcp->buf)); \
99 		HDCP_LOG_DDC(hdcp, "[Link %d] Read %s%s", hdcp->config.index, \
100 				msg_name, hdcp->buf); \
101 } while (0)
102 #define HDCP_DDC_WRITE_TRACE(hdcp, msg_name, msg, msg_size) do { \
103 		mod_hdcp_dump_binary_message(msg, msg_size, hdcp->buf, \
104 				sizeof(hdcp->buf)); \
105 		HDCP_LOG_DDC(hdcp, "[Link %d] Write %s%s", \
106 				hdcp->config.index, msg_name,\
107 				hdcp->buf); \
108 } while (0)
109 #define HDCP_TOP_ADD_DISPLAY_TRACE(hdcp, i) \
110 		HDCP_LOG_TOP(hdcp, "[Link %d]\tadd display %d", \
111 				hdcp->config.index, i)
112 #define HDCP_TOP_REMOVE_DISPLAY_TRACE(hdcp, i) \
113 		HDCP_LOG_TOP(hdcp, "[Link %d]\tremove display %d", \
114 				hdcp->config.index, i)
115 #define HDCP_TOP_HDCP1_DESTROY_SESSION_TRACE(hdcp) \
116 		HDCP_LOG_TOP(hdcp, "[Link %d]\tdestroy hdcp1 session", \
117 				hdcp->config.index)
118 #define HDCP_TOP_HDCP2_DESTROY_SESSION_TRACE(hdcp) \
119 		HDCP_LOG_TOP(hdcp, "[Link %d]\tdestroy hdcp2 session", \
120 				hdcp->config.index)
121 #define HDCP_TOP_RESET_AUTH_TRACE(hdcp) \
122 		HDCP_LOG_TOP(hdcp, "[Link %d]\treset authentication", hdcp->config.index)
123 #define HDCP_TOP_RESET_CONN_TRACE(hdcp) \
124 		HDCP_LOG_TOP(hdcp, "[Link %d]\treset connection", hdcp->config.index)
125 #define HDCP_TOP_INTERFACE_TRACE(hdcp) do { \
126 		HDCP_LOG_TOP(hdcp, "\n"); \
127 		HDCP_LOG_TOP(hdcp, "[Link %d] %s", hdcp->config.index, __func__); \
128 } while (0)
129 #define HDCP_TOP_INTERFACE_TRACE_WITH_INDEX(hdcp, i) do { \
130 		HDCP_LOG_TOP(hdcp, "\n"); \
131 		HDCP_LOG_TOP(hdcp, "[Link %d] %s display %d", hdcp->config.index, __func__, i); \
132 } while (0)
133 
134 #endif // MOD_HDCP_LOG_H_
135