Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=857e594ad5662349d95ad33f987cbf55cc356a90
Commit:     857e594ad5662349d95ad33f987cbf55cc356a90
Parent:     4753647e6422341a091e729b9d81a9a5e7fe6179
Author:     Trent Piepho <[EMAIL PROTECTED]>
AuthorDate: Mon Oct 1 00:32:25 2007 -0300
Committer:  Mauro Carvalho Chehab <[EMAIL PROTECTED]>
CommitDate: Tue Oct 9 22:14:50 2007 -0300

    V4L/DVB (6245):  GemTek Radio card - frequency calculation
    
    Frequency calculation to use better math.  It's still the same
    IF offset and step size (which are not the same as the datasheet says) as
    the code was before.  It's just more efficient and accurate.
    
    Signed-off-by: Trent Piepho <[EMAIL PROTECTED]>
    Reviewed-by: Pekka Seppänen <[EMAIL PROTECTED]>
    Signed-off-by: Douglas Schilling Landgraf <[EMAIL PROTECTED]>
    Signed-off-by: Mauro Carvalho Chehab <[EMAIL PROTECTED]>
---
 drivers/media/radio/radio-gemtek.c |   21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/drivers/media/radio/radio-gemtek.c 
b/drivers/media/radio/radio-gemtek.c
index f959bb7..0fcd2b0 100644
--- a/drivers/media/radio/radio-gemtek.c
+++ b/drivers/media/radio/radio-gemtek.c
@@ -89,6 +89,14 @@ module_param(radio_nr, int, 0444);
 #define GEMTEK_LOWFREQ (87*16000)
 #define GEMTEK_HIGHFREQ        (108*16000)
 
+/*
+ * Frequency calculation constants.  Intermediate frequency 10.52 MHz (nominal
+ * value 10.7 MHz), reference divisor 6.39 kHz (nominal 6.25 kHz).
+ */
+#define FSCALE         8
+#define IF_OFFSET      ((unsigned int)(10.52 * 16000 * (1<<FSCALE)))
+#define REF_FREQ       ((unsigned int)(6.39 * 16 * (1<<FSCALE)))
+
 #define GEMTEK_CK              0x01    /* Clock signal                 */
 #define GEMTEK_DA              0x02    /* Serial data                  */
 #define GEMTEK_CE              0x04    /* Chip enable                  */
@@ -219,14 +227,11 @@ static void gemtek_bu2614_transmit(struct gemtek_device 
*dev)
 }
 
 /*
- * Convert FM-frequency for BU2614FS (3.125 KHz STDF expected).
+ * Calculate divisor from FM-frequency for BU2614FS (3.125 KHz STDF expected).
  */
-static inline void gemtek_convfreq(unsigned long *freq)
+static unsigned long gemtek_convfreq(unsigned long freq)
 {
-       (*freq) /= 160;
-       (*freq) += 1052;        /* FMIN, 10.52 MHz              */
-       (*freq) *= 1565;        /* STDF, 1 / 156.5 = 0.00639    */
-       (*freq) /= 1000;
+       return ((freq<<FSCALE) + IF_OFFSET + REF_FREQ/2) / REF_FREQ;
 }
 
 /*
@@ -253,10 +258,8 @@ static void gemtek_setfreq(struct gemtek_device *dev, 
unsigned long freq)
        gemtek_bu2614_set(dev, BU2614_FMUN, 1); /* GT bit set   */
        gemtek_bu2614_set(dev, BU2614_TEST, 0);
 
-       gemtek_convfreq(&freq);
-
        gemtek_bu2614_set(dev, BU2614_STDF, GEMTEK_STDF_3_125_KHZ);
-       gemtek_bu2614_set(dev, BU2614_FREQ, freq);
+       gemtek_bu2614_set(dev, BU2614_FREQ, gemtek_convfreq(freq));
 
        gemtek_bu2614_transmit(dev);
 }
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to