Porting FM Radio Driver

Hi all,

I ported the FM radio driver [1] to a more recent and close to upstream kernel (Linaro 4.4), but I have a hard time using it.

Some commands never gets a reply, some others get a reply with an error status (usually 0x0c, which is translated by the driver as ‘-EBUSY’), and some works (actually, only HCI_FM_GET_RECV_CONF_CMD work without failure of all the commands I’ve tested so far).

Does anyone have info on the init sequence of the radio or any information that could help me get the driver in a working state?

[1] radio-iris.c\radio\media\drivers - kernel/msm-4.4 - Unnamed repository



As far as I recall FM radio wasn’t really tested on Android. Were you able to get FM working on Android before you started the forward port?

I did not check personaly, but other members of the team did and assured me that it worked as expected. I’m currently looking at the Android FM app (platform/vendor/qcom-opensource/fm - Unnamed repository), but it doesnt seem to do any magic. I’ll keep searching and testing.

I’ve managed to found an init sequence that allows the radio to tune in a channel (not sure what data I’m getting yet, but I have a TUNE_STATUS event).

Here is the sequence I execute and the results I get with that:

disable receiver   -> TIMEOUT
enable receiver    -> TIMEOUT
initialise_recv()  -> OK
set_freq()         -> OK, and I get tune status event after that
disable receiver   -> OK (after 5s)
enable receiver    -> TIMEOUT

If I don’t do the enable receiver step, subsequent calls fail. I think under some conditions, one might get a reply to the enable receiver command but as there are not public documentation available, I’ll focus on the audio paths from now on.

Hi Damien,

I did take a quick glance at the FM driver while working on SMD, BT and WiFi but I was worried that there might be a dependency on some state of the audio DSP, and never tried.

Have you managed to make any further progress?


Hi Bjorn,

I kept this task as a background task so it hasn’t moved very fast. First I considered porting recent Srinivas’ patches for the QDSP6v2 to the kernel we are using, but it’s too big of a job. It seems from the documentation that the WCNSS and the DSP share their samples through the cMEM, so the other option I’m currently investigating is to read these samples from the cMEM in the FM driver. I could read the buffer address and size (via the WCSS_A_FM_FM_BUFFER_* registers), but I did not check if the application processor could read the cMEM yet.

Even if the cMEM is readable by the driver, the interrupt that is triggered when the FIFO reaches a certain threshold seems to be connected directly to the audio DSP. It doesn’t seem to be routable to the application processor, so a thread or a workqueue should be used to fetch the data on a regular basis.

That’s where I am at. Do you have plans for his feature?


Hi Damien,

Thanks for the update. We have not been discussing FM radio support before, so there are no active plans to support this feature.

It does sound plausible to grab the frames out of cMEM, but I think it would be a better idea to follow through on DSP-based audio; it should be a reasonable amount of work once it’s concluded for 8996. We will discuss this in our team during the upcoming Linaro Connect.

PS. It sounds like you’re aiming to support this in a product of yours, if so, please do let Qualcomm know your intention and interest in this feature - for planning purposes.


Hi Damienr,

I have tested FM in android 7.0 and its working. Now i want to support FM in linux.

I had ported radio-iris.c driver file from driver. After debugging i figured SMD core driver is different in linux and android kernel.

FM HCI SMD driver (radio-iris-transport.c) need to be modified. I want to know did you write or modify FM HCI SMD driver to support linux smd core driver.

In Android smd_named_open_on_edge function is used to open channel whereas in Linux qcom_wcnss_open_channel function is used.

Could you please tell which FM HCI SMD driver using or approach used by you porting from android to linux for FM.

I used the later, qcom_wcnss_open_channel. I still have some patches somewhere in my machine, but I didn’t achieve much. Audio and radio are very intricate and at the time of this post mainline Linux didn’t have all the audio stuff that was in Android, so porting the radio driver was not enough to make it work. We kinda dropped the radio support because of the amount of work required (and the lack of documentation besides Android’s code).

I think Srinivas’ patches for the whole audio system in the msm8916 are now upstream, so that should alleviate some of the work to do.

Hope that helps!

Can you share the patches. i am able to open channel and send command.

using fmtest application (vendor/qcom/proprietary/fm/fmtest) compiled using gcc compiler.

below is error:

Enabling FM …+++++++++++data 903160832 len 3

VIDIOC_QUERYCAP returns :0: version: 263177
Driver Version(Same as ChipId): 40409

Outside error

Opened Receiver
[ 3919.550998] iris_radio: Error while enabling RECV FM -110
[ 3919.551490] iris_radio: Enter iris_fops_release
set_v4l2_ctrl failed for control = 0x8000004
EnableReceiver Failed to set Radio State = 0
[ 3919.555734] iris_radio: Channel already closedCmd Status … 6

Can you share the application used for testing.

Hi moidin,

Please find below links to the patches. Basically the first one backport the code from Android “as-is”, and the second one does the adaptation to mainline Linux functions etc. There are two other patches but it’s only refactoring so I haven’t attached them. I’m not sure they will apply cleanly on the kernel you’re using, but I’m sure they will be easy to fix.

I didn’t use fmtest, I did some tweaking in the probe function to see how the chip responded. But as I said earlier, considering that the audio part was completely missing at that time I didn’t push further the investigation.

Hi Damien,

I am able to recv data with few commands with status 0 and few commands i get -EBUSY. In your above comment you faced same issue and you resolved it by some sequence. I didnt understand the sequence you mentioned above. Could you please share detailed info. Is module expecting delay or some timing issue ?

HCI_FM_ENABLE_RECV_CMD this command gives timeout.

Hi Damien,

Its working now. i am able see the stations list.

DQBUF support for radio was not enabled. i enabled and tested with fmtest application. I need to test fm audio with some open source application


That’s very good news! Would you mind sharing the patches you applied to make everything work? I’m sure that would benefit others. Also, I don’t know if any open source FM application would work, or if you need that can talk specifically to this hardware, it’s been a long time since I gave it a shot.

please share the patches …

please give a link to the finished image of android 7 for DB4

Hi! I’m sorry, how activate fm radio on dragonboard 410c on android?

I found this. I need to connect the microphone and ground on the headphones for a second. How I create L1? Can you tell me

L1 should already be on the audio mezzanine board, it is really small. All you need (from an electrical point of view) to do for FM radio is plug a headset into the jack. The ground wire in the headset cable is the FM antenna. When we designed and tested the board the FM circuitry was working with a test program, however the released software did not support FM. I do not know if the current software supports FM or not, all I know is the hardware is all there and known to work.

The Audio mezzanine board has the headset circuitry on it.

I made my own boards because I couldn’t buy original audio mezanine boards. I’m currently trying to solve a problem with RTC and power. I’m trying to make an android car radio out of it