diff options
author | Hans de Goede <hdegoede@redhat.com> | 2009-10-11 06:41:46 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-12-05 15:40:32 -0500 |
commit | 229bb7dc5181b3264550532a26a9c698be56fcb8 (patch) | |
tree | cec70dbcda4c48af2953245cabae0d1c39df2453 /drivers | |
parent | d76f975c574230fb00d07848d330e04d97e51475 (diff) |
V4L/DVB (13143): gspca_ov519 cleanup sensor detection
gspca_ov519 cleanup sensor detection
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/video/gspca/ov519.c | 55 |
1 files changed, 23 insertions, 32 deletions
diff --git a/drivers/media/video/gspca/ov519.c b/drivers/media/video/gspca/ov519.c index e16557819782..bb9976dc1e24 100644 --- a/drivers/media/video/gspca/ov519.c +++ b/drivers/media/video/gspca/ov519.c | |||
@@ -416,6 +416,7 @@ static const struct v4l2_pix_format ov511_sif_mode[] = { | |||
416 | 416 | ||
417 | /* I2C ADDRESSES */ | 417 | /* I2C ADDRESSES */ |
418 | #define OV7xx0_SID 0x42 | 418 | #define OV7xx0_SID 0x42 |
419 | #define OV_HIRES_SID 0x60 /* OV9xxx / OV2xxx / OV3xxx */ | ||
419 | #define OV8xx0_SID 0xa0 | 420 | #define OV8xx0_SID 0xa0 |
420 | #define OV6xx0_SID 0xc0 | 421 | #define OV6xx0_SID 0xc0 |
421 | 422 | ||
@@ -1423,13 +1424,18 @@ static inline int ov51x_restart(struct sd *sd) | |||
1423 | return 0; | 1424 | return 0; |
1424 | } | 1425 | } |
1425 | 1426 | ||
1427 | static int ov51x_set_slave_ids(struct sd *sd, __u8 slave); | ||
1428 | |||
1426 | /* This does an initial reset of an OmniVision sensor and ensures that I2C | 1429 | /* This does an initial reset of an OmniVision sensor and ensures that I2C |
1427 | * is synchronized. Returns <0 on failure. | 1430 | * is synchronized. Returns <0 on failure. |
1428 | */ | 1431 | */ |
1429 | static int init_ov_sensor(struct sd *sd) | 1432 | static int init_ov_sensor(struct sd *sd, __u8 slave) |
1430 | { | 1433 | { |
1431 | int i; | 1434 | int i; |
1432 | 1435 | ||
1436 | if (ov51x_set_slave_ids(sd, slave) < 0) | ||
1437 | return -EIO; | ||
1438 | |||
1433 | /* Reset the sensor */ | 1439 | /* Reset the sensor */ |
1434 | if (i2c_w(sd, 0x12, 0x80) < 0) | 1440 | if (i2c_w(sd, 0x12, 0x80) < 0) |
1435 | return -EIO; | 1441 | return -EIO; |
@@ -1996,46 +2002,31 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
1996 | 2002 | ||
1997 | ov51x_led_control(sd, 0); /* turn LED off */ | 2003 | ov51x_led_control(sd, 0); /* turn LED off */ |
1998 | 2004 | ||
1999 | /* Test for 76xx */ | ||
2000 | if (ov51x_set_slave_ids(sd, OV7xx0_SID) < 0) | ||
2001 | goto error; | ||
2002 | |||
2003 | /* The OV519 must be more aggressive about sensor detection since | 2005 | /* The OV519 must be more aggressive about sensor detection since |
2004 | * I2C write will never fail if the sensor is not present. We have | 2006 | * I2C write will never fail if the sensor is not present. We have |
2005 | * to try to initialize the sensor to detect its presence */ | 2007 | * to try to initialize the sensor to detect its presence */ |
2006 | if (init_ov_sensor(sd) >= 0) { | 2008 | |
2009 | /* Test for 76xx */ | ||
2010 | if (init_ov_sensor(sd, OV7xx0_SID) >= 0) { | ||
2007 | if (ov7xx0_configure(sd) < 0) { | 2011 | if (ov7xx0_configure(sd) < 0) { |
2008 | PDEBUG(D_ERR, "Failed to configure OV7xx0"); | 2012 | PDEBUG(D_ERR, "Failed to configure OV7xx0"); |
2009 | goto error; | 2013 | goto error; |
2010 | } | 2014 | } |
2011 | } else { | 2015 | /* Test for 6xx0 */ |
2012 | 2016 | } else if (init_ov_sensor(sd, OV6xx0_SID) >= 0) { | |
2013 | /* Test for 6xx0 */ | 2017 | if (ov6xx0_configure(sd) < 0) { |
2014 | if (ov51x_set_slave_ids(sd, OV6xx0_SID) < 0) | 2018 | PDEBUG(D_ERR, "Failed to configure OV6xx0"); |
2019 | goto error; | ||
2020 | } | ||
2021 | /* Test for 8xx0 */ | ||
2022 | } else if (init_ov_sensor(sd, OV8xx0_SID) >= 0) { | ||
2023 | if (ov8xx0_configure(sd) < 0) { | ||
2024 | PDEBUG(D_ERR, "Failed to configure OV8xx0"); | ||
2015 | goto error; | 2025 | goto error; |
2016 | |||
2017 | if (init_ov_sensor(sd) >= 0) { | ||
2018 | if (ov6xx0_configure(sd) < 0) { | ||
2019 | PDEBUG(D_ERR, "Failed to configure OV6xx0"); | ||
2020 | goto error; | ||
2021 | } | ||
2022 | } else { | ||
2023 | |||
2024 | /* Test for 8xx0 */ | ||
2025 | if (ov51x_set_slave_ids(sd, OV8xx0_SID) < 0) | ||
2026 | goto error; | ||
2027 | |||
2028 | if (init_ov_sensor(sd) < 0) { | ||
2029 | PDEBUG(D_ERR, | ||
2030 | "Can't determine sensor slave IDs"); | ||
2031 | goto error; | ||
2032 | } | ||
2033 | if (ov8xx0_configure(sd) < 0) { | ||
2034 | PDEBUG(D_ERR, | ||
2035 | "Failed to configure OV8xx0 sensor"); | ||
2036 | goto error; | ||
2037 | } | ||
2038 | } | 2026 | } |
2027 | } else { | ||
2028 | PDEBUG(D_ERR, "Can't determine sensor slave IDs"); | ||
2029 | goto error; | ||
2039 | } | 2030 | } |
2040 | 2031 | ||
2041 | cam = &gspca_dev->cam; | 2032 | cam = &gspca_dev->cam; |