int sr130pc10_sensor_power_down(struct msm_sensor_ctrl_t *s_ctrl)
{
	int rc = 0;
	int temp = 0;
	struct msm_camera_sensor_info *data = s_ctrl->sensordata;

	pr_info("=== POWER DOWN Start ===");

	sr130pc10_sensor_write(0x03, 0x02);
	sr130pc10_sensor_write(0x55, 0x10);
	mdelay(1);
	udelay(50);

	gpio_set_value_cansleep(data->sensor_platform_info->sensor_reset, 0);
	temp = __gpio_get_value(data->sensor_platform_info->sensor_reset);
	pr_info("[%s]check sensor_reset : %d\n", __func__, temp);

	gpio_set_value_cansleep(data->sensor_platform_info->sensor_stby, 0);
	temp = __gpio_get_value(data->sensor_platform_info->sensor_stby);
	pr_info("[%s]check sensor_stby : %d\n", __func__, temp);

	gpio_set_value_cansleep(data->sensor_platform_info->vt_sensor_reset, 0);
	temp = __gpio_get_value(data->sensor_platform_info->vt_sensor_reset);
	pr_info("[%s]check vt_sensor_reset : %d\n", __func__, temp);

	mdelay(2);

	/*CAM_MCLK0*/
	msm_cam_clk_enable(&s_ctrl->sensor_i2c_client->client->dev,
			cam_clk_info, &s_ctrl->cam_clk, \
			ARRAY_SIZE(cam_clk_info), 0);

	gpio_tlmm_config(GPIO_CFG(data->sensor_platform_info->mclk, 0,
				GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, \
				GPIO_CFG_2MA),
			GPIO_CFG_ENABLE);

	udelay(10);

	gpio_set_value_cansleep(data->sensor_platform_info->vt_sensor_stby, 0);
	temp = __gpio_get_value(data->sensor_platform_info->vt_sensor_stby);
	pr_info("[%s] check VT standby : %d", __func__, temp);

	udelay(10);

	data->sensor_platform_info->sensor_power_off(1);

	msm_camera_request_gpio_table(data, 0);

	sr130pc10_ctrl->op_mode = 0;
	sr130pc10_ctrl->dtp_mode = 0;
	sr130pc10_ctrl->settings.exposure = 0;
#ifdef CONFIG_LOAD_FILE
	sr130pc10_regs_table_exit();
#endif
	return rc;
}
Exemplo n.º 2
0
int sr130pc10_sensor_release(void)
{
	int rc = 0;

#ifdef CONFIG_MACH_ICON
	sr130pc10_sensor_write(0x03, 0x02);
	sr130pc10_sensor_write(0x55, 0x10);
	mdelay(1);

	gpio_set_value(CAM_RESET, 0);
	gpio_set_value(CAM_STANDBY, 0);


	gpio_set_value(CAM_VT_RST, 0);
	mdelay(1);


#else
	gpio_tlmm_config(
		GPIO_CFG(VCAM_I2C_SCL, 0, GPIO_CFG_OUTPUT,
			GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
		GPIO_CFG_ENABLE);
	gpio_tlmm_config(
		GPIO_CFG(VCAM_I2C_SDA, 0, GPIO_CFG_OUTPUT,
			GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
		GPIO_CFG_ENABLE);
	mdelay(1);
	udelay(50);
	gpio_set_value(CAM_RESET, 0); /*REST -> DOWN*/
	gpio_set_value(CAM_STANDBY, 0); /*REST -> DOWN*/
	gpio_set_value(CAM_VT_RST, 0);	/*REST -> DOWN */
	mdelay(2);

	/*mclk disable*/
	gpio_tlmm_config(GPIO_CFG(CAM_MCLK, 0,
		GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
		GPIO_CFG_16MA), GPIO_CFG_ENABLE); /*CAM_MCLK*/
	udelay(20);

	gpio_set_value(CAM_VT_nSTBY, 0); /*STBY -> DOWN*/
	udelay(10);

	gpio_set_value(CAM_EN_2, 0);
	vreg_disable(vreg_get(NULL, "gp7"));
	gpio_set_value(CAM_EN, 0); /*EN -> DOWN*/
#endif

	/* down(&sr130pc10_sem); */

	kfree(sr130pc10_ctrl);
	/* up(&sr130pc10_sem); */
	return rc;
}
Exemplo n.º 3
0
static int sr130pc10_start(void)
{
    int rc = 0;
    u8 data[2] = {0xEF, 0x01};
    u8 vender[1] = {0xC5};
    u8 version[1] = {0xC6};
    u8 vendor_id = 0xff, sw_ver = 0xff;
    
    printk(KERN_ERR "[CAMDRV/SR130PC10] %s E\n",__func__);

/*
    rc = sr130pc10_sensor_write(0xEF, 0x01);
    rc = sr130pc10_sensor_read(0xC5, &vendor_id);
    rc = sr130pc10_sensor_write(0xEF, 0x01);    
    rc = sr130pc10_sensor_read(0xC6, &sw_ver);
*/

    rc = sr130pc10_sensor_write(0x03, 0x00);
    rc = sr130pc10_sensor_read(0x04, &vendor_id);
    
    printk("[CAMDRV/SR130PC10]=================================rc=%d\n",rc);
    printk("[CAMDRV/SR130PC10]  [VGA CAM] vendor_id ID : 0x%x\n", vendor_id);
//    printk("[CAMDRV/SR130PC10]  [VGA CAM] software version : 0x%x\n", sw_ver);
//    printk("[CAMDRV/SR130PC10]=================================\n");

	//TELECA_PS_UPDATE
	if (vendor_id != 0x94){
		printk(" VENDOR not equal\n");
		//return  -1;
	}
    return rc;
}
Exemplo n.º 4
0
static int sr130pc10_sensor_write_list(struct samsung_short_t *list,int size, char *name)
{
  int ret = 0;
#ifdef CONFIG_LOAD_FILE
  ret = sr130pc10_regs_table_write(name);
#else
	int i;

  for (i = 0; i < size; i++)
  {
    if(list[i].subaddr == 0xff)
    {
      printk("<=PCAM=> now SLEEP!!!!\n");
      msleep(list[i].value*8);
    }
    else
    {
      if(sr130pc10_sensor_write(list[i].subaddr, list[i].value) < 0)
      {
        printk("<=PCAM=> sensor_write_list fail...-_-\n");
        return -1;
      }
    }
  }
#endif
	return ret;
}
static int sr130pc10_exif_iso(void)
{
	uint32_t iso_value = 0;

	unsigned short gain;
	int calc_gain;

	sr130pc10_sensor_write(0x03, 0x20);
	sr130pc10_sensor_read(0xb0, &gain);
	calc_gain = (gain/16) * 10000;

	if (calc_gain < 8750)
		iso_value = 50;
	else if (calc_gain < 17500)
		iso_value = 100;
	else if (calc_gain < 46250)
		iso_value = 200;
	else if (calc_gain < 69375)
		iso_value = 400;
	else if (calc_gain < 138750)
		iso_value = 800;
	else
		iso_value = 1600;

	pr_info("[%s]iso_value(%d)\n", __func__, iso_value);
	return (int)iso_value ;
}
static int
sr130pc10_sensor_write_list(struct sr130pc10_short_t *list,
							int size, char *name)
{
	int ret = 0;
#ifdef CONFIG_LOAD_FILE
	ret = sr130pc10_regs_table_write(name);
#else
	int i;

	pr_info("[%s] %s", __func__, name);
	for (i = 0; i < size; i++) {
		if (list[i].subaddr == 0xff) {
			printk(KERN_DEBUG "now SLEEP!!!!\n");
			msleep(list[i].value * 8);
		} else {
			if (sr130pc10_sensor_write
			    (list[i].subaddr, list[i].value) < 0) {
				printk(KERN_DEBUG
				    "sensor_write_list fail..\n");
				return -EINVAL;
			}
		}
	}
#endif
	return ret;
}
static int sr130pc10_check_dataline(unsigned short dtp)
{
	int rc = 0;

	if (dtp == 1) {
		pr_info("DATALINE_CHECK ON, dtp:%d\n", dtp);
		sr130pc10_sensor_write(0x03, 0x00);
		sr130pc10_sensor_write(0x50, 0x05);
	} else if (dtp == 0) {
		pr_info("DATALINE_CHECK OFF, dtp:%d\n", dtp);
		sr130pc10_sensor_write(0x03, 0x00);
		sr130pc10_sensor_write(0x50, 0x00);
	} else
		pr_info("[%s] value_1: %d", __func__, dtp);

	return rc;
}
static int sr130pc10_exif_shutter_speed(void)
{
	uint32_t shutter_speed = 0;

	unsigned short val1, val2, val3;

	sr130pc10_sensor_write(0x03, 0x20);
	sr130pc10_sensor_read(0x80, &val1);
	sr130pc10_sensor_read(0x81, &val2);
	sr130pc10_sensor_read(0x82, &val3);

	shutter_speed = 24000000 / ((val1<<19) + (val2<<11)+(val3<<3));

	pr_info("[%s]shutter_speed(%d)\n", __func__, shutter_speed);
	return (int)shutter_speed;
}
Exemplo n.º 9
0
static int sr130pc10_regs_table_write(char *name)
{
	char *start, *end, *reg;	
	unsigned short addr, value;
	char reg_buf[5], data_buf[5];

	*(reg_buf + 4) = '\0';
	*(data_buf + 4) = '\0';

	start = strstr(sr130pc10_regs_table, name);
	
	end = strstr(start, "};");

	while (1) {	
		/* Find Address */	
		reg = strstr(start,"{0x");		
		if (reg)
			start = (reg + 11);
		if ((reg == NULL) || (reg > end))
			break;
		/* Write Value to Address */	
		if (reg != NULL) {
			memcpy(reg_buf, (reg + 1), 4);	
			memcpy(data_buf, (reg + 7), 4);	
			addr = (unsigned short)simple_strtoul(reg_buf, NULL, 16); 
			value = (unsigned short)simple_strtoul(data_buf, NULL, 16); 
//			printk("addr 0x%04x, value 0x%04x\n", addr, value);

			if (addr == 0xdd)
			{
//		    	msleep(value);
//				printk("delay 0x%04x, value 0x%04x\n", addr, value);
			}	
			else if (addr == 0xff){
		    	msleep(value * 8);
				printk("delay 0x%04x, value 0x%04x\n", addr, value);
					}
			else
				sr130pc10_sensor_write(addr, value);
		}
	}
	return 0;
}
static int sr130pc10_regs_table_write(char *name)
{
	char *start, *end, *reg;
	unsigned short addr, value;
	char reg_buf[5], data_buf[5];

	*(reg_buf + 4) = '\0';
	*(data_buf + 4) = '\0';

	start = strnstr(sr130pc10_regs_table, name, sr130pc10_regs_table_size);
	end = strnstr(start, "};", sr130pc10_regs_table_size);

	while (1) {
		/* Find Address */
		reg = strnstr(start, "{0x", sr130pc10_regs_table_size);
		if (reg)
			start = (reg + 11);
		if ((reg == NULL) || (reg > end))
			break;
		/* Write Value to Address */
		if (reg != NULL) {
			memcpy(reg_buf, (reg + 1), 4);
			memcpy(data_buf, (reg + 7), 4);
			kstrtol(reg_buf, 16, &addr);
			kstrtol(data_buf, 16, &value);

			if (addr == 0xdd) {
				/* msleep(value); */
				/* printk(KERN_DEBUG "delay 0x%04x,
					value 0x%04x\n", addr, value); */
			} else if (addr == 0xff) {
				msleep(value * 8);
				printk(KERN_DEBUG
					"delay 0x%04x, value 0x%04x\n", addr,
				       value);
			} else
				sr130pc10_sensor_write(addr, value);
		}
	}
	return 0;
}
Exemplo n.º 11
0
int sr130pc10_sensor_ext_config(void __user *argp)
{
    long ext_config_return = 0;
    sensor_ext_cfg_data cfg_data;
    int exposureTime_value1 = 0, exposureTime_value2 = 0, exposureTime_value3 = 0;
    int exposureTime = 0;

    if (copy_from_user((void *)&cfg_data, (const void *)argp, sizeof(cfg_data)))
        return -EFAULT;

    //printk("sr130pc10_sensor_ext_config, cfg_data.cmd=%d\n", cfg_data.cmd);

    switch(cfg_data.cmd)
    {
        case EXT_CFG_SET_EFFECT:
            sr1_effect = cfg_data.value_1;
            ext_config_return = sr130pc10_set_effect(sr1_effect);
            break;

        case EXT_CFG_GET_EXIF_INFO:
            printk("[SR130PC10] EXT_CFG_GET_EXIF_INFO\n");
            sr130pc10_sensor_write(0x03, 0x20);
            sr130pc10_sensor_read(0x80, &exposureTime_value1);
            sr130pc10_sensor_read(0x81, &exposureTime_value2);
            sr130pc10_sensor_read(0x82, &exposureTime_value3);
            // MCLK = 24 MHz. Divide by 24000 to get exposure time in msec.
            exposureTime = ((exposureTime_value1<<19) + (exposureTime_value2<<11) + (exposureTime_value3<<3)) / 24000;
            cfg_data.value_1 = exposureTime;
            printk("[SR130PC10] EXT_CFG_GET_EXIF_INFO: A(%x), B(%x), C(%x)\n", exposureTime_value1, exposureTime_value2, exposureTime_value3);
            printk("[SR130PC10] exposureTime=%d\n", exposureTime);
            break;
         case EXT_CFG_SET_BRIGHTNESS:
         //  printk(KERN_ERR "[CAMDRV/SR130PC10] EXT_CFG_SET_BRIGHTNESS *** ( %d) brightness =%d preview_enable = %d \n",cfg_data.value_1, ,brightness,preview_enable);
			if((brightness == 0) && (preview_enable == 0)){ 
				//Brightness control should be applied only once before preview is enabled
            	ext_config_return = sr130pc10_set_exposure_value(cfg_data.value_1);
         		brightness = 1;
			}
			//P110909-1364 : running camera, control  Brightness, take a shot and then check image in quick view, return to preview 
			//error : there’s difference on brightness before Quick view and after
			//This created a side effect so chaged the condition to  ||  
			if((brightness) || (preview_enable))
				//This enables when the used tries to change the exposure from UI
            	ext_config_return = sr130pc10_set_exposure_value(cfg_data.value_1);

            break;
         case EXT_CFG_SET_FPS_MODE:
         // printk(KERN_ERR "[CAMDRV/SR130PC100] EXT_CFG_SET_FPS_MODE ***(%d %d)\n",cfg_data.cmd,cfg_data.value_1);
            sr130pc10_set_fps_mode(cfg_data.value_1); 
            break;
        case EXT_CFG_SET_WB:
            sr1_whiteBalance = cfg_data.value_1;
            ext_config_return = sr130pc10_set_whitebalance(sr1_whiteBalance);
	    break;

	case EXT_CFG_SET_DTP:
	    printk(KERN_ERR "[SR130PC10] EXT_CFG_SET_DTP (%d %d)\n",cfg_data.cmd,cfg_data.value_1);
	    ext_config_return = sr130pc10_set_dtp(cfg_data.value_1);
	    if(cfg_data.value_1 == 0) {
	        cfg_data.value_2 = 2;
	    } else if(cfg_data.value_1 == 1) {
	        cfg_data.value_2 = 3;
	    }        
	break;

        default: break;
    }

    if(copy_to_user((void *)argp, (const void *)&cfg_data, sizeof(cfg_data)))
        printk("[sr130pc10]%s fail on copy_to_user!\n", __func__);

#if 0
  struct sensor_cfg_data cfg_data;
  long   rc = 0;
  
  unsigned int value_1, value_2, value_3;
  
  if (copy_from_user(&cfg_data, (void *)argp, sizeof(struct sensor_cfg_data)))
    return -EFAULT;*/
  
  /* down(&sr130pc10_sem); */
  
  printk("sr130pc10_ioctl, cfgtype = %d, mode = %d\n", \
          cfg_data.cfgtype, cfg_data.mode);
  
  switch (cfg_data.cfgtype) {
    case CFG_SET_MODE:
    rc = sr130pc10_set_sensor_mode(cfg_data.mode);
    break;
    
    case CFG_SET_EFFECT:
    rc = sr130pc10_set_effect(cfg_data.mode, cfg_data.cfg.effect);
    break;
    
    case CFG_SET_EXPOSURE_VALUE:
    rc = sr130pc10_set_exposure_value(cfg_data.mode, cfg_data.cfg.ev);			
    break;
    
    case CFG_SET_WB:
    rc = sr130pc10_set_whitebalance(cfg_data.mode, cfg_data.cfg.wb);
    break;
    
    case CFG_SET_ROTATION:
    rc = sr130pc10_set_rotation(cfg_data.cfg.rotation);
    break;
    
    
    case CFG_SET_DATALINE_CHECK:
    if(cfg_data.cfg.dataline)
    {
      printk("[SR130PC10] CFG_SET_DATALINE_CHECK ON\n");
      sr130pc10_sensor_write(0x03, 0x00);
      sr130pc10_sensor_write(0x50, 0x05);
      factory_test = 1;                        
    }
    else
    {         
      printk("[SR130PC10] CFG_SET_DATALINE_CHECK OFF \n");
      sr130pc10_sensor_write(0x03, 0x00);
      sr130pc10_sensor_write(0x50, 0x00);
    }                            
    break;
    
    case CFG_GET_AF_MAX_STEPS:
    default:
    //			rc = -EINVAL;
    rc = 0;
    break;
  }
  /* up(&sr130pc10_sem); */
#endif
  
  return ext_config_return;
}
Exemplo n.º 12
0
void sensor_rough_control_sr130pc10(void __user *arg)      
{
	sensor_ext_cfg_data		ctrl_info;
/*
	int Exptime;
	int Expmax;
	unsigned short read_1, read_2, read_3;	
*/
	printk("[SR130PC10] sensor_rough_control\n");

	if(copy_from_user((void *)&ctrl_info, (const void *)arg, sizeof(ctrl_info)))
	{
		printk("<=SR130PC10=> %s fail copy_from_user!\n", __func__);
	}
	printk("<=SR130PC10=> TEST %d %d %d %d %d \n", ctrl_info.cmd, ctrl_info.device_id, ctrl_info.value_1, ctrl_info.value_2, ctrl_info.value_3);


	switch(ctrl_info.cmd)
	{
		case PCAM_CONNECT_CHECK:
                    printk("[SR130PC10] PCAM_CONNECT_CHECK\n");   
                    int rc = 0;
                    rc = sr130pc10_sensor_write(0x03, 0x00);
                    if(rc < 0) //check sensor connection
                    {
                       printk("[SR130PC10] Connect error\n");                       
                       ctrl_info.value_1 = 1;
                    }
                    break;
	
		case PCAM_EXPOSURE_TIME:
                    printk("[SR130PC10] PCAM_EXPOSURE_TIME\n");            
                    sr130pc10_sensor_write(0x03, 0x20);
                    sr130pc10_sensor_read(0x80, &ctrl_info.value_1);
                    sr130pc10_sensor_read(0x81, &ctrl_info.value_2);
                    sr130pc10_sensor_read(0x82, &ctrl_info.value_3);
                    printk("[SR130PC10] PCAM_EXPOSURE_TIME : A(%x), B(%x), C(%x)\n]",ctrl_info.value_1,ctrl_info.value_2,ctrl_info.value_3);
                    break;

		case PCAM_ISO_SPEED:
                    printk("[SR130PC10] PCAM_ISO_SPEED\n");            
                    sr130pc10_sensor_write(0x03, 0x20);
                    sr130pc10_sensor_read(0xb0, &ctrl_info.value_1);
                    break;

		case PCAM_PREVIEW_FPS:
                    printk("[SR130PC10] PCAM_PREVIEW_FPS : %d\n", ctrl_info.device_id);  
                    if(ctrl_info.device_id == 15)
                        sr130pc10_sensor_write_list(sr130pc10_vt_fps_15, sizeof(sr130pc10_vt_fps_15)/sizeof(sr130pc10_vt_fps_15[0]),"sr130pc10_vt_fps_15"); 
                    break;

		default :
			printk("<=SR130PC10=> Unexpected mode on sensor_rough_control!!!\n");
			break;
	}

	if(copy_to_user((void *)arg, (const void *)&ctrl_info, sizeof(ctrl_info)))
	{
		printk("<=SR130PC10=> %s fail on copy_to_user!\n", __func__);
	}
	
}
Exemplo n.º 13
0
int sr130pc10_sensor_config(void __user *argp)
{
	struct sensor_cfg_data cfg_data;
	long rc = 0;

	if (copy_from_user(&cfg_data,
			   (void *)argp, sizeof(struct sensor_cfg_data)))
		return -EFAULT;

	/* down(&sr130pc10_sem); */

	printk(KERN_DEBUG "sr130pc10_ioctl, cfgtype = %d, mode = %d\n",
	       cfg_data.cfgtype, cfg_data.mode);

	switch (cfg_data.cfgtype) {
	case CFG_SET_MODE:
		rc = sr130pc10_set_sensor_mode(cfg_data.mode);
		break;

	case CFG_SET_EFFECT:
		rc = sr130pc10_set_effect(cfg_data.mode, cfg_data.cfg.effect);
		break;

	case CFG_SET_EXPOSURE_VALUE:
		rc = sr130pc10_set_exposure_value(cfg_data.mode,
						  cfg_data.cfg.ev);
		break;

	case CFG_SET_WB:
		rc = sr130pc10_set_whitebalance(cfg_data.mode, cfg_data.cfg.wb);
		break;

	case CFG_SET_ROTATION:
		rc = sr130pc10_set_rotation(cfg_data.cfg.rotation);
		break;

	case CFG_SET_DATALINE_CHECK:
		if (cfg_data.cfg.dataline) {
			printk(KERN_DEBUG
				"[SR130PC10] CFG_SET_DATALINE_CHECK ON\n");
			sr130pc10_sensor_write(0x03, 0x00);
			sr130pc10_sensor_write(0x50, 0x05);
			factory_test = 1;
		} else {
			printk(KERN_DEBUG
				"[SR130PC10] CFG_SET_DATALINE_CHECK OFF\n");
			sr130pc10_sensor_write(0x03, 0x00);
			sr130pc10_sensor_write(0x50, 0x00);
		}
		break;

	case CFG_GET_AF_MAX_STEPS:
	default:
/*                      rc = -EINVAL; */
		rc = 0;
		break;
	}

	/* up(&sr130pc10_sem); */

	return rc;
}