clkrv.c
上传用户:fy98168
上传日期:2015-06-26
资源大小:13771k
文件大小:5k
- /*****************************************************************************
- File name : clkrv.c
- Description : Clock Recovery functions
- COPYRIGHT (C) STMicroelectronics 2004.
- *****************************************************************************/
- /* Includes --------------------------------------------------------------- */
- #include <string.h>
- #include "stlite.h"
- #include "stdevice.h"
- #include "sttbx.h"
- #include "section.h" /* memory partitions */
- #include "errors.h"
- #include "evt.h"
- #include "clkrv.h"
- #include "stpti_hal.h"
- //#include "tuner.h"
- /* Private Constants -------------------------------------------------- */
- /* Private Variables -------------------------------------------------- */
- /* Private Macros ----------------------------------------------------- */
- /* Private Function prototypes ---------------------------------------- */
- /* Global Variables ------------------------------------------------------- */
- ST_DeviceName_t g_KBCLKRVDeviceName = "CLKRV";
- STCLKRV_Handle_t CLKRV_Handle;
- /* Functions -------------------------------------------------------------- */
- /*-------------------------------------------------------------------------
- * Function : KB_CLKRVSetup
- * Input : None
- * Output :
- * Return : Error Code
- * ----------------------------------------------------------------------*/
- ST_ErrorCode_t KB_CLKRVSetup( void )
- {
- ST_ErrorCode_t ST_ErrorCode;
- STCLKRV_InitParams_t STCLKRV_InitParams;
- STCLKRV_OpenParams_t STCLKRV_OpenParams = 0; /* No parameters */
- STCLKRV_InitParams.DeviceType = KB_CLKRV_DEVICE_TYPE;
- STCLKRV_InitParams.Partition_p = SystemPartition;
- STCLKRV_InitParams.PCRMaxGlitch = KB_CLKRV_PCR_MAX_GLITCH;
- #if 0
- #if defined (BUILD_FOR_DVBS)
- STCLKRV_InitParams.MinSampleThres = KB_CLKRV_MIN_SAMPLE_THRES_SAT;
- STCLKRV_InitParams.PCRDriftThres = KB_CLKRV_PCR_DRIFT_THRES_SAT;
- STCLKRV_InitParams.MaxWindowSize = KB_CLKRV_MAX_WINDOW_SIZE_SAT;
- #elif defined(BUILD_FOR_DVBT)
- /* Set parameters for terrestrial tuner */
- STCLKRV_InitParams.MinSampleThres = KB_CLKRV_MIN_SAMPLE_THRES_TER;
- STCLKRV_InitParams.PCRDriftThres = KB_CLKRV_PCR_DRIFT_THRES_TER_8;
- STCLKRV_InitParams.MaxWindowSize = KB_CLKRV_MAX_WINDOW_SIZE_TER;
- #endif
- #endif
- STCLKRV_InitParams.MinSampleThres = KB_CLKRV_MIN_SAMPLE_THRES_SAT;
- STCLKRV_InitParams.PCRDriftThres = KB_CLKRV_PCR_DRIFT_THRES_SAT;
- STCLKRV_InitParams.MaxWindowSize = KB_CLKRV_MAX_WINDOW_SIZE_SAT;
- STCLKRV_InitParams.FSBaseAddress_p = (U32 *)CKG_BASE_ADDRESS;
- STCLKRV_InitParams.ADSCBaseAddress_p = NULL;
- STCLKRV_InitParams.InterruptNumber = KB_CLKRV_INTERRUPT;
- STCLKRV_InitParams.InterruptLevel = KB_CLKRV_INTERRUPT_LEVEL;
- strcpy( STCLKRV_InitParams.PCREvtHandlerName, "EVT" );
- strcpy( STCLKRV_InitParams.EVTDeviceName, "EVT" );
- strcpy( STCLKRV_InitParams.PTIDeviceName, KB_PTI_DeviceName );
- STTBX_Print(("KB_CLKRVSetup(%s)=", g_KBCLKRVDeviceName ));
- ST_ErrorCode = STCLKRV_Init(g_KBCLKRVDeviceName, &STCLKRV_InitParams);
- if (ST_ErrorCode != ST_NO_ERROR)
- {
- STTBX_Print(("%sn", KB_ErrorGetText(ST_ErrorCode) ));
- return( ST_ErrorCode );
- }
- STTBX_Print(("%sn", STCLKRV_GetRevision() ));
- STTBX_Print(("CLKRV_Open="));
- ST_ErrorCode = STCLKRV_Open(g_KBCLKRVDeviceName, &STCLKRV_OpenParams, &CLKRV_Handle);
- STTBX_Print(("%sn", KB_ErrorGetText(ST_ErrorCode) ));
- ST_ErrorCode = STCLKRV_Enable(CLKRV_Handle);
- if (ST_ErrorCode != ST_NO_ERROR)
- {
- STTBX_Print(("STCLKRV_Enable=%sn", KB_ErrorGetText(ST_ErrorCode) ));
- }
- ST_ErrorCode = STCLKRV_SetSTCOffset(CLKRV_Handle, STC_OFFSET);
- if (ST_ErrorCode != ST_NO_ERROR)
- {
- STTBX_Print(("STCLKRV_SetSTCOffset=%sn", KB_ErrorGetText(ST_ErrorCode) ));
- }
- return( ST_ErrorCode );
- }
- //TMTM added as per 5100
- /*******************************************************************************
- Name : C L K R V _ S e t P C R s o u r c e
- Description : <$functionDescription>
- Parameters :
- Assumptions :
- Limitations :
- Returns : (ST_ErrorCode_t) <$returnDescription>
- *******************************************************************************/
- ST_ErrorCode_t CLKRV_SetPCRsource(STPTI_Slot_t pcrSlot)
- {
- STCLKRV_SourceParams_t STCLKRV_SourceParams;
- ST_ErrorCode_t ST_ErrorCode;
- STCLKRV_SourceParams.Source = STCLKRV_PCR_SOURCE_PTI;
- STCLKRV_SourceParams.Source_u.STPTI_s.Slot = pcrSlot;
-
- ST_ErrorCode = STCLKRV_SetPCRSource(CLKRV_Handle, &STCLKRV_SourceParams);
- if (ST_ErrorCode != ST_NO_ERROR)
- {
- STTBX_Print(("PTI:CLKRV_SetPCRSource(CLKRV)=%s", KB_ErrorGetText(ST_ErrorCode) ));
- }
- return ST_ErrorCode;
- }/* End of C L K R V _ S e t P C R s o u r c e ( ) */
- /* EOF -------------------------------------------------------------------- */