aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/tuners/xc5000.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <m.chehab@samsung.com>2014-08-09 20:47:22 -0400
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-08-21 16:25:09 -0400
commitc3d6676bbaf4666ded026b35e0f62156e59ecfc1 (patch)
treed621553a7f8e94508d13cf113a3efe13d194cd1b /drivers/media/tuners/xc5000.c
parent164352023104207322614deef8d03bd0d773a22a (diff)
[media] xc5000: Split config and set code for analog/radio
As we need a function that reapply the last tuned radio, in order to do resume, split the code that validates and updates the internal priv struct from the ones that actually set radio and TV. A latter patch will add support for resume. Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media/tuners/xc5000.c')
-rw-r--r--drivers/media/tuners/xc5000.c81
1 files changed, 56 insertions, 25 deletions
diff --git a/drivers/media/tuners/xc5000.c b/drivers/media/tuners/xc5000.c
index 3293fd8df59b..78695ed4549c 100644
--- a/drivers/media/tuners/xc5000.c
+++ b/drivers/media/tuners/xc5000.c
@@ -863,12 +863,10 @@ static int xc5000_is_firmware_loaded(struct dvb_frontend *fe)
863 return ret; 863 return ret;
864} 864}
865 865
866static int xc5000_set_tv_freq(struct dvb_frontend *fe, 866static void xc5000_config_tv(struct dvb_frontend *fe,
867 struct analog_parameters *params) 867 struct analog_parameters *params)
868{ 868{
869 struct xc5000_priv *priv = fe->tuner_priv; 869 struct xc5000_priv *priv = fe->tuner_priv;
870 u16 pll_lock_status;
871 int ret;
872 870
873 dprintk(1, "%s() frequency=%d (in units of 62.5khz)\n", 871 dprintk(1, "%s() frequency=%d (in units of 62.5khz)\n",
874 __func__, params->frequency); 872 __func__, params->frequency);
@@ -887,42 +885,49 @@ static int xc5000_set_tv_freq(struct dvb_frontend *fe,
887 if (params->std & V4L2_STD_MN) { 885 if (params->std & V4L2_STD_MN) {
888 /* default to BTSC audio standard */ 886 /* default to BTSC audio standard */
889 priv->video_standard = MN_NTSC_PAL_BTSC; 887 priv->video_standard = MN_NTSC_PAL_BTSC;
890 goto tune_channel; 888 return;
891 } 889 }
892 890
893 if (params->std & V4L2_STD_PAL_BG) { 891 if (params->std & V4L2_STD_PAL_BG) {
894 /* default to NICAM audio standard */ 892 /* default to NICAM audio standard */
895 priv->video_standard = BG_PAL_NICAM; 893 priv->video_standard = BG_PAL_NICAM;
896 goto tune_channel; 894 return;
897 } 895 }
898 896
899 if (params->std & V4L2_STD_PAL_I) { 897 if (params->std & V4L2_STD_PAL_I) {
900 /* default to NICAM audio standard */ 898 /* default to NICAM audio standard */
901 priv->video_standard = I_PAL_NICAM; 899 priv->video_standard = I_PAL_NICAM;
902 goto tune_channel; 900 return;
903 } 901 }
904 902
905 if (params->std & V4L2_STD_PAL_DK) { 903 if (params->std & V4L2_STD_PAL_DK) {
906 /* default to NICAM audio standard */ 904 /* default to NICAM audio standard */
907 priv->video_standard = DK_PAL_NICAM; 905 priv->video_standard = DK_PAL_NICAM;
908 goto tune_channel; 906 return;
909 } 907 }
910 908
911 if (params->std & V4L2_STD_SECAM_DK) { 909 if (params->std & V4L2_STD_SECAM_DK) {
912 /* default to A2 DK1 audio standard */ 910 /* default to A2 DK1 audio standard */
913 priv->video_standard = DK_SECAM_A2DK1; 911 priv->video_standard = DK_SECAM_A2DK1;
914 goto tune_channel; 912 return;
915 } 913 }
916 914
917 if (params->std & V4L2_STD_SECAM_L) { 915 if (params->std & V4L2_STD_SECAM_L) {
918 priv->video_standard = L_SECAM_NICAM; 916 priv->video_standard = L_SECAM_NICAM;
919 goto tune_channel; 917 return;
920 } 918 }
921 919
922 if (params->std & V4L2_STD_SECAM_LC) { 920 if (params->std & V4L2_STD_SECAM_LC) {
923 priv->video_standard = LC_SECAM_NICAM; 921 priv->video_standard = LC_SECAM_NICAM;
924 goto tune_channel; 922 return;
925 } 923 }
924}
925
926static int xc5000_set_tv_freq(struct dvb_frontend *fe)
927{
928 struct xc5000_priv *priv = fe->tuner_priv;
929 u16 pll_lock_status;
930 int ret;
926 931
927tune_channel: 932tune_channel:
928 ret = xc_set_signal_source(priv, priv->rf_mode); 933 ret = xc_set_signal_source(priv, priv->rf_mode);
@@ -966,12 +971,11 @@ tune_channel:
966 return 0; 971 return 0;
967} 972}
968 973
969static int xc5000_set_radio_freq(struct dvb_frontend *fe, 974static int xc5000_config_radio(struct dvb_frontend *fe,
970 struct analog_parameters *params) 975 struct analog_parameters *params)
976
971{ 977{
972 struct xc5000_priv *priv = fe->tuner_priv; 978 struct xc5000_priv *priv = fe->tuner_priv;
973 int ret = -EINVAL;
974 u8 radio_input;
975 979
976 dprintk(1, "%s() frequency=%d (in units of khz)\n", 980 dprintk(1, "%s() frequency=%d (in units of khz)\n",
977 __func__, params->frequency); 981 __func__, params->frequency);
@@ -981,6 +985,18 @@ static int xc5000_set_radio_freq(struct dvb_frontend *fe,
981 return -EINVAL; 985 return -EINVAL;
982 } 986 }
983 987
988 priv->freq_hz = params->frequency * 125 / 2;
989 priv->rf_mode = XC_RF_MODE_AIR;
990
991 return 0;
992}
993
994static int xc5000_set_radio_freq(struct dvb_frontend *fe)
995{
996 struct xc5000_priv *priv = fe->tuner_priv;
997 int ret;
998 u8 radio_input;
999
984 if (priv->radio_input == XC5000_RADIO_FM1) 1000 if (priv->radio_input == XC5000_RADIO_FM1)
985 radio_input = FM_RADIO_INPUT1; 1001 radio_input = FM_RADIO_INPUT1;
986 else if (priv->radio_input == XC5000_RADIO_FM2) 1002 else if (priv->radio_input == XC5000_RADIO_FM2)
@@ -993,10 +1009,6 @@ static int xc5000_set_radio_freq(struct dvb_frontend *fe,
993 return -EINVAL; 1009 return -EINVAL;
994 } 1010 }
995 1011
996 priv->freq_hz = params->frequency * 125 / 2;
997
998 priv->rf_mode = XC_RF_MODE_AIR;
999
1000 ret = xc_set_tv_standard(priv, xc5000_standard[radio_input].video_mode, 1012 ret = xc_set_tv_standard(priv, xc5000_standard[radio_input].video_mode,
1001 xc5000_standard[radio_input].audio_mode, radio_input); 1013 xc5000_standard[radio_input].audio_mode, radio_input);
1002 1014
@@ -1024,11 +1036,27 @@ static int xc5000_set_radio_freq(struct dvb_frontend *fe,
1024 return 0; 1036 return 0;
1025} 1037}
1026 1038
1039static int xc5000_apply_params(struct dvb_frontend *fe)
1040{
1041 struct xc5000_priv *priv = fe->tuner_priv;
1042
1043 switch (priv->mode) {
1044 case V4L2_TUNER_RADIO:
1045 return xc5000_set_radio_freq(fe);
1046 case V4L2_TUNER_ANALOG_TV:
1047 return xc5000_set_tv_freq(fe);
1048 case V4L2_TUNER_DIGITAL_TV:
1049 return xc5000_tune_digital(fe);
1050 }
1051
1052 return 0;
1053}
1054
1027static int xc5000_set_analog_params(struct dvb_frontend *fe, 1055static int xc5000_set_analog_params(struct dvb_frontend *fe,
1028 struct analog_parameters *params) 1056 struct analog_parameters *params)
1029{ 1057{
1030 struct xc5000_priv *priv = fe->tuner_priv; 1058 struct xc5000_priv *priv = fe->tuner_priv;
1031 int ret = -EINVAL; 1059 int ret;
1032 1060
1033 if (priv->i2c_props.adap == NULL) 1061 if (priv->i2c_props.adap == NULL)
1034 return -EINVAL; 1062 return -EINVAL;
@@ -1040,18 +1068,21 @@ static int xc5000_set_analog_params(struct dvb_frontend *fe,
1040 1068
1041 switch (params->mode) { 1069 switch (params->mode) {
1042 case V4L2_TUNER_RADIO: 1070 case V4L2_TUNER_RADIO:
1043 ret = xc5000_set_radio_freq(fe, params); 1071 ret = xc5000_config_radio(fe, params);
1072 if (ret)
1073 return ret;
1044 break; 1074 break;
1045 case V4L2_TUNER_ANALOG_TV: 1075 case V4L2_TUNER_ANALOG_TV:
1046 case V4L2_TUNER_DIGITAL_TV: 1076 xc5000_config_tv(fe, params);
1047 ret = xc5000_set_tv_freq(fe, params); 1077 break;
1078 default:
1048 break; 1079 break;
1049 } 1080 }
1081 priv->mode = params->mode;
1050 1082
1051 return ret; 1083 return xc5000_apply_params(fe);
1052} 1084}
1053 1085
1054
1055static int xc5000_get_frequency(struct dvb_frontend *fe, u32 *freq) 1086static int xc5000_get_frequency(struct dvb_frontend *fe, u32 *freq)
1056{ 1087{
1057 struct xc5000_priv *priv = fe->tuner_priv; 1088 struct xc5000_priv *priv = fe->tuner_priv;