Esempio n. 1
0
int d6158_read_status(struct dvb_frontend *fe, enum fe_status *status)
{
	int j, iRet;
	struct dvb_d6158_fe_ofdm_state *state = fe->demodulator_priv;
	UINT8 bIsLocked;

	//printk("%s>>\n", __FUNCTION__);
	for (j = 0; j < (PANIC6158_T2_TUNE_TIMEOUT / 50); j++)
	{
		YWOS_TaskSleep(50);
		iRet = nim_panic6158_get_lock(&state->spark_nimdev, &bIsLocked);
		if (bIsLocked)
		{
			break;
		}
	}
	//printk("bIsLocked = %d\n", bIsLocked);
	if (bIsLocked)
	{
		*status = FE_HAS_SIGNAL
		        | FE_HAS_CARRIER
		        | FE_HAS_VITERBI
		        | FE_HAS_SYNC
		        | FE_HAS_LOCK;
	}
	else
	{
		*status = 0;
	}
	return 0;
}
Esempio n. 2
0
int d6158_read_signal_strength(struct dvb_frontend* fe, u16 *strength)
{
	int     iRet;
	u32     Strength;
	u32     *Intensity = &Strength;

	struct dvb_d6158_fe_ofdm_state *state = fe->demodulator_priv;
	iRet = nim_panic6158_get_AGC(&state->spark_nimdev, (UINT8*)Intensity);
	if (*Intensity > 90)
		*Intensity = 90;
	if (*Intensity < 10)
		*Intensity = *Intensity * 11 / 2;
	else
		*Intensity = *Intensity / 2 + 50;
	if (*Intensity > 90)
		*Intensity = 90;

	*Intensity = *Intensity * 255 * 255 / 100;
	printk("*Intensity = %d\n", *Intensity);
	*strength = (*Intensity);

	YWOS_TaskSleep(100);

	return iRet;
}
/*****************************************************
**FUNCTION	::	ChipSetRegisters_0367qam
**ACTION	::	Set values of consecutive's registers (values are taken in RegMap)
**PARAMS IN	::	hChip		==> Handle to the chip
**				FirstReg	==> Id of the first register
**				NbRegs		==> Number of register to write
**PARAMS OUT::	NONE
**RETURN	::	Error
*****************************************************/
YW_ErrorType_T  ChipSetRegisters_0367qam(TUNER_IOREG_DeviceMap_t *DeviceMap, IOARCH_Handle_t IOHandle,int FirstRegAddr,int NbRegs)
{
	unsigned char data[100],nbdata = 0;
	int i;
	//unsigned int Size;
	//TUNER_ScanTaskParam_T 		*Inst = NULL;
	//TUNER_IOREG_DeviceMap_t		*RepeaterDeviceMap = NULL;
	//IOARCH_Handle_t				RepeaterIOHandle = 0xffff;
    S32 firstRegIndex = -1;
    DeviceMap->Error = 0;

    firstRegIndex = ChipGetRegisterIndex(DeviceMap,IOHandle, FirstRegAddr);
    if (((firstRegIndex >= 0) && ((firstRegIndex + NbRegs - 1) < DeviceMap->Registers))==FALSE )
    {
        //printk("ChipSetRegisters_0367ter############DeviceMap->Registers = %d,firstRegIndex= %d,NbRegs=%d\n",DeviceMap->Registers,
           // firstRegIndex,NbRegs);////
        DeviceMap->Error = YWHAL_ERROR_BAD_PARAMETER;
        return DeviceMap->Error;
    }

	#if 0
	if(IOARCH_Handle[IOHandle].IORoute == TUNER_IO_REPEATER)
	{
		for (i = 0; i < YWTUNERi_MAX_TUNER_NUM/*TUNER_1*/; i++)
		{
			Inst = TUNER_GetScanInfo(i);
			if (Inst->DriverParam.Cab.TunerIOHandle == IOHandle)
			{
				RepeaterDeviceMap = &Inst->DriverParam.Cab.Demod_DeviceMap;
				RepeaterIOHandle = Inst->DriverParam.Cab.DemodIOHandle;
				break;
			}
		}

		if (i == YWTUNERi_MAX_TUNER_NUM)
		{
            //printk("DeviceMap->Error YWHAL_ERROR_INVALID_HANDLE=====\n");////
			DeviceMap->Error = YWHAL_ERROR_INVALID_HANDLE;
			return DeviceMap->Error;
		}
	}
	#endif

	if(DeviceMap)
	{
		{
			if(NbRegs < 70)
			{

				switch(DeviceMap->Mode)
				{
					case IOREG_MODE_SUBADR_16:
						data[nbdata++]=MSB(FirstRegAddr);	/* 16 bits sub addresses */
					case IOREG_MODE_SUBADR_8:
						data[nbdata++]=LSB(FirstRegAddr);	/* 8 bits sub addresses */
					case IOREG_MODE_NOSUBADR:
						for(i=0;i<NbRegs;i++)
							data[nbdata++] = DeviceMap->RegMap[firstRegIndex+i].Value;;	/* fill data buffer */
						break;

					default:
                        //printk("Error %d\n", __LINE__);
						DeviceMap->Error = YWHAL_ERROR_INVALID_HANDLE;
						return YWHAL_ERROR_INVALID_HANDLE;
				}
                //lwj add for test
                //int j = 0;

                /*printk("FirsetRegister = 0x%x", FirstRegAddr);
	                    for (j= 0 ; j < nbdata; j++)
	                    {
	                        printk("data = 0x%x,", data[j]);
	                    }
	                    printk("\n");*/
                //lwj add for test end
				//if(IOARCH_Handle[IOHandle].IORoute == TUNER_IO_REPEATER)
				//{
         		//	ChipSetField_0367qam(RepeaterDeviceMap, RepeaterIOHandle,F367qam_I2CT_ON, 1);	/* Set repeater ON */
				//}
				#if 0
                DeviceMap->Error = YWI2C_WriteWithStop( I2C_HANDLE(&IOARCH_Handle[IOHandle].ExtDeviceHandle), data, nbdata, DeviceMap->Timeout, &Size);
				if (DeviceMap->Error == YWI2C_ERROR_WRITE_FAILURE)
                {
                    YWOS_TaskSleep(2);
                }
				#else

				D0367qam_write(DeviceMap, IOHandle, data, nbdata);

				#endif
				//if(IOARCH_Handle[IOHandle].IORoute == TUNER_IO_REPEATER)
				//{
         		//	ChipSetField_0367qam(RepeaterDeviceMap, RepeaterIOHandle,F367qam_I2CT_ON, 0);	/* Set repeater OFF */
				//}
				//#endif
			}
			else
				DeviceMap->Error = YWHAL_ERROR_FEATURE_NOT_SUPPORTED;
		}
	}
	else
		return YWHAL_ERROR_INVALID_HANDLE;
   
	if (DeviceMap->Error != 0)
	{
        printk("d0367ter DeviceMap->Error=%d,FirstRegAddr=%x\n",DeviceMap->Error,FirstRegAddr);//for test
        YWOSTRACE((YWOS_TRACE_ERROR, "d0367cab DeviceMap->Error=%d,FirstRegAddr=%x\n",DeviceMap->Error,FirstRegAddr));//for test
	}
	return DeviceMap->Error;
}
Esempio n. 4
0
struct dvb_frontend *dvb_d6158earda_attach(struct i2c_adapter *i2c, UINT8 system)
{
	struct dvb_d6158_fe_ofdm_state *state = NULL;
	struct nim_panic6158_private *priv;
	int ret;
	struct COFDM_TUNER_CONFIG_API Tuner_API;

	/* allocate memory for the internal state */
	state = kzalloc(sizeof(struct dvb_d6158_fe_ofdm_state), GFP_KERNEL);
	if (state == NULL) goto error;
	priv = (PNIM_PANIC6158_PRIVATE)YWOS_Malloc(sizeof(struct nim_panic6158_private));
	if (NULL == priv)
	{
		goto error;
	}
	MEMSET(priv, 0, sizeof(struct nim_panic6158_private));
	/* create dvb_frontend */
	if (system == DEMO_BANK_T2) //dvb-t
	{
		printk("DEMO_BANK_T2\n");
		memcpy(&state->frontend.ops, &dvb_d6158_fe_ofdm_ops, sizeof(struct dvb_frontend_ops));
	}
	else if (system == DEMO_BANK_C) //dvb-c
	{
		printk("DEMO_BANK_C\n");
		memcpy(&state->frontend.ops, &dvb_d6158_fe_qam_ops, sizeof(struct dvb_frontend_ops));
	}
	printf("[%s]%d\n", __FUNCTION__, __LINE__);
	state->frontend.ops.set_frontend = d6158earda_set_frontend;
	state->frontend.demodulator_priv = state;
	state->i2c = i2c;
	state->DeviceMap.Timeout = IOREG_DEFAULT_TIMEOUT;
	state->DeviceMap.Registers = STV0367ofdm_NBREGS;
	state->DeviceMap.Fields = STV0367ofdm_NBFIELDS;
	state->DeviceMap.Mode = IOREG_MODE_SUBADR_16;
	state->DeviceMap.RegExtClk = 27000000; //Demod External Crystal_HZ
	state->DeviceMap.RegMap = (TUNER_IOREG_Register_t *)kzalloc(state->DeviceMap.Registers * sizeof(TUNER_IOREG_Register_t), GFP_KERNEL);
	state->DeviceMap.priv = (void *)state;
	state->spark_nimdev.priv = priv;
	state->spark_nimdev.base_addr = PANIC6158_T2_ADDR;
	//state->spark_nimdev.i2c_type_id= pConfig->ext_dm_config.i2c_type_id;
	//state->spark_nimdev.nim_idx = pConfig->ext_dm_config.nim_idx;//distinguish left or right
	priv->i2c_adap = i2c;
	priv->i2c_addr[0] = PANIC6158_T_ADDR;
	priv->i2c_addr[1] = PANIC6158_T2_ADDR;
	priv->i2c_addr[2] = PANIC6158_C_ADDR;
	priv->if_freq = DMD_E_IF_5000KHZ;
	priv->flag_id = OSAL_INVALID_ID;
	priv->i2c_mutex_id = OSAL_INVALID_ID;
	priv->system = system; //T2 C
	priv->first_tune_t2 = 1;
	priv->tuner_id = 2;
	YWOS_TaskSleep(50);
	nim_config_EARDATEK11658(&Tuner_API, 0, 0);
	Tuner_API.tuner_config.i2c_adap = (IOARCH_Handle_t *)i2c;
	MEMCPY((void *) & (priv->tc), (void *)&Tuner_API, sizeof(struct COFDM_TUNER_CONFIG_API));
	printf("[%s]%d\n", __FUNCTION__, __LINE__);
	if (NULL != Tuner_API.nim_Tuner_Init)
	{
		if (SUCCESS == Tuner_API.nim_Tuner_Init(&priv->tuner_id, &Tuner_API.tuner_config))
		{
			DEM_WRITE_READ_TUNER ThroughMode;
			printf("[%s]%d\n", __FUNCTION__, __LINE__);
			priv->tc.nim_Tuner_Init = Tuner_API.nim_Tuner_Init;
			priv->tc.nim_Tuner_Control = Tuner_API.nim_Tuner_Control;
			priv->tc.nim_Tuner_Status = Tuner_API.nim_Tuner_Status;
			YWLIB_Memcpy(&priv->tc.tuner_config, &Tuner_API.tuner_config, sizeof(struct COFDM_TUNER_CONFIG_EXT));
			ThroughMode.nim_dev_priv = state->spark_nimdev.priv;
			printf("[%s]%d\n", __FUNCTION__, __LINE__);
			ThroughMode.Dem_Write_Read_Tuner = DMD_TCB_WriteRead;///////////////////////////////////
			nim_panic6158_ioctl_earda(&state->spark_nimdev, NIM_TUNER_SET_THROUGH_MODE, (UINT32)&ThroughMode);
			printf("[%s]%d\n", __FUNCTION__, __LINE__);
		}
	}
	printf("[%s]%d\n", __FUNCTION__, __LINE__);
	state->spark_nimdev.get_lock = nim_panic6158_get_lock;
	state->spark_nimdev.get_AGC = nim_panic6158_get_AGC_603;
	ret = nim_panic6158_open(&state->spark_nimdev);
	printk("[%s]%d,open result=%d \n", __FUNCTION__, __LINE__, ret);
	/* Setup init work mode */
	return &state->frontend;
error:
	kfree(state);
	return NULL;
}
Esempio n. 5
0
struct dvb_frontend *dvb_d6158_attach(struct i2c_adapter *i2c, UINT8 system)
{
	struct dvb_d6158_fe_ofdm_state *state = NULL;
	struct nim_panic6158_private *priv;
	int ret;
	struct COFDM_TUNER_CONFIG_API Tuner_API;

	/* allocate memory for the internal state */
	state = kzalloc(sizeof(struct dvb_d6158_fe_ofdm_state), GFP_KERNEL);
	if (state == NULL) goto error;
	priv = (PNIM_PANIC6158_PRIVATE)YWOS_Malloc(sizeof(struct nim_panic6158_private));
	if (NULL == priv)
	{
		goto error;
	}
	/* create dvb_frontend */
	if (system == DEMO_BANK_T2)  //dvb-t
	{
		printk("DEMO_BANK_T2\n");
		memcpy(&state->frontend.ops, &dvb_d6158_fe_ofdm_ops, sizeof(struct dvb_frontend_ops));
	}
	else if (system == DEMO_BANK_C) //dvb-c
	{
		printk("DEMO_BANK_C\n");
		memcpy(&state->frontend.ops, &dvb_d6158_fe_qam_ops, sizeof(struct dvb_frontend_ops));
	}
	state->frontend.demodulator_priv = state;
	state->i2c = i2c;
	state->DeviceMap.Timeout = IOREG_DEFAULT_TIMEOUT;
	state->DeviceMap.Registers = STV0367ofdm_NBREGS;
	state->DeviceMap.Fields = STV0367ofdm_NBFIELDS;
	state->DeviceMap.Mode = IOREG_MODE_SUBADR_16;
	state->DeviceMap.RegExtClk = 27000000; //Demod External Crystal_HZ
	state->DeviceMap.RegMap = (TUNER_IOREG_Register_t *)kzalloc(state->DeviceMap.Registers * sizeof(TUNER_IOREG_Register_t), GFP_KERNEL);
	state->DeviceMap.priv = (void *)state;
	state->spark_nimdev.priv = priv;
	state->spark_nimdev.base_addr = PANIC6158_T2_ADDR;
	//state->spark_nimdev.i2c_type_id= pConfig->ext_dm_config.i2c_type_id;
	//state->spark_nimdev.nim_idx = pConfig->ext_dm_config.nim_idx;//distinguish left or right
	priv->i2c_adap = i2c;
	priv->i2c_addr[0] = PANIC6158_T_ADDR;
	priv->i2c_addr[1] = PANIC6158_T2_ADDR;
	priv->i2c_addr[2] = PANIC6158_C_ADDR;
	priv->if_freq = DMD_E_IF_5000KHZ;
	priv->flag_id = OSAL_INVALID_ID;
	priv->i2c_mutex_id = OSAL_INVALID_ID;
	priv->system = system; //T2 C
	priv->first_tune_t2 = 1;
	priv->tuner_id = 2;
	if (tuner_mxl301_Identify((IOARCH_Handle_t *)i2c) != YW_NO_ERROR)
	{
		printk("tuner_mxl301_Identify error!\n");
		YWOS_Free(priv);
		kfree(state);
		return NULL;
	}
	YWOS_TaskSleep(50);
	YWLIB_Memset(&Tuner_API, 0, sizeof(struct COFDM_TUNER_CONFIG_API));
	Tuner_API.nim_Tuner_Init = tun_mxl301_init;
	Tuner_API.nim_Tuner_Status = tun_mxl301_status;
	Tuner_API.nim_Tuner_Control = tun_mxl301_control;
	Tuner_API.tune_t2_first = 1;//when demod_d6158_ScanFreq,param.priv_param >DEMO_DVBT2,tuner tune T2 then t
	Tuner_API.tuner_config.demo_type = PANASONIC_DEMODULATOR;
	Tuner_API.tuner_config.cTuner_Base_Addr = 0xC2;
	Tuner_API.tuner_config.i2c_adap = (IOARCH_Handle_t *)i2c;
	//printf("[%s]%d,i=%d,ret=%d \n",__FUNCTION__,__LINE__,i,ret);
	if (NULL != Tuner_API.nim_Tuner_Init)
	{
		if (SUCCESS == Tuner_API.nim_Tuner_Init(&priv->tuner_id, &Tuner_API.tuner_config))
		{
			priv->tc.nim_Tuner_Init = Tuner_API.nim_Tuner_Init;
			priv->tc.nim_Tuner_Control = Tuner_API.nim_Tuner_Control;
			priv->tc.nim_Tuner_Status = Tuner_API.nim_Tuner_Status;
			YWLIB_Memcpy(&priv->tc.tuner_config, &Tuner_API.tuner_config, sizeof(struct COFDM_TUNER_CONFIG_EXT));
		}
	}
	state->spark_nimdev.get_lock = nim_panic6158_get_lock;
	state->spark_nimdev.get_AGC = nim_panic6158_get_AGC_301;
	ret = nim_panic6158_open(&state->spark_nimdev);
	printk("[%s]%d,open result=%d \n", __FUNCTION__, __LINE__, ret);
	/* Setup init work mode */
	return &state->frontend;
error:
	kfree(state);
	return NULL;
}