📄 msapi_tuner.c
字号:
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2006-2007 MStar Semiconductor, Inc.
// All rights reserved.
//
// Unless otherwise stipulated in writing, any and all information contained
// herein regardless in any format shall remain the sole proprietary of
// MStar Semiconductor Inc. and be kept in strict confidence
// (¨MStar Confidential Information〃) by the recipient.
// Any unauthorized act including without limitation unauthorized disclosure,
// copying, use, reproduction, sale, distribution, modification, disassembling,
// reverse engineering and compiling of the contents of MStar Confidential
// Information is unlawful and strictly prohibited. MStar hereby reserves the
// rights to any and all damages, losses, costs and expenses resulting therefrom.
//
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
// @file msAPI_Tuner.h
// @brief API for tuner settings
// @author MStar Semiconductor, Inc.
//
// Tuner settings differ from front end suppliers. Please check front end type define
//
////////////////////////////////////////////////////////////////////////////////
#define MSAPI_TUNER_C
/******************************************************************************/
/* Header Files */
/******************************************************************************/
#include <string.h>
#include <stdio.h>
#include "DataType.h"
#include "drviic.h"
#include "drvtimer.h"
#include "drvVD.h"
#include "msAPI_VD.h"
#include "msAPI_Tuner.h"
#include "msAPI_Timer.h"
#include "ZL10353.c"
#include "RF_Tuner_DVB.c"
#include "mskeypad.h"
#include "Tuner_pal.h"
#include "SamsungDTVS205.c"
#define TUNER_API_DBG(y) //y
#define SCAN_DEBUG_CH 0x01
#define SCAN_DEBUG_PAL 0x02
#define SCAN_DEBUG_DVB 0x04
#define SCAN_DEBUG 0x00
#define SCAN_DBG(flag,s) if(SCAN_DEBUG & flag) { s; }
/********************************************************************************/
/* Local */
/********************************************************************************/
static MS_TP_SETTING stCurrentTPSetting; //current setting of front end
static EN_VSB_CHECK_LOCK_STATE enVSBCheckLockState = STATE_VSB_CHECK_INIT;
static EN_VSB_CHECK_STABLE_STATE enVSBCheckStableState = STATE_VSB_STABLE_INIT;
static U32 u32CheckLock_Timer; //ms
/********************************************************************************/
/* Functions */
/********************************************************************************/
/******************************************************************************/
/// API for lnitialize Analog Tuner::
/******************************************************************************/
void msAPI_Tuner_TVTunerInitialize(void)
{
devTunerInitialize();
MDrv_VD_McuReset( 200 );
}
/******************************************************************************/
/// API for lnitialize current TP setting::
/******************************************************************************/
void msAPI_Tuner_InintCurrentTPSetting(void)
{
memset(&stCurrentTPSetting, 0, sizeof(stCurrentTPSetting));
}
/******************************************************************************/
/// API for lnitialize tuner::
/******************************************************************************/
void msAPI_Tuner_Initialization(void)
{
msAPI_Tuner_InintCurrentTPSetting();
ZL10353_Power_On_Initialization();
msAPI_Tuner_TVTunerInitialize();
}
/******************************************************************************/
/// API for Set RF tuner frequency::
/// @param u32Frequency \b IN RF frequency need to be tuned
/// @param enModulation \b IN modulation type of TS
/******************************************************************************/
void msAPI_Tuner_SetFreq(U32 u32Frequency, EN_SCAN_MODE enScanMode, EN_BW_MODE enBWMode)
{
U8 tuner_data[8];
//printf("\nmsAPI_Tuner_SetFreq is %lu",u32Frequency);
if(enScanMode==DVB_SCAN)
{
Set_Digital_TUNER((double)u32Frequency/1000, enBWMode, tuner_data);
ZL10353_Tuner_Programming( tuner_data );
ZL10353_FSM_Restart();
ZL10353_BW_Programming(enBWMode);
stCurrentTPSetting.enBandWidth = enBWMode;
}
else
{
//printf("PAL Set Freq\n");
devTunerSetFreq( u32Frequency );
}
stCurrentTPSetting.u32Frequency = u32Frequency;
}
void msAPI_Tuner_SetBW(EN_BW_MODE enBandWidth)
{
ZL10353_BW_Programming(enBandWidth);
stCurrentTPSetting.enBandWidth = enBandWidth;
}
/******************************************************************************/
/// API for Set RF channel::
/// Set RF channel related parameters, such as RF frequency, modulation type
/// @param pstTPSetting \b IN pointer to RF channel information structure
/******************************************************************************/
void msAPI_Tuner_Tune2RfCh(MS_TP_SETTING *pstTPSetting,U16 u16Freq)
{
U8 tuner_data[8];
if(pstTPSetting->fModulation==DEMOD_MODE_DVB)
{
if(pstTPSetting->u32Frequency != stCurrentTPSetting.u32Frequency ||
pstTPSetting->enBandWidth != stCurrentTPSetting.enBandWidth)
{
Set_Digital_TUNER((double)(pstTPSetting->u32Frequency/1000.0), pstTPSetting->enBandWidth, tuner_data);
ZL10353_Tuner_Programming( tuner_data );
ZL10353_FSM_Restart();
ZL10353_BW_Programming(pstTPSetting->enBandWidth);
stCurrentTPSetting.u32Frequency = pstTPSetting->u32Frequency;
stCurrentTPSetting.enBandWidth = pstTPSetting->enBandWidth;
}
}
else
{
devTunerSetChannel(TUNER_SOUND_BG,u16Freq);
devTunerSetSubSys( TUNER_SOUND_BG );
}
}
/******************************************************************************/
/// API for Check is same RF channel::
/// @param pstTPSetting \b IN pointer to RF channel information structure
/// @return same RF or not
/******************************************************************************/
BOOLEAN msAPI_Tuner_IsSameRfChannel(MS_TP_SETTING *pstTPSetting)
{
if(pstTPSetting->u32Frequency==stCurrentTPSetting.u32Frequency)
return TRUE;
else
return FALSE;
}
/******************************************************************************/
/// API for power on off front end::
/// @param bPower \b IN power on or off
/******************************************************************************/
void msAPI_Tuner_PowerOnOff(BOOLEAN bPower)
{
ZL10353_Power_ON_OFF(bPower);
}
/******************************************************************************/
/// API for get current signal SNR::
/// @return current signal SNR condition
/******************************************************************************/
EN_SIGNAL_CONDITION msAPI_Tuner_CheckSignalSNR(void)
{
EN_SIGNAL_CONDITION enSNRStatus;
float fSNRValue;
fSNRValue=ZL10353_GetSNR();
//printf("fSNRValue=%f \r\n",fSNRValue);
if(fSNRValue>25)
{
enSNRStatus=SIGNAL_VERY_STRONG;
}
else if(fSNRValue<=25&&fSNRValue>19)
{
enSNRStatus=SIGNAL_STRONG;
}
else if(fSNRValue<=19&&fSNRValue>13)
{
enSNRStatus=SIGNAL_MODERATE;
}
else if(fSNRValue<=13&&fSNRValue>9)
{
enSNRStatus=SIGNAL_WEAK;
}
else if(fSNRValue<=9)
{
enSNRStatus=SIGNAL_NO;
}
return enSNRStatus;
}
#define NEW_SCAN_API_DBG(y) //y
BOOLEAN msAPI_Demodulator_Reset(void)
{
return TRUE;
}
void msAPI_Check_Lock_State_Init(void)
{
enVSBCheckLockState = STATE_VSB_CHECK_INIT;
enVSBCheckStableState = STATE_VSB_STABLE_INIT;
}
BOOLEAN msAPI_DVB_Check_Lock(BOOLEAN *CheckLockResult)
{
msAPI_Timer_Delayms( 800 );
*CheckLockResult = ZL10353_Lock_Indicate();
return TRUE;
}
#ifdef PAL_TUNER_TEST
U8 temp;
void msAPI_Tuner_PALTest(void)
{
temp=devTunerSetChannel(TUNER_SOUND_BG,7540);
printf("temp=%bd \r\n",temp);
}
#endif
//*************************************************************************
//*************************************************************************
#undef MSAPI_TUNER_C
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -