yashsingh1/xdaforums huggingface dataset:
[Spirit FM] xmguy:
I use a standard 3 pole jack for my antenna mod. But use a 4 pole for my normal wire antenna. The wire one is a LG mic and call switch one. Seems to have better performance. I've noticed on my X that the antenna pin out on the jack is the normal jack ground. I've also found that a 4 pin with a unused or separate ground is better at reception vs a 3 pole with headphones/speakers. Because the audio voltage is coming down that negative line it causes interference. A dedicated ground is needed for best signal. Even though the 3 pole antenna mod uses only 1 of 3. Since no voltage is sent from positive to negative with normal headphones then it works better. I know the headphone jack audio out is disabled when the speaker is used but I think some small voltage goes from the L+R to GND pin on the jack. If you isolate the ground and feed it into the jack it will work better. Even if you split the output for headphone use as in my mod. The antenna signal and the headphone signal are separate until they get to the jack. So antenna ground voltage is preserved and audio can pass through. Unlike if you had a single wire and spit it off 1 FT away from the headphone jack to a audio out and antenna ground. Think of it as cross over with voltages for antenna and headphone wire competing. (maybe a bit more than you wanted to know) Yeah, I want to plug your app as much as I can it's WELL worth it IMHO!

As far as RDS. I've noticed as RDS is on the VHF frequency that it's much weaker and since it's a digital binary signal that it's much harder to lock on to that the analog pilot FM signal of the transmitting station. So if the station reduces the main FM station then the RDS signal is cut lower too. Once the station resumes full power operation then the RDS will work. You need to invest in a RDS generator and maybe a RF FM generator. The RDS generator can be as simple as a car iPod RDS encoder. but the RF generator is harder. but it's good for tweaking the RF values in the app. For RF mod you can use ANY small FM Mod device like an XM Radio. ;)
[Spirit FM] shadowcliffs:
Thanks so much for the reply. I agree that the fm support on Sprint's stock rom is proprietary. I have tried out more than 10 roms from various sources on my phone and I have only seen fm support on Sprint stock or stock based rom. Nextradio would report "no fm hardware found" on any other roms.
[Spirit FM] mikereidis:
FM support on pretty much ALL stock ROMs is proprietary, secret, undocumented and unpublished. Mostly from the chip manufacturer, but phone OEMs like HTC add their stuff, and then they "protect" FM from being accessed by any app except theirs, or sometimes by NextRadio if a contract is in place.

There are virtually no 3rd party FM apps for these reasons. And this is why I have given up on the ageing accessible unrooted proprietary APIs supported in Spirit1 but never to be supported in Spirit2.
[Spirit FM] mikereidis:
Great ! Good to get confirmation. :)

Z2 and Z3 marked Sony move to using Broadcom FM/BT/WiFi combo chips after the Z and Z1 lines.

I hope they return to Qualcomm for Z4+ because Broadcom chips use a single shared control channel for both FM and Bluetooth and that has created a LOT of work for me the last 3 1/2 years. Almost every new Android version changed the low level Bluetooth stuff and Spirit1 ended up with 4 access methods just for Broadcom: hcitool, UART, BT sockets, and now Bluedroid "shim" libraries.

The default and most reliable method is "UART" where Spirit talks directly to the chip, with Bluetooth otherwise off. Turning Bluetooth on while Spirit runs in this mode creates an error condition that may still require a phone reboot to clear. I hope to improve this, but good solutions take much time.

If Bluetooth is on, Spirit can use the Bluedroid Shim mode. At present, this is a manual step; previously it happened automatically, likely causing many to wonder why their phone rebooted. In this mode, BT headset can be used, but turning BT off while Spirit is running will also create problems that might require reboot.

Spirit1 allows selecting the default mode (BT on, or BT off). Spirit2 is so far automatic; if the shim is installed and BT is on, that mode will be used, otherwise BT is forced off for UART mode.

To install the shim with latest betas, use Menu->SHIM->IBTS, then reboot the phone, or if BT was never on or luck is with you, stop Spirit, start BT, then restart Spirit. It can be removed with Menu->SHIM->RBTS.

One SHIM downside is that ROM updates will write over the shim library that Spirit installs. Most or many Kitkat ROM updates have this automatically fixed with a /system/addon.d/ recovery script that Spirit adds, but I have never seen this work on Lollipop ROMs yet. So you may have to re-install each update, then reboot again.

I continue to work to improve this, but often it seems "unfair" to spend so much time on a chip that only about 14% of my app users have, when many improvements remain for the other 86% (Samsung Silicon Labs 61%, Qualcomm 24%), and UI improvements for the 100%.

C Code for Broadcom: 95K

C Code for Silicon Labs: 34K

C Code for Qualcomm: 57K including transmit.

Spirit2 sales Broadcom: 14%

Spirit2 sales Silicon Labs: 61%

Spirit2 sales Qualcom: 24%
[Spirit FM] mikereidis:
I posted an experimental G3 D855 kernel here that I think should work with Spirit2: http://xdaforums.com/showpost.php?p=59274657&postcount=12

I think the March 6 Spirit2 beta ACDB fix should fix clipping/distortion/
[Spirit FM] LenAsh:
Will give it a try soon...!

Thanks Mike
[Spirit FM] zander21510:
Totally understand, I appreciate the explanation! I'm not a programmer and only have a high-level grasp of the effort required so I'm not complaining. Great job :)
[Spirit FM] :
[MENTION=3575078]mikereidis[/MENTION]:

Trying to compile from source but I get an error. Any idea about how to solve that?:

Regards and thanks for the nice app and your hard work.

[subant] No sub-builds to iterate on
[javac] /spirit2_free/src/fm/a2d/sf/svc_aud.java:6: error: cannot find symbol
[javac] import android.media.AudioAttributes;
[javac] ^
[javac] symbol: class AudioAttributes
[javac] location: package android.media
[javac] /spirit2_free/src/fm/a2d/sf/svc_aud.java:7: error: package android.media.AudioAttributes does not exist
[javac] import android.media.AudioAttributes.Builder;
[javac] ^
[javac] /spirit2_free/src/fm/a2d/sf/svc_aud.java:214: error: cannot find symbol
[javac] else if (m_com_api.chass_plug_aud.equals ("LG2") && com_uti.android_version >= VERSION_CODES.LOLLIPOP)
[javac] ^
[javac] symbol: variable LOLLIPOP
[javac] location: class VERSION_CODES
[javac] /spirit2_free/src/fm/a2d/sf/svc_aud.java:225: error: cannot find symbol
[javac] if (com_uti.sony_get () && com_uti.android_version < VERSION_CODES.LOLLIPOP)
[javac] ^
[javac] symbol: variable LOLLIPOP
[javac] location: class VERSION_CODES
[javac] /spirit2_free/src/fm/a2d/sf/svc_aud.java:1445: error: cannot find symbol
[javac] else if (m_com_api.chass_plug_aud.equals ("XZ2") && com_uti.android_version >= VERSION_CODES.LOLLIPOP)
[javac] ^
[javac] symbol: variable LOLLIPOP
[javac] location: class VERSION_CODES
[javac] /spirit2_free/src/fm/a2d/sf/svc_svc.java:111: error: cannot find symbol
[javac] else if (com_uti.android_version < VERSION_CODES.LOLLIPOP) {
[javac] ^
[javac] symbol: variable LOLLIPOP
[javac] location: class VERSION_CODES
[javac] /spirit2_free/src/fm/a2d/sf/svc_svc.java:115: error: cannot find symbol
[javac] else if (com_uti.android_version >= VERSION_CODES.LOLLIPOP) {
[javac] ^
[javac] symbol: variable LOLLIPOP
[javac] location: class VERSION_CODES
[javac] /spirit2_free/src/fm/a2d/sf/svc_svc.java:754: error: cannot find symbol
[javac] if (com_uti.android_version < VERSION_CODES.LOLLIPOP)
[javac] ^
[javac] symbol: variable LOLLIPOP
[javac] location: class VERSION_CODES
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] 8 errors

BUILD FAILED
/adt-bundle-linux-x86_64-20140702/sdk/tools/ant/build.xml:720: The following error occurred while executing this line:
/adt-bundle-linux-x86_64-20140702/sdk/tools/ant/build.xml:734: Compile failed; see the compiler error output for details.

Also, what is this line for in the build-script?

export PROJ="so"
[Spirit FM] mikereidis:
Somebody pointed out that I should provide an Android.mk file, and they are probably right. I just use scripts myself and I'm not accustomed to building apps into ROMs, or otherwise integrating with Android build.

The build_spirit2_free script contains "android update project --target android-20"... and should be updated to ..."--target android-21"... so that VERSION_CODES.LOLLIPOP is recognized.

'export PROJ="so"' sets the directory (and project name) I use. For me at least, it should be "sf" for "Spirit2 Free" now, instead of "so" for "Spirit2 Open" I used previously.

I didn't catch these things because I don't use the build_spirit2_free script myself. This is another reason I should try to use Android.mk.
[Spirit FM] Czechnolog:
I can confirm that BETA from 6.3.3015 has solved this issue.
[Spirit FM] Androprise:
HI, I am trying to use this on my Galaxy Player 3.6 with CyanogenMod 10 and have only partial success with the Galaxy SL/i9003 audio method. The sound will only play over the speakers of the device weather the headphones or the speakers are selected. I have had perfect success with this app on my Galaxy Player 5.0 running CyanogenMod 11.
[Spirit FM] mikereidis:
At this point in the life of Spirit1, and given that I do not have a similar device to test, and given CM10 / Android 4.3, I likely won't be able to resolve this.

If you or anyone is able to work with adb shell, you could experiment with the ssd utility in /data/data/com.mikersmicros.fm_unlock/files/ (Find the fix and I would consider a Spirit1 update.)

Here is the code for mute/FM off:

ssd_run ("4 3 'Codec Status' 2"); // "FMR_FLAG_CLEAR"

Code for headset on:

ssd_run ("4 3 'Playback Path' 3"); // "HP"
ssd_run ("4 3 'FM Radio Path' 2"); //
ssd_run ("4 3 'MAX97000 Output Mode' 4"); // INB -> HP
// "MAX97000 Output Mode" = "INA -> SPK" / "INB -> HP"
// "Amp Enable" = "OFF"
// if "Playback Path" = 'SPK' / 'HP'
// "MAX97000 Output Mode" = "INA -> SPK" / "INB -> HP"

Code for speaker on:

ssd_run ("4 3 'Playback Path' 2"); // "SPK"
ssd_run ("4 3 'FM Radio Path' 1"); // Speaker
ssd_run ("4 3 'MAX97000 Output Mode' 0"); // INA -> SPK
// "MAX97000 Output Mode" = "INA -> SPK" / "INB -> HP"
// "Amp Enable" = "OFF"
// if "Playback Path" = 'SPK' / 'HP'
// "MAX97000 Output Mode" = "INA -> SPK" / "INB -> HP"

Numbers might have changed, such as the final 4 for 'MAX97000 Output Mode' or the 2 for 'FM Radio Path'.

ssd 4 0 can be used to see all ALSA controls.
[Spirit FM] mathieulh:
Hi, being the owner of an Xperia Z Ultra (currently using a GPE port rom on Lollipop), I recently purchased Spirit2 which works great.

My main concern is that, while the Sony stock radio app supports it, there is no specific band option in Spirit2 for Japan (where I often travel) and Japan uses the 76-90 MHz band for FM broadcasting, which is lower than the usual 87.5–108.0 MHz band.

Is there a workaround for this ? If not, is there any plan on implementing support for Japan FM broadcasting in Spirit2 ?
[Spirit FM] mikereidis:
Thanks for your support. :)

How about a wide band, from 76 - 108 MHz ? I will see if I can hack something in tonight. The dial numbers will be wrong but I personally never use the dial anyway.

Can go to 65 MHz on One M7, LG G2, Xperia Z2+ I think.

Do you know if de-emphasis should be 75 us like North America, or is it 50 us like Europe ? I never figured that out.

What about channel spacing ?

RDS doesn't work, does it ?

BTW, are you aware your phone can transmit FM ? (I think...)
[Spirit FM] mathieulh:
According to various Japanese websites Japan uses 50us for pre-emphasis http://cooltune.digi2.jp/jpandex.htm

RDS does work but it only displays the radio stations' name rather than the currently playing song.

According to various sites, including Japanese wikipedia, AM channel spacing went from 10Khz to 9Khz (which is in use today) I haven't seen any specific mention regarding FM channel spacing though.

Yes I know my phone can transmit, though I don't know if spirit transmit works on Lollipop, I also haven't had the need for FM transmissions so far.

Yes, a wide band 76-108 would work ! :)
[Spirit FM] LenAsh:
It does indeed work. However the audio is saturating a little, like compression, (latest paid Spirit 2 off Play Store).
[Spirit FM] mikereidis:
You will need a debug release (or wait for it to become regular; should be soon).

And then do Menu>ACDB>Install.
[Spirit FM] mikereidis:
OK, I have a "UU" band that works from 76-108 now, except on Broadcom which is only 76-90 at this time.

Will be in next debug release, and a regular release (for Lollipop only) is hopefully this week. I may try to update slowly for Kitkat too,

OK, so 50 us is same as Europe, as I thought.

So I guess RDS is mostly PS Program Service, same as Europe where it displays station ID (Here in North America it usually is scrolled RT/song info).

Strangely, this says there is no RDS in Japan: http://en.wikipedia.org/wiki/FM_broadcasting_in_Japan

I presume no RT Radiotext. There must be a PI Program ID shown in hex around top left after switching stations for a bit. Maybe PT Program Type around top right too ?

I think Japan FM spacing is 0.1 MHz, same as most of Europe.

I think there is not much info about Japan FM on the English language Internet, despite their technology prowess, because their culture is "insular". We almost never about Japan market only Android devices, even here on XDA. And I don't think I have EVER had an email from a native Japanese speaker in the last 4 years, or even in my life. And virtually no presence in my Spirit sales stats (0.2%), despite that Japan is around 3% for all Music and Audio apps.

Japan band probably used more in Germany than Japan, LOL, for access to emergency services transmissions.

Spirit Transmit is now based on Spirit2 beta release, so it runs fine on Lollipop. There is a hidden transmit capability in Spirit2 that I will likely make accessible from debug settings soon. But it does not, and likely won't be able to send media player info as RDS.

The worst part is that range is 10 feet or less, especially for half decent audio quality. I tried 2 FM/RF transmit amp devices but could not get either to work.
[Spirit FM] mustasusi:
No longer complicated at all!
[MENTION=5695250]shadowcliffs[/MENTION] On "ported" other devices' ROMs such as Note4 originally ROMs you have to disable bluetooth (freeze it with Titanium or something alike) and if you still run into problems just force close Spirit and relaunch. On Note3 based ROMs such as Priest punch or even stock ones - just be on a custom kernel, Beastmode or Lean kernel in our case, launch Spirit and set audio to "Galaxy S3\Note\S2_ICS" and use Spirit Normally - just don't turn on Bluetooth while Spirit is running.

Enjoy!
[Spirit FM] ghpille:
spirit2 free on Sony XZU, Lollipop 5.0.2

Hallo Mike,

I lost my patience waiting for an official Lollipop from Sony for my Xperia Z Ultra, so I went for the Resurrection Remix rom with a SlimLP kernel (Resurrection_Remix_LP_v5.3.7, 3.4.0_SlimLP-1.2 kernel). As was to be expected, no FM Radio app on that rom, but I knew your app and I'd found some promising noises in this endless thread.

I got Spirit2 Free, installed it and found SpiritF on my "desktop" (only a small exaggeration). But SpiritF isn't happy.

SpiritF 2015_03_06_beta

ERROR: Tuner API did not start.

This device may need a kernel with a working FM driver.

Which may very well be true: I had a look and there was no /dev/radio0.

So I got a copy of the SlimLP kernel, and enabled the Qualcomm IRIS radio + transport. Now this kernel does have the radio0 device, but still no cigar. I did not manage to find what Spirit2 expects from the kernel, apart from the radio device. In the logs I see it is complaining about a missing "/sys/class/rfkill/rfkill0/type". I've got a rfkill1, but that one is pointing to " ../../devices/fb000000.qcom,wcnss-wlan/ieee80211/phy1/rfkill1". Would Spirit2 want to manipulate wlan?

If you care to look, I extracted everything concerning /sf from the logcat. Any advice about the kernel config would be very welcome, otherwise I'll continue scanning the source ("Use the source, Luke!"). It's great reading.

Kind regards,

Gerard
[Spirit FM] mikereidis:
:)

I just posted a new Spirit2 Free for 2015_03_16 : http://xdaforums.com/attachment.php?attachmentid=3214105&d=1426537230

Either you set Menu>Set>Service>Audio Plugin to XZ2 or the Z Ultra is being misidentified as Z2/Z3+. Set it to the top blank setting for automatic detection, or if that doesn't work use "QCV" for "Qualcomm V4L". If needed set Tuner Plugin to QCV as well.

Z2 and Z3 use Broadcom chips via Bluetooth HCI and that's the only reason to use the rfkill stuff.

For Z Ultra, all that is needed from the kernel is a working /dev/radio0 for the tuner and /dev/snd/controlC0 for the audio control. (So called "analog" mode also needs "/dev/snd/pcmC0D6c".) Qualcomm audio drivers ALWAYS support FM so that's not a concern.

The kernel defconfig file needs an entry for radio-iris and another for radio-iris-transport. The radio-iris-transport driver is more likely to work as a kernel loadable radio-iris-transport.ko module. But many kernels no longer support modules. These kernels may need a well known fix to make transport work without modules.

AFAIK, most of the Xperia Z / Z1 class devices have working FM drivers now in CM12 (and by extension most XDA hosted custom AOSP ROMs), after I posted a patch and it was pushed to the other devices. I can verify if I look at the kernel source and check the defconfig file.
[Spirit FM] ghpille:
in jni/tnr/tnr_bch.c I found the following logic

void rfkill_state_file_get (char * rfkill_state_file, size_t rsf_size, const char * type) { // Get rfkill state filename for passed type
...
#define MAX_RFKILL 16 //4 // 1 was OK, but Nexus9 needs at least 3
for (id = 0; id < MAX_RFKILL; id ++) { // For all possible values of id that have a type file...
snprintf (type_path, sizeof (type_path), "/sys/class/rfkill/rfkill%d/type", id);

fd = open (type_path, O_RDONLY); // Open type file
if (fd < 0) {
loge ("rfkill_state_file_get open %s errno: %s (%d)", type_path, strerror (errno), errno);
return;
}

If rfkill0 doesn't exist, (but rfkill1 does, eg), rfkill_state_file_get exits, without looking any further. The program does a couple of more tries with rfkill0, to no avail.

Wouldn't it be better if the return was replaced by continue?

---------- Post added at 09:26 PM ---------- Previous post was at 09:12 PM ----------

Sorry, I spent too long refreshing my C knowledge, I should have checked for your reply before posting.

And this: "To prevent spam to the forums, new users must wait four minutes between posts. Sorry for the inconvenience! ".

---------- Post added at 09:35 PM ---------- Previous post was at 09:26 PM ----------

There was nothing to set, this version was working the moment I switched it on. Can't remember the last time I was so happy hearing noise, LOL.

Connecting the headphones, tuning 95.7 and I've got the wireless!

Nice job. I'll either make a donation or buy Spirit2, just need to contact a family member with a paypal account.
[Spirit FM] mikereidis:
:)

rfkill always starts with rfkill0 AFAICT. If there is no rfkill0 then there will be no higher numbers either.

Anyway, only 3 Broadcom based "architectures" are supported by Spirit2 (M7, G2, Z2/Z3) and they all use rfkill0 for BT. I only added a loop for more in order to test my Nexus 9 for FM.
[Spirit FM] feriber:
Hi Mike,

I would like to know if these above settings are right for my Samsung Galaxy SII I9100:

Settings:

TUNER

Band= EU

Stereo=Stereo

Soft Mute=Enable

RDS=Start

RDS AF=Start

QCom Antenna= External

Mode=Receive

All other vaules left blank

AUDIO:

Mode=Analog

Output=Auto (is the only way i can hear the radio)

Stereo=Stereo

GUI:

Visual State=Stop

SERVICE:

Update Notification=Disable

Update GUI Intents=Disable

Update Remote RCC...=Disable

Audio Plugin= GS2

Tuner Plugin=Auto

I cannot change the output from headphones to speaker (only runs in auto mode trough the headphones).

I've got 5.02 ROM you can see in my signature and i have not installed any other supersu/busybox software.

Last beta seems to work as bad for me :( :( as previous ones.

I'm sure i'm doing something wrong.

After five minutes listening the radio, the phone performs a soft reboot (while i'm still listeing the radio).

When it finishes booting, wifi connects, phone connects, then i stop listening the radio.

I've found similar with free version.

Any suggestion?.
[Spirit FM] ghpille:
shell@togari:/ $ ls -l /sys/class/rfkill/

lrwxrwxrwx root root 2015-03-15 22:53 rfkill1 -> ../../devices/fb000000.qcom,wcnss-wlan/ieee80211/phy1/rfkill1

after activation of wifi and bluetooth, there was only rfkill2, even when I switched those off again. After fooling around activating mobile data, wifi & bt, I've got only rfkill3.

just FYI
[Spirit FM] mikereidis:
The best settings are all default settings, except setting band for EU (But that should be automatic too).

I recommend the last 0306 of the Lysergic unofficial CM12 ROM for GT-I9100 (cm-12-20150306-UNOFFICIAL-i9100). That is what my GS2 has been running for the last 10 days, and I am not seeing any problems.

Are you using the kernel that comes with that ROM ?

That said, I am not using the phone as a phone, so your "environment" may be more severe. You run apps I never test I presume, your memory might be full and you make and receive phone calls. I just tested half my test devices (inc 9100) with a phone call the other night and had to fix a GS3 issue I was surprised about.

I know that with RDS rather active and screen on, ALL of my CM12 phones can only un for 12-24 hours before they restart. Each send of an RDS update uses an Android resource that is limited to 51,200. None of my CM11 phones and none of the stock Lollipop ROMs I tested have this issue.

And even in the new 5.1 Google still has memory leaks for which fixes have not been released yet.

So for the best way to make your testing similar to mine, install 0306 of the ROM and consider a clean flash, even if just for testing (after backing up).

Then reboot the phone and try the latest 0317 Spirit2 before and without starting any other apps.

If you have apps that do low level things, especially for audio, such as EQ, disable them if you can.

Leave RDS AF as Stop = Disabled at this time. For testing, consider turning off RDS also.

Analog mode probably does not work for speaker at this time. For speaker, or the most tested mode, use digital.
[Spirit FM] giltros1:
thanks
[Spirit FM] mikereidis:
Spirit2 Lollipop is now updated to March 18 2015_03_18_lollipop in Play store: https://play.google.com/store/apps/details?id=fm.a2d.s2

I posted 24 hours ago, but rolling out to 20% only. I'll enable 100% if no bad reports in a day or 2.

The last non-beta official release was 2015_01_31a_lollipop.

There were a very large number of changes, fixes and some new features/settings.

I'm happy to hear any reports, good or bad for this or the 0317 beta release.

I'll put up a new free version soon.

At this point I don't think I am going to update the last JB 4.1 - Kitkat release done in late November. Better to put my energies into Lollipop+.

Android 5.1 is upon us, and ALL 13 of my Spirit2 test devices are now running 5.0 CM12 unofficial or official or 5.1 OmniROM, the 5.1 on GT-I9000 and 9100 no less.

I don't want to flash any back to Kitkat now.

Spirit2 beta and free releases will still "support" (be able to run on) Kitkat 4.4+. But I don't want to do the Kitkat testing myself.
[Spirit FM] Airboner:
[MENTION=3575078]mikereidis[/MENTION] any cance having fm radio on our galaxy s5 (g900H) ?