summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_log.c
blob: 1a0f7c3dc96490c0c65e549f0ad18efaf7169ec7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
/*
 * Copyright 2019 Advanced Micro Devices, Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 *
 * Authors: AMD
 *
 */


#include "hdcp.h"

void mod_hdcp_dump_binary_message(uint8_t *msg, uint32_t msg_size,
		uint8_t *buf, uint32_t buf_size)
{
	const uint8_t bytes_per_line = 16,
			byte_size = 3,
			newline_size = 1,
			terminator_size = 1;
	uint32_t line_count = msg_size / bytes_per_line,
			trailing_bytes = msg_size % bytes_per_line;
	uint32_t target_size = (byte_size * bytes_per_line + newline_size) * line_count +
			byte_size * trailing_bytes + newline_size + terminator_size;
	uint32_t buf_pos = 0;
	uint32_t i = 0;

	if (buf_size >= target_size) {
		for (i = 0; i < msg_size; i++) {
			if (i % bytes_per_line == 0)
				buf[buf_pos++] = '\n';
			sprintf(&buf[buf_pos], "%02X ", msg[i]);
			buf_pos += byte_size;
		}
		buf[buf_pos++] = '\0';
	}
}

char *mod_hdcp_status_to_str(int32_t status)
{
	switch (status) {
	case MOD_HDCP_STATUS_SUCCESS:
		return "MOD_HDCP_STATUS_SUCCESS";
	case MOD_HDCP_STATUS_FAILURE:
		return "MOD_HDCP_STATUS_FAILURE";
	case MOD_HDCP_STATUS_RESET_NEEDED:
		return "MOD_HDCP_STATUS_RESET_NEEDED";
	case MOD_HDCP_STATUS_DISPLAY_OUT_OF_BOUND:
		return "MOD_HDCP_STATUS_DISPLAY_OUT_OF_BOUND";
	case MOD_HDCP_STATUS_DISPLAY_NOT_FOUND:
		return "MOD_HDCP_STATUS_DISPLAY_NOT_FOUND";
	case MOD_HDCP_STATUS_INVALID_STATE:
		return "MOD_HDCP_STATUS_INVALID_STATE";
	case MOD_HDCP_STATUS_NOT_IMPLEMENTED:
		return "MOD_HDCP_STATUS_NOT_IMPLEMENTED";
	case MOD_HDCP_STATUS_INTERNAL_POLICY_FAILURE:
		return "MOD_HDCP_STATUS_INTERNAL_POLICY_FAILURE";
	case MOD_HDCP_STATUS_UPDATE_TOPOLOGY_FAILURE:
		return "MOD_HDCP_STATUS_UPDATE_TOPOLOGY_FAILURE";
	case MOD_HDCP_STATUS_CREATE_PSP_SERVICE_FAILURE:
		return "MOD_HDCP_STATUS_CREATE_PSP_SERVICE_FAILURE";
	case MOD_HDCP_STATUS_DESTROY_PSP_SERVICE_FAILURE:
		return "MOD_HDCP_STATUS_DESTROY_PSP_SERVICE_FAILURE";
	case MOD_HDCP_STATUS_HDCP1_CREATE_SESSION_FAILURE:
		return "MOD_HDCP_STATUS_HDCP1_CREATE_SESSION_FAILURE";
	case MOD_HDCP_STATUS_HDCP1_DESTROY_SESSION_FAILURE:
		return "MOD_HDCP_STATUS_HDCP1_DESTROY_SESSION_FAILURE";
	case MOD_HDCP_STATUS_HDCP1_VALIDATE_ENCRYPTION_FAILURE:
		return "MOD_HDCP_STATUS_HDCP1_VALIDATE_ENCRYPTION_FAILURE";
	case MOD_HDCP_STATUS_HDCP1_NOT_HDCP_REPEATER:
		return "MOD_HDCP_STATUS_HDCP1_NOT_HDCP_REPEATER";
	case MOD_HDCP_STATUS_HDCP1_NOT_CAPABLE:
		return "MOD_HDCP_STATUS_HDCP1_NOT_CAPABLE";
	case MOD_HDCP_STATUS_HDCP1_R0_PRIME_PENDING:
		return "MOD_HDCP_STATUS_HDCP1_R0_PRIME_PENDING";
	case MOD_HDCP_STATUS_HDCP1_VALIDATE_RX_FAILURE:
		return "MOD_HDCP_STATUS_HDCP1_VALIDATE_RX_FAILURE";
	case MOD_HDCP_STATUS_HDCP1_BKSV_REVOKED:
		return "MOD_HDCP_STATUS_HDCP1_BKSV_REVOKED";
	case MOD_HDCP_STATUS_HDCP1_KSV_LIST_NOT_READY:
		return "MOD_HDCP_STATUS_HDCP1_KSV_LIST_NOT_READY";
	case MOD_HDCP_STATUS_HDCP1_VALIDATE_KSV_LIST_FAILURE:
		return "MOD_HDCP_STATUS_HDCP1_VALIDATE_KSV_LIST_FAILURE";
	case MOD_HDCP_STATUS_HDCP1_KSV_LIST_REVOKED:
		return "MOD_HDCP_STATUS_HDCP1_KSV_LIST_REVOKED";
	case MOD_HDCP_STATUS_HDCP1_ENABLE_ENCRYPTION_FAILURE:
		return "MOD_HDCP_STATUS_HDCP1_ENABLE_ENCRYPTION_FAILURE";
	case MOD_HDCP_STATUS_HDCP1_ENABLE_STREAM_ENCRYPTION_FAILURE:
		return "MOD_HDCP_STATUS_HDCP1_ENABLE_STREAM_ENCRYPTION_FAILURE";
	case MOD_HDCP_STATUS_HDCP1_MAX_CASCADE_EXCEEDED_FAILURE:
		return "MOD_HDCP_STATUS_HDCP1_MAX_CASCADE_EXCEEDED_FAILURE";
	case MOD_HDCP_STATUS_HDCP1_MAX_DEVS_EXCEEDED_FAILURE:
		return "MOD_HDCP_STATUS_HDCP1_MAX_DEVS_EXCEEDED_FAILURE";
	case MOD_HDCP_STATUS_HDCP1_DEVICE_COUNT_MISMATCH_FAILURE:
		return "MOD_HDCP_STATUS_HDCP1_DEVICE_COUNT_MISMATCH_FAILURE";
	case MOD_HDCP_STATUS_HDCP1_LINK_INTEGRITY_FAILURE:
		return "MOD_HDCP_STATUS_HDCP1_LINK_INTEGRITY_FAILURE";
	case MOD_HDCP_STATUS_HDCP1_REAUTH_REQUEST_ISSUED:
		return "MOD_HDCP_STATUS_HDCP1_REAUTH_REQUEST_ISSUED";
	case MOD_HDCP_STATUS_HDCP1_LINK_MAINTENANCE_FAILURE:
		return "MOD_HDCP_STATUS_HDCP1_LINK_MAINTENANCE_FAILURE";
	case MOD_HDCP_STATUS_HDCP1_INVALID_BKSV:
		return "MOD_HDCP_STATUS_HDCP1_INVALID_BKSV";
	case MOD_HDCP_STATUS_DDC_FAILURE:
		return "MOD_HDCP_STATUS_DDC_FAILURE";
	case MOD_HDCP_STATUS_INVALID_OPERATION:
		return "MOD_HDCP_STATUS_INVALID_OPERATION";
	case MOD_HDCP_STATUS_HDCP2_NOT_CAPABLE:
		return "MOD_HDCP_STATUS_HDCP2_NOT_CAPABLE";
	case MOD_HDCP_STATUS_HDCP2_CREATE_SESSION_FAILURE:
		return "MOD_HDCP_STATUS_HDCP2_CREATE_SESSION_FAILURE";
	case MOD_HDCP_STATUS_HDCP2_DESTROY_SESSION_FAILURE:
		return "MOD_HDCP_STATUS_HDCP2_DESTROY_SESSION_FAILURE";
	case MOD_HDCP_STATUS_HDCP2_PREP_AKE_INIT_FAILURE:
		return "MOD_HDCP_STATUS_HDCP2_PREP_AKE_INIT_FAILURE";
	case MOD_HDCP_STATUS_HDCP2_AKE_CERT_PENDING:
		return "MOD_HDCP_STATUS_HDCP2_AKE_CERT_PENDING";
	case MOD_HDCP_STATUS_HDCP2_H_PRIME_PENDING:
		return "MOD_HDCP_STATUS_HDCP2_H_PRIME_PENDING";
	case MOD_HDCP_STATUS_HDCP2_PAIRING_INFO_PENDING:
		return "MOD_HDCP_STATUS_HDCP2_PAIRING_INFO_PENDING";
	case MOD_HDCP_STATUS_HDCP2_VALIDATE_AKE_CERT_FAILURE:
		return "MOD_HDCP_STATUS_HDCP2_VALIDATE_AKE_CERT_FAILURE";
	case MOD_HDCP_STATUS_HDCP2_AKE_CERT_REVOKED:
		return "MOD_HDCP_STATUS_HDCP2_AKE_CERT_REVOKED";
	case MOD_HDCP_STATUS_HDCP2_VALIDATE_H_PRIME_FAILURE:
		return "MOD_HDCP_STATUS_HDCP2_VALIDATE_H_PRIME_FAILURE";
	case MOD_HDCP_STATUS_HDCP2_VALIDATE_PAIRING_INFO_FAILURE:
		return "MOD_HDCP_STATUS_HDCP2_VALIDATE_PAIRING_INFO_FAILURE";
	case MOD_HDCP_STATUS_HDCP2_PREP_LC_INIT_FAILURE:
		return "MOD_HDCP_STATUS_HDCP2_PREP_LC_INIT_FAILURE";
	case MOD_HDCP_STATUS_HDCP2_L_PRIME_PENDING:
		return "MOD_HDCP_STATUS_HDCP2_L_PRIME_PENDING";
	case MOD_HDCP_STATUS_HDCP2_VALIDATE_L_PRIME_FAILURE:
		return "MOD_HDCP_STATUS_HDCP2_VALIDATE_L_PRIME_FAILURE";
	case MOD_HDCP_STATUS_HDCP2_PREP_EKS_FAILURE:
		return "MOD_HDCP_STATUS_HDCP2_PREP_EKS_FAILURE";
	case MOD_HDCP_STATUS_HDCP2_ENABLE_ENCRYPTION_FAILURE:
		return "MOD_HDCP_STATUS_HDCP2_ENABLE_ENCRYPTION_FAILURE";
	case MOD_HDCP_STATUS_HDCP2_VALIDATE_RX_ID_LIST_FAILURE:
		return "MOD_HDCP_STATUS_HDCP2_VALIDATE_RX_ID_LIST_FAILURE";
	case MOD_HDCP_STATUS_HDCP2_RX_ID_LIST_REVOKED:
		return "MOD_HDCP_STATUS_HDCP2_RX_ID_LIST_REVOKED";
	case MOD_HDCP_STATUS_HDCP2_RX_ID_LIST_NOT_READY:
		return "MOD_HDCP_STATUS_HDCP2_RX_ID_LIST_NOT_READY";
	case MOD_HDCP_STATUS_HDCP2_ENABLE_STREAM_ENCRYPTION_FAILURE:
		return "MOD_HDCP_STATUS_HDCP2_ENABLE_STREAM_ENCRYPTION_FAILURE";
	case MOD_HDCP_STATUS_HDCP2_STREAM_READY_PENDING:
		return "MOD_HDCP_STATUS_HDCP2_STREAM_READY_PENDING";
	case MOD_HDCP_STATUS_HDCP2_VALIDATE_STREAM_READY_FAILURE:
		return "MOD_HDCP_STATUS_HDCP2_VALIDATE_STREAM_READY_FAILURE";
	case MOD_HDCP_STATUS_HDCP2_PREPARE_STREAM_MANAGEMENT_FAILURE:
		return "MOD_HDCP_STATUS_HDCP2_PREPARE_STREAM_MANAGEMENT_FAILURE";
	case MOD_HDCP_STATUS_HDCP2_REAUTH_REQUEST:
		return "MOD_HDCP_STATUS_HDCP2_REAUTH_REQUEST";
	case MOD_HDCP_STATUS_HDCP2_REAUTH_LINK_INTEGRITY_FAILURE:
		return "MOD_HDCP_STATUS_HDCP2_REAUTH_LINK_INTEGRITY_FAILURE";
	case MOD_HDCP_STATUS_HDCP2_DEVICE_COUNT_MISMATCH_FAILURE:
		return "MOD_HDCP_STATUS_HDCP2_DEVICE_COUNT_MISMATCH_FAILURE";
	case MOD_HDCP_STATUS_UNSUPPORTED_PSP_VER_FAILURE:
		return "MOD_HDCP_STATUS_UNSUPPORTED_PSP_VER_FAILURE";
	default:
		return "MOD_HDCP_STATUS_UNKNOWN";
	}
}

char *mod_hdcp_state_id_to_str(int32_t id)
{
	switch (id) {
	case HDCP_UNINITIALIZED:
		return "HDCP_UNINITIALIZED";
	case HDCP_INITIALIZED:
		return "HDCP_INITIALIZED";
	case HDCP_CP_NOT_DESIRED:
		return "HDCP_CP_NOT_DESIRED";
	case H1_A0_WAIT_FOR_ACTIVE_RX:
		return "H1_A0_WAIT_FOR_ACTIVE_RX";
	case H1_A1_EXCHANGE_KSVS:
		return "H1_A1_EXCHANGE_KSVS";
	case H1_A2_COMPUTATIONS_A3_VALIDATE_RX_A6_TEST_FOR_REPEATER:
		return "H1_A2_COMPUTATIONS_A3_VALIDATE_RX_A6_TEST_FOR_REPEATER";
	case H1_A45_AUTHENTICATED:
		return "H1_A45_AUTHENTICATED";
	case H1_A8_WAIT_FOR_READY:
		return "H1_A8_WAIT_FOR_READY";
	case H1_A9_READ_KSV_LIST:
		return "H1_A9_READ_KSV_LIST";
	case D1_A0_DETERMINE_RX_HDCP_CAPABLE:
		return "D1_A0_DETERMINE_RX_HDCP_CAPABLE";
	case D1_A1_EXCHANGE_KSVS:
		return "D1_A1_EXCHANGE_KSVS";
	case D1_A23_WAIT_FOR_R0_PRIME:
		return "D1_A23_WAIT_FOR_R0_PRIME";
	case D1_A2_COMPUTATIONS_A3_VALIDATE_RX_A5_TEST_FOR_REPEATER:
		return "D1_A2_COMPUTATIONS_A3_VALIDATE_RX_A5_TEST_FOR_REPEATER";
	case D1_A4_AUTHENTICATED:
		return "D1_A4_AUTHENTICATED";
	case D1_A6_WAIT_FOR_READY:
		return "D1_A6_WAIT_FOR_READY";
	case D1_A7_READ_KSV_LIST:
		return "D1_A7_READ_KSV_LIST";
	case H2_A0_KNOWN_HDCP2_CAPABLE_RX:
		return "H2_A0_KNOWN_HDCP2_CAPABLE_RX";
	case H2_A1_SEND_AKE_INIT:
		return "H2_A1_SEND_AKE_INIT";
	case H2_A1_VALIDATE_AKE_CERT:
		return "H2_A1_VALIDATE_AKE_CERT";
	case H2_A1_SEND_NO_STORED_KM:
		return "H2_A1_SEND_NO_STORED_KM";
	case H2_A1_READ_H_PRIME:
		return "H2_A1_READ_H_PRIME";
	case H2_A1_READ_PAIRING_INFO_AND_VALIDATE_H_PRIME:
		return "H2_A1_READ_PAIRING_INFO_AND_VALIDATE_H_PRIME";
	case H2_A1_SEND_STORED_KM:
		return "H2_A1_SEND_STORED_KM";
	case H2_A1_VALIDATE_H_PRIME:
		return "H2_A1_VALIDATE_H_PRIME";
	case H2_A2_LOCALITY_CHECK:
		return "H2_A2_LOCALITY_CHECK";
	case H2_A3_EXCHANGE_KS_AND_TEST_FOR_REPEATER:
		return "H2_A3_EXCHANGE_KS_AND_TEST_FOR_REPEATER";
	case H2_ENABLE_ENCRYPTION:
		return "H2_ENABLE_ENCRYPTION";
	case H2_A5_AUTHENTICATED:
		return "H2_A5_AUTHENTICATED";
	case H2_A6_WAIT_FOR_RX_ID_LIST:
		return "H2_A6_WAIT_FOR_RX_ID_LIST";
	case H2_A78_VERIFY_RX_ID_LIST_AND_SEND_ACK:
		return "H2_A78_VERIFY_RX_ID_LIST_AND_SEND_ACK";
	case H2_A9_SEND_STREAM_MANAGEMENT:
		return "H2_A9_SEND_STREAM_MANAGEMENT";
	case H2_A9_VALIDATE_STREAM_READY:
		return "H2_A9_VALIDATE_STREAM_READY";
	case D2_A0_DETERMINE_RX_HDCP_CAPABLE:
		return "D2_A0_DETERMINE_RX_HDCP_CAPABLE";
	case D2_A1_SEND_AKE_INIT:
		return "D2_A1_SEND_AKE_INIT";
	case D2_A1_VALIDATE_AKE_CERT:
		return "D2_A1_VALIDATE_AKE_CERT";
	case D2_A1_SEND_NO_STORED_KM:
		return "D2_A1_SEND_NO_STORED_KM";
	case D2_A1_READ_H_PRIME:
		return "D2_A1_READ_H_PRIME";
	case D2_A1_READ_PAIRING_INFO_AND_VALIDATE_H_PRIME:
		return "D2_A1_READ_PAIRING_INFO_AND_VALIDATE_H_PRIME";
	case D2_A1_SEND_STORED_KM:
		return "D2_A1_SEND_STORED_KM";
	case D2_A1_VALIDATE_H_PRIME:
		return "D2_A1_VALIDATE_H_PRIME";
	case D2_A2_LOCALITY_CHECK:
		return "D2_A2_LOCALITY_CHECK";
	case D2_A34_EXCHANGE_KS_AND_TEST_FOR_REPEATER:
		return "D2_A34_EXCHANGE_KS_AND_TEST_FOR_REPEATER";
	case D2_SEND_CONTENT_STREAM_TYPE:
		return "D2_SEND_CONTENT_STREAM_TYPE";
	case D2_ENABLE_ENCRYPTION:
		return "D2_ENABLE_ENCRYPTION";
	case D2_A5_AUTHENTICATED:
		return "D2_A5_AUTHENTICATED";
	case D2_A6_WAIT_FOR_RX_ID_LIST:
		return "D2_A6_WAIT_FOR_RX_ID_LIST";
	case D2_A78_VERIFY_RX_ID_LIST_AND_SEND_ACK:
		return "D2_A78_VERIFY_RX_ID_LIST_AND_SEND_ACK";
	case D2_A9_SEND_STREAM_MANAGEMENT:
		return "D2_A9_SEND_STREAM_MANAGEMENT";
	case D2_A9_VALIDATE_STREAM_READY:
		return "D2_A9_VALIDATE_STREAM_READY";
	default:
		return "UNKNOWN_STATE_ID";
	}
}