diff options
author | Antti Palosaari <crope@iki.fi> | 2014-12-16 08:50:54 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2015-02-03 13:16:17 -0500 |
commit | a2f7f220df5edf7cbe17ec89f49676a7b4b64d34 (patch) | |
tree | af8bd89f4902caff437ea7061388688eee977385 | |
parent | 63bdab5d31b987c5ccb81c3c6662016d07cbb5b7 (diff) |
[media] rtl28xxu: switch SDR module to platform driver
RTL2832 SDR module implements kernel platform driver. Change old
binding to that one.
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
-rw-r--r-- | drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 126 | ||||
-rw-r--r-- | drivers/media/usb/dvb-usb-v2/rtl28xxu.h | 3 |
2 files changed, 50 insertions, 79 deletions
diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c index c64b5ed60ab9..c2d377fa193a 100644 --- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c +++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c | |||
@@ -22,25 +22,6 @@ | |||
22 | 22 | ||
23 | #include "rtl28xxu.h" | 23 | #include "rtl28xxu.h" |
24 | 24 | ||
25 | #ifdef CONFIG_MEDIA_ATTACH | ||
26 | #define dvb_attach_sdr(FUNCTION, ARGS...) ({ \ | ||
27 | void *__r = NULL; \ | ||
28 | typeof(&FUNCTION) __a = symbol_request(FUNCTION); \ | ||
29 | if (__a) { \ | ||
30 | __r = (void *) __a(ARGS); \ | ||
31 | if (__r == NULL) \ | ||
32 | symbol_put(FUNCTION); \ | ||
33 | } \ | ||
34 | __r; \ | ||
35 | }) | ||
36 | |||
37 | #else | ||
38 | #define dvb_attach_sdr(FUNCTION, ARGS...) ({ \ | ||
39 | FUNCTION(ARGS); \ | ||
40 | }) | ||
41 | |||
42 | #endif | ||
43 | |||
44 | static int rtl28xxu_disable_rc; | 25 | static int rtl28xxu_disable_rc; |
45 | module_param_named(disable_rc, rtl28xxu_disable_rc, int, 0644); | 26 | module_param_named(disable_rc, rtl28xxu_disable_rc, int, 0644); |
46 | MODULE_PARM_DESC(disable_rc, "disable RTL2832U remote controller"); | 27 | MODULE_PARM_DESC(disable_rc, "disable RTL2832U remote controller"); |
@@ -662,37 +643,6 @@ static const struct rtl2832_platform_data rtl2832_r820t_platform_data = { | |||
662 | .tuner = TUNER_RTL2832_R820T, | 643 | .tuner = TUNER_RTL2832_R820T, |
663 | }; | 644 | }; |
664 | 645 | ||
665 | /* TODO: these are redundant information for rtl2832_sdr driver */ | ||
666 | static const struct rtl2832_config rtl28xxu_rtl2832_fc0012_config = { | ||
667 | .i2c_addr = 0x10, /* 0x20 */ | ||
668 | .xtal = 28800000, | ||
669 | .tuner = TUNER_RTL2832_FC0012 | ||
670 | }; | ||
671 | |||
672 | static const struct rtl2832_config rtl28xxu_rtl2832_fc0013_config = { | ||
673 | .i2c_addr = 0x10, /* 0x20 */ | ||
674 | .xtal = 28800000, | ||
675 | .tuner = TUNER_RTL2832_FC0013 | ||
676 | }; | ||
677 | |||
678 | static const struct rtl2832_config rtl28xxu_rtl2832_tua9001_config = { | ||
679 | .i2c_addr = 0x10, /* 0x20 */ | ||
680 | .xtal = 28800000, | ||
681 | .tuner = TUNER_RTL2832_TUA9001, | ||
682 | }; | ||
683 | |||
684 | static const struct rtl2832_config rtl28xxu_rtl2832_e4000_config = { | ||
685 | .i2c_addr = 0x10, /* 0x20 */ | ||
686 | .xtal = 28800000, | ||
687 | .tuner = TUNER_RTL2832_E4000, | ||
688 | }; | ||
689 | |||
690 | static const struct rtl2832_config rtl28xxu_rtl2832_r820t_config = { | ||
691 | .i2c_addr = 0x10, | ||
692 | .xtal = 28800000, | ||
693 | .tuner = TUNER_RTL2832_R820T, | ||
694 | }; | ||
695 | |||
696 | static int rtl2832u_fc0012_tuner_callback(struct dvb_usb_device *d, | 646 | static int rtl2832u_fc0012_tuner_callback(struct dvb_usb_device *d, |
697 | int cmd, int arg) | 647 | int cmd, int arg) |
698 | { | 648 | { |
@@ -1062,10 +1012,10 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap) | |||
1062 | int ret; | 1012 | int ret; |
1063 | struct dvb_usb_device *d = adap_to_d(adap); | 1013 | struct dvb_usb_device *d = adap_to_d(adap); |
1064 | struct rtl28xxu_priv *priv = d_to_priv(d); | 1014 | struct rtl28xxu_priv *priv = d_to_priv(d); |
1065 | struct rtl2832_platform_data *pdata = &priv->rtl2832_platform_data; | ||
1066 | struct dvb_frontend *fe = NULL; | 1015 | struct dvb_frontend *fe = NULL; |
1067 | struct i2c_board_info info; | 1016 | struct i2c_board_info info; |
1068 | struct i2c_client *client; | 1017 | struct i2c_client *client; |
1018 | struct v4l2_subdev *subdev = NULL; | ||
1069 | 1019 | ||
1070 | dev_dbg(&d->udev->dev, "%s:\n", __func__); | 1020 | dev_dbg(&d->udev->dev, "%s:\n", __func__); |
1071 | 1021 | ||
@@ -1080,10 +1030,6 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap) | |||
1080 | * that to the tuner driver */ | 1030 | * that to the tuner driver */ |
1081 | adap->fe[0]->ops.read_signal_strength = | 1031 | adap->fe[0]->ops.read_signal_strength = |
1082 | adap->fe[0]->ops.tuner_ops.get_rf_strength; | 1032 | adap->fe[0]->ops.tuner_ops.get_rf_strength; |
1083 | |||
1084 | /* attach SDR */ | ||
1085 | dvb_attach_sdr(rtl2832_sdr_attach, adap->fe[0], &d->i2c_adap, | ||
1086 | &rtl28xxu_rtl2832_fc0012_config, NULL); | ||
1087 | break; | 1033 | break; |
1088 | case TUNER_RTL2832_FC0013: | 1034 | case TUNER_RTL2832_FC0013: |
1089 | fe = dvb_attach(fc0013_attach, adap->fe[0], | 1035 | fe = dvb_attach(fc0013_attach, adap->fe[0], |
@@ -1092,16 +1038,8 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap) | |||
1092 | /* fc0013 also supports signal strength reading */ | 1038 | /* fc0013 also supports signal strength reading */ |
1093 | adap->fe[0]->ops.read_signal_strength = | 1039 | adap->fe[0]->ops.read_signal_strength = |
1094 | adap->fe[0]->ops.tuner_ops.get_rf_strength; | 1040 | adap->fe[0]->ops.tuner_ops.get_rf_strength; |
1095 | |||
1096 | /* attach SDR */ | ||
1097 | dvb_attach_sdr(rtl2832_sdr_attach, adap->fe[0], &d->i2c_adap, | ||
1098 | &rtl28xxu_rtl2832_fc0013_config, NULL); | ||
1099 | break; | 1041 | break; |
1100 | case TUNER_RTL2832_E4000: { | 1042 | case TUNER_RTL2832_E4000: { |
1101 | struct v4l2_subdev *sd; | ||
1102 | struct i2c_adapter *i2c_adap_internal = | ||
1103 | pdata->get_private_i2c_adapter(priv->i2c_client_demod); | ||
1104 | |||
1105 | struct e4000_config e4000_config = { | 1043 | struct e4000_config e4000_config = { |
1106 | .fe = adap->fe[0], | 1044 | .fe = adap->fe[0], |
1107 | .clock = 28800000, | 1045 | .clock = 28800000, |
@@ -1122,13 +1060,7 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap) | |||
1122 | } | 1060 | } |
1123 | 1061 | ||
1124 | priv->i2c_client_tuner = client; | 1062 | priv->i2c_client_tuner = client; |
1125 | sd = i2c_get_clientdata(client); | 1063 | subdev = i2c_get_clientdata(client); |
1126 | i2c_set_adapdata(i2c_adap_internal, d); | ||
1127 | |||
1128 | /* attach SDR */ | ||
1129 | dvb_attach_sdr(rtl2832_sdr_attach, adap->fe[0], | ||
1130 | i2c_adap_internal, | ||
1131 | &rtl28xxu_rtl2832_e4000_config, sd); | ||
1132 | } | 1064 | } |
1133 | break; | 1065 | break; |
1134 | case TUNER_RTL2832_FC2580: | 1066 | case TUNER_RTL2832_FC2580: |
@@ -1158,10 +1090,6 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap) | |||
1158 | /* Use tuner to get the signal strength */ | 1090 | /* Use tuner to get the signal strength */ |
1159 | adap->fe[0]->ops.read_signal_strength = | 1091 | adap->fe[0]->ops.read_signal_strength = |
1160 | adap->fe[0]->ops.tuner_ops.get_rf_strength; | 1092 | adap->fe[0]->ops.tuner_ops.get_rf_strength; |
1161 | |||
1162 | /* attach SDR */ | ||
1163 | dvb_attach_sdr(rtl2832_sdr_attach, adap->fe[0], &d->i2c_adap, | ||
1164 | &rtl28xxu_rtl2832_r820t_config, NULL); | ||
1165 | break; | 1093 | break; |
1166 | case TUNER_RTL2832_R828D: | 1094 | case TUNER_RTL2832_R828D: |
1167 | fe = dvb_attach(r820t_attach, adap->fe[0], | 1095 | fe = dvb_attach(r820t_attach, adap->fe[0], |
@@ -1177,21 +1105,53 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap) | |||
1177 | adap->fe[1]->ops.read_signal_strength = | 1105 | adap->fe[1]->ops.read_signal_strength = |
1178 | adap->fe[1]->ops.tuner_ops.get_rf_strength; | 1106 | adap->fe[1]->ops.tuner_ops.get_rf_strength; |
1179 | } | 1107 | } |
1180 | |||
1181 | /* attach SDR */ | ||
1182 | dvb_attach_sdr(rtl2832_sdr_attach, adap->fe[0], &d->i2c_adap, | ||
1183 | &rtl28xxu_rtl2832_r820t_config, NULL); | ||
1184 | break; | 1108 | break; |
1185 | default: | 1109 | default: |
1186 | dev_err(&d->udev->dev, "%s: unknown tuner=%d\n", KBUILD_MODNAME, | 1110 | dev_err(&d->udev->dev, "%s: unknown tuner=%d\n", KBUILD_MODNAME, |
1187 | priv->tuner); | 1111 | priv->tuner); |
1188 | } | 1112 | } |
1189 | |||
1190 | if (fe == NULL && priv->i2c_client_tuner == NULL) { | 1113 | if (fe == NULL && priv->i2c_client_tuner == NULL) { |
1191 | ret = -ENODEV; | 1114 | ret = -ENODEV; |
1192 | goto err; | 1115 | goto err; |
1193 | } | 1116 | } |
1194 | 1117 | ||
1118 | /* register SDR */ | ||
1119 | switch (priv->tuner) { | ||
1120 | struct platform_device *pdev; | ||
1121 | struct rtl2832_sdr_platform_data pdata = {}; | ||
1122 | |||
1123 | case TUNER_RTL2832_FC0012: | ||
1124 | case TUNER_RTL2832_FC0013: | ||
1125 | case TUNER_RTL2832_E4000: | ||
1126 | case TUNER_RTL2832_R820T: | ||
1127 | case TUNER_RTL2832_R828D: | ||
1128 | pdata.clk = priv->rtl2832_platform_data.clk; | ||
1129 | pdata.tuner = priv->tuner; | ||
1130 | pdata.i2c_client = priv->i2c_client_demod; | ||
1131 | pdata.bulk_read = priv->rtl2832_platform_data.bulk_read; | ||
1132 | pdata.bulk_write = priv->rtl2832_platform_data.bulk_write; | ||
1133 | pdata.update_bits = priv->rtl2832_platform_data.update_bits; | ||
1134 | pdata.dvb_frontend = adap->fe[0]; | ||
1135 | pdata.dvb_usb_device = d; | ||
1136 | pdata.v4l2_subdev = subdev; | ||
1137 | |||
1138 | request_module("%s", "rtl2832_sdr"); | ||
1139 | pdev = platform_device_register_data(&priv->i2c_client_demod->dev, | ||
1140 | "rtl2832_sdr", | ||
1141 | PLATFORM_DEVID_AUTO, | ||
1142 | &pdata, sizeof(pdata)); | ||
1143 | if (pdev == NULL || pdev->dev.driver == NULL) | ||
1144 | break; | ||
1145 | if (!try_module_get(pdev->dev.driver->owner)) { | ||
1146 | platform_device_unregister(pdev); | ||
1147 | break; | ||
1148 | } | ||
1149 | priv->platform_device_sdr = pdev; | ||
1150 | break; | ||
1151 | default: | ||
1152 | dev_dbg(&d->udev->dev, "no SDR for tuner=%d\n", priv->tuner); | ||
1153 | } | ||
1154 | |||
1195 | return 0; | 1155 | return 0; |
1196 | err: | 1156 | err: |
1197 | dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); | 1157 | dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); |
@@ -1203,9 +1163,17 @@ static int rtl2832u_tuner_detach(struct dvb_usb_adapter *adap) | |||
1203 | struct dvb_usb_device *d = adap_to_d(adap); | 1163 | struct dvb_usb_device *d = adap_to_d(adap); |
1204 | struct rtl28xxu_priv *priv = d_to_priv(d); | 1164 | struct rtl28xxu_priv *priv = d_to_priv(d); |
1205 | struct i2c_client *client; | 1165 | struct i2c_client *client; |
1166 | struct platform_device *pdev; | ||
1206 | 1167 | ||
1207 | dev_dbg(&d->udev->dev, "%s:\n", __func__); | 1168 | dev_dbg(&d->udev->dev, "%s:\n", __func__); |
1208 | 1169 | ||
1170 | /* remove platform SDR */ | ||
1171 | pdev = priv->platform_device_sdr; | ||
1172 | if (pdev) { | ||
1173 | module_put(pdev->dev.driver->owner); | ||
1174 | platform_device_unregister(pdev); | ||
1175 | } | ||
1176 | |||
1209 | /* remove I2C tuner */ | 1177 | /* remove I2C tuner */ |
1210 | client = priv->i2c_client_tuner; | 1178 | client = priv->i2c_client_tuner; |
1211 | if (client) { | 1179 | if (client) { |
diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.h b/drivers/media/usb/dvb-usb-v2/rtl28xxu.h index cb3fc6595332..62d32491fbe4 100644 --- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.h +++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.h | |||
@@ -22,6 +22,8 @@ | |||
22 | #ifndef RTL28XXU_H | 22 | #ifndef RTL28XXU_H |
23 | #define RTL28XXU_H | 23 | #define RTL28XXU_H |
24 | 24 | ||
25 | #include <linux/platform_device.h> | ||
26 | |||
25 | #include "dvb_usb.h" | 27 | #include "dvb_usb.h" |
26 | 28 | ||
27 | #include "rtl2830.h" | 29 | #include "rtl2830.h" |
@@ -76,6 +78,7 @@ struct rtl28xxu_priv { | |||
76 | struct i2c_client *i2c_client_demod; | 78 | struct i2c_client *i2c_client_demod; |
77 | struct i2c_client *i2c_client_tuner; | 79 | struct i2c_client *i2c_client_tuner; |
78 | struct i2c_client *i2c_client_slave_demod; | 80 | struct i2c_client *i2c_client_slave_demod; |
81 | struct platform_device *platform_device_sdr; | ||
79 | #define SLAVE_DEMOD_NONE 0 | 82 | #define SLAVE_DEMOD_NONE 0 |
80 | #define SLAVE_DEMOD_MN88472 1 | 83 | #define SLAVE_DEMOD_MN88472 1 |
81 | #define SLAVE_DEMOD_MN88473 2 | 84 | #define SLAVE_DEMOD_MN88473 2 |