static PRESULT win_progname_message_proc(UINT32 msg_type, UINT32 msg_code) { PRESULT ret = PROC_LOOP; switch(msg_type) { case CTRL_MSG_SUBTYPE_CMD_EPG_PF_UPDATED: event_update=TRUE; osal_flag_clear(epg_flag, EPG_MSG_FLAG_PF); case CTRL_MSG_SUBTYPE_CMD_EPG_SCH_UPDATED: case CTRL_MSG_SUBTYPE_CMD_TIMEDISPLAYUPDATE: case CTRL_MSG_SUBTYPE_STATUS_SIGNAL: win_progname_redraw(); event_update=FALSE; if(msg_type==CTRL_MSG_SUBTYPE_STATUS_SIGNAL) { ret = PROC_PASS; } else if(msg_type==CTRL_MSG_SUBTYPE_CMD_EPG_SCH_UPDATED) { osal_flag_clear(epg_flag, EPG_MSG_FLAG_SCH); } break; case CTRL_MSG_SUBTYPE_CMD_EXIT: if(sys_data_get_cur_chan_mode() == TV_CHAN) ret = PROC_LEAVE; break; default: ret = PROC_PASS; } return ret; }
INT32 psi_module_init(struct dmx_device *dmx, struct nim_device *nim, void *work_place, INT32 length) { if (psi_flag ==OSAL_INVALID_ID) { psi_flag = osal_flag_create(PSI_FLAG_STAT_MUTEX); if (psi_flag == OSAL_INVALID_ID) { PSI_PRINTF("%s: psi_flag create failure!\n"); return ERR_FAILUE; } } else { osal_flag_clear(psi_flag, 0xFFFFFFFF); osal_flag_set(psi_flag, PSI_FLAG_STAT_MUTEX); } if ((work_place==NULL) ||(length<(INT32)sizeof(struct psi_module_info))) { PSI_PRINTF("%s: work_place parameter invalid!\n", __FUNCTION__); return ERR_FAILUE; } psi_info = (struct psi_module_info *)work_place; MEMSET(psi_info, 0, sizeof(struct psi_module_info)); psi_info->dmx = dmx; psi_info->nim = nim; return SUCCESS; }
static INT32 win_otaupg_download(void) { ota_proc_ret = 0; ota_user_stop = 0; ota_proc_step = OTA_STEP_DOWNLOADING; osal_flag_clear(g_ota_flg_id,OTA_FLAG_PTN); ota_start_download(ota_pid,win_ota_upgrade_process_update); }
static INT32 win_otaupg_get_info(void) { ota_proc_ret = 0; ota_user_stop = 0; ota_proc_step = OTA_STEP_GET_INFO; osal_flag_clear(g_ota_flg_id,OTA_FLAG_PTN); ota_get_download_info(ota_pid,&ota_dl_info); }
static INT32 psi_wait_stat(UINT32 good, UINT32 clear) { INT32 ret = SI_SUCCESS; #define ABNORMAL_STAT (PSI_FLAG_STAT_ABORT|PSI_FLAG_STAT_STOFULL|PSI_FLAG_STAT_RELEASE) UINT32 flag; osal_flag_wait(&flag, psi_flag, good|ABNORMAL_STAT, OSAL_TWF_ORW, OSAL_WAIT_FOREVER_TIME); if (flag&(PSI_FLAG_STAT_ABORT|PSI_FLAG_STAT_RELEASE)) { ret = SI_UBREAK; } else if (flag&PSI_FLAG_STAT_STOFULL) { ret = SI_STOFULL; } else if (flag&clear) { osal_flag_clear(psi_flag, flag&clear); } return ret; }
static INT32 win_otaupg_burnflash(void) { ota_proc_ret = 0; ota_user_stop = 0; ota_proc_step = OTA_STEP_BURNFLASH; osal_flag_clear(g_ota_flg_id,OTA_FLAG_PTN); #if 1 InitStorage(); SetupOtaParameters(); INT32 ret = BurnFlash(); osal_flag_set(g_ota_flg_id,(ret == SUCCESS)?PROC_SUCCESS:PROC_FAILURE); #else ota_start_burnflash(win_ota_upgrade_process_update); #endif }
static INT32 psi_wait_stat(UINT32 good, UINT32 clear) { INT32 ret = SI_SUCCESS; #define ABNORMAL_STAT (PSI_FLAG_STAT_ABORT|PSI_FLAG_STAT_STOFULL|PSI_FLAG_STAT_RELEASE) UINT32 flag; osal_flag_wait(&flag, psi_flag, good|ABNORMAL_STAT, OSAL_TWF_ORW, 20*PSI_MODULE_TIMEOUT_EXTENTION); /* When the waiting Table does not exist in Stream, wait forever will cause this task can not wakeup */ /* OSAL_WAIT_FOREVER_TIME); */ if (flag&(PSI_FLAG_STAT_ABORT|PSI_FLAG_STAT_RELEASE)) { ret = SI_UBREAK; } else if (flag&PSI_FLAG_STAT_STOFULL) { ret = SI_STOFULL; } else if (flag&clear) { osal_flag_clear(psi_flag, flag&clear); } return ret; }
static INT32 win_otaupg_reboot(void) { ota_proc_ret = 0; ota_user_stop = 0; //ota_proc_step = OTA_STEP_BURNFLASH; osal_flag_clear(g_ota_flg_id,OTA_FLAG_PTN); key_pan_display("OFF ",4); osal_task_sleep(500); power_off_process(); sys_data_factroy_init(); sys_data_set_factory_reset(TRUE); sys_data_set_cur_chan_mode(TV_CHAN); power_on_process(); while(1) ; }
/***************************************************************************** * INT32 f_TC90512_channel_search(struct nim_device *dev, UINT32 freq); * Description: TC90512 channel search operation * * Arguments: * Parameter1: struct nim_device *dev * Parameter2: UINT32 freq : Frequency* * Return Value: INT32 *****************************************************************************/ //050803 yuchun add static INT32 f_TC90512_channel_search(struct nim_device *dev, UINT32 freq,UINT32 bandwidth, UINT8 guard_interval, UINT8 fft_mode, UINT8 modulation, UINT8 fec, UINT8 usage_type, UINT8 inverse,UINT16 freq_offset,UINT8 priority) { UINT8 i,data[1]; INT32 chsearch=ERR_FAILED ,center_freq; INT32 freq_offset_reg; UINT32 Center_NPRO,Search_NPRO,tmp_freq; UINT32 First_Frequency; UINT8 num,freq_step; UINT8 j=0,k = 0; INT32 get_freq_offset; INT32 remainder; UINT16 temp_Step_Freq; osal_flag_clear(nim_TC90512_flag,NIM_TC90512_SCAN_END); chsearch=f_TC90512_channel_change(dev,freq,bandwidth,guard_interval,fft_mode,modulation,fec,usage_type,inverse, priority); osal_flag_set(nim_TC90512_flag,NIM_TC90512_SCAN_END); return chsearch;
*****************************************************************************/ static INT32 f_TC90512_channel_change(struct nim_device *dev, UINT32 freq, UINT32 bandwidth, UINT8 guard_interval, UINT8 fft_mode, UINT8 modulation, UINT8 fec, UINT8 usage_type, UINT8 inverse,UINT8 priority) { UINT8 data[6]; //51117-01Angus UINT32 temp; UINT8 ret_flag = SCAN_TIMEOUT;// LOCK_OK; UINT32 start_time, temp_time; struct nim_TC90512_private *dev_priv; //51117-01Angus UINT8 code_rate,Tuner_Retry=0,Demod_Retry=0,hier=0; UINT8 lock=0,i=0; dev_priv = (struct nim_TC90512_private *)dev->priv; UINT32 tuner_id = 0;//dev_priv->tuner_id; osal_flag_clear(nim_TC90512_flag, NIM_TC90512_CHECKING); NIM_TC90512_PRINTF("freq %d, bandwidth %d\n",freq,bandwidth); osal_flag_clear(nim_TC90512_flag,NIM_TC90512_SCAN_END); TC90512_CurChannelInfo->Frequency = freq; TC90512_CurChannelInfo->ChannelBW = bandwidth; dev_priv = dev->priv; /*-------------------------------------------------------------------------*/ /* (1)Set demod */ /*-------------------------------------------------------------------------*/ if(bandwidth!=6) return ERR_FAILED; //data[0]=0x00; // f_TC90512_write(dev->base_addr, 0x03, data,1); /*-------------------------------------------------------------------------*/ /* (2)Set Tuner & Channel Acquisition: */ /*-------------------------------------------------------------------------*/ //f_TC90512_PassThrough(dev,TRUE); if(dev_priv->Tuner_Control.nim_Tuner_Control(tuner_id, freq,bandwidth,FAST_TIMECST_AGC,data,_1st_i2c_cmd)!=SUCCESS) { NIM_TC90512_PRINTF("WRITE tuner fail\n"); } sembsl_tc90512_reset(dev); /*-------------------------------------------------------------------------*/ /* (3)WAIT TUNER_LOCK */ /*-------------------------------------------------------------------------*/ //start_time = osal_get_tick(); Tuner_Retry=0; do { //if((dev_priv->Tuner_Control.tuner_config.cChip)==Tuner_Chip_INFINEON|| (dev_priv->Tuner_Control.tuner_config.cChip)==Tuner_Chip_MAXLINEAR) Tuner_Retry++; //f_TC90512_PassThrough(dev,TRUE); if(dev_priv->Tuner_Control.nim_Tuner_Status(tuner_id ,&lock)==ERR_FAILUE) { NIM_TC90512_PRINTF("read tuner fail\n"); ; } //f_TC90512_PassThrough(dev,FALSE); NIM_TC90512_PRINTF("Wait Tuner:lock=%d\n ",lock); if(lock==1) break; else if(Tuner_Retry>5) { NIM_TC90512_PRINTF("Tuner_ULock\n"); osal_flag_set(nim_TC90512_flag,NIM_TC90512_SCAN_END); return ERR_FAILED; } }while(lock==0); /*-------------------------------------------------------------------------*/ /* (4)WAIT SYNC_LOCK */ /*-------------------------------------------------------------------------*/ start_time = osal_get_tick(); Demod_Retry=0; while(1) { f_TC90512_read(dev->base_addr,0x96,data,1); if(data[0]&0xE0) { ret_flag = LOCK_OK; break; } f_TC90512_read(dev->base_addr,0xB0,data,1); data[0]&=0x0F; /*Demod_Retry++; if((Demod_Retry>20) &&(data[0]<8)) { Demod_Retry=0; libc_printf("NO TP\n"); return ERR_FAILED; }*/ temp_time = osal_get_tick(); if(temp_time >= start_time ? ( temp_time - start_time >1024) : (start_time - temp_time < 0xFFFFFFFF - 1024)) { ret_flag = SCAN_TIMEOUT; NIM_TC90512_PRINTF("TC90512_SYMBOL_NO_LOCK data[0] =0x%x ,ret=%d \n", data[0],ret_flag); osal_flag_set(nim_TC90512_flag,NIM_TC90512_SCAN_END); return ERR_FAILED; } } /*-------------------------------------------------------------------------*/ /* (7)Status update: */ /*-------------------------------------------------------------------------*/ if (ret_flag == LOCK_OK || ret_flag == TPS_UNLOCK || ret_flag == FEC_UNLOCK) { TC90512_CurChannelInfo->Frequency = freq; TC90512_CurChannelInfo->ChannelBW = (UINT8)bandwidth; f_TC90512_getinfo(dev, &code_rate, &guard_interval, &fft_mode, &modulation,&hier); //MT352_CurChannelInfo->HPRates = code_rate; TC90512_CurChannelInfo->Guard= guard_interval; TC90512_CurChannelInfo->Mode= fft_mode; TC90512_CurChannelInfo->Modulation= modulation; TC90512_CurChannelInfo->FECRates = code_rate; TC90512_CurChannelInfo->Hierarchy = hier; TC90512_CurChannelInfo->Priority=priority; TC90512_CurChannelInfo->lock_status=1; NIM_TC90512_PRINTF("SUCCESS end_time = %d\n",osal_get_tick()-start_time); osal_flag_set(nim_TC90512_flag,NIM_TC90512_SCAN_END); return SUCCESS; } else { TC90512_CurChannelInfo->lock_status=0; NIM_TC90512_PRINTF("ERR_FAILED end_time = %d ret=%d\n",osal_get_tick()-start_time,ret_flag); osal_flag_set(nim_TC90512_flag,NIM_TC90512_SCAN_END); return ERR_FAILED; }