aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/media/common/tuners/tda18271-common.c59
-rw-r--r--drivers/media/common/tuners/tda18271.h5
-rw-r--r--drivers/media/video/tuner-core.c2
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 e1f678281a5..195b30e3872 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 d7fcc36dc6e..3abb221f3d0 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
81enum tda18271_small_i2c { 81enum 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
87struct tda18271_config { 88struct tda18271_config {
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index d14f66f0cb3..1cec1224913 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,