Instead of using DVBv3 parameters, rely on DVBv5 parameters to set the tuner. Signed-off-by: Mauro Carvalho Chehab <mchehab@xxxxxxxxxx> --- drivers/media/common/tuners/max2165.c | 60 ++++++++++++++++++++------------ 1 files changed, 37 insertions(+), 23 deletions(-) diff --git a/drivers/media/common/tuners/max2165.c b/drivers/media/common/tuners/max2165.c index 9883617..8558a63 100644 --- a/drivers/media/common/tuners/max2165.c +++ b/drivers/media/common/tuners/max2165.c @@ -150,11 +150,26 @@ static int max2165_set_osc(struct max2165_priv *priv, u8 osc /*MHz*/) static int max2165_set_bandwidth(struct max2165_priv *priv, u32 bw) { u8 val; + u32 newbw; - if (bw == BANDWIDTH_8_MHZ) - val = priv->bb_filter_8mhz_cfg; - else + if (bw <= 7000000) { val = priv->bb_filter_7mhz_cfg; + priv->bandwidth = BANDWIDTH_7_MHZ; + newbw = 7000000; + } else { + val = priv->bb_filter_8mhz_cfg; + priv->bandwidth = BANDWIDTH_8_MHZ; + newbw = 8000000; + } + + switch (bw) { + case 7000000: + case 8000000: + break; + default: + printk(KERN_INFO "MAX2165: bandwidth %d Hz not supported. using %d Hz instead\n", + bw, newbw); + } max2165_mask_write_reg(priv, REG_BASEBAND_CTRL, 0xF0, val << 4); @@ -261,35 +276,34 @@ static int max2165_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) { struct max2165_priv *priv = fe->tuner_priv; + struct dtv_frontend_properties *c = &fe->dtv_property_cache; + u32 delsys = c->delivery_system; int ret; - dprintk("%s() frequency=%d (Hz)\n", __func__, params->frequency); - if (fe->ops.info.type == FE_ATSC) { - return -EINVAL; - } else if (fe->ops.info.type == FE_OFDM) { + dprintk("%s() frequency=%d (Hz)\n", __func__, c->frequency); + + switch (delsys) { + case SYS_DVBT: + case SYS_DVBT2: dprintk("%s() OFDM\n", __func__); - switch (params->u.ofdm.bandwidth) { - case BANDWIDTH_6_MHZ: - return -EINVAL; - case BANDWIDTH_7_MHZ: - case BANDWIDTH_8_MHZ: - priv->frequency = params->frequency; - priv->bandwidth = params->u.ofdm.bandwidth; - break; - default: - printk(KERN_ERR "MAX2165 bandwidth not set!\n"); - return -EINVAL; - } - } else { - printk(KERN_ERR "MAX2165 modulation type not supported!\n"); + break; + /* + * FIXME: it is likely that this would work with DVB-C as well, + * at least for 7MHz/8MHz. If this is needed, all the code should + * do is to add a new "case SYS_DVBC_ANNEX_A" line. + */ + default: + printk(KERN_ERR "MAX2165: delivery system not supported!\n"); return -EINVAL; } + priv->frequency = c->frequency; + dprintk("%s() frequency=%d\n", __func__, priv->frequency); if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 1); - max2165_set_bandwidth(priv, priv->bandwidth); + max2165_set_bandwidth(priv, c->bandwidth_hz); ret = max2165_set_rf(priv, priv->frequency); mdelay(50); max2165_debug_status(priv); @@ -370,7 +384,7 @@ static int max2165_init(struct dvb_frontend *fe) max2165_read_rom_table(priv); - max2165_set_bandwidth(priv, BANDWIDTH_8_MHZ); + max2165_set_bandwidth(priv, 8000000); if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0); -- 1.7.8.352.g876a6 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html