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_WARN(__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", \ 41 hdcp->config.index, \ 42 mod_hdcp_status_to_str(status), \ 43 mod_hdcp_state_id_to_str(hdcp->state.id)) 44 #define HDCP_HDCP1_ENABLED_TRACE(hdcp, displayIndex) \ 45 HDCP_LOG_VER(hdcp, \ 46 "[Link %d] HDCP 1.4 enabled on display %d", \ 47 hdcp->config.index, displayIndex) 48 #define HDCP_HDCP2_ENABLED_TRACE(hdcp, displayIndex) \ 49 HDCP_LOG_VER(hdcp, \ 50 "[Link %d] HDCP 2.2 enabled on display %d", \ 51 hdcp->config.index, displayIndex) 52 /* state machine logs */ 53 #define HDCP_REMOVE_DISPLAY_TRACE(hdcp, displayIndex) \ 54 HDCP_LOG_FSM(hdcp, \ 55 "[Link %d] HDCP_REMOVE_DISPLAY index %d", \ 56 hdcp->config.index, displayIndex) 57 #define HDCP_INPUT_PASS_TRACE(hdcp, str) \ 58 HDCP_LOG_FSM(hdcp, \ 59 "[Link %d]\tPASS %s", \ 60 hdcp->config.index, str) 61 #define HDCP_INPUT_FAIL_TRACE(hdcp, str) \ 62 HDCP_LOG_FSM(hdcp, \ 63 "[Link %d]\tFAIL %s", \ 64 hdcp->config.index, str) 65 #define HDCP_NEXT_STATE_TRACE(hdcp, id, output) do { \ 66 if (output->watchdog_timer_needed) \ 67 HDCP_LOG_FSM(hdcp, \ 68 "[Link %d] > %s with %d ms watchdog", \ 69 hdcp->config.index, \ 70 mod_hdcp_state_id_to_str(id), output->watchdog_timer_delay); \ 71 else \ 72 HDCP_LOG_FSM(hdcp, \ 73 "[Link %d] > %s", hdcp->config.index, \ 74 mod_hdcp_state_id_to_str(id)); \ 75 } while (0) 76 #define HDCP_TIMEOUT_TRACE(hdcp) \ 77 HDCP_LOG_FSM(hdcp, "[Link %d] --> TIMEOUT", hdcp->config.index) 78 #define HDCP_CPIRQ_TRACE(hdcp) \ 79 HDCP_LOG_FSM(hdcp, "[Link %d] --> CPIRQ", hdcp->config.index) 80 #define HDCP_EVENT_TRACE(hdcp, event) \ 81 if (event == MOD_HDCP_EVENT_WATCHDOG_TIMEOUT) \ 82 HDCP_TIMEOUT_TRACE(hdcp); \ 83 else if (event == MOD_HDCP_EVENT_CPIRQ) \ 84 HDCP_CPIRQ_TRACE(hdcp) 85 /* TODO: find some way to tell if logging is off to save time */ 86 #define HDCP_DDC_READ_TRACE(hdcp, msg_name, msg, msg_size) do { \ 87 mod_hdcp_dump_binary_message(msg, msg_size, hdcp->buf, \ 88 sizeof(hdcp->buf)); \ 89 HDCP_LOG_DDC(hdcp, "[Link %d] Read %s%s", hdcp->config.index, \ 90 msg_name, hdcp->buf); \ 91 } while (0) 92 #define HDCP_DDC_WRITE_TRACE(hdcp, msg_name, msg, msg_size) do { \ 93 mod_hdcp_dump_binary_message(msg, msg_size, hdcp->buf, \ 94 sizeof(hdcp->buf)); \ 95 HDCP_LOG_DDC(hdcp, "[Link %d] Write %s%s", \ 96 hdcp->config.index, msg_name,\ 97 hdcp->buf); \ 98 } while (0) 99 #define HDCP_FULL_DDC_TRACE(hdcp) do { \ 100 if (is_hdcp1(hdcp)) { \ 101 HDCP_DDC_READ_TRACE(hdcp, "BKSV", hdcp->auth.msg.hdcp1.bksv, \ 102 sizeof(hdcp->auth.msg.hdcp1.bksv)); \ 103 HDCP_DDC_READ_TRACE(hdcp, "BCAPS", &hdcp->auth.msg.hdcp1.bcaps, \ 104 sizeof(hdcp->auth.msg.hdcp1.bcaps)); \ 105 HDCP_DDC_WRITE_TRACE(hdcp, "AN", hdcp->auth.msg.hdcp1.an, \ 106 sizeof(hdcp->auth.msg.hdcp1.an)); \ 107 HDCP_DDC_WRITE_TRACE(hdcp, "AKSV", hdcp->auth.msg.hdcp1.aksv, \ 108 sizeof(hdcp->auth.msg.hdcp1.aksv)); \ 109 HDCP_DDC_WRITE_TRACE(hdcp, "AINFO", &hdcp->auth.msg.hdcp1.ainfo, \ 110 sizeof(hdcp->auth.msg.hdcp1.ainfo)); \ 111 HDCP_DDC_READ_TRACE(hdcp, "RI' / R0'", \ 112 (uint8_t *)&hdcp->auth.msg.hdcp1.r0p, \ 113 sizeof(hdcp->auth.msg.hdcp1.r0p)); \ 114 HDCP_DDC_READ_TRACE(hdcp, "BINFO", \ 115 (uint8_t *)&hdcp->auth.msg.hdcp1.binfo_dp, \ 116 sizeof(hdcp->auth.msg.hdcp1.binfo_dp)); \ 117 HDCP_DDC_READ_TRACE(hdcp, "KSVLIST", hdcp->auth.msg.hdcp1.ksvlist, \ 118 hdcp->auth.msg.hdcp1.ksvlist_size); \ 119 HDCP_DDC_READ_TRACE(hdcp, "V'", hdcp->auth.msg.hdcp1.vp, \ 120 sizeof(hdcp->auth.msg.hdcp1.vp)); \ 121 } else { \ 122 HDCP_DDC_READ_TRACE(hdcp, "HDCP2Version", \ 123 &hdcp->auth.msg.hdcp2.hdcp2version_hdmi, \ 124 sizeof(hdcp->auth.msg.hdcp2.hdcp2version_hdmi)); \ 125 HDCP_DDC_READ_TRACE(hdcp, "Rx Caps", hdcp->auth.msg.hdcp2.rxcaps_dp, \ 126 sizeof(hdcp->auth.msg.hdcp2.rxcaps_dp)); \ 127 HDCP_DDC_WRITE_TRACE(hdcp, "AKE Init", hdcp->auth.msg.hdcp2.ake_init, \ 128 sizeof(hdcp->auth.msg.hdcp2.ake_init)); \ 129 HDCP_DDC_READ_TRACE(hdcp, "AKE Cert", hdcp->auth.msg.hdcp2.ake_cert, \ 130 sizeof(hdcp->auth.msg.hdcp2.ake_cert)); \ 131 HDCP_DDC_WRITE_TRACE(hdcp, "Stored KM", \ 132 hdcp->auth.msg.hdcp2.ake_stored_km, \ 133 sizeof(hdcp->auth.msg.hdcp2.ake_stored_km)); \ 134 HDCP_DDC_WRITE_TRACE(hdcp, "No Stored KM", \ 135 hdcp->auth.msg.hdcp2.ake_no_stored_km, \ 136 sizeof(hdcp->auth.msg.hdcp2.ake_no_stored_km)); \ 137 HDCP_DDC_READ_TRACE(hdcp, "H'", hdcp->auth.msg.hdcp2.ake_h_prime, \ 138 sizeof(hdcp->auth.msg.hdcp2.ake_h_prime)); \ 139 HDCP_DDC_READ_TRACE(hdcp, "Pairing Info", \ 140 hdcp->auth.msg.hdcp2.ake_pairing_info, \ 141 sizeof(hdcp->auth.msg.hdcp2.ake_pairing_info)); \ 142 HDCP_DDC_WRITE_TRACE(hdcp, "LC Init", hdcp->auth.msg.hdcp2.lc_init, \ 143 sizeof(hdcp->auth.msg.hdcp2.lc_init)); \ 144 HDCP_DDC_READ_TRACE(hdcp, "L'", hdcp->auth.msg.hdcp2.lc_l_prime, \ 145 sizeof(hdcp->auth.msg.hdcp2.lc_l_prime)); \ 146 HDCP_DDC_WRITE_TRACE(hdcp, "Exchange KS", hdcp->auth.msg.hdcp2.ske_eks, \ 147 sizeof(hdcp->auth.msg.hdcp2.ske_eks)); \ 148 HDCP_DDC_READ_TRACE(hdcp, "Rx Status", \ 149 (uint8_t *)&hdcp->auth.msg.hdcp2.rxstatus, \ 150 sizeof(hdcp->auth.msg.hdcp2.rxstatus)); \ 151 HDCP_DDC_READ_TRACE(hdcp, "Rx Id List", \ 152 hdcp->auth.msg.hdcp2.rx_id_list, \ 153 hdcp->auth.msg.hdcp2.rx_id_list_size); \ 154 HDCP_DDC_WRITE_TRACE(hdcp, "Rx Id List Ack", \ 155 hdcp->auth.msg.hdcp2.repeater_auth_ack, \ 156 sizeof(hdcp->auth.msg.hdcp2.repeater_auth_ack)); \ 157 HDCP_DDC_WRITE_TRACE(hdcp, "Content Stream Management", \ 158 hdcp->auth.msg.hdcp2.repeater_auth_stream_manage, \ 159 hdcp->auth.msg.hdcp2.stream_manage_size); \ 160 HDCP_DDC_READ_TRACE(hdcp, "Stream Ready", \ 161 hdcp->auth.msg.hdcp2.repeater_auth_stream_ready, \ 162 sizeof(hdcp->auth.msg.hdcp2.repeater_auth_stream_ready)); \ 163 HDCP_DDC_WRITE_TRACE(hdcp, "Content Stream Type", \ 164 hdcp->auth.msg.hdcp2.content_stream_type_dp, \ 165 sizeof(hdcp->auth.msg.hdcp2.content_stream_type_dp)); \ 166 } \ 167 } while (0) 168 #define HDCP_TOP_ADD_DISPLAY_TRACE(hdcp, i) \ 169 HDCP_LOG_TOP(hdcp, "[Link %d]\tadd display %d", \ 170 hdcp->config.index, i) 171 #define HDCP_TOP_REMOVE_DISPLAY_TRACE(hdcp, i) \ 172 HDCP_LOG_TOP(hdcp, "[Link %d]\tremove display %d", \ 173 hdcp->config.index, i) 174 #define HDCP_TOP_HDCP1_DESTROY_SESSION_TRACE(hdcp) \ 175 HDCP_LOG_TOP(hdcp, "[Link %d]\tdestroy hdcp1 session", \ 176 hdcp->config.index) 177 #define HDCP_TOP_HDCP2_DESTROY_SESSION_TRACE(hdcp) \ 178 HDCP_LOG_TOP(hdcp, "[Link %d]\tdestroy hdcp2 session", \ 179 hdcp->config.index) 180 #define HDCP_TOP_RESET_AUTH_TRACE(hdcp) \ 181 HDCP_LOG_TOP(hdcp, "[Link %d]\treset authentication", hdcp->config.index) 182 #define HDCP_TOP_RESET_CONN_TRACE(hdcp) \ 183 HDCP_LOG_TOP(hdcp, "[Link %d]\treset connection", hdcp->config.index) 184 #define HDCP_TOP_INTERFACE_TRACE(hdcp) do { \ 185 HDCP_LOG_TOP(hdcp, "\n"); \ 186 HDCP_LOG_TOP(hdcp, "[Link %d] %s", hdcp->config.index, __func__); \ 187 } while (0) 188 #define HDCP_TOP_INTERFACE_TRACE_WITH_INDEX(hdcp, i) do { \ 189 HDCP_LOG_TOP(hdcp, "\n"); \ 190 HDCP_LOG_TOP(hdcp, "[Link %d] %s display %d", hdcp->config.index, __func__, i); \ 191 } while (0) 192 193 #endif // MOD_HDCP_LOG_H_ 194