aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Krufky <mkrufky@linuxtv.org>2007-12-24 02:15:20 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-01-25 16:04:19 -0500
commit49e7aaf0ff14a270f3c481ab200dcf361c4155a5 (patch)
tree70d328282d80a1970fe5104592c6027992e45ba0
parent7e946c8a4242e3ed944cececddd3f2294299ed65 (diff)
V4L/DVB (6905): tda18271: check ID register during attach
Identify the silicon during attach, return NULL if unsupported device. Signed-off-by: Michael Krufky <mkrufky@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
-rw-r--r--drivers/media/dvb/frontends/tda18271-fe.c40
1 files changed, 38 insertions, 2 deletions
diff --git a/drivers/media/dvb/frontends/tda18271-fe.c b/drivers/media/dvb/frontends/tda18271-fe.c
index d9994aeeb14f..4a32c2e63719 100644
--- a/drivers/media/dvb/frontends/tda18271-fe.c
+++ b/drivers/media/dvb/frontends/tda18271-fe.c
@@ -719,6 +719,36 @@ static int tda18271_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth)
719 return 0; 719 return 0;
720} 720}
721 721
722static int tda18271_get_id(struct dvb_frontend *fe)
723{
724 struct tda18271_priv *priv = fe->tuner_priv;
725 unsigned char *regs = priv->tda18271_regs;
726 char *name;
727 int ret = 0;
728
729 tda18271_read_regs(fe);
730
731 switch (regs[R_ID] & 0x7f) {
732 case 3:
733 name = "TDA18271HD/C1";
734 break;
735 case 4:
736 name = "TDA18271HD/C2";
737 ret = -EPROTONOSUPPORT;
738 break;
739 default:
740 name = "Unknown device";
741 ret = -EINVAL;
742 break;
743 }
744
745 dbg_info("%s detected @ %d-%04x%s\n", name,
746 i2c_adapter_id(priv->i2c_adap), priv->i2c_addr,
747 (0 == ret) ? "" : ", device not supported.");
748
749 return ret;
750}
751
722static struct dvb_tuner_ops tda18271_tuner_ops = { 752static struct dvb_tuner_ops tda18271_tuner_ops = {
723 .info = { 753 .info = {
724 .name = "NXP TDA18271HD", 754 .name = "NXP TDA18271HD",
@@ -749,14 +779,20 @@ struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr,
749 priv->i2c_adap = i2c; 779 priv->i2c_adap = i2c;
750 priv->gate = gate; 780 priv->gate = gate;
751 781
782 fe->tuner_priv = priv;
783
784 if (tda18271_get_id(fe) < 0)
785 goto fail;
786
752 memcpy(&fe->ops.tuner_ops, &tda18271_tuner_ops, 787 memcpy(&fe->ops.tuner_ops, &tda18271_tuner_ops,
753 sizeof(struct dvb_tuner_ops)); 788 sizeof(struct dvb_tuner_ops));
754 789
755 fe->tuner_priv = priv;
756
757 tda18271_init_regs(fe); 790 tda18271_init_regs(fe);
758 791
759 return fe; 792 return fe;
793fail:
794 tda18271_release(fe);
795 return NULL;
760} 796}
761EXPORT_SYMBOL_GPL(tda18271_attach); 797EXPORT_SYMBOL_GPL(tda18271_attach);
762MODULE_DESCRIPTION("NXP TDA18271HD analog / digital tuner driver"); 798MODULE_DESCRIPTION("NXP TDA18271HD analog / digital tuner driver");