summaryrefslogtreecommitdiff
path: root/linux
diff options
context:
space:
mode:
authorGerd Knorr <devnull@localhost>2005-02-15 15:59:34 +0000
committerGerd Knorr <devnull@localhost>2005-02-15 15:59:34 +0000
commit7d4651c8e0961354b298165ec03219c02bc7c734 (patch)
treef5288a3b033c9d07e9963080023e045b567aeb6e /linux
parentb57159d1bd8754b2845b558cf778e9698bb0fc71 (diff)
downloadmediapointer-dvb-s2-7d4651c8e0961354b298165ec03219c02bc7c734.tar.gz
mediapointer-dvb-s2-7d4651c8e0961354b298165ec03219c02bc7c734.tar.bz2
- merge some patches from mainline.
- tuner kernel message fixups. - misc.
Diffstat (limited to 'linux')
-rw-r--r--linux/drivers/media/video/cx88/cx88-cards.c26
-rw-r--r--linux/drivers/media/video/cx88/cx88-dvb.c39
-rw-r--r--linux/drivers/media/video/cx88/cx88-i2c.c4
-rw-r--r--linux/drivers/media/video/mt20xx.c101
-rw-r--r--linux/drivers/media/video/saa7134/saa7134-core.c18
-rw-r--r--linux/drivers/media/video/saa7134/saa7134-video.c6
-rw-r--r--linux/drivers/media/video/tda8290.c4
-rw-r--r--linux/drivers/media/video/tuner-core.c94
-rw-r--r--linux/drivers/media/video/tuner-simple.c33
-rw-r--r--linux/include/media/tuner.h12
10 files changed, 177 insertions, 160 deletions
diff --git a/linux/drivers/media/video/cx88/cx88-cards.c b/linux/drivers/media/video/cx88/cx88-cards.c
index ee18141ca..a74ef661d 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.62 2005/02/14 16:30:26 kraxel Exp $
+ * $Id: cx88-cards.c,v 1.63 2005/02/15 15:59:34 kraxel Exp $
*
* device driver for Conexant 2388x based TV cards
* card-specific stuff.
@@ -26,15 +26,7 @@
#include <linux/pci.h>
#include <linux/delay.h>
-#if defined(CONFIG_VIDEO_CX88_DVB) || defined(CONFIG_VIDEO_CX88_DVB_MODULE)
-# define WITH_DVB 1
-#endif
-
#include "cx88.h"
-#ifdef WITH_DVB
-# include "dvb-pll.h"
-# include "cx22702.h"
-#endif
/* ------------------------------------------------------------------ */
/* board config info */
@@ -716,7 +708,6 @@ static void hauppauge_eeprom(struct cx88_core *core, u8 *eeprom_data)
core->has_radio = tv.has_radio;
}
-#ifdef WITH_DVB
static int hauppauge_eeprom_dvb(struct cx88_core *core, u8 *ee)
{
int model;
@@ -750,7 +741,6 @@ static int hauppauge_eeprom_dvb(struct cx88_core *core, u8 *ee)
printk(KERN_INFO "%s: hauppauge eeprom: model=%d, tuner=%d\n",
core->name, model, tuner);
}
-#endif
/* ----------------------------------------------------------------------- */
/* some GDI (was: Modular Technology) specific stuff */
@@ -854,28 +844,17 @@ void cx88_card_setup(struct cx88_core *core)
if (0 == core->i2c_rc)
leadtek_eeprom(core,eeprom);
break;
-#ifdef WITH_DVB
case CX88_BOARD_HAUPPAUGE_DVB_T1:
if (0 == core->i2c_rc)
hauppauge_eeprom_dvb(core,eeprom);
break;
case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
- /* GPIO0:0 is hooked to mt352 reset pin */
- 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:
/* GPIO0:0 is hooked to mt352 reset pin */
cx_set(MO_GP0_IO, 0x00000101);
cx_clear(MO_GP0_IO, 0x00000001);
msleep(1);
cx_set(MO_GP0_IO, 0x00000101);
- core->pll_addr = 0x60;
- core->pll_desc = &dvb_pll_thomson_dtt7579;
break;
case CX88_BOARD_KWORLD_DVB_T:
case CX88_BOARD_DNTV_LIVE_DVB_T:
@@ -885,10 +864,7 @@ 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 316e5d3f6..057c7349c 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.26 2005/02/10 11:43:41 kraxel Exp $
+ * $Id: cx88-dvb.c,v 1.27 2005/02/15 15:59:35 kraxel Exp $
*
* device driver for Conexant 2388x based TV cards
* MPEG Transport Stream (DVB) routines
@@ -30,12 +30,20 @@
#include <linux/file.h>
#include <linux/suspend.h>
+/* those two frontends need merging via linuxtv cvs ... */
+#define HAVE_CX22702 1
+#define HAVE_OR51132 1
+
#include "cx88.h"
#include "dvb-pll.h"
-#include "cx22702.h"
#include "mt352.h"
-#include "mt352_priv.h" /* FIXME */
-#include "or51132.h"
+#include "mt352_priv.h"
+#if HAVE_CX22702
+# include "cx22702.h"
+#endif
+#if HAVE_OR51132
+# include "or51132.h"
+#endif
MODULE_DESCRIPTION("driver for cx2388x based DVB cards");
MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
@@ -160,6 +168,7 @@ static struct mt352_config dntv_live_dvbt_config = {
.pll_set = mt352_pll_set,
};
+#if HAVE_CX22702
static struct cx22702_config connexant_refboard_config = {
.demod_address = 0x43,
.pll_address = 0x60,
@@ -171,12 +180,15 @@ static struct cx22702_config hauppauge_novat_config = {
.pll_address = 0x61,
.pll_desc = &dvb_pll_thomson_dtt759x,
};
+#endif
+#if HAVE_OR51132
struct or51132_config pchdtv_hd3000 = {
.demod_address = 0x15,
.pll_address = 0x61,
.pll_desc = &dvb_pll_thomson_dtt7610,
};
+#endif
static int dvb_register(struct cx8802_dev *dev)
{
@@ -185,6 +197,7 @@ static int dvb_register(struct cx8802_dev *dev)
/* init frontend */
switch (dev->core->board) {
+#if HAVE_CX22702
case CX88_BOARD_HAUPPAUGE_DVB_T1:
dev->dvb.frontend = cx22702_attach(&hauppauge_novat_config,
&dev->core->i2c_adap);
@@ -193,23 +206,37 @@ static int dvb_register(struct cx8802_dev *dev)
dev->dvb.frontend = cx22702_attach(&connexant_refboard_config,
&dev->core->i2c_adap);
break;
+#endif
case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
+ dev->core->pll_addr = 0x61;
+ dev->core->pll_desc = &dvb_pll_lg_z201;
+ dev->dvb.frontend = mt352_attach(&dvico_fusionhdtv,
+ &dev->core->i2c_adap);
+ break;
case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
+ dev->core->pll_addr = 0x60;
+ dev->core->pll_desc = &dvb_pll_thomson_dtt7579;
dev->dvb.frontend = mt352_attach(&dvico_fusionhdtv,
&dev->core->i2c_adap);
break;
case CX88_BOARD_KWORLD_DVB_T:
case CX88_BOARD_DNTV_LIVE_DVB_T:
+ dev->core->pll_addr = 0x61;
+ dev->core->pll_desc = &dvb_pll_unknown_1;
dev->dvb.frontend = mt352_attach(&dntv_live_dvbt_config,
&dev->core->i2c_adap);
break;
+#if HAVE_OR51132
case CX88_BOARD_PCHDTV_HD3000:
dev->dvb.frontend = or51132_attach(&pchdtv_hd3000,
&dev->core->i2c_adap);
break;
+#endif
default:
- printk("%s: FIXME: frontend handling not here yet ...\n",
- dev->core->name);
+ printk("%s: The frontend of your DVB/ATSC card isn't supported yet\n"
+ "%s: you might want to look out for patches here:\n"
+ "%s: http://dl.bytesex.org/patches/\n",
+ dev->core->name, dev->core->name, dev->core->name);
break;
}
if (NULL == dev->dvb.frontend) {
diff --git a/linux/drivers/media/video/cx88/cx88-i2c.c b/linux/drivers/media/video/cx88/cx88-i2c.c
index def26d334..d15eae3ff 100644
--- a/linux/drivers/media/video/cx88/cx88-i2c.c
+++ b/linux/drivers/media/video/cx88/cx88-i2c.c
@@ -1,5 +1,5 @@
/*
- $Id: cx88-i2c.c,v 1.19 2004/12/10 12:33:39 kraxel Exp $
+ $Id: cx88-i2c.c,v 1.20 2005/02/15 15:59:35 kraxel Exp $
cx88-i2c.c -- all the i2c code is here
@@ -135,7 +135,7 @@ static struct i2c_algo_bit_data cx8800_i2c_algo_template = {
static struct i2c_adapter cx8800_i2c_adap_template = {
I2C_DEVNAME("cx2388x"),
.owner = THIS_MODULE,
- .id = I2C_HW_B_BT848,
+ .id = I2C_HW_B_CX2388x,
.client_register = attach_inform,
.client_unregister = detach_inform,
};
diff --git a/linux/drivers/media/video/mt20xx.c b/linux/drivers/media/video/mt20xx.c
index 4e66135d1..2bc3c1e19 100644
--- a/linux/drivers/media/video/mt20xx.c
+++ b/linux/drivers/media/video/mt20xx.c
@@ -1,5 +1,5 @@
/*
- * $Id: mt20xx.c,v 1.2 2005/02/09 19:27:21 kraxel Exp $
+ * $Id: mt20xx.c,v 1.3 2005/02/15 15:59:35 kraxel Exp $
*
* i2c tv tuner chip device driver
* controls microtune tuners, mt2032 + mt2050 at the moment.
@@ -35,8 +35,10 @@ static char *microtune_part[] = {
};
// IsSpurInBand()?
-static int mt2032_spurcheck(int f1, int f2, int spectrum_from,int spectrum_to)
+static int mt2032_spurcheck(struct i2c_client *c,
+ int f1, int f2, int spectrum_from,int spectrum_to)
{
+ struct tuner *t = i2c_get_clientdata(c);
int n1=1,n2,f;
f1=f1/1000; //scale to kHz to avoid 32bit overflows
@@ -44,7 +46,8 @@ static int mt2032_spurcheck(int f1, int f2, int spectrum_from,int spectrum_to)
spectrum_from/=1000;
spectrum_to/=1000;
- printk("spurcheck f1=%d f2=%d from=%d to=%d\n",f1,f2,spectrum_from,spectrum_to);
+ tuner_dbg("spurcheck f1=%d f2=%d from=%d to=%d\n",
+ f1,f2,spectrum_from,spectrum_to);
do {
n2=-n1;
@@ -52,10 +55,10 @@ static int mt2032_spurcheck(int f1, int f2, int spectrum_from,int spectrum_to)
do {
n2--;
f=f-f2;
- printk(" spurtest n1=%d n2=%d ftest=%d\n",n1,n2,f);
+ tuner_dbg("spurtest n1=%d n2=%d ftest=%d\n",n1,n2,f);
if( (f>spectrum_from) && (f<spectrum_to))
- printk("mt2032 spurcheck triggered: %d\n",n1);
+ tuner_dbg("mt2032 spurcheck triggered: %d\n",n1);
} while ( (f>(f2-spectrum_to)) || (n2>-5));
n1++;
} while (n1<5);
@@ -63,7 +66,8 @@ static int mt2032_spurcheck(int f1, int f2, int spectrum_from,int spectrum_to)
return 1;
}
-static int mt2032_compute_freq(unsigned int rfin,
+static int mt2032_compute_freq(struct i2c_client *c,
+ unsigned int rfin,
unsigned int if1, unsigned int if2,
unsigned int spectrum_from,
unsigned int spectrum_to,
@@ -71,6 +75,7 @@ static int mt2032_compute_freq(unsigned int rfin,
int *ret_sel,
unsigned int xogc) //all in Hz
{
+ struct tuner *t = i2c_get_clientdata(c);
unsigned int fref,lo1,lo1n,lo1a,s,sel,lo1freq, desired_lo1,
desired_lo2,lo2,lo2n,lo2a,lo2num,lo2freq;
@@ -101,8 +106,8 @@ static int mt2032_compute_freq(unsigned int rfin,
lo1freq=(lo1a+8*lo1n)*fref;
- printk("mt2032: rfin=%d lo1=%d lo1n=%d lo1a=%d sel=%d, lo1freq=%d\n",
- rfin,lo1,lo1n,lo1a,sel,lo1freq);
+ tuner_dbg("mt2032: rfin=%d lo1=%d lo1n=%d lo1a=%d sel=%d, lo1freq=%d\n",
+ rfin,lo1,lo1n,lo1a,sel,lo1freq);
desired_lo2=lo1freq-rfin-if2;
lo2=(desired_lo2)/fref;
@@ -111,16 +116,16 @@ static int mt2032_compute_freq(unsigned int rfin,
lo2num=((desired_lo2/1000)%(fref/1000))* 3780/(fref/1000); //scale to fit in 32bit arith
lo2freq=(lo2a+8*lo2n)*fref + lo2num*(fref/1000)/3780*1000;
- printk("mt2032: rfin=%d lo2=%d lo2n=%d lo2a=%d num=%d lo2freq=%d\n",
- rfin,lo2,lo2n,lo2a,lo2num,lo2freq);
+ tuner_dbg("mt2032: rfin=%d lo2=%d lo2n=%d lo2a=%d num=%d lo2freq=%d\n",
+ rfin,lo2,lo2n,lo2a,lo2num,lo2freq);
if(lo1a<0 || lo1a>7 || lo1n<17 ||lo1n>48 || lo2a<0 ||lo2a >7 ||lo2n<17 || lo2n>30) {
- printk("mt2032: frequency parameters out of range: %d %d %d %d\n",
- lo1a, lo1n, lo2a,lo2n);
+ tuner_info("mt2032: frequency parameters out of range: %d %d %d %d\n",
+ lo1a, lo1n, lo2a,lo2n);
return(-1);
}
- mt2032_spurcheck(lo1freq, desired_lo2, spectrum_from, spectrum_to);
+ mt2032_spurcheck(c, lo1freq, desired_lo2, spectrum_from, spectrum_to);
// should recalculate lo1 (one step up/down)
// set up MT2032 register map for transfer over i2c
@@ -146,19 +151,21 @@ static int mt2032_compute_freq(unsigned int rfin,
static int mt2032_check_lo_lock(struct i2c_client *c)
{
+ struct tuner *t = i2c_get_clientdata(c);
int try,lock=0;
unsigned char buf[2];
+
for(try=0;try<10;try++) {
buf[0]=0x0e;
i2c_master_send(c,buf,1);
i2c_master_recv(c,buf,1);
- printk("mt2032 Reg.E=0x%02x\n",buf[0]);
+ tuner_dbg("mt2032 Reg.E=0x%02x\n",buf[0]);
lock=buf[0] &0x06;
if (lock==6)
break;
- printk("mt2032: pll wait 1ms for lock (0x%2x)\n",buf[0]);
+ tuner_dbg("mt2032: pll wait 1ms for lock (0x%2x)\n",buf[0]);
udelay(1000);
}
return lock;
@@ -166,13 +173,14 @@ static int mt2032_check_lo_lock(struct i2c_client *c)
static int mt2032_optimize_vco(struct i2c_client *c,int sel,int lock)
{
+ struct tuner *t = i2c_get_clientdata(c);
unsigned char buf[2];
int tad1;
buf[0]=0x0f;
i2c_master_send(c,buf,1);
i2c_master_recv(c,buf,1);
- printk("mt2032 Reg.F=0x%02x\n",buf[0]);
+ tuner_dbg("mt2032 Reg.F=0x%02x\n",buf[0]);
tad1=buf[0]&0x07;
if(tad1 ==0) return lock;
@@ -190,7 +198,7 @@ static int mt2032_optimize_vco(struct i2c_client *c,int sel,int lock)
return lock;
}
- printk("mt2032 optimize_vco: sel=%d\n",sel);
+ tuner_dbg("mt2032 optimize_vco: sel=%d\n",sel);
buf[0]=0x0f;
buf[1]=sel;
@@ -208,14 +216,15 @@ static void mt2032_set_if_freq(struct i2c_client *c, unsigned int rfin,
int lint_try,ret,sel,lock=0;
struct tuner *t = i2c_get_clientdata(c);
- printk("mt2032_set_if_freq rfin=%d if1=%d if2=%d from=%d to=%d\n",rfin,if1,if2,from,to);
+ tuner_dbg("mt2032_set_if_freq rfin=%d if1=%d if2=%d from=%d to=%d\n",
+ rfin,if1,if2,from,to);
buf[0]=0;
ret=i2c_master_send(c,buf,1);
i2c_master_recv(c,buf,21);
buf[0]=0;
- ret=mt2032_compute_freq(rfin,if1,if2,from,to,&buf[1],&sel,t->xogc);
+ ret=mt2032_compute_freq(c,rfin,if1,if2,from,to,&buf[1],&sel,t->xogc);
if (ret<0)
return;
@@ -227,7 +236,7 @@ static void mt2032_set_if_freq(struct i2c_client *c, unsigned int rfin,
buf[11]=11;
ret=i2c_master_send(c,buf+11,3);
if(ret!=3)
- printk("mt2032_set_if_freq failed with %d\n",ret);
+ tuner_warn("i2c i/o error: rc == %d (should be 3)\n",ret);
// wait for PLLs to lock (per manual), retry LINT if not.
for(lint_try=0; lint_try<2; lint_try++) {
@@ -237,7 +246,7 @@ static void mt2032_set_if_freq(struct i2c_client *c, unsigned int rfin,
lock=mt2032_optimize_vco(c,sel,lock);
if(lock==6) break;
- printk("mt2032: re-init PLLs by LINT\n");
+ tuner_dbg("mt2032: re-init PLLs by LINT\n");
buf[0]=7;
buf[1]=0x80 +8+t->xogc; // set LINT to re-init PLLs
i2c_master_send(c,buf,2);
@@ -247,13 +256,13 @@ static void mt2032_set_if_freq(struct i2c_client *c, unsigned int rfin,
}
if (lock!=6)
- printk("MT2032 Fatal Error: PLLs didn't lock.\n");
+ tuner_warn("MT2032 Fatal Error: PLLs didn't lock.\n");
buf[0]=2;
buf[1]=0x20; // LOGC for optimal phase noise
ret=i2c_master_send(c,buf,2);
if (ret!=2)
- printk("mt2032_set_if_freq2 failed with %d\n",ret);
+ tuner_warn("i2c i/o error: rc == %d (should be 2)\n",ret);
}
@@ -318,17 +327,17 @@ static int mt2032_init(struct i2c_client *c)
// Adjust XOGC (register 7), wait for XOK
xogc=7;
do {
- printk("mt2032: xogc = 0x%02x\n",xogc&0x07);
+ tuner_dbg("mt2032: xogc = 0x%02x\n",xogc&0x07);
mdelay(10);
buf[0]=0x0e;
i2c_master_send(c,buf,1);
i2c_master_recv(c,buf,1);
xok=buf[0]&0x01;
- printk("mt2032: xok = 0x%02x\n",xok);
+ tuner_dbg("mt2032: xok = 0x%02x\n",xok);
if (xok == 1) break;
xogc--;
- printk("mt2032: xogc = 0x%02x\n",xogc&0x07);
+ tuner_dbg("mt2032: xogc = 0x%02x\n",xogc&0x07);
if (xogc == 3) {
xogc=4; // min. 4 per spec
break;
@@ -337,7 +346,7 @@ static int mt2032_init(struct i2c_client *c)
buf[1]=0x88 + xogc;
ret=i2c_master_send(c,buf,2);
if (ret!=2)
- printk("mt2032_init failed with %d\n",ret);
+ tuner_warn("i2c i/o error: rc == %d (should be 2)\n",ret);
} while (xok != 1 );
t->xogc=xogc;
@@ -348,24 +357,26 @@ static int mt2032_init(struct i2c_client *c)
static void mt2050_set_antenna(struct i2c_client *c, unsigned char antenna)
{
+ struct tuner *t = i2c_get_clientdata(c);
unsigned char buf[2];
int ret;
buf[0] = 6;
buf[1] = antenna ? 0x11 : 0x10;
ret=i2c_master_send(c,buf,2);
- printk("mt2050: enabled antenna connector %d\n", antenna);
+ tuner_dbg("mt2050: enabled antenna connector %d\n", antenna);
}
static void mt2050_set_if_freq(struct i2c_client *c,unsigned int freq, unsigned int if2)
{
+ struct tuner *t = i2c_get_clientdata(c);
unsigned int if1=1218*1000*1000;
unsigned int f_lo1,f_lo2,lo1,lo2,f_lo1_modulo,f_lo2_modulo,num1,num2,div1a,div1b,div2a,div2b;
int ret;
unsigned char buf[6];
- printk("mt2050_set_if_freq freq=%d if1=%d if2=%d\n",
- freq,if1,if2);
+ tuner_dbg("mt2050_set_if_freq freq=%d if1=%d if2=%d\n",
+ freq,if1,if2);
f_lo1=freq+if1;
f_lo1=(f_lo1/1000000)*1000000;
@@ -391,8 +402,9 @@ static void mt2050_set_if_freq(struct i2c_client *c,unsigned int freq, unsigned
div2b=lo2-(div2a+1)*8;
if (tuner_debug > 1) {
- printk("lo1 lo2 = %d %d\n", lo1, lo2);
- printk("num1 num2 div1a div1b div2a div2b= %x %x %x %x %x %x\n",num1,num2,div1a,div1b,div2a,div2b);
+ tuner_dbg("lo1 lo2 = %d %d\n", lo1, lo2);
+ tuner_dbg("num1 num2 div1a div1b div2a div2b= %x %x %x %x %x %x\n",
+ num1,num2,div1a,div1b,div2a,div2b);
}
buf[0]=1;
@@ -407,7 +419,7 @@ static void mt2050_set_if_freq(struct i2c_client *c,unsigned int freq, unsigned
if (tuner_debug > 1) {
int i;
- printk("bufs is: ");
+ tuner_dbg("bufs is: ");
for(i=0;i<6;i++)
printk("%x ",buf[i]);
printk("\n");
@@ -415,7 +427,7 @@ static void mt2050_set_if_freq(struct i2c_client *c,unsigned int freq, unsigned
ret=i2c_master_send(c,buf,6);
if (ret!=6)
- printk("mt2050_set_if_freq failed with %d\n",ret);
+ tuner_warn("i2c i/o error: rc == %d (should be 6)\n",ret);
}
static void mt2050_set_tv_freq(struct i2c_client *c, unsigned int freq)
@@ -431,7 +443,7 @@ static void mt2050_set_tv_freq(struct i2c_client *c, unsigned int freq)
if2 = 38900*1000;
}
if (V4L2_TUNER_DIGITAL_TV == t->mode) {
- // testing for DVB ...
+ // DVB (pinnacle 300i)
if2 = 36150*1000;
}
mt2050_set_if_freq(c, freq*62500, if2);
@@ -465,7 +477,7 @@ static int mt2050_init(struct i2c_client *c)
ret=i2c_master_send(c,buf,1);
i2c_master_recv(c,buf,1);
- printk("mt2050: sro is %x\n",buf[0]);
+ tuner_dbg("mt2050: sro is %x\n",buf[0]);
t->tv_freq = mt2050_set_tv_freq;
t->radio_freq = mt2050_set_radio_freq;
return 0;
@@ -487,17 +499,16 @@ int microtune_init(struct i2c_client *c)
i2c_master_recv(c,buf,21);
if (tuner_debug) {
int i;
- printk(KERN_DEBUG "tuner: MT2032 hexdump:\n");
+ tuner_dbg("MT20xx hexdump:");
for(i=0;i<21;i++) {
printk(" %02x",buf[i]);
if(((i+1)%8)==0) printk(" ");
- if(((i+1)%16)==0) printk("\n ");
}
- printk("\n ");
+ printk("\n");
}
company_code = buf[0x11] << 8 | buf[0x12];
- printk("tuner: microtune: companycode=%04x part=%02x rev=%02x\n",
- company_code,buf[0x13],buf[0x14]);
+ tuner_info("microtune: companycode=%04x part=%02x rev=%02x\n",
+ company_code,buf[0x13],buf[0x14]);
#if 0
/* seems to cause more problems than it solves ... */
@@ -511,7 +522,7 @@ int microtune_init(struct i2c_client *c)
/* ok (?) */
break;
default:
- printk("tuner: microtune: unknown companycode\n");
+ tuner_warn("tuner: microtune: unknown companycode\n");
return 0;
}
#endif
@@ -527,13 +538,13 @@ int microtune_init(struct i2c_client *c)
mt2050_init(c);
break;
default:
- printk("tuner: microtune %s found, not (yet?) supported, sorry :-/\n",
- name);
+ tuner_info("microtune %s found, not (yet?) supported, sorry :-/\n",
+ name);
return 0;
}
strlcpy(c->name, name, sizeof(c->name));
- printk("tuner: microtune %s found, OK\n",name);
+ tuner_info("microtune %s found, OK\n",name);
return 0;
}
diff --git a/linux/drivers/media/video/saa7134/saa7134-core.c b/linux/drivers/media/video/saa7134/saa7134-core.c
index cefb39d59..a639cc90a 100644
--- a/linux/drivers/media/video/saa7134/saa7134-core.c
+++ b/linux/drivers/media/video/saa7134/saa7134-core.c
@@ -1,5 +1,5 @@
/*
- * $Id: saa7134-core.c,v 1.25 2005/01/31 11:32:47 kraxel Exp $
+ * $Id: saa7134-core.c,v 1.26 2005/02/15 15:59:35 kraxel Exp $
*
* device driver for philips saa7134 based TV cards
* driver core
@@ -383,10 +383,8 @@ int saa7134_buffer_queue(struct saa7134_dev *dev,
struct saa7134_buf *buf)
{
struct saa7134_buf *next = NULL;
-#ifdef DEBUG_SPINLOCKS
- BUG_ON(!spin_is_locked(&dev->slock));
-#endif
+ assert_spin_locked(&dev->slock);
dprintk("buffer_queue %p\n",buf);
if (NULL == q->curr) {
if (!q->need_two) {
@@ -412,9 +410,7 @@ void saa7134_buffer_finish(struct saa7134_dev *dev,
struct saa7134_dmaqueue *q,
unsigned int state)
{
-#ifdef DEBUG_SPINLOCKS
- BUG_ON(!spin_is_locked(&dev->slock));
-#endif
+ assert_spin_locked(&dev->slock);
dprintk("buffer_finish %p\n",q->curr);
/* finish current buffer */
@@ -429,9 +425,7 @@ void saa7134_buffer_next(struct saa7134_dev *dev,
{
struct saa7134_buf *buf,*next = NULL;
-#ifdef DEBUG_SPINLOCKS
- BUG_ON(!spin_is_locked(&dev->slock));
-#endif
+ assert_spin_locked(&dev->slock);
BUG_ON(NULL != q->curr);
if (!list_empty(&q->queue)) {
@@ -486,9 +480,7 @@ int saa7134_set_dmabits(struct saa7134_dev *dev)
enum v4l2_field cap = V4L2_FIELD_ANY;
enum v4l2_field ov = V4L2_FIELD_ANY;
-#ifdef DEBUG_SPINLOCKS
- BUG_ON(!spin_is_locked(&dev->slock));
-#endif
+ assert_spin_locked(&dev->slock);
/* video capture -- dma 0 + video task A */
if (dev->video_q.curr) {
diff --git a/linux/drivers/media/video/saa7134/saa7134-video.c b/linux/drivers/media/video/saa7134/saa7134-video.c
index 3c101b95a..014d2389b 100644
--- a/linux/drivers/media/video/saa7134/saa7134-video.c
+++ b/linux/drivers/media/video/saa7134/saa7134-video.c
@@ -1,5 +1,5 @@
/*
- * $Id: saa7134-video.c,v 1.27 2005/02/03 10:48:23 kraxel Exp $
+ * $Id: saa7134-video.c,v 1.28 2005/02/15 15:59:35 kraxel Exp $
*
* device driver for philips saa7134 based TV cards
* video4linux video interface
@@ -2383,10 +2383,10 @@ void saa7134_irq_video_done(struct saa7134_dev *dev, unsigned long status)
if (!dev->video_q.curr->top_seen)
goto done;
} else if (field == V4L2_FIELD_TOP) {
- if ((status & 0x10) != 0x00)
+ if ((status & 0x10) != 0x10)
goto done;
} else if (field == V4L2_FIELD_BOTTOM) {
- if ((status & 0x10) != 0x10)
+ if ((status & 0x10) != 0x00)
goto done;
}
dev->video_q.curr->vb.field_count = dev->video_fieldcount;
diff --git a/linux/drivers/media/video/tda8290.c b/linux/drivers/media/video/tda8290.c
index c6b63873d..fdb08f113 100644
--- a/linux/drivers/media/video/tda8290.c
+++ b/linux/drivers/media/video/tda8290.c
@@ -1,5 +1,5 @@
/*
- * $Id: tda8290.c,v 1.4 2005/02/14 16:30:26 kraxel Exp $
+ * $Id: tda8290.c,v 1.5 2005/02/15 15:59:35 kraxel Exp $
*
* i2c tv tuner chip device driver
* controls the philips tda8290+75 tuner chip combo.
@@ -205,7 +205,7 @@ int tda8290_init(struct i2c_client *c)
struct tuner *t = i2c_get_clientdata(c);
strlcpy(c->name, "tda8290+75", sizeof(c->name));
- printk("tuner: type set to %s\n", c->name);
+ tuner_info("tuner: type set to %s\n", c->name);
t->tv_freq = set_tv_freq;
t->radio_freq = set_radio_freq;
t->has_signal = has_signal;
diff --git a/linux/drivers/media/video/tuner-core.c b/linux/drivers/media/video/tuner-core.c
index cc7a78af8..6f73235cf 100644
--- a/linux/drivers/media/video/tuner-core.c
+++ b/linux/drivers/media/video/tuner-core.c
@@ -1,5 +1,5 @@
/*
- * $Id: tuner-core.c,v 1.4 2005/02/14 16:30:26 kraxel Exp $
+ * $Id: tuner-core.c,v 1.5 2005/02/15 15:59:35 kraxel Exp $
*
* i2c tv tuner chip device driver
* core core, i.e. kernel interfaces, registering and so on
@@ -74,11 +74,11 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq)
struct tuner *t = i2c_get_clientdata(c);
if (t->type == UNSET) {
- printk("tuner: tuner type not set\n");
+ tuner_info("tuner type not set\n");
return;
}
if (NULL == t->tv_freq) {
- printk("tuner: Huh? tv_set is NULL?\n");
+ tuner_info("Huh? tv_set is NULL?\n");
return;
}
if (freq < tv_range[0]*16 || freq > tv_range[1]*16) {
@@ -86,8 +86,8 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq)
right now we don't have that in the config
struct and this way is still better than no
check at all */
- printk("tuner: TV freq (%d.%02d) out of range (%d-%d)\n",
- freq/16,freq%16*100/16,tv_range[0],tv_range[1]);
+ tuner_info("TV freq (%d.%02d) out of range (%d-%d)\n",
+ freq/16,freq%16*100/16,tv_range[0],tv_range[1]);
return;
}
t->tv_freq(c,freq);
@@ -98,17 +98,17 @@ static void set_radio_freq(struct i2c_client *c, unsigned int freq)
struct tuner *t = i2c_get_clientdata(c);
if (t->type == UNSET) {
- printk("tuner: tuner type not set\n");
+ tuner_info("tuner type not set\n");
return;
}
if (NULL == t->radio_freq) {
- printk("tuner: no radio tuning for this one, sorry.\n");
+ tuner_info("no radio tuning for this one, sorry.\n");
return;
}
if (freq < radio_range[0]*16 || freq > radio_range[1]*16) {
- printk("tuner: radio freq (%d.%02d) out of range (%d-%d)\n",
- freq/16,freq%16*100/16,
- radio_range[0],radio_range[1]);
+ tuner_info("radio freq (%d.%02d) out of range (%d-%d)\n",
+ freq/16,freq%16*100/16,
+ radio_range[0],radio_range[1]);
return;
}
t->radio_freq(c,freq);
@@ -120,33 +120,40 @@ static void set_freq(struct i2c_client *c, unsigned long freq)
switch (t->mode) {
case V4L2_TUNER_RADIO:
- printk("tuner: radio freq set to %lu.%02lu\n",
- freq/16,freq%16*100/16);
+ tuner_dbg("radio freq set to %lu.%02lu\n",
+ freq/16,freq%16*100/16);
set_radio_freq(c,freq);
break;
case V4L2_TUNER_ANALOG_TV:
case V4L2_TUNER_DIGITAL_TV:
- printk("tuner: tv freq set to %lu.%02lu\n",
- freq/16,freq%16*100/16);
+ tuner_dbg("tv freq set to %lu.%02lu\n",
+ freq/16,freq%16*100/16);
set_tv_freq(c, freq);
break;
}
t->freq = freq;
}
-static void set_type(struct i2c_client *c, unsigned int type, char *source)
+static void set_type(struct i2c_client *c, unsigned int type)
{
struct tuner *t = i2c_get_clientdata(c);
- if (t->type != UNSET && t->type != TUNER_ABSENT) {
- if (t->type != type)
- printk("tuner: type already set to %d, "
- "ignoring request for %d\n", t->type, type);
+ /* sanity check */
+ if (type == UNSET || type == TUNER_ABSENT)
return;
- }
if (type >= tuner_count)
return;
+ if (NULL == t->i2c.dev.driver) {
+ /* not registered yet */
+ t->type = type;
+ return;
+ }
+ if (t->initialized)
+ /* run only once */
+ return;
+
+ t->initialized = 1;
t->type = type;
switch (t->type) {
case TUNER_MT2032:
@@ -173,19 +180,19 @@ static int tuner_fixup_std(struct tuner *t)
case 'B':
case 'g':
case 'G':
- printk("insmod fixup: PAL => PAL-BG\n");
+ tuner_dbg("insmod fixup: PAL => PAL-BG\n");
t->std = V4L2_STD_PAL_BG;
break;
case 'i':
case 'I':
- printk("insmod fixup: PAL => PAL-I\n");
+ tuner_dbg("insmod fixup: PAL => PAL-I\n");
t->std = V4L2_STD_PAL_I;
break;
case 'd':
case 'D':
case 'k':
case 'K':
- printk("insmod fixup: PAL => PAL-DK\n");
+ tuner_dbg("insmod fixup: PAL => PAL-DK\n");
t->std = V4L2_STD_PAL_DK;
break;
}
@@ -198,7 +205,6 @@ static int tuner_fixup_std(struct tuner *t)
static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
{
struct tuner *t;
- struct i2c_client *client;
if (this_adap > 0)
return -1;
@@ -207,23 +213,19 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
client_template.adapter = adap;
client_template.addr = addr;
- printk("tuner: chip found at addr 0x%x i2c-bus %s\n",
- addr<<1, adap->name);
-
- if (NULL == (client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL)))
- return -ENOMEM;
- memcpy(client,&client_template,sizeof(struct i2c_client));
t = kmalloc(sizeof(struct tuner),GFP_KERNEL);
- if (NULL == t) {
- kfree(client);
+ if (NULL == t)
return -ENOMEM;
- }
memset(t,0,sizeof(struct tuner));
- i2c_set_clientdata(client, t);
+ memcpy(&t->i2c,&client_template,sizeof(struct i2c_client));
+ i2c_set_clientdata(&t->i2c, t);
t->type = UNSET;
t->radio_if2 = 10700*1000; // 10.7MHz - FM radio
- i2c_attach_client(client);
+ i2c_attach_client(&t->i2c);
+ tuner_info("chip found @ 0x%x (%s)\n",
+ addr << 1, adap->name);
+ set_type(&t->i2c, t->type);
return 0;
}
@@ -245,17 +247,16 @@ static int tuner_detach(struct i2c_client *client)
{
struct tuner *t = i2c_get_clientdata(client);
- i2c_detach_client(client);
+ i2c_detach_client(&t->i2c);
kfree(t);
- kfree(client);
return 0;
}
#define SWITCH_V4L2 if (!t->using_v4l2 && tuner_debug) \
- printk("tuner: switching to v4l2\n"); \
+ tuner_info("switching to v4l2\n"); \
t->using_v4l2 = 1;
#define CHECK_V4L2 if (t->using_v4l2) { if (tuner_debug) \
- printk("tuner: ignore v4l1 call\n"); \
+ tuner_info("ignore v4l1 call\n"); \
return 0; }
static int
@@ -268,7 +269,7 @@ tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
/* --- configuration --- */
case TUNER_SET_TYPE:
- set_type(client,*iarg,client->adapter->name);
+ set_type(client,*iarg);
break;
case AUDC_SET_RADIO:
if (V4L2_TUNER_RADIO != t->mode) {
@@ -279,11 +280,11 @@ tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
case AUDC_CONFIG_PINNACLE:
switch (*iarg) {
case 2:
- printk("tuner: pinnacle pal\n");
+ tuner_dbg("pinnacle pal\n");
t->radio_if2 = 33300 * 1000;
break;
case 3:
- printk("tuner: pinnacle ntsc\n");
+ tuner_dbg("pinnacle ntsc\n");
t->radio_if2 = 41300 * 1000;
break;
}
@@ -386,7 +387,10 @@ tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
static int tuner_suspend(struct device * dev, u32 state, u32 level)
{
- printk("tuner: suspend\n");
+ struct i2c_client *c = container_of(dev, struct i2c_client, dev);
+ struct tuner *t = i2c_get_clientdata(c);
+
+ tuner_dbg("suspend\n");
/* FIXME: power down ??? */
return 0;
}
@@ -396,7 +400,7 @@ static int tuner_resume(struct device * dev, u32 level)
struct i2c_client *c = container_of(dev, struct i2c_client, dev);
struct tuner *t = i2c_get_clientdata(c);
- printk("tuner: resume\n");
+ tuner_dbg("resume\n");
if (t->freq)
set_freq(c,t->freq);
return 0;
@@ -406,7 +410,7 @@ static int tuner_resume(struct device * dev, u32 level)
static struct i2c_driver driver = {
.owner = THIS_MODULE,
- .name = "i2c TV tuner driver",
+ .name = "tuner",
.id = I2C_DRIVERID_TUNER,
.flags = I2C_DF_NOTIFY,
.attach_adapter = tuner_probe,
diff --git a/linux/drivers/media/video/tuner-simple.c b/linux/drivers/media/video/tuner-simple.c
index c2a3b6134..0fabdea9d 100644
--- a/linux/drivers/media/video/tuner-simple.c
+++ b/linux/drivers/media/video/tuner-simple.c
@@ -1,5 +1,5 @@
/*
- * $Id: tuner-simple.c,v 1.3 2005/02/10 11:43:41 kraxel Exp $
+ * $Id: tuner-simple.c,v 1.4 2005/02/15 15:59:35 kraxel Exp $
*
* i2c tv tuner chip device driver
* controls all those simple 4-control-bytes style tuners.
@@ -214,11 +214,6 @@ static int tuner_getstatus(struct i2c_client *c)
{
unsigned char byte;
- struct tuner *t = i2c_get_clientdata(c);
-
- if (t->type == TUNER_MT2032)
- return 0;
-
if (1 != i2c_master_recv(c,&byte,1))
return 0;
return byte;
@@ -273,13 +268,13 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
tun = &tuners[t->type];
if (freq < tun->thresh1) {
config = tun->VHF_L;
- printk("tv: VHF lowrange\n");
+ tuner_dbg("tv: VHF lowrange\n");
} else if (freq < tun->thresh2) {
config = tun->VHF_H;
- printk("tv: VHF high range\n");
+ tuner_dbg("tv: VHF high range\n");
} else {
config = tun->UHF;
- printk("tv: UHF range\n");
+ tuner_dbg("tv: UHF range\n");
}
@@ -370,11 +365,11 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
buffer[2] = tun->config;
buffer[3] = config;
}
- printk("tuner: tv 0x%02x 0x%02x 0x%02x 0x%02x\n",
- buffer[0],buffer[1],buffer[2],buffer[3]);
+ tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n",
+ buffer[0],buffer[1],buffer[2],buffer[3]);
if (4 != (rc = i2c_master_send(c,buffer,4)))
- printk("tuner: i2c i/o error: rc == %d (should be 4)\n",rc);
+ tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc);
if (t->type == TUNER_MICROTUNE_4042FI5) {
// FIXME - this may also work for other tuners
@@ -386,7 +381,7 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
if (time_after(jiffies,timeout))
return;
if (1 != (rc = i2c_master_recv(c,&status_byte,1))) {
- printk("tuner: i2c i/o read error: rc == %d (should be 1)\n",rc);
+ tuner_warn("i2c i/o read error: rc == %d (should be 1)\n",rc);
break;
}
/* bit 6 is PLL locked indicator */
@@ -401,11 +396,11 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
buffer[1] = div & 0xff;
buffer[2] = tun->config;
buffer[3] = config;
- printk("tuner: tv 0x%02x 0x%02x 0x%02x 0x%02x\n",
+ tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n",
buffer[0],buffer[1],buffer[2],buffer[3]);
if (4 != (rc = i2c_master_send(c,buffer,4)))
- printk("tuner: i2c i/o error: rc == %d (should be 4)\n",rc);
+ tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc);
}
}
@@ -441,19 +436,19 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq)
buffer[0] = (div>>8) & 0x7f;
buffer[1] = div & 0xff;
- printk("tuner: radio 0x%02x 0x%02x 0x%02x 0x%02x\n",
+ tuner_dbg("radio 0x%02x 0x%02x 0x%02x 0x%02x\n",
buffer[0],buffer[1],buffer[2],buffer[3]);
if (4 != (rc = i2c_master_send(c,buffer,4)))
- printk("tuner: i2c i/o error: rc == %d (should be 4)\n",rc);
+ tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc);
}
int default_tuner_init(struct i2c_client *c)
{
struct tuner *t = i2c_get_clientdata(c);
- printk("tuner: type set to %d (%s)\n",
- t->type, tuners[t->type].name);
+ tuner_info("type set to %d (%s)\n",
+ t->type, tuners[t->type].name);
strlcpy(c->name, tuners[t->type].name, sizeof(c->name));
t->tv_freq = default_set_tv_freq;
diff --git a/linux/include/media/tuner.h b/linux/include/media/tuner.h
index d4c8a026b..74378a280 100644
--- a/linux/include/media/tuner.h
+++ b/linux/include/media/tuner.h
@@ -140,6 +140,11 @@
#define I2C_ADDR_TDA8275 0x61
struct tuner {
+ /* device */
+ struct i2c_client i2c;
+
+ /* state + config */
+ unsigned int initialized;
unsigned int type; /* chip type */
unsigned int freq; /* keep track of the current settings */
v4l2_std_id std;
@@ -170,6 +175,13 @@ extern int microtune_init(struct i2c_client *c);
extern int tda8290_init(struct i2c_client *c);
extern int default_tuner_init(struct i2c_client *c);
+#define tuner_warn(fmt, arg...) \
+ dev_printk(KERN_WARNING , &t->i2c.dev , fmt , ## arg)
+#define tuner_info(fmt, arg...) \
+ dev_printk(KERN_INFO , &t->i2c.dev , fmt , ## arg)
+#define tuner_dbg(fmt, arg...) \
+ if (tuner_debug) dev_printk(KERN_DEBUG , &t->i2c.dev , fmt , ## arg)
+
#endif /* __KERNEL__ */
#endif