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_INFO("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_enabled; 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 } else { 552 status = MOD_HDCP_STATUS_HDCP2_VALIDATE_AKE_CERT_FAILURE; 553 } 554 } 555 mutex_unlock(&psp->hdcp_context.mutex); 556 return status; 557 } 558 559 enum mod_hdcp_status mod_hdcp_hdcp2_validate_h_prime(struct mod_hdcp *hdcp) 560 { 561 struct psp_context *psp = hdcp->config.psp.handle; 562 struct ta_hdcp_shared_memory *hdcp_cmd; 563 struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_input_v2 *msg_in; 564 struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_output_v2 *msg_out; 565 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS; 566 567 mutex_lock(&psp->hdcp_context.mutex); 568 hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 569 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 570 571 msg_in = &hdcp_cmd->in_msg.hdcp2_prepare_process_authentication_message_v2; 572 msg_out = &hdcp_cmd->out_msg.hdcp2_prepare_process_authentication_message_v2; 573 574 hdcp2_message_init(hdcp, msg_in); 575 576 msg_in->process.msg1_desc.msg_id = TA_HDCP_HDCP2_MSG_ID__AKE_SEND_H_PRIME; 577 msg_in->process.msg1_desc.msg_size = TA_HDCP_HDCP2_MSG_ID_MAX_SIZE__AKE_SEND_H_PRIME; 578 579 memcpy(&msg_in->process.receiver_message[0], hdcp->auth.msg.hdcp2.ake_h_prime, 580 sizeof(hdcp->auth.msg.hdcp2.ake_h_prime)); 581 582 if (!hdcp->connection.is_km_stored) { 583 msg_in->process.msg2_desc.msg_id = TA_HDCP_HDCP2_MSG_ID__AKE_SEND_PAIRING_INFO; 584 msg_in->process.msg2_desc.msg_size = TA_HDCP_HDCP2_MSG_ID_MAX_SIZE__AKE_SEND_PAIRING_INFO; 585 memcpy(&msg_in->process.receiver_message[sizeof(hdcp->auth.msg.hdcp2.ake_h_prime)], 586 hdcp->auth.msg.hdcp2.ake_pairing_info, sizeof(hdcp->auth.msg.hdcp2.ake_pairing_info)); 587 } 588 589 hdcp_cmd->cmd_id = TA_HDCP_COMMAND__HDCP2_PREPARE_PROCESS_AUTHENTICATION_MSG_V2; 590 591 psp_hdcp_invoke(psp, hdcp_cmd->cmd_id); 592 593 if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS) 594 status = MOD_HDCP_STATUS_HDCP2_VALIDATE_H_PRIME_FAILURE; 595 else if (msg_out->process.msg1_status != TA_HDCP2_MSG_AUTHENTICATION_STATUS__SUCCESS) 596 status = MOD_HDCP_STATUS_HDCP2_VALIDATE_H_PRIME_FAILURE; 597 else if (!hdcp->connection.is_km_stored && 598 msg_out->process.msg2_status != TA_HDCP2_MSG_AUTHENTICATION_STATUS__SUCCESS) 599 status = MOD_HDCP_STATUS_HDCP2_VALIDATE_PAIRING_INFO_FAILURE; 600 601 mutex_unlock(&psp->hdcp_context.mutex); 602 return status; 603 } 604 605 enum mod_hdcp_status mod_hdcp_hdcp2_prepare_lc_init(struct mod_hdcp *hdcp) 606 { 607 struct psp_context *psp = hdcp->config.psp.handle; 608 struct ta_hdcp_shared_memory *hdcp_cmd; 609 struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_input_v2 *msg_in; 610 struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_output_v2 *msg_out; 611 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS; 612 613 mutex_lock(&psp->hdcp_context.mutex); 614 hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 615 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 616 617 msg_in = &hdcp_cmd->in_msg.hdcp2_prepare_process_authentication_message_v2; 618 msg_out = &hdcp_cmd->out_msg.hdcp2_prepare_process_authentication_message_v2; 619 620 hdcp2_message_init(hdcp, msg_in); 621 622 msg_in->prepare.msg1_id = TA_HDCP_HDCP2_MSG_ID__LC_INIT; 623 624 hdcp_cmd->cmd_id = TA_HDCP_COMMAND__HDCP2_PREPARE_PROCESS_AUTHENTICATION_MSG_V2; 625 626 psp_hdcp_invoke(psp, hdcp_cmd->cmd_id); 627 628 if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS) 629 status = MOD_HDCP_STATUS_HDCP2_PREP_LC_INIT_FAILURE; 630 else 631 memcpy(hdcp->auth.msg.hdcp2.lc_init, &msg_out->prepare.transmitter_message[0], 632 sizeof(hdcp->auth.msg.hdcp2.lc_init)); 633 634 mutex_unlock(&psp->hdcp_context.mutex); 635 return status; 636 } 637 638 enum mod_hdcp_status mod_hdcp_hdcp2_validate_l_prime(struct mod_hdcp *hdcp) 639 { 640 struct psp_context *psp = hdcp->config.psp.handle; 641 struct ta_hdcp_shared_memory *hdcp_cmd; 642 struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_input_v2 *msg_in; 643 struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_output_v2 *msg_out; 644 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS; 645 646 mutex_lock(&psp->hdcp_context.mutex); 647 hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 648 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 649 650 msg_in = &hdcp_cmd->in_msg.hdcp2_prepare_process_authentication_message_v2; 651 msg_out = &hdcp_cmd->out_msg.hdcp2_prepare_process_authentication_message_v2; 652 653 hdcp2_message_init(hdcp, msg_in); 654 655 msg_in->process.msg1_desc.msg_id = TA_HDCP_HDCP2_MSG_ID__LC_SEND_L_PRIME; 656 msg_in->process.msg1_desc.msg_size = TA_HDCP_HDCP2_MSG_ID_MAX_SIZE__LC_SEND_L_PRIME; 657 658 memcpy(&msg_in->process.receiver_message[0], hdcp->auth.msg.hdcp2.lc_l_prime, 659 sizeof(hdcp->auth.msg.hdcp2.lc_l_prime)); 660 661 hdcp_cmd->cmd_id = TA_HDCP_COMMAND__HDCP2_PREPARE_PROCESS_AUTHENTICATION_MSG_V2; 662 663 psp_hdcp_invoke(psp, hdcp_cmd->cmd_id); 664 665 if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS || 666 msg_out->process.msg1_status != TA_HDCP2_MSG_AUTHENTICATION_STATUS__SUCCESS) 667 status = MOD_HDCP_STATUS_HDCP2_VALIDATE_L_PRIME_FAILURE; 668 669 mutex_unlock(&psp->hdcp_context.mutex); 670 return status; 671 } 672 673 enum mod_hdcp_status mod_hdcp_hdcp2_prepare_eks(struct mod_hdcp *hdcp) 674 { 675 struct psp_context *psp = hdcp->config.psp.handle; 676 struct ta_hdcp_shared_memory *hdcp_cmd; 677 struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_input_v2 *msg_in; 678 struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_output_v2 *msg_out; 679 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS; 680 681 mutex_lock(&psp->hdcp_context.mutex); 682 hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 683 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 684 685 msg_in = &hdcp_cmd->in_msg.hdcp2_prepare_process_authentication_message_v2; 686 msg_out = &hdcp_cmd->out_msg.hdcp2_prepare_process_authentication_message_v2; 687 688 hdcp2_message_init(hdcp, msg_in); 689 690 msg_in->prepare.msg1_id = TA_HDCP_HDCP2_MSG_ID__SKE_SEND_EKS; 691 692 if (is_dp_hdcp(hdcp)) 693 msg_in->prepare.msg2_id = TA_HDCP_HDCP2_MSG_ID__SIGNAL_CONTENT_STREAM_TYPE_DP; 694 695 hdcp_cmd->cmd_id = TA_HDCP_COMMAND__HDCP2_PREPARE_PROCESS_AUTHENTICATION_MSG_V2; 696 psp_hdcp_invoke(psp, hdcp_cmd->cmd_id); 697 698 if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS) { 699 status = MOD_HDCP_STATUS_HDCP2_PREP_EKS_FAILURE; 700 } else { 701 memcpy(hdcp->auth.msg.hdcp2.ske_eks, 702 &msg_out->prepare.transmitter_message[0], 703 sizeof(hdcp->auth.msg.hdcp2.ske_eks)); 704 msg_out->prepare.msg1_desc.msg_size = 705 sizeof(hdcp->auth.msg.hdcp2.ske_eks); 706 707 if (is_dp_hdcp(hdcp)) { 708 memcpy(hdcp->auth.msg.hdcp2.content_stream_type_dp, 709 &msg_out->prepare.transmitter_message[sizeof(hdcp->auth.msg.hdcp2.ske_eks)], 710 sizeof(hdcp->auth.msg.hdcp2.content_stream_type_dp)); 711 } 712 } 713 mutex_unlock(&psp->hdcp_context.mutex); 714 715 return status; 716 } 717 718 enum mod_hdcp_status mod_hdcp_hdcp2_enable_encryption(struct mod_hdcp *hdcp) 719 { 720 struct psp_context *psp = hdcp->config.psp.handle; 721 struct ta_hdcp_shared_memory *hdcp_cmd; 722 struct mod_hdcp_display *display = get_first_active_display(hdcp); 723 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS; 724 725 if (!display) 726 return MOD_HDCP_STATUS_DISPLAY_NOT_FOUND; 727 728 mutex_lock(&psp->hdcp_context.mutex); 729 730 hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 731 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 732 733 hdcp_cmd->in_msg.hdcp2_set_encryption.session_handle = hdcp->auth.id; 734 735 hdcp_cmd->cmd_id = TA_HDCP_COMMAND__HDCP2_SET_ENCRYPTION; 736 psp_hdcp_invoke(psp, hdcp_cmd->cmd_id); 737 738 if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS) { 739 status = MOD_HDCP_STATUS_HDCP2_ENABLE_ENCRYPTION_FAILURE; 740 } else if (!is_dp_mst_hdcp(hdcp)) { 741 display->state = MOD_HDCP_DISPLAY_ENCRYPTION_ENABLED; 742 HDCP_HDCP2_ENABLED_TRACE(hdcp, display->index); 743 } 744 745 mutex_unlock(&psp->hdcp_context.mutex); 746 return status; 747 } 748 749 enum mod_hdcp_status mod_hdcp_hdcp2_validate_rx_id_list(struct mod_hdcp *hdcp) 750 { 751 struct psp_context *psp = hdcp->config.psp.handle; 752 struct ta_hdcp_shared_memory *hdcp_cmd; 753 struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_input_v2 *msg_in; 754 struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_output_v2 *msg_out; 755 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS; 756 757 mutex_lock(&psp->hdcp_context.mutex); 758 759 hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 760 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 761 762 msg_in = &hdcp_cmd->in_msg.hdcp2_prepare_process_authentication_message_v2; 763 msg_out = &hdcp_cmd->out_msg.hdcp2_prepare_process_authentication_message_v2; 764 765 hdcp2_message_init(hdcp, msg_in); 766 767 msg_in->process.msg1_desc.msg_id = TA_HDCP_HDCP2_MSG_ID__REPEATERAUTH_SEND_RECEIVERID_LIST; 768 msg_in->process.msg1_desc.msg_size = sizeof(hdcp->auth.msg.hdcp2.rx_id_list); 769 memcpy(&msg_in->process.receiver_message[0], hdcp->auth.msg.hdcp2.rx_id_list, 770 sizeof(hdcp->auth.msg.hdcp2.rx_id_list)); 771 772 msg_in->prepare.msg1_id = TA_HDCP_HDCP2_MSG_ID__REPEATERAUTH_SEND_ACK; 773 774 hdcp_cmd->cmd_id = TA_HDCP_COMMAND__HDCP2_PREPARE_PROCESS_AUTHENTICATION_MSG_V2; 775 776 psp_hdcp_invoke(psp, hdcp_cmd->cmd_id); 777 778 if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS) { 779 status = MOD_HDCP_STATUS_HDCP2_VALIDATE_RX_ID_LIST_FAILURE; 780 } else { 781 memcpy(hdcp->auth.msg.hdcp2.repeater_auth_ack, 782 &msg_out->prepare.transmitter_message[0], 783 sizeof(hdcp->auth.msg.hdcp2.repeater_auth_ack)); 784 785 if (msg_out->process.msg1_status == 786 TA_HDCP2_MSG_AUTHENTICATION_STATUS__SUCCESS) { 787 hdcp->connection.is_km_stored = msg_out->process.is_km_stored ? 1 : 0; 788 hdcp->connection.is_repeater = msg_out->process.is_repeater ? 1 : 0; 789 status = MOD_HDCP_STATUS_SUCCESS; 790 } else if (msg_out->process.msg1_status == 791 TA_HDCP2_MSG_AUTHENTICATION_STATUS__RECEIVERID_REVOKED) { 792 hdcp->connection.is_hdcp2_revoked = 1; 793 status = MOD_HDCP_STATUS_HDCP2_RX_ID_LIST_REVOKED; 794 } else { 795 status = MOD_HDCP_STATUS_HDCP2_VALIDATE_RX_ID_LIST_FAILURE; 796 } 797 } 798 mutex_unlock(&psp->hdcp_context.mutex); 799 return status; 800 } 801 802 enum mod_hdcp_status mod_hdcp_hdcp2_enable_dp_stream_encryption(struct mod_hdcp *hdcp) 803 { 804 struct psp_context *psp = hdcp->config.psp.handle; 805 struct ta_hdcp_shared_memory *hdcp_cmd; 806 struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_input_v2 *msg_in; 807 uint8_t i; 808 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS; 809 810 mutex_lock(&psp->hdcp_context.mutex); 811 hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 812 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 813 814 msg_in = &hdcp_cmd->in_msg.hdcp2_prepare_process_authentication_message_v2; 815 816 hdcp2_message_init(hdcp, msg_in); 817 818 819 for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++) { 820 if (hdcp->displays[i].adjust.disable || hdcp->displays[i].state != MOD_HDCP_DISPLAY_ACTIVE) 821 continue; 822 823 hdcp_cmd->in_msg.hdcp2_enable_dp_stream_encryption.display_handle = hdcp->displays[i].index; 824 hdcp_cmd->in_msg.hdcp2_enable_dp_stream_encryption.session_handle = hdcp->auth.id; 825 826 hdcp_cmd->cmd_id = TA_HDCP_COMMAND__HDCP2_ENABLE_DP_STREAM_ENCRYPTION; 827 psp_hdcp_invoke(psp, hdcp_cmd->cmd_id); 828 829 if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS) 830 break; 831 832 hdcp->displays[i].state = MOD_HDCP_DISPLAY_ENCRYPTION_ENABLED; 833 HDCP_HDCP2_ENABLED_TRACE(hdcp, hdcp->displays[i].index); 834 } 835 836 if (hdcp_cmd->hdcp_status == TA_HDCP_STATUS__SUCCESS) 837 status = MOD_HDCP_STATUS_SUCCESS; 838 else 839 status = MOD_HDCP_STATUS_HDCP2_ENABLE_STREAM_ENCRYPTION_FAILURE; 840 841 mutex_unlock(&psp->hdcp_context.mutex); 842 return status; 843 } 844 845 enum mod_hdcp_status mod_hdcp_hdcp2_prepare_stream_management(struct mod_hdcp *hdcp) 846 { 847 848 struct psp_context *psp = hdcp->config.psp.handle; 849 struct ta_hdcp_shared_memory *hdcp_cmd; 850 struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_input_v2 *msg_in; 851 struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_output_v2 *msg_out; 852 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS; 853 854 mutex_lock(&psp->hdcp_context.mutex); 855 hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 856 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 857 858 msg_in = &hdcp_cmd->in_msg.hdcp2_prepare_process_authentication_message_v2; 859 msg_out = &hdcp_cmd->out_msg.hdcp2_prepare_process_authentication_message_v2; 860 861 hdcp2_message_init(hdcp, msg_in); 862 863 msg_in->prepare.msg1_id = TA_HDCP_HDCP2_MSG_ID__REPEATERAUTH_STREAM_MANAGE; 864 865 866 hdcp_cmd->cmd_id = TA_HDCP_COMMAND__HDCP2_PREPARE_PROCESS_AUTHENTICATION_MSG_V2; 867 psp_hdcp_invoke(psp, hdcp_cmd->cmd_id); 868 869 if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS) { 870 status = MOD_HDCP_STATUS_HDCP2_PREPARE_STREAM_MANAGEMENT_FAILURE; 871 } else { 872 hdcp->auth.msg.hdcp2.stream_manage_size = msg_out->prepare.msg1_desc.msg_size; 873 874 memcpy(hdcp->auth.msg.hdcp2.repeater_auth_stream_manage, 875 &msg_out->prepare.transmitter_message[0], 876 sizeof(hdcp->auth.msg.hdcp2.repeater_auth_stream_manage)); 877 } 878 mutex_unlock(&psp->hdcp_context.mutex); 879 return status; 880 } 881 882 enum mod_hdcp_status mod_hdcp_hdcp2_validate_stream_ready(struct mod_hdcp *hdcp) 883 { 884 struct psp_context *psp = hdcp->config.psp.handle; 885 struct ta_hdcp_shared_memory *hdcp_cmd; 886 struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_input_v2 *msg_in; 887 struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_output_v2 *msg_out; 888 enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS; 889 890 mutex_lock(&psp->hdcp_context.mutex); 891 hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 892 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); 893 894 msg_in = &hdcp_cmd->in_msg.hdcp2_prepare_process_authentication_message_v2; 895 msg_out = &hdcp_cmd->out_msg.hdcp2_prepare_process_authentication_message_v2; 896 897 hdcp2_message_init(hdcp, msg_in); 898 899 msg_in->process.msg1_desc.msg_id = TA_HDCP_HDCP2_MSG_ID__REPEATERAUTH_STREAM_READY; 900 901 msg_in->process.msg1_desc.msg_size = sizeof(hdcp->auth.msg.hdcp2.repeater_auth_stream_ready); 902 903 memcpy(&msg_in->process.receiver_message[0], hdcp->auth.msg.hdcp2.repeater_auth_stream_ready, 904 sizeof(hdcp->auth.msg.hdcp2.repeater_auth_stream_ready)); 905 906 hdcp_cmd->cmd_id = TA_HDCP_COMMAND__HDCP2_PREPARE_PROCESS_AUTHENTICATION_MSG_V2; 907 psp_hdcp_invoke(psp, hdcp_cmd->cmd_id); 908 909 if (hdcp_cmd->hdcp_status == TA_HDCP_STATUS__SUCCESS && 910 msg_out->process.msg1_status == TA_HDCP2_MSG_AUTHENTICATION_STATUS__SUCCESS) 911 status = MOD_HDCP_STATUS_SUCCESS; 912 else 913 status = MOD_HDCP_STATUS_HDCP2_VALIDATE_STREAM_READY_FAILURE; 914 915 mutex_unlock(&psp->hdcp_context.mutex); 916 return status; 917 } 918 919 bool mod_hdcp_is_link_encryption_enabled(struct mod_hdcp *hdcp) 920 { 921 /* unsupported */ 922 return true; 923 } 924 925 void mod_hdcp_save_current_encryption_states(struct mod_hdcp *hdcp) 926 { 927 /* unsupported */ 928 } 929