summaryrefslogtreecommitdiff
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
parentd029b3e6978148a8f48a3c5fcd09d8b9d87fa115 (diff)
downloadrockbox-08d09e678f942fef9e9efc9a88e62f0b4e7bb0a4.tar.gz
rockbox-08d09e678f942fef9e9efc9a88e62f0b4e7bb0a4.zip
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
-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 a53d93bf65..86f8c39593 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)
496 496
497 /* start counter, delay for specified time and stop it */ 497 /* start counter, delay for specified time and stop it */
498 lv24020lp_write_set(CNT_CTRL, CNT_EN); 498 lv24020lp_write_set(CNT_CTRL, CNT_EN);
499 udelay(duration*1000 - 16); 499
500#ifdef CPU_PP
501 /* obtain actual duration, including interrupts that occurred and
502 * the time to write the counter stop */
503 long usec = USEC_TIMER;
504#endif
505
506 udelay(duration*1000);
507
500 lv24020lp_write_clear(CNT_CTRL, CNT_EN); 508 lv24020lp_write_clear(CNT_CTRL, CNT_EN);
501 509
510#ifdef CPU_PP
511 duration = (USEC_TIMER - usec) / 1000;
512#endif
513
514 /* This function takes a loooong time and other stuff needs
515 running by now */
516 yield();
517
502 /* read tick count */ 518 /* read tick count */
503 finval = (lv24020lp_read(CNT_H) << 8) | lv24020lp_read(CNT_L); 519 finval = (lv24020lp_read(CNT_H) << 8) | lv24020lp_read(CNT_L);
504 520
@@ -512,10 +528,6 @@ static int tuner_measure(unsigned char type, int scale, int duration)
512 else 528 else
513 finval = scale*finval / duration; 529 finval = scale*finval / duration;
514 530
515 /* This function takes a loooong time and other stuff needs
516 running by now */
517 yield();
518
519 return (int)finval; 531 return (int)finval;
520} 532}
521 533
@@ -532,6 +544,16 @@ static void set_frequency(int freq)
532 544
533 enable_afc(false); 545 enable_afc(false);
534 546
547 /* For the LV2400x, the tuned frequency is the sum of the displayed
548 * frequency and the preset IF frequency, in formula:
549 * Tuned FM frequency = displayed frequency + preset IF frequency
550 *
551 * For example: when the IF frequency of LV2400x is preset at 110 kHz,
552 * it must be tuned at 88.51 MHz to receive the radio station at 88.4 MHz.
553 * -- AN2400S04@ – V0.4
554 */
555 freq += if_set;
556
535 /* MHz -> kHz */ 557 /* MHz -> kHz */
536 freq /= 1000; 558 freq /= 1000;
537 559