summaryrefslogtreecommitdiff
path: root/linux/drivers
diff options
context:
space:
mode:
authorAndrew de Quincy <devnull@localhost>2004-09-06 17:00:21 +0000
committerAndrew de Quincy <devnull@localhost>2004-09-06 17:00:21 +0000
commit54aae56f70a8f5e0b61971a8dc96621fef7cfb46 (patch)
treea0b0db637725baaa994ee7ba5119060a8829d96a /linux/drivers
parent98db159990c918475140f1eff1451c2ea7012d3c (diff)
downloadmediapointer-dvb-s2-54aae56f70a8f5e0b61971a8dc96621fef7cfb46.tar.gz
mediapointer-dvb-s2-54aae56f70a8f5e0b61971a8dc96621fef7cfb46.tar.bz2
Support for Thomson DTT7579 tuner.
Diffstat (limited to 'linux/drivers')
-rw-r--r--linux/drivers/media/dvb/frontends/cx22702.c95
1 files changed, 85 insertions, 10 deletions
diff --git a/linux/drivers/media/dvb/frontends/cx22702.c b/linux/drivers/media/dvb/frontends/cx22702.c
index b27722a0c..53555ad44 100644
--- a/linux/drivers/media/dvb/frontends/cx22702.c
+++ b/linux/drivers/media/dvb/frontends/cx22702.c
@@ -1,4 +1,4 @@
-/*
+/*
Conexant 22702 DVB OFDM frontend driver
based on:
@@ -40,12 +40,16 @@
#define I2C_EEPROM_SLAVE_ADDR 0x50
#define I2C_PLL_SLAVE_ADDR 0x61
+#define PLLTYPE_DTT7592 1
+#define PLLTYPE_DTT7595 2
+#define PLLTYPE_DTT7579 3
+
static int debug = 0;
#define dprintk if (debug) printk
static struct dvb_frontend_info cx22702_info = {
- .name = "CX22702 Demod Thompson 759x PLL",
+ .name = "CX22702 Demod Thompson 759x/7579 PLL",
.type = FE_OFDM,
.frequency_min = 177000000,
.frequency_max = 858000000,
@@ -60,6 +64,7 @@ struct cx22702_state {
struct i2c_adapter *i2c;
struct dvb_adapter *dvb;
struct dvb_frontend_info cx22702_info;
+ char pll_type;
};
/* Register values to initialise the demod */
@@ -146,7 +151,7 @@ static int pll_write (struct i2c_adapter *i2c, u8 data [4])
return (ret != 1) ? -1 : 0;
}
-static int pll_set_tv_freq (struct i2c_adapter *i2c, u32 freq)
+static int pll_dtt759x_set_tv_freq (struct i2c_adapter *i2c, u32 freq)
{
int ret;
@@ -216,6 +221,56 @@ static int pll_set_tv_freq (struct i2c_adapter *i2c, u32 freq)
}
+static int pll_dtt7579_set_tv_freq (struct i2c_adapter *i2c, u32 freq)
+{
+ int ret;
+
+ u32 div = (freq + 36166667) / 166666;
+
+ /* dividerhigh, divierlow */
+ unsigned char buf [4] = {
+ div >> 8,
+ div & 0xff,
+ 0x00,
+ 0x00
+ };
+
+ // Now compensate for the charge pump osc
+ if(freq <= 506000000) {
+ buf[2] = 0xb4;
+ buf[3] = 0x02;
+ } else if (freq <= 735000000) {
+ buf[2] = 0xbc;
+ buf[3] = 0x08;
+ } else if (freq <= 835000000) {
+ buf[2] = 0xf4;
+ buf[3] = 0x08;
+ } else if (freq <= 896000000) {
+ buf[2] = 0xfc;
+ buf[3] = 0x08;
+ }
+
+ dprintk ("%s: freq == %i, div == 0x%04x\n", __FUNCTION__, (int) freq, (int) div);
+
+ ret= pll_write (i2c, buf);
+ if(ret<0) {
+ dprintk ("%s: first pll_write failed\n",__FUNCTION__);
+ return ret;
+ }
+
+ /* Set the AGC to search */
+ buf[2]=(buf[2] & 0xdc) | 0x9c;
+ buf[3]=0xa0;
+ ret=pll_write (i2c, buf);
+ if(ret<0) {
+ dprintk ("%s: second pll_write failed\n",__FUNCTION__);
+ return ret;
+ }
+
+ return ret;
+
+}
+
/* Reset the demod hardware and reset all of the configuration registers
to a default state. */
static int cx22702_init (struct i2c_adapter *i2c)
@@ -519,7 +574,16 @@ static int cx22702_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
/* Disable aquisition */
cx22702_writereg (i2c, 0x00, 0x00);
- pll_set_tv_freq (i2c, p->frequency);
+ switch(state->pll_type) {
+ case PLLTYPE_DTT7592:
+ case PLLTYPE_DTT7595:
+ pll_dtt759x_set_tv_freq (i2c, p->frequency);
+ break;
+
+ case PLLTYPE_DTT7579:
+ pll_dtt7579_set_tv_freq (i2c, p->frequency);
+ break;
+ }
cx22702_set_inversion (i2c, p->inversion);
if((ret=cx22702_set_tps (i2c, &p->u.ofdm))<0) {
dprintk ("%s: set_tps failed ret=%d\n",__FUNCTION__,ret);
@@ -552,7 +616,7 @@ static int cx22702_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
/* Validate the eeprom contents, make sure content look ok.
Get the eeprom data. */
-static int cx22702_validate_eeprom(struct i2c_adapter *i2c, int* minfreq)
+static int cx22702_validate_eeprom(struct i2c_adapter *i2c, int* minfreq, int* pll_type)
{
u8 b0 [] = { 0 };
u8 b1 [128];
@@ -607,10 +671,12 @@ static int cx22702_validate_eeprom(struct i2c_adapter *i2c, int* minfreq)
case 0x4B:
dprintk ("%s: Tuner Thompson DTT 7595\n",__FUNCTION__);
*minfreq = 177000000;
+ *pll_type = PLLTYPE_DTT7595;
break;
case 0x4C:
dprintk ("%s: Tuner Thompson DTT 7592\n",__FUNCTION__);
*minfreq = 474000000;
+ *pll_type = PLLTYPE_DTT7592;
break;
default:
printk ("%s: Unknown tuner 0x%02x not supported\n",__FUNCTION__,tuner);
@@ -666,13 +732,21 @@ static int cx22702_attach_adapter(struct i2c_adapter *adapter)
struct i2c_client *client;
int ret;
int minfreq;
+ int pll_type;
dprintk("Trying to attach to adapter 0x%x:%s.\n",
adapter->id, adapter->name);
- ret=cx22702_validate_eeprom(adapter, &minfreq);
- if(ret < 0)
- return ret;
+ if (!strcmp(adapter->name, "Conexant DVB-t")) {
+ printk("cx22702: Detected Conexant DVB-t card - PLL Thomson DTT7579\n");
+ pll_type = PLLTYPE_DTT7579;
+ minfreq = 474000000; // guess
+ } else {
+ // FIXME
+ ret=cx22702_validate_eeprom(adapter, &minfreq, &pll_type);
+ if(ret < 0)
+ return ret;
+ }
ret=cx22702_validate_demod(adapter);
if(ret < 0)
@@ -689,7 +763,8 @@ static int cx22702_attach_adapter(struct i2c_adapter *adapter)
state->i2c = adapter;
memcpy(&state->cx22702_info, &cx22702_info, sizeof(struct dvb_frontend_info));
state->cx22702_info.frequency_min = minfreq;
-
+ state->pll_type = pll_type;
+
if ( !(client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL)) ) {
kfree(state);
return -ENOMEM;
@@ -780,7 +855,7 @@ module_exit (exit_cx22702);
MODULE_PARM(debug,"i");
MODULE_PARM_DESC(debug, "Enable verbose debug messages");
-MODULE_DESCRIPTION("CX22702 / Thompson DTT 759x PLL DVB Frontend driver");
+MODULE_DESCRIPTION("CX22702 / Thompson DTT 759x / Thompson DTT 7579 PLL DVB Frontend driver");
MODULE_AUTHOR("Steven Toth");
MODULE_LICENSE("GPL");