FS#8238 - tuner fails to tune in when awaken by alarm wake-up

Attached to Project: Rockbox
Opened by Przemysław Hołubowski (p.h.) - Tuesday, 27 November 2007, 10:47 GMT
Last edited by Michael Sevakis (MikeS) - Friday, 25 January 2008, 19:21 GMT
Task Type Bugs
Category FM Tuner
Status Closed
Assigned To No-one
Operating System iriver H10
Severity Low
Priority Normal
Reported Version Daily build (which?)
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


When H10 is awaken by the RTC alarm wake-up and as a start screen tuner or recording screen is chosen then after awaking tuner does not tune in for the last played station. One can only hear noise and some hardly audible radio station different from the one that was played last.
This task depends upon

Closed by  Michael Sevakis (MikeS)
Friday, 25 January 2008, 19:21 GMT
Reason for closing:  Fixed
Additional comments about closing:  Just dumped an extra DELAY; in fmradio_i2c_outb and all is well on my unit.
Comment by Przemysław Hołubowski (p.h.) - Wednesday, 28 November 2007, 20:42 GMT
There's a workaround:

When the radio is turned on and PLL frequency is set it may be checked whether or not radio got tuned in. If it wasn't tuned in PLL frequency may be repeatedly set until the radio gets tuned in.

The patch was tested on H10 20GB and was found to work reliably.
Comment by Michael Sevakis (MikeS) - Monday, 03 December 2007, 14:44 GMT
In reference to  FS#8144  and in general I think the issues on 20GB need to be found (In my case, no chip communication at all at 80MHz) rather than a brute-force workaround. I'm pretty confident one exists. The driver probably needs tweaking too in order to allow powerup time before actually doing much with the radio.

Is the CPU frequency at 80MHz at the time the alarm wakes up?
Comment by Przemysław Hołubowski (p.h.) - Monday, 03 December 2007, 19:31 GMT
You're right of course. But as long as there's no solution and some users are in urge of having the tuner working the patch may help them. I'm not for committing it of course. The patch with addition of alarm wake-up helped me to use RB to perform night radio recordings and for my friend it made station selecting reliable (without the patch he was almost unable to tune in).

As to the CPU frequency - when alarm wakes up CPU freq. is 80MHz up to the line where tuner's PLL is set. It changes to 30MHz right after that line (see radio_start() in radio.c). When the player is turned on in a normal way CPU freq. is already set to 30MHz before the line which sets PLL.
Comment by Przemysław Hołubowski (p.h.) - Monday, 03 December 2007, 21:33 GMT
Setting CPU freq. to 30MHz at the start of fmradio_i2c_write() and fmradio_i2c_read() results in the tuner being able to find next station and tune in if the player was awaken by the alarm.
Comment by Przemysław Hołubowski (p.h.) - Wednesday, 05 December 2007, 19:45 GMT
Improved workaround patch for impatient ones.
Comment by Michael Sevakis (MikeS) - Friday, 25 January 2008, 06:55 GMT
This should fix the 80MHz problem which is caused by not having all the delays needed. It also uses IN/OUT for HI/LO instead of explicit pullup which indicates the big H10 has pullups on SCL and SDA. I don't know if that's true for small H10. This definitely functions properly on my device.