1 //<MStar Software>
2 //******************************************************************************
3 // MStar Software
4 // Copyright (c) 2010 - 2012 MStar Semiconductor, Inc. All rights reserved.
5 // All software, firmware and related documentation herein ("MStar Software") are
6 // intellectual property of MStar Semiconductor, Inc. ("MStar") and protected by
7 // law, including, but not limited to, copyright law and international treaties.
8 // Any use, modification, reproduction, retransmission, or republication of all
9 // or part of MStar Software is expressly prohibited, unless prior written
10 // permission has been granted by MStar.
11 //
12 // By accessing, browsing and/or using MStar Software, you acknowledge that you
13 // have read, understood, and agree, to be bound by below terms ("Terms") and to
14 // comply with all applicable laws and regulations:
15 //
16 // 1. MStar shall retain any and all right, ownership and interest to MStar
17 // Software and any modification/derivatives thereof.
18 // No right, ownership, or interest to MStar Software and any
19 // modification/derivatives thereof is transferred to you under Terms.
20 //
21 // 2. You understand that MStar Software might include, incorporate or be
22 // supplied together with third party`s software and the use of MStar
23 // Software may require additional licenses from third parties.
24 // Therefore, you hereby agree it is your sole responsibility to separately
25 // obtain any and all third party right and license necessary for your use of
26 // such third party`s software.
27 //
28 // 3. MStar Software and any modification/derivatives thereof shall be deemed as
29 // MStar`s confidential information and you agree to keep MStar`s
30 // confidential information in strictest confidence and not disclose to any
31 // third party.
32 //
33 // 4. MStar Software is provided on an "AS IS" basis without warranties of any
34 // kind. Any warranties are hereby expressly disclaimed by MStar, including
35 // without limitation, any warranties of merchantability, non-infringement of
36 // intellectual property rights, fitness for a particular purpose, error free
37 // and in conformity with any international standard. You agree to waive any
38 // claim against MStar for any loss, damage, cost or expense that you may
39 // incur related to your use of MStar Software.
40 // In no event shall MStar be liable for any direct, indirect, incidental or
41 // consequential damages, including without limitation, lost of profit or
42 // revenues, lost or damage of data, and unauthorized system use.
43 // You agree that this Section 4 shall still apply without being affected
44 // even if MStar Software has been modified by MStar in accordance with your
45 // request or instruction for your use, except otherwise agreed by both
46 // parties in writing.
47 //
48 // 5. If requested, MStar may from time to time provide technical supports or
49 // services in relation with MStar Software to you for your use of
50 // MStar Software in conjunction with your or your customer`s product
51 // ("Services").
52 // You understand and agree that, except otherwise agreed by both parties in
53 // writing, Services are provided on an "AS IS" basis and the warranty
54 // disclaimer set forth in Section 4 above shall apply.
55 //
56 // 6. Nothing contained herein shall be construed as by implication, estoppels
57 // or otherwise:
58 // (a) conferring any license or right to use MStar name, trademark, service
59 // mark, symbol or any other identification;
60 // (b) obligating MStar or any of its affiliates to furnish any person,
61 // including without limitation, you and your customers, any assistance
62 // of any kind whatsoever, or any information; or
63 // (c) conferring any license or right under any intellectual property right.
64 //
65 // 7. These terms shall be governed by and construed in accordance with the laws
66 // of Taiwan, R.O.C., excluding its conflict of law rules.
67 // Any and all dispute arising out hereof or related hereto shall be finally
68 // settled by arbitration referred to the Chinese Arbitration Association,
69 // Taipei in accordance with the ROC Arbitration Law and the Arbitration
70 // Rules of the Association by three (3) arbitrators appointed in accordance
71 // with the said Rules.
72 // The place of arbitration shall be in Taipei, Taiwan and the language shall
73 // be English.
74 // The arbitration award shall be final and binding to both parties.
75 //
76 //******************************************************************************
77 //<MStar Software>
78 ////////////////////////////////////////////////////////////////////////////////
79 //
80 // Copyright (c) 2006-2009 MStar Semiconductor, Inc.
81 // All rights reserved.
82 //
83 // Unless otherwise stipulated in writing, any and all information contained
84 // herein regardless in any format shall remain the sole proprietary of
85 // MStar Semiconductor Inc. and be kept in strict confidence
86 // ("MStar Confidential Information") by the recipient.
87 // Any unauthorized act including without limitation unauthorized disclosure,
88 // copying, use, reproduction, sale, distribution, modification, disassembling,
89 // reverse engineering and compiling of the contents of MStar Confidential
90 // Information is unlawful and strictly prohibited. MStar hereby reserves the
91 // rights to any and all damages, losses, costs and expenses resulting therefrom.
92 //
93 ////////////////////////////////////////////////////////////////////////////////
94
95 ////////////////////////////////////////////////////////////////////////////////////////////////////
96 // file halHDCP.c
97 // @brief HDCP HAL
98 // @author MStar Semiconductor,Inc.
99 ////////////////////////////////////////////////////////////////////////////////////////////////////
100 /*********************************************************************/
101 /* */
102 /* Includes */
103 /* */
104 /*********************************************************************/
105 #include <stdio.h>
106 #include <string.h>
107 #include "MsCommon.h"
108 #include "MsTypes.h"
109 #include "regHDCP.h"
110 #include "halHDCP.h"
111 #include "drvCPU.h"
112
113 #ifndef HAL_HDCP_C
114 #define HAL_HDCP_C
115
116 /*********************************************************************/
117 /* */
118 /* Defines */
119 /* */
120 /*********************************************************************/
121 #define DEF_HDCP_TX_FUNC_EN 1
122
123 #if(defined(CONFIG_MLOG))
124 #include "ULog.h"
125
126 #define HalHDCPLogInfo(format, args...) ULOGI("HDCP", format, ##args)
127 #define HalHDCPLogWarning(format, args...) ULOGW("HDCP", format, ##args)
128 #define HalHDCPLogDebug(format, args...) ULOGD("HDCP", format, ##args)
129 #define HalHDCPLogError(format, args...) ULOGE("HDCP", format, ##args)
130 #define HalHDCPLogFatal(format, args...) ULOGF("HDCP", format, ##args)
131
132 #else
133
134 #define HalHDCPLogInfo(format, args...) printf(format, ##args)
135 #define HalHDCPLogWarning(format, args...) printf(format, ##args)
136 #define HalHDCPLogDebug(format, args...) printf(format, ##args)
137 #define HalHDCPLogError(format, args...) printf(format, ##args)
138 #define HalHDCPLogFatal(format, args...) printf(format, ##args)
139
140 #endif
141
142
143 #define DEF_SIZE_OF_KSXORLC128 16
144 #define DEF_SIZE_OF_RIV 8
145 #define DEF_SIZE_OF_HDCP1X_KEY 304
146
147 MS_VIRT _gHDCPRegBase = 0x00U;
148 MS_VIRT _gHDCPPMRegBase = 0x00U;
149
150 #define HDCPREG(bank, addr) (*((volatile MS_U16 *)((_gHDCPRegBase + (bank << 1U)) + (addr << 2U))))
151 #define HDCPPMREG(bank, addr) (*((volatile MS_U16 *)((_gHDCPPMRegBase + (bank << 1U)) + (addr << 2U))))
152
153 #define DEF_HDCP14_M0_SIZE 64U //bytes
154
155 /*********************************************************************/
156 /* */
157 /* Global */
158 /* */
159 /*********************************************************************/
160 MS_U8 gu8Hdcp1xKey[DEF_SIZE_OF_HDCP1X_KEY]= {0x00};
161 static MS_BOOL gbIsKmNewMode = FALSE;
162
163 /*********************************************************************/
164 /* */
165 /* Functions */
166 /* */
167 /*********************************************************************/
168 /*********************************************************************/
169 /* */
170 /* Internal */
171 /* */
172 /*********************************************************************/
173
MHalHdcpRegRead(MS_U32 bank,MS_U16 address)174 MS_U16 MHalHdcpRegRead(MS_U32 bank, MS_U16 address)
175 {
176 return HDCPREG(bank, address);
177 }
178
MHalHdcpRegWrite(MS_U32 bank,MS_U16 address,MS_U16 reg_data)179 void MHalHdcpRegWrite(MS_U32 bank, MS_U16 address, MS_U16 reg_data)
180 {
181 HDCPREG(bank, address) = reg_data;
182 }
183
MHalHdcpRegMaskWrite(MS_U32 bank,MS_U16 address,MS_U16 reg_mask,MS_U16 reg_data)184 void MHalHdcpRegMaskWrite(MS_U32 bank, MS_U16 address, MS_U16 reg_mask, MS_U16 reg_data)
185 {
186 MS_U16 reg_value;
187
188 reg_value = (HDCPREG(bank, address) & (~reg_mask)) | (reg_data & reg_mask);
189 HDCPREG(bank, address) = reg_value;
190 }
191
MHalHdcpPMRegRead(MS_U32 bank,MS_U16 address)192 MS_U16 MHalHdcpPMRegRead(MS_U32 bank, MS_U16 address)
193 {
194 return HDCPPMREG(bank, address);
195 }
196
MHalHdcpPMRegWrite(MS_U32 bank,MS_U16 address,MS_U16 reg_data)197 void MHalHdcpPMRegWrite(MS_U32 bank, MS_U16 address, MS_U16 reg_data)
198 {
199 HDCPPMREG(bank, address) = reg_data;
200 }
201
MHalHdcpPMRegMaskWrite(MS_U32 bank,MS_U16 address,MS_U16 reg_mask,MS_U16 reg_data)202 void MHalHdcpPMRegMaskWrite(MS_U32 bank, MS_U16 address, MS_U16 reg_mask, MS_U16 reg_data)
203 {
204 MS_U16 reg_value;
205
206 reg_value = (HDCPPMREG(bank, address) & (~reg_mask)) | (reg_data & reg_mask);
207 HDCPPMREG(bank, address) = reg_value;
208 }
209
210 /*********************************************************************/
211 /* */
212 /* External */
213 /* */
214 /*********************************************************************/
MHal_HDCP_HDCP14TxInitHdcp(MS_U8 u8PortIdx)215 void MHal_HDCP_HDCP14TxInitHdcp(MS_U8 u8PortIdx)
216 {
217 //Kano has only 1 Tx port
218 u8PortIdx &= 0x0F;
219
220 //TBD: get bank offset by port index
221 MHalHdcpRegMaskWrite(DEF_HDCP14_TX_REG_BANK, 0x0001, 0x8000, 0x8000); // Enable HDCP encryption
222 MHalHdcpRegMaskWrite(DEF_HDCP14_TX_REG_BANK, 0x0002, 0x001C, 0x0000); //[4]: 1: km new mode; 0: km old mode
223 }
224
MHal_HDCP_HDCP14TxLoadKey(MS_U8 * pu8KeyData,MS_BOOL bUseKmNewMode)225 void MHal_HDCP_HDCP14TxLoadKey(MS_U8* pu8KeyData, MS_BOOL bUseKmNewMode)
226 {
227 gbIsKmNewMode = bUseKmNewMode;
228 if (pu8KeyData != NULL)
229 memcpy(gu8Hdcp1xKey, pu8KeyData, DEF_SIZE_OF_HDCP1X_KEY);
230 }
231
MHal_HDCP_HDCP14TxSetAuthPass(MS_U8 u8PortIdx)232 void MHal_HDCP_HDCP14TxSetAuthPass(MS_U8 u8PortIdx)
233 {
234 //Kano has only 1 Tx port
235 u8PortIdx &= 0x0F;
236
237 //TBD: get bank offset by port index
238 MHalHdcpRegMaskWrite(DEF_HDCP14_TX_REG_BANK, 0x0002, 0x000F, 0x000C);
239 }
240
MHal_HDCP_HDCP14TxEnableENC_EN(MS_U8 u8PortIdx,MS_BOOL bEnable)241 void MHal_HDCP_HDCP14TxEnableENC_EN(MS_U8 u8PortIdx, MS_BOOL bEnable)
242 {
243 //Kano has only 1 Tx port
244 u8PortIdx &= 0x0F;
245
246 if (bEnable == TRUE)
247 MHalHdcpRegMaskWrite(DEF_HDCP14_TX_REG_BANK, 0x0002, 0x0008, 0x0008);
248 else
249 MHalHdcpRegMaskWrite(DEF_HDCP14_TX_REG_BANK, 0x0002, 0x0008, 0x0000);
250 }
251
MHal_HDCP_HDCP14TxProcessAn(MS_U8 u8PortIdx,MS_BOOL bUseInternalAn,MS_U8 * pu8An)252 void MHal_HDCP_HDCP14TxProcessAn(MS_U8 u8PortIdx, MS_BOOL bUseInternalAn, MS_U8* pu8An)
253 {
254 MS_U8 i = 0;
255 //Kano has only 1 Tx port
256 u8PortIdx &= 0x0F;
257
258 if (bUseInternalAn == TRUE)
259 {
260 MHalHdcpRegMaskWrite(DEF_HDCP14_TX_REG_BANK, 0x0001, 0x0100, 0x0100);
261 MHalHdcpRegMaskWrite(DEF_HDCP14_TX_REG_BANK, 0x0002, 0x0002, 0x0002);
262 MHalHdcpRegMaskWrite(DEF_HDCP14_TX_REG_BANK, 0x0002, 0x0002, 0x0000);
263
264 MsOS_DelayTaskUs(1);
265
266 for ( i = 0; i < 4; i++ )
267 {
268 *(pu8An + 2*i) = MHalHdcpRegRead(DEF_HDCP14_TX_REG_BANK, 0x0008 + i) & 0x00FF;
269 *(pu8An + 2*i + 1) = (MHalHdcpRegRead(DEF_HDCP14_TX_REG_BANK, 0x0008 + i) & 0xFF00) >> 8;
270 }
271 }
272 else
273 {
274 MHalHdcpRegMaskWrite(DEF_HDCP14_TX_REG_BANK, 0x0001, 0x0100, 0x0000);
275
276 for ( i = 0; i < 4; i++ )
277 {
278 MHalHdcpRegWrite(DEF_HDCP14_TX_REG_BANK, 0x0008 + i, ((*(pu8An + 2*i + 1) << 8) | (*(pu8An + 2*i))));
279 }
280 }
281 }
282
283
MHal_HDCP_HDCP14TxGetAKSV(MS_U8 u8PortIdx,MS_U8 * pu8Aksv)284 void MHal_HDCP_HDCP14TxGetAKSV(MS_U8 u8PortIdx, MS_U8* pu8Aksv)
285 {
286 MS_U8 u8ByteCnt = 0;
287
288 //Kano has only 1 Tx port
289 u8PortIdx &= 0x0F;
290
291 for (u8ByteCnt = 0; u8ByteCnt < 5; u8ByteCnt++ )
292 {
293 *(pu8Aksv + u8ByteCnt) = gu8Hdcp1xKey[u8ByteCnt];
294 }
295 }
296
297
MHal_HDCP_HDCP14TxCompareRi(MS_U8 u8PortIdx,MS_U8 * pu8SinkRi)298 MS_BOOL MHal_HDCP_HDCP14TxCompareRi(MS_U8 u8PortIdx, MS_U8* pu8SinkRi)
299 {
300 MS_BOOL bRet = FALSE;
301 MS_U16 u16SrcRi = 0x0000;
302 //Kano has only 1 Tx port
303 u8PortIdx &= 0x0F;
304
305 do
306 {
307 u16SrcRi = MHalHdcpRegRead(DEF_HDCP14_TX_REG_BANK, 0x0000);
308
309 if (u16SrcRi == *(MS_U16*)pu8SinkRi)
310 {
311 bRet = TRUE;
312 break;
313 }
314
315 u16SrcRi = MHalHdcpRegRead(DEF_HDCP14_TX_REG_BANK, 0x0000);
316
317 if (u16SrcRi == *(MS_U16*)pu8SinkRi)
318 {
319 bRet = TRUE;
320 break;
321 }
322
323 } while (FALSE);
324
325 return bRet;
326 }
327
328
MHal_HDCP_HDCP14TxConfigMode(MS_U8 u8PortIdx,MS_U8 u8Mode)329 void MHal_HDCP_HDCP14TxConfigMode(MS_U8 u8PortIdx, MS_U8 u8Mode)
330 {
331 //Kano has only 1 Tx port
332 u8PortIdx &= 0x0F;
333
334 MHalHdcpRegMaskWrite(DEF_HDCP14_TX_REG_BANK, 0x0001, 0x0E00, u8Mode << 8);
335 }
336
337
MHal_HDCP_HDCP14TxGenerateCipher(MS_U8 u8PortIdx,MS_U8 * pu8Bksv)338 void MHal_HDCP_HDCP14TxGenerateCipher(MS_U8 u8PortIdx, MS_U8* pu8Bksv)
339 {
340 #define DEF_HDCP1X_KEY_OFFSET 8U
341
342 MS_U8 u8Lm[7] = {0};
343 MS_U8 u8ByteCnt = 0;
344 MS_U8 u8BitCnt = 0;
345 MS_U8 u8LmCnt = 0;
346 MS_U8 u8CarryBit = 0;
347 MS_U8 u8Seed = 0;
348 MS_U8 u8Tmp = 0;
349 MS_U16 u16Offset = 0;
350
351 for (u8ByteCnt = 0; u8ByteCnt < 5; u8ByteCnt++)
352 {
353 for (u8BitCnt = 0; u8BitCnt < 8; u8BitCnt++)
354 {
355 if (*(pu8Bksv + u8ByteCnt) & (1 << u8BitCnt))
356 {
357 u8CarryBit = 0;
358 u16Offset = (u8ByteCnt * 8 + u8BitCnt) * 7 + DEF_HDCP1X_KEY_OFFSET;
359
360 for (u8LmCnt = 0; u8LmCnt < 7; u8LmCnt++)
361 {
362 u8Seed = (u8LmCnt + gu8Hdcp1xKey[7]) % 7;
363 u8Tmp = gu8Hdcp1xKey[u16Offset + u8LmCnt] ^ gu8Hdcp1xKey[u8Seed];
364
365 u8Lm[u8LmCnt] = u8Lm[u8LmCnt] + u8Tmp + u8CarryBit;
366 if (((u8CarryBit == 0) && (u8Lm[u8LmCnt] >= u8Tmp)) || ((u8CarryBit == 1) && (u8Lm[u8LmCnt] > u8Tmp)))
367 u8CarryBit = 0;
368 else
369 u8CarryBit = 1;
370 }
371 }
372 }
373 }
374
375 u8Tmp = gu8Hdcp1xKey[288];
376
377 for (u8LmCnt = 0; u8LmCnt < 7; u8LmCnt++)
378 {
379 if (u8LmCnt < 6)
380 u8Lm[u8LmCnt] = u8Lm[u8LmCnt] ^ u8Tmp;
381 else
382 u8Lm[u8LmCnt] = u8Lm[u8LmCnt] ^ (~u8Tmp);
383
384 if (u8LmCnt % 2 != 0)
385 MHalHdcpRegWrite(DEF_HDCP14_TX_REG_BANK, 0x0004 + (u8LmCnt/2), (u8Lm[u8LmCnt] << 8) | u8Lm[u8LmCnt - 1]);
386 }
387
388 MHalHdcpRegWrite(DEF_HDCP14_TX_REG_BANK, 0x0007, (u8Tmp << 8) | u8Lm[6]);
389
390 #undef DEF_HDCP1X_KEY_OFFSET
391
392 }
393
MHal_HDCP_HDCP14TxProcessR0(MS_U8 u8PortIdx)394 MS_BOOL MHal_HDCP_HDCP14TxProcessR0(MS_U8 u8PortIdx)
395 {
396 MS_U8 u8Cnt = 0;
397
398 MHalHdcpRegMaskWrite(DEF_HDCP14_TX_REG_BANK, 0x0002, 0x000F, 0x0000);
399 MHalHdcpRegMaskWrite(DEF_HDCP14_TX_REG_BANK, 0x0002, 0x000F, 0x0001);
400 MHalHdcpRegMaskWrite(DEF_HDCP14_TX_REG_BANK, 0x0002, 0x000F, 0x0000);
401
402 while (u8Cnt-- && !(MHalHdcpRegRead(DEF_HDCP14_TX_REG_BANK, 0x0002) & 0x0100));
403
404 return ((u8Cnt == 0) ? FALSE : TRUE);
405 }
406
MHal_HDCP_HDCP14TxGetM0(MS_U8 u8PortIdx,MS_U8 * pu8M0)407 void MHal_HDCP_HDCP14TxGetM0(MS_U8 u8PortIdx, MS_U8* pu8M0)
408 {
409 #define DEF_HDCP1X_M0_SIZE 8
410 unsigned char u8DataCnt = 0;
411 MS_U16 u16BKOffset = 0x00;
412 MS_U16 u16RegVal = 0x00;
413
414 u8PortIdx &= 0x0F;
415
416 for ( u8DataCnt = 0; u8DataCnt < (DEF_HDCP1X_M0_SIZE>>1); u8DataCnt++ )
417 {
418 u16RegVal = MHalHdcpRegRead(DEF_HDCP14_TX_REG_BANK + u16BKOffset, 0x0C + u8DataCnt);
419 *(pu8M0 + 2*u8DataCnt) = (MS_U8)(u16RegVal & 0x00FF);
420 *(pu8M0 + 2*u8DataCnt + 1) = (MS_U8)((u16RegVal & 0xFF00)>>8);
421
422 }
423 #undef DEF_HDCP1X_M0_SIZE
424 }
425
MHal_HDCP_HDCP14GetM0(MS_U8 u8PortIdx,MS_U8 * pu8Data)426 void MHal_HDCP_HDCP14GetM0(MS_U8 u8PortIdx, MS_U8 *pu8Data)
427 {
428 MS_U8 cnt = 0x00;
429 MS_U16 u16BKOffset = 0x00;
430
431 u8PortIdx &= 0x0F;
432 //only has 1 Tx port
433
434 for ( cnt = 0; cnt < (DEF_HDCP14_M0_SIZE >> 4); cnt++ )
435 {
436 MS_U16 u16tmpData = 0x00;
437
438 u16tmpData = MHalHdcpRegRead(DEF_HDCP14_RX_REG_BANK + u16BKOffset, 0x0E + cnt);
439
440 *(pu8Data + cnt*2) = (MS_U8)(u16tmpData & 0x00FF);
441 *(pu8Data + cnt*2 + 1) = (MS_U8)((u16tmpData & 0xFF00) >> 8);
442 }
443 }
444
MHal_HDCP_HDCP14FillBksv(MS_U8 * pu8BksvData)445 void MHal_HDCP_HDCP14FillBksv(MS_U8 *pu8BksvData)
446 {
447 if(pu8BksvData != NULL)
448 {
449
450 }
451 }
452
MHal_HDCP_HDCP14FillKey(MS_U8 * pu8KeyData)453 void MHal_HDCP_HDCP14FillKey(MS_U8 *pu8KeyData)
454 {
455 if(pu8KeyData == NULL)
456 {
457
458 }
459 }
460
MHal_HDCP_SetBank(MS_U32 u32NonPmBankAddr,MS_U32 u32PmBankAddr)461 void MHal_HDCP_SetBank(MS_U32 u32NonPmBankAddr, MS_U32 u32PmBankAddr)
462 {
463 HalHDCPLogInfo("u32NonPmBankAddr = 0x%X, u32PmBankAddr = 0x%X\r\n", (unsigned int)u32NonPmBankAddr, (unsigned int)u32PmBankAddr);
464 _gHDCPRegBase = u32NonPmBankAddr;
465 _gHDCPPMRegBase = u32PmBankAddr;
466 }
467
MHal_HDCP_HDCP2TxInit(MS_U8 u8PortIdx,MS_BOOL bEnable)468 void MHal_HDCP_HDCP2TxInit(MS_U8 u8PortIdx, MS_BOOL bEnable)
469 {
470 MS_U16 u16BKOffset = 0x00;
471
472 MHalHdcpRegMaskWrite(DEF_HDCP22_TX_REG_BANK + u16BKOffset, 0x0000, 0x11, bEnable ? 0x11 : 0x00); // bit 0: enable hdcp22; bit 4: enable EESS
473 if (bEnable)
474 {
475 MHalHdcpRegMaskWrite(DEF_HDCP22_TX_REG_BANK + u16BKOffset, 0x0000, 0x02, 0x02); //reset hdcp22 FSM
476 MHalHdcpRegMaskWrite(DEF_HDCP22_TX_REG_BANK + u16BKOffset, 0x0000, 0x02, 0x00);
477 }
478 }
479
MHal_HDCP_HDCP2TxEnableEncrypt(MS_U8 u8PortIdx,MS_BOOL bEnable)480 void MHal_HDCP_HDCP2TxEnableEncrypt(MS_U8 u8PortIdx, MS_BOOL bEnable)
481 {
482 MS_U16 u16BKOffset = 0x00;
483
484 MHalHdcpRegMaskWrite(DEF_HDCP22_TX_REG_BANK + u16BKOffset, 0x0000, 0x04, bEnable ? 0x04 : 0x00); //bit 2: authentication pass
485 MHalHdcpRegMaskWrite(DEF_HDCP22_TX_REG_BANK + u16BKOffset, 0x0000, 0x08, bEnable ? 0x08 : 0x00); //bit 3: enable hdcp22 to issue encryption enable signal
486 }
487
MHal_HDCP_HDCP2TxFillCipherKey(MS_U8 u8PortIdx,MS_U8 * pu8Riv,MS_U8 * pu8KsXORLC128)488 void MHal_HDCP_HDCP2TxFillCipherKey(MS_U8 u8PortIdx, MS_U8 *pu8Riv, MS_U8 *pu8KsXORLC128)
489 {
490 MS_U8 cnt = 0;
491 MS_U16 u16BKOffset = 0x00;
492 //MS_U16 u16RegOffset = 0x00;
493
494 //only has 1 Tx port
495
496 //Ks^LC128
497 for ( cnt = 0; cnt < (DEF_SIZE_OF_KSXORLC128>>1); cnt++)
498 MHalHdcpRegWrite(DEF_HDCP22_TX_KEY_REG_BANK + u16BKOffset, 0x60 + (DEF_SIZE_OF_KSXORLC128 >> 1) - 1 - cnt, *(pu8KsXORLC128 + cnt*2 + 1)|(*(pu8KsXORLC128 + cnt*2)<<8));
499
500 //Riv
501 for ( cnt = 0; cnt < (DEF_SIZE_OF_RIV>>1); cnt++)
502 MHalHdcpRegWrite(DEF_HDCP22_TX_KEY_REG_BANK + u16BKOffset, 0x68 + (DEF_SIZE_OF_RIV >> 1) - 1 - cnt, *(pu8Riv + cnt*2 + 1)|(*(pu8Riv + cnt*2)<<8));
503
504 }
505
MHal_HDCP_HDCP2TxGetCipherState(MS_U8 u8PortIdx,MS_U8 * pu8State)506 void MHal_HDCP_HDCP2TxGetCipherState(MS_U8 u8PortIdx, MS_U8 *pu8State)
507 {
508 MS_U16 u16BKOffset = 0x00;
509 //MS_U16 u16RegOffset = 0x00;
510
511 //only has 1 Tx port
512
513 *pu8State = MHalHdcpRegRead(DEF_HDCP22_TX_REG_BANK + u16BKOffset, 0x00) & 0x0C;
514 }
515
MHal_HDCP_HDCP2TxSetAuthPass(MS_U8 u8PortIdx,MS_BOOL bEnable)516 void MHal_HDCP_HDCP2TxSetAuthPass(MS_U8 u8PortIdx, MS_BOOL bEnable)
517 {
518 MS_U16 u16BKOffset = 0x00;
519
520 MHalHdcpRegMaskWrite(DEF_HDCP22_TX_REG_BANK + u16BKOffset, 0x0000, 0x04, bEnable ? 0x04 : 0x00); //bit 2: authentication pass
521 }
522
MHal_HDCP_HDCP2RxInit(MS_U8 u8PortIdx)523 void MHal_HDCP_HDCP2RxInit(MS_U8 u8PortIdx)
524 {
525 return;
526 }
527
MHal_HDCP_HDCP2RxProcessCipher(MS_U8 u8PortIdx,MS_U8 * pu8Riv,MS_U8 * pu8ContentKey)528 void MHal_HDCP_HDCP2RxProcessCipher(MS_U8 u8PortIdx, MS_U8* pu8Riv, MS_U8 *pu8ContentKey)
529 {
530 return;
531 }
532
MHal_HDCP_HDCP2RxSetSKEPass(MS_U8 u8PortIdx,MS_BOOL bEnable)533 void MHal_HDCP_HDCP2RxSetSKEPass(MS_U8 u8PortIdx, MS_BOOL bEnable)
534 {
535 return;
536 }
537
MHal_HDCP_HDCP2RxFillCipherKey(MS_U8 u8PortIdx,MS_U8 * pu8Riv,MS_U8 * pu8ContentKey)538 void MHal_HDCP_HDCP2RxFillCipherKey(MS_U8 u8PortIdx, MS_U8* pu8Riv, MS_U8 *pu8ContentKey)
539 {
540 return;
541 }
542
MHal_HDCP_HDCP2RxGetCipherState(MS_U8 u8PortIdx,MS_U8 * pu8State)543 void MHal_HDCP_HDCP2RxGetCipherState(MS_U8 u8PortIdx, MS_U8 *pu8State)
544 {
545 *pu8State = 0;
546 }
547
MHal_HDCP_HDCP1TxEncrytionStatus(MS_U8 u8PortIdx,MS_U8 u8SetStatusFlag,MS_U32 u32SetStatus)548 MS_U32 MHal_HDCP_HDCP1TxEncrytionStatus(MS_U8 u8PortIdx, MS_U8 u8SetStatusFlag, MS_U32 u32SetStatus)
549 {
550 MS_U32 u32GetStatus = 0;
551
552 if(u8SetStatusFlag) // Set HDCP1 encrytion status
553 {
554 MHalHdcpRegMaskWrite(DEF_HDCP14_TX_REG_BANK, REG_HDCP14_TX_02_L, BIT(3), u32SetStatus? BIT(3): 0); //bit 3: enable hdcp14 to issue encryption enable signal
555 }
556
557 // Get HDCP1 encrytion status
558 if(MHalHdcpRegRead(DEF_HDCP14_TX_REG_BANK, REG_HDCP14_TX_02_L) &BIT(3))
559 {
560 u32GetStatus = TRUE;
561 }
562
563 return u32GetStatus;
564 }
565
MHal_HDCP_HDCP2TxEncrytionStatus(MS_U8 u8PortIdx,MS_U8 u8SetStatusFlag,MS_U32 u32SetStatus)566 MS_U32 MHal_HDCP_HDCP2TxEncrytionStatus(MS_U8 u8PortIdx, MS_U8 u8SetStatusFlag, MS_U32 u32SetStatus)
567 {
568 MS_U32 u32GetStatus = 0;
569
570 if(u8SetStatusFlag) // Set HDCP2 encrytion status
571 {
572 MHalHdcpRegMaskWrite(DEF_HDCP22_TX_REG_BANK, REG_HDCP22_TX_00_L, BIT(3), u32SetStatus? BIT(3): 0); //bit 3: enable hdcp22 to issue encryption enable signal
573 }
574
575 // Get HDCP2 encrytion status
576 if(MHalHdcpRegRead(DEF_HDCP22_TX_REG_BANK, REG_HDCP22_TX_00_L) &BIT(3))
577 {
578 u32GetStatus = TRUE;
579 }
580
581 return u32GetStatus;
582 }
583
MHal_HDCP_HDCPTxHDMIStatus(MS_U8 u8PortIdx,MS_U8 u8SetStatusFlag,MS_U32 u32SetStatus)584 MS_U32 MHal_HDCP_HDCPTxHDMIStatus(MS_U8 u8PortIdx, MS_U8 u8SetStatusFlag, MS_U32 u32SetStatus)
585 {
586 MS_U32 u32GetStatus = 0;
587
588 if(u8SetStatusFlag) // Set HDNI status
589 {
590 MHalHdcpRegMaskWrite(DEF_HDMITX_PHY_REG_BANK, REG_HDMITX_PHY_39_L, 0xFFFF, u32SetStatus? 0xF000: 0xFFFF);
591 MHalHdcpRegMaskWrite(DEF_HDMITX_PHY_REG_BANK, REG_HDMITX_PHY_2E_L, 0xE800, u32SetStatus? 0xE800: 0x0000);
592 }
593
594 // Get HDNI status
595 if((MHalHdcpRegRead(DEF_HDMITX_PHY_REG_BANK, REG_HDMITX_PHY_2E_L) &0xE800) == 0xE800)
596 {
597 u32GetStatus = TRUE;
598 }
599
600 return u32GetStatus;
601 }
602
603 #endif //#ifndef HAL_HDCP_C
604