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

📄 ui_input_pool.c

📁 ZORAN 962/966 SOURCE CODE,DVD chip
💻 C
📖 第 1 页 / 共 2 页
字号:
****************************************************************************************************/
static BOOL _GetHistory(pKEY_POOL_CODE pkeypool_code, UINT8 start_point, UINT8 key_code_size);

/****************************************************************************************************
*	DEFINITION: Public functions
****************************************************************************************************/


/************************************************************
* Function name	: UI_INPUT_POOL_Push
* Purpose		: Check repeat status and HOLD status, and put it into pKeyPool
* Input Parameters	: key_code - keycode that will be save in pKeyPool
*				  uicc_code - UICC for key thst will be save in pKeyPool
* Return type		: TRUE - success
*				  FALSE-Fail
* Output Parameters: None
************************************************************/
BOOL UI_INPUT_POOL_Push(UINT16 key_code, UINT16 uicc_code)
{
	KEY_POOL_CODE kp_code;
	UINT32	gtimer;
	//check repeat key
#ifdef D_GINGER_I96
	gtimer = cpu_gen_timer();
#else //D_GINGER_I96
	gtimer = gen_timer();
#endif //D_GINGER_I96
	if(KEY_STATUS_HOLD == (key_code&KEY_STATUS_MARSK))
		gcst.mKeyHold = TRUE;
	else
		gcst.mKeyHold = FALSE;
	gcst.mKeyRepeat = FALSE;
	if((uicc_code == key_pool.last_uicc) \
	   && (timing_get_diff(key_pool.last_time, gtimer) < REPEATKEY_3000MS) \
	   && (KEY_STATUS_NORMAL == (key_code&KEY_STATUS_MARSK)))
	{
		dbg_printf(("Set repeat key flag.\n"));
		key_code |= KEY_STATUS_REPEAT;
		gcst.mKeyRepeat = TRUE;
	}
	key_pool.last_time = gtimer;
	key_pool.last_uicc = uicc_code;
	//store key information into sc_pad
	kp_code.key_code = key_code;
	kp_code.uicc_code = uicc_code;
	kp_code.key_timer = gtimer;
	key_pool.ucHead++;
	if(key_pool.ucHead >= KEYPOOL_DEPTH)
		key_pool.ucHead = 0;
#ifdef D_GINGER_I96
	//sc_SetBytes(SC_KEY_POOL_ADDR, sizeof(KEY_POOL_CODE)*key_pool.ucHead, sizeof(KEY_POOL_CODE), (BYTE*)(&kp_code));
	kpKeepKeyPoolCode[key_pool.ucHead] =  kp_code;
#else //D_GINGER_I96
	sc_SetBytes(SC_KEY_POOL_ADDR, sizeof(KEY_POOL_CODE)*key_pool.ucHead, sizeof(KEY_POOL_CODE), (BYTE*)(&kp_code));
#endif //D_GINGER_I96
	return TRUE;
}
/************************************************************
* Function name	: UI_GetSecretUIOP
* Purpose		: Check Secret Key and call Secret function
* Input Parameters	: 
* Return type		: BOOL TRUE - Find a Secret Key 
*					     FALSE - Don't find Secret Key
* Output Parameters:  NONE
************************************************************/
BOOL UI_SecretOP(void)
{
	int i,j;
	KEY_POOL_CODE key_pool_buf[SECRET_KEY_MAX_LONG];
	_GetHistory(key_pool_buf, 0, SECRET_KEY_MAX_LONG);
	for(i = 0; i < MAX_SECRET_KEY; i++)
	{
		for(j = 0; j<Secret_Key_Tab[i]->wKeyCnt; j++)
		{
			if((Secret_Key_Tab[i]->wUicc[j] != key_pool_buf[Secret_Key_Tab[i]->wKeyCnt-j-1].uicc_code)
			     && Secret_Key_Tab[i]->wUicc[j] != SECRET_WILDCARD)
				break;
		}
		if(j == Secret_Key_Tab[i]->wKeyCnt)
		{
			dbg_printf(("Find a Secret KEY!\n"));
			return Secret_Key_Tab[i]->secret_op();
		}
	}
	return FALSE;
}

#if 0
/************************************************************
* Function name	: KeyPool_SetHistoryPoint
* Purpose		: Clean up the key information by the special point
* Input Parameters	: point-special point for pKeyPool's KEY_POOL_CODE that will be clean 
* Return type		: None
* Output Parameters: None
************************************************************/
void KeyPool_Clean(UINT8 point)
{
	KEY_POOL_CODE kp_code;
	if(point < KEYPOOL_DEPTH)
	{
		kp_code.key_code = NULL;
		kp_code.uicc_code = UICC_NULL;
		sc_SetBytes(SC_KEY_POOL_ADDR, sizeof(KEY_POOL_CODE)*point, sizeof(KEY_POOL_CODE), (BYTE*)(&kp_code));
	}
}

#endif
/************************************************************
* Function name	: _GetHistory
* Purpose		: Get history keypool-code from KeyPool
* Input Parameters	: key_code_size - number  for KEY_POOL_CODE
*				  start_point - index from head
* Return type		: TRUE -success
*				  FALSE - error or History is empty
* Output Parameters: pkeypool_code - KEY_POOL_CODE pointer which used to save the history KEY_POOL_CODE 
************************************************************/
static BOOL _GetHistory(pKEY_POOL_CODE pkeypool_code, UINT8 start_point, UINT8 key_code_size)
{
	int i;
	UINT8 ucHistory;
	if(KEYPOOL_DEPTH <= start_point)
		start_point = 0;
	if(start_point > key_pool.ucHead)
		ucHistory = KEYPOOL_DEPTH+key_pool.ucHead-start_point;
	else
		ucHistory = key_pool.ucHead-start_point;
	if(KEYPOOL_DEPTH <= ucHistory)
		ucHistory -= KEYPOOL_DEPTH;
	if(key_code_size>KEYPOOL_DEPTH)
		key_code_size = KEYPOOL_DEPTH;
	for(i=0; i<key_code_size; i++)
	{
#ifdef D_GINGER_I96
		//sc_GetBytes(SC_KEY_POOL_ADDR, sizeof(KEY_POOL_CODE)*ucHistory, sizeof(KEY_POOL_CODE), (BYTE *)pkeypool_code+i*sizeof(KEY_POOL_CODE));      
		pkeypool_code[i] = kpKeepKeyPoolCode[ucHistory];
#else //D_GINGER_I96
		sc_GetBytes(SC_KEY_POOL_ADDR, sizeof(KEY_POOL_CODE)*ucHistory, sizeof(KEY_POOL_CODE), (BYTE *)pkeypool_code+i*sizeof(KEY_POOL_CODE));
#endif //D_GINGER_I96
		if(ucHistory == 0)
			ucHistory = KEYPOOL_DEPTH-1;
		else
			ucHistory--;
	}
	return TRUE;
}
/////////////////////////////////////////////////////////////////////////////////////

/*************************************************************************
Function for Secret Key
**************************************************************************/
static BOOL SECRET_GetVersion(void)
{
	if (DEVICE_NO_DEVICE == DeviceManager_GetDeviceState(DEVICE_DISC))
	{
		MS_SendOp(MS_OP_MSG_SYS_BE_VERSION, 0);
		return TRUE;
	}
	return FALSE;
}
static BOOL SECRET_GetFEVersion(void)
{
	if (DEVICE_NO_DEVICE == DeviceManager_GetDeviceState(DEVICE_DISC))
	{
		MS_SendOp(MS_OP_MSG_SYS_FE_VERSION, 0);
		return TRUE;
	}
	return FALSE;
}
#ifndef D_GINGER_I86
static BOOL SECRET_GetChipID(void)
{
	if (DEVICE_NO_DEVICE == DeviceManager_GetDeviceState(DEVICE_DISC))
	{
		MS_SendOp(MS_OP_MSG_SYS_CHIP_ID, 0);
		return TRUE;
	}
	return FALSE;
}
#endif // not D_GINGER_I86
#ifndef D_GINGER_I96
static BOOL SECRET_GetBoardVersion(void)
{
	if (DEVICE_NO_DEVICE == DeviceManager_GetDeviceState(DEVICE_DISC))
	{
		MS_SendOp(MS_OP_MSG_SYS_BOARD_VERSION, 0);
		return TRUE;
	}
	return FALSE;
}
#endif //D_GINGER_I96
//Mars 10/20/2005
static BOOL SECRET_TVoutRecover(void)
{
	if ((DeviceManager_GetDeviceState(DEVICE_DISC) == DEVICE_TRAY_OPENING) 
		|| (DeviceManager_GetDeviceState(DEVICE_DISC) == DEVICE_TRAY_OPENED))
	{
		dbg_printf(("Reset TV out mode to default value\n"));
		CoreAPI_SetVideoOutMode(g_default_factory_settings.vid_out);
		return TRUE;
	}
	return FALSE;
}
static BOOL SECRET_TVformat_Recover(void)
{
	if ((DeviceManager_GetDeviceState(DEVICE_DISC) == DEVICE_TRAY_OPENING) 
		|| (DeviceManager_GetDeviceState(DEVICE_DISC) == DEVICE_TRAY_OPENED))
	{
		dbg_printf(("Reset TV out mode to default value\n"));
		CoreAPI_UpdatePlayerSetting(PS_UPDATE_TV_STANDARD, g_default_factory_settings.tv_standard);
		return TRUE;
	}
	return FALSE;
}
static BOOL SECRET_SetRegionCode(void)
{
	KEY_POOL_CODE keypool_code;
	if(DeviceManager_GetDeviceState(DEVICE_DISC) == DEVICE_TRAY_OPENED)
	{
		_GetHistory(&keypool_code, 0, 1);
		if(((UICC_1 <= keypool_code.uicc_code)&&(UICC_6 >= keypool_code.uicc_code))||(keypool_code.uicc_code == UICC_9))
		{
			dbg_printf(("Set Region code %d\n",keypool_code.uicc_code-UICC_0));
			CoreAPI_UpdatePlayerSetting(PS_UPDATE_REGION_CODE, keypool_code.uicc_code-UICC_0);
			MS_SendOp(MS_OP_MSG_SYS_NUMBER_INPUT, keypool_code.uicc_code-UICC_0);
			return TRUE;
		}
	}
	return FALSE;
}

static BOOL SECRET_GetChecksum(void)
{
	if (DEVICE_NO_DEVICE == DeviceManager_GetDeviceState(DEVICE_DISC))
	{
		UINT16 wCheckSum = 0;

		unsigned short huge * pFlash = MK_FP(0x4000,0);
		unsigned short huge * PS_POINTER = MK_FP(PS_SEG,0);
		
		while(pFlash < PS_POINTER)
		{
			wCheckSum += pFlash[0] & 0x00ff;
			wCheckSum += (pFlash[0] >> 8) & 0x00ff;
			pFlash += 1;
		}

		MS_SendOp(MS_OP_MSG_SECRET_KEY_CHECKSUM, (UINT32)wCheckSum);
		return TRUE;
	}
	return FALSE;
}

//if find a sequence key then return related uiop
//else return UIOP_LAST
#define NUM_SEQUENCE_KEY	(sizeof(oSequenceKeyTable)/sizeof(SEQUENCE_KEY))
BOOL UI_GetSequenceKey(UINT16 wUicc, UINT16* pUiop)
{
	//sequence key: A0~A9, B0~B9, C0~C9, ....G0~G9
	if (UICC_0 <= wUicc && UICC_9 >= wUicc)
	{
		KEY_POOL_CODE oKeyPoolBuffer[SEQUENCE_KEY_LENGTH];
		UINT8 i,j;
		_GetHistory(oKeyPoolBuffer, 0, SEQUENCE_KEY_LENGTH);
		for(i =0; i< NUM_SEQUENCE_KEY; i++)
		{
			for(j = 0;j< SEQUENCE_KEY_LENGTH;j++)
			{
				if(oSequenceKeyTable[i].wUicc[j] != oKeyPoolBuffer[SEQUENCE_KEY_LENGTH-j-1].uicc_code)
					break;		
			}
			if (SEQUENCE_KEY_LENGTH == j)
			{
				*pUiop = oSequenceKeyTable[i].wUiop;
				return TRUE;
			}
		}
	}
	return FALSE;	
};

⌨️ 快捷键说明

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