Exemplo n.º 1
0
void tr_condWait( tr_cond_t * c, tr_lock_t * l )
{
	UINT32 fptn;
	osal_mutex_unlock(*l);
	osal_flag_wait(&fptn, g_trans_flag, *c, OSAL_TWF_ANDW| OSAL_TWF_CLR, OSAL_WAIT_FOREVER_TIME);
	osal_mutex_lock(*l, OSAL_WAIT_FOREVER_TIME);
}
Exemplo n.º 2
0
/*****************************************************************************
* INT32 f_TC90512_get_lock(struct nim_device *dev, UINT8 *lock)
*
*  Read FEC lock status
*
*Arguments:
*  Parameter1: struct nim_device *dev
*  Parameter2: BOOL *fec_lock
*
*Return Value: INT32
*****************************************************************************/

static INT32 f_TC90512_get_lock(struct nim_device *dev, UINT8 *lock)
{
	UINT8 data=0;
	OSAL_ER	result;
       UINT32	flgptn;
	static UINT32 dd_time=0; 
	UINT8 ber_vld;
	UINT32 m_vbber, m_per;	
	
	result = osal_flag_wait(&flgptn,nim_TC90512_flag, NIM_TC90512_SCAN_END, OSAL_TWF_ANDW,0);
	if(OSAL_E_OK!=result)
	{
        	//libc_printf("Get LOCK Fail, Wait ChannelChg Complete!\n");
		*lock=0xff;
	}    
	
	else 
	{	
 		 f_TC90512_read(dev->base_addr,0xB0,&data,1); 
   		data&=0x0F; 
		
    		if(0<data) 
		{		
			NIM_TC90512_PRINTF("FE_HAS_SIGNAL ! \n");
		}
		if(2<data) 
		{		
			NIM_TC90512_PRINTF("FE_HAS_CARRIER ! \n");
		}
		if(8<data) 
		{		
			NIM_TC90512_PRINTF("FE_HAS_SYNC ! \n");
		}

		 f_TC90512_read(dev->base_addr,0x96,&data,1); 
   				  
		 if(data&0xE0) 
		 {
			NIM_TC90512_PRINTF("FE_HAS_VITERBI ! \n");
			*lock=1;
			TC90512_CurChannelInfo->lock_status=1;
		 }
		 else
		 {	
		 	*lock=0;
			TC90512_CurChannelInfo->lock_status=0;
		 }

		  f_TC90512_read(dev->base_addr,0xB2,&data,1); 		   
   		  if(data&0x02)	
		  {	
		  	//libc_printf("EWS start\n");
		  	;
   		  }	
	
	}
	
	return SUCCESS;
Exemplo n.º 3
0
static PRESULT	win_otaupg_message_proc(UINT32 msg_type, UINT32 msg_code)
{
	PRESULT ret = PROC_PASS;
    UINT flgptn = 0;
	
	if(ret == PROC_PASS && ota_proc_ret==0)
	{
		osal_flag_wait(&flgptn,g_ota_flg_id, OTA_FLAG_PTN, OSAL_TWF_ORW, OTA_FLAG_TIMEOUT);

		switch(ota_proc_step)
		{
		case OTA_STEP_GET_INFO:
 		case OTA_STEP_DOWNLOADING:		
	        if(ota_user_stop &&  (flgptn & PROC_STOPPED ) )
	            ota_proc_ret = PROC_STOPPED;
			
	        if(!ota_user_stop && (flgptn & PROC_FAILURE) )
	        	{
	            ota_proc_ret = PROC_FAILURE;
	        	}
			
	        if(flgptn & PROC_SUCCESS)
	        {
	            if(ota_user_stop)   
	               ota_proc_ret = PROC_STOPPED;
	            else
	               ota_proc_ret = PROC_SUCCESS;
	        }
			//libc_printf("flgptn == %d,ota_proc_ret ==%d\n",flgptn,ota_proc_ret);
			break;
			
		case OTA_STEP_BURNFLASH:
			if(flgptn & PROC_FAILURE)
				ota_proc_ret = PROC_FAILURE;
			if(flgptn & PROC_SUCCESS)
				ota_proc_ret = PROC_SUCCESS;
			break;
		
		}

		if(ota_proc_ret!= 0)
		{
			win_otaup_set_btn_msg_display(TRUE);	
			if(ota_proc_step == OTA_STEP_GET_INFO)
				win_otaup_set_swinfo_display(TRUE);
		}
	}

	return ret;
}
Exemplo n.º 4
0
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;
}
Exemplo n.º 5
0
static void ogg_stop(void)
{
	unsigned long									ogg_engine_flag;
	if (ogg_file && ogg_file->command != OGG_CMD_STOP)
	{
		osal_task_dispatch_off();
		ogg_file->command = OGG_CMD_STOP;
		osal_task_dispatch_on();
		
		osal_flag_wait(&ogg_engine_flag, ogg_engine.ogg_engine_flag_id, OGG_ENGINE_FLAG_MASK, OSAL_TWF_ORW | OSAL_TWF_CLR, OSAL_WAIT_FOREVER_TIME);
		
		ogg_engine.ogg_engine_task_id = OSAL_INVALID_ID;
		osal_flag_delete(ogg_engine.ogg_engine_flag_id);
		ogg_engine.ogg_engine_flag_id = OSAL_INVALID_ID;

	}
}
Exemplo n.º 6
0
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;
}
Exemplo n.º 7
0
*****************************************************************************/
static INT32 f_TC90512_get_SNR(struct nim_device *dev, UINT8 *snr)
{
	UINT8	data;
	OSAL_ER result;
	UINT32 	flgptn;
	UINT32 vbber=0;

		
	result = osal_flag_wait(&flgptn,nim_TC90512_flag, NIM_TC90512_SCAN_END, OSAL_TWF_ANDW,0);
    //libc_printf("SNR result = %d\r\n",result);
	if(OSAL_E_OK!=result)
	{
        	NIM_PRINTF("Get SNR Fail, Wait ChannelChg Complete!\n");
		*snr = 0;		
	}    
	else
	{	
		if(TC90512_CurChannelInfo->lock_status==1)
		{	

			// f_TC90512_get_BER(dev, &vbber);
			
			if(TC90512_CurChannelInfo->strength==100)
			*snr=100;
			else
			*snr=TC90512_CurChannelInfo->strength-2;

			if(*snr>100)
				*snr=100;

			if(*snr<20)
				*snr=20;

			//libc_printf("%d\n",*snr);
		}
		else
			*snr=0;
	}
		return SUCCESS;		
Exemplo n.º 8
0
*****************************************************************************/
static INT32 f_TC90512_get_BER(struct nim_device *dev, UINT32 *vbber)
{
	UINT32 dwPeriod=0,dwCount=0;
	UINT32 temp,temp1;
	UINT32 ber;
	INT32 i;
	UINT8 bytes[3];
	OSAL_ER result;
	UINT32 	flgptn;


	result = osal_flag_wait(&flgptn,nim_TC90512_flag, NIM_TC90512_SCAN_END, OSAL_TWF_ANDW,0);
	//libc_printf("BER result = %d\r\n",result);
	if(OSAL_E_OK!=result)
	{
        	NIM_PRINTF("Get SNR Fail, Wait ChannelChg Complete!\n");
		*vbber = 0;	
	}    
	else
	{
		 f_TC90512_read(dev->base_addr,0x96,bytes,1); 

		if(bytes[0]&0x02) //b_flag
		{ 
		        f_TC90512_read(dev->base_addr,0xA0,bytes,3); 
		      
		        dwCount=(bytes[0]<<16)|(bytes[1]<<8)|(bytes[2]);  
		        dwCount=((100000000/(1024*204*8))*dwCount);
			TC90512_ber=dwCount;
			*vbber=dwCount;
			NIM_TC90512_PRINTF("ber=%d\n",dwCount);
		       // p_obj->state.ber[1]=(BERcount+p_obj->state.ber[1])>>1; 
	    	} 

	
	}
	return SUCCESS;			
Exemplo n.º 9
0
*****************************************************************************/
static INT32 f_TC90512_get_freq(struct nim_device *dev, UINT32 *freq)
{
	INT32 freq_off=0;
	UINT8  data[3];
	INT32  tdata=0;
        OSAL_ER	result;
        UINT32	flgptn;       
#if 0
 	result = osal_flag_wait(&flgptn,nim_TC90512_flag, NIM_TC90512_SCAN_END, OSAL_TWF_ANDW,0);//050725 yuchun
	if(OSAL_E_OK!=result)
	{
        	NIM_PRINTF("Get Frequency Fail, Wait ChannelChg Complete!\n");
		*freq=0;
	}    
        
		
#endif	

	*freq=TC90512_CurChannelInfo->Frequency;
       
	return SUCCESS;
	
Exemplo n.º 10
0
*****************************************************************************/
static INT32 f_TC90512_get_AGC(struct nim_device *dev, UINT16 *agc)
{
	 UINT8		data[2];
	 UINT16		agc_if=0;	 
	 OSAL_ER	result;
	 UINT32		flgptn;	
 	 UINT16	rssi;
	struct nim_TC90512_private *dev_priv;
	 
	result = osal_flag_wait(&flgptn,nim_TC90512_flag, NIM_TC90512_SCAN_END, OSAL_TWF_ANDW,0);
	//libc_printf("AGC result = %d\r\n",result);
	if(OSAL_E_OK!=result)
	{
        	NIM_PRINTF("Get AGC Fail, Wait ChannelChg Complete!\n");
		*agc = 0;		
	} 
	else
	{ 
		if(TC90512_CurChannelInfo->lock_status==1)
		{		

			  f_TC90512_read(dev->base_addr,0x82,data,2); //0x82 if_agc.0x83 rf_agc
			  //libc_printf("If_agc=%x ,RF agc=%x\n",data[0],data[1]);
			  
			  rssi=(UINT16)(~((data[1]<<8)|data[0])); 

			  //libc_printf("rssi=%d\n",rssi);

			  if(rssi>255)
			  	rssi=255;

			  if(rssi<155)
			  	rssi=155;

			  if(rssi>212)
			  	*agc=100;
			 else if((rssi>195)&&(rssi<=212))
			 	*agc=rssi-120;
			  else if((rssi>184)&&(rssi<=195))
			 	*agc=rssi-130;
			 else if((rssi>176)&&(rssi<=184))
			 	*agc=rssi-155;
			 else
				*agc=20;
			 
			  TC90512_CurChannelInfo->strength= *agc;
			  
			  //libc_printf("AGC=%d\n",*agc);

		}
		else
		{	
			*agc=0;
			  TC90512_CurChannelInfo->strength=0;
		}
	}

	return SUCCESS;



	
Exemplo n.º 11
0
static void alloc_enter_mutex()
{
	UINT32 flag;
	osal_flag_wait(&flag, alloc_obj.flag, ALLOC_FLAG_MUTEX, 
				OSAL_TWF_ANDW|OSAL_TWF_CLR, OSAL_WAIT_FOREVER_TIME);
}
Exemplo n.º 12
0
static __inline__ INT32 psi_poll_stat(UINT32 stat)
{
	UINT32 flag;
	return (osal_flag_wait(&flag, psi_flag, stat, OSAL_TWF_ORW, 0)==OSAL_E_OK)?
		SI_SUCCESS : SI_SBREAK;
}
Exemplo n.º 13
0
INT32 nim_cxd2837_channel_change_smart(struct nim_device *dev,NIM_CHANNEL_CHANGE_T *change_para)
{	
	INT32 result  = SUCCESS;

	sony_demod_t * param = (sony_demod_t *)dev->priv;
	BOOL play_program, NeedToInitSystem = FALSE, NeedToConfigTuner = FALSE;
	
    mutex_lock(&param->demodMode_mutex_id);
	
	if ((change_para->freq <= 40000) || (change_para->freq >= 900000))
	{
	    mutex_unlock(&param->demodMode_mutex_id);
		return ERR_FAILUE;
	}
	
	PRINTK_INFO("[%s]:line=%d,system:%d\r\n",__FUNCTION__,__LINE__,param->system);

	if (change_para->bandwidth != SONY_DEMOD_BW_1_7_MHZ && change_para->bandwidth != SONY_DEMOD_BW_5_MHZ
        && change_para->bandwidth != SONY_DEMOD_BW_6_MHZ && change_para->bandwidth != SONY_DEMOD_BW_7_MHZ
        && change_para->bandwidth != SONY_DEMOD_BW_8_MHZ)
	{
	    PRINTK_INFO("[%s]:line=%d error:bandwidth=%d\n", __FUNCTION__,__LINE__,change_para->bandwidth);

		mutex_unlock(&param->demodMode_mutex_id);
		return ERR_FAILUE;
	}
	
	#if 0
	result = osal_flag_wait(&flgptn, param->flag_id, NIM_SCAN_END, OSAL_TWF_ANDW|OSAL_TWF_CLR, 2000); //OSAL_WAIT_FOREVER_TIME
	if(OSAL_E_OK != result)
	{
		return ERR_FAILUE;
	}
    #endif
	PRINTK_INFO("%s: usage_type %d, freq %d, bandwidth %d, priority %d, t2_signal %d, plp_index %d, plp_id  %d, profile %d\r\n",
                __FUNCTION__,change_para->usage_type, change_para->freq,change_para->bandwidth, change_para->priority, 
                change_para->t2_signal, change_para->plp_index, change_para->plp_id, change_para->t2_profile);

    PRINTK_INFO("[%s]line: %d,search_t2_only = %d\n",__FUNCTION__,__LINE__,param->search_t2_only);
	do
	{
		//osal_mutex_lock(param->demodMode_mutex_id, OSAL_WAIT_FOREVER_TIME);
		param->autoscan_stop_flag = 0;
		param->do_not_wait_t2_signal_locked = ( change_para->usage_type == USAGE_TYPE_AERIALTUNE ? 1:0 );

		PRINTK_INFO("[%s]:line=%d,system:%d\r\n",__FUNCTION__,__LINE__,param->system);

		if ( need_to_config_tuner(dev, change_para->freq, change_para->bandwidth) )
		{
		    
			PRINTK_INFO("[%s]:line=%d,need_to_config_tuner!\r\n",__FUNCTION__,__LINE__);

			if(param->bandwidth != change_para->bandwidth)
				NeedToInitSystem = TRUE;
			param->Frequency = change_para->freq;
			param->bandwidth = change_para->bandwidth;
			NeedToConfigTuner = TRUE;
		}
	    //search T2 signal only when search_t2_only is true
		if ((!(TRUE == param->search_t2_only)) && need_to_lock_DVBT_signal(dev, change_para, NeedToConfigTuner))
		{
			PRINTK_INFO("[%s]:line=%d,try_to_lock_DVBT_signal!\n",__FUNCTION__,__LINE__);

			param->priority = change_para->priority;
			result = try_to_lock_DVBT_signal(dev, NeedToInitSystem, NeedToConfigTuner, change_para);
			if (result == SUCCESS)
			{
			    break;
			}
			else
			{
				PRINTK_INFO("[%s]:line=%d,try_to_lock_DVBT_signal failed!\n",__FUNCTION__,__LINE__);
			}
		}

		PRINTK_INFO("[%s]:line=%d,system:%d\r\n",__FUNCTION__,__LINE__,param->system);

		if (param->autoscan_stop_flag)
		{
		    break;
		}

		if (need_to_lock_DVBT2_signal(dev, change_para, NeedToConfigTuner, &play_program) )
		{
		    
			PRINTK_INFO("[%s]:line=%d,try_to_lock_DVBT2_signal play_program =%d \n",__FUNCTION__,__LINE__,play_program);

			if (play_program)
			{
				param->do_not_wait_t2_signal_locked = 1;

				PRINTK_INFO("[%s]:line=%d,do_not_wait_t2_signal_locked = %d!\n",__FUNCTION__,__LINE__,param->do_not_wait_t2_signal_locked);

				param->plp_index = change_para->plp_index;
				param->t2_profile = change_para->t2_profile;
				result = DVBT2_change_PLP(dev, change_para->plp_id, NeedToInitSystem, NeedToConfigTuner,0);
			}
			else
			{
				if (change_para->usage_type == USAGE_TYPE_NEXT_PIPE_SCAN)
				{
				    PRINTK_INFO("[%s]:line=%d,USAGE_TYPE_NEXT_PIPE_SCAN \n",__FUNCTION__,__LINE__);
					result = try_to_lock_next_data_plp(dev, NeedToInitSystem, NeedToConfigTuner);
				}
				else
				{
				    PRINTK_INFO("[%s]:line=%d,system:%d\r\n",__FUNCTION__,__LINE__,param->system);
					result = try_to_lock_DVBT2_signal(dev, NeedToInitSystem, NeedToConfigTuner);
					change_para->plp_num = param->plp_num;
					change_para->t2_profile = param->t2_profile;
				}
				change_para->plp_index = param->plp_index;
				change_para->plp_id = param->plp_id;
				change_para->t2_system_id = param->t2_system_id;
			}
		}
    }while (0);
	PRINTK_INFO("[%s]:line=%d,system:%d\r\n",__FUNCTION__,__LINE__,param->system);
    change_para->t2_signal = param->t2_signal;
	
	mutex_unlock(&param->demodMode_mutex_id);
    return result;
}
Exemplo n.º 14
0
static void epgdb_enter_mutex()
{
	UINT32 flag;
	osal_flag_wait(&flag, db_block.flag, EPGDB_FLAG_MUTEX, 
				OSAL_TWF_ANDW|OSAL_TWF_CLR, OSAL_WAIT_FOREVER_TIME);
}
Exemplo n.º 15
0
static int ogg_play_file(char *filename, mp_callback_func cb)
{
	OSAL_T_CTSK										ogg_engine_play_task_attribute;
	unsigned long											ogg_engine_flag;

	PE_DBG_PRINTF("MusicEngine: ==> ogg_play_file()! \n");

	//check parameters
	if ((!filename) || (!cb) || (!ogg_file))
	{
		PE_DBG_PRINTF("MusicEngine: ogg_play_file() invalid parameter filename or cb or ogg_file! \n");
		return -1;
	}

	
	//init ogg_file
#ifdef ENABLE_PE_CACHE
	ogg_cache_id = pe_cache_open(filename, NULL, OGG_CACHE_SIZE, OGG_BLOCK_SIZE);
	if(ogg_cache_id < 0)
	{
		PE_DBG_PRINTF("MusicEngine: ogg_play_file() pe_cache_open failed! \n");
		return -1;
	}
	ogg_file->file = (FILE *)((UINT32)ogg_cache_id | PE_CACHE_ID_TAG);          //只有在作了这个操作之后,以后的文件系统函数才是pe_cache接口
#else
	ogg_file->file = fopen(filename, "rb");
	if (!ogg_file->file)
	{
		PE_DBG_PRINTF("MusicEngine: ogg_play_file() fopen failed! \n");
		return -1;
	}
#endif

	ogg_file->seek_to = 0;
	ogg_file->command = 0;
	ogg_file->stop_imm = TRUE;

	ogg_engine.ogg_engine_flag_id = OSAL_INVALID_ID;
	ogg_engine.ogg_engine_task_id = OSAL_INVALID_ID;

    deca_io_control((struct deca_device *)dev_get_by_id(HLD_DEV_TYPE_DECA, 0), DECA_SET_STR_TYPE, AUDIO_OGG );

	prev_sp_l = 0;
	prev_sp_r = 0;
    g_pcm_sample_num = 0;
    g_pcm_current_using = 0;
    g_temp_pcm_buff = (char *)(ogg_file->processed_pcm_buff+ON_PCM_BUFF_LEN*8);

	//code to create flag
	ogg_engine_flag = OGG_ENGINE_FLAG_INITIALIZE;
	ogg_engine.ogg_engine_flag_id = osal_flag_create(ogg_engine_flag);
	if ( ogg_engine.ogg_engine_flag_id == OSAL_INVALID_ID)
	{
		PE_DBG_PRINTF("MusicEngine: ogg_play_file() osal_flag_create failure! \n");
#ifdef ENABLE_PE_CACHE
		pe_cache_close(ogg_cache_id);
		ogg_cache_id = -1;
#else
		fclose(ogg_file->file);
#endif
		return -1;
	}


	//start thread
	ogg_engine_play_task_attribute.stksz	= OGG_ENGINE_PLAY_TASK_STACKSIZE*8;
	ogg_engine_play_task_attribute.quantum	= OGG_ENGINE_PLAY_TASK_QUANTUM;
	ogg_engine_play_task_attribute.itskpri	= OSAL_PRI_HIGH;//OSAL_PRI_NORMAL ;
	ogg_engine_play_task_attribute.para1	= (unsigned long)cb;
	//ogg_engine_play_task_attribute.para2	=;
	ogg_engine_play_task_attribute.name[0]	= 'O';
	ogg_engine_play_task_attribute.name[1]	= 'G';
	ogg_engine_play_task_attribute.name[2]	= 'G';
	ogg_engine_play_task_attribute.task = (FP)ogg_play_task;
	ogg_engine.ogg_engine_task_id = osal_task_create(&ogg_engine_play_task_attribute);
	if(ogg_engine.ogg_engine_task_id == OSAL_INVALID_ID)
	{
		PE_DBG_PRINTF("MusicEngine: ogg_play_file() osal_task_create failed! \n");
		
		osal_flag_delete(ogg_engine.ogg_engine_flag_id);
		ogg_engine.ogg_engine_flag_id = OSAL_INVALID_ID;

#ifdef ENABLE_PE_CACHE
		pe_cache_close(ogg_cache_id);
		ogg_cache_id = -1;
#else
		fclose(ogg_file->file);
#endif
		return -1;
	}

	//code to sync
	osal_flag_wait(&ogg_engine_flag, ogg_engine.ogg_engine_flag_id, OGG_ENGINE_FLAG_MASK, OSAL_TWF_ORW | OSAL_TWF_CLR, OSAL_WAIT_FOREVER_TIME);
	if (ogg_engine_flag != OGG_ENGINE_FLAG_SUCCESS)
	{		
		osal_flag_delete(ogg_engine.ogg_engine_flag_id);
		ogg_engine.ogg_engine_flag_id = OSAL_INVALID_ID;

		//fclose(ogg_file->file);

		return -1;
	}
	
	PE_DBG_PRINTF("MusicEngine: <== ogg_play_file()! \n");
	return 0;

}