]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
media: si2168: Add ts bus coontrol, turn off bus on sleep
authorBrad Love <brad@nextdimension.cc>
Fri, 12 Jan 2018 16:19:39 +0000 (11:19 -0500)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Tue, 6 Mar 2018 12:25:31 +0000 (07:25 -0500)
Includes a function to set TS MODE property os si2168. The function
either disables the TS output bus, or sets mode to config option.

When going to sleep the TS bus is turned off, this makes the driver
compatible with multiple frontend usage.

Signed-off-by: Brad Love <brad@nextdimension.cc>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/dvb-frontends/si2168.c
drivers/media/dvb-frontends/si2168.h

index 539399dac55149e0554960f430b081881065f545..429c03aaa90227691cd515311c82d637e5eadb78 100644 (file)
@@ -409,6 +409,30 @@ err:
        return ret;
 }
 
+static int si2168_ts_bus_ctrl(struct dvb_frontend *fe, int acquire)
+{
+       struct i2c_client *client = fe->demodulator_priv;
+       struct si2168_dev *dev = i2c_get_clientdata(client);
+       struct si2168_cmd cmd;
+       int ret = 0;
+
+       dev_dbg(&client->dev, "%s acquire: %d\n", __func__, acquire);
+
+       /* set TS_MODE property */
+       memcpy(cmd.args, "\x14\x00\x01\x10\x10\x00", 6);
+       if (acquire)
+               cmd.args[4] |= dev->ts_mode;
+       else
+               cmd.args[4] |= SI2168_TS_TRISTATE;
+       if (dev->ts_clock_gapped)
+               cmd.args[4] |= 0x40;
+       cmd.wlen = 6;
+       cmd.rlen = 4;
+       ret = si2168_cmd_execute(client, &cmd);
+
+       return ret;
+}
+
 static int si2168_init(struct dvb_frontend *fe)
 {
        struct i2c_client *client = fe->demodulator_priv;
@@ -540,14 +564,7 @@ static int si2168_init(struct dvb_frontend *fe)
                 dev->version >> 24 & 0xff, dev->version >> 16 & 0xff,
                 dev->version >> 8 & 0xff, dev->version >> 0 & 0xff);
 
-       /* set ts mode */
-       memcpy(cmd.args, "\x14\x00\x01\x10\x10\x00", 6);
-       cmd.args[4] |= dev->ts_mode;
-       if (dev->ts_clock_gapped)
-               cmd.args[4] |= 0x40;
-       cmd.wlen = 6;
-       cmd.rlen = 4;
-       ret = si2168_cmd_execute(client, &cmd);
+       ret = si2168_ts_bus_ctrl(fe, 1);
        if (ret)
                goto err;
 
@@ -584,6 +601,9 @@ static int si2168_sleep(struct dvb_frontend *fe)
 
        dev->active = false;
 
+       /* tri-state data bus */
+       si2168_ts_bus_ctrl(fe, 0);
+
        /* Firmware B 4.0-11 or later loses warm state during sleep */
        if (dev->version > ('B' << 24 | 4 << 16 | 0 << 8 | 11 << 0))
                dev->warm = false;
@@ -681,6 +701,8 @@ static const struct dvb_frontend_ops si2168_ops = {
        .init = si2168_init,
        .sleep = si2168_sleep,
 
+       .ts_bus_ctrl          = si2168_ts_bus_ctrl,
+
        .set_frontend = si2168_set_frontend,
 
        .read_status = si2168_read_status,
index 3225d0cc93c79192c749c93fb23627e11200a773..f48f0fb0ad697d7124c9f9b60e8a57e10f1ef4bb 100644 (file)
@@ -38,6 +38,7 @@ struct si2168_config {
        /* TS mode */
 #define SI2168_TS_PARALLEL     0x06
 #define SI2168_TS_SERIAL       0x03
+#define SI2168_TS_TRISTATE     0x00
        u8 ts_mode;
 
        /* TS clock inverted */