diff options
-rw-r--r-- | drivers/media/tuners/it913x.c | 76 | ||||
-rw-r--r-- | drivers/media/tuners/it913x.h | 10 | ||||
-rw-r--r-- | drivers/media/tuners/it913x_priv.h | 27 | ||||
-rw-r--r-- | drivers/media/usb/dvb-usb-v2/af9035.c | 14 |
4 files changed, 83 insertions, 44 deletions
diff --git a/drivers/media/tuners/it913x.c b/drivers/media/tuners/it913x.c index f3e212c127c8..11d391a5d5c6 100644 --- a/drivers/media/tuners/it913x.c +++ b/drivers/media/tuners/it913x.c | |||
@@ -26,7 +26,8 @@ struct it913x_dev { | |||
26 | struct i2c_client *client; | 26 | struct i2c_client *client; |
27 | struct regmap *regmap; | 27 | struct regmap *regmap; |
28 | struct dvb_frontend *fe; | 28 | struct dvb_frontend *fe; |
29 | u8 chip_ver; | 29 | u8 chip_ver:2; |
30 | u8 role:2; | ||
30 | u8 firmware_ver; | 31 | u8 firmware_ver; |
31 | u16 tun_xtal; | 32 | u16 tun_xtal; |
32 | u8 tun_fdiv; | 33 | u8 tun_fdiv; |
@@ -122,6 +123,62 @@ static int it913x_init(struct dvb_frontend *fe) | |||
122 | return regmap_write(dev->regmap, 0x80ed81, val); | 123 | return regmap_write(dev->regmap, 0x80ed81, val); |
123 | } | 124 | } |
124 | 125 | ||
126 | static int it913x_sleep(struct dvb_frontend *fe) | ||
127 | { | ||
128 | struct it913x_dev *dev = fe->tuner_priv; | ||
129 | int ret, len; | ||
130 | |||
131 | dev_dbg(&dev->client->dev, "role=%u\n", dev->role); | ||
132 | |||
133 | ret = regmap_bulk_write(dev->regmap, 0x80ec40, "\x00", 1); | ||
134 | if (ret) | ||
135 | goto err; | ||
136 | |||
137 | /* | ||
138 | * Writing '0x00' to master tuner register '0x80ec08' causes slave tuner | ||
139 | * communication lost. Due to that, we cannot put master full sleep. | ||
140 | */ | ||
141 | if (dev->role == IT913X_ROLE_DUAL_MASTER) | ||
142 | len = 4; | ||
143 | else | ||
144 | len = 15; | ||
145 | |||
146 | dev_dbg(&dev->client->dev, "role=%u len=%d\n", dev->role, len); | ||
147 | |||
148 | ret = regmap_bulk_write(dev->regmap, 0x80ec02, | ||
149 | "\x3f\x1f\x3f\x3e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", | ||
150 | len); | ||
151 | if (ret) | ||
152 | goto err; | ||
153 | |||
154 | ret = regmap_bulk_write(dev->regmap, 0x80ec12, "\x00\x00\x00\x00", 4); | ||
155 | if (ret) | ||
156 | goto err; | ||
157 | |||
158 | ret = regmap_bulk_write(dev->regmap, 0x80ec17, | ||
159 | "\x00\x00\x00\x00\x00\x00\x00\x00\x00", 9); | ||
160 | if (ret) | ||
161 | goto err; | ||
162 | |||
163 | ret = regmap_bulk_write(dev->regmap, 0x80ec22, | ||
164 | "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 10); | ||
165 | if (ret) | ||
166 | goto err; | ||
167 | |||
168 | ret = regmap_bulk_write(dev->regmap, 0x80ec20, "\x00", 1); | ||
169 | if (ret) | ||
170 | goto err; | ||
171 | |||
172 | ret = regmap_bulk_write(dev->regmap, 0x80ec3f, "\x01", 1); | ||
173 | if (ret) | ||
174 | goto err; | ||
175 | |||
176 | return 0; | ||
177 | err: | ||
178 | dev_dbg(&dev->client->dev, "failed %d\n", ret); | ||
179 | return ret; | ||
180 | } | ||
181 | |||
125 | static int it9137_set_params(struct dvb_frontend *fe) | 182 | static int it9137_set_params(struct dvb_frontend *fe) |
126 | { | 183 | { |
127 | struct it913x_dev *dev = fe->tuner_priv; | 184 | struct it913x_dev *dev = fe->tuner_priv; |
@@ -274,20 +331,6 @@ static int it9137_set_params(struct dvb_frontend *fe) | |||
274 | return (ret < 0) ? -ENODEV : 0; | 331 | return (ret < 0) ? -ENODEV : 0; |
275 | } | 332 | } |
276 | 333 | ||
277 | /* Power sequence */ | ||
278 | /* Power Up Tuner on -> Frontend suspend off -> Tuner clk on */ | ||
279 | /* Power Down Frontend suspend on -> Tuner clk off -> Tuner off */ | ||
280 | |||
281 | static int it913x_sleep(struct dvb_frontend *fe) | ||
282 | { | ||
283 | struct it913x_dev *dev = fe->tuner_priv; | ||
284 | |||
285 | if (dev->chip_ver == 0x01) | ||
286 | return it913x_script_loader(dev, it9135ax_tuner_off); | ||
287 | else | ||
288 | return it913x_script_loader(dev, it9137_tuner_off); | ||
289 | } | ||
290 | |||
291 | static const struct dvb_tuner_ops it913x_tuner_ops = { | 334 | static const struct dvb_tuner_ops it913x_tuner_ops = { |
292 | .info = { | 335 | .info = { |
293 | .name = "ITE Tech IT913X", | 336 | .name = "ITE Tech IT913X", |
@@ -323,6 +366,7 @@ static int it913x_probe(struct i2c_client *client, | |||
323 | dev->client = client; | 366 | dev->client = client; |
324 | dev->fe = cfg->fe; | 367 | dev->fe = cfg->fe; |
325 | dev->chip_ver = cfg->chip_ver; | 368 | dev->chip_ver = cfg->chip_ver; |
369 | dev->role = cfg->role; | ||
326 | dev->firmware_ver = 1; | 370 | dev->firmware_ver = 1; |
327 | dev->regmap = regmap_init_i2c(client, ®map_config); | 371 | dev->regmap = regmap_init_i2c(client, ®map_config); |
328 | if (IS_ERR(dev->regmap)) { | 372 | if (IS_ERR(dev->regmap)) { |
@@ -349,7 +393,7 @@ static int it913x_probe(struct i2c_client *client, | |||
349 | 393 | ||
350 | dev_info(&dev->client->dev, "ITE IT913X %s successfully attached\n", | 394 | dev_info(&dev->client->dev, "ITE IT913X %s successfully attached\n", |
351 | chip_ver_str); | 395 | chip_ver_str); |
352 | dev_dbg(&dev->client->dev, "chip_ver=%02x\n", dev->chip_ver); | 396 | dev_dbg(&dev->client->dev, "chip_ver=%u role=%u\n", dev->chip_ver, dev->role); |
353 | return 0; | 397 | return 0; |
354 | 398 | ||
355 | err_regmap_exit: | 399 | err_regmap_exit: |
diff --git a/drivers/media/tuners/it913x.h b/drivers/media/tuners/it913x.h index 9789c4d2a6ea..33de53d4a566 100644 --- a/drivers/media/tuners/it913x.h +++ b/drivers/media/tuners/it913x.h | |||
@@ -40,7 +40,15 @@ struct it913x_config { | |||
40 | * 1 = IT9135 AX | 40 | * 1 = IT9135 AX |
41 | * 2 = IT9135 BX | 41 | * 2 = IT9135 BX |
42 | */ | 42 | */ |
43 | u8 chip_ver:2; | 43 | unsigned int chip_ver:2; |
44 | |||
45 | /* | ||
46 | * tuner role | ||
47 | */ | ||
48 | #define IT913X_ROLE_SINGLE 0 | ||
49 | #define IT913X_ROLE_DUAL_MASTER 1 | ||
50 | #define IT913X_ROLE_DUAL_SLAVE 2 | ||
51 | unsigned int role:2; | ||
44 | }; | 52 | }; |
45 | 53 | ||
46 | #endif | 54 | #endif |
diff --git a/drivers/media/tuners/it913x_priv.h b/drivers/media/tuners/it913x_priv.h index 3ed2d3c0fe55..41f9b2a43e39 100644 --- a/drivers/media/tuners/it913x_priv.h +++ b/drivers/media/tuners/it913x_priv.h | |||
@@ -33,33 +33,6 @@ struct it913xset { u32 address; | |||
33 | u8 count; | 33 | u8 count; |
34 | }; | 34 | }; |
35 | 35 | ||
36 | /* Tuner setting scripts for IT9135 AX */ | ||
37 | static struct it913xset it9135ax_tuner_off[] = { | ||
38 | {0x80ec40, {0x00}, 0x01}, /* Power Down Tuner */ | ||
39 | {0x80ec02, {0x3f}, 0x01}, | ||
40 | {0x80ec03, {0x1f}, 0x01}, | ||
41 | {0x80ec04, {0x3f}, 0x01}, | ||
42 | {0x80ec05, {0x3f}, 0x01}, | ||
43 | {0x80ec3f, {0x01}, 0x01}, | ||
44 | {0x000000, {0x00}, 0x00}, /* Terminating Entry */ | ||
45 | }; | ||
46 | |||
47 | /* Tuner setting scripts (still keeping it9137) */ | ||
48 | static struct it913xset it9137_tuner_off[] = { | ||
49 | {0x80ec40, {0x00}, 0x01}, /* Power Down Tuner */ | ||
50 | {0x80ec02, {0x3f, 0x1f, 0x3f, 0x3f}, 0x04}, | ||
51 | {0x80ec06, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
52 | 0x00, 0x00, 0x00, 0x00}, 0x0c}, | ||
53 | {0x80ec12, {0x00, 0x00, 0x00, 0x00}, 0x04}, | ||
54 | {0x80ec17, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
55 | 0x00}, 0x09}, | ||
56 | {0x80ec22, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
57 | 0x00, 0x00}, 0x0a}, | ||
58 | {0x80ec20, {0x00}, 0x01}, | ||
59 | {0x80ec3f, {0x01}, 0x01}, | ||
60 | {0x000000, {0x00}, 0x00}, /* Terminating Entry */ | ||
61 | }; | ||
62 | |||
63 | static struct it913xset set_it9135_template[] = { | 36 | static struct it913xset set_it9135_template[] = { |
64 | {0x80ee06, {0x00}, 0x01}, | 37 | {0x80ee06, {0x00}, 0x01}, |
65 | {0x80ec56, {0x00}, 0x01}, | 38 | {0x80ec56, {0x00}, 0x01}, |
diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c b/drivers/media/usb/dvb-usb-v2/af9035.c index 1a5b600dc349..533c96e4fbb6 100644 --- a/drivers/media/usb/dvb-usb-v2/af9035.c +++ b/drivers/media/usb/dvb-usb-v2/af9035.c | |||
@@ -1324,6 +1324,13 @@ static int af9035_tuner_attach(struct dvb_usb_adapter *adap) | |||
1324 | .chip_ver = 1, | 1324 | .chip_ver = 1, |
1325 | }; | 1325 | }; |
1326 | 1326 | ||
1327 | if (state->dual_mode) { | ||
1328 | if (adap->id == 0) | ||
1329 | it913x_config.role = IT913X_ROLE_DUAL_MASTER; | ||
1330 | else | ||
1331 | it913x_config.role = IT913X_ROLE_DUAL_SLAVE; | ||
1332 | } | ||
1333 | |||
1327 | ret = af9035_add_i2c_dev(d, "it913x", | 1334 | ret = af9035_add_i2c_dev(d, "it913x", |
1328 | state->af9033_config[adap->id].i2c_addr, | 1335 | state->af9033_config[adap->id].i2c_addr, |
1329 | &it913x_config); | 1336 | &it913x_config); |
@@ -1342,6 +1349,13 @@ static int af9035_tuner_attach(struct dvb_usb_adapter *adap) | |||
1342 | .chip_ver = 2, | 1349 | .chip_ver = 2, |
1343 | }; | 1350 | }; |
1344 | 1351 | ||
1352 | if (state->dual_mode) { | ||
1353 | if (adap->id == 0) | ||
1354 | it913x_config.role = IT913X_ROLE_DUAL_MASTER; | ||
1355 | else | ||
1356 | it913x_config.role = IT913X_ROLE_DUAL_SLAVE; | ||
1357 | } | ||
1358 | |||
1345 | ret = af9035_add_i2c_dev(d, "it913x", | 1359 | ret = af9035_add_i2c_dev(d, "it913x", |
1346 | state->af9033_config[adap->id].i2c_addr, | 1360 | state->af9033_config[adap->id].i2c_addr, |
1347 | &it913x_config); | 1361 | &it913x_config); |