Beispiel #1
0
INT32 nim_cxd2837_get_SSI(struct nim_device *dev, UINT8 *data)
{
	sony_demod_t * priv = (sony_demod_t *)dev->priv;
	sony_result_t CalcResult = SONY_RESULT_OK;
	uint32_t  ssi=0;
	static uint32_t PreSSI =0;

	uint32_t rfLevel;

	mutex_lock(&priv->demodMode_mutex_id);

	if ( tun_cxd_ascot3_command(priv->tuner_id, NIM_TUNER_GET_RF_POWER_LEVEL, (UINT32)&rfLevel) == ERR_FAILUE )
	{
		PRINTK_INFO("error: Tuner does not support command 'NIM_TUNER_GET_RF_POWER_LEVEL'.\r\n"); 
		mutex_unlock(&priv->demodMode_mutex_id);
		return ERR_FAILUE;
	}
	//!Get SSI Value
	CalcResult = sony_integ_CalcSSI(priv, &ssi, rfLevel);
	if(SONY_RESULT_OK == CalcResult){
		*data = ssi;
		PreSSI = ssi;//save this data
		PRINTK_INFO("CalcSSI: ssi=%d\r\n",ssi); 
	}
	else{
		*data = PreSSI;//use the pre-value
		PreSSI = PreSSI/2;
		PRINTK_INFO("error: CalcSSI failure,use pre value!\r\n");
	}
	
	mutex_unlock(&priv->demodMode_mutex_id);
	
	return SUCCESS;
	
}
Beispiel #2
0
INT32 nim_cxd2837_get_BER(struct nim_device *dev, UINT32 *BER)
{
	sony_demod_t * priv = (sony_demod_t *)dev->priv;
	sony_result_t CalcResult = SONY_RESULT_OK;
	uint32_t  ber;
	static uint32_t PreBer;
	
	mutex_lock(&priv->demodMode_mutex_id);
	{
		//osal_mutex_lock(priv->demodMode_mutex_id, OSAL_WAIT_FOREVER_TIME);
		CalcResult = sony_integ_CalcBER(priv, &ber);
		if(SONY_RESULT_OK == CalcResult){
			*BER = ber;
			PreBer = ber;
			PRINTK_INFO("CalcBER: BER=%d\r\n",ber);
		}
		else{
			*BER = PreBer;
			PreBer =  PreBer/2;
			PRINTK_INFO("error: CalcBER failure, use pre value!\r\n");
		}
		//osal_mutex_unlock(priv->demodMode_mutex_id);	
	}
	mutex_unlock(&priv->demodMode_mutex_id);
	return SUCCESS;
}
Beispiel #3
0
INT32 nim_cxd2837_get_SQI(struct nim_device *dev, UINT8 *snr)
{
	sony_demod_t * priv = (sony_demod_t *)dev->priv;
	sony_result_t CalcResult = SONY_RESULT_OK;
	uint32_t  quality=0;
	static uint32_t PreQuality =0;
	
	mutex_lock(&priv->demodMode_mutex_id);
	
	CalcResult = sony_integ_CalcSQI(priv, &quality);
	if(SONY_RESULT_OK == CalcResult)
	{
		*snr = quality;
		PreQuality = quality;//save this data
		PRINTK_INFO("CalcSQI: sqi=%d\r\n",quality);
	}
	else
	{
		*snr = PreQuality;//use the pre-value
		PreQuality = PreQuality/2;
		PRINTK_INFO("error: CalcSQI failure,use pre value!\r\n");
	}
	
	mutex_unlock(&priv->demodMode_mutex_id);
	return SUCCESS;
}
Beispiel #4
0
INT32 need_to_lock_DVBT2_signal(struct nim_device *dev, NIM_CHANNEL_CHANGE_T *change_para,BOOL NeedToConfigTuner, BOOL *p_play_program)
{
    sony_demod_t * param = (sony_demod_t *)dev->priv;
    *p_play_program = FALSE;

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

    if ( change_para->usage_type == USAGE_TYPE_AUTOSCAN   \
        || change_para->usage_type == USAGE_TYPE_CHANSCAN \
        || change_para->usage_type == USAGE_TYPE_AERIALTUNE \
        || change_para->usage_type == USAGE_TYPE_NEXT_PIPE_SCAN )
        return TRUE;    //Auto detect signal type for Auto Scan and Channel Scan.

   //USAGE_TYPE_CHANCHG: for play program.
   // if ( !change_para->t2_signal ) //Do nothing for play DVB-T program.
   //     return FALSE;

    *p_play_program = TRUE;
    //if (param->system != SONY_DTV_SYSTEM_DVBT2) //DEM is not be DVB-T2 mode now.
    //    return TRUE;

    if (param->plp_index != change_para->plp_index) //Current selected PLP is different with the target PLP.
        return TRUE;

    if (param->t2_profile != change_para->t2_profile) //DVB-T2 profile: base or lite.
        return TRUE;
	 
    return NeedToConfigTuner;
}
Beispiel #5
0
static struct config_group *group_children_make_group(struct config_group *group,
													  const char *name)
{
	struct group_node *cfg;

	PRINTK_INFO("Creating configfs node for %s\n", name);

	cfg = kzalloc(sizeof(struct group_node), GFP_KERNEL);
	if (!cfg) {
		return ERR_PTR(-ENOMEM);
	}

	if (strcasecmp(name, GROUP_NAME_CR0) == 0) {
		config_group_init_type_name(&cfg->group, name,
			get_cr0_children_type());
	} else if (strcasecmp(name, GROUP_NAME_CR4) == 0) {
		config_group_init_type_name(&cfg->group, name,
			get_cr4_children_type());
	} else if (strcasecmp(name, GROUP_NAME_MSR) == 0) {
		config_group_init_type_name(&cfg->group, name,
			get_msr_children_type());
	} else if (strcasecmp(name, GROUP_NAME_LOG) == 0) {
		config_group_init_type_name(&cfg->group, name,
			get_log_children_type());
	}

	return &cfg->group;
}
Beispiel #6
0
INT32 try_to_lock_DVBT_signal(struct nim_device *dev, BOOL NeedToInitSystem,BOOL NeedToConfigTuner,NIM_CHANNEL_CHANGE_T *change_para)
{

	sony_demod_t * pDemod = (sony_demod_t *)dev->priv;
	sony_dvbt_tune_param_t TuneParam;
	sony_result_t tuneResult;

    if(SONY_DEMOD_BW_1_7_MHZ == change_para->bandwidth)    
    {        
        PRINTK_INFO("DVB-T not support 1.7MHZ!\n");
        return ERR_FAILUE;
    }
	memset(&TuneParam,0,sizeof(TuneParam));
	TuneParam.centerFreqKHz = change_para->freq;
	TuneParam.bandwidth = change_para->bandwidth;
	TuneParam.profile = change_para->priority; //SONY_DVBT_PROFILE_HP;

	if( NeedToInitSystem || (pDemod->system != SONY_DTV_SYSTEM_DVBT))
	{
		pDemod->t2_signal = 0;
		//to do...
	}

	tuneResult = sony_integ_dvbt_Tune(pDemod, &TuneParam,NeedToConfigTuner);
	switch(tuneResult){
	case SONY_RESULT_OK:
		 PRINTK_INFO("[SONY]DVB-T TS Locked.\n");
		//(("DVB-T TS Locked.\n"));
		return SUCCESS;
	case SONY_RESULT_ERROR_UNLOCK:
		PRINTK_INFO("[SONY]DVB-T TS Unlocked.\n");
		//(("DVB-T TS Unlocked.\n"));
		return ERR_FAILUE;
	case SONY_RESULT_ERROR_TIMEOUT:
		PRINTK_INFO("[SONY]DVB-T Wait TS Lock but Timeout.\n");
		//(("DVB-T Wait TS Lock but Timeout.\n"));
		return ERR_FAILUE;
	default:
		PRINTK_INFO("[SONY] default: in sony_integ_dvbt_Tune\n");
		//(("Error in sony_integ_dvbt_Tune (%s)\n", sony_FormatResult(sony_result)));
		return ERR_FAILUE;
	}
}
Beispiel #7
0
void cxd2837_log_i2c(sony_demod_t* param, UINT8 err, UINT8 write, UINT8 slv_addr, UINT8 *data, int len)
{
    int i = 0;
    if ( ! (param->output_buffer && param->fn_output_string) )
        return;

    if (write)
        PRINTK_INFO("I2C_Write,0x%02X", (slv_addr&0xFE));
    else
        PRINTK_INFO("I2C_Read,0x%02X", (slv_addr|1));

    for ( i=0; i<len; ++i )
    {
        PRINTK_INFO(",0x%02X", data[i]);
    }

    if (err)
        PRINTK_INFO("\terror");
    PRINTK_INFO("\r\n");
}
Beispiel #8
0
INT32 try_to_lock_DVBT2_signal(struct nim_device *dev, BOOL NeedToInitSystem, BOOL NeedToConfigTuner)
{	
	UINT16 waitTime = 0;
	INT32 result = ERR_FAILUE;
	sony_demod_t * param = (sony_demod_t *)dev->priv;
	
	param->plp_num = 0;
	param->plp_id = 0;
	param->plp_index = 0;
	
	PRINTK_INFO("[%s]:line=%d\n ", __FUNCTION__,__LINE__);

	if(NULL == dev)
	{
		return ERR_FAILUE;
	}
	else
	{
		PRINTK_INFO("[%s]:line=%d,NeedToInitSystem=%d,NeedToConfigTuner=%d,\n ", __FUNCTION__,__LINE__,NeedToInitSystem,NeedToConfigTuner);
	}
	
	result = DVBT2_change_PLP(dev, 0, NeedToInitSystem, NeedToConfigTuner,1); //for lock signal first.
	//get_the_first_data_PLP_info
	do
	{
		result = sony_demod_dvbt2_monitor_DataPLPs(param, (uint8_t *)&(param->all_plp_id),(uint8_t *)&(param->plp_num));
		if (result == SONY_RESULT_OK) 
		{
			UINT8 plp_idx;
			PRINTK_INFO("\t[%s]: plp_num=%d\n ", __FUNCTION__, param->plp_num);
			for (plp_idx=0; plp_idx < param->plp_num; ++plp_idx)
			{
				PRINTK_INFO("\t[plp_id=%d]\n", param->all_plp_id[plp_idx]);
			}
			break;
		}
		else if (result == SONY_RESULT_ERROR_HW_STATE) 
		{
			if (waitTime >= DTV_DEMOD_TUNE_T2_L1POST_TIMEOUT)
			{
				PRINTK_INFO("%s() error: timeout for get the first data_PLP\r\n", __FUNCTION__);
				param->plp_num = 0;
				return ERR_FAILUE;
			}
			else 
			{
				SONY_SLEEP (DEMOD_TUNE_POLL_INTERVAL); //10
				waitTime += DEMOD_TUNE_POLL_INTERVAL; 
			}
		} 
		else 
		{
			PRINTK_INFO("%s()=%d error: Fail to get the first data_PLP\r\n", __FUNCTION__, result);
			param->plp_num = 0;
			return ERR_FAILUE; // Other (fatal) error.
		}
	}while (1);
    
	return result;
}
Beispiel #9
0
INT32 DVBT2_change_PLP(struct nim_device *dev, UINT8 plp_id, BOOL NeedToInitSystem, BOOL NeedToConfigTuner, BOOL AUTOSCAN)
{
	sony_result_t tuneResult = SONY_RESULT_OK;
	sony_demod_t* pDemod = (sony_demod_t *)dev->priv;
	sony_dvbt2_tune_param_t tuneParam;

	pDemod->t2_signal = 1;
	pDemod->plp_id = plp_id;
	memset(&tuneParam,0,sizeof(tuneParam));
	tuneParam.centerFreqKHz = pDemod->Frequency;
	tuneParam.bandwidth= pDemod->bandwidth;
	tuneParam.dataPlpId = plp_id; //selected data PLP ID. 
	tuneParam.profile = pDemod->t2_profile;
	tuneParam.tuneInfo = SONY_DEMOD_DVBT2_TUNE_INFO_OK;

	PRINTK_INFO("[%s]:PLP_id(%d),autoScan(%d).\n",__FUNCTION__,plp_id,AUTOSCAN);

	if(0 == AUTOSCAN)
		tuneResult = sony_integ_dvbt2_Tune(pDemod, &tuneParam,NeedToConfigTuner);
	else if(1 == AUTOSCAN)
	{
		tuneResult = sony_integ_dvbt2_BlindTune(pDemod, &tuneParam,NeedToConfigTuner,t2_lite_support);	//By SONY AEC 20130701
	}
	switch(tuneResult){
        case SONY_RESULT_OK:
	        PRINTK_INFO("[%s]:DVB-T2 TS Locked.\n",__FUNCTION__);
	        return SUCCESS;
        case SONY_RESULT_ERROR_UNLOCK:
	        PRINTK_INFO("[%s]:DVB-T2 TS Unlocked.\n",__FUNCTION__);
	        return ERR_FAILUE;
        case SONY_RESULT_ERROR_TIMEOUT:
            PRINTK_INFO("[%s]:DVB-T2 Wait TS Lock but Timeout.\n",__FUNCTION__);
	        return ERR_FAILUE;
        default:
	        PRINTK_INFO("[%s]:Error in sony_integ_dvbt2_Tune (%d)\n",__FUNCTION__,tuneResult);
	        return ERR_FAILUE;
    }

}
Beispiel #10
0
static INT32 config_tuner(struct nim_device *dev, UINT32 freq, UINT32 bandwidth, UINT8 *ptr_lock)
{
	sony_demod_t * priv = (sony_demod_t *)dev->priv;
	UINT32 tuner_id = priv->tuner_id;
	UINT8 lock = 0, Tuner_Retry = 0;

	//set_bypass_mode(dev, TRUE);
	do
	{
		Tuner_Retry++;

		if(priv->tuner_control.nim_tuner_control(tuner_id, freq, bandwidth, 0, (UINT8*)&(priv->system),0) == ERR_FAILUE)
		{
			PRINTK_INFO("Config tuner failed, I2c failed!\r\n");
		}

		if(priv->tuner_control.nim_tuner_status(tuner_id, &lock) != SUCCESS)
		{
			//if i2c read failure, no lock state can be report.
			lock = 0;
			PRINTK_INFO("Config tuner failed, I2c failed!\r\n");
		}
		PRINTK_INFO("Tuner Lock Times=0x%d,Status=0x%d\r\n",Tuner_Retry,lock);

		if(Tuner_Retry > 5)
			break;
	}while(0 == lock);

	if(ptr_lock != NULL)
		*ptr_lock = lock;

	if(Tuner_Retry > 5)
	{
		PRINTK_INFO("ERROR! Tuner Lock Fail\r\n");
		return ERR_FAILUE;
	}
	return SUCCESS;
}
Beispiel #11
0
void test_hypercall(void)
{
	uint64_t out_buf;
	uint64_t out_offset;
	uint64_t ret;

	out_buf = (uint64_t)allocate_out_buf(sizeof(policy_message_t), &out_offset);

	ret = ikgt_hypercall(POLICY_GET_TEST, 0, out_offset);
	if (SUCCESS != ret) {
		PRINTK_ERROR("%s: ikgt_hypercall failed, ret=%llu\n", __func__, ret);
	}

	PRINTK_INFO("%s: *0x%llx=0x%llx\n", __func__, out_buf, *(uint64_t *)out_buf);

	free_out_buf(out_offset);
}
Beispiel #12
0
void ikgt_debug(uint64_t parameter)
{
	policy_message_t *msg;
	uint64_t ret;
	uint64_t in_offset;

	PRINTK_INFO("%s: parameter=%llu\n", __func__, parameter);

	msg = (policy_message_t *)allocate_in_buf(sizeof(policy_message_t), &in_offset);
	if (msg == NULL)
		return;

	msg->count = 1;
	msg->debug_param.parameter = parameter;

	ret = ikgt_hypercall(POLICY_DEBUG, in_offset, 0);
	if (SUCCESS != ret) {
		PRINTK_ERROR("%s: ikgt_hypercall failed, ret=%llu\n", __func__, ret);
	}

	free_in_buf(in_offset);
}
Beispiel #13
0
INT32 nim_cxd2837_get_FEC(struct nim_device *dev, UINT8* FEC)
{
    sony_result_t result;
    sony_demod_t * pDemod = (sony_demod_t *)dev->priv;
    sony_demod_lock_result_t lock = SONY_DEMOD_LOCK_RESULT_NOTDETECT;
    sony_dvbt2_l1pre_t L1Pre;
    sony_dvbt2_plp_t plpInfo;
    sony_dvbt_tpsinfo_t tps;

    *FEC = 0;
	
    mutex_lock(&pDemod->demodMode_mutex_id);

    switch (pDemod->system) {
	    case SONY_DTV_SYSTEM_DVBT2:
	        result = sony_demod_dvbt2_CheckDemodLock(pDemod, &lock);
	        break;
	    case SONY_DTV_SYSTEM_DVBT:
	        result = sony_demod_dvbt_CheckDemodLock (pDemod, &lock);
	        break;
	    case SONY_DTV_SYSTEM_DVBC:
	        result = sony_demod_dvbc_CheckDemodLock (pDemod, &lock);
	        break;
	    case SONY_DTV_SYSTEM_UNKNOWN:
	    default:
	        result = SONY_RESULT_OK;
    }
    if (result != SONY_RESULT_OK || lock != SONY_DEMOD_LOCK_RESULT_LOCKED){
		mutex_unlock(&pDemod->demodMode_mutex_id);
        return ERR_FAILUE;
    }

    if (pDemod->system == SONY_DTV_SYSTEM_DVBT2) 
    {
        sony_demod_dvbt2_monitor_L1Pre(pDemod, &L1Pre);//sony_dvb_demod_monitorT2_L1Pre
        if (result != SONY_RESULT_OK){ 
		    mutex_unlock(&pDemod->demodMode_mutex_id);
            return ERR_FAILUE;
        }
        // Get Active PLP information. 
        result = sony_demod_dvbt2_monitor_ActivePLP(pDemod, SONY_DVBT2_PLP_DATA, &plpInfo);//sony_dvb_demod_monitorT2_ActivePLP
        if (result != SONY_RESULT_OK){ 
			mutex_unlock(&pDemod->demodMode_mutex_id);
            return ERR_FAILUE;
        }
        if (plpInfo.type == SONY_DVBT2_PLP_TYPE_DATA1 || plpInfo.type == SONY_DVBT2_PLP_TYPE_DATA2)
        {
            if (plpInfo.id != pDemod->plp_id)
            {
                PRINTK_INFO("%s(): plp_id=%d, plpInfo.id=%d, error PLP locked.\r\n", __FUNCTION__,  pDemod->plp_id, plpInfo.id);
				mutex_unlock(&pDemod->demodMode_mutex_id);
				return ERR_FAILUE;
            }

            *FEC = cxd2837_FEC_map_to_ali_FEC(pDemod->system, plpInfo.plpCr);
			mutex_unlock(&pDemod->demodMode_mutex_id);
            return SUCCESS;
        }
    }
    else
    {
        result = sony_demod_dvbt_monitor_TPSInfo(pDemod, &tps);//sony_dvb_demod_monitorT_TPSInfo
        if (result != SONY_RESULT_OK || tps.constellation >= SONY_DVBT_CONSTELLATION_RESERVED_3 ){
			mutex_unlock(&pDemod->demodMode_mutex_id);
            return ERR_FAILUE;
        }

        *FEC = cxd2837_FEC_map_to_ali_FEC(pDemod->system, tps.rateHP);
    }
    mutex_unlock(&pDemod->demodMode_mutex_id);
    return SUCCESS;
}
Beispiel #14
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;
}
Beispiel #15
0
INT32 try_to_lock_next_data_plp(struct nim_device *dev, BOOL NeedToInitSystem, BOOL NeedToConfigTuner)
{
    INT32 result = ERR_FAILUE;
    sony_demod_t * param = (sony_demod_t *)dev->priv;
    sony_dvbt2_l1pre_t L1Pre;
    sony_dvbt2_plp_t plpInfo;
    UINT8 retry = 0; 
    UINT8 plp_index = 0; 

    for (plp_index = param->plp_index+1; plp_index < param->plp_num; ++plp_index )
    {
        if (plp_index >= param->plp_num)
            return ERR_FAILUE;
        result = DVBT2_change_PLP(dev, param->all_plp_id[plp_index], FALSE, FALSE, 0);
        
        for ( retry=0; retry<30; ++retry )
        {
            SONY_SLEEP (30);
            if (param->autoscan_stop_flag)
                return ERR_FAILUE;            
            if (param->do_not_wait_t2_signal_locked)
                return ERR_FAILUE;
            
            result = sony_demod_dvbt2_monitor_L1Pre(param, &L1Pre);//sony_dvb_demod_monitorT2_L1Pre
            if (result != SONY_RESULT_OK) 
            {
                PRINTK_INFO("%s(%d,%d)(plp_num=%d, all_plp_id[%d]=%d) error: sony_dvb_demod_monitorT2_L1Pre()=%d \r\n", __FUNCTION__,NeedToInitSystem,NeedToConfigTuner, param->plp_num, plp_index, param->all_plp_id[plp_index],result);
                continue;
				//return result;
            }
        
            // Get Active PLP information. 
            result = sony_demod_dvbt2_monitor_ActivePLP(param, SONY_DVBT2_PLP_DATA, &plpInfo);//sony_dvb_demod_monitorT2_ActivePLP
            if (result != SONY_RESULT_OK) 
            {
				PRINTK_INFO("%s(%d,%d)(plp_num=%d, all_plp_id[%d]=%d) error: sony_dvb_demod_monitorT2_ActivePLP()=%d \r\n", __FUNCTION__,NeedToInitSystem,NeedToConfigTuner, param->plp_num, plp_index, param->all_plp_id[plp_index],result);
				continue;
				//return result;
            }
            
            if (result == SONY_RESULT_OK) 
            {
                if (plpInfo.type == SONY_DVBT2_PLP_TYPE_DATA1 || plpInfo.type == SONY_DVBT2_PLP_TYPE_DATA2)
                {
                    if (plpInfo.id != param->all_plp_id[plp_index])
                    {
                        PRINTK_INFO("%s(%d,%d)(plp_num=%d, all_plp_id[%d]=%d), plpInfo.id=%d, error PLP locked: retry %d times.\r\n", __FUNCTION__, NeedToInitSystem,NeedToConfigTuner, param->plp_num, plp_index, param->all_plp_id[plp_index], plpInfo.id, retry);
                        continue;
                    }
                    else
                        break; //correct PLP is locked.
                }
            }
        }

        if (result == SONY_RESULT_OK  && (plpInfo.id == param->all_plp_id[plp_index]) ) 
        {
            if (plpInfo.type == SONY_DVBT2_PLP_TYPE_DATA1 || plpInfo.type == SONY_DVBT2_PLP_TYPE_DATA2)
            {
                param->plp_id = plpInfo.id;
                param->t2_system_id = L1Pre.systemId;
                param->plp_index = plp_index;
                
                if (retry!=0)
                    PRINTK_INFO("%s(%d,%d)(plp_num=%d, all_plp_id[%d]=%d), ok: retry %d times.\r\n", __FUNCTION__, NeedToInitSystem,NeedToConfigTuner, param->plp_num, plp_index, param->all_plp_id[plp_index], retry);
                return SONY_RESULT_OK;
            }
            else
            {
                    PRINTK_INFO("%s(%d,%d)(plp_num=%d, all_plp_id[%d]=%d), ok: retry %d times. error: Not DataPLP: (type=%d, id=%d)\r\n", __FUNCTION__, NeedToInitSystem,NeedToConfigTuner, param->plp_num, plp_index, param->all_plp_id[plp_index], retry, plpInfo.type, plpInfo.id);
            }
        }
        else
        {
            PRINTK_INFO("%s(%d,%d)(plp_num=%d, all_plp_id[%d]=%d), error: fail to lock the PLP.\r\n", __FUNCTION__, NeedToInitSystem,NeedToConfigTuner, param->plp_num, plp_index, param->all_plp_id[plp_index], retry);
        }
    }
    return ERR_FAILUE;
}
Beispiel #16
0
__ATTRIBUTE_REUSE_
INT32 nim_cxd2837_open(struct nim_device *dev)
{
    sony_demod_t * priv = (sony_demod_t *)dev->priv;
    struct COFDM_TUNER_CONFIG_API * config_info = &(priv->tuner_control);
    //sony_dvbt2_tune_param_t  TuneParam;
    sony_result_t result = SONY_RESULT_OK;
    if((NULL == dev) || (NULL == config_info))
    {
		PRINTK_INFO("nim_device is null\n");
		return SONY_RESULT_ERROR_ARG;
	}
	// Initialize the demod. 
    result = sony_demod_InitializeT_C(priv);//sony_demod_InitializeT_C
    if (result != SONY_RESULT_OK)
    {
        PRINTK_INFO("sony_dvb_demod_Initialize() error: %d.\r\n", result);
        return result;
    }
    PRINTK_INFO("[%s]:line=%d,system:%d\r\n",__FUNCTION__,__LINE__,priv->system);
    //Demod can be config now.
    //Demod shall can access tuner through the I2C gateway.
    // Initialize the tuner.
    tun_cxd_ascot3_command(priv->tuner_id, NIM_TUNER_POWER_CONTROL, FALSE); //tuner power on


    //Config TS output mode: SSI/SPI. Default is SPI.	
	//result = sony_demod_SetConfig(priv, SONY_DEMOD_CONFIG_PARALLEL_SEL, ((NIM_COFDM_TS_SSI == priv->tc.ts_mode)?0:1) );
	result = sony_demod_SetConfig(priv, SONY_DEMOD_CONFIG_PARALLEL_SEL, 0 );
	if (result != SONY_RESULT_OK)
	{
		PRINTK_INFO("Error: Unable to configure DEMOD_CONFIG_PARALLEL_SEL. (status=%d, %s)\r\n", result, FormatResult(result));
		return result;
	}
    //Confif Data output pin: 0:TS0(pin13), 1:TS7(pin20), default:1.
	//result = sony_demod_SetConfig(priv, SONY_DEMOD_CONFIG_SER_DATA_ON_MSB, ((NIM_COFDM_TS_SSI == priv->tc.ts_mode)?0:1) );
	result = sony_demod_SetConfig(priv, SONY_DEMOD_CONFIG_SER_DATA_ON_MSB, 0 );
	if (result != SONY_RESULT_OK)
	{
		PRINTK_INFO("Error: Unable to configure DEMOD_CONFIG_PARALLEL_SEL. (status=%d, %s)\r\n", result, FormatResult(result));
		return result;
	}

    //TS Error output.
	result = sony_demod_SetConfig(priv,SONY_DEMOD_CONFIG_TSERR_ACTIVE_HI, 1);//DEMOD_CONFIG_TSERR_ENABLE
	if (result != SONY_RESULT_OK)
	{
		PRINTK_INFO("Error: Unable to configure DEMOD_CONFIG_TSERR_ENABLE. (status=%d, %s)\r\n", result, FormatResult(result));
		return result;
	}

	/* IFAGC setup. Modify to suit connected tuner. */
	/* IFAGC: 0 for positive and 1 for negtive*/
#ifdef TUNER_IFAGCPOS
	result = sony_demod_SetConfig(priv, SONY_DEMOD_CONFIG_IFAGCNEG, 0);
	if (result != SONY_RESULT_OK)
	{
		PRINTK_INFO("Error: Unable to configure IFAGCNEG. (status=%d, %s)\r\n", result, FormatResult(result));
		return result;
	}
#else
	result = sony_demod_SetConfig(priv, SONY_DEMOD_CONFIG_IFAGCNEG, 1);
	if (result != SONY_RESULT_OK)
	{
		PRINTK_INFO("Error: Unable to configure IFAGCNEG. (status=%d, %s)\r\n", result, FormatResult(result));
		return result;
	}
#endif

	/*IFAGC ADC range[0-2]     0 : 1.4Vpp, 1 : 1.0Vpp, 2 : 0.7Vpp*/   
	result = sony_demod_SetConfig(priv,SONY_DEMOD_CONFIG_IFAGC_ADC_FS, 0);//DEMOD_CONFIG_TSERR_ENABLE
	if (result != SONY_RESULT_OK)
	{
		PRINTK_INFO("Error: Unable to configure SONY_DEMOD_CONFIG_IFAGC_ADC_FS. (status=%d, %s)\r\n", result, FormatResult(result));
		return result;
	}

	//Ben Debug 140221#1
	//add by AEC for TS error enable 2013-09-09
	 // TSERR output enable from GPIO2 pin
	result = sony_demod_GPIOSetConfig(priv, 2, 1, SONY_DEMOD_GPIO_MODE_TS_ERROR);
	if(result != SONY_RESULT_OK)
	{
		PRINTK_INFO("Error in sony_demod_GPIOSetConfig for TS error.\n");
		return result;
	}
	//end for TS error enable 2013-09-09  
	
	/* Spectrum Inversion setup. Modify to suit connected tuner. */
	/* Spectrum inverted, value = 1. */
#ifdef TUNER_SPECTRUM_INV
	result = sony_demod_SetConfig(priv, SONY_DEMOD_CONFIG_SPECTRUM_INV, 1);
	if (result != SONY_RESULT_OK)
	{
		PRINTK_INFO("Error: Unable to configure SPECTRUM_INV. (status=%d, %s)\r\n", result, FormatResult(result));
		return result;
	}
#endif

    /* RFAIN ADC and monitor enable/disable. */
    /* Default is disabled. 1: Enable, 0: Disable. */
#ifdef RFAIN_ADC_ENABLE
        result = sony_demod_SetConfig(priv, SONY_DEMOD_CONFIG_RFAIN_ENABLE, 0);
        if (result == SONY_RESULT_OK) {
            PRINTK_INFO("Demodulator configured to enable RF level monitoring.\n");
        }
        else {
            PRINTK_INFO("Error: Unable to configure RFLVMON_ENABLE. (result = %d)\n", result);
            return -1;
        }
#endif

	/* RF level monitoring (RFAIN/RFAGC) enable/disable. */
	/* Default is enabled. 1: Enable, 0: Disable. */
#ifdef TUNER_RFLVLMON_DISABLE
	result = sony_demod_SetConfig(priv, DEMOD_CONFIG_RFLVMON_ENABLE, 0);
	if (result != SONY_RESULT_OK)
	{
		PRINTK_INFO("Error: Unable to configure RFLVMON_ENABLE. (status=%d, %s)\r\n", result, FormatResult(result));
		return result;
	}
#endif
    //osal_flag_set(priv->flag_id, NIM_SCAN_END);
    return SUCCESS;
}