Skip to content

Commit

Permalink
V4L/DVB (12172): em28xx: Add autodetection code for Silvercrest 1.3 mpix
Browse files Browse the repository at this point in the history
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Mauro Carvalho Chehab committed Jul 5, 2009
1 parent 58fc1ce commit 791a08f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
44 changes: 44 additions & 0 deletions drivers/media/video/em28xx/em28xx-cards.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ static unsigned int card[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = UNSET };
module_param_array(card, int, NULL, 0444);
MODULE_PARM_DESC(card, "card type");

#define MT9V011_VERSION 0x8243

/* Bitmask marking allocated devices from 0 to EM28XX_MAXBOARDS */
static unsigned long em28xx_devused;

Expand Down Expand Up @@ -1702,6 +1704,46 @@ static inline void em28xx_set_model(struct em28xx *dev)
EM28XX_I2C_FREQ_100_KHZ;
}

/* HINT method: webcam I2C chips
*
* This method work for webcams with Micron sensors
*/
static int em28xx_hint_sensor(struct em28xx *dev)
{
int rc;
char *sensor_name;
unsigned char cmd;
__be16 version_be;
u16 version;

if (dev->model != EM2820_BOARD_UNKNOWN)
return 0;

dev->i2c_client.addr = 0xba >> 1;
cmd = 0;
i2c_master_send(&dev->i2c_client, &cmd, 1);
rc = i2c_master_recv(&dev->i2c_client, (char *)&version_be, 2);
if (rc != 2)
return -EINVAL;

version = be16_to_cpu(version_be);

switch (version) {
case MT9V011_VERSION:
dev->model = EM2820_BOARD_SILVERCREST_WEBCAM;
sensor_name = "mt9v011";
break;
default:
printk("Unknown Sensor 0x%04x\n", be16_to_cpu(version));
return -EINVAL;
}

em28xx_errdev("Sensor is %s, assuming that webcam is %s\n",
sensor_name, em28xx_boards[dev->model].name);

return 0;
}

/* Since em28xx_pre_card_setup() requires a proper dev->model,
* this won't work for boards with generic PCI IDs
*/
Expand Down Expand Up @@ -2368,6 +2410,8 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
return errCode;
}

em28xx_hint_sensor(dev);

/* Do board specific init and eeprom reading */
em28xx_card_setup(dev);

Expand Down
2 changes: 1 addition & 1 deletion drivers/media/video/em28xx/em28xx-i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ static char *i2c_devs[128] = {
[0xa0 >> 1] = "eeprom",
[0xb0 >> 1] = "tda9874",
[0xb8 >> 1] = "tvp5150a",
[0xba >> 1] = "tvp5150a",
[0xba >> 1] = "webcam sensor or tvp5150a",
[0xc0 >> 1] = "tuner (analog)",
[0xc2 >> 1] = "tuner (analog)",
[0xc4 >> 1] = "tuner (analog)",
Expand Down

0 comments on commit 791a08f

Please sign in to comment.