From b6b6fd6feb5f71267ef535f15061a397f86ebb26 Mon Sep 17 00:00:00 2001 From: Antti Palosaari Date: Sun, 13 Jul 2014 19:22:19 -0300 Subject: [PATCH] [media] si2168: few firmware download changes Rework firmware selection logic a little bit. Print notice asking user update firmware when old Si2168 B40 firmware is used. Signed-off-by: Antti Palosaari Tested-by: Olli Salonen Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/si2168.c | 41 ++++++++++++++++++---------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/drivers/media/dvb-frontends/si2168.c b/drivers/media/dvb-frontends/si2168.c index db4b28ac3fbf..1b56b8e4bb04 100644 --- a/drivers/media/dvb-frontends/si2168.c +++ b/drivers/media/dvb-frontends/si2168.c @@ -336,6 +336,7 @@ static int si2168_init(struct dvb_frontend *fe) u8 *fw_file; const unsigned int i2c_wr_max = 8; struct si2168_cmd cmd; + unsigned int chip_id; dev_dbg(&s->client->dev, "%s:\n", __func__); @@ -375,16 +376,24 @@ static int si2168_init(struct dvb_frontend *fe) if (ret) goto err; - if (((cmd.args[1] & 0x0f) == 2) && (cmd.args[3] == '4') && - (cmd.args[4] == '0')) - fw_file = SI2168_B40_FIRMWARE; - else if (((cmd.args[1] & 0x0f) == 1) && (cmd.args[3] == '3') && - (cmd.args[4] == '0')) + chip_id = cmd.args[1] << 24 | cmd.args[2] << 16 | cmd.args[3] << 8 | + cmd.args[4] << 0; + + #define SI2168_A30 ('A' << 24 | 68 << 16 | '3' << 8 | '0' << 0) + #define SI2168_B40 ('B' << 24 | 68 << 16 | '4' << 8 | '0' << 0) + + switch (chip_id) { + case SI2168_A30: fw_file = SI2168_A30_FIRMWARE; - else { + break; + case SI2168_B40: + fw_file = SI2168_B40_FIRMWARE; + break; + default: dev_err(&s->client->dev, - "%s: no firmware file for Si2168-%c%c defined\n", - KBUILD_MODNAME, cmd.args[3], cmd.args[4]); + "%s: unkown chip version Si21%d-%c%c%c\n", + KBUILD_MODNAME, cmd.args[2], cmd.args[1], + cmd.args[3], cmd.args[4]); ret = -EINVAL; goto err; } @@ -396,15 +405,19 @@ static int si2168_init(struct dvb_frontend *fe) /* request the firmware, this will block and timeout */ ret = request_firmware(&fw, fw_file, &s->client->dev); if (ret) { - /* fallback mechanism to handle old name for - SI2168_B40_FIRMWARE */ - if (((cmd.args[1] & 0x0f) == 2) && (cmd.args[3] == '4') && - (cmd.args[4] == '0')) { + /* fallback mechanism to handle old name for Si2168 B40 fw */ + if (chip_id == SI2168_B40) { fw_file = SI2168_B40_FIRMWARE_FALLBACK; ret = request_firmware(&fw, fw_file, &s->client->dev); } - if (ret) { - dev_err(&s->client->dev, "%s: firmware file '%s' not found\n", + + if (ret == 0) { + dev_notice(&s->client->dev, + "%s: please install firmware file '%s'\n", + KBUILD_MODNAME, SI2168_B40_FIRMWARE); + } else { + dev_err(&s->client->dev, + "%s: firmware file '%s' not found\n", KBUILD_MODNAME, fw_file); goto err; }