From 863981e96738983919de841ec669e157e6bdaeb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Fabian=20Silva=20Delgado?= Date: Sun, 11 Sep 2016 04:34:46 -0300 Subject: Linux-libre 4.7.1-gnu --- drivers/media/tuners/qm1d1c0042.c | 38 +++++++++++++++++++++++++++----------- drivers/media/tuners/si2157.c | 19 +++++++++++++------ drivers/media/tuners/si2157_priv.h | 1 - 3 files changed, 40 insertions(+), 18 deletions(-) (limited to 'drivers/media/tuners') diff --git a/drivers/media/tuners/qm1d1c0042.c b/drivers/media/tuners/qm1d1c0042.c index 18bc745ed..9af2a155c 100644 --- a/drivers/media/tuners/qm1d1c0042.c +++ b/drivers/media/tuners/qm1d1c0042.c @@ -32,14 +32,24 @@ #include "qm1d1c0042.h" #define QM1D1C0042_NUM_REGS 0x20 - -static const u8 reg_initval[QM1D1C0042_NUM_REGS] = { - 0x48, 0x1c, 0xa0, 0x10, 0xbc, 0xc5, 0x20, 0x33, - 0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x00, 0xff, 0xf3, 0x00, 0x2a, 0x64, 0xa6, 0x86, - 0x8c, 0xcf, 0xb8, 0xf1, 0xa8, 0xf2, 0x89, 0x00 +#define QM1D1C0042_NUM_REG_ROWS 2 + +static const u8 +reg_initval[QM1D1C0042_NUM_REG_ROWS][QM1D1C0042_NUM_REGS] = { { + 0x48, 0x1c, 0xa0, 0x10, 0xbc, 0xc5, 0x20, 0x33, + 0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x00, 0xff, 0xf3, 0x00, 0x2a, 0x64, 0xa6, 0x86, + 0x8c, 0xcf, 0xb8, 0xf1, 0xa8, 0xf2, 0x89, 0x00 + }, { + 0x68, 0x1c, 0xc0, 0x10, 0xbc, 0xc1, 0x11, 0x33, + 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x00, 0xff, 0xf3, 0x00, 0x3f, 0x25, 0x5c, 0xd6, + 0x55, 0xcf, 0x95, 0xf6, 0x36, 0xf2, 0x09, 0x00 + } }; +static int reg_index; + static const struct qm1d1c0042_config default_cfg = { .xtal_freq = 16000, .lpf = 1, @@ -320,7 +330,6 @@ static int qm1d1c0042_init(struct dvb_frontend *fe) int i, ret; state = fe->tuner_priv; - memcpy(state->regs, reg_initval, sizeof(reg_initval)); reg_write(state, 0x01, 0x0c); reg_write(state, 0x01, 0x0c); @@ -330,15 +339,22 @@ static int qm1d1c0042_init(struct dvb_frontend *fe) goto failed; usleep_range(2000, 3000); - val = state->regs[0x01] | 0x10; - ret = reg_write(state, 0x01, val); /* soft reset off */ + ret = reg_write(state, 0x01, 0x1c); /* soft reset off */ if (ret < 0) goto failed; - /* check ID */ + /* check ID and choose initial registers corresponding ID */ ret = reg_read(state, 0x00, &val); - if (ret < 0 || val != 0x48) + if (ret < 0) + goto failed; + for (reg_index = 0; reg_index < QM1D1C0042_NUM_REG_ROWS; + reg_index++) { + if (val == reg_initval[reg_index][0x00]) + break; + } + if (reg_index >= QM1D1C0042_NUM_REG_ROWS) goto failed; + memcpy(state->regs, reg_initval[reg_index], QM1D1C0042_NUM_REGS); usleep_range(2000, 3000); state->regs[0x0c] |= 0x40; diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c index 79ac27c30..abe362cd6 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 6fdc84fb3..fdc3f2f64 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; -- cgit v1.2.3