summaryrefslogtreecommitdiff
path: root/linux/drivers/media/video/cx88
diff options
context:
space:
mode:
Diffstat (limited to 'linux/drivers/media/video/cx88')
-rw-r--r--linux/drivers/media/video/cx88/cx88-cards.c47
-rw-r--r--linux/drivers/media/video/cx88/cx88-dvb.c151
-rw-r--r--linux/drivers/media/video/cx88/cx88.h4
3 files changed, 56 insertions, 146 deletions
diff --git a/linux/drivers/media/video/cx88/cx88-cards.c b/linux/drivers/media/video/cx88/cx88-cards.c
index 3ad9c2c40..0f8463a7b 100644
--- a/linux/drivers/media/video/cx88/cx88-cards.c
+++ b/linux/drivers/media/video/cx88/cx88-cards.c
@@ -1,5 +1,5 @@
/*
- * $Id: cx88-cards.c,v 1.51 2004/11/30 17:00:13 kraxel Exp $
+ * $Id: cx88-cards.c,v 1.52 2004/12/09 12:51:35 kraxel Exp $
*
* device driver for Conexant 2388x based TV cards
* card-specific stuff.
@@ -32,7 +32,8 @@
#include "cx88.h"
#ifdef WITH_DVB
-#include "cx22702.h"
+# include "dvb-pll.h"
+# include "cx22702.h"
#endif
/* ------------------------------------------------------------------ */
@@ -700,7 +701,6 @@ static int hauppauge_eeprom_dvb(struct cx88_core *core, u8 *ee)
{
int model;
int tuner;
- char *tname;
/* Make sure we support the board model */
model = ee[0x1f] << 24 | ee[0x1e] << 16 | ee[0x1d] << 8 | ee[0x1c];
@@ -719,21 +719,18 @@ static int hauppauge_eeprom_dvb(struct cx88_core *core, u8 *ee)
/* Make sure we support the tuner */
tuner = ee[0x2d];
switch(tuner) {
- case 0x4B:
- tname = "Thomson DTT 7595";
- core->pll_type = PLLTYPE_DTT7595;
- break;
- case 0x4C:
- tname = "Thomson DTT 7592";
- core->pll_type = PLLTYPE_DTT7592;
+ case 0x4B: /* ddt 7595 */
+ case 0x4C: /* dtt 7592 */
+ core->pll_desc = &dvb_pll_thomson_dtt759x;
break;
default:
printk("%s: error: unknown hauppauge tuner 0x%02x\n",
core->name, tuner);
return -ENODEV;
}
- printk(KERN_INFO "%s: hauppauge eeprom: model=%d, tuner=%s (%d)\n",
- core->name, model, tname, tuner);
+ printk(KERN_INFO "%s: hauppauge eeprom: model=%d, tuner=%d (%s)\n",
+ core->name, model, tuner,
+ core->pll_desc ? core->pll_desc->name : "UNKNOWN");
core->pll_addr = 0x61;
core->demod_addr = 0x43;
@@ -869,13 +866,6 @@ void cx88_card_setup(struct cx88_core *core)
i2c_eeprom(&core->i2c_client,eeprom,sizeof(eeprom));
leadtek_eeprom(core,eeprom);
break;
- case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
- /* Tuner reset is hooked to the tuner out of reset */
- cx_set(MO_GP0_IO, 0x00000101);
- cx_clear(MO_GP0_IO, 0x00000001);
- msleep(1);
- cx_set(MO_GP0_IO, 0x00000101);
- break;
#ifdef WITH_DVB
case CX88_BOARD_HAUPPAUGE_DVB_T1:
if (0 == core->i2c_rc)
@@ -883,11 +873,23 @@ void cx88_card_setup(struct cx88_core *core)
hauppauge_eeprom_dvb(core,eeprom);
break;
case CX88_BOARD_CONEXANT_DVB_T1:
- core->pll_type = PLLTYPE_DTT7579;
+ core->pll_desc = &dvb_pll_thomson_dtt7579;
core->pll_addr = 0x60;
core->demod_addr = 0x43;
break;
-#endif
+ case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
+ /* Tuner reset is hooked to the tuner out of reset */
+ cx_set(MO_GP0_IO, 0x00000101);
+ cx_clear(MO_GP0_IO, 0x00000001);
+ msleep(1);
+ cx_set(MO_GP0_IO, 0x00000101);
+ core->pll_addr = 0x61;
+ core->pll_desc = &dvb_pll_lg_z201;
+ break;
+ case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
+ core->pll_addr = 0x60;
+ core->pll_desc = &dvb_pll_thomson_dtt7579;
+ break;
case CX88_BOARD_DNTV_LIVE_DVB_T:
cx_set(MO_GP0_IO, 0x00000707);
cx_set(MO_GP2_IO, 0x00000101);
@@ -895,7 +897,10 @@ void cx88_card_setup(struct cx88_core *core)
msleep(1);
cx_clear(MO_GP0_IO, 0x00000007);
cx_set(MO_GP2_IO, 0x00000101);
+ core->pll_addr = 0x61;
+ core->pll_desc = &dvb_pll_unknown_1;
break;
+#endif
}
if (cx88_boards[core->board].radio.type == CX88_RADIO)
core->has_radio = 1;
diff --git a/linux/drivers/media/video/cx88/cx88-dvb.c b/linux/drivers/media/video/cx88/cx88-dvb.c
index 25632897c..b467c9b75 100644
--- a/linux/drivers/media/video/cx88/cx88-dvb.c
+++ b/linux/drivers/media/video/cx88/cx88-dvb.c
@@ -1,5 +1,5 @@
/*
- * $Id: cx88-dvb.c,v 1.20 2004/11/30 17:00:13 kraxel Exp $
+ * $Id: cx88-dvb.c,v 1.21 2004/12/09 12:51:35 kraxel Exp $
*
* device driver for Conexant 2388x based TV cards
* MPEG Transport Stream (DVB) routines
@@ -31,6 +31,7 @@
#include <linux/suspend.h>
#include "cx88.h"
+#include "dvb-pll.h"
#include "cx22702.h"
#include "mt352.h"
#include "mt352_priv.h" /* FIXME */
@@ -110,74 +111,6 @@ static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe)
return 0;
}
-#define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */
-
-static int lg_z201_pll_set(struct dvb_frontend* fe,
- struct dvb_frontend_parameters* params, u8* pllbuf)
-{
- u32 div;
- unsigned char cp = 0;
- unsigned char bs = 0;
-
- div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
-
- if (params->frequency < 542000000) cp = 0xbc;
- else if (params->frequency < 830000000) cp = 0xf4;
- else cp = 0xfc;
-
- if (params->frequency == 0) bs = 0x03;
- else if (params->frequency < 157500000) bs = 0x01;
- else if (params->frequency < 443250000) bs = 0x02;
- else bs = 0x04;
-
- pllbuf[0] = 0xC2; /* Note: non-linux standard PLL I2C address */
- pllbuf[1] = div >> 8;
- pllbuf[2] = div & 0xff;
- pllbuf[3] = cp;
- pllbuf[4] = bs;
-
- return 0;
-}
-
-static int thomson_dtt7579_pll_set(struct dvb_frontend* fe,
- struct dvb_frontend_parameters* params,
- u8* pllbuf)
-{
- u32 div;
- unsigned char cp = 0;
- unsigned char bs = 0;
-
- div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
-
- if (params->frequency < 542000000) cp = 0xb4;
- else if (params->frequency < 771000000) cp = 0xbc;
- else cp = 0xf4;
-
- if (params->frequency == 0) bs = 0x03;
- else if (params->frequency < 443250000) bs = 0x02;
- else bs = 0x08;
-
- pllbuf[0] = 0xc0; // Note: non-linux standard PLL i2c address
- pllbuf[1] = div >> 8;
- pllbuf[2] = div & 0xff;
- pllbuf[3] = cp;
- pllbuf[4] = bs;
-
- return 0;
-}
-
-struct mt352_config dvico_fusionhdtv_dvbt1 = {
- .demod_address = 0x0F,
- .demod_init = dvico_fusionhdtv_demod_init,
- .pll_set = lg_z201_pll_set,
-};
-
-struct mt352_config dvico_fusionhdtv_dvbt_plus = {
- .demod_address = 0x0F,
- .demod_init = dvico_fusionhdtv_demod_init,
- .pll_set = thomson_dtt7579_pll_set,
-};
-
static int dntv_live_dvbt_demod_init(struct dvb_frontend* fe)
{
static u8 clock_config [] = { 0x89, 0x38, 0x39 };
@@ -201,49 +134,29 @@ static int dntv_live_dvbt_demod_init(struct dvb_frontend* fe)
return 0;
}
-static int dntv_live_dvbt_pll_set(struct dvb_frontend* fe,
- struct dvb_frontend_parameters* params,
- u8* pllbuf)
+static int mt352_pll_set(struct dvb_frontend* fe,
+ struct dvb_frontend_parameters* params,
+ u8* pllbuf)
{
- u32 div;
- unsigned char bs = 0;
- unsigned char cp = 0;
-
- div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
-
- if (params->frequency < 150000000) cp = 0xB4;
- else if (params->frequency < 173000000) cp = 0xBC;
- else if (params->frequency < 250000000) cp = 0xB4;
- else if (params->frequency < 400000000) cp = 0xBC;
- else if (params->frequency < 420000000) cp = 0xF4;
- else if (params->frequency < 470000000) cp = 0xFC;
- else if (params->frequency < 600000000) cp = 0xBC;
- else if (params->frequency < 730000000) cp = 0xF4;
- else cp = 0xFC;
-
- if (params->frequency < 150000000) bs = 0x01;
- else if (params->frequency < 173000000) bs = 0x01;
- else if (params->frequency < 250000000) bs = 0x02;
- else if (params->frequency < 400000000) bs = 0x02;
- else if (params->frequency < 420000000) bs = 0x02;
- else if (params->frequency < 470000000) bs = 0x02;
- else if (params->frequency < 600000000) bs = 0x08;
- else if (params->frequency < 730000000) bs = 0x08;
- else bs = 0x08;
-
- pllbuf[0] = 0xc2; // Note: non-linux standard PLL i2c address
- pllbuf[1] = div >> 8;
- pllbuf[2] = div & 0xff;
- pllbuf[3] = cp;
- pllbuf[4] = bs;
+ struct cx8802_dev *dev= fe->dvb->priv;
+ pllbuf[0] = dev->core->pll_addr << 1;
+ dvb_pll_configure(dev->core->pll_desc, pllbuf+1,
+ params->frequency,
+ params->u.ofdm.bandwidth);
return 0;
}
+static struct mt352_config dvico_fusionhdtv = {
+ .demod_address = 0x0F,
+ .demod_init = dvico_fusionhdtv_demod_init,
+ .pll_set = mt352_pll_set,
+};
+
static struct mt352_config dntv_live_dvbt_config = {
.demod_address = 0x0f,
.demod_init = dntv_live_dvbt_demod_init,
- .pll_set = dntv_live_dvbt_pll_set,
+ .pll_set = mt352_pll_set,
};
static int dvb_register(struct cx8802_dev *dev)
@@ -257,40 +170,32 @@ static int dvb_register(struct cx8802_dev *dev)
case CX88_BOARD_CONEXANT_DVB_T1:
dev->dvb.frontend = cx22702_create(&dev->core->i2c_adap,
dev->core->pll_addr,
- dev->core->pll_type,
+ dev->core->pll_desc,
dev->core->demod_addr);
break;
case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
- dev->dvb.frontend = mt352_attach(&dvico_fusionhdtv_dvbt1,
- &dev->core->i2c_adap);
- if (dev->dvb.frontend) {
- dev->dvb.frontend->ops->info.frequency_min = 174000000;
- dev->dvb.frontend->ops->info.frequency_max = 862000000;
- }
- break;
case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
- dev->dvb.frontend = mt352_attach(&dvico_fusionhdtv_dvbt_plus,
+ dev->dvb.frontend = mt352_attach(&dvico_fusionhdtv,
&dev->core->i2c_adap);
- if (dev->dvb.frontend) {
- dev->dvb.frontend->ops->info.frequency_min = 174000000;
- dev->dvb.frontend->ops->info.frequency_max = 862000000;
- }
break;
case CX88_BOARD_DNTV_LIVE_DVB_T:
dev->dvb.frontend = mt352_attach(&dntv_live_dvbt_config,
&dev->core->i2c_adap);
- if (dev->dvb.frontend) {
- dev->dvb.frontend->ops->info.frequency_min = 174000000;
- dev->dvb.frontend->ops->info.frequency_max = 862000000;
- }
break;
default:
printk("%s: FIXME: frontend handling not here yet ...\n",
dev->core->name);
break;
}
- if (NULL == dev->dvb.frontend)
+ if (NULL == dev->dvb.frontend) {
+ printk("%s: frontend initialization failed\n",dev->core->name);
return -1;
+ }
+
+ if (dev->core->pll_desc) {
+ dev->dvb.frontend->ops->info.frequency_min = dev->core->pll_desc->min;
+ dev->dvb.frontend->ops->info.frequency_max = dev->core->pll_desc->max;
+ }
/* Copy the board name into the DVB structure */
strlcpy(dev->dvb.frontend->ops->info.name,
@@ -298,7 +203,7 @@ static int dvb_register(struct cx8802_dev *dev)
sizeof(dev->dvb.frontend->ops->info.name));
/* register everything */
- return videobuf_dvb_register(&dev->dvb);
+ return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev);
}
/* ----------------------------------------------------------- */
diff --git a/linux/drivers/media/video/cx88/cx88.h b/linux/drivers/media/video/cx88/cx88.h
index 6643f69c2..6a62739e7 100644
--- a/linux/drivers/media/video/cx88/cx88.h
+++ b/linux/drivers/media/video/cx88/cx88.h
@@ -1,5 +1,5 @@
/*
- * $Id: cx88.h,v 1.45 2004/12/07 13:17:57 kraxel Exp $
+ * $Id: cx88.h,v 1.46 2004/12/09 12:51:35 kraxel Exp $
*
* v4l2 device driver for cx2388x based TV cards
*
@@ -256,7 +256,7 @@ struct cx88_core {
unsigned int has_radio;
/* config info -- dvb */
- unsigned int pll_type;
+ struct dvb_pll_desc *pll_desc;
unsigned int pll_addr;
unsigned int demod_addr;