aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/frontends/tda1004x.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb/frontends/tda1004x.c')
-rw-r--r--drivers/media/dvb/frontends/tda1004x.c141
1 files changed, 92 insertions, 49 deletions
diff --git a/drivers/media/dvb/frontends/tda1004x.c b/drivers/media/dvb/frontends/tda1004x.c
index dd02aff467fe..c63e9a5084eb 100644
--- a/drivers/media/dvb/frontends/tda1004x.c
+++ b/drivers/media/dvb/frontends/tda1004x.c
@@ -23,7 +23,8 @@
23 * This driver needs external firmware. Please use the commands 23 * This driver needs external firmware. Please use the commands
24 * "<kerneldir>/Documentation/dvb/get_dvb_firmware tda10045", 24 * "<kerneldir>/Documentation/dvb/get_dvb_firmware tda10045",
25 * "<kerneldir>/Documentation/dvb/get_dvb_firmware tda10046" to 25 * "<kerneldir>/Documentation/dvb/get_dvb_firmware tda10046" to
26 * download/extract them, and then copy them to /usr/lib/hotplug/firmware. 26 * download/extract them, and then copy them to /usr/lib/hotplug/firmware
27 * or /lib/firmware (depending on configuration of firmware hotplug).
27 */ 28 */
28#define TDA10045_DEFAULT_FIRMWARE "dvb-fe-tda10045.fw" 29#define TDA10045_DEFAULT_FIRMWARE "dvb-fe-tda10045.fw"
29#define TDA10046_DEFAULT_FIRMWARE "dvb-fe-tda10046.fw" 30#define TDA10046_DEFAULT_FIRMWARE "dvb-fe-tda10046.fw"
@@ -271,32 +272,57 @@ static int tda10045h_set_bandwidth(struct tda1004x_state *state,
271static int tda10046h_set_bandwidth(struct tda1004x_state *state, 272static int tda10046h_set_bandwidth(struct tda1004x_state *state,
272 fe_bandwidth_t bandwidth) 273 fe_bandwidth_t bandwidth)
273{ 274{
274 static u8 bandwidth_6mhz[] = { 0x80, 0x15, 0xfe, 0xab, 0x8e }; 275 static u8 bandwidth_6mhz_53M[] = { 0x7b, 0x2e, 0x11, 0xf0, 0xd2 };
275 static u8 bandwidth_7mhz[] = { 0x6e, 0x02, 0x53, 0xc8, 0x25 }; 276 static u8 bandwidth_7mhz_53M[] = { 0x6a, 0x02, 0x6a, 0x43, 0x9f };
276 static u8 bandwidth_8mhz[] = { 0x60, 0x12, 0xa8, 0xe4, 0xbd }; 277 static u8 bandwidth_8mhz_53M[] = { 0x5c, 0x32, 0xc2, 0x96, 0x6d };
277 278
279 static u8 bandwidth_6mhz_48M[] = { 0x70, 0x02, 0x49, 0x24, 0x92 };
280 static u8 bandwidth_7mhz_48M[] = { 0x60, 0x02, 0xaa, 0xaa, 0xab };
281 static u8 bandwidth_8mhz_48M[] = { 0x54, 0x03, 0x0c, 0x30, 0xc3 };
282 int tda10046_clk53m;
283
284 if ((state->config->if_freq == TDA10046_FREQ_045) ||
285 (state->config->if_freq == TDA10046_FREQ_052))
286 tda10046_clk53m = 0;
287 else
288 tda10046_clk53m = 1;
278 switch (bandwidth) { 289 switch (bandwidth) {
279 case BANDWIDTH_6_MHZ: 290 case BANDWIDTH_6_MHZ:
280 tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_6mhz, sizeof(bandwidth_6mhz)); 291 if (tda10046_clk53m)
292 tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_6mhz_53M,
293 sizeof(bandwidth_6mhz_53M));
294 else
295 tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_6mhz_48M,
296 sizeof(bandwidth_6mhz_48M));
281 if (state->config->if_freq == TDA10046_FREQ_045) { 297 if (state->config->if_freq == TDA10046_FREQ_045) {
282 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x09); 298 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x0a);
283 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x4f); 299 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0xab);
284 } 300 }
285 break; 301 break;
286 302
287 case BANDWIDTH_7_MHZ: 303 case BANDWIDTH_7_MHZ:
288 tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_7mhz, sizeof(bandwidth_7mhz)); 304 if (tda10046_clk53m)
305 tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_7mhz_53M,
306 sizeof(bandwidth_7mhz_53M));
307 else
308 tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_7mhz_48M,
309 sizeof(bandwidth_7mhz_48M));
289 if (state->config->if_freq == TDA10046_FREQ_045) { 310 if (state->config->if_freq == TDA10046_FREQ_045) {
290 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x0a); 311 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x0c);
291 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x79); 312 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x00);
292 } 313 }
293 break; 314 break;
294 315
295 case BANDWIDTH_8_MHZ: 316 case BANDWIDTH_8_MHZ:
296 tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_8mhz, sizeof(bandwidth_8mhz)); 317 if (tda10046_clk53m)
318 tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_8mhz_53M,
319 sizeof(bandwidth_8mhz_53M));
320 else
321 tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_8mhz_48M,
322 sizeof(bandwidth_8mhz_48M));
297 if (state->config->if_freq == TDA10046_FREQ_045) { 323 if (state->config->if_freq == TDA10046_FREQ_045) {
298 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x0b); 324 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x0d);
299 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0xa3); 325 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x55);
300 } 326 }
301 break; 327 break;
302 328
@@ -418,9 +444,22 @@ static int tda10045_fwupload(struct dvb_frontend* fe)
418static void tda10046_init_plls(struct dvb_frontend* fe) 444static void tda10046_init_plls(struct dvb_frontend* fe)
419{ 445{
420 struct tda1004x_state* state = fe->demodulator_priv; 446 struct tda1004x_state* state = fe->demodulator_priv;
447 int tda10046_clk53m;
448
449 if ((state->config->if_freq == TDA10046_FREQ_045) ||
450 (state->config->if_freq == TDA10046_FREQ_052))
451 tda10046_clk53m = 0;
452 else
453 tda10046_clk53m = 1;
421 454
422 tda1004x_write_byteI(state, TDA10046H_CONFPLL1, 0xf0); 455 tda1004x_write_byteI(state, TDA10046H_CONFPLL1, 0xf0);
423 tda1004x_write_byteI(state, TDA10046H_CONFPLL2, 0x0a); // PLL M = 10 456 if(tda10046_clk53m) {
457 printk(KERN_INFO "tda1004x: setting up plls for 53MHz sampling clock\n");
458 tda1004x_write_byteI(state, TDA10046H_CONFPLL2, 0x08); // PLL M = 8
459 } else {
460 printk(KERN_INFO "tda1004x: setting up plls for 48MHz sampling clock\n");
461 tda1004x_write_byteI(state, TDA10046H_CONFPLL2, 0x03); // PLL M = 3
462 }
424 if (state->config->xtal_freq == TDA10046_XTAL_4M ) { 463 if (state->config->xtal_freq == TDA10046_XTAL_4M ) {
425 dprintk("%s: setting up PLLs for a 4 MHz Xtal\n", __FUNCTION__); 464 dprintk("%s: setting up PLLs for a 4 MHz Xtal\n", __FUNCTION__);
426 tda1004x_write_byteI(state, TDA10046H_CONFPLL3, 0); // PLL P = N = 0 465 tda1004x_write_byteI(state, TDA10046H_CONFPLL3, 0); // PLL P = N = 0
@@ -428,26 +467,32 @@ static void tda10046_init_plls(struct dvb_frontend* fe)
428 dprintk("%s: setting up PLLs for a 16 MHz Xtal\n", __FUNCTION__); 467 dprintk("%s: setting up PLLs for a 16 MHz Xtal\n", __FUNCTION__);
429 tda1004x_write_byteI(state, TDA10046H_CONFPLL3, 3); // PLL P = 0, N = 3 468 tda1004x_write_byteI(state, TDA10046H_CONFPLL3, 3); // PLL P = 0, N = 3
430 } 469 }
431 tda1004x_write_byteI(state, TDA10046H_FREQ_OFFSET, 99); 470 if(tda10046_clk53m)
471 tda1004x_write_byteI(state, TDA10046H_FREQ_OFFSET, 0x67);
472 else
473 tda1004x_write_byteI(state, TDA10046H_FREQ_OFFSET, 0x72);
474 /* Note clock frequency is handled implicitly */
432 switch (state->config->if_freq) { 475 switch (state->config->if_freq) {
433 case TDA10046_FREQ_3617:
434 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0xd4);
435 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x2c);
436 break;
437 case TDA10046_FREQ_3613:
438 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0xd4);
439 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x13);
440 break;
441 case TDA10046_FREQ_045: 476 case TDA10046_FREQ_045:
442 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x0b); 477 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x0c);
443 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0xa3); 478 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x00);
444 break; 479 break;
445 case TDA10046_FREQ_052: 480 case TDA10046_FREQ_052:
446 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x0c); 481 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x0d);
447 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x06); 482 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0xc7);
483 break;
484 case TDA10046_FREQ_3617:
485 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0xd7);
486 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x59);
487 break;
488 case TDA10046_FREQ_3613:
489 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0xd7);
490 tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x3f);
448 break; 491 break;
449 } 492 }
450 tda10046h_set_bandwidth(state, BANDWIDTH_8_MHZ); // default bandwidth 8 MHz 493 tda10046h_set_bandwidth(state, BANDWIDTH_8_MHZ); // default bandwidth 8 MHz
494 /* let the PLLs settle */
495 msleep(120);
451} 496}
452 497
453static int tda10046_fwupload(struct dvb_frontend* fe) 498static int tda10046_fwupload(struct dvb_frontend* fe)
@@ -462,13 +507,13 @@ static int tda10046_fwupload(struct dvb_frontend* fe)
462 /* let the clocks recover from sleep */ 507 /* let the clocks recover from sleep */
463 msleep(5); 508 msleep(5);
464 509
510 /* The PLLs need to be reprogrammed after sleep */
511 tda10046_init_plls(fe);
512
465 /* don't re-upload unless necessary */ 513 /* don't re-upload unless necessary */
466 if (tda1004x_check_upload_ok(state) == 0) 514 if (tda1004x_check_upload_ok(state) == 0)
467 return 0; 515 return 0;
468 516
469 /* set parameters */
470 tda10046_init_plls(fe);
471
472 if (state->config->request_firmware != NULL) { 517 if (state->config->request_firmware != NULL) {
473 /* request the firmware, this will block until someone uploads it */ 518 /* request the firmware, this will block until someone uploads it */
474 printk(KERN_INFO "tda1004x: waiting for firmware upload...\n"); 519 printk(KERN_INFO "tda1004x: waiting for firmware upload...\n");
@@ -484,7 +529,6 @@ static int tda10046_fwupload(struct dvb_frontend* fe)
484 return ret; 529 return ret;
485 } else { 530 } else {
486 /* boot from firmware eeprom */ 531 /* boot from firmware eeprom */
487 /* Hac Note: we might need to do some GPIO Magic here */
488 printk(KERN_INFO "tda1004x: booting from eeprom\n"); 532 printk(KERN_INFO "tda1004x: booting from eeprom\n");
489 tda1004x_write_mask(state, TDA1004X_CONFC4, 4, 4); 533 tda1004x_write_mask(state, TDA1004X_CONFC4, 4, 4);
490 msleep(300); 534 msleep(300);
@@ -606,10 +650,9 @@ static int tda10046_init(struct dvb_frontend* fe)
606 650
607 // tda setup 651 // tda setup
608 tda1004x_write_mask(state, TDA1004X_CONFC4, 0x20, 0); // disable DSP watchdog timer 652 tda1004x_write_mask(state, TDA1004X_CONFC4, 0x20, 0); // disable DSP watchdog timer
609 tda1004x_write_byteI(state, TDA1004X_AUTO, 7); // select HP stream 653 tda1004x_write_byteI(state, TDA1004X_AUTO, 0x87); // 100 ppm crystal, select HP stream
610 tda1004x_write_byteI(state, TDA1004X_CONFC1, 8); // disable pulse killer 654 tda1004x_write_byteI(state, TDA1004X_CONFC1, 8); // disable pulse killer
611 655
612 tda10046_init_plls(fe);
613 switch (state->config->agc_config) { 656 switch (state->config->agc_config) {
614 case TDA10046_AGC_DEFAULT: 657 case TDA10046_AGC_DEFAULT:
615 tda1004x_write_byteI(state, TDA10046H_AGC_CONF, 0x00); // AGC setup 658 tda1004x_write_byteI(state, TDA10046H_AGC_CONF, 0x00); // AGC setup
@@ -626,25 +669,22 @@ static int tda10046_init(struct dvb_frontend* fe)
626 case TDA10046_AGC_TDA827X: 669 case TDA10046_AGC_TDA827X:
627 tda1004x_write_byteI(state, TDA10046H_AGC_CONF, 0x02); // AGC setup 670 tda1004x_write_byteI(state, TDA10046H_AGC_CONF, 0x02); // AGC setup
628 tda1004x_write_byteI(state, TDA10046H_AGC_THR, 0x70); // AGC Threshold 671 tda1004x_write_byteI(state, TDA10046H_AGC_THR, 0x70); // AGC Threshold
629 tda1004x_write_byteI(state, TDA10046H_AGC_RENORM, 0x0E); // Gain Renormalize 672 tda1004x_write_byteI(state, TDA10046H_AGC_RENORM, 0x08); // Gain Renormalize
630 tda1004x_write_byteI(state, TDA10046H_CONF_POLARITY, 0x60); // set AGC polarities 673 tda1004x_write_byteI(state, TDA10046H_CONF_POLARITY, 0x6a); // set AGC polarities
631 break; 674 break;
632 } 675 }
676 tda1004x_write_byteI(state, TDA1004X_CONFADC2, 0x38);
633 tda1004x_write_byteI(state, TDA10046H_CONF_TRISTATE1, 0x61); // Turn both AGC outputs on 677 tda1004x_write_byteI(state, TDA10046H_CONF_TRISTATE1, 0x61); // Turn both AGC outputs on
634 tda1004x_write_byteI(state, TDA10046H_AGC_TUN_MIN, 0); // } 678 tda1004x_write_byteI(state, TDA10046H_AGC_TUN_MIN, 0); // }
635 tda1004x_write_byteI(state, TDA10046H_AGC_TUN_MAX, 0xff); // } AGC min/max values 679 tda1004x_write_byteI(state, TDA10046H_AGC_TUN_MAX, 0xff); // } AGC min/max values
636 tda1004x_write_byteI(state, TDA10046H_AGC_IF_MIN, 0); // } 680 tda1004x_write_byteI(state, TDA10046H_AGC_IF_MIN, 0); // }
637 tda1004x_write_byteI(state, TDA10046H_AGC_IF_MAX, 0xff); // } 681 tda1004x_write_byteI(state, TDA10046H_AGC_IF_MAX, 0xff); // }
638 tda1004x_write_byteI(state, TDA10046H_AGC_GAINS, 1); // IF gain 2, TUN gain 1 682 tda1004x_write_byteI(state, TDA10046H_AGC_GAINS, 0x12); // IF gain 2, TUN gain 1
639 tda1004x_write_byteI(state, TDA10046H_CVBER_CTRL, 0x1a); // 10^6 VBER measurement bits 683 tda1004x_write_byteI(state, TDA10046H_CVBER_CTRL, 0x1a); // 10^6 VBER measurement bits
640 tda1004x_write_byteI(state, TDA1004X_CONF_TS1, 7); // MPEG2 interface config 684 tda1004x_write_byteI(state, TDA1004X_CONF_TS1, 7); // MPEG2 interface config
641 tda1004x_write_byteI(state, TDA1004X_CONF_TS2, 0xc0); // MPEG2 interface config 685 tda1004x_write_byteI(state, TDA1004X_CONF_TS2, 0xc0); // MPEG2 interface config
642 tda1004x_write_mask(state, 0x3a, 0x80, state->config->invert_oclk << 7); 686 tda1004x_write_mask(state, 0x3a, 0x80, state->config->invert_oclk << 7);
643 687
644 tda1004x_write_byteI(state, TDA10046H_CONF_TRISTATE2, 0xe1); // tristate setup
645 tda1004x_write_byteI(state, TDA10046H_GPIO_OUT_SEL, 0xcc); // GPIO output config
646 tda1004x_write_byteI(state, TDA10046H_GPIO_SELECT, 8); // GPIO select
647
648 state->initialised = 1; 688 state->initialised = 1;
649 return 0; 689 return 0;
650} 690}
@@ -686,9 +726,9 @@ static int tda1004x_set_fe(struct dvb_frontend* fe,
686 726
687 // Set standard params.. or put them to auto 727 // Set standard params.. or put them to auto
688 if ((fe_params->u.ofdm.code_rate_HP == FEC_AUTO) || 728 if ((fe_params->u.ofdm.code_rate_HP == FEC_AUTO) ||
689 (fe_params->u.ofdm.code_rate_LP == FEC_AUTO) || 729 (fe_params->u.ofdm.code_rate_LP == FEC_AUTO) ||
690 (fe_params->u.ofdm.constellation == QAM_AUTO) || 730 (fe_params->u.ofdm.constellation == QAM_AUTO) ||
691 (fe_params->u.ofdm.hierarchy_information == HIERARCHY_AUTO)) { 731 (fe_params->u.ofdm.hierarchy_information == HIERARCHY_AUTO)) {
692 tda1004x_write_mask(state, TDA1004X_AUTO, 1, 1); // enable auto 732 tda1004x_write_mask(state, TDA1004X_AUTO, 1, 1); // enable auto
693 tda1004x_write_mask(state, TDA1004X_IN_CONF1, 0x03, 0); // turn off constellation bits 733 tda1004x_write_mask(state, TDA1004X_IN_CONF1, 0x03, 0); // turn off constellation bits
694 tda1004x_write_mask(state, TDA1004X_IN_CONF1, 0x60, 0); // turn off hierarchy bits 734 tda1004x_write_mask(state, TDA1004X_IN_CONF1, 0x60, 0); // turn off hierarchy bits
@@ -851,6 +891,7 @@ static int tda1004x_set_fe(struct dvb_frontend* fe,
851static int tda1004x_get_fe(struct dvb_frontend* fe, struct dvb_frontend_parameters *fe_params) 891static int tda1004x_get_fe(struct dvb_frontend* fe, struct dvb_frontend_parameters *fe_params)
852{ 892{
853 struct tda1004x_state* state = fe->demodulator_priv; 893 struct tda1004x_state* state = fe->demodulator_priv;
894
854 dprintk("%s\n", __FUNCTION__); 895 dprintk("%s\n", __FUNCTION__);
855 896
856 // inversion status 897 // inversion status
@@ -875,16 +916,18 @@ static int tda1004x_get_fe(struct dvb_frontend* fe, struct dvb_frontend_paramete
875 break; 916 break;
876 } 917 }
877 break; 918 break;
878
879 case TDA1004X_DEMOD_TDA10046: 919 case TDA1004X_DEMOD_TDA10046:
880 switch (tda1004x_read_byte(state, TDA10046H_TIME_WREF1)) { 920 switch (tda1004x_read_byte(state, TDA10046H_TIME_WREF1)) {
881 case 0x60: 921 case 0x5c:
922 case 0x54:
882 fe_params->u.ofdm.bandwidth = BANDWIDTH_8_MHZ; 923 fe_params->u.ofdm.bandwidth = BANDWIDTH_8_MHZ;
883 break; 924 break;
884 case 0x6e: 925 case 0x6a:
926 case 0x60:
885 fe_params->u.ofdm.bandwidth = BANDWIDTH_7_MHZ; 927 fe_params->u.ofdm.bandwidth = BANDWIDTH_7_MHZ;
886 break; 928 break;
887 case 0x80: 929 case 0x7b:
930 case 0x70:
888 fe_params->u.ofdm.bandwidth = BANDWIDTH_6_MHZ; 931 fe_params->u.ofdm.bandwidth = BANDWIDTH_6_MHZ;
889 break; 932 break;
890 } 933 }