Rockbox

  • Status Closed
  • Percent Complete
    100%
  • Task Type Patches
  • Category FM Tuner
  • Assigned To No-one
  • Operating System Sansa e200
  • Severity Low
  • Priority Very Low
  • Reported Version
  • Due in Version Undecided
  • Due Date Undecided
  • Votes 1
  • Private
Attached to Project: Rockbox
Opened by zivan56 - 2007-05-16
Last edited by MikeS - 2007-06-06

FS#7178 - Sansa e200 FM tuner support

Initial support for the Sandisk Sansa e200 FM tuner (Sanyo LV24020LP).
It is initialized as soon as rockbox is started and there is no volume control (BEWARE if you use in ear headphones).

Still needs to be done:
- tuning (now tunes to around 91Mhz and AFC finds something nearby)
- volume control
- Recording

Datasheets:
http://www.rockbox.org/twiki/pub/Main/DataSheets/AN2400S04.pdf (explains in general how to tune)
http://www.semiconductor-sanyo.com/ds_e/ENA0070.pdf (registers for this specific tuner)

Make sure it put tuner_sanyo.c in the /firmware/ folder

If someone could look into the tuning details, as the datasheet is not very specific in some parts.

Closed by  MikeS
2007-06-06 19:24
Reason for closing:  Accepted
Additional comments about closing:   Warning: Undefined array key "typography" in /home/rockbox/flyspray/plugins/dokuwiki/inc/parserutils.php on line 371 Warning: Undefined array key "camelcase" in /home/rockbox/flyspray/plugins/dokuwiki/inc/parserutils.php on line 407

Now part of SVN.

Hood work, it works. However, I can't seem to turn it off (I tried every single button).

Charles

Tuning support!
1.Very crude and causes possible race condition (tune very slowly to avoid this).
2.Set the region to US/Canada for best results.
3. Not using specifications, so frequencies are a bit off and hackish; see the FM debug screen for actual frequencies.
4. Scanning is not supported.

Buttons now work correctly, volume still needs to be figured out.
Initial radio start needs to be done correctly as well, as it starts on the main menu instead of the actual FM screen.

Improved tuning with faster tune times and more precision. Now, very close to real frequency set, give it ~10 secs for AFC to centre the frequency.

Scanning is supported, and scan time is somewhat acceptable. No more race conditions hopefully when scanning.

Initial tuning takes some time, but not a problem after that

Still need to work on muting when tuning, along with starting radio at proper time.
Volume support also needs to be implemented.

Fixed:
- Volume control now implemented
- Play/pause works
- Synced with SVN

Did some code cleanup as well.

Overall, quite usable now. Still have to force stereo, as an algorithm for fine tuning is needed.
Setting the region to Europe and fine adjusting manually usually allows you to get stereo sound. Adding +0.2Mhz to desired frequency seems to be what works for me, but it may not be a fixed offset for all frequencies.

MikeS commented on 2007-05-22 07:19

I'm for having this in SVN in order to facilitate getting the recording and input muxing properly enabled even if it's not perfect yet.

That would be nice. It would be great if someone could double-check the tuner init procedure and see if it is correct (I am sure it is not 100% right).
- Synced with SVN
- Lowered gain on line1 in so that people with IEMs don't get high pitched sounds

New algorithm for tuning, which greatly improves frequency centering and sound quality. However, it is still off by 0.2Mhz.
No more whining noises

MikeS commented on 2007-05-24 03:21

I just tried this out and it is 200kHz off but it also doesn't tune most of the major, strong stations in. US/Canada region.

MikeS commented on 2007-05-24 12:49

I think I've figured out how to work this thing and like most of these tuners, you have to compensate for the IF when setting the tuner frequency. I also tweaked up the bit driver to be more compact and auto-select the register block (only changes it when needed…less error prone, fewer write calls)…if you're interested in that I can post it.

I don't know if *he's* interested, but for what it's worth, if you've already got an improved version of the patch, *I'm* interested. Let 'er rip, I say…

Please post it. I seem to have been unsubscribed from this patch for some reason.
Have you booted to the OF radio before? I commented out the init part of the code so that the OF takes care of setting it properly.

MikeS commented on 2007-05-25 09:19

I'm not going to skip any init code and I'll see if I can just get it to work our own way for what rockbox requires. IMO, having to search for cap values to set the frequency implies "cheap as crap IC" otherwise you'd just be able to select it all directly. The fact this is all done in software says: "flexibility" = "cheap as crap so we don't add that circuitry". ;)

I'm guessing the Euro version doesn't have the radio is because the small 50kHz frequency steps required means scanning will be dismally slow there…OF is nastily slow here with 200kHz ones and misses all sorts of stuff it should pick up. I've used the OF radio and it's pretty lousy and slow but all OF radio code I've checked is just that and doesn't work worth a 5#17.

Well, I'll try to remedy that if possible.

I see someone has been reading the datasheet :)
The radio works decently in Europe, I don't live there, but it caught quite a number of stations when set to the World region. It has trouble finding some stations, especially if the station is very close to another one. The reason they don't have radio support in Europe is due to the EU Radio tax, which would add on to the price of the player. Either way, the OF still works better than what I have posted… radio5.diff had a totally different approach to scanning, which didn't work tool well, but I though it *should* have considering it was going though all cap/osc values and seeing which ones match the frequency best.

It would be interesting to compare results with a Cowon D2, which seems to have the same Sanyo chip.

MikeS commented on 2007-05-27 09:05

I was going to go with the tax thing but it almost seems to absurd. :)

To summarize what I've worked on from your code:
1) make code style follow rockbox guidelines
2) use symbolic constants for everything - defined them completely for all registers
3) automatic reg block switching and OR default "1" bits into RADIO_CTRL1 automatically
4) shadow writeable registers - this leaves a few single-byte gaps but tracking which bits are set isn't needed
5) reverse the IF_PM_L bit as clearing the bit mutes it - init steps 2 and 3 work fine now
7) actually write the FM_OSC value calculated by the cap searching routine - it _tends_ more toward tuning correcly (details below)
9) remove some unneeded stuff like the pow function
10) start adding things needed by the radio interface in general
11) implement radio regions directly in the driver - the details of region setting for the radio ICs really are low-level and I plan to address that for all others - radio.c can still implement the frequency ranges and grid

There could be a problem with precision in the math that seems to make it tune the chip to the same frequency for several different specifiec ones. If so, I have no problem using 64-bit ints or perhaps rescaling calulations will work too. Overflow can be a problem too. A scheme to speed up the searching will definitely be needed.

MikeS commented on 2007-05-28 04:15

Update: Tuning rock solid now. Does about 3 loops to find the cap and two to fine tune it within 32kHz so about 80ms to tune a station. The cap search should be able to be sped up I think.

Hello, synce december 2006, Sansa E200 FM Radio is available in Europe too.
I bought it one month ago in Italy.
Unfortunately I haven't development environment to compile Rockbox, otherwise I could tray to do it.
If you send me a compiled version, I'd be happy to test it.

MikeS commented on 2007-05-30 09:54

This is my little bit added in. Hopefully it will tune well in other regions and won't need more precision so that it stay fast…it shoots for +/-16kHz.

Setting the input level down is too quiet compared to playback btw.

TODO recap:
* Improve tuning algorithms more over Sanyo's to actually converge better and faster on the desired frequencies.

* Perhaps allow a few hundred HZ slop in the IF_OSC setting since this register bounces around a bit and is hard to set accurately which just leads to longer radio init at times. I don't know why it stays more stable for long runs then seems to be unruly for long runs. OF seems to take awhile to set this as well. hrm.

* Perhaps retune IF_OSC to have less interference from internal noise when tuning weaker stations? The OF suffers this too but the interference drops away when it idles the cores. In Rockbox, button/scrollwheel activity seems to improve reception…wtf?

* Really implement station detection to be accurate for scanning.

* Do all the other work to properly integrate radio into the e200 audio system.

MikeS commented on 2007-06-03 16:50

Synced to recent keymap changes.

jac0b commented on 2007-06-05 12:35

Can't get current SVN to build with this patch applied, also it give out an error when patching. I attached the .rej file.

patching file firmware/target/arm/sandisk/sansa-e200/ata-e200.c
Hunk #3 FAILED at 67.
Hunk #4 succeeded at 243 (offset 1 line).
Hunk #5 succeeded at 282 (offset 1 line).
Hunk #6 succeeded at 298 (offset 1 line).
Hunk #7 succeeded at 366 with fuzz 1 (offset -1 lines).
Hunk #8 FAILED at 417.
Hunk #9 FAILED at 434.
Hunk #10 FAILED at 499.
Hunk #11 succeeded at 580 (offset -1 lines).
Hunk #12 succeeded at 650 (offset -1 lines).
4 out of 12 hunks FAILED – saving rejects to file firmware/target/arm/sandisk/s
ansa-e200/ata-e200.c.rej

jac0b commented on 2007-06-05 12:37

DISREGARD THE ABOVE COMMENT. THIS IS THE CORRECT ERROR.
Can't get current SVN to build with this patch applied, also it give out an error when patching. I attached the .rej file.

patching file firmware/drivers/audio/as3514.c
Hunk #1 FAILED at 114.
1 out of 1 hunk FAILED – saving rejects to file firmware/drivers/audio/as3514.c.rej

Yes jac0b, someone moved a few lines around in there (why?)

I'm working on getting a patch working

as3514.c has a lot of fuzz, because I didn't bother to change the line numbers, but it works.

Loading...

Available keyboard shortcuts

Tasklist

Task Details

Task Editing