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.

13 comments:

Jonathan Pritchard said...

Good job, thanks.

motbo 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 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 :)

Jeroen 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.

Jess 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~!

jankoh 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"

mgulsoy said...

Perfect Man, thanks.

Die Ausreis(s)er 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.

gmmmocom said...

Are you fighting in Final Fantasy XIV for FFXIV Gil or Final Fantasy XIV Gil?
Can you suffer yourself being called newbie in FFXIV Gil game?
Are you seeking unofficial Buy FFXIV Gil cheats or Final Fantasy XIV guides in order to make Final Fantasy XIV Gil faster?
Can you get millions of Cheap FFXIV Gil in one day?
Even if you know how to farm Buy Final Fantasy XIV Gil you have to prepare enough Final Fantasy XIV Power Leveling first to buy height class Final Fantasy XIV Items, to upgrade your Final Fantasy XIV characters.
FF14 Gil Then why not Buy FFXIV Gil from us?
In Final Fantasy XIV it's the fastest way FF14 Gil,for you to get rich. We are online 24 hours a day ready and 7 days one week to power up your FFXIV Gil accounts with FFXIV Gil. Here is the best place for the Final Fantasy XIV Online players to buy your Final Fantasy XIV Gil.
We are the professional website in FFXIV GIL sale.FFXIV GIL here,We are professional FFXIV Power Leveling online. We update price every single day to make sure we are the lowest in the market.(we don't compare price with scam sites which uses unbelievable low price to deceive.)
Our slogan:Cheapest price, Fastest delivery, Best service! Final Fantasy Xiv Gil
In the 2 years we are in this field , FFXIV Gilbuilt many business with tens of thousands of customers. They are very satisfied with our service.So if you want to get a log of Cheap FFXIV Gil ,no doubt ,come to our website to buy. Our customer service is ready for you on line now!(WWW,GM MMO,COM Sell FFXIV Gil)

Ashoi 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.