aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/media/video/mt20xx.c33
-rw-r--r--drivers/media/video/tda8290.c105
-rw-r--r--drivers/media/video/tda9887.c33
-rw-r--r--drivers/media/video/tuner-core.c5
-rw-r--r--include/media/tuner.h13
5 files changed, 117 insertions, 72 deletions
diff --git a/drivers/media/video/mt20xx.c b/drivers/media/video/mt20xx.c
index 2987c1685da5..d7e68a639cd8 100644
--- a/drivers/media/video/mt20xx.c
+++ b/drivers/media/video/mt20xx.c
@@ -37,6 +37,11 @@ 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
40// IsSpurInBand()? 45// IsSpurInBand()?
41static int mt2032_spurcheck(struct i2c_client *c, 46static int mt2032_spurcheck(struct i2c_client *c,
42 int f1, int f2, int spectrum_from,int spectrum_to) 47 int f1, int f2, int spectrum_from,int spectrum_to)
@@ -218,6 +223,7 @@ static void mt2032_set_if_freq(struct i2c_client *c, unsigned int rfin,
218 unsigned char buf[21]; 223 unsigned char buf[21];
219 int lint_try,ret,sel,lock=0; 224 int lint_try,ret,sel,lock=0;
220 struct tuner *t = i2c_get_clientdata(c); 225 struct tuner *t = i2c_get_clientdata(c);
226 struct microtune_priv *priv = t->priv;
221 227
222 tuner_dbg("mt2032_set_if_freq rfin=%d if1=%d if2=%d from=%d to=%d\n", 228 tuner_dbg("mt2032_set_if_freq rfin=%d if1=%d if2=%d from=%d to=%d\n",
223 rfin,if1,if2,from,to); 229 rfin,if1,if2,from,to);
@@ -227,7 +233,7 @@ static void mt2032_set_if_freq(struct i2c_client *c, unsigned int rfin,
227 i2c_master_recv(c,buf,21); 233 i2c_master_recv(c,buf,21);
228 234
229 buf[0]=0; 235 buf[0]=0;
230 ret=mt2032_compute_freq(c,rfin,if1,if2,from,to,&buf[1],&sel,t->xogc); 236 ret=mt2032_compute_freq(c,rfin,if1,if2,from,to,&buf[1],&sel,priv->xogc);
231 if (ret<0) 237 if (ret<0)
232 return; 238 return;
233 239
@@ -251,10 +257,10 @@ static void mt2032_set_if_freq(struct i2c_client *c, unsigned int rfin,
251 257
252 tuner_dbg("mt2032: re-init PLLs by LINT\n"); 258 tuner_dbg("mt2032: re-init PLLs by LINT\n");
253 buf[0]=7; 259 buf[0]=7;
254 buf[1]=0x80 +8+t->xogc; // set LINT to re-init PLLs 260 buf[1]=0x80 +8+priv->xogc; // set LINT to re-init PLLs
255 i2c_master_send(c,buf,2); 261 i2c_master_send(c,buf,2);
256 mdelay(10); 262 mdelay(10);
257 buf[1]=8+t->xogc; 263 buf[1]=8+priv->xogc;
258 i2c_master_send(c,buf,2); 264 i2c_master_send(c,buf,2);
259 } 265 }
260 266
@@ -294,7 +300,8 @@ 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) 300static void mt2032_set_radio_freq(struct i2c_client *c, unsigned int freq)
295{ 301{
296 struct tuner *t = i2c_get_clientdata(c); 302 struct tuner *t = i2c_get_clientdata(c);
297 int if2 = t->radio_if2; 303 struct microtune_priv *priv = t->priv;
304 int if2 = priv->radio_if2;
298 305
299 // per Manual for FM tuning: first if center freq. 1085 MHz 306 // per Manual for FM tuning: first if center freq. 1085 MHz
300 mt2032_set_if_freq(c, freq * 1000 / 16, 307 mt2032_set_if_freq(c, freq * 1000 / 16,
@@ -305,6 +312,7 @@ static void mt2032_set_radio_freq(struct i2c_client *c, unsigned int freq)
305static int mt2032_init(struct i2c_client *c) 312static int mt2032_init(struct i2c_client *c)
306{ 313{
307 struct tuner *t = i2c_get_clientdata(c); 314 struct tuner *t = i2c_get_clientdata(c);
315 struct microtune_priv *priv = t->priv;
308 unsigned char buf[21]; 316 unsigned char buf[21];
309 int ret,xogc,xok=0; 317 int ret,xogc,xok=0;
310 318
@@ -351,7 +359,7 @@ static int mt2032_init(struct i2c_client *c)
351 if (ret!=2) 359 if (ret!=2)
352 tuner_warn("i2c i/o error: rc == %d (should be 2)\n",ret); 360 tuner_warn("i2c i/o error: rc == %d (should be 2)\n",ret);
353 } while (xok != 1 ); 361 } while (xok != 1 );
354 t->xogc=xogc; 362 priv->xogc=xogc;
355 363
356 t->set_tv_freq = mt2032_set_tv_freq; 364 t->set_tv_freq = mt2032_set_tv_freq;
357 t->set_radio_freq = mt2032_set_radio_freq; 365 t->set_radio_freq = mt2032_set_radio_freq;
@@ -456,7 +464,8 @@ 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) 464static void mt2050_set_radio_freq(struct i2c_client *c, unsigned int freq)
457{ 465{
458 struct tuner *t = i2c_get_clientdata(c); 466 struct tuner *t = i2c_get_clientdata(c);
459 int if2 = t->radio_if2; 467 struct microtune_priv *priv = t->priv;
468 int if2 = priv->radio_if2;
460 469
461 mt2050_set_if_freq(c, freq * 1000 / 16, if2); 470 mt2050_set_if_freq(c, freq * 1000 / 16, if2);
462 mt2050_set_antenna(c, radio_antenna); 471 mt2050_set_antenna(c, radio_antenna);
@@ -488,21 +497,29 @@ static int mt2050_init(struct i2c_client *c)
488 497
489int microtune_init(struct i2c_client *c) 498int microtune_init(struct i2c_client *c)
490{ 499{
500 struct microtune_priv *priv = NULL;
491 struct tuner *t = i2c_get_clientdata(c); 501 struct tuner *t = i2c_get_clientdata(c);
492 char *name; 502 char *name;
493 unsigned char buf[21]; 503 unsigned char buf[21];
494 int company_code; 504 int company_code;
495 505
506 priv = kzalloc(sizeof(struct microtune_priv), GFP_KERNEL);
507 if (priv == NULL)
508 return -ENOMEM;
509 t->priv = priv;
510
511 priv->radio_if2 = 10700 * 1000; /* 10.7MHz - FM radio */
512
496 memset(buf,0,sizeof(buf)); 513 memset(buf,0,sizeof(buf));
497 t->set_tv_freq = NULL; 514 t->set_tv_freq = NULL;
498 t->set_radio_freq = NULL; 515 t->set_radio_freq = NULL;
499 t->standby = NULL; 516 t->standby = NULL;
500 if (t->std & V4L2_STD_525_60) { 517 if (t->std & V4L2_STD_525_60) {
501 tuner_dbg("pinnacle ntsc\n"); 518 tuner_dbg("pinnacle ntsc\n");
502 t->radio_if2 = 41300 * 1000; 519 priv->radio_if2 = 41300 * 1000;
503 } else { 520 } else {
504 tuner_dbg("pinnacle pal\n"); 521 tuner_dbg("pinnacle pal\n");
505 t->radio_if2 = 33300 * 1000; 522 priv->radio_if2 = 33300 * 1000;
506 } 523 }
507 name = "unknown"; 524 name = "unknown";
508 525
diff --git a/drivers/media/video/tda8290.c b/drivers/media/video/tda8290.c
index 1a1bef0e9c3d..7bdf968bf6e5 100644
--- a/drivers/media/video/tda8290.c
+++ b/drivers/media/video/tda8290.c
@@ -25,6 +25,16 @@
25 25
26/* ---------------------------------------------------------------------- */ 26/* ---------------------------------------------------------------------- */
27 27
28struct tda8290_priv {
29 unsigned char tda8290_easy_mode;
30 unsigned char tda827x_lpsel;
31 unsigned char tda827x_addr;
32 unsigned char tda827x_ver;
33 unsigned int sgIF;
34};
35
36/* ---------------------------------------------------------------------- */
37
28struct tda827x_data { 38struct tda827x_data {
29 u32 lomax; 39 u32 lomax;
30 u8 spd; 40 u8 spd;
@@ -76,7 +86,8 @@ static void tda827x_tune(struct i2c_client *c, u16 ifc, unsigned int freq)
76 u32 N; 86 u32 N;
77 int i; 87 int i;
78 struct tuner *t = i2c_get_clientdata(c); 88 struct tuner *t = i2c_get_clientdata(c);
79 struct i2c_msg msg = {.addr = t->tda827x_addr, .flags = 0}; 89 struct tda8290_priv *priv = t->priv;
90 struct i2c_msg msg = {.addr = priv->tda827x_addr, .flags = 0};
80 91
81 if (t->mode == V4L2_TUNER_RADIO) 92 if (t->mode == V4L2_TUNER_RADIO)
82 freq = freq / 1000; 93 freq = freq / 1000;
@@ -95,7 +106,7 @@ static void tda827x_tune(struct i2c_client *c, u16 ifc, unsigned int freq)
95 tuner_reg[1] = (unsigned char)(N>>8); 106 tuner_reg[1] = (unsigned char)(N>>8);
96 tuner_reg[2] = (unsigned char) N; 107 tuner_reg[2] = (unsigned char) N;
97 tuner_reg[3] = 0x40; 108 tuner_reg[3] = 0x40;
98 tuner_reg[4] = 0x52 + (t->tda827x_lpsel << 5); 109 tuner_reg[4] = 0x52 + (priv->tda827x_lpsel << 5);
99 tuner_reg[5] = (tda827x_analog[i].spd << 6) + (tda827x_analog[i].div1p5 <<5) + 110 tuner_reg[5] = (tda827x_analog[i].spd << 6) + (tda827x_analog[i].div1p5 <<5) +
100 (tda827x_analog[i].bs <<3) + tda827x_analog[i].bp; 111 (tda827x_analog[i].bs <<3) + tda827x_analog[i].bp;
101 tuner_reg[6] = 0x8f + (tda827x_analog[i].gc3 << 4); 112 tuner_reg[6] = 0x8f + (tda827x_analog[i].gc3 << 4);
@@ -146,8 +157,9 @@ static void tda827x_tune(struct i2c_client *c, u16 ifc, unsigned int freq)
146static void tda827x_agcf(struct i2c_client *c) 157static void tda827x_agcf(struct i2c_client *c)
147{ 158{
148 struct tuner *t = i2c_get_clientdata(c); 159 struct tuner *t = i2c_get_clientdata(c);
160 struct tda8290_priv *priv = t->priv;
149 unsigned char data[] = {0x80, 0x0c}; 161 unsigned char data[] = {0x80, 0x0c};
150 struct i2c_msg msg = {.addr = t->tda827x_addr, .buf = data, 162 struct i2c_msg msg = {.addr = priv->tda827x_addr, .buf = data,
151 .flags = 0, .len = 2}; 163 .flags = 0, .len = 2};
152 i2c_transfer(c->adapter, &msg, 1); 164 i2c_transfer(c->adapter, &msg, 1);
153} 165}
@@ -234,7 +246,8 @@ static void tda827xa_tune(struct i2c_client *c, u16 ifc, unsigned int freq)
234 u32 N; 246 u32 N;
235 int i; 247 int i;
236 struct tuner *t = i2c_get_clientdata(c); 248 struct tuner *t = i2c_get_clientdata(c);
237 struct i2c_msg msg = {.addr = t->tda827x_addr, .flags = 0, .buf = tuner_reg}; 249 struct tda8290_priv *priv = t->priv;
250 struct i2c_msg msg = {.addr = priv->tda827x_addr, .flags = 0, .buf = tuner_reg};
238 251
239 tda827xa_lna_gain( c, 1); 252 tda827xa_lna_gain( c, 1);
240 msleep(10); 253 msleep(10);
@@ -271,7 +284,7 @@ static void tda827xa_tune(struct i2c_client *c, u16 ifc, unsigned int freq)
271 tuner_reg[1] = 0xff; 284 tuner_reg[1] = 0xff;
272 tuner_reg[2] = 0xe0; 285 tuner_reg[2] = 0xe0;
273 tuner_reg[3] = 0; 286 tuner_reg[3] = 0;
274 tuner_reg[4] = 0x99 + (t->tda827x_lpsel << 1); 287 tuner_reg[4] = 0x99 + (priv->tda827x_lpsel << 1);
275 msg.len = 5; 288 msg.len = 5;
276 i2c_transfer(c->adapter, &msg, 1); 289 i2c_transfer(c->adapter, &msg, 1);
277 290
@@ -311,15 +324,16 @@ static void tda827xa_tune(struct i2c_client *c, u16 ifc, unsigned int freq)
311 i2c_transfer(c->adapter, &msg, 1); 324 i2c_transfer(c->adapter, &msg, 1);
312 325
313 tuner_reg[0] = 0xc0; 326 tuner_reg[0] = 0xc0;
314 tuner_reg[1] = 0x19 + (t->tda827x_lpsel << 1); 327 tuner_reg[1] = 0x19 + (priv->tda827x_lpsel << 1);
315 i2c_transfer(c->adapter, &msg, 1); 328 i2c_transfer(c->adapter, &msg, 1);
316} 329}
317 330
318static void tda827xa_agcf(struct i2c_client *c) 331static void tda827xa_agcf(struct i2c_client *c)
319{ 332{
320 struct tuner *t = i2c_get_clientdata(c); 333 struct tuner *t = i2c_get_clientdata(c);
334 struct tda8290_priv *priv = t->priv;
321 unsigned char data[] = {0x80, 0x2c}; 335 unsigned char data[] = {0x80, 0x2c};
322 struct i2c_msg msg = {.addr = t->tda827x_addr, .buf = data, 336 struct i2c_msg msg = {.addr = priv->tda827x_addr, .buf = data,
323 .flags = 0, .len = 2}; 337 .flags = 0, .len = 2};
324 i2c_transfer(c->adapter, &msg, 1); 338 i2c_transfer(c->adapter, &msg, 1);
325} 339}
@@ -347,8 +361,9 @@ static void tda8290_i2c_bridge(struct i2c_client *c, int close)
347static int tda8290_tune(struct i2c_client *c, u16 ifc, unsigned int freq) 361static int tda8290_tune(struct i2c_client *c, u16 ifc, unsigned int freq)
348{ 362{
349 struct tuner *t = i2c_get_clientdata(c); 363 struct tuner *t = i2c_get_clientdata(c);
364 struct tda8290_priv *priv = t->priv;
350 unsigned char soft_reset[] = { 0x00, 0x00 }; 365 unsigned char soft_reset[] = { 0x00, 0x00 };
351 unsigned char easy_mode[] = { 0x01, t->tda8290_easy_mode }; 366 unsigned char easy_mode[] = { 0x01, priv->tda8290_easy_mode };
352 unsigned char expert_mode[] = { 0x01, 0x80 }; 367 unsigned char expert_mode[] = { 0x01, 0x80 };
353 unsigned char agc_out_on[] = { 0x02, 0x00 }; 368 unsigned char agc_out_on[] = { 0x02, 0x00 };
354 unsigned char gainset_off[] = { 0x28, 0x14 }; 369 unsigned char gainset_off[] = { 0x28, 0x14 };
@@ -375,18 +390,18 @@ static int tda8290_tune(struct i2c_client *c, u16 ifc, unsigned int freq)
375 i2c_master_send(c, soft_reset, 2); 390 i2c_master_send(c, soft_reset, 2);
376 msleep(1); 391 msleep(1);
377 392
378 expert_mode[1] = t->tda8290_easy_mode + 0x80; 393 expert_mode[1] = priv->tda8290_easy_mode + 0x80;
379 i2c_master_send(c, expert_mode, 2); 394 i2c_master_send(c, expert_mode, 2);
380 i2c_master_send(c, gainset_off, 2); 395 i2c_master_send(c, gainset_off, 2);
381 i2c_master_send(c, if_agc_spd, 2); 396 i2c_master_send(c, if_agc_spd, 2);
382 if (t->tda8290_easy_mode & 0x60) 397 if (priv->tda8290_easy_mode & 0x60)
383 i2c_master_send(c, adc_head_9, 2); 398 i2c_master_send(c, adc_head_9, 2);
384 else 399 else
385 i2c_master_send(c, adc_head_6, 2); 400 i2c_master_send(c, adc_head_6, 2);
386 i2c_master_send(c, pll_bw_nom, 2); 401 i2c_master_send(c, pll_bw_nom, 2);
387 402
388 tda8290_i2c_bridge(c, 1); 403 tda8290_i2c_bridge(c, 1);
389 if (t->tda827x_ver != 0) 404 if (priv->tda827x_ver != 0)
390 tda827xa_tune(c, ifc, freq); 405 tda827xa_tune(c, ifc, freq);
391 else 406 else
392 tda827x_tune(c, ifc, freq); 407 tda827x_tune(c, ifc, freq);
@@ -418,7 +433,7 @@ static int tda8290_tune(struct i2c_client *c, u16 ifc, unsigned int freq)
418 if ((agc_stat > 115) || !(pll_stat & 0x80)) { 433 if ((agc_stat > 115) || !(pll_stat & 0x80)) {
419 tuner_dbg("adjust gain, step 2. Agc: %d, lock: %d\n", 434 tuner_dbg("adjust gain, step 2. Agc: %d, lock: %d\n",
420 agc_stat, pll_stat & 0x80); 435 agc_stat, pll_stat & 0x80);
421 if (t->tda827x_ver != 0) 436 if (priv->tda827x_ver != 0)
422 tda827xa_agcf(c); 437 tda827xa_agcf(c);
423 else 438 else
424 tda827x_agcf(c); 439 tda827x_agcf(c);
@@ -437,7 +452,7 @@ static int tda8290_tune(struct i2c_client *c, u16 ifc, unsigned int freq)
437 } 452 }
438 453
439 /* l/ l' deadlock? */ 454 /* l/ l' deadlock? */
440 if(t->tda8290_easy_mode & 0x60) { 455 if(priv->tda8290_easy_mode & 0x60) {
441 i2c_master_send(c, &addr_adc_sat, 1); 456 i2c_master_send(c, &addr_adc_sat, 1);
442 i2c_master_recv(c, &adc_sat, 1); 457 i2c_master_recv(c, &adc_sat, 1);
443 i2c_master_send(c, &addr_pll_stat, 1); 458 i2c_master_send(c, &addr_pll_stat, 1);
@@ -459,41 +474,42 @@ static int tda8290_tune(struct i2c_client *c, u16 ifc, unsigned int freq)
459 474
460static void set_audio(struct tuner *t) 475static void set_audio(struct tuner *t)
461{ 476{
477 struct tda8290_priv *priv = t->priv;
462 char* mode; 478 char* mode;
463 479
464 t->tda827x_lpsel = 0; 480 priv->tda827x_lpsel = 0;
465 if (t->std & V4L2_STD_MN) { 481 if (t->std & V4L2_STD_MN) {
466 t->sgIF = 92; 482 priv->sgIF = 92;
467 t->tda8290_easy_mode = 0x01; 483 priv->tda8290_easy_mode = 0x01;
468 t->tda827x_lpsel = 1; 484 priv->tda827x_lpsel = 1;
469 mode = "MN"; 485 mode = "MN";
470 } else if (t->std & V4L2_STD_B) { 486 } else if (t->std & V4L2_STD_B) {
471 t->sgIF = 108; 487 priv->sgIF = 108;
472 t->tda8290_easy_mode = 0x02; 488 priv->tda8290_easy_mode = 0x02;
473 mode = "B"; 489 mode = "B";
474 } else if (t->std & V4L2_STD_GH) { 490 } else if (t->std & V4L2_STD_GH) {
475 t->sgIF = 124; 491 priv->sgIF = 124;
476 t->tda8290_easy_mode = 0x04; 492 priv->tda8290_easy_mode = 0x04;
477 mode = "GH"; 493 mode = "GH";
478 } else if (t->std & V4L2_STD_PAL_I) { 494 } else if (t->std & V4L2_STD_PAL_I) {
479 t->sgIF = 124; 495 priv->sgIF = 124;
480 t->tda8290_easy_mode = 0x08; 496 priv->tda8290_easy_mode = 0x08;
481 mode = "I"; 497 mode = "I";
482 } else if (t->std & V4L2_STD_DK) { 498 } else if (t->std & V4L2_STD_DK) {
483 t->sgIF = 124; 499 priv->sgIF = 124;
484 t->tda8290_easy_mode = 0x10; 500 priv->tda8290_easy_mode = 0x10;
485 mode = "DK"; 501 mode = "DK";
486 } else if (t->std & V4L2_STD_SECAM_L) { 502 } else if (t->std & V4L2_STD_SECAM_L) {
487 t->sgIF = 124; 503 priv->sgIF = 124;
488 t->tda8290_easy_mode = 0x20; 504 priv->tda8290_easy_mode = 0x20;
489 mode = "L"; 505 mode = "L";
490 } else if (t->std & V4L2_STD_SECAM_LC) { 506 } else if (t->std & V4L2_STD_SECAM_LC) {
491 t->sgIF = 20; 507 priv->sgIF = 20;
492 t->tda8290_easy_mode = 0x40; 508 priv->tda8290_easy_mode = 0x40;
493 mode = "LC"; 509 mode = "LC";
494 } else { 510 } else {
495 t->sgIF = 124; 511 priv->sgIF = 124;
496 t->tda8290_easy_mode = 0x10; 512 priv->tda8290_easy_mode = 0x10;
497 mode = "xx"; 513 mode = "xx";
498 } 514 }
499 tuner_dbg("setting tda8290 to system %s\n", mode); 515 tuner_dbg("setting tda8290 to system %s\n", mode);
@@ -502,9 +518,10 @@ static void set_audio(struct tuner *t)
502static void set_tv_freq(struct i2c_client *c, unsigned int freq) 518static void set_tv_freq(struct i2c_client *c, unsigned int freq)
503{ 519{
504 struct tuner *t = i2c_get_clientdata(c); 520 struct tuner *t = i2c_get_clientdata(c);
521 struct tda8290_priv *priv = t->priv;
505 522
506 set_audio(t); 523 set_audio(t);
507 tda8290_tune(c, t->sgIF, freq); 524 tda8290_tune(c, priv->sgIF, freq);
508} 525}
509 526
510static void set_radio_freq(struct i2c_client *c, unsigned int freq) 527static void set_radio_freq(struct i2c_client *c, unsigned int freq)
@@ -528,13 +545,14 @@ static int has_signal(struct i2c_client *c)
528static void standby(struct i2c_client *c) 545static void standby(struct i2c_client *c)
529{ 546{
530 struct tuner *t = i2c_get_clientdata(c); 547 struct tuner *t = i2c_get_clientdata(c);
548 struct tda8290_priv *priv = t->priv;
531 unsigned char cb1[] = { 0x30, 0xD0 }; 549 unsigned char cb1[] = { 0x30, 0xD0 };
532 unsigned char tda8290_standby[] = { 0x00, 0x02 }; 550 unsigned char tda8290_standby[] = { 0x00, 0x02 };
533 unsigned char tda8290_agc_tri[] = { 0x02, 0x20 }; 551 unsigned char tda8290_agc_tri[] = { 0x02, 0x20 };
534 struct i2c_msg msg = {.addr = t->tda827x_addr, .flags=0, .buf=cb1, .len = 2}; 552 struct i2c_msg msg = {.addr = priv->tda827x_addr, .flags=0, .buf=cb1, .len = 2};
535 553
536 tda8290_i2c_bridge(c, 1); 554 tda8290_i2c_bridge(c, 1);
537 if (t->tda827x_ver != 0) 555 if (priv->tda827x_ver != 0)
538 cb1[1] = 0x90; 556 cb1[1] = 0x90;
539 i2c_transfer(c->adapter, &msg, 1); 557 i2c_transfer(c->adapter, &msg, 1);
540 tda8290_i2c_bridge(c, 0); 558 tda8290_i2c_bridge(c, 0);
@@ -560,13 +578,14 @@ static void tda8290_init_if(struct i2c_client *c)
560static void tda8290_init_tuner(struct i2c_client *c) 578static void tda8290_init_tuner(struct i2c_client *c)
561{ 579{
562 struct tuner *t = i2c_get_clientdata(c); 580 struct tuner *t = i2c_get_clientdata(c);
581 struct tda8290_priv *priv = t->priv;
563 unsigned char tda8275_init[] = { 0x00, 0x00, 0x00, 0x40, 0xdC, 0x04, 0xAf, 582 unsigned char tda8275_init[] = { 0x00, 0x00, 0x00, 0x40, 0xdC, 0x04, 0xAf,
564 0x3F, 0x2A, 0x04, 0xFF, 0x00, 0x00, 0x40 }; 583 0x3F, 0x2A, 0x04, 0xFF, 0x00, 0x00, 0x40 };
565 unsigned char tda8275a_init[] = { 0x00, 0x00, 0x00, 0x00, 0xdC, 0x05, 0x8b, 584 unsigned char tda8275a_init[] = { 0x00, 0x00, 0x00, 0x00, 0xdC, 0x05, 0x8b,
566 0x0c, 0x04, 0x20, 0xFF, 0x00, 0x00, 0x4b }; 585 0x0c, 0x04, 0x20, 0xFF, 0x00, 0x00, 0x4b };
567 struct i2c_msg msg = {.addr = t->tda827x_addr, .flags=0, 586 struct i2c_msg msg = {.addr = priv->tda827x_addr, .flags=0,
568 .buf=tda8275_init, .len = 14}; 587 .buf=tda8275_init, .len = 14};
569 if (t->tda827x_ver != 0) 588 if (priv->tda827x_ver != 0)
570 msg.buf = tda8275a_init; 589 msg.buf = tda8275a_init;
571 590
572 tda8290_i2c_bridge(c, 1); 591 tda8290_i2c_bridge(c, 1);
@@ -578,12 +597,18 @@ static void tda8290_init_tuner(struct i2c_client *c)
578 597
579int tda8290_init(struct i2c_client *c) 598int tda8290_init(struct i2c_client *c)
580{ 599{
600 struct tda8290_priv *priv = NULL;
581 struct tuner *t = i2c_get_clientdata(c); 601 struct tuner *t = i2c_get_clientdata(c);
582 u8 data; 602 u8 data;
583 int i, ret, tuners_found; 603 int i, ret, tuners_found;
584 u32 tuner_addrs; 604 u32 tuner_addrs;
585 struct i2c_msg msg = {.flags=I2C_M_RD, .buf=&data, .len = 1}; 605 struct i2c_msg msg = {.flags=I2C_M_RD, .buf=&data, .len = 1};
586 606
607 priv = kzalloc(sizeof(struct tda8290_priv), GFP_KERNEL);
608 if (priv == NULL)
609 return -ENOMEM;
610 t->priv = priv;
611
587 tda8290_i2c_bridge(c, 1); 612 tda8290_i2c_bridge(c, 1);
588 /* probe for tuner chip */ 613 /* probe for tuner chip */
589 tuners_found = 0; 614 tuners_found = 0;
@@ -618,7 +643,7 @@ int tda8290_init(struct i2c_client *c)
618 tuner_addrs = tuner_addrs & 0xff; 643 tuner_addrs = tuner_addrs & 0xff;
619 tuner_info ("setting tuner address to %x\n", tuner_addrs); 644 tuner_info ("setting tuner address to %x\n", tuner_addrs);
620 } 645 }
621 t->tda827x_addr = tuner_addrs; 646 priv->tda827x_addr = tuner_addrs;
622 msg.addr = tuner_addrs; 647 msg.addr = tuner_addrs;
623 648
624 tda8290_i2c_bridge(c, 1); 649 tda8290_i2c_bridge(c, 1);
@@ -627,10 +652,10 @@ int tda8290_init(struct i2c_client *c)
627 tuner_warn ("TDA827x access failed!\n"); 652 tuner_warn ("TDA827x access failed!\n");
628 if ((data & 0x3c) == 0) { 653 if ((data & 0x3c) == 0) {
629 strlcpy(c->name, "tda8290+75", sizeof(c->name)); 654 strlcpy(c->name, "tda8290+75", sizeof(c->name));
630 t->tda827x_ver = 0; 655 priv->tda827x_ver = 0;
631 } else { 656 } else {
632 strlcpy(c->name, "tda8290+75a", sizeof(c->name)); 657 strlcpy(c->name, "tda8290+75a", sizeof(c->name));
633 t->tda827x_ver = 2; 658 priv->tda827x_ver = 2;
634 } 659 }
635 tuner_info("type set to %s\n", c->name); 660 tuner_info("type set to %s\n", c->name);
636 661
@@ -638,7 +663,7 @@ int tda8290_init(struct i2c_client *c)
638 t->set_radio_freq = set_radio_freq; 663 t->set_radio_freq = set_radio_freq;
639 t->has_signal = has_signal; 664 t->has_signal = has_signal;
640 t->standby = standby; 665 t->standby = standby;
641 t->tda827x_lpsel = 0; 666 priv->tda827x_lpsel = 0;
642 t->mode = V4L2_TUNER_ANALOG_TV; 667 t->mode = V4L2_TUNER_ANALOG_TV;
643 668
644 tda8290_init_tuner(c); 669 tda8290_init_tuner(c);
diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c
index fde576f1101c..01f18b07d013 100644
--- a/drivers/media/video/tda9887.c
+++ b/drivers/media/video/tda9887.c
@@ -29,6 +29,9 @@
29 printk(KERN_INFO "%s %d-%04x: " fmt, t->i2c.name, \ 29 printk(KERN_INFO "%s %d-%04x: " fmt, t->i2c.name, \
30 i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0) 30 i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0)
31 31
32struct tda9887_priv {
33 unsigned char data[4];
34};
32 35
33/* ---------------------------------------------------------------------- */ 36/* ---------------------------------------------------------------------- */
34 37
@@ -508,10 +511,11 @@ static int tda9887_status(struct tuner *t)
508static void tda9887_configure(struct i2c_client *client) 511static void tda9887_configure(struct i2c_client *client)
509{ 512{
510 struct tuner *t = i2c_get_clientdata(client); 513 struct tuner *t = i2c_get_clientdata(client);
514 struct tda9887_priv *priv = t->priv;
511 int rc; 515 int rc;
512 516
513 memset(t->tda9887_data,0,sizeof(t->tda9887_data)); 517 memset(priv->data,0,sizeof(priv->data));
514 tda9887_set_tvnorm(t,t->tda9887_data); 518 tda9887_set_tvnorm(t,priv->data);
515 519
516 /* A note on the port settings: 520 /* A note on the port settings:
517 These settings tend to depend on the specifics of the board. 521 These settings tend to depend on the specifics of the board.
@@ -526,22 +530,22 @@ static void tda9887_configure(struct i2c_client *client)
526 the ports should be set to active (0), but, again, that may 530 the ports should be set to active (0), but, again, that may
527 differ depending on the precise hardware configuration. 531 differ depending on the precise hardware configuration.
528 */ 532 */
529 t->tda9887_data[1] |= cOutputPort1Inactive; 533 priv->data[1] |= cOutputPort1Inactive;
530 t->tda9887_data[1] |= cOutputPort2Inactive; 534 priv->data[1] |= cOutputPort2Inactive;
531 535
532 tda9887_set_config(t,t->tda9887_data); 536 tda9887_set_config(t,priv->data);
533 tda9887_set_insmod(t,t->tda9887_data); 537 tda9887_set_insmod(t,priv->data);
534 538
535 if (t->mode == T_STANDBY) { 539 if (t->mode == T_STANDBY) {
536 t->tda9887_data[1] |= cForcedMuteAudioON; 540 priv->data[1] |= cForcedMuteAudioON;
537 } 541 }
538 542
539 tda9887_dbg("writing: b=0x%02x c=0x%02x e=0x%02x\n", 543 tda9887_dbg("writing: b=0x%02x c=0x%02x e=0x%02x\n",
540 t->tda9887_data[1],t->tda9887_data[2],t->tda9887_data[3]); 544 priv->data[1],priv->data[2],priv->data[3]);
541 if (tuner_debug > 1) 545 if (tuner_debug > 1)
542 dump_write_message(t, t->tda9887_data); 546 dump_write_message(t, priv->data);
543 547
544 if (4 != (rc = i2c_master_send(&t->i2c,t->tda9887_data,4))) 548 if (4 != (rc = i2c_master_send(&t->i2c,priv->data,4)))
545 tda9887_info("i2c i/o error: rc == %d (should be 4)\n",rc); 549 tda9887_info("i2c i/o error: rc == %d (should be 4)\n",rc);
546 550
547 if (tuner_debug > 2) { 551 if (tuner_debug > 2) {
@@ -555,7 +559,8 @@ static void tda9887_configure(struct i2c_client *client)
555static void tda9887_tuner_status(struct i2c_client *client) 559static void tda9887_tuner_status(struct i2c_client *client)
556{ 560{
557 struct tuner *t = i2c_get_clientdata(client); 561 struct tuner *t = i2c_get_clientdata(client);
558 tda9887_info("Data bytes: b=0x%02x c=0x%02x e=0x%02x\n", t->tda9887_data[1], t->tda9887_data[2], t->tda9887_data[3]); 562 struct tda9887_priv *priv = t->priv;
563 tda9887_info("Data bytes: b=0x%02x c=0x%02x e=0x%02x\n", priv->data[1], priv->data[2], priv->data[3]);
559} 564}
560 565
561static int tda9887_get_afc(struct i2c_client *client) 566static int tda9887_get_afc(struct i2c_client *client)
@@ -588,8 +593,14 @@ static void tda9887_set_freq(struct i2c_client *client, unsigned int freq)
588 593
589int tda9887_tuner_init(struct i2c_client *c) 594int tda9887_tuner_init(struct i2c_client *c)
590{ 595{
596 struct tda9887_priv *priv = NULL;
591 struct tuner *t = i2c_get_clientdata(c); 597 struct tuner *t = i2c_get_clientdata(c);
592 598
599 priv = kzalloc(sizeof(struct tda9887_priv), GFP_KERNEL);
600 if (priv == NULL)
601 return -ENOMEM;
602 t->priv = priv;
603
593 strlcpy(c->name, "tda9887", sizeof(c->name)); 604 strlcpy(c->name, "tda9887", sizeof(c->name));
594 605
595 tda9887_info("tda988[5/6/7] found @ 0x%x (%s)\n", t->i2c.addr, 606 tda9887_info("tda988[5/6/7] found @ 0x%x (%s)\n", t->i2c.addr,
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index 591ca9ce0440..406b85cd6064 100644
--- a/drivers/media/video/tuner-core.c
+++ b/drivers/media/video/tuner-core.c
@@ -177,6 +177,9 @@ static void set_type(struct i2c_client *c, unsigned int type,
177 return; 177 return;
178 } 178 }
179 179
180 /* discard private data, in case set_type() was previously called */
181 kfree(t->priv);
182 t->priv = NULL;
180 switch (t->type) { 183 switch (t->type) {
181 case TUNER_MT2032: 184 case TUNER_MT2032:
182 microtune_init(c); 185 microtune_init(c);
@@ -450,7 +453,6 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
450 memcpy(&t->i2c, &client_template, sizeof(struct i2c_client)); 453 memcpy(&t->i2c, &client_template, sizeof(struct i2c_client));
451 i2c_set_clientdata(&t->i2c, t); 454 i2c_set_clientdata(&t->i2c, t);
452 t->type = UNSET; 455 t->type = UNSET;
453 t->radio_if2 = 10700 * 1000; /* 10.7MHz - FM radio */
454 t->audmode = V4L2_TUNER_MODE_STEREO; 456 t->audmode = V4L2_TUNER_MODE_STEREO;
455 t->mode_mask = T_UNINITIALIZED; 457 t->mode_mask = T_UNINITIALIZED;
456 t->tuner_status = tuner_status; 458 t->tuner_status = tuner_status;
@@ -559,6 +561,7 @@ static int tuner_detach(struct i2c_client *client)
559 return err; 561 return err;
560 } 562 }
561 563
564 kfree(t->priv);
562 kfree(t); 565 kfree(t);
563 return 0; 566 return 0;
564} 567}
diff --git a/include/media/tuner.h b/include/media/tuner.h
index 7861babd4c90..b901373c6e10 100644
--- a/include/media/tuner.h
+++ b/include/media/tuner.h
@@ -199,21 +199,10 @@ struct tuner {
199 v4l2_std_id std; 199 v4l2_std_id std;
200 200
201 int using_v4l2; 201 int using_v4l2;
202 void *priv;
202 203
203 /* used by tda9887 */ 204 /* used by tda9887 */
204 unsigned int tda9887_config; 205 unsigned int tda9887_config;
205 unsigned char tda9887_data[4];
206
207 /* used by MT2032 */
208 unsigned int xogc;
209 unsigned int radio_if2;
210
211 /* used by tda8290 */
212 unsigned char tda8290_easy_mode;
213 unsigned char tda827x_lpsel;
214 unsigned char tda827x_addr;
215 unsigned char tda827x_ver;
216 unsigned int sgIF;
217 206
218 unsigned int config; 207 unsigned int config;
219 int (*tuner_callback) (void *dev, int command,int arg); 208 int (*tuner_callback) (void *dev, int command,int arg);