Commit e163609e authored by Hans de Goede's avatar Hans de Goede Committed by Mauro Carvalho Chehab

[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: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 8bb58964
...@@ -103,7 +103,8 @@ static void reg_w(struct gspca_dev *gspca_dev, u16 value, u16 index) ...@@ -103,7 +103,8 @@ static void reg_w(struct gspca_dev *gspca_dev, u16 value, u16 index)
0, 0,
1000); 1000);
if (ret < 0) { 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; gspca_dev->usb_err = ret;
} }
} }
...@@ -124,7 +125,7 @@ static void reg_r(struct gspca_dev *gspca_dev, u16 value, u16 index) ...@@ -124,7 +125,7 @@ static void reg_r(struct gspca_dev *gspca_dev, u16 value, u16 index)
2, 2,
1000); 1000);
if (ret < 0) { if (ret < 0) {
pr_err("reg_w err %d\n", ret); pr_err("reg_r err %d\n", ret);
gspca_dev->usb_err = ret; gspca_dev->usb_err = ret;
} }
} }
...@@ -153,16 +154,23 @@ static int sd_config(struct gspca_dev *gspca_dev, ...@@ -153,16 +154,23 @@ static int sd_config(struct gspca_dev *gspca_dev,
/* this function is called at probe and resume time */ /* this function is called at probe and resume time */
static int sd_init(struct gspca_dev *gspca_dev) static int sd_init(struct gspca_dev *gspca_dev)
{ {
/* HDG not sure if these 2 reads are needed */ int i;
reg_r(gspca_dev, 0, 0x10);
PDEBUG(D_PROBE, "Reg 0x10 reads: %02x %02x", /*
gspca_dev->usb_buf[0], gspca_dev->usb_buf[1]); * The konica needs a freaking large time to "boot" (approx 6.5 sec.),
reg_r(gspca_dev, 0, 0x10); * and does not want to be bothered while doing so :|
PDEBUG(D_PROBE, "Reg 0x10 reads: %02x %02x", * Register 0x10 counts from 1 - 3, with 3 being "ready"
gspca_dev->usb_buf[0], gspca_dev->usb_buf[1]); */
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); reg_w(gspca_dev, 0, 0x0d);
return 0; return gspca_dev->usb_err;
} }
static int sd_start(struct gspca_dev *gspca_dev) static int sd_start(struct gspca_dev *gspca_dev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment