From patchwork Sat Jun 23 15:36:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scheller X-Patchwork-Id: 10483721 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 72BBD6023A for ; Sat, 23 Jun 2018 15:36:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 73D92288D1 for ; Sat, 23 Jun 2018 15:36:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 68896289D1; Sat, 23 Jun 2018 15:36:39 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, MAILING_LIST_MULTI, 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 0C1C9288D1 for ; Sat, 23 Jun 2018 15:36:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751688AbeFWPgh (ORCPT ); Sat, 23 Jun 2018 11:36:37 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:55298 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751458AbeFWPg2 (ORCPT ); Sat, 23 Jun 2018 11:36:28 -0400 Received: by mail-wm0-f65.google.com with SMTP id v16-v6so4922025wmh.5 for ; Sat, 23 Jun 2018 08:36:27 -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=pLEUpsorKrDImlPmRpz90CZxUg7TEW11ypePpSCkvz0=; b=bdUHc7HEZgMclIyOnnRylCLi3NBL6WKL1JZF2qcefhLQT6soh9ixtnYLJHecrRRLDX FSP1OcgQ9UDANXmJPrD5uRrC+x7rKUw9G/bj8xINdSDQhhFRrQJxiTBlwuH0xm4TNNRI 04SIGtES/CEgWFgX8i1Eac+91MvXw5d2THozo4TwMfcNGi+uTEbG6WmWvwmp+wgQk051 Pcgby7x6reImMTvuWDOoOa1b2k3i62bqkmI5bwoRx9f01vzcymGkh+1qcZxEtiHsPs8u QTaYdTvMZqDAtzKNERULTN7gOKvSu99PDgvaZjVtt8ptiLyOmlX+vQHsAur/1+DX5jy9 vKEQ== 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=pLEUpsorKrDImlPmRpz90CZxUg7TEW11ypePpSCkvz0=; b=gmbOrPmJHaSy1t3/Ps4WIHr6+x+vAHNSIM1c5EC89iWgzbB6PSphcgh/Ktg5caqpdm GIbrp8qz2FC7Q7VfekjKGeZH3CpRqpD/Z8xbhwoVm+9WtQO2Pj+nlbh/boOGLJv/u+0W IPZIvXCdOsa01aMu4AmVM68j9Czr2zKDfsGvZwhHE15qPbl60imJbAfT7q/P0AE2OUKS 2DJ2O0EZfkVji9AJcB8ll21kJDob7tmhAoX7wFrYpqOouMNAyWqcepqqKtUHt9Vg5p/i EZV275QTOe5fCGFRtm3Q/NHRRPYxx20tdaBohEvlpiaAmUPrvpaZpyIFtTIJSl0phS1B TN7w== X-Gm-Message-State: APt69E1DnxEPjjjW1OIkNlbBp3JQztfHGqPTTScDr8TbhQKKLz+ZA56y ARwFtaTmEt/SNfh4CQMmhuNddg== X-Google-Smtp-Source: AAOMgpcFUOs4ELx+QiL1PTIfIBsNSQ+Gg8skYyMtRedUx7QXJTeGdhQUYP3ylNYeMfMFP/kMzZyihQ== X-Received: by 2002:a1c:7d56:: with SMTP id y83-v6mr5194078wmc.65.1529768187364; Sat, 23 Jun 2018 08:36:27 -0700 (PDT) Received: from dvbdev.wuest.de (ip-176-199-71-134.hsi06.unitymediagroup.de. [176.199.71.134]) by smtp.gmail.com with ESMTPSA id o15-v6sm3443156wrm.38.2018.06.23.08.36.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 23 Jun 2018 08:36:26 -0700 (PDT) From: Daniel Scheller To: mchehab@kernel.org, mchehab@s-opensource.com Cc: linux-media@vger.kernel.org Subject: [PATCH 10/19] [media] ddbridge/mci: read and report signal strength and SNR Date: Sat, 23 Jun 2018 17:36:06 +0200 Message-Id: <20180623153615.27630-11-d.scheller.oss@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180623153615.27630-1-d.scheller.oss@gmail.com> References: <20180623153615.27630-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 Implement querying signal statistics from the MCI and report this data in read_status() as DVBv5 statistics. Picked up from the upstream dddvb GIT. Signed-off-by: Daniel Scheller --- drivers/media/pci/ddbridge/ddbridge-mci.c | 47 ++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/drivers/media/pci/ddbridge/ddbridge-mci.c b/drivers/media/pci/ddbridge/ddbridge-mci.c index 46b20b06e2a6..7d402861fa9e 100644 --- a/drivers/media/pci/ddbridge/ddbridge-mci.c +++ b/drivers/media/pci/ddbridge/ddbridge-mci.c @@ -155,6 +155,47 @@ static void release(struct dvb_frontend *fe) kfree(state); } +static int get_info(struct dvb_frontend *fe) +{ + int stat; + struct mci *state = fe->demodulator_priv; + struct mci_command cmd; + + memset(&cmd, 0, sizeof(cmd)); + cmd.command = MCI_CMD_GETSIGNALINFO; + cmd.demod = state->demod; + stat = mci_cmd(state, &cmd, &state->signal_info); + return stat; +} + +static int get_snr(struct dvb_frontend *fe) +{ + struct mci *state = fe->demodulator_priv; + struct dtv_frontend_properties *p = &fe->dtv_property_cache; + + p->cnr.len = 1; + p->cnr.stat[0].scale = FE_SCALE_DECIBEL; + p->cnr.stat[0].svalue = + (s64)state->signal_info.dvbs2_signal_info.signal_to_noise + * 10; + return 0; +} + +static int get_strength(struct dvb_frontend *fe) +{ + struct mci *state = fe->demodulator_priv; + struct dtv_frontend_properties *p = &fe->dtv_property_cache; + s32 str; + + str = 100000 - + (state->signal_info.dvbs2_signal_info.channel_power + * 10 + 108750); + p->strength.len = 1; + p->strength.stat[0].scale = FE_SCALE_DECIBEL; + p->strength.stat[0].svalue = str; + return 0; +} + static int read_status(struct dvb_frontend *fe, enum fe_status *status) { int stat; @@ -168,10 +209,14 @@ static int read_status(struct dvb_frontend *fe, enum fe_status *status) if (stat) return stat; *status = 0x00; + get_info(fe); + get_strength(fe); if (res.status == SX8_DEMOD_WAIT_MATYPE) *status = 0x0f; - if (res.status == SX8_DEMOD_LOCKED) + if (res.status == SX8_DEMOD_LOCKED) { *status = 0x1f; + get_snr(fe); + } return stat; }