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; }
/* * init the epg db * buffer: IN, db node table. */ INT32 init_epg_db(OSAL_ID flag, UINT8 *buffer, UINT32 buf_len) { if (buffer == NULL || buf_len == 0) { DB_PRINT("%s: buffer is NULL!\n",__FUNCTION__); return ERR_FAILED; } MEMSET(buffer, 0, buf_len); db_block.node = (struct DB_NODE*)buffer; db_block.max_count = buf_len / sizeof(struct DB_NODE); db_block.index = 0; db_block.count = 0; DB_PRINT("epg db buffer: 0x%X, len: %d, sizeof DB_NODE: %d, max count: %d\n", buffer, buf_len, sizeof(struct DB_NODE), db_block.max_count); if (flag == OSAL_INVALID_ID) { DB_PRINT("%s: flag ivalid!\n",__FUNCTION__); return ERR_FAILED; } db_block.flag = flag; #ifdef EPG_MULTI_TP g_update_all_events = FALSE; MEMSET(&epg_update_view, 0, sizeof(epg_update_view)); reset_multi_tp(); #endif osal_flag_set(db_block.flag, EPGDB_FLAG_MUTEX); return SUCCESS; }
*****************************************************************************/ static INT32 f_TC90512_open(struct nim_device *dev) { UINT8 data = 0,i=0; UINT8 tdata ; UINT8 lock = 0; struct nim_TC90512_private * priv_mem = (struct nim_TC90512_private *)(dev->priv); struct COFDM_TUNER_CONFIG_API * config_info = &(priv_mem->Tuner_Control); INT32 wStatus=0; UINT8 wAdrs=0,wData=0; UINT8 iexdev=0; UINT8 ilpdev=0; UINT8 adciqin=0; UINT8 zifmd=0; UINT8 dif25m=0; UINT8 dif25v=0; UINT8 difpll=0; UINT8 vlfmd=0; UINT8 f_inv=0; UINT16 hkfrq=0; UINT16 cpld_dt=0; UINT8 lpfsl=0; UINT16 affrq=0; UINT8 agcref1=0; UINT8 agcref2=0; NIM_PRINTF("f_TC90512_open\n"); nim_TC90512_flag = osal_flag_create(NIM_TC90512_FLAG_ENABLE);//050513 Tom if (nim_TC90512_flag==OSAL_INVALID_ID) return ERR_FAILUE; TC90512_CurChannelInfo = (struct TC90512_Lock_Info *)MALLOC(sizeof(struct TC90512_Lock_Info)); if (TC90512_CurChannelInfo == NULL) { NIM_PRINTF("f_TC90512_open MALLOC fail!\n"); return ERR_FAILUE; } MEMSET(TC90512_CurChannelInfo, 0, sizeof(struct TC90512_Lock_Info)); //init TC90512 for (i=0; i<IF_44m_25p4_ary_size;i++) { f_TC90512_write(dev->base_addr,IF_44m_25p4_ary_init[2*i],&IF_44m_25p4_ary_init[2*i+1],1); f_TC90512_read(dev->base_addr,IF_44m_25p4_ary_init[2*i],&tdata,1); NIM_TC90512_PRINTF("reg[%x] = %x\n",IF_44m_25p4_ary_init[2*i],tdata); } osal_flag_set(nim_TC90512_flag,NIM_TC90512_SCAN_END); return SUCCESS;
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 }
/***************************************************************************** * 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;
INT32 x_init_mem(OSAL_ID flag, UINT8 *buffer, UINT32 buf_len) { if (alloc_obj.free_list != NULL || flag == OSAL_INVALID_ID || buffer == NULL || buf_len < sizeof(struct content_t)) { X_PRINT("%s: parameter error!\n",__FUNCTION__); return ERR_FAILED; } alloc_obj.flag = flag; osal_flag_set(alloc_obj.flag, ALLOC_FLAG_MUTEX); alloc_obj.buffer = buffer; alloc_obj.buf_len = buf_len; alloc_obj.free_list = (struct content_t*)buffer; alloc_obj.free_list->next = NULL; alloc_obj.free_list->len = buf_len - sizeof(struct content_t); alloc_obj.status = STATUS_AVAILABLE; X_PRINT("[epg alloc] malloc buffer: 0x%X, len: %d\n",buffer, buf_len); return SUCCESS; }
*****************************************************************************/ 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; }
static void alloc_leave_mutex() { osal_flag_set(alloc_obj.flag, ALLOC_FLAG_MUTEX); }
static void epgdb_leave_mutex() { osal_flag_set(db_block.flag, EPGDB_FLAG_MUTEX); }
static void ogg_play_task(mp_callback_func cb) { long ret = 0; int current_section = 0; double time_seek_to = 0; vorbis_info *vi; struct snd_device *sound_dev; int *processed_pcm; double song_time; PE_DBG_PRINTF("MusicEngine: ==> ogg_play_task()! \n"); sound_dev = (struct snd_device*)dev_get_by_type(NULL, HLD_DEV_TYPE_SND); processed_pcm = (int*)ogg_file->processed_pcm_buff; if (ov_open(ogg_file->file, &ogg_file->vf, NULL, 0) < 0) { PE_DBG_PRINTF("MusicEngine: ogg_play_task() ov_open failed! \n"); #ifdef ENABLE_PE_CACHE pe_cache_close(ogg_cache_id); // 这个ogg_cache_id是在play_file时打开 ogg_cache_id = -1; #else fclose(ogg_file->file); #endif //FREE(processed_pcm); osal_flag_set(ogg_engine.ogg_engine_flag_id, OGG_ENGINE_FLAG_UNSUCCESSFUL); return; } else { PE_DBG_PRINTF("MusicEngine: ov_opened \n"); { vorbis_info *vi = ov_info(&ogg_file->vf, -1); if (!vi) { PE_DBG_PRINTF("MusicEngine: ov_info failed!\n"); ov_clear(&ogg_file->vf); osal_flag_set(ogg_engine.ogg_engine_flag_id, OGG_ENGINE_FLAG_UNSUCCESSFUL); return; } ogg_file->samplerate = vi->rate; ogg_file->channel = vi->channels; PE_DBG_PRINTF("\nBitstream is %d channel, %ldHz\n", vi->channels, vi->rate); song_time = ov_time_total(&ogg_file->vf, -1); if (song_time <= 0) { PE_DBG_PRINTF("MusicEngine: ov_info failed!\n"); ov_clear(&ogg_file->vf); osal_flag_set(ogg_engine.ogg_engine_flag_id, OGG_ENGINE_FLAG_UNSUCCESSFUL); } } osal_flag_set(ogg_engine.ogg_engine_flag_id, OGG_ENGINE_FLAG_SUCCESS); } //all work success, we can start to play while (ogg_file->command != OGG_CMD_STOP) { if (ogg_file->seek_to != 0) { time_seek_to = ov_time_tell(&ogg_file->vf); time_seek_to = time_seek_to + (ogg_file->seek_to * 1000); if (time_seek_to < 0) { time_seek_to = 0; } else if (time_seek_to > song_time) { time_seek_to = song_time; } ret = ov_time_seek(&ogg_file->vf, time_seek_to); if (ret < 0) { //seek failed } osal_task_dispatch_off(); ogg_file->seek_to = 0; osal_task_dispatch_on(); } if (ogg_file->command == OGG_CMD_NONE) { ret = ov_read(&ogg_file->vf, (void *)ogg_file->pcm_out_buff, 2304, ¤t_section); if (ret == 0) { PE_DBG_PRINTF("file end!\n"); //EOF we need call back osal_task_dispatch_off(); if (ogg_file->command != OGG_CMD_STOP) { ogg_file->command = OGG_CMD_WAIT_FOR_STOP; } osal_task_dispatch_on(); cb(MP_MUSIC_PLAYBACK_END, 0); osal_task_sleep(10); } else if (ret < 0) { PE_DBG_PRINTF("error!!!\n"); /* error in the stream. Not a problem, just reporting it in case we (the app) cares. In this case, we don't. */ osal_task_dispatch_off(); if (ogg_file->command != OGG_CMD_STOP) { ogg_file->command = OGG_CMD_WAIT_FOR_STOP; } osal_task_dispatch_on(); cb(MP_MUSIC_PLAYBACK_END, 0); osal_task_sleep(10); } else { /* we don't bother dealing with sample rate changes, etc, but you'll have to*/ process_ogg_pcm(sound_dev, ret, processed_pcm); } } else { osal_task_sleep(10); } } ov_clear(&ogg_file->vf); ogg_avoid_under_run = 0; snd_io_control(sound_dev, SND_CC_MUTE, 0); snd_stop(sound_dev); //FREE(processed_pcm); osal_flag_set(ogg_engine.ogg_engine_flag_id, OGG_ENGINE_FLAG_TASK_EXIT); // task结束,发出EXIT消息 PE_DBG_PRINTF("MusicEngine: <== ogg_play_task()! \n"); }
void tr_condSignal( tr_cond_t * c ) { osal_flag_set(g_trans_flag, *c); }