From patchwork Tue Jun 20 17:45:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scheller X-Patchwork-Id: 9800027 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 AC2E260329 for ; Tue, 20 Jun 2017 17:45:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E405204C1 for ; Tue, 20 Jun 2017 17:45:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 92F3C2223E; Tue, 20 Jun 2017 17:45:14 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, 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 383C31FFD6 for ; Tue, 20 Jun 2017 17:45:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751131AbdFTRpN (ORCPT ); Tue, 20 Jun 2017 13:45:13 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:33378 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751094AbdFTRpM (ORCPT ); Tue, 20 Jun 2017 13:45:12 -0400 Received: by mail-wr0-f194.google.com with SMTP id x23so19170843wrb.0 for ; Tue, 20 Jun 2017 10:45:11 -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=jncyUnm7kZs/FSA04Wi0xk4Sh3LhZmsEnSNW6ChM7Iw=; b=b6jCcuNPtUf4XyAmkCfv4A5me3jeT7mCBD7X4634m/qtNW13DgJ+FoHKs2CcX/E29y CBCCyVwAZxfn6OpfTR/6dKA5oWBexiNK2l4NBRBI0IgEiLKs3hyM6Q0Mz+b/wJfngS62 WVkrSpT7SZMAT/T+/EzCmEVZiDACT66A4c8QlAKRCpcdQ44lUesJ6pDlm3hXRSNHyERY z3zPeKTL/Y4ADtk/To5RnAyu3sNdn+zcyDdXqKGWwlaDMEtwTQiZsrmfSFrHYS0PzWkQ mgy3GTsQrJgCUq4mltO9d6eexILjpaD4MhZV4R+V/THdxzR/jRh0Kc8T5Q6+6Vbr9Xh3 Ol8g== 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=jncyUnm7kZs/FSA04Wi0xk4Sh3LhZmsEnSNW6ChM7Iw=; b=fVAsb1E9EBWDWj+/7+fsTtY2vWuLF/l56BXXLf83CWCKLH7l4AyUsYiujWXVTX9TqF /6zr99U/QhiYdtualfaiLUc67neNkc7xSFULIC3SI3tuukXUapvR+jzHvgdm5JugPPxz RHivX/RX2pzePUFomL2uvGMRMOQ9syL1OglzRyKvX30w8Fa0TylLuo27ncH9tPTm0ZTw Qd5KOP6aNo8pT6O+s7ilF2niAGd1q5uS8+Bdg8XYzLxLqgo/O1n7+dQxwQthC4MOks2y 7ogyb+TJPf4T6Q+jefbQj2Q3Atz6RF80TExaAeKioO/yzup3ecGWG6crX2v+ntoX3brZ WkDQ== X-Gm-Message-State: AKS2vOwPCLi9cNqeFSdGAPjYiuwu9OULKNvGMVox/XynjgneHRVp9Ihf p8Lj5qck/RkQeARZ X-Received: by 10.223.175.37 with SMTP id z34mr20786110wrc.11.1497980710585; Tue, 20 Jun 2017 10:45:10 -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 e130sm18622962wmf.10.2017.06.20.10.45.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 Jun 2017 10:45:09 -0700 (PDT) From: Daniel Scheller To: linux-media@vger.kernel.org, mchehab@kernel.org, mchehab@s-opensource.com Cc: liplianin@netup.ru, rjkm@metzlerbros.de Subject: [PATCH 1/4] [media] dvb-frontends/stv0367: initial DDB DVBv5 stats, implement ucblocks Date: Tue, 20 Jun 2017 19:45:03 +0200 Message-Id: <20170620174506.7593-2-d.scheller.oss@gmail.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170620174506.7593-1-d.scheller.oss@gmail.com> References: <20170620174506.7593-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 This adds the basics to stv0367ddb_get_frontend() to be able to properly provide signal statistics in DVBv5 format. Also adds UCB readout and provides those values. Signed-off-by: Daniel Scheller --- drivers/media/dvb-frontends/stv0367.c | 59 ++++++++++++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 4 deletions(-) diff --git a/drivers/media/dvb-frontends/stv0367.c b/drivers/media/dvb-frontends/stv0367.c index e726c2e00460..5374d4eaabd6 100644 --- a/drivers/media/dvb-frontends/stv0367.c +++ b/drivers/media/dvb-frontends/stv0367.c @@ -2997,21 +2997,64 @@ static int stv0367ddb_read_status(struct dvb_frontend *fe, return -EINVAL; } +static void stv0367ddb_read_ucblocks(struct dvb_frontend *fe) +{ + struct stv0367_state *state = fe->demodulator_priv; + struct dtv_frontend_properties *p = &fe->dtv_property_cache; + u32 ucblocks = 0; + + switch (state->activedemod) { + case demod_ter: + stv0367ter_read_ucblocks(fe, &ucblocks); + break; + case demod_cab: + stv0367cab_read_ucblcks(fe, &ucblocks); + break; + default: + p->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; + return; + } + + p->block_error.stat[0].scale = FE_SCALE_COUNTER; + p->block_error.stat[0].uvalue = ucblocks; +} + static int stv0367ddb_get_frontend(struct dvb_frontend *fe, struct dtv_frontend_properties *p) { struct stv0367_state *state = fe->demodulator_priv; + int ret = -EINVAL; + enum fe_status status = 0; switch (state->activedemod) { case demod_ter: - return stv0367ter_get_frontend(fe, p); + ret = stv0367ter_get_frontend(fe, p); + break; case demod_cab: - return stv0367cab_get_frontend(fe, p); - default: + ret = stv0367cab_get_frontend(fe, p); break; + default: + p->strength.stat[0].scale = FE_SCALE_NOT_AVAILABLE; + p->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE; + p->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; + return ret; } - return -EINVAL; + /* read fe lock status */ + if (!ret) + ret = stv0367ddb_read_status(fe, &status); + + /* stop if get_frontend failed or if demod isn't locked */ + if (ret || !(status & FE_HAS_LOCK)) { + p->strength.stat[0].scale = FE_SCALE_NOT_AVAILABLE; + p->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE; + p->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; + return ret; + } + + stv0367ddb_read_ucblocks(fe); + + return 0; } static int stv0367ddb_sleep(struct dvb_frontend *fe) @@ -3035,6 +3078,7 @@ static int stv0367ddb_sleep(struct dvb_frontend *fe) static int stv0367ddb_init(struct stv0367_state *state) { struct stv0367ter_state *ter_state = state->ter_state; + struct dtv_frontend_properties *p = &state->fe.dtv_property_cache; stv0367_writereg(state, R367TER_TOPCTRL, 0x10); @@ -3109,6 +3153,13 @@ static int stv0367ddb_init(struct stv0367_state *state) ter_state->first_lock = 0; ter_state->unlock_counter = 2; + p->strength.len = 1; + p->strength.stat[0].scale = FE_SCALE_NOT_AVAILABLE; + p->cnr.len = 1; + p->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE; + p->block_error.len = 1; + p->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; + return 0; }