Пример #1
0
I32U Tcc353xGetStreamBuffer(I32S _moduleIndex, I08U * _buff, I32U _size)
{
	I32U tsSize = 0;
	I32U totalSize = 0;
	I32U rp;
	I32U wp;
	I32U nextRp;

	TcpalSemaphoreLock(&Tcc353xStreamSema);
	rp = Tcc353xStreamRp[_moduleIndex];
	wp = Tcc353xStreamWp[_moduleIndex];
	Tcc353xStreamFlushFlag[_moduleIndex] = 0;
	TcpalSemaphoreUnLock(&Tcc353xStreamSema);

	if(rp > wp)
		totalSize = wp + (TCC353X_STREAM_BUFFER_SIZE - rp);
	else if (rp < wp)
		totalSize = wp - rp;
	else 
		totalSize = 0;

	if(_size > totalSize)
		tsSize = totalSize;
	else
		tsSize = _size;
	tsSize = tsSize - (tsSize%188);

	if (tsSize<188) {
		return 0;
	}

	nextRp = ((rp+tsSize)%TCC353X_STREAM_BUFFER_SIZE);
	
	if(rp+tsSize>TCC353X_STREAM_BUFFER_SIZE) {	/* read twice */
		I32U first;
		I32U remain;
		first = TCC353X_STREAM_BUFFER_SIZE - rp;
		remain = nextRp;

		TcpalMemcpy (&_buff[0], &Tcc353xStreamData[rp], first);
		TcpalMemcpy (&_buff[first], &Tcc353xStreamData[0], nextRp);
	} else {
		TcpalMemcpy (&_buff[0], &Tcc353xStreamData[rp], tsSize);
	}

	TcpalSemaphoreLock(&Tcc353xStreamSema);
	if(Tcc353xStreamFlushFlag[_moduleIndex]!=0) {
		/* no update read pointer & no push data */
		Tcc353xStreamFlushFlag[_moduleIndex] = 0;
		tsSize = 0;
	} else {
		Tcc353xStreamRp[_moduleIndex] = nextRp;
		if(Tcc353xStreamBufferedSize[0]>=tsSize)
			Tcc353xStreamBufferedSize[0] -= tsSize;
	}
	TcpalSemaphoreUnLock(&Tcc353xStreamSema);
	return tsSize;
}
Пример #2
0
void Tcc353xInterruptGetStream(I32U _fifoSize)
{
	I32S moduleIndex = 0;
	I32U totalSize = 0;
	I32U wp;

	totalSize = _fifoSize - (_fifoSize%188);

	//                                                                           
	//TcpalPrintErr((I08S *) "Tcc353xInterruptGetStream size[%d]\n", totalSize);

	totalSize = (totalSize/188/4)*188*4;

	if(totalSize > 188 * 87)
		totalSize = 188 * 84;
	//                                                                         

	if(totalSize>=188) {
		I32U nextwp;

		if(Tcc353xStreamBufferedSize[moduleIndex]+totalSize > TCC353X_STREAM_BUFFER_SIZE)
			Tcc353xStreamBufferFlush (moduleIndex);

		TcpalSemaphoreLock(&Tcc353xStreamSema);
		wp = Tcc353xStreamWp[moduleIndex];
		TcpalSemaphoreUnLock(&Tcc353xStreamSema);

		nextwp = ((wp+totalSize)%TCC353X_STREAM_BUFFER_SIZE);
		
		if(wp+totalSize>TCC353X_STREAM_BUFFER_SIZE) {	/* read twice */
			I32U first;
			first = TCC353X_STREAM_BUFFER_SIZE - wp;
			Tcc353xApiStreamRead(moduleIndex,
					     &Tcc353xStreamData[wp],
					     first);
			Tcc353xApiStreamRead(moduleIndex,
					     &Tcc353xStreamData[0],
					     nextwp);
		} else {
			Tcc353xApiStreamRead(moduleIndex,
					     &Tcc353xStreamData[wp],
					     totalSize);
		}

		TcpalSemaphoreLock(&Tcc353xStreamSema);
		Tcc353xStreamWp[moduleIndex] = nextwp;
		Tcc353xStreamBufferedSize[moduleIndex] += totalSize;
		TcpalSemaphoreUnLock(&Tcc353xStreamSema);

		if(Tcc353xStreamData[wp]!=0x47) {
			TcpalPrintErr((I08S *) "[TCC353X] SyncByte Error! [0x%02x]\n",
				     Tcc353xStreamData[wp]);
			TcpalPrintErr((I08S *) "[TCC353X] Buff Flush for SyncByte matching\n");
			Tcc353xApiInterruptBuffClr(moduleIndex);
		}
	}
}
Пример #3
0
I32S TcbdDequeue(TcbdQueue_t *_queue, I08U *_chunk, I32S *_size, I32S *_type)
{
    *_size = 0;
    TcpalSemaphoreLock(&_queue->sem);
    if(TcbdQueueIsEmpty(_queue))
    {
        TcbdDebug(0, "Queue Empty!! \n");
        TcpalSemaphoreUnLock(&_queue->sem);        
        return -1;
    }
    else 
    {
        TcbdDebug(0, "Dequeue! size%d\n", _queue->q[_queue->front].size);
    }

    *_size = _queue->q[_queue->front].size;
    if(_type) *_type = _queue->q[_queue->front].type;
    TcpalMemoryCopy(_chunk, _queue->q[_queue->front].buffer, *_size);
    _queue->front = (_queue->front + 1) % _queue->qsize;

    _queue->pointer -= *_size;

    TcbdDebug(0, "pos:%d, size:%d\n", _queue->pointer, *_size);
    TcpalSemaphoreUnLock(&_queue->sem);

    return 0;
}
Пример #4
0
int	broadcast_drv_if_detect_sync(struct broadcast_dmb_sync_info *udata)
{
	IsdbLock_t lock;
	I08U reg;

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

	Tcc353xApiRegisterRead(0, 0, 0x0B, &reg, 1);
	Tcc353xApiParseIsdbSyncStat(&lock, reg);

	if(lock.TMCC)
		udata->sync_status = 3;
	else if(lock.CFO)
		udata->sync_status = 1;
	else
		udata->sync_status = 0;

	udata->sync_ext_status = reg;
	TcpalSemaphoreUnLock(&Tcc353xDrvSem);
	return OK;
}
/* misc wite - not increase address */
I32S Tcc353xMiscWriteEx(I32S _moduleIndex, I32S _diversityIndex,
		      I08U _miscConfig, I08U *_startAddress, 
		      I32U *_data, I32U _size)
{
	Tcc353xHandle_t *h;
	I32U i;
	I32U temp;
	
	if (Tcc353xHandle[_moduleIndex][_diversityIndex].handleOpen == 0)
		return TCC353X_RETURN_FAIL_INVALID_HANDLE;

	h = &Tcc353xHandle[_moduleIndex][_diversityIndex];

	TcpalSemaphoreLock(&Tcc353xInterfaceSema);

	Tcc353xSetRegMiscConfig(h, _miscConfig | 1, _UNLOCK_);

	for (i = 0; i< _size; i++)	{
		Tcc353xSetRegMiscAddress(h, _startAddress[i], _UNLOCK_);
		temp = _data[i];
		temp = SWAP32(temp);
		Tcc353xSetRegMiscData(h, (I08U *) (&temp), _UNLOCK_);
		Tcc353xSetRegMiscAction(h, TC3XREG_MISC_ACTION, _UNLOCK_);
	}
	/* warning : please reset to opcontrol miscconfig0 */
	Tcc353xSetRegMiscConfig(h, 0, _UNLOCK_);

	TcpalSemaphoreUnLock(&Tcc353xInterfaceSema);
	return TCC353X_RETURN_SUCCESS;
}
I32S Tcc353xDspAsmWrite(Tcc353xHandle_t * _handle, I08U * _data,
			I32S _size)
{
	I08U inputValue[4];
	I32U codeMemoryAddress = TCC353X_CODEMEMBASE;

	if (_size <= 0)
		return TCC353X_RETURN_FAIL;

	codeMemoryAddress = TCC353X_CODEMEMBASE;

	TcpalSemaphoreLock(&Tcc353xInterfaceSema);
	Tcc353xSetRegDmaControl(_handle,
				TC3XREG_CMDDMA_DMAEN |
				TC3XREG_CMDDMA_WRITEMODE |
				TC3XREG_CMDDMA_CRC32EN, _UNLOCK_);
	inputValue[0] = (I08U)((codeMemoryAddress >> 24) & 0xFF);
	inputValue[1] = (I08U)((codeMemoryAddress >> 16) & 0xFF);
	inputValue[2] = (I08U)((codeMemoryAddress >> 8) & 0xFF);
	inputValue[3] = (I08U)(codeMemoryAddress & 0xFF);
	Tcc353xSetRegDmaSourceAddress(_handle, &inputValue[0], _UNLOCK_);
	inputValue[0] = (I08U)(((_size >> 2) >> 8) & 0xFF);
	inputValue[1] = (I08U)((_size >> 2) & 0xFF);
	Tcc353xSetRegDmaSize(_handle, &inputValue[0], _UNLOCK_);
	Tcc353xSetRegDmaStartControl(_handle,
				     TC3XREG_CMDDMA_START_AUTOCLR |
				     TC3XREG_CMDDMA_INIT_AUTOCLR |
				     TC3XREG_CMDDMA_CRC32INIT_AUTOCLR,
				     _UNLOCK_);
	Tcc353xSetRegDataWindow(_handle, _data, _size, _UNLOCK_);
	TcpalSemaphoreUnLock(&Tcc353xInterfaceSema);
	return TCC353X_RETURN_SUCCESS;
}
I32S Tcc353xMemoryWrite(I32S _moduleIndex, I32S _diversityIndex,
			I32U _address, I08U * _data, I32U _size)
{
	I08U inputValue[4];
	Tcc353xHandle_t *h;

	if (Tcc353xHandle[_moduleIndex][_diversityIndex].handleOpen == 0)
		return TCC353X_RETURN_FAIL_INVALID_HANDLE;

	h = &Tcc353xHandle[_moduleIndex][_diversityIndex];
	if (!(_size > 0))
		return TCC353X_RETURN_FAIL;

	_address |= PHY_BASE_ADDR;
	TcpalSemaphoreLock(&Tcc353xInterfaceSema);
	Tcc353xSetRegDmaControl(h,
				TC3XREG_CMDDMA_DMAEN |
				TC3XREG_CMDDMA_WRITEMODE, _UNLOCK_);
	inputValue[0] = (I08U)((_address >> 24) & 0xFF);
	inputValue[1] = (I08U)((_address >> 16) & 0xFF);
	inputValue[2] = (I08U)((_address >> 8) & 0xFF);
	inputValue[3] = (I08U)(_address & 0xFF);
	Tcc353xSetRegDmaSourceAddress(h, &inputValue[0], _UNLOCK_);
	inputValue[0] = (I08U)(((_size >> 2) >> 8) & 0xFF);
	inputValue[1] = (I08U)((_size >> 2) & 0xFF);
	Tcc353xSetRegDmaSize(h, &inputValue[0], _UNLOCK_);
	Tcc353xSetRegDmaStartControl(h,
				     TC3XREG_CMDDMA_START_AUTOCLR |
				     TC3XREG_CMDDMA_INIT_AUTOCLR |
				     TC3XREG_CMDDMA_CRC32INIT_AUTOCLR,
				     _UNLOCK_);
	Tcc353xSetRegDataWindow(h, _data, _size, _UNLOCK_);
	TcpalSemaphoreUnLock(&Tcc353xInterfaceSema);
	return TCC353X_RETURN_SUCCESS;
}
Пример #8
0
void Tcc353xStreamBufferReset(I32S _moduleIndex)
{
	TcpalSemaphoreLock(&Tcc353xStreamSema);
	Tcc353xStreamRp[_moduleIndex] = 0;
	Tcc353xStreamWp[_moduleIndex] = 0;
	Tcc353xStreamBufferedSize[_moduleIndex] = 0;
	Tcc353xStreamFlushFlag[_moduleIndex] = 0;
	TcpalSemaphoreUnLock(&Tcc353xStreamSema);
}
int	broadcast_drv_if_open(void)
{
	int rc = ERROR;
	
	Tcc353xStreamFormat_t streamFormat;
	int ret = 0;

	TcpalSemaphoreLock(&Tcc353xDrvSem);

#if defined (_USE_SEND_GOOD_SIGNAL_INFO_CHANGING_)
	Time_channel_tune = 0;
	Need_send_good_signal = 0;
#endif

	Tcc353xI2cOpen(0);
	ret = Tcc353xApiOpen(0, &Tcc353xOptionSingle, sizeof(Tcc353xOption_t));
	if (ret != TCC353X_RETURN_SUCCESS) {
		/* driver re-open routine */
		TcpalPrintErr((I08S *) "[1seg] TCC3530 Re-init (close & open)...\n");
		Tcc353xWrapperSafeClose ();

		/* re-open driver & power ctrl*/
		broadcast_drv_if_power_on();
		Tcc353xI2cOpen(0);
		ret = Tcc353xApiOpen(0, &Tcc353xOptionSingle, sizeof(Tcc353xOption_t));
		if (ret != TCC353X_RETURN_SUCCESS) {
			TcpalPrintErr((I08S *) "[1seg] TCC3530 Init Fail!!!\n");
			Tcc353xWrapperSafeClose ();
			TcpalSemaphoreUnLock(&Tcc353xDrvSem);
			return ERROR;
		}
	}

	streamFormat.pidFilterEnable = 0;
	streamFormat.syncByteFilterEnable = 1;
	streamFormat.tsErrorFilterEnable = 1;
	streamFormat.tsErrorInsertEnable = 1;
#if defined (_MODEL_TCC3535_) && defined (_TCC3535_ROM_MASK_VER_)
	ret = Tcc353xApiInit(0, NULL, 0, &streamFormat);
#else
	ret = Tcc353xApiInit(0, (I08U *)TCC353X_BOOT_DATA_ISDBT13SEG,
			     TCC353X_BOOT_SIZE_ISDBT13SEG, &streamFormat);
#endif
	if (ret != TCC353X_RETURN_SUCCESS) {
		TcpalPrintErr((I08S *) "[1seg] TCC3530 Init Fail!!!\n");
		Tcc353xWrapperSafeClose ();
		rc = ERROR;
	} else {
		TcpalPrintStatus((I08S *) "[1seg] TCC3530 Init Success!!!\n");
		rc = OK;
	}

	OnAir = 1;
	TcpalSemaphoreUnLock(&Tcc353xDrvSem);
	return rc;
}
Пример #10
0
void Tcc353xStreamBufferFlush(I32S _moduleIndex)
{
	TcpalPrintStatus((I08S *) "[TCC353X] StreamBufferFlushing\n");
	TcpalSemaphoreLock(&Tcc353xStreamSema);
	Tcc353xStreamRp[_moduleIndex] = 0;
	Tcc353xStreamWp[_moduleIndex] = 0;
	Tcc353xStreamBufferedSize[_moduleIndex] = 0;
	Tcc353xStreamFlushFlag[_moduleIndex] = 1;
	TcpalSemaphoreUnLock(&Tcc353xStreamSema);
}
I32S Tcc353xStreamRead(I32S _moduleIndex, I08U * _data, I32S _size)
{
	I32S ret;
	Tcc353xHandle_t *h;

	ret = TCC353X_RETURN_SUCCESS;
	h = &Tcc353xHandle[_moduleIndex][0];

	TcpalSemaphoreLock(&Tcc353xInterfaceSema);
	ret = StreamRead_optimum(_moduleIndex, _data, _size);
	TcpalSemaphoreUnLock(&Tcc353xInterfaceSema);
	return ret;
}
Пример #12
0
int	broadcast_drv_if_get_sig_info(struct broadcast_dmb_control_info *pInfo)
{	
	int ret = 0;
	Tcc353xStatus_t st;

	TcpalSemaphoreLock(&Tcc353xDrvSem);
	if(OnAir == 0 || pInfo==NULL) {
		TcpalSemaphoreUnLock(&Tcc353xDrvSem);
		return ERROR;
	}

	ret =Tcc353xMonitoringApiGetStatus(0, 0, &st);
	if(ret != TCC353X_RETURN_SUCCESS) {
		TcpalSemaphoreUnLock(&Tcc353xDrvSem);
		return ERROR;
	}

	Tcc353xMonitoringApiAntennaPercentage (0, &st, sizeof(Tcc353xStatus_t));

	if(currentBroadCast == UHF_1SEG) {
		pInfo->sig_info.info.oneseg_info.lock = st.status.isdbLock.TMCC;
		pInfo->sig_info.info.oneseg_info.cn = st.status.snr.avgValue;
		pInfo->sig_info.info.oneseg_info.ber = st.status.viterbiber[0].avgValue;
		pInfo->sig_info.info.oneseg_info.per = st.status.tsper[0].avgValue;
		pInfo->sig_info.info.oneseg_info.agc = st.bbLoopGain;
		pInfo->sig_info.info.oneseg_info.rssi = st.status.rssi.avgValue/100;
		pInfo->sig_info.info.oneseg_info.ErrTSP = st.opstat.ARsErrorCnt;
		pInfo->sig_info.info.oneseg_info.TotalTSP = st.opstat.ARsCnt;

		if(st.antennaPercent[0]>=80)
			pInfo->sig_info.info.oneseg_info.antenna_level = 3;
		else if(st.antennaPercent[0]>=60)
			pInfo->sig_info.info.oneseg_info.antenna_level = 3;
		else if(st.antennaPercent[0]>=40)
			pInfo->sig_info.info.oneseg_info.antenna_level = 2;
		else if(st.antennaPercent[0]>=20)
			pInfo->sig_info.info.oneseg_info.antenna_level = 1;
		else
			pInfo->sig_info.info.oneseg_info.antenna_level = 0;

#if defined (_USE_ONSEG_SIGINFO_MODIFIED_MODE_)
		/*
		Num : Modulation
		Exp : CR
		mode : GI
		*/
		if((st.opstat.syncStatus>>8&0x0F)<0x0C) {
			pInfo->sig_info.info.oneseg_info.Num = 0xFF;
			pInfo->sig_info.info.oneseg_info.Exp = 0xFF;
			pInfo->sig_info.info.oneseg_info.mode = 0xFF;
		} else {
I32S WriteProcess(Tcc353xHandle_t * _handle, I08U _registerAddr,
		  I08U * _inputData, I32S _size, I08U _unlock)
{
	if (_unlock == _LOCK_)
		TcpalSemaphoreLock(&Tcc353xInterfaceSema);

	_handle->Write(_handle->moduleIndex, _handle->currentAddress,
		       _registerAddr, _inputData, _size);

	if (_unlock == _LOCK_)
		TcpalSemaphoreUnLock(&Tcc353xInterfaceSema);

	return TCC353X_RETURN_SUCCESS;
}
Пример #14
0
int	broadcast_drv_if_open(void)
{
	int rc = ERROR;
	
	Tcc353xStreamFormat_t streamFormat;
	int ret = 0;

	TcpalSemaphoreLock(&Tcc353xDrvSem);

	Tcc353xTccspiOpen(0);
	ret = Tcc353xApiOpen(0, &Tcc353xOptionSingle, sizeof(Tcc353xOption_t));
	if (ret != TCC353X_RETURN_SUCCESS) {
		/* driver re-open routine */
		TcpalPrintErr((I08S *) "[1seg] TCC3530 Re-init (close & open)...\n");
		Tcc353xWrapperSafeClose ();

		/* re-open driver & power ctrl*/
		broadcast_drv_if_power_on();
		Tcc353xTccspiOpen(0);
		ret = Tcc353xApiOpen(0, &Tcc353xOptionSingle, sizeof(Tcc353xOption_t));
		if (ret != TCC353X_RETURN_SUCCESS) {
			TcpalPrintErr((I08S *) "[1seg] TCC3530 Init Fail!!!\n");
			Tcc353xWrapperSafeClose ();
			TcpalSemaphoreUnLock(&Tcc353xDrvSem);
			return ERROR;
		}
	}

	streamFormat.pidFilterEnable = 0;
	streamFormat.syncByteFilterEnable = 1;
	streamFormat.tsErrorFilterEnable = 1;
	streamFormat.tsErrorInsertEnable = 1;
	ret = Tcc353xApiInit(0, (I08U *)TCC353X_BOOT_DATA_ISDBT13SEG,
			     TCC353X_BOOT_SIZE_ISDBT13SEG, &streamFormat);
	if (ret != TCC353X_RETURN_SUCCESS) {
		TcpalPrintErr((I08S *) "[1seg] TCC3530 Init Fail!!!\n");
		Tcc353xWrapperSafeClose ();
		rc = ERROR;
	} else {
		Tcc353xStreamBufferInit(0);
		TcpalIrqEnable();
		TcpalPrintStatus((I08S *) "[1seg] TCC3530 Init Success!!!\n");
		rc = OK;
	}

	OnAir = 1;
	TcpalSemaphoreUnLock(&Tcc353xDrvSem);
	return rc;
}
Пример #15
0
I32S TcbdGetFirstQueuePtr(TcbdQueue_t *_queue, I08U **_chunk, I32S *_size, I32S *_type)
{
    TcpalSemaphoreLock(&_queue->sem);

    if(TcbdQueueIsEmpty(_queue))
    {
        TcbdDebug(0, "Queue Empty!! \n");
        TcpalSemaphoreUnLock(&_queue->sem);
        return -1;
    }
    *_size = _queue->q[_queue->front].size;
    *_chunk = _queue->q[_queue->front].buffer;
    if(_type) *_type = _queue->q[_queue->front].type;

    TcbdDebug(0, "pos:%d, size:%d\n", _queue->pointer, *_size);
    TcpalSemaphoreUnLock(&_queue->sem);
    
    return 0;
}
Пример #16
0
int	broadcast_drv_if_close(void)
{
	int rc = ERROR;	
	int ret = 0;

	TcpalSemaphoreLock(&Tcc353xDrvSem);
	OnAir = 0;
	currentSelectedChannel = -1;
	currentBroadCast = TMM_13SEG;
	
	TcpalIrqDisable();
	ret = Tcc353xApiClose(0);
	Tcc353xStreamBufferClose(0);
	Tcc353xTccspiClose(0);
	if(ret == TCC353X_RETURN_SUCCESS)
		rc = OK;

	TcpalSemaphoreUnLock(&Tcc353xDrvSem);
	return rc;
}
inline static void TcbdParseStream(TcbdIrqData_t * irqData)
{
    I32S size = TCBD_MAX_THRESHOLD*2, ret = 0;
    I08S irqStatus;
    I08S irqError;
    TcbdDevice_t *device = irqData->device;

	TcpalSemaphoreLock(&TcbdIrqData.lock);
    ret = TcbdReadIrqStatus(device, &irqStatus, &irqError);
    ret |= TcbdClearIrq(device, irqStatus);
    ret |= TcbdReadStream(device, StreamBuffer, &size);
    if(ret == 0 && !irqError)
    {
        TcbdParser(StreamBuffer, size);
    }
    else
    {
        TcbdDebug(DEBUG_ERROR,
        	"================================================================================\n"
        	"### buffer is full, skip the data (status=0x%02X, error=0x%02X, ret:%d, time%d)  ###\n"
        	"================================================================================\n",
        	irqStatus, irqError, ret, (int)TcpalGetTimeIntervalMs(irqData->startTick));
	TcbdInitStreamDataConfig(device, ENABLE_CMD_FIFO, device->lastSelectedBuffer, device->intrThreshold);
        TcbdInitParser(NULL);
    }
	ret = TcbdReadIrqStatus(device, &irqStatus, &irqError);
	if(irqError)
	{
		TcbdDebug(DEBUG_ERROR,
		   "================================================================================\n"
		   "### TcbdReadIrqStatus  buffer is full, skip the data (status=0x%02X, error=0x%02X, ret:%d, time%d)  ###\n"
		   "================================================================================\n",
			   irqStatus, irqError, (int)ret, (int)TcpalGetTimeIntervalMs(irqData->startTick));
		TcbdInitStreamDataConfig(device, ENABLE_CMD_FIFO, device->lastSelectedBuffer, device->intrThreshold);
		TcbdInitParser(NULL);
	}
	
	TcpalSemaphoreUnLock(&TcbdIrqData.lock);
}
I32S Tcc353xMiscWrite(I32S _moduleIndex, I32S _diversityIndex,
		      I08U _miscConfig, I08U _address, I32U _data)
{
	Tcc353xHandle_t *h;

	if (Tcc353xHandle[_moduleIndex][_diversityIndex].handleOpen == 0)
		return TCC353X_RETURN_FAIL_INVALID_HANDLE;

	h = &Tcc353xHandle[_moduleIndex][_diversityIndex];

	TcpalSemaphoreLock(&Tcc353xInterfaceSema);

	Tcc353xSetRegMiscConfig(h, _miscConfig | 1, _UNLOCK_);
	Tcc353xSetRegMiscAddress(h, _address, _UNLOCK_);
	_data = SWAP32(_data);
	Tcc353xSetRegMiscData(h, (I08U *) (&_data), _UNLOCK_);
	Tcc353xSetRegMiscAction(h, TC3XREG_MISC_ACTION, _UNLOCK_);
	/* warning : please reset to opcontrol miscconfig0 */
	Tcc353xSetRegMiscConfig(h, 0, _UNLOCK_);

	TcpalSemaphoreUnLock(&Tcc353xInterfaceSema);
	return TCC353X_RETURN_SUCCESS;
}
int	broadcast_drv_if_close(void)
{
	int rc = ERROR;	
	int ret = 0;

	TcpalSemaphoreLock(&Tcc353xDrvSem);
	OnAir = 0;
	currentSelectedChannel = -1;
	currentBroadCast = TMM_13SEG;

	ret = Tcc353xApiClose(0);
	Tcc353xI2cClose(0);
	if(ret == TCC353X_RETURN_SUCCESS)
		rc = OK;

#if defined (_USE_SEND_GOOD_SIGNAL_INFO_CHANGING_)
	Time_channel_tune = 0;
	Need_send_good_signal = 0;
#endif

	TcpalSemaphoreUnLock(&Tcc353xDrvSem);
	return rc;
}
I32S Tcc353xMiscRead(I32S _moduleIndex, I32S _diversityIndex,
		     I08U _miscConfig, I08U _address, I32U * _data)
{
	Tcc353xHandle_t *h;

	if (Tcc353xHandle[_moduleIndex][_diversityIndex].handleOpen == 0)
		return TCC353X_RETURN_FAIL_INVALID_HANDLE;

	h = &Tcc353xHandle[_moduleIndex][_diversityIndex];

	TcpalSemaphoreLock(&Tcc353xInterfaceSema);

	Tcc353xSetRegMiscConfig(h, _miscConfig, _UNLOCK_);
	Tcc353xSetRegMiscAddress(h, _address, _UNLOCK_);
	Tcc353xSetRegMiscAction(h, TC3XREG_MISC_ACTION, _UNLOCK_);
	Tcc353xGetRegMiscData(h, (I08U *) (_data), _UNLOCK_);
	_data[0] = SWAP32(_data[0]);
	/*                                                 */
	Tcc353xSetRegMiscConfig(h, 0, _UNLOCK_);

	TcpalSemaphoreUnLock(&Tcc353xInterfaceSema);
	return TCC353X_RETURN_SUCCESS;
}
Пример #21
0
I32S TcbdEnqueue(TcbdQueue_t *_queue, I08U *_chunk, I32S _size, I32S _type)
{
    if(_chunk == NULL || _size <= 0)
    {
        TcbdDebug(DEBUG_ERROR, "Invalid argument!! \n");
        return -1;
    }

    TcpalSemaphoreLock(&_queue->sem);
    if(_queue->pointer + _size > _queue->buffSize)
    {
        TcbdDebug(0, "Memory full! \n");
        TcbdResetQueue(_queue);
        TcpalSemaphoreUnLock(&_queue->sem);
        return -1;
    }

    if(TcbdQueueIsFull(_queue))
    {
        TcbdDebug(0, "Queue Full!! \n");
        _queue->pointer = 0;
    }

    TcpalMemoryCopy(_queue->globalBuffer + _queue->pointer, _chunk, _size);

    _queue->q[_queue->rear].buffer = _queue->globalBuffer + _queue->pointer;
    _queue->q[_queue->rear].size   = _size;
    _queue->q[_queue->rear].type   = _type;

    _queue->rear     = (_queue->rear + 1) % _queue->qsize;
    _queue->pointer += _size;
    TcbdDebug(0, "pos:%d, size:%d\n", _queue->pointer, _size);

    TcpalSemaphoreUnLock(&_queue->sem);

    return 0;
}
/* stream read control */
I32S Tcc353xStreamRead(I32S _moduleIndex, I08U * _data, I32S _size)
{
	I32U address;
	I08U inputValue[4];
	Tcc353xHandle_t *h;

	if (Tcc353xHandle[_moduleIndex][0].handleOpen == 0)
		return TCC353X_RETURN_FAIL_INVALID_HANDLE;

	h = &Tcc353xHandle[_moduleIndex][0];
	if (!(_size > 0))
		return TCC353X_RETURN_FAIL;

	address = 0x3F0A0 | PHY_BASE_ADDR;
	TcpalSemaphoreLock(&Tcc353xInterfaceSema);
	Tcc353xSetRegDmaControl(h,
				TC3XREG_CMDDMA_DMAEN |
				TC3XREG_CMDDMA_ADDRFIX |
				TC3XREG_CMDDMA_READMODE, _UNLOCK_);
	inputValue[0] = (I08U)((address >> 24) & 0xFF);
	inputValue[1] = (I08U)((address >> 16) & 0xFF);
	inputValue[2] = (I08U)((address >> 8) & 0xFF);
	inputValue[3] = (I08U)(address & 0xFF);
	Tcc353xSetRegDmaSourceAddress(h, &inputValue[0], _UNLOCK_);
	inputValue[0] = (I08U)(((_size >> 2) >> 8) & 0xFF);
	inputValue[1] = (I08U)((_size >> 2) & 0xFF);
	Tcc353xSetRegDmaSize(h, &inputValue[0], _UNLOCK_);
	Tcc353xSetRegDmaStartControl(h,
				     TC3XREG_CMDDMA_START_AUTOCLR |
				     TC3XREG_CMDDMA_INIT_AUTOCLR |
				     TC3XREG_CMDDMA_CRC32INIT_AUTOCLR,
				     _UNLOCK_);
	Tcc353xGetRegDataWindow(h, _data, _size, _UNLOCK_);
	TcpalSemaphoreUnLock(&Tcc353xInterfaceSema);
	return TCC353X_RETURN_SUCCESS;
}
Пример #23
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;
}