aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/common/tuners
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/common/tuners')
-rw-r--r--drivers/media/common/tuners/tda18271-common.c10
-rw-r--r--drivers/media/common/tuners/tda18271-fe.c53
-rw-r--r--drivers/media/common/tuners/xc5000.c30
-rw-r--r--drivers/media/common/tuners/xc5000_priv.h1
4 files changed, 66 insertions, 28 deletions
diff --git a/drivers/media/common/tuners/tda18271-common.c b/drivers/media/common/tuners/tda18271-common.c
index f1894fec32b9..6fb5b4586569 100644
--- a/drivers/media/common/tuners/tda18271-common.c
+++ b/drivers/media/common/tuners/tda18271-common.c
@@ -649,9 +649,17 @@ int tda18271_calc_rf_cal(struct dvb_frontend *fe, u32 *freq)
649 u8 val; 649 u8 val;
650 650
651 int ret = tda18271_lookup_map(fe, RF_CAL, freq, &val); 651 int ret = tda18271_lookup_map(fe, RF_CAL, freq, &val);
652 /* The TDA18271HD/C1 rf_cal map lookup is expected to go out of range
653 * for frequencies above 61.1 MHz. In these cases, the internal RF
654 * tracking filters calibration mechanism is used.
655 *
656 * There is no need to warn the user about this.
657 */
658 if (ret < 0)
659 goto fail;
652 660
653 regs[R_EB14] = val; 661 regs[R_EB14] = val;
654 662fail:
655 return ret; 663 return ret;
656} 664}
657 665
diff --git a/drivers/media/common/tuners/tda18271-fe.c b/drivers/media/common/tuners/tda18271-fe.c
index 89c01fb1f859..93063c6fbbf6 100644
--- a/drivers/media/common/tuners/tda18271-fe.c
+++ b/drivers/media/common/tuners/tda18271-fe.c
@@ -45,6 +45,21 @@ static inline int charge_pump_source(struct dvb_frontend *fe, int force)
45 TDA18271_MAIN_PLL, force); 45 TDA18271_MAIN_PLL, force);
46} 46}
47 47
48static inline void tda18271_set_if_notch(struct dvb_frontend *fe)
49{
50 struct tda18271_priv *priv = fe->tuner_priv;
51 unsigned char *regs = priv->tda18271_regs;
52
53 switch (priv->mode) {
54 case TDA18271_ANALOG:
55 regs[R_MPD] &= ~0x80; /* IF notch = 0 */
56 break;
57 case TDA18271_DIGITAL:
58 regs[R_MPD] |= 0x80; /* IF notch = 1 */
59 break;
60 }
61}
62
48static int tda18271_channel_configuration(struct dvb_frontend *fe, 63static int tda18271_channel_configuration(struct dvb_frontend *fe,
49 struct tda18271_std_map_item *map, 64 struct tda18271_std_map_item *map,
50 u32 freq, u32 bw) 65 u32 freq, u32 bw)
@@ -60,25 +75,18 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe,
60 regs[R_EP3] &= ~0x1f; /* clear std bits */ 75 regs[R_EP3] &= ~0x1f; /* clear std bits */
61 regs[R_EP3] |= (map->agc_mode << 3) | map->std; 76 regs[R_EP3] |= (map->agc_mode << 3) | map->std;
62 77
63 /* set rfagc to high speed mode */ 78 if (priv->id == TDA18271HDC2) {
64 regs[R_EP3] &= ~0x04; 79 /* set rfagc to high speed mode */
80 regs[R_EP3] &= ~0x04;
81 }
65 82
66 /* set cal mode to normal */ 83 /* set cal mode to normal */
67 regs[R_EP4] &= ~0x03; 84 regs[R_EP4] &= ~0x03;
68 85
69 /* update IF output level & IF notch frequency */ 86 /* update IF output level */
70 regs[R_EP4] &= ~0x1c; /* clear if level bits */ 87 regs[R_EP4] &= ~0x1c; /* clear if level bits */
71 regs[R_EP4] |= (map->if_lvl << 2); 88 regs[R_EP4] |= (map->if_lvl << 2);
72 89
73 switch (priv->mode) {
74 case TDA18271_ANALOG:
75 regs[R_MPD] &= ~0x80; /* IF notch = 0 */
76 break;
77 case TDA18271_DIGITAL:
78 regs[R_MPD] |= 0x80; /* IF notch = 1 */
79 break;
80 }
81
82 /* update FM_RFn */ 90 /* update FM_RFn */
83 regs[R_EP4] &= ~0x80; 91 regs[R_EP4] &= ~0x80;
84 regs[R_EP4] |= map->fm_rfn << 7; 92 regs[R_EP4] |= map->fm_rfn << 7;
@@ -95,6 +103,9 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe,
95 /* disable Power Level Indicator */ 103 /* disable Power Level Indicator */
96 regs[R_EP1] |= 0x40; 104 regs[R_EP1] |= 0x40;
97 105
106 /* make sure thermometer is off */
107 regs[R_TM] &= ~0x10;
108
98 /* frequency dependent parameters */ 109 /* frequency dependent parameters */
99 110
100 tda18271_calc_ir_measure(fe, &freq); 111 tda18271_calc_ir_measure(fe, &freq);
@@ -135,6 +146,7 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe,
135 switch (priv->role) { 146 switch (priv->role) {
136 case TDA18271_MASTER: 147 case TDA18271_MASTER:
137 tda18271_calc_main_pll(fe, N); 148 tda18271_calc_main_pll(fe, N);
149 tda18271_set_if_notch(fe);
138 tda18271_write_regs(fe, R_MPD, 4); 150 tda18271_write_regs(fe, R_MPD, 4);
139 break; 151 break;
140 case TDA18271_SLAVE: 152 case TDA18271_SLAVE:
@@ -142,6 +154,7 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe,
142 tda18271_write_regs(fe, R_CPD, 4); 154 tda18271_write_regs(fe, R_CPD, 4);
143 155
144 regs[R_MPD] = regs[R_CPD] & 0x7f; 156 regs[R_MPD] = regs[R_CPD] & 0x7f;
157 tda18271_set_if_notch(fe);
145 tda18271_write_regs(fe, R_MPD, 1); 158 tda18271_write_regs(fe, R_MPD, 1);
146 break; 159 break;
147 } 160 }
@@ -160,12 +173,14 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe,
160 173
161 msleep(20); 174 msleep(20);
162 175
163 /* set rfagc to normal speed mode */ 176 if (priv->id == TDA18271HDC2) {
164 if (map->fm_rfn) 177 /* set rfagc to normal speed mode */
165 regs[R_EP3] &= ~0x04; 178 if (map->fm_rfn)
166 else 179 regs[R_EP3] &= ~0x04;
167 regs[R_EP3] |= 0x04; 180 else
168 ret = tda18271_write_regs(fe, R_EP3, 1); 181 regs[R_EP3] |= 0x04;
182 ret = tda18271_write_regs(fe, R_EP3, 1);
183 }
169fail: 184fail:
170 return ret; 185 return ret;
171} 186}
@@ -507,7 +522,7 @@ static int tda18271_powerscan_init(struct dvb_frontend *fe)
507 /* set cal mode to normal */ 522 /* set cal mode to normal */
508 regs[R_EP4] &= ~0x03; 523 regs[R_EP4] &= ~0x03;
509 524
510 /* update IF output level & IF notch frequency */ 525 /* update IF output level */
511 regs[R_EP4] &= ~0x1c; /* clear if level bits */ 526 regs[R_EP4] &= ~0x1c; /* clear if level bits */
512 527
513 ret = tda18271_write_regs(fe, R_EP3, 2); 528 ret = tda18271_write_regs(fe, R_EP3, 2);
diff --git a/drivers/media/common/tuners/xc5000.c b/drivers/media/common/tuners/xc5000.c
index ceae6db901ec..7cf4f5bdb2ec 100644
--- a/drivers/media/common/tuners/xc5000.c
+++ b/drivers/media/common/tuners/xc5000.c
@@ -177,6 +177,7 @@ static XC_TV_STANDARD XC5000_Standard[MAX_TV_STANDARD] = {
177 {"FM Radio-INPUT1", 0x0208, 0x9002} 177 {"FM Radio-INPUT1", 0x0208, 0x9002}
178}; 178};
179 179
180static int xc5000_is_firmware_loaded(struct dvb_frontend *fe);
180static int xc5000_writeregs(struct xc5000_priv *priv, u8 *buf, u8 len); 181static int xc5000_writeregs(struct xc5000_priv *priv, u8 *buf, u8 len);
181static int xc5000_readregs(struct xc5000_priv *priv, u8 *buf, u8 len); 182static int xc5000_readregs(struct xc5000_priv *priv, u8 *buf, u8 len);
182static void xc5000_TunerReset(struct dvb_frontend *fe); 183static void xc5000_TunerReset(struct dvb_frontend *fe);
@@ -352,7 +353,7 @@ static int xc_SetTVStandard(struct xc5000_priv *priv,
352 353
353static int xc_shutdown(struct xc5000_priv *priv) 354static int xc_shutdown(struct xc5000_priv *priv)
354{ 355{
355 return 0; 356 return XC_RESULT_SUCCESS;
356 /* Fixme: cannot bring tuner back alive once shutdown 357 /* Fixme: cannot bring tuner back alive once shutdown
357 * without reloading the driver modules. 358 * without reloading the driver modules.
358 * return xc_write_reg(priv, XREG_POWER_DOWN, 0); 359 * return xc_write_reg(priv, XREG_POWER_DOWN, 0);
@@ -685,6 +686,25 @@ static int xc5000_set_params(struct dvb_frontend *fe,
685 return 0; 686 return 0;
686} 687}
687 688
689static int xc5000_is_firmware_loaded(struct dvb_frontend *fe)
690{
691 struct xc5000_priv *priv = fe->tuner_priv;
692 int ret;
693 u16 id;
694
695 ret = xc5000_readreg(priv, XREG_PRODUCT_ID, &id);
696 if (ret == XC_RESULT_SUCCESS) {
697 if (id == XC_PRODUCT_ID_FW_NOT_LOADED)
698 ret = XC_RESULT_RESET_FAILURE;
699 else
700 ret = XC_RESULT_SUCCESS;
701 }
702
703 dprintk(1, "%s() returns %s id = 0x%x\n", __func__,
704 ret == XC_RESULT_SUCCESS ? "True" : "False", id);
705 return ret;
706}
707
688static int xc_load_fw_and_init_tuner(struct dvb_frontend *fe); 708static int xc_load_fw_and_init_tuner(struct dvb_frontend *fe);
689 709
690static int xc5000_set_analog_params(struct dvb_frontend *fe, 710static int xc5000_set_analog_params(struct dvb_frontend *fe,
@@ -693,7 +713,7 @@ static int xc5000_set_analog_params(struct dvb_frontend *fe,
693 struct xc5000_priv *priv = fe->tuner_priv; 713 struct xc5000_priv *priv = fe->tuner_priv;
694 int ret; 714 int ret;
695 715
696 if(priv->fwloaded == 0) 716 if (xc5000_is_firmware_loaded(fe) != XC_RESULT_SUCCESS)
697 xc_load_fw_and_init_tuner(fe); 717 xc_load_fw_and_init_tuner(fe);
698 718
699 dprintk(1, "%s() frequency=%d (in units of 62.5khz)\n", 719 dprintk(1, "%s() frequency=%d (in units of 62.5khz)\n",
@@ -808,11 +828,10 @@ static int xc_load_fw_and_init_tuner(struct dvb_frontend *fe)
808 struct xc5000_priv *priv = fe->tuner_priv; 828 struct xc5000_priv *priv = fe->tuner_priv;
809 int ret = 0; 829 int ret = 0;
810 830
811 if (priv->fwloaded == 0) { 831 if (xc5000_is_firmware_loaded(fe) != XC_RESULT_SUCCESS) {
812 ret = xc5000_fwupload(fe); 832 ret = xc5000_fwupload(fe);
813 if (ret != XC_RESULT_SUCCESS) 833 if (ret != XC_RESULT_SUCCESS)
814 return ret; 834 return ret;
815 priv->fwloaded = 1;
816 } 835 }
817 836
818 /* Start the tuner self-calibration process */ 837 /* Start the tuner self-calibration process */
@@ -852,7 +871,6 @@ static int xc5000_sleep(struct dvb_frontend *fe)
852 return -EREMOTEIO; 871 return -EREMOTEIO;
853 } 872 }
854 else { 873 else {
855 /* priv->fwloaded = 0; */
856 return XC_RESULT_SUCCESS; 874 return XC_RESULT_SUCCESS;
857 } 875 }
858} 876}
@@ -933,7 +951,6 @@ struct dvb_frontend *xc5000_attach(struct dvb_frontend *fe,
933 cfg->i2c_address); 951 cfg->i2c_address);
934 printk(KERN_INFO 952 printk(KERN_INFO
935 "xc5000: Firmware has been loaded previously\n"); 953 "xc5000: Firmware has been loaded previously\n");
936 priv->fwloaded = 1;
937 break; 954 break;
938 case XC_PRODUCT_ID_FW_NOT_LOADED: 955 case XC_PRODUCT_ID_FW_NOT_LOADED:
939 printk(KERN_INFO 956 printk(KERN_INFO
@@ -941,7 +958,6 @@ struct dvb_frontend *xc5000_attach(struct dvb_frontend *fe,
941 cfg->i2c_address); 958 cfg->i2c_address);
942 printk(KERN_INFO 959 printk(KERN_INFO
943 "xc5000: Firmware has not been loaded previously\n"); 960 "xc5000: Firmware has not been loaded previously\n");
944 priv->fwloaded = 0;
945 break; 961 break;
946 default: 962 default:
947 printk(KERN_ERR 963 printk(KERN_ERR
diff --git a/drivers/media/common/tuners/xc5000_priv.h b/drivers/media/common/tuners/xc5000_priv.h
index ecebfe4745ad..a72a9887fe7f 100644
--- a/drivers/media/common/tuners/xc5000_priv.h
+++ b/drivers/media/common/tuners/xc5000_priv.h
@@ -30,7 +30,6 @@ struct xc5000_priv {
30 u32 bandwidth; 30 u32 bandwidth;
31 u8 video_standard; 31 u8 video_standard;
32 u8 rf_mode; 32 u8 rf_mode;
33 u8 fwloaded;
34 33
35 void *devptr; 34 void *devptr;
36}; 35};