[media] si2168: few firmware download changes
authorAntti Palosaari <crope@iki.fi>
Sun, 13 Jul 2014 22:22:19 +0000 (19:22 -0300)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Tue, 15 Jul 2014 00:07:09 +0000 (21:07 -0300)
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 <crope@iki.fi>
Tested-by: Olli Salonen <olli.salonen@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
drivers/media/dvb-frontends/si2168.c

index db4b28ac3fbffc456df9167cea941fd91cab2778..1b56b8e4bb049ab3ee48d0cbb6ed05edb76d57ce 100644 (file)
@@ -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;
                }