From patchwork Tue Dec 24 16:18:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Malcolm Priestley X-Patchwork-Id: 3404401 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 8B394C0D4A for ; Tue, 24 Dec 2013 16:18:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A03B420563 for ; Tue, 24 Dec 2013 16:18:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CB60220557 for ; Tue, 24 Dec 2013 16:18:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752212Ab3LXQSy (ORCPT ); Tue, 24 Dec 2013 11:18:54 -0500 Received: from mail-wi0-f170.google.com ([209.85.212.170]:39578 "EHLO mail-wi0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752012Ab3LXQSx (ORCPT ); Tue, 24 Dec 2013 11:18:53 -0500 Received: by mail-wi0-f170.google.com with SMTP id hq4so11621076wib.3 for ; Tue, 24 Dec 2013 08:18:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:subject:from:to:date:content-type:mime-version :content-transfer-encoding; bh=4QZL80UPFskakdxp1IJSU9ktrEiz7e+sb5HZUUEvwlc=; b=y2DOte9mBu+45mLUw6VB2HM23EMO0KSNnmeSbEwaGObQgLZ6Dm0LEfatTOUbJU6bre NP/0XwqI4RsxDggzC4VIEzONuU/8sTr3zCZOmKXgy5vNOnJfozbmfAb+wy24c2+TOSlT p/o158X8Y58djw2Nninr3WXsnC4a+Hd+BLy3Uf8+iLU5SMHk8uL/GaB2PjI1vYkLJOpo WXero+sLyaAIF9dtaCznGunhR0LSBLgd0wMWlU+04sX6dpvLhiCGICLd2pOlAMNNiEvB +hmXiWATKLsWw6BUtMmtJfJ7fm/TG8WoAwgGWjfZo0bNQV0QzWpaTVSDabwM07Hj2lNA J09g== X-Received: by 10.180.79.106 with SMTP id i10mr12795218wix.23.1387901932614; Tue, 24 Dec 2013 08:18:52 -0800 (PST) Received: from [192.168.1.100] (94.196.117.167.threembb.co.uk. [94.196.117.167]) by mx.google.com with ESMTPSA id at5sm24025359wic.1.2013.12.24.08.18.51 for (version=SSLv3 cipher=RC4-SHA bits=128/128); Tue, 24 Dec 2013 08:18:51 -0800 (PST) Message-ID: <1387901926.24033.41.camel@canaries32-MCP7A> Subject: [PATCH 2/2] m88rs2000: set symbol rate accurately. From: Malcolm Priestley To: linux-media@vger.kernel.org Date: Tue, 24 Dec 2013 16:18:46 +0000 X-Mailer: Evolution 3.10.1-2ubuntu2 Mime-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 Current setting of symbol rate is not very actuate causing loss of lock. Covert temp to u64 and use mclk to calculate from big number. Calculate symbol rate by dividing symbol rate by 1000 times 1 << 24 and dividing sum by mclk. Add other symbol rate settings to function registers 0xa0-0xa3. In set_frontend add changes to register 0xf1 this must be done prior call to fe_reset. Register 0x00 doesn't need a second write of 0x1 Applied after patch m88rs2000: add m88rs2000_set_carrieroffset Signed-off-by: Malcolm Priestley Cc: stable@vger.kernel.org # v3.9+ --- drivers/media/dvb-frontends/m88rs2000.c | 42 ++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/drivers/media/dvb-frontends/m88rs2000.c b/drivers/media/dvb-frontends/m88rs2000.c index 8091653..02699c1 100644 --- a/drivers/media/dvb-frontends/m88rs2000.c +++ b/drivers/media/dvb-frontends/m88rs2000.c @@ -160,24 +160,44 @@ static int m88rs2000_set_symbolrate(struct dvb_frontend *fe, u32 srate) { struct m88rs2000_state *state = fe->demodulator_priv; int ret; - u32 temp; + u64 temp; + u32 mclk; u8 b[3]; if ((srate < 1000000) || (srate > 45000000)) return -EINVAL; + mclk = m88rs2000_get_mclk(fe); + if (!mclk) + return -EINVAL; + temp = srate / 1000; - temp *= 11831; - temp /= 68; - temp -= 3; + temp *= 1 << 24; + + do_div(temp, mclk); b[0] = (u8) (temp >> 16) & 0xff; b[1] = (u8) (temp >> 8) & 0xff; b[2] = (u8) temp & 0xff; + ret = m88rs2000_writereg(state, 0x93, b[2]); ret |= m88rs2000_writereg(state, 0x94, b[1]); ret |= m88rs2000_writereg(state, 0x95, b[0]); + if (srate > 10000000) + ret |= m88rs2000_writereg(state, 0xa0, 0x20); + else + ret |= m88rs2000_writereg(state, 0xa0, 0x60); + + ret |= m88rs2000_writereg(state, 0xa1, 0xe0); + + if (srate > 12000000) + ret |= m88rs2000_writereg(state, 0xa3, 0x20); + else if (srate > 2800000) + ret |= m88rs2000_writereg(state, 0xa3, 0x98); + else + ret |= m88rs2000_writereg(state, 0xa3, 0x90); + deb_info("m88rs2000: m88rs2000_set_symbolrate\n"); return ret; } @@ -307,8 +327,6 @@ struct inittab m88rs2000_shutdown[] = { struct inittab fe_reset[] = { {DEMOD_WRITE, 0x00, 0x01}, - {DEMOD_WRITE, 0xf1, 0xbf}, - {DEMOD_WRITE, 0x00, 0x01}, {DEMOD_WRITE, 0x20, 0x81}, {DEMOD_WRITE, 0x21, 0x80}, {DEMOD_WRITE, 0x10, 0x33}, @@ -351,9 +369,6 @@ struct inittab fe_trigger[] = { {DEMOD_WRITE, 0x9b, 0x64}, {DEMOD_WRITE, 0x9e, 0x00}, {DEMOD_WRITE, 0x9f, 0xf8}, - {DEMOD_WRITE, 0xa0, 0x20}, - {DEMOD_WRITE, 0xa1, 0xe0}, - {DEMOD_WRITE, 0xa3, 0x38}, {DEMOD_WRITE, 0x98, 0xff}, {DEMOD_WRITE, 0xc0, 0x0f}, {DEMOD_WRITE, 0x89, 0x01}, @@ -625,8 +640,13 @@ static int m88rs2000_set_frontend(struct dvb_frontend *fe) if (ret < 0) return -ENODEV; - /* Reset Demod */ - ret = m88rs2000_tab_set(state, fe_reset); + /* Reset demod by symbol rate */ + if (c->symbol_rate > 27500000) + ret = m88rs2000_writereg(state, 0xf1, 0xa4); + else + ret = m88rs2000_writereg(state, 0xf1, 0xbf); + + ret |= m88rs2000_tab_set(state, fe_reset); if (ret < 0) return -ENODEV;