Пример #1
0
void Tcc353xInterruptGetStream(I32U _fifoSize)
{
	I32U totalSize = 0;
	I32U freeSize = 0;
	I32U writeSize = 0;

	totalSize = _fifoSize - (_fifoSize%188);

	if(totalSize>=188) {
		Tcc353xApiStreamRead(0,
				     &Tcc353xStreamData[0],
				     totalSize);

		if(Tcc353xStreamData[0]!=0x47) {
			TcpalPrintErr((I08S *) "[TCC353X] SyncByte Error! [0x%02x]\n",
				     Tcc353xStreamData[0]);
			TcpalPrintErr((I08S *) "[TCC353X] Buff Flush for SyncByte matching\n");
		} else {
			freeSize = mbt_dataring_free(RingBufId);

			if(freeSize >= totalSize) {
				writeSize = mbt_dataring_write(RingBufId, &Tcc353xStreamData[0], totalSize);
				if(writeSize < 0) {
					TcpalPrintErr((I08S *) "[TCC353X] Ring Buffer Error!\n");
				}
			}
		}
	}
}
Пример #2
0
I32U Tcc353xInterruptProcess(void)
{
	I32U ret = 0;
	I08U irqStatus = 0;
	I32S moduleIndex = 0;
	I32U totalSize = 0;
	I08U data = 0x00;

	/* Read BB Interrupt Status */
	Tcc353xApiGetIrqStatus(moduleIndex, &irqStatus);

#if defined (_I2C_STS_)
	totalSize = 0;
	data = 0x00;

	/* Tcc353x IRQ Clear */
	Tcc353xApiIrqClear(moduleIndex, irqStatus);
	ret = 0; /* return no data */
#else
	/* Stream Interrupt */
	if (irqStatus&0x01) {
		TcpalPrintErr((I08S *)
			      "[TCC353X] FIFO overflow[0x%02X] flush!!!\n",
			      irqStatus);

		/* IRQ Disable - Prevent additional interrupt signal */
		data = 0x00;
		Tcc353xApiRegisterWrite(0,0, 0x03, &data, 1);

		/* Tcc353x IRQ Clear */
		Tcc353xApiIrqClear(moduleIndex, irqStatus);
		Tcc353xApiInterruptBuffClr(moduleIndex);
		gOverflowcnt ++;
		ret = 0;
	} else {
		/* Tcc353x IRQ Clear */
		Tcc353xApiIrqClear(moduleIndex, irqStatus);
		Tcc353xApiGetFifoStatus(moduleIndex, &totalSize);
		ret = totalSize;
		if(ret>=150*188)
			TcpalPrintErr((I08S *)
			      "[TCC353X] FIFO stat size[%d]\n",
			      ret);
	}

	gDbgIsrCnt++;

	if(gDbgIsrCnt>100) {
		gDbgIsrCnt = 0;
#ifdef _DBG_CHK_OVERFLOW_CNT_
		TcpalPrintStatus((I08S *)
				  "[TCC353X] CurrOverflow Cnt %d\n",
				  gOverflowcnt);
#endif
	}
#endif

	return ret;
}
Пример #3
0
void Tcc353xInterruptGetStream(I32U _fifoSize)
{
#if defined (USE_LGE_RING_BUFFER) && !defined (_I2C_STS_)
#define _MAX_TS_READ_SIZE_	(15792) /* 188*84 */
	I32U totalSize = 0;
	I32U freeSize = 0;
	I32U writeSize = 0;
	I32U remainSize = 0;
	I32U i;
	I32U readSizes[2] = {0,0};

	totalSize = _fifoSize - (_fifoSize%188);

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

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

	//if(totalSize > 188 * 87)
	if(totalSize > _MAX_TS_READ_SIZE_) {
		remainSize = totalSize - _MAX_TS_READ_SIZE_;
		remainSize = (remainSize/188/4)*188*4;
		if(remainSize> _MAX_TS_READ_SIZE_)
			remainSize = _MAX_TS_READ_SIZE_;
		totalSize = _MAX_TS_READ_SIZE_;
	} else {
		remainSize = 0;
	}
	readSizes[0] = totalSize;
	readSizes[1] = remainSize;

	//                                                                         

	for(i=0; i<2; i++) {
		if(readSizes[i]>=188) {
			Tcc353xApiStreamRead(0,
					     &Tcc353xStreamData[0],
					     readSizes[i]);

			if(Tcc353xStreamData[0]!=0x47) {
				TcpalPrintErr((I08S *) "[TCC353X] SyncByte Error! [0x%02x]\n",
					     Tcc353xStreamData[0]);
				TcpalPrintErr((I08S *) "[TCC353X] Buff Flush for SyncByte matching\n");
			} else {
				freeSize = mbt_dataring_free(RingBufId);

				if(freeSize >= readSizes[i]) {
					writeSize = mbt_dataring_write(RingBufId, &Tcc353xStreamData[0], readSizes[i]);
					if(writeSize < 0) {
						TcpalPrintErr((I08S *) "[TCC353X] Ring Buffer Error!\n");
					}
				}
			}
		}
	}
#else
	return;
#endif
}
Пример #4
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);
		}
	}
}
Пример #5
0
I32S Tcc353xAdaptI2CWriteEx(I08U raddr, I08U* txdata, I32S length)
{
#if !defined (_TCSPI_ONLY_)

	I32S rc;
	I32S cMax, remain;
	I32S i;
	struct i2c_msg msg;

	TcpalMemset (&msg, 0x00, sizeof(struct i2c_msg));

	cMax = length / MAX_I2C_BURST;
	remain = length % MAX_I2C_BURST;

	msg.addr = TcpalI2cClient->addr;
	msg.flags = 0;
	msg.len = MAX_I2C_BURST+1;
	msg.buf = (unsigned char*)I2cBuffer;

	I2cBuffer[0] = (unsigned char) (raddr);

	for (i = 0; i < cMax; i++) {
		TcpalMemcpy(&I2cBuffer[1], &txdata[i * MAX_I2C_BURST],
			    MAX_I2C_BURST);

		msg.len = MAX_I2C_BURST+1;
		msg.buf = (unsigned char*)I2cBuffer;

		rc = i2c_transfer(TcpalI2cClient->adapter, &msg, 1);
		if(rc < 0)
		{
			TcpalPrintErr((I08S *)"[dtv][tcc3536][error] fail rc=%d, addr=0x%X, data=0x%02x\n", 
				(int)rc, (unsigned int)TcpalI2cClient->addr, (unsigned int)txdata[1]);
		
			return TCC353X_RETURN_FAIL;
		}
	}

	if (remain) {
		TcpalMemcpy(&I2cBuffer[1],
			    &txdata[cMax * MAX_I2C_BURST], remain);

		msg.len = remain+1;
		msg.buf = (unsigned char*)I2cBuffer;

		rc = i2c_transfer(TcpalI2cClient->adapter, &msg, 1);
		if(rc < 0)
		{
			TcpalPrintErr((I08S *)"[dtv][tcc3536][error] fail rc=%d, addr=0x%X, data=0x%02x\n", 
				(int)rc, (unsigned int)TcpalI2cClient->addr, (unsigned int)txdata[1]);
		
			return TCC353X_RETURN_FAIL;
		}
	}
#endif
	return TCC353X_RETURN_SUCCESS;
}
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;
}
Пример #7
0
I32S Tcc353xAdaptI2CReadEx(I08U raddr, I08U *rxdata, I32S length)
{
#if !defined (_TCSPI_ONLY_)

	I32S rc;
	I32S cMax, remain;
	I32S i;
	struct i2c_msg msgs[2];

	TcpalMemset (&msgs[0], 0x00, sizeof(struct i2c_msg)*2);

	cMax = length / MAX_I2C_BURST;
	remain = length % MAX_I2C_BURST;

	msgs[0].addr	= TcpalI2cClient->addr;
	msgs[0].flags = 0;
	msgs[0].len   = 1;
	msgs[0].buf   = (unsigned char*)&raddr;

	msgs[1].addr	= TcpalI2cClient->addr;
	msgs[1].flags = I2C_M_RD;
	msgs[1].len   = length;
	msgs[1].buf   = (unsigned char*)rxdata;

	for (i = 0; i < cMax; i++) {
		msgs[1].len   = MAX_I2C_BURST;
		msgs[1].buf   = (unsigned char*)rxdata + i*MAX_I2C_BURST;

		rc = i2c_transfer(TcpalI2cClient->adapter, msgs, 2);
		if(rc < 0)
		{
			TcpalPrintErr((I08S *)"[dtv][tcc3536][error] failed! rc=%d, addr=0x%x\n", 
				(int)rc, (unsigned int)TcpalI2cClient->addr);
		
			return TCC353X_RETURN_FAIL;
		}
	}

	if (remain) {
		msgs[1].len   = remain;
		msgs[1].buf   = (unsigned char*)rxdata + cMax*MAX_I2C_BURST;

		rc = i2c_transfer(TcpalI2cClient->adapter, msgs, 2);
		if(rc < 0)
		{
			TcpalPrintErr((I08S *)"[dtv][tcc3536][error] failed! rc=%d, addr=0x%x\n", 
				(int)rc, (unsigned int)TcpalI2cClient->addr);
		
			return TCC353X_RETURN_FAIL;
		}
	}
#endif
	return TCC353X_RETURN_SUCCESS;
};
Пример #8
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;
}
Пример #9
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;
}
Пример #10
0
static int broadcast_Isdb_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
    int rc = 0;

    int addr;

    TcpalPrintLog("broadcast_Isdb_i2c_probe client:0x%X\n", (unsigned int)client);
    if(!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
        TcpalPrintErr("need I2C_FUNC_I2C\n");
        return -ENODEV;
    }
    /* taew00k.kang added for Device Tree Structure 2013-06-04 [start] */
    addr = client->addr; //Slave Addr
    pr_err("[1seg] i2c Slaveaddr [%x] \n", addr);
    /* taew00k.kang added for Device Tree Structure 2013-06-04 [end] */

    TcpalCreateSemaphore(&Tcc353xDrvSem,
                         (I08S *) "Tcc353xDriverControlSemaphore", 1);

    IsdbCtrlInfo.pclient = client;
    //i2c_set_clientdata(client, (void*)&IsdbCtrlInfo.pclient);

    TchalInit();
#ifndef _NOT_USE_WAKE_LOCK_
    wake_lock_init(&IsdbCtrlInfo.wake_lock, WAKE_LOCK_SUSPEND,
                   dev_name(&client->dev));
#endif

    return rc;
}
I32S Tcc353xSetRegManual(Tcc353xHandle_t * _handle, I08U _addr,
			 I08U * _data, I32S _size)
{
	if (_addr == TC3XREG_SYS_EN) {
		TcpalPrintErr((I08S *)
			      "[TCC353X] Can't control System Register!!\n");
		return TCC353X_RETURN_FAIL;
	}
	return (WriteProcess(_handle, _addr, _data, _size, _LOCK_));
}
I32S TcpalSemaphoreLock(TcpalSemaphore_t * _semaphore)
{
	struct mutex *lock = (struct mutex*)*_semaphore;

	if(lock == NULL) {
		TcpalPrintErr((I08S *)"semaphore lock error\n");
		return TCC353X_RETURN_FAIL;
	}
	mutex_lock(lock);
	return TCC353X_RETURN_SUCCESS;
}
static I32S Tcc353xI2cSetup(I32S _moduleIndex)
{
	if (_moduleIndex >= 2) {
		TcpalPrintErr((I08S *) "Not supported, moduleidx=%d\n",
			      _moduleIndex);
		return TCC353X_RETURN_FAIL;
	}

	TcpalI2cClient = TCC_GET_I2C_DRIVER();	
	return TCC353X_RETURN_SUCCESS;
}
Пример #14
0
I32S TcpalCreateSemaphore(TcpalSemaphore_t * _semaphore, I08S * _name,
			  I32U _initialCount)
{
	struct mutex *lock;
	I32S index;

	index = TcpalGetSemaphoreAddress();
	if(index<0) {
		TcpalPrintErr((I08S *)"######## Mutex Get Fail :%d \n", (int)index);
		return TCC353X_RETURN_FAIL;
	}

	lock = &MutexPool[index];
	mutex_init(lock);

	TcpalPrintErr((I08S *)"######## MutexC %s [%d] \n", _name, (int)(lock));

	*_semaphore = (TcpalSemaphore_t)lock;
	return TCC353X_RETURN_SUCCESS;
}
Пример #15
0
static I32S Tcc353xI2cSetup(I32S _moduleIndex)
{
#if !defined (_TCSPI_ONLY_)
	if (_moduleIndex >= 2) {
		TcpalPrintErr((I08S *) "[dtv][tcc3536][error] Not supported, moduleidx=%d\n",
			      _moduleIndex);
		return TCC353X_RETURN_FAIL;
	}

	TcpalI2cClient = TCC_GET_I2C_DRIVER();	
#endif
	return TCC353X_RETURN_SUCCESS;
}
void Tcc353xInterruptGetStream(I32U _fifoSize)
{
	I32U totalSize = 0;
	I32U freeSize = 0;
	I32U writeSize = 0;

	totalSize = _fifoSize - (_fifoSize%188);

	//[Fix Start]align TS size to use DMA only mode - 20121228 [email protected]
	//TcpalPrintErr((I08S *) "Tcc353xInterruptGetStream size[%d]\n", totalSize);

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

	if(totalSize > 188 * 87)
		totalSize = 188 * 84;
	//[Fix End]align TS size to use DMA only mode - 20121228 [email protected]

	if(totalSize>=188) {
		Tcc353xApiStreamRead(0,
				     &Tcc353xStreamData[0],
				     totalSize);

		if(Tcc353xStreamData[0]!=0x47) {
			TcpalPrintErr((I08S *) "[TCC353X] SyncByte Error! [0x%02x]\n",
				     Tcc353xStreamData[0]);
			TcpalPrintErr((I08S *) "[TCC353X] Buff Flush for SyncByte matching\n");
		} else {
			freeSize = mbt_dataring_free(RingBufId);

			if(freeSize >= totalSize) {
				writeSize = mbt_dataring_write(RingBufId, &Tcc353xStreamData[0], totalSize);
				if(writeSize < 0) {
					TcpalPrintErr((I08S *) "[TCC353X] Ring Buffer Error!\n");
				}
			}
		}
	}
}
Пример #17
0
I32S TcpalDeleteSemaphore(TcpalSemaphore_t * _semaphore)
{
	struct mutex *lock = (struct mutex*)*_semaphore;
	I32U address;
	I32S index;
	
	if(lock == NULL) 
		return TCC353X_RETURN_FAIL;

	address = (I32U)(lock);
	index = TcpalFreeSemaphoreAddress(address);
	if(index < 0)
	{
		TcpalPrintErr((I08S *)"####### Mutex Delete Fail :%d \n", (int)index);
		return TCC353X_RETURN_FAIL;
	}
	
	TcpalPrintErr((I08S *)"######## MutexR [%d] \n", (int)(lock));

	mutex_destroy(lock);
	*_semaphore = 0;
	return TCC353X_RETURN_SUCCESS;
}
Пример #18
0
int __devinit broadcast_dmb_drv_init(void)
{
    int rc;
    TcpalPrintStatus((I08S *)"[%s]\n", __func__);
    rc = broadcast_dmb_drv_start(&device_tcc353x);
    if (rc)
    {
        TcpalPrintErr((I08S *)"failed to load\n");
        return rc;
    }
    TcpalPrintStatus((I08S *)"[%s add i2c driver]\n", __func__);
    rc = i2c_add_driver(&broadcast_Isdb_driver);
    TcpalPrintStatus((I08S *)"broadcast_add_driver rc = (%d)\n", rc);
    return rc;
}
Пример #19
0
static I32S Tcc353xTccspiSetup(I32S _moduleIndex)
{
	struct TcpalTcspiData_t *spiData;

	if (_moduleIndex >= 2) {
		TcpalPrintErr((I08S *) "Not supported, moduleidx=%d\n",
			      _moduleIndex);
		return TCC353X_RETURN_FAIL;
	}

	spiData = &TcpalTcspiData;
	memset(&TcpalTcspiData, 0, sizeof(TcpalTcspiData));

	spiData->spi_dev = TCC_GET_SPI_DRIVER();	
	Tcc353xTccspiInit();

	return TCC353X_RETURN_SUCCESS;
}
static int broadcast_Isdb_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
	int rc = 0;

	int addr;

	TcpalPrintLog("broadcast_Isdb_i2c_probe client:0x%X\n", (unsigned int)client);
	if(!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
		TcpalPrintErr("need I2C_FUNC_I2C\n");
		return -ENODEV;
	}
	/*                                                                 */
	addr = client->addr; //          
	pr_err("[1seg] i2c Slaveaddr [%x] \n", addr);
	/*                                                               */

	TcpalCreateSemaphore(&Tcc353xDrvSem,
			     (I08S *) "Tcc353xDriverControlSemaphore", 1);
	TcpalCreateSemaphore(&Tcc353xStreamSema,
			     (I08S *) "StreamSemaphore", 1);
	TcpalCreateSemaphore(&Tcc353xLnaControlSema,
			     (I08S *) "LnaControlSemaphore", 1);

	IsdbCtrlInfo.pclient = client;
	//                                                         

	TchalInit();
	TcpalRegisterIrqHandler();
	TcpalIrqDisable();

#ifndef _NOT_USE_WAKE_LOCK_
	wake_lock_init(&IsdbCtrlInfo.wake_lock, WAKE_LOCK_SUSPEND,
					dev_name(&client->dev));	
#endif

	/*                        */
	tcc353x_lnaControl_start();

	return rc;
}
Пример #21
0
I32U Tcc353xInterruptProcess(void)
{
	I32U ret = 0;
	I08U irqStatus = 0;
	I32S moduleIndex = 0;
	I32U totalSize = 0;

	/* Read BB Interrupt Status */
	Tcc353xApiGetIrqStatus(moduleIndex, &irqStatus);

	/* Stream Interrupt */
	if (irqStatus&0x01) {
		TcpalPrintErr((I08S *)
			      "[TCC353X] FIFO overflow[0x%02X] flush!!!\n",
			      irqStatus);
		/* Tcc353x IRQ Clear */
		Tcc353xApiIrqClear(moduleIndex, irqStatus);
		Tcc353xApiInterruptBuffClr(moduleIndex);
		gOverflowcnt ++;
		ret = 0;
	} else {
		/* Tcc353x IRQ Clear */
		Tcc353xApiIrqClear(moduleIndex, irqStatus);
		Tcc353xApiGetFifoStatus(moduleIndex, &totalSize);
		ret = totalSize;
	}

	gDbgIsrCnt++;

	if(gDbgIsrCnt>40) {
		gDbgIsrCnt = 0;
#ifdef _DBG_CHK_OVERFLOW_CNT_
		TcpalPrintStatus((I08S *)
				  "[TCC353X] CurrOverflow Cnt %d\n",
				  gOverflowcnt);
#endif
	}
	
	return ret;
}
int __devinit broadcast_dmb_drv_init(void)
{
	int rc;

	TcpalPrintStatus((I08S *)"[%s]\n", __func__);
	rc = broadcast_dmb_drv_start();	
	if (rc) 
	{
		TcpalPrintErr((I08S *)"failed to load\n");
		return rc;
	}

#if defined(_I2C_STS_)
	TcpalPrintStatus((I08S *)"[%s add i2c driver]\n", __func__);
	rc = i2c_add_driver(&broadcast_Isdb_driver);
#else
	TcpalPrintStatus((I08S *)"[%s add spi driver]\n", __func__);
	rc =  spi_register_driver(&broadcast_Isdb_driver);
#endif

	TcpalPrintStatus((I08S *)"broadcast_add_driver rc = (%d)\n", rc);
	return rc;
}
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;
}
Пример #24
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;
}