From patchwork Sat Dec 13 00:18:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Larsson X-Patchwork-Id: 5486061 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 04875BEEA8 for ; Sat, 13 Dec 2014 00:19:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 247CB20204 for ; Sat, 13 Dec 2014 00:19:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DC2BA2014A for ; Sat, 13 Dec 2014 00:18:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753887AbaLMAS4 (ORCPT ); Fri, 12 Dec 2014 19:18:56 -0500 Received: from smtp.bredband2.com ([83.219.192.166]:52969 "EHLO smtp.bredband2.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753836AbaLMASz (ORCPT ); Fri, 12 Dec 2014 19:18:55 -0500 Received: from localhost.localdomain (92-244-23-216.customers.ownit.se [92.244.23.216]) (Authenticated sender: ed8153) by smtp.bredband2.com (Postfix) with ESMTPA id 23DD899F0; Sat, 13 Dec 2014 01:18:46 +0100 (CET) From: Benjamin Larsson To: crope@iki.fi Cc: Linux Media Mailing List Subject: [PATCH 4/4] mn88472: implemented ber reporting Date: Sat, 13 Dec 2014 01:18:45 +0100 Message-Id: <1418429925-16342-4-git-send-email-benjamin@southpole.se> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1418429925-16342-1-git-send-email-benjamin@southpole.se> References: <1418429925-16342-1-git-send-email-benjamin@southpole.se> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 Signed-off-by: Benjamin Larsson Reviewed-by: Antti Palosaari --- drivers/staging/media/mn88472/mn88472.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/staging/media/mn88472/mn88472.c b/drivers/staging/media/mn88472/mn88472.c index 746cc94..8b35639 100644 --- a/drivers/staging/media/mn88472/mn88472.c +++ b/drivers/staging/media/mn88472/mn88472.c @@ -392,6 +392,36 @@ err: return ret; } +static int mn88472_read_ber(struct dvb_frontend *fe, u32 *ber) +{ + struct i2c_client *client = fe->demodulator_priv; + struct mn88472_dev *dev = i2c_get_clientdata(client); + int ret, err, len; + u8 data[3]; + + dev_dbg(&client->dev, "%s:\n", __func__); + + ret = regmap_bulk_read(dev->regmap[0], 0x9F , data, 3); + if (ret) + goto err; + err = data[0]<<16 | data[1]<<8 | data[2]; + + ret = regmap_bulk_read(dev->regmap[0], 0xA2 , data, 2); + if (ret) + goto err; + len = data[0]<<8 | data[1]; + + if (len) + *ber = (err*100)/len; + else + *ber = 0; + + return 0; +err: + dev_dbg(&client->dev, "%s: failed=%d\n", __func__, ret); + return ret; +} + static struct dvb_frontend_ops mn88472_ops = { .delsys = {SYS_DVBT, SYS_DVBT2, SYS_DVBC_ANNEX_A}, .info = { @@ -425,6 +455,7 @@ static struct dvb_frontend_ops mn88472_ops = { .set_frontend = mn88472_set_frontend, .read_status = mn88472_read_status, + .read_ber = mn88472_read_ber, }; static int mn88472_probe(struct i2c_client *client,