summaryrefslogtreecommitdiff
path: root/linux/drivers/media/video/tda8290.c
diff options
context:
space:
mode:
authorGerd Knorr <devnull@localhost>2005-02-09 19:27:21 +0000
committerGerd Knorr <devnull@localhost>2005-02-09 19:27:21 +0000
commita57f1dd6d13a9b061984fe1621703da7ae99090d (patch)
tree2599ac5eb9411b6573213c22407fcf583ac4f769 /linux/drivers/media/video/tda8290.c
parentd88c7c9e5a9181439bd0facde6802a881acd5442 (diff)
downloadmediapointer-dvb-s2-a57f1dd6d13a9b061984fe1621703da7ae99090d.tar.gz
mediapointer-dvb-s2-a57f1dd6d13a9b061984fe1621703da7ae99090d.tar.bz2
- make the new splitted tuner module build.
Diffstat (limited to 'linux/drivers/media/video/tda8290.c')
-rw-r--r--linux/drivers/media/video/tda8290.c164
1 files changed, 63 insertions, 101 deletions
diff --git a/linux/drivers/media/video/tda8290.c b/linux/drivers/media/video/tda8290.c
index 898ac62e5..6c54d9e82 100644
--- a/linux/drivers/media/video/tda8290.c
+++ b/linux/drivers/media/video/tda8290.c
@@ -1,5 +1,8 @@
/*
- * $Id: tda8290.c,v 1.1 2005/02/09 15:42:46 kraxel Exp $
+ * $Id: tda8290.c,v 1.2 2005/02/09 19:27:21 kraxel Exp $
+ *
+ * i2c tv tuner chip device driver
+ * controls the philips tda8290+75 tuner chip combo.
*/
#include <linux/i2c.h>
#include <linux/videodev.h>
@@ -8,9 +11,12 @@
/* ---------------------------------------------------------------------- */
+#define I2C_ADDR_TDA8290 0x4b
+#define I2C_ADDR_TDA8275 0x61
+
struct freq_entry {
- __u16 freq;
- __u8 value;
+ u16 freq;
+ u8 value;
};
static struct freq_entry band_table[] = {
@@ -71,12 +77,9 @@ static unsigned char i2c_init_tda8275[14] = { 0x00, 0x00, 0x00, 0x00,
0x00, 0x40 };
static unsigned char i2c_set_VS[2] = { 0x30, 0x6F };
static unsigned char i2c_set_GP01_CF[2] = { 0x20, 0x0B };
-static unsigned char i2c_easy_mode[2] = { 0x01, 0x02 };
static unsigned char i2c_tda8290_reset[2] = { 0x00, 0x00 };
static unsigned char i2c_gainset_off[2] = { 0x28, 0x14 };
static unsigned char i2c_gainset_on[2] = { 0x28, 0x54 };
-static unsigned char i2c_set_freq[8] = { 0x00, 0x00, 0x00, 0x40,
- 0x52, 0x00, 0x00, 0x8F };
static unsigned char i2c_agc3_00[2] = { 0x80, 0x00 };
static unsigned char i2c_agc2_BF[2] = { 0x60, 0xBF };
static unsigned char i2c_cb1_D2[2] = { 0x30, 0xD2 };
@@ -94,14 +97,14 @@ static struct i2c_msg i2c_msg_init[] = {
};
static struct i2c_msg i2c_msg_prolog[] = {
- { I2C_ADDR_TDA8290, 0, ARRAY_SIZE(i2c_easy_mode), i2c_easy_mode },
+// { I2C_ADDR_TDA8290, 0, ARRAY_SIZE(i2c_easy_mode), i2c_easy_mode },
{ I2C_ADDR_TDA8290, 0, ARRAY_SIZE(i2c_gainset_off), i2c_gainset_off },
{ I2C_ADDR_TDA8290, 0, ARRAY_SIZE(i2c_tda8290_reset), i2c_tda8290_reset },
{ I2C_ADDR_TDA8290, 0, ARRAY_SIZE(i2c_enable_bridge), i2c_enable_bridge },
};
static struct i2c_msg i2c_msg_config[] = {
- { I2C_ADDR_TDA8275, 0, ARRAY_SIZE(i2c_set_freq), i2c_set_freq },
+// { I2C_ADDR_TDA8275, 0, ARRAY_SIZE(i2c_set_freq), i2c_set_freq },
{ I2C_ADDR_TDA8275, 0, ARRAY_SIZE(i2c_agc3_00), i2c_agc3_00 },
{ I2C_ADDR_TDA8275, 0, ARRAY_SIZE(i2c_agc2_BF), i2c_agc2_BF },
{ I2C_ADDR_TDA8275, 0, ARRAY_SIZE(i2c_cb1_D2), i2c_cb1_D2 },
@@ -117,26 +120,38 @@ static struct i2c_msg i2c_msg_epilog[] = {
{ I2C_ADDR_TDA8290, 0, ARRAY_SIZE(i2c_gainset_on), i2c_gainset_on },
};
-static int tda8290_tune(void)
+static int tda8290_tune(struct i2c_client *c)
{
- i2c_transfer(tda8290_client_template.adapter, i2c_msg_prolog, ARRAY_SIZE(i2c_msg_prolog));
- i2c_transfer(tda8290_client_template.adapter, i2c_msg_config, ARRAY_SIZE(i2c_msg_config));
- msleep(550);
- i2c_transfer(tda8290_client_template.adapter, i2c_msg_epilog, ARRAY_SIZE(i2c_msg_epilog));
+ struct tuner *t = i2c_get_clientdata(c);
+ struct i2c_msg easy_mode =
+ { I2C_ADDR_TDA8290, 0, 2, t->i2c_easy_mode };
+ struct i2c_msg set_freq =
+ { I2C_ADDR_TDA8290, 0, 8, t->i2c_set_freq };
+
+ i2c_transfer(c->adapter, &easy_mode, 1);
+ i2c_transfer(c->adapter, i2c_msg_prolog, ARRAY_SIZE(i2c_msg_prolog));
+
+ i2c_transfer(c->adapter, &set_freq, 1);
+ i2c_transfer(c->adapter, i2c_msg_config, ARRAY_SIZE(i2c_msg_config));
+ msleep(550);
+ i2c_transfer(c->adapter, i2c_msg_epilog, ARRAY_SIZE(i2c_msg_epilog));
return 0;
}
-static void set_frequency(struct tuner *t, u32 frequency, u16 ifc)
+static void set_frequency(struct tuner *t, u16 ifc)
{
- u32 N = (((frequency<<3)+ifc)&0x3fffc);
-
- N = N >> get_freq_entry(div_table, frequency);
-
- i2c_set_freq[1] = (unsigned char)(N>>8);
- i2c_set_freq[2] = (unsigned char) N;
- i2c_set_freq[5] = get_freq_entry(band_table, frequency);
- i2c_set_freq[6] = get_freq_entry(agc_table, frequency);
+ u32 N = (((t->freq<<3)+ifc)&0x3fffc);
+
+ N = N >> get_freq_entry(div_table, t->freq);
+ t->i2c_set_freq[0] = 0;
+ t->i2c_set_freq[1] = (unsigned char)(N>>8);
+ t->i2c_set_freq[2] = (unsigned char) N;
+ t->i2c_set_freq[0] = 0x40;
+ t->i2c_set_freq[0] = 0x52;
+ t->i2c_set_freq[5] = get_freq_entry(band_table, t->freq);
+ t->i2c_set_freq[6] = get_freq_entry(agc_table, t->freq);
+ t->i2c_set_freq[0] = 0x8f;
}
#define V4L2_STD_MN (V4L2_STD_PAL_M|V4L2_STD_PAL_N|V4L2_STD_PAL_Nc|V4L2_STD_NTSC)
@@ -146,18 +161,20 @@ static void set_frequency(struct tuner *t, u32 frequency, u16 ifc)
static void set_audio(struct tuner *t)
{
+ t->i2c_easy_mode[0] = 0x01;
+
if (t->std & V4L2_STD_MN)
- i2c_easy_mode[1] = 0x01;
+ t->i2c_easy_mode[1] = 0x01;
else if (t->std & V4L2_STD_B)
- i2c_easy_mode[1] = 0x02;
+ t->i2c_easy_mode[1] = 0x02;
else if (t->std & V4L2_STD_GH)
- i2c_easy_mode[1] = 0x04;
+ t->i2c_easy_mode[1] = 0x04;
else if (t->std & V4L2_STD_PAL_I)
- i2c_easy_mode[1] = 0x08;
+ t->i2c_easy_mode[1] = 0x08;
else if (t->std & V4L2_STD_DK)
- i2c_easy_mode[1] = 0x10;
+ t->i2c_easy_mode[1] = 0x10;
else if (t->std & V4L2_STD_SECAM_L)
- i2c_easy_mode[1] = 0x20;
+ t->i2c_easy_mode[1] = 0x20;
}
static void set_tv_freq(struct i2c_client *c, unsigned int freq)
@@ -165,18 +182,28 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq)
struct tuner *t = i2c_get_clientdata(c);
set_audio(t);
- set_frequency(t, f->frequency, 864);
- tda8290_tune();
+ set_frequency(t, 864);
+ tda8290_tune(c);
}
static void set_radio_freq(struct i2c_client *c, unsigned int freq)
{
struct tuner *t = i2c_get_clientdata(c);
- set_frequency(t, f->frequency, 704);
- tda8290_tune();
+ set_frequency(t, 704);
+ tda8290_tune(c);
}
-int default_tuner_init(struct i2c_client *c)
+static int has_signal(struct i2c_client *c)
+{
+ unsigned char i2c_get_afc[1] = { 0x1B };
+ unsigned char afc = 0;
+
+ i2c_master_send(c, i2c_get_afc, ARRAY_SIZE(i2c_get_afc));
+ i2c_master_recv(c, &afc, 1);
+ return (afc & 0x80)? 65535:0;
+}
+
+int tda8290_init(struct i2c_client *c)
{
struct tuner *t = i2c_get_clientdata(c);
@@ -184,77 +211,13 @@ int default_tuner_init(struct i2c_client *c)
printk("tuner: type set to %s\n", c->name);
t->tv_freq = set_tv_freq;
t->radio_freq = set_radio_freq;
- return 0;
-}
-
-/* ----------------------------------------------------------------------- */
-
-#if 0
-
-static int tda8290_command(struct i2c_client *client, unsigned int cmd, void *arg)
-{
- if( client->addr == I2C_ADDR_TDA8275)
- return 0;
-
- switch (cmd) {
- /* --- v4l ioctls --- */
- case VIDIOC_G_TUNER:
- {
- struct v4l2_tuner* t = arg;
-
- if (t->type == V4L2_TUNER_ANALOG_TV)
- {
- unsigned char afc = 0;
- unsigned char i2c_get_afc[1] = { 0x1B };
-
- i2c_master_send(&tda8290_client_template, i2c_get_afc, ARRAY_SIZE(i2c_get_afc));
- i2c_master_recv(&tda8290_client_template, &afc, 1);
-
- t->signal = (afc & 0x80)? 65535:0;
- t->afc = -((((char)(afc<<1))*3375)>>9);
- }
- return 0;
- }
- }
-
- return -EINVAL;
-}
-
-static int tda8290_attach(struct i2c_adapter *adap, int addr, int kind)
-{
- printk("%s: chip found @ 0x%x\n", __FUNCTION__, addr);
-
- switch(addr)
- {
- case I2C_ADDR_TDA8290:
- {
- tda8290_client_template.adapter = adap;
- tda8290_client_template.addr = addr;
-
- i2c_attach_client(&tda8290_client_template);
-
- i2c_master_send(&tda8290_client_template, i2c_enable_bridge, ARRAY_SIZE(i2c_enable_bridge));
- } break;
-
- case I2C_ADDR_TDA8275:
- {
- tda8275_client_template.adapter = adap;
- tda8275_client_template.addr = addr;
-
- i2c_attach_client(&tda8275_client_template);
-
- i2c_transfer(tda8290_client_template.adapter, i2c_msg_init, ARRAY_SIZE(i2c_msg_init));
- } break;
-
- default:
- return -EINVAL;
- }
+ t->has_signal = has_signal;
+ i2c_master_send(c, i2c_enable_bridge, ARRAY_SIZE(i2c_enable_bridge));
+ i2c_transfer(c->adapter, i2c_msg_init, ARRAY_SIZE(i2c_msg_init));
return 0;
}
-#endif
-
/*
* Overrides for Emacs so that we follow Linus's tabbing style.
* ---------------------------------------------------------------------------
@@ -262,4 +225,3 @@ static int tda8290_attach(struct i2c_adapter *adap, int addr, int kind)
* c-basic-offset: 8
* End:
*/
-