yashsingh1/xdaforums huggingface dataset:
[Spirit FM] mikereidis:
Thanks for your thoughts. Warning: no particularly useful app info in this post:

Recording won't be done unless I can find an easy way. If anyone can point me to an app or phone that does it, or can help me get it working on some phone, then I will re-consider.

Skinning should be more or less possible now, without access to my source code, by modifying the XML files in my APK. I might document this so others can try. I'm all for anything that can allow users to modify and improve so that I can concentrate on the harder or core parts.

IMO a free version should use all the things that are different between phones, so I get plenty of feedback on what works and what doesn't.

For example, both versions would use the back/pause/forward buttons on HTC or other earphone cables. A free version might map those buttons to volume and mute. A pay version may allow configuring the mapping to the same or to next/previous station or whatever.

My biggest challenges are at least some of the reasons why Google hasn't produced an FM app (and may never?). Ideally these could be solved for all phone and ROM combinations without root/SuperUser:

(1) Audio routing

(2) FM chip access, provided by HCI access for TI and Broadcom chips.

I'm hoping I can get assistance from others to help solve these problems on various phone/ROM combos. Thus a free app that uses these features is essential.

BUT, once the hard part of getting, for example, BT HCI access, is done, it's relatively easy to have universal TI and Broadcom code using that API. And a paid app could offer more features, like transmitting perhaps that use the same HCI interface for basic functions like power on/off or tuning.
[Spirit FM] 4silvertooth:
Ok I get you now I know why the dsp manager (cyanogenmod) doesn't effect audio from radio. If you get the audio to rout there would be cool possibility to get audio effects to work on FM like bass treble etc etc... Or can the equilizer be implimented internally.

Tip:There r call recorders which can record audio maybe we can get hint from it. As soon as I get time I m gonna decompile one such app and will post something usefully.

Is the lib file mikersmicros.... compiled from scratch with source code? Edit: ofcourse you have sorry.
[Spirit FM] Talbes:
Any chance of getting this to work with MIUI GB

Hi,

Talbess here from miui-au.

just wondering if you are able to get Spirit Radio working with MIUI GB release. The FM radio has been absent from all MIUI GB releases as is hcitool.

I have tried putting hcitool back but it won't run and when I install Spirit Radio it doesn't connect to anything.

Just wondering if its some other missing modules or is it something MIUI have removed from CM7 that is stopping it.

Thanks
[Spirit FM] mikereidis:
Yes, the audio path in use is the same the HTC FM app uses. It's analog from the BT/FM chip through where-ever eventually on to the speaker or headphones. It seems to be a "special" path and can result in two audio streams mixing without regard for each other.

Yes, DSP stuff and VU meters etc would be wonderful if possible.

Yes, I stumbled across a thread where some hack is used for 2 way voice call recording. Maybe...

Yes libmikersmicros_fm.so is compiled C code via the NDK. Most of my audio routing code is in the Java app, and modelled after the routing code in the CM FM app. But there is still some code in the lib that writes to /sys/devices/virtual/htc_accessory/fm/flag, which does nothing on CM, but works on stock ROMs. Also an ioctl to /dev/msm_snd but that is disabled by default now since CM supports the routing now.
[Spirit FM] mikereidis:
Hi Talbess. I haven't tried, but I hope it's possible some how.

Some time back I tried to get hciattach, hcitool etc running on a sense ROM (Blayo) based on the stock HTC ROM for the Legend, but I was not successful after a few days of trying. I'm not too experienced with the innards of Bluetooth however.

Basically, I just need some way to get direct HCI access, even if root is required (but preferably not).

I trawled through MANY threads over many days trying to find someone who managed to do this on Android but found nothing. Supposedly the PyBluez guys did it, but I tried their scripts and they didn't work, except I think on CM with root. I tried some fancy tricks with the handles from the Java BT APIs but no go.

Even on CM, from NDK code I could not access the parts of HCI I needed. Android seemed to let me run the equivalent of "hcitool cmd 4 1" (Get BT version), but wouldn't allow me to talk to the FM.

I WAS able to write a daemon that could be started by my app, and the daemon could talk directly to the Bluez stack and FM just fine. But this only worked on CM, and with root to install the daemon (Although I think I know the trick to avoid this now).

AFAICT, hcitool is pretty simple and just talks directly to the libbluetooth stack like my daemon did. So if it won't run, then my daemon wouldn't either. I considered D-Bus APIs but never looked too far into it and couldn't see any HCI api there.

But assuming we have root and can modify the kernel or whatever, there has to be a way to do this.

Over the next few days I'm going to put a stock, or other Sense ROM back on my Desire HD and will be looking for some way to get my app running there. If anyone can recommend a Sense/Stock like ROM suitable for this, please let me know.

Perhaps I'll find some way for stock and hopefully your MIUI GB as well.
[Spirit FM] Victorino86:
Yeah, sorry, didn't see the post where you were explaining all the PT, PI, PS stuff

Btw, I'm getting a code starting with K.

Ah, ok, 'cuz it finds the next station but sometimes when i tap "stop" it goes back to the starting station, but I think you already know.
[Spirit FM] mikereidis:
https://market.android.com/details?id=com.mikersmicros.fm

v2.0.9.

- Seeks at end of band should wrap around automatically.

- Fixed some seek problems. Seek (via long press of frequency up/down) may still occasionally hang. If so, press "Cancel" and retry.
[Spirit FM] 4silvertooth:
https://github.com/mik9/android_packages_apps_FM

well if it helps here's repository of FM app which is running successfully on cm7 lgp500.

Note: Its not my work all credit to Mik for the work.
[Spirit FM] CR5N:
Hi, tried this on HD2 running Tytung2.7 GB2.3.4. If I put in a frequency for a known strong transmission, I see signal bars but no audio from headset or speaker.
[Spirit FM] lupoalberto12:
I tried it on my Wildfire but it doesn't work.

Bye!

! :) !
[Spirit FM] avalst:
I'm having the same issue on my EVO no sound on any station I've tried.
[Spirit FM] gmpurohit:
Not working on lgop1 cm7

Not working on my lg optimus one flashed with cm7..neither is shows signal strength...hats off to the innovative idea.will wait till it gets more stable & polished &
[Spirit FM] nibras_reeza:
Hmm, I was really looking forward to an FM app that doesn't require headset but alas, this doesn't work on GT540 with stock 2.1.
[Spirit FM] Quinny899:
You'd have found it doesn't get much signal anyway, my 2.3.4 GT540 doesn't.
[Spirit FM] mikereidis:
Thanks ! I'll investigate further but first thing I see is "We're using hack in libaudiopolicy to fix crappy FM behavior.."

Can you refresh me on your issue ? I looked back but can't figure out if you are looking to record FM, or if my app isn't running on your phone. I've had at least one report of success on Optimus One/p500 with the unofficial CM port I guess.

------------------------------------------------------------------------------------------------------------

I had mutlii-quote working before but can't figure it out now, LOL.

CR5N and avalst :

>Hi, tried this on HD2 running Tytung2.7 GB2.3.4. If I put in a frequency for a known strong transmission, I see signal bars but no audio from headset or speaker.

>I'm having the same issue on my EVO no sound on any station I've tried.

Yes, I think you are close, but you've run into the dreaded "audio routing" issue. Do you have "adb shell" on a PC ? Here are some things you can try if so. If not, perhaps a terminal emulator for the phone, just remove "adb shell" from these commands:

adb shell "echo fm_headset > /sys/class/htc_accessory/fm/flag"

adb shell "echo fm_speaker > /sys/class/htc_accessory/fm/flag"

If that fails, you can try this:

adb shell "touch /sdcard/fm_su"

But then you have to have a SuperUser.apk or similar installed, and when it requests su access you have to respond in the affirmative. All it does is a chmod on /dev/msm_snd so it can use an "ioctl" to route audio,

------------------------------

lupoalberto12:

>I tried it on my Wildfire but it doesn't work.

Do you get any indication of signal strength when set to a strong frequency ?

-------------------------

gmpurohit:

>Not working on my lg optimus one flashed with cm7..neither is shows signal strength..

OK. I don't know why I had one report of success on Optimus One with CM and many reports of failure. I will likely buy this phone soon and I'm sure I'll figure it out...

----------------------

nibras_reeza:

>Hmm, I was really looking forward to an FM app that doesn't require headset but alas, this doesn't work on GT540 with stock 2.1.

Stock ROMs seem to have these nasty proprietary BT stacks that make life difficult.

I've started a dev thread about this and hope to find solutions: http://xdaforums.com/showthread.php?p=13627988
[Spirit FM] altroy2:
Very cool :)
[Spirit FM] _wyrm:
This description is misleading. The data format is _always_ 8khz, 16bit mono.

8000 * 16 * 1 = 128kbps.

When you set a higher clock rate you increase the number of timeslots, not the actual sampling rate of a single slot.

So, if you have it at the default 512kbps, it's 4 timeslots of 128kbps each.

But anyway, these options doesn't affect fmradio at all, it's used just for bluetooth SCO.
[Spirit FM] cos68:
Hi Mike

Since you released this version fixing the PTY I now have program type displayed just fine on my phone.

If eg PTY 10 is transmitted, I get "Pop Music" because I am in Europe.

However one small strange thing I see is, that whenever the screen orientation is switched from portrait to landscape, then the PTY displayed switches to "Country", which is the US representation for PTY 10. If the screen orientation is switched back to portrait, then I still see "Country". I have to restart your application to get back to European representation.

It is not a big issue, but hopefully not too hard to fix either ;)

Thanks!

Claus
[Spirit FM] _wyrm:
LOL. hciattach can't be "obsoleted" by brcm_patchram_plus. hciattach is generic, and is a bluez component. brcm_patchram is just the result of NIH syndrome.

In fact, BCM2035 support in hciattach works just fine with BCM4329. (at lower baud rates). And adding support for bcm4329 in hciattach isn't that hard.
[Spirit FM] mikereidis:
Great ! :)

Did the stock FM app or the CM FM app require stock headphones ? That seems weird, but possible due to some special detection of headphone jack insertion.

Or are you just talking about my app not requiring headphone insertion as an antenna ?
[Spirit FM] mikereidis:
Thanks, I'll look. I wonder if there are some subtle hardware differences between i9000s bought in different countries. The CM FM app was apparently working for a few people, but not most I think.

OTOH, I was re-reading threads last night about the mono FM problem on the first Samsung ROMs. One comment indicated the Samsung bugs could have resulted in some damage to the WM8994 audio chip:

http://xdaforums.com/showpost.php?p=8218737&postcount=194

"This one's a real gem: it can cause real damage..."

It's possible that some of the earlier phones suffered damage due to Samsung bugs, or even aftermarket ROM bugs, perpetuated from Samsung code or not.

The CM7 kernels STILL seem to have the mono FM bug.
[Spirit FM] mikereidis:
OK, thanks. Android apps re-initialise the UI on orientation change. I probably have to ensure all the preferences are properly reloaded when that happens. You can lock an orientation if you prefer.
[Spirit FM] mikereidis:
subpsyke said: "...the patchram function is completely optional"

I recall you saying on IRC that Broadcom chips have REAL ROM, that can't be reflashed. Is that correct, and still true for the newer chips ?

And the patchram serves the purpose of updating firmware ? So I'd guess patchram is optional, but bugs would be present...
[Spirit FM] mikereidis:
Thread post 1000 and my 777th XDA post. :D

Thanks all for your reports, info and support !
[Spirit FM] psyke83:
I think you're being a bit too harsh, or taking it too personally. What I meant is that brcm_patchram_plus obsoletes hciattach for my specific device.

NIH = not invented here. The brcm_patchram_plus's core functions may overlap hciattach, but they are also superior to hciattach for the parts specific to Broadcom chips (patchram and MAC). So I would argue that it's not a case of NIH syndrome at all.

I'm not even sure what you meant here. My device uses the BCM2049B0 chip, and while hciattach does work, I am forced to supplement it with the buggy Atheros abtfilt tool in order to get my MAC address recognised properly. With this combination, the patchram file is not possible to be used, either.

I'll continue using brcm_patchram_plus which allows me to use the patchram, sets up my MAC addresses (exported to the framework via RIL), and sets the master/slave PCM route. In the meantime feel free to add all these functions to hciattach. Who will be reasonably guilty of being a NIH candidate by this time? :P
[Spirit FM] _wyrm:
I think real ROM or flash depends on chip, i know that there are some BCM chips which are meant to HID devices or headsets which have r/w memory for the firmware.

There are different firmwares, stuff for testing and regulatory approval, different defaults, etc.. You can use patchram to "update" the firmware for these uses.

What i meant is that patchram can't really make hciattach "obsolete", hciattach is the official bluez tool, it supports a lot of other chips, and implementing what patchram does inside hciattach should be an easy task. In fact, if you don't need to patch the firmware or need baud rates higher than 921600 you can just use bcm2035 support already present in hciattach.
[Spirit FM] _wyrm:
I've added support to set bcm2035 BDADDR to hciattach back in 2007, it still works for bcm4329. :)

I've added it already.. You can use bcm2035 for bdaddr since it is all that you seem to care about.

The other important bit is the serial port baud rate, in this case bcm2035 support isn't good enough, i've added bcm4329 baud rate setting to hciattach too, but i'm not allowed to release it yet. Just pointing you that it is _really_ easy to add if you want to.

About the "master/slave" pcm route, as i already said, it isn't related to fm audio. :D

I think hciattach was written a long time before patchram. You, as a community member, not working for a corporation, should value more other community driven projects. Anyway, you can add all you need to hciattach and contribute it upstream. I don't think you can add anything to brcm_patchram and send it upstream, or can you? :confused:
[Spirit FM] psyke83:
That's not all I care about ;). I care about all the functions that I mentioned, since they're all needed for functional Bluetooth.

Right, thanks for the information. The SCO support needs to be working for headsets and so on. I'm without many Bluetooth gadgets to test this properly myself, but brcm_patchram_plus is working according to user reports.

I value it, yes, but one is more functional than the other, and both are released under permissive licenses. Please note that as a CyanogenMod ROM developer, I'm limited to the version of hciattach and brcm_patchram_plus that's present in the current CyanogenMod source repository - not upstream. Comparing the versions I have available to me, the latter tool is more functional for my device, which is the only reason why I use it. I'll be happy to switch to hciattach once the missing functionality is present (especially if it solves brcm_patchram_plus's tendency to fail at initializing Bluetooth on random occasions).
[Spirit FM] psyke83:
Mike,

I assume that your SamsungCM7 audio output path is intended for use with the Galaxy S/S2, but I gave it as shot on the G5. It causes a constant sound to be played, identical to a DTMF tone (like when you press and hold a key on an analog phone).

I also did some poking around in the MAX8899 service menu (only available on stock ROMs). There's some options to choose the amp gain and to force the amp on/off for various devices (headset, speaker, fm speaker, fm headset, force speaker, and others).

It's possible to "force" the amp on for certain devices without causing the radio to interrupt. For example, while the FM radio is playing via the headset, if I force the "force speaker" device amp on, the radio will play via the speaker and headphones simultaneously (which is not an option via the FM app).

Some example output while the FM radio is playing via headphones:

Radio:

MAXIM AMP
FM RADIO MODE
SP VOL: 0
HPL VOL: 21 HPR VOL:21
INPUT MODE 0x2
OUTPUT MODE 0x91

I noticed that "input mode" is 0x2 for FM playback and 0x1 when the FM radio is not enabled. I'll do some more checking a bit later.
[Spirit FM] _wyrm:
You may want to check this yourself.

The original firmware should work perfectly fine on your device. So, for "functional bluetooth" you just need to set the bdaddr. For "functional Bluetooth EDR" you will also need higher baudrate.
[Spirit FM] psyke83:
Oh, I see. I wasn't aware that you worked for Samsung, personally signed off the "BCM2049B0_BCM20780B0_002.001.022.0170.0174.hcd" file for the GT-I5500, and therefore know with certainty that it's a dud update and unnecessary for full functionality ;).

The brcm_patchram_plus tool initializes the device at 3Mbit, isn't that EDR already?

I already mentioned that I tried the hciattach tool, and the problems that I encountered (with CyanogenMod's version).

Edit: to illustrate how outdated CyanogenMod's version is (not your fault, of course): https://github.com/CyanogenMod/android_external_bluetooth_bluez/tree/gingerbread/tools

Sadly, it's not out of sync with Android's revision either: http://android.git.kernel.org/?p=pl...49e1a21746764c0ad3f;hb=refs/heads/gingerbread
[Spirit FM] _wyrm:
No, i just disassembled it (it's just a bunch of hci commands) and looked at the resulting patches in IDA. I've also extracted the full rom from the chip and found the audio peripheral registers, so i could do more than what's supported by the firmware. :)

Please, stop flaming, just go and test it yourself. I'm pretty sure that it will work without the patches, it did work without patches for BCM2035, BCM2045 and BCM4329, which are the chips i had opportunity to work with.
[Spirit FM] psyke83:
That's the second time you ignored me ;). I told you that I tested hciattach already - I used it for my port originally, and it gave the problems that I outlined, as well as issues such as devices not pairing properly.

You started this disagreement over semantics ("obsoleted"). I meant for my specific chip and phone, and you took it as a personal insult on your baby. If you'll look at the hciattach revision that I'm forced to use (see my last post), you'll see that it's not suitable, since it can't set the MAC address properly.

Let's not pollute Mike's thread and instead focus on the FM radio, please.

P.S. Though I'm not aware of your involvement in Bluez exactly, I appreciate your efforts as much as anybody who chooses to contribute to the community. Just try to understand that for CyanogenMod I'm forced to use a specific, outdated revision that's not fit for purpose.
[Spirit FM] _wyrm:
MAC(BDADDR) address setup for BCM chips was added to hciattach in 2007 (4 years ago). It's supported since bluez-utils .14 or something. And it is supported on the repository you sent the link to.

Just use bcm2035 as the "type" argument to it.

i.e.: After a reboot, don't use patchram and do:

# hciattach /dev/whatever_serial_port bcm2035 921600 flow 01:23:45:67:89:ab

# hciconfig hci0 up

# hciconfig hci0

And you will see that your MAC(BDADDR) will be set to 01:23:45:67:89:ab. You can also skip the "hciconfigs" and let android do this step for you.

The baud rate setting would require you to write ~10 lines of code. Worth a contribution, considering that your code has the potential to still be in use when Broadcom announces BCM9999. ;)
[Spirit FM] FadeFx:
Ok, so that means for me to flash back to samy rom so i can see if the chip suffers from real damage. But this wont happen before next weekend as i am going on vacation tomorrow.

----------------------------------------

tapatalked
[Spirit FM] psyke83:
Thanks. The only problem: the binary is invoked from a static init script, like so: https://github.com/psyke83/android_device_samsung_galaxy5/blob/gingerbread/files/init.gt-i5500.rc

I suppose I could work around the issue by making a wrapper script, but I'm not sure if it could process Android's stop/restart init service calls in that case.

The brcm_patchram_plus binary already parses the address from a file defined in Android's "ro.bt.bcm_bdaddr_path" property, so it's more convenient.
[Spirit FM] FadeFx:
Hi Mike, just found out that morning that my receiver actually works. i started spirit-fm, still on cm7, accidentally without headset and first only heard some noise like out of tune, then i stopped it again to not wake my gf. Now i tried again and i could even hear the station i adjusted it to. So tuner works and i will try now with headset again.

----------------------------------------

tapatalked
[Spirit FM] mikereidis:
It would be interesting to know, but I'm not sure it's a high probability. Proven cases where software caused permanent hardware damage seem rare.

EDIT: Oh, OK, your next post indicates you have it at least partially working. Great !

>first only heard some noise like out of tune

Perhaps you were also hearing the DTMF (touchtone) 0.
[Spirit FM] mikereidis:
Wyrm:

You didn't get higher bitrate digital audio working did you ? Think it's possible ?
[Spirit FM] FadeFx:
I don't think so, i minimized it first as a short reaction, so it took me a few seconds to actually power it down.

Edit: so it seems to fully work now, no matter if i connect headphones before i start spirit-fm or after. Pretty happy with it so far. Thanx a lot mike, also for your support.

You remember my offer, its still valid...

Edit2: one problem remains, there is no audio at phone calls after using spirit-fm. Looks like something is not released propperly on shutdown.

----------------------------------------

tapatalked
[Spirit FM] pirrera:
Yea. The CM FM app require stock headphones in the first time, then you can switch to other hf and it works. I've read something about the mic detection, but not sure now. And in CM FM the volume control doesnt work at all.

Yours work even w/o headphones :D. I understand it still have much work to do, but for now, Spirit FM is the best option to ear FM Radio in SGS CM7.
[Spirit FM] mikereidis:
Thanks... This command might restore audio after FM power off:

adb shell /data/data/com.mikersmicros.fm/files/ssd 4 1 9 /dev/snd/controlC0 0

I'll move my SIM to the Galaxy S and test phone calls.
[Spirit FM] mikereidis:
xmguy has posted a 10 minute video demonstrating Spirit FM: http://www.youtube.com/watch?v=UYVMv-d601g

Thanks xmguy !