drm/amd/display: add mod hdcp interface for supporting encryption state query
authorWenjing Liu <wenjing.liu@amd.com>
Thu, 11 Mar 2021 18:14:25 +0000 (13:14 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 9 Apr 2021 20:48:15 +0000 (16:48 -0400)
Signed-off-by: Wenjing Liu <wenjing.liu@amd.com>
Reviewed-by: George Shen <George.Shen@amd.com>
Acked-by: Anson Jacob <Anson.Jacob@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/modules/hdcp/hdcp.c
drivers/gpu/drm/amd/display/modules/hdcp/hdcp.h
drivers/gpu/drm/amd/display/modules/hdcp/hdcp1_execution.c
drivers/gpu/drm/amd/display/modules/hdcp/hdcp1_transition.c
drivers/gpu/drm/amd/display/modules/hdcp/hdcp2_execution.c
drivers/gpu/drm/amd/display/modules/hdcp/hdcp2_transition.c
drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c

index e7b841d..68a6481 100644 (file)
@@ -314,6 +314,9 @@ enum mod_hdcp_status mod_hdcp_add_display(struct mod_hdcp *hdcp,
                goto out;
        }
 
+       /* save current encryption states to restore after next authentication */
+       mod_hdcp_save_current_encryption_states(hdcp);
+
        /* reset existing authentication status */
        status = reset_authentication(hdcp, output);
        if (status != MOD_HDCP_STATUS_SUCCESS)
@@ -360,6 +363,9 @@ enum mod_hdcp_status mod_hdcp_remove_display(struct mod_hdcp *hdcp,
                goto out;
        }
 
+       /* save current encryption states to restore after next authentication */
+       mod_hdcp_save_current_encryption_states(hdcp);
+
        /* stop current authentication */
        status = reset_authentication(hdcp, output);
        if (status != MOD_HDCP_STATUS_SUCCESS)
index 5c22cf7..3ce91db 100644 (file)
@@ -331,6 +331,8 @@ enum mod_hdcp_status mod_hdcp_add_display_to_topology(
                struct mod_hdcp *hdcp, struct mod_hdcp_display *display);
 enum mod_hdcp_status mod_hdcp_remove_display_from_topology(
                struct mod_hdcp *hdcp, uint8_t index);
+bool mod_hdcp_is_link_encryption_enabled(struct mod_hdcp *hdcp);
+void mod_hdcp_save_current_encryption_states(struct mod_hdcp *hdcp);
 enum mod_hdcp_status mod_hdcp_hdcp1_create_session(struct mod_hdcp *hdcp);
 enum mod_hdcp_status mod_hdcp_hdcp1_destroy_session(struct mod_hdcp *hdcp);
 enum mod_hdcp_status mod_hdcp_hdcp1_validate_rx(struct mod_hdcp *hdcp);
@@ -339,8 +341,6 @@ enum mod_hdcp_status mod_hdcp_hdcp1_validate_ksvlist_vp(struct mod_hdcp *hdcp);
 enum mod_hdcp_status mod_hdcp_hdcp1_enable_dp_stream_encryption(
        struct mod_hdcp *hdcp);
 enum mod_hdcp_status mod_hdcp_hdcp1_link_maintenance(struct mod_hdcp *hdcp);
-enum mod_hdcp_status mod_hdcp_hdcp1_get_link_encryption_status(struct mod_hdcp *hdcp,
-                                                              enum mod_hdcp_encryption_status *encryption_status);
 enum mod_hdcp_status mod_hdcp_hdcp2_create_session(struct mod_hdcp *hdcp);
 enum mod_hdcp_status mod_hdcp_hdcp2_destroy_session(struct mod_hdcp *hdcp);
 enum mod_hdcp_status mod_hdcp_hdcp2_prepare_ake_init(struct mod_hdcp *hdcp);
index 73ca49f..eeac143 100644 (file)
@@ -256,10 +256,12 @@ static enum mod_hdcp_status authenticated(struct mod_hdcp *hdcp,
                goto out;
        }
 
-       if (!mod_hdcp_execute_and_set(mod_hdcp_hdcp1_link_maintenance,
+       mod_hdcp_execute_and_set(mod_hdcp_hdcp1_link_maintenance,
                        &input->link_maintenance, &status,
-                       hdcp, "link_maintenance"))
-               goto out;
+                       hdcp, "link_maintenance");
+
+       if (status != MOD_HDCP_STATUS_SUCCESS)
+               mod_hdcp_save_current_encryption_states(hdcp);
 out:
        return status;
 }
@@ -425,19 +427,24 @@ static enum mod_hdcp_status authenticated_dp(struct mod_hdcp *hdcp,
                event_ctx->unexpected_event = 1;
                goto out;
        }
-
-       if (!mod_hdcp_execute_and_set(mod_hdcp_read_bstatus,
-                       &input->bstatus_read, &status,
-                       hdcp, "bstatus_read"))
-               goto out;
-       if (!mod_hdcp_execute_and_set(check_link_integrity_dp,
-                       &input->link_integrity_check, &status,
-                       hdcp, "link_integrity_check"))
-               goto out;
-       if (!mod_hdcp_execute_and_set(check_no_reauthentication_request_dp,
-                       &input->reauth_request_check, &status,
-                       hdcp, "reauth_request_check"))
+       if (!mod_hdcp_is_link_encryption_enabled(hdcp))
                goto out;
+
+       if (status == MOD_HDCP_STATUS_SUCCESS)
+               mod_hdcp_execute_and_set(mod_hdcp_read_bstatus,
+                               &input->bstatus_read, &status,
+                               hdcp, "bstatus_read");
+       if (status == MOD_HDCP_STATUS_SUCCESS)
+               mod_hdcp_execute_and_set(check_link_integrity_dp,
+                               &input->link_integrity_check, &status,
+                               hdcp, "link_integrity_check");
+       if (status == MOD_HDCP_STATUS_SUCCESS)
+               mod_hdcp_execute_and_set(check_no_reauthentication_request_dp,
+                               &input->reauth_request_check, &status,
+                               hdcp, "reauth_request_check");
+
+       if (status != MOD_HDCP_STATUS_SUCCESS)
+               mod_hdcp_save_current_encryption_states(hdcp);
 out:
        return status;
 }
index 24ab95b..3dda8c1 100644 (file)
@@ -93,7 +93,7 @@ enum mod_hdcp_status mod_hdcp_hdcp1_transition(struct mod_hdcp *hdcp,
                }
                break;
        case H1_A45_AUTHENTICATED:
-               if (input->link_maintenance != PASS) {
+               if (input->link_maintenance == FAIL) {
                        /* 1A-07: consider invalid ri' a failure */
                        /* 1A-07a: consider read ri' not returned a failure */
                        fail_and_restart_in_ms(0, &status, output);
@@ -243,8 +243,8 @@ enum mod_hdcp_status mod_hdcp_hdcp1_dp_transition(struct mod_hdcp *hdcp,
                }
                break;
        case D1_A4_AUTHENTICATED:
-               if (input->link_integrity_check != PASS ||
-                               input->reauth_request_check != PASS) {
+               if (input->link_integrity_check == FAIL ||
+                               input->reauth_request_check == FAIL) {
                        /* 1A-07: restart hdcp on a link integrity failure */
                        fail_and_restart_in_ms(0, &status, output);
                        break;
index a0895a7..f164f6a 100644 (file)
@@ -564,11 +564,13 @@ static enum mod_hdcp_status authenticated(struct mod_hdcp *hdcp,
                event_ctx->unexpected_event = 1;
                goto out;
        }
-
-       if (!process_rxstatus(hdcp, event_ctx, input, &status))
-               goto out;
-       if (event_ctx->rx_id_list_ready)
+       if (!mod_hdcp_is_link_encryption_enabled(hdcp))
                goto out;
+
+       process_rxstatus(hdcp, event_ctx, input, &status);
+
+       if (status != MOD_HDCP_STATUS_SUCCESS)
+               mod_hdcp_save_current_encryption_states(hdcp);
 out:
        return status;
 }
index e738c7a..b0306ed 100644 (file)
@@ -245,8 +245,8 @@ enum mod_hdcp_status mod_hdcp_hdcp2_transition(struct mod_hdcp *hdcp,
                HDCP_FULL_DDC_TRACE(hdcp);
                break;
        case H2_A5_AUTHENTICATED:
-               if (input->rxstatus_read != PASS ||
-                               input->reauth_request_check != PASS) {
+               if (input->rxstatus_read == FAIL ||
+                               input->reauth_request_check == FAIL) {
                        fail_and_restart_in_ms(0, &status, output);
                        break;
                } else if (event_ctx->rx_id_list_ready && conn->is_repeater) {
@@ -562,11 +562,11 @@ enum mod_hdcp_status mod_hdcp_hdcp2_dp_transition(struct mod_hdcp *hdcp,
                HDCP_FULL_DDC_TRACE(hdcp);
                break;
        case D2_A5_AUTHENTICATED:
-               if (input->rxstatus_read != PASS ||
-                               input->reauth_request_check != PASS) {
+               if (input->rxstatus_read == FAIL ||
+                               input->reauth_request_check == FAIL) {
                        fail_and_restart_in_ms(0, &status, output);
                        break;
-               } else if (input->link_integrity_check_dp != PASS) {
+               } else if (input->link_integrity_check_dp == FAIL) {
                        if (hdcp->connection.hdcp2_retry_count >= 1)
                                adjust->hdcp2.force_type = MOD_HDCP_FORCE_TYPE_0;
                        fail_and_restart_in_ms(0, &status, output);
index 904ce9b..9d7ca31 100644 (file)
@@ -914,3 +914,13 @@ enum mod_hdcp_status mod_hdcp_hdcp2_validate_stream_ready(struct mod_hdcp *hdcp)
        return status;
 }
 
+bool mod_hdcp_is_link_encryption_enabled(struct mod_hdcp *hdcp)
+{
+       /* unsupported */
+       return true;
+}
+
+void mod_hdcp_save_current_encryption_states(struct mod_hdcp *hdcp)
+{
+       /* unsupported */
+}