aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/common/tuners/xc5000.c
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
commitc71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch)
treeecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /drivers/media/common/tuners/xc5000.c
parentea53c912f8a86a8567697115b6a0d8152beee5c8 (diff)
parent6a00f206debf8a5c8899055726ad127dbeeed098 (diff)
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts: litmus/sched_cedf.c
Diffstat (limited to 'drivers/media/common/tuners/xc5000.c')
-rw-r--r--drivers/media/common/tuners/xc5000.c78
1 files changed, 75 insertions, 3 deletions
diff --git a/drivers/media/common/tuners/xc5000.c b/drivers/media/common/tuners/xc5000.c
index d2b2c12a5561..aa1b2e844d32 100644
--- a/drivers/media/common/tuners/xc5000.c
+++ b/drivers/media/common/tuners/xc5000.c
@@ -65,7 +65,7 @@ struct xc5000_priv {
65}; 65};
66 66
67/* Misc Defines */ 67/* Misc Defines */
68#define MAX_TV_STANDARD 23 68#define MAX_TV_STANDARD 24
69#define XC_MAX_I2C_WRITE_LENGTH 64 69#define XC_MAX_I2C_WRITE_LENGTH 64
70 70
71/* Signal Types */ 71/* Signal Types */
@@ -92,6 +92,8 @@ struct xc5000_priv {
92#define XREG_IF_OUT 0x05 92#define XREG_IF_OUT 0x05
93#define XREG_SEEK_MODE 0x07 93#define XREG_SEEK_MODE 0x07
94#define XREG_POWER_DOWN 0x0A /* Obsolete */ 94#define XREG_POWER_DOWN 0x0A /* Obsolete */
95/* Set the output amplitude - SIF for analog, DTVP/DTVN for digital */
96#define XREG_OUTPUT_AMP 0x0B
95#define XREG_SIGNALSOURCE 0x0D /* 0=Air, 1=Cable */ 97#define XREG_SIGNALSOURCE 0x0D /* 0=Air, 1=Cable */
96#define XREG_SMOOTHEDCVBS 0x0E 98#define XREG_SMOOTHEDCVBS 0x0E
97#define XREG_XTALFREQ 0x0F 99#define XREG_XTALFREQ 0x0F
@@ -173,6 +175,7 @@ struct XC_TV_STANDARD {
173#define DTV7 20 175#define DTV7 20
174#define FM_Radio_INPUT2 21 176#define FM_Radio_INPUT2 21
175#define FM_Radio_INPUT1 22 177#define FM_Radio_INPUT1 22
178#define FM_Radio_INPUT1_MONO 23
176 179
177static struct XC_TV_STANDARD XC5000_Standard[MAX_TV_STANDARD] = { 180static struct XC_TV_STANDARD XC5000_Standard[MAX_TV_STANDARD] = {
178 {"M/N-NTSC/PAL-BTSC", 0x0400, 0x8020}, 181 {"M/N-NTSC/PAL-BTSC", 0x0400, 0x8020},
@@ -197,7 +200,8 @@ static struct XC_TV_STANDARD XC5000_Standard[MAX_TV_STANDARD] = {
197 {"DTV7/8", 0x00C0, 0x801B}, 200 {"DTV7/8", 0x00C0, 0x801B},
198 {"DTV7", 0x00C0, 0x8007}, 201 {"DTV7", 0x00C0, 0x8007},
199 {"FM Radio-INPUT2", 0x9802, 0x9002}, 202 {"FM Radio-INPUT2", 0x9802, 0x9002},
200 {"FM Radio-INPUT1", 0x0208, 0x9002} 203 {"FM Radio-INPUT1", 0x0208, 0x9002},
204 {"FM Radio-INPUT1_MONO", 0x0278, 0x9002}
201}; 205};
202 206
203static int xc_load_fw_and_init_tuner(struct dvb_frontend *fe); 207static int xc_load_fw_and_init_tuner(struct dvb_frontend *fe);
@@ -624,6 +628,15 @@ static void xc_debug_dump(struct xc5000_priv *priv)
624 dprintk(1, "*** Quality (0:<8dB, 7:>56dB) = %d\n", quality); 628 dprintk(1, "*** Quality (0:<8dB, 7:>56dB) = %d\n", quality);
625} 629}
626 630
631/*
632 * As defined on EN 300 429, the DVB-C roll-off factor is 0.15.
633 * So, the amount of the needed bandwith is given by:
634 * Bw = Symbol_rate * (1 + 0.15)
635 * As such, the maximum symbol rate supported by 6 MHz is given by:
636 * max_symbol_rate = 6 MHz / 1.15 = 5217391 Bauds
637 */
638#define MAX_SYMBOL_RATE_6MHz 5217391
639
627static int xc5000_set_params(struct dvb_frontend *fe, 640static int xc5000_set_params(struct dvb_frontend *fe,
628 struct dvb_frontend_parameters *params) 641 struct dvb_frontend_parameters *params)
629{ 642{
@@ -683,6 +696,35 @@ static int xc5000_set_params(struct dvb_frontend *fe,
683 return -EINVAL; 696 return -EINVAL;
684 } 697 }
685 priv->rf_mode = XC_RF_MODE_AIR; 698 priv->rf_mode = XC_RF_MODE_AIR;
699 } else if (fe->ops.info.type == FE_QAM) {
700 switch (params->u.qam.modulation) {
701 case QAM_256:
702 case QAM_AUTO:
703 case QAM_16:
704 case QAM_32:
705 case QAM_64:
706 case QAM_128:
707 dprintk(1, "%s() QAM modulation\n", __func__);
708 priv->rf_mode = XC_RF_MODE_CABLE;
709 /*
710 * Using a 8MHz bandwidth sometimes fail
711 * with 6MHz-spaced channels, due to inter-carrier
712 * interference. So, use DTV6 firmware
713 */
714 if (params->u.qam.symbol_rate <= MAX_SYMBOL_RATE_6MHz) {
715 priv->bandwidth = BANDWIDTH_6_MHZ;
716 priv->video_standard = DTV6;
717 priv->freq_hz = params->frequency - 1750000;
718 } else {
719 priv->bandwidth = BANDWIDTH_8_MHZ;
720 priv->video_standard = DTV7_8;
721 priv->freq_hz = params->frequency - 2750000;
722 }
723 break;
724 default:
725 dprintk(1, "%s() Unsupported QAM type\n", __func__);
726 return -EINVAL;
727 }
686 } else { 728 } else {
687 printk(KERN_ERR "xc5000 modulation type not supported!\n"); 729 printk(KERN_ERR "xc5000 modulation type not supported!\n");
688 return -EINVAL; 730 return -EINVAL;
@@ -714,6 +756,8 @@ static int xc5000_set_params(struct dvb_frontend *fe,
714 return -EIO; 756 return -EIO;
715 } 757 }
716 758
759 xc_write_reg(priv, XREG_OUTPUT_AMP, 0x8a);
760
717 xc_tune_channel(priv, priv->freq_hz, XC_TUNE_DIGITAL); 761 xc_tune_channel(priv, priv->freq_hz, XC_TUNE_DIGITAL);
718 762
719 if (debug) 763 if (debug)
@@ -818,6 +862,8 @@ tune_channel:
818 return -EREMOTEIO; 862 return -EREMOTEIO;
819 } 863 }
820 864
865 xc_write_reg(priv, XREG_OUTPUT_AMP, 0x09);
866
821 xc_tune_channel(priv, priv->freq_hz, XC_TUNE_ANALOG); 867 xc_tune_channel(priv, priv->freq_hz, XC_TUNE_ANALOG);
822 868
823 if (debug) 869 if (debug)
@@ -845,6 +891,8 @@ static int xc5000_set_radio_freq(struct dvb_frontend *fe,
845 radio_input = FM_Radio_INPUT1; 891 radio_input = FM_Radio_INPUT1;
846 else if (priv->radio_input == XC5000_RADIO_FM2) 892 else if (priv->radio_input == XC5000_RADIO_FM2)
847 radio_input = FM_Radio_INPUT2; 893 radio_input = FM_Radio_INPUT2;
894 else if (priv->radio_input == XC5000_RADIO_FM1_MONO)
895 radio_input = FM_Radio_INPUT1_MONO;
848 else { 896 else {
849 dprintk(1, "%s() unknown radio input %d\n", __func__, 897 dprintk(1, "%s() unknown radio input %d\n", __func__,
850 priv->radio_input); 898 priv->radio_input);
@@ -871,6 +919,12 @@ static int xc5000_set_radio_freq(struct dvb_frontend *fe,
871 return -EREMOTEIO; 919 return -EREMOTEIO;
872 } 920 }
873 921
922 if ((priv->radio_input == XC5000_RADIO_FM1) ||
923 (priv->radio_input == XC5000_RADIO_FM2))
924 xc_write_reg(priv, XREG_OUTPUT_AMP, 0x09);
925 else if (priv->radio_input == XC5000_RADIO_FM1_MONO)
926 xc_write_reg(priv, XREG_OUTPUT_AMP, 0x06);
927
874 xc_tune_channel(priv, priv->freq_hz, XC_TUNE_ANALOG); 928 xc_tune_channel(priv, priv->freq_hz, XC_TUNE_ANALOG);
875 929
876 return 0; 930 return 0;
@@ -1021,6 +1075,23 @@ static int xc5000_release(struct dvb_frontend *fe)
1021 return 0; 1075 return 0;
1022} 1076}
1023 1077
1078static int xc5000_set_config(struct dvb_frontend *fe, void *priv_cfg)
1079{
1080 struct xc5000_priv *priv = fe->tuner_priv;
1081 struct xc5000_config *p = priv_cfg;
1082
1083 dprintk(1, "%s()\n", __func__);
1084
1085 if (p->if_khz)
1086 priv->if_khz = p->if_khz;
1087
1088 if (p->radio_input)
1089 priv->radio_input = p->radio_input;
1090
1091 return 0;
1092}
1093
1094
1024static const struct dvb_tuner_ops xc5000_tuner_ops = { 1095static const struct dvb_tuner_ops xc5000_tuner_ops = {
1025 .info = { 1096 .info = {
1026 .name = "Xceive XC5000", 1097 .name = "Xceive XC5000",
@@ -1033,6 +1104,7 @@ static const struct dvb_tuner_ops xc5000_tuner_ops = {
1033 .init = xc5000_init, 1104 .init = xc5000_init,
1034 .sleep = xc5000_sleep, 1105 .sleep = xc5000_sleep,
1035 1106
1107 .set_config = xc5000_set_config,
1036 .set_params = xc5000_set_params, 1108 .set_params = xc5000_set_params,
1037 .set_analog_params = xc5000_set_analog_params, 1109 .set_analog_params = xc5000_set_analog_params,
1038 .get_frequency = xc5000_get_frequency, 1110 .get_frequency = xc5000_get_frequency,
@@ -1042,7 +1114,7 @@ static const struct dvb_tuner_ops xc5000_tuner_ops = {
1042 1114
1043struct dvb_frontend *xc5000_attach(struct dvb_frontend *fe, 1115struct dvb_frontend *xc5000_attach(struct dvb_frontend *fe,
1044 struct i2c_adapter *i2c, 1116 struct i2c_adapter *i2c,
1045 struct xc5000_config *cfg) 1117 const struct xc5000_config *cfg)
1046{ 1118{
1047 struct xc5000_priv *priv = NULL; 1119 struct xc5000_priv *priv = NULL;
1048 int instance; 1120 int instance;