Example #1
0
static int CAMERA_HW_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) 
{             
    int i4RetValue = 0;
    PK_DBG("[CAMERA_HW] Attach I2C \n");
 
    //get sensor i2c client
    spin_lock(&kdsensor_drv_lock);
    g_pstI2Cclient = client;
    //set I2C clock rate	
    g_pstI2Cclient->timing = 200;//200k
    spin_unlock(&kdsensor_drv_lock);

    //Register char driver
    i4RetValue = RegisterCAMERA_HWCharDrv();

    if(i4RetValue){
        PK_ERR("[CAMERA_HW] register char device failed!\n");
        return i4RetValue;
    }

    //spin_lock_init(&g_CamHWLock);

    PK_DBG("[CAMERA_HW] Attached!! \n");
    return 0;                                                                                       
} 
Example #2
0
static int constant_flashlight_open(void *pArg)
{
    int i4RetValue = 0;
    PK_DBG("constant_flashlight_open line=%d\n", __LINE__);

	if (0 == strobe_Res)
	{
	    FL_init();
		timerInit();
		timerInit_600ms();
	}
	spin_lock_irq(&g_strobeSMPLock);

    if(strobe_Res)
    {
        PK_ERR(" busy!\n");
        i4RetValue = -EBUSY;
    }
    else
    {
        strobe_Res += 1;
    }

    spin_unlock_irq(&g_strobeSMPLock);

    return i4RetValue;

}
Example #3
0
static int bat_probe(struct device *dev)
{
	int ret;
	struct platform_device	*pdev;
	struct resource		    *pres;

	bat_hw_init();

	if(IO_HaveGpioLowBattDetect())
	{
		PK_DBG("Registering LOW_DC_VCC ISR\n");
		/* Get the resources assigned */
		pdev = to_platform_device(dev);
		pres = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
		/* Register the interrupt. */
		if ((pres == NULL) || request_irq(pres->start,
				low_dc_vcc_irq_handler, SA_INTERRUPT | SA_SAMPLE_RANDOM,
				"LOW_DC_VCC_irq", dev))
		{
			PK_ERR("Can't register low dc vcc interrupt !\n");
			return -ENODEV;
		}
		IO_SetInterruptOnDeactivation(LOW_DC_VCC);
	}

	PK_DBG("Registering ADC pollfunc\n");
	if (IO_HaveADCAIN4Ref())
		ret = adc_register_poll(bat_adc_poll_ain4, NULL, ADC_RATE_BAT );
	else
		ret = adc_register_poll(bat_adc_poll, NULL, ADC_RATE_BAT );

	if (ret < 0) {
		PK_ERR("Unable to register ADC pollfunc (%d)\n", ret);
		return ret;
	}

	PK_DBG("Registering chardev\n");
	ret = register_chrdev(BATTERY_MAJOR, BATTERY_DEVNAME, &bat_fops);
	if (ret != 0) {
		PK_ERR("Unable to register chardev on major=%d (%d)\n", BATTERY_MAJOR, ret);
		return ret;
	}

	PK_DBG("Done\n");
	return 0;
}
static int adp1650_probe(struct i2c_client *client,
			const struct i2c_device_id *id)
{
	struct adp1650_chip_data *chip;
	struct adp1650_platform_data *pdata = client->dev.platform_data;

	int err = -1;

	PK_DBG("adp1650_probe start--->.\n");

	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
		err = -ENODEV;
		printk(KERN_ERR  "ADP1650 i2c functionality check fail.\n");
		return err; 
	}

	chip = kzalloc(sizeof(struct adp1650_chip_data), GFP_KERNEL);
	chip->client = client;	

	mutex_init(&chip->lock);	
	i2c_set_clientdata(client, chip);

	if(pdata == NULL){ //values are set to Zero. 
		PK_ERR("ADP1650 Platform data does not exist\n");
		pdata = kzalloc(sizeof(struct adp1650_platform_data),GFP_KERNEL);
		chip->pdata  = pdata;
		chip->no_pdata = 1; 
	}
	
	chip->pdata  = pdata;
	if(adp1650_chip_init(chip)<0)
		goto err_chip_init;

	adp1650_i2c_client = client;
	PK_DBG("ADP1650 Initializing is done \n");

	return 0;

err_chip_init:	
	i2c_set_clientdata(client, NULL);
	kfree(chip);
	PK_ERR("ADP1650 probe is failed \n");
	return -ENODEV;
}
static int __init flashchip_init(void)
{
    int ret = 0;
    PK_DBG("[flashchip_init] start\n");

	ret = platform_device_register (&flashchip_platform_device);
	if (ret) {
        PK_ERR("[flashchip_init] platform_device_register fail\n");
        return ret;
	}

    ret = platform_driver_register(&flashchip_platform_driver);
	if(ret){
		PK_ERR("[flashchip_init] platform_driver_register fail\n");
		return ret;
	}

	PK_DBG("[flashchip_init] done!\n");
    return ret;
}
Example #6
0
static int TMP103_HW_i2c_probe(struct i2c_client *client,	const struct i2c_device_id *id)
{
	int ret = 0;
	u8 out_buff[2];

	PK_DBG_FUNC("TMP103_I2C_Probe\n");
	
	out_buff[0] = 0x01;  //Pointer Register byte
  out_buff[1] = 0x22;  //Data byte; continuous mode and 1Hz

	if (client->addr==0x70)
	{	
		printk("TMP103_HW_device_A 0x70\n");
		g_pstI2CclientA = client;
		g_pstI2CclientA->timing = 400;//400k
		g_pstI2CclientA->ext_flag = I2C_DIRECTION_FLAG | I2C_POLLING_FLAG;
		
		if ((TMP103_I2C_write_bytes(0x70, (u8*)out_buff, sizeof(out_buff)))!= sizeof(out_buff)) //TMP103A, continuous mode and 1Hz
		{
			PK_ERR("TMP103_I2C_write_bytes 0x70 failed!!\n");
			return 0;
		}
		i_enable_A = 1;
	}
	else if (client->addr==0x71)
	{
		printk("TMP103_HW_device_B 0x71\n");
		g_pstI2CclientB = client;
		g_pstI2CclientB->timing = 400;//400k
		g_pstI2CclientB->ext_flag = I2C_DIRECTION_FLAG | I2C_POLLING_FLAG;
		
		if ((TMP103_I2C_write_bytes(0x71, (u8*)out_buff, sizeof(out_buff)))!= sizeof(out_buff)) //TMP103B, continuous mode and 1Hz
		{
			PK_ERR("TMP103_I2C_write_bytes 0x71 failed!!\n");
			return 0;
		}
		i_enable_B = 1;
	}
	
	return ret; 
}
int FL_disable(void)
{
	struct flash_chip_data *chip = &chipconf;
	PK_ERR("FL_disable\n");

	mt_set_gpio_out(FLASH_PIN,GPIO_OUT_ZERO);
	mt_set_gpio_out(TORCH_PIN,GPIO_OUT_ZERO);
	mdelay(4);
	chip->torch_level = 0;
	chip->mode = 0;
    return 0;
}
Example #8
0
int kdSetDriver(unsigned int* pDrvIndex)
{
    ACDK_KD_SENSOR_INIT_FUNCTION_STRUCT *pSensorList = NULL;
    unsigned int drvIdx = (*pDrvIndex & KDIMGSENSOR_DUAL_MASK_LSB);

    //set driver for MAIN or SUB sensor
    spin_lock(&kdsensor_drv_lock);
    g_currDualSensorIdx = (CAMERA_DUAL_CAMERA_SENSOR_ENUM)((*pDrvIndex & KDIMGSENSOR_DUAL_MASK_MSB)>>KDIMGSENSOR_DUAL_SHIFT);
	spin_unlock(&kdsensor_drv_lock);

    
    if (0 != kdGetSensorInitFuncList(&pSensorList))
    {
        PK_ERR("ERROR:kdGetSensorInitFuncList()\n");
        return -EIO;
    }

    if (drvIdx < MAX_NUM_OF_SUPPORT_SENSOR)
    {
        if (NULL == pSensorList[drvIdx].SensorInit)
        {
            PK_ERR("ERROR:kdSetDriver()\n");
            return -EIO;
        }

        pSensorList[drvIdx].SensorInit(&g_pSensorFunc);
        if (NULL == g_pSensorFunc)
        {
            PK_ERR("ERROR:NULL g_pSensorFunc\n");
            return -EIO;
        }

        //get sensor name
        memcpy((char*)g_currSensorName,(char*)pSensorList[drvIdx].drvname,sizeof(pSensorList[drvIdx].drvname));
        //return sensor ID
        *pDrvIndex = (unsigned int)pSensorList[drvIdx].SensorId;
        PK_DBG("[kdSetDriver] :%d,%d,%s,%d\n",g_currDualSensorIdx,drvIdx,g_currSensorName,sizeof(pSensorList[drvIdx].drvname));
    }
	return 0;
}
static int flashchip_probe(struct platform_device *dev)
{
	struct flash_chip_data *chip;

	PK_ERR("[flashchip_probe] start\n");
	chip = &chipconf;
	chip->mode = 0;
	chip->torch_level = 0;
	mutex_init(&chip->lock);

	//flash
	chip->cdev_flash.name="flash";
	chip->cdev_flash.max_brightness = 1;
	chip->cdev_flash.brightness_set = chip_flash_brightness_set;
	if(led_classdev_register((struct device *)&dev->dev,&chip->cdev_flash)<0)
		goto err_create_flash_file;	
	//torch
	chip->cdev_torch.name="torch";
#if defined(LENOVO_FLASH_RT9387)
	chip->cdev_torch.max_brightness = 16;
#elif defined(LENOVO_FLASH_ADP1650)
	chip->cdev_torch.max_brightness = 7;
#endif
	chip->cdev_torch.brightness_set = chip_torch_brightness_set;
	if(led_classdev_register((struct device *)&dev->dev,&chip->cdev_torch)<0)
		goto err_create_torch_file;

    PK_ERR("[flashchip_probe] Done\n");
    return 0;

err_create_torch_file:
	led_classdev_unregister(&chip->cdev_flash);
err_create_flash_file:
err_chip_init:	
	printk(KERN_ERR "[flashchip_probe] is failed !\n");
	return -ENODEV;



}
static int adp1650_write_reg(struct i2c_client *client, u8 reg, u8 val)
{
	int ret=0;
	struct adp1650_chip_data *chip = i2c_get_clientdata(client);

	mutex_lock(&chip->lock);
	ret =  i2c_smbus_write_byte_data(client, reg, val);
	mutex_unlock(&chip->lock);
	
	if (ret < 0)
		PK_ERR("failed writting at 0x%02x\n", reg);
	return ret;
}
Example #11
0
/*=======================================================================
  * CAMERA_HW_i2C_init() 
  *=======================================================================*/
static int __init CAMERA_HW_i2C_init(void)
{
    struct proc_dir_entry *prEntry;

    if(platform_driver_register(&g_stCAMERA_HW_Driver)){
        PK_ERR("failed to register CAMERA_HW driver\n");
        return -ENODEV;
    }

    //Register proc file for sensor register debug 
    prEntry = create_proc_entry("driver/camsensor", 0, NULL); 
    if (prEntry) {
        prEntry->read_proc = CAMERA_HW_DumpReg_To_Proc; 
        prEntry->write_proc = CAMERA_HW_Reg_Debug; 
    }
    else {
        PK_ERR("add /proc/driver/camsensor entry fail \n");  
    }
    atomic_set(&g_CamHWOpend, 0); 
    atomic_set(&g_CamDrvOpenCnt, 0);
    atomic_set(&g_CamHWOpening, 0);
    return 0;
}
Example #12
0
static int __init hw_mod_init(void)
{
	int ret;

	printk(KERN_INFO "TomTom GO Hardware Detection Driver, (C) 2004,2005 TomTom BV\n");
	PK_DBG("Registering driver\n");
	ret = driver_register(&hw_driver);
	if (ret) {
		PK_ERR("Unable to register driver (%d)\n", ret);
		return ret;
	}
	PK_DBG("Done\n");
	return 0;
}
Example #13
0
static int hw_probe(struct device *dev)
{
	int ret;

	PK_DBG("Setting up proc entries\n");
	ret = hw_proc_init();
	if (ret < 0) {
		PK_ERR("Unable to setup proc entries\n");
		return -ENODEV;
	}

	PK_DBG("Done\n");
	return 0;
}
Example #14
0
static int __init bat_mod_init(void)
{
	int ret;

	printk(KERN_INFO "TomTom GO Battery Driver, (C) 2004,2005,2006,2007 TomTom BV\n");
	PK_DBG("Registering driver\n");
	ret = driver_register(&bat_driver);
	if (ret) {
		PK_ERR("Unable to register driver (%d)\n", ret);
		return ret;
	}
	PK_DBG("Done\n");
	return 0;
}
Example #15
0
int FL_dim_duty(kal_uint32 duty)
{
	PK_DBG("FL_dim_duty %d, thres %d", duty, LEDS_CUSTOM_MODE_THRES);
	
	if(duty < LEDS_CUSTOM_MODE_THRES)	
		mt_set_gpio_out(GPIO_CAMERA_FLASH_MODE_PIN, LEDS_TORCH_MODE);
	else
		mt_set_gpio_out(GPIO_CAMERA_FLASH_MODE_PIN, LEDS_FLASH_MODE);	

	if((g_timeOutTimeMs == 0) && (duty > LEDS_CUSTOM_MODE_THRES))
	{
		PK_ERR("FL_dim_duty %d > thres %d, FLASH mode but timeout %d", duty, LEDS_CUSTOM_MODE_THRES, g_timeOutTimeMs);	
		mt_set_gpio_out(GPIO_CAMERA_FLASH_MODE_PIN, LEDS_TORCH_MODE);
	}	
//	upmu_set_flash_dim_duty(duty);
    return 0;
}
/* i2c access*/
static int adp1650_read_reg(struct i2c_client *client, u8 reg,u8 *val)
{
	int ret;
	struct adp1650_chip_data *chip = i2c_get_clientdata(client);

	mutex_lock(&chip->lock);
	ret = i2c_smbus_read_byte_data(client, reg);
	mutex_unlock(&chip->lock);

	if (ret < 0) {
		PK_ERR("failed reading at 0x%02x error %d\n",reg, ret);
		return ret;
	}
	*val = ret&0xff; 

	return 0;
}
Example #17
0
static int wm8771_set_fs(enum codec_fs fs,unsigned int samplerate, unsigned int clockrate)
{
	uint16_t newr8;

	if ((IO_GetCodecMaster()) && (!IO_HasPin(CDCLK_12MHZ))) {
		/* Set codec in master mode */
		WM8711_WRREG(7, 0x42);

		/* Codec is master with fixed 6 MHz clock so set sample frequency according to double the rate as defined in the datasheet */
		switch (samplerate) {
		case 16000:
			newr8 = 0x19;
			break;
		case 22050:
			newr8 = 0x23;
			break;
		case 24000:
			newr8 = 0x01;
			break;
		case 44100:
			newr8 = 0x3f;
			break;
		case 48000:
			newr8 = 0x1d;
			break;
		default:
			return -1;
		}
	} else {
		switch (fs) {
		case FS256:
			newr8 = R8_FS256;
			break;
		case FS384:
			newr8 = R8_FS384;
			break;
		default:
			PK_ERR("Unknown fs %d\n", (int) fs);
			return -EINVAL;
		}
	}
	WM8711_WRREG(8, newr8);

	return 0;
}
Example #18
0
int FL_dim_duty(kal_uint32 duty)
{
	PK_DBG("FL_dim_duty %d, thres %d", duty, LEDS_CUSTOM_MODE_THRES);
	
	PK_DBG("FL_dim_duty LEDS_LOWHIGH_END_FLAG %d", LEDS_LOWHIGH_END_FLAG);
      #if (LEDS_LOWHIGH_END_FLAG == 0)
	if(duty < 10) { //LEDS_CUSTOM_MODE_THRES==20,torch mode:duty==6,flash mode:duty==12
		flashpwm = 0;
		mt_set_gpio_out(GPIO_CAMERA_FLASH_MODE_PIN, LEDS_TORCH_MODE);
	} else {
		flashpwm = 1;
		mt_set_gpio_out(GPIO_CAMERA_FLASH_MODE_PIN, LEDS_TORCH_MODE);
	}
      #elif (LEDS_LOWHIGH_END_FLAG == 1)
	if(duty < 10) { //LEDS_CUSTOM_MODE_THRES==20,torch mode:duty==6,flash mode:duty==12
		flashpwm = 1;
		mt_set_gpio_out(GPIO_CAMERA_FLASH_MODE_PIN, LEDS_TORCH_MODE);
	} else {
		flashpwm = 1;
		mt_set_gpio_out(GPIO_CAMERA_FLASH_MODE_PIN, LEDS_FLASH_MODE);
	}
      #elif (LEDS_LOWHIGH_END_FLAG == 2)
	if(duty < 10) { //LEDS_CUSTOM_MODE_THRES==20,torch mode:duty==6,flash mode:duty==12
		flashpwm = 0;
		mt_set_gpio_out(GPIO_CAMERA_FLASH_MODE_PIN, LEDS_TORCH_MODE);
	} else {
		flashpwm = 1;
		mt_set_gpio_out(GPIO_CAMERA_FLASH_MODE_PIN, LEDS_FLASH_MODE);	
	}
      #endif

	if((g_timeOutTimeMs == 0) && (duty > LEDS_CUSTOM_MODE_THRES))
	{
		flashpwm = 0;
		PK_ERR("FL_dim_duty %d > thres %d, FLASH mode but timeout %d", duty, LEDS_CUSTOM_MODE_THRES, g_timeOutTimeMs);	
		mt_set_gpio_out(GPIO_CAMERA_FLASH_MODE_PIN, LEDS_TORCH_MODE);
	}	
//	upmu_set_flash_dim_duty(duty);
    return 0;
}
Example #19
0
//static u16 g_SensorAFPos = 0; 
//static atomic_t g_SetSensorAF; 
int kdSensorSyncFunctionPtr(void)
{
    unsigned int FeatureParaLen = 0;
    //PK_DBG("[Sensor] kdSensorSyncFunctionPtr1:%d %d %d\n", g_NewSensorExpGain.uSensorExpDelayFrame, g_NewSensorExpGain.uSensorGainDelayFrame, g_NewSensorExpGain.uISPGainDelayFrame);    
    mutex_lock(&kdCam_Mutex);
    if (NULL == g_pSensorFunc) {
        PK_ERR("ERROR:NULL g_pSensorFunc\n");
        mutex_unlock(&kdCam_Mutex);        
        return -EIO;
    }           
    //PK_DBG("[Sensor] Exposure time:%d, Gain = %d\n", g_NewSensorExpGain.u2SensorNewExpTime,g_NewSensorExpGain.u2SensorNewGain );
    // exposure time 
    if (g_NewSensorExpGain.uSensorExpDelayFrame == 0) {
        FeatureParaLen = 2;
        g_pSensorFunc->SensorFeatureControl(SENSOR_FEATURE_SET_ESHUTTER, (unsigned char*)&g_NewSensorExpGain.u2SensorNewExpTime, (unsigned int*) &FeatureParaLen);        
        g_NewSensorExpGain.uSensorExpDelayFrame = 0xFF; // disable                         
    }
    else if(g_NewSensorExpGain.uSensorExpDelayFrame != 0xFF) {
        g_NewSensorExpGain.uSensorExpDelayFrame --;  
    }
   
    // exposure gain 
    if (g_NewSensorExpGain.uSensorGainDelayFrame == 0) {
        FeatureParaLen = 2;
        g_pSensorFunc->SensorFeatureControl(SENSOR_FEATURE_SET_GAIN, (unsigned char*)&g_NewSensorExpGain.u2SensorNewGain, (unsigned int*) &FeatureParaLen);
        g_NewSensorExpGain.uSensorGainDelayFrame = 0xFF; // disable 
     }
    else if(g_NewSensorExpGain.uSensorGainDelayFrame != 0xFF) {
        g_NewSensorExpGain.uSensorGainDelayFrame --;  
     } 
    
    // if the delay frame is 0 or 0xFF, stop to count
    if((g_NewSensorExpGain.uISPGainDelayFrame != 0xFF) && (g_NewSensorExpGain.uISPGainDelayFrame != 0)){
        g_NewSensorExpGain.uISPGainDelayFrame --;  
    }	
    mutex_unlock(&kdCam_Mutex);           
    return 0;
}
Example #20
0
int TMP103_I2C_read_bytes(u8 id, u8 *puBuff, u8 sizeofRecvData)
{
	int ret = 0;

	mutex_lock(&TMP103_i2c_access);
	//g_pstI2CclientA->addr = id;
  if (id == 0x70)
	{  
			ret = i2c_master_recv(g_pstI2CclientA, (char *)puBuff, sizeofRecvData);
	}
	else if (id == 0x71)
	{
			ret = i2c_master_recv(g_pstI2CclientB, (char *)puBuff, sizeofRecvData);
	}
	
	if ( ret != sizeofRecvData ) 
	{
		PK_ERR("i2c_master_recv failed!!\n");
	}

	mutex_unlock(&TMP103_i2c_access);
	return ret;
}
Example #21
0
int TMP103_I2C_write_bytes(u8 id, u8 *SendData, u8 sizeofSendData)
{
	int ret = 0;
  PK_DBG_FUNC("id=0x%x \n",id);
  mutex_lock(&TMP103_i2c_access);
	//g_pstI2CclientA->addr = id;

	if (id == 0x70)
	{
			ret = i2c_master_send(g_pstI2CclientA, SendData, sizeofSendData);	
	}
	else if (id == 0x71)
	{
			ret = i2c_master_send(g_pstI2CclientB, SendData, sizeofSendData);	
	}
	
	if ( ret != sizeofSendData ) 
	{
		PK_ERR("i2c_master_send failed!!\n");
	}
	PK_DBG_FUNC("id=0x%x  ret=%d \n",id,ret);
	mutex_unlock(&TMP103_i2c_access);
	return ret;
}
Example #22
0
static int wm8971_set_fs(enum codec_fs fs,unsigned int samplerate, unsigned int clockrate)
{
	int ret;
	uint16_t newr8;

	if (IO_GetCodecMaster() == GOCODECCFG_INTERNAL_MASTER ) {
		/* Set codec in master mode */
		WM8971_WRREG(7, 0x42);

		/* Codec is master with fixed 6 MHz clock, set sample frequency according to double the rate as defined in the datasheet */
		switch (samplerate) {
		case 8000:
			newr8 = 0x15;
			break;
		case 11025:
			newr8 = 0x37;
			break;
		case 12000:
			newr8 = 0x39;
			break;
		case 16000:
			newr8 = 0x19;
			break;
		case 22050:
			newr8 = 0x23;
			break;
		case 24000:
			newr8 = 0x01;
			break;
		case 44100:
			newr8 = 0x3f;
			break;
		case 48000:
			newr8 = 0x1b;
			break;
		default:
			return -1;
		}
	} else if (IO_GetCodecMaster() == GOCODECCFG_EXTERNAL_MASTER ) {
		/* Set codec in master mode */
		if(IO_GetCpuType() == GOCPU_S3C2443 ){
#ifdef SIX_MHZ_AUDIO_TEST
			WM8971_WRREG(7, 0x42);
			samplerate *= 2;
#else
	
			WM8971_WRREG(7, 0xc2);
#endif	/* SIX_MHZ_AUDIO_TEST	*/
		} else {
			WM8971_WRREG(7, 0x42);
		}

		if (IO_HaveUsbHost()) {
			if ((ret = wm8971_set_fixed12(samplerate, &newr8)) == -1) return ret;
		}
		else {
			switch (IO_GetGpsType()) {
				/* GL type chips */
				case GOGPS_GL:
				case GOGPS_GL_INT_LNA:
				case GOGPS_GL_BCM4750:

					if ((ret = wm8971_set_switch1211(samplerate, &newr8)) == -1) return ret;
					break;

				/* SiRF chips */
				case GOGPS_SIRF1:
				case GOGPS_SIRF2:
				case GOGPS_SIRF3:

					if ((ret = wm8971_set_fixed12(samplerate, &newr8)) == -1) return ret;
					break;

				default:
					printk("%s: ERROR: GPS chip type needs to be set!\n", __FUNCTION__);
					return -1;
			}
		}

#ifdef SIX_MHZ_AUDIO_TEST
		if(IO_GetCpuType() == GOCPU_S3C2443 ){
			newr8 |= (1<<6); /* divide Master clock by two!	*/
		}
#endif /* SIX_MHZ_AUDIO_TEST	*/

	} else { 	/* IO_GetCodecMaster()) == GOCODECCFG_SLAVE */
		/* Set codec in slave mode */
		WM8971_WRREG(7, 0x02);

		/* Codec is slave, so only set oversample frequency */
		switch (fs) {
		case FS256:
			newr8 = R8_FS256;
			break;
		case FS384:
			newr8 = R8_FS384;
			break;
		default:
			PK_ERR("Unknown fs %d\n", (int) fs);
			return -EINVAL;
		}
	}

	WM8971_WRREG(8, newr8);

	return 0;
}
Example #23
0
/*******************************************************************************
* adopt_CAMERA_HW_FeatureControl
********************************************************************************/
inline static int  adopt_CAMERA_HW_FeatureControl(void *pBuf)
{
    ACDK_SENSOR_FEATURECONTROL_STRUCT *pFeatureCtrl = (ACDK_SENSOR_FEATURECONTROL_STRUCT*)pBuf;
    unsigned int FeatureParaLen = 0;
    void *pFeaturePara = NULL;
    
    ACDK_SENSOR_GROUP_INFO_STRUCT *pSensorGroupInfo = NULL;
    ACDK_KD_SENSOR_SYNC_STRUCT *pSensorSyncInfo = NULL;
    char kernelGroupNamePtr[128];
    unsigned char *pUserGroupNamePtr = NULL;
    //UINT16 u2RAWGain[4];

    if (NULL == pFeatureCtrl ) {
        PK_ERR(" NULL arg.\n");
        return -EFAULT;
    }

    if(SENSOR_FEATURE_SINGLE_FOCUS_MODE == pFeatureCtrl->FeatureId || SENSOR_FEATURE_CANCEL_AF == pFeatureCtrl->FeatureId
		|| SENSOR_FEATURE_CONSTANT_AF == pFeatureCtrl->FeatureId)
    {//YUV AF_init and AF_constent and AF_single has no params
    }
    else 
    {
        if (NULL == pFeatureCtrl->pFeaturePara || NULL == pFeatureCtrl->pFeatureParaLen) {
            PK_ERR(" NULL arg.\n");
            return -EFAULT;
        }
    }

    if(copy_from_user((void*)&FeatureParaLen , (void *) pFeatureCtrl->pFeatureParaLen, sizeof(unsigned int))) {
        PK_ERR(" ioctl copy from user failed\n");
        return -EFAULT;
    }

    pFeaturePara = kmalloc(FeatureParaLen,GFP_KERNEL);
    if(NULL == pFeaturePara) {
        PK_ERR(" ioctl allocate mem failed\n");
        return -ENOMEM;
    }

    //copy from user
	switch (pFeatureCtrl->FeatureId)
	{
        case SENSOR_FEATURE_SET_ESHUTTER:
        case SENSOR_FEATURE_SET_GAIN:
            // reset the delay frame flag	
            g_NewSensorExpGain.uSensorExpDelayFrame = 0xFF;
            g_NewSensorExpGain.uSensorGainDelayFrame = 0xFF;
            g_NewSensorExpGain.uISPGainDelayFrame = 0xFF;  
        case SENSOR_FEATURE_SET_ISP_MASTER_CLOCK_FREQ:
        case SENSOR_FEATURE_SET_REGISTER:
        case SENSOR_FEATURE_GET_REGISTER:        	
        case SENSOR_FEATURE_SET_CCT_REGISTER:
        case SENSOR_FEATURE_SET_ENG_REGISTER:
        case SENSOR_FEATURE_SET_ITEM_INFO:
        case SENSOR_FEATURE_GET_ITEM_INFO:
        case SENSOR_FEATURE_GET_ENG_INFO:
        case SENSOR_FEATURE_SET_VIDEO_MODE:
        case SENSOR_FEATURE_SET_YUV_CMD:            
        case SENSOR_FEATURE_MOVE_FOCUS_LENS:            
        case SENSOR_FEATURE_SET_AF_WINDOW:	        
        case SENSOR_FEATURE_SET_CALIBRATION_DATA:	        
        case SENSOR_FEATURE_SET_AUTO_FLICKER_MODE:
        case SENSOR_FEATURE_GET_EV_AWB_REF:    
        case SENSOR_FEATURE_GET_SHUTTER_GAIN_AWB_GAIN:
        case SENSOR_FEATURE_SET_AE_WINDOW:
        case SENSOR_FEATURE_GET_EXIF_INFO:
            //
            if(copy_from_user((void*)pFeaturePara , (void *) pFeatureCtrl->pFeaturePara, FeatureParaLen)) {
                kfree(pFeaturePara);
                PK_DBG("[CAMERA_HW][pFeaturePara] ioctl copy from user failed\n");
                return -EFAULT;
            }
            break;
	 case SENSOR_FEATURE_SET_SENSOR_SYNC:    // Update new sensor exposure time and gain to keep
            if(copy_from_user((void*)pFeaturePara , (void *) pFeatureCtrl->pFeaturePara, FeatureParaLen)) {
	         PK_DBG("[CAMERA_HW][pFeaturePara] ioctl copy from user failed\n");
	         return -EFAULT;
	    }
	    // keep the information to wait Vsync synchronize
            pSensorSyncInfo = (ACDK_KD_SENSOR_SYNC_STRUCT*)pFeaturePara;
	    g_NewSensorExpGain.u2SensorNewExpTime = pSensorSyncInfo->u2SensorNewExpTime;
            g_NewSensorExpGain.u2SensorNewGain = pSensorSyncInfo->u2SensorNewGain;
	    g_NewSensorExpGain.u2ISPNewRGain = pSensorSyncInfo->u2ISPNewRGain;
	    g_NewSensorExpGain.u2ISPNewGrGain = pSensorSyncInfo->u2ISPNewGrGain;
	    g_NewSensorExpGain.u2ISPNewGbGain = pSensorSyncInfo->u2ISPNewGbGain;
            g_NewSensorExpGain.u2ISPNewBGain = pSensorSyncInfo->u2ISPNewBGain;
            g_NewSensorExpGain.uSensorExpDelayFrame = pSensorSyncInfo->uSensorExpDelayFrame;
	    g_NewSensorExpGain.uSensorGainDelayFrame = pSensorSyncInfo->uSensorGainDelayFrame;
	    g_NewSensorExpGain.uISPGainDelayFrame = pSensorSyncInfo->uISPGainDelayFrame;
	     
//          PK_DBG("[pFeaturePara] NewExp:%d NewSensorGain:%d NewISPGain:%d %d %d %d ExpDelay:%d SensorGainDelay:%d ISPGainDelay:%d\n", 
//	    	g_NewSensorExpGain.u2SensorNewExpTime,	g_NewSensorExpGain.u2SensorNewGain, g_NewSensorExpGain.u2ISPNewRGain, 
//				g_NewSensorExpGain.u2ISPNewGrGain, g_NewSensorExpGain.u2ISPNewGbGain, g_NewSensorExpGain.u2ISPNewBGain, 
//				g_NewSensorExpGain.uSensorExpDelayFrame, g_NewSensorExpGain.uSensorGainDelayFrame, g_NewSensorExpGain.uISPGainDelayFrame);            
//            if(bSesnorVsyncFlag == FALSE)   // set to sensor driver for 1st frame
//            {
//               PK_DBG("[CAMERA_HW][pFeaturePara] kdSensorSyncFunctionPtr \n");
//               kdSensorSyncFunctionPtr(u2RAWGain);
//            }

	     break;
        case SENSOR_FEATURE_GET_GROUP_INFO:
            if(copy_from_user((void*)pFeaturePara , (void *) pFeatureCtrl->pFeaturePara, FeatureParaLen)) {
                kfree(pFeaturePara);
                PK_DBG("[CAMERA_HW][pFeaturePara] ioctl copy from user failed\n");
                return -EFAULT;
            }
            pSensorGroupInfo = (ACDK_SENSOR_GROUP_INFO_STRUCT*)pFeaturePara;
            pUserGroupNamePtr = pSensorGroupInfo->GroupNamePtr;
            //
            if (NULL == pUserGroupNamePtr) {
                kfree(pFeaturePara);
                PK_DBG("[CAMERA_HW] NULL arg.\n");
                return -EFAULT;
            }
            pSensorGroupInfo->GroupNamePtr = kernelGroupNamePtr;
            break;
        //copy to user
        case SENSOR_FEATURE_GET_RESOLUTION:
        case SENSOR_FEATURE_GET_PERIOD:
        case SENSOR_FEATURE_GET_PIXEL_CLOCK_FREQ:
        case SENSOR_FEATURE_GET_REGISTER_DEFAULT:
        case SENSOR_FEATURE_GET_CONFIG_PARA:
        case SENSOR_FEATURE_GET_GROUP_COUNT:
        case SENSOR_FEATURE_GET_LENS_DRIVER_ID:
        //do nothing
        case SENSOR_FEATURE_CAMERA_PARA_TO_SENSOR:
        case SENSOR_FEATURE_SENSOR_TO_CAMERA_PARA:
        case SENSOR_FEATURE_SINGLE_FOCUS_MODE:
        case SENSOR_FEATURE_CANCEL_AF:
        case SENSOR_FEATURE_CONSTANT_AF:
		default:
			break;
	}

    //
    if (g_pSensorFunc) {
        //sync with AE taske 
        //if (pFeatureCtrl->FeatureId == SENSOR_FEATURE_MOVE_FOCUS_LENS) {
        //    if (*(u16*)pFeaturePara != g_SensorAFPos) {
        //        g_SensorAFPos = *(u16 *)pFeaturePara;             
        //        atomic_set(&g_SetSensorAF, 1);  
                //PK_DBG("Set AF Pos = %d\n", g_SensorAFPos); 
        //    }
       //}
       //else {
            g_pSensorFunc->SensorFeatureControl(pFeatureCtrl->FeatureId,(unsigned char*)pFeaturePara,(unsigned int*) &FeatureParaLen);
        //}
    }
    else {
        PK_DBG("[CAMERA_HW]ERROR:NULL g_pSensorFunc\n");
    }

    //copy to user
	switch (pFeatureCtrl->FeatureId)
	{
        case SENSOR_FEATURE_SET_ESHUTTER:
        case SENSOR_FEATURE_SET_GAIN:
        case SENSOR_FEATURE_SET_ISP_MASTER_CLOCK_FREQ:
        case SENSOR_FEATURE_SET_REGISTER:
        case SENSOR_FEATURE_SET_CCT_REGISTER:
        case SENSOR_FEATURE_SET_ENG_REGISTER:
        case SENSOR_FEATURE_SET_ITEM_INFO:
        //do nothing
        case SENSOR_FEATURE_CAMERA_PARA_TO_SENSOR:
        case SENSOR_FEATURE_SENSOR_TO_CAMERA_PARA:
            break;
        //copy to user
        case SENSOR_FEATURE_GET_RESOLUTION:
        case SENSOR_FEATURE_GET_PERIOD:
        case SENSOR_FEATURE_GET_PIXEL_CLOCK_FREQ:
        case SENSOR_FEATURE_GET_REGISTER:
        case SENSOR_FEATURE_GET_REGISTER_DEFAULT:
        case SENSOR_FEATURE_GET_CONFIG_PARA:
        case SENSOR_FEATURE_GET_GROUP_COUNT:
        case SENSOR_FEATURE_GET_LENS_DRIVER_ID:
        case SENSOR_FEATURE_GET_ITEM_INFO:
        case SENSOR_FEATURE_GET_ENG_INFO:
        case SENSOR_FEATURE_GET_AF_STATUS:            
        case SENSOR_FEATURE_GET_AF_INF:            
        case SENSOR_FEATURE_GET_AF_MACRO:       
        case SENSOR_FEATURE_GET_AF_MAX_NUM_FOCUS_AREAS:    
        case SENSOR_FEATURE_GET_AE_MAX_NUM_METERING_AREAS:
        case SENSOR_FEATURE_CHECK_SENSOR_ID:
            //
            if(copy_to_user((void __user *) pFeatureCtrl->pFeaturePara, (void*)pFeaturePara , FeatureParaLen))
            {
                kfree(pFeaturePara);
                PK_DBG("[CAMERA_HW][pSensorRegData] ioctl copy to user failed\n");
                return -EFAULT;
            }
            break;
        //copy from and to user
        case SENSOR_FEATURE_GET_GROUP_INFO:
            //copy 32 bytes
            if(copy_to_user((void __user *) pUserGroupNamePtr, (void*)kernelGroupNamePtr , sizeof(char)*32))
            {
                kfree(pFeaturePara);
                PK_DBG("[CAMERA_HW][pFeatureReturnPara32] ioctl copy to user failed\n");
                return -EFAULT;
            }
            pSensorGroupInfo->GroupNamePtr = pUserGroupNamePtr;
            if(copy_to_user((void __user *) pFeatureCtrl->pFeaturePara, (void*)pFeaturePara , FeatureParaLen))
            {
                kfree(pFeaturePara);
                PK_DBG("[CAMERA_HW][pFeatureReturnPara32] ioctl copy to user failed\n");
                return -EFAULT;
            }
            break;
	default:
			break;
	}

    kfree(pFeaturePara);
    if(copy_to_user((void __user *) pFeatureCtrl->pFeatureParaLen, (void*)&FeatureParaLen , sizeof(unsigned int))) {
        PK_DBG("[CAMERA_HW][pFeatureParaLen] ioctl copy to user failed\n");
        return -EFAULT;
    }
    return 0;
}	/* adopt_CAMERA_HW_FeatureControl() */
Example #24
0
static int TMP103_status_report(unsigned long data)
{	
		u8 out_buff[1];
		u8 in_buff[1]; 

		if (data==1)
		{		
		  	//TMP103A_value
		  	out_buff[0] = 0x00;  //Pointer Register byte
		  	in_buff[0] = 0xFF;
				if ((TMP103_I2C_write_bytes(0x70, (u8*)out_buff, sizeof(out_buff)))!= sizeof(out_buff)) 
				{
					PK_ERR("TMP103_I2C_write_bytes 0x70 failed!!\n");
				}
				
				if ((TMP103_I2C_read_bytes(0x70, (u8*)in_buff, sizeof(in_buff)))!= sizeof(in_buff)) 
				{
					PK_ERR("TMP103_I2C_read_bytes 0x70 failed!!\n");
				}
				else
				{
					PK_DBG_FUNC("TMP103A_value 0x%x \n",in_buff[0]);
					if (in_buff[0] & 0x80) //negative
					{
						TMP103A_value = (in_buff[0] - 256);
					}
					else  //positive
					{
						TMP103A_value = in_buff[0];
					}
				}
				PK_DBG_FUNC("TMP103A=%d \n",TMP103A_value);
		}
		else if (data==2)
		{
				//TMP103B_value
				out_buff[0] = 0x00;  //Pointer Register byte
		  	in_buff[0] = 0xFF;
				if ((TMP103_I2C_write_bytes(0x71, (u8*)out_buff, sizeof(out_buff)))!= sizeof(out_buff)) 
				{
					PK_ERR("TMP103_I2C_write_bytes 0x71 failed!!\n");
				}
				
				if ((TMP103_I2C_read_bytes(0x71, (u8*)in_buff, sizeof(in_buff)))!= sizeof(in_buff)) 
				{
					PK_ERR("TMP103_I2C_read_bytes 0x71 failed!!\n");
				}
				else
				{
					PK_DBG_FUNC("TMP103B_value 0x%x \n",in_buff[0]);
					if (in_buff[0] & 0x80) //negative
					{
						TMP103B_value = (in_buff[0] - 256);
					}
					else  //positive
					{
						TMP103B_value = in_buff[0];
					}
				}
				PK_DBG_FUNC("TMP103B=%d \n",TMP103B_value);
		}

		return 0;
}
static void chip_torch_brightness_set(struct led_classdev *cdev,
				  enum led_brightness brightness)
{
	int i, cc;
	struct flash_chip_data *chip = &chipconf;
	u8 tmp4,tmp5;
#if defined(LENOVO_FLASH_RT9387)
	if(brightness == 0)
	{
		mt_set_gpio_out(FLASH_PIN,GPIO_OUT_ZERO);
		mt_set_gpio_out(TORCH_PIN,GPIO_OUT_ZERO);
		mdelay(4);
		chip->torch_level = 0;
		chip->mode = 0;
		PK_ERR("[flashchip] level = 0\n");

		return;
	}

	switch(chip->mode)
	{
		case 0:
			mt_set_gpio_out(FLASH_PIN,GPIO_OUT_ZERO);
			mt_set_gpio_out(TORCH_PIN,GPIO_OUT_ONE);
			udelay(50);

			if(brightness >= 16)
			{
				/* keep current */
				brightness = 16;
			}
			else
			{
				cc = 16 - brightness;

				for(i = 0; i < cc; i++)
				{
					udelay(15);
					mt_set_gpio_out(TORCH_PIN,GPIO_OUT_ZERO);
					udelay(15);
					mt_set_gpio_out(TORCH_PIN,GPIO_OUT_ONE);
				}
			}
			chip->torch_level = brightness;
			chip->mode = 1;
			PK_ERR("[flashchip] init level=%d cc=%d\n", brightness, cc);
			break;

		case 1:
			if(brightness >= 16)
			{
				brightness = 16;
			}
			if(brightness == chip->torch_level)
			{
				/* keep current */
				cc = 0;
			}
			else if(brightness < chip->torch_level)
			{
				cc = chip->torch_level - brightness;
			}
			else /* (brightness > chip->torch_level) */
			{
				cc = chip->torch_level + 16 - brightness;
			}
			for(i = 0; i < cc; i++)
			{
				udelay(15);
				mt_set_gpio_out(TORCH_PIN,GPIO_OUT_ZERO);
				udelay(15);
				mt_set_gpio_out(TORCH_PIN,GPIO_OUT_ONE);
			}
			PK_ERR("[flashchip] old=%d level=%d cc=%d\n", chip->torch_level, brightness, cc);
			chip->torch_level = brightness;
			break;
			
		case 2:
			/* not support now */
			break;

		default:
			break;
	}
#elif defined(LENOVO_FLASH_ADP1650)

	if(brightness == 0)
	{
		mt_set_gpio_out(FLASH_PIN,GPIO_OUT_ZERO);
		mt_set_gpio_out(TORCH_PIN,GPIO_OUT_ZERO);
		udelay(50);
		chip->torch_level = 0;
		chip->mode = 0;
		PK_ERR("[flashchip] PRADA level = 0\n");

		return;
	}

	switch(chip->mode)
	{
		case 0:
			
			
			

			if(brightness >= 7)
			{
				/* keep current */
				brightness = 7;
			}
			else
			{
				cc = brightness;
				adp1650_write_reg(adp1650_i2c_client, 0x04, 0xAC); //75ma torch output_en
				adp1650_write_reg(adp1650_i2c_client, 0x03, cc); //75ma torch output_en

			}
			udelay(100);
			mt_set_gpio_out(FLASH_PIN,GPIO_OUT_ZERO);
			mt_set_gpio_out(TORCH_PIN,GPIO_OUT_ONE);
			adp1650_read_reg(adp1650_i2c_client, 0x05, &tmp5);
        		adp1650_read_reg(adp1650_i2c_client, 0x04, &tmp4);
			chip->torch_level = brightness;
			chip->mode = 1;
			PK_ERR("[flashchip] init PRADA tmp5=%d tmp4=%d\n", tmp5, tmp4);
			PK_ERR("[flashchip] init PRADA level=%d cc=%d\n", brightness, cc);
			break;

		case 1:
			if(brightness >= 7)
			{
				brightness = 7;
			}
			if(brightness == chip->torch_level)
			{
				/* keep current */
				cc = 0;
			}
			else if(brightness < chip->torch_level)
			{
				cc = chip->torch_level - brightness;
			}
			else /* (brightness > chip->torch_level) */
			{
				cc = chip->torch_level - brightness;
			}
			adp1650_write_reg(adp1650_i2c_client, 0x04, 0xAC); //75ma torch output_en
			adp1650_write_reg(adp1650_i2c_client, 0x03, cc); //75ma torch output_en
			PK_ERR("[flashchip] old=%d level=%d cc=%d\n", chip->torch_level, brightness, cc);
			chip->torch_level = brightness;
			break;
			
		case 2:
			/* not support now */
			break;

		default:
			break;
	}
#endif
}
int FL_enable(void)
{
	int i, cc;
	struct flash_chip_data *chip = &chipconf;
	int brightness = 6;
	PK_ERR("FL_enable\n");
	if(g_duty == 1)
	{
		switch(chip->mode)
		{
			case 0:
				mt_set_gpio_out(FLASH_PIN,GPIO_OUT_ZERO);
				mt_set_gpio_out(TORCH_PIN,GPIO_OUT_ONE);
				udelay(50);

				if(brightness >= 16)
				{
					/* keep current */
					brightness = 16;
				}
				else
				{
					cc = 16 - brightness;

					for(i = 0; i < cc; i++)
					{
						udelay(15);
						mt_set_gpio_out(TORCH_PIN,GPIO_OUT_ZERO);
						udelay(15);
						mt_set_gpio_out(TORCH_PIN,GPIO_OUT_ONE);
					}
				}
				chip->torch_level = brightness;
				chip->mode = 1;
				PK_ERR("[flashchip] init level=%d cc=%d\n", brightness, cc);
				break;

			case 1:
				if(brightness >= 16)
				{
					brightness = 16;
				}
				if(brightness == chip->torch_level)
				{
					/* keep current */
					cc = 0;
				}
				else if(brightness < chip->torch_level)
				{
					cc = chip->torch_level - brightness;
				}
				else /* (brightness > chip->torch_level) */
				{
					cc = chip->torch_level + 16 - brightness;
				}
				for(i = 0; i < cc; i++)
				{
					udelay(15);
					mt_set_gpio_out(TORCH_PIN,GPIO_OUT_ZERO);
					udelay(15);
					mt_set_gpio_out(TORCH_PIN,GPIO_OUT_ONE);
				}
				PK_ERR("[flashchip] old=%d level=%d cc=%d\n", chip->torch_level, brightness, cc);
				chip->torch_level = brightness;
				break;
				
			case 2:
				/* not support now */
				break;

			default:
				break;
		}
	}
	else if((g_duty == 2)||(g_duty == 0))
	{
/*lenovo-sw xuegb1 2013022 -for lenovoTorch light for long time begin*/		
		mt_set_gpio_out(TORCH_PIN,GPIO_OUT_ZERO);
		mt_set_gpio_out(FLASH_PIN,GPIO_OUT_ONE);
/*lenovo-sw xuegb1 2013022 -for lenovoTorch light for long time end */
		//mdelay(4);
		chip->torch_level = 0;
		chip->mode = 2;
		PK_ERR("[flashchip] flash level = 1\n");
	}

    return 0;
}