Re: gspca webcam: need to plug it 5 times before it works

From: Pavel Machek
Date: Sat Apr 04 2020 - 15:18:53 EST


Hi!

> > ..but if I'm patient enough, it eventually starts working... somehow.
> >
> > Incoming data seems to go in reliably. Outgoing commands (such as
> > change gain) don't seem to be unreliable.
> >
> > Any idea how to debug / what could be wrong?
>
> And I can force it to probe like this: which... makes it work, but
> does not fix the outgoing commands.
>
> Any ideas?

(Adding people from module_authors to the list.)

Pavel

> diff --git a/drivers/media/usb/gspca/sq930x.c b/drivers/media/usb/gspca/sq930x.c
> index c3610247a90e..c9756c0a78df 100644
> --- a/drivers/media/usb/gspca/sq930x.c
> +++ b/drivers/media/usb/gspca/sq930x.c
> @@ -7,6 +7,7 @@
> * Copyright (C) 2007 Sam Revitch <samr7@xxxxxxxxxxxxxxxxx>
> */
>
> +#define DEBUG
> #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>
> #define MODULE_NAME "sq930x"
> @@ -446,7 +447,7 @@ static void reg_w(struct gspca_dev *gspca_dev, u16 value, u16 index)
> USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
> value, index, NULL, 0,
> 500);
> - msleep(30);
> + msleep(90);
> if (ret < 0) {
> pr_err("reg_w %04x %04x failed %d\n", value, index, ret);
> gspca_dev->usb_err = ret;
> @@ -635,19 +636,25 @@ static void cmos_probe(struct gspca_dev *gspca_dev)
> SENSOR_MT9V111,
> };
>
> + printk("CMOS Probing...\n");
> for (i = 0; i < ARRAY_SIZE(probe_order); i++) {
> + printk("Probing type %d...\n", i);
> +
> sensor = &sensor_tb[probe_order[i]];
> ucbus_write(&sd->gspca_dev, sensor->cmd, sensor->cmd_len, 8);
> gpio_init(sd, sensor->gpio);
> - msleep(100);
> + msleep(200);
> reg_r(gspca_dev, (sensor->i2c_addr << 8) | 0x001c, 1);
> - msleep(100);
> - if (gspca_dev->usb_buf[0] != 0)
> + msleep(200);
> + if (gspca_dev->usb_buf[0] != 0) {
> + printk("#### LUCKY! Have type %d\n", i);
> break;
> + }
> }
> if (i >= ARRAY_SIZE(probe_order)) {
> - pr_err("Unknown sensor\n");
> - gspca_dev->usb_err = -EINVAL;
> + printk("Unknown sensor ... hmm?\n");
> + sd->sensor = probe_order[i-1];
> + //gspca_dev->usb_err = -EINVAL;
> return;
> }
> sd->sensor = probe_order[i];
>
>
> --
> (english) http://www.livejournal.com/~pavelmachek
> (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html



--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

Attachment: signature.asc
Description: PGP signature