static int tda18271_tune(struct dvb_frontend *fe, struct tda18271_std_map_item *map, u32 freq, u32 bw) { struct tda18271_priv *priv = fe->tuner_priv; int ret; tda_dbg("freq = %d, ifc = %d, bw = %d, agc_mode = %d, std = %d\n", freq, map->if_freq, bw, map->agc_mode, map->std); ret = tda18271_agc(fe); if (tda_fail(ret)) tda_warn("failed to configure agc\n"); ret = tda18271_init(fe); if (tda_fail(ret)) goto fail; mutex_lock(&priv->lock); switch (priv->id) { case TDA18271HDC1: tda18271c1_rf_tracking_filter_calibration(fe, freq, bw); break; case TDA18271HDC2: tda18271c2_rf_tracking_filters_correction(fe, freq); break; } ret = tda18271_channel_configuration(fe, map, freq, bw); mutex_unlock(&priv->lock); fail: return ret; }
static int tda18271_set_params(struct dvb_frontend *fe) { struct dtv_frontend_properties *c = &fe->dtv_property_cache; u32 delsys = c->delivery_system; u32 bw = c->bandwidth_hz; u32 freq = c->frequency; struct tda18271_priv *priv = fe->tuner_priv; struct tda18271_std_map *std_map = &priv->std; struct tda18271_std_map_item *map; int ret; priv->mode = TDA18271_DIGITAL; switch (delsys) { case SYS_ATSC: map = &std_map->atsc_6; bw = 6000000; break; case SYS_ISDBT: case SYS_DVBT: case SYS_DVBT2: if (bw <= 6000000) { map = &std_map->dvbt_6; } else if (bw <= 7000000) { map = &std_map->dvbt_7; } else { map = &std_map->dvbt_8; } break; case SYS_DVBC_ANNEX_B: bw = 6000000; /* falltrough */ case SYS_DVBC_ANNEX_A: case SYS_DVBC_ANNEX_C: if (bw <= 6000000) { map = &std_map->qam_6; } else if (bw <= 7000000) { map = &std_map->qam_7; } else { map = &std_map->qam_8; } break; default: tda_warn("modulation type not supported!\n"); return -EINVAL; } /* When tuning digital, the analog demod must be tri-stated */ if (fe->ops.analog_ops.standby) fe->ops.analog_ops.standby(fe); ret = tda18271_tune(fe, map, freq, bw); if (tda_fail(ret)) goto fail; priv->if_freq = map->if_freq; priv->frequency = freq; priv->bandwidth = bw; fail: return ret; }
static int tda18271_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) { struct tda18271_priv *priv = fe->tuner_priv; struct tda18271_std_map *std_map = &priv->std; struct tda18271_std_map_item *map; int ret; u32 bw, freq = params->frequency; priv->mode = TDA18271_DIGITAL; if (fe->ops.info.type == FE_ATSC) { switch (params->u.vsb.modulation) { case VSB_8: case VSB_16: map = &std_map->atsc_6; break; case QAM_64: case QAM_256: map = &std_map->qam_6; break; default: tda_warn("modulation not set!\n"); return -EINVAL; } #if 0 /* keep */ /* userspace request is already center adjusted */ freq += 1750000; /* Adjust to center (+1.75MHZ) */ #endif bw = 6000000; } else if (fe->ops.info.type == FE_OFDM) { switch (params->u.ofdm.bandwidth) { case BANDWIDTH_6_MHZ: bw = 6000000; map = &std_map->dvbt_6; break; case BANDWIDTH_7_MHZ: bw = 7000000; map = &std_map->dvbt_7; break; case BANDWIDTH_8_MHZ: bw = 8000000; map = &std_map->dvbt_8; break; default: tda_warn("bandwidth not set!\n"); return -EINVAL; } } else { tda_warn("modulation type not supported!\n"); return -EINVAL; } /* When tuning digital, the analog demod must be tri-stated */ if (fe->ops.analog_ops.standby) fe->ops.analog_ops.standby(fe); ret = tda18271_tune(fe, map, freq, bw); if (tda_fail(ret)) goto fail; priv->frequency = freq; priv->bandwidth = (fe->ops.info.type == FE_OFDM) ? params->u.ofdm.bandwidth : 0; fail: return ret; }