Skip to content

Commit

Permalink
V4L/DVB (5455): Dvb-pll: Adjust rounding to be consistent
Browse files Browse the repository at this point in the history
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: Trent Piepho <xyzzy@speakeasy.org>
Acked-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
  • Loading branch information
Trent Piepho authored and Mauro Carvalho Chehab committed Apr 27, 2007
1 parent a5a2ecf commit 0fd17d6
Showing 1 changed file with 75 additions and 73 deletions.
148 changes: 75 additions & 73 deletions drivers/media/dvb/frontends/dvb-pll.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ struct dvb_pll_desc dvb_pll_thomson_dtt7579 = {
.max = 858000000,
.count = 5,
.entries = {
{ 0, 36166667, 166666, 0xb4, 0x03 }, /* go sleep */
{ 443250000, 36166667, 166666, 0xb4, 0x02 },
{ 542000000, 36166667, 166666, 0xb4, 0x08 },
{ 771000000, 36166667, 166666, 0xbc, 0x08 },
{ 999999999, 36166667, 166666, 0xf4, 0x08 },
{ 0, 36166667, 166667, 0xb4, 0x03 }, /* go sleep */
{ 443250000, 36166667, 166667, 0xb4, 0x02 },
{ 542000000, 36166667, 166667, 0xb4, 0x08 },
{ 771000000, 36166667, 166667, 0xbc, 0x08 },
{ 999999999, 36166667, 166667, 0xf4, 0x08 },
},
};
EXPORT_SYMBOL(dvb_pll_thomson_dtt7579);
Expand Down Expand Up @@ -79,12 +79,12 @@ struct dvb_pll_desc dvb_pll_thomson_dtt759x = {
.setbw = thomson_dtt759x_bw,
.count = 6,
.entries = {
{ 0, 36166667, 166666, 0x84, 0x03 },
{ 264000000, 36166667, 166666, 0xb4, 0x02 },
{ 470000000, 36166667, 166666, 0xbc, 0x02 },
{ 735000000, 36166667, 166666, 0xbc, 0x08 },
{ 835000000, 36166667, 166666, 0xf4, 0x08 },
{ 999999999, 36166667, 166666, 0xfc, 0x08 },
{ 0, 36166667, 166667, 0x84, 0x03 },
{ 264000000, 36166667, 166667, 0xb4, 0x02 },
{ 470000000, 36166667, 166667, 0xbc, 0x02 },
{ 735000000, 36166667, 166667, 0xbc, 0x08 },
{ 835000000, 36166667, 166667, 0xf4, 0x08 },
{ 999999999, 36166667, 166667, 0xfc, 0x08 },
},
};
EXPORT_SYMBOL(dvb_pll_thomson_dtt759x);
Expand All @@ -95,12 +95,12 @@ struct dvb_pll_desc dvb_pll_lg_z201 = {
.max = 862000000,
.count = 6,
.entries = {
{ 0, 36166667, 166666, 0xbc, 0x03 },
{ 157500000, 36166667, 166666, 0xbc, 0x01 },
{ 443250000, 36166667, 166666, 0xbc, 0x02 },
{ 542000000, 36166667, 166666, 0xbc, 0x04 },
{ 830000000, 36166667, 166666, 0xf4, 0x04 },
{ 999999999, 36166667, 166666, 0xfc, 0x04 },
{ 0, 36166667, 166667, 0xbc, 0x03 },
{ 157500000, 36166667, 166667, 0xbc, 0x01 },
{ 443250000, 36166667, 166667, 0xbc, 0x02 },
{ 542000000, 36166667, 166667, 0xbc, 0x04 },
{ 830000000, 36166667, 166667, 0xf4, 0x04 },
{ 999999999, 36166667, 166667, 0xfc, 0x04 },
},
};
EXPORT_SYMBOL(dvb_pll_lg_z201);
Expand Down Expand Up @@ -139,15 +139,15 @@ struct dvb_pll_desc dvb_pll_unknown_1 = {
.max = 862000000,
.count = 9,
.entries = {
{ 150000000, 36166667, 166666, 0xb4, 0x01 },
{ 173000000, 36166667, 166666, 0xbc, 0x01 },
{ 250000000, 36166667, 166666, 0xb4, 0x02 },
{ 400000000, 36166667, 166666, 0xbc, 0x02 },
{ 420000000, 36166667, 166666, 0xf4, 0x02 },
{ 470000000, 36166667, 166666, 0xfc, 0x02 },
{ 600000000, 36166667, 166666, 0xbc, 0x08 },
{ 730000000, 36166667, 166666, 0xf4, 0x08 },
{ 999999999, 36166667, 166666, 0xfc, 0x08 },
{ 150000000, 36166667, 166667, 0xb4, 0x01 },
{ 173000000, 36166667, 166667, 0xbc, 0x01 },
{ 250000000, 36166667, 166667, 0xb4, 0x02 },
{ 400000000, 36166667, 166667, 0xbc, 0x02 },
{ 420000000, 36166667, 166667, 0xf4, 0x02 },
{ 470000000, 36166667, 166667, 0xfc, 0x02 },
{ 600000000, 36166667, 166667, 0xbc, 0x08 },
{ 730000000, 36166667, 166667, 0xf4, 0x08 },
{ 999999999, 36166667, 166667, 0xfc, 0x08 },
},
};
EXPORT_SYMBOL(dvb_pll_unknown_1);
Expand Down Expand Up @@ -175,10 +175,10 @@ struct dvb_pll_desc dvb_pll_env57h1xd5 = {
.max = 858000000,
.count = 4,
.entries = {
{ 153000000, 36291666, 166666, 0xc2, 0x41 },
{ 470000000, 36291666, 166666, 0xc2, 0x42 },
{ 526000000, 36291666, 166666, 0xc2, 0x84 },
{ 999999999, 36291666, 166666, 0xc2, 0xa4 },
{ 153000000, 36125000, 166667, 0xc2, 0x41 },
{ 470000000, 36125000, 166667, 0xc2, 0x42 },
{ 526000000, 36125000, 166667, 0xc2, 0x84 },
{ 999999999, 36125000, 166667, 0xc2, 0xa4 },
},
};
EXPORT_SYMBOL(dvb_pll_env57h1xd5);
Expand All @@ -199,18 +199,18 @@ struct dvb_pll_desc dvb_pll_tda665x = {
.setbw = tda665x_bw,
.count = 12,
.entries = {
{ 93834000, 36249333, 166667, 0xca, 0x61 /* 011 0 0 0 01 */ },
{ 123834000, 36249333, 166667, 0xca, 0xa1 /* 101 0 0 0 01 */ },
{ 161000000, 36249333, 166667, 0xca, 0xa1 /* 101 0 0 0 01 */ },
{ 163834000, 36249333, 166667, 0xca, 0xc2 /* 110 0 0 0 10 */ },
{ 253834000, 36249333, 166667, 0xca, 0x62 /* 011 0 0 0 10 */ },
{ 383834000, 36249333, 166667, 0xca, 0xa2 /* 101 0 0 0 10 */ },
{ 443834000, 36249333, 166667, 0xca, 0xc2 /* 110 0 0 0 10 */ },
{ 444000000, 36249333, 166667, 0xca, 0xc4 /* 110 0 0 1 00 */ },
{ 583834000, 36249333, 166667, 0xca, 0x64 /* 011 0 0 1 00 */ },
{ 793834000, 36249333, 166667, 0xca, 0xa4 /* 101 0 0 1 00 */ },
{ 444834000, 36249333, 166667, 0xca, 0xc4 /* 110 0 0 1 00 */ },
{ 861000000, 36249333, 166667, 0xca, 0xe4 /* 111 0 0 1 00 */ },
{ 93834000, 36166667, 166667, 0xca, 0x61 /* 011 0 0 0 01 */ },
{ 123834000, 36166667, 166667, 0xca, 0xa1 /* 101 0 0 0 01 */ },
{ 161000000, 36166667, 166667, 0xca, 0xa1 /* 101 0 0 0 01 */ },
{ 163834000, 36166667, 166667, 0xca, 0xc2 /* 110 0 0 0 10 */ },
{ 253834000, 36166667, 166667, 0xca, 0x62 /* 011 0 0 0 10 */ },
{ 383834000, 36166667, 166667, 0xca, 0xa2 /* 101 0 0 0 10 */ },
{ 443834000, 36166667, 166667, 0xca, 0xc2 /* 110 0 0 0 10 */ },
{ 444000000, 36166667, 166667, 0xca, 0xc4 /* 110 0 0 1 00 */ },
{ 583834000, 36166667, 166667, 0xca, 0x64 /* 011 0 0 1 00 */ },
{ 793834000, 36166667, 166667, 0xca, 0xa4 /* 101 0 0 1 00 */ },
{ 444834000, 36166667, 166667, 0xca, 0xc4 /* 110 0 0 1 00 */ },
{ 861000000, 36166667, 166667, 0xca, 0xe4 /* 111 0 0 1 00 */ },
}
};
EXPORT_SYMBOL(dvb_pll_tda665x);
Expand Down Expand Up @@ -271,13 +271,13 @@ struct dvb_pll_desc dvb_pll_fmd1216me = {
.setbw = fmd1216me_bw,
.count = 7,
.entries = {
{ 143870000, 36213333, 166667, 0xbc, 0x41 },
{ 158870000, 36213333, 166667, 0xf4, 0x41 },
{ 329870000, 36213333, 166667, 0xbc, 0x42 },
{ 441870000, 36213333, 166667, 0xf4, 0x42 },
{ 625870000, 36213333, 166667, 0xbc, 0x44 },
{ 803870000, 36213333, 166667, 0xf4, 0x44 },
{ 999999999, 36213333, 166667, 0xfc, 0x44 },
{ 143870000, 36125000, 166667, 0xbc, 0x41 },
{ 158870000, 36125000, 166667, 0xf4, 0x41 },
{ 329870000, 36125000, 166667, 0xbc, 0x42 },
{ 441870000, 36125000, 166667, 0xf4, 0x42 },
{ 625870000, 36125000, 166667, 0xbc, 0x44 },
{ 803870000, 36125000, 166667, 0xf4, 0x44 },
{ 999999999, 36125000, 166667, 0xfc, 0x44 },
}
};
EXPORT_SYMBOL(dvb_pll_fmd1216me);
Expand Down Expand Up @@ -348,12 +348,12 @@ struct dvb_pll_desc dvb_pll_samsung_tbmv = {
.max = 860000000,
.count = 6,
.entries = {
{ 172000000, 44000000, 166666, 0xb4, 0x01 },
{ 214000000, 44000000, 166666, 0xb4, 0x02 },
{ 467000000, 44000000, 166666, 0xbc, 0x02 },
{ 721000000, 44000000, 166666, 0xbc, 0x08 },
{ 841000000, 44000000, 166666, 0xf4, 0x08 },
{ 999999999, 44000000, 166666, 0xfc, 0x02 },
{ 172000000, 44000000, 166667, 0xb4, 0x01 },
{ 214000000, 44000000, 166667, 0xb4, 0x02 },
{ 467000000, 44000000, 166667, 0xbc, 0x02 },
{ 721000000, 44000000, 166667, 0xbc, 0x08 },
{ 841000000, 44000000, 166667, 0xf4, 0x08 },
{ 999999999, 44000000, 166667, 0xfc, 0x02 },
}
};
EXPORT_SYMBOL(dvb_pll_samsung_tbmv);
Expand All @@ -367,10 +367,11 @@ struct dvb_pll_desc dvb_pll_philips_sd1878_tda8261 = {
.max = 2150000,
.count = 4,
.entries = {
{ 1250000, 499, 500, 0xc4, 0x00},
{ 1550000, 499, 500, 0xc4, 0x40},
{ 2050000, 499, 500, 0xc4, 0x80},
{ 2150000, 499, 500, 0xc4, 0xc0},
/* zero-IF, offset 249 is to round up */
{ 1250000, 249, 500, 0xc4, 0x00},
{ 1550000, 249, 500, 0xc4, 0x40},
{ 2050000, 249, 500, 0xc4, 0x80},
{ 2150000, 249, 500, 0xc4, 0xc0},
},
};
EXPORT_SYMBOL(dvb_pll_philips_sd1878_tda8261);
Expand Down Expand Up @@ -404,15 +405,15 @@ struct dvb_pll_desc dvb_pll_philips_td1316 = {
.setbw = td1316_bw,
.count = 9,
.entries = {
{ 93834000, 36166000, 166666, 0xca, 0x60},
{ 123834000, 36166000, 166666, 0xca, 0xa0},
{ 163834000, 36166000, 166666, 0xca, 0xc0},
{ 253834000, 36166000, 166666, 0xca, 0x60},
{ 383834000, 36166000, 166666, 0xca, 0xa0},
{ 443834000, 36166000, 166666, 0xca, 0xc0},
{ 583834000, 36166000, 166666, 0xca, 0x60},
{ 793834000, 36166000, 166666, 0xca, 0xa0},
{ 858834000, 36166000, 166666, 0xca, 0xe0},
{ 93834000, 36166667, 166667, 0xca, 0x60},
{ 123834000, 36166667, 166667, 0xca, 0xa0},
{ 163834000, 36166667, 166667, 0xca, 0xc0},
{ 253834000, 36166667, 166667, 0xca, 0x60},
{ 383834000, 36166667, 166667, 0xca, 0xa0},
{ 443834000, 36166667, 166667, 0xca, 0xc0},
{ 583834000, 36166667, 166667, 0xca, 0x60},
{ 793834000, 36166667, 166667, 0xca, 0xa0},
{ 858834000, 36166667, 166667, 0xca, 0xe0},
},
};
EXPORT_SYMBOL(dvb_pll_philips_td1316);
Expand All @@ -424,10 +425,10 @@ struct dvb_pll_desc dvb_pll_thomson_fe6600 = {
.max = 858000000,
.count = 4,
.entries = {
{ 250000000, 36213333, 166667, 0xb4, 0x12 },
{ 455000000, 36213333, 166667, 0xfe, 0x11 },
{ 775500000, 36213333, 166667, 0xbc, 0x18 },
{ 999999999, 36213333, 166667, 0xf4, 0x18 },
{ 250000000, 36125000, 166667, 0xb4, 0x12 },
{ 455000000, 36125000, 166667, 0xfe, 0x11 },
{ 775500000, 36125000, 166667, 0xbc, 0x18 },
{ 999999999, 36125000, 166667, 0xf4, 0x18 },
}
};
EXPORT_SYMBOL(dvb_pll_thomson_fe6600);
Expand Down Expand Up @@ -472,7 +473,8 @@ int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf,
if (i == desc->count)
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[1] = div & 0xff;
buf[2] = desc->entries[i].config;
Expand Down

0 comments on commit 0fd17d6

Please sign in to comment.