public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Andreas Regel <andreas.regel@gmx.de>
To: linux-media@vger.kernel.org
Subject: [PATCH] stv6110x: fix r divider calculation
Date: Mon, 02 Nov 2009 21:23:17 +0100	[thread overview]
Message-ID: <4AEF3FB5.9080001@gmx.de> (raw)

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 <andreas.regel@gmx.de>

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;

                 reply	other threads:[~2009-11-02 20:37 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4AEF3FB5.9080001@gmx.de \
    --to=andreas.regel@gmx.de \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox