From patchwork Tue Sep 23 09:45:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bimow Chen X-Patchwork-Id: 4954791 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A5FFD9F2BB for ; Tue, 23 Sep 2014 09:52:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 981C52024C for ; Tue, 23 Sep 2014 09:52:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 20C8A2022D for ; Tue, 23 Sep 2014 09:52:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755235AbaIWJww (ORCPT ); Tue, 23 Sep 2014 05:52:52 -0400 Received: from 219-87-157-213.static.tfn.net.tw ([219.87.157.213]:11817 "EHLO ironport.ite.com.tw" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755232AbaIWJwv (ORCPT ); Tue, 23 Sep 2014 05:52:51 -0400 Received: from unknown (HELO mse.ite.com.tw) ([192.168.35.30]) by ironport.ite.com.tw with ESMTP; 23 Sep 2014 17:42:46 +0800 Received: from ms2.internal.ite.com.tw (ms2.internal.ite.com.tw [192.168.15.236]) by mse.ite.com.tw with ESMTP id s8N9ghDL018158; Tue, 23 Sep 2014 17:42:43 +0800 (CST) (envelope-from Bimow.Chen@ite.com.tw) Received: from [192.168.190.2] (unknown [192.168.190.2]) by ms2.internal.ite.com.tw (Postfix) with ESMTP id 11D9D454C6; Tue, 23 Sep 2014 17:42:39 +0800 (CST) Subject: [2/2] af9033: fix snr value not correct issue From: Bimow Chen To: linux-media@vger.kernel.org Cc: crope@iki.fi Organization: ITE Date: Tue, 23 Sep 2014 17:45:36 +0800 Message-ID: <1411465536.1919.7.camel@ite-desktop> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 X-MAIL: mse.ite.com.tw s8N9ghDL018158 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_TVD_MIME_EPI, UNPARSEABLE_RELAY autolearn=ham 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 Snr returns value not correct. Fix it. From f3d5c9e2b01e666eca7aa66cd15b67609a0589ea Mon Sep 17 00:00:00 2001 From: Bimow Chen Date: Tue, 23 Sep 2014 17:23:31 +0800 Subject: [PATCH 2/2] af9033: fix snr value not correct issue Snr returns value not correct. Fix it. Signed-off-by: Bimow Chen --- drivers/media/dvb-frontends/af9033.c | 46 +++++++++++++++++++++++++++-- drivers/media/dvb-frontends/af9033_priv.h | 5 ++- 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/drivers/media/dvb-frontends/af9033.c b/drivers/media/dvb-frontends/af9033.c index 0a0aeaf..37bd624 100644 --- a/drivers/media/dvb-frontends/af9033.c +++ b/drivers/media/dvb-frontends/af9033.c @@ -840,7 +840,7 @@ static int af9033_read_snr(struct dvb_frontend *fe, u16 *snr) { struct af9033_state *state = fe->demodulator_priv; int ret, i, len; - u8 buf[3], tmp; + u8 buf[3], tmp, tmp2; u32 snr_val; const struct val_snr *uninitialized_var(snr_lut); @@ -851,6 +851,33 @@ static int af9033_read_snr(struct dvb_frontend *fe, u16 *snr) snr_val = (buf[2] << 16) | (buf[1] << 8) | buf[0]; + /* read superframe number */ + ret = af9033_rd_reg(state, 0x80f78b, &tmp); + if (ret < 0) + goto err; + + if (tmp) + snr_val /= tmp; + + /* read current transmission mode */ + ret = af9033_rd_reg(state, 0x80f900, &tmp); + if (ret < 0) + goto err; + + switch ((tmp >> 0) & 3) { + case 0: + snr_val *= 4; + break; + case 1: + snr_val *= 1; + break; + case 2: + snr_val *= 2; + break; + default: + goto err; + } + /* read current modulation */ ret = af9033_rd_reg(state, 0x80f903, &tmp); if (ret < 0) @@ -874,13 +901,26 @@ static int af9033_read_snr(struct dvb_frontend *fe, u16 *snr) } for (i = 0; i < len; i++) { - tmp = snr_lut[i].snr; + tmp2 = snr_lut[i].snr; if (snr_val < snr_lut[i].val) break; } - *snr = tmp * 10; /* dB/10 */ + /* scale value to 0x0000-0xffff */ + switch ((tmp >> 0) & 3) { + case 0: + *snr = tmp2 * 0xFFFF / 23; + break; + case 1: + *snr = tmp2 * 0xFFFF / 26; + break; + case 2: + *snr = tmp2 * 0xFFFF / 32; + break; + default: + goto err; + } return 0; diff --git a/drivers/media/dvb-frontends/af9033_priv.h b/drivers/media/dvb-frontends/af9033_priv.h index 58315e0..6351626 100644 --- a/drivers/media/dvb-frontends/af9033_priv.h +++ b/drivers/media/dvb-frontends/af9033_priv.h @@ -180,7 +180,10 @@ static const struct val_snr qam64_snr_lut[] = { { 0x05570d, 26 }, { 0x059feb, 27 }, { 0x05bf38, 28 }, - { 0xffffff, 29 }, + { 0x05f78f, 29 }, + { 0x0612c3, 30 }, + { 0x0626be, 31 }, + { 0xffffff, 32 }, }; static const struct reg_val ofsm_init[] = { -- 1.7.0.4