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
This commit is contained in:
Michael Sevakis 2010-06-22 07:27:34 +00:00
parent d029b3e697
commit 08d09e678f

View file

@ -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;