From patchwork Fri Jul 1 18:41:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 9210335 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E53BB607D6 for ; Fri, 1 Jul 2016 18:41:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D6DD9286D1 for ; Fri, 1 Jul 2016 18:41:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB4BA286D6; Fri, 1 Jul 2016 18:41:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C9A6286D1 for ; Fri, 1 Jul 2016 18:41:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752542AbcGASls (ORCPT ); Fri, 1 Jul 2016 14:41:48 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:54936 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752004AbcGASlr (ORCPT ); Fri, 1 Jul 2016 14:41:47 -0400 Received: from 177.17.252.210.dynamic.adsl.gvt.net.br ([177.17.252.210] helo=smtp.w2.samsung.com) by bombadil.infradead.org with esmtpsa (Exim 4.85_2 #1 (Red Hat Linux)) id 1bJ3Np-0002Vi-AV; Fri, 01 Jul 2016 18:41:45 +0000 Received: from mchehab by smtp.w2.samsung.com with local (Exim 4.87) (envelope-from ) id 1bJ3Nk-0004tf-Kt; Fri, 01 Jul 2016 15:41:40 -0300 From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , Linux Media Mailing List , Mauro Carvalho Chehab , Sergey Kozlov , Abylay Ospan Subject: [PATCH] cxd2841er: fix signal strength scale for ISDB-T Date: Fri, 1 Jul 2016 15:41:38 -0300 Message-Id: X-Mailer: git-send-email 2.7.4 To: unlisted-recipients:; (no To-header on input) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The scale for ISDB-T was wrong too: it was inverted, and on a relative scale. Use a linear interpolation to make it look better. The formula was empirically determined, using 3 frequencies (175 MHz, 410 MHz and 800 MHz), measuring from -50dBm to -12dBm in steps of 0.5dB. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/cxd2841er.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/media/dvb-frontends/cxd2841er.c b/drivers/media/dvb-frontends/cxd2841er.c index 6c660761563d..b706118903fa 100644 --- a/drivers/media/dvb-frontends/cxd2841er.c +++ b/drivers/media/dvb-frontends/cxd2841er.c @@ -1731,7 +1731,7 @@ static void cxd2841er_read_signal_strength(struct dvb_frontend *fe) { struct dtv_frontend_properties *p = &fe->dtv_property_cache; struct cxd2841er_priv *priv = fe->demodulator_priv; - u32 strength; + s32 strength; dev_dbg(&priv->i2c->dev, "%s()\n", __func__); switch (p->delivery_system) { @@ -1741,7 +1741,7 @@ static void cxd2841er_read_signal_strength(struct dvb_frontend *fe) p->delivery_system); p->strength.stat[0].scale = FE_SCALE_DECIBEL; /* Formula was empirically determinated @ 410 MHz */ - p->strength.stat[0].uvalue = ((s32)strength) * 366 / 100 - 89520; + p->strength.stat[0].uvalue = strength * 366 / 100 - 89520; break; /* Code moved out of the function */ case SYS_DVBC_ANNEX_A: strength = cxd2841er_read_agc_gain_t_t2(priv, @@ -1752,13 +1752,16 @@ static void cxd2841er_read_signal_strength(struct dvb_frontend *fe) * using frequencies: 175 MHz, 410 MHz and 800 MHz, and a * stream modulated with QAM64 */ - p->strength.stat[0].uvalue = ((s32)strength) * 4045 / 1000 - 85224; + p->strength.stat[0].uvalue = strength * 4045 / 1000 - 85224; break; case SYS_ISDBT: - strength = 65535 - cxd2841er_read_agc_gain_i( - priv, p->delivery_system); - p->strength.stat[0].scale = FE_SCALE_RELATIVE; - p->strength.stat[0].uvalue = strength; + strength = cxd2841er_read_agc_gain_i(priv, p->delivery_system); + p->strength.stat[0].scale = FE_SCALE_DECIBEL; + /* + * Formula was empirically determinated via linear regression, + * using frequencies: 175 MHz, 410 MHz and 800 MHz. + */ + p->strength.stat[0].uvalue = strength * 3775 / 1000 - 90185; break; case SYS_DVBS: case SYS_DVBS2: