提交 71e34201 编写于 作者: J Johannes Stezenbach 提交者: Linus Torvalds

[PATCH] dvb: tda10046: support for different firmware versions

added support for different tda10046 firmware versions.  tested with v20, v21
and v25.  (Andreas Oberritter)
Signed-off-by: NJohannes Stezenbach <js@linuxtv.org>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 1dfb800f
...@@ -107,7 +107,7 @@ sub tda10045 { ...@@ -107,7 +107,7 @@ sub tda10045 {
sub tda10046 { sub tda10046 {
my $sourcefile = "tt_budget_217g.zip"; my $sourcefile = "tt_budget_217g.zip";
my $url = "http://www.technotrend.de/new/217g/$sourcefile"; my $url = "http://www.technotrend.de/new/217g/$sourcefile";
my $hash = "a25b579e37109af60f4a36c37893957c"; my $hash = "6a7e1e2f2644b162ff0502367553c72d";
my $outfile = "dvb-fe-tda10046.fw"; my $outfile = "dvb-fe-tda10046.fw";
my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
...@@ -115,7 +115,7 @@ sub tda10046 { ...@@ -115,7 +115,7 @@ sub tda10046 {
wgetfile($sourcefile, $url); wgetfile($sourcefile, $url);
unzip($sourcefile, $tmpdir); unzip($sourcefile, $tmpdir);
extract("$tmpdir/software/OEM/PCI/App/ttlcdacc.dll", 0x3f731, 24479, "$tmpdir/fwtmp"); extract("$tmpdir/software/OEM/PCI/App/ttlcdacc.dll", 0x3f731, 24478, "$tmpdir/fwtmp");
verify("$tmpdir/fwtmp", $hash); verify("$tmpdir/fwtmp", $hash);
copy("$tmpdir/fwtmp", $outfile); copy("$tmpdir/fwtmp", $outfile);
......
...@@ -49,6 +49,7 @@ struct tda1004x_state { ...@@ -49,6 +49,7 @@ struct tda1004x_state {
/* private demod data */ /* private demod data */
u8 initialised; u8 initialised;
enum tda1004x_demod demod_type; enum tda1004x_demod demod_type;
u8 fw_version;
}; };
...@@ -380,6 +381,25 @@ static int tda10045_fwupload(struct dvb_frontend* fe) ...@@ -380,6 +381,25 @@ static int tda10045_fwupload(struct dvb_frontend* fe)
return tda1004x_check_upload_ok(state, 0x2c); return tda1004x_check_upload_ok(state, 0x2c);
} }
static int tda10046_get_fw_version(struct tda1004x_state *state,
const struct firmware *fw)
{
const unsigned char pattern[] = { 0x67, 0x00, 0x50, 0x62, 0x5e, 0x18, 0x67 };
unsigned int i;
/* area guessed from firmware v20, v21 and v25 */
for (i = 0x660; i < 0x700; i++) {
if (!memcmp(&fw->data[i], pattern, sizeof(pattern))) {
state->fw_version = fw->data[i + sizeof(pattern)];
printk(KERN_INFO "tda1004x: using firmware v%02x\n",
state->fw_version);
return 0;
}
}
return -EINVAL;
}
static int tda10046_fwupload(struct dvb_frontend* fe) static int tda10046_fwupload(struct dvb_frontend* fe)
{ {
struct tda1004x_state* state = fe->demodulator_priv; struct tda1004x_state* state = fe->demodulator_priv;
...@@ -393,7 +413,7 @@ static int tda10046_fwupload(struct dvb_frontend* fe) ...@@ -393,7 +413,7 @@ static int tda10046_fwupload(struct dvb_frontend* fe)
msleep(100); msleep(100);
/* don't re-upload unless necessary */ /* don't re-upload unless necessary */
if (tda1004x_check_upload_ok(state, 0x20) == 0) if (tda1004x_check_upload_ok(state, state->fw_version) == 0)
return 0; return 0;
/* request the firmware, this will block until someone uploads it */ /* request the firmware, this will block until someone uploads it */
...@@ -404,6 +424,17 @@ static int tda10046_fwupload(struct dvb_frontend* fe) ...@@ -404,6 +424,17 @@ static int tda10046_fwupload(struct dvb_frontend* fe)
return ret; return ret;
} }
if (fw->size < 24478) { /* size of firmware v20, which is the smallest of v20, v21 and v25 */
printk("tda1004x: firmware file seems to be too small (%d bytes)\n", fw->size);
return -EINVAL;
}
ret = tda10046_get_fw_version(state, fw);
if (ret < 0) {
printk("tda1004x: unable to find firmware version\n");
return ret;
}
/* set parameters */ /* set parameters */
tda1004x_write_byteI(state, TDA10046H_CONFPLL2, 10); tda1004x_write_byteI(state, TDA10046H_CONFPLL2, 10);
tda1004x_write_byteI(state, TDA10046H_CONFPLL3, state->config->n_i2c); tda1004x_write_byteI(state, TDA10046H_CONFPLL3, state->config->n_i2c);
...@@ -427,7 +458,7 @@ static int tda10046_fwupload(struct dvb_frontend* fe) ...@@ -427,7 +458,7 @@ static int tda10046_fwupload(struct dvb_frontend* fe)
msleep(1); msleep(1);
} }
return tda1004x_check_upload_ok(state, 0x20); return tda1004x_check_upload_ok(state, state->fw_version);
} }
static int tda1004x_encode_fec(int fec) static int tda1004x_encode_fec(int fec)
...@@ -1185,6 +1216,7 @@ struct dvb_frontend* tda10046_attach(const struct tda1004x_config* config, ...@@ -1185,6 +1216,7 @@ struct dvb_frontend* tda10046_attach(const struct tda1004x_config* config,
memcpy(&state->ops, &tda10046_ops, sizeof(struct dvb_frontend_ops)); memcpy(&state->ops, &tda10046_ops, sizeof(struct dvb_frontend_ops));
state->initialised = 0; state->initialised = 0;
state->demod_type = TDA1004X_DEMOD_TDA10046; state->demod_type = TDA1004X_DEMOD_TDA10046;
state->fw_version = 0x20; /* dummy default value */
/* check if the demod is there */ /* check if the demod is there */
if (tda1004x_read_byte(state, TDA1004X_CHIPID) != 0x46) { if (tda1004x_read_byte(state, TDA1004X_CHIPID) != 0x46) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册