aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/dvb/get_dvb_firmware4
-rw-r--r--drivers/media/dvb/frontends/tda1004x.c36
2 files changed, 36 insertions, 4 deletions
diff --git a/Documentation/dvb/get_dvb_firmware b/Documentation/dvb/get_dvb_firmware
index 3ffdcb394299..a750f0101d9d 100644
--- a/Documentation/dvb/get_dvb_firmware
+++ b/Documentation/dvb/get_dvb_firmware
@@ -107,7 +107,7 @@ sub tda10045 {
107sub tda10046 { 107sub tda10046 {
108 my $sourcefile = "tt_budget_217g.zip"; 108 my $sourcefile = "tt_budget_217g.zip";
109 my $url = "http://www.technotrend.de/new/217g/$sourcefile"; 109 my $url = "http://www.technotrend.de/new/217g/$sourcefile";
110 my $hash = "a25b579e37109af60f4a36c37893957c"; 110 my $hash = "6a7e1e2f2644b162ff0502367553c72d";
111 my $outfile = "dvb-fe-tda10046.fw"; 111 my $outfile = "dvb-fe-tda10046.fw";
112 my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); 112 my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
113 113
@@ -115,7 +115,7 @@ sub tda10046 {
115 115
116 wgetfile($sourcefile, $url); 116 wgetfile($sourcefile, $url);
117 unzip($sourcefile, $tmpdir); 117 unzip($sourcefile, $tmpdir);
118 extract("$tmpdir/software/OEM/PCI/App/ttlcdacc.dll", 0x3f731, 24479, "$tmpdir/fwtmp"); 118 extract("$tmpdir/software/OEM/PCI/App/ttlcdacc.dll", 0x3f731, 24478, "$tmpdir/fwtmp");
119 verify("$tmpdir/fwtmp", $hash); 119 verify("$tmpdir/fwtmp", $hash);
120 copy("$tmpdir/fwtmp", $outfile); 120 copy("$tmpdir/fwtmp", $outfile);
121 121
diff --git a/drivers/media/dvb/frontends/tda1004x.c b/drivers/media/dvb/frontends/tda1004x.c
index ecfa8c7a9784..0beb370792ae 100644
--- a/drivers/media/dvb/frontends/tda1004x.c
+++ b/drivers/media/dvb/frontends/tda1004x.c
@@ -49,6 +49,7 @@ struct tda1004x_state {
49 /* private demod data */ 49 /* private demod data */
50 u8 initialised; 50 u8 initialised;
51 enum tda1004x_demod demod_type; 51 enum tda1004x_demod demod_type;
52 u8 fw_version;
52}; 53};
53 54
54 55
@@ -380,6 +381,25 @@ static int tda10045_fwupload(struct dvb_frontend* fe)
380 return tda1004x_check_upload_ok(state, 0x2c); 381 return tda1004x_check_upload_ok(state, 0x2c);
381} 382}
382 383
384static int tda10046_get_fw_version(struct tda1004x_state *state,
385 const struct firmware *fw)
386{
387 const unsigned char pattern[] = { 0x67, 0x00, 0x50, 0x62, 0x5e, 0x18, 0x67 };
388 unsigned int i;
389
390 /* area guessed from firmware v20, v21 and v25 */
391 for (i = 0x660; i < 0x700; i++) {
392 if (!memcmp(&fw->data[i], pattern, sizeof(pattern))) {
393 state->fw_version = fw->data[i + sizeof(pattern)];
394 printk(KERN_INFO "tda1004x: using firmware v%02x\n",
395 state->fw_version);
396 return 0;
397 }
398 }
399
400 return -EINVAL;
401}
402
383static int tda10046_fwupload(struct dvb_frontend* fe) 403static int tda10046_fwupload(struct dvb_frontend* fe)
384{ 404{
385 struct tda1004x_state* state = fe->demodulator_priv; 405 struct tda1004x_state* state = fe->demodulator_priv;
@@ -393,7 +413,7 @@ static int tda10046_fwupload(struct dvb_frontend* fe)
393 msleep(100); 413 msleep(100);
394 414
395 /* don't re-upload unless necessary */ 415 /* don't re-upload unless necessary */
396 if (tda1004x_check_upload_ok(state, 0x20) == 0) 416 if (tda1004x_check_upload_ok(state, state->fw_version) == 0)
397 return 0; 417 return 0;
398 418
399 /* request the firmware, this will block until someone uploads it */ 419 /* request the firmware, this will block until someone uploads it */
@@ -404,6 +424,17 @@ static int tda10046_fwupload(struct dvb_frontend* fe)
404 return ret; 424 return ret;
405 } 425 }
406 426
427 if (fw->size < 24478) { /* size of firmware v20, which is the smallest of v20, v21 and v25 */
428 printk("tda1004x: firmware file seems to be too small (%d bytes)\n", fw->size);
429 return -EINVAL;
430 }
431
432 ret = tda10046_get_fw_version(state, fw);
433 if (ret < 0) {
434 printk("tda1004x: unable to find firmware version\n");
435 return ret;
436 }
437
407 /* set parameters */ 438 /* set parameters */
408 tda1004x_write_byteI(state, TDA10046H_CONFPLL2, 10); 439 tda1004x_write_byteI(state, TDA10046H_CONFPLL2, 10);
409 tda1004x_write_byteI(state, TDA10046H_CONFPLL3, state->config->n_i2c); 440 tda1004x_write_byteI(state, TDA10046H_CONFPLL3, state->config->n_i2c);
@@ -427,7 +458,7 @@ static int tda10046_fwupload(struct dvb_frontend* fe)
427 msleep(1); 458 msleep(1);
428 } 459 }
429 460
430 return tda1004x_check_upload_ok(state, 0x20); 461 return tda1004x_check_upload_ok(state, state->fw_version);
431} 462}
432 463
433static int tda1004x_encode_fec(int fec) 464static int tda1004x_encode_fec(int fec)
@@ -1185,6 +1216,7 @@ struct dvb_frontend* tda10046_attach(const struct tda1004x_config* config,
1185 memcpy(&state->ops, &tda10046_ops, sizeof(struct dvb_frontend_ops)); 1216 memcpy(&state->ops, &tda10046_ops, sizeof(struct dvb_frontend_ops));
1186 state->initialised = 0; 1217 state->initialised = 0;
1187 state->demod_type = TDA1004X_DEMOD_TDA10046; 1218 state->demod_type = TDA1004X_DEMOD_TDA10046;
1219 state->fw_version = 0x20; /* dummy default value */
1188 1220
1189 /* check if the demod is there */ 1221 /* check if the demod is there */
1190 if (tda1004x_read_byte(state, TDA1004X_CHIPID) != 0x46) { 1222 if (tda1004x_read_byte(state, TDA1004X_CHIPID) != 0x46) {