aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntti Palosaari <crope@iki.fi>2014-12-12 22:09:57 -0500
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-02-03 13:01:04 -0500
commit77a2e76b8505c2ed00db4925c22bfcde2be701a4 (patch)
tree5c65acf3067fe6e4cb491481ba5f7337b23b6789
parent6f5f6ee24ea3a27f0ed3655c2051691bceb8beec (diff)
[media] rtl28xxu: use rtl2832 demod callbacks accessing its resources
Switch demod resource use from exported symbols to callbacks its provides. 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.c39
-rw-r--r--drivers/media/usb/dvb-usb-v2/rtl28xxu.h5
2 files changed, 24 insertions, 20 deletions
diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index fa76ad2ac214..3d619def7066 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -782,36 +782,35 @@ static int rtl2832u_frontend_callback(void *adapter_priv, int component,
782 782
783static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap) 783static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap)
784{ 784{
785 int ret;
786 struct dvb_usb_device *d = adap_to_d(adap); 785 struct dvb_usb_device *d = adap_to_d(adap);
787 struct rtl28xxu_priv *priv = d_to_priv(d); 786 struct rtl28xxu_priv *priv = d_to_priv(d);
788 struct rtl2832_platform_data platform_data; 787 struct rtl2832_platform_data *pdata = &priv->rtl2832_platform_data;
789 const struct rtl2832_config *rtl2832_config; 788 struct i2c_board_info board_info;
790 struct i2c_board_info board_info = {};
791 struct i2c_client *client; 789 struct i2c_client *client;
790 int ret;
792 791
793 dev_dbg(&d->udev->dev, "%s:\n", __func__); 792 dev_dbg(&d->udev->dev, "%s:\n", __func__);
794 793
795 switch (priv->tuner) { 794 switch (priv->tuner) {
796 case TUNER_RTL2832_FC0012: 795 case TUNER_RTL2832_FC0012:
797 rtl2832_config = &rtl28xxu_rtl2832_fc0012_config; 796 pdata->config = &rtl28xxu_rtl2832_fc0012_config;
798 break; 797 break;
799 case TUNER_RTL2832_FC0013: 798 case TUNER_RTL2832_FC0013:
800 rtl2832_config = &rtl28xxu_rtl2832_fc0013_config; 799 pdata->config = &rtl28xxu_rtl2832_fc0013_config;
801 break; 800 break;
802 case TUNER_RTL2832_FC2580: 801 case TUNER_RTL2832_FC2580:
803 /* FIXME: do not abuse fc0012 settings */ 802 /* FIXME: do not abuse fc0012 settings */
804 rtl2832_config = &rtl28xxu_rtl2832_fc0012_config; 803 pdata->config = &rtl28xxu_rtl2832_fc0012_config;
805 break; 804 break;
806 case TUNER_RTL2832_TUA9001: 805 case TUNER_RTL2832_TUA9001:
807 rtl2832_config = &rtl28xxu_rtl2832_tua9001_config; 806 pdata->config = &rtl28xxu_rtl2832_tua9001_config;
808 break; 807 break;
809 case TUNER_RTL2832_E4000: 808 case TUNER_RTL2832_E4000:
810 rtl2832_config = &rtl28xxu_rtl2832_e4000_config; 809 pdata->config = &rtl28xxu_rtl2832_e4000_config;
811 break; 810 break;
812 case TUNER_RTL2832_R820T: 811 case TUNER_RTL2832_R820T:
813 case TUNER_RTL2832_R828D: 812 case TUNER_RTL2832_R828D:
814 rtl2832_config = &rtl28xxu_rtl2832_r820t_config; 813 pdata->config = &rtl28xxu_rtl2832_r820t_config;
815 break; 814 break;
816 default: 815 default:
817 dev_err(&d->udev->dev, "%s: unknown tuner=%s\n", 816 dev_err(&d->udev->dev, "%s: unknown tuner=%s\n",
@@ -821,11 +820,10 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap)
821 } 820 }
822 821
823 /* attach demodulator */ 822 /* attach demodulator */
824 platform_data.config = rtl2832_config; 823 memset(&board_info, 0, sizeof(board_info));
825 platform_data.dvb_frontend = &adap->fe[0];
826 strlcpy(board_info.type, "rtl2832", I2C_NAME_SIZE); 824 strlcpy(board_info.type, "rtl2832", I2C_NAME_SIZE);
827 board_info.addr = 0x10; 825 board_info.addr = 0x10;
828 board_info.platform_data = &platform_data; 826 board_info.platform_data = pdata;
829 request_module("%s", board_info.type); 827 request_module("%s", board_info.type);
830 client = i2c_new_device(&d->i2c_adap, &board_info); 828 client = i2c_new_device(&d->i2c_adap, &board_info);
831 if (client == NULL || client->dev.driver == NULL) { 829 if (client == NULL || client->dev.driver == NULL) {
@@ -839,10 +837,10 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap)
839 goto err; 837 goto err;
840 } 838 }
841 839
842 priv->i2c_client_demod = client; 840 adap->fe[0] = pdata->get_dvb_frontend(client);
841 priv->demod_i2c_adapter = pdata->get_i2c_adapter(client);
843 842
844 /* RTL2832 I2C repeater */ 843 priv->i2c_client_demod = client;
845 priv->demod_i2c_adapter = rtl2832_get_i2c_adapter(adap->fe[0]);
846 844
847 /* set fe callback */ 845 /* set fe callback */
848 adap->fe[0]->callback = rtl2832u_frontend_callback; 846 adap->fe[0]->callback = rtl2832u_frontend_callback;
@@ -1038,6 +1036,7 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap)
1038 int ret; 1036 int ret;
1039 struct dvb_usb_device *d = adap_to_d(adap); 1037 struct dvb_usb_device *d = adap_to_d(adap);
1040 struct rtl28xxu_priv *priv = d_to_priv(d); 1038 struct rtl28xxu_priv *priv = d_to_priv(d);
1039 struct rtl2832_platform_data *pdata = &priv->rtl2832_platform_data;
1041 struct dvb_frontend *fe = NULL; 1040 struct dvb_frontend *fe = NULL;
1042 struct i2c_board_info info; 1041 struct i2c_board_info info;
1043 struct i2c_client *client; 1042 struct i2c_client *client;
@@ -1075,7 +1074,8 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap)
1075 case TUNER_RTL2832_E4000: { 1074 case TUNER_RTL2832_E4000: {
1076 struct v4l2_subdev *sd; 1075 struct v4l2_subdev *sd;
1077 struct i2c_adapter *i2c_adap_internal = 1076 struct i2c_adapter *i2c_adap_internal =
1078 rtl2832_get_private_i2c_adapter(adap->fe[0]); 1077 pdata->get_private_i2c_adapter(priv->i2c_client_demod);
1078
1079 struct e4000_config e4000_config = { 1079 struct e4000_config e4000_config = {
1080 .fe = adap->fe[0], 1080 .fe = adap->fe[0],
1081 .clock = 28800000, 1081 .clock = 28800000,
@@ -1346,7 +1346,8 @@ err:
1346static int rtl2832u_frontend_ctrl(struct dvb_frontend *fe, int onoff) 1346static int rtl2832u_frontend_ctrl(struct dvb_frontend *fe, int onoff)
1347{ 1347{
1348 struct dvb_usb_device *d = fe_to_d(fe); 1348 struct dvb_usb_device *d = fe_to_d(fe);
1349 struct dvb_usb_adapter *adap = fe_to_adap(fe); 1349 struct rtl28xxu_priv *priv = fe_to_priv(fe);
1350 struct rtl2832_platform_data *pdata = &priv->rtl2832_platform_data;
1350 int ret; 1351 int ret;
1351 u8 val; 1352 u8 val;
1352 1353
@@ -1364,7 +1365,7 @@ static int rtl2832u_frontend_ctrl(struct dvb_frontend *fe, int onoff)
1364 1365
1365 /* bypass slave demod TS through master demod */ 1366 /* bypass slave demod TS through master demod */
1366 if (fe->id == 1 && onoff) { 1367 if (fe->id == 1 && onoff) {
1367 ret = rtl2832_enable_external_ts_if(adap->fe[0]); 1368 ret = pdata->enable_slave_ts(priv->i2c_client_demod);
1368 if (ret) 1369 if (ret)
1369 goto err; 1370 goto err;
1370 } 1371 }
diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.h b/drivers/media/usb/dvb-usb-v2/rtl28xxu.h
index 3f630c842949..cb3fc6595332 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.h
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.h
@@ -80,7 +80,10 @@ struct rtl28xxu_priv {
80 #define SLAVE_DEMOD_MN88472 1 80 #define SLAVE_DEMOD_MN88472 1
81 #define SLAVE_DEMOD_MN88473 2 81 #define SLAVE_DEMOD_MN88473 2
82 unsigned int slave_demod:2; 82 unsigned int slave_demod:2;
83 struct rtl2830_platform_data rtl2830_platform_data; 83 union {
84 struct rtl2830_platform_data rtl2830_platform_data;
85 struct rtl2832_platform_data rtl2832_platform_data;
86 };
84}; 87};
85 88
86enum rtl28xxu_chip_id { 89enum rtl28xxu_chip_id {