19 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
107 .ident =
"Alienware Aurora m9700",
116 static const struct ctrl ov9650_ctrls[] = {
117 #define EXPOSURE_IDX 0
129 .set = ov9650_set_exposure,
130 .get = ov9650_get_exposure
144 .set = ov9650_set_gain,
145 .get = ov9650_get_gain
147 #define RED_BALANCE_IDX 2
152 .name =
"red balance",
159 .set = ov9650_set_red_balance,
160 .get = ov9650_get_red_balance
162 #define BLUE_BALANCE_IDX 3
167 .name =
"blue balance",
174 .set = ov9650_set_blue_balance,
175 .get = ov9650_get_blue_balance
182 .name =
"horizontal flip",
188 .set = ov9650_set_hflip,
189 .get = ov9650_get_hflip
196 .name =
"vertical flip",
202 .set = ov9650_set_vflip,
203 .get = ov9650_get_vflip
205 #define AUTO_WHITE_BALANCE_IDX 6
210 .name =
"auto white balance",
216 .set = ov9650_set_auto_white_balance,
217 .get = ov9650_get_auto_white_balance
219 #define AUTO_GAIN_CTRL_IDX 7
224 .name =
"auto gain control",
230 .set = ov9650_set_auto_gain,
231 .get = ov9650_get_auto_gain
233 #define AUTO_EXPOSURE_IDX 8
238 .name =
"auto exposure",
244 .set = ov9650_set_auto_exposure,
245 .get = ov9650_get_auto_exposure
294 static void ov9650_dump_registers(
struct sd *
sd);
299 u8 prod_id = 0, ver_id = 0,
i;
300 s32 *sensor_settings;
304 pr_info(
"Forcing an %s sensor\n", ov9650.name);
312 PDEBUG(D_PROBE,
"Probing for an ov9650 sensor");
316 u8 data = preinit_ov9650[
i][2];
317 if (preinit_ov9650[
i][0] ==
SENSOR)
319 preinit_ov9650[
i][1], &data, 1);
322 preinit_ov9650[i][1], data);
334 if ((prod_id == 0x96) && (ver_id == 0x52)) {
335 pr_info(
"Detected an ov9650 sensor\n");
343 if (!sensor_settings)
346 sd->
gspca_dev.cam.cam_mode = ov9650_modes;
348 sd->
desc->ctrls = ov9650_ctrls;
352 sensor_settings[
i] = ov9650_ctrls[
i].qctrl.default_value;
364 ov9650_dump_registers(sd);
367 data = init_ov9650[
i][2];
368 if (init_ov9650[i][0] ==
SENSOR)
375 err = ov9650_set_exposure(&sd->
gspca_dev,
384 err = ov9650_set_red_balance(&sd->
gspca_dev,
389 err = ov9650_set_blue_balance(&sd->
gspca_dev,
402 err = ov9650_set_auto_exposure(&sd->
gspca_dev,
407 err = ov9650_set_auto_white_balance(&sd->
gspca_dev,
412 err = ov9650_set_auto_gain(&sd->
gspca_dev,
432 !sensor_settings[VFLIP_IDX]))
440 if (res_init_ov9650[i][0] ==
BRIDGE)
442 res_init_ov9650[i][2]);
443 else if (res_init_ov9650[i][0] ==
SENSOR) {
444 data = res_init_ov9650[
i][2];
446 res_init_ov9650[i][1], &data, 1);
453 ((ver_offs >> 8) & 0xff));
473 for (i = 0; i < 2 && !
err; i++)
487 (hor_offs >> 8) & 0xff);
496 ((width + hor_offs) >> 8) & 0xff);
501 ((width + hor_offs) & 0xff));
511 PDEBUG(D_V4L2,
"Configuring camera for VGA mode");
519 PDEBUG(D_V4L2,
"Configuring camera for CIF mode");
527 PDEBUG(D_V4L2,
"Configuring camera for QVGA mode");
535 PDEBUG(D_V4L2,
"Configuring camera for QCIF mode");
561 struct sd *
sd = (
struct sd *) gspca_dev;
565 PDEBUG(D_V4L2,
"Read exposure %d", *val);
571 struct sd *
sd = (
struct sd *) gspca_dev;
576 PDEBUG(D_V4L2,
"Set exposure to %d", val);
580 i2c_data = (val >> 10) & 0x3f;
587 i2c_data = (val >> 2) & 0xff;
594 i2c_data = val & 0x03;
599 static int ov9650_get_gain(
struct gspca_dev *gspca_dev,
__s32 *val)
601 struct sd *sd = (
struct sd *) gspca_dev;
605 PDEBUG(D_V4L2,
"Read gain %d", *val);
609 static int ov9650_set_gain(
struct gspca_dev *gspca_dev,
__s32 val)
613 struct sd *sd = (
struct sd *) gspca_dev;
616 PDEBUG(D_V4L2,
"Setting gain to %d", val);
628 i2c_data = ((val & 0x0300) >> 2) |
635 i2c_data = val & 0xff;
640 static int ov9650_get_red_balance(
struct gspca_dev *gspca_dev,
__s32 *val)
642 struct sd *sd = (
struct sd *) gspca_dev;
646 PDEBUG(D_V4L2,
"Read red gain %d", *val);
650 static int ov9650_set_red_balance(
struct gspca_dev *gspca_dev,
__s32 val)
654 struct sd *sd = (
struct sd *) gspca_dev;
657 PDEBUG(D_V4L2,
"Set red gain to %d", val);
661 i2c_data = val & 0xff;
666 static int ov9650_get_blue_balance(
struct gspca_dev *gspca_dev,
__s32 *val)
668 struct sd *sd = (
struct sd *) gspca_dev;
672 PDEBUG(D_V4L2,
"Read blue gain %d", *val);
677 static int ov9650_set_blue_balance(
struct gspca_dev *gspca_dev,
__s32 val)
681 struct sd *sd = (
struct sd *) gspca_dev;
684 PDEBUG(D_V4L2,
"Set blue gain to %d", val);
688 i2c_data = val & 0xff;
693 static int ov9650_get_hflip(
struct gspca_dev *gspca_dev,
__s32 *val)
695 struct sd *sd = (
struct sd *) gspca_dev;
699 PDEBUG(D_V4L2,
"Read horizontal flip %d", *val);
703 static int ov9650_set_hflip(
struct gspca_dev *gspca_dev,
__s32 val)
707 struct sd *sd = (
struct sd *) gspca_dev;
710 PDEBUG(D_V4L2,
"Set horizontal flip to %d", val);
715 i2c_data = ((val & 0x01) << 5) |
718 i2c_data = ((val & 0x01) << 5) |
726 static int ov9650_get_vflip(
struct gspca_dev *gspca_dev,
__s32 *val)
728 struct sd *sd = (
struct sd *) gspca_dev;
732 PDEBUG(D_V4L2,
"Read vertical flip %d", *val);
737 static int ov9650_set_vflip(
struct gspca_dev *gspca_dev,
__s32 val)
741 struct sd *sd = (
struct sd *) gspca_dev;
744 PDEBUG(D_V4L2,
"Set vertical flip to %d", val);
750 i2c_data = ((val & 0x01) << 4) | (sensor_settings[
VFLIP_IDX] << 5);
762 static int ov9650_get_auto_exposure(
struct gspca_dev *gspca_dev,
__s32 *val)
764 struct sd *sd = (
struct sd *) gspca_dev;
768 PDEBUG(D_V4L2,
"Read auto exposure control %d", *val);
772 static int ov9650_set_auto_exposure(
struct gspca_dev *gspca_dev,
777 struct sd *sd = (
struct sd *) gspca_dev;
780 PDEBUG(D_V4L2,
"Set auto exposure control to %d", val);
787 i2c_data = ((i2c_data & 0xfe) | ((val & 0x01) << 0));
792 static int ov9650_get_auto_white_balance(
struct gspca_dev *gspca_dev,
795 struct sd *sd = (
struct sd *) gspca_dev;
802 static int ov9650_set_auto_white_balance(
struct gspca_dev *gspca_dev,
807 struct sd *sd = (
struct sd *) gspca_dev;
810 PDEBUG(D_V4L2,
"Set auto white balance to %d", val);
817 i2c_data = ((i2c_data & 0xfd) | ((val & 0x01) << 1));
823 static int ov9650_get_auto_gain(
struct gspca_dev *gspca_dev,
__s32 *val)
825 struct sd *sd = (
struct sd *) gspca_dev;
829 PDEBUG(D_V4L2,
"Read auto gain control %d", *val);
833 static int ov9650_set_auto_gain(
struct gspca_dev *gspca_dev,
__s32 val)
837 struct sd *sd = (
struct sd *) gspca_dev;
840 PDEBUG(D_V4L2,
"Set auto gain control to %d", val);
847 i2c_data = ((i2c_data & 0xfb) | ((val & 0x01) << 2));
852 static void ov9650_dump_registers(
struct sd *sd)
855 pr_info(
"Dumping the ov9650 register state\n");
856 for (address = 0; address < 0xa9; address++) {
859 pr_info(
"register 0x%x contains 0x%x\n", address, value);
862 pr_info(
"ov9650 register state dump complete\n");
864 pr_info(
"Probing for which registers that are read/write\n");
865 for (address = 0; address < 0xff; address++) {
866 u8 old_value, ctrl_value;
867 u8 test_value[2] = {0xff, 0xff};
873 if (ctrl_value == test_value[0])
874 pr_info(
"register 0x%x is writeable\n", address);
876 pr_info(
"register 0x%x is read only\n", address);