summaryrefslogtreecommitdiff
path: root/linux/drivers/media/video/tea5767.c
diff options
context:
space:
mode:
Diffstat (limited to 'linux/drivers/media/video/tea5767.c')
-rw-r--r--linux/drivers/media/video/tea5767.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/linux/drivers/media/video/tea5767.c b/linux/drivers/media/video/tea5767.c
index 7e68f1cd8..ae60613f9 100644
--- a/linux/drivers/media/video/tea5767.c
+++ b/linux/drivers/media/video/tea5767.c
@@ -2,7 +2,7 @@
* For Philips TEA5767 FM Chip used on some TV Cards like Prolink Pixelview
* I2C address is allways 0xC0.
*
- * $Id: tea5767.c,v 1.2 2005/06/06 04:54:42 mchehab Exp $
+ * $Id: tea5767.c,v 1.3 2005/06/07 02:45:36 mchehab Exp $
*
* Copyright (c) 2005 Mauro Carvalho Chehab (mchehab@brturbo.com.br)
* This code is placed under the terms of the GNU General Public License
@@ -135,6 +135,18 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq)
tuner_warn("This tuner doesn't support TV freq.\n");
}
+/* Closest value table */
+/* int radio_frq[16]={ 0, 1, 2, 4, 5, 6, 8, 9, 10, 11, 12, 14, 15, 16, 17, 18 }; */
+/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */
+
+/* radio adjust freq for odd channel frequencies used in US, Brazil, ... */
+int radio_frq[16]={ 0, 1, 2, 3, 5, 6, 7, 9, 10, 11, 13, 14, 15, 17, 18, 19 };
+/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */
+
+/* radio adjust freq for even channel frequencies */
+/* int radio_frq[16]={ 0, 1, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 15, 16, 17, 19 }; */
+/ * 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */
+
static void set_radio_freq(struct i2c_client *c, unsigned int frq)
{
struct tuner *t = i2c_get_clientdata(c);
@@ -142,29 +154,31 @@ static void set_radio_freq(struct i2c_client *c, unsigned int frq)
unsigned div;
int rc;
+ /* Rounds freq to next decimal value */
+ frq = 20*(frq/16)+radio_frq[frq%16];
+
buffer[2] = TEA5767_PORT1_HIGH;
buffer[3] = TEA5767_PORT2_HIGH | TEA5767_HIGH_CUT_CTRL | TEA5767_ST_NOISE_CTL;
buffer[4]=0;
switch (t->type) {
-
case TEA5767_HIGH_LO_13MHz:
tuner_dbg("TEA5767 radio HIGH LO inject xtal @ 13 MHz\n");
buffer[2] |= TEA5767_HIGH_LO_INJECT;
buffer[4] |= TEA5767_PLLREF_ENABLE;
- div = (frq*4000/16+225+25)/50;
+ div = (frq*4000/20+225+25)/50;
break;
case TEA5767_LOW_LO_13MHz:
tuner_dbg("TEA5767 radio LOW LO inject xtal @ 13 MHz\n");
buffer[4] |= TEA5767_PLLREF_ENABLE;
- div = (frq*4000/16-225+25)/50;
+ div = (frq*4000/20-225+25)/50;
break;
case TEA5767_LOW_LO_32768:
tuner_dbg("TEA5767 radio LOW LO inject xtal @ 32,768 MHz\n");
-
buffer[3] |= TEA5767_XTAL_32768;
- div = (1000*(frq*4000/16+225)+16384)/32768;
+ /* const 700=4000*175 Khz - to adjust freq to right value */
+ div = (1000*(frq*4000/20-700-225)+16384)>>15;
break;
case TEA5767_HIGH_LO_32768:
default:
@@ -172,7 +186,7 @@ static void set_radio_freq(struct i2c_client *c, unsigned int frq)
buffer[2] |= TEA5767_HIGH_LO_INJECT;
buffer[3] |= TEA5767_XTAL_32768;
- div = (1000*(frq*4000/16+225)+16384)/32768;
+ div = (1000*(frq*4000/20+225)+16384)/32768;
break;
}
buffer[0] = (div>>8) & 0x3f;
@@ -265,8 +279,7 @@ int tea5767_tuner_init(struct i2c_client *c)
/***************************************************************************
HACKING FOR TESTING PURPOSES ONLY. Should have an option to configure
***************************************************************************/
- t->type= TEA5767_HIGH_LO_32768;
-// t->type= TEA5767_LOW_LO_32768;
+ t->type= TEA5767_LOW_LO_32768;
strlcpy(c->name, "TEA5767", sizeof("TEA5767"));
tuner_info("type set to TEA5797\n");