From: Stefan Ringel <linu...@stefanringel.de> Signed-off-by: Stefan Ringel <linu...@stefanringel.de> --- drivers/media/common/tuners/mt2063.c | 97 ++++++++++++++------------------- 1 files changed, 41 insertions(+), 56 deletions(-)
diff --git a/drivers/media/common/tuners/mt2063.c b/drivers/media/common/tuners/mt2063.c index e5d96e9..2a2cce3 100644 --- a/drivers/media/common/tuners/mt2063.c +++ b/drivers/media/common/tuners/mt2063.c @@ -261,22 +261,63 @@ static int mt2063_tune(struct mt2063_state *state) return 0; } +static int mt2063_set_analog_params(struct dvb_frontend *fe, + struct analog_parameters *params) { + struct mt2063_state *state = fe->tuner_priv; + u32 freq, bw; + int ret = 0; + dprintk(1, "\n"); + mutex_lock(&state->lock); + /* open gate */ + if (fe->ops.i2c_gate_ctrl) + fe->ops.i2c_gate_ctrl(fe, 1); + /* all calculation is in kHz */ + freq = params->frequency / 1000; + switch(params->mode) { + case V4L2_TUNER_RADIO: + state->mode = MT2063_OFFAIR_ANALOG; + state->if2 = 38900; + bw = 8000; /* TODO */ break; + case V4L2_TUNER_ANALOG_TV: + state->mode = MT2063_CABLE_ANALOG; + state->if2 = 38900; + if (params->std & ~V4L2_STD_MN) + bw = 6000; + else if (params->std & V4L2_STD_PAL_G) + bw = 7000; + else + bw = 8000; break; default: + ret = -EINVAL; + goto err; } + state->frequency = freq; + state->bw = bw; + dprintk(2, "Set input frequency to %d kHz.\n", freq); + ret = mt2063_set_mode(state, state->mode); + if (ret < 0) + goto err; + ret = mt2063_tune(state); +err: + /* close gate */ + if (fe->ops.i2c_gate_ctrl) + fe->ops.i2c_gate_ctrl(fe, 0); + mutex_unlock(&state->lock); + return ret; } { @@ -500,68 +541,12 @@ static int mt2063_release(struct dvb_frontend *fe) return 0; } -static int mt2063_set_analog_params(struct dvb_frontend *fe, - struct analog_parameters *params) { struct mt2063_state *state = fe->tuner_priv; - s32 pict_car; - s32 pict2chanb_vsb; - s32 ch_bw; - s32 if_mid; - s32 rcvr_mode; - int status; - - dprintk(2, "\n"); - - if (!state->init) { - status = mt2063_init(fe); - if (status < 0) - return status; - } - - switch (params->mode) { - case V4L2_TUNER_RADIO: - pict_car = 38900000; - ch_bw = 8000000; - pict2chanb_vsb = -(ch_bw / 2); - rcvr_mode = MT2063_OFFAIR_ANALOG; - break; - case V4L2_TUNER_ANALOG_TV: - rcvr_mode = MT2063_CABLE_ANALOG; - if (params->std & ~V4L2_STD_MN) { - pict_car = 38900000; - ch_bw = 6000000; - pict2chanb_vsb = -1250000; - } else if (params->std & V4L2_STD_PAL_G) { - pict_car = 38900000; - ch_bw = 7000000; - pict2chanb_vsb = -1250000; - } else { /* PAL/SECAM standards */ - pict_car = 38900000; - ch_bw = 8000000; - pict2chanb_vsb = -1250000; - } - break; - default: - return -EINVAL; - } - if_mid = pict_car - (pict2chanb_vsb + (ch_bw / 2)); - state->AS_Data.f_LO2_Step = 125000; /* FIXME: probably 5000 for FM */ - state->AS_Data.f_out = if_mid; - state->AS_Data.f_out_bw = ch_bw + 750000; - status = MT2063_SetReceiverMode(state, rcvr_mode); - if (status < 0) - return status; - dprintk(1, "Tuning to frequency: %d, bandwidth %d, foffset %d\n", - params->frequency, ch_bw, pict2chanb_vsb); - status = MT2063_Tune(state, (params->frequency + (pict2chanb_vsb + (ch_bw / 2)))); - if (status < 0) - return status; - state->frequency = params->frequency; return 0; } -- 1.7.7.6 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html