aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2009-01-18 17:37:59 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-03-30 11:42:22 -0400
commitc7d29e2f530654aa0c323aafb94d42a6a718482c (patch)
tree76e876fc6de0f79c281c2a31695ecc58c5f12122
parentfac6986c4777ae85fa2108ea25fee98de2c1f7b2 (diff)
V4L/DVB (10249): v4l2-common: added v4l2_i2c_tuner_addrs()
Add v4l2_i2c_tuner_addrs() to obtain the various I2C tuner addresses. This will be used in several drivers, so make this a common function as we do not want to have these I2C addresses all over the place. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/video/saa7134/saa7134-core.c42
-rw-r--r--drivers/media/video/v4l2-common.c36
-rw-r--r--include/media/v4l2-common.h13
3 files changed, 65 insertions, 26 deletions
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c
index ac23ff53543d..829006ebdf34 100644
--- a/drivers/media/video/saa7134/saa7134-core.c
+++ b/drivers/media/video/saa7134/saa7134-core.c
@@ -980,35 +980,25 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
980 980
981 /* initialize hardware #2 */ 981 /* initialize hardware #2 */
982 if (TUNER_ABSENT != dev->tuner_type) { 982 if (TUNER_ABSENT != dev->tuner_type) {
983 if (dev->radio_type != UNSET) { 983 int has_demod = (dev->tda9887_conf & TDA9887_PRESENT);
984 v4l2_i2c_new_subdev(&dev->i2c_adap, "tuner", "tuner",
985 dev->radio_addr);
986 }
987 if (dev->tda9887_conf & TDA9887_PRESENT) {
988 unsigned short addrs[] = { 0x42, 0x43, 0x4a, 0x4b,
989 I2C_CLIENT_END };
990 984
991 v4l2_i2c_new_probed_subdev(&dev->i2c_adap, 985 /* Note: radio tuner address is always filled in,
992 "tuner", "tuner", addrs); 986 so we do not need to probe for a radio tuner device. */
993 } 987 if (dev->radio_type != UNSET)
994 if (dev->tuner_addr != ADDR_UNSET) {
995 v4l2_i2c_new_subdev(&dev->i2c_adap, 988 v4l2_i2c_new_subdev(&dev->i2c_adap,
996 "tuner", "tuner", dev->tuner_addr); 989 "tuner", "tuner", dev->radio_addr);
990 if (has_demod)
991 v4l2_i2c_new_probed_subdev(&dev->i2c_adap, "tuner",
992 "tuner", v4l2_i2c_tuner_addrs(ADDRS_DEMOD));
993 if (dev->tuner_addr == ADDR_UNSET) {
994 enum v4l2_i2c_tuner_type type =
995 has_demod ? ADDRS_TV_WITH_DEMOD : ADDRS_TV;
996
997 v4l2_i2c_new_probed_subdev(&dev->i2c_adap, "tuner",
998 "tuner", v4l2_i2c_tuner_addrs(type));
997 } else { 999 } else {
998 unsigned short addrs[] = { 1000 v4l2_i2c_new_subdev(&dev->i2c_adap,
999 0x42, 0x43, 0x4a, 0x4b, /* tda8290 */ 1001 "tuner", "tuner", dev->tuner_addr);
1000 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
1001 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
1002 I2C_CLIENT_END
1003 };
1004
1005 if (dev->tda9887_conf & TDA9887_PRESENT) {
1006 v4l2_i2c_new_probed_subdev(&dev->i2c_adap,
1007 "tuner", "tuner", addrs + 4);
1008 } else {
1009 v4l2_i2c_new_probed_subdev(&dev->i2c_adap,
1010 "tuner", "tuner", addrs);
1011 }
1012 } 1002 }
1013 } 1003 }
1014 saa7134_board_init2(dev); 1004 saa7134_board_init2(dev);
diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c
index 0f450a73477a..26e162f13f7f 100644
--- a/drivers/media/video/v4l2-common.c
+++ b/drivers/media/video/v4l2-common.c
@@ -991,4 +991,40 @@ struct v4l2_subdev *v4l2_i2c_new_probed_subdev(struct i2c_adapter *adapter,
991} 991}
992EXPORT_SYMBOL_GPL(v4l2_i2c_new_probed_subdev); 992EXPORT_SYMBOL_GPL(v4l2_i2c_new_probed_subdev);
993 993
994/* Return a list of I2C tuner addresses to probe. Use only if the tuner
995 addresses are unknown. */
996const unsigned short *v4l2_i2c_tuner_addrs(enum v4l2_i2c_tuner_type type)
997{
998 static const unsigned short radio_addrs[] = {
999#if defined(CONFIG_MEDIA_TUNER_TEA5761) || defined(CONFIG_MEDIA_TUNER_TEA5761_MODULE)
1000 0x10,
1001#endif
1002 0x60,
1003 I2C_CLIENT_END
1004 };
1005 static const unsigned short demod_addrs[] = {
1006 0x42, 0x43, 0x4a, 0x4b,
1007 I2C_CLIENT_END
1008 };
1009 static const unsigned short tv_addrs[] = {
1010 0x42, 0x43, 0x4a, 0x4b, /* tda8290 */
1011 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
1012 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
1013 I2C_CLIENT_END
1014 };
1015
1016 switch (type) {
1017 case ADDRS_RADIO:
1018 return radio_addrs;
1019 case ADDRS_DEMOD:
1020 return demod_addrs;
1021 case ADDRS_TV:
1022 return tv_addrs;
1023 case ADDRS_TV_WITH_DEMOD:
1024 return tv_addrs + 4;
1025 }
1026 return NULL;
1027}
1028EXPORT_SYMBOL_GPL(v4l2_i2c_tuner_addrs);
1029
994#endif 1030#endif
diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
index 95e74f1874e1..0f864f8daaf2 100644
--- a/include/media/v4l2-common.h
+++ b/include/media/v4l2-common.h
@@ -150,6 +150,19 @@ struct v4l2_subdev *v4l2_i2c_new_probed_subdev(struct i2c_adapter *adapter,
150void v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client, 150void v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client,
151 const struct v4l2_subdev_ops *ops); 151 const struct v4l2_subdev_ops *ops);
152 152
153enum v4l2_i2c_tuner_type {
154 ADDRS_RADIO, /* Radio tuner addresses */
155 ADDRS_DEMOD, /* Demod tuner addresses */
156 ADDRS_TV, /* TV tuner addresses */
157 /* TV tuner addresses if demod is present, this excludes
158 addresses used by the demodulator from the list of
159 candidates. */
160 ADDRS_TV_WITH_DEMOD,
161};
162/* Return a list of I2C tuner addresses to probe. Use only if the tuner
163 addresses are unknown. */
164const unsigned short *v4l2_i2c_tuner_addrs(enum v4l2_i2c_tuner_type type);
165
153/* ------------------------------------------------------------------------- */ 166/* ------------------------------------------------------------------------- */
154 167
155/* Internal ioctls */ 168/* Internal ioctls */