19 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
38 static const struct ctrl ov7660_ctrls[] = {
51 .set = ov7660_set_gain,
52 .get = ov7660_get_gain
54 #define BLUE_BALANCE_IDX 2
55 #define RED_BALANCE_IDX 3
56 #define AUTO_WHITE_BALANCE_IDX 4
61 .name =
"auto white balance",
67 .set = ov7660_set_auto_white_balance,
68 .get = ov7660_get_auto_white_balance
70 #define AUTO_GAIN_CTRL_IDX 5
75 .name =
"auto gain control",
81 .set = ov7660_set_auto_gain,
82 .get = ov7660_get_auto_gain
84 #define AUTO_EXPOSURE_IDX 6
89 .name =
"auto exposure",
95 .set = ov7660_set_auto_exposure,
96 .get = ov7660_get_auto_exposure
103 .name =
"horizontal flip",
109 .set = ov7660_set_hflip,
110 .get = ov7660_get_hflip
117 .name =
"vertical flip",
123 .set = ov7660_set_vflip,
124 .get = ov7660_get_vflip
143 static void ov7660_dump_registers(
struct sd *
sd);
148 u8 prod_id = 0, ver_id = 0;
150 s32 *sensor_settings;
154 pr_info(
"Forcing an %s sensor\n", ov7660.name);
166 if (preinit_ov7660[
i][0] ==
BRIDGE) {
168 preinit_ov7660[
i][1],
169 preinit_ov7660[i][2]);
171 data[0] = preinit_ov7660[
i][2];
173 preinit_ov7660[
i][1], data, 1);
185 pr_info(
"Sensor reported 0x%x%x\n", prod_id, ver_id);
187 if ((prod_id == 0x76) && (ver_id == 0x60)) {
188 pr_info(
"Detected a ov7660 sensor\n");
196 if (!sensor_settings)
199 sd->
gspca_dev.cam.cam_mode = ov7660_modes;
201 sd->
desc->ctrls = ov7660_ctrls;
205 sensor_settings[
i] = ov7660_ctrls[
i].qctrl.default_value;
217 for (i = 0; i <
ARRAY_SIZE(init_ov7660); i++) {
220 if (init_ov7660[i][0] ==
BRIDGE) {
225 data[0] = init_ov7660[
i][2];
227 init_ov7660[i][1], data, 1);
232 ov7660_dump_registers(sd);
238 err = ov7660_set_auto_white_balance(&sd->
gspca_dev,
243 err = ov7660_set_auto_gain(&sd->
gspca_dev,
248 err = ov7660_set_auto_exposure(&sd->
gspca_dev,
283 struct sd *
sd = (
struct sd *) gspca_dev;
287 PDEBUG(D_V4L2,
"Read gain %d", *val);
295 struct sd *
sd = (
struct sd *) gspca_dev;
298 PDEBUG(D_V4L2,
"Setting gain to %d", val);
310 struct sd *
sd = (
struct sd *) gspca_dev;
322 struct sd *
sd = (
struct sd *) gspca_dev;
325 PDEBUG(D_V4L2,
"Set auto white balance to %d", val);
332 i2c_data = ((i2c_data & 0xfd) | ((val & 0x01) << 1));
338 static int ov7660_get_auto_gain(
struct gspca_dev *gspca_dev,
__s32 *val)
340 struct sd *sd = (
struct sd *) gspca_dev;
344 PDEBUG(D_V4L2,
"Read auto gain control %d", *val);
348 static int ov7660_set_auto_gain(
struct gspca_dev *gspca_dev,
__s32 val)
352 struct sd *sd = (
struct sd *) gspca_dev;
355 PDEBUG(D_V4L2,
"Set auto gain control to %d", val);
362 i2c_data = ((i2c_data & 0xfb) | ((val & 0x01) << 2));
367 static int ov7660_get_auto_exposure(
struct gspca_dev *gspca_dev,
__s32 *val)
369 struct sd *sd = (
struct sd *) gspca_dev;
373 PDEBUG(D_V4L2,
"Read auto exposure control %d", *val);
377 static int ov7660_set_auto_exposure(
struct gspca_dev *gspca_dev,
382 struct sd *sd = (
struct sd *) gspca_dev;
385 PDEBUG(D_V4L2,
"Set auto exposure control to %d", val);
392 i2c_data = ((i2c_data & 0xfe) | ((val & 0x01) << 0));
397 static int ov7660_get_hflip(
struct gspca_dev *gspca_dev,
__s32 *val)
399 struct sd *sd = (
struct sd *) gspca_dev;
403 PDEBUG(D_V4L2,
"Read horizontal flip %d", *val);
407 static int ov7660_set_hflip(
struct gspca_dev *gspca_dev,
__s32 val)
411 struct sd *sd = (
struct sd *) gspca_dev;
414 PDEBUG(D_V4L2,
"Set horizontal flip to %d", val);
418 i2c_data = ((val & 0x01) << 5) |
426 static int ov7660_get_vflip(
struct gspca_dev *gspca_dev,
__s32 *val)
428 struct sd *sd = (
struct sd *) gspca_dev;
432 PDEBUG(D_V4L2,
"Read vertical flip %d", *val);
437 static int ov7660_set_vflip(
struct gspca_dev *gspca_dev,
__s32 val)
441 struct sd *sd = (
struct sd *) gspca_dev;
444 PDEBUG(D_V4L2,
"Set vertical flip to %d", val);
447 i2c_data = ((val & 0x01) << 4) | (sensor_settings[
VFLIP_IDX] << 5);
459 static void ov7660_dump_registers(
struct sd *sd)
462 pr_info(
"Dumping the ov7660 register state\n");
463 for (address = 0; address < 0xa9; address++) {
466 pr_info(
"register 0x%x contains 0x%x\n", address, value);
469 pr_info(
"ov7660 register state dump complete\n");
471 pr_info(
"Probing for which registers that are read/write\n");
472 for (address = 0; address < 0xff; address++) {
473 u8 old_value, ctrl_value;
474 u8 test_value[2] = {0xff, 0xff};
480 if (ctrl_value == test_value[0])
481 pr_info(
"register 0x%x is writeable\n", address);
483 pr_info(
"register 0x%x is read only\n", address);