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; mutex_lock(&priv->lock); tda18271_read_regs(fe); mutex_unlock(&priv->lock); switch (regs[R_ID] & 0x7f) { case 3: name = "TDA18271HD/C1"; priv->id = TDA18271HDC1; break; case 4: name = "TDA18271HD/C2"; priv->id = TDA18271HDC2; break; default: name = "Unknown device"; ret = -EINVAL; break; } tda_info("%s detected @ %d-%04x%s\n", name, i2c_adapter_id(priv->i2c_props.adap), priv->i2c_props.addr, (0 == ret) ? "" : ", device not supported."); return ret; }
static int tda18271_read_thermometer(struct dvb_frontend *fe) { struct tda18271_priv *priv = fe->tuner_priv; unsigned char *regs = priv->tda18271_regs; int tm; /* switch thermometer on */ regs[R_TM] |= 0x10; tda18271_write_regs(fe, R_TM, 1); /* read thermometer info */ tda18271_read_regs(fe); if ((((regs[R_TM] & 0x0f) == 0x00) && ((regs[R_TM] & 0x20) == 0x20)) || (((regs[R_TM] & 0x0f) == 0x08) && ((regs[R_TM] & 0x20) == 0x00))) { if ((regs[R_TM] & 0x20) == 0x20) regs[R_TM] &= ~0x20; else regs[R_TM] |= 0x20; tda18271_write_regs(fe, R_TM, 1); msleep(10); /* temperature sensing */ /* read thermometer info */ tda18271_read_regs(fe); } tm = tda18271_lookup_thermometer(fe); /* switch thermometer off */ regs[R_TM] &= ~0x10; tda18271_write_regs(fe, R_TM, 1); /* set CAL mode to normal */ regs[R_EP4] &= ~0x03; tda18271_write_regs(fe, R_EP4, 1); return tm; }
static int tda18271_read_thermometer(struct dvb_frontend *fe) { struct tda18271_priv *priv = fe->tuner_priv; unsigned char *regs = priv->tda18271_regs; int tm; regs[R_TM] |= 0x10; tda18271_write_regs(fe, R_TM, 1); tda18271_read_regs(fe); if ((((regs[R_TM] & 0x0f) == 0x00) && ((regs[R_TM] & 0x20) == 0x20)) || (((regs[R_TM] & 0x0f) == 0x08) && ((regs[R_TM] & 0x20) == 0x00))) { if ((regs[R_TM] & 0x20) == 0x20) regs[R_TM] &= ~0x20; else regs[R_TM] |= 0x20; tda18271_write_regs(fe, R_TM, 1); msleep(10); tda18271_read_regs(fe); } tm = tda18271_lookup_thermometer(fe); regs[R_TM] &= ~0x10; tda18271_write_regs(fe, R_TM, 1); regs[R_EP4] &= ~0x03; tda18271_write_regs(fe, R_EP4, 1); return tm; }
static int tda18271_ir_cal_init(struct dvb_frontend *fe) { struct tda18271_priv *priv = fe->tuner_priv; unsigned char *regs = priv->tda18271_regs; int ret; ret = tda18271_read_regs(fe); if (tda_fail(ret)) goto fail; /* test IR_CAL_OK to see if we need init */ if ((regs[R_EP1] & 0x08) == 0) ret = tda18271_init_regs(fe); fail: return ret; }
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; mutex_lock(&priv->lock); ret = tda18271_read_regs(fe); mutex_unlock(&priv->lock); if (ret) { tda_info("Error reading device ID @ %d-%04x, bailing out.\n", i2c_adapter_id(priv->i2c_props.adap), priv->i2c_props.addr); return -EIO; } switch (regs[R_ID] & 0x7f) { case 3: name = "TDA18271HD/C1"; priv->id = TDA18271HDC1; break; case 4: name = "TDA18271HD/C2"; priv->id = TDA18271HDC2; break; default: tda_info("Unknown device (%i) detected @ %d-%04x, device not supported.\n", regs[R_ID], i2c_adapter_id(priv->i2c_props.adap), priv->i2c_props.addr); return -EINVAL; } tda_info("%s detected @ %d-%04x\n", name, i2c_adapter_id(priv->i2c_props.adap), priv->i2c_props.addr); return 0; }