From patchwork Fri Jan 2 13:56:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Malcolm Priestley X-Patchwork-Id: 5559151 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0B3DD9F344 for ; Fri, 2 Jan 2015 13:57:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 219042022D for ; Fri, 2 Jan 2015 13:57:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 204262021B for ; Fri, 2 Jan 2015 13:57:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752130AbbABN47 (ORCPT ); Fri, 2 Jan 2015 08:56:59 -0500 Received: from mail-wi0-f174.google.com ([209.85.212.174]:56681 "EHLO mail-wi0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752121AbbABN46 (ORCPT ); Fri, 2 Jan 2015 08:56:58 -0500 Received: by mail-wi0-f174.google.com with SMTP id h11so27733862wiw.1 for ; Fri, 02 Jan 2015 05:56:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CC90ebhdGY4QFfkagPd9FD4GLcyyPEkl+XdKPdAsuc8=; b=Ob1UZnvLCRb7++Xz/7IQPmdl5DvnsjHet4Kv8/E/jUI+LHHviXryq40P8tB03yGQTu BUBlYaDXrH54HFeriJZUqmu2pY1tVuiUPDlzIQEQWxz4177TQzpWFmoAUTzFBkVAojYC olfrUBt4yLhFP80eqinFwYwzO2ZTwn85fkoPwixpYz72Wslf9T3+gh9csET9N3FWlLJO G6ud/EgF3XlRJ20/h+WAaU8sOvOXXU+Wdm0e0EqAfiKxujwL+1jVKyu1Jne0RZo6QTcE 6XVx4Q6ZsHAzPsjq0Wbkbvb+tFWCcV36bvtSUo5r3ocFL8UJ5T/VDvlH9AxQVkApty6w t9JA== X-Received: by 10.180.108.235 with SMTP id hn11mr130841871wib.14.1420207017018; Fri, 02 Jan 2015 05:56:57 -0800 (PST) Received: from localhost.localdomain (dab-far1-h-1-8.dab.02.net. [82.132.222.244]) by mx.google.com with ESMTPSA id fc6sm3520943wib.12.2015.01.02.05.56.55 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 02 Jan 2015 05:56:56 -0800 (PST) From: Malcolm Priestley To: linux-media@vger.kernel.org Cc: Malcolm Priestley Subject: [PATCH 3/5] lmedm04: create frontend callbacks for signal/snr/ber/ucblocks Date: Fri, 2 Jan 2015 13:56:29 +0000 Message-Id: <1420206991-3939-3-git-send-email-tvboxspy@gmail.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1420206991-3939-1-git-send-email-tvboxspy@gmail.com> References: <1420206991-3939-1-git-send-email-tvboxspy@gmail.com> 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.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, 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 Create call backs dm04_read_signal_strength, dm04_read_snr and move dm04_read_ber and dm04_read_ucblocks for all frontends Removing the I2C filtering from lme2510_msg and the old rs2000 callbacks. Signed-off-by: Malcolm Priestley --- drivers/media/usb/dvb-usb-v2/lmedm04.c | 93 ++++++++++++---------------------- 1 file changed, 33 insertions(+), 60 deletions(-) diff --git a/drivers/media/usb/dvb-usb-v2/lmedm04.c b/drivers/media/usb/dvb-usb-v2/lmedm04.c index 15db9f6..55d7690 100644 --- a/drivers/media/usb/dvb-usb-v2/lmedm04.c +++ b/drivers/media/usb/dvb-usb-v2/lmedm04.c @@ -515,21 +515,6 @@ static int lme2510_msg(struct dvb_usb_device *d, rbuf[0] = 0x55; rbuf[1] = st->signal_lock; break; - case 0x43: - rbuf[0] = 0x55; - rbuf[1] = st->signal_level; - break; - case 0x1c: - rbuf[0] = 0x55; - rbuf[1] = st->signal_sn; - break; - case 0x15: - case 0x16: - case 0x17: - case 0x18: - rbuf[0] = 0x55; - rbuf[1] = 0x00; - break; default: lme2510_usb_talk(d, wbuf, wlen, rbuf, rlen); st->i2c_talk_onoff = 1; @@ -538,25 +523,10 @@ static int lme2510_msg(struct dvb_usb_device *d, break; case TUNER_S7395: switch (wbuf[3]) { - case 0x10: - rbuf[0] = 0x55; - rbuf[1] = (st->signal_level & 0x80) - ? 0 : (st->signal_level * 2); - break; - case 0x2d: - rbuf[0] = 0x55; - rbuf[1] = st->signal_sn; - break; case 0x24: rbuf[0] = 0x55; rbuf[1] = st->signal_lock; break; - case 0x2e: - case 0x26: - case 0x27: - rbuf[0] = 0x55; - rbuf[1] = 0x00; - break; default: lme2510_usb_talk(d, wbuf, wlen, rbuf, rlen); st->i2c_talk_onoff = 1; @@ -565,26 +535,10 @@ static int lme2510_msg(struct dvb_usb_device *d, break; case TUNER_S0194: switch (wbuf[3]) { - case 0x18: - rbuf[0] = 0x55; - rbuf[1] = (st->signal_level & 0x80) - ? 0 : (st->signal_level * 2); - break; - case 0x24: - rbuf[0] = 0x55; - rbuf[1] = st->signal_sn; - break; case 0x1b: rbuf[0] = 0x55; rbuf[1] = st->signal_lock; break; - case 0x19: - case 0x25: - case 0x1e: - case 0x1d: - rbuf[0] = 0x55; - rbuf[1] = 0x00; - break; default: lme2510_usb_talk(d, wbuf, wlen, rbuf, rlen); st->i2c_talk_onoff = 1; @@ -1006,21 +960,44 @@ static int dm04_lme2510_set_voltage(struct dvb_frontend *fe, return (ret < 0) ? -ENODEV : 0; } -static int dm04_rs2000_read_signal_strength(struct dvb_frontend *fe, - u16 *strength) +static int dm04_read_signal_strength(struct dvb_frontend *fe, u16 *strength) { struct lme2510_state *st = fe_to_priv(fe); - *strength = (u16)((u32)st->signal_level * 0xffff / 0xff); + switch (st->tuner_config) { + case TUNER_LG: + *strength = 0xff - st->signal_level; + *strength |= *strength << 8; + break; + /* fall through */ + case TUNER_S7395: + case TUNER_S0194: + *strength = 0xffff - (((st->signal_level * 2) << 8) * 5 / 4); + break; + case TUNER_RS2000: + *strength = (u16)((u32)st->signal_level * 0xffff / 0xff); + } return 0; } -static int dm04_rs2000_read_snr(struct dvb_frontend *fe, u16 *snr) +static int dm04_read_snr(struct dvb_frontend *fe, u16 *snr) { struct lme2510_state *st = fe_to_priv(fe); - *snr = (u16)((u32)st->signal_sn * 0xffff / 0x7f); + switch (st->tuner_config) { + case TUNER_LG: + *snr = 0xff - st->signal_sn; + *snr |= *snr << 8; + break; + /* fall through */ + case TUNER_S7395: + case TUNER_S0194: + *snr = (u16)((0xff - st->signal_sn - 0xa1) * 3) << 8; + break; + case TUNER_RS2000: + *snr = (u16)((u32)st->signal_sn * 0xffff / 0x7f); + } return 0; } @@ -1127,15 +1104,6 @@ static int dm04_lme2510_frontend_attach(struct dvb_usb_adapter *adap) st->tuner_config = TUNER_RS2000; st->fe_set_voltage = adap->fe[0]->ops.set_voltage; - - adap->fe[0]->ops.read_signal_strength = - dm04_rs2000_read_signal_strength; - adap->fe[0]->ops.read_snr = - dm04_rs2000_read_snr; - adap->fe[0]->ops.read_ber = - dm04_read_ber; - adap->fe[0]->ops.read_ucblocks = - dm04_read_ucblocks; } break; } @@ -1154,7 +1122,12 @@ static int dm04_lme2510_frontend_attach(struct dvb_usb_adapter *adap) return -ENODEV; } + adap->fe[0]->ops.read_signal_strength = dm04_read_signal_strength; + adap->fe[0]->ops.read_snr = dm04_read_snr; + adap->fe[0]->ops.read_ber = dm04_read_ber; + adap->fe[0]->ops.read_ucblocks = dm04_read_ucblocks; adap->fe[0]->ops.set_voltage = dm04_lme2510_set_voltage; + ret = lme_name(adap); return ret; }