📄 clkrvfilter.c
字号:
#elif defined (ST_7710) || defined (ST_7100) || defined (ST_7109)
switch(Clock)
{
case STCLKRV_CLOCK_PCM_0:
CaptureCntOffset = CAPTURE_COUNTER_PCM;
break;
case STCLKRV_CLOCK_HD_0:
CaptureCntOffset = CAPTURE_COUNTER_HD;
break;
default:
/* what else */
CaptureCntOffset = CAPTURE_COUNTER_PCM;
break;
}
#elif defined (ST_5188)
switch(Clock)
{
case STCLKRV_CLOCK_PCM_0:
CaptureCntOffset = CAPTURE_COUNTER_PCM;
break;
default:
/* what else */
CaptureCntOffset = CAPTURE_COUNTER_PCM;
break;
}
#elif defined (ST_5525)
switch(Clock)
{
case STCLKRV_CLOCK_PCM_0:
if (CB_p->InitPars.DecodeType == STCLKRV_DECODE_PRIMARY)
CaptureCntOffset = CAPTURE_COUNTER_PCM;
else
CaptureCntOffset = CAPTURE_COUNTER_1_PCM;
break;
case STCLKRV_CLOCK_PCM_1:
if (CB_p->InitPars.DecodeType == STCLKRV_DECODE_PRIMARY)
CaptureCntOffset = CAPTURE_COUNTER_PCM_1;
else
CaptureCntOffset = CAPTURE_COUNTER_1_PCM_1;
break;
case STCLKRV_CLOCK_PCM_2:
if (CB_p->InitPars.DecodeType == STCLKRV_DECODE_PRIMARY)
CaptureCntOffset = CAPTURE_COUNTER_PCM_2;
else
CaptureCntOffset = CAPTURE_COUNTER_1_PCM_2;
break;
case STCLKRV_CLOCK_PCM_3:
if (CB_p->InitPars.DecodeType == STCLKRV_DECODE_PRIMARY)
CaptureCntOffset = CAPTURE_COUNTER_PCM_3;
else
CaptureCntOffset = CAPTURE_COUNTER_1_PCM_3;
break;
case STCLKRV_CLOCK_SPDIF_0:
if (CB_p->InitPars.DecodeType == STCLKRV_DECODE_PRIMARY)
CaptureCntOffset = CAPTURE_COUNTER_SPDIF;
else
CaptureCntOffset = CAPTURE_COUNTER_1_SPDIF;
break;
default:
/* what else */
CaptureCntOffset = CAPTURE_COUNTER_PCM;
break;
}
#endif
return CaptureCntOffset;
}
/****************************************************************************
Name : SlaveHaveCounter
Description : To find whether slave has a HW counter associated.
Parameters : Pointer to STCLKRV_ControlBlock_t, Clock
Return Value : ST_ErrorCode_t specified as
ST_NO_ERROR No errors determined
ST_ERROR_BAD_PARAMETER Bad parameter
See Also :
****************************************************************************/
BOOL SlaveHaveCounter(STCLKRV_ClockSource_t ClockSource )
{
#if defined(ST_7100) || defined (ST_7109) || defined (ST_7710)
if( (ClockSource == STCLKRV_CLOCK_PCM_0) ||
(ClockSource == STCLKRV_CLOCK_HD_0))
{
return( TRUE );
}
else
{
return( FALSE );
}
#elif defined (ST_5525)
/* all possible salves */
if( (ClockSource == STCLKRV_CLOCK_PCM_0) ||
(ClockSource == STCLKRV_CLOCK_PCM_1) ||
(ClockSource == STCLKRV_CLOCK_PCM_2) ||
(ClockSource == STCLKRV_CLOCK_PCM_3) ||
(ClockSource == STCLKRV_CLOCK_SPDIF_0))
{
return( TRUE );
}
else
{
return( FALSE );
}
#elif defined (ST_5188)
if( (ClockSource == STCLKRV_CLOCK_PCM_0))
{
return( TRUE );
}
else
{
return( FALSE );
}
#else
if( (ClockSource == STCLKRV_CLOCK_PCM_0) ||
(ClockSource == STCLKRV_CLOCK_SPDIF_0))
{
return( TRUE );
}
else
{
return( FALSE );
}
#endif
}
/****************************************************************************
Name : clkrv_InitHW
Description : Resets the Clock Recovery Hardware Block during Initialization
FS0 to 27MHz and invalidate FS1 ans FS2 in SW
Parameters : Pointer to STCLKRV_ControlBlock_t
Return Value : ST_ErrorCode_t specified as
ST_NO_ERROR No errors determined
ST_ERROR_BAD_PARAMETER Bad parameter
See Also : STCLKRV_Init
****************************************************************************/
ST_ErrorCode_t clkrv_InitHW( STCLKRV_ControlBlock_t *CB_p )
{
U16 i = 0;
STSYS_DU32 *BaseAddress = NULL;
ST_ErrorCode_t ErrorCode = ST_NO_ERROR;
U32 Index =0;
STCLKRV_ClockSource_t MasterClock;
BaseAddress = (STSYS_DU32*)(CB_p->InitPars.FSBaseAddress_p);
#if (STCLKRV_CRYSTAL_ERROR != 0x00)
/* Update nminal frequency table values -
Incase such as crystal is too far off */
clkrv_CorrectCrystalError();
#endif
/* First clock to be set (Pixel normally) */
CB_p->HWContext.ClockIndex = 0;
/* Invalidate all clocks */
for ( i = 0; i < STCLKRV_NO_OF_CLOCKS; i++ )
{
CB_p->HWContext.Clocks[i].Valid = FALSE;
}
i = 0; /* Pixel clock Always at Zero */
Index = CB_p->HWContext.ClockIndex;
/* In 5525, two decodes possible Pixel clock 0/1*/
if (CB_p->InitPars.DeviceType == STCLKRV_DEVICE_TYPE_5525){
if (CB_p->InitPars.DecodeType == STCLKRV_DECODE_PRIMARY)
MasterClock = STCLKRV_CLOCK_SD_0;
else
MasterClock = STCLKRV_CLOCK_SD_1;
}
else {
MasterClock = STCLKRV_CLOCK_SD_0;
}
CB_p->HWContext.Clocks[Index].ClockType = MasterClock;
CB_p->HWContext.Clocks[Index].Frequency = NominalFreqTable[i].Frequency;
CB_p->HWContext.Clocks[Index].SDIV = NominalFreqTable[i].SDIV;
CB_p->HWContext.Clocks[Index].MD = NominalFreqTable[i].MD;
CB_p->HWContext.Clocks[Index].IPE = NominalFreqTable[i].IPE;
CB_p->HWContext.Clocks[Index].Step = NominalFreqTable[i].Step;
CB_p->HWContext.Clocks[Index].Valid = TRUE;
CB_p->HWContext.Clocks[Index].SlaveWithCounter = FALSE;
/* Following parameter is not Valid for SD the master clock */
CB_p->HWContext.Clocks[Index].PrevCounter = 0;
CB_p->HWContext.Clocks[Index].DriftError = 0;
#if defined (ST_7710) || defined (ST_7100) || defined (ST_7109)
CB_p->HWContext.ApplicationMode = STCLKRV_APPLICATION_MODE_NORMAL;
#endif
/* Setup FS setup */
/*
* Input freq divided by 1
* refernece is 27 Mhz
* Analog part switched off
*/
#if defined (ST_5100) || defined (ST_5105) || defined (ST_5301) || defined (ST_5107)
/* Initialize the FS_A to its Default Value */
/* It should be removed */
clkrv_writeRegUnLock( BaseAddress,
FSA_SETUP,
DEFAULT_VAL_FS_A_SETUP);
#elif defined (ST_5188) || defined (ST_5525)
/* TB coded */
#endif
#if defined(ST_7100) || defined(ST_7109)
/* Unlock the registers */
clkrv_writeReg(BaseAddress, 0x00010, 0xC0DE);
/* Set the reference clock source */
clkrv_writeReg(BaseAddress, CKGB_REF_CLK_SRC, 0);
#if (STCLKRV_EXT_CLK_MHZ == 27) || (STCLKRV_EXT_CLK_MHZ == 30)
clkrv_writeReg(BaseAddress, CKGB_REF_CLK_SRC, 1);
#endif
#endif
/* Set Pixel - 27 Mhz Nominal */
ErrorCode = clkrv_setClockFreq( CB_p, MasterClock, Index);
if (ErrorCode==ST_NO_ERROR)
CB_p->HWContext.ClockIndex++;
#if defined (ST_7710)
{
U32 RegValue;
STSYS_DU32 *BaseAddress_AUDFS = (STSYS_DU32*)(CB_p->InitPars.ADSCBaseAddress_p);
clkrv_readReg(BaseAddress_AUDFS, ADSC_IOCONTROL_PROG, &RegValue);
RegValue |= 0x00000002;
clkrv_writeReg(BaseAddress_AUDFS, ADSC_IOCONTROL_PROG, RegValue);
}
#elif defined (ST_7100) || defined (ST_7109)
{
U32 RegValue;
STSYS_DU32 *BaseAddress_AUDFS = (STSYS_DU32*)(CB_p->InitPars.AUDCFGBaseAddress_p);
clkrv_readReg(BaseAddress_AUDFS, AUD_IOCONTROL_PROG, &RegValue);
RegValue |= 0x00000007;
clkrv_writeReg(BaseAddress_AUDFS, AUD_IOCONTROL_PROG, RegValue);
/* Select reference clock source for Audio clocks */
clkrv_readReg(BaseAddress_AUDFS, AUD_FSYN_CFG, &RegValue);
/* STFAE - Reset synthetizer to avoid bad audio on internal dac */
RegValue=RegValue|0x00000001;
clkrv_writeReg(BaseAddress_AUDFS, AUD_FSYN_CFG, RegValue);
RegValue=RegValue&0xFFFFFFFE;
clkrv_writeReg(BaseAddress_AUDFS, AUD_FSYN_CFG, RegValue);
#if ( (STCLKRV_EXT_CLK_MHZ == 27) || (STCLKRV_EXT_CLK_MHZ == 30) )
RegValue |= 0x800000;
clkrv_writeReg(BaseAddress_AUDFS, AUD_FSYN_CFG, RegValue);
#endif
}
#endif
/* Handle this error in Init if something went wrong */
return ErrorCode;
}
/****************************************************************************
Name : STCLKRV_ActionPCR()
Description : Call back function called by STPTI to notify the PCR and STC
values. It signals the waiting clock recovery task and store
current (PCR,STC) data in control block for later references.
ActionPCR will NOT process the PCR that caused it to be
invoked if the PCRHandling is disabled or,
if the SlotID passed is not valid.
Parameters : STEVT_CallReason_t EventReason : Cause
ST_DeviceName_t RegistrantName: Null
STEVT_EventConstant_t EventOccured : Type
STPTI_EventData_t *PcrData_p : Event data
STCLKRV_Handle_t *InstanceHandle_p : Valid handle
Return Value : None
See Also :
****************************************************************************/
/* Use device event callback to get slotID from event handler */
#ifndef STCLKRV_NO_PTI
#if defined(ST_OS20) || defined(ST_OS21) /* linux changes */
void STCLKRV_ActionPCR(STEVT_CallReason_t EventReason,
ST_DeviceName_t RegistrantName,
STEVT_EventConstant_t EventOccured,
#ifdef ST_5188
STDEMUX_EventData_t *PcrData_p,
#else
STPTI_EventData_t *PcrData_p,
#endif
STCLKRV_Handle_t *InstanceHandle_p)
{
STCLKRV_ControlBlock_t *TmpCB_p;
TmpCB_p = (STCLKRV_ControlBlock_t *)InstanceHandle_p;
/* Check handling control status */
if (TmpCB_p->ActvRefPcr.PCRHandlingActive != TRUE)
{
return;
}
/* Check Slot validity */
if ( (TmpCB_p->SlotEnabled != TRUE) ||
#ifdef ST_5188
(PcrData_p->ObjectHandle != TmpCB_p->Slot) ) /* GNBVd06147 */
#else
(PcrData_p->SlotHandle != TmpCB_p->Slot) ) /* GNBVd06147 */
#endif
{
STTBX_Report( (STTBX_REPORT_LEVEL_ERROR, "Invalid handle or slot not enabled"));
return;
}
/* Take semap. STPTI callbakck from event queue, so semap ok */
STOS_SemaphoreWait(TmpCB_p->InstanceSemaphore_p);
/* Store data for future reference */
TmpCB_p->InstancePcrData = *PcrData_p;
STOS_SemaphoreSignal(TmpCB_p->InstanceSemaphore_p);
/* Signal waiting Filter task */
STOS_SemaphoreSignal(TmpCB_p->FilterSemaphore_p);
/* Simply return */
return;
}
#endif
/****************************************************************************
Name : ClockRecoveryFilterTask()
Description : Filter task implemneted to remove PTI callback blocking
Parameters : pointer to control block
Return Value : None
See Also : ActionPCR()
****************************************************************************/
#if defined(ST_OSLINUX) && CLKRV_TESTING==2
ST_ErrorCode_t STPTI_WaitEventList( const STPTI_Handle_t Handle,
U32 NbEvents,
U32 *Events_p,
U32 *Event_That_Has_Occurred,
U32 EventDataSize, /* Size of Event data pointed to by EventData_p */
void *EventData_p )
{
return !ST_NO_ERROR;
}
#endif
#if defined(ST_OS20) || defined(ST_OS21) /* linux changes */
void ClockRecoveryFilterTask(STCLKRV_ControlBlock_t *CB_p)
{
STCLKRV_Print(("ClockRecoveryFilterTask Created..\n"));
STOS_TaskEnter (NULL);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -