diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-09-26 21:58:28 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-10-20 23:17:43 -0400 |
commit | e350d44fed8eb86a7192a579e3687fcd76a4645b (patch) | |
tree | 9e80c1c819150391729d7247e9f9d450d6edd11b /drivers | |
parent | 78bb6df6f2dd390a3480249187a055c385c0618a (diff) |
[media] tda18271: allow restricting max out to 4 bytes
By default, tda18271 tries to optimize I2C bus by updating all registers
at the same time. Unfortunately, some devices doesn't support it.
The current logic has a problem when small_i2c is equal to 8, since there
are some transfers using 11 + 1 bytes.
Fix the problem by enforcing the max size at the right place, and allows
reducing it to max = 3 + 1.
Acked-by: Michael Krufky <mkrufky@kernellabs.com>
Acked-by: Sri Deevi <Srinivasa.Deevi@conexant.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/common/tuners/tda18271-common.c | 59 | ||||
-rw-r--r-- | drivers/media/common/tuners/tda18271.h | 5 | ||||
-rw-r--r-- | drivers/media/video/tuner-core.c | 2 |
3 files changed, 38 insertions, 28 deletions
diff --git a/drivers/media/common/tuners/tda18271-common.c b/drivers/media/common/tuners/tda18271-common.c index e1f678281a58..195b30e3872d 100644 --- a/drivers/media/common/tuners/tda18271-common.c +++ b/drivers/media/common/tuners/tda18271-common.c | |||
@@ -193,20 +193,46 @@ int tda18271_write_regs(struct dvb_frontend *fe, int idx, int len) | |||
193 | unsigned char *regs = priv->tda18271_regs; | 193 | unsigned char *regs = priv->tda18271_regs; |
194 | unsigned char buf[TDA18271_NUM_REGS + 1]; | 194 | unsigned char buf[TDA18271_NUM_REGS + 1]; |
195 | struct i2c_msg msg = { .addr = priv->i2c_props.addr, .flags = 0, | 195 | struct i2c_msg msg = { .addr = priv->i2c_props.addr, .flags = 0, |
196 | .buf = buf, .len = len + 1 }; | 196 | .buf = buf }; |
197 | int i, ret; | 197 | int i, ret = 1, max; |
198 | 198 | ||
199 | BUG_ON((len == 0) || (idx + len > sizeof(buf))); | 199 | BUG_ON((len == 0) || (idx + len > sizeof(buf))); |
200 | 200 | ||
201 | buf[0] = idx; | 201 | |
202 | for (i = 1; i <= len; i++) | 202 | switch (priv->small_i2c) { |
203 | buf[i] = regs[idx - 1 + i]; | 203 | case TDA18271_03_BYTE_CHUNK_INIT: |
204 | max = 3; | ||
205 | break; | ||
206 | case TDA18271_08_BYTE_CHUNK_INIT: | ||
207 | max = 8; | ||
208 | break; | ||
209 | case TDA18271_16_BYTE_CHUNK_INIT: | ||
210 | max = 16; | ||
211 | break; | ||
212 | case TDA18271_39_BYTE_CHUNK_INIT: | ||
213 | default: | ||
214 | max = 39; | ||
215 | } | ||
204 | 216 | ||
205 | tda18271_i2c_gate_ctrl(fe, 1); | 217 | tda18271_i2c_gate_ctrl(fe, 1); |
218 | while (len) { | ||
219 | if (max > len) | ||
220 | max = len; | ||
221 | |||
222 | buf[0] = idx; | ||
223 | for (i = 1; i <= max; i++) | ||
224 | buf[i] = regs[idx - 1 + i]; | ||
206 | 225 | ||
207 | /* write registers */ | 226 | msg.len = max + 1; |
208 | ret = i2c_transfer(priv->i2c_props.adap, &msg, 1); | ||
209 | 227 | ||
228 | /* write registers */ | ||
229 | ret = i2c_transfer(priv->i2c_props.adap, &msg, 1); | ||
230 | if (ret != 1) | ||
231 | break; | ||
232 | |||
233 | idx += max; | ||
234 | len -= max; | ||
235 | } | ||
210 | tda18271_i2c_gate_ctrl(fe, 0); | 236 | tda18271_i2c_gate_ctrl(fe, 0); |
211 | 237 | ||
212 | if (ret != 1) | 238 | if (ret != 1) |
@@ -326,24 +352,7 @@ int tda18271_init_regs(struct dvb_frontend *fe) | |||
326 | regs[R_EB22] = 0x48; | 352 | regs[R_EB22] = 0x48; |
327 | regs[R_EB23] = 0xb0; | 353 | regs[R_EB23] = 0xb0; |
328 | 354 | ||
329 | switch (priv->small_i2c) { | 355 | tda18271_write_regs(fe, 0x00, TDA18271_NUM_REGS); |
330 | case TDA18271_08_BYTE_CHUNK_INIT: | ||
331 | tda18271_write_regs(fe, 0x00, 0x08); | ||
332 | tda18271_write_regs(fe, 0x08, 0x08); | ||
333 | tda18271_write_regs(fe, 0x10, 0x08); | ||
334 | tda18271_write_regs(fe, 0x18, 0x08); | ||
335 | tda18271_write_regs(fe, 0x20, 0x07); | ||
336 | break; | ||
337 | case TDA18271_16_BYTE_CHUNK_INIT: | ||
338 | tda18271_write_regs(fe, 0x00, 0x10); | ||
339 | tda18271_write_regs(fe, 0x10, 0x10); | ||
340 | tda18271_write_regs(fe, 0x20, 0x07); | ||
341 | break; | ||
342 | case TDA18271_39_BYTE_CHUNK_INIT: | ||
343 | default: | ||
344 | tda18271_write_regs(fe, 0x00, TDA18271_NUM_REGS); | ||
345 | break; | ||
346 | } | ||
347 | 356 | ||
348 | /* setup agc1 gain */ | 357 | /* setup agc1 gain */ |
349 | regs[R_EB17] = 0x00; | 358 | regs[R_EB17] = 0x00; |
diff --git a/drivers/media/common/tuners/tda18271.h b/drivers/media/common/tuners/tda18271.h index d7fcc36dc6e6..3abb221f3d07 100644 --- a/drivers/media/common/tuners/tda18271.h +++ b/drivers/media/common/tuners/tda18271.h | |||
@@ -80,8 +80,9 @@ enum tda18271_output_options { | |||
80 | 80 | ||
81 | enum tda18271_small_i2c { | 81 | enum tda18271_small_i2c { |
82 | TDA18271_39_BYTE_CHUNK_INIT = 0, | 82 | TDA18271_39_BYTE_CHUNK_INIT = 0, |
83 | TDA18271_16_BYTE_CHUNK_INIT = 1, | 83 | TDA18271_16_BYTE_CHUNK_INIT = 16, |
84 | TDA18271_08_BYTE_CHUNK_INIT = 2, | 84 | TDA18271_08_BYTE_CHUNK_INIT = 8, |
85 | TDA18271_03_BYTE_CHUNK_INIT = 3, | ||
85 | }; | 86 | }; |
86 | 87 | ||
87 | struct tda18271_config { | 88 | struct tda18271_config { |
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c index d14f66f0cb31..1cec1224913f 100644 --- a/drivers/media/video/tuner-core.c +++ b/drivers/media/video/tuner-core.c | |||
@@ -427,7 +427,7 @@ static void set_type(struct i2c_client *c, unsigned int type, | |||
427 | { | 427 | { |
428 | struct tda18271_config cfg = { | 428 | struct tda18271_config cfg = { |
429 | .config = t->config, | 429 | .config = t->config, |
430 | .small_i2c = TDA18271_08_BYTE_CHUNK_INIT, | 430 | .small_i2c = TDA18271_03_BYTE_CHUNK_INIT, |
431 | }; | 431 | }; |
432 | 432 | ||
433 | if (!dvb_attach(tda18271_attach, &t->fe, t->i2c->addr, | 433 | if (!dvb_attach(tda18271_attach, &t->fe, t->i2c->addr, |