Skip to content

Commit

Permalink
[media] gspca_sonixb: Properly wait between i2c writes
Browse files Browse the repository at this point in the history
We must wait for the previous i2c write to complete before starting a new
one. Sofar we were getting away with this, but it seems that some parts
of the usb-subsystem has been sped up making us go to fast :)
This fixes streaming on sn9c103 based cams not working with an
"i2c_w error" error.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Hans de Goede authored and Mauro Carvalho Chehab committed Dec 21, 2012
1 parent 8547fd1 commit 18fa0d3
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions drivers/media/usb/gspca/sonixb.c
Original file line number Diff line number Diff line change
Expand Up @@ -496,24 +496,27 @@ static void reg_w(struct gspca_dev *gspca_dev,
}
}

static void i2c_w(struct gspca_dev *gspca_dev, const __u8 *buffer)
static void i2c_w(struct gspca_dev *gspca_dev, const u8 *buf)
{
int retry = 60;

if (gspca_dev->usb_err < 0)
return;

/* is i2c ready */
reg_w(gspca_dev, 0x08, buffer, 8);
reg_w(gspca_dev, 0x08, buf, 8);
while (retry--) {
if (gspca_dev->usb_err < 0)
return;
msleep(10);
msleep(1);
reg_r(gspca_dev, 0x08);
if (gspca_dev->usb_buf[0] & 0x04) {
if (gspca_dev->usb_buf[0] & 0x08) {
dev_err(gspca_dev->v4l2_dev.dev,
"i2c write error\n");
"i2c error writing %02x %02x %02x %02x"
" %02x %02x %02x %02x\n",
buf[0], buf[1], buf[2], buf[3],
buf[4], buf[5], buf[6], buf[7]);
gspca_dev->usb_err = -EIO;
}
return;
Expand All @@ -530,7 +533,7 @@ static void i2c_w_vector(struct gspca_dev *gspca_dev,
for (;;) {
if (gspca_dev->usb_err < 0)
return;
reg_w(gspca_dev, 0x08, *buffer, 8);
i2c_w(gspca_dev, *buffer);
len -= 8;
if (len <= 0)
break;
Expand Down

0 comments on commit 18fa0d3

Please sign in to comment.