0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026 #include "hdcp.h"
0027
0028 enum mod_hdcp_status mod_hdcp_hdcp2_transition(struct mod_hdcp *hdcp,
0029 struct mod_hdcp_event_context *event_ctx,
0030 struct mod_hdcp_transition_input_hdcp2 *input,
0031 struct mod_hdcp_output *output)
0032 {
0033 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
0034 struct mod_hdcp_connection *conn = &hdcp->connection;
0035 struct mod_hdcp_link_adjustment *adjust = &hdcp->connection.link.adjust;
0036
0037 switch (current_state(hdcp)) {
0038 case H2_A0_KNOWN_HDCP2_CAPABLE_RX:
0039 if (input->hdcp2version_read != PASS ||
0040 input->hdcp2_capable_check != PASS) {
0041 adjust->hdcp2.disable = 1;
0042 callback_in_ms(0, output);
0043 set_state_id(hdcp, output, HDCP_INITIALIZED);
0044 } else {
0045 callback_in_ms(0, output);
0046 set_state_id(hdcp, output, H2_A1_SEND_AKE_INIT);
0047 }
0048 break;
0049 case H2_A1_SEND_AKE_INIT:
0050 if (input->create_session != PASS ||
0051 input->ake_init_prepare != PASS) {
0052
0053 adjust->hdcp2.disable = 1;
0054 fail_and_restart_in_ms(0, &status, output);
0055 break;
0056 } else if (input->ake_init_write != PASS) {
0057 fail_and_restart_in_ms(0, &status, output);
0058 break;
0059 }
0060 set_watchdog_in_ms(hdcp, 100, output);
0061 callback_in_ms(0, output);
0062 set_state_id(hdcp, output, H2_A1_VALIDATE_AKE_CERT);
0063 break;
0064 case H2_A1_VALIDATE_AKE_CERT:
0065 if (input->ake_cert_available != PASS) {
0066 if (event_ctx->event ==
0067 MOD_HDCP_EVENT_WATCHDOG_TIMEOUT) {
0068
0069
0070
0071
0072
0073
0074 fail_and_restart_in_ms(1000, &status, output);
0075 } else {
0076
0077 callback_in_ms(10, output);
0078 increment_stay_counter(hdcp);
0079 }
0080 break;
0081 } else if (input->ake_cert_read != PASS ||
0082 input->ake_cert_validation != PASS) {
0083
0084
0085
0086
0087 fail_and_restart_in_ms(0, &status, output);
0088 break;
0089 }
0090 if (conn->is_km_stored &&
0091 !adjust->hdcp2.force_no_stored_km) {
0092 callback_in_ms(0, output);
0093 set_state_id(hdcp, output, H2_A1_SEND_STORED_KM);
0094 } else {
0095 callback_in_ms(0, output);
0096 set_state_id(hdcp, output, H2_A1_SEND_NO_STORED_KM);
0097 }
0098 break;
0099 case H2_A1_SEND_NO_STORED_KM:
0100 if (input->no_stored_km_write != PASS) {
0101 fail_and_restart_in_ms(0, &status, output);
0102 break;
0103 }
0104 if (adjust->hdcp2.increase_h_prime_timeout)
0105 set_watchdog_in_ms(hdcp, 2000, output);
0106 else
0107 set_watchdog_in_ms(hdcp, 1000, output);
0108 callback_in_ms(0, output);
0109 set_state_id(hdcp, output, H2_A1_READ_H_PRIME);
0110 break;
0111 case H2_A1_READ_H_PRIME:
0112 if (input->h_prime_available != PASS) {
0113 if (event_ctx->event ==
0114 MOD_HDCP_EVENT_WATCHDOG_TIMEOUT) {
0115
0116 fail_and_restart_in_ms(1000, &status, output);
0117 } else {
0118
0119 callback_in_ms(100, output);
0120 increment_stay_counter(hdcp);
0121 }
0122 break;
0123 } else if (input->h_prime_read != PASS) {
0124 fail_and_restart_in_ms(0, &status, output);
0125 break;
0126 }
0127 set_watchdog_in_ms(hdcp, 200, output);
0128 callback_in_ms(0, output);
0129 set_state_id(hdcp, output, H2_A1_READ_PAIRING_INFO_AND_VALIDATE_H_PRIME);
0130 break;
0131 case H2_A1_READ_PAIRING_INFO_AND_VALIDATE_H_PRIME:
0132 if (input->pairing_available != PASS) {
0133 if (event_ctx->event ==
0134 MOD_HDCP_EVENT_WATCHDOG_TIMEOUT) {
0135
0136
0137
0138 fail_and_restart_in_ms(0, &status, output);
0139 } else {
0140
0141 callback_in_ms(20, output);
0142 increment_stay_counter(hdcp);
0143 }
0144 break;
0145 } else if (input->pairing_info_read != PASS ||
0146 input->h_prime_validation != PASS) {
0147
0148 fail_and_restart_in_ms(0, &status, output);
0149 break;
0150 }
0151 callback_in_ms(0, output);
0152 set_state_id(hdcp, output, H2_A2_LOCALITY_CHECK);
0153 break;
0154 case H2_A1_SEND_STORED_KM:
0155 if (input->stored_km_write != PASS) {
0156 fail_and_restart_in_ms(0, &status, output);
0157 break;
0158 }
0159 set_watchdog_in_ms(hdcp, 200, output);
0160 callback_in_ms(0, output);
0161 set_state_id(hdcp, output, H2_A1_VALIDATE_H_PRIME);
0162 break;
0163 case H2_A1_VALIDATE_H_PRIME:
0164 if (input->h_prime_available != PASS) {
0165 if (event_ctx->event ==
0166 MOD_HDCP_EVENT_WATCHDOG_TIMEOUT) {
0167
0168 fail_and_restart_in_ms(1000, &status, output);
0169 } else {
0170
0171 callback_in_ms(20, output);
0172 increment_stay_counter(hdcp);
0173 }
0174 break;
0175 } else if (input->h_prime_read != PASS) {
0176 fail_and_restart_in_ms(0, &status, output);
0177 break;
0178 } else if (input->h_prime_validation != PASS) {
0179
0180 adjust->hdcp2.force_no_stored_km = 1;
0181 fail_and_restart_in_ms(0, &status, output);
0182 break;
0183 }
0184 callback_in_ms(0, output);
0185 set_state_id(hdcp, output, H2_A2_LOCALITY_CHECK);
0186 break;
0187 case H2_A2_LOCALITY_CHECK:
0188 if (hdcp->state.stay_count > 10 ||
0189 input->lc_init_prepare != PASS ||
0190 input->lc_init_write != PASS ||
0191 input->l_prime_available_poll != PASS ||
0192 input->l_prime_read != PASS) {
0193
0194
0195
0196
0197
0198 fail_and_restart_in_ms(0, &status, output);
0199 break;
0200 } else if (input->l_prime_validation != PASS) {
0201 callback_in_ms(0, output);
0202 increment_stay_counter(hdcp);
0203 break;
0204 }
0205 callback_in_ms(0, output);
0206 set_state_id(hdcp, output, H2_A3_EXCHANGE_KS_AND_TEST_FOR_REPEATER);
0207 break;
0208 case H2_A3_EXCHANGE_KS_AND_TEST_FOR_REPEATER:
0209 if (input->eks_prepare != PASS ||
0210 input->eks_write != PASS) {
0211 fail_and_restart_in_ms(0, &status, output);
0212 break;
0213 }
0214 if (conn->is_repeater) {
0215 set_watchdog_in_ms(hdcp, 3000, output);
0216 callback_in_ms(0, output);
0217 set_state_id(hdcp, output, H2_A6_WAIT_FOR_RX_ID_LIST);
0218 } else {
0219
0220
0221
0222 callback_in_ms(210, output);
0223 set_state_id(hdcp, output, H2_ENABLE_ENCRYPTION);
0224 }
0225 break;
0226 case H2_ENABLE_ENCRYPTION:
0227 if (input->rxstatus_read != PASS ||
0228 input->reauth_request_check != PASS) {
0229
0230
0231
0232
0233 fail_and_restart_in_ms(0, &status, output);
0234 break;
0235 } else if (event_ctx->rx_id_list_ready && conn->is_repeater) {
0236 callback_in_ms(0, output);
0237 set_state_id(hdcp, output, H2_A78_VERIFY_RX_ID_LIST_AND_SEND_ACK);
0238 break;
0239 } else if (input->enable_encryption != PASS) {
0240 fail_and_restart_in_ms(0, &status, output);
0241 break;
0242 }
0243 callback_in_ms(0, output);
0244 set_state_id(hdcp, output, H2_A5_AUTHENTICATED);
0245 set_auth_complete(hdcp, output);
0246 break;
0247 case H2_A5_AUTHENTICATED:
0248 if (input->rxstatus_read == FAIL ||
0249 input->reauth_request_check == FAIL) {
0250 fail_and_restart_in_ms(0, &status, output);
0251 break;
0252 } else if (event_ctx->rx_id_list_ready && conn->is_repeater) {
0253 callback_in_ms(0, output);
0254 set_state_id(hdcp, output, H2_A78_VERIFY_RX_ID_LIST_AND_SEND_ACK);
0255 break;
0256 }
0257 callback_in_ms(500, output);
0258 increment_stay_counter(hdcp);
0259 break;
0260 case H2_A6_WAIT_FOR_RX_ID_LIST:
0261 if (input->rxstatus_read != PASS ||
0262 input->reauth_request_check != PASS) {
0263 fail_and_restart_in_ms(0, &status, output);
0264 break;
0265 } else if (!event_ctx->rx_id_list_ready) {
0266 if (event_ctx->event == MOD_HDCP_EVENT_WATCHDOG_TIMEOUT) {
0267
0268
0269
0270
0271
0272
0273 fail_and_restart_in_ms(100, &status, output);
0274 } else {
0275 callback_in_ms(300, output);
0276 increment_stay_counter(hdcp);
0277 }
0278 break;
0279 }
0280 callback_in_ms(0, output);
0281 set_state_id(hdcp, output, H2_A78_VERIFY_RX_ID_LIST_AND_SEND_ACK);
0282 break;
0283 case H2_A78_VERIFY_RX_ID_LIST_AND_SEND_ACK:
0284 if (input->rxstatus_read != PASS ||
0285 input->reauth_request_check != PASS ||
0286 input->rx_id_list_read != PASS ||
0287 input->device_count_check != PASS ||
0288 input->rx_id_list_validation != PASS ||
0289 input->repeater_auth_ack_write != PASS) {
0290
0291
0292
0293
0294
0295
0296 fail_and_restart_in_ms(0, &status, output);
0297 break;
0298 }
0299 callback_in_ms(0, output);
0300 set_state_id(hdcp, output, H2_A9_SEND_STREAM_MANAGEMENT);
0301 break;
0302 case H2_A9_SEND_STREAM_MANAGEMENT:
0303 if (input->rxstatus_read != PASS ||
0304 input->reauth_request_check != PASS) {
0305 fail_and_restart_in_ms(0, &status, output);
0306 break;
0307 } else if (event_ctx->rx_id_list_ready && conn->is_repeater) {
0308 callback_in_ms(0, output);
0309 set_state_id(hdcp, output, H2_A78_VERIFY_RX_ID_LIST_AND_SEND_ACK);
0310 break;
0311 } else if (input->prepare_stream_manage != PASS ||
0312 input->stream_manage_write != PASS) {
0313 fail_and_restart_in_ms(0, &status, output);
0314 break;
0315 }
0316 set_watchdog_in_ms(hdcp, 100, output);
0317 callback_in_ms(0, output);
0318 set_state_id(hdcp, output, H2_A9_VALIDATE_STREAM_READY);
0319 break;
0320 case H2_A9_VALIDATE_STREAM_READY:
0321 if (input->rxstatus_read != PASS ||
0322 input->reauth_request_check != PASS) {
0323 fail_and_restart_in_ms(0, &status, output);
0324 break;
0325 } else if (event_ctx->rx_id_list_ready && conn->is_repeater) {
0326 callback_in_ms(0, output);
0327 set_state_id(hdcp, output, H2_A78_VERIFY_RX_ID_LIST_AND_SEND_ACK);
0328 break;
0329 } else if (input->stream_ready_available != PASS) {
0330 if (event_ctx->event == MOD_HDCP_EVENT_WATCHDOG_TIMEOUT) {
0331
0332
0333
0334 hdcp->auth.count.stream_management_retry_count++;
0335 callback_in_ms(0, output);
0336 set_state_id(hdcp, output, H2_A9_SEND_STREAM_MANAGEMENT);
0337 } else {
0338 callback_in_ms(10, output);
0339 increment_stay_counter(hdcp);
0340 }
0341 break;
0342 } else if (input->stream_ready_read != PASS ||
0343 input->stream_ready_validation != PASS) {
0344
0345
0346
0347
0348 if (hdcp->auth.count.stream_management_retry_count > 10) {
0349 fail_and_restart_in_ms(0, &status, output);
0350 } else {
0351 hdcp->auth.count.stream_management_retry_count++;
0352 callback_in_ms(0, output);
0353 set_state_id(hdcp, output, H2_A9_SEND_STREAM_MANAGEMENT);
0354 }
0355 break;
0356 }
0357 callback_in_ms(200, output);
0358 set_state_id(hdcp, output, H2_ENABLE_ENCRYPTION);
0359 break;
0360 default:
0361 status = MOD_HDCP_STATUS_INVALID_STATE;
0362 fail_and_restart_in_ms(0, &status, output);
0363 break;
0364 }
0365
0366 return status;
0367 }
0368
0369 enum mod_hdcp_status mod_hdcp_hdcp2_dp_transition(struct mod_hdcp *hdcp,
0370 struct mod_hdcp_event_context *event_ctx,
0371 struct mod_hdcp_transition_input_hdcp2 *input,
0372 struct mod_hdcp_output *output)
0373 {
0374 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
0375 struct mod_hdcp_connection *conn = &hdcp->connection;
0376 struct mod_hdcp_link_adjustment *adjust = &hdcp->connection.link.adjust;
0377
0378 switch (current_state(hdcp)) {
0379 case D2_A0_DETERMINE_RX_HDCP_CAPABLE:
0380 if (input->rx_caps_read_dp != PASS ||
0381 input->hdcp2_capable_check != PASS) {
0382 adjust->hdcp2.disable = 1;
0383 callback_in_ms(0, output);
0384 set_state_id(hdcp, output, HDCP_INITIALIZED);
0385 } else {
0386 callback_in_ms(0, output);
0387 set_state_id(hdcp, output, D2_A1_SEND_AKE_INIT);
0388 }
0389 break;
0390 case D2_A1_SEND_AKE_INIT:
0391 if (input->create_session != PASS ||
0392 input->ake_init_prepare != PASS) {
0393
0394 adjust->hdcp2.disable = 1;
0395 fail_and_restart_in_ms(0, &status, output);
0396 break;
0397 } else if (input->ake_init_write != PASS) {
0398
0399 fail_and_restart_in_ms(0, &status, output);
0400 break;
0401 }
0402 callback_in_ms(100, output);
0403 set_state_id(hdcp, output, D2_A1_VALIDATE_AKE_CERT);
0404 break;
0405 case D2_A1_VALIDATE_AKE_CERT:
0406 if (input->ake_cert_read != PASS ||
0407 input->ake_cert_validation != PASS) {
0408
0409
0410
0411
0412 fail_and_restart_in_ms(0, &status, output);
0413 break;
0414 }
0415 if (conn->is_km_stored &&
0416 !adjust->hdcp2.force_no_stored_km) {
0417 callback_in_ms(0, output);
0418 set_state_id(hdcp, output, D2_A1_SEND_STORED_KM);
0419 } else {
0420 callback_in_ms(0, output);
0421 set_state_id(hdcp, output, D2_A1_SEND_NO_STORED_KM);
0422 }
0423 break;
0424 case D2_A1_SEND_NO_STORED_KM:
0425 if (input->no_stored_km_write != PASS) {
0426 fail_and_restart_in_ms(0, &status, output);
0427 break;
0428 }
0429 if (adjust->hdcp2.increase_h_prime_timeout)
0430 set_watchdog_in_ms(hdcp, 2000, output);
0431 else
0432 set_watchdog_in_ms(hdcp, 1000, output);
0433 set_state_id(hdcp, output, D2_A1_READ_H_PRIME);
0434 break;
0435 case D2_A1_READ_H_PRIME:
0436 if (input->h_prime_available != PASS) {
0437 if (event_ctx->event ==
0438 MOD_HDCP_EVENT_WATCHDOG_TIMEOUT)
0439
0440 fail_and_restart_in_ms(1000, &status, output);
0441 else
0442 increment_stay_counter(hdcp);
0443 break;
0444 } else if (input->h_prime_read != PASS) {
0445 fail_and_restart_in_ms(0, &status, output);
0446 break;
0447 }
0448 set_watchdog_in_ms(hdcp, 200, output);
0449 set_state_id(hdcp, output, D2_A1_READ_PAIRING_INFO_AND_VALIDATE_H_PRIME);
0450 break;
0451 case D2_A1_READ_PAIRING_INFO_AND_VALIDATE_H_PRIME:
0452 if (input->pairing_available != PASS) {
0453 if (event_ctx->event ==
0454 MOD_HDCP_EVENT_WATCHDOG_TIMEOUT)
0455
0456
0457
0458
0459 fail_and_restart_in_ms(0, &status, output);
0460 else
0461 increment_stay_counter(hdcp);
0462 break;
0463 } else if (input->pairing_info_read != PASS ||
0464 input->h_prime_validation != PASS) {
0465
0466 fail_and_restart_in_ms(0, &status, output);
0467 break;
0468 }
0469 callback_in_ms(0, output);
0470 set_state_id(hdcp, output, D2_A2_LOCALITY_CHECK);
0471 break;
0472 case D2_A1_SEND_STORED_KM:
0473 if (input->stored_km_write != PASS) {
0474 fail_and_restart_in_ms(0, &status, output);
0475 break;
0476 }
0477 set_watchdog_in_ms(hdcp, 200, output);
0478 set_state_id(hdcp, output, D2_A1_VALIDATE_H_PRIME);
0479 break;
0480 case D2_A1_VALIDATE_H_PRIME:
0481 if (input->h_prime_available != PASS) {
0482 if (event_ctx->event ==
0483 MOD_HDCP_EVENT_WATCHDOG_TIMEOUT)
0484
0485 fail_and_restart_in_ms(1000, &status, output);
0486 else
0487 increment_stay_counter(hdcp);
0488 break;
0489 } else if (input->h_prime_read != PASS) {
0490 fail_and_restart_in_ms(0, &status, output);
0491 break;
0492 } else if (input->h_prime_validation != PASS) {
0493
0494 adjust->hdcp2.force_no_stored_km = 1;
0495 fail_and_restart_in_ms(0, &status, output);
0496 break;
0497 }
0498 callback_in_ms(0, output);
0499 set_state_id(hdcp, output, D2_A2_LOCALITY_CHECK);
0500 break;
0501 case D2_A2_LOCALITY_CHECK:
0502 if (hdcp->state.stay_count > 10 ||
0503 input->lc_init_prepare != PASS ||
0504 input->lc_init_write != PASS ||
0505 input->l_prime_read != PASS) {
0506
0507 fail_and_restart_in_ms(0, &status, output);
0508 break;
0509 } else if (input->l_prime_validation != PASS) {
0510 callback_in_ms(0, output);
0511 increment_stay_counter(hdcp);
0512 break;
0513 }
0514 callback_in_ms(0, output);
0515 set_state_id(hdcp, output, D2_A34_EXCHANGE_KS_AND_TEST_FOR_REPEATER);
0516 break;
0517 case D2_A34_EXCHANGE_KS_AND_TEST_FOR_REPEATER:
0518 if (input->eks_prepare != PASS ||
0519 input->eks_write != PASS) {
0520 fail_and_restart_in_ms(0, &status, output);
0521 break;
0522 }
0523 if (conn->is_repeater) {
0524 set_watchdog_in_ms(hdcp, 3000, output);
0525 set_state_id(hdcp, output, D2_A6_WAIT_FOR_RX_ID_LIST);
0526 } else {
0527 callback_in_ms(1, output);
0528 set_state_id(hdcp, output, D2_SEND_CONTENT_STREAM_TYPE);
0529 }
0530 break;
0531 case D2_SEND_CONTENT_STREAM_TYPE:
0532 if (input->rxstatus_read != PASS ||
0533 input->reauth_request_check != PASS ||
0534 input->link_integrity_check_dp != PASS ||
0535 input->content_stream_type_write != PASS) {
0536 fail_and_restart_in_ms(0, &status, output);
0537 break;
0538 }
0539 callback_in_ms(210, output);
0540 set_state_id(hdcp, output, D2_ENABLE_ENCRYPTION);
0541 break;
0542 case D2_ENABLE_ENCRYPTION:
0543 if (input->rxstatus_read != PASS ||
0544 input->reauth_request_check != PASS ||
0545 input->link_integrity_check_dp != PASS) {
0546
0547
0548
0549
0550 fail_and_restart_in_ms(0, &status, output);
0551 break;
0552 } else if (event_ctx->rx_id_list_ready && conn->is_repeater) {
0553 callback_in_ms(0, output);
0554 set_state_id(hdcp, output, D2_A78_VERIFY_RX_ID_LIST_AND_SEND_ACK);
0555 break;
0556 } else if (input->enable_encryption != PASS ||
0557 (is_dp_mst_hdcp(hdcp) && input->stream_encryption_dp != PASS)) {
0558 fail_and_restart_in_ms(0, &status, output);
0559 break;
0560 }
0561 set_state_id(hdcp, output, D2_A5_AUTHENTICATED);
0562 set_auth_complete(hdcp, output);
0563 break;
0564 case D2_A5_AUTHENTICATED:
0565 if (input->rxstatus_read == FAIL ||
0566 input->reauth_request_check == FAIL) {
0567 fail_and_restart_in_ms(100, &status, output);
0568 break;
0569 } else if (input->link_integrity_check_dp == FAIL) {
0570 if (hdcp->connection.hdcp2_retry_count >= 1)
0571 adjust->hdcp2.force_type = MOD_HDCP_FORCE_TYPE_0;
0572 fail_and_restart_in_ms(0, &status, output);
0573 break;
0574 } else if (event_ctx->rx_id_list_ready && conn->is_repeater) {
0575 callback_in_ms(0, output);
0576 set_state_id(hdcp, output, D2_A78_VERIFY_RX_ID_LIST_AND_SEND_ACK);
0577 break;
0578 }
0579 increment_stay_counter(hdcp);
0580 break;
0581 case D2_A6_WAIT_FOR_RX_ID_LIST:
0582 if (input->rxstatus_read != PASS ||
0583 input->reauth_request_check != PASS ||
0584 input->link_integrity_check_dp != PASS) {
0585 fail_and_restart_in_ms(0, &status, output);
0586 break;
0587 } else if (!event_ctx->rx_id_list_ready) {
0588 if (event_ctx->event == MOD_HDCP_EVENT_WATCHDOG_TIMEOUT)
0589
0590 fail_and_restart_in_ms(0, &status, output);
0591 else
0592 increment_stay_counter(hdcp);
0593 break;
0594 }
0595 callback_in_ms(0, output);
0596 set_state_id(hdcp, output, D2_A78_VERIFY_RX_ID_LIST_AND_SEND_ACK);
0597 break;
0598 case D2_A78_VERIFY_RX_ID_LIST_AND_SEND_ACK:
0599 if (input->rxstatus_read != PASS ||
0600 input->reauth_request_check != PASS ||
0601 input->link_integrity_check_dp != PASS ||
0602 input->rx_id_list_read != PASS ||
0603 input->device_count_check != PASS ||
0604 input->rx_id_list_validation != PASS ||
0605 input->repeater_auth_ack_write != PASS) {
0606
0607
0608
0609
0610
0611
0612
0613 fail_and_restart_in_ms(0, &status, output);
0614 break;
0615 }
0616 callback_in_ms(0, output);
0617 set_state_id(hdcp, output, D2_A9_SEND_STREAM_MANAGEMENT);
0618 break;
0619 case D2_A9_SEND_STREAM_MANAGEMENT:
0620 if (input->rxstatus_read != PASS ||
0621 input->reauth_request_check != PASS ||
0622 input->link_integrity_check_dp != PASS) {
0623 fail_and_restart_in_ms(0, &status, output);
0624 break;
0625 } else if (event_ctx->rx_id_list_ready) {
0626 callback_in_ms(0, output);
0627 set_state_id(hdcp, output, D2_A78_VERIFY_RX_ID_LIST_AND_SEND_ACK);
0628 break;
0629 } else if (input->prepare_stream_manage != PASS ||
0630 input->stream_manage_write != PASS) {
0631 if (event_ctx->event == MOD_HDCP_EVENT_CALLBACK)
0632 fail_and_restart_in_ms(0, &status, output);
0633 else
0634 increment_stay_counter(hdcp);
0635 break;
0636 }
0637 callback_in_ms(100, output);
0638 set_state_id(hdcp, output, D2_A9_VALIDATE_STREAM_READY);
0639 break;
0640 case D2_A9_VALIDATE_STREAM_READY:
0641 if (input->rxstatus_read != PASS ||
0642 input->reauth_request_check != PASS ||
0643 input->link_integrity_check_dp != PASS) {
0644 fail_and_restart_in_ms(0, &status, output);
0645 break;
0646 } else if (event_ctx->rx_id_list_ready) {
0647 callback_in_ms(0, output);
0648 set_state_id(hdcp, output, D2_A78_VERIFY_RX_ID_LIST_AND_SEND_ACK);
0649 break;
0650 } else if (input->stream_ready_read != PASS ||
0651 input->stream_ready_validation != PASS) {
0652
0653
0654
0655
0656
0657 if (hdcp->auth.count.stream_management_retry_count > 10) {
0658 fail_and_restart_in_ms(0, &status, output);
0659 } else if (event_ctx->event == MOD_HDCP_EVENT_CALLBACK) {
0660 hdcp->auth.count.stream_management_retry_count++;
0661 callback_in_ms(0, output);
0662 set_state_id(hdcp, output, D2_A9_SEND_STREAM_MANAGEMENT);
0663 } else {
0664 increment_stay_counter(hdcp);
0665 }
0666 break;
0667 }
0668 callback_in_ms(200, output);
0669 set_state_id(hdcp, output, D2_ENABLE_ENCRYPTION);
0670 break;
0671 default:
0672 status = MOD_HDCP_STATUS_INVALID_STATE;
0673 fail_and_restart_in_ms(0, &status, output);
0674 break;
0675 }
0676 return status;
0677 }