summaryrefslogtreecommitdiff
path: root/firmware/drivers
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2010-06-22 07:27:34 +0000
committerMichael Sevakis <jethead71@rockbox.org>2010-06-22 07:27:34 +0000
commit08d09e678f942fef9e9efc9a88e62f0b4e7bb0a4 (patch)
tree68ff8aadd5853c726630f7302c27ac3900f8b733 /firmware/drivers
parentd029b3e6978148a8f48a3c5fcd09d8b9d87fa115 (diff)
downloadrockbox-08d09e678f942fef9e9efc9a88e62f0b4e7bb0a4.zip
rockbox-08d09e678f942fef9e9efc9a88e62f0b4e7bb0a4.tar.gz
rockbox-08d09e678f942fef9e9efc9a88e62f0b4e7bb0a4.tar.bz2
rockbox-08d09e678f942fef9e9efc9a88e62f0b4e7bb0a4.tar.xz
Sanyo lv24020lp FM: Improve frequency measurement on PP thus improving initial frequency setting. Properly account for IF when tuning FM oscillator (this worked poorly before but appears to work as expected now -- aka. works for me). Not sure what this will do to iAudio7 or Cowon D2 but if they can implement a good duration measurement, they should do so or use the internal timer if possible.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27042 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers')
-rw-r--r--firmware/drivers/tuner/lv24020lp.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/firmware/drivers/tuner/lv24020lp.c b/firmware/drivers/tuner/lv24020lp.c
index a53d93b..86f8c39 100644
--- a/firmware/drivers/tuner/lv24020lp.c
+++ b/firmware/drivers/tuner/lv24020lp.c
@@ -496,9 +496,25 @@ static int tuner_measure(unsigned char type, int scale, int duration)
/* start counter, delay for specified time and stop it */
lv24020lp_write_set(CNT_CTRL, CNT_EN);
- udelay(duration*1000 - 16);
+
+#ifdef CPU_PP
+ /* obtain actual duration, including interrupts that occurred and
+ * the time to write the counter stop */
+ long usec = USEC_TIMER;
+#endif
+
+ udelay(duration*1000);
+
lv24020lp_write_clear(CNT_CTRL, CNT_EN);
+#ifdef CPU_PP
+ duration = (USEC_TIMER - usec) / 1000;
+#endif
+
+ /* This function takes a loooong time and other stuff needs
+ running by now */
+ yield();
+
/* read tick count */
finval = (lv24020lp_read(CNT_H) << 8) | lv24020lp_read(CNT_L);
@@ -512,10 +528,6 @@ static int tuner_measure(unsigned char type, int scale, int duration)
else
finval = scale*finval / duration;
- /* This function takes a loooong time and other stuff needs
- running by now */
- yield();
-
return (int)finval;
}
@@ -532,6 +544,16 @@ static void set_frequency(int freq)
enable_afc(false);
+ /* For the LV2400x, the tuned frequency is the sum of the displayed
+ * frequency and the preset IF frequency, in formula:
+ * Tuned FM frequency = displayed frequency + preset IF frequency
+ *
+ * For example: when the IF frequency of LV2400x is preset at 110 kHz,
+ * it must be tuned at 88.51 MHz to receive the radio station at 88.4 MHz.
+ * -- AN2400S04@ – V0.4
+ */
+ freq += if_set;
+
/* MHz -> kHz */
freq /= 1000;