From: Trent Piepho Date: Mon, 19 Mar 2007 05:23:59 +0000 (-0300) Subject: V4L/DVB (5455): Dvb-pll: Adjust rounding to be consistent X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=0fd17d6da8154e1a6391440a268b0620ab339122;p=linux-beck.git 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: Trent Piepho Acked-by: Michael Krufky Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/dvb/frontends/dvb-pll.c b/drivers/media/dvb/frontends/dvb-pll.c index abc08f0ae197..35973e7faac3 100644 --- a/drivers/media/dvb/frontends/dvb-pll.c +++ b/drivers/media/dvb/frontends/dvb-pll.c @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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;