diff options
author | Hartmut Hackmann <hartmut.hackmann@t-online.de> | 2007-04-27 11:31:10 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-04-27 14:43:29 -0400 |
commit | 1bb0e8667fab773d6c5a3d7caf506001deaeb7f5 (patch) | |
tree | d74d1dca69859a253e9bab9bb3fda2611abcac50 /drivers/media/dvb | |
parent | 2435be11ae1afb64ac7dfb25e10b6e3037ab0522 (diff) |
V4L/DVB (5311): Tda1004x driver updates
There are the following changes:
- separate configuration of IF and GPIOs.
- set GPIOs before firmware load. This helps to avoid I2C address
collisions.
- if desired invert GPIOs at sleep (automatic return to analog mode of card).
- added 3 tuner configuration bytes to config stuct.
- added i2c gate address to config struct.
- moved _state struct declaration to header file to make it accessible
on board layer.
- added "conf_probed" to the state struct to allow i.e. probing for correct
tuner version.
- changed firmware load mechanism to always:
+ check if already loaded
+ try to boot from eeprom
+ try downlad from host
- corrected name of tda10046 firmware image (backward compatible).
Signed-off-by: Hartmut Hackmann <hartmut.hackmann@t-online.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/dvb')
-rw-r--r-- | drivers/media/dvb/frontends/tda1004x.c | 86 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/tda1004x.h | 49 |
2 files changed, 83 insertions, 52 deletions
diff --git a/drivers/media/dvb/frontends/tda1004x.c b/drivers/media/dvb/frontends/tda1004x.c index f4a9cf9d26d..c47501ae8b0 100644 --- a/drivers/media/dvb/frontends/tda1004x.c +++ b/drivers/media/dvb/frontends/tda1004x.c | |||
@@ -40,20 +40,6 @@ | |||
40 | #include "dvb_frontend.h" | 40 | #include "dvb_frontend.h" |
41 | #include "tda1004x.h" | 41 | #include "tda1004x.h" |
42 | 42 | ||
43 | enum tda1004x_demod { | ||
44 | TDA1004X_DEMOD_TDA10045, | ||
45 | TDA1004X_DEMOD_TDA10046, | ||
46 | }; | ||
47 | |||
48 | struct tda1004x_state { | ||
49 | struct i2c_adapter* i2c; | ||
50 | const struct tda1004x_config* config; | ||
51 | struct dvb_frontend frontend; | ||
52 | |||
53 | /* private demod data */ | ||
54 | enum tda1004x_demod demod_type; | ||
55 | }; | ||
56 | |||
57 | static int debug; | 43 | static int debug; |
58 | #define dprintk(args...) \ | 44 | #define dprintk(args...) \ |
59 | do { \ | 45 | do { \ |
@@ -507,8 +493,13 @@ static int tda10046_fwupload(struct dvb_frontend* fe) | |||
507 | tda1004x_write_byteI(state, TDA1004X_CONFC4, 0x80); | 493 | tda1004x_write_byteI(state, TDA1004X_CONFC4, 0x80); |
508 | } | 494 | } |
509 | tda1004x_write_mask(state, TDA10046H_CONF_TRISTATE1, 1, 0); | 495 | tda1004x_write_mask(state, TDA10046H_CONF_TRISTATE1, 1, 0); |
496 | /* set GPIO 1 and 3 */ | ||
497 | if (state->config->gpio_config != TDA10046_GPTRI) { | ||
498 | tda1004x_write_byteI(state, TDA10046H_CONF_TRISTATE2, 0x33); | ||
499 | tda1004x_write_mask(state, TDA10046H_CONF_POLARITY, 0x0f, state->config->gpio_config &0x0f); | ||
500 | } | ||
510 | /* let the clocks recover from sleep */ | 501 | /* let the clocks recover from sleep */ |
511 | msleep(5); | 502 | msleep(10); |
512 | 503 | ||
513 | /* The PLLs need to be reprogrammed after sleep */ | 504 | /* The PLLs need to be reprogrammed after sleep */ |
514 | tda10046_init_plls(fe); | 505 | tda10046_init_plls(fe); |
@@ -517,25 +508,29 @@ static int tda10046_fwupload(struct dvb_frontend* fe) | |||
517 | if (tda1004x_check_upload_ok(state) == 0) | 508 | if (tda1004x_check_upload_ok(state) == 0) |
518 | return 0; | 509 | return 0; |
519 | 510 | ||
520 | if (state->config->request_firmware != NULL) { | 511 | printk(KERN_INFO "tda1004x: trying to boot from eeprom\n"); |
521 | /* request the firmware, this will block until someone uploads it */ | 512 | tda1004x_write_mask(state, TDA1004X_CONFC4, 4, 4); |
522 | printk(KERN_INFO "tda1004x: waiting for firmware upload...\n"); | 513 | msleep(300); |
523 | ret = state->config->request_firmware(fe, &fw, TDA10046_DEFAULT_FIRMWARE); | 514 | /* don't re-upload unless necessary */ |
515 | if (tda1004x_check_upload_ok(state) == 0) | ||
516 | return 0; | ||
517 | |||
518 | /* request the firmware, this will block until someone uploads it */ | ||
519 | printk(KERN_INFO "tda1004x: waiting for firmware upload...\n"); | ||
520 | ret = state->config->request_firmware(fe, &fw, TDA10046_DEFAULT_FIRMWARE); | ||
521 | if (ret) { | ||
522 | /* remain compatible to old bug: try to load with tda10045 image name */ | ||
523 | ret = state->config->request_firmware(fe, &fw, TDA10045_DEFAULT_FIRMWARE); | ||
524 | if (ret) { | 524 | if (ret) { |
525 | printk(KERN_ERR "tda1004x: no firmware upload (timeout or file not found?)\n"); | 525 | printk(KERN_ERR "tda1004x: no firmware upload (timeout or file not found?)\n"); |
526 | return ret; | 526 | return ret; |
527 | } | 527 | } else |
528 | tda1004x_write_mask(state, TDA1004X_CONFC4, 8, 8); // going to boot from HOST | 528 | printk(KERN_INFO "tda1004x: please rename the firmware file to %s\n", |
529 | ret = tda1004x_do_upload(state, fw->data, fw->size, TDA10046H_CODE_CPT, TDA10046H_CODE_IN); | 529 | TDA10046_DEFAULT_FIRMWARE); |
530 | release_firmware(fw); | ||
531 | if (ret) | ||
532 | return ret; | ||
533 | } else { | ||
534 | /* boot from firmware eeprom */ | ||
535 | printk(KERN_INFO "tda1004x: booting from eeprom\n"); | ||
536 | tda1004x_write_mask(state, TDA1004X_CONFC4, 4, 4); | ||
537 | msleep(300); | ||
538 | } | 530 | } |
531 | tda1004x_write_mask(state, TDA1004X_CONFC4, 8, 8); // going to boot from HOST | ||
532 | ret = tda1004x_do_upload(state, fw->data, fw->size, TDA10046H_CODE_CPT, TDA10046H_CODE_IN); | ||
533 | release_firmware(fw); | ||
539 | return tda1004x_check_upload_ok(state); | 534 | return tda1004x_check_upload_ok(state); |
540 | } | 535 | } |
541 | 536 | ||
@@ -638,37 +633,25 @@ static int tda10046_init(struct dvb_frontend* fe) | |||
638 | switch (state->config->agc_config) { | 633 | switch (state->config->agc_config) { |
639 | case TDA10046_AGC_DEFAULT: | 634 | case TDA10046_AGC_DEFAULT: |
640 | tda1004x_write_byteI(state, TDA10046H_AGC_CONF, 0x00); // AGC setup | 635 | tda1004x_write_byteI(state, TDA10046H_AGC_CONF, 0x00); // AGC setup |
641 | tda1004x_write_byteI(state, TDA10046H_CONF_POLARITY, 0x60); // set AGC polarities | 636 | tda1004x_write_mask(state, TDA10046H_CONF_POLARITY, 0xf0, 0x60); // set AGC polarities |
642 | break; | 637 | break; |
643 | case TDA10046_AGC_IFO_AUTO_NEG: | 638 | case TDA10046_AGC_IFO_AUTO_NEG: |
644 | tda1004x_write_byteI(state, TDA10046H_AGC_CONF, 0x0a); // AGC setup | 639 | tda1004x_write_byteI(state, TDA10046H_AGC_CONF, 0x0a); // AGC setup |
645 | tda1004x_write_byteI(state, TDA10046H_CONF_POLARITY, 0x60); // set AGC polarities | 640 | tda1004x_write_mask(state, TDA10046H_CONF_POLARITY, 0xf0, 0x60); // set AGC polarities |
646 | break; | 641 | break; |
647 | case TDA10046_AGC_IFO_AUTO_POS: | 642 | case TDA10046_AGC_IFO_AUTO_POS: |
648 | tda1004x_write_byteI(state, TDA10046H_AGC_CONF, 0x0a); // AGC setup | 643 | tda1004x_write_byteI(state, TDA10046H_AGC_CONF, 0x0a); // AGC setup |
649 | tda1004x_write_byteI(state, TDA10046H_CONF_POLARITY, 0x00); // set AGC polarities | 644 | tda1004x_write_mask(state, TDA10046H_CONF_POLARITY, 0xf0, 0x00); // set AGC polarities |
650 | break; | 645 | break; |
651 | case TDA10046_AGC_TDA827X_GP11: | 646 | case TDA10046_AGC_TDA827X: |
652 | tda1004x_write_byteI(state, TDA10046H_AGC_CONF, 0x02); // AGC setup | 647 | tda1004x_write_byteI(state, TDA10046H_AGC_CONF, 0x02); // AGC setup |
653 | tda1004x_write_byteI(state, TDA10046H_AGC_THR, 0x70); // AGC Threshold | 648 | tda1004x_write_byteI(state, TDA10046H_AGC_THR, 0x70); // AGC Threshold |
654 | tda1004x_write_byteI(state, TDA10046H_AGC_RENORM, 0x08); // Gain Renormalize | 649 | tda1004x_write_byteI(state, TDA10046H_AGC_RENORM, 0x08); // Gain Renormalize |
655 | tda1004x_write_byteI(state, TDA10046H_CONF_POLARITY, 0x6a); // set AGC polarities | 650 | tda1004x_write_mask(state, TDA10046H_CONF_POLARITY, 0xf0, 0x60); // set AGC polarities |
656 | break; | ||
657 | case TDA10046_AGC_TDA827X_GP00: | ||
658 | tda1004x_write_byteI(state, TDA10046H_AGC_CONF, 0x02); // AGC setup | ||
659 | tda1004x_write_byteI(state, TDA10046H_AGC_THR, 0x70); // AGC Threshold | ||
660 | tda1004x_write_byteI(state, TDA10046H_AGC_RENORM, 0x08); // Gain Renormalize | ||
661 | tda1004x_write_byteI(state, TDA10046H_CONF_POLARITY, 0x60); // set AGC polarities | ||
662 | break; | ||
663 | case TDA10046_AGC_TDA827X_GP01: | ||
664 | tda1004x_write_byteI(state, TDA10046H_AGC_CONF, 0x02); // AGC setup | ||
665 | tda1004x_write_byteI(state, TDA10046H_AGC_THR, 0x70); // AGC Threshold | ||
666 | tda1004x_write_byteI(state, TDA10046H_AGC_RENORM, 0x08); // Gain Renormalize | ||
667 | tda1004x_write_byteI(state, TDA10046H_CONF_POLARITY, 0x62); // set AGC polarities | ||
668 | break; | 651 | break; |
669 | } | 652 | } |
670 | tda1004x_write_byteI(state, TDA1004X_CONFADC2, 0x38); | 653 | tda1004x_write_byteI(state, TDA1004X_CONFADC2, 0x38); |
671 | tda1004x_write_byteI(state, TDA10046H_CONF_TRISTATE1, 0x61); // Turn both AGC outputs on | 654 | tda1004x_write_byteI(state, TDA10046H_CONF_TRISTATE1, 0x79); // Turn IF AGC output on |
672 | tda1004x_write_byteI(state, TDA10046H_AGC_TUN_MIN, 0); // } | 655 | tda1004x_write_byteI(state, TDA10046H_AGC_TUN_MIN, 0); // } |
673 | tda1004x_write_byteI(state, TDA10046H_AGC_TUN_MAX, 0xff); // } AGC min/max values | 656 | tda1004x_write_byteI(state, TDA10046H_AGC_TUN_MAX, 0xff); // } AGC min/max values |
674 | tda1004x_write_byteI(state, TDA10046H_AGC_IF_MIN, 0); // } | 657 | tda1004x_write_byteI(state, TDA10046H_AGC_IF_MIN, 0); // } |
@@ -1165,6 +1148,7 @@ static int tda1004x_read_ber(struct dvb_frontend* fe, u32* ber) | |||
1165 | static int tda1004x_sleep(struct dvb_frontend* fe) | 1148 | static int tda1004x_sleep(struct dvb_frontend* fe) |
1166 | { | 1149 | { |
1167 | struct tda1004x_state* state = fe->demodulator_priv; | 1150 | struct tda1004x_state* state = fe->demodulator_priv; |
1151 | int gpio_conf; | ||
1168 | 1152 | ||
1169 | switch (state->demod_type) { | 1153 | switch (state->demod_type) { |
1170 | case TDA1004X_DEMOD_TDA10045: | 1154 | case TDA1004X_DEMOD_TDA10045: |
@@ -1174,6 +1158,12 @@ static int tda1004x_sleep(struct dvb_frontend* fe) | |||
1174 | case TDA1004X_DEMOD_TDA10046: | 1158 | case TDA1004X_DEMOD_TDA10046: |
1175 | /* set outputs to tristate */ | 1159 | /* set outputs to tristate */ |
1176 | tda1004x_write_byteI(state, TDA10046H_CONF_TRISTATE1, 0xff); | 1160 | tda1004x_write_byteI(state, TDA10046H_CONF_TRISTATE1, 0xff); |
1161 | /* invert GPIO 1 and 3 if desired*/ | ||
1162 | gpio_conf = state->config->gpio_config; | ||
1163 | if (gpio_conf >= TDA10046_GP00_I) | ||
1164 | tda1004x_write_mask(state, TDA10046H_CONF_POLARITY, 0x0f, | ||
1165 | (gpio_conf & 0x0f) ^ 0x0a); | ||
1166 | |||
1177 | tda1004x_write_mask(state, TDA1004X_CONFC4, 1, 1); | 1167 | tda1004x_write_mask(state, TDA1004X_CONFC4, 1, 1); |
1178 | break; | 1168 | break; |
1179 | } | 1169 | } |
diff --git a/drivers/media/dvb/frontends/tda1004x.h b/drivers/media/dvb/frontends/tda1004x.h index ec502d71b83..886db3f75d5 100644 --- a/drivers/media/dvb/frontends/tda1004x.h +++ b/drivers/media/dvb/frontends/tda1004x.h | |||
@@ -35,9 +35,23 @@ enum tda10046_agc { | |||
35 | TDA10046_AGC_DEFAULT, /* original configuration */ | 35 | TDA10046_AGC_DEFAULT, /* original configuration */ |
36 | TDA10046_AGC_IFO_AUTO_NEG, /* IF AGC only, automatic, negtive */ | 36 | TDA10046_AGC_IFO_AUTO_NEG, /* IF AGC only, automatic, negtive */ |
37 | TDA10046_AGC_IFO_AUTO_POS, /* IF AGC only, automatic, positive */ | 37 | TDA10046_AGC_IFO_AUTO_POS, /* IF AGC only, automatic, positive */ |
38 | TDA10046_AGC_TDA827X_GP11, /* IF AGC only, special setup for tda827x */ | 38 | TDA10046_AGC_TDA827X, /* IF AGC only, special setup for tda827x */ |
39 | TDA10046_AGC_TDA827X_GP00, /* same as above, but GPIOs 0 */ | 39 | }; |
40 | TDA10046_AGC_TDA827X_GP01, /* same as above, but GPIO3=0 GPIO1=1*/ | 40 | |
41 | /* Many (hybrid) boards use GPIO 1 and 3 | ||
42 | GPIO1 analog - dvb switch | ||
43 | GPIO3 firmware eeprom address switch | ||
44 | */ | ||
45 | enum tda10046_gpio { | ||
46 | TDA10046_GPTRI = 0x00, /* All GPIOs tristate */ | ||
47 | TDA10046_GP00 = 0x40, /* GPIO3=0, GPIO1=0 */ | ||
48 | TDA10046_GP01 = 0x42, /* GPIO3=0, GPIO1=1 */ | ||
49 | TDA10046_GP10 = 0x48, /* GPIO3=1, GPIO1=0 */ | ||
50 | TDA10046_GP11 = 0x4a, /* GPIO3=1, GPIO1=1 */ | ||
51 | TDA10046_GP00_I = 0x80, /* GPIO3=0, GPIO1=0, invert in sleep mode*/ | ||
52 | TDA10046_GP01_I = 0x82, /* GPIO3=0, GPIO1=1, invert in sleep mode */ | ||
53 | TDA10046_GP10_I = 0x88, /* GPIO3=1, GPIO1=0, invert in sleep mode */ | ||
54 | TDA10046_GP11_I = 0x8a, /* GPIO3=1, GPIO1=1, invert in sleep mode */ | ||
41 | }; | 55 | }; |
42 | 56 | ||
43 | enum tda10046_if { | 57 | enum tda10046_if { |
@@ -67,11 +81,38 @@ struct tda1004x_config | |||
67 | /* AGC configuration */ | 81 | /* AGC configuration */ |
68 | enum tda10046_agc agc_config; | 82 | enum tda10046_agc agc_config; |
69 | 83 | ||
84 | /* setting of GPIO1 and 3 */ | ||
85 | enum tda10046_gpio gpio_config; | ||
86 | |||
87 | /* slave address and configuration of the tuner */ | ||
88 | u8 tuner_address; | ||
89 | u8 tuner_config; | ||
90 | u8 antenna_switch; | ||
91 | |||
92 | /* if the board uses another I2c Bridge (tda8290), its address */ | ||
93 | u8 i2c_gate; | ||
94 | |||
70 | /* request firmware for device */ | 95 | /* request firmware for device */ |
71 | /* set this to NULL if the card has a firmware EEPROM */ | ||
72 | int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name); | 96 | int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name); |
73 | }; | 97 | }; |
74 | 98 | ||
99 | enum tda1004x_demod { | ||
100 | TDA1004X_DEMOD_TDA10045, | ||
101 | TDA1004X_DEMOD_TDA10046, | ||
102 | }; | ||
103 | |||
104 | struct tda1004x_state { | ||
105 | struct i2c_adapter* i2c; | ||
106 | const struct tda1004x_config* config; | ||
107 | struct dvb_frontend frontend; | ||
108 | |||
109 | /* this allows to store probed board information */ | ||
110 | int conf_probed; | ||
111 | |||
112 | /* private demod data */ | ||
113 | enum tda1004x_demod demod_type; | ||
114 | }; | ||
115 | |||
75 | #if defined(CONFIG_DVB_TDA1004X) || (defined(CONFIG_DVB_TDA1004X_MODULE) && defined(MODULE)) | 116 | #if defined(CONFIG_DVB_TDA1004X) || (defined(CONFIG_DVB_TDA1004X_MODULE) && defined(MODULE)) |
76 | extern struct dvb_frontend* tda10045_attach(const struct tda1004x_config* config, | 117 | extern struct dvb_frontend* tda10045_attach(const struct tda1004x_config* config, |
77 | struct i2c_adapter* i2c); | 118 | struct i2c_adapter* i2c); |