Message ID | 4F1E7B01.2050602@tvdr.de (mailing list archive) |
---|---|
State | Accepted, archived |
Headers |
Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from <linux-media-owner@vger.kernel.org>) id 1Rpcld-0003Sb-OG for patchwork@linuxtv.org; Tue, 24 Jan 2012 10:34:17 +0100 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.75/mailfrontend-2) with esmtp for <patchwork@linuxtv.org> id 1Rpclc-0002Dh-JH; Tue, 24 Jan 2012 10:34:17 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755189Ab2AXJeF (ORCPT <rfc822;patchwork@linuxtv.org>); Tue, 24 Jan 2012 04:34:05 -0500 Received: from racoon.tvdr.de ([188.40.50.18]:48718 "EHLO racoon.tvdr.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754642Ab2AXJeC (ORCPT <rfc822;linux-media@vger.kernel.org>); Tue, 24 Jan 2012 04:34:02 -0500 Received: from dolphin.tvdr.de (dolphin.tvdr.de [192.168.100.2]) by racoon.tvdr.de (8.14.3/8.14.3) with ESMTP id q0O9YD3J006218 for <linux-media@vger.kernel.org>; Tue, 24 Jan 2012 10:34:14 +0100 Received: from [192.168.100.10] (hawk.tvdr.de [192.168.100.10]) by dolphin.tvdr.de (8.14.4/8.14.4) with ESMTP id q0O9XrTa010973 for <linux-media@vger.kernel.org>; Tue, 24 Jan 2012 10:33:54 +0100 Message-ID: <4F1E7B01.2050602@tvdr.de> Date: Tue, 24 Jan 2012 10:33:53 +0100 From: Klaus Schmidinger <Klaus.Schmidinger@tvdr.de> User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.24) Gecko/20111101 SUSE/3.1.16 Thunderbird/3.1.16 MIME-Version: 1.0 To: linux-media@vger.kernel.org Subject: Re: [linux-media] Re: [PATCH] stb0899: fix the limits for signal strength values References: <4F18555D.3000205@tvdr.de> <4F1DB873.20206@redhat.com> In-Reply-To: <4F1DB873.20206@redhat.com> Content-Type: multipart/mixed; boundary="------------020705030101040801010701" X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.0.1 (racoon.tvdr.de [188.40.50.18]); Tue, 24 Jan 2012 10:34:14 +0100 (CET) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: <linux-media.vger.kernel.org> X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2012.1.24.92114 X-PMX-Spam: Gauge=X, Probability=10%, Report=' HASHBUSTER_BLOCK_V2 0.5, MIME_TEXT_ONLY_MP_MIXED 0.05, MSGID_ADDED_BY_MTA 0.05, __ANY_URI 0, __BAT_BOUNDARY 0, __BOUNCE_CHALLENGE_SUBJ 0, __BOUNCE_NDR_SUBJ_EXEMPT 0, __CP_URI_IN_BODY 0, __CT 0, __CTYPE_HAS_BOUNDARY 0, __CTYPE_MULTIPART 0, __CTYPE_MULTIPART_MIXED 0, __HASHBUSTER_BLOCK_V2_1 0, __HAS_MSGID 0, __HAS_X_MAILING_LIST 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __MOZILLA_MSGID 0, __SANE_MSGID 0, __STOCK_PHRASE_7 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_WWW 0, __URI_NS , __USER_AGENT 0' |
Commit Message
Klaus Schmidinger
Jan. 24, 2012, 9:33 a.m. UTC
On 23.01.2012 20:43, Mauro Carvalho Chehab wrote: > Hi Klaus, > > The patch didn't apply. It seems to be due to your emailer that mangled the > whitespaces. Sorry about that. Here it is again as an attachment. > The patch looks correct on my eyes. Yet, I'd like to have Manu's ack on it. > > Em 19-01-2012 15:39, Klaus Schmidinger escreveu: >> stb0899_read_signal_strength() adds an offset to the result of the table lookup. >> That offset must correspond to the lowest value in the lookup table, to make sure >> the result doesn't get below 0, which would mean a "very high" value since the >> parameter is unsigned. >> 'strength' and 'snr' need to be initialized to 0 to make sure they have a >> defined result in case there is no "internal->lock". >> >> Signed-off-by: Klaus Schmidinger<Klaus.Schmidinger@tvdr.de> >> >> --- a/linux/drivers/media/dvb/frontends/stb0899_drv.c 2011-06-11 16:54:32.000000000 +0200 >> +++ b/linux/drivers/media/dvb/frontends/stb0899_drv.c 2011-06-11 16:23:00.000000000 +0200 >> @@ -67,7 +67,7 @@ >> * Crude linear extrapolation below -84.8dBm and above -8.0dBm. >> */ >> static const struct stb0899_tab stb0899_dvbsrf_tab[] = { >> - { -950, -128 }, >> + { -750, -128 }, >> { -748, -94 }, >> { -745, -92 }, >> { -735, -90 }, >> @@ -131,7 +131,7 @@ >> { -730, 13645 }, >> { -750, 13909 }, >> { -766, 14153 }, >> - { -999, 16383 } >> + { -950, 16383 } >> }; >> >> /* DVB-S2 Es/N0 quant in dB/100 vs read value * 100*/ >> @@ -964,6 +964,7 @@ >> >> int val; >> u32 reg; >> + *strength = 0; > > This is not needed, as strength is not initialized only on invalid delivery systems, > where -EINVAL is returned. What about the 'if' conditions within the valid delivery system cases? For instance case SYS_DSS: if (internal->lock) { ... if (STB0899_GETFIELD(VSTATUS_LOCKEDVIT, reg)) { ... *strength = ... } } break; So there may be cases where strength has an undefined value, even if this function returns 0. >> switch (state->delsys) { >> case SYS_DVBS: >> case SYS_DSS: >> @@ -987,7 +988,7 @@ >> val = STB0899_GETFIELD(IF_AGC_GAIN, reg); >> >> *strength = stb0899_table_lookup(stb0899_dvbs2rf_tab, ARRAY_SIZE(stb0899_dvbs2rf_tab) - 1, val); >> - *strength += 750; >> + *strength += 950; >> dprintk(state->verbose, FE_DEBUG, 1, "IF_AGC_GAIN = 0x%04x, C = %d * 0.1 dBm", >> val& 0x3fff, *strength); >> } >> @@ -1009,6 +1010,7 @@ >> u8 buf[2]; >> u32 reg; >> >> + *snr = 0; > > This is not needed, as strength is not initialized only on invalid delivery systems, > where -EINVAL is returned. See above. >> reg = stb0899_read_reg(state, STB0899_VSTATUS); >> switch (state->delsys) { >> case SYS_DVBS: > > PS.: Another alternative for it would be the enclosed patch, > wich will be a little simpler, and will also preserve the slope > on the boundary values, used at the stb0899_table_lookup() > interpolation logic. Well, as long as there are no negative values for strength... However, I don't quite see why the range is 750 - 950 for DVB-S and 750 - 999 for DVB-S2. Shouldn't this be the same maximum value in both cases? Klaus > [PATCH] stb0899: fix the limits for signal strength values > > The current minimal measures for strengh is 750 - 950, for table > stb0899_dvbsrf_tab[], and 750 - 999, for stb0899_dvbs2rf_tab[]. > Both are negative values. However, the strength measure is unsigned. > > Don't allow negative values for strengh to underflow. Instead, > shift the scale, in order to have 0 as the lowest strength. > > Signed-off-by: Mauro Carvalho Chehab<mchehab@redhat.com> > > diff --git a/drivers/media/dvb/frontends/stb0899_drv.c b/drivers/media/dvb/frontends/stb0899_drv.c > index 38565be..9cfdcb2 100644 > --- a/drivers/media/dvb/frontends/stb0899_drv.c > +++ b/drivers/media/dvb/frontends/stb0899_drv.c > @@ -975,7 +975,7 @@ static int stb0899_read_signal_strength(struct dvb_frontend *fe, u16 *strength) > val = (s32)(s8)STB0899_GETFIELD(AGCIQVALUE, reg); > > *strength = stb0899_table_lookup(stb0899_dvbsrf_tab, ARRAY_SIZE(stb0899_dvbsrf_tab) - 1, val); > - *strength += 750; > + *strength += 950; > dprintk(state->verbose, FE_DEBUG, 1, "AGCIQVALUE = 0x%02x, C = %d * 0.1 dBm", > val& 0xff, *strength); > } > @@ -987,7 +987,7 @@ static int stb0899_read_signal_strength(struct dvb_frontend *fe, u16 *strength) > val = STB0899_GETFIELD(IF_AGC_GAIN, reg); > > *strength = stb0899_table_lookup(stb0899_dvbs2rf_tab, ARRAY_SIZE(stb0899_dvbs2rf_tab) - 1, val); > - *strength += 750; > + *strength += 999; > dprintk(state->verbose, FE_DEBUG, 1, "IF_AGC_GAIN = 0x%04x, C = %d * 0.1 dBm", > val& 0x3fff, *strength); > }
Comments
Em 24-01-2012 07:33, Klaus Schmidinger escreveu: > On 23.01.2012 20:43, Mauro Carvalho Chehab wrote: >> Hi Klaus, >> >> The patch didn't apply. It seems to be due to your emailer that mangled the >> whitespaces. > > Sorry about that. Here it is again as an attachment. Thanks! >> The patch looks correct on my eyes. Yet, I'd like to have Manu's ack on it. >> >> Em 19-01-2012 15:39, Klaus Schmidinger escreveu: >>> stb0899_read_signal_strength() adds an offset to the result of the table lookup. >>> That offset must correspond to the lowest value in the lookup table, to make sure >>> the result doesn't get below 0, which would mean a "very high" value since the >>> parameter is unsigned. >>> 'strength' and 'snr' need to be initialized to 0 to make sure they have a >>> defined result in case there is no "internal->lock". >>> >>> Signed-off-by: Klaus Schmidinger<Klaus.Schmidinger@tvdr.de> >>> >>> --- a/linux/drivers/media/dvb/frontends/stb0899_drv.c 2011-06-11 16:54:32.000000000 +0200 >>> +++ b/linux/drivers/media/dvb/frontends/stb0899_drv.c 2011-06-11 16:23:00.000000000 +0200 >>> @@ -67,7 +67,7 @@ >>> * Crude linear extrapolation below -84.8dBm and above -8.0dBm. >>> */ >>> static const struct stb0899_tab stb0899_dvbsrf_tab[] = { >>> - { -950, -128 }, >>> + { -750, -128 }, >>> { -748, -94 }, >>> { -745, -92 }, >>> { -735, -90 }, >>> @@ -131,7 +131,7 @@ >>> { -730, 13645 }, >>> { -750, 13909 }, >>> { -766, 14153 }, >>> - { -999, 16383 } >>> + { -950, 16383 } >>> }; >>> >>> /* DVB-S2 Es/N0 quant in dB/100 vs read value * 100*/ >>> @@ -964,6 +964,7 @@ >>> >>> int val; >>> u32 reg; >>> + *strength = 0; >> >> This is not needed, as strength is not initialized only on invalid delivery systems, >> where -EINVAL is returned. > > What about the 'if' conditions within the valid delivery system cases? > For instance > > case SYS_DSS: > if (internal->lock) { > ... > if (STB0899_GETFIELD(VSTATUS_LOCKEDVIT, reg)) { > ... > *strength = ... > } > } > break; > > So there may be cases where strength has an undefined value, even > if this function returns 0. Good point. I wandering why gcc didn't complain about that. >>> switch (state->delsys) { >>> case SYS_DVBS: >>> case SYS_DSS: >>> @@ -987,7 +988,7 @@ >>> val = STB0899_GETFIELD(IF_AGC_GAIN, reg); >>> >>> *strength = stb0899_table_lookup(stb0899_dvbs2rf_tab, ARRAY_SIZE(stb0899_dvbs2rf_tab) - 1, val); >>> - *strength += 750; >>> + *strength += 950; >>> dprintk(state->verbose, FE_DEBUG, 1, "IF_AGC_GAIN = 0x%04x, C = %d * 0.1 dBm", >>> val& 0x3fff, *strength); >>> } >>> @@ -1009,6 +1010,7 @@ >>> u8 buf[2]; >>> u32 reg; >>> >>> + *snr = 0; >> >> This is not needed, as strength is not initialized only on invalid delivery systems, >> where -EINVAL is returned. > > See above. > >>> reg = stb0899_read_reg(state, STB0899_VSTATUS); >>> switch (state->delsys) { >>> case SYS_DVBS: >> >> PS.: Another alternative for it would be the enclosed patch, >> wich will be a little simpler, and will also preserve the slope >> on the boundary values, used at the stb0899_table_lookup() >> interpolation logic. > > Well, as long as there are no negative values for strength... > However, I don't quite see why the range is 750 - 950 for DVB-S > and 750 - 999 for DVB-S2. Shouldn't this be the same maximum > value in both cases? This is a very good question. Unfortunately, I don't have the datasheets for this device. Manu shold be able to answer that better than me. Based on the table lookup routine, I suspect that what those tables are doing are to interpolate some log curve by breaking it into a few straight line segments. Changing from 999 to 950 will affect such interpolation. So, it is better to check this at the datasheets before changing from -999 to -950, or from -750 to -950. Manu, Could you please review it? Thanks! Mauro Em 24-01-2012 07:33, Klaus Schmidinger escreveu: > > stb0899: fix the limits for signal strength values > > stb0899_read_signal_strength() adds an offset to the result of the table lookup. > That offset must correspond to the lowest value in the lookup table, to make sure > the result doesn't get below 0, which would mean a "very high" value since the > parameter is unsigned. > 'strength' and 'snr' need to be initialized to 0 to make sure they have a > defined result in case there is no "internal->lock". > > Signed-off-by: Klaus Schmidinger <Klaus.Schmidinger@tvdr.de> > > --- a/linux/drivers/media/dvb/frontends/stb0899_drv.c 2011-06-11 16:54:32.000000000 +0200 > +++ b/linux/drivers/media/dvb/frontends/stb0899_drv.c 2011-06-11 16:23:00.000000000 +0200 > @@ -67,7 +67,7 @@ > * Crude linear extrapolation below -84.8dBm and above -8.0dBm. > */ > static const struct stb0899_tab stb0899_dvbsrf_tab[] = { > - { -950, -128 }, > + { -750, -128 }, > { -748, -94 }, > { -745, -92 }, > { -735, -90 }, > @@ -131,7 +131,7 @@ > { -730, 13645 }, > { -750, 13909 }, > { -766, 14153 }, > - { -999, 16383 } > + { -950, 16383 } > }; > > /* DVB-S2 Es/N0 quant in dB/100 vs read value * 100*/ > @@ -964,6 +964,7 @@ > > int val; > u32 reg; > + *strength = 0; > switch (state->delsys) { > case SYS_DVBS: > case SYS_DSS: > @@ -987,7 +988,7 @@ > val = STB0899_GETFIELD(IF_AGC_GAIN, reg); > > *strength = stb0899_table_lookup(stb0899_dvbs2rf_tab, ARRAY_SIZE(stb0899_dvbs2rf_tab) - 1, val); > - *strength += 750; > + *strength += 950; > dprintk(state->verbose, FE_DEBUG, 1, "IF_AGC_GAIN = 0x%04x, C = %d * 0.1 dBm", > val & 0x3fff, *strength); > } > @@ -1009,6 +1010,7 @@ > u8 buf[2]; > u32 reg; > > + *snr = 0; > reg = stb0899_read_reg(state, STB0899_VSTATUS); > switch (state->delsys) { > case SYS_DVBS: -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
stb0899: fix the limits for signal strength values stb0899_read_signal_strength() adds an offset to the result of the table lookup. That offset must correspond to the lowest value in the lookup table, to make sure the result doesn't get below 0, which would mean a "very high" value since the parameter is unsigned. 'strength' and 'snr' need to be initialized to 0 to make sure they have a defined result in case there is no "internal->lock". Signed-off-by: Klaus Schmidinger <Klaus.Schmidinger@tvdr.de> --- a/linux/drivers/media/dvb/frontends/stb0899_drv.c 2011-06-11 16:54:32.000000000 +0200 +++ b/linux/drivers/media/dvb/frontends/stb0899_drv.c 2011-06-11 16:23:00.000000000 +0200 @@ -67,7 +67,7 @@ * Crude linear extrapolation below -84.8dBm and above -8.0dBm. */ static const struct stb0899_tab stb0899_dvbsrf_tab[] = { - { -950, -128 }, + { -750, -128 }, { -748, -94 }, { -745, -92 }, { -735, -90 }, @@ -131,7 +131,7 @@ { -730, 13645 }, { -750, 13909 }, { -766, 14153 }, - { -999, 16383 } + { -950, 16383 } }; /* DVB-S2 Es/N0 quant in dB/100 vs read value * 100*/ @@ -964,6 +964,7 @@ int val; u32 reg; + *strength = 0; switch (state->delsys) { case SYS_DVBS: case SYS_DSS: @@ -987,7 +988,7 @@ val = STB0899_GETFIELD(IF_AGC_GAIN, reg); *strength = stb0899_table_lookup(stb0899_dvbs2rf_tab, ARRAY_SIZE(stb0899_dvbs2rf_tab) - 1, val); - *strength += 750; + *strength += 950; dprintk(state->verbose, FE_DEBUG, 1, "IF_AGC_GAIN = 0x%04x, C = %d * 0.1 dBm", val & 0x3fff, *strength); } @@ -1009,6 +1010,7 @@ u8 buf[2]; u32 reg; + *snr = 0; reg = stb0899_read_reg(state, STB0899_VSTATUS); switch (state->delsys) { case SYS_DVBS: