Skip to content

Commit

Permalink
V4L/DVB (13143): gspca_ov519 cleanup sensor detection
Browse files Browse the repository at this point in the history
gspca_ov519 cleanup sensor detection

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 5, 2009
1 parent d76f975 commit 229bb7d
Showing 1 changed file with 23 additions and 32 deletions.
55 changes: 23 additions & 32 deletions drivers/media/video/gspca/ov519.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ static const struct v4l2_pix_format ov511_sif_mode[] = {

/* I2C ADDRESSES */
#define OV7xx0_SID 0x42
#define OV_HIRES_SID 0x60 /* OV9xxx / OV2xxx / OV3xxx */
#define OV8xx0_SID 0xa0
#define OV6xx0_SID 0xc0

Expand Down Expand Up @@ -1423,13 +1424,18 @@ static inline int ov51x_restart(struct sd *sd)
return 0;
}

static int ov51x_set_slave_ids(struct sd *sd, __u8 slave);

/* This does an initial reset of an OmniVision sensor and ensures that I2C
* is synchronized. Returns <0 on failure.
*/
static int init_ov_sensor(struct sd *sd)
static int init_ov_sensor(struct sd *sd, __u8 slave)
{
int i;

if (ov51x_set_slave_ids(sd, slave) < 0)
return -EIO;

/* Reset the sensor */
if (i2c_w(sd, 0x12, 0x80) < 0)
return -EIO;
Expand Down Expand Up @@ -1996,46 +2002,31 @@ static int sd_config(struct gspca_dev *gspca_dev,

ov51x_led_control(sd, 0); /* turn LED off */

/* Test for 76xx */
if (ov51x_set_slave_ids(sd, OV7xx0_SID) < 0)
goto error;

/* The OV519 must be more aggressive about sensor detection since
* I2C write will never fail if the sensor is not present. We have
* to try to initialize the sensor to detect its presence */
if (init_ov_sensor(sd) >= 0) {

/* Test for 76xx */
if (init_ov_sensor(sd, OV7xx0_SID) >= 0) {
if (ov7xx0_configure(sd) < 0) {
PDEBUG(D_ERR, "Failed to configure OV7xx0");
goto error;
}
} else {

/* Test for 6xx0 */
if (ov51x_set_slave_ids(sd, OV6xx0_SID) < 0)
/* Test for 6xx0 */
} else if (init_ov_sensor(sd, OV6xx0_SID) >= 0) {
if (ov6xx0_configure(sd) < 0) {
PDEBUG(D_ERR, "Failed to configure OV6xx0");
goto error;
}
/* Test for 8xx0 */
} else if (init_ov_sensor(sd, OV8xx0_SID) >= 0) {
if (ov8xx0_configure(sd) < 0) {
PDEBUG(D_ERR, "Failed to configure OV8xx0");
goto error;

if (init_ov_sensor(sd) >= 0) {
if (ov6xx0_configure(sd) < 0) {
PDEBUG(D_ERR, "Failed to configure OV6xx0");
goto error;
}
} else {

/* Test for 8xx0 */
if (ov51x_set_slave_ids(sd, OV8xx0_SID) < 0)
goto error;

if (init_ov_sensor(sd) < 0) {
PDEBUG(D_ERR,
"Can't determine sensor slave IDs");
goto error;
}
if (ov8xx0_configure(sd) < 0) {
PDEBUG(D_ERR,
"Failed to configure OV8xx0 sensor");
goto error;
}
}
} else {
PDEBUG(D_ERR, "Can't determine sensor slave IDs");
goto error;
}

cam = &gspca_dev->cam;
Expand Down

0 comments on commit 229bb7d

Please sign in to comment.