Commit 0fd17d6d authored by Trent Piepho's avatar Trent Piepho Committed by Mauro Carvalho Chehab

V4L/DVB (5455): Dvb-pll: Adjust rounding to be consistent

Some PLLs had one half the step size added to the offset, so that the
divisor would be rounded to the nearest integer.  Some didn't and so
would always be rounded down.

This makes dvb-pll round to the nearest when calculating the divisor,
without the offset needing to be fudged.  PLLs that had a fudged offset
have the offset changed to be just the IF frequency.
The satellite PLL dvb_pll_philips_sd1878_tda8261 was rounding up for some
reason, and I've kept it that way.

In addition, frequencies that were rounded to the nearest kHz are
extended to full Hz resolution.  One sixth MHz step sizes that were
listed as 166,666 Hz are changed to 166,667 Hz, which is slightly closer.

PLLs that were already rounding:
dvb_pll_tda665x, offset was 36 1/6 (to nearest kHz) + step/2
dvb_pll_fmd1216me, offset was 36 1/8 (to two digits) + step/2
dvb_pll_thomson_fe6600, offset was 36 1/8 (to two digits) + step/2
dvb_pll_env57h1xd5, offset was 36 1/8 + step

Note that the last PLL, dvb_pll_env57h1xd5, appears to have had a bug in
the offset.  Rather than adding stepsize/2, it was adding a full
stepsize.  The PLL definition originally came from the dibusb driver,
which used 36 1/8 + step/2.  The change to 36 1/8 + step was probably a
mistake added when the tuner was converted to dvb-pll.
Signed-off-by: default avatarTrent Piepho <xyzzy@speakeasy.org>
Acked-by: default avatarMichael Krufky <mkrufky@linuxtv.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent a5a2ecfc
...@@ -44,11 +44,11 @@ struct dvb_pll_desc dvb_pll_thomson_dtt7579 = { ...@@ -44,11 +44,11 @@ struct dvb_pll_desc dvb_pll_thomson_dtt7579 = {
.max = 858000000, .max = 858000000,
.count = 5, .count = 5,
.entries = { .entries = {
{ 0, 36166667, 166666, 0xb4, 0x03 }, /* go sleep */ { 0, 36166667, 166667, 0xb4, 0x03 }, /* go sleep */
{ 443250000, 36166667, 166666, 0xb4, 0x02 }, { 443250000, 36166667, 166667, 0xb4, 0x02 },
{ 542000000, 36166667, 166666, 0xb4, 0x08 }, { 542000000, 36166667, 166667, 0xb4, 0x08 },
{ 771000000, 36166667, 166666, 0xbc, 0x08 }, { 771000000, 36166667, 166667, 0xbc, 0x08 },
{ 999999999, 36166667, 166666, 0xf4, 0x08 }, { 999999999, 36166667, 166667, 0xf4, 0x08 },
}, },
}; };
EXPORT_SYMBOL(dvb_pll_thomson_dtt7579); EXPORT_SYMBOL(dvb_pll_thomson_dtt7579);
...@@ -79,12 +79,12 @@ struct dvb_pll_desc dvb_pll_thomson_dtt759x = { ...@@ -79,12 +79,12 @@ struct dvb_pll_desc dvb_pll_thomson_dtt759x = {
.setbw = thomson_dtt759x_bw, .setbw = thomson_dtt759x_bw,
.count = 6, .count = 6,
.entries = { .entries = {
{ 0, 36166667, 166666, 0x84, 0x03 }, { 0, 36166667, 166667, 0x84, 0x03 },
{ 264000000, 36166667, 166666, 0xb4, 0x02 }, { 264000000, 36166667, 166667, 0xb4, 0x02 },
{ 470000000, 36166667, 166666, 0xbc, 0x02 }, { 470000000, 36166667, 166667, 0xbc, 0x02 },
{ 735000000, 36166667, 166666, 0xbc, 0x08 }, { 735000000, 36166667, 166667, 0xbc, 0x08 },
{ 835000000, 36166667, 166666, 0xf4, 0x08 }, { 835000000, 36166667, 166667, 0xf4, 0x08 },
{ 999999999, 36166667, 166666, 0xfc, 0x08 }, { 999999999, 36166667, 166667, 0xfc, 0x08 },
}, },
}; };
EXPORT_SYMBOL(dvb_pll_thomson_dtt759x); EXPORT_SYMBOL(dvb_pll_thomson_dtt759x);
...@@ -95,12 +95,12 @@ struct dvb_pll_desc dvb_pll_lg_z201 = { ...@@ -95,12 +95,12 @@ struct dvb_pll_desc dvb_pll_lg_z201 = {
.max = 862000000, .max = 862000000,
.count = 6, .count = 6,
.entries = { .entries = {
{ 0, 36166667, 166666, 0xbc, 0x03 }, { 0, 36166667, 166667, 0xbc, 0x03 },
{ 157500000, 36166667, 166666, 0xbc, 0x01 }, { 157500000, 36166667, 166667, 0xbc, 0x01 },
{ 443250000, 36166667, 166666, 0xbc, 0x02 }, { 443250000, 36166667, 166667, 0xbc, 0x02 },
{ 542000000, 36166667, 166666, 0xbc, 0x04 }, { 542000000, 36166667, 166667, 0xbc, 0x04 },
{ 830000000, 36166667, 166666, 0xf4, 0x04 }, { 830000000, 36166667, 166667, 0xf4, 0x04 },
{ 999999999, 36166667, 166666, 0xfc, 0x04 }, { 999999999, 36166667, 166667, 0xfc, 0x04 },
}, },
}; };
EXPORT_SYMBOL(dvb_pll_lg_z201); EXPORT_SYMBOL(dvb_pll_lg_z201);
...@@ -139,15 +139,15 @@ struct dvb_pll_desc dvb_pll_unknown_1 = { ...@@ -139,15 +139,15 @@ struct dvb_pll_desc dvb_pll_unknown_1 = {
.max = 862000000, .max = 862000000,
.count = 9, .count = 9,
.entries = { .entries = {
{ 150000000, 36166667, 166666, 0xb4, 0x01 }, { 150000000, 36166667, 166667, 0xb4, 0x01 },
{ 173000000, 36166667, 166666, 0xbc, 0x01 }, { 173000000, 36166667, 166667, 0xbc, 0x01 },
{ 250000000, 36166667, 166666, 0xb4, 0x02 }, { 250000000, 36166667, 166667, 0xb4, 0x02 },
{ 400000000, 36166667, 166666, 0xbc, 0x02 }, { 400000000, 36166667, 166667, 0xbc, 0x02 },
{ 420000000, 36166667, 166666, 0xf4, 0x02 }, { 420000000, 36166667, 166667, 0xf4, 0x02 },
{ 470000000, 36166667, 166666, 0xfc, 0x02 }, { 470000000, 36166667, 166667, 0xfc, 0x02 },
{ 600000000, 36166667, 166666, 0xbc, 0x08 }, { 600000000, 36166667, 166667, 0xbc, 0x08 },
{ 730000000, 36166667, 166666, 0xf4, 0x08 }, { 730000000, 36166667, 166667, 0xf4, 0x08 },
{ 999999999, 36166667, 166666, 0xfc, 0x08 }, { 999999999, 36166667, 166667, 0xfc, 0x08 },
}, },
}; };
EXPORT_SYMBOL(dvb_pll_unknown_1); EXPORT_SYMBOL(dvb_pll_unknown_1);
...@@ -175,10 +175,10 @@ struct dvb_pll_desc dvb_pll_env57h1xd5 = { ...@@ -175,10 +175,10 @@ struct dvb_pll_desc dvb_pll_env57h1xd5 = {
.max = 858000000, .max = 858000000,
.count = 4, .count = 4,
.entries = { .entries = {
{ 153000000, 36291666, 166666, 0xc2, 0x41 }, { 153000000, 36125000, 166667, 0xc2, 0x41 },
{ 470000000, 36291666, 166666, 0xc2, 0x42 }, { 470000000, 36125000, 166667, 0xc2, 0x42 },
{ 526000000, 36291666, 166666, 0xc2, 0x84 }, { 526000000, 36125000, 166667, 0xc2, 0x84 },
{ 999999999, 36291666, 166666, 0xc2, 0xa4 }, { 999999999, 36125000, 166667, 0xc2, 0xa4 },
}, },
}; };
EXPORT_SYMBOL(dvb_pll_env57h1xd5); EXPORT_SYMBOL(dvb_pll_env57h1xd5);
...@@ -199,18 +199,18 @@ struct dvb_pll_desc dvb_pll_tda665x = { ...@@ -199,18 +199,18 @@ struct dvb_pll_desc dvb_pll_tda665x = {
.setbw = tda665x_bw, .setbw = tda665x_bw,
.count = 12, .count = 12,
.entries = { .entries = {
{ 93834000, 36249333, 166667, 0xca, 0x61 /* 011 0 0 0 01 */ }, { 93834000, 36166667, 166667, 0xca, 0x61 /* 011 0 0 0 01 */ },
{ 123834000, 36249333, 166667, 0xca, 0xa1 /* 101 0 0 0 01 */ }, { 123834000, 36166667, 166667, 0xca, 0xa1 /* 101 0 0 0 01 */ },
{ 161000000, 36249333, 166667, 0xca, 0xa1 /* 101 0 0 0 01 */ }, { 161000000, 36166667, 166667, 0xca, 0xa1 /* 101 0 0 0 01 */ },
{ 163834000, 36249333, 166667, 0xca, 0xc2 /* 110 0 0 0 10 */ }, { 163834000, 36166667, 166667, 0xca, 0xc2 /* 110 0 0 0 10 */ },
{ 253834000, 36249333, 166667, 0xca, 0x62 /* 011 0 0 0 10 */ }, { 253834000, 36166667, 166667, 0xca, 0x62 /* 011 0 0 0 10 */ },
{ 383834000, 36249333, 166667, 0xca, 0xa2 /* 101 0 0 0 10 */ }, { 383834000, 36166667, 166667, 0xca, 0xa2 /* 101 0 0 0 10 */ },
{ 443834000, 36249333, 166667, 0xca, 0xc2 /* 110 0 0 0 10 */ }, { 443834000, 36166667, 166667, 0xca, 0xc2 /* 110 0 0 0 10 */ },
{ 444000000, 36249333, 166667, 0xca, 0xc4 /* 110 0 0 1 00 */ }, { 444000000, 36166667, 166667, 0xca, 0xc4 /* 110 0 0 1 00 */ },
{ 583834000, 36249333, 166667, 0xca, 0x64 /* 011 0 0 1 00 */ }, { 583834000, 36166667, 166667, 0xca, 0x64 /* 011 0 0 1 00 */ },
{ 793834000, 36249333, 166667, 0xca, 0xa4 /* 101 0 0 1 00 */ }, { 793834000, 36166667, 166667, 0xca, 0xa4 /* 101 0 0 1 00 */ },
{ 444834000, 36249333, 166667, 0xca, 0xc4 /* 110 0 0 1 00 */ }, { 444834000, 36166667, 166667, 0xca, 0xc4 /* 110 0 0 1 00 */ },
{ 861000000, 36249333, 166667, 0xca, 0xe4 /* 111 0 0 1 00 */ }, { 861000000, 36166667, 166667, 0xca, 0xe4 /* 111 0 0 1 00 */ },
} }
}; };
EXPORT_SYMBOL(dvb_pll_tda665x); EXPORT_SYMBOL(dvb_pll_tda665x);
...@@ -271,13 +271,13 @@ struct dvb_pll_desc dvb_pll_fmd1216me = { ...@@ -271,13 +271,13 @@ struct dvb_pll_desc dvb_pll_fmd1216me = {
.setbw = fmd1216me_bw, .setbw = fmd1216me_bw,
.count = 7, .count = 7,
.entries = { .entries = {
{ 143870000, 36213333, 166667, 0xbc, 0x41 }, { 143870000, 36125000, 166667, 0xbc, 0x41 },
{ 158870000, 36213333, 166667, 0xf4, 0x41 }, { 158870000, 36125000, 166667, 0xf4, 0x41 },
{ 329870000, 36213333, 166667, 0xbc, 0x42 }, { 329870000, 36125000, 166667, 0xbc, 0x42 },
{ 441870000, 36213333, 166667, 0xf4, 0x42 }, { 441870000, 36125000, 166667, 0xf4, 0x42 },
{ 625870000, 36213333, 166667, 0xbc, 0x44 }, { 625870000, 36125000, 166667, 0xbc, 0x44 },
{ 803870000, 36213333, 166667, 0xf4, 0x44 }, { 803870000, 36125000, 166667, 0xf4, 0x44 },
{ 999999999, 36213333, 166667, 0xfc, 0x44 }, { 999999999, 36125000, 166667, 0xfc, 0x44 },
} }
}; };
EXPORT_SYMBOL(dvb_pll_fmd1216me); EXPORT_SYMBOL(dvb_pll_fmd1216me);
...@@ -348,12 +348,12 @@ struct dvb_pll_desc dvb_pll_samsung_tbmv = { ...@@ -348,12 +348,12 @@ struct dvb_pll_desc dvb_pll_samsung_tbmv = {
.max = 860000000, .max = 860000000,
.count = 6, .count = 6,
.entries = { .entries = {
{ 172000000, 44000000, 166666, 0xb4, 0x01 }, { 172000000, 44000000, 166667, 0xb4, 0x01 },
{ 214000000, 44000000, 166666, 0xb4, 0x02 }, { 214000000, 44000000, 166667, 0xb4, 0x02 },
{ 467000000, 44000000, 166666, 0xbc, 0x02 }, { 467000000, 44000000, 166667, 0xbc, 0x02 },
{ 721000000, 44000000, 166666, 0xbc, 0x08 }, { 721000000, 44000000, 166667, 0xbc, 0x08 },
{ 841000000, 44000000, 166666, 0xf4, 0x08 }, { 841000000, 44000000, 166667, 0xf4, 0x08 },
{ 999999999, 44000000, 166666, 0xfc, 0x02 }, { 999999999, 44000000, 166667, 0xfc, 0x02 },
} }
}; };
EXPORT_SYMBOL(dvb_pll_samsung_tbmv); EXPORT_SYMBOL(dvb_pll_samsung_tbmv);
...@@ -367,10 +367,11 @@ struct dvb_pll_desc dvb_pll_philips_sd1878_tda8261 = { ...@@ -367,10 +367,11 @@ struct dvb_pll_desc dvb_pll_philips_sd1878_tda8261 = {
.max = 2150000, .max = 2150000,
.count = 4, .count = 4,
.entries = { .entries = {
{ 1250000, 499, 500, 0xc4, 0x00}, /* zero-IF, offset 249 is to round up */
{ 1550000, 499, 500, 0xc4, 0x40}, { 1250000, 249, 500, 0xc4, 0x00},
{ 2050000, 499, 500, 0xc4, 0x80}, { 1550000, 249, 500, 0xc4, 0x40},
{ 2150000, 499, 500, 0xc4, 0xc0}, { 2050000, 249, 500, 0xc4, 0x80},
{ 2150000, 249, 500, 0xc4, 0xc0},
}, },
}; };
EXPORT_SYMBOL(dvb_pll_philips_sd1878_tda8261); EXPORT_SYMBOL(dvb_pll_philips_sd1878_tda8261);
...@@ -404,15 +405,15 @@ struct dvb_pll_desc dvb_pll_philips_td1316 = { ...@@ -404,15 +405,15 @@ struct dvb_pll_desc dvb_pll_philips_td1316 = {
.setbw = td1316_bw, .setbw = td1316_bw,
.count = 9, .count = 9,
.entries = { .entries = {
{ 93834000, 36166000, 166666, 0xca, 0x60}, { 93834000, 36166667, 166667, 0xca, 0x60},
{ 123834000, 36166000, 166666, 0xca, 0xa0}, { 123834000, 36166667, 166667, 0xca, 0xa0},
{ 163834000, 36166000, 166666, 0xca, 0xc0}, { 163834000, 36166667, 166667, 0xca, 0xc0},
{ 253834000, 36166000, 166666, 0xca, 0x60}, { 253834000, 36166667, 166667, 0xca, 0x60},
{ 383834000, 36166000, 166666, 0xca, 0xa0}, { 383834000, 36166667, 166667, 0xca, 0xa0},
{ 443834000, 36166000, 166666, 0xca, 0xc0}, { 443834000, 36166667, 166667, 0xca, 0xc0},
{ 583834000, 36166000, 166666, 0xca, 0x60}, { 583834000, 36166667, 166667, 0xca, 0x60},
{ 793834000, 36166000, 166666, 0xca, 0xa0}, { 793834000, 36166667, 166667, 0xca, 0xa0},
{ 858834000, 36166000, 166666, 0xca, 0xe0}, { 858834000, 36166667, 166667, 0xca, 0xe0},
}, },
}; };
EXPORT_SYMBOL(dvb_pll_philips_td1316); EXPORT_SYMBOL(dvb_pll_philips_td1316);
...@@ -424,10 +425,10 @@ struct dvb_pll_desc dvb_pll_thomson_fe6600 = { ...@@ -424,10 +425,10 @@ struct dvb_pll_desc dvb_pll_thomson_fe6600 = {
.max = 858000000, .max = 858000000,
.count = 4, .count = 4,
.entries = { .entries = {
{ 250000000, 36213333, 166667, 0xb4, 0x12 }, { 250000000, 36125000, 166667, 0xb4, 0x12 },
{ 455000000, 36213333, 166667, 0xfe, 0x11 }, { 455000000, 36125000, 166667, 0xfe, 0x11 },
{ 775500000, 36213333, 166667, 0xbc, 0x18 }, { 775500000, 36125000, 166667, 0xbc, 0x18 },
{ 999999999, 36213333, 166667, 0xf4, 0x18 }, { 999999999, 36125000, 166667, 0xf4, 0x18 },
} }
}; };
EXPORT_SYMBOL(dvb_pll_thomson_fe6600); EXPORT_SYMBOL(dvb_pll_thomson_fe6600);
...@@ -472,7 +473,8 @@ int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf, ...@@ -472,7 +473,8 @@ int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf,
if (i == desc->count) if (i == desc->count)
return -EINVAL; return -EINVAL;
div = (freq + desc->entries[i].offset) / desc->entries[i].stepsize; div = (freq + desc->entries[i].offset + 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;
......
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