From patchwork Sat Jun 6 11:58:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antti Palosaari X-Patchwork-Id: 6559331 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8C33FC0020 for ; Sat, 6 Jun 2015 11:59:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A55D520676 for ; Sat, 6 Jun 2015 11:59:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B64B72066A for ; Sat, 6 Jun 2015 11:59:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752505AbbFFL7L (ORCPT ); Sat, 6 Jun 2015 07:59:11 -0400 Received: from mail.kapsi.fi ([217.30.184.167]:53648 "EHLO mail.kapsi.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751148AbbFFL7J (ORCPT ); Sat, 6 Jun 2015 07:59:09 -0400 Received: from dyn3-82-128-190-185.psoas.suomi.net ([82.128.190.185] helo=localhost.localdomain.localdomain) by mail.kapsi.fi with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Z1Ckl-0006LH-GP; Sat, 06 Jun 2015 14:59:07 +0300 From: Antti Palosaari To: linux-media@vger.kernel.org Cc: Antti Palosaari Subject: [PATCH 2/8] ts2020: improve filter limit calc Date: Sat, 6 Jun 2015 14:58:42 +0300 Message-Id: <1433591928-30915-2-git-send-email-crope@iki.fi> X-Mailer: git-send-email 2.4.2 In-Reply-To: <1433591928-30915-1-git-send-email-crope@iki.fi> References: <1433591928-30915-1-git-send-email-crope@iki.fi> X-SA-Exim-Connect-IP: 82.128.190.185 X-SA-Exim-Mail-From: crope@iki.fi X-SA-Exim-Scanned: No (on mail.kapsi.fi); SAEximRunCond expanded to false Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP * We don't need calculate channel bandwidth from symbol rate as it is calculated by DVB core. * Use clamp() to force upper/lower limit of filter 3dB frequency. Upper limit should never exceeded 40MHz (80MHz BW) in any case, though... Signed-off-by: Antti Palosaari --- drivers/media/dvb-frontends/ts2020.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/media/dvb-frontends/ts2020.c b/drivers/media/dvb-frontends/ts2020.c index bc48388..590f7e1 100644 --- a/drivers/media/dvb-frontends/ts2020.c +++ b/drivers/media/dvb-frontends/ts2020.c @@ -233,7 +233,6 @@ static int ts2020_set_params(struct dvb_frontend *fe) struct dtv_frontend_properties *c = &fe->dtv_property_cache; struct ts2020_priv *priv = fe->tuner_priv; int ret; - u32 symbol_rate = (c->symbol_rate / 1000); u32 f3db, gdiv28; u16 u16tmp, value, lpf_coeff; u8 buf[3], reg10, lpf_mxdiv, mlpf_max, mlpf_min, nlpf; @@ -312,12 +311,9 @@ static int ts2020_set_params(struct dvb_frontend *fe) value = ts2020_readreg(fe, 0x26); - f3db = (symbol_rate * 135) / 200 + 2000; - f3db += FREQ_OFFSET_LOW_SYM_RATE; - if (f3db < 7000) - f3db = 7000; - if (f3db > 40000) - f3db = 40000; + f3db = (c->bandwidth_hz / 1000 / 2) + 2000; + f3db += FREQ_OFFSET_LOW_SYM_RATE; /* FIXME: ~always too wide filter */ + f3db = clamp(f3db, 7000U, 40000U); gdiv28 = gdiv28 * 207 / (value * 2 + 151); mlpf_max = gdiv28 * 135 / 100;