Commit 77d67504 authored by Michael Krufky's avatar Michael Krufky Committed by Mauro Carvalho Chehab

V4L/DVB (5632): Dvb-pll: pass dvb_frontend_parameters to generic set() function

Rename dvb_pll_desc.setbw() to set(), and accept struct dvb_frontend_parameters
instead of passing both freq and bandwidth, so that this may be used as a
generic function.

In order to do this, dvb_pll_configure must also be altered in the same manner,
to take struct dvb_frontend_parameters instead of freq and bandwidth.
Signed-off-by: default avatarMichael Krufky <mkrufky@linuxtv.org>
Signed-off-by: default avatarTrent Piepho <xyzzy@speakeasy.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent 900858ec
...@@ -90,7 +90,7 @@ int dvb_usb_tuner_calc_regs(struct dvb_frontend *fe, struct dvb_frontend_paramet ...@@ -90,7 +90,7 @@ int dvb_usb_tuner_calc_regs(struct dvb_frontend *fe, struct dvb_frontend_paramet
deb_pll("pll addr: %x, freq: %d %p\n",adap->pll_addr, fep->frequency, adap->pll_desc); deb_pll("pll addr: %x, freq: %d %p\n",adap->pll_addr, fep->frequency, adap->pll_desc);
b[0] = adap->pll_addr; b[0] = adap->pll_addr;
dvb_pll_configure(adap->pll_desc, &b[1], fep->frequency, fep->u.ofdm.bandwidth); dvb_pll_configure(adap->pll_desc, &b[1], fep);
deb_pll("pll-buf: %x %x %x %x %x\n",b[0],b[1],b[2],b[3],b[4]); deb_pll("pll-buf: %x %x %x %x %x\n",b[0],b[1],b[2],b[3],b[4]);
......
...@@ -68,9 +68,10 @@ struct dvb_pll_desc dvb_pll_thomson_dtt7610 = { ...@@ -68,9 +68,10 @@ struct dvb_pll_desc dvb_pll_thomson_dtt7610 = {
}; };
EXPORT_SYMBOL(dvb_pll_thomson_dtt7610); EXPORT_SYMBOL(dvb_pll_thomson_dtt7610);
static void thomson_dtt759x_bw(u8 *buf, u32 freq, int bandwidth) static void thomson_dtt759x_bw(u8 *buf,
const struct dvb_frontend_parameters *params)
{ {
if (BANDWIDTH_7_MHZ == bandwidth) if (BANDWIDTH_7_MHZ == params->u.ofdm.bandwidth)
buf[3] |= 0x10; buf[3] |= 0x10;
} }
...@@ -78,7 +79,7 @@ struct dvb_pll_desc dvb_pll_thomson_dtt759x = { ...@@ -78,7 +79,7 @@ struct dvb_pll_desc dvb_pll_thomson_dtt759x = {
.name = "Thomson dtt759x", .name = "Thomson dtt759x",
.min = 177000000, .min = 177000000,
.max = 896000000, .max = 896000000,
.setbw = thomson_dtt759x_bw, .set = thomson_dtt759x_bw,
.iffreq= 36166667, .iffreq= 36166667,
.sleepdata = (u8[]){ 2, 0x84, 0x03 }, .sleepdata = (u8[]){ 2, 0x84, 0x03 },
.count = 5, .count = 5,
...@@ -195,9 +196,9 @@ EXPORT_SYMBOL(dvb_pll_env57h1xd5); ...@@ -195,9 +196,9 @@ EXPORT_SYMBOL(dvb_pll_env57h1xd5);
/* Philips TDA6650/TDA6651 /* Philips TDA6650/TDA6651
* used in Panasonic ENV77H11D5 * used in Panasonic ENV77H11D5
*/ */
static void tda665x_bw(u8 *buf, u32 freq, int bandwidth) static void tda665x_bw(u8 *buf, const struct dvb_frontend_parameters *params)
{ {
if (bandwidth == BANDWIDTH_8_MHZ) if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ)
buf[3] |= 0x08; buf[3] |= 0x08;
} }
...@@ -205,7 +206,7 @@ struct dvb_pll_desc dvb_pll_tda665x = { ...@@ -205,7 +206,7 @@ struct dvb_pll_desc dvb_pll_tda665x = {
.name = "Philips TDA6650/TDA6651", .name = "Philips TDA6650/TDA6651",
.min = 44250000, .min = 44250000,
.max = 858000000, .max = 858000000,
.setbw = tda665x_bw, .set = tda665x_bw,
.iffreq= 36166667, .iffreq= 36166667,
.count = 12, .count = 12,
.entries = { .entries = {
...@@ -228,9 +229,9 @@ EXPORT_SYMBOL(dvb_pll_tda665x); ...@@ -228,9 +229,9 @@ EXPORT_SYMBOL(dvb_pll_tda665x);
/* Infineon TUA6034 /* Infineon TUA6034
* used in LG TDTP E102P * used in LG TDTP E102P
*/ */
static void tua6034_bw(u8 *buf, u32 freq, int bandwidth) static void tua6034_bw(u8 *buf, const struct dvb_frontend_parameters *params)
{ {
if (BANDWIDTH_7_MHZ != bandwidth) if (BANDWIDTH_7_MHZ != params->u.ofdm.bandwidth)
buf[3] |= 0x08; buf[3] |= 0x08;
} }
...@@ -240,7 +241,7 @@ struct dvb_pll_desc dvb_pll_tua6034 = { ...@@ -240,7 +241,7 @@ struct dvb_pll_desc dvb_pll_tua6034 = {
.max = 858000000, .max = 858000000,
.iffreq= 36166667, .iffreq= 36166667,
.count = 3, .count = 3,
.setbw = tua6034_bw, .set = tua6034_bw,
.entries = { .entries = {
{ 174500000, 62500, 0xce, 0x01 }, { 174500000, 62500, 0xce, 0x01 },
{ 230000000, 62500, 0xce, 0x02 }, { 230000000, 62500, 0xce, 0x02 },
...@@ -270,9 +271,10 @@ EXPORT_SYMBOL(dvb_pll_lg_tdvs_h06xf); ...@@ -270,9 +271,10 @@ EXPORT_SYMBOL(dvb_pll_lg_tdvs_h06xf);
/* Philips FMD1216ME /* Philips FMD1216ME
* used in Medion Hybrid PCMCIA card and USB Box * used in Medion Hybrid PCMCIA card and USB Box
*/ */
static void fmd1216me_bw(u8 *buf, u32 freq, int bandwidth) static void fmd1216me_bw(u8 *buf, const struct dvb_frontend_parameters *params)
{ {
if (bandwidth == BANDWIDTH_8_MHZ && freq >= 158870000) if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ &&
params->frequency >= 158870000)
buf[3] |= 0x08; buf[3] |= 0x08;
} }
...@@ -281,7 +283,7 @@ struct dvb_pll_desc dvb_pll_fmd1216me = { ...@@ -281,7 +283,7 @@ struct dvb_pll_desc dvb_pll_fmd1216me = {
.min = 50870000, .min = 50870000,
.max = 858000000, .max = 858000000,
.iffreq= 36125000, .iffreq= 36125000,
.setbw = fmd1216me_bw, .set = fmd1216me_bw,
.count = 7, .count = 7,
.entries = { .entries = {
{ 143870000, 166667, 0xbc, 0x41 }, { 143870000, 166667, 0xbc, 0x41 },
...@@ -298,9 +300,9 @@ EXPORT_SYMBOL(dvb_pll_fmd1216me); ...@@ -298,9 +300,9 @@ EXPORT_SYMBOL(dvb_pll_fmd1216me);
/* ALPS TDED4 /* ALPS TDED4
* used in Nebula-Cards and USB boxes * used in Nebula-Cards and USB boxes
*/ */
static void tded4_bw(u8 *buf, u32 freq, int bandwidth) static void tded4_bw(u8 *buf, const struct dvb_frontend_parameters *params)
{ {
if (bandwidth == BANDWIDTH_8_MHZ) if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ)
buf[3] |= 0x04; buf[3] |= 0x04;
} }
...@@ -309,7 +311,7 @@ struct dvb_pll_desc dvb_pll_tded4 = { ...@@ -309,7 +311,7 @@ struct dvb_pll_desc dvb_pll_tded4 = {
.min = 47000000, .min = 47000000,
.max = 863000000, .max = 863000000,
.iffreq= 36166667, .iffreq= 36166667,
.setbw = tded4_bw, .set = tded4_bw,
.count = 4, .count = 4,
.entries = { .entries = {
{ 153000000, 166667, 0x85, 0x01 }, { 153000000, 166667, 0x85, 0x01 },
...@@ -396,14 +398,14 @@ EXPORT_SYMBOL(dvb_pll_philips_sd1878_tda8261); ...@@ -396,14 +398,14 @@ EXPORT_SYMBOL(dvb_pll_philips_sd1878_tda8261);
/* /*
* Philips TD1316 Tuner. * Philips TD1316 Tuner.
*/ */
static void td1316_bw(u8 *buf, u32 freq, int bandwidth) static void td1316_bw(u8 *buf, const struct dvb_frontend_parameters *params)
{ {
u8 band; u8 band;
/* determine band */ /* determine band */
if (freq < 161000000) if (params->frequency < 161000000)
band = 1; band = 1;
else if (freq < 444000000) else if (params->frequency < 444000000)
band = 2; band = 2;
else else
band = 4; band = 4;
...@@ -411,7 +413,7 @@ static void td1316_bw(u8 *buf, u32 freq, int bandwidth) ...@@ -411,7 +413,7 @@ static void td1316_bw(u8 *buf, u32 freq, int bandwidth)
buf[3] |= band; buf[3] |= band;
/* setup PLL filter */ /* setup PLL filter */
if (bandwidth == BANDWIDTH_8_MHZ) if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ)
buf[3] |= 1 << 3; buf[3] |= 1 << 3;
} }
...@@ -420,7 +422,7 @@ struct dvb_pll_desc dvb_pll_philips_td1316 = { ...@@ -420,7 +422,7 @@ struct dvb_pll_desc dvb_pll_philips_td1316 = {
.min = 87000000, .min = 87000000,
.max = 895000000, .max = 895000000,
.iffreq= 36166667, .iffreq= 36166667,
.setbw = td1316_bw, .set = td1316_bw,
.count = 9, .count = 9,
.entries = { .entries = {
{ 93834000, 166667, 0xca, 0x60}, { 93834000, 166667, 0xca, 0x60},
...@@ -451,9 +453,9 @@ struct dvb_pll_desc dvb_pll_thomson_fe6600 = { ...@@ -451,9 +453,9 @@ struct dvb_pll_desc dvb_pll_thomson_fe6600 = {
} }
}; };
EXPORT_SYMBOL(dvb_pll_thomson_fe6600); EXPORT_SYMBOL(dvb_pll_thomson_fe6600);
static void opera1_bw(u8 *buf, u32 freq, int bandwidth) static void opera1_bw(u8 *buf, const struct dvb_frontend_parameters *params)
{ {
if (bandwidth == BANDWIDTH_8_MHZ) if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ)
buf[2] |= 0x08; buf[2] |= 0x08;
} }
...@@ -462,7 +464,7 @@ struct dvb_pll_desc dvb_pll_opera1 = { ...@@ -462,7 +464,7 @@ struct dvb_pll_desc dvb_pll_opera1 = {
.min = 900000, .min = 900000,
.max = 2250000, .max = 2250000,
.iffreq= 0, .iffreq= 0,
.setbw = opera1_bw, .set = opera1_bw,
.count = 8, .count = 8,
.entries = { .entries = {
{ 1064000, 500, 0xe5, 0xc6 }, { 1064000, 500, 0xe5, 0xc6 },
...@@ -498,34 +500,36 @@ module_param(debug, int, 0644); ...@@ -498,34 +500,36 @@ module_param(debug, int, 0644);
MODULE_PARM_DESC(debug, "enable verbose debug messages"); MODULE_PARM_DESC(debug, "enable verbose debug messages");
int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf, int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf,
u32 freq, int bandwidth) const struct dvb_frontend_parameters *params)
{ {
u32 div; u32 div;
int i; int i;
if (freq != 0 && (freq < desc->min || freq > desc->max)) if (params->frequency != 0 && (params->frequency < desc->min ||
params->frequency > desc->max))
return -EINVAL; return -EINVAL;
for (i = 0; i < desc->count; i++) { for (i = 0; i < desc->count; i++) {
if (freq > desc->entries[i].limit) if (params->frequency > desc->entries[i].limit)
continue; continue;
break; break;
} }
if (debug) if (debug)
printk("pll: %s: freq=%d bw=%d | i=%d/%d\n", printk("pll: %s: freq=%d | i=%d/%d\n", desc->name,
desc->name, freq, bandwidth, i, desc->count); params->frequency, i, desc->count);
if (i == desc->count) if (i == desc->count)
return -EINVAL; return -EINVAL;
div = (freq + desc->iffreq + desc->entries[i].stepsize/2) / div = (params->frequency + desc->iffreq +
desc->entries[i].stepsize; desc->entries[i].stepsize/2) / desc->entries[i].stepsize;
buf[0] = div >> 8; buf[0] = div >> 8;
buf[1] = div & 0xff; buf[1] = div & 0xff;
buf[2] = desc->entries[i].config; buf[2] = desc->entries[i].config;
buf[3] = desc->entries[i].cb; buf[3] = desc->entries[i].cb;
if (desc->setbw) if (desc->set)
desc->setbw(buf, freq, bandwidth); desc->set(buf, params);
if (debug) if (debug)
printk("pll: %s: div=%d | buf=0x%02x,0x%02x,0x%02x,0x%02x\n", printk("pll: %s: div=%d | buf=0x%02x,0x%02x,0x%02x,0x%02x\n",
...@@ -578,18 +582,12 @@ static int dvb_pll_set_params(struct dvb_frontend *fe, ...@@ -578,18 +582,12 @@ static int dvb_pll_set_params(struct dvb_frontend *fe,
{ .addr = priv->pll_i2c_address, .flags = 0, { .addr = priv->pll_i2c_address, .flags = 0,
.buf = buf, .len = sizeof(buf) }; .buf = buf, .len = sizeof(buf) };
int result; int result;
u32 bandwidth = 0, frequency = 0; u32 frequency = 0;
if (priv->i2c == NULL) if (priv->i2c == NULL)
return -EINVAL; return -EINVAL;
// DVBT bandwidth only just now if ((result = dvb_pll_configure(priv->pll_desc, buf, params)) < 0)
if (fe->ops.info.type == FE_OFDM) {
bandwidth = params->u.ofdm.bandwidth;
}
if ((result = dvb_pll_configure(priv->pll_desc, buf,
params->frequency, bandwidth)) < 0)
return result; return result;
else else
frequency = result; frequency = result;
...@@ -601,7 +599,7 @@ static int dvb_pll_set_params(struct dvb_frontend *fe, ...@@ -601,7 +599,7 @@ static int dvb_pll_set_params(struct dvb_frontend *fe,
} }
priv->frequency = frequency; priv->frequency = frequency;
priv->bandwidth = bandwidth; priv->bandwidth = (fe->ops.info.type == FE_OFDM) ? params->u.ofdm.bandwidth : 0;
return 0; return 0;
} }
...@@ -612,18 +610,12 @@ static int dvb_pll_calc_regs(struct dvb_frontend *fe, ...@@ -612,18 +610,12 @@ static int dvb_pll_calc_regs(struct dvb_frontend *fe,
{ {
struct dvb_pll_priv *priv = fe->tuner_priv; struct dvb_pll_priv *priv = fe->tuner_priv;
int result; int result;
u32 bandwidth = 0, frequency = 0; u32 frequency = 0;
if (buf_len < 5) if (buf_len < 5)
return -EINVAL; return -EINVAL;
// DVBT bandwidth only just now if ((result = dvb_pll_configure(priv->pll_desc, buf+1, params)) < 0)
if (fe->ops.info.type == FE_OFDM) {
bandwidth = params->u.ofdm.bandwidth;
}
if ((result = dvb_pll_configure(priv->pll_desc, buf+1,
params->frequency, bandwidth)) < 0)
return result; return result;
else else
frequency = result; frequency = result;
...@@ -631,7 +623,7 @@ static int dvb_pll_calc_regs(struct dvb_frontend *fe, ...@@ -631,7 +623,7 @@ static int dvb_pll_calc_regs(struct dvb_frontend *fe,
buf[0] = priv->pll_i2c_address; buf[0] = priv->pll_i2c_address;
priv->frequency = frequency; priv->frequency = frequency;
priv->bandwidth = bandwidth; priv->bandwidth = (fe->ops.info.type == FE_OFDM) ? params->u.ofdm.bandwidth : 0;
return 5; return 5;
} }
......
...@@ -13,7 +13,7 @@ struct dvb_pll_desc { ...@@ -13,7 +13,7 @@ struct dvb_pll_desc {
u32 min; u32 min;
u32 max; u32 max;
u32 iffreq; u32 iffreq;
void (*setbw)(u8 *buf, u32 freq, int bandwidth); void (*set)(u8 *buf, const struct dvb_frontend_parameters *params);
u8 *initdata; u8 *initdata;
u8 *sleepdata; u8 *sleepdata;
int count; int count;
...@@ -51,7 +51,7 @@ extern struct dvb_pll_desc dvb_pll_thomson_fe6600; ...@@ -51,7 +51,7 @@ extern struct dvb_pll_desc dvb_pll_thomson_fe6600;
extern struct dvb_pll_desc dvb_pll_opera1; extern struct dvb_pll_desc dvb_pll_opera1;
extern int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf, extern int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf,
u32 freq, int bandwidth); const struct dvb_frontend_parameters *params);
/** /**
* Attach a dvb-pll to the supplied frontend structure. * Attach a dvb-pll to the supplied frontend structure.
......
...@@ -839,8 +839,7 @@ static int philips_sd1878_tda8261_tuner_set_params(struct dvb_frontend *fe, ...@@ -839,8 +839,7 @@ static int philips_sd1878_tda8261_tuner_set_params(struct dvb_frontend *fe,
if((params->frequency < 950000) || (params->frequency > 2150000)) if((params->frequency < 950000) || (params->frequency > 2150000))
return -EINVAL; return -EINVAL;
rc=dvb_pll_configure(&dvb_pll_philips_sd1878_tda8261, buf, rc=dvb_pll_configure(&dvb_pll_philips_sd1878_tda8261, buf, params);
params->frequency, 0);
if(rc < 0) return rc; if(rc < 0) return rc;
if (fe->ops.i2c_gate_ctrl) if (fe->ops.i2c_gate_ctrl)
......
...@@ -260,9 +260,7 @@ static int dntv_live_dvbt_pro_tuner_set_params(struct dvb_frontend* fe, ...@@ -260,9 +260,7 @@ static int dntv_live_dvbt_pro_tuner_set_params(struct dvb_frontend* fe,
return err; return err;
/* Tune PLL */ /* Tune PLL */
dvb_pll_configure(dev->core->pll_desc, buf, dvb_pll_configure(dev->core->pll_desc, buf, params);
params->frequency,
params->u.ofdm.bandwidth);
if (fe->ops.i2c_gate_ctrl) if (fe->ops.i2c_gate_ctrl)
fe->ops.i2c_gate_ctrl(fe, 1); fe->ops.i2c_gate_ctrl(fe, 1);
if ((err = i2c_transfer(&dev->core->i2c_adap, &msg, 1)) != 1) { if ((err = i2c_transfer(&dev->core->i2c_adap, &msg, 1)) != 1) {
......
...@@ -181,9 +181,7 @@ static int mt352_aver777_tuner_calc_regs(struct dvb_frontend *fe, struct dvb_fro ...@@ -181,9 +181,7 @@ static int mt352_aver777_tuner_calc_regs(struct dvb_frontend *fe, struct dvb_fro
return -EINVAL; return -EINVAL;
pllbuf[0] = 0x61; pllbuf[0] = 0x61;
dvb_pll_configure(&dvb_pll_philips_td1316, pllbuf+1, dvb_pll_configure(&dvb_pll_philips_td1316, pllbuf+1, params);
params->frequency,
params->u.ofdm.bandwidth);
return 5; return 5;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment