* [PATCH] m88ts2022: fix high symbol rate transponders missing on 32bit platform.
@ 2014-08-16 6:12 nibble.max
2014-08-16 12:38 ` Mauro Carvalho Chehab
2014-08-16 13:31 ` Re: [PATCH] m88ts2022: fix high symbol rate transponders missing on32bit platform Max Xiang
0 siblings, 2 replies; 6+ messages in thread
From: nibble.max @ 2014-08-16 6:12 UTC (permalink / raw)
To: Antti Palosaari; +Cc: linux-media, olli.salonen
The current m88ts2022 driver will miss the following high symbol rate transponders on Telstar 18 138.0.
12385 H 43200,
12690 H 43200,
12538 V 41250...
the code for f_3db_hz will overflow for the high symbol rate.
for example, symbol rate=41250 KS/s
symbol_rate * 135UL = 5568750000(1 4BEC 61B0), the value is larger than unsigned int on 32bit platform.
that makes the wrong result.
Exchanging the div and mul position fixs it.
Signed-off-by: Nibble Max <nibble.max@gmail.com>
---
drivers/media/tuners/m88ts2022.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/tuners/m88ts2022.c b/drivers/media/tuners/m88ts2022.c
index 40c42de..65c8acc 100644
--- a/drivers/media/tuners/m88ts2022.c
+++ b/drivers/media/tuners/m88ts2022.c
@@ -314,7 +314,7 @@ static int m88ts2022_set_params(struct dvb_frontend *fe)
div_min = gdiv28 * 78 / 100;
div_max = clamp_val(div_max, 0U, 63U);
- f_3db_hz = c->symbol_rate * 135UL / 200UL;
+ f_3db_hz = (c->symbol_rate / 200UL) * 135UL;
f_3db_hz += 2000000U + (frequency_offset_khz * 1000U);
f_3db_hz = clamp(f_3db_hz, 7000000U, 40000000U);
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] m88ts2022: fix high symbol rate transponders missing on 32bit platform.
2014-08-16 6:12 [PATCH] m88ts2022: fix high symbol rate transponders missing on 32bit platform nibble.max
@ 2014-08-16 12:38 ` Mauro Carvalho Chehab
2014-08-16 12:53 ` Antti Palosaari
2014-08-16 13:31 ` Re: [PATCH] m88ts2022: fix high symbol rate transponders missing on32bit platform Max Xiang
1 sibling, 1 reply; 6+ messages in thread
From: Mauro Carvalho Chehab @ 2014-08-16 12:38 UTC (permalink / raw)
To: nibble.max; +Cc: Antti Palosaari, linux-media, olli.salonen
Em Sat, 16 Aug 2014 14:12:32 +0800
"nibble.max" <nibble.max@gmail.com> escreveu:
> The current m88ts2022 driver will miss the following high symbol rate transponders on Telstar 18 138.0.
> 12385 H 43200,
> 12690 H 43200,
> 12538 V 41250...
> the code for f_3db_hz will overflow for the high symbol rate.
> for example, symbol rate=41250 KS/s
> symbol_rate * 135UL = 5568750000(1 4BEC 61B0), the value is larger than unsigned int on 32bit platform.
> that makes the wrong result.
> Exchanging the div and mul position fixs it.
>
> Signed-off-by: Nibble Max <nibble.max@gmail.com>
> ---
> drivers/media/tuners/m88ts2022.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/tuners/m88ts2022.c b/drivers/media/tuners/m88ts2022.c
> index 40c42de..65c8acc 100644
> --- a/drivers/media/tuners/m88ts2022.c
> +++ b/drivers/media/tuners/m88ts2022.c
> @@ -314,7 +314,7 @@ static int m88ts2022_set_params(struct dvb_frontend *fe)
> div_min = gdiv28 * 78 / 100;
> div_max = clamp_val(div_max, 0U, 63U);
>
> - f_3db_hz = c->symbol_rate * 135UL / 200UL;
> + f_3db_hz = (c->symbol_rate / 200UL) * 135UL;
Hmm... wouldn't this make worse for low symbol rates?
IMHO, the better is to use a u64 instead, and do_div64().
> f_3db_hz += 2000000U + (frequency_offset_khz * 1000U);
> f_3db_hz = clamp(f_3db_hz, 7000000U, 40000000U);
>
Regards,
--
Cheers,
Mauro
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] m88ts2022: fix high symbol rate transponders missing on 32bit platform.
2014-08-16 12:38 ` Mauro Carvalho Chehab
@ 2014-08-16 12:53 ` Antti Palosaari
2014-08-16 19:26 ` Matthias Schwarzott
0 siblings, 1 reply; 6+ messages in thread
From: Antti Palosaari @ 2014-08-16 12:53 UTC (permalink / raw)
To: Mauro Carvalho Chehab, nibble.max; +Cc: linux-media, olli.salonen
On 08/16/2014 02:38 PM, Mauro Carvalho Chehab wrote:
> Em Sat, 16 Aug 2014 14:12:32 +0800
> "nibble.max" <nibble.max@gmail.com> escreveu:
>
>> The current m88ts2022 driver will miss the following high symbol rate transponders on Telstar 18 138.0.
>> 12385 H 43200,
>> 12690 H 43200,
>> 12538 V 41250...
>> the code for f_3db_hz will overflow for the high symbol rate.
>> for example, symbol rate=41250 KS/s
>> symbol_rate * 135UL = 5568750000(1 4BEC 61B0), the value is larger than unsigned int on 32bit platform.
>> that makes the wrong result.
>> Exchanging the div and mul position fixs it.
>>
>> Signed-off-by: Nibble Max <nibble.max@gmail.com>
>> ---
>> drivers/media/tuners/m88ts2022.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/media/tuners/m88ts2022.c b/drivers/media/tuners/m88ts2022.c
>> index 40c42de..65c8acc 100644
>> --- a/drivers/media/tuners/m88ts2022.c
>> +++ b/drivers/media/tuners/m88ts2022.c
>> @@ -314,7 +314,7 @@ static int m88ts2022_set_params(struct dvb_frontend *fe)
>> div_min = gdiv28 * 78 / 100;
>> div_max = clamp_val(div_max, 0U, 63U);
>>
>> - f_3db_hz = c->symbol_rate * 135UL / 200UL;
>> + f_3db_hz = (c->symbol_rate / 200UL) * 135UL;
>
> Hmm... wouldn't this make worse for low symbol rates?
>
> IMHO, the better is to use a u64 instead, and do_div64().
>
>> f_3db_hz += 2000000U + (frequency_offset_khz * 1000U);
>> f_3db_hz = clamp(f_3db_hz, 7000000U, 40000000U);
>>
I will look that more carefully on end of next week, go through possible
symbol rates and rounding errors.
Maybe it should be something like that (didn't test any way, may not
even compile):
f_3db_hz = div_u64((u64) (c->symbol_rate * 135), 200);
Antti
--
http://palosaari.fi/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] m88ts2022: fix high symbol rate transponders missing on 32bit platform.
2014-08-16 12:53 ` Antti Palosaari
@ 2014-08-16 19:26 ` Matthias Schwarzott
0 siblings, 0 replies; 6+ messages in thread
From: Matthias Schwarzott @ 2014-08-16 19:26 UTC (permalink / raw)
To: Antti Palosaari, Mauro Carvalho Chehab, nibble.max
Cc: linux-media, olli.salonen
On 16.08.2014 14:53, Antti Palosaari wrote:
>
>
> I will look that more carefully on end of next week, go through possible
> symbol rates and rounding errors.
>
> Maybe it should be something like that (didn't test any way, may not
> even compile):
> f_3db_hz = div_u64((u64) (c->symbol_rate * 135), 200);
>
In this case c->symbol_rate * 135 is still 32bits wide, but maybe signed
because 135 is signed.
So there will be an overflow on 32bit platforms at symbol rates equal to
15907287.
So better cast symbol_rate to u64 before.
Matthias
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Re: [PATCH] m88ts2022: fix high symbol rate transponders missing on32bit platform.
2014-08-16 6:12 [PATCH] m88ts2022: fix high symbol rate transponders missing on 32bit platform nibble.max
2014-08-16 12:38 ` Mauro Carvalho Chehab
@ 2014-08-16 13:31 ` Max Xiang
1 sibling, 0 replies; 6+ messages in thread
From: Max Xiang @ 2014-08-16 13:31 UTC (permalink / raw)
To: Mauro Carvalho Chehab; +Cc: Antti Palosaari, linux-media, olli.salonen
[-- Attachment #1: Type: text/plain, Size: 1535 bytes --]
>Em Sat, 16 Aug 2014 14:12:32 +0800
>"nibble.max" <nibble.max@gmail.com> escreveu:
>
>> The current m88ts2022 driver will miss the following high symbol rate transponders on Telstar 18 138.0.
>> 12385 H 43200,
>> 12690 H 43200,
>> 12538 V 41250...
>> the code for f_3db_hz will overflow for the high symbol rate.
>> for example, symbol rate=41250 KS/s
>> symbol_rate * 135UL = 5568750000(1 4BEC 61B0), the value is larger than unsigned int on 32bit platform.
>> that makes the wrong result.
>> Exchanging the div and mul position fixs it.
>>
>> Signed-off-by: Nibble Max <nibble.max@gmail.com>
>> ---
>> drivers/media/tuners/m88ts2022.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/media/tuners/m88ts2022.c b/drivers/media/tuners/m88ts2022.c
>> index 40c42de..65c8acc 100644
>> --- a/drivers/media/tuners/m88ts2022.c
>> +++ b/drivers/media/tuners/m88ts2022.c
>> @@ -314,7 +314,7 @@ static int m88ts2022_set_params(struct dvb_frontend *fe)
>> div_min = gdiv28 * 78 / 100;
>> div_max = clamp_val(div_max, 0U, 63U);
>>
>> - f_3db_hz = c->symbol_rate * 135UL / 200UL;
>> + f_3db_hz = (c->symbol_rate / 200UL) * 135UL;
>
>Hmm... wouldn't this make worse for low symbol rates?
>
The unit of symbol rate for Satellite is KS/s(1000S/s).
So it is safe to divide 200 at the first.
>IMHO, the better is to use a u64 instead, and do_div64().
>
>> f_3db_hz += 2000000U + (frequency_offset_khz * 1000U);
>> f_3db_hz = clamp(f_3db_hz, 7000000U, 40000000U);
>>
>
>Regards,
>--
>
>Cheers,
>Mauro
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: nibble.max(3).vcf --]
[-- Type: text/x-vcard; name="nibble.max(3).vcf", Size: 131 bytes --]
BEGIN:VCARD
VERSION:2.1
N:nibble.max;
FN:nibble.max
EMAIL;PREF;INTERNET:nibble.max@gmail.com
REV:20140816T213101Z
END:VCARD
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] m88ts2022: fix high symbol rate transponders missing on 32bit platform.
@ 2014-08-16 6:26 nibble.max
0 siblings, 0 replies; 6+ messages in thread
From: nibble.max @ 2014-08-16 6:26 UTC (permalink / raw)
To: Antti Palosaari; +Cc: linux-media, olli.salonen
The current m88ts2022 driver will miss the following high symbol rate transponders on Telstar 18 138.0.
12385 H 43200,
12690 H 43200,
12538 V 41250...
the code for f_3db_hz will overflow for the high symbol rate.
for example, symbol rate=41250 KS/s
symbol_rate * 135UL = 5568750000(1 4BEC 61B0), the value is larger than unsigned int on 32bit platform.
that makes the wrong result.
Exchanging the div and mul position fixs it.
Signed-off-by: Nibble Max <nibble.max@gmail.com>
---
drivers/media/tuners/m88ts2022.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/tuners/m88ts2022.c b/drivers/media/tuners/m88ts2022.c
index 40c42de..65c8acc 100644
--- a/drivers/media/tuners/m88ts2022.c
+++ b/drivers/media/tuners/m88ts2022.c
@@ -314,7 +314,7 @@ static int m88ts2022_set_params(struct dvb_frontend *fe)
div_min = gdiv28 * 78 / 100;
div_max = clamp_val(div_max, 0U, 63U);
- f_3db_hz = c->symbol_rate * 135UL / 200UL;
+ f_3db_hz = (c->symbol_rate / 200UL) * 135UL;
f_3db_hz += 2000000U + (frequency_offset_khz * 1000U);
f_3db_hz = clamp(f_3db_hz, 7000000U, 40000000U);
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-08-16 19:27 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-16 6:12 [PATCH] m88ts2022: fix high symbol rate transponders missing on 32bit platform nibble.max
2014-08-16 12:38 ` Mauro Carvalho Chehab
2014-08-16 12:53 ` Antti Palosaari
2014-08-16 19:26 ` Matthias Schwarzott
2014-08-16 13:31 ` Re: [PATCH] m88ts2022: fix high symbol rate transponders missing on32bit platform Max Xiang
-- strict thread matches above, loose matches on Subject: below --
2014-08-16 6:26 [PATCH] m88ts2022: fix high symbol rate transponders missing on 32bit platform nibble.max
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).