Sunday, October 11, 2009

Update on the N900 FM Radio

Success! We can receive FM radio on the N900 now.

Controlling the FM radio in the N900 is tricky stuff. At first, the hardware is disabled for power saving reasons. Bluetooth has to be powered up, the I2C communication bus has to be powered up, and only then, the FM radio driver will actually load.

I have created a package n900-fmrx-enabler for this task. The FMRX-Enabler is a D-Bus service that takes care about enabling the FM radio hardware on request and powering it down again when no application are using it.

After the driver has been loaded by the FMRX-Enabler, the FM radio provides two interfaces for controlling. A classic Video4Linux2 interface featuring only the basic stuff such as setting the frequency and muting/unmuting it, and a sysfs interface where you can read and write into file-like objects to control the radio.

Another tricky part is getting to hear sound from the radio. Unlike the N800, the FM radio doesn't output to the speakers directly. You have to capture the sound from the PGA line and play it back. A simple GStreamer pipeline such as
gst-launch pulsesrc ! pulsesink

does the job, after enabling PGA line2 and PGA capturing in the mixer.

I have uploaded an application package fmradio for the FM radio to extras-testing. Testers are encouraged to test this, too.

One drawback with the FM radio is that due to constant capturing and replaying, the FM radio is kinda demanding on the battery. There's no safe way around that. The unsafe way around that can damage your speakers, so capturing/replaying is a must.

I'm gonna put up some developer documentation for the FM radio stuff.

12 comments:

Jonathan Pritchard said...

Good job, thanks.

previouslysilentOld said...

doesn't this mean that you could implement a replay buffer, so that you could rewind live radio if you missed a bit? you could also dump the stream to record it too.

Martin Grimme said...

Yes, this is possible.

Raghu said...

Tried it, but could not get any sound of it ... When i initially started the app, it asked me to connect headphones, which wud act as a FM antenna. Even after connecting Nokia earphones from my N810, i could not hear any sound

Matti Viljanen said...

Raghu, the app is for Nokia N900, not N810!

I thought I would never use FM radio on a small device (I have terrible headache-experiences from cell phone radios [which tend to hiss and buzz and...]) Maybe this time I can get useful radio.

About the battery time, not an issue to me, because I would only listen to it at home, with a charger.

Raghu said...

@Matti: I tried the app on N900, but used the N810 earphones. Sorry, i shud have made that clear :)

Unknown said...

I get the same as Raghu, the app seems to work and asks to connect the headphones (mine are for the N900). No sound though.

Unknown said...

Hey it was exciting...But I did not figure out how to install either the radio or the media box...Any other plug-ins required? Thanks a lot~!

hijotech said...

After installing the FMradio (apt-get install fmradio) I could launch it, and see, that it works(tuning to a frequency, I could see via RDS the station name and Song?artist), but neither I could at first hear the music.

Then I launched from console the "alsamixer -c0".And I then I moved to the right, and by pressing "M" I unmuted "Left PGA Bypass Mixer Line Swi" + "Left PGA Mixer Line2L" + "Right PGA Bypass Mixer Line Swi" + "Right PGA Mixer Line2R"

Mert Gülsoy said...

Perfect Man, thanks.

Anonymous said...

Tried the app and it works. But there are two problems left that should be fixed. First: It seems that there's a problem if other applications cause high CPU load. Audio output becomes stuttering or fully stops (e.g. if opening a web page containing some flash banners in the browser). In the latter case the FM radio must be closed and started again to get the sound back. 2. After starting the app there's "classic fm noise" in my headphones until the app tunes into the frequency of the last active radio station. Maybe audio should be muted until the frequency is finally set.

Unknown said...

great app, but there is a problem when you get an incoming call and if you don't answer it, the radio does not come back after the call has dissconected.