summaryrefslogtreecommitdiff
path: root/linux/drivers/media/video/tea5767.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <devnull@localhost>2005-06-15 02:43:03 +0000
committerMauro Carvalho Chehab <devnull@localhost>2005-06-15 02:43:03 +0000
commit9ca80dc4f0206c43b06abe9a42637b5e634874f5 (patch)
treeba69f6cb6f081879e03fe48af2b621026df2f953 /linux/drivers/media/video/tea5767.c
parent91d384425a9324c328c5f2c3e648d40ddfc76c19 (diff)
downloadmediapointer-dvb-s2-9ca80dc4f0206c43b06abe9a42637b5e634874f5.tar.gz
mediapointer-dvb-s2-9ca80dc4f0206c43b06abe9a42637b5e634874f5.tar.bz2
I2C API has changed on 2.6.12-rc6-mm1: I2C_CLIENT_INSMOD macro now doesn't
require nor uses normal_i2c_range. A new define (CONFIG_USE_I2C_RANGE) is provided to provide compatibility. It is meant to be replaced by a kernel version test after aplyed to mainstream. This patch corrects it. High precision tunning on Radio is correclty supported. Some radio apps already uses it. There's an auto-detection process to check tuner range. Detailed info: * Make.config, Makefile, tuner-core.c: - CONFIG_TUNER_MULTI_I2C dropped from tuner-core.c and included on Make.config - included CONFIG_USE_I2C_RANGE for kernels that requires normal_i2c_range struct (only kernels after 2.6.12-rc6-mm1 doesn't require). * bt832.c, msp3400.c, saa6752hs.c, tda7432.c, tda9875.c, tda9887.c, tuner-core.c,tvaudio.c, tveeprom.c, - I2C range detection corrected to new behavior of 2.6.12-rc6-mm1 * cx88-video.c, tea5767, tuner-core.c: - V4L2_TUNER_CAP_LOW implemented according with V4L2 API for Radio. - tea5767 debug improved. * .bp/2.6/v4l-driver-doc - typo corrected. Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br>
Diffstat (limited to 'linux/drivers/media/video/tea5767.c')
-rw-r--r--linux/drivers/media/video/tea5767.c46
1 files changed, 36 insertions, 10 deletions
diff --git a/linux/drivers/media/video/tea5767.c b/linux/drivers/media/video/tea5767.c
index 153e4aa90..ed7b56944 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.6 2005/06/10 10:57:18 mchehab Exp $
+ * $Id: tea5767.c,v 1.7 2005/06/15 02:43:03 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
@@ -134,13 +134,14 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq)
/* 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 };
+/* 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 */
+/* Freq should be specifyed at 62.5 Hz */
static void set_radio_freq(struct i2c_client *c, unsigned int frq)
{
struct tuner *t = i2c_get_clientdata(c);
@@ -151,8 +152,8 @@ static void set_radio_freq(struct i2c_client *c, unsigned int frq)
printk(PREFIX "radio freq counter %d\n",frq);
- /* Rounds freq to next decimal value */
- frq = 20*(frq/16)+radio_frq[frq%16];
+ /* Rounds freq to next decimal value - for 62.5 KHz step */
+ /* 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 | TEA5767_JAPAN_BAND;
@@ -163,19 +164,22 @@ static void set_radio_freq(struct i2c_client *c, unsigned int frq)
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/20+225+25)/50;
+/* div = (frq*4000/20+225+25)/50; */
+ div = (frq*4/16+700+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/20-225+25)/50;
+/* div = (frq*4000/20-225+25)/50; */
+ div = (frq*4/16-700-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;
/* const 700=4000*175 Khz - to adjust freq to right value */
- div = (1000*(frq*4000/20-700-225)+16384)>>15;
+ div = (1000*(frq*4/16-700-225)+16384)>>15;
+/* div = (1000*(frq*4000/20-700-225)+16384)>>15; */
break;
case TEA5767_HIGH_LO_32768:
default:
@@ -183,7 +187,8 @@ 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/20+700+225)+16384)/32768;
+/* div = (1000*(frq*4000/20+700+225)+16384)/32768; */
+ div = (1000*(frq*4/16+700+225)+16384)>>15;
break;
}
buffer[0] = (div>>8) & 0x3f;
@@ -198,7 +203,7 @@ static void set_radio_freq(struct i2c_client *c, unsigned int frq)
static void tea5767_status_dump(unsigned char *buffer)
{
- unsigned int div;
+ unsigned int div, frq;
if (TEA5767_READY_FLAG_MASK & buffer[0])
printk(PREFIX "Ready Flag ON\n");
@@ -211,8 +216,29 @@ static void tea5767_status_dump(unsigned char *buffer)
printk(PREFIX "Tuner not at band limit\n");
div=((buffer[0]&0x3f)<<8) | buffer[1];
+
+ switch (TEA5767_HIGH_LO_32768) {
+ case TEA5767_HIGH_LO_13MHz:
+ frq = 1000*(div*50-700-225)/4; /* Freq in KHz */
+ break;
+ case TEA5767_LOW_LO_13MHz:
+ frq = 1000*(div*50+700+225)/4; /* Freq in KHz */
+ break;
+ case TEA5767_LOW_LO_32768:
+ frq = 1000*(div*32768/1000+700+225)/4; /* Freq in KHz */
+ break;
+ case TEA5767_HIGH_LO_32768:
+ default:
+// div = (1000*(frq*4/20+700+225)+16384)>>15;
+ frq = 1000*(div*32768/1000-700-225)/4; /* Freq in KHz */
+ break;
+ }
+ buffer[0] = (div>>8) & 0x3f;
+ buffer[1] = div & 0xff;
+
- printk(PREFIX "Frequency divider = 0x%4x\n",div);
+ printk(PREFIX "Frequency %d.%03d KHz (divider = 0x%04x)\n",
+ frq/1000,frq%1000,div);
if (TEA5767_STEREO_MASK & buffer[2])
printk(PREFIX "Stereo\n");