static int tda18271_por(struct dvb_frontend *fe) { struct tda18271_priv *priv = fe->tuner_priv; unsigned char *regs = priv->tda18271_regs; int ret; /* power up detector 1 */ regs[R_EB12] &= ~0x20; ret = tda18271_write_regs(fe, R_EB12, 1); if (tda_fail(ret)) goto fail; regs[R_EB18] &= ~0x80; /* turn agc1 loop on */ regs[R_EB18] &= ~0x03; /* set agc1_gain to 6 dB */ ret = tda18271_write_regs(fe, R_EB18, 1); if (tda_fail(ret)) goto fail; regs[R_EB21] |= 0x03; /* set agc2_gain to -6 dB */ /* POR mode */ ret = tda18271_set_standby_mode(fe, 1, 0, 0); if (tda_fail(ret)) goto fail; /* disable 1.5 MHz low pass filter */ regs[R_EB23] &= ~0x04; /* forcelp_fc2_en = 0 */ regs[R_EB23] &= ~0x02; /* XXX: lp_fc[2] = 0 */ ret = tda18271_write_regs(fe, R_EB21, 3); fail: return ret; }
static int tda18271_por(struct dvb_frontend *fe) { struct tda18271_priv *priv = fe->tuner_priv; unsigned char *regs = priv->tda18271_regs; int ret; regs[R_EB12] &= ~0x20; ret = tda18271_write_regs(fe, R_EB12, 1); if (tda_fail(ret)) goto fail; regs[R_EB18] &= ~0x80; regs[R_EB18] &= ~0x03; ret = tda18271_write_regs(fe, R_EB18, 1); if (tda_fail(ret)) goto fail; regs[R_EB21] |= 0x03; ret = tda18271_set_standby_mode(fe, 1, 0, 0); if (tda_fail(ret)) goto fail; regs[R_EB23] &= ~0x04; regs[R_EB23] &= ~0x02; ret = tda18271_write_regs(fe, R_EB21, 3); fail: return ret; }
static int tda18271c2_rf_tracking_filters_correction(struct dvb_frontend *fe, u32 freq) { struct tda18271_priv *priv = fe->tuner_priv; struct tda18271_rf_tracking_filter_cal *map = priv->rf_cal_state; unsigned char *regs = priv->tda18271_regs; int i, ret; u8 tm_current, dc_over_dt, rf_tab; s32 rfcal_comp, approx; /* power up */ ret = tda18271_set_standby_mode(fe, 0, 0, 0); if (tda_fail(ret)) goto fail; /* read die current temperature */ tm_current = tda18271_read_thermometer(fe); /* frequency dependent parameters */ tda18271_calc_rf_cal(fe, &freq); rf_tab = regs[R_EB14]; i = tda18271_lookup_rf_band(fe, &freq, NULL); if (tda_fail(i)) return i; if ((0 == map[i].rf3) || (freq / 1000 < map[i].rf2)) { approx = map[i].rf_a1 * (s32)(freq / 1000 - map[i].rf1) + map[i].rf_b1 + rf_tab; } else { approx = map[i].rf_a2 * (s32)(freq / 1000 - map[i].rf2) + map[i].rf_b2 + rf_tab; } if (approx < 0) approx = 0; if (approx > 255) approx = 255; tda18271_lookup_map(fe, RF_CAL_DC_OVER_DT, &freq, &dc_over_dt); /* calculate temperature compensation */ rfcal_comp = dc_over_dt * (s32)(tm_current - priv->tm_rfcal) / 1000; regs[R_EB14] = (unsigned char)(approx + rfcal_comp); ret = tda18271_write_regs(fe, R_EB14, 1); fail: return ret; }
static int tda18271_toggle_output(struct dvb_frontend *fe, int standby) { struct tda18271_priv *priv = fe->tuner_priv; int ret = tda18271_set_standby_mode(fe, standby ? 1 : 0, priv->output_opt & TDA18271_OUTPUT_LT_OFF ? 1 : 0, priv->output_opt & TDA18271_OUTPUT_XT_OFF ? 1 : 0); if (tda_fail(ret)) goto fail; tda_dbg("%s mode: xtal oscillator %s, slave tuner loop thru %s\n", standby ? "standby" : "active", priv->output_opt & TDA18271_OUTPUT_XT_OFF ? "off" : "on", priv->output_opt & TDA18271_OUTPUT_LT_OFF ? "off" : "on"); fail: return ret; }
static int tda18271_init(struct dvb_frontend *fe) { struct tda18271_priv *priv = fe->tuner_priv; int ret; mutex_lock(&priv->lock); /* full power up */ ret = tda18271_set_standby_mode(fe, 0, 0, 0); if (tda_fail(ret)) goto fail; /* initialization */ ret = tda18271_ir_cal_init(fe); if (tda_fail(ret)) goto fail; if (priv->id == TDA18271HDC2) tda18271c2_rf_cal_init(fe); fail: mutex_unlock(&priv->lock); return ret; }