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