diff options
author | Hartmut Hackmann <hartmut.hackmann@t-online.de> | 2007-03-23 20:00:07 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-04-27 14:45:17 -0400 |
commit | 9971f4f1d3d71a5b6654ba226976ba82d2e047a4 (patch) | |
tree | fd1d01a8b7630f173b1a4c88a913fffefdb95bc8 /drivers/media/dvb/frontends | |
parent | e65ec752ced103eb86e5f9c1f747f06d3e266780 (diff) |
V4L/DVB (5485): Tda827x: delayed probing of tuner version
When the tuner is attached, the tda10046 is not initilized yet, so it
is searching for its firmware. If the tuner is attached to the tda10046
silent i2c port, a bus collision can occur. Now the version is probed
during the first init or sleep call.
Signed-off-by: Hartmut Hackmann <hartmut.hackmann@t-online.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/dvb/frontends')
-rw-r--r-- | drivers/media/dvb/frontends/tda827x.c | 85 |
1 files changed, 53 insertions, 32 deletions
diff --git a/drivers/media/dvb/frontends/tda827x.c b/drivers/media/dvb/frontends/tda827x.c index 8176a9b5898f..256fc4bf500b 100644 --- a/drivers/media/dvb/frontends/tda827x.c +++ b/drivers/media/dvb/frontends/tda827x.c | |||
@@ -91,6 +91,7 @@ static int tda827xo_set_params(struct dvb_frontend *fe, | |||
91 | int i, tuner_freq, if_freq; | 91 | int i, tuner_freq, if_freq; |
92 | u32 N; | 92 | u32 N; |
93 | 93 | ||
94 | dprintk("%s:\n", __FUNCTION__); | ||
94 | switch (params->u.ofdm.bandwidth) { | 95 | switch (params->u.ofdm.bandwidth) { |
95 | case BANDWIDTH_6_MHZ: | 96 | case BANDWIDTH_6_MHZ: |
96 | if_freq = 4000000; | 97 | if_freq = 4000000; |
@@ -159,6 +160,7 @@ static int tda827xo_sleep(struct dvb_frontend *fe) | |||
159 | struct i2c_msg msg = { .addr = priv->i2c_addr, .flags = 0, | 160 | struct i2c_msg msg = { .addr = priv->i2c_addr, .flags = 0, |
160 | .buf = buf, .len = sizeof(buf) }; | 161 | .buf = buf, .len = sizeof(buf) }; |
161 | 162 | ||
163 | dprintk("%s:\n", __FUNCTION__); | ||
162 | if (fe->ops.i2c_gate_ctrl) | 164 | if (fe->ops.i2c_gate_ctrl) |
163 | fe->ops.i2c_gate_ctrl(fe, 1); | 165 | fe->ops.i2c_gate_ctrl(fe, 1); |
164 | i2c_transfer(priv->i2c_adap, &msg, 1); | 166 | i2c_transfer(priv->i2c_adap, &msg, 1); |
@@ -222,6 +224,7 @@ static int tda827xa_set_params(struct dvb_frontend *fe, | |||
222 | int i, tuner_freq, if_freq; | 224 | int i, tuner_freq, if_freq; |
223 | u32 N; | 225 | u32 N; |
224 | 226 | ||
227 | dprintk("%s:\n", __FUNCTION__); | ||
225 | if (priv->cfg && priv->cfg->lna_gain) | 228 | if (priv->cfg && priv->cfg->lna_gain) |
226 | priv->cfg->lna_gain(fe, 1); | 229 | priv->cfg->lna_gain(fe, 1); |
227 | msleep(20); | 230 | msleep(20); |
@@ -350,6 +353,7 @@ static int tda827xa_sleep(struct dvb_frontend *fe) | |||
350 | struct i2c_msg msg = { .addr = priv->i2c_addr, .flags = 0, | 353 | struct i2c_msg msg = { .addr = priv->i2c_addr, .flags = 0, |
351 | .buf = buf, .len = sizeof(buf) }; | 354 | .buf = buf, .len = sizeof(buf) }; |
352 | 355 | ||
356 | dprintk("%s:\n", __FUNCTION__); | ||
353 | if (fe->ops.i2c_gate_ctrl) | 357 | if (fe->ops.i2c_gate_ctrl) |
354 | fe->ops.i2c_gate_ctrl(fe, 1); | 358 | fe->ops.i2c_gate_ctrl(fe, 1); |
355 | 359 | ||
@@ -388,13 +392,32 @@ static int tda827x_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth) | |||
388 | static int tda827x_init(struct dvb_frontend *fe) | 392 | static int tda827x_init(struct dvb_frontend *fe) |
389 | { | 393 | { |
390 | struct tda827x_priv *priv = fe->tuner_priv; | 394 | struct tda827x_priv *priv = fe->tuner_priv; |
391 | 395 | dprintk("%s:\n", __FUNCTION__); | |
392 | if (priv->cfg && priv->cfg->init) | 396 | if (priv->cfg && priv->cfg->init) |
393 | priv->cfg->init(fe); | 397 | priv->cfg->init(fe); |
394 | 398 | ||
395 | return 0; | 399 | return 0; |
396 | } | 400 | } |
397 | 401 | ||
402 | static int tda827x_probe_version(struct dvb_frontend *fe); | ||
403 | |||
404 | static int tda827x_initial_init(struct dvb_frontend *fe) | ||
405 | { | ||
406 | int ret; | ||
407 | ret = tda827x_probe_version(fe); | ||
408 | if (ret) | ||
409 | return ret; | ||
410 | return fe->ops.tuner_ops.init(fe); | ||
411 | } | ||
412 | |||
413 | static int tda827x_initial_sleep(struct dvb_frontend *fe) | ||
414 | { | ||
415 | int ret; | ||
416 | ret = tda827x_probe_version(fe); | ||
417 | if (ret) | ||
418 | return ret; | ||
419 | return fe->ops.tuner_ops.sleep(fe); | ||
420 | } | ||
398 | 421 | ||
399 | static struct dvb_tuner_ops tda827xo_tuner_ops = { | 422 | static struct dvb_tuner_ops tda827xo_tuner_ops = { |
400 | .info = { | 423 | .info = { |
@@ -404,8 +427,8 @@ static struct dvb_tuner_ops tda827xo_tuner_ops = { | |||
404 | .frequency_step = 250000 | 427 | .frequency_step = 250000 |
405 | }, | 428 | }, |
406 | .release = tda827x_release, | 429 | .release = tda827x_release, |
407 | .init = tda827x_init, | 430 | .init = tda827x_initial_init, |
408 | .sleep = tda827xo_sleep, | 431 | .sleep = tda827x_initial_sleep, |
409 | .set_params = tda827xo_set_params, | 432 | .set_params = tda827xo_set_params, |
410 | .get_frequency = tda827x_get_frequency, | 433 | .get_frequency = tda827x_get_frequency, |
411 | .get_bandwidth = tda827x_get_bandwidth, | 434 | .get_bandwidth = tda827x_get_bandwidth, |
@@ -426,26 +449,36 @@ static struct dvb_tuner_ops tda827xa_tuner_ops = { | |||
426 | .get_bandwidth = tda827x_get_bandwidth, | 449 | .get_bandwidth = tda827x_get_bandwidth, |
427 | }; | 450 | }; |
428 | 451 | ||
429 | struct dvb_frontend *tda827x_attach(struct dvb_frontend *fe, int addr, | 452 | static int tda827x_probe_version(struct dvb_frontend *fe) |
430 | struct i2c_adapter *i2c, | 453 | { u8 data; |
431 | struct tda827x_config *cfg) | 454 | struct tda827x_priv *priv = fe->tuner_priv; |
432 | { | 455 | struct i2c_msg msg = { .addr = priv->i2c_addr, .flags = I2C_M_RD, |
433 | struct tda827x_priv *priv = NULL; | ||
434 | u8 data; | ||
435 | u8 sb_msg[] = { 0x30, 0xd0 }; | ||
436 | struct i2c_msg msg = { .addr = addr, .flags = I2C_M_RD, | ||
437 | .buf = &data, .len = 1 }; | 456 | .buf = &data, .len = 1 }; |
438 | dprintk("%s:\n", __FUNCTION__); | ||
439 | |||
440 | if (fe->ops.i2c_gate_ctrl) | 457 | if (fe->ops.i2c_gate_ctrl) |
441 | fe->ops.i2c_gate_ctrl(fe, 1); | 458 | fe->ops.i2c_gate_ctrl(fe, 1); |
442 | 459 | if (i2c_transfer(priv->i2c_adap, &msg, 1) != 1) { | |
443 | if (i2c_transfer(i2c, &msg, 1) != 1) { | ||
444 | printk("%s: could not read from tuner at addr: 0x%02x\n", | 460 | printk("%s: could not read from tuner at addr: 0x%02x\n", |
445 | __FUNCTION__, addr << 1); | 461 | __FUNCTION__, msg.addr << 1); |
446 | return NULL; | 462 | return -EIO; |
463 | } | ||
464 | if ((data & 0x3c) == 0) { | ||
465 | dprintk("tda827x tuner found\n"); | ||
466 | fe->ops.tuner_ops.init = tda827x_init; | ||
467 | fe->ops.tuner_ops.sleep = tda827xo_sleep; | ||
468 | } else { | ||
469 | dprintk("tda827xa tuner found\n"); | ||
470 | memcpy(&fe->ops.tuner_ops, &tda827xa_tuner_ops, sizeof(struct dvb_tuner_ops)); | ||
447 | } | 471 | } |
472 | return 0; | ||
473 | } | ||
474 | |||
475 | struct dvb_frontend *tda827x_attach(struct dvb_frontend *fe, int addr, | ||
476 | struct i2c_adapter *i2c, | ||
477 | struct tda827x_config *cfg) | ||
478 | { | ||
479 | struct tda827x_priv *priv = NULL; | ||
448 | 480 | ||
481 | dprintk("%s:\n", __FUNCTION__); | ||
449 | priv = kzalloc(sizeof(struct tda827x_priv), GFP_KERNEL); | 482 | priv = kzalloc(sizeof(struct tda827x_priv), GFP_KERNEL); |
450 | if (priv == NULL) | 483 | if (priv == NULL) |
451 | return NULL; | 484 | return NULL; |
@@ -453,25 +486,13 @@ struct dvb_frontend *tda827x_attach(struct dvb_frontend *fe, int addr, | |||
453 | priv->i2c_addr = addr; | 486 | priv->i2c_addr = addr; |
454 | priv->i2c_adap = i2c; | 487 | priv->i2c_adap = i2c; |
455 | priv->cfg = cfg; | 488 | priv->cfg = cfg; |
489 | memcpy(&fe->ops.tuner_ops, &tda827xo_tuner_ops, sizeof(struct dvb_tuner_ops)); | ||
456 | 490 | ||
457 | msg.flags = 0; | ||
458 | msg.buf = sb_msg; | ||
459 | msg.len = sizeof(sb_msg); | ||
460 | |||
461 | if ((data & 0x3c) == 0) { | ||
462 | dprintk("tda827x tuner found\n"); | ||
463 | memcpy(&fe->ops.tuner_ops, &tda827xo_tuner_ops, sizeof(struct dvb_tuner_ops)); | ||
464 | } else { | ||
465 | dprintk("tda827xa tuner found\n"); | ||
466 | memcpy(&fe->ops.tuner_ops, &tda827xa_tuner_ops, sizeof(struct dvb_tuner_ops)); | ||
467 | sb_msg[1] = 0x90; | ||
468 | } | ||
469 | fe->tuner_priv = priv; | 491 | fe->tuner_priv = priv; |
470 | if (fe->ops.i2c_gate_ctrl) | 492 | |
471 | fe->ops.i2c_gate_ctrl(fe, 1); | ||
472 | i2c_transfer(i2c, &msg, 1); | ||
473 | return fe; | 493 | return fe; |
474 | } | 494 | } |
495 | |||
475 | EXPORT_SYMBOL(tda827x_attach); | 496 | EXPORT_SYMBOL(tda827x_attach); |
476 | 497 | ||
477 | module_param(debug, int, 0644); | 498 | module_param(debug, int, 0644); |