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 #define MAX_NUM_DISPLAYS 24 27 28 29 #include "hdcp.h" 30 31 #include "amdgpu.h" 32 #include "hdcp_psp.h" 33 34 static void hdcp2_message_init(struct mod_hdcp *hdcp, 35 struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_input_v2 *in) 36 { 37 in->session_handle = hdcp->auth.id; 38 in->prepare.msg1_id = TA_HDCP_HDCP2_MSG_ID__NULL_MESSAGE; 39 in->prepare.msg2_id = TA_HDCP_HDCP2_MSG_ID__NULL_MESSAGE; 40 in->process.msg1_desc.msg_id = TA_HDCP_HDCP2_MSG_ID__NULL_MESSAGE; 41 in->process.msg1_desc.msg_size = 0; 42 in->process.msg2_desc.msg_id = TA_HDCP_HDCP2_MSG_ID__NULL_MESSAGE; 43 in->process.msg2_desc.msg_size = 0; 44 in->process.msg3_desc.msg_id = TA_HDCP_HDCP2_MSG_ID__NULL_MESSAGE; 45 in->process.msg3_desc.msg_size = 0; 46 } 47 enum mod_hdcp_status mod_hdcp_remove_display_topology(struct mod_hdcp *hdcp) 48 { 49 50 struct psp_context *psp = hdcp->config.psp.handle; 51 struct ta_dtm_shared_memory *dtm_cmd; 52 struct mod_hdcp_display *display = NULL; 53 uint8_t i; 54 55 dtm_cmd = (struct ta_dtm_shared_memory *)psp->dtm_context.dtm_shared_buf; 56 57 for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++) { 58 if (is_display_added(&(hdcp->connection.displays[i]))) { 59 60 memset(dtm_cmd, 0, sizeof(struct ta_dtm_shared_memory)); 61 62 display = &hdcp->connection.displays[i]; 63 64 dtm_cmd->cmd_id = TA_DTM_COMMAND__TOPOLOGY_UPDATE_V2; 65 dtm_cmd->dtm_in_message.topology_update_v2.display_handle = display->index; 66 dtm_cmd->dtm_in_message.topology_update_v2.is_active = 0; 67 dtm_cmd->dtm_status = TA_DTM_STATUS__GENERIC_FAILURE; 68 69 psp_dtm_invoke(psp, dtm_cmd->cmd_id); 70 71 if (dtm_cmd->dtm_status != TA_DTM_STATUS__SUCCESS) 72 return MOD_HDCP_STATUS_UPDATE_TOPOLOGY_FAILURE; 73 74 display->state = MOD_HDCP_DISPLAY_ACTIVE; 75 HDCP_TOP_REMOVE_DISPLAY_TRACE(hdcp, display->index); 76 } 77 } 78 79 return MOD_HDCP_STATUS_SUCCESS; 80 } 81 82 enum mod_hdcp_status mod_hdcp_add_display_topology(struct mod_hdcp *hdcp) 83 { 84 struct psp_context *psp = hdcp->config.psp.handle; 85 struct ta_dtm_shared_memory *dtm_cmd; 86 struct mod_hdcp_display *display = NULL; 87 struct mod_hdcp_link *link = &hdcp->connection.link; 88 uint8_t i; 89 90 if (!psp->dtm_context.dtm_initialized) { 91 DRM_ERROR("Failed to add display topology, DTM TA is not initialized."); 92 return MOD_HDCP_STATUS_FAILURE; 93 } 94 95 dtm_cmd = (struct ta_dtm_shared_memory *)psp->dtm_context.dtm_shared_buf; 96 97 for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++) { 98 if (hdcp->connection.displays[i].state == MOD_HDCP_DISPLAY_ACTIVE) { 99 display = &hdcp->connection.displays[i]; 100 101 memset(dtm_cmd, 0, sizeof(struct ta_dtm_shared_memory)); 102 103 dtm_cmd->cmd_id = TA_DTM_COMMAND__TOPOLOGY_UPDATE_V2; 104 dtm_cmd->dtm_in_message.topology_update_v2.display_handle = display->index; 105 dtm_cmd->dtm_in_message.topology_update_v2.is_active = 1; 106 dtm_cmd->dtm_in_message.topology_update_v2.controller = display->controller; 107 dtm_cmd->dtm_in_message.topology_update_v2.ddc_line = link->ddc_line; 108 dtm_cmd->dtm_in_message.topology_update_v2.dig_be = link->dig_be; 109 dtm_cmd->dtm_in_message.topology_update_v2.dig_fe = display->dig_fe; 110 dtm_cmd->dtm_in_message.topology_update_v2.dp_mst_vcid = display->vc_id; 111 dtm_cmd->dtm_in_message.topology_update_v2.max_hdcp_supported_version = 112 TA_DTM_HDCP_VERSION_MAX_SUPPORTED__2_2; 113 dtm_cmd->dtm_status = TA_DTM_STATUS__GENERIC_FAILURE; 114 115 psp_dtm_invoke(psp, dtm_cmd->cmd_id); 116 117 if (dtm_cmd->dtm_status != TA_DTM_STATUS__SUCCESS) 118 return MOD_HDCP_STATUS_UPDATE_TOPOLOGY_FAILURE; 119 120 display->state = MOD_HDCP_DISPLAY_ACTIVE_AND_ADDED; 121 HDCP_TOP_ADD_DISPLAY_TRACE(hdcp, display->index); 122 } 123 } 124 125 return MOD_HDCP_STATUS_SUCCESS; 126 } 127 128 enum mod_hdcp_status mod_hdcp_hdcp1_create_session(struct mod_hdcp *hdcp) 129 { 130 131 struct psp_context *psp = hdcp->config.psp.handle; 132 struct mod_hdcp_display *display = get_first_added_display(hdcp); 133 struct ta_hdcp_shared_memory *hdcp_cmd; 134 135 if (!psp->hdcp_context.hdcp_initialized) { 136 DRM_ERROR("Failed to create hdcp session. HDCP TA is not initialized."); 137 return MOD_HDCP_STATUS_FAILURE; 138 } 139 140 hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 141 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 142 143 hdcp_cmd->in_msg.hdcp1_create_session.display_handle = display->index; 144 hdcp_cmd->cmd_id = TA_HDCP_COMMAND__HDCP1_CREATE_SESSION; 145 146 psp_hdcp_invoke(psp, hdcp_cmd->cmd_id); 147 148 hdcp->auth.id = hdcp_cmd->out_msg.hdcp1_create_session.session_handle; 149 150 if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS) 151 return MOD_HDCP_STATUS_HDCP1_CREATE_SESSION_FAILURE; 152 153 hdcp->auth.msg.hdcp1.ainfo = hdcp_cmd->out_msg.hdcp1_create_session.ainfo_primary; 154 memcpy(hdcp->auth.msg.hdcp1.aksv, hdcp_cmd->out_msg.hdcp1_create_session.aksv_primary, 155 sizeof(hdcp->auth.msg.hdcp1.aksv)); 156 memcpy(hdcp->auth.msg.hdcp1.an, hdcp_cmd->out_msg.hdcp1_create_session.an_primary, 157 sizeof(hdcp->auth.msg.hdcp1.an)); 158 159 return MOD_HDCP_STATUS_SUCCESS; 160 } 161 162 enum mod_hdcp_status mod_hdcp_hdcp1_destroy_session(struct mod_hdcp *hdcp) 163 { 164 165 struct psp_context *psp = hdcp->config.psp.handle; 166 struct ta_hdcp_shared_memory *hdcp_cmd; 167 168 hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 169 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 170 171 hdcp_cmd->in_msg.hdcp1_destroy_session.session_handle = hdcp->auth.id; 172 hdcp_cmd->cmd_id = TA_HDCP_COMMAND__HDCP1_DESTROY_SESSION; 173 174 psp_hdcp_invoke(psp, hdcp_cmd->cmd_id); 175 176 if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS) 177 return MOD_HDCP_STATUS_HDCP1_DESTROY_SESSION_FAILURE; 178 179 HDCP_TOP_HDCP1_DESTROY_SESSION_TRACE(hdcp); 180 181 return MOD_HDCP_STATUS_SUCCESS; 182 } 183 184 enum mod_hdcp_status mod_hdcp_hdcp1_validate_rx(struct mod_hdcp *hdcp) 185 { 186 struct psp_context *psp = hdcp->config.psp.handle; 187 struct ta_hdcp_shared_memory *hdcp_cmd; 188 189 hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 190 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 191 192 hdcp_cmd->in_msg.hdcp1_first_part_authentication.session_handle = hdcp->auth.id; 193 194 memcpy(hdcp_cmd->in_msg.hdcp1_first_part_authentication.bksv_primary, hdcp->auth.msg.hdcp1.bksv, 195 TA_HDCP__HDCP1_KSV_SIZE); 196 197 hdcp_cmd->in_msg.hdcp1_first_part_authentication.r0_prime_primary = hdcp->auth.msg.hdcp1.r0p; 198 hdcp_cmd->in_msg.hdcp1_first_part_authentication.bcaps = hdcp->auth.msg.hdcp1.bcaps; 199 hdcp_cmd->cmd_id = TA_HDCP_COMMAND__HDCP1_FIRST_PART_AUTHENTICATION; 200 201 psp_hdcp_invoke(psp, hdcp_cmd->cmd_id); 202 203 if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS) 204 return MOD_HDCP_STATUS_HDCP1_VALIDATE_RX_FAILURE; 205 206 if (hdcp_cmd->out_msg.hdcp1_first_part_authentication.authentication_status == 207 TA_HDCP_AUTHENTICATION_STATUS__HDCP1_FIRST_PART_COMPLETE) { 208 /* needs second part of authentication */ 209 hdcp->connection.is_repeater = 1; 210 } else if (hdcp_cmd->out_msg.hdcp1_first_part_authentication.authentication_status == 211 TA_HDCP_AUTHENTICATION_STATUS__HDCP1_AUTHENTICATED) { 212 hdcp->connection.is_repeater = 0; 213 } else 214 return MOD_HDCP_STATUS_HDCP1_VALIDATE_RX_FAILURE; 215 216 217 return MOD_HDCP_STATUS_SUCCESS; 218 } 219 220 enum mod_hdcp_status mod_hdcp_hdcp1_enable_encryption(struct mod_hdcp *hdcp) 221 { 222 struct psp_context *psp = hdcp->config.psp.handle; 223 struct ta_hdcp_shared_memory *hdcp_cmd; 224 struct mod_hdcp_display *display = get_first_added_display(hdcp); 225 226 hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 227 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 228 229 hdcp_cmd->in_msg.hdcp1_enable_encryption.session_handle = hdcp->auth.id; 230 hdcp_cmd->cmd_id = TA_HDCP_COMMAND__HDCP1_ENABLE_ENCRYPTION; 231 232 psp_hdcp_invoke(psp, hdcp_cmd->cmd_id); 233 234 if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS) 235 return MOD_HDCP_STATUS_HDCP1_ENABLE_ENCRYPTION; 236 237 if (!is_dp_mst_hdcp(hdcp)) { 238 display->state = MOD_HDCP_DISPLAY_ENCRYPTION_ENABLED; 239 HDCP_HDCP1_ENABLED_TRACE(hdcp, display->index); 240 } 241 return MOD_HDCP_STATUS_SUCCESS; 242 } 243 244 enum mod_hdcp_status mod_hdcp_hdcp1_validate_ksvlist_vp(struct mod_hdcp *hdcp) 245 { 246 struct psp_context *psp = hdcp->config.psp.handle; 247 struct ta_hdcp_shared_memory *hdcp_cmd; 248 249 hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 250 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 251 252 hdcp_cmd->in_msg.hdcp1_second_part_authentication.session_handle = hdcp->auth.id; 253 254 hdcp_cmd->in_msg.hdcp1_second_part_authentication.ksv_list_size = hdcp->auth.msg.hdcp1.ksvlist_size; 255 memcpy(hdcp_cmd->in_msg.hdcp1_second_part_authentication.ksv_list, hdcp->auth.msg.hdcp1.ksvlist, 256 hdcp->auth.msg.hdcp1.ksvlist_size); 257 258 memcpy(hdcp_cmd->in_msg.hdcp1_second_part_authentication.v_prime, hdcp->auth.msg.hdcp1.vp, 259 sizeof(hdcp->auth.msg.hdcp1.vp)); 260 261 hdcp_cmd->in_msg.hdcp1_second_part_authentication.bstatus_binfo = 262 is_dp_hdcp(hdcp) ? hdcp->auth.msg.hdcp1.binfo_dp : hdcp->auth.msg.hdcp1.bstatus; 263 hdcp_cmd->cmd_id = TA_HDCP_COMMAND__HDCP1_SECOND_PART_AUTHENTICATION; 264 265 psp_hdcp_invoke(psp, hdcp_cmd->cmd_id); 266 267 if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS) 268 return MOD_HDCP_STATUS_HDCP1_VALIDATE_KSV_LIST_FAILURE; 269 270 return MOD_HDCP_STATUS_SUCCESS; 271 } 272 273 enum mod_hdcp_status mod_hdcp_hdcp1_enable_dp_stream_encryption(struct mod_hdcp *hdcp) 274 { 275 276 struct psp_context *psp = hdcp->config.psp.handle; 277 struct ta_hdcp_shared_memory *hdcp_cmd; 278 int i = 0; 279 280 hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 281 282 for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++) { 283 284 if (hdcp->connection.displays[i].state != MOD_HDCP_DISPLAY_ACTIVE_AND_ADDED || 285 hdcp->connection.displays[i].adjust.disable) 286 continue; 287 288 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 289 290 hdcp_cmd->in_msg.hdcp1_enable_dp_stream_encryption.session_handle = hdcp->auth.id; 291 hdcp_cmd->in_msg.hdcp1_enable_dp_stream_encryption.display_handle = hdcp->connection.displays[i].index; 292 hdcp_cmd->cmd_id = TA_HDCP_COMMAND__HDCP1_ENABLE_DP_STREAM_ENCRYPTION; 293 294 psp_hdcp_invoke(psp, hdcp_cmd->cmd_id); 295 296 if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS) 297 return MOD_HDCP_STATUS_HDCP1_ENABLE_STREAM_ENCRYPTION_FAILURE; 298 299 hdcp->connection.displays[i].state = MOD_HDCP_DISPLAY_ENCRYPTION_ENABLED; 300 HDCP_HDCP1_ENABLED_TRACE(hdcp, hdcp->connection.displays[i].index); 301 } 302 303 return MOD_HDCP_STATUS_SUCCESS; 304 } 305 306 enum mod_hdcp_status mod_hdcp_hdcp1_link_maintenance(struct mod_hdcp *hdcp) 307 { 308 struct psp_context *psp = hdcp->config.psp.handle; 309 struct ta_hdcp_shared_memory *hdcp_cmd; 310 311 hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 312 313 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 314 315 hdcp_cmd->in_msg.hdcp1_get_encryption_status.session_handle = hdcp->auth.id; 316 317 hdcp_cmd->out_msg.hdcp1_get_encryption_status.protection_level = 0; 318 hdcp_cmd->cmd_id = TA_HDCP_COMMAND__HDCP1_GET_ENCRYPTION_STATUS; 319 320 psp_hdcp_invoke(psp, hdcp_cmd->cmd_id); 321 322 if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS) 323 return MOD_HDCP_STATUS_HDCP1_LINK_MAINTENANCE_FAILURE; 324 325 return (hdcp_cmd->out_msg.hdcp1_get_encryption_status.protection_level == 1) 326 ? MOD_HDCP_STATUS_SUCCESS 327 : MOD_HDCP_STATUS_HDCP1_LINK_MAINTENANCE_FAILURE; 328 } 329 330 enum mod_hdcp_status mod_hdcp_hdcp1_get_link_encryption_status(struct mod_hdcp *hdcp, 331 enum mod_hdcp_encryption_status *encryption_status) 332 { 333 *encryption_status = MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF; 334 335 if (mod_hdcp_hdcp1_link_maintenance(hdcp) != MOD_HDCP_STATUS_SUCCESS) 336 return MOD_HDCP_STATUS_FAILURE; 337 338 *encryption_status = MOD_HDCP_ENCRYPTION_STATUS_HDCP1_ON; 339 340 return MOD_HDCP_STATUS_SUCCESS; 341 } 342 343 enum mod_hdcp_status mod_hdcp_hdcp2_create_session(struct mod_hdcp *hdcp) 344 { 345 struct psp_context *psp = hdcp->config.psp.handle; 346 struct ta_hdcp_shared_memory *hdcp_cmd; 347 struct mod_hdcp_display *display = get_first_added_display(hdcp); 348 349 if (!psp->hdcp_context.hdcp_initialized) { 350 DRM_ERROR("Failed to create hdcp session, HDCP TA is not initialized"); 351 return MOD_HDCP_STATUS_FAILURE; 352 } 353 354 hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 355 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 356 357 if (!display) 358 return MOD_HDCP_STATUS_DISPLAY_NOT_FOUND; 359 360 hdcp_cmd->in_msg.hdcp2_create_session_v2.display_handle = display->index; 361 362 if (hdcp->connection.link.adjust.hdcp2.force_type == MOD_HDCP_FORCE_TYPE_0) 363 hdcp_cmd->in_msg.hdcp2_create_session_v2.negotiate_content_type = 364 TA_HDCP2_CONTENT_TYPE_NEGOTIATION_TYPE__FORCE_TYPE0; 365 else if (hdcp->connection.link.adjust.hdcp2.force_type == MOD_HDCP_FORCE_TYPE_1) 366 hdcp_cmd->in_msg.hdcp2_create_session_v2.negotiate_content_type = 367 TA_HDCP2_CONTENT_TYPE_NEGOTIATION_TYPE__FORCE_TYPE1; 368 else if (hdcp->connection.link.adjust.hdcp2.force_type == MOD_HDCP_FORCE_TYPE_MAX) 369 hdcp_cmd->in_msg.hdcp2_create_session_v2.negotiate_content_type = 370 TA_HDCP2_CONTENT_TYPE_NEGOTIATION_TYPE__MAX_SUPPORTED; 371 372 hdcp_cmd->cmd_id = TA_HDCP_COMMAND__HDCP2_CREATE_SESSION_V2; 373 374 psp_hdcp_invoke(psp, hdcp_cmd->cmd_id); 375 376 if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS) 377 return MOD_HDCP_STATUS_HDCP2_CREATE_SESSION_FAILURE; 378 379 hdcp->auth.id = hdcp_cmd->out_msg.hdcp2_create_session_v2.session_handle; 380 381 return MOD_HDCP_STATUS_SUCCESS; 382 } 383 384 enum mod_hdcp_status mod_hdcp_hdcp2_destroy_session(struct mod_hdcp *hdcp) 385 { 386 struct psp_context *psp = hdcp->config.psp.handle; 387 struct ta_hdcp_shared_memory *hdcp_cmd; 388 389 hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 390 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 391 392 hdcp_cmd->in_msg.hdcp2_destroy_session.session_handle = hdcp->auth.id; 393 hdcp_cmd->cmd_id = TA_HDCP_COMMAND__HDCP2_DESTROY_SESSION; 394 395 psp_hdcp_invoke(psp, hdcp_cmd->cmd_id); 396 397 if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS) 398 return MOD_HDCP_STATUS_HDCP2_DESTROY_SESSION_FAILURE; 399 400 HDCP_TOP_HDCP2_DESTROY_SESSION_TRACE(hdcp); 401 402 return MOD_HDCP_STATUS_SUCCESS; 403 } 404 405 enum mod_hdcp_status mod_hdcp_hdcp2_prepare_ake_init(struct mod_hdcp *hdcp) 406 { 407 struct psp_context *psp = hdcp->config.psp.handle; 408 struct ta_hdcp_shared_memory *hdcp_cmd; 409 struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_input_v2 *msg_in; 410 struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_output_v2 *msg_out; 411 412 hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 413 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 414 415 msg_in = &hdcp_cmd->in_msg.hdcp2_prepare_process_authentication_message_v2; 416 msg_out = &hdcp_cmd->out_msg.hdcp2_prepare_process_authentication_message_v2; 417 418 hdcp2_message_init(hdcp, msg_in); 419 420 hdcp_cmd->cmd_id = TA_HDCP_COMMAND__HDCP2_PREPARE_PROCESS_AUTHENTICATION_MSG_V2; 421 msg_in->prepare.msg1_id = TA_HDCP_HDCP2_MSG_ID__AKE_INIT; 422 423 psp_hdcp_invoke(psp, hdcp_cmd->cmd_id); 424 425 if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS) 426 return MOD_HDCP_STATUS_HDCP2_PREP_AKE_INIT_FAILURE; 427 428 memcpy(&hdcp->auth.msg.hdcp2.ake_init[0], &msg_out->prepare.transmitter_message[0], 429 sizeof(hdcp->auth.msg.hdcp2.ake_init)); 430 431 return MOD_HDCP_STATUS_SUCCESS; 432 } 433 434 enum mod_hdcp_status mod_hdcp_hdcp2_validate_ake_cert(struct mod_hdcp *hdcp) 435 { 436 struct psp_context *psp = hdcp->config.psp.handle; 437 struct ta_hdcp_shared_memory *hdcp_cmd; 438 struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_input_v2 *msg_in; 439 struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_output_v2 *msg_out; 440 441 hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 442 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 443 444 msg_in = &hdcp_cmd->in_msg.hdcp2_prepare_process_authentication_message_v2; 445 msg_out = &hdcp_cmd->out_msg.hdcp2_prepare_process_authentication_message_v2; 446 447 hdcp2_message_init(hdcp, msg_in); 448 449 msg_in->process.msg1_desc.msg_id = TA_HDCP_HDCP2_MSG_ID__AKE_SEND_CERT; 450 msg_in->process.msg1_desc.msg_size = TA_HDCP_HDCP2_MSG_ID_MAX_SIZE__AKE_SEND_CERT; 451 452 memcpy(&msg_in->process.receiver_message[0], hdcp->auth.msg.hdcp2.ake_cert, 453 sizeof(hdcp->auth.msg.hdcp2.ake_cert)); 454 455 msg_in->prepare.msg1_id = TA_HDCP_HDCP2_MSG_ID__AKE_NO_STORED_KM; 456 msg_in->prepare.msg2_id = TA_HDCP_HDCP2_MSG_ID__AKE_STORED_KM; 457 458 hdcp_cmd->cmd_id = TA_HDCP_COMMAND__HDCP2_PREPARE_PROCESS_AUTHENTICATION_MSG_V2; 459 460 psp_hdcp_invoke(psp, hdcp_cmd->cmd_id); 461 462 if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS) 463 return MOD_HDCP_STATUS_HDCP2_VALIDATE_AKE_CERT_FAILURE; 464 465 memcpy(hdcp->auth.msg.hdcp2.ake_no_stored_km, &msg_out->prepare.transmitter_message[0], 466 sizeof(hdcp->auth.msg.hdcp2.ake_no_stored_km)); 467 468 memcpy(hdcp->auth.msg.hdcp2.ake_stored_km, 469 &msg_out->prepare.transmitter_message[sizeof(hdcp->auth.msg.hdcp2.ake_no_stored_km)], 470 sizeof(hdcp->auth.msg.hdcp2.ake_stored_km)); 471 472 if (msg_out->process.msg1_status == TA_HDCP2_MSG_AUTHENTICATION_STATUS__SUCCESS) { 473 hdcp->connection.is_km_stored = msg_out->process.is_km_stored ? 1 : 0; 474 hdcp->connection.is_repeater = msg_out->process.is_repeater ? 1 : 0; 475 return MOD_HDCP_STATUS_SUCCESS; 476 } 477 478 return MOD_HDCP_STATUS_FAILURE; 479 } 480 481 enum mod_hdcp_status mod_hdcp_hdcp2_validate_h_prime(struct mod_hdcp *hdcp) 482 { 483 struct psp_context *psp = hdcp->config.psp.handle; 484 struct ta_hdcp_shared_memory *hdcp_cmd; 485 struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_input_v2 *msg_in; 486 struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_output_v2 *msg_out; 487 488 hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 489 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 490 491 msg_in = &hdcp_cmd->in_msg.hdcp2_prepare_process_authentication_message_v2; 492 msg_out = &hdcp_cmd->out_msg.hdcp2_prepare_process_authentication_message_v2; 493 494 hdcp2_message_init(hdcp, msg_in); 495 496 msg_in->process.msg1_desc.msg_id = TA_HDCP_HDCP2_MSG_ID__AKE_SEND_H_PRIME; 497 msg_in->process.msg1_desc.msg_size = TA_HDCP_HDCP2_MSG_ID_MAX_SIZE__AKE_SEND_H_PRIME; 498 499 memcpy(&msg_in->process.receiver_message[0], hdcp->auth.msg.hdcp2.ake_h_prime, 500 sizeof(hdcp->auth.msg.hdcp2.ake_h_prime)); 501 502 if (!hdcp->connection.is_km_stored) { 503 msg_in->process.msg2_desc.msg_id = TA_HDCP_HDCP2_MSG_ID__AKE_SEND_PAIRING_INFO; 504 msg_in->process.msg2_desc.msg_size = TA_HDCP_HDCP2_MSG_ID_MAX_SIZE__AKE_SEND_PAIRING_INFO; 505 memcpy(&msg_in->process.receiver_message[sizeof(hdcp->auth.msg.hdcp2.ake_h_prime)], 506 hdcp->auth.msg.hdcp2.ake_pairing_info, sizeof(hdcp->auth.msg.hdcp2.ake_pairing_info)); 507 } 508 509 hdcp_cmd->cmd_id = TA_HDCP_COMMAND__HDCP2_PREPARE_PROCESS_AUTHENTICATION_MSG_V2; 510 511 psp_hdcp_invoke(psp, hdcp_cmd->cmd_id); 512 513 if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS) 514 return MOD_HDCP_STATUS_HDCP2_VALIDATE_H_PRIME_FAILURE; 515 516 if (msg_out->process.msg1_status != TA_HDCP2_MSG_AUTHENTICATION_STATUS__SUCCESS) 517 return MOD_HDCP_STATUS_HDCP2_VALIDATE_H_PRIME_FAILURE; 518 else if (!hdcp->connection.is_km_stored && 519 msg_out->process.msg2_status != TA_HDCP2_MSG_AUTHENTICATION_STATUS__SUCCESS) 520 return MOD_HDCP_STATUS_HDCP2_VALIDATE_PAIRING_INFO_FAILURE; 521 522 523 return MOD_HDCP_STATUS_SUCCESS; 524 } 525 526 enum mod_hdcp_status mod_hdcp_hdcp2_prepare_lc_init(struct mod_hdcp *hdcp) 527 { 528 struct psp_context *psp = hdcp->config.psp.handle; 529 struct ta_hdcp_shared_memory *hdcp_cmd; 530 struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_input_v2 *msg_in; 531 struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_output_v2 *msg_out; 532 533 hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 534 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 535 536 msg_in = &hdcp_cmd->in_msg.hdcp2_prepare_process_authentication_message_v2; 537 msg_out = &hdcp_cmd->out_msg.hdcp2_prepare_process_authentication_message_v2; 538 539 hdcp2_message_init(hdcp, msg_in); 540 541 msg_in->prepare.msg1_id = TA_HDCP_HDCP2_MSG_ID__LC_INIT; 542 543 hdcp_cmd->cmd_id = TA_HDCP_COMMAND__HDCP2_PREPARE_PROCESS_AUTHENTICATION_MSG_V2; 544 545 psp_hdcp_invoke(psp, hdcp_cmd->cmd_id); 546 547 if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS) 548 return MOD_HDCP_STATUS_HDCP2_PREP_LC_INIT_FAILURE; 549 550 memcpy(hdcp->auth.msg.hdcp2.lc_init, &msg_out->prepare.transmitter_message[0], 551 sizeof(hdcp->auth.msg.hdcp2.lc_init)); 552 553 return MOD_HDCP_STATUS_SUCCESS; 554 } 555 556 enum mod_hdcp_status mod_hdcp_hdcp2_validate_l_prime(struct mod_hdcp *hdcp) 557 { 558 struct psp_context *psp = hdcp->config.psp.handle; 559 struct ta_hdcp_shared_memory *hdcp_cmd; 560 struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_input_v2 *msg_in; 561 struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_output_v2 *msg_out; 562 563 hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 564 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 565 566 msg_in = &hdcp_cmd->in_msg.hdcp2_prepare_process_authentication_message_v2; 567 msg_out = &hdcp_cmd->out_msg.hdcp2_prepare_process_authentication_message_v2; 568 569 hdcp2_message_init(hdcp, msg_in); 570 571 msg_in->process.msg1_desc.msg_id = TA_HDCP_HDCP2_MSG_ID__LC_SEND_L_PRIME; 572 msg_in->process.msg1_desc.msg_size = TA_HDCP_HDCP2_MSG_ID_MAX_SIZE__LC_SEND_L_PRIME; 573 574 memcpy(&msg_in->process.receiver_message[0], hdcp->auth.msg.hdcp2.lc_l_prime, 575 sizeof(hdcp->auth.msg.hdcp2.lc_l_prime)); 576 577 hdcp_cmd->cmd_id = TA_HDCP_COMMAND__HDCP2_PREPARE_PROCESS_AUTHENTICATION_MSG_V2; 578 579 psp_hdcp_invoke(psp, hdcp_cmd->cmd_id); 580 581 if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS) 582 return MOD_HDCP_STATUS_HDCP2_VALIDATE_L_PRIME_FAILURE; 583 584 if (msg_out->process.msg1_status != TA_HDCP2_MSG_AUTHENTICATION_STATUS__SUCCESS) 585 return MOD_HDCP_STATUS_HDCP2_VALIDATE_L_PRIME_FAILURE; 586 587 return MOD_HDCP_STATUS_SUCCESS; 588 } 589 590 enum mod_hdcp_status mod_hdcp_hdcp2_prepare_eks(struct mod_hdcp *hdcp) 591 { 592 struct psp_context *psp = hdcp->config.psp.handle; 593 struct ta_hdcp_shared_memory *hdcp_cmd; 594 struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_input_v2 *msg_in; 595 struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_output_v2 *msg_out; 596 597 hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 598 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 599 600 msg_in = &hdcp_cmd->in_msg.hdcp2_prepare_process_authentication_message_v2; 601 msg_out = &hdcp_cmd->out_msg.hdcp2_prepare_process_authentication_message_v2; 602 603 hdcp2_message_init(hdcp, msg_in); 604 605 msg_in->prepare.msg1_id = TA_HDCP_HDCP2_MSG_ID__SKE_SEND_EKS; 606 607 if (is_dp_hdcp(hdcp)) 608 msg_in->prepare.msg2_id = TA_HDCP_HDCP2_MSG_ID__SIGNAL_CONTENT_STREAM_TYPE_DP; 609 610 hdcp_cmd->cmd_id = TA_HDCP_COMMAND__HDCP2_PREPARE_PROCESS_AUTHENTICATION_MSG_V2; 611 psp_hdcp_invoke(psp, hdcp_cmd->cmd_id); 612 613 if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS) 614 return MOD_HDCP_STATUS_HDCP2_PREP_EKS_FAILURE; 615 616 memcpy(hdcp->auth.msg.hdcp2.ske_eks, &msg_out->prepare.transmitter_message[0], 617 sizeof(hdcp->auth.msg.hdcp2.ske_eks)); 618 msg_out->prepare.msg1_desc.msg_size = sizeof(hdcp->auth.msg.hdcp2.ske_eks); 619 620 if (is_dp_hdcp(hdcp)) { 621 memcpy(hdcp->auth.msg.hdcp2.content_stream_type_dp, 622 &msg_out->prepare.transmitter_message[sizeof(hdcp->auth.msg.hdcp2.ske_eks)], 623 sizeof(hdcp->auth.msg.hdcp2.content_stream_type_dp)); 624 } 625 626 return MOD_HDCP_STATUS_SUCCESS; 627 } 628 629 enum mod_hdcp_status mod_hdcp_hdcp2_enable_encryption(struct mod_hdcp *hdcp) 630 { 631 struct psp_context *psp = hdcp->config.psp.handle; 632 struct ta_hdcp_shared_memory *hdcp_cmd; 633 struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_input_v2 *msg_in; 634 struct mod_hdcp_display *display = get_first_added_display(hdcp); 635 636 hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 637 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 638 639 msg_in = &hdcp_cmd->in_msg.hdcp2_prepare_process_authentication_message_v2; 640 641 hdcp2_message_init(hdcp, msg_in); 642 643 if (!display) 644 return MOD_HDCP_STATUS_DISPLAY_NOT_FOUND; 645 646 hdcp_cmd->in_msg.hdcp1_enable_encryption.session_handle = hdcp->auth.id; 647 648 hdcp_cmd->cmd_id = TA_HDCP_COMMAND__HDCP2_SET_ENCRYPTION; 649 psp_hdcp_invoke(psp, hdcp_cmd->cmd_id); 650 651 if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS) 652 return MOD_HDCP_STATUS_HDCP2_ENABLE_ENCRYPTION_FAILURE; 653 654 if (!is_dp_mst_hdcp(hdcp)) { 655 display->state = MOD_HDCP_DISPLAY_ENCRYPTION_ENABLED; 656 HDCP_HDCP2_ENABLED_TRACE(hdcp, display->index); 657 } 658 659 return MOD_HDCP_STATUS_SUCCESS; 660 } 661 662 enum mod_hdcp_status mod_hdcp_hdcp2_validate_rx_id_list(struct mod_hdcp *hdcp) 663 { 664 struct psp_context *psp = hdcp->config.psp.handle; 665 struct ta_hdcp_shared_memory *hdcp_cmd; 666 struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_input_v2 *msg_in; 667 struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_output_v2 *msg_out; 668 669 hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 670 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 671 672 msg_in = &hdcp_cmd->in_msg.hdcp2_prepare_process_authentication_message_v2; 673 msg_out = &hdcp_cmd->out_msg.hdcp2_prepare_process_authentication_message_v2; 674 675 hdcp2_message_init(hdcp, msg_in); 676 677 msg_in->process.msg1_desc.msg_id = TA_HDCP_HDCP2_MSG_ID__REPEATERAUTH_SEND_RECEIVERID_LIST; 678 msg_in->process.msg1_desc.msg_size = sizeof(hdcp->auth.msg.hdcp2.rx_id_list); 679 memcpy(&msg_in->process.receiver_message[0], hdcp->auth.msg.hdcp2.rx_id_list, 680 sizeof(hdcp->auth.msg.hdcp2.rx_id_list)); 681 682 msg_in->prepare.msg1_id = TA_HDCP_HDCP2_MSG_ID__REPEATERAUTH_SEND_ACK; 683 684 hdcp_cmd->cmd_id = TA_HDCP_COMMAND__HDCP2_PREPARE_PROCESS_AUTHENTICATION_MSG_V2; 685 686 psp_hdcp_invoke(psp, hdcp_cmd->cmd_id); 687 688 if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS) 689 return MOD_HDCP_STATUS_HDCP2_VALIDATE_RX_ID_LIST_FAILURE; 690 691 memcpy(hdcp->auth.msg.hdcp2.repeater_auth_ack, &msg_out->prepare.transmitter_message[0], 692 sizeof(hdcp->auth.msg.hdcp2.repeater_auth_ack)); 693 694 if (msg_out->process.msg1_status == TA_HDCP2_MSG_AUTHENTICATION_STATUS__SUCCESS) { 695 hdcp->connection.is_km_stored = msg_out->process.is_km_stored ? 1 : 0; 696 hdcp->connection.is_repeater = msg_out->process.is_repeater ? 1 : 0; 697 return MOD_HDCP_STATUS_SUCCESS; 698 } 699 700 701 return MOD_HDCP_STATUS_HDCP2_VALIDATE_RX_ID_LIST_FAILURE; 702 } 703 704 enum mod_hdcp_status mod_hdcp_hdcp2_enable_dp_stream_encryption(struct mod_hdcp *hdcp) 705 { 706 struct psp_context *psp = hdcp->config.psp.handle; 707 struct ta_hdcp_shared_memory *hdcp_cmd; 708 struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_input_v2 *msg_in; 709 uint8_t i; 710 711 hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 712 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 713 714 msg_in = &hdcp_cmd->in_msg.hdcp2_prepare_process_authentication_message_v2; 715 716 hdcp2_message_init(hdcp, msg_in); 717 718 719 for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++) { 720 if (hdcp->connection.displays[i].state != MOD_HDCP_DISPLAY_ACTIVE_AND_ADDED || 721 hdcp->connection.displays[i].adjust.disable) 722 continue; 723 hdcp_cmd->in_msg.hdcp2_enable_dp_stream_encryption.display_handle = hdcp->connection.displays[i].index; 724 hdcp_cmd->in_msg.hdcp2_enable_dp_stream_encryption.session_handle = hdcp->auth.id; 725 726 hdcp_cmd->cmd_id = TA_HDCP_COMMAND__HDCP2_ENABLE_DP_STREAM_ENCRYPTION; 727 psp_hdcp_invoke(psp, hdcp_cmd->cmd_id); 728 729 if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS) 730 break; 731 732 hdcp->connection.displays[i].state = MOD_HDCP_DISPLAY_ENCRYPTION_ENABLED; 733 HDCP_HDCP2_ENABLED_TRACE(hdcp, hdcp->connection.displays[i].index); 734 } 735 736 return (hdcp_cmd->hdcp_status == TA_HDCP_STATUS__SUCCESS) ? MOD_HDCP_STATUS_SUCCESS 737 : MOD_HDCP_STATUS_HDCP2_ENABLE_STREAM_ENCRYPTION; 738 } 739 740 enum mod_hdcp_status mod_hdcp_hdcp2_prepare_stream_management(struct mod_hdcp *hdcp) 741 { 742 743 struct psp_context *psp = hdcp->config.psp.handle; 744 struct ta_hdcp_shared_memory *hdcp_cmd; 745 struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_input_v2 *msg_in; 746 struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_output_v2 *msg_out; 747 748 hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 749 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 750 751 msg_in = &hdcp_cmd->in_msg.hdcp2_prepare_process_authentication_message_v2; 752 msg_out = &hdcp_cmd->out_msg.hdcp2_prepare_process_authentication_message_v2; 753 754 hdcp2_message_init(hdcp, msg_in); 755 756 msg_in->prepare.msg1_id = TA_HDCP_HDCP2_MSG_ID__REPEATERAUTH_STREAM_MANAGE; 757 758 759 hdcp_cmd->cmd_id = TA_HDCP_COMMAND__HDCP2_PREPARE_PROCESS_AUTHENTICATION_MSG_V2; 760 psp_hdcp_invoke(psp, hdcp_cmd->cmd_id); 761 762 if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS) 763 return MOD_HDCP_STATUS_HDCP2_PREPARE_STREAM_MANAGEMENT_FAILURE; 764 765 hdcp->auth.msg.hdcp2.stream_manage_size = msg_out->prepare.msg1_desc.msg_size; 766 767 memcpy(hdcp->auth.msg.hdcp2.repeater_auth_stream_manage, &msg_out->prepare.transmitter_message[0], 768 sizeof(hdcp->auth.msg.hdcp2.repeater_auth_stream_manage)); 769 770 return MOD_HDCP_STATUS_SUCCESS; 771 } 772 773 enum mod_hdcp_status mod_hdcp_hdcp2_validate_stream_ready(struct mod_hdcp *hdcp) 774 { 775 struct psp_context *psp = hdcp->config.psp.handle; 776 struct ta_hdcp_shared_memory *hdcp_cmd; 777 struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_input_v2 *msg_in; 778 struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_output_v2 *msg_out; 779 780 hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 781 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 782 783 msg_in = &hdcp_cmd->in_msg.hdcp2_prepare_process_authentication_message_v2; 784 msg_out = &hdcp_cmd->out_msg.hdcp2_prepare_process_authentication_message_v2; 785 786 hdcp2_message_init(hdcp, msg_in); 787 788 msg_in->process.msg1_desc.msg_id = TA_HDCP_HDCP2_MSG_ID__REPEATERAUTH_STREAM_READY; 789 790 msg_in->process.msg1_desc.msg_size = sizeof(hdcp->auth.msg.hdcp2.repeater_auth_stream_ready); 791 792 memcpy(&msg_in->process.receiver_message[0], hdcp->auth.msg.hdcp2.repeater_auth_stream_ready, 793 sizeof(hdcp->auth.msg.hdcp2.repeater_auth_stream_ready)); 794 795 hdcp_cmd->cmd_id = TA_HDCP_COMMAND__HDCP2_PREPARE_PROCESS_AUTHENTICATION_MSG_V2; 796 psp_hdcp_invoke(psp, hdcp_cmd->cmd_id); 797 798 return (hdcp_cmd->hdcp_status == TA_HDCP_STATUS__SUCCESS) && 799 (msg_out->process.msg1_status == TA_HDCP2_MSG_AUTHENTICATION_STATUS__SUCCESS) 800 ? MOD_HDCP_STATUS_SUCCESS 801 : MOD_HDCP_STATUS_HDCP2_VALIDATE_STREAM_READY_FAILURE; 802 } 803 804 enum mod_hdcp_status mod_hdcp_hdcp2_get_link_encryption_status(struct mod_hdcp *hdcp, 805 enum mod_hdcp_encryption_status *encryption_status) 806 { 807 struct psp_context *psp = hdcp->config.psp.handle; 808 struct ta_hdcp_shared_memory *hdcp_cmd; 809 810 hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 811 812 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 813 814 hdcp_cmd->in_msg.hdcp2_get_encryption_status.session_handle = hdcp->auth.id; 815 hdcp_cmd->out_msg.hdcp2_get_encryption_status.protection_level = 0; 816 hdcp_cmd->cmd_id = TA_HDCP_COMMAND__HDCP2_GET_ENCRYPTION_STATUS; 817 *encryption_status = MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF; 818 819 psp_hdcp_invoke(psp, hdcp_cmd->cmd_id); 820 821 if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS) 822 return MOD_HDCP_STATUS_FAILURE; 823 824 if (hdcp_cmd->out_msg.hdcp2_get_encryption_status.protection_level == 1) { 825 if (hdcp_cmd->out_msg.hdcp2_get_encryption_status.hdcp2_type == TA_HDCP2_CONTENT_TYPE__TYPE1) 826 *encryption_status = MOD_HDCP_ENCRYPTION_STATUS_HDCP2_TYPE1_ON; 827 else 828 *encryption_status = MOD_HDCP_ENCRYPTION_STATUS_HDCP2_TYPE0_ON; 829 } 830 831 return MOD_HDCP_STATUS_SUCCESS; 832 } 833