diff options
author | Michael Krufky <mkrufky@linuxtv.org> | 2007-12-24 02:15:20 -0500 |
---|---|---|
committer | Michael Krufky <mkrufky@linuxtv.org> | 2007-12-24 02:15:20 -0500 |
commit | 6349ddb1bab66c5e2584d244b06c62bbedfea6c2 (patch) | |
tree | f7fcf626cd79139f29426d05f72ab513b68fcd93 /linux | |
parent | 7d5aefb40335b61b494bf1cf936e68dd7ee7038e (diff) | |
download | mediapointer-dvb-s2-6349ddb1bab66c5e2584d244b06c62bbedfea6c2.tar.gz mediapointer-dvb-s2-6349ddb1bab66c5e2584d244b06c62bbedfea6c2.tar.bz2 |
tda18271: check ID register during attach
From: Michael Krufky <mkrufky@linuxtv.org>
Identify the silicon during attach, return NULL if unsupported device.
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Diffstat (limited to 'linux')
-rw-r--r-- | linux/drivers/media/dvb/frontends/tda18271-fe.c | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/linux/drivers/media/dvb/frontends/tda18271-fe.c b/linux/drivers/media/dvb/frontends/tda18271-fe.c index 37e778dcb..011b2cac8 100644 --- a/linux/drivers/media/dvb/frontends/tda18271-fe.c +++ b/linux/drivers/media/dvb/frontends/tda18271-fe.c @@ -725,6 +725,36 @@ static int tda18271_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth) return 0; } +static int tda18271_get_id(struct dvb_frontend *fe) +{ + struct tda18271_priv *priv = fe->tuner_priv; + unsigned char *regs = priv->tda18271_regs; + char *name; + int ret = 0; + + tda18271_read_regs(fe); + + switch (regs[R_ID] & 0x7f) { + case 3: + name = "TDA18271HD/C1"; + break; + case 4: + name = "TDA18271HD/C2"; + ret = -EPROTONOSUPPORT; + break; + default: + name = "Unknown device"; + ret = -EINVAL; + break; + } + + dbg_info("%s detected @ %d-%04x%s\n", name, + i2c_adapter_id(priv->i2c_adap), priv->i2c_addr, + (0 == ret) ? "" : ", device not supported."); + + return ret; +} + static struct dvb_tuner_ops tda18271_tuner_ops = { .info = { .name = "NXP TDA18271HD", @@ -755,14 +785,20 @@ struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr, priv->i2c_adap = i2c; priv->gate = gate; + fe->tuner_priv = priv; + + if (tda18271_get_id(fe) < 0) + goto fail; + memcpy(&fe->ops.tuner_ops, &tda18271_tuner_ops, sizeof(struct dvb_tuner_ops)); - fe->tuner_priv = priv; - tda18271_init_regs(fe); return fe; +fail: + tda18271_release(fe); + return NULL; } EXPORT_SYMBOL_GPL(tda18271_attach); MODULE_DESCRIPTION("NXP TDA18271HD analog / digital tuner driver"); |