aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/mt20xx.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/mt20xx.c')
-rw-r--r--drivers/media/video/mt20xx.c80
1 files changed, 58 insertions, 22 deletions
diff --git a/drivers/media/video/mt20xx.c b/drivers/media/video/mt20xx.c
index c7c9f3f8715c..7549114aaaca 100644
--- a/drivers/media/video/mt20xx.c
+++ b/drivers/media/video/mt20xx.c
@@ -7,7 +7,7 @@
7#include <linux/i2c.h> 7#include <linux/i2c.h>
8#include <linux/videodev.h> 8#include <linux/videodev.h>
9#include <linux/moduleparam.h> 9#include <linux/moduleparam.h>
10#include <media/tuner.h> 10#include "tuner-driver.h"
11 11
12/* ---------------------------------------------------------------------- */ 12/* ---------------------------------------------------------------------- */
13 13
@@ -37,6 +37,19 @@ static char *microtune_part[] = {
37 [ MT2050 ] = "MT2050", 37 [ MT2050 ] = "MT2050",
38}; 38};
39 39
40struct microtune_priv {
41 unsigned int xogc;
42 unsigned int radio_if2;
43};
44
45static void microtune_release(struct i2c_client *c)
46{
47 struct tuner *t = i2c_get_clientdata(c);
48
49 kfree(t->priv);
50 t->priv = NULL;
51}
52
40// IsSpurInBand()? 53// IsSpurInBand()?
41static int mt2032_spurcheck(struct i2c_client *c, 54static int mt2032_spurcheck(struct i2c_client *c,
42 int f1, int f2, int spectrum_from,int spectrum_to) 55 int f1, int f2, int spectrum_from,int spectrum_to)
@@ -218,6 +231,7 @@ static void mt2032_set_if_freq(struct i2c_client *c, unsigned int rfin,
218 unsigned char buf[21]; 231 unsigned char buf[21];
219 int lint_try,ret,sel,lock=0; 232 int lint_try,ret,sel,lock=0;
220 struct tuner *t = i2c_get_clientdata(c); 233 struct tuner *t = i2c_get_clientdata(c);
234 struct microtune_priv *priv = t->priv;
221 235
222 tuner_dbg("mt2032_set_if_freq rfin=%d if1=%d if2=%d from=%d to=%d\n", 236 tuner_dbg("mt2032_set_if_freq rfin=%d if1=%d if2=%d from=%d to=%d\n",
223 rfin,if1,if2,from,to); 237 rfin,if1,if2,from,to);
@@ -227,7 +241,7 @@ static void mt2032_set_if_freq(struct i2c_client *c, unsigned int rfin,
227 i2c_master_recv(c,buf,21); 241 i2c_master_recv(c,buf,21);
228 242
229 buf[0]=0; 243 buf[0]=0;
230 ret=mt2032_compute_freq(c,rfin,if1,if2,from,to,&buf[1],&sel,t->xogc); 244 ret=mt2032_compute_freq(c,rfin,if1,if2,from,to,&buf[1],&sel,priv->xogc);
231 if (ret<0) 245 if (ret<0)
232 return; 246 return;
233 247
@@ -251,10 +265,10 @@ static void mt2032_set_if_freq(struct i2c_client *c, unsigned int rfin,
251 265
252 tuner_dbg("mt2032: re-init PLLs by LINT\n"); 266 tuner_dbg("mt2032: re-init PLLs by LINT\n");
253 buf[0]=7; 267 buf[0]=7;
254 buf[1]=0x80 +8+t->xogc; // set LINT to re-init PLLs 268 buf[1]=0x80 +8+priv->xogc; // set LINT to re-init PLLs
255 i2c_master_send(c,buf,2); 269 i2c_master_send(c,buf,2);
256 mdelay(10); 270 mdelay(10);
257 buf[1]=8+t->xogc; 271 buf[1]=8+priv->xogc;
258 i2c_master_send(c,buf,2); 272 i2c_master_send(c,buf,2);
259 } 273 }
260 274
@@ -294,17 +308,25 @@ static void mt2032_set_tv_freq(struct i2c_client *c, unsigned int freq)
294static void mt2032_set_radio_freq(struct i2c_client *c, unsigned int freq) 308static void mt2032_set_radio_freq(struct i2c_client *c, unsigned int freq)
295{ 309{
296 struct tuner *t = i2c_get_clientdata(c); 310 struct tuner *t = i2c_get_clientdata(c);
297 int if2 = t->radio_if2; 311 struct microtune_priv *priv = t->priv;
312 int if2 = priv->radio_if2;
298 313
299 // per Manual for FM tuning: first if center freq. 1085 MHz 314 // per Manual for FM tuning: first if center freq. 1085 MHz
300 mt2032_set_if_freq(c, freq * 1000 / 16, 315 mt2032_set_if_freq(c, freq * 1000 / 16,
301 1085*1000*1000,if2,if2,if2); 316 1085*1000*1000,if2,if2,if2);
302} 317}
303 318
319static struct tuner_operations mt2032_tuner_ops = {
320 .set_tv_freq = mt2032_set_tv_freq,
321 .set_radio_freq = mt2032_set_radio_freq,
322 .release = microtune_release,
323};
324
304// Initalization as described in "MT203x Programming Procedures", Rev 1.2, Feb.2001 325// Initalization as described in "MT203x Programming Procedures", Rev 1.2, Feb.2001
305static int mt2032_init(struct i2c_client *c) 326static int mt2032_init(struct i2c_client *c)
306{ 327{
307 struct tuner *t = i2c_get_clientdata(c); 328 struct tuner *t = i2c_get_clientdata(c);
329 struct microtune_priv *priv = t->priv;
308 unsigned char buf[21]; 330 unsigned char buf[21];
309 int ret,xogc,xok=0; 331 int ret,xogc,xok=0;
310 332
@@ -351,23 +373,23 @@ static int mt2032_init(struct i2c_client *c)
351 if (ret!=2) 373 if (ret!=2)
352 tuner_warn("i2c i/o error: rc == %d (should be 2)\n",ret); 374 tuner_warn("i2c i/o error: rc == %d (should be 2)\n",ret);
353 } while (xok != 1 ); 375 } while (xok != 1 );
354 t->xogc=xogc; 376 priv->xogc=xogc;
377
378 memcpy(&t->ops, &mt2032_tuner_ops, sizeof(struct tuner_operations));
355 379
356 t->set_tv_freq = mt2032_set_tv_freq;
357 t->set_radio_freq = mt2032_set_radio_freq;
358 return(1); 380 return(1);
359} 381}
360 382
361static void mt2050_set_antenna(struct i2c_client *c, unsigned char antenna) 383static void mt2050_set_antenna(struct i2c_client *c, unsigned char antenna)
362{ 384{
363 struct tuner *t = i2c_get_clientdata(c); 385 struct tuner *t = i2c_get_clientdata(c);
364 unsigned char buf[2]; 386 unsigned char buf[2];
365 int ret; 387 int ret;
366 388
367 buf[0] = 6; 389 buf[0] = 6;
368 buf[1] = antenna ? 0x11 : 0x10; 390 buf[1] = antenna ? 0x11 : 0x10;
369 ret=i2c_master_send(c,buf,2); 391 ret=i2c_master_send(c,buf,2);
370 tuner_dbg("mt2050: enabled antenna connector %d\n", antenna); 392 tuner_dbg("mt2050: enabled antenna connector %d\n", antenna);
371} 393}
372 394
373static void mt2050_set_if_freq(struct i2c_client *c,unsigned int freq, unsigned int if2) 395static void mt2050_set_if_freq(struct i2c_client *c,unsigned int freq, unsigned int if2)
@@ -456,12 +478,19 @@ static void mt2050_set_tv_freq(struct i2c_client *c, unsigned int freq)
456static void mt2050_set_radio_freq(struct i2c_client *c, unsigned int freq) 478static void mt2050_set_radio_freq(struct i2c_client *c, unsigned int freq)
457{ 479{
458 struct tuner *t = i2c_get_clientdata(c); 480 struct tuner *t = i2c_get_clientdata(c);
459 int if2 = t->radio_if2; 481 struct microtune_priv *priv = t->priv;
482 int if2 = priv->radio_if2;
460 483
461 mt2050_set_if_freq(c, freq * 1000 / 16, if2); 484 mt2050_set_if_freq(c, freq * 1000 / 16, if2);
462 mt2050_set_antenna(c, radio_antenna); 485 mt2050_set_antenna(c, radio_antenna);
463} 486}
464 487
488static struct tuner_operations mt2050_tuner_ops = {
489 .set_tv_freq = mt2050_set_tv_freq,
490 .set_radio_freq = mt2050_set_radio_freq,
491 .release = microtune_release,
492};
493
465static int mt2050_init(struct i2c_client *c) 494static int mt2050_init(struct i2c_client *c)
466{ 495{
467 struct tuner *t = i2c_get_clientdata(c); 496 struct tuner *t = i2c_get_clientdata(c);
@@ -481,28 +510,35 @@ static int mt2050_init(struct i2c_client *c)
481 i2c_master_recv(c,buf,1); 510 i2c_master_recv(c,buf,1);
482 511
483 tuner_dbg("mt2050: sro is %x\n",buf[0]); 512 tuner_dbg("mt2050: sro is %x\n",buf[0]);
484 t->set_tv_freq = mt2050_set_tv_freq; 513
485 t->set_radio_freq = mt2050_set_radio_freq; 514 memcpy(&t->ops, &mt2050_tuner_ops, sizeof(struct tuner_operations));
515
486 return 0; 516 return 0;
487} 517}
488 518
489int microtune_init(struct i2c_client *c) 519int microtune_init(struct i2c_client *c)
490{ 520{
521 struct microtune_priv *priv = NULL;
491 struct tuner *t = i2c_get_clientdata(c); 522 struct tuner *t = i2c_get_clientdata(c);
492 char *name; 523 char *name;
493 unsigned char buf[21]; 524 unsigned char buf[21];
494 int company_code; 525 int company_code;
495 526
527 priv = kzalloc(sizeof(struct microtune_priv), GFP_KERNEL);
528 if (priv == NULL)
529 return -ENOMEM;
530 t->priv = priv;
531
532 priv->radio_if2 = 10700 * 1000; /* 10.7MHz - FM radio */
533
496 memset(buf,0,sizeof(buf)); 534 memset(buf,0,sizeof(buf));
497 t->set_tv_freq = NULL; 535
498 t->set_radio_freq = NULL;
499 t->standby = NULL;
500 if (t->std & V4L2_STD_525_60) { 536 if (t->std & V4L2_STD_525_60) {
501 tuner_dbg("pinnacle ntsc\n"); 537 tuner_dbg("pinnacle ntsc\n");
502 t->radio_if2 = 41300 * 1000; 538 priv->radio_if2 = 41300 * 1000;
503 } else { 539 } else {
504 tuner_dbg("pinnacle pal\n"); 540 tuner_dbg("pinnacle pal\n");
505 t->radio_if2 = 33300 * 1000; 541 priv->radio_if2 = 33300 * 1000;
506 } 542 }
507 name = "unknown"; 543 name = "unknown";
508 544