int32_t sr200pc20_sensor_config(struct msm_sensor_ctrl_t *s_ctrl,
	void __user *argp)
{
	struct sensorb_cfg_data *cdata = (struct sensorb_cfg_data *)argp;
	int32_t rc = 0;
	int32_t i = 0;
	mutex_lock(s_ctrl->msm_sensor_mutex);

	CDBG("ENTER %d", cdata->cfgtype);

	switch (cdata->cfgtype) {
	case CFG_GET_SENSOR_INFO:
		CDBG(" CFG_GET_SENSOR_INFO");
		memcpy(cdata->cfg.sensor_info.sensor_name,
			s_ctrl->sensordata->sensor_name,
			sizeof(cdata->cfg.sensor_info.sensor_name));
		cdata->cfg.sensor_info.session_id =
			s_ctrl->sensordata->sensor_info->session_id;
		for (i = 0; i < SUB_MODULE_MAX; i++)
			cdata->cfg.sensor_info.subdev_id[i] =
				s_ctrl->sensordata->sensor_info->subdev_id[i];


		cdata->cfg.sensor_info.is_mount_angle_valid =
			s_ctrl->sensordata->sensor_info->is_mount_angle_valid;
		cdata->cfg.sensor_info.sensor_mount_angle =
			s_ctrl->sensordata->sensor_info->sensor_mount_angle;
		cdata->cfg.sensor_info.position =
			s_ctrl->sensordata->sensor_info->position;
		cdata->cfg.sensor_info.modes_supported =
			s_ctrl->sensordata->sensor_info->modes_supported;

		CDBG("sensor name %s", cdata->cfg.sensor_info.sensor_name);
		CDBG("session id %d", cdata->cfg.sensor_info.session_id);
		for (i = 0; i < SUB_MODULE_MAX; i++)
			CDBG("%s:%d subdev_id[%d] %d", __func__, __LINE__, i,
				cdata->cfg.sensor_info.subdev_id[i]);

		CDBG("mount angle valid %d value %d", cdata->cfg.sensor_info.is_mount_angle_valid,
			cdata->cfg.sensor_info.sensor_mount_angle);

		break;
		case CFG_SET_INIT_SETTING:
			sr200pc20_ctrl.vtcall_mode = 0;
			CDBG("CFG_SET_INIT_SETTING writing INIT registers: sr200pc20_Init_Reg \n");
#if defined(CONFIG_SEC_ROSSA_PROJECT)
			init_setting_write = TRUE;
#endif
			if (cdata->flicker_type == MSM_CAM_FLICKER_50HZ) {
				pr_err("%s : %d 50Hz init setting\n", __func__, __LINE__);
				SR200PC20_WRITE_LIST(sr200pc20_Init_Reg_50hz);
			} else {
				pr_err("%s : %d 60Hz init setting\n", __func__,	__LINE__);
				SR200PC20_WRITE_LIST(sr200pc20_Init_Reg_60hz);
			}

#ifdef CONFIG_SEC_CAMERA_TUNING
		if (front_tune){
			register_table_init(FILENAME);
			pr_err("/data/sr200pc20_yuv.h inside CFG_SET_INIT_SETTING");
		}
#endif
			break;
		case CFG_SET_RESOLUTION:
			resolution = *((int32_t  *)cdata->cfg.setting);
#if defined(CONFIG_MACH_GT5NOTE10_KOR_OPEN)
			if(sr200pc20_ctrl.vtcall_mode) {
				sr200pc20_set_vt_resolution(s_ctrl , resolution , cdata->flicker_type, sr200pc20_ctrl.vtcall_mode);
				break;
			}
#else
			if (sr200pc20_ctrl.prev_mode == CAMERA_MODE_INIT) {
				if (sr200pc20_ctrl.vtcall_mode) {
					if (cdata->flicker_type == MSM_CAM_FLICKER_50HZ) {
						pr_err("%s : %d 50Hz VT init setting\n", __func__, __LINE__);
					SR200PC20_WRITE_LIST(sr200pc20_VT_Init_Reg_50Hz);
					} else {
						pr_err("%s : %d 60Hz VT init setting\n", __func__,	__LINE__);
						SR200PC20_WRITE_LIST(sr200pc20_VT_Init_Reg_60Hz);
					}
				}else {
#if 0
					if (cdata->flicker_type == MSM_CAM_FLICKER_50HZ) {
						pr_err("%s : %d 50Hz init setting\n", __func__, __LINE__);
						SR200PC20_WRITE_LIST(sr200pc20_Init_Reg_50hz);
			                } else {
						pr_err("%s : %d 60Hz init setting\n", __func__,	__LINE__);
						SR200PC20_WRITE_LIST(sr200pc20_Init_Reg_60hz);
			                }
#endif
					CDBG("Init settings");
				}
			}
#endif
			CDBG("CFG_SET_RESOLUTION *** res = %d" , resolution);
			if( sr200pc20_ctrl.op_mode == CAMERA_MODE_RECORDING ) {
				//sr200pc20_set_resolution(s_ctrl , resolution , cdata->flicker_type);
				if (cdata->flicker_type == MSM_CAM_FLICKER_50HZ) {
					pr_err("%s : %d 50Hz 24fps camcorder\n", __func__, __LINE__);
					SR200PC20_WRITE_LIST(sr200pc20_24fps_Camcoder_50hz);
				} else {
					pr_err("%s : %d 60Hz 24fps camcorder\n", __func__, __LINE__);
					SR200PC20_WRITE_LIST(sr200pc20_24fps_Camcoder_60hz);
				}
#if 0
				CDBG("CFG_SET_RESOLUTION recording START recording =1 *** res = %d" , resolution);
				if (cdata->flicker_type == MSM_CAM_FLICKER_50HZ) {
					pr_err("%s : %d 50Hz Auto fps\n", __func__, __LINE__);
					SR200PC20_WRITE_LIST(sr200pc20_Auto_fps_50hz);
				} else {
					pr_err("%s : %d 60Hz Auto fps\n", __func__, __LINE__);
					SR200PC20_WRITE_LIST(sr200pc20_Auto_fps_60hz);
				}

#endif
				sr200pc20_set_effect( s_ctrl , sr200pc20_ctrl.settings.effect);
				sr200pc20_set_white_balance( s_ctrl, sr200pc20_ctrl.settings.wb);
				sr200pc20_set_exposure_compensation( s_ctrl , sr200pc20_ctrl.settings.exposure);
				recording = 1;
			}else{
				if(recording == 1){
					CDBG("CFG_SET_RESOLUTION recording STOP recording =1 *** res = %d" , resolution);
					//sr200pc20_set_resolution(s_ctrl , resolution , cdata->flicker_type);

					if (cdata->flicker_type == MSM_CAM_FLICKER_50HZ) {
						pr_err("%s : %d 50Hz Auto fps\n", __func__, __LINE__);
						SR200PC20_WRITE_LIST(sr200pc20_Auto_fps_50hz);
					} else {
						pr_err("%s : %d 60Hz Auto fps\n", __func__, __LINE__);
						SR200PC20_WRITE_LIST(sr200pc20_Auto_fps_60hz);
					}
					sr200pc20_set_effect( s_ctrl , sr200pc20_ctrl.settings.effect);
					sr200pc20_set_white_balance( s_ctrl, sr200pc20_ctrl.settings.wb);
					sr200pc20_set_exposure_compensation( s_ctrl , sr200pc20_ctrl.settings.exposure);
					sr200pc20_set_resolution(s_ctrl , resolution , cdata->flicker_type);
					recording = 0;
				}else if( sr200pc20_ctrl.prev_mode == CAMERA_MODE_INIT ){
					sr200pc20_set_effect( s_ctrl , sr200pc20_ctrl.settings.effect);
					sr200pc20_set_white_balance( s_ctrl, sr200pc20_ctrl.settings.wb);
					sr200pc20_set_exposure_compensation( s_ctrl , sr200pc20_ctrl.settings.exposure);
					sr200pc20_set_resolution(s_ctrl , resolution , cdata->flicker_type);
					CDBG("CFG_SET_RESOLUTION END *** res = %d" , resolution);
				} else{
					sr200pc20_set_resolution(s_ctrl , resolution , cdata->flicker_type);
					CDBG("CFG_SET_RESOLUTION END *** res = %d" , resolution);
				}
			}
			break;

	case CFG_SET_STOP_STREAM:
		CDBG("CFG_SET_STOP_STREAM");
		if(streamon == 1){
				SR200PC20_WRITE_LIST(sr200pc20_stop_stream);
				rc=0;
				streamon = 0;
		}
		break;
	case CFG_SET_START_STREAM:
		CDBG(" CFG_SET_START_STREAM");
#if 0
		if( sr200pc20_ctrl.op_mode != CAMERA_MODE_CAPTURE){
			sr200pc20_set_effect( s_ctrl , sr200pc20_ctrl.settings.effect);
			sr200pc20_set_white_balance( s_ctrl, sr200pc20_ctrl.settings.wb);
			sr200pc20_set_exposure_compensation( s_ctrl , sr200pc20_ctrl.settings.exposure);
		}
#endif
		streamon = 1;
		break;
	case CFG_SET_SLAVE_INFO: {
		struct msm_camera_sensor_slave_info sensor_slave_info;
		struct msm_camera_power_ctrl_t *p_ctrl;
		uint16_t size;
		int slave_index = 0;
		if (copy_from_user(&sensor_slave_info,
			(void *)cdata->cfg.setting,
				sizeof(sensor_slave_info))) {
			pr_err("%s:%d failed\n", __func__, __LINE__);
			rc = -EFAULT;
			break;
		}
		/* Update sensor slave address */
		if (sensor_slave_info.slave_addr) {
			s_ctrl->sensor_i2c_client->cci_client->sid =
				sensor_slave_info.slave_addr >> 1;
		}

		/* Update sensor address type */
		s_ctrl->sensor_i2c_client->addr_type =
			sensor_slave_info.addr_type;

		/* Update power up / down sequence */
		p_ctrl = &s_ctrl->sensordata->power_info;
		size = sensor_slave_info.power_setting_array.size;
		if (p_ctrl->power_setting_size < size) {
			struct msm_sensor_power_setting *tmp;
			tmp = kmalloc(sizeof(*tmp) * size, GFP_KERNEL);
			if (!tmp) {
				pr_err("%s: failed to alloc mem\n", __func__);
			rc = -ENOMEM;
			break;
			}
			kfree(p_ctrl->power_setting);
			p_ctrl->power_setting = tmp;
		}
		p_ctrl->power_setting_size = size;
		rc = copy_from_user(p_ctrl->power_setting, (void *)
			sensor_slave_info.power_setting_array.power_setting,
			size * sizeof(struct msm_sensor_power_setting));
		if (rc) {
			pr_err("%s:%d failed\n", __func__, __LINE__);
			kfree(sensor_slave_info.power_setting_array.
				power_setting);
			rc = -EFAULT;
			break;
		}
		CDBG("sensor id %x", sensor_slave_info.slave_addr);
		CDBG("sensor addr type %d", sensor_slave_info.addr_type);
		CDBG("sensor reg %x", sensor_slave_info.sensor_id_info.sensor_id_reg_addr);
		CDBG("sensor id %x", sensor_slave_info.sensor_id_info.sensor_id);
		for (slave_index = 0; slave_index <
			p_ctrl->power_setting_size; slave_index++) {
			CDBG("%s i %d power setting %d %d %ld %d", __func__,
				slave_index,
				p_ctrl->power_setting[slave_index].seq_type,
				p_ctrl->power_setting[slave_index].seq_val,
				p_ctrl->power_setting[slave_index].config_val,
				p_ctrl->power_setting[slave_index].delay);
		}
		break;
	}
	case CFG_WRITE_I2C_ARRAY: {
		struct msm_camera_i2c_reg_setting conf_array;
		struct msm_camera_i2c_reg_array *reg_setting = NULL;

		CDBG(" CFG_WRITE_I2C_ARRAY");

		if (copy_from_user(&conf_array,
			(void *)cdata->cfg.setting,
			sizeof(struct msm_camera_i2c_reg_setting))) {
			pr_err("%s:%d failed\n", __func__, __LINE__);
			rc = -EFAULT;
			break;
		}

		reg_setting = kzalloc(conf_array.size *
			(sizeof(struct msm_camera_i2c_reg_array)), GFP_KERNEL);
		if (!reg_setting) {
			pr_err("%s:%d failed\n", __func__, __LINE__);
			rc = -ENOMEM;
			break;
		}
		if (copy_from_user(reg_setting, (void *)conf_array.reg_setting,
			conf_array.size *
			sizeof(struct msm_camera_i2c_reg_array))) {
			pr_err("%s:%d failed\n", __func__, __LINE__);
			kfree(reg_setting);
			rc = -EFAULT;
			break;
		}

		conf_array.reg_setting = reg_setting;
		rc = s_ctrl->sensor_i2c_client->i2c_func_tbl->i2c_write_table(
			s_ctrl->sensor_i2c_client, &conf_array);
		kfree(reg_setting);
		break;
	}
	case CFG_WRITE_I2C_SEQ_ARRAY: {
		struct msm_camera_i2c_seq_reg_setting conf_array;
		struct msm_camera_i2c_seq_reg_array *reg_setting = NULL;

		CDBG("CFG_WRITE_I2C_SEQ_ARRAY");

		if (copy_from_user(&conf_array,
			(void *)cdata->cfg.setting,
			sizeof(struct msm_camera_i2c_seq_reg_setting))) {
			pr_err("%s:%d failed\n", __func__, __LINE__);
			rc = -EFAULT;
			break;
		}

		reg_setting = kzalloc(conf_array.size *
			(sizeof(struct msm_camera_i2c_seq_reg_array)),
			GFP_KERNEL);
		if (!reg_setting) {
			pr_err("%s:%d failed\n", __func__, __LINE__);
			rc = -ENOMEM;
			break;
		}
		if (copy_from_user(reg_setting, (void *)conf_array.reg_setting,
			conf_array.size *
			sizeof(struct msm_camera_i2c_seq_reg_array))) {
			pr_err("%s:%d failed\n", __func__, __LINE__);
			kfree(reg_setting);
			rc = -EFAULT;
			break;
		}

		conf_array.reg_setting = reg_setting;
		rc = s_ctrl->sensor_i2c_client->i2c_func_tbl->
			i2c_write_seq_table(s_ctrl->sensor_i2c_client,
			&conf_array);
		kfree(reg_setting);
		break;
	}

	case CFG_POWER_UP:
		streamon = 0;
		sr200pc20_ctrl.op_mode = CAMERA_MODE_INIT;
		sr200pc20_ctrl.prev_mode = CAMERA_MODE_INIT;
		sr200pc20_ctrl.settings.metering = CAMERA_CENTER_WEIGHT;
		sr200pc20_ctrl.settings.exposure = CAMERA_EV_DEFAULT;
		sr200pc20_ctrl.settings.wb = CAMERA_WHITE_BALANCE_AUTO;
		sr200pc20_ctrl.settings.iso = CAMERA_ISO_MODE_AUTO;
		sr200pc20_ctrl.settings.effect = CAMERA_EFFECT_OFF;
		sr200pc20_ctrl.settings.scenemode = CAMERA_SCENE_AUTO;
		if (s_ctrl->func_tbl->sensor_power_up) {
            CDBG("CFG_POWER_UP");
			rc = s_ctrl->func_tbl->sensor_power_up(s_ctrl);
                } else
			rc = -EFAULT;
		break;

	case CFG_POWER_DOWN:
		 if (s_ctrl->func_tbl->sensor_power_down) {
            CDBG("CFG_POWER_DOWN");
			rc = s_ctrl->func_tbl->sensor_power_down(s_ctrl);
                } else
			rc = -EFAULT;
#ifdef CONFIG_SEC_CAMERA_TUNING
		if (front_tune){
		register_table_exit();
		}
#endif
		break;

	case CFG_SET_STOP_STREAM_SETTING: {
		struct msm_camera_i2c_reg_setting *stop_setting =
			&s_ctrl->stop_setting;
		struct msm_camera_i2c_reg_array *reg_setting = NULL;

		CDBG("CFG_SET_STOP_STREAM_SETTING");

		if (copy_from_user(stop_setting, (void *)cdata->cfg.setting,
		    sizeof(struct msm_camera_i2c_reg_setting))) {
			pr_err("%s:%d failed\n", __func__, __LINE__);
			rc = -EFAULT;
			break;
		}

		reg_setting = stop_setting->reg_setting;
		stop_setting->reg_setting = kzalloc(stop_setting->size *
			(sizeof(struct msm_camera_i2c_reg_array)), GFP_KERNEL);
		if (!stop_setting->reg_setting) {
			pr_err("%s:%d failed\n", __func__, __LINE__);
			rc = -ENOMEM;
			break;
		}
		if (copy_from_user(stop_setting->reg_setting,
		    (void *)reg_setting, stop_setting->size *
		    sizeof(struct msm_camera_i2c_reg_array))) {
			pr_err("%s:%d failed\n", __func__, __LINE__);
			kfree(stop_setting->reg_setting);
			stop_setting->reg_setting = NULL;
			stop_setting->size = 0;
			rc = -EFAULT;
			break;
		}
		break;
	}
	default:
		rc = 0;
		break;
	}
int32_t sr200pc20_sensor_config(struct msm_sensor_ctrl_t *s_ctrl,
                                void __user *argp)
{
    struct sensorb_cfg_data *cdata = (struct sensorb_cfg_data *)argp;
    int32_t rc = 0;
    int32_t i = 0;
    mutex_lock(s_ctrl->msm_sensor_mutex);

    CDBG("ENTER \n ");

    switch (cdata->cfgtype) {
    case CFG_GET_SENSOR_INFO:
        CDBG(" CFG_GET_SENSOR_INFO \n");
        memcpy(cdata->cfg.sensor_info.sensor_name,
               s_ctrl->sensordata->sensor_name,
               sizeof(cdata->cfg.sensor_info.sensor_name));
        cdata->cfg.sensor_info.session_id =
            s_ctrl->sensordata->sensor_info->session_id;
        for (i = 0; i < SUB_MODULE_MAX; i++)
            cdata->cfg.sensor_info.subdev_id[i] =
                s_ctrl->sensordata->sensor_info->subdev_id[i];
        CDBG("%s:%d sensor name %s\n", __func__, __LINE__,
             cdata->cfg.sensor_info.sensor_name);
        CDBG("%s:%d session id %d\n", __func__, __LINE__,
             cdata->cfg.sensor_info.session_id);
        for (i = 0; i < SUB_MODULE_MAX; i++)
            CDBG("%s:%d subdev_id[%d] %d\n", __func__, __LINE__, i,
                 cdata->cfg.sensor_info.subdev_id[i]);

        break;
    case CFG_SET_INIT_SETTING:
        CDBG("CFG_SET_INIT_SETTING writing INIT registers: sr200pc20_Init_Reg \n");
        rc = s_ctrl->sensor_i2c_client->i2c_func_tbl->
             i2c_write_conf_tbl(
                 s_ctrl->sensor_i2c_client, sr200pc20_Init_Reg,
                 ARRAY_SIZE(sr200pc20_Init_Reg),
                 MSM_CAMERA_I2C_BYTE_DATA);

        break;
    case CFG_SET_RESOLUTION:
        resolution = *((int32_t  *)cdata->cfg.setting);
        CDBG("CFG_SET_RESOLUTION  res = %d\n " , resolution);
        break;
    case CFG_SET_STOP_STREAM:
        if(streamon == 1) {
            /*	CDBG(" CFG_SET_STOP_STREAM writing stop stream registers: sr200pc20_stop_stream \n");
            		rc = s_ctrl->sensor_i2c_client->i2c_func_tbl->
            			i2c_write_conf_tbl(
            			s_ctrl->sensor_i2c_client, sr200pc20_stop_stream,
            			ARRAY_SIZE(sr200pc20_stop_stream),
            			MSM_CAMERA_I2C_BYTE_DATA);*/
            rc=0;   //eunice
            streamon = 0;
        }
        break;
    case CFG_SET_START_STREAM:
        CDBG(" CFG_SET_START_STREAM writing start stream registers: sr200pc20_start_stream start   \n");
        sr200pc20_set_effect( s_ctrl , sr200pc20_ctrl.settings.effect);
        sr200pc20_set_white_balance( s_ctrl, sr200pc20_ctrl.settings.wb);
        sr200pc20_set_exposure_compensation( s_ctrl , sr200pc20_ctrl.settings.exposure );
        sr200pc20_set_resolution(s_ctrl , resolution );
        streamon = 1;
        CDBG("CFG_SET_START_STREAM : sr200pc20_start_stream rc = %d \n", rc);
        break;
    case CFG_SET_SLAVE_INFO: {
        struct msm_camera_sensor_slave_info sensor_slave_info;
        struct msm_camera_power_ctrl_t *p_ctrl;
        uint16_t size;
        int slave_index = 0;
        if (copy_from_user(&sensor_slave_info,
                           (void *)cdata->cfg.setting,
                           sizeof(sensor_slave_info))) {
            pr_err("%s:%d failed\n", __func__, __LINE__);
            rc = -EFAULT;
            break;
        }
        /* Update sensor slave address */
        if (sensor_slave_info.slave_addr) {
            s_ctrl->sensor_i2c_client->cci_client->sid =
                sensor_slave_info.slave_addr >> 1;
        }

        /* Update sensor address type */
        s_ctrl->sensor_i2c_client->addr_type =
            sensor_slave_info.addr_type;

        /* Update power up / down sequence */
        p_ctrl = &s_ctrl->sensordata->power_info;
        size = sensor_slave_info.power_setting_array.size;
        if (p_ctrl->power_setting_size < size) {
            struct msm_sensor_power_setting *tmp;
            tmp = kmalloc(sizeof(*tmp) * size, GFP_KERNEL);
            if (!tmp) {
                pr_err("%s: failed to alloc mem\n", __func__);
                rc = -ENOMEM;
                break;
            }
            kfree(p_ctrl->power_setting);
            p_ctrl->power_setting = tmp;
        }
        p_ctrl->power_setting_size = size;
        rc = copy_from_user(p_ctrl->power_setting, (void *)
                            sensor_slave_info.power_setting_array.power_setting,
                            size * sizeof(struct msm_sensor_power_setting));
        if (rc) {
            pr_err("%s:%d failed\n", __func__, __LINE__);
            kfree(sensor_slave_info.power_setting_array.
                  power_setting);
            rc = -EFAULT;
            break;
        }
        CDBG("%s sensor id %x\n", __func__,
             sensor_slave_info.slave_addr);
        CDBG("%s sensor addr type %d\n", __func__,
             sensor_slave_info.addr_type);
        CDBG("%s sensor reg %x\n", __func__,
             sensor_slave_info.sensor_id_info.sensor_id_reg_addr);
        CDBG("%s sensor id %x\n", __func__,
             sensor_slave_info.sensor_id_info.sensor_id);
        for (slave_index = 0; slave_index <
                p_ctrl->power_setting_size; slave_index++) {
            CDBG("%s i %d power setting %d %d %ld %d\n", __func__,
                 slave_index,
                 p_ctrl->power_setting[slave_index].seq_type,
                 p_ctrl->power_setting[slave_index].seq_val,
                 p_ctrl->power_setting[slave_index].config_val,
                 p_ctrl->power_setting[slave_index].delay);
        }
        break;
    }
    case CFG_WRITE_I2C_ARRAY: {
        struct msm_camera_i2c_reg_setting conf_array;
        struct msm_camera_i2c_reg_array *reg_setting = NULL;

        CDBG(" CFG_WRITE_I2C_ARRAY  \n");

        if (copy_from_user(&conf_array,
                           (void *)cdata->cfg.setting,
                           sizeof(struct msm_camera_i2c_reg_setting))) {
            pr_err("%s:%d failed\n", __func__, __LINE__);
            rc = -EFAULT;
            break;
        }

        reg_setting = kzalloc(conf_array.size *
                              (sizeof(struct msm_camera_i2c_reg_array)), GFP_KERNEL);
        if (!reg_setting) {
            pr_err("%s:%d failed\n", __func__, __LINE__);
            rc = -ENOMEM;
            break;
        }
        if (copy_from_user(reg_setting, (void *)conf_array.reg_setting,
                           conf_array.size *
                           sizeof(struct msm_camera_i2c_reg_array))) {
            pr_err("%s:%d failed\n", __func__, __LINE__);
            kfree(reg_setting);
            rc = -EFAULT;
            break;
        }

        conf_array.reg_setting = reg_setting;
        rc = s_ctrl->sensor_i2c_client->i2c_func_tbl->i2c_write_table(
                 s_ctrl->sensor_i2c_client, &conf_array);
        kfree(reg_setting);
        break;
    }
    case CFG_WRITE_I2C_SEQ_ARRAY: {
        struct msm_camera_i2c_seq_reg_setting conf_array;
        struct msm_camera_i2c_seq_reg_array *reg_setting = NULL;

        CDBG("CFG_WRITE_I2C_SEQ_ARRAY  \n");

        if (copy_from_user(&conf_array,
                           (void *)cdata->cfg.setting,
                           sizeof(struct msm_camera_i2c_seq_reg_setting))) {
            pr_err("%s:%d failed\n", __func__, __LINE__);
            rc = -EFAULT;
            break;
        }

        reg_setting = kzalloc(conf_array.size *
                              (sizeof(struct msm_camera_i2c_seq_reg_array)),
                              GFP_KERNEL);
        if (!reg_setting) {
            pr_err("%s:%d failed\n", __func__, __LINE__);
            rc = -ENOMEM;
            break;
        }
        if (copy_from_user(reg_setting, (void *)conf_array.reg_setting,
                           conf_array.size *
                           sizeof(struct msm_camera_i2c_seq_reg_array))) {
            pr_err("%s:%d failed\n", __func__, __LINE__);
            kfree(reg_setting);
            rc = -EFAULT;
            break;
        }

        conf_array.reg_setting = reg_setting;
        rc = s_ctrl->sensor_i2c_client->i2c_func_tbl->
             i2c_write_seq_table(s_ctrl->sensor_i2c_client,
                                 &conf_array);
        kfree(reg_setting);
        break;
    }

    case CFG_POWER_UP:
        CDBG(" CFG_POWER_UP  \n");
        streamon = 0;
        sr200pc20_ctrl.op_mode = CAMERA_MODE_INIT;
        sr200pc20_ctrl.prev_mode = CAMERA_MODE_INIT;
        sr200pc20_ctrl.settings.metering = CAMERA_CENTER_WEIGHT;
        sr200pc20_ctrl.settings.exposure = CAMERA_EV_DEFAULT;
        sr200pc20_ctrl.settings.wb = CAMERA_WHITE_BALANCE_AUTO;
        sr200pc20_ctrl.settings.iso = CAMERA_ISO_MODE_AUTO;
        sr200pc20_ctrl.settings.effect = CAMERA_EFFECT_OFF;
        sr200pc20_ctrl.settings.scenemode = CAMERA_SCENE_AUTO;
        if (s_ctrl->func_tbl->sensor_power_up) {
            CDBG("CFG_POWER_UP");
            rc = s_ctrl->func_tbl->sensor_power_up(s_ctrl,
                                                   &s_ctrl->sensordata->power_info,
                                                   s_ctrl->sensor_i2c_client,
                                                   s_ctrl->sensordata->slave_info,
                                                   s_ctrl->sensordata->sensor_name);
        } else
            rc = -EFAULT;
        break;

    case CFG_POWER_DOWN:
        CDBG("CFG_POWER_DOWN  \n");
        if (s_ctrl->func_tbl->sensor_power_down) {
            CDBG("CFG_POWER_DOWN");
            rc = s_ctrl->func_tbl->sensor_power_down(
                     s_ctrl,
                     &s_ctrl->sensordata->power_info,
                     s_ctrl->sensor_device_type,
                     s_ctrl->sensor_i2c_client);
        } else
            rc = -EFAULT;
        break;

    case CFG_SET_STOP_STREAM_SETTING: {
        struct msm_camera_i2c_reg_setting *stop_setting =
                &s_ctrl->stop_setting;
        struct msm_camera_i2c_reg_array *reg_setting = NULL;

        CDBG("CFG_SET_STOP_STREAM_SETTING  \n");

        if (copy_from_user(stop_setting, (void *)cdata->cfg.setting,
                           sizeof(struct msm_camera_i2c_reg_setting))) {
            pr_err("%s:%d failed\n", __func__, __LINE__);
            rc = -EFAULT;
            break;
        }

        reg_setting = stop_setting->reg_setting;
        stop_setting->reg_setting = kzalloc(stop_setting->size *
                                            (sizeof(struct msm_camera_i2c_reg_array)), GFP_KERNEL);
        if (!stop_setting->reg_setting) {
            pr_err("%s:%d failed\n", __func__, __LINE__);
            rc = -ENOMEM;
            break;
        }
        if (copy_from_user(stop_setting->reg_setting,
                           (void *)reg_setting, stop_setting->size *
                           sizeof(struct msm_camera_i2c_reg_array))) {
            pr_err("%s:%d failed\n", __func__, __LINE__);
            kfree(stop_setting->reg_setting);
            stop_setting->reg_setting = NULL;
            stop_setting->size = 0;
            rc = -EFAULT;
            break;
        }
        break;
    }
    default:
        rc = 0;
        break;
    }