Loading...
1/*
2 * Copyright 2018 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#include <linux/delay.h>
27
28#include "hdcp.h"
29
30static inline enum mod_hdcp_status check_receiver_id_list_ready(struct mod_hdcp *hdcp)
31{
32 uint8_t is_ready = 0;
33
34 if (is_dp_hdcp(hdcp))
35 is_ready = HDCP_2_2_DP_RXSTATUS_READY(hdcp->auth.msg.hdcp2.rxstatus_dp) ? 1 : 0;
36 else
37 is_ready = (HDCP_2_2_HDMI_RXSTATUS_READY(hdcp->auth.msg.hdcp2.rxstatus[1]) &&
38 (HDCP_2_2_HDMI_RXSTATUS_MSG_SZ_HI(hdcp->auth.msg.hdcp2.rxstatus[1]) << 8 |
39 hdcp->auth.msg.hdcp2.rxstatus[0])) ? 1 : 0;
40 return is_ready ? MOD_HDCP_STATUS_SUCCESS :
41 MOD_HDCP_STATUS_HDCP2_RX_ID_LIST_NOT_READY;
42}
43
44static inline enum mod_hdcp_status check_hdcp2_capable(struct mod_hdcp *hdcp)
45{
46 enum mod_hdcp_status status;
47
48 if (is_dp_hdcp(hdcp))
49 status = (hdcp->auth.msg.hdcp2.rxcaps_dp[0] == HDCP_2_2_RX_CAPS_VERSION_VAL) &&
50 HDCP_2_2_DP_HDCP_CAPABLE(hdcp->auth.msg.hdcp2.rxcaps_dp[2]) ?
51 MOD_HDCP_STATUS_SUCCESS :
52 MOD_HDCP_STATUS_HDCP2_NOT_CAPABLE;
53 else
54 status = (hdcp->auth.msg.hdcp2.hdcp2version_hdmi & HDCP_2_2_HDMI_SUPPORT_MASK) ?
55 MOD_HDCP_STATUS_SUCCESS :
56 MOD_HDCP_STATUS_HDCP2_NOT_CAPABLE;
57 return status;
58}
59
60static inline enum mod_hdcp_status check_reauthentication_request(
61 struct mod_hdcp *hdcp)
62{
63 uint8_t ret = 0;
64
65 if (is_dp_hdcp(hdcp))
66 ret = HDCP_2_2_DP_RXSTATUS_REAUTH_REQ(hdcp->auth.msg.hdcp2.rxstatus_dp) ?
67 MOD_HDCP_STATUS_HDCP2_REAUTH_REQUEST :
68 MOD_HDCP_STATUS_SUCCESS;
69 else
70 ret = HDCP_2_2_HDMI_RXSTATUS_REAUTH_REQ(hdcp->auth.msg.hdcp2.rxstatus[1]) ?
71 MOD_HDCP_STATUS_HDCP2_REAUTH_REQUEST :
72 MOD_HDCP_STATUS_SUCCESS;
73 return ret;
74}
75
76static inline enum mod_hdcp_status check_link_integrity_failure_dp(
77 struct mod_hdcp *hdcp)
78{
79 return HDCP_2_2_DP_RXSTATUS_LINK_FAILED(hdcp->auth.msg.hdcp2.rxstatus_dp) ?
80 MOD_HDCP_STATUS_HDCP2_REAUTH_LINK_INTEGRITY_FAILURE :
81 MOD_HDCP_STATUS_SUCCESS;
82}
83
84static enum mod_hdcp_status check_ake_cert_available(struct mod_hdcp *hdcp)
85{
86 enum mod_hdcp_status status;
87 uint16_t size;
88
89 if (is_dp_hdcp(hdcp)) {
90 status = MOD_HDCP_STATUS_SUCCESS;
91 } else {
92 status = mod_hdcp_read_rxstatus(hdcp);
93 if (status == MOD_HDCP_STATUS_SUCCESS) {
94 size = HDCP_2_2_HDMI_RXSTATUS_MSG_SZ_HI(hdcp->auth.msg.hdcp2.rxstatus[1]) << 8 |
95 hdcp->auth.msg.hdcp2.rxstatus[0];
96 status = (size == sizeof(hdcp->auth.msg.hdcp2.ake_cert)) ?
97 MOD_HDCP_STATUS_SUCCESS :
98 MOD_HDCP_STATUS_HDCP2_AKE_CERT_PENDING;
99 }
100 }
101 return status;
102}
103
104static enum mod_hdcp_status check_h_prime_available(struct mod_hdcp *hdcp)
105{
106 enum mod_hdcp_status status;
107 uint8_t size;
108
109 status = mod_hdcp_read_rxstatus(hdcp);
110 if (status != MOD_HDCP_STATUS_SUCCESS)
111 goto out;
112
113 if (is_dp_hdcp(hdcp)) {
114 status = HDCP_2_2_DP_RXSTATUS_H_PRIME(hdcp->auth.msg.hdcp2.rxstatus_dp) ?
115 MOD_HDCP_STATUS_SUCCESS :
116 MOD_HDCP_STATUS_HDCP2_H_PRIME_PENDING;
117 } else {
118 size = HDCP_2_2_HDMI_RXSTATUS_MSG_SZ_HI(hdcp->auth.msg.hdcp2.rxstatus[1]) << 8 |
119 hdcp->auth.msg.hdcp2.rxstatus[0];
120 status = (size == sizeof(hdcp->auth.msg.hdcp2.ake_h_prime)) ?
121 MOD_HDCP_STATUS_SUCCESS :
122 MOD_HDCP_STATUS_HDCP2_H_PRIME_PENDING;
123 }
124out:
125 return status;
126}
127
128static enum mod_hdcp_status check_pairing_info_available(struct mod_hdcp *hdcp)
129{
130 enum mod_hdcp_status status;
131 uint8_t size;
132
133 status = mod_hdcp_read_rxstatus(hdcp);
134 if (status != MOD_HDCP_STATUS_SUCCESS)
135 goto out;
136
137 if (is_dp_hdcp(hdcp)) {
138 status = HDCP_2_2_DP_RXSTATUS_PAIRING(hdcp->auth.msg.hdcp2.rxstatus_dp) ?
139 MOD_HDCP_STATUS_SUCCESS :
140 MOD_HDCP_STATUS_HDCP2_PAIRING_INFO_PENDING;
141 } else {
142 size = HDCP_2_2_HDMI_RXSTATUS_MSG_SZ_HI(hdcp->auth.msg.hdcp2.rxstatus[1]) << 8 |
143 hdcp->auth.msg.hdcp2.rxstatus[0];
144 status = (size == sizeof(hdcp->auth.msg.hdcp2.ake_pairing_info)) ?
145 MOD_HDCP_STATUS_SUCCESS :
146 MOD_HDCP_STATUS_HDCP2_PAIRING_INFO_PENDING;
147 }
148out:
149 return status;
150}
151
152static enum mod_hdcp_status poll_l_prime_available(struct mod_hdcp *hdcp)
153{
154 enum mod_hdcp_status status;
155 uint8_t size;
156 uint16_t max_wait = 20; // units of ms
157 uint16_t num_polls = 5;
158 uint16_t wait_time = max_wait / num_polls;
159
160 if (is_dp_hdcp(hdcp))
161 status = MOD_HDCP_STATUS_INVALID_OPERATION;
162 else
163 for (; num_polls; num_polls--) {
164 msleep(wait_time);
165
166 status = mod_hdcp_read_rxstatus(hdcp);
167 if (status != MOD_HDCP_STATUS_SUCCESS)
168 break;
169
170 size = HDCP_2_2_HDMI_RXSTATUS_MSG_SZ_HI(hdcp->auth.msg.hdcp2.rxstatus[1]) << 8 |
171 hdcp->auth.msg.hdcp2.rxstatus[0];
172 status = (size == sizeof(hdcp->auth.msg.hdcp2.lc_l_prime)) ?
173 MOD_HDCP_STATUS_SUCCESS :
174 MOD_HDCP_STATUS_HDCP2_L_PRIME_PENDING;
175 if (status == MOD_HDCP_STATUS_SUCCESS)
176 break;
177 }
178 return status;
179}
180
181static enum mod_hdcp_status check_stream_ready_available(struct mod_hdcp *hdcp)
182{
183 enum mod_hdcp_status status;
184 uint8_t size;
185
186 if (is_dp_hdcp(hdcp)) {
187 status = MOD_HDCP_STATUS_INVALID_OPERATION;
188 } else {
189 status = mod_hdcp_read_rxstatus(hdcp);
190 if (status != MOD_HDCP_STATUS_SUCCESS)
191 goto out;
192 size = HDCP_2_2_HDMI_RXSTATUS_MSG_SZ_HI(hdcp->auth.msg.hdcp2.rxstatus[1]) << 8 |
193 hdcp->auth.msg.hdcp2.rxstatus[0];
194 status = (size == sizeof(hdcp->auth.msg.hdcp2.repeater_auth_stream_ready)) ?
195 MOD_HDCP_STATUS_SUCCESS :
196 MOD_HDCP_STATUS_HDCP2_STREAM_READY_PENDING;
197 }
198out:
199 return status;
200}
201
202static inline uint8_t get_device_count(struct mod_hdcp *hdcp)
203{
204 return HDCP_2_2_DEV_COUNT_LO(hdcp->auth.msg.hdcp2.rx_id_list[2]) +
205 (HDCP_2_2_DEV_COUNT_HI(hdcp->auth.msg.hdcp2.rx_id_list[1]) << 4);
206}
207
208static enum mod_hdcp_status check_device_count(struct mod_hdcp *hdcp)
209{
210 /* Avoid device count == 0 to do authentication */
211 if (get_device_count(hdcp) == 0)
212 return MOD_HDCP_STATUS_HDCP1_DEVICE_COUNT_MISMATCH_FAILURE;
213
214 /* Some MST display may choose to report the internal panel as an HDCP RX. */
215 /* To update this condition with 1(because the immediate repeater's internal */
216 /* panel is possibly not included in DEVICE_COUNT) + get_device_count(hdcp). */
217 /* Device count must be greater than or equal to tracked hdcp displays. */
218 return ((1 + get_device_count(hdcp)) < get_active_display_count(hdcp)) ?
219 MOD_HDCP_STATUS_HDCP2_DEVICE_COUNT_MISMATCH_FAILURE :
220 MOD_HDCP_STATUS_SUCCESS;
221}
222
223static uint8_t process_rxstatus(struct mod_hdcp *hdcp,
224 struct mod_hdcp_event_context *event_ctx,
225 struct mod_hdcp_transition_input_hdcp2 *input,
226 enum mod_hdcp_status *status)
227{
228 if (!mod_hdcp_execute_and_set(mod_hdcp_read_rxstatus,
229 &input->rxstatus_read, status,
230 hdcp, "rxstatus_read"))
231 goto out;
232 if (!mod_hdcp_execute_and_set(check_reauthentication_request,
233 &input->reauth_request_check, status,
234 hdcp, "reauth_request_check"))
235 goto out;
236 if (is_dp_hdcp(hdcp)) {
237 if (!mod_hdcp_execute_and_set(check_link_integrity_failure_dp,
238 &input->link_integrity_check_dp, status,
239 hdcp, "link_integrity_check_dp"))
240 goto out;
241 }
242 if (hdcp->connection.is_repeater)
243 if (check_receiver_id_list_ready(hdcp) ==
244 MOD_HDCP_STATUS_SUCCESS) {
245 HDCP_INPUT_PASS_TRACE(hdcp, "rx_id_list_ready");
246 event_ctx->rx_id_list_ready = 1;
247 if (is_dp_hdcp(hdcp))
248 hdcp->auth.msg.hdcp2.rx_id_list_size =
249 sizeof(hdcp->auth.msg.hdcp2.rx_id_list);
250 else
251 hdcp->auth.msg.hdcp2.rx_id_list_size =
252 HDCP_2_2_HDMI_RXSTATUS_MSG_SZ_HI(hdcp->auth.msg.hdcp2.rxstatus[1]) << 8 |
253 hdcp->auth.msg.hdcp2.rxstatus[0];
254 }
255out:
256 return (*status == MOD_HDCP_STATUS_SUCCESS);
257}
258
259static enum mod_hdcp_status known_hdcp2_capable_rx(struct mod_hdcp *hdcp,
260 struct mod_hdcp_event_context *event_ctx,
261 struct mod_hdcp_transition_input_hdcp2 *input)
262{
263 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
264
265 if (event_ctx->event != MOD_HDCP_EVENT_CALLBACK) {
266 event_ctx->unexpected_event = 1;
267 goto out;
268 }
269
270 if (!mod_hdcp_execute_and_set(mod_hdcp_read_hdcp2version,
271 &input->hdcp2version_read, &status,
272 hdcp, "hdcp2version_read"))
273 goto out;
274 if (!mod_hdcp_execute_and_set(check_hdcp2_capable,
275 &input->hdcp2_capable_check, &status,
276 hdcp, "hdcp2_capable"))
277 goto out;
278out:
279 return status;
280}
281
282static enum mod_hdcp_status send_ake_init(struct mod_hdcp *hdcp,
283 struct mod_hdcp_event_context *event_ctx,
284 struct mod_hdcp_transition_input_hdcp2 *input)
285{
286 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
287
288 if (event_ctx->event != MOD_HDCP_EVENT_CALLBACK) {
289 event_ctx->unexpected_event = 1;
290 goto out;
291 }
292
293 if (!mod_hdcp_execute_and_set(mod_hdcp_hdcp2_create_session,
294 &input->create_session, &status,
295 hdcp, "create_session"))
296 goto out;
297 if (!mod_hdcp_execute_and_set(mod_hdcp_hdcp2_prepare_ake_init,
298 &input->ake_init_prepare, &status,
299 hdcp, "ake_init_prepare"))
300 goto out;
301 if (!mod_hdcp_execute_and_set(mod_hdcp_write_ake_init,
302 &input->ake_init_write, &status,
303 hdcp, "ake_init_write"))
304 goto out;
305out:
306 return status;
307}
308
309static enum mod_hdcp_status validate_ake_cert(struct mod_hdcp *hdcp,
310 struct mod_hdcp_event_context *event_ctx,
311 struct mod_hdcp_transition_input_hdcp2 *input)
312{
313 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
314
315
316 if (event_ctx->event != MOD_HDCP_EVENT_CALLBACK &&
317 event_ctx->event != MOD_HDCP_EVENT_WATCHDOG_TIMEOUT) {
318 event_ctx->unexpected_event = 1;
319 goto out;
320 }
321
322 if (is_hdmi_dvi_sl_hdcp(hdcp))
323 if (!mod_hdcp_execute_and_set(check_ake_cert_available,
324 &input->ake_cert_available, &status,
325 hdcp, "ake_cert_available"))
326 goto out;
327 if (!mod_hdcp_execute_and_set(mod_hdcp_read_ake_cert,
328 &input->ake_cert_read, &status,
329 hdcp, "ake_cert_read"))
330 goto out;
331 if (!mod_hdcp_execute_and_set(mod_hdcp_hdcp2_validate_ake_cert,
332 &input->ake_cert_validation, &status,
333 hdcp, "ake_cert_validation"))
334 goto out;
335out:
336 return status;
337}
338
339static enum mod_hdcp_status send_no_stored_km(struct mod_hdcp *hdcp,
340 struct mod_hdcp_event_context *event_ctx,
341 struct mod_hdcp_transition_input_hdcp2 *input)
342{
343 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
344
345 if (event_ctx->event != MOD_HDCP_EVENT_CALLBACK) {
346 event_ctx->unexpected_event = 1;
347 goto out;
348 }
349
350 if (!mod_hdcp_execute_and_set(mod_hdcp_write_no_stored_km,
351 &input->no_stored_km_write, &status,
352 hdcp, "no_stored_km_write"))
353 goto out;
354out:
355 return status;
356}
357
358static enum mod_hdcp_status read_h_prime(struct mod_hdcp *hdcp,
359 struct mod_hdcp_event_context *event_ctx,
360 struct mod_hdcp_transition_input_hdcp2 *input)
361{
362 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
363
364 if (event_ctx->event != MOD_HDCP_EVENT_CALLBACK &&
365 event_ctx->event != MOD_HDCP_EVENT_CPIRQ &&
366 event_ctx->event != MOD_HDCP_EVENT_WATCHDOG_TIMEOUT) {
367 event_ctx->unexpected_event = 1;
368 goto out;
369 }
370
371 if (!mod_hdcp_execute_and_set(check_h_prime_available,
372 &input->h_prime_available, &status,
373 hdcp, "h_prime_available"))
374 goto out;
375
376 if (!mod_hdcp_execute_and_set(mod_hdcp_read_h_prime,
377 &input->h_prime_read, &status,
378 hdcp, "h_prime_read"))
379 goto out;
380out:
381 return status;
382}
383
384static enum mod_hdcp_status read_pairing_info_and_validate_h_prime(
385 struct mod_hdcp *hdcp,
386 struct mod_hdcp_event_context *event_ctx,
387 struct mod_hdcp_transition_input_hdcp2 *input)
388{
389 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
390
391 if (event_ctx->event != MOD_HDCP_EVENT_CALLBACK &&
392 event_ctx->event != MOD_HDCP_EVENT_CPIRQ &&
393 event_ctx->event != MOD_HDCP_EVENT_WATCHDOG_TIMEOUT) {
394 event_ctx->unexpected_event = 1;
395 goto out;
396 }
397
398 if (!mod_hdcp_execute_and_set(check_pairing_info_available,
399 &input->pairing_available, &status,
400 hdcp, "pairing_available"))
401 goto out;
402 if (!mod_hdcp_execute_and_set(mod_hdcp_read_pairing_info,
403 &input->pairing_info_read, &status,
404 hdcp, "pairing_info_read"))
405 goto out;
406 if (!mod_hdcp_execute_and_set(mod_hdcp_hdcp2_validate_h_prime,
407 &input->h_prime_validation, &status,
408 hdcp, "h_prime_validation"))
409 goto out;
410out:
411 return status;
412}
413
414static enum mod_hdcp_status send_stored_km(struct mod_hdcp *hdcp,
415 struct mod_hdcp_event_context *event_ctx,
416 struct mod_hdcp_transition_input_hdcp2 *input)
417{
418 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
419
420 if (event_ctx->event != MOD_HDCP_EVENT_CALLBACK) {
421 event_ctx->unexpected_event = 1;
422 goto out;
423 }
424
425 if (!mod_hdcp_execute_and_set(mod_hdcp_write_stored_km,
426 &input->stored_km_write, &status,
427 hdcp, "stored_km_write"))
428 goto out;
429out:
430 return status;
431}
432
433static enum mod_hdcp_status validate_h_prime(struct mod_hdcp *hdcp,
434 struct mod_hdcp_event_context *event_ctx,
435 struct mod_hdcp_transition_input_hdcp2 *input)
436{
437 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
438
439 if (event_ctx->event != MOD_HDCP_EVENT_CALLBACK &&
440 event_ctx->event != MOD_HDCP_EVENT_CPIRQ &&
441 event_ctx->event != MOD_HDCP_EVENT_WATCHDOG_TIMEOUT) {
442 event_ctx->unexpected_event = 1;
443 goto out;
444 }
445
446 if (!mod_hdcp_execute_and_set(check_h_prime_available,
447 &input->h_prime_available, &status,
448 hdcp, "h_prime_available"))
449 goto out;
450 if (!mod_hdcp_execute_and_set(mod_hdcp_read_h_prime,
451 &input->h_prime_read, &status,
452 hdcp, "h_prime_read"))
453 goto out;
454 if (!mod_hdcp_execute_and_set(mod_hdcp_hdcp2_validate_h_prime,
455 &input->h_prime_validation, &status,
456 hdcp, "h_prime_validation"))
457 goto out;
458out:
459 return status;
460}
461
462static enum mod_hdcp_status locality_check(struct mod_hdcp *hdcp,
463 struct mod_hdcp_event_context *event_ctx,
464 struct mod_hdcp_transition_input_hdcp2 *input)
465{
466 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
467
468 if (event_ctx->event != MOD_HDCP_EVENT_CALLBACK) {
469 event_ctx->unexpected_event = 1;
470 goto out;
471 }
472
473 if (!mod_hdcp_execute_and_set(mod_hdcp_hdcp2_prepare_lc_init,
474 &input->lc_init_prepare, &status,
475 hdcp, "lc_init_prepare"))
476 goto out;
477 if (!mod_hdcp_execute_and_set(mod_hdcp_write_lc_init,
478 &input->lc_init_write, &status,
479 hdcp, "lc_init_write"))
480 goto out;
481 if (is_dp_hdcp(hdcp))
482 msleep(16);
483 else
484 if (!mod_hdcp_execute_and_set(poll_l_prime_available,
485 &input->l_prime_available_poll, &status,
486 hdcp, "l_prime_available_poll"))
487 goto out;
488 if (!mod_hdcp_execute_and_set(mod_hdcp_read_l_prime,
489 &input->l_prime_read, &status,
490 hdcp, "l_prime_read"))
491 goto out;
492 if (!mod_hdcp_execute_and_set(mod_hdcp_hdcp2_validate_l_prime,
493 &input->l_prime_validation, &status,
494 hdcp, "l_prime_validation"))
495 goto out;
496out:
497 return status;
498}
499
500static enum mod_hdcp_status exchange_ks_and_test_for_repeater(struct mod_hdcp *hdcp,
501 struct mod_hdcp_event_context *event_ctx,
502 struct mod_hdcp_transition_input_hdcp2 *input)
503{
504 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
505
506 if (event_ctx->event != MOD_HDCP_EVENT_CALLBACK) {
507 event_ctx->unexpected_event = 1;
508 goto out;
509 }
510
511 if (!mod_hdcp_execute_and_set(mod_hdcp_hdcp2_prepare_eks,
512 &input->eks_prepare, &status,
513 hdcp, "eks_prepare"))
514 goto out;
515 if (!mod_hdcp_execute_and_set(mod_hdcp_write_eks,
516 &input->eks_write, &status,
517 hdcp, "eks_write"))
518 goto out;
519out:
520 return status;
521}
522
523static enum mod_hdcp_status enable_encryption(struct mod_hdcp *hdcp,
524 struct mod_hdcp_event_context *event_ctx,
525 struct mod_hdcp_transition_input_hdcp2 *input)
526{
527 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
528
529 if (event_ctx->event != MOD_HDCP_EVENT_CALLBACK &&
530 event_ctx->event != MOD_HDCP_EVENT_CPIRQ) {
531 event_ctx->unexpected_event = 1;
532 goto out;
533 }
534 if (event_ctx->event == MOD_HDCP_EVENT_CPIRQ) {
535 process_rxstatus(hdcp, event_ctx, input, &status);
536 goto out;
537 }
538
539 if (is_hdmi_dvi_sl_hdcp(hdcp)) {
540 if (!process_rxstatus(hdcp, event_ctx, input, &status))
541 goto out;
542 if (event_ctx->rx_id_list_ready)
543 goto out;
544 }
545 if (!mod_hdcp_execute_and_set(mod_hdcp_hdcp2_enable_encryption,
546 &input->enable_encryption, &status,
547 hdcp, "enable_encryption"))
548 goto out;
549 if (is_dp_mst_hdcp(hdcp)) {
550 if (!mod_hdcp_execute_and_set(
551 mod_hdcp_hdcp2_enable_dp_stream_encryption,
552 &input->stream_encryption_dp, &status,
553 hdcp, "stream_encryption_dp"))
554 goto out;
555 }
556out:
557 return status;
558}
559
560static enum mod_hdcp_status authenticated(struct mod_hdcp *hdcp,
561 struct mod_hdcp_event_context *event_ctx,
562 struct mod_hdcp_transition_input_hdcp2 *input)
563{
564 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
565
566 if (event_ctx->event != MOD_HDCP_EVENT_CALLBACK &&
567 event_ctx->event != MOD_HDCP_EVENT_CPIRQ) {
568 event_ctx->unexpected_event = 1;
569 goto out;
570 }
571
572 process_rxstatus(hdcp, event_ctx, input, &status);
573out:
574 return status;
575}
576
577static enum mod_hdcp_status wait_for_rx_id_list(struct mod_hdcp *hdcp,
578 struct mod_hdcp_event_context *event_ctx,
579 struct mod_hdcp_transition_input_hdcp2 *input)
580{
581 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
582
583 if (event_ctx->event != MOD_HDCP_EVENT_CALLBACK &&
584 event_ctx->event != MOD_HDCP_EVENT_CPIRQ &&
585 event_ctx->event != MOD_HDCP_EVENT_WATCHDOG_TIMEOUT) {
586 event_ctx->unexpected_event = 1;
587 goto out;
588 }
589
590 if (!process_rxstatus(hdcp, event_ctx, input, &status))
591 goto out;
592 if (!event_ctx->rx_id_list_ready) {
593 status = MOD_HDCP_STATUS_HDCP2_RX_ID_LIST_NOT_READY;
594 goto out;
595 }
596out:
597 return status;
598}
599
600static enum mod_hdcp_status verify_rx_id_list_and_send_ack(struct mod_hdcp *hdcp,
601 struct mod_hdcp_event_context *event_ctx,
602 struct mod_hdcp_transition_input_hdcp2 *input)
603{
604 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
605
606 if (event_ctx->event != MOD_HDCP_EVENT_CALLBACK &&
607 event_ctx->event != MOD_HDCP_EVENT_CPIRQ) {
608 event_ctx->unexpected_event = 1;
609 goto out;
610 }
611 if (event_ctx->event == MOD_HDCP_EVENT_CPIRQ) {
612 process_rxstatus(hdcp, event_ctx, input, &status);
613 goto out;
614 }
615
616 if (!mod_hdcp_execute_and_set(mod_hdcp_read_rx_id_list,
617 &input->rx_id_list_read,
618 &status, hdcp, "receiver_id_list_read"))
619 goto out;
620 if (!mod_hdcp_execute_and_set(check_device_count,
621 &input->device_count_check,
622 &status, hdcp, "device_count_check"))
623 goto out;
624 if (!mod_hdcp_execute_and_set(mod_hdcp_hdcp2_validate_rx_id_list,
625 &input->rx_id_list_validation,
626 &status, hdcp, "rx_id_list_validation"))
627 goto out;
628 if (!mod_hdcp_execute_and_set(mod_hdcp_write_repeater_auth_ack,
629 &input->repeater_auth_ack_write,
630 &status, hdcp, "repeater_auth_ack_write"))
631 goto out;
632out:
633 return status;
634}
635
636static enum mod_hdcp_status send_stream_management(struct mod_hdcp *hdcp,
637 struct mod_hdcp_event_context *event_ctx,
638 struct mod_hdcp_transition_input_hdcp2 *input)
639{
640 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
641
642 if (event_ctx->event != MOD_HDCP_EVENT_CALLBACK &&
643 event_ctx->event != MOD_HDCP_EVENT_CPIRQ) {
644 event_ctx->unexpected_event = 1;
645 goto out;
646 }
647 if (event_ctx->event == MOD_HDCP_EVENT_CPIRQ) {
648 process_rxstatus(hdcp, event_ctx, input, &status);
649 goto out;
650 }
651
652 if (is_hdmi_dvi_sl_hdcp(hdcp)) {
653 if (!process_rxstatus(hdcp, event_ctx, input, &status))
654 goto out;
655 if (event_ctx->rx_id_list_ready)
656 goto out;
657 }
658 if (!mod_hdcp_execute_and_set(mod_hdcp_hdcp2_prepare_stream_management,
659 &input->prepare_stream_manage,
660 &status, hdcp, "prepare_stream_manage"))
661 goto out;
662
663 if (!mod_hdcp_execute_and_set(mod_hdcp_write_stream_manage,
664 &input->stream_manage_write,
665 &status, hdcp, "stream_manage_write"))
666 goto out;
667out:
668 return status;
669}
670
671static enum mod_hdcp_status validate_stream_ready(struct mod_hdcp *hdcp,
672 struct mod_hdcp_event_context *event_ctx,
673 struct mod_hdcp_transition_input_hdcp2 *input)
674{
675 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
676
677 if (event_ctx->event != MOD_HDCP_EVENT_CALLBACK &&
678 event_ctx->event != MOD_HDCP_EVENT_CPIRQ &&
679 event_ctx->event != MOD_HDCP_EVENT_WATCHDOG_TIMEOUT) {
680 event_ctx->unexpected_event = 1;
681 goto out;
682 }
683 if (event_ctx->event == MOD_HDCP_EVENT_CPIRQ) {
684 process_rxstatus(hdcp, event_ctx, input, &status);
685 goto out;
686 }
687
688 if (is_hdmi_dvi_sl_hdcp(hdcp)) {
689 if (!process_rxstatus(hdcp, event_ctx, input, &status))
690 goto out;
691 if (event_ctx->rx_id_list_ready)
692 goto out;
693 }
694 if (is_hdmi_dvi_sl_hdcp(hdcp))
695 if (!mod_hdcp_execute_and_set(check_stream_ready_available,
696 &input->stream_ready_available,
697 &status, hdcp, "stream_ready_available"))
698 goto out;
699 if (!mod_hdcp_execute_and_set(mod_hdcp_read_stream_ready,
700 &input->stream_ready_read,
701 &status, hdcp, "stream_ready_read"))
702 goto out;
703 if (!mod_hdcp_execute_and_set(mod_hdcp_hdcp2_validate_stream_ready,
704 &input->stream_ready_validation,
705 &status, hdcp, "stream_ready_validation"))
706 goto out;
707
708out:
709 return status;
710}
711
712static enum mod_hdcp_status determine_rx_hdcp_capable_dp(struct mod_hdcp *hdcp,
713 struct mod_hdcp_event_context *event_ctx,
714 struct mod_hdcp_transition_input_hdcp2 *input)
715{
716 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
717
718 if (event_ctx->event != MOD_HDCP_EVENT_CALLBACK) {
719 event_ctx->unexpected_event = 1;
720 goto out;
721 }
722
723 if (!mod_hdcp_execute_and_set(mod_hdcp_read_rxcaps,
724 &input->rx_caps_read_dp,
725 &status, hdcp, "rx_caps_read_dp"))
726 goto out;
727 if (!mod_hdcp_execute_and_set(check_hdcp2_capable,
728 &input->hdcp2_capable_check, &status,
729 hdcp, "hdcp2_capable_check"))
730 goto out;
731out:
732 return status;
733}
734
735static enum mod_hdcp_status send_content_stream_type_dp(struct mod_hdcp *hdcp,
736 struct mod_hdcp_event_context *event_ctx,
737 struct mod_hdcp_transition_input_hdcp2 *input)
738{
739 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
740
741 if (event_ctx->event != MOD_HDCP_EVENT_CALLBACK &&
742 event_ctx->event != MOD_HDCP_EVENT_CPIRQ) {
743 event_ctx->unexpected_event = 1;
744 goto out;
745 }
746
747 if (!process_rxstatus(hdcp, event_ctx, input, &status))
748 goto out;
749 if (!mod_hdcp_execute_and_set(mod_hdcp_write_content_type,
750 &input->content_stream_type_write, &status,
751 hdcp, "content_stream_type_write"))
752 goto out;
753out:
754 return status;
755}
756
757enum mod_hdcp_status mod_hdcp_hdcp2_execution(struct mod_hdcp *hdcp,
758 struct mod_hdcp_event_context *event_ctx,
759 struct mod_hdcp_transition_input_hdcp2 *input)
760{
761 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
762
763 switch (current_state(hdcp)) {
764 case H2_A0_KNOWN_HDCP2_CAPABLE_RX:
765 status = known_hdcp2_capable_rx(hdcp, event_ctx, input);
766 break;
767 case H2_A1_SEND_AKE_INIT:
768 status = send_ake_init(hdcp, event_ctx, input);
769 break;
770 case H2_A1_VALIDATE_AKE_CERT:
771 status = validate_ake_cert(hdcp, event_ctx, input);
772 break;
773 case H2_A1_SEND_NO_STORED_KM:
774 status = send_no_stored_km(hdcp, event_ctx, input);
775 break;
776 case H2_A1_READ_H_PRIME:
777 status = read_h_prime(hdcp, event_ctx, input);
778 break;
779 case H2_A1_READ_PAIRING_INFO_AND_VALIDATE_H_PRIME:
780 status = read_pairing_info_and_validate_h_prime(hdcp,
781 event_ctx, input);
782 break;
783 case H2_A1_SEND_STORED_KM:
784 status = send_stored_km(hdcp, event_ctx, input);
785 break;
786 case H2_A1_VALIDATE_H_PRIME:
787 status = validate_h_prime(hdcp, event_ctx, input);
788 break;
789 case H2_A2_LOCALITY_CHECK:
790 status = locality_check(hdcp, event_ctx, input);
791 break;
792 case H2_A3_EXCHANGE_KS_AND_TEST_FOR_REPEATER:
793 status = exchange_ks_and_test_for_repeater(hdcp, event_ctx, input);
794 break;
795 case H2_ENABLE_ENCRYPTION:
796 status = enable_encryption(hdcp, event_ctx, input);
797 break;
798 case H2_A5_AUTHENTICATED:
799 status = authenticated(hdcp, event_ctx, input);
800 break;
801 case H2_A6_WAIT_FOR_RX_ID_LIST:
802 status = wait_for_rx_id_list(hdcp, event_ctx, input);
803 break;
804 case H2_A78_VERIFY_RX_ID_LIST_AND_SEND_ACK:
805 status = verify_rx_id_list_and_send_ack(hdcp, event_ctx, input);
806 break;
807 case H2_A9_SEND_STREAM_MANAGEMENT:
808 status = send_stream_management(hdcp, event_ctx, input);
809 break;
810 case H2_A9_VALIDATE_STREAM_READY:
811 status = validate_stream_ready(hdcp, event_ctx, input);
812 break;
813 default:
814 status = MOD_HDCP_STATUS_INVALID_STATE;
815 break;
816 }
817
818 return status;
819}
820
821enum mod_hdcp_status mod_hdcp_hdcp2_dp_execution(struct mod_hdcp *hdcp,
822 struct mod_hdcp_event_context *event_ctx,
823 struct mod_hdcp_transition_input_hdcp2 *input)
824{
825 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
826
827 switch (current_state(hdcp)) {
828 case D2_A0_DETERMINE_RX_HDCP_CAPABLE:
829 status = determine_rx_hdcp_capable_dp(hdcp, event_ctx, input);
830 break;
831 case D2_A1_SEND_AKE_INIT:
832 status = send_ake_init(hdcp, event_ctx, input);
833 break;
834 case D2_A1_VALIDATE_AKE_CERT:
835 status = validate_ake_cert(hdcp, event_ctx, input);
836 break;
837 case D2_A1_SEND_NO_STORED_KM:
838 status = send_no_stored_km(hdcp, event_ctx, input);
839 break;
840 case D2_A1_READ_H_PRIME:
841 status = read_h_prime(hdcp, event_ctx, input);
842 break;
843 case D2_A1_READ_PAIRING_INFO_AND_VALIDATE_H_PRIME:
844 status = read_pairing_info_and_validate_h_prime(hdcp,
845 event_ctx, input);
846 break;
847 case D2_A1_SEND_STORED_KM:
848 status = send_stored_km(hdcp, event_ctx, input);
849 break;
850 case D2_A1_VALIDATE_H_PRIME:
851 status = validate_h_prime(hdcp, event_ctx, input);
852 break;
853 case D2_A2_LOCALITY_CHECK:
854 status = locality_check(hdcp, event_ctx, input);
855 break;
856 case D2_A34_EXCHANGE_KS_AND_TEST_FOR_REPEATER:
857 status = exchange_ks_and_test_for_repeater(hdcp,
858 event_ctx, input);
859 break;
860 case D2_SEND_CONTENT_STREAM_TYPE:
861 status = send_content_stream_type_dp(hdcp, event_ctx, input);
862 break;
863 case D2_ENABLE_ENCRYPTION:
864 status = enable_encryption(hdcp, event_ctx, input);
865 break;
866 case D2_A5_AUTHENTICATED:
867 status = authenticated(hdcp, event_ctx, input);
868 break;
869 case D2_A6_WAIT_FOR_RX_ID_LIST:
870 status = wait_for_rx_id_list(hdcp, event_ctx, input);
871 break;
872 case D2_A78_VERIFY_RX_ID_LIST_AND_SEND_ACK:
873 status = verify_rx_id_list_and_send_ack(hdcp, event_ctx, input);
874 break;
875 case D2_A9_SEND_STREAM_MANAGEMENT:
876 status = send_stream_management(hdcp, event_ctx, input);
877 break;
878 case D2_A9_VALIDATE_STREAM_READY:
879 status = validate_stream_ready(hdcp, event_ctx, input);
880 break;
881 default:
882 status = MOD_HDCP_STATUS_INVALID_STATE;
883 break;
884 }
885
886 return status;
887}
1/*
2 * Copyright 2018 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#include <linux/delay.h>
27
28#include "hdcp.h"
29
30static inline enum mod_hdcp_status check_receiver_id_list_ready(struct mod_hdcp *hdcp)
31{
32 uint8_t is_ready = 0;
33
34 if (is_dp_hdcp(hdcp))
35 is_ready = HDCP_2_2_DP_RXSTATUS_READY(hdcp->auth.msg.hdcp2.rxstatus_dp) ? 1 : 0;
36 else
37 is_ready = (HDCP_2_2_HDMI_RXSTATUS_READY(hdcp->auth.msg.hdcp2.rxstatus[1]) &&
38 (HDCP_2_2_HDMI_RXSTATUS_MSG_SZ_HI(hdcp->auth.msg.hdcp2.rxstatus[1]) << 8 |
39 hdcp->auth.msg.hdcp2.rxstatus[0])) ? 1 : 0;
40 return is_ready ? MOD_HDCP_STATUS_SUCCESS :
41 MOD_HDCP_STATUS_HDCP2_RX_ID_LIST_NOT_READY;
42}
43
44static inline enum mod_hdcp_status check_hdcp2_capable(struct mod_hdcp *hdcp)
45{
46 enum mod_hdcp_status status;
47
48 if (is_dp_hdcp(hdcp))
49 status = (hdcp->auth.msg.hdcp2.rxcaps_dp[0] == HDCP_2_2_RX_CAPS_VERSION_VAL) &&
50 HDCP_2_2_DP_HDCP_CAPABLE(hdcp->auth.msg.hdcp2.rxcaps_dp[2]) ?
51 MOD_HDCP_STATUS_SUCCESS :
52 MOD_HDCP_STATUS_HDCP2_NOT_CAPABLE;
53 else
54 status = (hdcp->auth.msg.hdcp2.hdcp2version_hdmi & HDCP_2_2_HDMI_SUPPORT_MASK) ?
55 MOD_HDCP_STATUS_SUCCESS :
56 MOD_HDCP_STATUS_HDCP2_NOT_CAPABLE;
57 return status;
58}
59
60static inline enum mod_hdcp_status check_reauthentication_request(
61 struct mod_hdcp *hdcp)
62{
63 uint8_t ret = 0;
64
65 if (is_dp_hdcp(hdcp))
66 ret = HDCP_2_2_DP_RXSTATUS_REAUTH_REQ(hdcp->auth.msg.hdcp2.rxstatus_dp) ?
67 MOD_HDCP_STATUS_HDCP2_REAUTH_REQUEST :
68 MOD_HDCP_STATUS_SUCCESS;
69 else
70 ret = HDCP_2_2_HDMI_RXSTATUS_REAUTH_REQ(hdcp->auth.msg.hdcp2.rxstatus[1]) ?
71 MOD_HDCP_STATUS_HDCP2_REAUTH_REQUEST :
72 MOD_HDCP_STATUS_SUCCESS;
73 return ret;
74}
75
76static inline enum mod_hdcp_status check_link_integrity_failure_dp(
77 struct mod_hdcp *hdcp)
78{
79 return HDCP_2_2_DP_RXSTATUS_LINK_FAILED(hdcp->auth.msg.hdcp2.rxstatus_dp) ?
80 MOD_HDCP_STATUS_HDCP2_REAUTH_LINK_INTEGRITY_FAILURE :
81 MOD_HDCP_STATUS_SUCCESS;
82}
83
84static enum mod_hdcp_status check_ake_cert_available(struct mod_hdcp *hdcp)
85{
86 enum mod_hdcp_status status;
87 uint16_t size;
88
89 if (is_dp_hdcp(hdcp)) {
90 status = MOD_HDCP_STATUS_SUCCESS;
91 } else {
92 status = mod_hdcp_read_rxstatus(hdcp);
93 if (status == MOD_HDCP_STATUS_SUCCESS) {
94 size = HDCP_2_2_HDMI_RXSTATUS_MSG_SZ_HI(hdcp->auth.msg.hdcp2.rxstatus[1]) << 8 |
95 hdcp->auth.msg.hdcp2.rxstatus[0];
96 status = (size == sizeof(hdcp->auth.msg.hdcp2.ake_cert)) ?
97 MOD_HDCP_STATUS_SUCCESS :
98 MOD_HDCP_STATUS_HDCP2_AKE_CERT_PENDING;
99 }
100 }
101 return status;
102}
103
104static enum mod_hdcp_status check_h_prime_available(struct mod_hdcp *hdcp)
105{
106 enum mod_hdcp_status status;
107 uint8_t size;
108
109 status = mod_hdcp_read_rxstatus(hdcp);
110 if (status != MOD_HDCP_STATUS_SUCCESS)
111 goto out;
112
113 if (is_dp_hdcp(hdcp)) {
114 status = HDCP_2_2_DP_RXSTATUS_H_PRIME(hdcp->auth.msg.hdcp2.rxstatus_dp) ?
115 MOD_HDCP_STATUS_SUCCESS :
116 MOD_HDCP_STATUS_HDCP2_H_PRIME_PENDING;
117 } else {
118 size = HDCP_2_2_HDMI_RXSTATUS_MSG_SZ_HI(hdcp->auth.msg.hdcp2.rxstatus[1]) << 8 |
119 hdcp->auth.msg.hdcp2.rxstatus[0];
120 status = (size == sizeof(hdcp->auth.msg.hdcp2.ake_h_prime)) ?
121 MOD_HDCP_STATUS_SUCCESS :
122 MOD_HDCP_STATUS_HDCP2_H_PRIME_PENDING;
123 }
124out:
125 return status;
126}
127
128static enum mod_hdcp_status check_pairing_info_available(struct mod_hdcp *hdcp)
129{
130 enum mod_hdcp_status status;
131 uint8_t size;
132
133 status = mod_hdcp_read_rxstatus(hdcp);
134 if (status != MOD_HDCP_STATUS_SUCCESS)
135 goto out;
136
137 if (is_dp_hdcp(hdcp)) {
138 status = HDCP_2_2_DP_RXSTATUS_PAIRING(hdcp->auth.msg.hdcp2.rxstatus_dp) ?
139 MOD_HDCP_STATUS_SUCCESS :
140 MOD_HDCP_STATUS_HDCP2_PAIRING_INFO_PENDING;
141 } else {
142 size = HDCP_2_2_HDMI_RXSTATUS_MSG_SZ_HI(hdcp->auth.msg.hdcp2.rxstatus[1]) << 8 |
143 hdcp->auth.msg.hdcp2.rxstatus[0];
144 status = (size == sizeof(hdcp->auth.msg.hdcp2.ake_pairing_info)) ?
145 MOD_HDCP_STATUS_SUCCESS :
146 MOD_HDCP_STATUS_HDCP2_PAIRING_INFO_PENDING;
147 }
148out:
149 return status;
150}
151
152static enum mod_hdcp_status poll_l_prime_available(struct mod_hdcp *hdcp)
153{
154 enum mod_hdcp_status status;
155 uint8_t size;
156 uint16_t max_wait = 20; // units of ms
157 uint16_t num_polls = 5;
158 uint16_t wait_time = max_wait / num_polls;
159
160 if (is_dp_hdcp(hdcp))
161 status = MOD_HDCP_STATUS_INVALID_OPERATION;
162 else
163 for (; num_polls; num_polls--) {
164 msleep(wait_time);
165
166 status = mod_hdcp_read_rxstatus(hdcp);
167 if (status != MOD_HDCP_STATUS_SUCCESS)
168 break;
169
170 size = HDCP_2_2_HDMI_RXSTATUS_MSG_SZ_HI(hdcp->auth.msg.hdcp2.rxstatus[1]) << 8 |
171 hdcp->auth.msg.hdcp2.rxstatus[0];
172 status = (size == sizeof(hdcp->auth.msg.hdcp2.lc_l_prime)) ?
173 MOD_HDCP_STATUS_SUCCESS :
174 MOD_HDCP_STATUS_HDCP2_L_PRIME_PENDING;
175 if (status == MOD_HDCP_STATUS_SUCCESS)
176 break;
177 }
178 return status;
179}
180
181static enum mod_hdcp_status check_stream_ready_available(struct mod_hdcp *hdcp)
182{
183 enum mod_hdcp_status status;
184 uint8_t size;
185
186 if (is_dp_hdcp(hdcp)) {
187 status = MOD_HDCP_STATUS_INVALID_OPERATION;
188 } else {
189 status = mod_hdcp_read_rxstatus(hdcp);
190 if (status != MOD_HDCP_STATUS_SUCCESS)
191 goto out;
192 size = HDCP_2_2_HDMI_RXSTATUS_MSG_SZ_HI(hdcp->auth.msg.hdcp2.rxstatus[1]) << 8 |
193 hdcp->auth.msg.hdcp2.rxstatus[0];
194 status = (size == sizeof(hdcp->auth.msg.hdcp2.repeater_auth_stream_ready)) ?
195 MOD_HDCP_STATUS_SUCCESS :
196 MOD_HDCP_STATUS_HDCP2_STREAM_READY_PENDING;
197 }
198out:
199 return status;
200}
201
202static inline uint8_t get_device_count(struct mod_hdcp *hdcp)
203{
204 return HDCP_2_2_DEV_COUNT_LO(hdcp->auth.msg.hdcp2.rx_id_list[2]) +
205 (HDCP_2_2_DEV_COUNT_HI(hdcp->auth.msg.hdcp2.rx_id_list[1]) << 4);
206}
207
208static enum mod_hdcp_status check_device_count(struct mod_hdcp *hdcp)
209{
210 /* device count must be greater than or equal to tracked hdcp displays */
211 return (get_device_count(hdcp) < get_active_display_count(hdcp)) ?
212 MOD_HDCP_STATUS_HDCP2_DEVICE_COUNT_MISMATCH_FAILURE :
213 MOD_HDCP_STATUS_SUCCESS;
214}
215
216static uint8_t process_rxstatus(struct mod_hdcp *hdcp,
217 struct mod_hdcp_event_context *event_ctx,
218 struct mod_hdcp_transition_input_hdcp2 *input,
219 enum mod_hdcp_status *status)
220{
221 if (!mod_hdcp_execute_and_set(mod_hdcp_read_rxstatus,
222 &input->rxstatus_read, status,
223 hdcp, "rxstatus_read"))
224 goto out;
225 if (!mod_hdcp_execute_and_set(check_reauthentication_request,
226 &input->reauth_request_check, status,
227 hdcp, "reauth_request_check"))
228 goto out;
229 if (is_dp_hdcp(hdcp)) {
230 if (!mod_hdcp_execute_and_set(check_link_integrity_failure_dp,
231 &input->link_integrity_check_dp, status,
232 hdcp, "link_integrity_check_dp"))
233 goto out;
234 }
235 if (hdcp->connection.is_repeater)
236 if (check_receiver_id_list_ready(hdcp) ==
237 MOD_HDCP_STATUS_SUCCESS) {
238 HDCP_INPUT_PASS_TRACE(hdcp, "rx_id_list_ready");
239 event_ctx->rx_id_list_ready = 1;
240 if (is_dp_hdcp(hdcp))
241 hdcp->auth.msg.hdcp2.rx_id_list_size =
242 sizeof(hdcp->auth.msg.hdcp2.rx_id_list);
243 else
244 hdcp->auth.msg.hdcp2.rx_id_list_size =
245 HDCP_2_2_HDMI_RXSTATUS_MSG_SZ_HI(hdcp->auth.msg.hdcp2.rxstatus[1]) << 8 |
246 hdcp->auth.msg.hdcp2.rxstatus[0];
247 }
248out:
249 return (*status == MOD_HDCP_STATUS_SUCCESS);
250}
251
252static enum mod_hdcp_status known_hdcp2_capable_rx(struct mod_hdcp *hdcp,
253 struct mod_hdcp_event_context *event_ctx,
254 struct mod_hdcp_transition_input_hdcp2 *input)
255{
256 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
257
258 if (event_ctx->event != MOD_HDCP_EVENT_CALLBACK) {
259 event_ctx->unexpected_event = 1;
260 goto out;
261 }
262
263 if (!mod_hdcp_execute_and_set(mod_hdcp_read_hdcp2version,
264 &input->hdcp2version_read, &status,
265 hdcp, "hdcp2version_read"))
266 goto out;
267 if (!mod_hdcp_execute_and_set(check_hdcp2_capable,
268 &input->hdcp2_capable_check, &status,
269 hdcp, "hdcp2_capable"))
270 goto out;
271out:
272 return status;
273}
274
275static enum mod_hdcp_status send_ake_init(struct mod_hdcp *hdcp,
276 struct mod_hdcp_event_context *event_ctx,
277 struct mod_hdcp_transition_input_hdcp2 *input)
278{
279 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
280
281 if (event_ctx->event != MOD_HDCP_EVENT_CALLBACK) {
282 event_ctx->unexpected_event = 1;
283 goto out;
284 }
285
286 if (!mod_hdcp_execute_and_set(mod_hdcp_hdcp2_create_session,
287 &input->create_session, &status,
288 hdcp, "create_session"))
289 goto out;
290 if (!mod_hdcp_execute_and_set(mod_hdcp_hdcp2_prepare_ake_init,
291 &input->ake_init_prepare, &status,
292 hdcp, "ake_init_prepare"))
293 goto out;
294 if (!mod_hdcp_execute_and_set(mod_hdcp_write_ake_init,
295 &input->ake_init_write, &status,
296 hdcp, "ake_init_write"))
297 goto out;
298out:
299 return status;
300}
301
302static enum mod_hdcp_status validate_ake_cert(struct mod_hdcp *hdcp,
303 struct mod_hdcp_event_context *event_ctx,
304 struct mod_hdcp_transition_input_hdcp2 *input)
305{
306 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
307
308
309 if (event_ctx->event != MOD_HDCP_EVENT_CALLBACK &&
310 event_ctx->event != MOD_HDCP_EVENT_WATCHDOG_TIMEOUT) {
311 event_ctx->unexpected_event = 1;
312 goto out;
313 }
314
315 if (is_hdmi_dvi_sl_hdcp(hdcp))
316 if (!mod_hdcp_execute_and_set(check_ake_cert_available,
317 &input->ake_cert_available, &status,
318 hdcp, "ake_cert_available"))
319 goto out;
320 if (!mod_hdcp_execute_and_set(mod_hdcp_read_ake_cert,
321 &input->ake_cert_read, &status,
322 hdcp, "ake_cert_read"))
323 goto out;
324 if (!mod_hdcp_execute_and_set(mod_hdcp_hdcp2_validate_ake_cert,
325 &input->ake_cert_validation, &status,
326 hdcp, "ake_cert_validation"))
327 goto out;
328out:
329 return status;
330}
331
332static enum mod_hdcp_status send_no_stored_km(struct mod_hdcp *hdcp,
333 struct mod_hdcp_event_context *event_ctx,
334 struct mod_hdcp_transition_input_hdcp2 *input)
335{
336 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
337
338 if (event_ctx->event != MOD_HDCP_EVENT_CALLBACK) {
339 event_ctx->unexpected_event = 1;
340 goto out;
341 }
342
343 if (!mod_hdcp_execute_and_set(mod_hdcp_write_no_stored_km,
344 &input->no_stored_km_write, &status,
345 hdcp, "no_stored_km_write"))
346 goto out;
347out:
348 return status;
349}
350
351static enum mod_hdcp_status read_h_prime(struct mod_hdcp *hdcp,
352 struct mod_hdcp_event_context *event_ctx,
353 struct mod_hdcp_transition_input_hdcp2 *input)
354{
355 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
356
357 if (event_ctx->event != MOD_HDCP_EVENT_CALLBACK &&
358 event_ctx->event != MOD_HDCP_EVENT_CPIRQ &&
359 event_ctx->event != MOD_HDCP_EVENT_WATCHDOG_TIMEOUT) {
360 event_ctx->unexpected_event = 1;
361 goto out;
362 }
363
364 if (!mod_hdcp_execute_and_set(check_h_prime_available,
365 &input->h_prime_available, &status,
366 hdcp, "h_prime_available"))
367 goto out;
368
369 if (!mod_hdcp_execute_and_set(mod_hdcp_read_h_prime,
370 &input->h_prime_read, &status,
371 hdcp, "h_prime_read"))
372 goto out;
373out:
374 return status;
375}
376
377static enum mod_hdcp_status read_pairing_info_and_validate_h_prime(
378 struct mod_hdcp *hdcp,
379 struct mod_hdcp_event_context *event_ctx,
380 struct mod_hdcp_transition_input_hdcp2 *input)
381{
382 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
383
384 if (event_ctx->event != MOD_HDCP_EVENT_CALLBACK &&
385 event_ctx->event != MOD_HDCP_EVENT_CPIRQ &&
386 event_ctx->event != MOD_HDCP_EVENT_WATCHDOG_TIMEOUT) {
387 event_ctx->unexpected_event = 1;
388 goto out;
389 }
390
391 if (!mod_hdcp_execute_and_set(check_pairing_info_available,
392 &input->pairing_available, &status,
393 hdcp, "pairing_available"))
394 goto out;
395 if (!mod_hdcp_execute_and_set(mod_hdcp_read_pairing_info,
396 &input->pairing_info_read, &status,
397 hdcp, "pairing_info_read"))
398 goto out;
399 if (!mod_hdcp_execute_and_set(mod_hdcp_hdcp2_validate_h_prime,
400 &input->h_prime_validation, &status,
401 hdcp, "h_prime_validation"))
402 goto out;
403out:
404 return status;
405}
406
407static enum mod_hdcp_status send_stored_km(struct mod_hdcp *hdcp,
408 struct mod_hdcp_event_context *event_ctx,
409 struct mod_hdcp_transition_input_hdcp2 *input)
410{
411 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
412
413 if (event_ctx->event != MOD_HDCP_EVENT_CALLBACK) {
414 event_ctx->unexpected_event = 1;
415 goto out;
416 }
417
418 if (!mod_hdcp_execute_and_set(mod_hdcp_write_stored_km,
419 &input->stored_km_write, &status,
420 hdcp, "stored_km_write"))
421 goto out;
422out:
423 return status;
424}
425
426static enum mod_hdcp_status validate_h_prime(struct mod_hdcp *hdcp,
427 struct mod_hdcp_event_context *event_ctx,
428 struct mod_hdcp_transition_input_hdcp2 *input)
429{
430 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
431
432 if (event_ctx->event != MOD_HDCP_EVENT_CALLBACK &&
433 event_ctx->event != MOD_HDCP_EVENT_CPIRQ &&
434 event_ctx->event != MOD_HDCP_EVENT_WATCHDOG_TIMEOUT) {
435 event_ctx->unexpected_event = 1;
436 goto out;
437 }
438
439 if (!mod_hdcp_execute_and_set(check_h_prime_available,
440 &input->h_prime_available, &status,
441 hdcp, "h_prime_available"))
442 goto out;
443 if (!mod_hdcp_execute_and_set(mod_hdcp_read_h_prime,
444 &input->h_prime_read, &status,
445 hdcp, "h_prime_read"))
446 goto out;
447 if (!mod_hdcp_execute_and_set(mod_hdcp_hdcp2_validate_h_prime,
448 &input->h_prime_validation, &status,
449 hdcp, "h_prime_validation"))
450 goto out;
451out:
452 return status;
453}
454
455static enum mod_hdcp_status locality_check(struct mod_hdcp *hdcp,
456 struct mod_hdcp_event_context *event_ctx,
457 struct mod_hdcp_transition_input_hdcp2 *input)
458{
459 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
460
461 if (event_ctx->event != MOD_HDCP_EVENT_CALLBACK) {
462 event_ctx->unexpected_event = 1;
463 goto out;
464 }
465
466 if (!mod_hdcp_execute_and_set(mod_hdcp_hdcp2_prepare_lc_init,
467 &input->lc_init_prepare, &status,
468 hdcp, "lc_init_prepare"))
469 goto out;
470 if (!mod_hdcp_execute_and_set(mod_hdcp_write_lc_init,
471 &input->lc_init_write, &status,
472 hdcp, "lc_init_write"))
473 goto out;
474 if (is_dp_hdcp(hdcp))
475 msleep(16);
476 else
477 if (!mod_hdcp_execute_and_set(poll_l_prime_available,
478 &input->l_prime_available_poll, &status,
479 hdcp, "l_prime_available_poll"))
480 goto out;
481 if (!mod_hdcp_execute_and_set(mod_hdcp_read_l_prime,
482 &input->l_prime_read, &status,
483 hdcp, "l_prime_read"))
484 goto out;
485 if (!mod_hdcp_execute_and_set(mod_hdcp_hdcp2_validate_l_prime,
486 &input->l_prime_validation, &status,
487 hdcp, "l_prime_validation"))
488 goto out;
489out:
490 return status;
491}
492
493static enum mod_hdcp_status exchange_ks_and_test_for_repeater(struct mod_hdcp *hdcp,
494 struct mod_hdcp_event_context *event_ctx,
495 struct mod_hdcp_transition_input_hdcp2 *input)
496{
497 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
498
499 if (event_ctx->event != MOD_HDCP_EVENT_CALLBACK) {
500 event_ctx->unexpected_event = 1;
501 goto out;
502 }
503
504 if (!mod_hdcp_execute_and_set(mod_hdcp_hdcp2_prepare_eks,
505 &input->eks_prepare, &status,
506 hdcp, "eks_prepare"))
507 goto out;
508 if (!mod_hdcp_execute_and_set(mod_hdcp_write_eks,
509 &input->eks_write, &status,
510 hdcp, "eks_write"))
511 goto out;
512out:
513 return status;
514}
515
516static enum mod_hdcp_status enable_encryption(struct mod_hdcp *hdcp,
517 struct mod_hdcp_event_context *event_ctx,
518 struct mod_hdcp_transition_input_hdcp2 *input)
519{
520 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
521
522 if (event_ctx->event != MOD_HDCP_EVENT_CALLBACK &&
523 event_ctx->event != MOD_HDCP_EVENT_CPIRQ) {
524 event_ctx->unexpected_event = 1;
525 goto out;
526 }
527 if (event_ctx->event == MOD_HDCP_EVENT_CPIRQ) {
528 process_rxstatus(hdcp, event_ctx, input, &status);
529 goto out;
530 }
531
532 if (is_hdmi_dvi_sl_hdcp(hdcp)) {
533 if (!process_rxstatus(hdcp, event_ctx, input, &status))
534 goto out;
535 if (event_ctx->rx_id_list_ready)
536 goto out;
537 }
538 if (!mod_hdcp_execute_and_set(mod_hdcp_hdcp2_enable_encryption,
539 &input->enable_encryption, &status,
540 hdcp, "enable_encryption"))
541 goto out;
542 if (is_dp_mst_hdcp(hdcp)) {
543 if (!mod_hdcp_execute_and_set(
544 mod_hdcp_hdcp2_enable_dp_stream_encryption,
545 &input->stream_encryption_dp, &status,
546 hdcp, "stream_encryption_dp"))
547 goto out;
548 }
549out:
550 return status;
551}
552
553static enum mod_hdcp_status authenticated(struct mod_hdcp *hdcp,
554 struct mod_hdcp_event_context *event_ctx,
555 struct mod_hdcp_transition_input_hdcp2 *input)
556{
557 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
558
559 if (event_ctx->event != MOD_HDCP_EVENT_CALLBACK &&
560 event_ctx->event != MOD_HDCP_EVENT_CPIRQ) {
561 event_ctx->unexpected_event = 1;
562 goto out;
563 }
564
565 if (!process_rxstatus(hdcp, event_ctx, input, &status))
566 goto out;
567 if (event_ctx->rx_id_list_ready)
568 goto out;
569out:
570 return status;
571}
572
573static enum mod_hdcp_status wait_for_rx_id_list(struct mod_hdcp *hdcp,
574 struct mod_hdcp_event_context *event_ctx,
575 struct mod_hdcp_transition_input_hdcp2 *input)
576{
577 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
578
579 if (event_ctx->event != MOD_HDCP_EVENT_CALLBACK &&
580 event_ctx->event != MOD_HDCP_EVENT_CPIRQ &&
581 event_ctx->event != MOD_HDCP_EVENT_WATCHDOG_TIMEOUT) {
582 event_ctx->unexpected_event = 1;
583 goto out;
584 }
585
586 if (!process_rxstatus(hdcp, event_ctx, input, &status))
587 goto out;
588 if (!event_ctx->rx_id_list_ready) {
589 status = MOD_HDCP_STATUS_HDCP2_RX_ID_LIST_NOT_READY;
590 goto out;
591 }
592out:
593 return status;
594}
595
596static enum mod_hdcp_status verify_rx_id_list_and_send_ack(struct mod_hdcp *hdcp,
597 struct mod_hdcp_event_context *event_ctx,
598 struct mod_hdcp_transition_input_hdcp2 *input)
599{
600 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
601
602 if (event_ctx->event != MOD_HDCP_EVENT_CALLBACK &&
603 event_ctx->event != MOD_HDCP_EVENT_CPIRQ) {
604 event_ctx->unexpected_event = 1;
605 goto out;
606 }
607 if (event_ctx->event == MOD_HDCP_EVENT_CPIRQ) {
608 process_rxstatus(hdcp, event_ctx, input, &status);
609 goto out;
610 }
611
612 if (!mod_hdcp_execute_and_set(mod_hdcp_read_rx_id_list,
613 &input->rx_id_list_read,
614 &status, hdcp, "receiver_id_list_read"))
615 goto out;
616 if (!mod_hdcp_execute_and_set(check_device_count,
617 &input->device_count_check,
618 &status, hdcp, "device_count_check"))
619 goto out;
620 if (!mod_hdcp_execute_and_set(mod_hdcp_hdcp2_validate_rx_id_list,
621 &input->rx_id_list_validation,
622 &status, hdcp, "rx_id_list_validation"))
623 goto out;
624 if (!mod_hdcp_execute_and_set(mod_hdcp_write_repeater_auth_ack,
625 &input->repeater_auth_ack_write,
626 &status, hdcp, "repeater_auth_ack_write"))
627 goto out;
628out:
629 return status;
630}
631
632static enum mod_hdcp_status send_stream_management(struct mod_hdcp *hdcp,
633 struct mod_hdcp_event_context *event_ctx,
634 struct mod_hdcp_transition_input_hdcp2 *input)
635{
636 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
637
638 if (event_ctx->event != MOD_HDCP_EVENT_CALLBACK &&
639 event_ctx->event != MOD_HDCP_EVENT_CPIRQ) {
640 event_ctx->unexpected_event = 1;
641 goto out;
642 }
643 if (event_ctx->event == MOD_HDCP_EVENT_CPIRQ) {
644 process_rxstatus(hdcp, event_ctx, input, &status);
645 goto out;
646 }
647
648 if (is_hdmi_dvi_sl_hdcp(hdcp)) {
649 if (!process_rxstatus(hdcp, event_ctx, input, &status))
650 goto out;
651 if (event_ctx->rx_id_list_ready)
652 goto out;
653 }
654 if (!mod_hdcp_execute_and_set(mod_hdcp_hdcp2_prepare_stream_management,
655 &input->prepare_stream_manage,
656 &status, hdcp, "prepare_stream_manage"))
657 goto out;
658
659 if (!mod_hdcp_execute_and_set(mod_hdcp_write_stream_manage,
660 &input->stream_manage_write,
661 &status, hdcp, "stream_manage_write"))
662 goto out;
663out:
664 return status;
665}
666
667static enum mod_hdcp_status validate_stream_ready(struct mod_hdcp *hdcp,
668 struct mod_hdcp_event_context *event_ctx,
669 struct mod_hdcp_transition_input_hdcp2 *input)
670{
671 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
672
673 if (event_ctx->event != MOD_HDCP_EVENT_CALLBACK &&
674 event_ctx->event != MOD_HDCP_EVENT_CPIRQ &&
675 event_ctx->event != MOD_HDCP_EVENT_WATCHDOG_TIMEOUT) {
676 event_ctx->unexpected_event = 1;
677 goto out;
678 }
679 if (event_ctx->event == MOD_HDCP_EVENT_CPIRQ) {
680 process_rxstatus(hdcp, event_ctx, input, &status);
681 goto out;
682 }
683
684 if (is_hdmi_dvi_sl_hdcp(hdcp)) {
685 if (!process_rxstatus(hdcp, event_ctx, input, &status))
686 goto out;
687 if (event_ctx->rx_id_list_ready) {
688 goto out;
689 }
690 }
691 if (is_hdmi_dvi_sl_hdcp(hdcp))
692 if (!mod_hdcp_execute_and_set(check_stream_ready_available,
693 &input->stream_ready_available,
694 &status, hdcp, "stream_ready_available"))
695 goto out;
696 if (!mod_hdcp_execute_and_set(mod_hdcp_read_stream_ready,
697 &input->stream_ready_read,
698 &status, hdcp, "stream_ready_read"))
699 goto out;
700 if (!mod_hdcp_execute_and_set(mod_hdcp_hdcp2_validate_stream_ready,
701 &input->stream_ready_validation,
702 &status, hdcp, "stream_ready_validation"))
703 goto out;
704
705out:
706 return status;
707}
708
709static enum mod_hdcp_status determine_rx_hdcp_capable_dp(struct mod_hdcp *hdcp,
710 struct mod_hdcp_event_context *event_ctx,
711 struct mod_hdcp_transition_input_hdcp2 *input)
712{
713 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
714
715 if (event_ctx->event != MOD_HDCP_EVENT_CALLBACK) {
716 event_ctx->unexpected_event = 1;
717 goto out;
718 }
719
720 if (!mod_hdcp_execute_and_set(mod_hdcp_read_rxcaps,
721 &input->rx_caps_read_dp,
722 &status, hdcp, "rx_caps_read_dp"))
723 goto out;
724 if (!mod_hdcp_execute_and_set(check_hdcp2_capable,
725 &input->hdcp2_capable_check, &status,
726 hdcp, "hdcp2_capable_check"))
727 goto out;
728out:
729 return status;
730}
731
732static enum mod_hdcp_status send_content_stream_type_dp(struct mod_hdcp *hdcp,
733 struct mod_hdcp_event_context *event_ctx,
734 struct mod_hdcp_transition_input_hdcp2 *input)
735{
736 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
737
738 if (event_ctx->event != MOD_HDCP_EVENT_CALLBACK &&
739 event_ctx->event != MOD_HDCP_EVENT_CPIRQ) {
740 event_ctx->unexpected_event = 1;
741 goto out;
742 }
743
744 if (!process_rxstatus(hdcp, event_ctx, input, &status))
745 goto out;
746 if (!mod_hdcp_execute_and_set(mod_hdcp_write_content_type,
747 &input->content_stream_type_write, &status,
748 hdcp, "content_stream_type_write"))
749 goto out;
750out:
751 return status;
752}
753
754enum mod_hdcp_status mod_hdcp_hdcp2_execution(struct mod_hdcp *hdcp,
755 struct mod_hdcp_event_context *event_ctx,
756 struct mod_hdcp_transition_input_hdcp2 *input)
757{
758 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
759
760 switch (current_state(hdcp)) {
761 case H2_A0_KNOWN_HDCP2_CAPABLE_RX:
762 status = known_hdcp2_capable_rx(hdcp, event_ctx, input);
763 break;
764 case H2_A1_SEND_AKE_INIT:
765 status = send_ake_init(hdcp, event_ctx, input);
766 break;
767 case H2_A1_VALIDATE_AKE_CERT:
768 status = validate_ake_cert(hdcp, event_ctx, input);
769 break;
770 case H2_A1_SEND_NO_STORED_KM:
771 status = send_no_stored_km(hdcp, event_ctx, input);
772 break;
773 case H2_A1_READ_H_PRIME:
774 status = read_h_prime(hdcp, event_ctx, input);
775 break;
776 case H2_A1_READ_PAIRING_INFO_AND_VALIDATE_H_PRIME:
777 status = read_pairing_info_and_validate_h_prime(hdcp,
778 event_ctx, input);
779 break;
780 case H2_A1_SEND_STORED_KM:
781 status = send_stored_km(hdcp, event_ctx, input);
782 break;
783 case H2_A1_VALIDATE_H_PRIME:
784 status = validate_h_prime(hdcp, event_ctx, input);
785 break;
786 case H2_A2_LOCALITY_CHECK:
787 status = locality_check(hdcp, event_ctx, input);
788 break;
789 case H2_A3_EXCHANGE_KS_AND_TEST_FOR_REPEATER:
790 status = exchange_ks_and_test_for_repeater(hdcp, event_ctx, input);
791 break;
792 case H2_ENABLE_ENCRYPTION:
793 status = enable_encryption(hdcp, event_ctx, input);
794 break;
795 case H2_A5_AUTHENTICATED:
796 status = authenticated(hdcp, event_ctx, input);
797 break;
798 case H2_A6_WAIT_FOR_RX_ID_LIST:
799 status = wait_for_rx_id_list(hdcp, event_ctx, input);
800 break;
801 case H2_A78_VERIFY_RX_ID_LIST_AND_SEND_ACK:
802 status = verify_rx_id_list_and_send_ack(hdcp, event_ctx, input);
803 break;
804 case H2_A9_SEND_STREAM_MANAGEMENT:
805 status = send_stream_management(hdcp, event_ctx, input);
806 break;
807 case H2_A9_VALIDATE_STREAM_READY:
808 status = validate_stream_ready(hdcp, event_ctx, input);
809 break;
810 default:
811 status = MOD_HDCP_STATUS_INVALID_STATE;
812 break;
813 }
814
815 return status;
816}
817
818enum mod_hdcp_status mod_hdcp_hdcp2_dp_execution(struct mod_hdcp *hdcp,
819 struct mod_hdcp_event_context *event_ctx,
820 struct mod_hdcp_transition_input_hdcp2 *input)
821{
822 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
823
824 switch (current_state(hdcp)) {
825 case D2_A0_DETERMINE_RX_HDCP_CAPABLE:
826 status = determine_rx_hdcp_capable_dp(hdcp, event_ctx, input);
827 break;
828 case D2_A1_SEND_AKE_INIT:
829 status = send_ake_init(hdcp, event_ctx, input);
830 break;
831 case D2_A1_VALIDATE_AKE_CERT:
832 status = validate_ake_cert(hdcp, event_ctx, input);
833 break;
834 case D2_A1_SEND_NO_STORED_KM:
835 status = send_no_stored_km(hdcp, event_ctx, input);
836 break;
837 case D2_A1_READ_H_PRIME:
838 status = read_h_prime(hdcp, event_ctx, input);
839 break;
840 case D2_A1_READ_PAIRING_INFO_AND_VALIDATE_H_PRIME:
841 status = read_pairing_info_and_validate_h_prime(hdcp,
842 event_ctx, input);
843 break;
844 case D2_A1_SEND_STORED_KM:
845 status = send_stored_km(hdcp, event_ctx, input);
846 break;
847 case D2_A1_VALIDATE_H_PRIME:
848 status = validate_h_prime(hdcp, event_ctx, input);
849 break;
850 case D2_A2_LOCALITY_CHECK:
851 status = locality_check(hdcp, event_ctx, input);
852 break;
853 case D2_A34_EXCHANGE_KS_AND_TEST_FOR_REPEATER:
854 status = exchange_ks_and_test_for_repeater(hdcp,
855 event_ctx, input);
856 break;
857 case D2_SEND_CONTENT_STREAM_TYPE:
858 status = send_content_stream_type_dp(hdcp, event_ctx, input);
859 break;
860 case D2_ENABLE_ENCRYPTION:
861 status = enable_encryption(hdcp, event_ctx, input);
862 break;
863 case D2_A5_AUTHENTICATED:
864 status = authenticated(hdcp, event_ctx, input);
865 break;
866 case D2_A6_WAIT_FOR_RX_ID_LIST:
867 status = wait_for_rx_id_list(hdcp, event_ctx, input);
868 break;
869 case D2_A78_VERIFY_RX_ID_LIST_AND_SEND_ACK:
870 status = verify_rx_id_list_and_send_ack(hdcp, event_ctx, input);
871 break;
872 case D2_A9_SEND_STREAM_MANAGEMENT:
873 status = send_stream_management(hdcp, event_ctx, input);
874 break;
875 case D2_A9_VALIDATE_STREAM_READY:
876 status = validate_stream_ready(hdcp, event_ctx, input);
877 break;
878 default:
879 status = MOD_HDCP_STATUS_INVALID_STATE;
880 break;
881 }
882
883 return status;
884}