Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 142452
b: refs/heads/master
c: e6574f2
h: refs/heads/master
v: v3
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Apr 7, 2009
1 parent a0944b6 commit fe7c0f2
Show file tree
Hide file tree
Showing 23 changed files with 154 additions and 123 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 868f985c2fb85b5f32785bb55a349d180a30f3d3
refs/heads/master: e6574f2fbecdb8af807169d345c10131ae060a88
8 changes: 3 additions & 5 deletions trunk/Documentation/video4linux/v4l2-framework.txt
Original file line number Diff line number Diff line change
Expand Up @@ -364,14 +364,12 @@ from the remove() callback ensures that this is always done correctly.

The bridge driver also has some helper functions it can use:

struct v4l2_subdev *sd = v4l2_i2c_new_subdev(adapter, "module_foo", "chipid", 0x36);
struct v4l2_subdev *sd = v4l2_i2c_new_subdev(v4l2_dev, adapter,
"module_foo", "chipid", 0x36);

This loads the given module (can be NULL if no module needs to be loaded) and
calls i2c_new_device() with the given i2c_adapter and chip/address arguments.
If all goes well, then it registers the subdev with the v4l2_device. It gets
the v4l2_device by calling i2c_get_adapdata(adapter), so you should make sure
to call i2c_set_adapdata(adapter, v4l2_device) when you setup the i2c_adapter
in your driver.
If all goes well, then it registers the subdev with the v4l2_device.

You can also use v4l2_i2c_new_probed_subdev() which is very similar to
v4l2_i2c_new_subdev(), except that it has an array of possible I2C addresses
Expand Down
8 changes: 4 additions & 4 deletions trunk/drivers/media/video/au0828/au0828-cards.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,17 +211,17 @@ void au0828_card_setup(struct au0828_dev *dev)
/* Load the analog demodulator driver (note this would need to
be abstracted out if we ever need to support a different
demod) */
sd = v4l2_i2c_new_subdev(&dev->i2c_adap, "au8522", "au8522",
0x8e >> 1);
sd = v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
"au8522", "au8522", 0x8e >> 1);
if (sd == NULL)
printk(KERN_ERR "analog subdev registration failed\n");
}

/* Setup tuners */
if (dev->board.tuner_type != TUNER_ABSENT) {
/* Load the tuner module, which does the attach */
sd = v4l2_i2c_new_subdev(&dev->i2c_adap, "tuner", "tuner",
dev->board.tuner_addr);
sd = v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
"tuner", "tuner", dev->board.tuner_addr);
if (sd == NULL)
printk(KERN_ERR "tuner subdev registration fail\n");

Expand Down
47 changes: 25 additions & 22 deletions trunk/drivers/media/video/bt8xx/bttv-cards.c
Original file line number Diff line number Diff line change
Expand Up @@ -3512,12 +3512,15 @@ void __devinit bttv_init_card2(struct bttv *btv)

/* Load tuner module before issuing tuner config call! */
if (bttv_tvcards[btv->c.type].has_radio)
v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap,
"tuner", "tuner", v4l2_i2c_tuner_addrs(ADDRS_RADIO));
v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap, "tuner",
"tuner", v4l2_i2c_tuner_addrs(ADDRS_DEMOD));
v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap, "tuner",
"tuner", v4l2_i2c_tuner_addrs(ADDRS_TV_WITH_DEMOD));
v4l2_i2c_new_probed_subdev(&btv->c.v4l2_dev,
&btv->c.i2c_adap, "tuner", "tuner",
v4l2_i2c_tuner_addrs(ADDRS_RADIO));
v4l2_i2c_new_probed_subdev(&btv->c.v4l2_dev,
&btv->c.i2c_adap, "tuner", "tuner",
v4l2_i2c_tuner_addrs(ADDRS_DEMOD));
v4l2_i2c_new_probed_subdev(&btv->c.v4l2_dev,
&btv->c.i2c_adap, "tuner", "tuner",
v4l2_i2c_tuner_addrs(ADDRS_TV_WITH_DEMOD));

tun_setup.mode_mask = T_ANALOG_TV | T_DIGITAL_TV;
tun_setup.type = btv->tuner_type;
Expand Down Expand Up @@ -3570,8 +3573,8 @@ void __devinit bttv_init_card2(struct bttv *btv)
};
struct v4l2_subdev *sd;

sd = v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap,
"saa6588", "saa6588", addrs);
sd = v4l2_i2c_new_probed_subdev(&btv->c.v4l2_dev,
&btv->c.i2c_adap, "saa6588", "saa6588", addrs);
btv->has_saa6588 = (sd != NULL);
}

Expand All @@ -3595,8 +3598,8 @@ void __devinit bttv_init_card2(struct bttv *btv)
I2C_CLIENT_END
};

btv->sd_msp34xx = v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap,
"msp3400", "msp3400", addrs);
btv->sd_msp34xx = v4l2_i2c_new_probed_subdev(&btv->c.v4l2_dev,
&btv->c.i2c_adap, "msp3400", "msp3400", addrs);
if (btv->sd_msp34xx)
return;
goto no_audio;
Expand All @@ -3609,16 +3612,16 @@ void __devinit bttv_init_card2(struct bttv *btv)
I2C_CLIENT_END
};

if (v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap,
"tda7432", "tda7432", addrs))
if (v4l2_i2c_new_probed_subdev(&btv->c.v4l2_dev,
&btv->c.i2c_adap, "tda7432", "tda7432", addrs))
return;
goto no_audio;
}

case 3: {
/* The user specified that we should probe for tvaudio */
btv->sd_tvaudio = v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap,
"tvaudio", "tvaudio", tvaudio_addrs);
btv->sd_tvaudio = v4l2_i2c_new_probed_subdev(&btv->c.v4l2_dev,
&btv->c.i2c_adap, "tvaudio", "tvaudio", tvaudio_addrs);
if (btv->sd_tvaudio)
return;
goto no_audio;
Expand All @@ -3642,16 +3645,16 @@ void __devinit bttv_init_card2(struct bttv *btv)
I2C_CLIENT_END
};

btv->sd_msp34xx = v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap,
"msp3400", "msp3400", addrs);
btv->sd_msp34xx = v4l2_i2c_new_probed_subdev(&btv->c.v4l2_dev,
&btv->c.i2c_adap, "msp3400", "msp3400", addrs);
} else if (bttv_tvcards[btv->c.type].msp34xx_alt) {
static const unsigned short addrs[] = {
I2C_ADDR_MSP3400_ALT >> 1,
I2C_CLIENT_END
};

btv->sd_msp34xx = v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap,
"msp3400", "msp3400", addrs);
btv->sd_msp34xx = v4l2_i2c_new_probed_subdev(&btv->c.v4l2_dev,
&btv->c.i2c_adap, "msp3400", "msp3400", addrs);
}

/* If we found a msp34xx, then we're done. */
Expand All @@ -3665,14 +3668,14 @@ void __devinit bttv_init_card2(struct bttv *btv)
I2C_CLIENT_END
};

if (v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap,
"tda7432", "tda7432", addrs))
if (v4l2_i2c_new_probed_subdev(&btv->c.v4l2_dev,
&btv->c.i2c_adap, "tda7432", "tda7432", addrs))
return;
}

/* Now see if we can find one of the tvaudio devices. */
btv->sd_tvaudio = v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap,
"tvaudio", "tvaudio", tvaudio_addrs);
btv->sd_tvaudio = v4l2_i2c_new_probed_subdev(&btv->c.v4l2_dev,
&btv->c.i2c_adap, "tvaudio", "tvaudio", tvaudio_addrs);
if (btv->sd_tvaudio)
return;

Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/media/video/cafe_ccic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1954,7 +1954,7 @@ static int cafe_pci_probe(struct pci_dev *pdev,
goto out_freeirq;

cam->sensor_addr = 0x42;
cam->sensor = v4l2_i2c_new_subdev(&cam->i2c_adapter,
cam->sensor = v4l2_i2c_new_subdev(&cam->v4l2_dev, &cam->i2c_adapter,
"ov7670", "ov7670", cam->sensor_addr);
if (cam->sensor == NULL) {
ret = -ENODEV;
Expand Down
14 changes: 7 additions & 7 deletions trunk/drivers/media/video/cx18/cx18-i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,16 @@ int cx18_i2c_register(struct cx18 *cx, unsigned idx)

if (hw == CX18_HW_TUNER) {
/* special tuner group handling */
sd = v4l2_i2c_new_probed_subdev(adap, mod, type,
cx->card_i2c->radio);
sd = v4l2_i2c_new_probed_subdev(&cx->v4l2_dev,
adap, mod, type, cx->card_i2c->radio);
if (sd != NULL)
sd->grp_id = hw;
sd = v4l2_i2c_new_probed_subdev(adap, mod, type,
cx->card_i2c->demod);
sd = v4l2_i2c_new_probed_subdev(&cx->v4l2_dev,
adap, mod, type, cx->card_i2c->demod);
if (sd != NULL)
sd->grp_id = hw;
sd = v4l2_i2c_new_probed_subdev(adap, mod, type,
cx->card_i2c->tv);
sd = v4l2_i2c_new_probed_subdev(&cx->v4l2_dev,
adap, mod, type, cx->card_i2c->tv);
if (sd != NULL)
sd->grp_id = hw;
return sd != NULL ? 0 : -1;
Expand All @@ -120,7 +120,7 @@ int cx18_i2c_register(struct cx18 *cx, unsigned idx)
return -1;

/* It's an I2C device other than an analog tuner */
sd = v4l2_i2c_new_subdev(adap, mod, type, hw_addrs[idx]);
sd = v4l2_i2c_new_subdev(&cx->v4l2_dev, adap, mod, type, hw_addrs[idx]);
if (sd != NULL)
sd->grp_id = hw;
return sd != NULL ? 0 : -1;
Expand Down
8 changes: 4 additions & 4 deletions trunk/drivers/media/video/cx231xx/cx231xx-cards.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@ void cx231xx_card_setup(struct cx231xx *dev)

/* request some modules */
if (dev->board.decoder == CX231XX_AVDECODER) {
dev->sd_cx25840 =
v4l2_i2c_new_subdev(&dev->i2c_bus[0].i2c_adap,
dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->v4l2_dev,
&dev->i2c_bus[0].i2c_adap,
"cx25840", "cx25840", 0x88 >> 1);
if (dev->sd_cx25840 == NULL)
cx231xx_info("cx25840 subdev registration failure\n");
Expand All @@ -321,8 +321,8 @@ void cx231xx_card_setup(struct cx231xx *dev)
}

if (dev->board.tuner_type != TUNER_ABSENT) {
dev->sd_tuner =
v4l2_i2c_new_subdev(&dev->i2c_bus[1].i2c_adap,
dev->sd_tuner = v4l2_i2c_new_subdev(&dev->v4l2_dev,
&dev->i2c_bus[1].i2c_adap,
"tuner", "tuner", 0xc2 >> 1);
if (dev->sd_tuner == NULL)
cx231xx_info("tuner subdev registration failure\n");
Expand Down
3 changes: 2 additions & 1 deletion trunk/drivers/media/video/cx23885/cx23885-cards.c
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,8 @@ void cx23885_card_setup(struct cx23885_dev *dev)
case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H:
case CX23885_BOARD_COMPRO_VIDEOMATE_E650F:
case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->i2c_bus[2].i2c_adap,
dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->v4l2_dev,
&dev->i2c_bus[2].i2c_adap,
"cx25840", "cx25840", 0x88 >> 1);
v4l2_subdev_call(dev->sd_cx25840, core, load_fw);
break;
Expand Down
6 changes: 4 additions & 2 deletions trunk/drivers/media/video/cx23885/cx23885-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -1523,10 +1523,12 @@ int cx23885_video_register(struct cx23885_dev *dev)
struct v4l2_subdev *sd = NULL;

if (dev->tuner_addr)
sd = v4l2_i2c_new_subdev(&dev->i2c_bus[1].i2c_adap,
sd = v4l2_i2c_new_subdev(&dev->v4l2_dev,
&dev->i2c_bus[1].i2c_adap,
"tuner", "tuner", dev->tuner_addr);
else
sd = v4l2_i2c_new_probed_subdev(&dev->i2c_bus[1].i2c_adap,
sd = v4l2_i2c_new_probed_subdev(&dev->v4l2_dev,
&dev->i2c_bus[1].i2c_adap,
"tuner", "tuner", v4l2_i2c_tuner_addrs(ADDRS_TV));
if (sd) {
struct tuner_setup tun_setup;
Expand Down
15 changes: 9 additions & 6 deletions trunk/drivers/media/video/cx88/cx88-cards.c
Original file line number Diff line number Diff line change
Expand Up @@ -3221,16 +3221,19 @@ struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr)
The radio_type is sometimes missing, or set to UNSET but
later code configures a tea5767.
*/
v4l2_i2c_new_probed_subdev(&core->i2c_adap, "tuner", "tuner",
v4l2_i2c_new_probed_subdev(&core->v4l2_dev, &core->i2c_adap,
"tuner", "tuner",
v4l2_i2c_tuner_addrs(ADDRS_RADIO));
if (has_demod)
v4l2_i2c_new_probed_subdev(&core->i2c_adap, "tuner",
"tuner", v4l2_i2c_tuner_addrs(ADDRS_DEMOD));
v4l2_i2c_new_probed_subdev(&core->v4l2_dev,
&core->i2c_adap, "tuner", "tuner",
v4l2_i2c_tuner_addrs(ADDRS_DEMOD));
if (core->board.tuner_addr == ADDR_UNSET) {
v4l2_i2c_new_probed_subdev(&core->i2c_adap, "tuner",
"tuner", has_demod ? tv_addrs + 4 : tv_addrs);
v4l2_i2c_new_probed_subdev(&core->v4l2_dev,
&core->i2c_adap, "tuner", "tuner",
has_demod ? tv_addrs + 4 : tv_addrs);
} else {
v4l2_i2c_new_subdev(&core->i2c_adap,
v4l2_i2c_new_subdev(&core->v4l2_dev, &core->i2c_adap,
"tuner", "tuner", core->board.tuner_addr);
}
}
Expand Down
4 changes: 2 additions & 2 deletions trunk/drivers/media/video/cx88/cx88-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -1882,7 +1882,7 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
/* load and configure helper modules */

if (core->board.audio_chip == V4L2_IDENT_WM8775)
v4l2_i2c_new_subdev(&core->i2c_adap,
v4l2_i2c_new_subdev(&core->v4l2_dev, &core->i2c_adap,
"wm8775", "wm8775", 0x36 >> 1);

if (core->board.audio_chip == V4L2_IDENT_TVAUDIO) {
Expand All @@ -1892,7 +1892,7 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
0xb0 >> 1, I2C_CLIENT_END
};

v4l2_i2c_new_probed_subdev(&core->i2c_adap,
v4l2_i2c_new_probed_subdev(&core->v4l2_dev, &core->i2c_adap,
"tvaudio", "tvaudio", i2c_addr);
}

Expand Down
34 changes: 18 additions & 16 deletions trunk/drivers/media/video/em28xx/em28xx-cards.c
Original file line number Diff line number Diff line change
Expand Up @@ -1958,44 +1958,46 @@ void em28xx_card_setup(struct em28xx *dev)

/* request some modules */
if (dev->board.has_msp34xx)
v4l2_i2c_new_probed_subdev(&dev->i2c_adap, "msp3400",
"msp3400", msp3400_addrs);
v4l2_i2c_new_probed_subdev(&dev->v4l2_dev, &dev->i2c_adap,
"msp3400", "msp3400", msp3400_addrs);

if (dev->board.decoder == EM28XX_SAA711X)
v4l2_i2c_new_probed_subdev(&dev->i2c_adap, "saa7115",
"saa7115_auto", saa711x_addrs);
v4l2_i2c_new_probed_subdev(&dev->v4l2_dev, &dev->i2c_adap,
"saa7115", "saa7115_auto", saa711x_addrs);

if (dev->board.decoder == EM28XX_TVP5150)
v4l2_i2c_new_probed_subdev(&dev->i2c_adap, "tvp5150",
"tvp5150", tvp5150_addrs);
v4l2_i2c_new_probed_subdev(&dev->v4l2_dev, &dev->i2c_adap,
"tvp5150", "tvp5150", tvp5150_addrs);

if (dev->board.adecoder == EM28XX_TVAUDIO)
v4l2_i2c_new_subdev(&dev->i2c_adap, "tvaudio",
"tvaudio", dev->board.tvaudio_addr);
v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
"tvaudio", "tvaudio", dev->board.tvaudio_addr);

if (dev->board.tuner_type != TUNER_ABSENT) {
int has_demod = (dev->tda9887_conf & TDA9887_PRESENT);

if (dev->board.radio.type)
v4l2_i2c_new_subdev(&dev->i2c_adap, "tuner", "tuner",
dev->board.radio_addr);
v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
"tuner", "tuner", dev->board.radio_addr);

if (has_demod)
v4l2_i2c_new_probed_subdev(&dev->i2c_adap, "tuner",
"tuner", v4l2_i2c_tuner_addrs(ADDRS_DEMOD));
v4l2_i2c_new_probed_subdev(&dev->v4l2_dev,
&dev->i2c_adap, "tuner", "tuner",
v4l2_i2c_tuner_addrs(ADDRS_DEMOD));
if (dev->tuner_addr == 0) {
enum v4l2_i2c_tuner_type type =
has_demod ? ADDRS_TV_WITH_DEMOD : ADDRS_TV;
struct v4l2_subdev *sd;

sd = v4l2_i2c_new_probed_subdev(&dev->i2c_adap, "tuner",
"tuner", v4l2_i2c_tuner_addrs(type));
sd = v4l2_i2c_new_probed_subdev(&dev->v4l2_dev,
&dev->i2c_adap, "tuner", "tuner",
v4l2_i2c_tuner_addrs(type));

if (sd)
dev->tuner_addr = v4l2_i2c_subdev_addr(sd);
} else {
v4l2_i2c_new_subdev(&dev->i2c_adap, "tuner",
"tuner", dev->tuner_addr);
v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
"tuner", "tuner", dev->tuner_addr);
}
}

Expand Down
15 changes: 10 additions & 5 deletions trunk/drivers/media/video/ivtv/ivtv-i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,18 @@ int ivtv_i2c_register(struct ivtv *itv, unsigned idx)
return -1;
if (hw == IVTV_HW_TUNER) {
/* special tuner handling */
sd = v4l2_i2c_new_probed_subdev(adap, mod, type,
sd = v4l2_i2c_new_probed_subdev(&itv->v4l2_dev,
adap, mod, type,
itv->card_i2c->radio);
if (sd)
sd->grp_id = 1 << idx;
sd = v4l2_i2c_new_probed_subdev(adap, mod, type,
sd = v4l2_i2c_new_probed_subdev(&itv->v4l2_dev,
adap, mod, type,
itv->card_i2c->demod);
if (sd)
sd->grp_id = 1 << idx;
sd = v4l2_i2c_new_probed_subdev(adap, mod, type,
sd = v4l2_i2c_new_probed_subdev(&itv->v4l2_dev,
adap, mod, type,
itv->card_i2c->tv);
if (sd)
sd->grp_id = 1 << idx;
Expand All @@ -180,9 +183,11 @@ int ivtv_i2c_register(struct ivtv *itv, unsigned idx)
if (hw == IVTV_HW_UPD64031A || hw == IVTV_HW_UPD6408X) {
unsigned short addrs[2] = { hw_addrs[idx], I2C_CLIENT_END };

sd = v4l2_i2c_new_probed_subdev(adap, mod, type, addrs);
sd = v4l2_i2c_new_probed_subdev(&itv->v4l2_dev,
adap, mod, type, addrs);
} else {
sd = v4l2_i2c_new_subdev(adap, mod, type, hw_addrs[idx]);
sd = v4l2_i2c_new_subdev(&itv->v4l2_dev,
adap, mod, type, hw_addrs[idx]);
}
if (sd)
sd->grp_id = 1 << idx;
Expand Down
Loading

0 comments on commit fe7c0f2

Please sign in to comment.