From patchwork Sun Apr 9 19:38:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scheller X-Patchwork-Id: 9671735 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 4F716600CB for ; Sun, 9 Apr 2017 19:38:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C01026E8A for ; Sun, 9 Apr 2017 19:38:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 30F2E27F10; Sun, 9 Apr 2017 19:38:55 +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.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 D17D726E8A for ; Sun, 9 Apr 2017 19:38:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752635AbdDITix (ORCPT ); Sun, 9 Apr 2017 15:38:53 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:34784 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752322AbdDITiq (ORCPT ); Sun, 9 Apr 2017 15:38:46 -0400 Received: by mail-wm0-f67.google.com with SMTP id x75so6393781wma.1 for ; Sun, 09 Apr 2017 12:38:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+tJ4PqSbWCKhhqFgcJEVVIdaT+Xd04ZAGhXcRDesRjY=; b=vHbId2zivfhJfr9o2OTpYS1ix36bfaV2DkROjyacFYEnpis2AB1B+x256GNIUG1kj6 TmK5GU3wkUFHqHFcYFQzLGXD59gZvuKpv2YkM70A7+emnBDvWUm/sn3xTo0gnIK4Hp9t J3dD1TfxvbTAWKAkeO3J1BHEv/W3kQKTfez/JNDyIrsTB+QbyxNlYWKfvt0F7fVB5NBe SacEgHIQfefZ/6Lmngruyasg1g+A6i4l+jUcIr5nmCkJAZjhNy2Fr7NxmMCBM57lhCjG V9Z+kdHzGSnTZ2XIbUFE2VCD+PAeNl/MsBj+SLAkzu0HASN34Hlc35dxTfd7Sop8Iz/I bCsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+tJ4PqSbWCKhhqFgcJEVVIdaT+Xd04ZAGhXcRDesRjY=; b=aVZgNgc7WYT5YZcxN0w4ngaixbCHj3EBUv/5JEfUs+gvj2fz1R2untW9pffaT3ubV1 CZMmXEUdqzMV4490jbuX+zsKwnlGtxv297giwKGYBZsB4LnhrJrSIr3AFZ8BDOSQXS7s c20UVhC/IlKgRC4AVUIKj+K2vo4zp+wQUqESqT0vqxIp8Ex7TyBlEeig0txjB5fNfD/W wITKAToFgPf5Mv+Pa4pBEJG2GkB5VuWdpWAwcBXCNFqFo79jTakKJ038v8wZTR6Xctk5 8GVK4ivtDPaXLKVL5zltfA4k1JU5WW7Krzqr7WY7cWALBsWXFTiFlmkv/hYnk9WIBEF2 yU5g== X-Gm-Message-State: AN3rC/6AEXROe7dX+B0i590AmdSWBdCSl9vDwwYfbC6zGu4wY+zOFUNd pv5UL1D5lhGgJw== X-Received: by 10.28.93.65 with SMTP id r62mr6930129wmb.77.1491766724786; Sun, 09 Apr 2017 12:38:44 -0700 (PDT) Received: from dvbdev.wuest.de (ip-37-24-178-151.hsi14.unitymediagroup.de. [37.24.178.151]) by smtp.gmail.com with ESMTPSA id f135sm7441407wmd.7.2017.04.09.12.38.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 09 Apr 2017 12:38:44 -0700 (PDT) From: Daniel Scheller To: aospan@netup.ru, serjk@netup.ru, mchehab@kernel.org, linux-media@vger.kernel.org Cc: rjkm@metzlerbros.de Subject: [PATCH 15/19] [media] dvb-frontends/cxd2841er: improved snr reporting Date: Sun, 9 Apr 2017 21:38:24 +0200 Message-Id: <20170409193828.18458-16-d.scheller.oss@gmail.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170409193828.18458-1-d.scheller.oss@gmail.com> References: <20170409193828.18458-1-d.scheller.oss@gmail.com> 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 From: Daniel Scheller On DVB-T/T2 at least, SNR might be reported as >2500dB, which not only is just wrong but also ridiculous, so fix this by improving the conversion of the register value. The INTLOG10X100 function/macro and the way the values are converted were both taken from DD's cxd2843 driver. Signed-off-by: Daniel Scheller Acked-by: Abylay Ospan --- drivers/media/dvb-frontends/cxd2841er.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/media/dvb-frontends/cxd2841er.c b/drivers/media/dvb-frontends/cxd2841er.c index efb2795..a01ac58 100644 --- a/drivers/media/dvb-frontends/cxd2841er.c +++ b/drivers/media/dvb-frontends/cxd2841er.c @@ -38,6 +38,8 @@ #define MAX_WRITE_REGSIZE 16 #define LOG2_E_100X 144 +#define INTLOG10X100(x) ((u32) (((u64) intlog10(x) * 100) >> 24)) + /* DVB-C constellation */ enum sony_dvbc_constellation_t { SONY_DVBC_CONSTELLATION_16QAM, @@ -1817,7 +1819,7 @@ static int cxd2841er_read_snr_t(struct cxd2841er_priv *priv, u32 *snr) } if (reg > 4996) reg = 4996; - *snr = 10000 * ((intlog10(reg) - intlog10(5350 - reg)) >> 24) + 28500; + *snr = 100 * ((INTLOG10X100(reg) - INTLOG10X100(5350 - reg)) + 285); return 0; } @@ -1846,8 +1848,7 @@ static int cxd2841er_read_snr_t2(struct cxd2841er_priv *priv, u32 *snr) } if (reg > 10876) reg = 10876; - *snr = 10000 * ((intlog10(reg) - - intlog10(12600 - reg)) >> 24) + 32000; + *snr = 100 * ((INTLOG10X100(reg) - INTLOG10X100(12600 - reg)) + 320); return 0; }