From patchwork Fri Mar 17 16:50:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antti Palosaari X-Patchwork-Id: 9631063 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 9968C602D6 for ; Fri, 17 Mar 2017 16:50:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89E9D286DF for ; Fri, 17 Mar 2017 16:50:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7D2AC286E7; Fri, 17 Mar 2017 16:50:51 +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=-6.9 required=2.0 tests=BAYES_00,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 5C35C286DF for ; Fri, 17 Mar 2017 16:50:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751132AbdCQQut (ORCPT ); Fri, 17 Mar 2017 12:50:49 -0400 Received: from mail.kapsi.fi ([217.30.184.167]:58814 "EHLO mail.kapsi.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751079AbdCQQut (ORCPT ); Fri, 17 Mar 2017 12:50:49 -0400 Received: from dyn3-82-128-188-78.psoas.suomi.net ([82.128.188.78] helo=localhost.localdomain) by mail.kapsi.fi with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cov5T-00080P-0L; Fri, 17 Mar 2017 18:50:47 +0200 From: Antti Palosaari To: linux-media@vger.kernel.org Cc: Antti Palosaari Subject: [PATCH 1/3] mn88472: implement signal strength statistics Date: Fri, 17 Mar 2017 18:50:25 +0200 Message-Id: <20170317165027.11471-1-crope@iki.fi> X-Mailer: git-send-email 2.9.3 X-SA-Exim-Connect-IP: 82.128.188.78 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-Virus-Scanned: ClamAV using ClamSMTP Implement DVBv5 signal strength on relative scale. Signed-off-by: Antti Palosaari --- drivers/media/dvb-frontends/mn88472.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/drivers/media/dvb-frontends/mn88472.c b/drivers/media/dvb-frontends/mn88472.c index 29dd13b..25dd742 100644 --- a/drivers/media/dvb-frontends/mn88472.c +++ b/drivers/media/dvb-frontends/mn88472.c @@ -28,8 +28,9 @@ static int mn88472_read_status(struct dvb_frontend *fe, enum fe_status *status) struct i2c_client *client = fe->demodulator_priv; struct mn88472_dev *dev = i2c_get_clientdata(client); struct dtv_frontend_properties *c = &fe->dtv_property_cache; - int ret; - unsigned int utmp; + int ret, i; + unsigned int utmp, utmp1; + u8 buf[2]; if (!dev->active) { ret = -EAGAIN; @@ -77,6 +78,24 @@ static int mn88472_read_status(struct dvb_frontend *fe, enum fe_status *status) goto err; } + /* Signal strength */ + if (*status & FE_HAS_SIGNAL) { + for (i = 0; i < 2; i++) { + ret = regmap_bulk_read(dev->regmap[2], 0x8e + i, + &buf[i], 1); + if (ret) + goto err; + } + + utmp1 = buf[0] << 8 | buf[1] << 0 | buf[0] >> 2; + dev_dbg(&client->dev, "strength=%u\n", utmp1); + + c->strength.stat[0].scale = FE_SCALE_RELATIVE; + c->strength.stat[0].uvalue = utmp1; + } else { + c->strength.stat[0].scale = FE_SCALE_NOT_AVAILABLE; + } + return 0; err: dev_dbg(&client->dev, "failed=%d\n", ret); @@ -462,6 +481,7 @@ static int mn88472_probe(struct i2c_client *client, { struct mn88472_config *pdata = client->dev.platform_data; struct mn88472_dev *dev; + struct dtv_frontend_properties *c; int ret; unsigned int utmp; static const struct regmap_config regmap_config = { @@ -547,6 +567,10 @@ static int mn88472_probe(struct i2c_client *client, *pdata->fe = &dev->fe; i2c_set_clientdata(client, dev); + /* Init stats to indicate which stats are supported */ + c = &dev->fe.dtv_property_cache; + c->strength.len = 1; + /* Setup callbacks */ pdata->get_dvb_frontend = mn88472_get_dvb_frontend;