From patchwork Tue May 7 21:04:40 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Reinhard Nissl X-Patchwork-Id: 2536661 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 057443FCA5 for ; Tue, 7 May 2013 21:05:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757187Ab3EGVFD (ORCPT ); Tue, 7 May 2013 17:05:03 -0400 Received: from mout.gmx.net ([212.227.15.19]:54142 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753119Ab3EGVFC (ORCPT ); Tue, 7 May 2013 17:05:02 -0400 Received: from mailout-de.gmx.net ([10.1.76.33]) by mrigmx.server.lan (mrigmx001) with ESMTP (Nemesis) id 0M06gE-1UHBDc1uCC-00uKpF for ; Tue, 07 May 2013 23:05:00 +0200 Received: (qmail invoked by alias); 07 May 2013 21:05:00 -0000 Received: from pD95F0F07.dip0.t-ipconnect.de (EHLO corei7.home.test) [217.95.15.7] by mail.gmx.net (mp033) with SMTP; 07 May 2013 23:05:00 +0200 X-Authenticated: #527675 X-Provags-ID: V01U2FsdGVkX19k0Zsni+tkMaP4ZIl9MFr20LhtbuBDzkqKKzRWZN KXxwb40u7bQVh7 Received: by corei7.home.test (Postfix, from userid 0) id 8717310B66; Tue, 7 May 2013 23:04:58 +0200 (CEST) From: =?UTF-8?q?Reinhard=20Ni=C3=9Fl?= To: linux-media@vger.kernel.org Cc: =?UTF-8?q?Reinhard=20Ni=C3=9Fl?= Subject: [PATCH] stb0899: sign extend raw CRL_FREQ value Date: Tue, 7 May 2013 23:04:40 +0200 Message-Id: <1367960680-17663-1-git-send-email-rnissl@gmx.de> X-Mailer: git-send-email 1.8.1.4 MIME-Version: 1.0 X-Y-GMX-Trusted: 0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Contrary to the chip's specs, the register's value is signed, so we need to sign extend the value before using it in calculations like when determining the offset frequency. Signed-off-by: Reinhard Nißl --- drivers/media/dvb-frontends/stb0899_algo.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/media/dvb-frontends/stb0899_algo.c b/drivers/media/dvb-frontends/stb0899_algo.c index 117a569..bd9dbd7 100644 --- a/drivers/media/dvb-frontends/stb0899_algo.c +++ b/drivers/media/dvb-frontends/stb0899_algo.c @@ -1487,6 +1487,10 @@ enum stb0899_status stb0899_dvbs2_algo(struct stb0899_state *state) /* Store signal parameters */ offsetfreq = STB0899_READ_S2REG(STB0899_S2DEMOD, CRL_FREQ); + /* sign extend 30 bit value before using it in calculations */ + if (offsetfreq & (1 << 29)) + offsetfreq |= -1 << 30; + offsetfreq = offsetfreq / ((1 << 30) / 1000); offsetfreq *= (internal->master_clk / 1000000); reg = STB0899_READ_S2REG(STB0899_S2DEMOD, DMD_CNTRL2);