From patchwork Mon Nov 2 20:23:17 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Regel X-Patchwork-Id: 1956 Return-path: Envelope-to: mchehab@infradead.org Delivery-date: Mon, 02 Nov 2009 20:37:19 +0000 Received: from bombadil.infradead.org [18.85.46.34] by pedra.chehab.org with IMAP (fetchmail-6.3.6) for (single-drop); Tue, 03 Nov 2009 07:40:18 -0200 (BRST) Received: from vger.kernel.org ([209.132.176.167]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1N53eR-0006Nd-16; Mon, 02 Nov 2009 20:37:19 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932387AbZKBUhL (ORCPT + 1 other); Mon, 2 Nov 2009 15:37:11 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932405AbZKBUhK (ORCPT ); Mon, 2 Nov 2009 15:37:10 -0500 Received: from mail.gmx.net ([213.165.64.20]:54134 "HELO mail.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S932378AbZKBUhJ (ORCPT ); Mon, 2 Nov 2009 15:37:09 -0500 Received: (qmail invoked by alias); 02 Nov 2009 20:23:31 -0000 Received: from i59F6A205.versanet.de (EHLO [192.168.0.20]) [89.246.162.5] by mail.gmx.net (mp069) with SMTP; 02 Nov 2009 21:23:31 +0100 X-Authenticated: #126152 X-Provags-ID: V01U2FsdGVkX182+94RvnA29/4Jgy6mcfFQPH0Ab6N/tcbwNOFp7q PdAjQBvfv+ua5t Message-ID: <4AEF3FB5.9080001@gmx.de> Date: Mon, 02 Nov 2009 21:23:17 +0100 From: Andreas Regel User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) MIME-Version: 1.0 To: linux-media@vger.kernel.org Subject: [PATCH] stv6110x: fix r divider calculation X-Y-GMX-Trusted: 0 X-FuHaFi: 0.5 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org This patch fixed the calculation of the r divider in stv6110x_set_frequency. It had always the value 3 no matter what frequency was given. Signed-off-by: Andreas Regel --- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff -r 43878f8dbfb0 linux/drivers/media/dvb/frontends/stv6110x.c --- a/linux/drivers/media/dvb/frontends/stv6110x.c Sun Nov 01 07:17:46 2009 -0200 +++ b/linux/drivers/media/dvb/frontends/stv6110x.c Mon Nov 02 21:02:22 2009 +0100 @@ -95,7 +95,7 @@ { struct stv6110x_state *stv6110x = fe->tuner_priv; u32 rDiv, divider; - s32 pVal, pCalc, rDivOpt = 0; + s32 pVal, pCalc, rDivOpt = 0, pCalcOpt = 1000; u8 i; STV6110x_SETFIELD(stv6110x_regs[STV6110x_CTRL1], CTRL1_K, (REFCLOCK_MHz - 16)); @@ -121,8 +121,10 @@ for (rDiv = 0; rDiv <= 3; rDiv++) { pCalc = (REFCLOCK_kHz / 100) / R_DIV(rDiv); - if ((abs((s32)(pCalc - pVal))) < (abs((s32)(1000 - pVal)))) + if ((abs((s32)(pCalc - pVal))) < (abs((s32)(pCalcOpt - pVal)))) rDivOpt = rDiv; + + pCalcOpt = (REFCLOCK_kHz / 100) / R_DIV(rDivOpt); } divider = (frequency * R_DIV(rDivOpt) * pVal) / REFCLOCK_kHz;