Playing with the FM Radio on the #N900
In a previous blog posts, I wrote about the FM receiver on the Nokia N900. I commented
You are supposed to be able to get RDS as well, but I didn’t get any RDS messages. All in all, the fmradio package is fine for my use, but nothing special.
Since then, I started playing with the FM Transmitter built into the N900, and when you start playing with both of them, it can get very interesting. For the FM Transmitter, there is a client that you can use to control the transmitter, fmtx_client.
With this, you can set the frequency, the RDS Station name, the RDS information text as well as power on and off the transmitter. I ran into one bug, with the current firmware level of my phone, the station name needs to be exactly eight characters long. However, you can control pad the station name with blanks.
Our car is a Prius which has a nice RDS enabled FM receiver. With a little playing around at the command prompt, I set up the FM transmitter to set the radio station to “aldonsfm” and sent out messages to my family members. The Prius has a safety feature that it won’t display RDS messages when the car is in motion, so I didn’t play with it extensively. However, with a little work, it seems like I could set up the phone so that it would display the most recent SMS message I’ve received on the RDS receiver whenever the car is stopped. I also talked with my wife about how this could be a great idea for car salesmen. When a potential buyer checks out the car, it has music selected to their taste playing on the radio, broadcasting off of the salesperson’s N900, along with appropriate ads for the car company, and could have personalized RDS messages display for the potential buyer.
I also got into a discussion with a friend about using the N900 as an RDS receiver. Could someone send an RDS message to the FM Receiver which would then get processed by some program? It appears as if that isn’t that difficult.
One of the key aspects of the N900 is that many components are accessible via sys, a virtual file system which makes information about various components available as files. As an example, information about the FM Transmitter can be found on the N900 at /sys/class/i2c-adapter/i2c-2/2-0063. There are files like rds_ps_name which say what station name the FM Transmitter is. The FM Receiver can be found at /sys/class/i2c-adapter/i2c-3/3-0022. When the FM Receiver is powered on, there are all kinds of interesting files, including an rds_ps which I believe would display the station name.
One problem that I ran into is that the FM radio application only works when the headphones are plugged in. It uses the headphones as an antenna, but you can still use the stereo speakers on the N900. The transmitter, however, only works when the headphones are not plugged in, so I couldn’t test running the transmitter and the receiver at the same time.
To get at the FM transmitter via the D-Bus, there is documentation on the Maemo Wikei: FM Transmitter API Usage
As I looked at the sysfs, I notice that for each device there is a name file. For the receiver, the name is bcm2048. This happens to be the name of the Broadcom chip that handles the FM receiver and Bluetooth. For the transmitter, it is si4713, which is the name for the Silicon Labs 4713 FM transmitter. What I found especially interesting, as I search on the si4713 was Video4linux documentation about this chip, including C code to check the noiselevel.
Digging deeper, I found A single master I2C tutorial. So, one of my projects is to learn more about i2c, and for that matter the whole sysfs.
Another area that I want to dig more into is the Dbus. There are a couple interesting commands, dbus-send to send a message out onto the dbus, dbus-monitor, to track traffic coming in on the dbus, and a package, dbus-scripts to be able to run a script whenever a message comes in on the dbus.
Yeah, the FM receiver, in and of itself isn’t all that exciting, but what is exciting about the N900, at least for a geek like me, is to be able to get in under the covers and start poking around and seeing what is where. Have you done any interesting N900 hacking yet? What else should I be looking at?