コード例 #1
0
ファイル: IBase.c プロジェクト: herryfan/x5hd2-drivers
AVL_DVBSx_ErrorCode AVL_DVBSx_IBase_SendRxOP(AVL_uchar ucOpCmd, struct AVL_DVBSx_Chip * pAVLChip )
{
    AVL_DVBSx_ErrorCode r = AVL_DVBSx_EC_OK;
    AVL_uchar pucBuff[2];
    AVL_uint16 uiTemp;
    enum AVL_DVBSx_Sleep_Wake_Status sleep_wake_status;
    const AVL_uint16 uiTimeDelay = 10;
    AVL_uint16 uiMaxRetries = 20;

    r = AVL_DVBSx_IBSP_WaitSemaphore(&(pAVLChip->m_semRx));
    r |= AVL_DVBSx_IBase_GetChipStatus(&sleep_wake_status, pAVLChip);
    if(r == AVL_DVBSx_EC_OK)
    {
        if(sleep_wake_status == AVL_DVBSx_Sleep_Mode)
        {
            if((ucOpCmd != OP_RX_WAKE) && (ucOpCmd != OP_RX_HALT) && (ucOpCmd != OP_RX_SLEEP))
            {
                AVL_DVBSx_IBSP_ReleaseSemaphore(&(pAVLChip->m_semRx));
                r = AVL_DVBSx_EC_InSleepMode;
                return(r);
            }
        }

        do
        {
            r = AVL_DVBSx_IBase_GetRxOPStatus(pAVLChip);
            if( AVL_DVBSx_EC_OK == r )
            {
                break;
            }
            //AVL_DVBSx_IBSP_Delay(uiTimeDelay);
            tuner_mdelay(uiTimeDelay);
            uiMaxRetries--;

        } while(uiMaxRetries != 0);

        if( AVL_DVBSx_EC_OK == r )
        {
            pucBuff[0] = 0;
            pucBuff[1] = ucOpCmd;
            uiTemp = DeChunk16(pucBuff);
            r |= AVL_DVBSx_II2C_Write16(pAVLChip, rx_cmd_addr, uiTemp);
        }
    }
    r |= AVL_DVBSx_IBSP_ReleaseSemaphore(&(pAVLChip->m_semRx));

    return(r);
}
コード例 #2
0
ファイル: II2CRepeater.c プロジェクト: herryfan/x5hd2-drivers
AVL_DVBSx_ErrorCode AVL_DVBSx_II2CRepeater_SendOP(AVL_puchar pBuff, AVL_uchar ucSize, struct AVL_DVBSx_Chip * pAVLChip )
{
    AVL_DVBSx_ErrorCode r;
    const AVL_uint16 uiTimeDelay = 10;
    const AVL_uint16 uiMaxRetries = 30;
    AVL_uint32 i;

    r = AVL_DVBSx_IBSP_WaitSemaphore(&(pAVLChip->m_semI2CRepeater));

    i = 0;
    while (AVL_DVBSx_EC_OK != AVL_DVBSx_II2CRepeater_GetOPStatus(pAVLChip))   //Maximum waiting time is 300mS.
    {
        if (uiMaxRetries < i++)
        {
            r |= AVL_DVBSx_EC_Running;
            break;
        }
        //AVL_DVBSx_IBSP_Delay(uiTimeDelay);
        tuner_mdelay(uiTimeDelay);
    }

    if ( AVL_DVBSx_EC_OK == r )
    {
        r = AVL_DVBSx_II2C_Write(pAVLChip, pBuff, ucSize);
    }
    r |= AVL_DVBSx_IBSP_ReleaseSemaphore(&(pAVLChip->m_semI2CRepeater));
    return(r);
}
コード例 #3
0
ファイル: II2CRepeater.c プロジェクト: herryfan/x5hd2-drivers
AVL_DVBSx_ErrorCode AVL_DVBSx_II2CRepeater_ReadData_Multi(  AVL_uchar ucSlaveAddr, AVL_puchar pucBuff, AVL_uchar ucRegAddr, AVL_uint16 uiSize, struct AVL_DVBSx_Chip * pAVLChip )
{
    AVL_DVBSx_ErrorCode r;
    AVL_uchar pBuff[I2CM_RSP_LENGTH];
    AVL_uint16 uiTimeOut;
    const AVL_uint16 uiTimeOutTh = 10;
    const AVL_uint32 uiTimeDelay = 100;  //100 ms

    if ( uiSize > I2CM_RSP_LENGTH )
    {
        return(AVL_DVBSx_EC_GeneralFail);
    }

    r = AVL_DVBSx_IBSP_WaitSemaphore(&(pAVLChip->m_semI2CRepeater_r));

    ChunkAddr(i2cm_cmd_addr+I2CM_CMD_LENGTH-6, pBuff);
    pBuff[3] = 0;
    pBuff[4] = ucRegAddr;
    pBuff[5] = 0x1;
    pBuff[6] = (AVL_uchar)uiSize;
    pBuff[7] = ucSlaveAddr;
    pBuff[8] = OP_I2CM_READ;
    r |= AVL_DVBSx_II2CRepeater_SendOP(pBuff, 9, pAVLChip);
    if ( AVL_DVBSx_EC_OK == r )
    {
        uiTimeOut = 0;
        while ( AVL_DVBSx_EC_OK != AVL_DVBSx_II2CRepeater_GetOPStatus(pAVLChip) )
        {
            if((++uiTimeOut) >= uiTimeOutTh)
            {
                r |= AVL_DVBSx_EC_TimeOut;
                r |= AVL_DVBSx_IBSP_ReleaseSemaphore(&(pAVLChip->m_semI2CRepeater_r));
                return(r);
            }
            r |= AVL_DVBSx_IBSP_Delay(uiTimeDelay);
        }
        r |= (AVL_DVBSx_II2C_Read(pAVLChip, i2cm_rsp_addr, pucBuff, uiSize));
    }
    r |= AVL_DVBSx_IBSP_ReleaseSemaphore(&(pAVLChip->m_semI2CRepeater_r));

    return(r);
}
コード例 #4
0
ファイル: II2C.c プロジェクト: MindShow/hisi-driverlibs
AVL_DVBSx_ErrorCode AVL_DVBSx_II2C_Read( const struct AVL_DVBSx_Chip * pAVLChip, AVL_uint32 uiOffset, AVL_puchar pucBuff, AVL_uint16 uiSize)
{
	AVL_DVBSx_ErrorCode r;
	AVL_uchar pucBuffTemp[3];
	AVL_uint16 ui1, ui2;
	AVL_uint16 iSize;

	r = AVL_DVBSx_IBSP_WaitSemaphore(&(gI2CSem));
	if( AVL_DVBSx_EC_OK == r )
	{
		ChunkAddr(uiOffset, pucBuffTemp);
		ui1 = 3;
		r = AVL_DVBSx_IBSP_I2CWrite(pAVLChip, pucBuffTemp, &ui1);  
		if( AVL_DVBSx_EC_OK == r )
		{
			if( uiSize & 1 )
			{
				iSize = uiSize - 1;
			}
			else
			{
				iSize = uiSize;
			}
			ui2 = 0;
			while( iSize > MAX_II2C_READ_SIZE )
			{
				ui1 = MAX_II2C_READ_SIZE;
				r |= AVL_DVBSx_IBSP_I2CRead(pAVLChip, pucBuff+ui2, &ui1);
				ui2 += MAX_II2C_READ_SIZE;
				iSize -= MAX_II2C_READ_SIZE;
			}

			if( 0 != iSize )
			{
				r |= AVL_DVBSx_IBSP_I2CRead(pAVLChip, pucBuff+ui2, &iSize);
			}

			if( uiSize & 1 )
			{
				ui1 = 2;
				r |= AVL_DVBSx_IBSP_I2CRead(pAVLChip, pucBuffTemp, &ui1);
				pucBuff[uiSize-1] = pucBuffTemp[0];
			}
		}
	}
	r |= AVL_DVBSx_IBSP_ReleaseSemaphore(&(gI2CSem)); 
	return(r);
}
コード例 #5
0
static int AVL6211_Blindscan_Scan(struct dvb_frontend* fe, struct dvbsx_blindscanpara *pbspara)
{
	printk(KERN_INFO "AVL6211_Blindscan_Scan printk\n");

	AVL_DVBSx_IBSP_WaitSemaphore(&blindscanSem);
	fe_use = fe;
	blindstart=1;
	AVL_DVBSx_IBSP_ReleaseSemaphore(&blindscanSem);
	  dvbs2_task = kthread_create(dvbs2_blindscan_task, pbspara, "dvbs2_task");
      if(!dvbs2_task){
      	printk("Unable to start dvbs2 thread.\n");
     	dvbs2_task = NULL;
      return -1;
      }
	  wake_up_process(dvbs2_task);
	  return 0;
}
コード例 #6
0
static int AVL6211_Blindscan_Scan(struct dvb_frontend* fe, struct dvbsx_blindscanpara *pbspara)
{
		AVL_DVBSx_IBSP_WaitSemaphore(&blindscanSem);
		blindstart=1;
		AVL_DVBSx_IBSP_ReleaseSemaphore(&blindscanSem);
		printk("[%s]\n",__FUNCTION__);
		AVL_DVBSx_ErrorCode r = AVL_DVBSx_EC_OK;
		struct AVL_DVBSx_BlindScanPara  pbsParaZ ;
		r |= AVL_DVBSx_IBase_SetFunctionalMode(pAVLChip_all, AVL_DVBSx_FunctMode_BlindScan);
		r |= AVL_DVBSx_IBase_SetSpectrumPolarity(0,pAVLChip_all); 
		avl6211pTuner->m_uiLPF_100kHz =  pbspara->m_uitunerlpf_100khz;
		avl6211pTuner->m_uiFrequency_100kHz = pbspara->m_uifrequency_100khz;
		r |= avl6211pTuner->m_pLockFunc(avl6211pTuner);	//Lock the tuner. 
		
		msleep(50);		//wait a while for tuner to lock in certain frequency.
		
		r |= avl6211pTuner->m_pGetLockStatusFunc(avl6211pTuner);	 //Check the lock status of the tuner.
		if (AVL_DVBSx_EC_OK != r)		 
		{
			return r;
		}

		r |= AVL_DVBSx_IBlindScan_Reset(pAVLChip_all);
		
	//	printf("m_uistartfreq_100khz is %d,m_uistartfreq_100khz is %d,m_uiminsymrate_khz is %d,,m_uimaxsymrate_khz is %d,m_uitunerlpf_100khz is %d\n",pbspara->m_uistartfreq_100khz,pbspara->m_uistopfreq_100khz,pbspara->m_uiminsymrate_khz,pbspara->m_uimaxsymrate_khz,pbspara->m_uitunerlpf_100khz);
		pbsParaZ.m_uiStartFreq_100kHz = pbspara->m_uifrequency_100khz-320;//pbspara->m_uistartfreq_100khz;//pbspara->m_uifrequency_100khz-320
		pbsParaZ.m_uiStopFreq_100kHz = pbspara->m_uifrequency_100khz+320;//pbspara->m_uistopfreq_100khz;//pbspara->m_uifrequency_100khz+320
		pbsParaZ.m_uiMinSymRate_kHz =2*1000;// pbspara->m_uiminsymrate_khz;
		pbsParaZ.m_uiMaxSymRate_kHz =45*1000;// pbspara->m_uimaxsymrate_khz;

		r |=AVL_DVBSx_IBlindScan_Scan(&pbsParaZ,340, pAVLChip_all);
		if(r== AVL_DVBSx_EC_OK)
		{
			pr_dbg("AVL_DVBSx_IBlindScan_Scan,OK\n");
		}
		return r;
}
コード例 #7
0
ファイル: II2C.c プロジェクト: MindShow/hisi-driverlibs
AVL_DVBSx_ErrorCode AVL_DVBSx_II2C_Write( const struct AVL_DVBSx_Chip * pAVLChip, AVL_puchar pucBuff, AVL_uint16 uiSize)
{
	AVL_DVBSx_ErrorCode r;
	AVL_uchar pucBuffTemp[5];
	AVL_uint16 ui1, ui2, uTemp;
	AVL_uint16 iSize;
	AVL_uint32 uAddr;
	if( uiSize<3 )
	{
		return(AVL_DVBSx_EC_GeneralFail);	 //at least 3 bytes
	}

	uiSize -= 3;			//actual data size
	r = AVL_DVBSx_IBSP_WaitSemaphore(&(gI2CSem));
	if( AVL_DVBSx_EC_OK == r )
	{
		//dump address
		uAddr = pucBuff[0];
		uAddr = uAddr<<8;
		uAddr += pucBuff[1];
		uAddr = uAddr<<8;
		uAddr += pucBuff[2];

		if( uiSize & 1 )
		{
			iSize = uiSize -1;
		}
		else
		{
			iSize = uiSize;
		}

		uTemp = (MAX_II2C_Write_SIZE-3) & 0xfffe; //how many bytes data we can transfer every time

		ui2 = 0;
		while( iSize > uTemp )
		{
			ui1 = uTemp+3;
			//save the data
			pucBuffTemp[0] = pucBuff[ui2];
			pucBuffTemp[1] = pucBuff[ui2+1];
			pucBuffTemp[2] = pucBuff[ui2+2];
			ChunkAddr(uAddr, pucBuff+ui2);
			r |= AVL_DVBSx_IBSP_I2CWrite(pAVLChip, pucBuff+ui2, &ui1);
			//restore data
			pucBuff[ui2] = pucBuffTemp[0];
			pucBuff[ui2+1] = pucBuffTemp[1];
			pucBuff[ui2+2] = pucBuffTemp[2];
			uAddr += uTemp;
			ui2 += uTemp;
			iSize -= uTemp;
		}
		ui1 = iSize+3;
		//save the data
		pucBuffTemp[0] = pucBuff[ui2];
		pucBuffTemp[1] = pucBuff[ui2+1];
		pucBuffTemp[2] = pucBuff[ui2+2];
		ChunkAddr(uAddr, pucBuff+ui2);
		r |= AVL_DVBSx_IBSP_I2CWrite(pAVLChip, pucBuff+ui2, &ui1);
		//restore data
		pucBuff[ui2] = pucBuffTemp[0];
		pucBuff[ui2+1] = pucBuffTemp[1];
		pucBuff[ui2+2] = pucBuffTemp[2];
		uAddr += iSize;
		ui2 += iSize;

		if( uiSize & 1 )
		{
			ChunkAddr(uAddr, pucBuffTemp);
			ui1 = 3;
			r |= AVL_DVBSx_IBSP_I2CWrite(pAVLChip, pucBuffTemp, &ui1);
			ui1 = 2;
			r |= AVL_DVBSx_IBSP_I2CRead(pAVLChip, pucBuffTemp+3, &ui1);
			pucBuffTemp[3] = pucBuff[ui2+3];
			ui1 = 5;
			r |= AVL_DVBSx_IBSP_I2CWrite(pAVLChip, pucBuffTemp, &ui1);
		}
	}
	r |= AVL_DVBSx_IBSP_ReleaseSemaphore(&(gI2CSem)); 

	return(r);
}
コード例 #8
0
static int AVL6211_Set_Frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p)
{
	int async_ret = 0;

	if(initflag!=0)
	{
		pr_dbg("[%s] avl6211 init fail\n",__FUNCTION__);
		return 0;	
	}
//	printk("[AVL6211_Set_Frontend],blindstart is %d\n",blindstart);

	if(1==blindstart)
		return 0;
	AVL_DVBSx_IBSP_WaitSemaphore(&blindscanSem);
	if((850000>p->frequency)||(p->frequency>2300000))
	{
			p->frequency =945000;
			pr_dbg("freq is out of range,force to set 945000khz\n");
	}
	struct avl6211_state *state = fe->demodulator_priv;
	struct AVL_DVBSx_Channel Channel;
	AVL_DVBSx_ErrorCode r = AVL_DVBSx_EC_OK;
	avl6211pTuner->m_uiFrequency_100kHz=p->frequency/100;
//	avl6211pTuner->m_uiFrequency_100kHz=15000;
//	printk("avl6211pTuner m_uiFrequency_100kHz is %d",avl6211pTuner->m_uiFrequency_100kHz);
	
	/* r = CPU_Halt(pAVLChip_all);
	if(AVL_DVBSx_EC_OK != r)
	{
		printf("CPU halt failed !\n");
		return (r);
	}*/

	//Change the value defined by macro and go back here when we want to lock a new channel.
//	avl6211pTuner->m_uiFrequency_100kHz = tuner_freq*10;      
	avl6211pTuner->m_uiSymbolRate_Hz = p->u.qam.symbol_rate;//p->u.qam.symbol_rate;//30000000; //symbol rate of the channel to be locked.
	//This function should be called before locking the tuner to adjust the tuner LPF based on channel symbol rate.
	AVL_Set_LPF(avl6211pTuner, avl6211pTuner->m_uiSymbolRate_Hz);

	r=avl6211pTuner->m_pLockFunc(avl6211pTuner);
	if (AVL_DVBSx_EC_OK != r)
	{
		state->freq=p->frequency;
		state->mode=p->u.qam.modulation ;
		state->symbol_rate=p->u.qam.symbol_rate;
		AVL_DVBSx_IBSP_ReleaseSemaphore(&blindscanSem);
 		pr_dbg("Tuner test failed !\n");
		return (r);
	}
	pr_dbg("Tuner test ok !\n");
	//msleep(50);
	fe->ops.asyncinfo.set_frontend_asyncpreproc(fe);
	async_ret = fe->ops.asyncinfo.set_frontend_asyncwait(fe, 50);
	if(async_ret > 0){
		fe->ops.asyncinfo.set_frontend_asyncpostproc(fe, async_ret);
		AVL_DVBSx_IBSP_ReleaseSemaphore(&blindscanSem);
		return 0;
	}	
	fe->ops.asyncinfo.set_frontend_asyncpostproc(fe, async_ret);	
	#if 0
	Channel.m_uiSymbolRate_Hz = p->u.qam.symbol_rate;      //Change the value defined by macro when we want to lock a new channel.
	Channel.m_Flags = (CI_FLAG_MANUAL_LOCK_MODE) << CI_FLAG_MANUAL_LOCK_MODE_BIT;		//Manual lock Flag
									
	Channel.m_Flags |= (CI_FLAG_IQ_NO_SWAPPED) << CI_FLAG_IQ_BIT;   		//Auto IQ swap
	Channel.m_Flags |= (CI_FLAG_IQ_AUTO_BIT_AUTO) << CI_FLAG_IQ_AUTO_BIT;			//Auto IQ swap Flag
													//Support QPSK and 8PSK  dvbs2
	{
	#define Coderate				RX_DVBS2_2_3
	#define Modulation				AVL_DVBSx_MM_QPSK
	
		if (Coderate > 16 || Coderate < 6 || Modulation > 3)
		{			
			printf("Configure error !\n");
			return AVL_DVBSx_EC_GeneralFail;
		}
		Channel.m_Flags |= (CI_FLAG_DVBS2) << CI_FLAG_DVBS2_BIT;											//Disable automatic standard detection
		Channel.m_Flags |= (enum AVL_DVBSx_FecRate)(Coderate) << CI_FLAG_CODERATE_BIT;						//Manual config FEC code rate
		Channel.m_Flags |= ((enum AVL_DVBSx_ModulationMode)(Modulation)) << CI_FLAG_MODULATION_BIT;			//Manual config Modulation
	}
	//This function should be called after tuner locked to lock the channel.
	#else
	Channel.m_uiSymbolRate_Hz = p->u.qam.symbol_rate;
	Channel.m_Flags = (CI_FLAG_IQ_NO_SWAPPED) << CI_FLAG_IQ_BIT;	//Normal IQ
	Channel.m_Flags |= (CI_FLAG_IQ_AUTO_BIT_AUTO) << CI_FLAG_IQ_AUTO_BIT;	//Enable automatic IQ swap detection
	Channel.m_Flags |= (CI_FLAG_DVBS2_UNDEF) << CI_FLAG_DVBS2_BIT;			//Enable automatic standard detection
	#endif
	r = AVL_DVBSx_IRx_LockChannel(&Channel, pAVLChip_all);  
	if (AVL_DVBSx_EC_OK != r)
	{
		state->freq=p->frequency;
		state->mode=p->u.qam.modulation ;
		state->symbol_rate=p->u.qam.symbol_rate;	
		AVL_DVBSx_IBSP_ReleaseSemaphore(&blindscanSem);
		pr_dbg("Lock channel failed !\n");
		return (r);
	}
	AVL_DVBSx_IBSP_ReleaseSemaphore(&blindscanSem);
	if (AVL_DVBSx_EC_OK != r)
	{
		printf("Lock channel failed !\n");
		return (r);
	}
	int waittime=150;//3s 
	//Channel lock time increase while symbol rate decrease.Give the max waiting time for different symbolrates.
	if(p->u.qam.symbol_rate<5000000)
	{
		waittime = 150;//250;       //The max waiting time is 5000ms,considering the IQ swapped status the time should be doubled.
	}
	else if(p->u.qam.symbol_rate<10000000)
	{
        waittime = 30;        //The max waiting time is 600ms,considering the IQ swapped status the time should be doubled.
	}
	else
	{
        waittime = 15;        //The max waiting time is 300ms,considering the IQ swapped status the time should be doubled.
	} 
	int lockstatus = 0;
	fe->ops.asyncinfo.set_frontend_asyncpreproc(fe);
	while(waittime)
	{
		//msleep(20);
		async_ret = fe->ops.asyncinfo.set_frontend_asyncwait(fe, 20);
		if(async_ret > 0){
			break;
		}
		
		lockstatus=AVL6211_GETLockStatus();
		if(1==lockstatus){
			pr_dbg("lock success !\n");
			break;
		}
		
		waittime--;
	}
	fe->ops.asyncinfo.set_frontend_asyncpostproc(fe, async_ret);
	
	if(!AVL6211_GETLockStatus())
		pr_dbg("lock timeout !\n");
	
	r=AVL_DVBSx_IRx_ResetErrorStat(pAVLChip_all);
	if (AVL_DVBSx_EC_OK != r)
	{
		state->freq=p->frequency;
		state->mode=p->u.qam.modulation ;
		state->symbol_rate=p->u.qam.symbol_rate;
		
		printf("Reset error status failed !\n");
		return (r);
	}
	
//	demod_connect(state, p->frequency,p->u.qam.modulation,p->u.qam.symbol_rate);
	state->freq=p->frequency;
	state->mode=p->u.qam.modulation ;
	state->symbol_rate=p->u.qam.symbol_rate; //these data will be writed to eeprom

	pr_dbg("avl6211=>frequency=%d,symbol_rate=%d\r\n",p->frequency,p->u.qam.symbol_rate);
	return  0;
}