Hi, Here's a small diff against tuner.c (kernel 2.6.0) to get radio working on recent Pinnacle PCTV Pro cards that have a MT2050 tuner. In addition to Gerd's recent mini patch to tuner.c to get video working for these cards (an additional check company_code!=0x3cbf), apply this one and you're in business for radio too. Merry Xmas everybody. BJ *** /usr/src/linux/drivers/media/video/tuner.c.orig Tue Dec 23 15:29:49 2003 --- /usr/src/linux/drivers/media/video/tuner.c Wed Dec 24 17:40:28 2003 *************** *** 523,530 **** --- 523,588 ---- if (ret!=2) printk("mt2032_set_if_freq2 failed with %d\n",ret); } + 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); + } static void mt2032_set_tv_freq(struct i2c_client *c, unsigned int freq) { struct tuner *t = i2c_get_clientdata(c); *************** *** 555,562 **** --- 613,630 ---- mt2032_set_if_freq(c, freq*62500 /* freq*1000*1000/16 */, 1085*1000*1000,if2,if2,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; + + dprintk( "mt2050_set_radio_freq\n" ); + + mt2050_set_if_freq(c, freq*62500, if2); + } + // Initalization as described in "MT203x Programming Procedures", Rev 1.2, Feb.2001 static int mt2032_init(struct i2c_client *c) { struct tuner *t = i2c_get_clientdata(c); *************** *** 612,677 **** 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); - } static void mt2050_set_tv_freq(struct i2c_client *c, unsigned int freq) { struct tuner *t = i2c_get_clientdata(c); --- 680,687 ---- *************** *** 705,712 **** --- 715,723 ---- 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)