From: Antti Palosaari Date: Mon, 8 Feb 2016 11:51:16 +0000 (-0200) Subject: [media] si2157: detect if firmware is running X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=78bab93026ab95b6c8b9e8770ef7089f7d40b2d5;p=openwrt%2Fstaging%2Fblogic.git [media] si2157: detect if firmware is running 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 Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c index 243ac3816028..b07a681f3fbc 100644 --- a/drivers/media/tuners/si2157.c +++ b/drivers/media/tuners/si2157.c @@ -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); diff --git a/drivers/media/tuners/si2157_priv.h b/drivers/media/tuners/si2157_priv.h index 589d558d381c..d6b2c7b44053 100644 --- a/drivers/media/tuners/si2157_priv.h +++ b/drivers/media/tuners/si2157_priv.h @@ -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;