summaryrefslogtreecommitdiff
path: root/linux/drivers/media/video/tea5767.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <devnull@localhost>2005-07-26 10:37:41 +0000
committerMauro Carvalho Chehab <devnull@localhost>2005-07-26 10:37:41 +0000
commitd57f358bcb3c68408bf1df0e373a07552d47004c (patch)
tree9950b5ae5768fe6ff3efdde021876f8c89cff34c /linux/drivers/media/video/tea5767.c
parent25d2ce93706b068d51417fbada61b34133795388 (diff)
downloadmediapointer-dvb-s2-d57f358bcb3c68408bf1df0e373a07552d47004c.tar.gz
mediapointer-dvb-s2-d57f358bcb3c68408bf1df0e373a07552d47004c.tar.bz2
- tea5767_autodetection improved. It requires more testing.
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.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/linux/drivers/media/video/tea5767.c b/linux/drivers/media/video/tea5767.c
index b84a89536..325f6f273 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.22 2005/07/15 21:44:14 mchehab Exp $
+ * $Id: tea5767.c,v 1.23 2005/07/26 10:37:41 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
@@ -294,7 +294,7 @@ static int tea5767_stereo(struct i2c_client *c)
int tea5767_autodetection(struct i2c_client *c)
{
unsigned char buffer[5] = { 0xff, 0xff, 0xff, 0xff, 0xff };
- int rc;
+ int rc,div;
struct tuner *t = i2c_get_clientdata(c);
if (5 != (rc = i2c_master_recv(c, buffer, 5))) {
@@ -319,6 +319,33 @@ int tea5767_autodetection(struct i2c_client *c)
return EINVAL;
}
+ /* Sets tuner at some freq (87.5 MHz) and see if it is ok */
+ div = ((87500 * 4000 + 700000 + 225000) + 16768) >> 15;
+ buffer[0] = ((div >> 8) & 0x3f) | TEA5767_MUTE;
+ buffer[1] = div & 0xff;
+ buffer[2] = TEA5767_PORT1_HIGH;
+ buffer[3] = TEA5767_PORT2_HIGH | TEA5767_HIGH_CUT_CTRL |
+ TEA5767_ST_NOISE_CTL;
+ buffer[4] = 0;
+
+ if (5 != (rc = i2c_master_send(c, buffer, 5)))
+ tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc);
+
+ msleep(10);
+
+ if (5 != (rc = i2c_master_recv(c, buffer, 5))) {
+ tuner_warn("It is not a TEA5767. Received %i bytes.\n", rc);
+ return EINVAL;
+ }
+
+ /* Initial freq for 32.768KHz clock */
+ if ((buffer[1] != (div & 0xff) ) || ((buffer[0] & 0x3f) != ((div >> 8) & 0x3f))) {
+ tuner_warn("It is not a TEA5767. div=%d, Return: %02x %02x %02x %02x %02x\n",
+ div,buffer[0],buffer[1],buffer[2],buffer[3],buffer[4]);
+ tea5767_status_dump(buffer);
+ return EINVAL;
+ }
+
tuner_warn("TEA5767 detected.\n");
return 0;
}