コード例 #1
0
static int __init
altek6045_init_module(void)
{
    int ret = 0;

    cam_notice("%s enter", __func__);

    ret = platform_driver_probe(&s_altek6045_driver,
                                altek6045_platform_probe);

    /* NOTE: use driver attribute */
    if (ret == 0) {
        if (driver_create_file(&s_altek6045_driver.driver, &driver_attr_test_pipe))
            cam_warn("%s create driver attr failed", __func__);
        if (driver_create_file(&s_altek6045_driver.driver, &driver_attr_ois_pixel))
            cam_warn("%s create driver attr failed", __func__);
        if (driver_create_file(&s_altek6045_driver.driver, &driver_attr_test_ois))
            cam_warn("%s create driver attr failed", __func__);
        if (driver_create_file(&s_altek6045_driver.driver, &driver_attr_check_ois))
            cam_warn("%s create driver attr failed", __func__);
        if (driver_create_file(&s_altek6045_driver.driver, &driver_attr_firmware))
            cam_warn("%s create driver attr firmware failed", __func__);
    }
    //init queue
    init_waitqueue_head(&ois_queue);

    return ret;
}
コード例 #2
0
static int tps61310_flash_mode(struct hisi_flash_ctrl_t *flash_ctrl,
	int data)
{
	struct hisi_flash_i2c_client *i2c_client;
	struct hisi_flash_i2c_fn_t *i2c_func;
	struct tps61310_private_data_t *pdata;
	unsigned char val;

	cam_info("%s data=%d.\n", __func__, data);

	if (NULL == flash_ctrl) {
		cam_err("%s flash_ctrl is NULL.", __func__);
		return -1;
	}

	i2c_client = flash_ctrl->flash_i2c_client;
	i2c_func = flash_ctrl->flash_i2c_client->i2c_func_tbl;
	pdata = flash_ctrl->pdata;

	/* set LED1/2/3 Flash current value */
	if (data < pdata->flash_led2_num) {
		cam_debug("%s flash_led2=0x%x.", __func__, pdata->flash_led2[data]);
		i2c_func->i2c_write(i2c_client, REGISTER1,
			pdata->flash_led2[data] | FLASH_MODE_CTRL);
	} else {
		cam_warn("%s data(%d) > flash_led2_num(%d).", __func__,
			data, pdata->flash_led2_num);
		i2c_func->i2c_write(i2c_client, REGISTER1,
			pdata->flash_led2[pdata->flash_led2_num-1] | FLASH_MODE_CTRL);
	}

	if (data < pdata->flash_led13_num) {
		i2c_func->i2c_write(i2c_client, REGISTER2,
			pdata->flash_led13[data] | FLASH_MODE_CTRL);

	} else {
		cam_warn("%s data(%d) > flash_led13_num(%d).", __func__,
			data, pdata->flash_led13_num);
		i2c_func->i2c_write(i2c_client, REGISTER2,
			pdata->flash_led13[pdata->flash_led13_num-1] | FLASH_MODE_CTRL);
	}

	/* set start flash timer bit */
	i2c_func->i2c_read(i2c_client, REGISTER3, &val);
	i2c_func->i2c_write(i2c_client, REGISTER3, val | FLASH_SFT);

	/* start flash mode */
	tps61310_set_strobe1(flash_ctrl, LOW);
	tps61310_set_strobe0(flash_ctrl, HIGH);

	return 0;
}
コード例 #3
0
ファイル: sr200pc20-p2.c プロジェクト: ARMP/ARMP-i9300
/*
 * sr200pc20_probe
 * Fetching platform data is being done with s_config subdev call.
 * In probe routine, we just register subdev device
 */
static int sr200pc20_probe(struct i2c_client *client,
		const struct i2c_device_id *id)
{
	struct sr200pc20_state *state = NULL;
	struct v4l2_subdev *sd = NULL;
	int err = 0;

	cam_dbg("E\n");

	state = kzalloc(sizeof(struct sr200pc20_state), GFP_KERNEL);
	if (state == NULL)
		return -ENOMEM;

	sd = &state->sd;
	strcpy(sd->name, SR200PC20_DRIVER_NAME);

	/* Registering subdev */
	v4l2_i2c_subdev_init(sd, client, &sr200pc20_ops);

	err = sr200pc20_s_config(sd, 0, client->dev.platform_data);
	CHECK_ERR_MSG(err, "fail to s_config\n");

	if (device_create_file(&client->dev, &dev_attr_camera_type) < 0) {
		cam_warn("failed to create device file, %s\n",
				dev_attr_camera_type.attr.name);
	}
	cam_dbg("probed!!\n");

	return 0;
}
コード例 #4
0
static int s5k5bbgx_control_stream(struct v4l2_subdev *sd, stream_cmd_t cmd)
{
	int err = 0;

	switch (cmd) {
	case STREAM_START:
		cam_warn("WARN: do nothing\n");
		break;

	case STREAM_STOP:
		cam_dbg("stream stop!!!\n");
#if 0
#ifdef CONFIG_LOAD_FILE
		err = s5k5bbgx_write_regs_from_sd(sd, "s5k5bbgx_stream_stop");
#else
		err = s5k5bbgx_write_regs(sd, s5k5bbgx_stream_stop,
			sizeof(s5k5bbgx_stream_stop) / \
			sizeof(s5k5bbgx_stream_stop[0]));
#endif
#endif
		break;
	default:
		cam_err("ERR: Invalid cmd\n");
		break;
	}

	if (unlikely(err))
		cam_err("failed to stream start(stop)\n");

	return err;
}
コード例 #5
0
ファイル: sr200pc20.c プロジェクト: Ante0/xxICSKernel
static int sr200pc20_check_sensor_status(struct v4l2_subdev *sd)
{

	/*struct i2c_client *client = v4l2_get_subdevdata(sd);*/
	/*u16 val_1 = 0, val_2 = 0;
	int err = -EINVAL; */

#if 1 /* DSLIM */
	cam_warn("check_sensor_status: WARNING, Not implemented!!\n\n");
	return 0;
#else

	err = sr200pc20_read_reg(sd, 0x7000, 0x0132, &val_1);
	CHECK_ERR(err);
	err = sr200pc20_read_reg(sd, 0xD000, 0x1002, &val_2);
	CHECK_ERR(err);

	cam_dbg("read val1=0x%x, val2=0x%x\n", val_1, val_2);

	if ((val_1 != 0xAAAA) || (val_2 != 0))
		goto error_occur;

	cam_info("Sensor ESD Check: not detected\n");
	return 0;
#endif
error_occur:
	cam_err("%s: ERROR, ESD Shock detected!\n\n", __func__);
	return -ERESTART;
}
コード例 #6
0
static int sr200_set_sensor_mode(struct v4l2_subdev *subdev, s32 val)
{
	struct sr200_state *state = to_state(subdev);

	cam_info("mode=%d\n", val);

	switch (val) {
	case SENSOR_MOVIE:
		/* We does not support movie mode when in VT. */
		if (state->vt_mode) {
			state->sensor_mode = SENSOR_CAMERA;
			cam_warn("%s: error, Not support movie\n", __func__);
		} else {
			state->sensor_mode = SENSOR_MOVIE;
		}
		break;
	case SENSOR_CAMERA:
		state->sensor_mode = SENSOR_CAMERA;
		break;

	default:
		cam_err("%s: error, Not support.(%d)\n", __func__, val);
		state->sensor_mode = SENSOR_CAMERA;
		break;
	}

	return 0;
}
コード例 #7
0
static int s5k5bbgx_check_dataline_stop(struct v4l2_subdev *sd)
{
	struct i2c_client *client = v4l2_get_subdevdata(sd);
	struct s5k5bbgx_state *state = to_state(sd);
	int err = -EINVAL;

	extern int s5k5bbgx_power_reset(void);

	cam_warn("Warning: do nothing!!\n");
	return err;


	//s5k5bbgx_write(client, 0xFCFCD000);
	//s5k5bbgx_write(client, 0x0028D000);
	//s5k5bbgx_write(client, 0x002A3100);
    	//s5k5bbgx_write(client, 0x0F120000);

   //	err =  s5k5bbgx_write_regs(sd, s5k5bbgx_pattern_off,	sizeof(s5k5bbgx_pattern_off) / sizeof(s5k5bbgx_pattern_off[0]));
	printk("%s: sensor reset\n", __func__);
#if defined(CONFIG_TARGET_LOCALE_KOR) || defined(CONFIG_TARGET_LOCALE_EUR) || defined(CONFIG_TARGET_LOCALE_HKTW) || defined(CONFIG_TARGET_LOCALE_HKTW_FET) || defined(CONFIG_TARGET_LOCALE_USAGSM)
        // dont't know where this code came from - comment out for compile error
        // s5k5bbgx_power_reset();
 #endif
	cam_dbg("load camera init setting\n");
	err =  s5k5bbgx_write_regs(sd, s5k5bbgx_common,	sizeof(s5k5bbgx_common) / sizeof(s5k5bbgx_common[0]));

	state->check_dataline = 0;
	/* mdelay(100); */
	return err;
}
コード例 #8
0
static int sr130pc10_check_dataline_stop(struct v4l2_subdev *sd)
{
	struct i2c_client *client = v4l2_get_subdevdata(sd);
	struct sr130pc10_state *state = to_state(sd);
	int err = -EINVAL;

	extern int sr130pc10_power_reset(void);

	cam_warn("Warning: do nothing!!\n");
	return err;

	//sr130pc10_write(client, 0xFCFCD000);
	//sr130pc10_write(client, 0x0028D000);
	//sr130pc10_write(client, 0x002A3100);
	//sr130pc10_write(client, 0x0F120000);

	//	err =  sr130pc10_write_regs(sd, sr130pc10_pattern_off,	sizeof(sr130pc10_pattern_off) / sizeof(sr130pc10_pattern_off[0]));
	cam_dbg("sensor reset\n");
#if defined(CONFIG_TARGET_LOCALE_KOR) || defined(CONFIG_TARGET_LOCALE_EUR) || defined(CONFIG_TARGET_LOCALE_HKTW) || defined(CONFIG_TARGET_LOCALE_HKTW_FET) || defined(CONFIG_TARGET_LOCALE_USAGSM)
        // dont't know where this code came from - comment out for compile error
        // sr130pc10_power_reset();
 #endif
	cam_dbg("load camera init setting\n");
	err = sr130pc10_i2c_set_config_register(client,
								   front_init_regs,
								   INIT_NUM_OF_REGS,
								   "front_init_regs");
	state->check_dataline = 0;
	/* mdelay(100); */
	return err;
}
コード例 #9
0
static int tps61310_torch_mode(struct hisi_flash_ctrl_t *flash_ctrl,
	int data)
{
	struct hisi_flash_i2c_client *i2c_client;
	struct hisi_flash_i2c_fn_t *i2c_func;
	struct tps61310_private_data_t *pdata;
	unsigned char val;

	cam_info("%s data=%d.\n", __func__, data);

	if (NULL == flash_ctrl) {
		cam_err("%s flash_ctrl is NULL.", __func__);
		return -1;
	}

	i2c_client = flash_ctrl->flash_i2c_client;
	i2c_func = flash_ctrl->flash_i2c_client->i2c_func_tbl;
	pdata = (struct tps61310_private_data_t *)flash_ctrl->pdata;

	/*******************************************************
	 * TPS61310 REGISTER0[5:3] control LED1/3 tourch current,
	 * TPS61310 REGISTER0[2:0] control LED2 tourch current,
	 *******************************************************/
	if ((data < pdata->torch_led13_num) && (data < pdata->torch_led2_num)) {
		val = (((pdata->torch_led13[data] & 0x7) << 3)
			| (pdata->torch_led2[data] & 0x7));
		cam_debug("%s torch_led13=0x%x, torch_led2=0x%x.", __func__,
			pdata->torch_led13[data], pdata->torch_led2[data]);
	} else {
		cam_warn("%s data(%d) > torch_led13_num(%d) or torch_led2_num(%d)",
			__func__, data, pdata->torch_led13_num, pdata->torch_led2_num);
		val = (((pdata->torch_led13[pdata->torch_led13_num-1] & 0x7) << 3)
			| (pdata->torch_led2[pdata->torch_led2_num-1] & 0x7));
	}

	i2c_func->i2c_write(i2c_client, REGISTER0, val);

	i2c_func->i2c_read(i2c_client, REGISTER1, &val);
	i2c_func->i2c_write(i2c_client, REGISTER1, (val & MODE_CTRL_SHUTDONW) | TORCH_MODE_CTRL);
	i2c_func->i2c_read(i2c_client, REGISTER2, &val);
	i2c_func->i2c_write(i2c_client, REGISTER2, (val & MODE_CTRL_SHUTDONW) | TORCH_MODE_CTRL);

	/* start tourch mode */
	tps61310_set_strobe1(flash_ctrl, HIGH);
	tps61310_set_strobe0(flash_ctrl, HIGH);
	return 0;
}
コード例 #10
0
static int sr200_set_preview_size(struct v4l2_subdev *subdev)
{
	struct sr200_state *state = to_state(subdev);
	int err = 0;

	u32 width, height;

	if (!state->preview.update_frmsize)
		return 0;

	if (unlikely(!state->preview.frmsize)) {
		cam_warn("warning, preview resolution not set\n");
		state->preview.frmsize = sr200_get_framesize(
					sr200_preview_frmsizes,
					ARRAY_SIZE(sr200_preview_frmsizes),
					PREVIEW_SZ_SVGA);
	}

	width = state->preview.frmsize->width;
	height = state->preview.frmsize->height;

	cam_info("set preview size(%dx%d)\n", width, height);

	if (state->sensor_mode == SENSOR_MOVIE) {
		if(width == 352 && height == 288) {
			err = sensor_sr200_apply_set(subdev, "sr200_resol_352_288", &sr200_regset_table.resol_352_288);
		} else {
			/*err = sensor_sr200_apply_set(subdev, "sr200_resol_640_480", &sr200_regset_table.resol_640_480);*/
			/*CHECK_ERR_MSG(err, "fail to set preview size\n");*/
			cam_info("MOVIE Mode : skip preview size\n");
		}
	} else {
		if(width == 352 && height == 288) { /* VT Preview size */
			err = sensor_sr200_apply_set(subdev, "sr200_Init_VT_Reg", &sr200_regset_table.init_vt);
			CHECK_ERR_MSG(err, "fail to set VT init\n");
			err = sensor_sr200_apply_set(subdev, "sr200_resol_352_288", &sr200_regset_table.resol_352_288);
		} else {
			err = sensor_sr200_apply_set(subdev, "sr200_resol_800_600", &sr200_regset_table.resol_800_600);
		}
	}
	CHECK_ERR_MSG(err, "fail to set preview size\n");

	state->preview.update_frmsize = 0;

	return 0;
}
コード例 #11
0
ファイル: lm3642.c プロジェクト: herryfan/kernel-huawei-h60
static int hw_lm3642_flash_mode(struct hw_flash_ctrl_t *flash_ctrl,
	int data)
{
	struct hw_flash_i2c_client *i2c_client;
	struct hw_flash_i2c_fn_t *i2c_func;
	struct hw_lm3642_private_data_t *pdata;
	unsigned char val;

	cam_debug("%s data=%d.\n", __func__, data);
	cam_info("%s 220250 data=%d.\n", __func__, data);
	if (NULL == flash_ctrl) {
		cam_err("%s flash_ctrl is NULL.", __func__);
		return -1;
	}

	i2c_client = flash_ctrl->flash_i2c_client;
	i2c_func = flash_ctrl->flash_i2c_client->i2c_func_tbl;
	pdata = flash_ctrl->pdata;

	/* clear error flag,resume chip */
	i2c_func->i2c_read(i2c_client, REG_FLAGS, &val);
	i2c_func->i2c_read(i2c_client, REG_CURRENT_CONTROL, &val);

	/* set LED Flash current value */
	if (data < pdata->flash_led_num) {
		cam_info("%s flash_led=0x%x.", __func__,
			pdata->flash_led[data]);
		/* REG_CURRENT_CONTROL[3:0] control flash current */
		val = ((val & 0xf0) | (pdata->flash_led[data] & 0x0f));

	} else {
		cam_warn("%s data(%d) > flash_led_num(%d).", __func__,
			data, pdata->flash_led_num);
		/* REG_CURRENT_CONTROL[3:0] control flash current */
		val = ((val & 0xf0) | (pdata->flash_led[pdata->flash_led_num-1] & 0x0f));
	}

	i2c_func->i2c_write(i2c_client, REG_CURRENT_CONTROL, val);
	if (flash_ctrl->flash_mask_enable) {
		i2c_func->i2c_write(i2c_client, REG_ENABLE, MODE_FLASH|TX_PIN);
	} else {
		i2c_func->i2c_write(i2c_client, REG_ENABLE, MODE_FLASH);
	}

	return 0;
}
コード例 #12
0
static int sensor_sr200_g_ext_ctrls(struct v4l2_subdev *subdev, struct v4l2_ext_controls *ctrls)
{
	struct v4l2_ext_control *ctrl = ctrls->controls;
	int ret = 0;

	switch (ctrl->id) {
	case V4L2_CID_CAM_SENSOR_FW_VER:
		strcpy(ctrl->string, SENSOR_VER);
		cam_dbg("V4L2_CID_CAM_SENSOR_FW_VER :%s\n", ctrl->string);
		break;
	default:
		cam_warn("g_ext_ctrl : invalid ioctl(0x%08X) is requested", ctrl->id);
		break;
	}

	return ret;
}
コード例 #13
0
static int hw_lm3646_front_flash_mode(struct hw_flash_ctrl_t *flash_ctrl,
    int data)
{
    struct hw_flash_i2c_client *i2c_client;
    struct hw_flash_i2c_fn_t *i2c_func;
    struct hw_lm3646_front_private_data_t *pdata;
    unsigned char val;

    cam_info("%s data=%d.\n", __func__, data);
    if (NULL == flash_ctrl) {
        cam_err("%s flash_ctrl is NULL.", __func__);
        return -1;
    }

    i2c_client = flash_ctrl->flash_i2c_client;
    i2c_func = flash_ctrl->flash_i2c_client->i2c_func_tbl;
    pdata = flash_ctrl->pdata;

    /* clear error flag,resume chip */
    i2c_func->i2c_read(i2c_client, REG_FLAGS1, &val);
    i2c_func->i2c_read(i2c_client, REG_FLAGS2, &val);
    i2c_func->i2c_read(i2c_client, REG_LED1_FLASH_CURRENT_CONTROL, &val);

    /* set LED Flash current value */
    if (data < FLASH_LED_MAX) {
        cam_info("%s flash_led=0x%x.", __func__,
        pdata->flash_led[data]);
        /* REG_CURRENT_CONTROL[3:0] control flash current */
        val = ((val & 0x80) | (data & 0x7f));
    } else {
        cam_warn("%s data(%d) > flash_led_num(%d).", __func__,
        data, pdata->flash_led_num);
        /* REG_CURRENT_CONTROL[3:0] control flash current */
        val = ((val & 0x80) | (0x7f));
    }
    i2c_func->i2c_write(i2c_client, REG_MAX_CURRENT, 0x7c);
    i2c_func->i2c_write(i2c_client, REG_LED1_FLASH_CURRENT_CONTROL, 0x22);
    if (flash_ctrl->flash_mask_enable) {
        i2c_func->i2c_write(i2c_client, REG_ENABLE, 0xd3);
    } else {
        i2c_func->i2c_write(i2c_client, REG_ENABLE, 0xd3);
    }

    return 0;
}
コード例 #14
0
static int pmu_led_flash_mode(struct hisi_flash_ctrl_t *flash_ctrl,
	int data)
{
	struct pmu_led_private_data_t *pdata;

	cam_debug("%s data=%d.\n", __func__, data);

	if (NULL == flash_ctrl) {
		cam_err("%s flash_ctrl is NULL.", __func__);
		return -1;
	}

	pum_led_flash_on = true;
	//hi6401_set_gain_for_flashlight(true);

	pdata = (struct pmu_led_private_data_t *)flash_ctrl->pdata;

	pmu_led_write(LED_CTRL1, pdata->led_ctrl_flash[LED_CTRL_1]);
	pmu_led_write(LED_CTRL2, pdata->led_ctrl_flash[LED_CTRL_2]);
	pmu_led_write(LED_CTRL3, pdata->led_ctrl_flash[LED_CTRL_3]);

	/* set LED Flash current value */
	if (data < pdata->flash_led_num) {
		cam_debug("%s flash_led=0x%x.", __func__,
			pdata->flash_led[data]);
		pmu_led_write(LED_CTRL4, (pdata->flash_led[data] & 0x0f));
	} else {
		cam_warn("%s data(%d) > flash_led_num(%d).", __func__,
			data, pdata->flash_led_num);
		pmu_led_write(LED_CTRL4, (pdata->flash_led[pdata->flash_led_num-1] & 0x0f));
	}

	pmu_led_write(LED_CTRL5, pdata->led_ctrl_flash[LED_CTRL_5]);
	if (flash_ctrl->flash_mask_enable) {
		pmu_led_write(LED_CTRL6, (pdata->led_ctrl_flash[LED_CTRL_6] & 0xf7));
	} else {
		pmu_led_write(LED_CTRL6, (pdata->led_ctrl_flash[LED_CTRL_6] | 0x8));
	}

	pmu_led_write(LED_CTRL7, pdata->led_ctrl_flash[LED_CTRL_7]);

	pmu_led_write(LED_CTRL2, LED_FLASH_ENABLE);

	return 0;
}
コード例 #15
0
static int __init 
altek6045_init_module(void)
{
	int ret = 0;

	cam_notice("%s enter", __func__);

	ret = platform_driver_probe(&s_altek6045_driver,
			altek6045_platform_probe);

	/* NOTE: use driver attribute */
	if (ret == 0) {
		if (driver_create_file(&s_altek6045_driver.driver, &driver_attr_test_pipe))
			cam_warn("%s create driver attr failed", __func__);
	}

	return ret;
}
コード例 #16
0
static ssize_t altel6045_check_ois_show(struct device_driver *drv,
                                        char *buf)
{
    int ret = -1;
    char *offset = buf;

    cam_info("Enter: %s", __func__);
    ois_check = 0;
    //wait for start command
    msleep(50);
    ret = wait_event_interruptible_timeout(ois_queue, ois_check != 0, OIS_TEST_TIMEOUT);
    if(ret <= 0) {
        cam_warn("%s: wait ois signal timeout", __func__);
    }
    ret = snprintf(offset, PAGE_SIZE, "%d", ois_check);
    offset += ret;

    return (offset - buf);
}
コード例 #17
0
static int sr130pc10_set_sensor_mode(struct v4l2_subdev *sd,
					struct v4l2_control *ctrl)
{
	struct sr130pc10_state *state = to_state(sd);

	if ((ctrl->value != SENSOR_CAMERA) &&
	(ctrl->value != SENSOR_MOVIE)) {
		cam_err("ERR: Not support.(%d)\n", ctrl->value);
		return -EINVAL;
	}

	/* We does not support movie mode when in VT. */
	if ((ctrl->value == SENSOR_MOVIE) && state->vt_mode) {
		state->sensor_mode = SENSOR_CAMERA;
		cam_warn("ERR: Not support movie\n");
	} else
		state->sensor_mode = ctrl->value;

	return 0;
}
コード例 #18
0
static int sr200_set_capture_size(struct v4l2_subdev *subdev)
{
	struct sr200_state *state = to_state(subdev);

	u32 width, height;
	int err = 0;

	cam_info("%s - E\n",__func__);

	if (unlikely(!state->capture.frmsize)) {
		cam_warn("warning, capture resolution not set\n");
		state->capture.frmsize = sr200_get_framesize(
					sr200_capture_frmsizes,
					ARRAY_SIZE(sr200_capture_frmsizes),
					CAPTURE_SZ_1MP);
	}

	width = state->capture.frmsize->width;
	height = state->capture.frmsize->height;
	state->preview.update_frmsize = 1;

	/* Transit to capture mode */
	if (state->capture.lowlux_night) {
		cam_info("capture_mode: night lowlux\n");
	/*	err = sensor_sr200_apply_set(client, &sr200_regset_table.lowcapture);*/
	}

	cam_info("%s - width * height = %d * %d \n",__func__, width, height);
	if(width == 1600 && height == 1200)
		err = sensor_sr200_apply_set(subdev, "sr200_resol_1600_1200", &sr200_regset_table.resol_1600_1200);
	else if(width == 1280 && height == 960)
		err = sensor_sr200_apply_set(subdev, "sr200_resol_1280_960", &sr200_regset_table.resol_1280_960);
	else
		err = sensor_sr200_apply_set(subdev, "sr200_resol_640_480", &sr200_regset_table.resol_640_480);

	CHECK_ERR_MSG(err, "fail to capture_mode (%d)\n", err);

	cam_info("%s - X\n",__func__);

	return err;
}
コード例 #19
0
static int sr130pc10_control_stream(struct v4l2_subdev *sd, stream_cmd_t cmd)
{
	int err = 0;

	switch (cmd) {
	case STREAM_START:
		cam_warn("WARN: do nothing\n");
		break;

	case STREAM_STOP:
		cam_dbg("stream stop!!!\n");
		break;
	default:
		cam_err("ERR: Invalid cmd\n");
		break;
	}

	if (unlikely(err))
		cam_err("failed to stream start(stop)\n");

	return err;
}
コード例 #20
0
static int pmu_led_torch_mode(struct hisi_flash_ctrl_t *flash_ctrl,
	int data)
{
	struct pmu_led_private_data_t *pdata;

	cam_debug("%s data=%d.\n", __func__, data);

	if (NULL == flash_ctrl) {
		cam_err("%s flash_ctrl is NULL.", __func__);
		return -1;
	}

	pdata = (struct pmu_led_private_data_t *)flash_ctrl->pdata;

	pmu_led_write(LED_CTRL1, pdata->led_ctrl_torch[LED_CTRL_1]);
	pmu_led_write(LED_CTRL2, pdata->led_ctrl_torch[LED_CTRL_2]);
	pmu_led_write(LED_CTRL3, pdata->led_ctrl_torch[LED_CTRL_3]);

	/* set LED Torch current value */
	if (data < pdata->torch_led_num) {
		cam_debug("%s torch_led=0x%x.", __func__,
			pdata->torch_led[data]);
		pmu_led_write(LED_CTRL3, ((pdata->torch_led[data] & 0x07)
				| (pdata->led_ctrl_torch[LED_CTRL_3] & 0x70)));
	} else {
		cam_warn("%s data(%d) > torch_led_num(%d).", __func__,
			data, pdata->torch_led_num);
		pmu_led_write(LED_CTRL3, ((pdata->torch_led[pdata->torch_led_num-1] & 0x07)
				| (pdata->led_ctrl_torch[LED_CTRL_3] & 0x70)));
	}
	pmu_led_write(LED_CTRL4, pdata->led_ctrl_torch[LED_CTRL_4]);
	pmu_led_write(LED_CTRL5, pdata->led_ctrl_torch[LED_CTRL_5]);
	pmu_led_write(LED_CTRL6, pdata->led_ctrl_torch[LED_CTRL_6]);
	pmu_led_write(LED_CTRL7, pdata->led_ctrl_torch[LED_CTRL_7]);

	pmu_led_write(LED_CTRL2, LED_TORCH_ENABLE);

	return 0;
}
コード例 #21
0
ファイル: slp_db8131m.c プロジェクト: AndreiLux/Perseus-S3
static int db8131m_control_stream(struct v4l2_subdev *sd, u32 cmd)
{
	int err = 0;

	switch (cmd) {
	case 0: /* STREAM_STOP */
		cam_dbg("stream stop!!!\n");
		break;

	case 1: /* STREAM_START */
		cam_warn("WARN: do nothing\n");
		break;

	default:
		cam_err("ERR: Invalid cmd\n");
		break;
	}

	if (unlikely(err))
		cam_err("failed to stream start(stop)\n");

	return err;
}
コード例 #22
0
static int sensor_sr200_g_ctrl(struct v4l2_subdev *subdev, struct v4l2_control *ctrl)
{
	struct sr200_state *state = to_state(subdev);
	int ret = 0;

	switch (ctrl->id) {
	case V4L2_CID_EXIF_EXPOSURE_TIME_DEN:
		if (state->sensor_mode == SENSOR_CAMERA) {
			ctrl->value = state->exif.exp_time_den;
		} else {
			ctrl->value = 26;
		}
		cam_dbg("V4L2_CID_CAMERA_EXIF_EXPTIME :%d\n", ctrl->value);
		break;
	case V4L2_CID_EXIF_EXPOSURE_TIME_NUM:
		ctrl->value = 1;
		cam_dbg("V4L2_CID_EXIF_EXPOSURE_TIME_NUM :%d\n", ctrl->value);
		break;
	case V4L2_CID_CAMERA_EXIF_FLASH:
		ctrl->value = state->exif.flash;
		cam_dbg("V4L2_CID_CAMERA_EXIF_FLASH :%d\n", ctrl->value);
		break;
	case V4L2_CID_CAMERA_EXIF_ISO:
		if (state->sensor_mode == SENSOR_CAMERA) {
			ctrl->value = state->exif.iso;
		} else {
			ctrl->value = 100;
		}
		cam_dbg("V4L2_CID_CAMERA_EXIF_ISO :%d\n", ctrl->value);
		break;
	default:
		cam_warn("g_ctrl : invalid ioctl(0x%08X) is requested", ctrl->id);
		break;
	}

	return ret;
}
コード例 #23
0
ファイル: sr200pc20.c プロジェクト: Ante0/xxICSKernel
static int sr200pc20_set_sensor_mode(struct v4l2_subdev *sd, s32 val)
{
	struct sr200pc20_state *state = to_state(sd);

	switch (val) {
	case SENSOR_MOVIE:
		if (state->vt_mode) {
			state->sensor_mode = SENSOR_CAMERA;
			cam_warn("%s: WARNING, Not support movie in vt mode\n",
				__func__);
			break;
		}
		/* We do not break. */
	case SENSOR_CAMERA:
		state->sensor_mode = val;
		break;
	default:
		cam_err("%s: ERROR: Not support mode.(%d)\n",
			__func__, val);
		return -EINVAL;
	}

	return 0;
}
コード例 #24
0
ファイル: slp_db8131m.c プロジェクト: AndreiLux/Perseus-S3
static int db8131m_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
{
	/* struct i2c_client *client = v4l2_get_subdevdata(sd); */
	struct db8131m_state *state = to_state(sd);
	int err = 0;

	cam_info("ctrl->id : %d, value=%d\n", ctrl->id - V4L2_CID_PRIVATE_BASE,
	ctrl->value);

	if ((ctrl->id != V4L2_CID_CAMERA_CHECK_DATALINE)
	&& (ctrl->id != V4L2_CID_CAMERA_SENSOR_MODE)
	&& ((ctrl->id != V4L2_CID_CAMERA_VT_MODE))
	&& (!state->initialized)) {
		cam_warn("camera isn't initialized\n");
		return 0;
	}

	switch (ctrl->id) {
	case V4L2_CID_CAM_PREVIEW_ONOFF:
		if (ctrl->value)
			err = db8131m_set_preview_start(sd);
		else
			err = db8131m_set_preview_stop(sd);
		cam_dbg("V4L2_CID_CAM_PREVIEW_ONOFF [%d]\n", ctrl->value);
		break;

	case V4L2_CID_CAM_CAPTURE:
		err = db8131m_set_capture_start(sd);
		cam_dbg("V4L2_CID_CAM_CAPTURE\n");
		break;

	case V4L2_CID_CAMERA_BRIGHTNESS:
		err = db8131m_set_brightness(sd, ctrl);
		cam_dbg("V4L2_CID_CAMERA_BRIGHTNESS [%d]\n", ctrl->value);
		break;

	case V4L2_CID_CAMERA_VGA_BLUR:
		err = db8131m_set_blur(sd, ctrl);
		cam_dbg("V4L2_CID_CAMERA_VGA_BLUR [%d]\n", ctrl->value);
		break;

	case V4L2_CID_CAMERA_VT_MODE:
		state->vt_mode = ctrl->value;
		break;

	case V4L2_CID_CAMERA_CHECK_DATALINE:
		state->check_dataline = ctrl->value;
		cam_dbg("check_dataline = %d\n", state->check_dataline);
		err = 0;
		break;

	case V4L2_CID_CAMERA_SENSOR_MODE:
		err = db8131m_set_sensor_mode(sd, ctrl);
		cam_dbg("sensor_mode = %d\n", ctrl->value);
		break;

	case V4L2_CID_CAMERA_CHECK_DATALINE_STOP:
		cam_dbg("do nothing\n");
		/*err = db8131m_check_dataline_stop(sd);*/
		break;

	case V4L2_CID_CAMERA_CHECK_ESD:
		err = db8131m_check_esd(sd);
		break;

	case V4L2_CID_CAMERA_FRAME_RATE:
		cam_dbg("do nothing\n");
		break;

	case V4L2_CID_CAMERA_CHECK_SENSOR_STATUS:
		db8131m_debug_sensor_status(sd);
		err = db8131m_check_sensor_status(sd);
		break;

	default:
		cam_err("ERR(ENOIOCTLCMD)\n");
		/* no errors return.*/
		break;
	}

	cam_dbg("X\n");
	return err;
}
コード例 #25
0
static int s5k5bbgx_set_frame_rate(struct v4l2_subdev *sd, u32 fps)
{
	int err = 0;

	cam_info("frame rate %d\n\n", fps);

#ifdef CONFIG_LOAD_FILE
	switch (fps) {
	case 7:
		err = s5k5bbgx_write_regs_from_sd(sd, "s5k5bbgx_vt_7fps");
		break;
	case 10:
		err = s5k5bbgx_write_regs_from_sd(sd, "s5k5bbgx_vt_10fps");

		break;
	case 12:
		err = s5k5bbgx_write_regs_from_sd(sd, "s5k5bbgx_vt_12fps");

		break;
	case 15:
		err = s5k5bbgx_write_regs_from_sd(sd, "s5k5bbgx_vt_15fps");
		break;
	case 30:
		cam_err("frame rate is 30\n");
		break;
	default:
		cam_err("ERR: Invalid framerate\n");
		break;
	}
#else
	switch (fps) {
	case 7:
		err = s5k5bbgx_write_regs(sd, s5k5bbgx_vt_7fps,
				sizeof(s5k5bbgx_vt_7fps) / \
				sizeof(s5k5bbgx_vt_7fps[0]));
		break;
	case 10:
		err = s5k5bbgx_write_regs(sd, s5k5bbgx_vt_10fps,
				sizeof(s5k5bbgx_vt_10fps) / \
				sizeof(s5k5bbgx_vt_10fps[0]));

		break;
	case 12:
		err = s5k5bbgx_write_regs(sd, s5k5bbgx_vt_12fps,
				sizeof(s5k5bbgx_vt_12fps) / \
				sizeof(s5k5bbgx_vt_12fps[0]));

		break;
	case 15:
		err = s5k5bbgx_write_regs(sd, s5k5bbgx_vt_15fps,
				sizeof(s5k5bbgx_vt_15fps) / \
				sizeof(s5k5bbgx_vt_15fps[0]));
		break;
	case 30:
		cam_warn("frame rate is 30\n");
		break;
	default:
		cam_err("ERR: Invalid framerate\n");
		break;
	}
#endif

	if (unlikely(err < 0)) {
		cam_err("i2c_write for set framerate\n");
		return -EIO;
	}

	return err;
}
コード例 #26
0
static int m5mo_read(struct i2c_client *c,
	u8 len, u8 category, u8 byte, int *val)
{
	struct i2c_msg msg;
	unsigned char data[5];
	unsigned char recv_data[len + 1];
	int i, err = 0;

	if (!c->adapter)
		return -ENODEV;

	if (len != 0x01 && len != 0x02 && len != 0x04)
		return -EINVAL;

	msg.addr = c->addr;
	msg.flags = 0;
	msg.len = sizeof(data);
	msg.buf = data;

	/* high byte goes out first */
	data[0] = msg.len;
	data[1] = 0x01;			/* Read category parameters */
	data[2] = category;
	data[3] = byte;
	data[4] = len;

	for (i = M5MO_I2C_RETRY; i; i--) {
		err = i2c_transfer(c->adapter, &msg, 1);
		if (err == 1)
			break;
		msleep(20);
	}

	if (err != 1) {
		cam_err("category %#x, byte %#x\n", category, byte);
		return err;
	}

	msg.flags = I2C_M_RD;
	msg.len = sizeof(recv_data);
	msg.buf = recv_data;
	for(i = M5MO_I2C_RETRY; i; i--) {
		err = i2c_transfer(c->adapter, &msg, 1);
		if (err == 1)
			break;
		msleep(20);
	}

	if (err != 1) {
		cam_err("category %#x, byte %#x\n", category, byte);
		return err;
	}

	if (recv_data[0] != sizeof(recv_data))
		cam_warn("expected length %d, but return length %d\n",
				 sizeof(recv_data), recv_data[0]);

	if (len == 0x01)
		*val = recv_data[1];
	else if (len == 0x02)
		*val = recv_data[1] << 8 | recv_data[2];
	else
		*val = recv_data[1] << 24 | recv_data[2] << 16 |
				recv_data[3] << 8 | recv_data[4];

	cam_dbg("category %#02x, byte %#x, value %#x\n", category, byte, *val);
	return err;
}
コード例 #27
0
static int sr200_set_frame_rate(struct v4l2_subdev *subdev, s32 fps)
{
	struct sr200_state *state = to_state(subdev);
	int min = FRAME_RATE_AUTO;
	int max = FRAME_RATE_25;
	int ret = 0;
	int i=0, fps_index=-1;

	cam_info("set frame rate %d\n", fps);

	if (state->runmode == RUNMODE_INIT) {
		cam_dbg("%s: skip fps setting \n", __func__);
		return 0;
	}

	if ((fps < min) || (fps > max)) {
		cam_warn("set_frame_rate: error, invalid frame rate %d\n", fps);
		fps = (fps < min) ? min : max;
	}

	if (unlikely(!state->initialized)) {
		cam_info("pending fps %d\n", fps);
		state->req_fps = fps;
		return 0;
	}

	for (i = 0; i < ARRAY_SIZE(sr200_framerates); i++) {
		if (fps == sr200_framerates[i].fps) {
			fps_index = sr200_framerates[i].index;
			state->fps = fps;
			state->req_fps = -1;
			break;
		}
	}

	if (unlikely(fps_index < 0)) {
		cam_warn("set_fps: warning, not supported fps %d\n", fps);
		return 0;
	}

	switch (fps) {
	case FRAME_RATE_AUTO :
		ret = sensor_sr200_apply_set(subdev, "sr200_fps_auto", &sr200_regset_table.fps_auto);
		break;
	case FRAME_RATE_7 :
		ret = sensor_sr200_apply_set(subdev, "sr200_fps_7", &sr200_regset_table.fps_7);
		break;
	case FRAME_RATE_15 :
		ret = sensor_sr200_apply_set(subdev, "sr200_fps_15", &sr200_regset_table.fps_15);
		break;
	case FRAME_RATE_25 :
		ret = sensor_sr200_apply_set(subdev, "sr200_fps_25", &sr200_regset_table.fps_25);
		break;
	default:
		cam_dbg("%s: Not supported fps (%d)\n", __func__, fps);
		break;
	}

	CHECK_ERR_MSG(ret, "fail to set framerate\n");

	return 0;
}
コード例 #28
0
static int sensor_sr200_s_ctrl(struct v4l2_subdev *subdev, struct v4l2_control *ctrl)
{
	struct sr200_state *state = to_state(subdev);
	int ret = 0;

	if (!state->initialized && ctrl->id != V4L2_CID_CAMERA_SENSOR_MODE) {
		cam_warn("s_ctrl: warning, camera not initialized. ID %d(0x%08X)\n",
			ctrl->id & 0xFF, ctrl->id);
		return 0;
	}

	switch (ctrl->id) {
	case V4L2_CID_CAMERA_SENSOR_MODE:
		cam_info("V4L2_CID_CAMERA_SENSOR_MODE : %d\n", ctrl->value);
		 sr200_set_sensor_mode(subdev, ctrl->value);
		break;
	case V4L2_CID_CAMERA_INIT:
		cam_info("V4L2_CID_CAMERA_INIT\n");
/*  // Move to set_power function
		ret = sensor_sr200_init(subdev, 0);
		if (ret) {
			cam_err("sensor_sr200_init is fail(%d)", ret);
			goto p_err;
		}
*/
		break;
	case V4L2_CID_CAPTURE:
		cam_info("V4L2_CID_CAPTURE : %d \n", ctrl->value);
		ret = sensor_sr200_s_capture_mode(subdev, ctrl->value);
		if (ret) {
			cam_err("sensor_sr200_s_capture_mode is fail(%d)", ret);
			goto p_err;
		}
		break;
	case V4L2_CID_CAMERA_SET_SNAPSHOT_SIZE:
/* capture size of SoC sensor is to be set up in start_capture.
		cam_info("V4L2_CID_CAMERA_SET_SNAPSHOT_SIZE : %d\n", ctrl->value);
		ret = sr200_set_capture_size(subdev, ctrl->value);
		if (ret) {
			cam_err("sr200_set_snapshot_size is fail(%d)", ret);
			goto p_err;
		}
*/
		break;
	case V4L2_CID_IMAGE_EFFECT:
	case V4L2_CID_CAMERA_EFFECT:
		cam_info("V4L2_CID_IMAGE_EFFECT :%d\n", ctrl->value);
		ret = sr200_set_effect(subdev, ctrl->value);
		break;
	case V4L2_CID_CAMERA_ISO:
	case V4L2_CID_CAMERA_BRIGHTNESS:
	case V4L2_CID_CAMERA_AEAWB_LOCK_UNLOCK:
	case V4L2_CID_CAMERA_SET_POSTVIEW_SIZE:
	case V4L2_CID_JPEG_QUALITY:
	case V4L2_CID_CAM_BRIGHTNESS:
		cam_dbg("s_ctrl : unsupported id is requested. ID (0x%08X)\n", ctrl->id);
		break;
	default:
		cam_warn("s_ctrl : invalid id is requested. ID (0x%08X)\n", ctrl->id);
		break;
	}

p_err:
	return ret;
}
コード例 #29
0
static inline int s5k5bbgx_read(struct i2c_client *client,
	u16 subaddr, u16 *data)
{
	u8 buf[2];
	int err = 0;
	struct i2c_msg msg = {
		.addr = client->addr,
		.flags = 0,
		.len = 2,
		.buf = buf,
	};

	*(u16 *)buf = cpu_to_be16(subaddr);

	/* printk("\n\n\n%X %X\n\n\n", buf[0], buf[1]);*/

	err = i2c_transfer(client->adapter, &msg, 1);
	if (unlikely(err < 0))
		cam_err("ERR: %d register read fail\n", __LINE__);

	msg.flags = I2C_M_RD;

	err = i2c_transfer(client->adapter, &msg, 1);
	if (unlikely(err < 0))
		cam_err("ERR: %d register read fail\n", __LINE__);

	/*printk("\n\n\n%X %X\n\n\n", buf[0], buf[1]);*/
	*data = ((buf[0] << 8) | buf[1]);

	return err;
}

/*
 * s5k6aafx sensor i2c write routine
 * <start>--<Device address><2Byte Subaddr><2Byte Value>--<stop>
 */
#ifdef CONFIG_LOAD_FILE
static int loadFile(void)
{
	struct file *fp = NULL;
	struct test *nextBuf = NULL;

	u8 *nBuf = NULL;
	size_t file_size = 0, max_size = 0, testBuf_size = 0;
	size_t nread = 0;
	s32 check = 0, starCheck = 0;
	s32 tmp_large_file = 0;
	s32 i = 0;
	int ret = 0;
	loff_t pos;

	mm_segment_t fs = get_fs();
	set_fs(get_ds());

	BUG_ON(testBuf);

	fp = filp_open("/mnt/sdcard/external_sd/s5k5bbgx_setfile.h", O_RDONLY, 0);
	if (IS_ERR(fp)) {
		cam_err("file open error\n");
		return PTR_ERR(fp);
	}

	file_size = (size_t) fp->f_path.dentry->d_inode->i_size;
	max_size = file_size;

	cam_dbg("file_size = %d\n", file_size);

	nBuf = kmalloc(file_size, GFP_ATOMIC);
	if (nBuf == NULL) {
		cam_dbg("Fail to 1st get memory\n");
		nBuf = vmalloc(file_size);
		if (nBuf == NULL) {
			cam_err("ERR: nBuf Out of Memory\n");
			ret = -ENOMEM;
			goto error_out;
		}
		tmp_large_file = 1;
	}

	testBuf_size = sizeof(struct test) * file_size;
	if (tmp_large_file) {
		testBuf = (struct test *)vmalloc(testBuf_size);
		large_file = 1;
	} else {
		testBuf = kmalloc(testBuf_size, GFP_ATOMIC);
		if (testBuf == NULL) {
			cam_dbg("Fail to get mem(%d bytes)\n", testBuf_size);
			testBuf = (struct test *)vmalloc(testBuf_size);
			large_file = 1;
		}
	}
	if (testBuf == NULL) {
		cam_err("ERR: Out of Memory\n");
		ret = -ENOMEM;
		goto error_out;
	}

	pos = 0;
	memset(nBuf, 0, file_size);
	memset(testBuf, 0, file_size * sizeof(struct test));

	nread = vfs_read(fp, (char __user *)nBuf, file_size, &pos);
	if (nread != file_size) {
		cam_err("failed to read file ret = %d\n", nread);
		ret = -1;
		goto error_out;
	}

	set_fs(fs);

	i = max_size;

	printk("i = %d\n", i);

	while (i) {
		testBuf[max_size - i].data = *nBuf;
		if (i != 1) {
			testBuf[max_size - i].nextBuf = &testBuf[max_size - i + 1];
		} else {
			testBuf[max_size - i].nextBuf = NULL;
			break;
		}
		i--;
		nBuf++;
	}

	i = max_size;
	nextBuf = &testBuf[0];

#if 1
	while (i - 1) {
		if (!check && !starCheck) {
			if (testBuf[max_size - i].data == '/') {
				if (testBuf[max_size-i].nextBuf != NULL) {
					if (testBuf[max_size-i].nextBuf->data
								== '/') {
						check = 1;/* when find '//' */
						i--;
					} else if (testBuf[max_size-i].nextBuf->data == '*') {
						starCheck = 1;/* when find '/ *' */
						i--;
					}
				} else
					break;
			}
			if (!check && !starCheck) {
				/* ignore '\t' */
				if (testBuf[max_size - i].data != '\t') {
					nextBuf->nextBuf = &testBuf[max_size-i];
					nextBuf = &testBuf[max_size - i];
				}
			}
		} else if (check && !starCheck) {
			if (testBuf[max_size - i].data == '/') {
				if(testBuf[max_size-i].nextBuf != NULL) {
					if (testBuf[max_size-i].nextBuf->data == '*') {
						starCheck = 1; /* when find '/ *' */
						check = 0;
						i--;
					}
				} else
					break;
			}

			 /* when find '\n' */
			if (testBuf[max_size - i].data == '\n' && check) {
				check = 0;
				nextBuf->nextBuf = &testBuf[max_size - i];
				nextBuf = &testBuf[max_size - i];
			}

		} else if (!check && starCheck) {
			if (testBuf[max_size - i].data == '*') {
				if (testBuf[max_size-i].nextBuf != NULL) {
					if (testBuf[max_size-i].nextBuf->data == '/') {
						starCheck = 0; /* when find '* /' */
						i--;
					}
				} else
					break;
			}
		}

		i--;

		if (i < 2) {
			nextBuf = NULL;
			break;
		}

		if (testBuf[max_size - i].nextBuf == NULL) {
			nextBuf = NULL;
			break;
		}
	}
#endif

#if 0 // for print
	printk("i = %d\n", i);
	nextBuf = &testBuf[0];
	while (1) {
		//printk("sdfdsf\n");
		if (nextBuf->nextBuf == NULL)
			break;
		printk("%c", nextBuf->data);
		nextBuf = nextBuf->nextBuf;
	}
#endif

error_out:

	if (nBuf)
		tmp_large_file ? vfree(nBuf) : kfree(nBuf);
	if (fp)
		filp_close(fp, current->files);
	return ret;
}
#endif

static inline int s5k5bbgx_write(struct i2c_client *client,
		u32 packet)
{
	u8 buf[4];
	int err = 0, retry_count = 5;

	struct i2c_msg msg = {
		.addr	= client->addr,
		.flags	= 0,
		.buf	= buf,
		.len	= 4,
	};

	if (!client->adapter) {
		cam_err("ERR - can't search i2c client adapter\n");
		return -EIO;
	}

	while (retry_count--) {
		*(u32 *)buf = cpu_to_be32(packet);
		err = i2c_transfer(client->adapter, &msg, 1);
		if (likely(err == 1))
			break;
		mdelay(10);
	}

	if (unlikely(err < 0)) {
		cam_err("ERR - 0x%08x write failed err=%d\n",
				(u32)packet, err);
		return err;
	}

	return (err != 1) ? -1 : 0;
}

#ifdef CONFIG_LOAD_FILE
static int s5k5bbgx_write_regs_from_sd(struct v4l2_subdev *sd, u8 s_name[])
{

	struct i2c_client *client = v4l2_get_subdevdata(sd);
	struct test *tempData = NULL;

	int ret = -EAGAIN;
	u32 temp;
	u32 delay = 0;
	u8 data[11];
	s32 searched = 0;
	size_t size = strlen(s_name);
	s32 i;

	cam_dbg("E size = %d, string = %s\n", size, s_name);
	tempData = &testBuf[0];
	while (!searched) {
		searched = 1;
		for (i = 0; i < size; i++) {
			if (tempData->data != s_name[i]) {
				searched = 0;
				break;
			}
			tempData = tempData->nextBuf;
		}
		tempData = tempData->nextBuf;
	}
	/* structure is get..*/

	while (1) {
		if (tempData->data == '{')
			break;
		else
			tempData = tempData->nextBuf;
	}

	while (1) {
		searched = 0;
		while (1) {
			if (tempData->data == 'x') {
				/* get 10 strings.*/
				data[0] = '0';
				for (i = 1; i < 11; i++) {
					data[i] = tempData->data;
					tempData = tempData->nextBuf;
				}
				/*cam_dbg("%s\n", data);*/
				temp = simple_strtoul(data, NULL, 16);
				break;
			} else if (tempData->data == '}') {
				searched = 1;
				break;
			} else
				tempData = tempData->nextBuf;

			if (tempData->nextBuf == NULL)
				return -1;
		}

		if (searched)
			break;

		if ((temp & S5K5BBGX_DELAY) == S5K5BBGX_DELAY) {
			delay = temp & 0xFFFF;
			cam_info("line(%d):delay(0x%x, %d)\n", __LINE__,
							delay, delay);
			msleep(delay);
			continue;
		}

		ret = s5k5bbgx_write(client, temp);

		/* In error circumstances */
		/* Give second shot */
		if (unlikely(ret)) {
			dev_info(&client->dev,
					"s5k5bbgx i2c retry one more time\n");
			ret = s5k5bbgx_write(client, temp);

			/* Give it one more shot */
			if (unlikely(ret)) {
				dev_info(&client->dev,
						"s5k5bbgx i2c retry twice\n");
				ret = s5k5bbgx_write(client, temp);
			}
		}
	}

	return ret;
}
#endif

/*
* Read a register.
*/
static int s5k5bbgx_read_reg(struct v4l2_subdev *sd,
		u16 page, u16 addr, u16 *val)
{
	struct i2c_client *client = v4l2_get_subdevdata(sd);
	u32 page_cmd = (0x002C << 16) | page;
	u32 addr_cmd = (0x002E << 16) | addr;
	int err = 0;

	cam_dbg("page_cmd=0x%X, addr_cmd=0x%X\n", page_cmd, addr_cmd);

	err = s5k5bbgx_write(client, page_cmd);
	CHECK_ERR(err);
	err = s5k5bbgx_write(client, addr_cmd);
	CHECK_ERR(err);
	err = s5k5bbgx_read(client, 0x0F12, val);
	CHECK_ERR(err);

	return 0;
}

/* program multiple registers */
static int s5k5bbgx_write_regs(struct v4l2_subdev *sd,
		const u32 *packet, u32 num)
{
	struct s5k5bbgx_state *state = to_state(sd);
	struct i2c_client *client = v4l2_get_subdevdata(sd);
	int ret = -EAGAIN;
	u32 temp = 0;
	u16 delay = 0;

	while (num--) {
		temp = *packet++;

		if ((temp & S5K5BBGX_DELAY) == S5K5BBGX_DELAY) {
			delay = temp & 0xFFFF;
			cam_dbg("line(%d):delay(0x%x):delay(%d)\n",
						__LINE__, delay, delay);
			msleep(delay);
			continue;
		}

		ret = s5k5bbgx_write(client, temp);

		/* In error circumstances
		 *Give second shot
		 */
		if (unlikely(ret)) {
			cam_warn("i2c retry one more time\n");
			ret = s5k5bbgx_write(client, temp);

			/* Give it one more shot */
			if (unlikely(ret)) {
				cam_warn("i2c retry twice\n");
				ret = s5k5bbgx_write(client, temp);
				break;
			}
		}
#ifdef S5K5BBGX_USLEEP
		if (unlikely(state->vt_mode))
			if (!(num%200))
				s5k5bbgx_usleep(3);
#endif		
	}

	if (unlikely(ret < 0)) {
		cam_err("fail to write registers!!\n");
		return -EIO;
	}

	return 0;
}

static int s5k5bbgx_get_exif(struct v4l2_subdev *sd)
{
	struct s5k5bbgx_state *state = to_state(sd);
	u16 iso_gain_table[] = {10, 18, 23, 28};
	u16 iso_table[] = {0, 50, 100, 200, 400};
	u16 gain = 0, val = 0;
	s32 index = 0;

	state->exif.shutter_speed = 0;
	state->exif.iso = 0;

	/* Get shutter speed */
	s5k5bbgx_read_reg(sd, REG_PAGE_SHUTTER, REG_ADDR_SHUTTER, &val);
	state->exif.shutter_speed = 1000 / (val / 400);
	cam_dbg("val = %d\n", val);

	/* Get ISO */
	val = 0;
	s5k5bbgx_read_reg(sd, REG_PAGE_ISO, REG_ADDR_ISO, &val);
	cam_dbg("val = %d\n", val);
	gain = val * 10 / 256;
	for (index = 0; index < sizeof(iso_gain_table); index++) {
		if (gain < iso_gain_table[index])
			break;
	}
	state->exif.iso = iso_table[index];

	cam_dbg("gain=%d, Shutter speed=%d, ISO=%d\n",
		gain, state->exif.shutter_speed, state->exif.iso);
	return 0;
}

static int s5k5bbgx_check_dataline(struct v4l2_subdev *sd, s32 val)
{
	int err = 0;

	cam_info("DTP %s\n", val ? "ON" : "OFF");

#ifdef CONFIG_LOAD_FILE
	if (val)
		err = s5k5bbgx_write_regs_from_sd(sd, "s5k5bbgx_pattern_on");
	else
		err = s5k5bbgx_write_regs_from_sd(sd, "s5k5bbgx_pattern_off");
#else
	if (val) {
		err = s5k5bbgx_write_regs(sd, s5k5bbgx_pattern_on,
			sizeof(s5k5bbgx_pattern_on) / \
			sizeof(s5k5bbgx_pattern_on[0]));
	} else {
		err = s5k5bbgx_write_regs(sd, s5k5bbgx_pattern_off,
			sizeof(s5k5bbgx_pattern_off) / \
			sizeof(s5k5bbgx_pattern_off[0]));
	}
#endif
	if (unlikely(err)) {
		cam_err("fail to DTP setting\n");
		return err;
	}

	return 0;
}