diff options
-rw-r--r-- | 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 f959bb71c460..0fcd2b09218d 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); | |||
89 | #define GEMTEK_LOWFREQ (87*16000) | 89 | #define GEMTEK_LOWFREQ (87*16000) |
90 | #define GEMTEK_HIGHFREQ (108*16000) | 90 | #define GEMTEK_HIGHFREQ (108*16000) |
91 | 91 | ||
92 | /* | ||
93 | * Frequency calculation constants. Intermediate frequency 10.52 MHz (nominal | ||
94 | * value 10.7 MHz), reference divisor 6.39 kHz (nominal 6.25 kHz). | ||
95 | */ | ||
96 | #define FSCALE 8 | ||
97 | #define IF_OFFSET ((unsigned int)(10.52 * 16000 * (1<<FSCALE))) | ||
98 | #define REF_FREQ ((unsigned int)(6.39 * 16 * (1<<FSCALE))) | ||
99 | |||
92 | #define GEMTEK_CK 0x01 /* Clock signal */ | 100 | #define GEMTEK_CK 0x01 /* Clock signal */ |
93 | #define GEMTEK_DA 0x02 /* Serial data */ | 101 | #define GEMTEK_DA 0x02 /* Serial data */ |
94 | #define GEMTEK_CE 0x04 /* Chip enable */ | 102 | #define GEMTEK_CE 0x04 /* Chip enable */ |
@@ -219,14 +227,11 @@ static void gemtek_bu2614_transmit(struct gemtek_device *dev) | |||
219 | } | 227 | } |
220 | 228 | ||
221 | /* | 229 | /* |
222 | * Convert FM-frequency for BU2614FS (3.125 KHz STDF expected). | 230 | * Calculate divisor from FM-frequency for BU2614FS (3.125 KHz STDF expected). |
223 | */ | 231 | */ |
224 | static inline void gemtek_convfreq(unsigned long *freq) | 232 | static unsigned long gemtek_convfreq(unsigned long freq) |
225 | { | 233 | { |
226 | (*freq) /= 160; | 234 | return ((freq<<FSCALE) + IF_OFFSET + REF_FREQ/2) / REF_FREQ; |
227 | (*freq) += 1052; /* FMIN, 10.52 MHz */ | ||
228 | (*freq) *= 1565; /* STDF, 1 / 156.5 = 0.00639 */ | ||
229 | (*freq) /= 1000; | ||
230 | } | 235 | } |
231 | 236 | ||
232 | /* | 237 | /* |
@@ -253,10 +258,8 @@ static void gemtek_setfreq(struct gemtek_device *dev, unsigned long freq) | |||
253 | gemtek_bu2614_set(dev, BU2614_FMUN, 1); /* GT bit set */ | 258 | gemtek_bu2614_set(dev, BU2614_FMUN, 1); /* GT bit set */ |
254 | gemtek_bu2614_set(dev, BU2614_TEST, 0); | 259 | gemtek_bu2614_set(dev, BU2614_TEST, 0); |
255 | 260 | ||
256 | gemtek_convfreq(&freq); | ||
257 | |||
258 | gemtek_bu2614_set(dev, BU2614_STDF, GEMTEK_STDF_3_125_KHZ); | 261 | gemtek_bu2614_set(dev, BU2614_STDF, GEMTEK_STDF_3_125_KHZ); |
259 | gemtek_bu2614_set(dev, BU2614_FREQ, freq); | 262 | gemtek_bu2614_set(dev, BU2614_FREQ, gemtek_convfreq(freq)); |
260 | 263 | ||
261 | gemtek_bu2614_transmit(dev); | 264 | gemtek_bu2614_transmit(dev); |
262 | } | 265 | } |