19 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
52 .sizeimage = 640 * 480,
59 static const struct ctrl po1030_ctrls[] = {
72 .set = po1030_set_gain,
73 .get = po1030_get_gain
75 #define EXPOSURE_IDX 1
87 .set = po1030_set_exposure,
88 .get = po1030_get_exposure
90 #define RED_BALANCE_IDX 2
95 .name =
"red balance",
102 .set = po1030_set_red_balance,
103 .get = po1030_get_red_balance
105 #define BLUE_BALANCE_IDX 3
110 .name =
"blue balance",
117 .set = po1030_set_blue_balance,
118 .get = po1030_get_blue_balance
125 .name =
"horizontal flip",
131 .set = po1030_set_hflip,
132 .get = po1030_get_hflip
139 .name =
"vertical flip",
145 .set = po1030_set_vflip,
146 .get = po1030_get_vflip
148 #define AUTO_WHITE_BALANCE_IDX 6
153 .name =
"auto white balance",
159 .set = po1030_set_auto_white_balance,
160 .get = po1030_get_auto_white_balance
162 #define AUTO_EXPOSURE_IDX 7
167 .name =
"auto exposure",
173 .set = po1030_set_auto_exposure,
174 .get = po1030_get_auto_exposure
176 #define GREEN_BALANCE_IDX 8
181 .name =
"green balance",
188 .set = po1030_set_green_balance,
189 .get = po1030_get_green_balance
193 static void po1030_dump_registers(
struct sd *
sd);
198 s32 *sensor_settings;
202 pr_info(
"Forcing a %s sensor\n", po1030.name);
210 PDEBUG(D_PROBE,
"Probing for a po1030 sensor");
214 u8 data = preinit_po1030[
i][2];
215 if (preinit_po1030[
i][0] ==
SENSOR)
217 preinit_po1030[
i][1], &data, 1);
225 if (dev_id_h == 0x30) {
226 pr_info(
"Detected a po1030 sensor\n");
234 if (!sensor_settings)
237 sd->
gspca_dev.cam.cam_mode = po1030_modes;
239 sd->
desc->ctrls = po1030_ctrls;
243 sensor_settings[
i] = po1030_ctrls[
i].
qctrl.default_value;
256 u8 data[2] = {0x00, 0x00};
258 switch (init_po1030[i][0]) {
266 data[0] = init_po1030[
i][2];
268 init_po1030[i][1], data, 1);
272 pr_info(
"Invalid stream command, exiting init\n");
280 po1030_dump_registers(sd);
282 err = po1030_set_exposure(&sd->
gspca_dev,
299 err = po1030_set_red_balance(&sd->
gspca_dev,
304 err = po1030_set_blue_balance(&sd->
gspca_dev,
309 err = po1030_set_green_balance(&sd->
gspca_dev,
314 err = po1030_set_auto_white_balance(&sd->
gspca_dev,
319 err = po1030_set_auto_exposure(&sd->
gspca_dev,
340 data = ((width + 3) >> 8) & 0xff;
345 data = (width + 3) & 0xff;
350 data = ((height + 1) >> 8) & 0xff;
355 data = (height + 1) & 0xff;
368 data = ((width + 7) >> 8) & 0xff;
373 data = (width + 7) & 0xff;
378 data = ((height + 3) >> 8) & 0xff;
383 data = (height + 3) & 0xff;
407 ((ver_offs >> 8) & 0xff));
415 for (i = 0; i < 2 && !
err; i++)
428 for (i = 0; i < 2 && !
err; i++)
431 for (i = 0; i < 2 && !
err; i++)
434 for (i = 0; i < 2 && !
err; i++)
453 struct sd *
sd = (
struct sd *) gspca_dev;
457 PDEBUG(D_V4L2,
"Exposure read as %d", *val);
463 struct sd *
sd = (
struct sd *) gspca_dev;
469 PDEBUG(D_V4L2,
"Set exposure to %d", val & 0xffff);
471 i2c_data = ((val & 0xff00) >> 8);
472 PDEBUG(D_V4L2,
"Set exposure to high byte to 0x%x",
480 i2c_data = (val & 0xff);
481 PDEBUG(D_V4L2,
"Set exposure to low byte to 0x%x",
489 static int po1030_get_gain(
struct gspca_dev *gspca_dev,
__s32 *val)
491 struct sd *sd = (
struct sd *) gspca_dev;
495 PDEBUG(D_V4L2,
"Read global gain %d", *val);
499 static int po1030_set_gain(
struct gspca_dev *gspca_dev,
__s32 val)
501 struct sd *sd = (
struct sd *) gspca_dev;
508 i2c_data = val & 0xff;
509 PDEBUG(D_V4L2,
"Set global gain to %d", i2c_data);
515 static int po1030_get_hflip(
struct gspca_dev *gspca_dev,
__s32 *val)
517 struct sd *sd = (
struct sd *) gspca_dev;
521 PDEBUG(D_V4L2,
"Read hflip %d", *val);
526 static int po1030_set_hflip(
struct gspca_dev *gspca_dev,
__s32 val)
528 struct sd *sd = (
struct sd *) gspca_dev;
535 PDEBUG(D_V4L2,
"Set hflip %d", val);
540 i2c_data = (0x7f &
i2c_data) | ((val & 0x01) << 7);
548 static int po1030_get_vflip(
struct gspca_dev *gspca_dev,
__s32 *val)
550 struct sd *sd = (
struct sd *) gspca_dev;
554 PDEBUG(D_V4L2,
"Read vflip %d", *val);
559 static int po1030_set_vflip(
struct gspca_dev *gspca_dev,
__s32 val)
561 struct sd *sd = (
struct sd *) gspca_dev;
568 PDEBUG(D_V4L2,
"Set vflip %d", val);
573 i2c_data = (i2c_data & 0xbf) | ((val & 0x01) << 6);
581 static int po1030_get_red_balance(
struct gspca_dev *gspca_dev,
__s32 *val)
583 struct sd *sd = (
struct sd *) gspca_dev;
587 PDEBUG(D_V4L2,
"Read red gain %d", *val);
591 static int po1030_set_red_balance(
struct gspca_dev *gspca_dev,
__s32 val)
593 struct sd *sd = (
struct sd *) gspca_dev;
600 i2c_data = val & 0xff;
601 PDEBUG(D_V4L2,
"Set red gain to %d", i2c_data);
607 static int po1030_get_blue_balance(
struct gspca_dev *gspca_dev,
__s32 *val)
609 struct sd *sd = (
struct sd *) gspca_dev;
613 PDEBUG(D_V4L2,
"Read blue gain %d", *val);
618 static int po1030_set_blue_balance(
struct gspca_dev *gspca_dev,
__s32 val)
620 struct sd *sd = (
struct sd *) gspca_dev;
627 i2c_data = val & 0xff;
628 PDEBUG(D_V4L2,
"Set blue gain to %d", i2c_data);
635 static int po1030_get_green_balance(
struct gspca_dev *gspca_dev,
__s32 *val)
637 struct sd *sd = (
struct sd *) gspca_dev;
641 PDEBUG(D_V4L2,
"Read green gain %d", *val);
646 static int po1030_set_green_balance(
struct gspca_dev *gspca_dev,
__s32 val)
648 struct sd *sd = (
struct sd *) gspca_dev;
654 i2c_data = val & 0xff;
655 PDEBUG(D_V4L2,
"Set green gain to %d", i2c_data);
666 static int po1030_get_auto_white_balance(
struct gspca_dev *gspca_dev,
669 struct sd *sd = (
struct sd *) gspca_dev;
673 PDEBUG(D_V4L2,
"Auto white balancing is %d", *val);
678 static int po1030_set_auto_white_balance(
struct gspca_dev *gspca_dev,
681 struct sd *sd = (
struct sd *) gspca_dev;
692 PDEBUG(D_V4L2,
"Set auto white balance to %d", val);
693 i2c_data = (i2c_data & 0xfe) | (val & 0x01);
698 static int po1030_get_auto_exposure(
struct gspca_dev *gspca_dev,
701 struct sd *sd = (
struct sd *) gspca_dev;
705 PDEBUG(D_V4L2,
"Auto exposure is %d", *val);
709 static int po1030_set_auto_exposure(
struct gspca_dev *gspca_dev,
712 struct sd *sd = (
struct sd *) gspca_dev;
722 PDEBUG(D_V4L2,
"Set auto exposure to %d", val);
723 i2c_data = (i2c_data & 0xfd) | ((val & 0x01) << 1);
733 static void po1030_dump_registers(
struct sd *sd)
738 pr_info(
"Dumping the po1030 sensor core registers\n");
739 for (address = 0; address < 0x7f; address++) {
741 pr_info(
"register 0x%x contains 0x%x\n", address, value);
744 pr_info(
"po1030 register state dump complete\n");
746 pr_info(
"Probing for which registers that are read/write\n");
747 for (address = 0; address < 0xff; address++) {
748 u8 old_value, ctrl_value;
749 u8 test_value[2] = {0xff, 0xff};
755 if (ctrl_value == test_value[0])
756 pr_info(
"register 0x%x is writeable\n", address);
758 pr_info(
"register 0x%x is read only\n", address);