diff options
author | Hans de Goede <hdegoede@redhat.com> | 2012-06-30 16:03:21 +0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-07-31 01:40:19 +0400 |
commit | e163609ef77f065dbf3936dcb8f5ffcf6d19b35c (patch) | |
tree | 6326d963d1bb49f6b193c9ca14c7db1e8132c034 /drivers/media/video/gspca | |
parent | 8bb58964bc139d5ff5285f84aa302977d221754d (diff) | |
download | linux-e163609ef77f065dbf3936dcb8f5ffcf6d19b35c.tar.xz |
[media] gspca_konica: Fix init sequence
The konica needs a freaking large time (circa 6.5 seconds) to "boot", and
does not want to be bothered while doing so, so sleep for 6 seconds, and
then query its status register at 100ms intervals until it becomes ready.
This removes the "reg_w err: -32" messages shown in dmesg whenever a
konica cam gets initialized, and also fixes the camera not working when
an app tries to use it directly after it has been plugged in and after
a suspend/resume cycle.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/gspca')
-rw-r--r-- | drivers/media/video/gspca/konica.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/drivers/media/video/gspca/konica.c b/drivers/media/video/gspca/konica.c index 46e1ae402767..bbf91e07e38b 100644 --- a/drivers/media/video/gspca/konica.c +++ b/drivers/media/video/gspca/konica.c @@ -103,7 +103,8 @@ static void reg_w(struct gspca_dev *gspca_dev, u16 value, u16 index) 0, 1000); if (ret < 0) { - pr_err("reg_w err %d\n", ret); + pr_err("reg_w err writing %02x to %02x: %d\n", + value, index, ret); gspca_dev->usb_err = ret; } } @@ -124,7 +125,7 @@ static void reg_r(struct gspca_dev *gspca_dev, u16 value, u16 index) 2, 1000); if (ret < 0) { - pr_err("reg_w err %d\n", ret); + pr_err("reg_r err %d\n", ret); gspca_dev->usb_err = ret; } } @@ -153,16 +154,23 @@ static int sd_config(struct gspca_dev *gspca_dev, /* this function is called at probe and resume time */ static int sd_init(struct gspca_dev *gspca_dev) { - /* HDG not sure if these 2 reads are needed */ - reg_r(gspca_dev, 0, 0x10); - PDEBUG(D_PROBE, "Reg 0x10 reads: %02x %02x", - gspca_dev->usb_buf[0], gspca_dev->usb_buf[1]); - reg_r(gspca_dev, 0, 0x10); - PDEBUG(D_PROBE, "Reg 0x10 reads: %02x %02x", - gspca_dev->usb_buf[0], gspca_dev->usb_buf[1]); + int i; + + /* + * The konica needs a freaking large time to "boot" (approx 6.5 sec.), + * and does not want to be bothered while doing so :| + * Register 0x10 counts from 1 - 3, with 3 being "ready" + */ + msleep(6000); + for (i = 0; i < 20; i++) { + reg_r(gspca_dev, 0, 0x10); + if (gspca_dev->usb_buf[0] == 3) + break; + msleep(100); + } reg_w(gspca_dev, 0, 0x0d); - return 0; + return gspca_dev->usb_err; } static int sd_start(struct gspca_dev *gspca_dev) |