mirror of https://gitee.com/openkylin/linux.git
[media] rtl2832: properly set en_bbin for r820t
DVBT_EN_BBIN should be set on both places where IF is set. So, move it to a function and call it where needed. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com> Tested-by: Antti Palosaari <crope@iki.fi>
This commit is contained in:
parent
a7dd065f49
commit
884655ad2e
|
@ -380,13 +380,37 @@ static int rtl2832_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
|
|||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static int rtl2832_set_if(struct dvb_frontend *fe, u32 if_freq)
|
||||
{
|
||||
struct rtl2832_priv *priv = fe->demodulator_priv;
|
||||
int ret;
|
||||
u64 pset_iffreq;
|
||||
u8 en_bbin = (if_freq == 0 ? 0x1 : 0x0);
|
||||
|
||||
/*
|
||||
* PSET_IFFREQ = - floor((IfFreqHz % CrystalFreqHz) * pow(2, 22)
|
||||
* / CrystalFreqHz)
|
||||
*/
|
||||
|
||||
pset_iffreq = if_freq % priv->cfg.xtal;
|
||||
pset_iffreq *= 0x400000;
|
||||
pset_iffreq = div_u64(pset_iffreq, priv->cfg.xtal);
|
||||
pset_iffreq = pset_iffreq & 0x3fffff;
|
||||
ret = rtl2832_wr_demod_reg(priv, DVBT_EN_BBIN, en_bbin);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = rtl2832_wr_demod_reg(priv, DVBT_PSET_IFFREQ, pset_iffreq);
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static int rtl2832_init(struct dvb_frontend *fe)
|
||||
{
|
||||
struct rtl2832_priv *priv = fe->demodulator_priv;
|
||||
int i, ret, len;
|
||||
u8 en_bbin;
|
||||
u64 pset_iffreq;
|
||||
const struct rtl2832_reg_value *init;
|
||||
int i, ret, len;
|
||||
|
||||
/* initialization values for the demodulator registers */
|
||||
struct rtl2832_reg_value rtl2832_initial_regs[] = {
|
||||
|
@ -436,8 +460,6 @@ static int rtl2832_init(struct dvb_frontend *fe)
|
|||
|
||||
dev_dbg(&priv->i2c->dev, "%s:\n", __func__);
|
||||
|
||||
en_bbin = (priv->cfg.if_dvbt == 0 ? 0x1 : 0x0);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(rtl2832_initial_regs); i++) {
|
||||
ret = rtl2832_wr_demod_reg(priv, rtl2832_initial_regs[i].reg,
|
||||
rtl2832_initial_regs[i].value);
|
||||
|
@ -477,27 +499,10 @@ static int rtl2832_init(struct dvb_frontend *fe)
|
|||
goto err;
|
||||
}
|
||||
|
||||
/*
|
||||
* if frequency settings
|
||||
* Some tuners (r820t) don't initialize IF here; instead; they do it
|
||||
* at set_params()
|
||||
*/
|
||||
if (!fe->ops.tuner_ops.get_if_frequency) {
|
||||
/*
|
||||
* PSET_IFFREQ = - floor((IfFreqHz % CrystalFreqHz) * pow(2, 22)
|
||||
* / CrystalFreqHz)
|
||||
*/
|
||||
pset_iffreq = priv->cfg.if_dvbt % priv->cfg.xtal;
|
||||
pset_iffreq *= 0x400000;
|
||||
pset_iffreq = div_u64(pset_iffreq, priv->cfg.xtal);
|
||||
pset_iffreq = pset_iffreq & 0x3fffff;
|
||||
ret = rtl2832_wr_demod_reg(priv, DVBT_EN_BBIN, en_bbin);
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
ret = rtl2832_wr_demod_reg(priv, DVBT_PSET_IFFREQ, pset_iffreq);
|
||||
if (ret)
|
||||
goto err;
|
||||
ret = rtl2832_set_if(fe, priv->cfg.if_dvbt);
|
||||
if (ret)
|
||||
goto err;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -590,18 +595,12 @@ static int rtl2832_set_frontend(struct dvb_frontend *fe)
|
|||
/* If the frontend has get_if_frequency(), use it */
|
||||
if (fe->ops.tuner_ops.get_if_frequency) {
|
||||
u32 if_freq;
|
||||
u64 pset_iffreq;
|
||||
|
||||
ret = fe->ops.tuner_ops.get_if_frequency(fe, &if_freq);
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
pset_iffreq = if_freq % priv->cfg.xtal;
|
||||
pset_iffreq *= 0x400000;
|
||||
pset_iffreq = div_u64(pset_iffreq, priv->cfg.xtal);
|
||||
pset_iffreq = pset_iffreq & 0x3fffff;
|
||||
|
||||
ret = rtl2832_wr_demod_reg(priv, DVBT_PSET_IFFREQ, pset_iffreq);
|
||||
ret = rtl2832_set_if(fe, if_freq);
|
||||
if (ret)
|
||||
goto err;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue