aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrent Piepho <xyzzy@speakeasy.org>2007-08-03 17:32:38 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-10-09 21:04:34 -0400
commit5e082f1521598a91c9194b2356b157cade9b6e87 (patch)
treed23454e16f03f1777aca03d981f89890ce022aea
parenta75d204860b5051ebd5635278c097bafb4ea53f9 (diff)
V4L/DVB (5978): tuner: Better tuner radio support
Add radio support for the Thomson DTT7612 tuner. This tuner uses a different 1st intermediate frequency than the other radio tuners supported (a lot of NTSC radio tuners probably need this change too). Add a new tuner-simple parameter, radio_if. It selects the 1st IF used for radio reception. The radio frequency setting code in tuner-simple now uses this field, instead of a special case select() block for each tuner with radio support. The tuner parameters for tuners that used a 33.3 MHz RIF now set radio_if to 1 in tuner-types.c. The Thomson DTT7612 gets radio_if = 2, also add has_tda9887 = 1 and fm_gain_normal = 1. Add some defines for tda9887 bits that control IF setting in radio mode. Add a new tda9887 config option, TDA9887_RIF_41_3, that selects a 41.3 MHz radio IF. Fix the way tda9887 radio options work. The driver was modifying the default radio mode config templates based on the TDA9887_XXXX flags. This means that _all_ tuners would get the same settings. If you had a one tuner than used TDA9887_GAIN_NORMAL and one that didn't, both would get the setting. Now the tda9987 driver just checks if tuner mode is radio and then applies the config settings directly to the data being sent, just like how all the TV mode settings already work. The PLL setting math is made a little more accurate. And a grammar error in a printk is fixed. Signed-off-by: Trent Piepho <xyzzy@speakeasy.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
-rw-r--r--drivers/media/video/tda9887.c19
-rw-r--r--drivers/media/video/tuner-simple.c55
-rw-r--r--drivers/media/video/tuner-types.c5
-rw-r--r--include/media/tuner-types.h4
-rw-r--r--include/media/tuner.h1
5 files changed, 62 insertions, 22 deletions
diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c
index a8f773274fe3..aa311e4f1f61 100644
--- a/drivers/media/video/tda9887.c
+++ b/drivers/media/video/tda9887.c
@@ -97,6 +97,8 @@ struct tvnorm {
97#define cAudioIF_6_5 0x03 // bit e0:1 97#define cAudioIF_6_5 0x03 // bit e0:1
98 98
99 99
100#define cVideoIFMask 0x1c // bit e2:4
101/* Video IF selection in TV Mode (bit B3=0) */
100#define cVideoIF_58_75 0x00 // bit e2:4 102#define cVideoIF_58_75 0x00 // bit e2:4
101#define cVideoIF_45_75 0x04 // bit e2:4 103#define cVideoIF_45_75 0x04 // bit e2:4
102#define cVideoIF_38_90 0x08 // bit e2:4 104#define cVideoIF_38_90 0x08 // bit e2:4
@@ -106,6 +108,13 @@ struct tvnorm {
106#define cRadioIF_45_75 0x18 // bit e2:4 108#define cRadioIF_45_75 0x18 // bit e2:4
107#define cRadioIF_38_90 0x1C // bit e2:4 109#define cRadioIF_38_90 0x1C // bit e2:4
108 110
111/* IF1 selection in Radio Mode (bit B3=1) */
112#define cRadioIF_33_30 0x00 // bit e2,4 (also 0x10,0x14)
113#define cRadioIF_41_30 0x04 // bit e2,4
114
115/* Output of AFC pin in radio mode when bit E7=1 */
116#define cRadioAGC_SIF 0x00 // bit e3
117#define cRadioAGC_FM 0x08 // bit e3
109 118
110#define cTunerGainNormal 0x00 // bit e5 119#define cTunerGainNormal 0x00 // bit e5
111#define cTunerGainLow 0x20 // bit e5 120#define cTunerGainLow 0x20 // bit e5
@@ -487,9 +496,13 @@ static int tda9887_set_config(struct tuner *t, char *buf)
487 if (t->tda9887_config & TDA9887_GATING_18) 496 if (t->tda9887_config & TDA9887_GATING_18)
488 buf[3] &= ~cGating_36; 497 buf[3] &= ~cGating_36;
489 498
490 if (t->tda9887_config & TDA9887_GAIN_NORMAL) { 499 if (t->mode == V4L2_TUNER_RADIO) {
491 radio_stereo.e &= ~cTunerGainLow; 500 if (t->tda9887_config & TDA9887_RIF_41_3) {
492 radio_mono.e &= ~cTunerGainLow; 501 buf[3] &= ~cVideoIFMask;
502 buf[3] |= cRadioIF_41_30;
503 }
504 if (t->tda9887_config & TDA9887_GAIN_NORMAL)
505 buf[3] &= ~cTunerGainLow;
493 } 506 }
494 507
495 return 0; 508 return 0;
diff --git a/drivers/media/video/tuner-simple.c b/drivers/media/video/tuner-simple.c
index 2d57e8bc0db3..10a7d36a2646 100644
--- a/drivers/media/video/tuner-simple.c
+++ b/drivers/media/video/tuner-simple.c
@@ -402,53 +402,68 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq)
402 u8 buffer[4]; 402 u8 buffer[4];
403 u16 div; 403 u16 div;
404 int rc, j; 404 int rc, j;
405 enum param_type desired_type = TUNER_PARAM_TYPE_RADIO;
406 struct tuner_params *params; 405 struct tuner_params *params;
407 406
408 tun = &tuners[t->type]; 407 tun = &tuners[t->type];
409 408
410 for (j = 0; j < tun->count-1; j++) { 409 for (j = tun->count-1; j > 0; j--)
411 if (desired_type != tun->params[j].type) 410 if (tun->params[j].type == TUNER_PARAM_TYPE_RADIO)
412 continue; 411 break;
412 /* default params (j=0) will be used if desired type wasn't found */
413 params = &tun->params[j];
414
415 /* Select Radio 1st IF used */
416 switch (params->radio_if) {
417 case 0: /* 10.7 MHz */
418 freq += (unsigned int)(10.7*16000);
413 break; 419 break;
420 case 1: /* 33.3 MHz */
421 freq += (unsigned int)(33.3*16000);
422 break;
423 case 2: /* 41.3 MHz */
424 freq += (unsigned int)(41.3*16000);
425 break;
426 default:
427 tuner_warn("Unsupported radio_if value %d\n", params->radio_if);
428 return;
414 } 429 }
415 /* use default tuner_params if desired_type not available */
416 if (desired_type != tun->params[j].type)
417 j = 0;
418
419 div = (20 * freq / 16000) + (int)(20*10.7); /* IF 10.7 MHz */
420 params = &tun->params[j];
421 buffer[2] = (params->ranges[0].config & ~TUNER_RATIO_MASK) | TUNER_RATIO_SELECT_50; /* 50 kHz step */
422 430
431 /* Bandswitch byte */
423 switch (t->type) { 432 switch (t->type) {
424 case TUNER_TENA_9533_DI: 433 case TUNER_TENA_9533_DI:
425 case TUNER_YMEC_TVF_5533MF: 434 case TUNER_YMEC_TVF_5533MF:
426 tuner_dbg ("This tuner doesn't have FM. Most cards has a TEA5767 for FM\n"); 435 tuner_dbg ("This tuner doesn't have FM. Most cards have a TEA5767 for FM\n");
427 return; 436 return;
428 case TUNER_PHILIPS_FM1216ME_MK3: 437 case TUNER_PHILIPS_FM1216ME_MK3:
429 case TUNER_PHILIPS_FM1236_MK3: 438 case TUNER_PHILIPS_FM1236_MK3:
430 case TUNER_PHILIPS_FMD1216ME_MK3: 439 case TUNER_PHILIPS_FMD1216ME_MK3:
431 case TUNER_LG_NTSC_TAPE: 440 case TUNER_LG_NTSC_TAPE:
441 case TUNER_PHILIPS_FM1256_IH3:
432 buffer[3] = 0x19; 442 buffer[3] = 0x19;
433 break; 443 break;
434 case TUNER_TNF_5335MF: 444 case TUNER_TNF_5335MF:
435 buffer[3] = 0x11; 445 buffer[3] = 0x11;
436 break; 446 break;
437 case TUNER_PHILIPS_FM1256_IH3:
438 div = (20 * freq) / 16000 + (int)(33.3 * 20); /* IF 33.3 MHz */
439 buffer[3] = 0x19;
440 break;
441 case TUNER_LG_PAL_FM: 447 case TUNER_LG_PAL_FM:
442 buffer[3] = 0xa5; 448 buffer[3] = 0xa5;
443 break; 449 break;
444 case TUNER_MICROTUNE_4049FM5: 450 case TUNER_THOMSON_DTT761X:
445 div = (20 * freq) / 16000 + (int)(33.3 * 20); /* IF 33.3 MHz */ 451 buffer[3] = 0x39;
446 buffer[3] = 0xa4;
447 break; 452 break;
453 case TUNER_MICROTUNE_4049FM5:
448 default: 454 default:
449 buffer[3] = 0xa4; 455 buffer[3] = 0xa4;
450 break; 456 break;
451 } 457 }
458
459 buffer[2] = (params->ranges[0].config & ~TUNER_RATIO_MASK) |
460 TUNER_RATIO_SELECT_50; /* 50 kHz step */
461
462 /* Convert from 1/16 kHz V4L steps to 1/20 MHz (=50 kHz) PLL steps
463 freq * (1 Mhz / 16000 V4L steps) * (20 PLL steps / 1 MHz) =
464 freq * (1/800) */
465 div = (freq + 400) / 800;
466
452 if (params->cb_first_if_lower_freq && div < t->last_div) { 467 if (params->cb_first_if_lower_freq && div < t->last_div) {
453 buffer[0] = buffer[2]; 468 buffer[0] = buffer[2];
454 buffer[1] = buffer[3]; 469 buffer[1] = buffer[3];
@@ -475,6 +490,8 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq)
475 config &= ~TDA9887_PORT1_ACTIVE;*/ 490 config &= ~TDA9887_PORT1_ACTIVE;*/
476 if (params->fm_gain_normal) 491 if (params->fm_gain_normal)
477 config |= TDA9887_GAIN_NORMAL; 492 config |= TDA9887_GAIN_NORMAL;
493 if (params->radio_if == 2)
494 config |= TDA9887_RIF_41_3;
478 i2c_clients_command(c->adapter, TDA9887_SET_CONFIG, &config); 495 i2c_clients_command(c->adapter, TDA9887_SET_CONFIG, &config);
479 } 496 }
480 if (4 != (rc = i2c_master_send(c,buffer,4))) 497 if (4 != (rc = i2c_master_send(c,buffer,4)))
diff --git a/drivers/media/video/tuner-types.c b/drivers/media/video/tuner-types.c
index 53a99b39387f..c6a7934bd5a6 100644
--- a/drivers/media/video/tuner-types.c
+++ b/drivers/media/video/tuner-types.c
@@ -652,6 +652,7 @@ static struct tuner_params tuner_microtune_4049_fm5_params[] = {
652 .port1_invert_for_secam_lc = 1, 652 .port1_invert_for_secam_lc = 1,
653 .default_pll_gating_18 = 1, 653 .default_pll_gating_18 = 1,
654 .fm_gain_normal=1, 654 .fm_gain_normal=1,
655 .radio_if = 1, /* 33.3 MHz */
655 }, 656 },
656}; 657};
657 658
@@ -733,6 +734,7 @@ static struct tuner_params tuner_philips_fm1256_ih3_params[] = {
733 .type = TUNER_PARAM_TYPE_PAL, 734 .type = TUNER_PARAM_TYPE_PAL,
734 .ranges = tuner_fm1236_mk3_ntsc_ranges, 735 .ranges = tuner_fm1236_mk3_ntsc_ranges,
735 .count = ARRAY_SIZE(tuner_fm1236_mk3_ntsc_ranges), 736 .count = ARRAY_SIZE(tuner_fm1236_mk3_ntsc_ranges),
737 .radio_if = 1, /* 33.3 MHz */
736 }, 738 },
737}; 739};
738 740
@@ -859,6 +861,9 @@ static struct tuner_params tuner_thomson_dtt761x_params[] = {
859 .type = TUNER_PARAM_TYPE_NTSC, 861 .type = TUNER_PARAM_TYPE_NTSC,
860 .ranges = tuner_thomson_dtt761x_ntsc_ranges, 862 .ranges = tuner_thomson_dtt761x_ntsc_ranges,
861 .count = ARRAY_SIZE(tuner_thomson_dtt761x_ntsc_ranges), 863 .count = ARRAY_SIZE(tuner_thomson_dtt761x_ntsc_ranges),
864 .has_tda9887 = 1,
865 .fm_gain_normal = 1,
866 .radio_if = 2, /* 41.3 MHz */
862 }, 867 },
863}; 868};
864 869
diff --git a/include/media/tuner-types.h b/include/media/tuner-types.h
index e5ad3fcfe984..b201371416a0 100644
--- a/include/media/tuner-types.h
+++ b/include/media/tuner-types.h
@@ -79,6 +79,10 @@ struct tuner_params {
79 /* Select 18% (or according to datasheet 0%) L standard PLL gating, 79 /* Select 18% (or according to datasheet 0%) L standard PLL gating,
80 vs the driver default of 36%. */ 80 vs the driver default of 36%. */
81 unsigned int default_pll_gating_18:1; 81 unsigned int default_pll_gating_18:1;
82 /* IF to use in radio mode. Tuners with a separate radio IF filter
83 seem to use 10.7, while those without use 33.3 for PAL/SECAM tuners
84 and 41.3 for NTSC tuners. 0 = 10.7, 1 = 33.3, 2 = 41.3 */
85 unsigned int radio_if:2;
82 /* Default tda9887 TOP value in dB for the low band. Default is 0. 86 /* Default tda9887 TOP value in dB for the low band. Default is 0.
83 Range: -16:+15 */ 87 Range: -16:+15 */
84 signed int default_top_low:5; 88 signed int default_top_low:5;
diff --git a/include/media/tuner.h b/include/media/tuner.h
index 160381c72e4b..c03dceb92605 100644
--- a/include/media/tuner.h
+++ b/include/media/tuner.h
@@ -146,6 +146,7 @@ extern int tuner_debug;
146#define TDA9887_AUTOMUTE (1<<18) 146#define TDA9887_AUTOMUTE (1<<18)
147#define TDA9887_GATING_18 (1<<19) 147#define TDA9887_GATING_18 (1<<19)
148#define TDA9887_GAIN_NORMAL (1<<20) 148#define TDA9887_GAIN_NORMAL (1<<20)
149#define TDA9887_RIF_41_3 (1<<21) /* radio IF1 41.3 vs 33.3 */
149 150
150#ifdef __KERNEL__ 151#ifdef __KERNEL__
151 152