]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
[media] si2157: detect if firmware is running
authorAntti Palosaari <crope@iki.fi>
Mon, 8 Feb 2016 11:51:16 +0000 (09:51 -0200)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Fri, 6 May 2016 13:07:45 +0000 (10:07 -0300)
Detect if firmware is running run-time and download / start it only
when needed. Detection is done by reading IF frequency value.
Garbage value is returned by firmware when it is not running,
otherwise correct value is returned.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/tuners/si2157.c
drivers/media/tuners/si2157_priv.h

index 243ac3816028b70edb6c1b15fa70ccd7f87d0f69..b07a681f3fbc7e0cfaef675314995055e4675182 100644 (file)
@@ -84,11 +84,22 @@ static int si2157_init(struct dvb_frontend *fe)
        struct si2157_cmd cmd;
        const struct firmware *fw;
        const char *fw_name;
-       unsigned int chip_id;
+       unsigned int uitmp, chip_id;
 
        dev_dbg(&client->dev, "\n");
 
-       if (dev->fw_loaded)
+       /* Returned IF frequency is garbage when firmware is not running */
+       memcpy(cmd.args, "\x15\x00\x06\x07", 4);
+       cmd.wlen = 4;
+       cmd.rlen = 4;
+       ret = si2157_cmd_execute(client, &cmd);
+       if (ret)
+               goto err;
+
+       uitmp = cmd.args[2] << 0 | cmd.args[3] << 8;
+       dev_dbg(&client->dev, "if_frequency kHz=%u\n", uitmp);
+
+       if (uitmp == dev->if_frequency / 1000)
                goto warm;
 
        /* power up */
@@ -203,9 +214,6 @@ skip_fw_download:
 
        dev_info(&client->dev, "firmware version: %c.%c.%d\n",
                        cmd.args[6], cmd.args[7], cmd.args[8]);
-
-       dev->fw_loaded = true;
-
 warm:
        /* init statistics in order signal app which are supported */
        c->strength.len = 1;
@@ -422,7 +430,6 @@ static int si2157_probe(struct i2c_client *client,
        dev->fe = cfg->fe;
        dev->inversion = cfg->inversion;
        dev->if_port = cfg->if_port;
-       dev->fw_loaded = false;
        dev->chiptype = (u8)id->driver_data;
        dev->if_frequency = 5000000; /* default value of property 0x0706 */
        mutex_init(&dev->i2c_mutex);
index 589d558d381c911f8290859122e405ea93966572..d6b2c7b4405321558534edf9291dfb217e2e9b76 100644 (file)
@@ -26,7 +26,6 @@ struct si2157_dev {
        struct mutex i2c_mutex;
        struct dvb_frontend *fe;
        bool active;
-       bool fw_loaded;
        bool inversion;
        u8 chiptype;
        u8 if_port;