diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2009-01-17 10:17:14 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-03-30 11:42:22 -0400 |
commit | fac6986c4777ae85fa2108ea25fee98de2c1f7b2 (patch) | |
tree | 477119cf15d50bcc548ddd6e6ba15eb69e311d23 | |
parent | 5b73e98c83fc5087f591c9b12ee546b97e9283d4 (diff) |
V4L/DVB (10247): saa7134: convert to the new v4l2 framework.
Register v4l2_device and switch to v4l2_subdev to access the i2c modules.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/video/saa7134/saa6752hs.c | 13 | ||||
-rw-r--r-- | drivers/media/video/saa7134/saa7134-cards.c | 13 | ||||
-rw-r--r-- | drivers/media/video/saa7134/saa7134-core.c | 66 | ||||
-rw-r--r-- | drivers/media/video/saa7134/saa7134-dvb.c | 4 | ||||
-rw-r--r-- | drivers/media/video/saa7134/saa7134-empress.c | 22 | ||||
-rw-r--r-- | drivers/media/video/saa7134/saa7134-i2c.c | 21 | ||||
-rw-r--r-- | drivers/media/video/saa7134/saa7134-video.c | 17 | ||||
-rw-r--r-- | drivers/media/video/saa7134/saa7134.h | 13 |
8 files changed, 91 insertions, 78 deletions
diff --git a/drivers/media/video/saa7134/saa6752hs.c b/drivers/media/video/saa7134/saa6752hs.c index 25e6ab28a0a3..2d292ad776e9 100644 --- a/drivers/media/video/saa7134/saa6752hs.c +++ b/drivers/media/video/saa7134/saa6752hs.c | |||
@@ -36,7 +36,7 @@ | |||
36 | #include <media/v4l2-device.h> | 36 | #include <media/v4l2-device.h> |
37 | #include <media/v4l2-common.h> | 37 | #include <media/v4l2-common.h> |
38 | #include <media/v4l2-chip-ident.h> | 38 | #include <media/v4l2-chip-ident.h> |
39 | #include <media/v4l2-i2c-drv-legacy.h> | 39 | #include <media/v4l2-i2c-drv.h> |
40 | #include <linux/init.h> | 40 | #include <linux/init.h> |
41 | #include <linux/crc32.h> | 41 | #include <linux/crc32.h> |
42 | 42 | ||
@@ -45,10 +45,6 @@ | |||
45 | #define MPEG_TOTAL_TARGET_BITRATE_MAX 27000 | 45 | #define MPEG_TOTAL_TARGET_BITRATE_MAX 27000 |
46 | #define MPEG_PID_MAX ((1 << 14) - 1) | 46 | #define MPEG_PID_MAX ((1 << 14) - 1) |
47 | 47 | ||
48 | /* Addresses to scan */ | ||
49 | static unsigned short normal_i2c[] = {0x20, I2C_CLIENT_END}; | ||
50 | |||
51 | I2C_CLIENT_INSMOD; | ||
52 | 48 | ||
53 | MODULE_DESCRIPTION("device driver for saa6752hs MPEG2 encoder"); | 49 | MODULE_DESCRIPTION("device driver for saa6752hs MPEG2 encoder"); |
54 | MODULE_AUTHOR("Andrew de Quincey"); | 50 | MODULE_AUTHOR("Andrew de Quincey"); |
@@ -914,11 +910,6 @@ static int saa6752hs_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_i | |||
914 | chip, h->chip, h->revision); | 910 | chip, h->chip, h->revision); |
915 | } | 911 | } |
916 | 912 | ||
917 | static int saa6752hs_command(struct i2c_client *client, unsigned cmd, void *arg) | ||
918 | { | ||
919 | return v4l2_subdev_command(i2c_get_clientdata(client), cmd, arg); | ||
920 | } | ||
921 | |||
922 | /* ----------------------------------------------------------------------- */ | 913 | /* ----------------------------------------------------------------------- */ |
923 | 914 | ||
924 | static const struct v4l2_subdev_core_ops saa6752hs_core_ops = { | 915 | static const struct v4l2_subdev_core_ops saa6752hs_core_ops = { |
@@ -993,8 +984,6 @@ MODULE_DEVICE_TABLE(i2c, saa6752hs_id); | |||
993 | 984 | ||
994 | static struct v4l2_i2c_driver_data v4l2_i2c_data = { | 985 | static struct v4l2_i2c_driver_data v4l2_i2c_data = { |
995 | .name = "saa6752hs", | 986 | .name = "saa6752hs", |
996 | .driverid = I2C_DRIVERID_SAA6752HS, | ||
997 | .command = saa6752hs_command, | ||
998 | .probe = saa6752hs_probe, | 987 | .probe = saa6752hs_probe, |
999 | .remove = saa6752hs_remove, | 988 | .remove = saa6752hs_remove, |
1000 | .id_table = saa6752hs_id, | 989 | .id_table = saa6752hs_id, |
diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c index e2febcd6e529..0d50d7448fc5 100644 --- a/drivers/media/video/saa7134/saa7134-cards.c +++ b/drivers/media/video/saa7134/saa7134-cards.c | |||
@@ -4611,7 +4611,7 @@ struct saa7134_board saa7134_boards[] = { | |||
4611 | .tuner_type = TUNER_YMEC_TVF_5533MF, | 4611 | .tuner_type = TUNER_YMEC_TVF_5533MF, |
4612 | .radio_type = TUNER_TEA5767, | 4612 | .radio_type = TUNER_TEA5767, |
4613 | .tuner_addr = ADDR_UNSET, | 4613 | .tuner_addr = ADDR_UNSET, |
4614 | .radio_addr = ADDR_UNSET, | 4614 | .radio_addr = 0x60, |
4615 | .gpiomask = 0x80000700, | 4615 | .gpiomask = 0x80000700, |
4616 | .inputs = { { | 4616 | .inputs = { { |
4617 | .name = name_tv, | 4617 | .name = name_tv, |
@@ -6109,7 +6109,7 @@ static void saa7134_tuner_setup(struct saa7134_dev *dev) | |||
6109 | 6109 | ||
6110 | tun_setup.mode_mask = T_RADIO; | 6110 | tun_setup.mode_mask = T_RADIO; |
6111 | 6111 | ||
6112 | saa7134_i2c_call_clients(dev, TUNER_SET_TYPE_ADDR, &tun_setup); | 6112 | saa_call_all(dev, tuner, s_type_addr, &tun_setup); |
6113 | mode_mask &= ~T_RADIO; | 6113 | mode_mask &= ~T_RADIO; |
6114 | } | 6114 | } |
6115 | 6115 | ||
@@ -6121,7 +6121,7 @@ static void saa7134_tuner_setup(struct saa7134_dev *dev) | |||
6121 | 6121 | ||
6122 | tun_setup.mode_mask = mode_mask; | 6122 | tun_setup.mode_mask = mode_mask; |
6123 | 6123 | ||
6124 | saa7134_i2c_call_clients(dev, TUNER_SET_TYPE_ADDR, &tun_setup); | 6124 | saa_call_all(dev, tuner, s_type_addr, &tun_setup); |
6125 | } | 6125 | } |
6126 | 6126 | ||
6127 | if (dev->tda9887_conf) { | 6127 | if (dev->tda9887_conf) { |
@@ -6130,8 +6130,7 @@ static void saa7134_tuner_setup(struct saa7134_dev *dev) | |||
6130 | tda9887_cfg.tuner = TUNER_TDA9887; | 6130 | tda9887_cfg.tuner = TUNER_TDA9887; |
6131 | tda9887_cfg.priv = &dev->tda9887_conf; | 6131 | tda9887_cfg.priv = &dev->tda9887_conf; |
6132 | 6132 | ||
6133 | saa7134_i2c_call_clients(dev, TUNER_SET_CONFIG, | 6133 | saa_call_all(dev, tuner, s_config, &tda9887_cfg); |
6134 | &tda9887_cfg); | ||
6135 | } | 6134 | } |
6136 | 6135 | ||
6137 | if (dev->tuner_type == TUNER_XC2028) { | 6136 | if (dev->tuner_type == TUNER_XC2028) { |
@@ -6158,7 +6157,7 @@ static void saa7134_tuner_setup(struct saa7134_dev *dev) | |||
6158 | xc2028_cfg.tuner = TUNER_XC2028; | 6157 | xc2028_cfg.tuner = TUNER_XC2028; |
6159 | xc2028_cfg.priv = &ctl; | 6158 | xc2028_cfg.priv = &ctl; |
6160 | 6159 | ||
6161 | saa7134_i2c_call_clients(dev, TUNER_SET_CONFIG, &xc2028_cfg); | 6160 | saa_call_all(dev, tuner, s_config, &xc2028_cfg); |
6162 | } | 6161 | } |
6163 | } | 6162 | } |
6164 | 6163 | ||
@@ -6401,7 +6400,7 @@ int saa7134_board_init2(struct saa7134_dev *dev) | |||
6401 | ctl.xtal_freq = TEA5767_HIGH_LO_13MHz; | 6400 | ctl.xtal_freq = TEA5767_HIGH_LO_13MHz; |
6402 | tea5767_cfg.tuner = TUNER_TEA5767; | 6401 | tea5767_cfg.tuner = TUNER_TEA5767; |
6403 | tea5767_cfg.priv = &ctl; | 6402 | tea5767_cfg.priv = &ctl; |
6404 | saa7134_i2c_call_clients(dev, TUNER_SET_CONFIG, &tea5767_cfg); | 6403 | saa_call_all(dev, tuner, s_config, &tea5767_cfg); |
6405 | break; | 6404 | break; |
6406 | } | 6405 | } |
6407 | } /* switch() */ | 6406 | } /* switch() */ |
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c index 99221d726edb..ac23ff53543d 100644 --- a/drivers/media/video/saa7134/saa7134-core.c +++ b/drivers/media/video/saa7134/saa7134-core.c | |||
@@ -851,6 +851,10 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev, | |||
851 | if (NULL == dev) | 851 | if (NULL == dev) |
852 | return -ENOMEM; | 852 | return -ENOMEM; |
853 | 853 | ||
854 | err = v4l2_device_register(&pci_dev->dev, &dev->v4l2_dev); | ||
855 | if (err) | ||
856 | goto fail0; | ||
857 | |||
854 | /* pci init */ | 858 | /* pci init */ |
855 | dev->pci = pci_dev; | 859 | dev->pci = pci_dev; |
856 | if (pci_enable_device(pci_dev)) { | 860 | if (pci_enable_device(pci_dev)) { |
@@ -927,6 +931,8 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev, | |||
927 | dev->autodetected = card[dev->nr] != dev->board; | 931 | dev->autodetected = card[dev->nr] != dev->board; |
928 | dev->tuner_type = saa7134_boards[dev->board].tuner_type; | 932 | dev->tuner_type = saa7134_boards[dev->board].tuner_type; |
929 | dev->tuner_addr = saa7134_boards[dev->board].tuner_addr; | 933 | dev->tuner_addr = saa7134_boards[dev->board].tuner_addr; |
934 | dev->radio_type = saa7134_boards[dev->board].radio_type; | ||
935 | dev->radio_addr = saa7134_boards[dev->board].radio_addr; | ||
930 | dev->tda9887_conf = saa7134_boards[dev->board].tda9887_conf; | 936 | dev->tda9887_conf = saa7134_boards[dev->board].tda9887_conf; |
931 | if (UNSET != tuner[dev->nr]) | 937 | if (UNSET != tuner[dev->nr]) |
932 | dev->tuner_type = tuner[dev->nr]; | 938 | dev->tuner_type = tuner[dev->nr]; |
@@ -973,15 +979,50 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev, | |||
973 | saa7134_i2c_register(dev); | 979 | saa7134_i2c_register(dev); |
974 | 980 | ||
975 | /* initialize hardware #2 */ | 981 | /* initialize hardware #2 */ |
976 | if (TUNER_ABSENT != dev->tuner_type) | 982 | if (TUNER_ABSENT != dev->tuner_type) { |
977 | request_module("tuner"); | 983 | if (dev->radio_type != UNSET) { |
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 | |||
991 | v4l2_i2c_new_probed_subdev(&dev->i2c_adap, | ||
992 | "tuner", "tuner", addrs); | ||
993 | } | ||
994 | if (dev->tuner_addr != ADDR_UNSET) { | ||
995 | v4l2_i2c_new_subdev(&dev->i2c_adap, | ||
996 | "tuner", "tuner", dev->tuner_addr); | ||
997 | } else { | ||
998 | unsigned short addrs[] = { | ||
999 | 0x42, 0x43, 0x4a, 0x4b, /* tda8290 */ | ||
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 | } | ||
1013 | } | ||
978 | saa7134_board_init2(dev); | 1014 | saa7134_board_init2(dev); |
979 | 1015 | ||
980 | saa7134_hwinit2(dev); | 1016 | saa7134_hwinit2(dev); |
981 | 1017 | ||
982 | /* load i2c helpers */ | 1018 | /* load i2c helpers */ |
983 | if (card_is_empress(dev)) { | 1019 | if (card_is_empress(dev)) { |
984 | request_module("saa6752hs"); | 1020 | struct v4l2_subdev *sd = |
1021 | v4l2_i2c_new_subdev(&dev->i2c_adap, "saa6752hs", | ||
1022 | "saa6752hs", 0x20); | ||
1023 | |||
1024 | if (sd) | ||
1025 | sd->grp_id = GRP_EMPRESS; | ||
985 | } | 1026 | } |
986 | 1027 | ||
987 | request_submodules(dev); | 1028 | request_submodules(dev); |
@@ -1023,7 +1064,6 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev, | |||
1023 | } | 1064 | } |
1024 | 1065 | ||
1025 | /* everything worked */ | 1066 | /* everything worked */ |
1026 | pci_set_drvdata(pci_dev,dev); | ||
1027 | saa7134_devcount++; | 1067 | saa7134_devcount++; |
1028 | 1068 | ||
1029 | mutex_lock(&devlist_lock); | 1069 | mutex_lock(&devlist_lock); |
@@ -1040,7 +1080,7 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev, | |||
1040 | } | 1080 | } |
1041 | 1081 | ||
1042 | if (TUNER_ABSENT != dev->tuner_type) | 1082 | if (TUNER_ABSENT != dev->tuner_type) |
1043 | saa7134_i2c_call_clients(dev, TUNER_SET_STANDBY, NULL); | 1083 | saa_call_all(dev, core, s_standby, 0); |
1044 | 1084 | ||
1045 | return 0; | 1085 | return 0; |
1046 | 1086 | ||
@@ -1055,13 +1095,16 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev, | |||
1055 | release_mem_region(pci_resource_start(pci_dev,0), | 1095 | release_mem_region(pci_resource_start(pci_dev,0), |
1056 | pci_resource_len(pci_dev,0)); | 1096 | pci_resource_len(pci_dev,0)); |
1057 | fail1: | 1097 | fail1: |
1098 | v4l2_device_unregister(&dev->v4l2_dev); | ||
1099 | fail0: | ||
1058 | kfree(dev); | 1100 | kfree(dev); |
1059 | return err; | 1101 | return err; |
1060 | } | 1102 | } |
1061 | 1103 | ||
1062 | static void __devexit saa7134_finidev(struct pci_dev *pci_dev) | 1104 | static void __devexit saa7134_finidev(struct pci_dev *pci_dev) |
1063 | { | 1105 | { |
1064 | struct saa7134_dev *dev = pci_get_drvdata(pci_dev); | 1106 | struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev); |
1107 | struct saa7134_dev *dev = container_of(v4l2_dev, struct saa7134_dev, v4l2_dev); | ||
1065 | struct saa7134_mpeg_ops *mops; | 1108 | struct saa7134_mpeg_ops *mops; |
1066 | 1109 | ||
1067 | /* Release DMA sound modules if present */ | 1110 | /* Release DMA sound modules if present */ |
@@ -1113,7 +1156,8 @@ static void __devexit saa7134_finidev(struct pci_dev *pci_dev) | |||
1113 | release_mem_region(pci_resource_start(pci_dev,0), | 1156 | release_mem_region(pci_resource_start(pci_dev,0), |
1114 | pci_resource_len(pci_dev,0)); | 1157 | pci_resource_len(pci_dev,0)); |
1115 | 1158 | ||
1116 | pci_set_drvdata(pci_dev, NULL); | 1159 | |
1160 | v4l2_device_unregister(&dev->v4l2_dev); | ||
1117 | 1161 | ||
1118 | /* free memory */ | 1162 | /* free memory */ |
1119 | kfree(dev); | 1163 | kfree(dev); |
@@ -1148,8 +1192,8 @@ static int saa7134_buffer_requeue(struct saa7134_dev *dev, | |||
1148 | 1192 | ||
1149 | static int saa7134_suspend(struct pci_dev *pci_dev , pm_message_t state) | 1193 | static int saa7134_suspend(struct pci_dev *pci_dev , pm_message_t state) |
1150 | { | 1194 | { |
1151 | 1195 | struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev); | |
1152 | struct saa7134_dev *dev = pci_get_drvdata(pci_dev); | 1196 | struct saa7134_dev *dev = container_of(v4l2_dev, struct saa7134_dev, v4l2_dev); |
1153 | 1197 | ||
1154 | /* disable overlay - apps should enable it explicitly on resume*/ | 1198 | /* disable overlay - apps should enable it explicitly on resume*/ |
1155 | dev->ovenable = 0; | 1199 | dev->ovenable = 0; |
@@ -1185,7 +1229,8 @@ static int saa7134_suspend(struct pci_dev *pci_dev , pm_message_t state) | |||
1185 | 1229 | ||
1186 | static int saa7134_resume(struct pci_dev *pci_dev) | 1230 | static int saa7134_resume(struct pci_dev *pci_dev) |
1187 | { | 1231 | { |
1188 | struct saa7134_dev *dev = pci_get_drvdata(pci_dev); | 1232 | struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev); |
1233 | struct saa7134_dev *dev = container_of(v4l2_dev, struct saa7134_dev, v4l2_dev); | ||
1189 | unsigned long flags; | 1234 | unsigned long flags; |
1190 | 1235 | ||
1191 | pci_set_power_state(pci_dev, PCI_D0); | 1236 | pci_set_power_state(pci_dev, PCI_D0); |
@@ -1307,7 +1352,6 @@ module_exit(saa7134_fini); | |||
1307 | /* ----------------------------------------------------------- */ | 1352 | /* ----------------------------------------------------------- */ |
1308 | 1353 | ||
1309 | EXPORT_SYMBOL(saa7134_set_gpio); | 1354 | EXPORT_SYMBOL(saa7134_set_gpio); |
1310 | EXPORT_SYMBOL(saa7134_i2c_call_clients); | ||
1311 | EXPORT_SYMBOL(saa7134_devlist); | 1355 | EXPORT_SYMBOL(saa7134_devlist); |
1312 | EXPORT_SYMBOL(saa7134_boards); | 1356 | EXPORT_SYMBOL(saa7134_boards); |
1313 | 1357 | ||
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c index b5370b3e1a3d..af9a22d1b94d 100644 --- a/drivers/media/video/saa7134/saa7134-dvb.c +++ b/drivers/media/video/saa7134/saa7134-dvb.c | |||
@@ -189,7 +189,7 @@ static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe, | |||
189 | if (fe->ops.i2c_gate_ctrl) | 189 | if (fe->ops.i2c_gate_ctrl) |
190 | fe->ops.i2c_gate_ctrl(fe, 1); | 190 | fe->ops.i2c_gate_ctrl(fe, 1); |
191 | i2c_transfer(&dev->i2c_adap, &msg, 1); | 191 | i2c_transfer(&dev->i2c_adap, &msg, 1); |
192 | saa7134_i2c_call_clients(dev,VIDIOC_S_FREQUENCY,&f); | 192 | saa_call_all(dev, tuner, s_frequency, &f); |
193 | msg.buf = on; | 193 | msg.buf = on; |
194 | if (fe->ops.i2c_gate_ctrl) | 194 | if (fe->ops.i2c_gate_ctrl) |
195 | fe->ops.i2c_gate_ctrl(fe, 1); | 195 | fe->ops.i2c_gate_ctrl(fe, 1); |
@@ -1449,7 +1449,7 @@ static int dvb_fini(struct saa7134_dev *dev) | |||
1449 | tda9887_cfg.priv = &on; | 1449 | tda9887_cfg.priv = &on; |
1450 | 1450 | ||
1451 | /* otherwise we don't detect the tuner on next insmod */ | 1451 | /* otherwise we don't detect the tuner on next insmod */ |
1452 | saa7134_i2c_call_clients(dev, TUNER_SET_CONFIG, &tda9887_cfg); | 1452 | saa_call_all(dev, tuner, s_config, &tda9887_cfg); |
1453 | } else if (dev->board == SAA7134_BOARD_MEDION_MD8800_QUADRO) { | 1453 | } else if (dev->board == SAA7134_BOARD_MEDION_MD8800_QUADRO) { |
1454 | if ((dev->eedata[2] == 0x07) && use_frontend) { | 1454 | if ((dev->eedata[2] == 0x07) && use_frontend) { |
1455 | /* turn off the 2nd lnb supply */ | 1455 | /* turn off the 2nd lnb supply */ |
diff --git a/drivers/media/video/saa7134/saa7134-empress.c b/drivers/media/video/saa7134/saa7134-empress.c index c9d8beb87a60..d9d9607044a7 100644 --- a/drivers/media/video/saa7134/saa7134-empress.c +++ b/drivers/media/video/saa7134/saa7134-empress.c | |||
@@ -76,7 +76,7 @@ static int ts_init_encoder(struct saa7134_dev* dev) | |||
76 | break; | 76 | break; |
77 | } | 77 | } |
78 | ts_reset_encoder(dev); | 78 | ts_reset_encoder(dev); |
79 | saa7134_i2c_call_clients(dev, VIDIOC_INT_INIT, &leading_null_bytes); | 79 | saa_call_all(dev, core, init, leading_null_bytes); |
80 | dev->empress_started = 1; | 80 | dev->empress_started = 1; |
81 | return 0; | 81 | return 0; |
82 | } | 82 | } |
@@ -234,7 +234,7 @@ static int empress_g_fmt_vid_cap(struct file *file, void *priv, | |||
234 | { | 234 | { |
235 | struct saa7134_dev *dev = file->private_data; | 235 | struct saa7134_dev *dev = file->private_data; |
236 | 236 | ||
237 | saa7134_i2c_call_clients(dev, VIDIOC_G_FMT, f); | 237 | saa_call_all(dev, video, g_fmt, f); |
238 | 238 | ||
239 | f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; | 239 | f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; |
240 | f->fmt.pix.sizeimage = TS_PACKET_SIZE * dev->ts.nr_packets; | 240 | f->fmt.pix.sizeimage = TS_PACKET_SIZE * dev->ts.nr_packets; |
@@ -247,7 +247,7 @@ static int empress_s_fmt_vid_cap(struct file *file, void *priv, | |||
247 | { | 247 | { |
248 | struct saa7134_dev *dev = file->private_data; | 248 | struct saa7134_dev *dev = file->private_data; |
249 | 249 | ||
250 | saa7134_i2c_call_clients(dev, VIDIOC_S_FMT, f); | 250 | saa_call_all(dev, video, s_fmt, f); |
251 | 251 | ||
252 | f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; | 252 | f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; |
253 | f->fmt.pix.sizeimage = TS_PACKET_SIZE * dev->ts.nr_packets; | 253 | f->fmt.pix.sizeimage = TS_PACKET_SIZE * dev->ts.nr_packets; |
@@ -317,7 +317,7 @@ static int empress_s_ext_ctrls(struct file *file, void *priv, | |||
317 | if (ctrls->ctrl_class != V4L2_CTRL_CLASS_MPEG) | 317 | if (ctrls->ctrl_class != V4L2_CTRL_CLASS_MPEG) |
318 | return -EINVAL; | 318 | return -EINVAL; |
319 | 319 | ||
320 | err = saa7134_i2c_call_saa6752(dev, VIDIOC_S_EXT_CTRLS, ctrls); | 320 | err = saa_call_empress(dev, core, s_ext_ctrls, ctrls); |
321 | ts_init_encoder(dev); | 321 | ts_init_encoder(dev); |
322 | 322 | ||
323 | return err; | 323 | return err; |
@@ -330,7 +330,7 @@ static int empress_g_ext_ctrls(struct file *file, void *priv, | |||
330 | 330 | ||
331 | if (ctrls->ctrl_class != V4L2_CTRL_CLASS_MPEG) | 331 | if (ctrls->ctrl_class != V4L2_CTRL_CLASS_MPEG) |
332 | return -EINVAL; | 332 | return -EINVAL; |
333 | return saa7134_i2c_call_saa6752(dev, VIDIOC_G_EXT_CTRLS, ctrls); | 333 | return saa_call_empress(dev, core, g_ext_ctrls, ctrls); |
334 | } | 334 | } |
335 | 335 | ||
336 | static int empress_g_ctrl(struct file *file, void *priv, | 336 | static int empress_g_ctrl(struct file *file, void *priv, |
@@ -391,7 +391,7 @@ static int empress_queryctrl(struct file *file, void *priv, | |||
391 | return v4l2_ctrl_query_fill_std(c); | 391 | return v4l2_ctrl_query_fill_std(c); |
392 | if (V4L2_CTRL_ID2CLASS(c->id) != V4L2_CTRL_CLASS_MPEG) | 392 | if (V4L2_CTRL_ID2CLASS(c->id) != V4L2_CTRL_CLASS_MPEG) |
393 | return saa7134_queryctrl(file, priv, c); | 393 | return saa7134_queryctrl(file, priv, c); |
394 | return saa7134_i2c_call_saa6752(dev, VIDIOC_QUERYCTRL, c); | 394 | return saa_call_empress(dev, core, queryctrl, c); |
395 | } | 395 | } |
396 | 396 | ||
397 | static int empress_querymenu(struct file *file, void *priv, | 397 | static int empress_querymenu(struct file *file, void *priv, |
@@ -401,7 +401,7 @@ static int empress_querymenu(struct file *file, void *priv, | |||
401 | 401 | ||
402 | if (V4L2_CTRL_ID2CLASS(c->id) != V4L2_CTRL_CLASS_MPEG) | 402 | if (V4L2_CTRL_ID2CLASS(c->id) != V4L2_CTRL_CLASS_MPEG) |
403 | return -EINVAL; | 403 | return -EINVAL; |
404 | return saa7134_i2c_call_saa6752(dev, VIDIOC_QUERYMENU, c); | 404 | return saa_call_empress(dev, core, querymenu, c); |
405 | } | 405 | } |
406 | 406 | ||
407 | static int empress_g_chip_ident(struct file *file, void *fh, | 407 | static int empress_g_chip_ident(struct file *file, void *fh, |
@@ -411,14 +411,12 @@ static int empress_g_chip_ident(struct file *file, void *fh, | |||
411 | 411 | ||
412 | chip->ident = V4L2_IDENT_NONE; | 412 | chip->ident = V4L2_IDENT_NONE; |
413 | chip->revision = 0; | 413 | chip->revision = 0; |
414 | if (dev->mpeg_i2c_client == NULL) | ||
415 | return -EINVAL; | ||
416 | if (chip->match.type == V4L2_CHIP_MATCH_I2C_DRIVER && | 414 | if (chip->match.type == V4L2_CHIP_MATCH_I2C_DRIVER && |
417 | !strcmp(chip->match.name, "saa6752hs")) | 415 | !strcmp(chip->match.name, "saa6752hs")) |
418 | return saa7134_i2c_call_saa6752(dev, VIDIOC_DBG_G_CHIP_IDENT, chip); | 416 | return saa_call_empress(dev, core, g_chip_ident, chip); |
419 | if (chip->match.type == V4L2_CHIP_MATCH_I2C_ADDR && | 417 | if (chip->match.type == V4L2_CHIP_MATCH_I2C_ADDR && |
420 | chip->match.addr == dev->mpeg_i2c_client->addr) | 418 | chip->match.addr == 0x20) |
421 | return saa7134_i2c_call_saa6752(dev, VIDIOC_DBG_G_CHIP_IDENT, chip); | 419 | return saa_call_empress(dev, core, g_chip_ident, chip); |
422 | return -EINVAL; | 420 | return -EINVAL; |
423 | } | 421 | } |
424 | 422 | ||
diff --git a/drivers/media/video/saa7134/saa7134-i2c.c b/drivers/media/video/saa7134/saa7134-i2c.c index 20c1b33caf7b..2e15f43d26ec 100644 --- a/drivers/media/video/saa7134/saa7134-i2c.c +++ b/drivers/media/video/saa7134/saa7134-i2c.c | |||
@@ -327,8 +327,6 @@ static int attach_inform(struct i2c_client *client) | |||
327 | 327 | ||
328 | d1printk( "%s i2c attach [addr=0x%x,client=%s]\n", | 328 | d1printk( "%s i2c attach [addr=0x%x,client=%s]\n", |
329 | client->driver->driver.name, client->addr, client->name); | 329 | client->driver->driver.name, client->addr, client->name); |
330 | if (client->addr == 0x20 && client->driver && client->driver->command) | ||
331 | dev->mpeg_i2c_client = client; | ||
332 | 330 | ||
333 | /* Am I an i2c remote control? */ | 331 | /* Am I an i2c remote control? */ |
334 | 332 | ||
@@ -357,7 +355,6 @@ static struct i2c_algorithm saa7134_algo = { | |||
357 | 355 | ||
358 | static struct i2c_adapter saa7134_adap_template = { | 356 | static struct i2c_adapter saa7134_adap_template = { |
359 | .owner = THIS_MODULE, | 357 | .owner = THIS_MODULE, |
360 | .class = I2C_CLASS_TV_ANALOG, | ||
361 | .name = "saa7134", | 358 | .name = "saa7134", |
362 | .id = I2C_HW_SAA7134, | 359 | .id = I2C_HW_SAA7134, |
363 | .algo = &saa7134_algo, | 360 | .algo = &saa7134_algo, |
@@ -421,29 +418,13 @@ static void do_i2c_scan(char *name, struct i2c_client *c) | |||
421 | } | 418 | } |
422 | } | 419 | } |
423 | 420 | ||
424 | void saa7134_i2c_call_clients(struct saa7134_dev *dev, | ||
425 | unsigned int cmd, void *arg) | ||
426 | { | ||
427 | BUG_ON(NULL == dev->i2c_adap.algo_data); | ||
428 | i2c_clients_command(&dev->i2c_adap, cmd, arg); | ||
429 | } | ||
430 | |||
431 | int saa7134_i2c_call_saa6752(struct saa7134_dev *dev, | ||
432 | unsigned int cmd, void *arg) | ||
433 | { | ||
434 | if (dev->mpeg_i2c_client == NULL) | ||
435 | return -EINVAL; | ||
436 | return dev->mpeg_i2c_client->driver->command(dev->mpeg_i2c_client, | ||
437 | cmd, arg); | ||
438 | } | ||
439 | EXPORT_SYMBOL_GPL(saa7134_i2c_call_saa6752); | ||
440 | |||
441 | int saa7134_i2c_register(struct saa7134_dev *dev) | 421 | int saa7134_i2c_register(struct saa7134_dev *dev) |
442 | { | 422 | { |
443 | dev->i2c_adap = saa7134_adap_template; | 423 | dev->i2c_adap = saa7134_adap_template; |
444 | dev->i2c_adap.dev.parent = &dev->pci->dev; | 424 | dev->i2c_adap.dev.parent = &dev->pci->dev; |
445 | strcpy(dev->i2c_adap.name,dev->name); | 425 | strcpy(dev->i2c_adap.name,dev->name); |
446 | dev->i2c_adap.algo_data = dev; | 426 | dev->i2c_adap.algo_data = dev; |
427 | i2c_set_adapdata(&dev->i2c_adap, &dev->v4l2_dev); | ||
447 | i2c_add_adapter(&dev->i2c_adap); | 428 | i2c_add_adapter(&dev->i2c_adap); |
448 | 429 | ||
449 | dev->i2c_client = saa7134_client_template; | 430 | dev->i2c_client = saa7134_client_template; |
diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c index a1f7e351f572..193b07d83d1e 100644 --- a/drivers/media/video/saa7134/saa7134-video.c +++ b/drivers/media/video/saa7134/saa7134-video.c | |||
@@ -627,10 +627,10 @@ void saa7134_set_tvnorm_hw(struct saa7134_dev *dev) | |||
627 | saa7134_set_decoder(dev); | 627 | saa7134_set_decoder(dev); |
628 | 628 | ||
629 | if (card_in(dev, dev->ctl_input).tv) | 629 | if (card_in(dev, dev->ctl_input).tv) |
630 | saa7134_i2c_call_clients(dev, VIDIOC_S_STD, &dev->tvnorm->id); | 630 | saa_call_all(dev, tuner, s_std, dev->tvnorm->id); |
631 | /* Set the correct norm for the saa6752hs. This function | 631 | /* Set the correct norm for the saa6752hs. This function |
632 | does nothing if there is no saa6752hs. */ | 632 | does nothing if there is no saa6752hs. */ |
633 | saa7134_i2c_call_saa6752(dev, VIDIOC_S_STD, &dev->tvnorm->id); | 633 | saa_call_empress(dev, tuner, s_std, dev->tvnorm->id); |
634 | } | 634 | } |
635 | 635 | ||
636 | static void set_h_prescale(struct saa7134_dev *dev, int task, int prescale) | 636 | static void set_h_prescale(struct saa7134_dev *dev, int task, int prescale) |
@@ -1266,8 +1266,7 @@ int saa7134_s_ctrl_internal(struct saa7134_dev *dev, struct saa7134_fh *fh, str | |||
1266 | else | 1266 | else |
1267 | dev->tda9887_conf &= ~TDA9887_AUTOMUTE; | 1267 | dev->tda9887_conf &= ~TDA9887_AUTOMUTE; |
1268 | 1268 | ||
1269 | saa7134_i2c_call_clients(dev, TUNER_SET_CONFIG, | 1269 | saa_call_all(dev, tuner, s_config, &tda9887_cfg); |
1270 | &tda9887_cfg); | ||
1271 | } | 1270 | } |
1272 | break; | 1271 | break; |
1273 | } | 1272 | } |
@@ -1387,7 +1386,7 @@ static int video_open(struct file *file) | |||
1387 | if (fh->radio) { | 1386 | if (fh->radio) { |
1388 | /* switch to radio mode */ | 1387 | /* switch to radio mode */ |
1389 | saa7134_tvaudio_setinput(dev,&card(dev).radio); | 1388 | saa7134_tvaudio_setinput(dev,&card(dev).radio); |
1390 | saa7134_i2c_call_clients(dev,AUDC_SET_RADIO, NULL); | 1389 | saa_call_all(dev, tuner, s_radio); |
1391 | } else { | 1390 | } else { |
1392 | /* switch to video/vbi mode */ | 1391 | /* switch to video/vbi mode */ |
1393 | video_mux(dev,dev->ctl_input); | 1392 | video_mux(dev,dev->ctl_input); |
@@ -1498,7 +1497,7 @@ static int video_release(struct file *file) | |||
1498 | saa_andorb(SAA7134_OFMT_DATA_A, 0x1f, 0); | 1497 | saa_andorb(SAA7134_OFMT_DATA_A, 0x1f, 0); |
1499 | saa_andorb(SAA7134_OFMT_DATA_B, 0x1f, 0); | 1498 | saa_andorb(SAA7134_OFMT_DATA_B, 0x1f, 0); |
1500 | 1499 | ||
1501 | saa7134_i2c_call_clients(dev, TUNER_SET_STANDBY, NULL); | 1500 | saa_call_all(dev, core, s_standby, 0); |
1502 | 1501 | ||
1503 | /* free stuff */ | 1502 | /* free stuff */ |
1504 | videobuf_mmap_free(&fh->cap); | 1503 | videobuf_mmap_free(&fh->cap); |
@@ -2041,7 +2040,7 @@ static int saa7134_s_frequency(struct file *file, void *priv, | |||
2041 | mutex_lock(&dev->lock); | 2040 | mutex_lock(&dev->lock); |
2042 | dev->ctl_freq = f->frequency; | 2041 | dev->ctl_freq = f->frequency; |
2043 | 2042 | ||
2044 | saa7134_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, f); | 2043 | saa_call_all(dev, tuner, s_frequency, f); |
2045 | 2044 | ||
2046 | saa7134_tvaudio_do_scan(dev); | 2045 | saa7134_tvaudio_do_scan(dev); |
2047 | mutex_unlock(&dev->lock); | 2046 | mutex_unlock(&dev->lock); |
@@ -2299,7 +2298,7 @@ static int radio_g_tuner(struct file *file, void *priv, | |||
2299 | strcpy(t->name, "Radio"); | 2298 | strcpy(t->name, "Radio"); |
2300 | t->type = V4L2_TUNER_RADIO; | 2299 | t->type = V4L2_TUNER_RADIO; |
2301 | 2300 | ||
2302 | saa7134_i2c_call_clients(dev, VIDIOC_G_TUNER, t); | 2301 | saa_call_all(dev, tuner, g_tuner, t); |
2303 | if (dev->input->amux == TV) { | 2302 | if (dev->input->amux == TV) { |
2304 | t->signal = 0xf800 - ((saa_readb(0x581) & 0x1f) << 11); | 2303 | t->signal = 0xf800 - ((saa_readb(0x581) & 0x1f) << 11); |
2305 | t->rxsubchans = (saa_readb(0x529) & 0x08) ? | 2304 | t->rxsubchans = (saa_readb(0x529) & 0x08) ? |
@@ -2316,7 +2315,7 @@ static int radio_s_tuner(struct file *file, void *priv, | |||
2316 | if (0 != t->index) | 2315 | if (0 != t->index) |
2317 | return -EINVAL; | 2316 | return -EINVAL; |
2318 | 2317 | ||
2319 | saa7134_i2c_call_clients(dev, VIDIOC_S_TUNER, t); | 2318 | saa_call_all(dev, tuner, s_tuner, t); |
2320 | return 0; | 2319 | return 0; |
2321 | } | 2320 | } |
2322 | 2321 | ||
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h index 14ee265f3374..bb6952118d01 100644 --- a/drivers/media/video/saa7134/saa7134.h +++ b/drivers/media/video/saa7134/saa7134.h | |||
@@ -35,6 +35,7 @@ | |||
35 | 35 | ||
36 | #include <media/v4l2-common.h> | 36 | #include <media/v4l2-common.h> |
37 | #include <media/v4l2-ioctl.h> | 37 | #include <media/v4l2-ioctl.h> |
38 | #include <media/v4l2-device.h> | ||
38 | #include <media/tuner.h> | 39 | #include <media/tuner.h> |
39 | #include <media/ir-common.h> | 40 | #include <media/ir-common.h> |
40 | #include <media/ir-kbd-i2c.h> | 41 | #include <media/ir-kbd-i2c.h> |
@@ -482,6 +483,7 @@ struct saa7134_dev { | |||
482 | struct mutex lock; | 483 | struct mutex lock; |
483 | spinlock_t slock; | 484 | spinlock_t slock; |
484 | struct v4l2_prio_state prio; | 485 | struct v4l2_prio_state prio; |
486 | struct v4l2_device v4l2_dev; | ||
485 | /* workstruct for loading modules */ | 487 | /* workstruct for loading modules */ |
486 | struct work_struct request_module_wk; | 488 | struct work_struct request_module_wk; |
487 | 489 | ||
@@ -572,7 +574,6 @@ struct saa7134_dev { | |||
572 | enum saa7134_ts_status ts_state; | 574 | enum saa7134_ts_status ts_state; |
573 | unsigned int buff_cnt; | 575 | unsigned int buff_cnt; |
574 | struct saa7134_mpeg_ops *mops; | 576 | struct saa7134_mpeg_ops *mops; |
575 | struct i2c_client *mpeg_i2c_client; | ||
576 | 577 | ||
577 | /* SAA7134_MPEG_EMPRESS only */ | 578 | /* SAA7134_MPEG_EMPRESS only */ |
578 | struct video_device *empress_dev; | 579 | struct video_device *empress_dev; |
@@ -616,6 +617,12 @@ struct saa7134_dev { | |||
616 | V4L2_STD_NTSC | V4L2_STD_PAL_M | \ | 617 | V4L2_STD_NTSC | V4L2_STD_PAL_M | \ |
617 | V4L2_STD_PAL_60) | 618 | V4L2_STD_PAL_60) |
618 | 619 | ||
620 | #define GRP_EMPRESS (1) | ||
621 | #define saa_call_all(dev, o, f, args...) \ | ||
622 | v4l2_device_call_all(&(dev)->v4l2_dev, 0, o, f , ##args) | ||
623 | #define saa_call_empress(dev, o, f, args...) \ | ||
624 | v4l2_device_call_until_err(&(dev)->v4l2_dev, GRP_EMPRESS, o, f , ##args) | ||
625 | |||
619 | /* ----------------------------------------------------------- */ | 626 | /* ----------------------------------------------------------- */ |
620 | /* saa7134-core.c */ | 627 | /* saa7134-core.c */ |
621 | 628 | ||
@@ -668,10 +675,6 @@ int saa7134_tuner_callback(void *priv, int component, int command, int arg); | |||
668 | 675 | ||
669 | int saa7134_i2c_register(struct saa7134_dev *dev); | 676 | int saa7134_i2c_register(struct saa7134_dev *dev); |
670 | int saa7134_i2c_unregister(struct saa7134_dev *dev); | 677 | int saa7134_i2c_unregister(struct saa7134_dev *dev); |
671 | void saa7134_i2c_call_clients(struct saa7134_dev *dev, | ||
672 | unsigned int cmd, void *arg); | ||
673 | int saa7134_i2c_call_saa6752(struct saa7134_dev *dev, | ||
674 | unsigned int cmd, void *arg); | ||
675 | 678 | ||
676 | 679 | ||
677 | /* ----------------------------------------------------------- */ | 680 | /* ----------------------------------------------------------- */ |