From patchwork Tue Dec 17 15:30:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 3363881 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1A92DC0D4A for ; Tue, 17 Dec 2013 18:34:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 79A4B202B4 for ; Tue, 17 Dec 2013 18:33:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7FB8E201BF for ; Tue, 17 Dec 2013 18:33:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932085Ab3LQSdv (ORCPT ); Tue, 17 Dec 2013 13:33:51 -0500 Received: from bombadil.infradead.org ([198.137.202.9]:41981 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756274Ab3LQSdr (ORCPT ); Tue, 17 Dec 2013 13:33:47 -0500 Received: from [177.143.133.66] (helo=smtp.w2.samsung.com) by bombadil.infradead.org with esmtpsa (Exim 4.80.1 #2 (Red Hat Linux)) id 1VszSk-0001w1-VN; Tue, 17 Dec 2013 18:33:47 +0000 Received: from mchehab by smtp.w2.samsung.com with local (Exim 4.80.1) (envelope-from ) id 1Vswbf-0002ef-U1; Tue, 17 Dec 2013 13:30:47 -0200 From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , Linux Media Mailing List , Mauro Carvalho Chehab Subject: [PATCH 4/6] [media] dib8000: Fix UCB measure with DVBv5 stats Date: Tue, 17 Dec 2013 13:30:44 -0200 Message-Id: <1387294246-10155-5-git-send-email-m.chehab@samsung.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1387294246-10155-1-git-send-email-m.chehab@samsung.com> References: <1387294246-10155-1-git-send-email-m.chehab@samsung.com> 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-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 On dib8000, the block error count is a monotonic 32 bits register. With DVBv5 stats, we use a 64 bits counter, that it is reset when a new channel is tuned. Change the UCB counting start from 0 and to be returned with 64 bits, just like the API requests. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/dib8000.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/media/dvb-frontends/dib8000.c b/drivers/media/dvb-frontends/dib8000.c index 7b10b73befbe..ef0d9ec0df23 100644 --- a/drivers/media/dvb-frontends/dib8000.c +++ b/drivers/media/dvb-frontends/dib8000.c @@ -119,6 +119,7 @@ struct dib8000_state { u8 longest_intlv_layer; u16 output_mode; + s64 init_ucb; #ifdef DIB8000_AGC_FREEZE u16 agc1_max; u16 agc1_min; @@ -986,10 +987,13 @@ static u16 dib8000_identify(struct i2c_device *client) return value; } +static int dib8000_read_unc_blocks(struct dvb_frontend *fe, u32 *unc); + static void dib8000_reset_stats(struct dvb_frontend *fe) { struct dib8000_state *state = fe->demodulator_priv; struct dtv_frontend_properties *c = &state->fe[0]->dtv_property_cache; + u32 ucb; memset(&c->strength, 0, sizeof(c->strength)); memset(&c->cnr, 0, sizeof(c->cnr)); @@ -1010,6 +1014,9 @@ static void dib8000_reset_stats(struct dvb_frontend *fe) c->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; c->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; c->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE; + + dib8000_read_unc_blocks(fe, &ucb); + state->init_ucb = -ucb; } static int dib8000_reset(struct dvb_frontend *fe) @@ -3989,14 +3996,12 @@ static int dib8000_get_stats(struct dvb_frontend *fe, fe_status_t stat) c->post_bit_count.stat[0].scale = FE_SCALE_COUNTER; c->post_bit_count.stat[0].uvalue += 100000000; - /* - * FIXME: this is refreshed on every second, but a time - * drift between dib8000 and PC clock may cause troubles - */ dib8000_read_unc_blocks(fe, &val); + if (val < state->init_ucb) + state->init_ucb += 1L << 32; c->block_error.stat[0].scale = FE_SCALE_COUNTER; - c->block_error.stat[0].uvalue += val; + c->block_error.stat[0].uvalue = val + state->init_ucb; if (state->revision < 0x8002) return 0;