📄 xp_osi_clk.c
字号:
| XXXX XX XX XX XX XX| XX XX XX XX XX XX| XX XX XXXXX XX XX| XXXXXX XX XX XX| XX XX XX XX XX XX| XX XX XX XXXXXX XXXXX+----------------------------------------------------------------------------*//*----------------------------------------------------------------------------+| xp0_clk_get_errors+----------------------------------------------------------------------------*/void xp_osi_clk_get_errors(GLOBAL_RESOURCES *pGlobal,XP_CLK_STATUS_PTR pClkStatus){ pClkStatus->Incons_data = pGlobal->ClkInfo.XpClkInconsData; pClkStatus->Errors = pGlobal->ClkInfo.XpClkErrs;}/*----------------------------------------------------------------------------+| xp0_clk_set_pid+-----------------------------------------------------------------------------+|| DESCRIPTION: define the PID value which contains the PCR's|| PROTOTYPE : void xp0_clk_set_pid(| unsigned short pid)|| ARGUMENTS : pid - PID value containing PCRs.|| RETURNS :|| ERRORS :|| COMMENS : This function is called to set the pid which contains| the PCR information used for clock synchronization.| When the PCR pid is written, the hardware will load the| next PCR value into the stc register. This action| generates an XP_INTERRUPT_IR_STCL interrupt.|+----------------------------------------------------------------------------*/void xp_osi_clk_set_pid(GLOBAL_RESOURCES *pGlobal,USHORT uwPid){ unsigned reg; XP_PCRPID_REGP p_reg; UINT32 flag; /*------------------------------------------------------------------------+ | Do not use xp0_os_semaphore_wait() since called from an interrupt +------------------------------------------------------------------------*/ p_reg = (XP_PCRPID_REG *)(void *) ® p_reg->res1 = 0; p_reg->pidv = uwPid; flag = os_enter_critical_section(); xp_atom_dcr_write(pGlobal->uDeviceIndex,XP_DCR_ADDR_PCRPID, reg); os_leave_critical_section(flag); pGlobal->ClkInfo.XpClkNpcrs = 0; /* Initialize to 0 */}/*----------------------------------------------------------------------------+| xp0_clk_start+-----------------------------------------------------------------------------+|| FUNCTION : xp0_clk_start|| DESCRIPTION : This function is called to start using the clock| recovery algorithms (software/hardware combination)| provided with the driver.|| COMMENTS : The function xp0_clk_stop() is used to turn off the| default clock recovery routines.|| NOTES : xp0_clk_start() is called during driver initialization.|+----------------------------------------------------------------------------*/SHORT xp_osi_clk_start(GLOBAL_RESOURCES *pGlobal){ UINT32 flag; if(pGlobal->ClkInfo.XpClkInstalled == 0) { pGlobal->ClkInfo.XpClkInstalled = 1; pGlobal->ClkInfo.XpClkInconsData = 0; pGlobal->ClkInfo.XpClkErrs = 0; pGlobal->ClkInfo.XpClkNpcrs = PCRS_HIGH_GAIN; /*--------------------------------------------------------------------+ | Setup the stcThreshold to be 0 and Setup the Interrupt | Notification function to Process each stcThreshhold | Turn on AutoPWM +--------------------------------------------------------------------*/ flag = os_enter_critical_section(); xp_atom_dcr_write(pGlobal->uDeviceIndex,XP_DCR_ADDR_PCRSTCT, 0); os_leave_critical_section(flag); xp_osi_interrupt_notify( pGlobal, XP_INTERRUPT_NOTIFY_ADD, XP_INTERRUPT_IR_PCR | XP_INTERRUPT_IR_STCL, (PFS)pcr_interrupt); flag = os_enter_critical_section(); xp_atom_dcr_write_register(pGlobal->uDeviceIndex,XP_CONFIG1_REG_APWMA, 1); os_leave_critical_section(flag); } return(0);}/*----------------------------------------------------------------------------+| xp0_clk_stop+-----------------------------------------------------------------------------+|| FUNCTION : xp0_clk_stop|| DESCRIPTION : This function is called to stop using the clock| recovery algorithms (software/hardware combination)| provided with the driver.|| COMMENTS : Clock recovery functions may be re-started using the| xp0_clk_start() function.|+----------------------------------------------------------------------------*/void xp_osi_clk_stop(GLOBAL_RESOURCES *pGlobal){ UINT32 flag; if(pGlobal->ClkInfo.XpClkInstalled) { pGlobal->ClkInfo.XpClkInstalled = 0; /*--------------------------------------------------------------------+ | Setup Interrupt notification function to process each | stcThreshhold. Turn off AutoPWM +--------------------------------------------------------------------*/ xp_osi_interrupt_notify(pGlobal,XP_INTERRUPT_NOTIFY_DELETE, XP_INTERRUPT_IR_PCR | XP_INTERRUPT_IR_STCL, (PFS)pcr_interrupt); flag = os_enter_critical_section(); xp_atom_dcr_write_register(pGlobal->uDeviceIndex,XP_CONFIG1_REG_APWMA, 0); os_leave_critical_section(flag); if(stc_notify_fn != NULL) { xp_osi_interrupt_notify( pGlobal, XP_INTERRUPT_NOTIFY_DELETE, XP_INTERRUPT_IR_STCC, (PFS)stc_interrupt); xp_osi_interrupt_status_notify( pGlobal, XP_INTERRUPT_NOTIFY_DELETE, XP_INTERRUPT_FESTAT_FPCR, (PFS)first_pcr_interrupt); stc_notify_fn = NULL; } }}int xp_osi_clk_set_stc_compare(GLOBAL_RESOURCES *pGlobal,ULONG stc_high){ UINT32 flag; if(pGlobal->uDeviceIndex != 0) return -1; flag = os_enter_critical_section(); xp_atom_dcr_write(pGlobal->uDeviceIndex,XP_DCR_ADDR_STCCOMP,stc_high); os_leave_critical_section(flag); return 0;}int xp_osi_clk_set_stc_event_notify(GLOBAL_RESOURCES *pGlobal,XP_STC_NOTIFY_FN notify_fn){ if(notify_fn == NULL) return -1; if(stc_notify_fn != NULL) { xp_osi_interrupt_notify( pGlobal, XP_INTERRUPT_NOTIFY_DELETE, XP_INTERRUPT_IR_STCC, (PFS)stc_interrupt); xp_osi_interrupt_status_notify( pGlobal, XP_INTERRUPT_NOTIFY_DELETE, XP_INTERRUPT_FESTAT_FPCR, (PFS)first_pcr_interrupt); stc_notify_fn = NULL; } stc_notify_fn = notify_fn; xp_osi_interrupt_notify( pGlobal, XP_INTERRUPT_NOTIFY_ADD, XP_INTERRUPT_IR_STCC, (PFS)stc_interrupt); xp_osi_interrupt_status_notify( pGlobal, XP_INTERRUPT_NOTIFY_ADD, XP_INTERRUPT_FESTAT_FPCR, (PFS)first_pcr_interrupt); return 0;}int xp_osi_clk_release_stc_event(GLOBAL_RESOURCES *pGlobal){ if(stc_notify_fn != NULL) { xp_osi_interrupt_notify( pGlobal, XP_INTERRUPT_NOTIFY_DELETE, XP_INTERRUPT_IR_STCC, (PFS)stc_interrupt); xp_osi_interrupt_status_notify( pGlobal, XP_INTERRUPT_NOTIFY_DELETE, XP_INTERRUPT_FESTAT_FPCR, (PFS)first_pcr_interrupt); stc_notify_fn = NULL; return 0; } return -1;}void stc_interrupt(GLOBAL_RESOURCES *pGlobal,ULONG ulInterrupt){ ULONG flag; flag = os_enter_critical_section(); xp_atom_dcr_write(pGlobal->uDeviceIndex,XP_DCR_ADDR_STCCMPD,0xffffffff); os_leave_critical_section(flag); if(ulInterrupt & XP_INTERRUPT_IR_STCC) { if(stc_notify_fn != NULL) { (*stc_notify_fn)(pGlobal,STC_FIRED); } }}void first_pcr_interrupt(GLOBAL_RESOURCES *pGlobal,ULONG ulInterrupt){ if(ulInterrupt & XP_INTERRUPT_IR_STCC) { if(stc_notify_fn != NULL) { (*stc_notify_fn)(pGlobal,STC_PRESENT); } }}void xp_osi_clk_get_current_stc(GLOBAL_RESOURCES *pGlobal, STC_TYPE *stc_type_ptr){ ULONG flag; ULONG stc_high; ULONG stc_low; flag = os_enter_critical_section(); stc_high = xp_atom_dcr_read(pGlobal->uDeviceIndex,XP_DCR_ADDR_STCHI); stc_low = xp_atom_dcr_read(pGlobal->uDeviceIndex,XP_DCR_ADDR_STCLOW); os_leave_critical_section(flag); stc_type_ptr->base_time1 = ((stc_high & 0xfffffffe) << 1) | ((stc_low & 0x00000200) >> 9); stc_type_ptr->base_time2 = (stc_high & 0x80000000)>>31; return;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -