V4L/DVB (10013): Convert all sensors to use the unified write sensor function

Signed-off-by: Erik Andrén <erik.andren@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
Erik Andrén 2008-11-26 04:08:10 -03:00 committed by Mauro Carvalho Chehab
parent 4b8f393391
commit 6dc4cff0c3
6 changed files with 98 additions and 95 deletions

View File

@ -133,4 +133,7 @@ int m5602_read_bridge(
int m5602_write_bridge( int m5602_write_bridge(
struct sd *sd, u8 address, u8 i2c_data); struct sd *sd, u8 address, u8 i2c_data);
int m5602_write_sensor(struct sd *sd, const u8 address,
u8 *i2c_data, const u8 len);
#endif #endif

View File

@ -46,7 +46,7 @@ int mt9m111_probe(struct sd *sd)
} else { } else {
data[0] = preinit_mt9m111[i][2]; data[0] = preinit_mt9m111[i][2];
data[1] = preinit_mt9m111[i][3]; data[1] = preinit_mt9m111[i][3];
mt9m111_write_sensor(sd, m5602_write_sensor(sd,
preinit_mt9m111[i][1], data, 2); preinit_mt9m111[i][1], data, 2);
} }
} }
@ -84,7 +84,7 @@ int mt9m111_init(struct sd *sd)
} else { } else {
data[0] = init_mt9m111[i][2]; data[0] = init_mt9m111[i][2];
data[1] = init_mt9m111[i][3]; data[1] = init_mt9m111[i][3];
err = mt9m111_write_sensor(sd, err = m5602_write_sensor(sd,
init_mt9m111[i][1], data, 2); init_mt9m111[i][1], data, 2);
} }
} }
@ -123,7 +123,7 @@ int mt9m111_set_vflip(struct gspca_dev *gspca_dev, __s32 val)
PDEBUG(D_V4L2, "Set vertical flip to %d", val); PDEBUG(D_V4L2, "Set vertical flip to %d", val);
/* Set the correct page map */ /* Set the correct page map */
err = mt9m111_write_sensor(sd, MT9M111_PAGE_MAP, data, 2); err = m5602_write_sensor(sd, MT9M111_PAGE_MAP, data, 2);
if (err < 0) if (err < 0)
goto out; goto out;
@ -132,7 +132,7 @@ int mt9m111_set_vflip(struct gspca_dev *gspca_dev, __s32 val)
goto out; goto out;
data[0] = (data[0] & 0xfe) | val; data[0] = (data[0] & 0xfe) | val;
err = mt9m111_write_sensor(sd, MT9M111_SC_R_MODE_CONTEXT_B, err = m5602_write_sensor(sd, MT9M111_SC_R_MODE_CONTEXT_B,
data, 2); data, 2);
out: out:
return err; return err;
@ -161,7 +161,7 @@ int mt9m111_set_hflip(struct gspca_dev *gspca_dev, __s32 val)
PDEBUG(D_V4L2, "Set horizontal flip to %d", val); PDEBUG(D_V4L2, "Set horizontal flip to %d", val);
/* Set the correct page map */ /* Set the correct page map */
err = mt9m111_write_sensor(sd, MT9M111_PAGE_MAP, data, 2); err = m5602_write_sensor(sd, MT9M111_PAGE_MAP, data, 2);
if (err < 0) if (err < 0)
goto out; goto out;
@ -170,7 +170,7 @@ int mt9m111_set_hflip(struct gspca_dev *gspca_dev, __s32 val)
goto out; goto out;
data[0] = (data[0] & 0xfd) | ((val << 1) & 0x02); data[0] = (data[0] & 0xfd) | ((val << 1) & 0x02);
err = mt9m111_write_sensor(sd, MT9M111_SC_R_MODE_CONTEXT_B, err = m5602_write_sensor(sd, MT9M111_SC_R_MODE_CONTEXT_B,
data, 2); data, 2);
out: out:
return err; return err;
@ -202,7 +202,7 @@ int mt9m111_set_gain(struct gspca_dev *gspca_dev, __s32 val)
struct sd *sd = (struct sd *) gspca_dev; struct sd *sd = (struct sd *) gspca_dev;
/* Set the correct page map */ /* Set the correct page map */
err = mt9m111_write_sensor(sd, MT9M111_PAGE_MAP, data, 2); err = m5602_write_sensor(sd, MT9M111_PAGE_MAP, data, 2);
if (err < 0) if (err < 0)
goto out; goto out;
@ -227,7 +227,7 @@ int mt9m111_set_gain(struct gspca_dev *gspca_dev, __s32 val)
PDEBUG(D_V4L2, "tmp=%d, data[1]=%d, data[0]=%d", tmp, PDEBUG(D_V4L2, "tmp=%d, data[1]=%d, data[0]=%d", tmp,
data[1], data[0]); data[1], data[0]);
err = mt9m111_write_sensor(sd, MT9M111_SC_GLOBAL_GAIN, err = m5602_write_sensor(sd, MT9M111_SC_GLOBAL_GAIN,
data, 2); data, 2);
out: out:
return err; return err;
@ -318,7 +318,7 @@ static void mt9m111_dump_registers(struct sd *sd)
info("Dumping the mt9m111 sensor core registers"); info("Dumping the mt9m111 sensor core registers");
value[1] = MT9M111_SENSOR_CORE; value[1] = MT9M111_SENSOR_CORE;
mt9m111_write_sensor(sd, MT9M111_PAGE_MAP, value, 2); m5602_write_sensor(sd, MT9M111_PAGE_MAP, value, 2);
for (address = 0; address < 0xff; address++) { for (address = 0; address < 0xff; address++) {
mt9m111_read_sensor(sd, address, value, 2); mt9m111_read_sensor(sd, address, value, 2);
info("register 0x%x contains 0x%x%x", info("register 0x%x contains 0x%x%x",
@ -327,7 +327,7 @@ static void mt9m111_dump_registers(struct sd *sd)
info("Dumping the mt9m111 color pipeline registers"); info("Dumping the mt9m111 color pipeline registers");
value[1] = MT9M111_COLORPIPE; value[1] = MT9M111_COLORPIPE;
mt9m111_write_sensor(sd, MT9M111_PAGE_MAP, value, 2); m5602_write_sensor(sd, MT9M111_PAGE_MAP, value, 2);
for (address = 0; address < 0xff; address++) { for (address = 0; address < 0xff; address++) {
mt9m111_read_sensor(sd, address, value, 2); mt9m111_read_sensor(sd, address, value, 2);
info("register 0x%x contains 0x%x%x", info("register 0x%x contains 0x%x%x",
@ -336,7 +336,7 @@ static void mt9m111_dump_registers(struct sd *sd)
info("Dumping the mt9m111 camera control registers"); info("Dumping the mt9m111 camera control registers");
value[1] = MT9M111_CAMERA_CONTROL; value[1] = MT9M111_CAMERA_CONTROL;
mt9m111_write_sensor(sd, MT9M111_PAGE_MAP, value, 2); m5602_write_sensor(sd, MT9M111_PAGE_MAP, value, 2);
for (address = 0; address < 0xff; address++) { for (address = 0; address < 0xff; address++) {
mt9m111_read_sensor(sd, address, value, 2); mt9m111_read_sensor(sd, address, value, 2);
info("register 0x%x contains 0x%x%x", info("register 0x%x contains 0x%x%x",

View File

@ -166,7 +166,7 @@ int ov9650_probe(struct sd *sd)
for (i = 0; i < ARRAY_SIZE(preinit_ov9650); i++) { for (i = 0; i < ARRAY_SIZE(preinit_ov9650); i++) {
u8 data = preinit_ov9650[i][2]; u8 data = preinit_ov9650[i][2];
if (preinit_ov9650[i][0] == SENSOR) if (preinit_ov9650[i][0] == SENSOR)
ov9650_write_sensor(sd, m5602_write_sensor(sd,
preinit_ov9650[i][1], &data, 1); preinit_ov9650[i][1], &data, 1);
else else
m5602_write_bridge(sd, preinit_ov9650[i][1], data); m5602_write_bridge(sd, preinit_ov9650[i][1], data);
@ -204,7 +204,7 @@ int ov9650_init(struct sd *sd)
for (i = 0; i < ARRAY_SIZE(init_ov9650) && !err; i++) { for (i = 0; i < ARRAY_SIZE(init_ov9650) && !err; i++) {
data = init_ov9650[i][2]; data = init_ov9650[i][2];
if (init_ov9650[i][0] == SENSOR) if (init_ov9650[i][0] == SENSOR)
err = ov9650_write_sensor(sd, init_ov9650[i][1], err = m5602_write_sensor(sd, init_ov9650[i][1],
&data, 1); &data, 1);
else else
err = m5602_write_bridge(sd, init_ov9650[i][1], data); err = m5602_write_bridge(sd, init_ov9650[i][1], data);
@ -213,7 +213,7 @@ int ov9650_init(struct sd *sd)
if (dmi_check_system(ov9650_flip_dmi_table) && !err) { if (dmi_check_system(ov9650_flip_dmi_table) && !err) {
info("vflip quirk active"); info("vflip quirk active");
data = 0x30; data = 0x30;
err = ov9650_write_sensor(sd, OV9650_MVFP, &data, 1); err = m5602_write_sensor(sd, OV9650_MVFP, &data, 1);
} }
return err; return err;
@ -225,7 +225,7 @@ int ov9650_power_down(struct sd *sd)
for (i = 0; i < ARRAY_SIZE(power_down_ov9650) && !err; i++) { for (i = 0; i < ARRAY_SIZE(power_down_ov9650) && !err; i++) {
u8 data = power_down_ov9650[i][2]; u8 data = power_down_ov9650[i][2];
if (power_down_ov9650[i][0] == SENSOR) if (power_down_ov9650[i][0] == SENSOR)
err = ov9650_write_sensor(sd, err = m5602_write_sensor(sd,
power_down_ov9650[i][1], &data, 1); power_down_ov9650[i][1], &data, 1);
else else
err = m5602_write_bridge(sd, power_down_ov9650[i][1], err = m5602_write_bridge(sd, power_down_ov9650[i][1],
@ -272,21 +272,21 @@ int ov9650_set_exposure(struct gspca_dev *gspca_dev, __s32 val)
/* The 6 MSBs */ /* The 6 MSBs */
i2c_data = (val >> 10) & 0x3f; i2c_data = (val >> 10) & 0x3f;
err = ov9650_write_sensor(sd, OV9650_AECHM, err = m5602_write_sensor(sd, OV9650_AECHM,
&i2c_data, 1); &i2c_data, 1);
if (err < 0) if (err < 0)
goto out; goto out;
/* The 8 middle bits */ /* The 8 middle bits */
i2c_data = (val >> 2) & 0xff; i2c_data = (val >> 2) & 0xff;
err = ov9650_write_sensor(sd, OV9650_AECH, err = m5602_write_sensor(sd, OV9650_AECH,
&i2c_data, 1); &i2c_data, 1);
if (err < 0) if (err < 0)
goto out; goto out;
/* The 2 LSBs */ /* The 2 LSBs */
i2c_data = val & 0x03; i2c_data = val & 0x03;
err = ov9650_write_sensor(sd, OV9650_COM1, &i2c_data, 1); err = m5602_write_sensor(sd, OV9650_COM1, &i2c_data, 1);
out: out:
return err; return err;
@ -320,11 +320,11 @@ int ov9650_set_gain(struct gspca_dev *gspca_dev, __s32 val)
/* Mask away all uninteresting bits */ /* Mask away all uninteresting bits */
i2c_data = ((val & 0x0300) >> 2) | i2c_data = ((val & 0x0300) >> 2) |
(i2c_data & 0x3F); (i2c_data & 0x3F);
err = ov9650_write_sensor(sd, OV9650_VREF, &i2c_data, 1); err = m5602_write_sensor(sd, OV9650_VREF, &i2c_data, 1);
/* The 8 LSBs */ /* The 8 LSBs */
i2c_data = val & 0xff; i2c_data = val & 0xff;
err = ov9650_write_sensor(sd, OV9650_GAIN, &i2c_data, 1); err = m5602_write_sensor(sd, OV9650_GAIN, &i2c_data, 1);
return err; return err;
} }
@ -352,7 +352,7 @@ int ov9650_set_red_balance(struct gspca_dev *gspca_dev, __s32 val)
val & 0xff); val & 0xff);
i2c_data = val & 0xff; i2c_data = val & 0xff;
err = ov9650_write_sensor(sd, OV9650_RED, &i2c_data, 1); err = m5602_write_sensor(sd, OV9650_RED, &i2c_data, 1);
return err; return err;
} }
@ -381,7 +381,7 @@ int ov9650_set_blue_balance(struct gspca_dev *gspca_dev, __s32 val)
val & 0xff); val & 0xff);
i2c_data = val & 0xff; i2c_data = val & 0xff;
err = ov9650_write_sensor(sd, OV9650_BLUE, &i2c_data, 1); err = m5602_write_sensor(sd, OV9650_BLUE, &i2c_data, 1);
return err; return err;
} }
@ -420,7 +420,7 @@ int ov9650_set_hflip(struct gspca_dev *gspca_dev, __s32 val)
i2c_data = ((i2c_data & 0xdf) | i2c_data = ((i2c_data & 0xdf) |
((val & 0x01) << 5)); ((val & 0x01) << 5));
err = ov9650_write_sensor(sd, OV9650_MVFP, &i2c_data, 1); err = m5602_write_sensor(sd, OV9650_MVFP, &i2c_data, 1);
out: out:
return err; return err;
} }
@ -459,7 +459,7 @@ int ov9650_set_vflip(struct gspca_dev *gspca_dev, __s32 val)
i2c_data = ((i2c_data & 0xef) | i2c_data = ((i2c_data & 0xef) |
((val & 0x01) << 4)); ((val & 0x01) << 4));
err = ov9650_write_sensor(sd, OV9650_MVFP, &i2c_data, 1); err = m5602_write_sensor(sd, OV9650_MVFP, &i2c_data, 1);
out: out:
return err; return err;
} }
@ -498,13 +498,13 @@ int ov9650_set_brightness(struct gspca_dev *gspca_dev, __s32 val)
/* Mask away all uninteresting bits */ /* Mask away all uninteresting bits */
i2c_data = ((val & 0x0300) >> 2) | (i2c_data & 0x3F); i2c_data = ((val & 0x0300) >> 2) | (i2c_data & 0x3F);
err = ov9650_write_sensor(sd, OV9650_VREF, &i2c_data, 1); err = m5602_write_sensor(sd, OV9650_VREF, &i2c_data, 1);
if (err < 0) if (err < 0)
goto out; goto out;
/* The 8 LSBs */ /* The 8 LSBs */
i2c_data = val & 0xff; i2c_data = val & 0xff;
err = ov9650_write_sensor(sd, OV9650_GAIN, &i2c_data, 1); err = m5602_write_sensor(sd, OV9650_GAIN, &i2c_data, 1);
out: out:
return err; return err;
@ -535,7 +535,7 @@ int ov9650_set_auto_white_balance(struct gspca_dev *gspca_dev, __s32 val)
goto out; goto out;
i2c_data = ((i2c_data & 0xfd) | ((val & 0x01) << 1)); i2c_data = ((i2c_data & 0xfd) | ((val & 0x01) << 1));
err = ov9650_write_sensor(sd, OV9650_COM8, &i2c_data, 1); err = m5602_write_sensor(sd, OV9650_COM8, &i2c_data, 1);
out: out:
return err; return err;
} }
@ -565,7 +565,7 @@ int ov9650_set_auto_gain(struct gspca_dev *gspca_dev, __s32 val)
goto out; goto out;
i2c_data = ((i2c_data & 0xfb) | ((val & 0x01) << 2)); i2c_data = ((i2c_data & 0xfb) | ((val & 0x01) << 2));
err = ov9650_write_sensor(sd, OV9650_COM8, &i2c_data, 1); err = m5602_write_sensor(sd, OV9650_COM8, &i2c_data, 1);
out: out:
return err; return err;
} }
@ -589,7 +589,7 @@ static void ov9650_dump_registers(struct sd *sd)
u8 test_value[2] = {0xff, 0xff}; u8 test_value[2] = {0xff, 0xff};
ov9650_read_sensor(sd, address, &old_value, 1); ov9650_read_sensor(sd, address, &old_value, 1);
ov9650_write_sensor(sd, address, test_value, 1); m5602_write_sensor(sd, address, test_value, 1);
ov9650_read_sensor(sd, address, &ctrl_value, 1); ov9650_read_sensor(sd, address, &ctrl_value, 1);
if (ctrl_value == test_value[0]) if (ctrl_value == test_value[0])
@ -598,6 +598,6 @@ static void ov9650_dump_registers(struct sd *sd)
info("register 0x%x is read only", address); info("register 0x%x is read only", address);
/* Restore original value */ /* Restore original value */
ov9650_write_sensor(sd, address, &old_value, 1); m5602_write_sensor(sd, address, &old_value, 1);
} }
} }

View File

@ -40,7 +40,7 @@ int po1030_probe(struct sd *sd)
for (i = 0; i < ARRAY_SIZE(preinit_po1030); i++) { for (i = 0; i < ARRAY_SIZE(preinit_po1030); i++) {
u8 data = preinit_po1030[i][2]; u8 data = preinit_po1030[i][2];
if (preinit_po1030[i][0] == SENSOR) if (preinit_po1030[i][0] == SENSOR)
po1030_write_sensor(sd, m5602_write_sensor(sd,
preinit_po1030[i][1], &data, 1); preinit_po1030[i][1], &data, 1);
else else
m5602_write_bridge(sd, preinit_po1030[i][1], data); m5602_write_bridge(sd, preinit_po1030[i][1], data);
@ -158,14 +158,14 @@ int po1030_init(struct sd *sd)
case SENSOR: case SENSOR:
data[0] = init_po1030[i][2]; data[0] = init_po1030[i][2];
err = po1030_write_sensor(sd, err = m5602_write_sensor(sd,
init_po1030[i][1], data, 1); init_po1030[i][1], data, 1);
break; break;
case SENSOR_LONG: case SENSOR_LONG:
data[0] = init_po1030[i][2]; data[0] = init_po1030[i][2];
data[1] = init_po1030[i][3]; data[1] = init_po1030[i][3];
err = po1030_write_sensor(sd, err = m5602_write_sensor(sd,
init_po1030[i][1], data, 2); init_po1030[i][1], data, 2);
break; break;
default: default:
@ -213,7 +213,7 @@ int po1030_set_exposure(struct gspca_dev *gspca_dev, __s32 val)
PDEBUG(D_V4L2, "Set exposure to high byte to 0x%x", PDEBUG(D_V4L2, "Set exposure to high byte to 0x%x",
i2c_data); i2c_data);
err = po1030_write_sensor(sd, PO1030_REG_INTEGLINES_H, err = m5602_write_sensor(sd, PO1030_REG_INTEGLINES_H,
&i2c_data, 1); &i2c_data, 1);
if (err < 0) if (err < 0)
goto out; goto out;
@ -221,7 +221,7 @@ int po1030_set_exposure(struct gspca_dev *gspca_dev, __s32 val)
i2c_data = (val & 0xff); i2c_data = (val & 0xff);
PDEBUG(D_V4L2, "Set exposure to low byte to 0x%x", PDEBUG(D_V4L2, "Set exposure to low byte to 0x%x",
i2c_data); i2c_data);
err = po1030_write_sensor(sd, PO1030_REG_INTEGLINES_M, err = m5602_write_sensor(sd, PO1030_REG_INTEGLINES_M,
&i2c_data, 1); &i2c_data, 1);
out: out:
@ -268,7 +268,7 @@ int po1030_set_hflip(struct gspca_dev *gspca_dev, __s32 val)
i2c_data = (val & 0x01) << 7; i2c_data = (val & 0x01) << 7;
err = po1030_write_sensor(sd, PO1030_REG_CONTROL2, err = m5602_write_sensor(sd, PO1030_REG_CONTROL2,
&i2c_data, 1); &i2c_data, 1);
return err; return err;
@ -300,7 +300,7 @@ int po1030_set_vflip(struct gspca_dev *gspca_dev, __s32 val)
i2c_data = (val & 0x01) << 6; i2c_data = (val & 0x01) << 6;
err = po1030_write_sensor(sd, PO1030_REG_CONTROL2, err = m5602_write_sensor(sd, PO1030_REG_CONTROL2,
&i2c_data, 1); &i2c_data, 1);
return err; return err;
@ -314,7 +314,7 @@ int po1030_set_gain(struct gspca_dev *gspca_dev, __s32 val)
i2c_data = val & 0xff; i2c_data = val & 0xff;
PDEBUG(D_V4L2, "Set global gain to %d", i2c_data); PDEBUG(D_V4L2, "Set global gain to %d", i2c_data);
err = po1030_write_sensor(sd, PO1030_REG_GLOBALGAIN, err = m5602_write_sensor(sd, PO1030_REG_GLOBALGAIN,
&i2c_data, 1); &i2c_data, 1);
return err; return err;
} }
@ -340,7 +340,7 @@ int po1030_set_red_balance(struct gspca_dev *gspca_dev, __s32 val)
i2c_data = val & 0xff; i2c_data = val & 0xff;
PDEBUG(D_V4L2, "Set red gain to %d", i2c_data); PDEBUG(D_V4L2, "Set red gain to %d", i2c_data);
err = po1030_write_sensor(sd, PO1030_REG_RED_GAIN, err = m5602_write_sensor(sd, PO1030_REG_RED_GAIN,
&i2c_data, 1); &i2c_data, 1);
return err; return err;
} }
@ -366,7 +366,7 @@ int po1030_set_blue_balance(struct gspca_dev *gspca_dev, __s32 val)
int err; int err;
i2c_data = val & 0xff; i2c_data = val & 0xff;
PDEBUG(D_V4L2, "Set blue gain to %d", i2c_data); PDEBUG(D_V4L2, "Set blue gain to %d", i2c_data);
err = po1030_write_sensor(sd, PO1030_REG_BLUE_GAIN, err = m5602_write_sensor(sd, PO1030_REG_BLUE_GAIN,
&i2c_data, 1); &i2c_data, 1);
return err; return err;
@ -397,7 +397,7 @@ static void po1030_dump_registers(struct sd *sd)
u8 test_value[2] = {0xff, 0xff}; u8 test_value[2] = {0xff, 0xff};
po1030_read_sensor(sd, address, &old_value, 1); po1030_read_sensor(sd, address, &old_value, 1);
po1030_write_sensor(sd, address, test_value, 1); m5602_write_sensor(sd, address, test_value, 1);
po1030_read_sensor(sd, address, &ctrl_value, 1); po1030_read_sensor(sd, address, &ctrl_value, 1);
if (ctrl_value == test_value[0]) if (ctrl_value == test_value[0])
@ -406,6 +406,6 @@ static void po1030_dump_registers(struct sd *sd)
info("register 0x%x is read only", address); info("register 0x%x is read only", address);
/* Restore original value */ /* Restore original value */
po1030_write_sensor(sd, address, &old_value, 1); m5602_write_sensor(sd, address, &old_value, 1);
} }
} }

View File

@ -83,7 +83,7 @@ int s5k4aa_probe(struct sd *sd)
case SENSOR: case SENSOR:
data[0] = preinit_s5k4aa[i][2]; data[0] = preinit_s5k4aa[i][2];
err = s5k4aa_write_sensor(sd, err = m5602_write_sensor(sd,
preinit_s5k4aa[i][1], preinit_s5k4aa[i][1],
data, 1); data, 1);
break; break;
@ -91,7 +91,7 @@ int s5k4aa_probe(struct sd *sd)
case SENSOR_LONG: case SENSOR_LONG:
data[0] = preinit_s5k4aa[i][2]; data[0] = preinit_s5k4aa[i][2];
data[1] = preinit_s5k4aa[i][3]; data[1] = preinit_s5k4aa[i][3];
err = s5k4aa_write_sensor(sd, err = m5602_write_sensor(sd,
preinit_s5k4aa[i][1], preinit_s5k4aa[i][1],
data, 2); data, 2);
break; break;
@ -219,14 +219,14 @@ int s5k4aa_init(struct sd *sd)
case SENSOR: case SENSOR:
data[0] = init_s5k4aa[i][2]; data[0] = init_s5k4aa[i][2];
err = s5k4aa_write_sensor(sd, err = m5602_write_sensor(sd,
init_s5k4aa[i][1], data, 1); init_s5k4aa[i][1], data, 1);
break; break;
case SENSOR_LONG: case SENSOR_LONG:
data[0] = init_s5k4aa[i][2]; data[0] = init_s5k4aa[i][2];
data[1] = init_s5k4aa[i][3]; data[1] = init_s5k4aa[i][3];
err = s5k4aa_write_sensor(sd, err = m5602_write_sensor(sd,
init_s5k4aa[i][1], data, 2); init_s5k4aa[i][1], data, 2);
break; break;
default: default:
@ -241,21 +241,21 @@ int s5k4aa_init(struct sd *sd)
if (!err && dmi_check_system(s5k4aa_vflip_dmi_table)) { if (!err && dmi_check_system(s5k4aa_vflip_dmi_table)) {
u8 data = 0x02; u8 data = 0x02;
info("vertical flip quirk active"); info("vertical flip quirk active");
s5k4aa_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1);
s5k4aa_read_sensor(sd, S5K4AA_READ_MODE, &data, 1); s5k4aa_read_sensor(sd, S5K4AA_READ_MODE, &data, 1);
data |= S5K4AA_RM_V_FLIP; data |= S5K4AA_RM_V_FLIP;
data &= ~S5K4AA_RM_H_FLIP; data &= ~S5K4AA_RM_H_FLIP;
s5k4aa_write_sensor(sd, S5K4AA_READ_MODE, &data, 1); m5602_write_sensor(sd, S5K4AA_READ_MODE, &data, 1);
/* Decrement COLSTART to preserve color order (BGGR) */ /* Decrement COLSTART to preserve color order (BGGR) */
s5k4aa_read_sensor(sd, S5K4AA_COLSTART_LO, &data, 1); s5k4aa_read_sensor(sd, S5K4AA_COLSTART_LO, &data, 1);
data--; data--;
s5k4aa_write_sensor(sd, S5K4AA_COLSTART_LO, &data, 1); m5602_write_sensor(sd, S5K4AA_COLSTART_LO, &data, 1);
/* Increment ROWSTART to preserve color order (BGGR) */ /* Increment ROWSTART to preserve color order (BGGR) */
s5k4aa_read_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1); s5k4aa_read_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1);
data++; data++;
s5k4aa_write_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1); m5602_write_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1);
} }
return (err < 0) ? err : 0; return (err < 0) ? err : 0;
@ -272,7 +272,7 @@ int s5k4aa_get_exposure(struct gspca_dev *gspca_dev, __s32 *val)
u8 data = S5K4AA_PAGE_MAP_2; u8 data = S5K4AA_PAGE_MAP_2;
int err; int err;
err = s5k4aa_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1);
if (err < 0) if (err < 0)
goto out; goto out;
@ -295,15 +295,15 @@ int s5k4aa_set_exposure(struct gspca_dev *gspca_dev, __s32 val)
int err; int err;
PDEBUG(D_V4L2, "Set exposure to %d", val); PDEBUG(D_V4L2, "Set exposure to %d", val);
err = s5k4aa_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1);
if (err < 0) if (err < 0)
goto out; goto out;
data = (val >> 8) & 0xff; data = (val >> 8) & 0xff;
err = s5k4aa_write_sensor(sd, S5K4AA_EXPOSURE_HI, &data, 1); err = m5602_write_sensor(sd, S5K4AA_EXPOSURE_HI, &data, 1);
if (err < 0) if (err < 0)
goto out; goto out;
data = val & 0xff; data = val & 0xff;
err = s5k4aa_write_sensor(sd, S5K4AA_EXPOSURE_LO, &data, 1); err = m5602_write_sensor(sd, S5K4AA_EXPOSURE_LO, &data, 1);
out: out:
return err; return err;
} }
@ -314,7 +314,7 @@ int s5k4aa_get_vflip(struct gspca_dev *gspca_dev, __s32 *val)
u8 data = S5K4AA_PAGE_MAP_2; u8 data = S5K4AA_PAGE_MAP_2;
int err; int err;
err = s5k4aa_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1);
if (err < 0) if (err < 0)
goto out; goto out;
@ -333,15 +333,15 @@ int s5k4aa_set_vflip(struct gspca_dev *gspca_dev, __s32 val)
int err; int err;
PDEBUG(D_V4L2, "Set vertical flip to %d", val); PDEBUG(D_V4L2, "Set vertical flip to %d", val);
err = s5k4aa_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1);
if (err < 0) if (err < 0)
goto out; goto out;
err = s5k4aa_write_sensor(sd, S5K4AA_READ_MODE, &data, 1); err = m5602_write_sensor(sd, S5K4AA_READ_MODE, &data, 1);
if (err < 0) if (err < 0)
goto out; goto out;
data = ((data & ~S5K4AA_RM_V_FLIP) data = ((data & ~S5K4AA_RM_V_FLIP)
| ((val & 0x01) << 7)); | ((val & 0x01) << 7));
err = s5k4aa_write_sensor(sd, S5K4AA_READ_MODE, &data, 1); err = m5602_write_sensor(sd, S5K4AA_READ_MODE, &data, 1);
if (err < 0) if (err < 0)
goto out; goto out;
@ -351,14 +351,14 @@ int s5k4aa_set_vflip(struct gspca_dev *gspca_dev, __s32 val)
goto out; goto out;
data++; data++;
err = s5k4aa_write_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1); err = m5602_write_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1);
} else { } else {
err = s5k4aa_read_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1); err = s5k4aa_read_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1);
if (err < 0) if (err < 0)
goto out; goto out;
data--; data--;
err = s5k4aa_write_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1); err = m5602_write_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1);
} }
out: out:
return err; return err;
@ -370,7 +370,7 @@ int s5k4aa_get_hflip(struct gspca_dev *gspca_dev, __s32 *val)
u8 data = S5K4AA_PAGE_MAP_2; u8 data = S5K4AA_PAGE_MAP_2;
int err; int err;
err = s5k4aa_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1);
if (err < 0) if (err < 0)
goto out; goto out;
@ -389,15 +389,15 @@ int s5k4aa_set_hflip(struct gspca_dev *gspca_dev, __s32 val)
PDEBUG(D_V4L2, "Set horizontal flip to %d", PDEBUG(D_V4L2, "Set horizontal flip to %d",
val); val);
err = s5k4aa_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1);
if (err < 0) if (err < 0)
goto out; goto out;
err = s5k4aa_write_sensor(sd, S5K4AA_READ_MODE, &data, 1); err = m5602_write_sensor(sd, S5K4AA_READ_MODE, &data, 1);
if (err < 0) if (err < 0)
goto out; goto out;
data = ((data & ~S5K4AA_RM_H_FLIP) | ((val & 0x01) << 6)); data = ((data & ~S5K4AA_RM_H_FLIP) | ((val & 0x01) << 6));
err = s5k4aa_write_sensor(sd, S5K4AA_READ_MODE, &data, 1); err = m5602_write_sensor(sd, S5K4AA_READ_MODE, &data, 1);
if (err < 0) if (err < 0)
goto out; goto out;
@ -406,7 +406,7 @@ int s5k4aa_set_hflip(struct gspca_dev *gspca_dev, __s32 val)
if (err < 0) if (err < 0)
goto out; goto out;
data++; data++;
err = s5k4aa_write_sensor(sd, S5K4AA_COLSTART_LO, &data, 1); err = m5602_write_sensor(sd, S5K4AA_COLSTART_LO, &data, 1);
if (err < 0) if (err < 0)
goto out; goto out;
} else { } else {
@ -414,7 +414,7 @@ int s5k4aa_set_hflip(struct gspca_dev *gspca_dev, __s32 val)
if (err < 0) if (err < 0)
goto out; goto out;
data--; data--;
err = s5k4aa_write_sensor(sd, S5K4AA_COLSTART_LO, &data, 1); err = m5602_write_sensor(sd, S5K4AA_COLSTART_LO, &data, 1);
} }
out: out:
return err; return err;
@ -426,7 +426,7 @@ int s5k4aa_get_gain(struct gspca_dev *gspca_dev, __s32 *val)
u8 data = S5K4AA_PAGE_MAP_2; u8 data = S5K4AA_PAGE_MAP_2;
int err; int err;
err = s5k4aa_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1);
if (err < 0) if (err < 0)
goto out; goto out;
@ -445,12 +445,12 @@ int s5k4aa_set_gain(struct gspca_dev *gspca_dev, __s32 val)
int err; int err;
PDEBUG(D_V4L2, "Set gain to %d", val); PDEBUG(D_V4L2, "Set gain to %d", val);
err = s5k4aa_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1);
if (err < 0) if (err < 0)
goto out; goto out;
data = val & 0xff; data = val & 0xff;
err = s5k4aa_write_sensor(sd, S5K4AA_GAIN_2, &data, 1); err = m5602_write_sensor(sd, S5K4AA_GAIN_2, &data, 1);
out: out:
return err; return err;
@ -462,7 +462,7 @@ static void s5k4aa_dump_registers(struct sd *sd)
u8 page, old_page; u8 page, old_page;
s5k4aa_read_sensor(sd, S5K4AA_PAGE_MAP, &old_page, 1); s5k4aa_read_sensor(sd, S5K4AA_PAGE_MAP, &old_page, 1);
for (page = 0; page < 16; page++) { for (page = 0; page < 16; page++) {
s5k4aa_write_sensor(sd, S5K4AA_PAGE_MAP, &page, 1); m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &page, 1);
info("Dumping the s5k4aa register state for page 0x%x", page); info("Dumping the s5k4aa register state for page 0x%x", page);
for (address = 0; address <= 0xff; address++) { for (address = 0; address <= 0xff; address++) {
u8 value = 0; u8 value = 0;
@ -474,14 +474,14 @@ static void s5k4aa_dump_registers(struct sd *sd)
info("s5k4aa register state dump complete"); info("s5k4aa register state dump complete");
for (page = 0; page < 16; page++) { for (page = 0; page < 16; page++) {
s5k4aa_write_sensor(sd, S5K4AA_PAGE_MAP, &page, 1); m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &page, 1);
info("Probing for which registers that are " info("Probing for which registers that are "
"read/write for page 0x%x", page); "read/write for page 0x%x", page);
for (address = 0; address <= 0xff; address++) { for (address = 0; address <= 0xff; address++) {
u8 old_value, ctrl_value, test_value = 0xff; u8 old_value, ctrl_value, test_value = 0xff;
s5k4aa_read_sensor(sd, address, &old_value, 1); s5k4aa_read_sensor(sd, address, &old_value, 1);
s5k4aa_write_sensor(sd, address, &test_value, 1); m5602_write_sensor(sd, address, &test_value, 1);
s5k4aa_read_sensor(sd, address, &ctrl_value, 1); s5k4aa_read_sensor(sd, address, &ctrl_value, 1);
if (ctrl_value == test_value) if (ctrl_value == test_value)
@ -490,9 +490,9 @@ static void s5k4aa_dump_registers(struct sd *sd)
info("register 0x%x is read only", address); info("register 0x%x is read only", address);
/* Restore original value */ /* Restore original value */
s5k4aa_write_sensor(sd, address, &old_value, 1); m5602_write_sensor(sd, address, &old_value, 1);
} }
} }
info("Read/write register probing complete"); info("Read/write register probing complete");
s5k4aa_write_sensor(sd, S5K4AA_PAGE_MAP, &old_page, 1); m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &old_page, 1);
} }

View File

@ -41,7 +41,7 @@ int s5k83a_probe(struct sd *sd)
for (i = 0; i < ARRAY_SIZE(preinit_s5k83a) && !err; i++) { for (i = 0; i < ARRAY_SIZE(preinit_s5k83a) && !err; i++) {
u8 data[2] = {preinit_s5k83a[i][2], preinit_s5k83a[i][3]}; u8 data[2] = {preinit_s5k83a[i][2], preinit_s5k83a[i][3]};
if (preinit_s5k83a[i][0] == SENSOR) if (preinit_s5k83a[i][0] == SENSOR)
err = s5k83a_write_sensor(sd, preinit_s5k83a[i][1], err = m5602_write_sensor(sd, preinit_s5k83a[i][1],
data, 2); data, 2);
else else
err = m5602_write_bridge(sd, preinit_s5k83a[i][1], err = m5602_write_bridge(sd, preinit_s5k83a[i][1],
@ -167,14 +167,14 @@ int s5k83a_init(struct sd *sd)
case SENSOR: case SENSOR:
data[0] = init_s5k83a[i][2]; data[0] = init_s5k83a[i][2];
err = s5k83a_write_sensor(sd, err = m5602_write_sensor(sd,
init_s5k83a[i][1], data, 1); init_s5k83a[i][1], data, 1);
break; break;
case SENSOR_LONG: case SENSOR_LONG:
data[0] = init_s5k83a[i][2]; data[0] = init_s5k83a[i][2];
data[1] = init_s5k83a[i][3]; data[1] = init_s5k83a[i][3];
err = s5k83a_write_sensor(sd, err = m5602_write_sensor(sd,
init_s5k83a[i][1], data, 2); init_s5k83a[i][1], data, 2);
break; break;
default: default:
@ -201,7 +201,7 @@ void s5k83a_dump_registers(struct sd *sd)
s5k83a_read_sensor(sd, S5K83A_PAGE_MAP, &old_page, 1); s5k83a_read_sensor(sd, S5K83A_PAGE_MAP, &old_page, 1);
for (page = 0; page < 16; page++) { for (page = 0; page < 16; page++) {
s5k83a_write_sensor(sd, S5K83A_PAGE_MAP, &page, 1); m5602_write_sensor(sd, S5K83A_PAGE_MAP, &page, 1);
info("Dumping the s5k83a register state for page 0x%x", page); info("Dumping the s5k83a register state for page 0x%x", page);
for (address = 0; address <= 0xff; address++) { for (address = 0; address <= 0xff; address++) {
u8 val = 0; u8 val = 0;
@ -213,14 +213,14 @@ void s5k83a_dump_registers(struct sd *sd)
info("s5k83a register state dump complete"); info("s5k83a register state dump complete");
for (page = 0; page < 16; page++) { for (page = 0; page < 16; page++) {
s5k83a_write_sensor(sd, S5K83A_PAGE_MAP, &page, 1); m5602_write_sensor(sd, S5K83A_PAGE_MAP, &page, 1);
info("Probing for which registers that are read/write " info("Probing for which registers that are read/write "
"for page 0x%x", page); "for page 0x%x", page);
for (address = 0; address <= 0xff; address++) { for (address = 0; address <= 0xff; address++) {
u8 old_val, ctrl_val, test_val = 0xff; u8 old_val, ctrl_val, test_val = 0xff;
s5k83a_read_sensor(sd, address, &old_val, 1); s5k83a_read_sensor(sd, address, &old_val, 1);
s5k83a_write_sensor(sd, address, &test_val, 1); m5602_write_sensor(sd, address, &test_val, 1);
s5k83a_read_sensor(sd, address, &ctrl_val, 1); s5k83a_read_sensor(sd, address, &ctrl_val, 1);
if (ctrl_val == test_val) if (ctrl_val == test_val)
@ -229,11 +229,11 @@ void s5k83a_dump_registers(struct sd *sd)
info("register 0x%x is read only", address); info("register 0x%x is read only", address);
/* Restore original val */ /* Restore original val */
s5k83a_write_sensor(sd, address, &old_val, 1); m5602_write_sensor(sd, address, &old_val, 1);
} }
} }
info("Read/write register probing complete"); info("Read/write register probing complete");
s5k83a_write_sensor(sd, S5K83A_PAGE_MAP, &old_page, 1); m5602_write_sensor(sd, S5K83A_PAGE_MAP, &old_page, 1);
} }
int s5k83a_get_brightness(struct gspca_dev *gspca_dev, __s32 *val) int s5k83a_get_brightness(struct gspca_dev *gspca_dev, __s32 *val)
@ -261,13 +261,13 @@ int s5k83a_set_brightness(struct gspca_dev *gspca_dev, __s32 val)
data[0] = 0x00; data[0] = 0x00;
data[1] = 0x20; data[1] = 0x20;
err = s5k83a_write_sensor(sd, 0x14, data, 2); err = m5602_write_sensor(sd, 0x14, data, 2);
if (err < 0) if (err < 0)
goto out; goto out;
data[0] = 0x01; data[0] = 0x01;
data[1] = 0x00; data[1] = 0x00;
err = s5k83a_write_sensor(sd, 0x0d, data, 2); err = m5602_write_sensor(sd, 0x0d, data, 2);
if (err < 0) if (err < 0)
goto out; goto out;
@ -275,7 +275,7 @@ int s5k83a_set_brightness(struct gspca_dev *gspca_dev, __s32 val)
of these registers */ of these registers */
data[0] = val >> 3; /* brightness, high 5 bits */ data[0] = val >> 3; /* brightness, high 5 bits */
data[1] = val >> 1; /* brightness, high 7 bits */ data[1] = val >> 1; /* brightness, high 7 bits */
err = s5k83a_write_sensor(sd, S5K83A_BRIGHTNESS, data, 2); err = m5602_write_sensor(sd, S5K83A_BRIGHTNESS, data, 2);
out: out:
return err; return err;
@ -304,7 +304,7 @@ int s5k83a_set_whiteness(struct gspca_dev *gspca_dev, __s32 val)
struct sd *sd = (struct sd *) gspca_dev; struct sd *sd = (struct sd *) gspca_dev;
data[0] = val; data[0] = val;
err = s5k83a_write_sensor(sd, S5K83A_WHITENESS, data, 1); err = m5602_write_sensor(sd, S5K83A_WHITENESS, data, 1);
return err; return err;
} }
@ -337,7 +337,7 @@ int s5k83a_set_gain(struct gspca_dev *gspca_dev, __s32 val)
data[0] = 0; data[0] = 0;
data[1] = val; data[1] = val;
err = s5k83a_write_sensor(sd, S5K83A_GAIN, data, 2); err = m5602_write_sensor(sd, S5K83A_GAIN, data, 2);
return err; return err;
} }
@ -348,7 +348,7 @@ int s5k83a_get_vflip(struct gspca_dev *gspca_dev, __s32 *val)
struct sd *sd = (struct sd *) gspca_dev; struct sd *sd = (struct sd *) gspca_dev;
data[0] = 0x05; data[0] = 0x05;
err = s5k83a_write_sensor(sd, S5K83A_PAGE_MAP, data, 1); err = m5602_write_sensor(sd, S5K83A_PAGE_MAP, data, 1);
if (err < 0) if (err < 0)
goto out; goto out;
@ -366,7 +366,7 @@ int s5k83a_set_vflip(struct gspca_dev *gspca_dev, __s32 val)
struct sd *sd = (struct sd *) gspca_dev; struct sd *sd = (struct sd *) gspca_dev;
data[0] = 0x05; data[0] = 0x05;
err = s5k83a_write_sensor(sd, S5K83A_PAGE_MAP, data, 1); err = m5602_write_sensor(sd, S5K83A_PAGE_MAP, data, 1);
if (err < 0) if (err < 0)
goto out; goto out;
@ -377,12 +377,12 @@ int s5k83a_set_vflip(struct gspca_dev *gspca_dev, __s32 val)
/* set or zero six bit, seven is hflip */ /* set or zero six bit, seven is hflip */
data[0] = (val) ? (data[0] & 0x80) | 0x40 | S5K83A_FLIP_MASK data[0] = (val) ? (data[0] & 0x80) | 0x40 | S5K83A_FLIP_MASK
: (data[0] & 0x80) | S5K83A_FLIP_MASK; : (data[0] & 0x80) | S5K83A_FLIP_MASK;
err = s5k83a_write_sensor(sd, S5K83A_FLIP, data, 1); err = m5602_write_sensor(sd, S5K83A_FLIP, data, 1);
if (err < 0) if (err < 0)
goto out; goto out;
data[0] = (val) ? 0x0b : 0x0a; data[0] = (val) ? 0x0b : 0x0a;
err = s5k83a_write_sensor(sd, S5K83A_VFLIP_TUNE, data, 1); err = m5602_write_sensor(sd, S5K83A_VFLIP_TUNE, data, 1);
out: out:
return err; return err;
@ -395,7 +395,7 @@ int s5k83a_get_hflip(struct gspca_dev *gspca_dev, __s32 *val)
struct sd *sd = (struct sd *) gspca_dev; struct sd *sd = (struct sd *) gspca_dev;
data[0] = 0x05; data[0] = 0x05;
err = s5k83a_write_sensor(sd, S5K83A_PAGE_MAP, data, 1); err = m5602_write_sensor(sd, S5K83A_PAGE_MAP, data, 1);
if (err < 0) if (err < 0)
goto out; goto out;
@ -413,7 +413,7 @@ int s5k83a_set_hflip(struct gspca_dev *gspca_dev, __s32 val)
struct sd *sd = (struct sd *) gspca_dev; struct sd *sd = (struct sd *) gspca_dev;
data[0] = 0x05; data[0] = 0x05;
err = s5k83a_write_sensor(sd, S5K83A_PAGE_MAP, data, 1); err = m5602_write_sensor(sd, S5K83A_PAGE_MAP, data, 1);
if (err < 0) if (err < 0)
goto out; goto out;
@ -424,12 +424,12 @@ int s5k83a_set_hflip(struct gspca_dev *gspca_dev, __s32 val)
/* set or zero seven bit, six is vflip */ /* set or zero seven bit, six is vflip */
data[0] = (val) ? (data[0] & 0x40) | 0x80 | S5K83A_FLIP_MASK data[0] = (val) ? (data[0] & 0x40) | 0x80 | S5K83A_FLIP_MASK
: (data[0] & 0x40) | S5K83A_FLIP_MASK; : (data[0] & 0x40) | S5K83A_FLIP_MASK;
err = s5k83a_write_sensor(sd, S5K83A_FLIP, data, 1); err = m5602_write_sensor(sd, S5K83A_FLIP, data, 1);
if (err < 0) if (err < 0)
goto out; goto out;
data[0] = (val) ? 0x0a : 0x0b; data[0] = (val) ? 0x0a : 0x0b;
err = s5k83a_write_sensor(sd, S5K83A_HFLIP_TUNE, data, 1); err = m5602_write_sensor(sd, S5K83A_HFLIP_TUNE, data, 1);
out: out:
return err; return err;
} }