static bool t3900_set_ch(unsigned long freq
						, unsigned char subchid
						, bool factory_test)
{
	unsigned char ret_err;
	bool ret = false;

	if (t3900_pwr_on) {
		st_ch_info->nSetCnt = 1;
		st_ch_info->astSubChInfo[0].ulRFFreq = freq / 1000;
		st_ch_info->astSubChInfo[0].ucSubChID = subchid;
		st_ch_info->astSubChInfo[0].ucServiceType = 0x0;
		if (st_ch_info->astSubChInfo[0].ucSubChID >= 64) {
			st_ch_info->astSubChInfo[0].ucSubChID -= 64;
			st_ch_info->astSubChInfo[0].ucServiceType = 0x18;
		}

		t3900_on_air = false;

		if (factory_test == false)
			ret_err = INTERFACE_START(
				TDMB_I2C_ID80, st_ch_info);
		else
			ret_err = INTERFACE_START_TEST(
				TDMB_I2C_ID80, st_ch_info);

		if (ret_err == INC_SUCCESS) {
			/* TODO Ensemble  good code .... */
			t3900_on_air = true;
			ret = true;
		} else if (ret_err == INC_RETRY) {
			DPRINTK("IOCTL_TDMB_ASSIGN_CH retry\n");

			t3900_power_off();
			t3900_power_on();

			if (factory_test == false)
				ret_err = INTERFACE_START(
					TDMB_I2C_ID80, st_ch_info);
			else
				ret_err = INTERFACE_START_TEST(
					TDMB_I2C_ID80, st_ch_info);

			if (ret_err == INC_SUCCESS) {
				/* TODO Ensemble  good code .... */
				t3900_on_air = true;
				ret = true;
			}
		}
	}

	return ret;
}
Ejemplo n.º 2
0
static bool T3900_set_ch(unsigned long freqHz, unsigned char subhcid, bool factory_test)
{
	INC_UINT8 reErr;
	bool ret = false;

	if (g_bPowerOn) {
		g_pStChInfo->nSetCnt = 1;
		g_pStChInfo->astSubChInfo[0].ulRFFreq = freqHz / 1000;
		g_pStChInfo->astSubChInfo[0].ucSubChID = subhcid;
		g_pStChInfo->astSubChInfo[0].ucServiceType = 0x0;
		if (g_pStChInfo->astSubChInfo[0].ucSubChID >= 64) {
			g_pStChInfo->astSubChInfo[0].ucSubChID -= 64;
			g_pStChInfo->astSubChInfo[0].ucServiceType = 0x18;
		}

		g_bOnAir = false;

		if (factory_test == false)
			reErr = INTERFACE_START(TDMB_I2C_ID80, g_pStChInfo);
		else
			reErr = INTERFACE_START_TEST(TDMB_I2C_ID80, g_pStChInfo);

		if (reErr == INC_SUCCESS) {
			/* TODO Ensemble  good code .... */
			g_bOnAir = true;
			ret = true;
		} else if (reErr == INC_RETRY) {
			DPRINTK("IOCTL_TDMB_ASSIGN_CH retry\n");

			T3900_power_off();
			T3900_power_on();

			if (factory_test == false)
				reErr = INTERFACE_START(TDMB_I2C_ID80, g_pStChInfo);
			else
				reErr = INTERFACE_START_TEST(TDMB_I2C_ID80, g_pStChInfo);

			if (reErr == INC_SUCCESS) {
				/* TODO Ensemble  good code .... */
				g_bOnAir = true;
				ret = true;
			}
		}
	}

	return ret;
}
int8 tunerbb_drv_t39fx_multi_set_channel(int32 freq_num, uint8 subch_cnt, uint8 subch_id[ ], uint8 op_mode[ ])
{
	int major_ch, minor_ch, fnindex;
	int i;
	INC_INT16 nLoop;
	INC_CHANNEL_INFO ChInfo[INC_MULTI_MAX_CHANNEL];
	INC_ERROR_INFO ErrorInfo;
	ST_SUBCH_INFO stSubInfo;
	
	if(subch_cnt>INC_MULTI_MAX_CHANNEL) 
	{
		return INC_ERROR;
	}

	serviceType = (t39fx_service_type)op_mode[0];

	major_ch = freq_num /10;
	minor_ch = freq_num %10;
	if(major_ch<7)	major_ch = 7;
	else if(major_ch>13) major_ch = 13;
	if(minor_ch<1)	minor_ch = 1;
	else if(minor_ch>3) minor_ch = 3;

	// index of function point..
	fnindex = (major_ch-7)*3 + (minor_ch-1);

	if(op_mode[0]==T39FX_ENSQUERY)
	{
		if(INTERFACE_SCAN(TDMB_RFBB_DEV_ADDR, g_uiKOREnsembleFullFreq[fnindex])==INC_SUCCESS)
		{
			return INC_SUCCESS;
		}
	}
	else
	{
		for(i=0;i<subch_cnt;i++)
		{
			switch(op_mode[i])
			{
				case T39FX_DAB:					
					_ChInfo->ucSubChID = subch_id[i];
					_ChInfo->ulRFFreq = g_uiKOREnsembleFullFreq[fnindex];
					_ChInfo->ucServiceType = 0x00;
					_ChInfo->uiTmID = TMID_0;
					//_ChInfo->ucDataType = TDMB_BB_DATA_DAB;
					//_ChInfo->ulDataThreshold = 188*10;
					break;
				case T39FX_DATA:
					_ChInfo->ucSubChID = subch_id[i];
					_ChInfo->ulRFFreq = g_uiKOREnsembleFullFreq[fnindex];
					_ChInfo->ucServiceType = 0x00;
					_ChInfo->uiTmID = TMID_2;	
					//_ChInfo->ucDataType = TDMB_BB_DATA_PACK;
					//_ChInfo->ulDataThreshold = 288;//188;
					break;
				case T39FX_DMB:
				case T39FX_VISUAL:
					_ChInfo->ucSubChID = subch_id[i];
					_ChInfo->ulRFFreq = g_uiKOREnsembleFullFreq[fnindex];
					_ChInfo->ucServiceType = 0x18;
					_ChInfo->uiTmID = TMID_1;
					//_ChInfo->ucDataType = TDMB_BB_DATA_TS;
					//_ChInfo->ulDataThreshold = 188*32;
					break;
				default:
					return INC_ERROR;
			}
			memcpy(&stSubInfo.astSubChInfo[i], &ChInfo[i], sizeof(INC_CHANNEL_INFO));
		}

		stSubInfo.nSetCnt = subch_cnt;
		INC_MULTI_SORT_INIT();

		memcpy(&g_stSubInfo, &stSubInfo, sizeof(ST_SUBCH_INFO));
		
		for(nLoop = 0; nLoop < 2; nLoop++)
		{
			if(INTERFACE_START(TDMB_RFBB_DEV_ADDR, &stSubInfo))
			{	
				return INC_SUCCESS;
			}
			ErrorInfo = INTERFACE_ERROR_STATUS(TDMB_RFBB_DEV_ADDR);
			printk("[INC]^__^ INTERFACE_ERROR_STATUS = (0x%04x)", ErrorInfo);
			if(ErrorInfo == ERROR_SYNC_NULL || ErrorInfo == ERROR_FICDECODER || 
				ErrorInfo == ERROR_SYNC_TIMEOUT) continue; // 약전계시 한번더 호출함. 
			else
			{
				return INC_ERROR;
			}
		}
	}

	return INC_ERROR;
}
int8 tunerbb_drv_t39fx_multi_set_channel(int32 freq_num, uint8 subch_cnt, uint8 subch_id[], uint8 op_mode[])
{
	int i;
	//INC_INT16 nLoop;
	INC_ERROR_INFO ErrorInfo;

	uint32 set_freq;			 
	
	if(subch_cnt>INC_MULTI_MAX_CHANNEL) 
	{
		return INC_ERROR;
	}

	serviceType = (t39fx_service_type)op_mode[0];

	set_freq = tunerbb_drv_t39fx_get_freq(freq_num);

	if(op_mode[0]==T39FX_ENSQUERY)
	{
		if(INTERFACE_SCAN(TDMB_RFBB_DEV_ADDR, set_freq)==INC_SUCCESS)
		{
			return INC_SUCCESS;
		}
	}
	else
	{
		
#ifdef LGE_FW_LARGE_STACK // for build error 
		INC_CHANNEL_INFO ChInfo[INC_MULTI_MAX_CHANNEL];
		ST_SUBCH_INFO stSubInfo;

		for(i=0;i<subch_cnt;i++)
		{
			switch(op_mode[i])
			{
				case T39FX_DAB:					
					ChInfo[i].ucSubChID = subch_id[i];
					ChInfo[i].ulRFFreq = set_freq;
					ChInfo[i].ucServiceType = 0x00;
					ChInfo[i].uiTmID = TMID_0;
					ChInfo[i].ucDataType = TDMB_BB_DATA_DAB;
					ChInfo[i].ulDataThreshold = 188*10;
					break;
				case T39FX_DATA:
					ChInfo[i].ucSubChID = subch_id[i];
					ChInfo[i].ulRFFreq = set_freq;
					ChInfo[i].ucServiceType = 0x3C;
					ChInfo[i].uiTmID = TMID_3;  
					ChInfo[i].ucDataType = TDMB_BB_DATA_PACK;
					ChInfo[i].ulDataThreshold = 288*10;//288;
					break;
				case T39FX_DMB:
				case T39FX_VISUAL:
				case T39FX_BLT_TEST:
					ChInfo[i].ucSubChID = subch_id[i];
					ChInfo[i].ulRFFreq = set_freq;
					ChInfo[i].ucServiceType = 0x18;
					ChInfo[i].uiTmID = TMID_1;
					ChInfo[i].ucDataType = TDMB_BB_DATA_TS;
					ChInfo[i].ulDataThreshold = 188*32;
					break;
				default:
					return INC_ERROR;
			}
			memcpy(&stSubInfo.astSubChInfo[i], &ChInfo[i], sizeof(INC_CHANNEL_INFO));
		}

		stSubInfo.nSetCnt = subch_cnt;
		INC_MULTI_SORT_INIT();

		memcpy(&g_stSubInfo, &stSubInfo, sizeof(ST_SUBCH_INFO));

		//for(nLoop = 0; nLoop < 2; nLoop++)
		{
			if(INTERFACE_START(TDMB_RFBB_DEV_ADDR, &stSubInfo))
			{
				return INC_SUCCESS;
			}
			ErrorInfo = INTERFACE_ERROR_STATUS(TDMB_RFBB_DEV_ADDR);
			printk("[INC]^__^ INTERFACE_STATUS = (0x%04x)\n", ErrorInfo);
			if(ErrorInfo == ERROR_SYNC_NULL || ErrorInfo == ERROR_FICDECODER || 
				ErrorInfo == ERROR_SYNC_TIMEOUT) continue; // 약전계시 한번더 호출함. 
			else
			{
				return INC_ERROR;
			}
		}
#else
		for(i=0;i<subch_cnt;i++)
		{
			INC_CHANNEL_INFO *_ChInfo = &g_stSubInfo.astSubChInfo[i];
			switch(op_mode[i])
			{
				case T39FX_DAB:					
					_ChInfo->ucSubChID = subch_id[i];
					_ChInfo->ulRFFreq = set_freq;
					_ChInfo->ucServiceType = 0x00;
					_ChInfo->uiTmID = TMID_0;
					_ChInfo->ucDataType = TDMB_BB_DATA_DAB;
					_ChInfo->ulDataThreshold = 188*10;
					break;
				case T39FX_DATA:
					_ChInfo->ucSubChID = subch_id[i];
					_ChInfo->ulRFFreq = set_freq;
					_ChInfo->ucServiceType = 0x3C;
					_ChInfo->uiTmID = TMID_3;  
					_ChInfo->ucDataType = TDMB_BB_DATA_PACK;
					_ChInfo->ulDataThreshold = 288*10;//288;
					break;
				case T39FX_DMB:
				case T39FX_VISUAL:
				case T39FX_BLT_TEST:
					_ChInfo->ucSubChID = subch_id[i];
					_ChInfo->ulRFFreq = set_freq;
					_ChInfo->ucServiceType = 0x18;
					_ChInfo->uiTmID = TMID_1;
					_ChInfo->ucDataType = TDMB_BB_DATA_TS;
					_ChInfo->ulDataThreshold = 188*32;
					break;
				default:
					return INC_ERROR;
			}
		}

		g_stSubInfo.nSetCnt = subch_cnt;
		INC_MULTI_SORT_INIT();


		//for(nLoop = 0; nLoop < 2; nLoop++)
		{
			if(INTERFACE_START(TDMB_RFBB_DEV_ADDR, &g_stSubInfo))
			{
				return INC_SUCCESS;
			}
			ErrorInfo = INTERFACE_ERROR_STATUS(TDMB_RFBB_DEV_ADDR);
			printk("[INC]^__^ INTERFACE_STATUS = (0x%04x)\n", ErrorInfo);
			if(ErrorInfo == ERROR_SYNC_NULL || ErrorInfo == ERROR_FICDECODER || 
				ErrorInfo == ERROR_SYNC_TIMEOUT) return INC_ERROR;  
			else
			{
				return INC_ERROR;
			}
		}

#endif
	}

	return INC_ERROR;
}