示例#1
0
int	broadcast_drv_if_set_channel(struct broadcast_dmb_set_ch_info *udata)
{	
	Tcc353xTuneOptions tuneOption;
	signed long frequency = 214714; /*tmm*/
	int ret;
	int needLockCheck = 0;

	TcpalSemaphoreLock(&Tcc353xDrvSem);

	if(OnAir == 0 || udata == NULL) {
		TcpalPrintErr((I08S *)"[1seg] broadcast_drv_if_set_channel error [!OnAir]\n");
		TcpalSemaphoreUnLock(&Tcc353xDrvSem);
		return ERROR;
	}

	TcpalMemset (&tuneOption, 0x00, sizeof(tuneOption));

	if(udata->subchannel == 22 && udata->rf_band==0) {
		/* uhf 1segment */
		currentBroadCast = UHF_1SEG;
		currentSelectedChannel = udata->channel;
		tuneOption.rfIfType = TCC353X_LOW_IF;
		tuneOption.segmentType = TCC353X_ISDBT_1_OF_13SEG;
		tuneOption.userFifothr = _1_SEG_FIFO_THR_;

		needLockCheck = 1;

		if(udata->channel<13 || udata->channel>62) {
			TcpalPrintErr((I08S *)"[1seg] channel information error\n");
			TcpalSemaphoreUnLock(&Tcc353xDrvSem);
			return ERROR;
		}
		frequency = frequencyTable[udata->channel-13];
	} else if (udata->subchannel == 22) {
		/* tmm 13seg */

		if(udata->channel==0 || udata->channel>33) {
			TcpalPrintErr((I08S *)"[1seg] channel information error [%d]\n", udata->channel);
			TcpalSemaphoreUnLock(&Tcc353xDrvSem);
			return ERROR;
		}

		currentBroadCast = TMM_13SEG;
		currentSelectedChannel = udata->channel;
		tuneOption.rfIfType = TCC353X_ZERO_IF;
		tuneOption.segmentType = TCC353X_ISDBTMM;
		tuneOption.userFifothr = _13_SEG_FIFO_THR_;

		if(udata->channel == 7)
			tuneOption.tmmSet = C_1st_13Seg;
		else if(udata->channel == 20)
			tuneOption.tmmSet = C_2nd_13Seg;
		else if(udata->channel == 27)
			tuneOption.tmmSet = B_2nd_13Seg;
		else if(udata->channel == 14)
			tuneOption.tmmSet = A_1st_13Seg;
		else {
			tuneOption.tmmSet = UserDefine_Tmm13Seg;
			frequency = MMBI_FREQ_TABLE[udata->channel-1];
		}
	} else {
		/* tmm 1seg */

		if(udata->channel==0 || udata->channel>33) {
			TcpalPrintErr((I08S *)"[1seg] channel information error [%d]\n", udata->channel);
			TcpalSemaphoreUnLock(&Tcc353xDrvSem);
			return ERROR;
		}

		currentBroadCast = TMM_1SEG;
		currentSelectedChannel = udata->channel;
		tuneOption.rfIfType = TCC353X_LOW_IF;
		tuneOption.segmentType = TCC353X_ISDBTMM;
		tuneOption.userFifothr = _1_SEG_FIFO_THR_;

		if(udata->channel < 8 && udata->channel > 0)
			tuneOption.tmmSet = A_1st_1Seg+udata->channel-1;
		else if(udata->channel < 21 && udata->channel > 13)
			tuneOption.tmmSet = B_1st_1Seg+udata->channel-14;
		else if(udata->channel < 34 && udata->channel > 26)
			tuneOption.tmmSet = C_1st_1Seg+udata->channel-27;
		else {
			tuneOption.tmmSet = UserDefine_Tmm1Seg;
			frequency = MMBI_FREQ_TABLE[udata->channel-1];
		}
	}

	TcpalIrqDisable();
	gOverflowcnt = 0;

	if(needLockCheck && udata->mode == 1)	/* Scan mode & need lock check */
		ret = Tcc353xApiChannelSearch(0, frequency, &tuneOption);
	else				/* normal mode */
		ret = Tcc353xApiChannelSelect(0, frequency, &tuneOption);
	Tcc353xStreamBufferReset(0);
	Tcc353xMonitoringApiInit(0, 0);
	TcpalIrqEnable();

	if(ret!=TCC353X_RETURN_SUCCESS) {
		TcpalSemaphoreUnLock(&Tcc353xDrvSem);
		return ERROR;
	}

	TcpalSemaphoreUnLock(&Tcc353xDrvSem);
	return OK;
}
int	broadcast_drv_if_set_channel(struct broadcast_dmb_set_ch_info *udata)
{	
	Tcc353xTuneOptions tuneOption;
	signed long frequency = 214714; /*tmm*/
	int ret;
	int needLockCheck = 0;

	TcpalSemaphoreLock(&Tcc353xDrvSem);

	if(OnAir == 0 || udata == NULL) {
		TcpalPrintErr((I08S *)"[1seg] broadcast_drv_if_set_channel error [!OnAir]\n");
		TcpalSemaphoreUnLock(&Tcc353xDrvSem);
		return ERROR;
	}

	TcpalMemset (&tuneOption, 0x00, sizeof(tuneOption));

	/* uhf 1segment */
	currentSelectedChannel = udata->channel;

	if(udata->segment == 13) {
		currentBroadCast = UHF_13SEG;
		tuneOption.rfIfType = TCC353X_ZERO_IF;
		tuneOption.segmentType = TCC353X_ISDBT_13SEG;
	} else {
		currentBroadCast = UHF_1SEG;
		tuneOption.rfIfType = TCC353X_LOW_IF;
		tuneOption.segmentType = TCC353X_ISDBT_1_OF_13SEG;
	}
	
	tuneOption.userFifothr = 0;
	needLockCheck = 1;

	if(udata->channel<13 || udata->channel>62) {
		TcpalPrintErr((I08S *)"[1seg] channel information error\n");
		TcpalSemaphoreUnLock(&Tcc353xDrvSem);
		return ERROR;
	}
	frequency = frequencyTable[udata->channel-13];

	/* lna control - high gain */
	/* high gain : PON 1, EN 0   low gain : PON 0, EN 1 */
	Tcc353xApiSetGpioControl(0, 0, GPIO_LNA_PON, 1);
	Tcc353xApiSetGpioControl(0, 0, GPIO_MMBI_ELNA_EN, 0);

	if(needLockCheck && udata->mode == 1)	/* Scan mode & need lock check */
		ret = Tcc353xApiChannelSearch(0, frequency, &tuneOption);
	else				/* normal mode */
		ret = Tcc353xApiChannelSelect(0, frequency, &tuneOption);

#if defined (_USE_SEND_GOOD_SIGNAL_INFO_CHANGING_)
	Time_channel_tune = TcpalGetCurrentTimeCount_ms();
	Need_send_good_signal = 1;
#endif

	Tcc353xMonitoringApiInit(0, 0);
	CurrentMonitoringTime = 0;

	if(ret!=TCC353X_RETURN_SUCCESS) {
		TcpalSemaphoreUnLock(&Tcc353xDrvSem);
		return ERROR;
	}

	TcpalSemaphoreUnLock(&Tcc353xDrvSem);
	return OK;
}