diff options
Diffstat (limited to 'drivers/media/video/tuner-simple.c')
-rw-r--r-- | drivers/media/video/tuner-simple.c | 55 |
1 files changed, 36 insertions, 19 deletions
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))) |