⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nv_hdcp.c

📁 GM5621原代码
💻 C
字号:
/*
	$Workfile:   nv_hdcp.c  $
	$Revision:   1.8  $
	$Date:   Aug 23 2006 23:54:02  $
*/

//******************************************************************
//
//          Copyright (C) 2002. GENESIS MICROCHIP INC.
//  All rights reserved.  No part of this program may be reproduced.
//
//	Genesis Microchip Corp., 2150 Gold Street
//			Alviso, CA 95002	USA
//  Genesis Microchip Inc., 165 Commerce Valley Dr. West
//          Thornhill, Ontario, Canada, L3T 7V8
//
//================================================================
//
//  MODULE: hdcp.c
//
//  USAGE : This module contains function related to loading and maintaining
//          the HDCP keys.
//
//******************************************************************

//******************************************************************
//                  I N C L U D E    F I L E S
//******************************************************************
#include "inc\all.h"
#if !defined(TUCSON) && HDCP_ENABLE_4TH

#include <mem.h>

#define DEBUG_HDCP  0

#if  DEBUG_MSG &&	DEBUG_HDCP
	#define	msg(a,b)		gm_Print((const char far *)a,b)
#else
	#define msg(a,b)
#endif

#define BKSV_SIZE				5
#define SECRET_KEY_SIZE			7
#define HDCP_MEM_ROW_SIZE		8
#define MAX_NUM_SECRET_KEYS 	41 // if gencrypt, one extra key for encryption.

#if defined(NVRAM_BLOCK_HDCPData_WB_Used) && HDCP_KEYS_IN_NVRAM
gmt_RET_STAT gm_InitHdcpTableFromNVRAM(BYTE B_BlockType, BYTE B_DDC_Addr)
{
   BYTE					B_Count;
   BYTE				   B_tempArray[SECRET_KEY_SIZE];
   BYTE					B_numKeys;
   BYTE					B_genCrypt = 0x00;
   gmt_BLOCKINFO		S_blockInfo;
   BYTE*					Bp_HdcpRAM;

	S_blockInfo = gm_GetNVRAMBlockInfo(B_BlockType, 0);
   if(S_blockInfo.address == 0xffff || S_blockInfo.address == 0x0000)
   {
      msg("LoadHDCP: NVRAM B_BlockType 0x%x not found!",B_BlockType);
      return gmd_ERR_PARAM;
   }

   if( gm_ReadNVRAMAbsolute(S_blockInfo.address, B_tempArray, BKSV_SIZE) != gmd_OK)
   {
      msg("HDCP_Init: error reading BKSV",0);
      return gmd_FAIL;
   }

	if(S_blockInfo.length >= (BKSV_SIZE + (SECRET_KEY_SIZE * MAX_NUM_SECRET_KEYS)))
   {
      B_genCrypt = DECRYPT_EN;
      B_numKeys  = MAX_NUM_SECRET_KEYS;
      msg("HDCP_Init (gencrypt enabled): NVRAM addr 0x%x", S_blockInfo.address);
   }
   else
   {
      msg("HDCP_Init (gencrypt disabled): NVRAM addr 0x%x", S_blockInfo.address);
      B_numKeys  = (MAX_NUM_SECRET_KEYS - 1); // no gencrypt key.
   }


	gm_WriteRegByte(HDCP_CONTROL, KEYLOAD_EN | B_genCrypt);

   gm_WriteRegByte(HDCP_ADDR, 0x00);

	#if HDCP_SHOW_DEBUG_SIGNAL
	Hdcp_Debug_Signal_HDCP_Off();
	#endif   

   // write BKSV to BKSV registers.
   for(B_Count=0; B_Count < BKSV_SIZE; B_Count++)
   {
      gm_WriteRegByte(HDCP_BKSV0 + B_Count, B_tempArray[B_Count]);
   }

   S_blockInfo.address += BKSV_SIZE; // inc past BKSV values.

   Bp_HdcpRAM = (BYTE *)IRAM_HDCPKeyRAMStart;

   for(B_Count=0; B_Count < B_numKeys; B_Count++)
   {
      if(gm_ReadNVRAMAbsolute(S_blockInfo.address + (B_Count * SECRET_KEY_SIZE), B_tempArray, SECRET_KEY_SIZE) != gmd_OK)
      {
         msg("HDCP_Init: gm_ReadNVRAMAbsolute error reading keys",0);
         return gmd_FAIL;
      }
      // write key data to internal RAM table
      memcpy(Bp_HdcpRAM, B_tempArray, SECRET_KEY_SIZE);
      Bp_HdcpRAM += HDCP_MEM_ROW_SIZE;
   }

   // Put Keyram in read mode (disable KEYLOAD_EN)
   gm_ClearRegBitsByte(HDCP_CONTROL, KEYLOAD_EN);

   return gmd_OK;
}
#endif	// HDCPData_WB_Used

#endif //!defined(TUCSON) && HDCP_ENABLE_4TH

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -