| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2005-2010, Broadcom Corporation |
|---|
| 3 | * All Rights Reserved |
|---|
| 4 | * Confidential Property of Broadcom Corporation |
|---|
| 5 | * |
|---|
| 6 | * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE |
|---|
| 7 | * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR |
|---|
| 8 | * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. |
|---|
| 9 | * |
|---|
| 10 | * $brcm_Workfile: bhdcplib.c $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/10 $ |
|---|
| 12 | * $brcm_Date: 3/3/10 12:37p $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /magnum/syslib/hdcplib/7405/bhdcplib.c $ |
|---|
| 19 | * |
|---|
| 20 | * Hydra_Software_Devel/10 3/3/10 12:37p vle |
|---|
| 21 | * SW7405-3987: Merge into main branch |
|---|
| 22 | * |
|---|
| 23 | * Hydra_Software_Devel/SW7405-3987/2 3/2/10 7:12p vle |
|---|
| 24 | * SW7405-3987: Report specific HDCP error status to high level |
|---|
| 25 | * application - Take 2: warn users for invalid errors. |
|---|
| 26 | * |
|---|
| 27 | * Hydra_Software_Devel/SW7405-3987/1 3/2/10 5:39p vle |
|---|
| 28 | * SW7405-3987: Report specific HDCP error status to high level |
|---|
| 29 | * application. |
|---|
| 30 | * |
|---|
| 31 | * Hydra_Software_Devel/9 1/28/10 1:56p vle |
|---|
| 32 | * SW7420-489: merge to main branch |
|---|
| 33 | * |
|---|
| 34 | * Hydra_Software_Devel/SW7420-489/1 1/26/10 3:39p vle |
|---|
| 35 | * SW7420-489: propagate max_device_count and max_depth to application |
|---|
| 36 | * |
|---|
| 37 | * Hydra_Software_Devel/8 8/25/09 3:31p vle |
|---|
| 38 | * SW7405-2670: |
|---|
| 39 | * Do not poll for receiver sense while encryption is still enabled. |
|---|
| 40 | * Add implementation of interrupt based receiver sense |
|---|
| 41 | * |
|---|
| 42 | * Hydra_Software_Devel/PR56486/1 8/6/09 12:05p vle |
|---|
| 43 | * PR56486: Do not poll for receiver sense while encryption is still |
|---|
| 44 | * enabled. |
|---|
| 45 | * |
|---|
| 46 | * Hydra_Software_Devel/7 2/27/09 8:56p vle |
|---|
| 47 | * PR52505: Fix non-const global data in HDM and HDCPLIB |
|---|
| 48 | * |
|---|
| 49 | * Hydra_Software_Devel/6 11/24/08 8:42p vle |
|---|
| 50 | * PR49219, PR49593, PR48842, PR48937: Merge to main branch |
|---|
| 51 | * |
|---|
| 52 | * Hydra_Software_Devel/HDMI_TX_Plugfest11_200811/2 11/24/08 8:26p vle |
|---|
| 53 | * PR49219, PR49593, PR48842: Add additional state in the state machine to |
|---|
| 54 | * clearly identify HDCP authentication errors. Update the current hdcp |
|---|
| 55 | * state appropriately. |
|---|
| 56 | * |
|---|
| 57 | * Hydra_Software_Devel/HDMI_TX_Plugfest11_200811/1 11/12/08 4:54p vle |
|---|
| 58 | * PR 48937: Add support for HDCP repeater error during HDCP |
|---|
| 59 | * authentication process. |
|---|
| 60 | * |
|---|
| 61 | * Hydra_Software_Devel/5 11/10/08 6:56p vle |
|---|
| 62 | * PR44550, PR48842: Be sure to retrieve receiver info for the |
|---|
| 63 | * authentication process instead of relying on the application. |
|---|
| 64 | * |
|---|
| 65 | * Hydra_Software_Devel/4 11/6/08 11:23a vle |
|---|
| 66 | * PR48705: Fix crash in kernel mode when closing BHDCPlib. |
|---|
| 67 | * |
|---|
| 68 | * Hydra_Software_Devel/3 10/29/08 7:40p vle |
|---|
| 69 | * PR44550: Merge changes from bdvd_v2.0 branch. |
|---|
| 70 | * Fix bug on size of revoked KSV list |
|---|
| 71 | * Be sure to free the revoked KSV list appropriately. |
|---|
| 72 | * |
|---|
| 73 | * Hydra_Software_Devel/2 3/18/08 7:18p vle |
|---|
| 74 | * PR 39991: Rename HDMIlib to HDCPlib. Remove unused implementation. |
|---|
| 75 | * |
|---|
| 76 | * Hydra_Software_Devel/1 2/26/08 5:43p jgarrett |
|---|
| 77 | * PR 39991: Renaming new HDMlib to HDCPlib |
|---|
| 78 | * |
|---|
| 79 | * Hydra_Software_Devel/Syslib_Initiative/11 2/22/08 6:16p vle |
|---|
| 80 | * PR 31924: Set default HDCP configuration during open. |
|---|
| 81 | * Use HDCP test keys as default HDCP keys. |
|---|
| 82 | * |
|---|
| 83 | * Hydra_Software_Devel/Syslib_Initiative/10 2/21/08 7:01p vle |
|---|
| 84 | * PR 31924: Fix RevokedKSV callback |
|---|
| 85 | * |
|---|
| 86 | * Hydra_Software_Devel/Syslib_Initiative/9 2/21/08 5:00p vle |
|---|
| 87 | * PR 31924: Change Settings back to Dependencies |
|---|
| 88 | * Remove Hotplug callback |
|---|
| 89 | * Move RevokedKSVList to Handle |
|---|
| 90 | * |
|---|
| 91 | * Hydra_Software_Devel/Syslib_Initiative/8 2/15/08 10:01p vle |
|---|
| 92 | * PR 31924: Improve HDMI Syslib API from feedback. |
|---|
| 93 | * |
|---|
| 94 | ***************************************************************************/ |
|---|
| 95 | |
|---|
| 96 | #include "bavc_hdmi.h" |
|---|
| 97 | #include "bhdcplib.h" |
|---|
| 98 | #include "bhdcplib_priv.h" |
|---|
| 99 | #include "bhdcplib_keyloader.h" |
|---|
| 100 | |
|---|
| 101 | |
|---|
| 102 | BDBG_MODULE(BHDCPLIB) ; |
|---|
| 103 | |
|---|
| 104 | |
|---|
| 105 | #define BHDCPLIB_CHECK_RC( rc, func ) \ |
|---|
| 106 | do \ |
|---|
| 107 | { \ |
|---|
| 108 | if( (rc = BERR_TRACE(func)) != BERR_SUCCESS ) \ |
|---|
| 109 | { \ |
|---|
| 110 | goto done; \ |
|---|
| 111 | } \ |
|---|
| 112 | } while(0) |
|---|
| 113 | |
|---|
| 114 | |
|---|
| 115 | /* HDCP default settings */ |
|---|
| 116 | static const BHDCPlib_Configuration stHdcpDefaultConfiguration = |
|---|
| 117 | { |
|---|
| 118 | BHDM_HDCP_AnSelect_eRandomAn, |
|---|
| 119 | { |
|---|
| 120 | {0x14, 0xF7, 0x61, 0x03, 0xB7}, |
|---|
| 121 | { /* HDCP Test Keys */ |
|---|
| 122 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x691e138f, 0x58a44d00}, |
|---|
| 123 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x0950e658, 0x35821f00}, |
|---|
| 124 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x0d98b9ab, 0x476a8a00}, |
|---|
| 125 | { 0, 0, 0, 0, 0, 0, 0, 0, 0xcac5cb52, 0x1b18f300}, |
|---|
| 126 | { 0, 0, 0, 0, 0, 0, 0, 0, 0xb4d89668, 0x7f14fb00}, |
|---|
| 127 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x818f4878, 0xc98be000}, |
|---|
| 128 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x412c11c8, 0x64d0a000}, |
|---|
| 129 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x44202428, 0x5a9db300}, |
|---|
| 130 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x6b56adbd, 0xb228b900}, |
|---|
| 131 | { 0, 0, 0, 0, 0, 0, 0, 0, 0xf6e46c4a, 0x7ba49100}, |
|---|
| 132 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x589d5e20, 0xf8005600}, |
|---|
| 133 | { 0, 0, 0, 0, 0, 0, 0, 0, 0xa03fee06, 0xb77f8c00}, |
|---|
| 134 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x28bc7c9d, 0x8c2dc000}, |
|---|
| 135 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x059f4be5, 0x61125600}, |
|---|
| 136 | { 0, 0, 0, 0, 0, 0, 0, 0, 0xcbc1ca8c, 0xdef07400}, |
|---|
| 137 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x6adbfc0e, 0xf6b83b00}, |
|---|
| 138 | { 0, 0, 0, 0, 0, 0, 0, 0, 0xd72fb216, 0xbb2ba000}, |
|---|
| 139 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x98547846, 0x8e2f4800}, |
|---|
| 140 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x38472762, 0x25ae6600}, |
|---|
| 141 | { 0, 0, 0, 0, 0, 0, 0, 0, 0xf2dd23a3, 0x52493d00}, |
|---|
| 142 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x543a7b76, 0x31d2e200}, |
|---|
| 143 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x2561e6ed, 0x1a584d00}, |
|---|
| 144 | { 0, 0, 0, 0, 0, 0, 0, 0, 0xf7227bbf, 0x82603200}, |
|---|
| 145 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x6bce3035, 0x461bf600}, |
|---|
| 146 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x6b97d7f0, 0x09043600}, |
|---|
| 147 | { 0, 0, 0, 0, 0, 0, 0, 0, 0xf9498d61, 0x05e1a100}, |
|---|
| 148 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x063405d1, 0x9d8ec900}, |
|---|
| 149 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x90614294, 0x67c32000}, |
|---|
| 150 | { 0, 0, 0, 0, 0, 0, 0, 0, 0xc34facce, 0x51449600}, |
|---|
| 151 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x8a8ce104, 0x45903e00}, |
|---|
| 152 | { 0, 0, 0, 0, 0, 0, 0, 0, 0xfc2d9c57, 0x10002900}, |
|---|
| 153 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x80b1e569, 0x3b94d700}, |
|---|
| 154 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x437bdd5b, 0xeac75400}, |
|---|
| 155 | { 0, 0, 0, 0, 0, 0, 0, 0, 0xba90c787, 0x58fb7400}, |
|---|
| 156 | { 0, 0, 0, 0, 0, 0, 0, 0, 0xe01d4e36, 0xfa5c9300}, |
|---|
| 157 | { 0, 0, 0, 0, 0, 0, 0, 0, 0xae119a15, 0x5e070300}, |
|---|
| 158 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x01fb788a, 0x40d30500}, |
|---|
| 159 | { 0, 0, 0, 0, 0, 0, 0, 0, 0xb34da0d7, 0xa5590000}, |
|---|
| 160 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x409e2c4a, 0x633b3700}, |
|---|
| 161 | { 0, 0, 0, 0, 0, 0, 0, 0, 0x412056b4, 0xbb732500} |
|---|
| 162 | } |
|---|
| 163 | }, |
|---|
| 164 | {{0x11,0x11,0x11,0x11,0x11}, 0, 0, false}, |
|---|
| 165 | 100 /* msWaitForR0 */, |
|---|
| 166 | 100 /*msIntervalKsvFifoReadyCheck */, |
|---|
| 167 | 1 /* uiKsvFifoReadyChecks */ , |
|---|
| 168 | BHDM_HDCP_REPEATER_MAX_DEVICE_COUNT /* uiMaxDeviceCount */, |
|---|
| 169 | BHDM_HDCP_REPEATER_MAX_DEPTH /* uiMaxDepth */ |
|---|
| 170 | }; |
|---|
| 171 | |
|---|
| 172 | |
|---|
| 173 | typedef struct _BHDCPLIB_P_HDM_HdcpErrors |
|---|
| 174 | { |
|---|
| 175 | BERR_Code hdmHdcpError; |
|---|
| 176 | BHDCPlib_HdcpError hdcplibHdcpError; |
|---|
| 177 | |
|---|
| 178 | } BHDCPLIB_P_HDM_HdcpErrors; |
|---|
| 179 | |
|---|
| 180 | static const BHDCPLIB_P_HDM_HdcpErrors BHDCPlib_SupportedHdcpErrors[BHDCPlib_HdcpError_eCount]= |
|---|
| 181 | { |
|---|
| 182 | {BERR_SUCCESS, BHDCPlib_HdcpError_eSuccess}, |
|---|
| 183 | {BHDM_HDCP_RX_BKSV_ERROR, BHDCPlib_HdcpError_eRxBksvError}, |
|---|
| 184 | {BHDM_HDCP_RX_BKSV_REVOKED, BHDCPlib_HdcpError_eRxBksvRevoked}, |
|---|
| 185 | {BHDM_HDCP_RX_BKSV_I2C_READ_ERROR, BHDCPlib_HdcpError_eRxBksvI2cReadError}, |
|---|
| 186 | {BHDM_HDCP_TX_AKSV_ERROR, BHDCPlib_HdcpError_eTxAksvError}, |
|---|
| 187 | {BHDM_HDCP_TX_AKSV_I2C_WRITE_ERROR, BHDCPlib_HdcpError_eTxAksvI2cWriteError}, |
|---|
| 188 | {BHDM_HDCP_RECEIVER_AUTH_ERROR, BHDCPlib_HdcpError_eReceiverAuthenticationError}, |
|---|
| 189 | {BHDM_HDCP_REPEATER_AUTH_ERROR, BHDCPlib_HdcpError_eRepeaterAuthenticationError}, |
|---|
| 190 | {BHDM_HDCP_RX_DEVICES_EXCEEDED, BHDCPlib_HdcpError_eRxDevicesExceeded}, |
|---|
| 191 | {BHDM_HDCP_REPEATER_DEPTH_EXCEEDED, BHDCPlib_HdcpError_eRepeaterDepthExceeded}, |
|---|
| 192 | {BHDM_HDCP_REPEATER_FIFO_NOT_READY, BHDCPlib_HdcpError_eRepeaterFifoNotReady}, |
|---|
| 193 | {BHDM_HDCP_REPEATER_DEVCOUNT_0, BHDCPlib_HdcpError_eRepeaterDeviceCount0}, |
|---|
| 194 | {BHDM_HDCP_LINK_FAILURE, BHDCPlib_HdcpError_eRepeaterLinkFailure}, |
|---|
| 195 | {BHDM_HDCP_LINK_RI_FAILURE, BHDCPlib_HdcpError_eLinkRiFailure}, |
|---|
| 196 | {BHDM_HDCP_LINK_PJ_FAILURE, BHDCPlib_HdcpError_eLinkPjFailure}, |
|---|
| 197 | {BHDM_HDCP_FIFO_UNDERFLOW, BHDCPlib_HdcpError_eFifoUnderflow}, |
|---|
| 198 | {BHDM_HDCP_FIFO_OVERFLOW, BHDCPlib_HdcpError_eFifoOverflow}, |
|---|
| 199 | {BHDM_HDCP_MULTIPLE_AN_REQUEST, BHDCPlib_HdcpError_eMultipleAnRequest} |
|---|
| 200 | }; |
|---|
| 201 | |
|---|
| 202 | |
|---|
| 203 | static BERR_Code BHDCPlib_P_CheckRepeaterReady(BHDCPlib_Handle hHDCPlib) |
|---|
| 204 | { |
|---|
| 205 | BERR_Code rc = BERR_SUCCESS; |
|---|
| 206 | uint16_t msElapsedTime; |
|---|
| 207 | |
|---|
| 208 | BDBG_ENTER(BHDCPlib_P_CheckRepeaterReady); |
|---|
| 209 | BDBG_ASSERT(hHDCPlib); |
|---|
| 210 | |
|---|
| 211 | |
|---|
| 212 | rc = BHDCPlib_GetReceiverInfo(hHDCPlib, &hHDCPlib->stHdcpConfiguration.RxInfo); |
|---|
| 213 | if (rc != BERR_SUCCESS) |
|---|
| 214 | goto done; |
|---|
| 215 | |
|---|
| 216 | if (hHDCPlib->stHdcpConfiguration.RxInfo.uiRxBCaps & BHDM_HDCP_RxCaps_eKsvFifoReady) |
|---|
| 217 | { |
|---|
| 218 | hHDCPlib->stHdcpStatus.eAuthenticationState = BHDCPlib_State_eRepeaterReady; |
|---|
| 219 | goto done; |
|---|
| 220 | } |
|---|
| 221 | |
|---|
| 222 | /* Calculate elapsed time */ |
|---|
| 223 | msElapsedTime = hHDCPlib->stHdcpConfiguration.uiKsvFifoReadyChecks |
|---|
| 224 | * hHDCPlib->stHdcpConfiguration.msIntervalKsvFifoReadyCheck; |
|---|
| 225 | |
|---|
| 226 | if (msElapsedTime >= 5000) |
|---|
| 227 | { |
|---|
| 228 | BDBG_ERR(("HDCP Auth Failure; Repeater KSV FIFO not ready")) ; |
|---|
| 229 | hHDCPlib->stHdcpStatus.eAuthenticationState = BHDCPlib_State_eRepeaterAuthenticationFailure; |
|---|
| 230 | rc = BHDM_HDCP_REPEATER_FIFO_NOT_READY ; |
|---|
| 231 | goto done; |
|---|
| 232 | |
|---|
| 233 | } |
|---|
| 234 | BDBG_WRN(("Wait for KSV FIFO Ready; timeout in %d ms", (5000 - msElapsedTime))); |
|---|
| 235 | hHDCPlib->stHdcpConfiguration.uiKsvFifoReadyChecks++; |
|---|
| 236 | |
|---|
| 237 | /* Update HDCP Authentication state */ |
|---|
| 238 | hHDCPlib->stHdcpStatus.eAuthenticationState = BHDCPlib_State_eWaitForRepeaterReady; |
|---|
| 239 | |
|---|
| 240 | /* Restart periodic timer for msIntervalKsvFifoReadyCheck */ |
|---|
| 241 | hHDCPlib->bRepeaterReadyTimerExpired = false; |
|---|
| 242 | BTMR_StopTimer(hHDCPlib->hTimer); |
|---|
| 243 | BTMR_StartTimer(hHDCPlib->hTimer, hHDCPlib->stHdcpConfiguration.msIntervalKsvFifoReadyCheck * 1000) ; |
|---|
| 244 | |
|---|
| 245 | done: |
|---|
| 246 | |
|---|
| 247 | /* Clear authentication if error */ |
|---|
| 248 | if (rc != BERR_SUCCESS) |
|---|
| 249 | BHDM_HDCP_ClearAuthentication(hHDCPlib->stDependencies.hHdm); |
|---|
| 250 | |
|---|
| 251 | |
|---|
| 252 | BDBG_LEAVE(BHDCPlib_P_CheckRepeaterReady); |
|---|
| 253 | return rc; |
|---|
| 254 | |
|---|
| 255 | } |
|---|
| 256 | |
|---|
| 257 | |
|---|
| 258 | static void BHDCPlib_P_TimerExpiration_isr (BHDCPlib_Handle hHDCPlib, int parm2) |
|---|
| 259 | { |
|---|
| 260 | BDBG_ENTER(BHDCPlib_P_TimerExpiration_isr); |
|---|
| 261 | BDBG_ASSERT(hHDCPlib); |
|---|
| 262 | BSTD_UNUSED(parm2); |
|---|
| 263 | |
|---|
| 264 | switch (hHDCPlib->stHdcpStatus.eAuthenticationState) |
|---|
| 265 | { |
|---|
| 266 | case BHDCPlib_State_eWaitForReceiverAuthentication : |
|---|
| 267 | hHDCPlib->bR0ReadyTimerExpired = true; |
|---|
| 268 | break ; |
|---|
| 269 | |
|---|
| 270 | case BHDCPlib_State_eWaitForRepeaterReady: |
|---|
| 271 | hHDCPlib->bRepeaterReadyTimerExpired = true; |
|---|
| 272 | break; |
|---|
| 273 | |
|---|
| 274 | default : |
|---|
| 275 | BDBG_WRN(("Unknown Timer expiration...")) ; |
|---|
| 276 | } |
|---|
| 277 | |
|---|
| 278 | BDBG_LEAVE(BHDCPlib_P_TimerExpiration_isr); |
|---|
| 279 | } |
|---|
| 280 | |
|---|
| 281 | |
|---|
| 282 | BERR_Code BHDCPlib_Open(BHDCPlib_Handle *hHDCPlib, const BHDCPlib_Dependencies *pstDependencies) |
|---|
| 283 | { |
|---|
| 284 | BERR_Code rc = BERR_SUCCESS; |
|---|
| 285 | BHDCPlib_Handle hHandle; |
|---|
| 286 | |
|---|
| 287 | |
|---|
| 288 | BDBG_ENTER(BHDCPlib_Open); |
|---|
| 289 | BDBG_ASSERT(pstDependencies->hHdm); |
|---|
| 290 | #if (CONFIG_ENABLE_SCM != 1) |
|---|
| 291 | BDBG_ASSERT(pstDependencies->hHsm); |
|---|
| 292 | #endif |
|---|
| 293 | BDBG_ASSERT(pstDependencies->hTmr); |
|---|
| 294 | |
|---|
| 295 | /* Alloc memory from the system */ |
|---|
| 296 | hHandle = BKNI_Malloc(sizeof(BHDCPlib_P_Handle)); |
|---|
| 297 | if (hHandle == NULL) |
|---|
| 298 | { |
|---|
| 299 | rc = BERR_OUT_OF_SYSTEM_MEMORY; |
|---|
| 300 | BDBG_ERR(("BHDCPlib_Open: BKNI_malloc() failed\n")); |
|---|
| 301 | goto done; |
|---|
| 302 | } |
|---|
| 303 | |
|---|
| 304 | |
|---|
| 305 | #if 0 |
|---|
| 306 | if (!pstDependentData->pfHdcpGetRevokedKsvsCallback) |
|---|
| 307 | { |
|---|
| 308 | BDBG_ERR(("Missing required callback functions")); |
|---|
| 309 | rc = BERR_INVALID_PARAMETER; |
|---|
| 310 | goto done ; |
|---|
| 311 | } |
|---|
| 312 | #endif |
|---|
| 313 | |
|---|
| 314 | BKNI_Memcpy(&hHandle->stDependencies, pstDependencies, sizeof(BHDCPlib_Dependencies)) ; |
|---|
| 315 | hHandle->hTmr = pstDependencies->hTmr ; |
|---|
| 316 | |
|---|
| 317 | hHandle->stTmrSettings.type = BTMR_Type_eCountDown ; |
|---|
| 318 | hHandle->stTmrSettings.cb_isr = (BTMR_CallbackFunc) BHDCPlib_P_TimerExpiration_isr ; |
|---|
| 319 | hHandle->stTmrSettings.pParm1 = hHandle; |
|---|
| 320 | hHandle->stTmrSettings.parm2 = 0 ; |
|---|
| 321 | hHandle->stTmrSettings.exclusive = false ; |
|---|
| 322 | |
|---|
| 323 | rc = BTMR_CreateTimer(hHandle->hTmr, &hHandle->hTimer, &hHandle->stTmrSettings) ; |
|---|
| 324 | if(rc != BERR_SUCCESS) |
|---|
| 325 | { |
|---|
| 326 | rc = BERR_TRACE(BERR_LEAKED_RESOURCE); |
|---|
| 327 | goto done ; |
|---|
| 328 | } |
|---|
| 329 | |
|---|
| 330 | /* Initialize HDCP authentication state, error status */ |
|---|
| 331 | hHandle->stHdcpStatus.eAuthenticationState = BHDCPlib_State_eUnauthenticated; |
|---|
| 332 | hHandle->stHdcpStatus.eHdcpError = BHDCPlib_HdcpError_eSuccess; |
|---|
| 333 | |
|---|
| 334 | /* Set default HDCP configuration information*/ |
|---|
| 335 | BHDCPlib_GetDefaultConfiguration(&hHandle->stHdcpConfiguration); |
|---|
| 336 | |
|---|
| 337 | /* Initialize revoked KSV list */ |
|---|
| 338 | hHandle->RevokedKsvList.Ksvs = NULL; |
|---|
| 339 | hHandle->RevokedKsvList.uiNumRevokedKsvs = 0; |
|---|
| 340 | |
|---|
| 341 | done: |
|---|
| 342 | if (rc != BERR_SUCCESS) |
|---|
| 343 | { |
|---|
| 344 | if (!hHandle) |
|---|
| 345 | { |
|---|
| 346 | BKNI_Free(hHandle); |
|---|
| 347 | hHandle=NULL; |
|---|
| 348 | } |
|---|
| 349 | } |
|---|
| 350 | |
|---|
| 351 | *hHDCPlib = hHandle; |
|---|
| 352 | |
|---|
| 353 | BDBG_LEAVE(BHDCPlib_Open); |
|---|
| 354 | return rc ; |
|---|
| 355 | |
|---|
| 356 | } |
|---|
| 357 | |
|---|
| 358 | |
|---|
| 359 | BERR_Code BHDCPlib_Close(BHDCPlib_Handle hHDCPlib) |
|---|
| 360 | { |
|---|
| 361 | BERR_Code rc = BERR_SUCCESS; |
|---|
| 362 | |
|---|
| 363 | BDBG_ENTER(BHDCPlib_Close); |
|---|
| 364 | BDBG_ASSERT(hHDCPlib); |
|---|
| 365 | |
|---|
| 366 | rc = BTMR_DestroyTimer(hHDCPlib->hTimer); |
|---|
| 367 | if (rc != BERR_SUCCESS) |
|---|
| 368 | BDBG_ERR(("Error destroying timer")); |
|---|
| 369 | |
|---|
| 370 | |
|---|
| 371 | /* free memory associated with the Revoked KSV list, if any */ |
|---|
| 372 | if (hHDCPlib->RevokedKsvList.Ksvs) |
|---|
| 373 | { |
|---|
| 374 | BKNI_Free(hHDCPlib->RevokedKsvList.Ksvs); |
|---|
| 375 | hHDCPlib->RevokedKsvList.Ksvs = NULL; |
|---|
| 376 | hHDCPlib->RevokedKsvList.uiNumRevokedKsvs = 0; |
|---|
| 377 | } |
|---|
| 378 | |
|---|
| 379 | /* free memory associated with the HDMIlib Handle */ |
|---|
| 380 | BKNI_Memset(hHDCPlib, 0, sizeof(BHDCPlib_P_Handle)) ; |
|---|
| 381 | BKNI_Free( (void *) hHDCPlib) ; |
|---|
| 382 | |
|---|
| 383 | |
|---|
| 384 | BDBG_LEAVE(BHDCPlib_Close); |
|---|
| 385 | return rc; |
|---|
| 386 | } |
|---|
| 387 | |
|---|
| 388 | |
|---|
| 389 | BERR_Code BHDCPlib_GetDefaultDependencies(BHDCPlib_Dependencies *pDefaultDependencies) |
|---|
| 390 | { |
|---|
| 391 | BERR_Code rc = BERR_SUCCESS; |
|---|
| 392 | |
|---|
| 393 | BDBG_ENTER(BHDCPlib_GetDefaultDependencies); |
|---|
| 394 | |
|---|
| 395 | /* Set all Dependencies to NULL */ |
|---|
| 396 | BKNI_Memset(pDefaultDependencies, 0, sizeof(*pDefaultDependencies)); |
|---|
| 397 | |
|---|
| 398 | BDBG_LEAVE(BHDCPlib_GetDefaultDependencies); |
|---|
| 399 | return rc; |
|---|
| 400 | } |
|---|
| 401 | |
|---|
| 402 | |
|---|
| 403 | BERR_Code BHDCPlib_InitializeReceiverAuthentication(BHDCPlib_Handle hHDCPlib) |
|---|
| 404 | { |
|---|
| 405 | BERR_Code rc = BERR_SUCCESS; |
|---|
| 406 | |
|---|
| 407 | BDBG_ENTER(BHDCPlib_InitializeReceiverAuthentication) ; |
|---|
| 408 | BDBG_ASSERT(hHDCPlib); |
|---|
| 409 | BDBG_ASSERT(hHDCPlib->stDependencies.hHdm) ; |
|---|
| 410 | |
|---|
| 411 | /* get revoked list */ |
|---|
| 412 | if (!hHDCPlib->stDependencies.pfHdcpGetRevokedKsvsCallback) |
|---|
| 413 | { |
|---|
| 414 | BDBG_WRN(("No Revoked KSV Callback Installed")) ; |
|---|
| 415 | } |
|---|
| 416 | else |
|---|
| 417 | { |
|---|
| 418 | BHDCPlib_RevokedKsvList tmpRevokedKSVs; |
|---|
| 419 | |
|---|
| 420 | hHDCPlib->stDependencies.pfHdcpGetRevokedKsvsCallback( |
|---|
| 421 | hHDCPlib->stDependencies.pSysDevice, |
|---|
| 422 | hHDCPlib->stDependencies.iGetRevokedKsvParam2, |
|---|
| 423 | &tmpRevokedKSVs) ; |
|---|
| 424 | |
|---|
| 425 | BHDCPlib_SetRevokedKSVs(hHDCPlib, &tmpRevokedKSVs); |
|---|
| 426 | } |
|---|
| 427 | |
|---|
| 428 | /* Retrieve Receiver information before starting the authentication process */ |
|---|
| 429 | rc = BHDCPlib_GetReceiverInfo(hHDCPlib, &hHDCPlib->stHdcpConfiguration.RxInfo); |
|---|
| 430 | if (rc != BERR_SUCCESS) |
|---|
| 431 | { |
|---|
| 432 | BDBG_ERR(("Error getting receiver info")); |
|---|
| 433 | goto done; |
|---|
| 434 | } |
|---|
| 435 | |
|---|
| 436 | /* Read the Bksv from the Rx, compare revoked list against retrieved Rx information */ |
|---|
| 437 | rc = BHDM_HDCP_ReadRxBksv(hHDCPlib->stDependencies.hHdm, |
|---|
| 438 | (const uint8_t *) hHDCPlib->RevokedKsvList.Ksvs, |
|---|
| 439 | hHDCPlib->RevokedKsvList.uiNumRevokedKsvs); |
|---|
| 440 | if (rc != BERR_SUCCESS) |
|---|
| 441 | goto done; |
|---|
| 442 | |
|---|
| 443 | |
|---|
| 444 | /* Update the RxBksv in BHDCPlib_Configuration */ |
|---|
| 445 | rc = BHDM_HDCP_GetRxKsv(hHDCPlib->stDependencies.hHdm, (uint8_t *) hHDCPlib->stHdcpConfiguration.RxInfo.RxBksv); |
|---|
| 446 | if (rc != BERR_SUCCESS) |
|---|
| 447 | goto done; |
|---|
| 448 | |
|---|
| 449 | |
|---|
| 450 | /* Generate/Write the Authentication An value */ |
|---|
| 451 | rc = BHDM_HDCP_GenerateAn(hHDCPlib->stDependencies.hHdm, hHDCPlib->stHdcpConfiguration.eAnSelection) ; |
|---|
| 452 | if (rc != BERR_SUCCESS) |
|---|
| 453 | goto done; |
|---|
| 454 | |
|---|
| 455 | |
|---|
| 456 | /* Write the Tx Aksv to the Receiver */ |
|---|
| 457 | rc = BHDM_HDCP_WriteTxAksvToRx(hHDCPlib->stDependencies.hHdm, hHDCPlib->stHdcpConfiguration.TxKeySet.TxAksv); |
|---|
| 458 | if (rc != BERR_SUCCESS) |
|---|
| 459 | goto done; |
|---|
| 460 | |
|---|
| 461 | |
|---|
| 462 | /* load the transmitter HDCP Keys */ |
|---|
| 463 | rc = BHDM_HDCP_EnableSerialKeyLoad(hHDCPlib->stDependencies.hHdm); |
|---|
| 464 | if (rc != BERR_SUCCESS) |
|---|
| 465 | goto done; |
|---|
| 466 | |
|---|
| 467 | |
|---|
| 468 | rc = BHDCPlib_FastLoadEncryptedHdcpKeys(hHDCPlib); |
|---|
| 469 | if (rc != BERR_SUCCESS) |
|---|
| 470 | goto done; |
|---|
| 471 | |
|---|
| 472 | |
|---|
| 473 | /* Initiate timer countdown for msWaitForR0 (default 100ms) before setting Receiver Ready */ |
|---|
| 474 | hHDCPlib->bR0ReadyTimerExpired = false; |
|---|
| 475 | BTMR_StopTimer(hHDCPlib->hTimer); |
|---|
| 476 | BTMR_StartTimer(hHDCPlib->hTimer, hHDCPlib->stHdcpConfiguration.msWaitForR0 * 1000) ; |
|---|
| 477 | |
|---|
| 478 | /* Update HDCP authentication state */ |
|---|
| 479 | hHDCPlib->stHdcpStatus.eAuthenticationState = BHDCPlib_State_eWaitForReceiverAuthentication; |
|---|
| 480 | |
|---|
| 481 | done: |
|---|
| 482 | |
|---|
| 483 | if (rc != BERR_SUCCESS) |
|---|
| 484 | hHDCPlib->stHdcpStatus.eAuthenticationState = BHDCPlib_State_eUnauthenticated; |
|---|
| 485 | |
|---|
| 486 | BDBG_LEAVE(BHDCPlib_InitializeReceiverAuthentication) ; |
|---|
| 487 | return rc ; |
|---|
| 488 | |
|---|
| 489 | } |
|---|
| 490 | |
|---|
| 491 | |
|---|
| 492 | |
|---|
| 493 | BERR_Code BHDCPlib_AuthenticateReceiver(BHDCPlib_Handle hHDCPlib) |
|---|
| 494 | { |
|---|
| 495 | BERR_Code rc = BERR_SUCCESS; |
|---|
| 496 | |
|---|
| 497 | BDBG_ENTER(BHDCPlib_AuthenticateReceiver) ; |
|---|
| 498 | BDBG_ASSERT(hHDCPlib); |
|---|
| 499 | |
|---|
| 500 | |
|---|
| 501 | /* Authenticate the Link */ |
|---|
| 502 | rc = BHDM_HDCP_AuthenticateLink(hHDCPlib->stDependencies.hHdm) ; |
|---|
| 503 | if ( rc != BERR_SUCCESS) |
|---|
| 504 | { |
|---|
| 505 | hHDCPlib->stHdcpStatus.eAuthenticationState = BHDCPlib_State_eR0LinkFailure; |
|---|
| 506 | goto done; |
|---|
| 507 | } |
|---|
| 508 | |
|---|
| 509 | hHDCPlib->stHdcpStatus.eAuthenticationState = BHDCPlib_State_eReceiverAuthenticated; |
|---|
| 510 | |
|---|
| 511 | done: |
|---|
| 512 | |
|---|
| 513 | BDBG_LEAVE(BHDCPlib_AuthenticateReceiver) ; |
|---|
| 514 | return rc; |
|---|
| 515 | |
|---|
| 516 | } |
|---|
| 517 | |
|---|
| 518 | |
|---|
| 519 | |
|---|
| 520 | BERR_Code BHDCPlib_InitializeRepeaterAuthentication(BHDCPlib_Handle hHDCPlib) |
|---|
| 521 | { |
|---|
| 522 | BERR_Code rc = BERR_SUCCESS; |
|---|
| 523 | |
|---|
| 524 | BDBG_ENTER(BHDCPlib_InitializeRepeaterAuthentication) ; |
|---|
| 525 | BDBG_ASSERT(hHDCPlib); |
|---|
| 526 | |
|---|
| 527 | /* Set default configuration */ |
|---|
| 528 | hHDCPlib->stHdcpConfiguration.msIntervalKsvFifoReadyCheck = 100; |
|---|
| 529 | hHDCPlib->stHdcpConfiguration.uiKsvFifoReadyChecks = 1; |
|---|
| 530 | |
|---|
| 531 | /* Enable/Initiate periodic timer once every msIntervalKsvFifoReadyCheck */ |
|---|
| 532 | hHDCPlib->bRepeaterReadyTimerExpired = false; |
|---|
| 533 | BTMR_StopTimer(hHDCPlib->hTimer); |
|---|
| 534 | BTMR_StartTimer(hHDCPlib->hTimer, hHDCPlib->stHdcpConfiguration.msIntervalKsvFifoReadyCheck * 1000) ; |
|---|
| 535 | |
|---|
| 536 | /* Update state machine */ |
|---|
| 537 | hHDCPlib->stHdcpStatus.eAuthenticationState = BHDCPlib_State_eWaitForRepeaterReady; |
|---|
| 538 | |
|---|
| 539 | BDBG_LEAVE(BHDCPlib_InitializeRepeaterAuthentication) ; |
|---|
| 540 | return rc ; |
|---|
| 541 | } |
|---|
| 542 | |
|---|
| 543 | |
|---|
| 544 | |
|---|
| 545 | BERR_Code BHDCPlib_AuthenticateRepeater(BHDCPlib_Handle hHDCPlib) |
|---|
| 546 | { |
|---|
| 547 | BERR_Code rc = BERR_SUCCESS; |
|---|
| 548 | uint16_t BStatus; |
|---|
| 549 | uint8_t RepeaterLevels; |
|---|
| 550 | uint8_t DeviceCount; |
|---|
| 551 | uint16_t uiNumKsvBytes; |
|---|
| 552 | uint8_t KsvListMemoryAllocated = 0 ; |
|---|
| 553 | uint8_t *KsvFifoList = NULL ; |
|---|
| 554 | |
|---|
| 555 | BDBG_ENTER(BHDCPlib_AuthenticateRepeater) ; |
|---|
| 556 | BDBG_ASSERT(hHDCPlib); |
|---|
| 557 | |
|---|
| 558 | |
|---|
| 559 | /* check Repeater Values */ |
|---|
| 560 | BHDCPLIB_CHECK_RC(rc, |
|---|
| 561 | BHDM_HDCP_GetRxStatus(hHDCPlib->stDependencies.hHdm, &BStatus)) ; |
|---|
| 562 | BHDCPLIB_CHECK_RC(rc, |
|---|
| 563 | BHDM_HDCP_GetRepeaterDepth(hHDCPlib->stDependencies.hHdm, &RepeaterLevels)) ; |
|---|
| 564 | BHDCPLIB_CHECK_RC(rc, |
|---|
| 565 | BHDM_HDCP_GetRepeaterDeviceCount(hHDCPlib->stDependencies.hHdm, &DeviceCount)) ; |
|---|
| 566 | |
|---|
| 567 | BDBG_MSG(("RXStatus: %X, Depth: %d, Devices: %d", |
|---|
| 568 | BStatus, RepeaterLevels, DeviceCount)) ; |
|---|
| 569 | |
|---|
| 570 | |
|---|
| 571 | /* check if the number of repeater levels has been exceeded */ |
|---|
| 572 | if (BStatus & BHDM_HDCP_RxStatus_eMaxRepeatersExceeded) |
|---|
| 573 | { |
|---|
| 574 | BDBG_ERR(("%d Levels of Repeaters exceed the MAX allowed of %d", |
|---|
| 575 | RepeaterLevels, BHDM_HDCP_REPEATER_MAX_DEPTH )) ; |
|---|
| 576 | rc = BHDM_HDCP_REPEATER_DEPTH_EXCEEDED ; |
|---|
| 577 | goto done; |
|---|
| 578 | } |
|---|
| 579 | |
|---|
| 580 | /* check if the number of receiver devices has been exceeded */ |
|---|
| 581 | if (BStatus & BHDM_HDCP_RxStatus_eMaxDevicesExceeded) |
|---|
| 582 | { |
|---|
| 583 | BDBG_ERR(("Number of Devices: %d exceeds the MAX allowed of %d", |
|---|
| 584 | DeviceCount, BHDM_HDCP_REPEATER_MAX_DEVICE_COUNT )) ; |
|---|
| 585 | rc = BHDM_HDCP_RX_DEVICES_EXCEEDED ; |
|---|
| 586 | goto done ; |
|---|
| 587 | } |
|---|
| 588 | |
|---|
| 589 | /* initialize the Repeater Authentication */ |
|---|
| 590 | BHDM_HDCP_InitializeRepeaterAuthentication(hHDCPlib->stDependencies.hHdm); |
|---|
| 591 | |
|---|
| 592 | if (DeviceCount) |
|---|
| 593 | { |
|---|
| 594 | /* allocate a buffer to hold the Ksv List */ |
|---|
| 595 | uiNumKsvBytes = (uint16_t) (DeviceCount * BHDM_HDCP_KSV_LENGTH) ; |
|---|
| 596 | KsvFifoList = (uint8_t *) BKNI_Malloc(sizeof(uint8_t) * uiNumKsvBytes) ; |
|---|
| 597 | KsvListMemoryAllocated = 1 ; |
|---|
| 598 | |
|---|
| 599 | /* read the Ksv List */ |
|---|
| 600 | /* pass the revoked list for checking against downstream Rx devices */ |
|---|
| 601 | BHDCPLIB_CHECK_RC(rc, |
|---|
| 602 | BHDM_HDCP_ReadRxRepeaterKsvFIFO(hHDCPlib->stDependencies.hHdm, |
|---|
| 603 | KsvFifoList, DeviceCount, |
|---|
| 604 | (uint8_t *) &hHDCPlib->RevokedKsvList.Ksvs, |
|---|
| 605 | (uint16_t) hHDCPlib->RevokedKsvList.uiNumRevokedKsvs)) ; |
|---|
| 606 | |
|---|
| 607 | /* write the Ksvs from the Rx (Repeater) to the Transmitter core for verification */ |
|---|
| 608 | BHDCPLIB_CHECK_RC(rc, |
|---|
| 609 | BHDM_HDCP_WriteTxKsvFIFO(hHDCPlib->stDependencies.hHdm, |
|---|
| 610 | KsvFifoList, DeviceCount)) ; |
|---|
| 611 | |
|---|
| 612 | } |
|---|
| 613 | else /* handle zero devices attached to repeater */ |
|---|
| 614 | { |
|---|
| 615 | #if BHDM_CONFIG_DISABLE_HDCP_AUTH_REPEATER_DEVCOUNT0 |
|---|
| 616 | /* do not allow authentication with repeaters that have device count of 0 */ |
|---|
| 617 | BDBG_WRN(("Auth Disabled for Repeaters with Device Count of 0")) ; |
|---|
| 618 | rc = BHDM_HDCP_REPEATER_DEVCOUNT_0 ; |
|---|
| 619 | goto done; |
|---|
| 620 | #else |
|---|
| 621 | /* force V calculation for repeater with zero attached devices */ |
|---|
| 622 | BHDM_HDCP_ForceVCalculation(hHDCPlib->stDependencies.hHdm) ; |
|---|
| 623 | #endif |
|---|
| 624 | |
|---|
| 625 | } |
|---|
| 626 | |
|---|
| 627 | /* check SHA-1 Hash Verification (V).... */ |
|---|
| 628 | BHDCPLIB_CHECK_RC(rc, |
|---|
| 629 | BHDM_HDCP_RepeaterAuthenticateLink(hHDCPlib->stDependencies.hHdm, |
|---|
| 630 | &hHDCPlib->stHdcpConfiguration.RxInfo.uiIsAuthenticated)) ; |
|---|
| 631 | |
|---|
| 632 | if (!hHDCPlib->stHdcpConfiguration.RxInfo.uiIsAuthenticated) |
|---|
| 633 | { |
|---|
| 634 | BDBG_ERR(("Repeater failed to authenticate")) ; |
|---|
| 635 | rc = BHDM_HDCP_REPEATER_AUTH_ERROR ; |
|---|
| 636 | goto done ; |
|---|
| 637 | } |
|---|
| 638 | |
|---|
| 639 | hHDCPlib->stHdcpStatus.eAuthenticationState = BHDCPlib_State_eLinkAuthenticated; |
|---|
| 640 | |
|---|
| 641 | done: |
|---|
| 642 | /* release allocated memory for Ksv list */ |
|---|
| 643 | if (KsvListMemoryAllocated) |
|---|
| 644 | BKNI_Free(KsvFifoList) ; |
|---|
| 645 | |
|---|
| 646 | if (rc != BERR_SUCCESS) |
|---|
| 647 | hHDCPlib->stHdcpStatus.eAuthenticationState = BHDCPlib_State_eRepeaterAuthenticationFailure; |
|---|
| 648 | |
|---|
| 649 | BDBG_LEAVE(BHDCPlib_AuthenticateRepeater) ; |
|---|
| 650 | return rc ; |
|---|
| 651 | } |
|---|
| 652 | |
|---|
| 653 | |
|---|
| 654 | BERR_Code BHDCPlib_TransmitEncrypted(BHDCPlib_Handle hHDCPlib) |
|---|
| 655 | { |
|---|
| 656 | BERR_Code rc = BERR_SUCCESS; |
|---|
| 657 | |
|---|
| 658 | BDBG_ENTER(BHDCPlib_TransmitEncrypted); |
|---|
| 659 | BDBG_ASSERT(hHDCPlib); |
|---|
| 660 | |
|---|
| 661 | rc = BHDM_HDCP_XmitEncrypted(hHDCPlib->stDependencies.hHdm); |
|---|
| 662 | if (rc != BERR_SUCCESS) |
|---|
| 663 | goto done; |
|---|
| 664 | |
|---|
| 665 | hHDCPlib->stHdcpStatus.eAuthenticationState = BHDCPlib_State_eEncryptionEnabled; |
|---|
| 666 | |
|---|
| 667 | done: |
|---|
| 668 | |
|---|
| 669 | BDBG_LEAVE(BHDCPlib_TransmitEncrypted); |
|---|
| 670 | return rc; |
|---|
| 671 | } |
|---|
| 672 | |
|---|
| 673 | BERR_Code BHDCPlib_TransmitClear(BHDCPlib_Handle hHDCPlib) |
|---|
| 674 | { |
|---|
| 675 | BERR_Code rc = BERR_SUCCESS; |
|---|
| 676 | |
|---|
| 677 | BDBG_ENTER(BHDCPlib_TransmitClear); |
|---|
| 678 | BDBG_ASSERT(hHDCPlib); |
|---|
| 679 | |
|---|
| 680 | rc = BHDM_HDCP_XmitClear(hHDCPlib->stDependencies.hHdm); |
|---|
| 681 | if (rc != BERR_SUCCESS) |
|---|
| 682 | goto done; |
|---|
| 683 | |
|---|
| 684 | hHDCPlib->stHdcpStatus.eAuthenticationState = BHDCPlib_State_eUnauthenticated; |
|---|
| 685 | |
|---|
| 686 | done: |
|---|
| 687 | |
|---|
| 688 | BDBG_LEAVE(BHDCPlib_TransmitClear); |
|---|
| 689 | return rc; |
|---|
| 690 | } |
|---|
| 691 | |
|---|
| 692 | void BHDCPlib_ProcessEvent(BHDCPlib_Handle hHDCPlib, BHDCPlib_Event *stHdmiEvent) |
|---|
| 693 | { |
|---|
| 694 | |
|---|
| 695 | BERR_Code rc ; |
|---|
| 696 | uint8_t ucRxSense; |
|---|
| 697 | uint8_t ucDeviceAttached; |
|---|
| 698 | uint8_t ucErrorDetected = 0 ; |
|---|
| 699 | |
|---|
| 700 | BDBG_ENTER(BHDCPlib_ProcessEvent); |
|---|
| 701 | |
|---|
| 702 | switch (stHdmiEvent->event) |
|---|
| 703 | { |
|---|
| 704 | case BHDM_EventHDCPRiValue: |
|---|
| 705 | if (BHDM_HDCP_RiLinkIntegrityCheck(hHDCPlib->stDependencies.hHdm) != BERR_SUCCESS) |
|---|
| 706 | { |
|---|
| 707 | hHDCPlib->stHdcpStatus.eAuthenticationState = BHDCPlib_State_eRiLinkIntegrityFailure; |
|---|
| 708 | ucErrorDetected = 1 ; |
|---|
| 709 | } |
|---|
| 710 | |
|---|
| 711 | break; |
|---|
| 712 | |
|---|
| 713 | case BHDM_EventHDCPPjValue: |
|---|
| 714 | if (BHDM_HDCP_PjLinkIntegrityCheck(hHDCPlib->stDependencies.hHdm) != BERR_SUCCESS) |
|---|
| 715 | { |
|---|
| 716 | hHDCPlib->stHdcpStatus.eAuthenticationState = BHDCPlib_State_ePjLinkIntegrityFailure; |
|---|
| 717 | ucErrorDetected = 1 ; |
|---|
| 718 | } |
|---|
| 719 | |
|---|
| 720 | break; |
|---|
| 721 | |
|---|
| 722 | case BHDM_EventHDCPRepeater: |
|---|
| 723 | hHDCPlib->stHdcpStatus.eAuthenticationState = BHDCPlib_State_eRepeaterAuthenticationFailure; |
|---|
| 724 | ucErrorDetected = 1 ; |
|---|
| 725 | break; |
|---|
| 726 | |
|---|
| 727 | case BHDM_EventHotPlug: |
|---|
| 728 | rc = BHDM_RxDeviceAttached(hHDCPlib->stDependencies.hHdm, &ucDeviceAttached) ; |
|---|
| 729 | |
|---|
| 730 | if (!ucDeviceAttached) |
|---|
| 731 | hHDCPlib->stHdcpStatus.eAuthenticationState = |
|---|
| 732 | BHDCPlib_State_eUnPowered; |
|---|
| 733 | else |
|---|
| 734 | hHDCPlib->stHdcpStatus.eAuthenticationState = |
|---|
| 735 | BHDCPlib_State_eUnauthenticated; |
|---|
| 736 | |
|---|
| 737 | break; |
|---|
| 738 | |
|---|
| 739 | default: |
|---|
| 740 | BDBG_WRN(("Invalid Event")) ; |
|---|
| 741 | break; |
|---|
| 742 | } |
|---|
| 743 | |
|---|
| 744 | if (ucErrorDetected) |
|---|
| 745 | { |
|---|
| 746 | rc = BHDM_GetReceiverSense(hHDCPlib->stDependencies.hHdm, &ucRxSense); |
|---|
| 747 | if (!ucRxSense) |
|---|
| 748 | { |
|---|
| 749 | BDBG_WRN(("HdcpLibState: %d generated due to Rx powered off", |
|---|
| 750 | hHDCPlib->stHdcpStatus.eAuthenticationState)) ; |
|---|
| 751 | hHDCPlib->stHdcpStatus.eAuthenticationState = BHDCPlib_State_eUnPowered; |
|---|
| 752 | } |
|---|
| 753 | } |
|---|
| 754 | |
|---|
| 755 | BDBG_LEAVE(BHDCPlib_ProcessEvent); |
|---|
| 756 | return; |
|---|
| 757 | } |
|---|
| 758 | |
|---|
| 759 | |
|---|
| 760 | BERR_Code BHDCPlib_SetRevokedKSVs(BHDCPlib_Handle hHDCPlib, BHDCPlib_RevokedKsvList *stKsvList) |
|---|
| 761 | { |
|---|
| 762 | BERR_Code rc = BERR_SUCCESS; |
|---|
| 763 | |
|---|
| 764 | BDBG_ENTER(BHDCPlib_SetRevokedKSVs); |
|---|
| 765 | BDBG_ASSERT(hHDCPlib); |
|---|
| 766 | |
|---|
| 767 | |
|---|
| 768 | if (hHDCPlib->RevokedKsvList.Ksvs) |
|---|
| 769 | { |
|---|
| 770 | BKNI_Free(hHDCPlib->RevokedKsvList.Ksvs); |
|---|
| 771 | hHDCPlib->RevokedKsvList.Ksvs = NULL; |
|---|
| 772 | hHDCPlib->RevokedKsvList.uiNumRevokedKsvs = 0; |
|---|
| 773 | } |
|---|
| 774 | |
|---|
| 775 | if (!stKsvList->uiNumRevokedKsvs) |
|---|
| 776 | { |
|---|
| 777 | BDBG_WRN(("No Revoked KSVs specified.")); |
|---|
| 778 | goto done; |
|---|
| 779 | } |
|---|
| 780 | |
|---|
| 781 | /* Store the Revoked KSVs in the handle */ |
|---|
| 782 | hHDCPlib->RevokedKsvList.Ksvs = |
|---|
| 783 | BKNI_Malloc(sizeof(uint8_t) * stKsvList->uiNumRevokedKsvs * BAVC_HDMI_HDCP_KSV_LENGTH); |
|---|
| 784 | |
|---|
| 785 | BKNI_Memcpy(hHDCPlib->RevokedKsvList.Ksvs, stKsvList->Ksvs, |
|---|
| 786 | (sizeof(uint8_t) * stKsvList->uiNumRevokedKsvs * BAVC_HDMI_HDCP_KSV_LENGTH)); |
|---|
| 787 | |
|---|
| 788 | hHDCPlib->RevokedKsvList.uiNumRevokedKsvs = stKsvList->uiNumRevokedKsvs; |
|---|
| 789 | |
|---|
| 790 | done: |
|---|
| 791 | BDBG_LEAVE(BHDCPlib_SetRevokedKSVs); |
|---|
| 792 | return rc; |
|---|
| 793 | } |
|---|
| 794 | |
|---|
| 795 | |
|---|
| 796 | BERR_Code BHDCPlib_SetConfiguration(BHDCPlib_Handle hHDCPlib, BHDCPlib_Configuration * stHdcpConfiguration) |
|---|
| 797 | { |
|---|
| 798 | BDBG_ENTER(BHDCPlib_SetConfiguration); |
|---|
| 799 | BDBG_ASSERT(hHDCPlib); |
|---|
| 800 | |
|---|
| 801 | |
|---|
| 802 | /* Copy Hdcp Link data into HDMlib handle */ |
|---|
| 803 | BKNI_Memcpy(&hHDCPlib->stHdcpConfiguration, stHdcpConfiguration, sizeof(BHDCPlib_Configuration)); |
|---|
| 804 | |
|---|
| 805 | |
|---|
| 806 | BDBG_LEAVE(BHDCPlib_SetConfiguration); |
|---|
| 807 | return BERR_SUCCESS; |
|---|
| 808 | } |
|---|
| 809 | |
|---|
| 810 | BERR_Code BHDCPlib_GetDefaultConfiguration(BHDCPlib_Configuration *stHdcpConfiguration) |
|---|
| 811 | { |
|---|
| 812 | BDBG_ENTER(BHDCPlib_GetDefaultConfiguration); |
|---|
| 813 | BDBG_ASSERT(stHdcpConfiguration); |
|---|
| 814 | |
|---|
| 815 | /* Copy default Hdcp configuration */ |
|---|
| 816 | BKNI_Memcpy(stHdcpConfiguration, &stHdcpDefaultConfiguration, sizeof(BHDCPlib_Configuration)); |
|---|
| 817 | |
|---|
| 818 | BDBG_LEAVE(BHDCPlib_GetDefaultConfiguration); |
|---|
| 819 | return BERR_SUCCESS; |
|---|
| 820 | } |
|---|
| 821 | |
|---|
| 822 | BERR_Code BHDCPlib_GetConfiguration(BHDCPlib_Handle hHDCPlib, BHDCPlib_Configuration *stHdcpConfiguration) |
|---|
| 823 | { |
|---|
| 824 | BDBG_ENTER(BHDCPlib_GetConfiguration); |
|---|
| 825 | BDBG_ASSERT(hHDCPlib); |
|---|
| 826 | |
|---|
| 827 | |
|---|
| 828 | /* Copy Hdcp Link data from HDCPlib handle */ |
|---|
| 829 | BKNI_Memcpy(stHdcpConfiguration, &hHDCPlib->stHdcpConfiguration, sizeof(BHDCPlib_Configuration)); |
|---|
| 830 | |
|---|
| 831 | |
|---|
| 832 | BDBG_LEAVE(BHDCPlib_GetConfiguration); |
|---|
| 833 | return BERR_SUCCESS; |
|---|
| 834 | } |
|---|
| 835 | |
|---|
| 836 | |
|---|
| 837 | BERR_Code BHDCPlib_GetReceiverInfo(BHDCPlib_Handle hHDCPlib, BHDCPlib_RxInfo *stRxHdcpInfo) |
|---|
| 838 | { |
|---|
| 839 | BERR_Code rc = BERR_SUCCESS; |
|---|
| 840 | |
|---|
| 841 | BDBG_ENTER(BHDCPlib_GetReceiverInfo); |
|---|
| 842 | BDBG_ASSERT(hHDCPlib); |
|---|
| 843 | |
|---|
| 844 | |
|---|
| 845 | /* Retrieve RxBCaps */ |
|---|
| 846 | rc = BHDM_HDCP_GetRxCaps(hHDCPlib->stDependencies.hHdm, |
|---|
| 847 | &stRxHdcpInfo->uiRxBCaps) ; |
|---|
| 848 | if (rc != BERR_SUCCESS) |
|---|
| 849 | { |
|---|
| 850 | BDBG_ERR(("Error getting Rx BCaps")); |
|---|
| 851 | goto done; |
|---|
| 852 | } |
|---|
| 853 | |
|---|
| 854 | /* Retrieve the RxBksv */ |
|---|
| 855 | rc = BHDM_HDCP_GetRxKsv(hHDCPlib->stDependencies.hHdm, |
|---|
| 856 | (uint8_t *) stRxHdcpInfo->RxBksv); |
|---|
| 857 | if (rc != BERR_SUCCESS) |
|---|
| 858 | { |
|---|
| 859 | BDBG_ERR(("Error getting Rx BCaps")); |
|---|
| 860 | goto done; |
|---|
| 861 | } |
|---|
| 862 | |
|---|
| 863 | /* Check for Repeater */ |
|---|
| 864 | stRxHdcpInfo->bIsHdcpRepeater = |
|---|
| 865 | stRxHdcpInfo->uiRxBCaps & BHDM_HDCP_RxCaps_eHdcpRepeater ; |
|---|
| 866 | |
|---|
| 867 | done: |
|---|
| 868 | |
|---|
| 869 | BDBG_LEAVE(BHDCPlib_GetReceiverInfo); |
|---|
| 870 | return rc; |
|---|
| 871 | |
|---|
| 872 | } |
|---|
| 873 | |
|---|
| 874 | |
|---|
| 875 | BERR_Code BHDCPlib_GetAuthenticationState(BHDCPlib_Handle hHDCPlib, BHDCPlib_State *eAuthenticationState) |
|---|
| 876 | { |
|---|
| 877 | BDBG_ENTER(BHDCPlib_GetAuthenticationState); |
|---|
| 878 | BDBG_ASSERT(hHDCPlib); |
|---|
| 879 | |
|---|
| 880 | /* Retrieve the current HDCP authentication state */ |
|---|
| 881 | *eAuthenticationState = hHDCPlib->stHdcpStatus.eAuthenticationState; |
|---|
| 882 | |
|---|
| 883 | BDBG_LEAVE(BHDCPlib_GetAuthenticationState); |
|---|
| 884 | return BERR_SUCCESS; |
|---|
| 885 | } |
|---|
| 886 | |
|---|
| 887 | |
|---|
| 888 | BERR_Code BHDCPlib_GetHdcpStatus(BHDCPlib_Handle hHDCPlib, BHDCPlib_Status *stHdcpStatus) |
|---|
| 889 | { |
|---|
| 890 | BDBG_ENTER(BHDCPlib_GetHdcpStatus); |
|---|
| 891 | BDBG_ASSERT(hHDCPlib); |
|---|
| 892 | |
|---|
| 893 | /* Retrieve the current HDCP status */ |
|---|
| 894 | BKNI_Memcpy(stHdcpStatus, &hHDCPlib->stHdcpStatus, sizeof(BHDCPlib_Status)); |
|---|
| 895 | |
|---|
| 896 | |
|---|
| 897 | BDBG_LEAVE(BHDCPlib_GetHdcpStatus); |
|---|
| 898 | return BERR_SUCCESS; |
|---|
| 899 | } |
|---|
| 900 | |
|---|
| 901 | |
|---|
| 902 | bool BHDCPlib_LinkReadyForEncryption(BHDCPlib_Handle hHDCPlib) |
|---|
| 903 | { |
|---|
| 904 | bool brc = false; |
|---|
| 905 | |
|---|
| 906 | BDBG_ENTER(BHDCPlib_LinkReadyForEncryption); |
|---|
| 907 | BDBG_ASSERT(hHDCPlib); |
|---|
| 908 | |
|---|
| 909 | if (hHDCPlib->stHdcpStatus.eAuthenticationState == BHDCPlib_State_eLinkAuthenticated) |
|---|
| 910 | brc = true; |
|---|
| 911 | |
|---|
| 912 | |
|---|
| 913 | BDBG_LEAVE(BHDCPlib_LinkReadyForEncryption); |
|---|
| 914 | return brc; |
|---|
| 915 | } |
|---|
| 916 | |
|---|
| 917 | |
|---|
| 918 | BERR_Code BHDCPlib_StartAuthentication(BHDCPlib_Handle hHDCPlib) |
|---|
| 919 | { |
|---|
| 920 | BDBG_ENTER(BHDCPlib_StartAuthentication); |
|---|
| 921 | BDBG_ASSERT(hHDCPlib); |
|---|
| 922 | |
|---|
| 923 | /* Initialize HDCP Authentication state */ |
|---|
| 924 | hHDCPlib->stHdcpStatus.eAuthenticationState = BHDCPlib_State_eInitializeAuthentication; |
|---|
| 925 | |
|---|
| 926 | |
|---|
| 927 | BDBG_LEAVE(BHDCPlib_StartAuthentication); |
|---|
| 928 | return BERR_SUCCESS; |
|---|
| 929 | } |
|---|
| 930 | |
|---|
| 931 | |
|---|
| 932 | /****************************** |
|---|
| 933 | |
|---|
| 934 | Possible return errors: |
|---|
| 935 | |
|---|
| 936 | BHDM_NO_RX_DEVICE |
|---|
| 937 | BHDM_HDCP_RX_BKSV_ERROR |
|---|
| 938 | BHDM_HDCP_RX_BKSV_REVOKED |
|---|
| 939 | BHDM_HDCP_TX_AKSV_ERROR |
|---|
| 940 | |
|---|
| 941 | BHDM_HDCP_AUTH_ABORTED |
|---|
| 942 | BHDM_HDCP_AUTHENTICATE_ERROR |
|---|
| 943 | BHDM_HDCP_LINK_RI_FAILURE |
|---|
| 944 | BHDM_HDCP_LINK_PJ_FAILURE |
|---|
| 945 | |
|---|
| 946 | BHDM_HDCP_REPEATER_FIFO_NOT_READY |
|---|
| 947 | BHDM_HDCP_REPEATER_DEVCOUNT_0 |
|---|
| 948 | BHDM_HDCP_REPEATER_DEPTH_EXCEEDED |
|---|
| 949 | BHDM_HDCP_RX_DEVICES_EXCEEDED |
|---|
| 950 | |
|---|
| 951 | |
|---|
| 952 | TBD: |
|---|
| 953 | |
|---|
| 954 | BHDM_HDCP_RX_NO_HDCP_SUPPORT |
|---|
| 955 | BHDM_HDCP_RECEIVER_AUTH_ERROR |
|---|
| 956 | BHDM_HDCP_REPEATER_AUTH_ERROR |
|---|
| 957 | BHDM_HDCP_NO_AUTHENTICATED_LINK |
|---|
| 958 | |
|---|
| 959 | **********************************/ |
|---|
| 960 | BERR_Code BHDCPlib_ProcessAuthentication(BHDCPlib_Handle hHDCPlib, BHDCPlib_Status *stHdcpStatus) |
|---|
| 961 | { |
|---|
| 962 | BERR_Code rc = BERR_SUCCESS; |
|---|
| 963 | uint8_t i; |
|---|
| 964 | bool bErrFound = false; |
|---|
| 965 | |
|---|
| 966 | BDBG_ENTER(BHDCPlib_ProcessAuthentication); |
|---|
| 967 | BDBG_ASSERT(hHDCPlib); |
|---|
| 968 | |
|---|
| 969 | |
|---|
| 970 | /* Always recommend a delay of 1 ms between states unless specified below */ |
|---|
| 971 | hHDCPlib->stHdcpStatus.msRecommendedWaitTime = 1; |
|---|
| 972 | |
|---|
| 973 | BDBG_MSG(("Current Authentication State: %d", hHDCPlib->stHdcpStatus.eAuthenticationState)) ; |
|---|
| 974 | switch (hHDCPlib->stHdcpStatus.eAuthenticationState) |
|---|
| 975 | { |
|---|
| 976 | case BHDCPlib_State_eUnPowered: |
|---|
| 977 | hHDCPlib->stHdcpStatus.msRecommendedWaitTime = 500 ; |
|---|
| 978 | break; |
|---|
| 979 | |
|---|
| 980 | case BHDCPlib_State_eUnauthenticated: |
|---|
| 981 | hHDCPlib->stHdcpStatus.msRecommendedWaitTime = 100; |
|---|
| 982 | break; |
|---|
| 983 | |
|---|
| 984 | case BHDCPlib_State_eInitializeAuthentication: |
|---|
| 985 | /* Attempting first part of authentication */ |
|---|
| 986 | rc = BHDCPlib_InitializeReceiverAuthentication(hHDCPlib); |
|---|
| 987 | if (rc != BERR_SUCCESS) |
|---|
| 988 | { |
|---|
| 989 | BDBG_ERR(("first part of the authentication process failed")) ; |
|---|
| 990 | goto done; |
|---|
| 991 | } |
|---|
| 992 | break; |
|---|
| 993 | |
|---|
| 994 | case BHDCPlib_State_eWaitForReceiverAuthentication: |
|---|
| 995 | if (hHDCPlib->bR0ReadyTimerExpired) |
|---|
| 996 | hHDCPlib->stHdcpStatus.eAuthenticationState = BHDCPlib_State_eReceiverR0Ready; |
|---|
| 997 | else |
|---|
| 998 | hHDCPlib->stHdcpStatus.msRecommendedWaitTime = hHDCPlib->stHdcpConfiguration.msWaitForR0; |
|---|
| 999 | |
|---|
| 1000 | break; |
|---|
| 1001 | |
|---|
| 1002 | case BHDCPlib_State_eReceiverR0Ready: |
|---|
| 1003 | rc = BHDCPlib_AuthenticateReceiver(hHDCPlib); |
|---|
| 1004 | if (rc != BERR_SUCCESS) |
|---|
| 1005 | { |
|---|
| 1006 | BDBG_ERR(("Failed to authenticate receiver")); |
|---|
| 1007 | goto done; |
|---|
| 1008 | } |
|---|
| 1009 | break; |
|---|
| 1010 | |
|---|
| 1011 | case BHDCPlib_State_eR0LinkFailure: |
|---|
| 1012 | hHDCPlib->stHdcpStatus.msRecommendedWaitTime = 2000; |
|---|
| 1013 | break; |
|---|
| 1014 | |
|---|
| 1015 | case BHDCPlib_State_eReceiverAuthenticated: |
|---|
| 1016 | /* Proceed to part 2 of authentication if attached device is a repeater */ |
|---|
| 1017 | if (hHDCPlib->stHdcpConfiguration.RxInfo.bIsHdcpRepeater) |
|---|
| 1018 | { |
|---|
| 1019 | rc = BHDCPlib_InitializeRepeaterAuthentication(hHDCPlib); |
|---|
| 1020 | if (rc != BERR_SUCCESS) |
|---|
| 1021 | { |
|---|
| 1022 | BDBG_ERR(("Second part of the authentication process failed")); |
|---|
| 1023 | goto done; |
|---|
| 1024 | } |
|---|
| 1025 | } |
|---|
| 1026 | else |
|---|
| 1027 | hHDCPlib->stHdcpStatus.eAuthenticationState = BHDCPlib_State_eLinkAuthenticated; |
|---|
| 1028 | |
|---|
| 1029 | break; |
|---|
| 1030 | |
|---|
| 1031 | case BHDCPlib_State_eWaitForRepeaterReady: |
|---|
| 1032 | if (hHDCPlib->bRepeaterReadyTimerExpired) |
|---|
| 1033 | hHDCPlib->stHdcpStatus.eAuthenticationState = BHDCPlib_State_eCheckForRepeaterReady; |
|---|
| 1034 | else |
|---|
| 1035 | /* Recommend waiting 100 ms for Repeater Fifo ready */ |
|---|
| 1036 | hHDCPlib->stHdcpStatus.msRecommendedWaitTime = 100; |
|---|
| 1037 | |
|---|
| 1038 | break; |
|---|
| 1039 | |
|---|
| 1040 | case BHDCPlib_State_eCheckForRepeaterReady: |
|---|
| 1041 | /* Check for repeater FIFO ready */ |
|---|
| 1042 | rc = BHDCPlib_P_CheckRepeaterReady(hHDCPlib); |
|---|
| 1043 | if (rc != BERR_SUCCESS) |
|---|
| 1044 | { |
|---|
| 1045 | BDBG_ERR(("Repeater KSV FIFO not ready")); |
|---|
| 1046 | goto done; |
|---|
| 1047 | } |
|---|
| 1048 | break; |
|---|
| 1049 | |
|---|
| 1050 | case BHDCPlib_State_eRepeaterReady: |
|---|
| 1051 | /* Repeater Ready, start authenticate repeater */ |
|---|
| 1052 | rc = BHDCPlib_AuthenticateRepeater(hHDCPlib); |
|---|
| 1053 | if (rc != BERR_SUCCESS) |
|---|
| 1054 | { |
|---|
| 1055 | BDBG_ERR(("Failed to authenticate repeater")); |
|---|
| 1056 | goto done; |
|---|
| 1057 | } |
|---|
| 1058 | break; |
|---|
| 1059 | |
|---|
| 1060 | case BHDCPlib_State_eLinkAuthenticated: |
|---|
| 1061 | /* HDCP AUTHENTICATION SUCCESS - link is now authenticated */ |
|---|
| 1062 | |
|---|
| 1063 | /* Recommend 10ms for checking encryption enabled */ |
|---|
| 1064 | hHDCPlib->stHdcpStatus.msRecommendedWaitTime = 10; |
|---|
| 1065 | break; |
|---|
| 1066 | |
|---|
| 1067 | |
|---|
| 1068 | case BHDCPlib_State_eEncryptionEnabled: |
|---|
| 1069 | /* Transmitting Encrypted Video */ |
|---|
| 1070 | hHDCPlib->stHdcpStatus.msRecommendedWaitTime = 2000; |
|---|
| 1071 | goto done; |
|---|
| 1072 | break; |
|---|
| 1073 | |
|---|
| 1074 | case BHDCPlib_State_eRepeaterAuthenticationFailure: |
|---|
| 1075 | /* Repeater Error */ |
|---|
| 1076 | rc = BHDM_HDCP_LINK_FAILURE; |
|---|
| 1077 | break; |
|---|
| 1078 | |
|---|
| 1079 | case BHDCPlib_State_eRiLinkIntegrityFailure: |
|---|
| 1080 | /* Ri Link Failure */ |
|---|
| 1081 | rc = BHDM_HDCP_LINK_RI_FAILURE; |
|---|
| 1082 | break; |
|---|
| 1083 | |
|---|
| 1084 | case BHDCPlib_State_ePjLinkIntegrityFailure: |
|---|
| 1085 | /* Pj Link Failure */ |
|---|
| 1086 | rc = BHDM_HDCP_LINK_PJ_FAILURE ; |
|---|
| 1087 | break; |
|---|
| 1088 | |
|---|
| 1089 | default: |
|---|
| 1090 | BDBG_WRN(("Invalid HDCP Authentication state: %d", hHDCPlib->stHdcpStatus.eAuthenticationState)) ; |
|---|
| 1091 | break; |
|---|
| 1092 | |
|---|
| 1093 | } |
|---|
| 1094 | |
|---|
| 1095 | |
|---|
| 1096 | done: |
|---|
| 1097 | /* HDCP error */ |
|---|
| 1098 | for (i=0; i < sizeof(BHDCPlib_SupportedHdcpErrors)/sizeof(BHDCPLIB_P_HDM_HdcpErrors); i++) |
|---|
| 1099 | { |
|---|
| 1100 | if (rc == BHDCPlib_SupportedHdcpErrors[i].hdmHdcpError) |
|---|
| 1101 | { |
|---|
| 1102 | hHDCPlib->stHdcpStatus.eHdcpError = BHDCPlib_SupportedHdcpErrors[i].hdcplibHdcpError; |
|---|
| 1103 | bErrFound = true; |
|---|
| 1104 | break; |
|---|
| 1105 | } |
|---|
| 1106 | } |
|---|
| 1107 | |
|---|
| 1108 | if (!bErrFound) |
|---|
| 1109 | { |
|---|
| 1110 | BDBG_ERR(("Cannot not find matching BHDM_HDCP error code")); |
|---|
| 1111 | hHDCPlib->stHdcpStatus.eHdcpError = BHDCPlib_HdcpError_eReceiverAuthenticationError; |
|---|
| 1112 | } |
|---|
| 1113 | |
|---|
| 1114 | /* Save current hdcp status */ |
|---|
| 1115 | BKNI_Memcpy(stHdcpStatus, &hHDCPlib->stHdcpStatus, sizeof(BHDCPlib_Status)); |
|---|
| 1116 | |
|---|
| 1117 | BDBG_LEAVE(BHDCPlib_ProcessAuthentication); |
|---|
| 1118 | return rc; |
|---|
| 1119 | |
|---|
| 1120 | } |
|---|
| 1121 | |
|---|
| 1122 | |
|---|
| 1123 | BERR_Code BHDCPlib_DisableAuthentication(BHDCPlib_Handle hHDCPlib) |
|---|
| 1124 | { |
|---|
| 1125 | BERR_Code rc = BERR_SUCCESS; |
|---|
| 1126 | |
|---|
| 1127 | BDBG_ENTER(BHDCPlib_DisableAuthentication); |
|---|
| 1128 | BDBG_ASSERT(hHDCPlib); |
|---|
| 1129 | |
|---|
| 1130 | /* clear HDCP Authentication */ |
|---|
| 1131 | BHDM_HDCP_ClearAuthentication(hHDCPlib->stDependencies.hHdm) ; |
|---|
| 1132 | |
|---|
| 1133 | /* Transmit clear data */ |
|---|
| 1134 | rc = BHDCPlib_TransmitClear(hHDCPlib); |
|---|
| 1135 | |
|---|
| 1136 | BDBG_LEAVE(BHDCPlib_DisableAuthentication); |
|---|
| 1137 | return rc; |
|---|
| 1138 | } |
|---|
| 1139 | |
|---|