SOURCES (AC-branch): 31_tuner-2.4.26.diff (NEW) - uncompressed 31_...

hawk hawk at pld-linux.org
Mon Oct 8 16:35:51 CEST 2007


Author: hawk                         Date: Mon Oct  8 14:35:51 2007 GMT
Module: SOURCES                       Tag: AC-branch
---- Log message:
- uncompressed 31_tuner-2.4.26.diff.gz adjusted for kernel 2.4.35.3

---- Files affected:
SOURCES:
   31_tuner-2.4.26.diff (NONE -> 1.1.2.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/31_tuner-2.4.26.diff
diff -u /dev/null SOURCES/31_tuner-2.4.26.diff:1.1.2.1
--- /dev/null	Mon Oct  8 16:35:51 2007
+++ SOURCES/31_tuner-2.4.26.diff	Mon Oct  8 16:35:46 2007
@@ -0,0 +1,898 @@
+31_tuner
+diff -up linux-2.4.26/drivers/media/video/tuner.c linux/drivers/media/video/tuner.c
+--- linux-2.4.26/drivers/media/video/tuner.c	2004-04-21 13:45:45.000000000 +0200
++++ linux/drivers/media/video/tuner.c	2004-04-21 14:11:38.000000000 +0200
+@@ -1,3 +1,4 @@
++
+ #include <linux/module.h>
+ #include <linux/kernel.h>
+ #include <linux/sched.h>
+@@ -28,7 +29,6 @@ I2C_CLIENT_INSMOD;
+ static unsigned int debug =  0;
+ static unsigned int type  =  UNSET;
+ static unsigned int addr  =  0;
+-static char *pal =  "b";
+ static unsigned int tv_range[2]    = { 44, 958 };
+ static unsigned int radio_range[2] = { 65, 108 };
+ MODULE_PARM(debug,"i");
+@@ -36,7 +36,6 @@ MODULE_PARM(type,"i");
+ MODULE_PARM(addr,"i");
+ MODULE_PARM(tv_range,"2i");
+ MODULE_PARM(radio_range,"2i");
+-MODULE_PARM(pal,"s");
+ 
+ #define optimize_vco 1
+ 
+@@ -47,18 +46,20 @@ MODULE_LICENSE("GPL");
+ static int this_adap;
+ #define dprintk     if (debug) printk
+ 
+-struct tuner
+-{
++struct tuner {
+ 	unsigned int type;            /* chip type */
+ 	unsigned int freq;            /* keep track of the current settings */
+-	unsigned int std;
++	v4l2_std_id  std;
+ 	
+ 	unsigned int radio;
+-	unsigned int mode;            /* current norm for multi-norm tuners */
++	unsigned int input;
+ 	
+ 	// only for MT2032
+ 	unsigned int xogc;
+ 	unsigned int radio_if2;
++
++	void (*tv_freq)(struct i2c_client *c, unsigned int freq);
++	void (*radio_freq)(struct i2c_client *c, unsigned int freq);
+ };
+ 
+ static struct i2c_driver driver;
+@@ -209,7 +210,7 @@ static struct tunertype tuners[] = {
+ 
+ 	{ "Samsung PAL TCPM9091PD27", Samsung, PAL,  /* from sourceforge v3tv */
+           16*169,16*464,0xA0,0x90,0x30,0x8e,623},
+-	{ "MT2032 universal", Microtune,PAL|NTSC,
++	{ "MT20xx universal", Microtune,PAL|NTSC,
+                0,0,0,0,0,0,0},
+ 	{ "Temic PAL_BG (4106 FH5)", TEMIC, PAL,
+           16*141.00, 16*464.00, 0xa0,0x90,0x30,0x8e,623},
+@@ -229,6 +230,16 @@ static struct tunertype tuners[] = {
+ 	  16*170.00, 16*450.00, 0x01,0x02,0x00,0x8e,940 },
+ 	{ "Philips PAL_MK (FI1216 MK)", Philips, PAL,
+ 	  16*140.25,16*463.25,0x01,0xc2,0xcf,0x8e,623},
++	{ "Philips 1236D ATSC/NTSC daul in",Philips,ATSC,
++	  16*157.25,16*454.00,0xa0,0x90,0x30,0x8e,732},
++        { "Philips NTSC MK3 (FM1236MK3 or FM1236/F)", Philips, NTSC,
++          16*160.00,16*442.00,0x01,0x02,0x04,0x8e,732},
++
++        { "Philips 4 in 1 (ATI TV Wonder Pro/Conexant)", Philips, NTSC,
++          16*160.00,16*442.00,0x01,0x02,0x04,0x8e,732},
++	{ "Microtune 4049 FM5",Microtune,PAL,
++	  16*141.00,16*464.00,0xa0,0x90,0x30,0x8e,623},
++
+ };
+ #define TUNERS ARRAY_SIZE(tuners)
+ 
+@@ -283,86 +294,19 @@ static int tuner_mode (struct i2c_client
+ }
+ #endif
+ 
+-// Initalization as described in "MT203x Programming Procedures", Rev 1.2, Feb.2001
+-static int mt2032_init(struct i2c_client *c)
+-{
+-        unsigned char buf[21];
+-        int ret,xogc,xok=0;
+-	struct tuner *t = i2c_get_clientdata(c);
+-
+-        buf[0]=0;
+-        ret=i2c_master_send(c,buf,1);
+-        i2c_master_recv(c,buf,21);
+-
+-        printk("MT2032: Companycode=%02x%02x Part=%02x Revision=%02x\n",
+-                buf[0x11],buf[0x12],buf[0x13],buf[0x14]);
+-
+-        if(debug) {
+-                int i;
+-                printk("MT2032 hexdump:\n");
+-                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 ");
+-        }
+-	// Look for MT2032 id:
+-	// part= 0x04(MT2032), 0x06(MT2030), 0x07(MT2040)
+-        if((buf[0x11] != 0x4d) || (buf[0x12] != 0x54) || (buf[0x13] != 0x04)) {
+-                printk("not a MT2032.\n");
+-                return 0;
+-        }
+-
+-
+-        // Initialize Registers per spec.
+-        buf[1]=2; // Index to register 2
+-        buf[2]=0xff;
+-        buf[3]=0x0f;
+-        buf[4]=0x1f;
+-        ret=i2c_master_send(c,buf+1,4);
+-
+-        buf[5]=6; // Index register 6
+-        buf[6]=0xe4;
+-        buf[7]=0x8f;
+-        buf[8]=0xc3;
+-        buf[9]=0x4e;
+-        buf[10]=0xec;
+-        ret=i2c_master_send(c,buf+5,6);
+-
+-        buf[12]=13;  // Index register 13
+-        buf[13]=0x32;
+-        ret=i2c_master_send(c,buf+12,2);
+-
+-        // Adjust XOGC (register 7), wait for XOK
+-        xogc=7;
+-        do {
+-		dprintk("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;
+-                dprintk("mt2032: xok = 0x%02x\n",xok);
+-                if (xok == 1) break;
+-
+-                xogc--;
+-                dprintk("mt2032: xogc = 0x%02x\n",xogc&0x07);
+-                if (xogc == 3) {
+-                        xogc=4; // min. 4 per spec
+-                        break;
+-                }
+-                buf[0]=0x07;
+-                buf[1]=0x88 + xogc;
+-                ret=i2c_master_send(c,buf,2);
+-                if (ret!=2)
+-                        printk("mt2032_init failed with %d\n",ret);
+-        } while (xok != 1 );
+-	t->xogc=xogc;
+-
+-        return(1);
+-}
++/* ---------------------------------------------------------------------- */
+ 
++#define MT2032 0x04
++#define MT2030 0x06
++#define MT2040 0x07
++#define MT2050 0x42
++
++static char *microtune_part[] = {
++	[ MT2030 ] = "MT2030",
++	[ MT2032 ] = "MT2032",
++	[ MT2040 ] = "MT2040",
++	[ MT2050 ] = "MT2050",
++};
+ 
+ // IsSpurInBand()?
+ static int mt2032_spurcheck(int f1, int f2, int spectrum_from,int spectrum_to)
+@@ -587,56 +531,275 @@ static void mt2032_set_if_freq(struct i2
+ }
+ 
+ 
+-static void mt2032_set_tv_freq(struct i2c_client *c,
+-			       unsigned int freq, unsigned int norm)
++static void mt2032_set_tv_freq(struct i2c_client *c, unsigned int freq)
+ {
++	struct tuner *t = i2c_get_clientdata(c);
+ 	int if2,from,to;
+ 
+ 	// signal bandwidth and picture carrier
+-	if (norm==VIDEO_MODE_NTSC) {
+-		from=40750*1000;
+-		to=46750*1000;
+-		if2=45750*1000; 
++	if (t->std & V4L2_STD_525_60) {
++		// NTSC
++		from = 40750*1000;
++		to   = 46750*1000;
++		if2  = 45750*1000; 
+ 	} else {
+-		// Pal 
+-		from=32900*1000;
+-		to=39900*1000;
+-		if2=38900*1000;
++		// PAL
++		from = 32900*1000;
++		to   = 39900*1000;
++		if2  = 38900*1000;
+ 	}
+ 
+         mt2032_set_if_freq(c, freq*62500 /* freq*1000*1000/16 */,
+ 			   1090*1000*1000, if2, from, to);
+ }
+ 
++static void mt2032_set_radio_freq(struct i2c_client *c, unsigned int freq)
++{
++	struct tuner *t = i2c_get_clientdata(c);
++	int if2 = t->radio_if2;
+ 
+-// Set tuner frequency,  freq in Units of 62.5kHz = 1/16MHz
+-static void set_tv_freq(struct i2c_client *c, unsigned int freq)
++	// per Manual for FM tuning: first if center freq. 1085 MHz
++        mt2032_set_if_freq(c, freq*62500 /* freq*1000*1000/16 */,
++			   1085*1000*1000,if2,if2,if2);
++}
++
++// Initalization as described in "MT203x Programming Procedures", Rev 1.2, Feb.2001
++static int mt2032_init(struct i2c_client *c)
+ {
+-	u8 config;
+-	u16 div;
+-	struct tunertype *tun;
+ 	struct tuner *t = i2c_get_clientdata(c);
+-        unsigned char buffer[4];
+-	int rc;
++        unsigned char buf[21];
++        int ret,xogc,xok=0;
+ 
+-	if (t->type == UNSET) {
+-		printk("tuner: tuner type not set\n");
+-		return;
+-	}
+-	if (t->type == TUNER_MT2032) {
+-		mt2032_set_tv_freq(c,freq,t->mode);
+-		return;
++	// Initialize Registers per spec.
++        buf[1]=2; // Index to register 2
++        buf[2]=0xff;
++        buf[3]=0x0f;
++        buf[4]=0x1f;
++        ret=i2c_master_send(c,buf+1,4);
++
++        buf[5]=6; // Index register 6
++        buf[6]=0xe4;
++        buf[7]=0x8f;
++        buf[8]=0xc3;
++        buf[9]=0x4e;
++        buf[10]=0xec;
++        ret=i2c_master_send(c,buf+5,6);
++
++        buf[12]=13;  // Index register 13
++        buf[13]=0x32;
++        ret=i2c_master_send(c,buf+12,2);
++
++        // Adjust XOGC (register 7), wait for XOK
++        xogc=7;
++        do {
++		dprintk("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;
++                dprintk("mt2032: xok = 0x%02x\n",xok);
++                if (xok == 1) break;
++
++                xogc--;
++                dprintk("mt2032: xogc = 0x%02x\n",xogc&0x07);
++                if (xogc == 3) {
++                        xogc=4; // min. 4 per spec
++                        break;
++                }
++                buf[0]=0x07;
++                buf[1]=0x88 + xogc;
++                ret=i2c_master_send(c,buf,2);
++                if (ret!=2)
++                        printk("mt2032_init failed with %d\n",ret);
++        } while (xok != 1 );
++	t->xogc=xogc;
++
++	t->tv_freq    = mt2032_set_tv_freq;
++	t->radio_freq = mt2032_set_radio_freq;
++        return(1);
++}
++
++static void mt2050_set_if_freq(struct i2c_client *c,unsigned int freq, unsigned int if2)
++{
++	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];
++	
++	dprintk("mt2050_set_if_freq freq=%d\n",freq);
++	
++	f_lo1=freq+if1;
++	f_lo1=(f_lo1/1000000)*1000000;
++	
++	f_lo2=f_lo1-freq-if2;
++	f_lo2=(f_lo2/50000)*50000;
++	
++	lo1=f_lo1/4000000;
++	lo2=f_lo2/4000000;
++	
++	f_lo1_modulo= f_lo1-(lo1*4000000);
++	f_lo2_modulo= f_lo2-(lo2*4000000);
++	
++	num1=4*f_lo1_modulo/4000000;
++	num2=4096*(f_lo2_modulo/1000)/4000;
++	
++	// todo spurchecks
++	
++	div1a=(lo1/12)-1;
++	div1b=lo1-(div1a+1)*12;
++	
++	div2a=(lo2/8)-1;
++	div2b=lo2-(div2a+1)*8;
++	
++	dprintk("lo1 lo2 = %d %d\n", lo1, lo2);
++        dprintk("num1 num2 div1a div1b div2a div2b= %x %x %x %x %x %x\n",num1,num2,div1a,div1b,div2a,div2b);
++	
++	
++	buf[0]=1;
++	buf[1]= 4*div1b + num1;
++	if(freq<275*1000*1000) buf[1] = buf[1]|0x80;
++	
++	buf[2]=div1a;
++	buf[3]=32*div2b + num2/256;
++	buf[4]=num2-(num2/256)*256;
++	buf[5]=div2a;
++	if(num2!=0) buf[5]=buf[5]|0x40;
++	
++	if(debug) {
++		int i;
++		printk("bufs is: ");
++		for(i=0;i<6;i++)
++			printk("%x ",buf[i]);
++		printk("\n");
+ 	}
++	
++	ret=i2c_master_send(c,buf,6);
++        if (ret!=6)
++                printk("mt2050_set_if_freq failed with %d\n",ret);
++}
+ 
+-	if (freq < tv_range[0]*16 || freq > tv_range[1]*16) {
+-		/* FIXME: better do that chip-specific, but
+-		   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]);
+-		return;
++static void mt2050_set_tv_freq(struct i2c_client *c, unsigned int freq)
++{
++	struct tuner *t = i2c_get_clientdata(c);
++	unsigned int if2;
++	
++	if (t->std & V4L2_STD_525_60) {
++		// NTSC
++                if2 = 45750*1000;
++        } else {
++                // PAL
++                if2 = 38900*1000;
++        }
++	mt2050_set_if_freq(c,freq*62500,if2);
++}
++
++static void mt2050_set_radio_freq(struct i2c_client *c, unsigned int freq)
++{
++	struct tuner *t = i2c_get_clientdata(c);
++	int if2 = t->radio_if2;
++	
++	mt2050_set_if_freq(c, freq*62500, if2);
++}
++
++static int mt2050_init(struct i2c_client *c)
++{
++	struct tuner *t = i2c_get_clientdata(c);
++	unsigned char buf[2];
++	int ret;
++	
++	buf[0]=6;
++	buf[1]=0x10;
++	ret=i2c_master_send(c,buf,2); //  power
++	
++	buf[0]=0x0f;
++	buf[1]=0x0f;
++	ret=i2c_master_send(c,buf,2); // m1lo
++	
++	buf[0]=0x0d;
++	ret=i2c_master_send(c,buf,1);
++	i2c_master_recv(c,buf,1);
++	
++	dprintk("mt2050: sro is %x\n",buf[0]);
++	t->tv_freq    = mt2050_set_tv_freq;
++	t->radio_freq = mt2050_set_radio_freq;
++	return 0;
++}
++
++static int microtune_init(struct i2c_client *c)
++{
++	struct tuner *t = i2c_get_clientdata(c);
++	char *name;
++        unsigned char buf[21];
++	int company_code;
++	
++	memset(buf,0,sizeof(buf));
++	t->tv_freq    = NULL;
++	t->radio_freq = NULL;
++	name = "unknown";
++
++        i2c_master_send(c,buf,1);
++        i2c_master_recv(c,buf,21);
++        if(debug) {
++                int i;
++                printk(KERN_DEBUG "tuner: MT2032 hexdump:\n");
++                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 ");
++        }
++	company_code = buf[0x11] << 8 | buf[0x12];
++        printk("tuner: microtune: companycode=%04x part=%02x rev=%02x\n",
++	       company_code,buf[0x13],buf[0x14]);
++
++#if 0
++	/* seems to cause more problems than it solves ... */
++	switch (company_code) {
++	case 0x30bf:
++	case 0x3cbf:
++	case 0x3dbf:
++	case 0x4d54:
++	case 0x8e81:
++	case 0x8e91:
++		/* ok (?) */
++		break;
++	default:
++		printk("tuner: microtune: unknown companycode\n");
++		return 0;
+ 	}
++#endif
++
++	if (buf[0x13] < ARRAY_SIZE(microtune_part) &&
++	    NULL != microtune_part[buf[0x13]])
++		name = microtune_part[buf[0x13]];
++	switch (buf[0x13]) {
++	case MT2032:
++		mt2032_init(c);
++		break;
++	case MT2050:
++		mt2050_init(c);
++		break;
++	default:
++		printk("tuner: microtune %s found, not (yet?) supported, sorry :-/\n",
++		       name);
++                return 0;
++        }
++	printk("tuner: microtune %s found, OK\n",name);
++	return 0;
++}
++
++/* ---------------------------------------------------------------------- */
++
++static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
++{
++	struct tuner *t = i2c_get_clientdata(c);
++	u8 config;
++	u16 div;
++	struct tunertype *tun;
++        unsigned char buffer[4];
++	int rc;
+ 
+ 	tun=&tuners[t->type];
+ 	if (freq < tun->thresh1) 
+@@ -654,56 +817,53 @@ static void set_tv_freq(struct i2c_clien
+ 		/* 0x02 -> PAL BDGHI / SECAM L */
+ 		/* 0x04 -> ??? PAL others / SECAM others ??? */
+ 		config &= ~0x02;
+-		if (t->mode == VIDEO_MODE_SECAM)
++		if (t->std & V4L2_STD_SECAM)
+ 			config |= 0x02;
+ 		break;
+ 
+ 	case TUNER_TEMIC_4046FM5:
+ 		config &= ~0x0f;
+-		switch (pal[0]) {
+-		case 'i':
+-		case 'I':
++
++		if (t->std & V4L2_STD_PAL_BG) {
++			config |= TEMIC_SET_PAL_BG;
++
++		} else if (t->std & V4L2_STD_PAL_I) {
+ 			config |= TEMIC_SET_PAL_I;
+-			break;
+-		case 'd':
+-		case 'D':
++
++		} else if (t->std & V4L2_STD_PAL_DK) {
+ 			config |= TEMIC_SET_PAL_DK;
+-			break;
+-		case 'l':
+-		case 'L':
++			
++		} else if (t->std & V4L2_STD_SECAM_L) {
+ 			config |= TEMIC_SET_PAL_L;
+-			break;
+-		case 'b':
+-		case 'B':
+-		case 'g':
+-		case 'G':
+-		default:
+-			config |= TEMIC_SET_PAL_BG;
+-			break;
++
+ 		}
+ 		break;
+ 
+ 	case TUNER_PHILIPS_FQ1216ME:
+ 		config &= ~0x0f;
+-		switch (pal[0]) {
+-		case 'i':
+-		case 'I':
++
++		if (t->std & (V4L2_STD_PAL_BG|V4L2_STD_PAL_DK)) {
++			config |= PHILIPS_SET_PAL_BGDK;
++
++		} else if (t->std & V4L2_STD_PAL_I) {
+ 			config |= PHILIPS_SET_PAL_I;
+-			break;
+-		case 'l':
+-		case 'L':
++
++		} else if (t->std & V4L2_STD_SECAM_L) {
+ 			config |= PHILIPS_SET_PAL_L;
+-			break;
+-		case 'd':
+-		case 'D':
+-		case 'b':
+-		case 'B':
+-		case 'g':
+-		case 'G':
+-			config |= PHILIPS_SET_PAL_BGDK;
+-			break;
++
+ 		}
+ 		break;
++
++	case TUNER_PHILIPS_ATSC:
++		/* 0x00 -> ATSC antenna input 1 */
++		/* 0x01 -> ATSC antenna input 2 */
++		/* 0x02 -> NTSC antenna input 1 */
++		/* 0x03 -> NTSC antenna input 2 */
++		config &= ~0x03;
++		if (t->std & V4L2_STD_ATSC)
++			config |= 2;
++		/* FIXME: input */
++		break;
+ 	}
+ 
+ 	
+@@ -741,62 +901,162 @@ static void set_tv_freq(struct i2c_clien
+ 
+ }
+ 
+-static void mt2032_set_radio_freq(struct i2c_client *c, unsigned int freq)
++static void default_set_radio_freq(struct i2c_client *c, unsigned int freq)
+ {
++	struct tunertype *tun;
+ 	struct tuner *t = i2c_get_clientdata(c);
+-	int if2 = t->radio_if2;
++        unsigned char buffer[4];
++	unsigned div;
++	int rc;
+ 
+-	// per Manual for FM tuning: first if center freq. 1085 MHz
+-        mt2032_set_if_freq(c, freq*62500 /* freq*1000*1000/16 */,
+-			   1085*1000*1000,if2,if2,if2);
++	tun=&tuners[t->type];
++	div = freq + (int)(16*10.7);
++        buffer[0] = (div>>8) & 0x7f;
++        buffer[1] = div      & 0xff;
<<Diff was trimmed, longer than 597 lines>>


More information about the pld-cvs-commit mailing list