Esempio n. 1
0
static inline int sr200pc20_get_iso(struct v4l2_subdev *sd, u16 *iso)
{
	struct i2c_client *client = v4l2_get_subdevdata(sd);
	/* u16 iso_gain_table[] = {10, 18, 23, 28};
	u16 iso_table[] = {0, 50, 100, 200, 400}; */
	u16 read_value = 0, gain = 0;


	sr200pc20_i2c_write_byte(client, 0x03, 0x20);
	sr200pc20_i2c_read_byte(client, 0xb0, &read_value);
	gain = (read_value * 100  / 32) + 50;

	if (read_value < 125)
		*iso = 50;
	else if (read_value < 175)
		*iso = 100;
	else if (read_value < 250)
		*iso = 200;
	else if (read_value < 375)
		*iso = 400;
	else if (read_value < 550)
		*iso = 800;
	else
		*iso = 1600;

	cam_dbg("gain=%d, ISO=%d\n", gain, *iso);

	return 0;
}
Esempio n. 2
0
static int sr200pc20_init_regs(struct v4l2_subdev *sd)
{
	struct sr200pc20_state *state = to_state(sd);
	struct i2c_client *client = v4l2_get_subdevdata(sd);
	u16 read_value = 0;
	int err = -ENODEV;

	err = sr200pc20_i2c_write_byte(client, 0x03, 0x00);
	if (unlikely(err < 0))
	{
		/**************************************************************
		 	add by cym 20130222
			because if the device dose not exist the driver also access this struct 
		***************************************************************/
		state->regs = &reg_datas;
		/* end add */
		
		return -ENODEV;
	}

	sr200pc20_i2c_read_byte(client, 0x04, &read_value);
	if (likely(read_value == SR200PC20_CHIP_ID))
		cam_info("Sensor ChipID: 0x%02X\n", SR200PC20_CHIP_ID);
	else
		cam_info("Sensor ChipID: 0x%02X, unknown chipID\n", read_value);

	state->regs = &reg_datas;

	return 0;
}
Esempio n. 3
0
static int sr200pc20_get_iso_speed_rate(struct v4l2_subdev *sd)
{
	struct i2c_client *client = v4l2_get_subdevdata(sd);
	unsigned short read_value;
	int gain;
	int isospeedrating = 0;

	sr200pc20_i2c_write_byte(client, 0x03, 0x20);
	sr200pc20_i2c_read_byte(client, 0xb0, &read_value);
	gain = ((int)read_value * 100  / 32) + 50;

	if (read_value < 125)
		isospeedrating = 50;
	else if (read_value < 175)
		isospeedrating = 100;
	else if (read_value < 250)
		isospeedrating = 200;
	else if (read_value < 375)
		isospeedrating = 400;
	else if (read_value < 550)
		isospeedrating = 800;
	else
		isospeedrating = 1600;

	cam_dbg("get iso = %d\n", isospeedrating);
	return isospeedrating;
}
Esempio n. 4
0
static int sr200pc20_get_expousretime(struct v4l2_subdev *sd,
					u32 *exp_time)
{
	struct i2c_client *client = v4l2_get_subdevdata(sd);
	u16 read_value = 0;
	u32 cintr = 0;

	sr200pc20_i2c_write_byte(client, 0x03, 0x20);
	sr200pc20_i2c_read_byte(client, 0x80, &read_value);
	cintr = read_value << 19;
	sr200pc20_i2c_read_byte(client, 0x81, &read_value);
	cintr |= read_value << 11;
	sr200pc20_i2c_read_byte(client, 0x82, &read_value);
	cintr |= read_value << 3;

	*exp_time =  cintr / 24; /* us */

	return 0;
}
Esempio n. 5
0
static int sr200pc20_get_shutterspeed(struct v4l2_subdev *sd)
{
	struct i2c_client *client = v4l2_get_subdevdata(sd);
	unsigned short read_value;
	int cintr;
	int ShutterSpeed = 0;

	sr200pc20_i2c_write_byte(client, 0x03, 0x20);
	sr200pc20_i2c_read_byte(client, 0x80, &read_value);
	cintr = (int)read_value << 19;
	sr200pc20_i2c_read_byte(client, 0x81, &read_value);
	cintr += (int)read_value << 11;
	sr200pc20_i2c_read_byte(client, 0x82, &read_value);
	cintr += (int)read_value << 3;

	cintr = cintr/24;
	ShutterSpeed =  1000000/cintr;

	cam_dbg("get shutterspeed = %d\n", ShutterSpeed);
	return ShutterSpeed;
}
Esempio n. 6
0
static int sr200pc20_init_regs(struct v4l2_subdev *sd)
{
	struct sr200pc20_state *state = to_state(sd);
	struct i2c_client *client = v4l2_get_subdevdata(sd);
	u16 read_value = 0;
	int err = -ENODEV;

	err = sr200pc20_i2c_write_byte(client, 0x03, 0x00);
	if (unlikely(err < 0))
		return -ENODEV;

	sr200pc20_i2c_read_byte(client, 0x04, &read_value);
	if (likely(read_value == SR200PC20_CHIP_ID))
		cam_info("Sensor ChipID: 0x%02X\n", SR200PC20_CHIP_ID);
	else
		cam_info("Sensor ChipID: 0x%02X, unknown chipID\n", read_value);

	state->regs = &reg_datas;

	return 0;
}