yashsingh1/xdaforums huggingface dataset:
[Spirit FM] mikereidis:
I could use some assistance in testing the new Audio Methods I'm building. The utilities are in: http://www.mediafire.com/file/utmq7ce17z7w72k/SpiritSound.zip

I'm interested in devices with one or more of the following device "pseudo files":

(1) /dev/msm_audio_dev_ctrl

(2) /dev/snd/controlC0 (ALSA)

(3) /dev/msm_snd

The Zip contains:

a new ssd utility,

amixer

alsa_amixer

Before installing amixer or alsa_amixer make sure there is no same named command on your device. IE run "adb shell amixer" and "adb shell alsa_amixer" and ensure the command does not exist. If it DOES exist, don't install the version from the Zip, but use the version already installed.

After unzipping, to install:

adb remount

adb push ssd /system/bin

adb push amixer /system/bin

adb push alsa_amixer /system/bin

adb shell chmod 777 /system/bin/ssd

adb shell chmod 777 /system/bin/amixer

adb shell chmod 777 /system/bin/alsa_amixer

Then run:

adb shell alsa_amixer contents

and:

adb shell amixer contents

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

For /dev/msm_snd devices I'm interested in the output from:

adb shell ssd 1 0

On my LG P500h I get:

Error opening device errno: Device or resource busy (16)

So then I run:

adb shell "killall mediaserver; ssd 1 0"

And then I get:

m1_do SND_GET_NUM_ENDPOINTS ioctl num_endpoints: 20

m1_do SND_GET_ENDPOINT ioctl snd_endpoint.id: 5 name: HANDSET_LOOPBACK

m1_do SND_GET_ENDPOINT ioctl snd_endpoint.id: 6 name: HANDSET

....

1_do SND_GET_ENDPOINT ioctl snd_endpoint.id: 10 name: FM_HEADSET

m1_do SND_GET_ENDPOINT ioctl snd_endpoint.id: 11 name: FM_SPEAKER

....

Most interesting are lines containing the letters "FM".

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

For /dev/msm_audio_dev_ctrl devices I'm interested in the output from:

adb shell ssd 3 0

Or if an error:

adb shell "killall mediaserver; ssd 3 0"

Most interesting are lines containing the letters "FM".

Some more "ssd 3 X" commands:

ssd 3 1 = FM Headset enable

ssd 3 2 = FM Headset disable

ssd 3 3 = FM Speaker enable

ssd 3 4 = FM Speaker disable

I wrote this code "blind" as I don't have such a device, so bugs are very possible.

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

For ALSA devices with/dev/snd/controlC0 try:

adb shell amixer contents

adb shell alsa_amixer contents

Most interesting are lines containing the letters "FM".

The utilities require a working ALSA library and config files etc. But the ssd utility should work even without libraries and ALSA config as it uses the ALSA Kernel API.

So run:

adb shell ssd 4 0

Please post the outputs you get. Thanks !
[Spirit FM] g4rb4g3:
Desire Z MIUI 1.6.24 /dev/msm_audio_dev_ctrl

alsa_amixer doesn't work

./alsa_amixer contents
reloc_library[1311]: 9635 cannot locate 'snd_mixer_first_elem'...
CANNOT LINK EXECUTABLE

amixer can't even start (the file is on the phone but I can't execute it)

C:\Users\g4rb4g3\Desktop\SpiritSound>adb shell amixer contents
amixer: not found

C:\Users\g4rb4g3\Desktop\SpiritSound>adb shell ls -l /system/bin | grep amixer
-rwxrwxrwx 1 root root 35300 Jun 29 05:36 alsa_amixer
-rwxrwxrwx 1 root root 41844 Jun 29 05:36 amixer

ssd, no lines contain FM

ssd 3 0
FM analog audio enable utility v11.06.29
Copyright (c) 2011 Michael A. Reid. All rights reserved.
Mode: "3" (3)
Func: "0" (0)
Opening device /dev/msm_audio_dev_ctrl
snd_fd: 3
dev_id_get_disp sizeof (struct msm_snd_device_info): 72 num_dev: 19
dev_id: 00 dev_cap: 0x00000005 dev_name:

dev_id: 01 dev_cap: 0x00000006 dev_name:

dev_id: 02 dev_cap: 0x00000005 dev_name:

dev_id: 03 dev_cap: 0x00000005 dev_name:

dev_id: 04 dev_cap: 0x00000006 dev_name:

dev_id: 05 dev_cap: 0x00000011 dev_name:

dev_id: 06 dev_cap: 0x00000005 dev_name:

dev_id: 07 dev_cap: 0x00000011 dev_name:

dev_id: 08 dev_cap: 0x00000005 dev_name:

dev_id: 09 dev_cap: 0x00000026 dev_name:

dev_id: 10 dev_cap: 0x00000025 dev_name:

dev_id: 11 dev_cap: 0x00000006 dev_name:

dev_id: 12 dev_cap: 0x00000005 dev_name:

dev_id: 13 dev_cap: 0x00000005 dev_name:

dev_id: 14 dev_cap: 0x00000005 dev_name:

dev_id: 15 dev_cap: 0x00000005 dev_name:

dev_id: 16 dev_cap: 0x00000006 dev_name:

dev_id: 17 dev_cap: 0x00000005 dev_name:

dev_id: 18 dev_cap: 0x00000006 dev_name:

Hope this helps ;)

EDIT: I played abit with ssd and I could get the speaker and the headset working:):):)

You wrote

but for me it's

ssd 3 1 = FM Headset disable
ssd 3 2 = FM Headset enable
ssd 3 3 = FM Speaker disable
ssd 3 4 = FM Speaker enable

IT WORKS :D:D:D It's so cool you made it possible, now you just have to wrap it together in the apk and everythings fine :)

EDIT2: I noticed that the "headset-less" mode doesn't work. So if you listen to the speaker and disconnect the headphones it will stop playing. It's not about the signal quality since it works for like 1-2 seconds without headphones. But then it stops.

EDIT3: Another bug is that while listening to the radio the phone doesn't ring if you get a call.

Even if you notice it and pick up you can't here anything and the other one doesn't hear anything too.

The only way to get it working again is to reboot the phone.
[Spirit FM] mikereidis:
Thanks a LOT g4rb4g3 ! Yes, amixer won't even start for me also, and alsa_amixer gives the same errors, due to the lack of ALSA library support.

It seems that even at the kernel level we can expect minimal ALSA support. Your "ssd 3 0" output shows no values for "dev_name", BUT the hexadecimal values for "dev_cap" shows bit 4 set (0x00000010 + 1) for "dev_id" 5 and 7. This is the SNDDEV_CAP_FM bit, so that's great. ALSA can likely be used as an alternative audio method on your Desire Z.

Good ! You found a bug in that enable and disable were swapped. Getting code working without prior testing on a real device is VERY difficult, so I'm very happy it's worked this well.

Re: "headset-less" mode, That is unusual and unexpected, I would guess that there is some code in your MIUI ROM that does this. It is likely code that is trying to be helpful by automatically switching from headset to speaker mode, but it's not switching for FM because it assumes it's switching for non FM modes.

If you can find a way to get sound working again using "ssd 3 X" commands without re-inserting the headset, then I should be able to re-initialize audio on a "jack unplug event". Sometimes before an enable, you'll need to disable one or both of speaker and headphone. Also, you could try powering up the app and running ssd AFTER the headset is removed.

Re: incoming calls. Could you also try placing a call when the radio is running ? I'd guess that doesn't work either.

Again, I think this is a MIUI related issue. AFAIK, calls are handled pretty well on other devices/ROMs. But I think that my code that detects an incoming or outgoing call could be modified to explicitly switch the FM audio path off and the normal paths back on. Hopefully that could work.
[Spirit FM] g4rb4g3:
I'm pretty sure all those issues come from MIUI since your app works great on CM on the same device.

But since i read this: http://miuiandroid.com/2011/06/fm-radio-support-for-defy-coming-this-week/

I'm not sure if we should try to fix those problems. It seems like they bring back FM support, not for Desire Z yet but as far as I know Nexus One and Desire Z are very close about the FM Radio. Before MIUI made an official Desire Z rom I ported the Nexus One rom to the Desire Z. And there the radio was working too. But since they switched to Android 2.3 they didn't support FM on any device anymore.

Maybe we should wait 1-2 weeks and see how far they have come with adding FM support back.

I'm pretty sure that your app would work too then.

I'll try outgoing calls tomorow when I'm back home but I don't expect them to work.

I tried different "ssd 3 x" modes to get my phone working as a phone again but I couldn't find any way. 2 times my phone just rebooted while executing a ssd command.

Only after a reboot the phone was ringing when I got a call.

It enough to just enable and disable speaker/headphones with ssd to block every noise from the phone except for FM radio.
[Spirit FM] Victorino86:
What buttons (the ones that move just for one step the frequency)? :D

I see 4: 2 for scan and 2 for moving 1 station, right?

Well, for me is just annoying :p , some times I don't have the headphones plugged in but i like messing around with the apps and when i open your radio i get hit with the damn white noise :D

Some radio apps won't open if there isn't a headset plugged, maybe you could put an option in the settings that allow to enter or not the app even without nothing in the jack. Or a disclaimer before starting the audio: "no headset plugged, loud white noise ahead, wanna go on and get some?" Y / N

:D

tried the antenna-less 'cause i read it in the thread ;)

Noted that while trying to find the right method.

This was just for MIUI? Because none of these are in my DesireZ
[Spirit FM] idkidk:
Hi Mike,

I've play with command:

alsa_amixer don't work

amixer don't start (the file is in the bin directory with 777 permission, but I can't execute it)

ssd 4 0 work, and there is only one line than contain FM:

elid name: FM Radio Path.

More result in attach.

Bye

Idk
[Spirit FM] bra1nDeaD:
Great app, thank you very much.
[Spirit FM] mikereidis:
Thanks for the link about MIUI FM Radio.

Absolutely we should get the MIUI problems fixed. I'm reasonably sure my app will always have some features the MIUI app won't. I don't think they have UART mode support that works with the BT off, and AFAIK they don't have RDS support, do they ? I've never run the MIUI app but expect to at some point.

Yes the Android 2.3 MIUI releases went back to the Broadcom proprietary BT stack I think. Perhaps they are moving back to the Bluez stack.

Yes, I wouldn't expect trying different "ssd 3 x" modes to fix the ringer problem. I proposed it as a possible workaround to the "remove headset/antenna" problem.

I'll respond to some of the other posts once I get my kids and I fed for dinner. :)
[Spirit FM] alspecial2007:
I am happy that there was help with the files I added, I hope you can find a solution I see very well together, thanks for the '

commitment
[Spirit FM] mikereidis:
Yes I removed the 2 that move one "channel", whether 50, 100 or 200 KHz as configured by Band Region. The thumbwheel provides the equivalent, more or less.

Yes, others have requested this option and I will implement it in due course. :)

[/quote]

For any that have those devices/device drivers. Different ROMs sometimes use different device drivers even for the same device/hardware. Makes my job challenging... :)
[Spirit FM] mikereidis:
One line may be all we need, especially when it has the very promising name of "FM Radio Path". :D

It's possible that is a digital path, unless the schematic was lying about no analog audio connection.

I'll try to get some ALSA controls implemented as soon as I can. Would be nice to solve the Galaxy Tab problem, even if we only got static and proved the antenna is not connected. (Not ideal for you though, other than learning.)

EDIT: I should have mentioned:

For ALSA, if you have multiple files /dev/snd/controlC*, such as /dev/snd/controlC0 and /dev/snd/controlC1 (0=Zero and 1=One) and perhaps even /dev/snd/controlC2 etc., it's best if you can get output for each device like so:

adb shell ssd 4 0

OR the equivalent:

adb shell ssd 4 0 x /dev/snd/controlC0

AND

adb shell ssd 4 0 x /dev/snd/controlC1

adb shell ssd 4 0 x /dev/snd/controlC2

Thanks !
[Spirit FM] mikereidis:
Does anyone know of a reason why someone with 0 posts can't post in this thread ? I've seen some low post counts here, even first post, but something might have changed.

The top heading is "Android Development and Hacking", but under that is "Android Apps and Games" and AFAIK anyone with an account can post here.

Unless it's confidential or of no interest to anyone else, I prefer that people post questions here for the benefit of all instead of PMing me.

Thanks !
[Spirit FM] mikereidis:
I received a question about whether the app works on Samsung galaxy I5700 spica, with bcm4325.

I've found no such reports, but think it should, assuming you have a working hcitool or are rooted for UART mode with BT off. There may be the no audio problem but I'd hope that is solved now or in near future with one of the new Audio Methods.

This command was run:

adb shell hcitool cmd 3f 15 0 0 1

< HCI Command: ogf 0x3f, ocf 0x0015, plen 3

00 00 01

> HCI Event: 0x0e plen 6

01 15 FC 00 00 00

The command above appears successful in writing a "1" to the Broadcom FM power register, which should power it on, albeit without RDS.

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

The command below reads the power register and shows results with power off, IE before the command above was executed:

a hcitool cmd 3f 15 0 1 1

< HCI Command: ogf 0x3f, ocf 0x0015, plen 3

00 01 01

> HCI Event: 0x0e plen 7

01 15 FC 00 00 01 00

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

The command below reads the power register and shows results with power ON, IE after the power on command (the first) was executed:

a hcitool cmd 3f 15 0 1 1

< HCI Command: ogf 0x3f, ocf 0x0015, plen 3

00 01 01

> HCI Event: 0x0e plen 7

01 15 FC 00 00 01 01

Note the only difference is the last byte which is the "1" we wrote to the power register in the first command.

If the app doesn't seem to be working, I need to see the results text file from a command like the following, started before the Spirit FM app is started. At some later point, enter Ctrl-C to abort the results collection and post or send me the results.txt file:

adb logcat > results.txt

Also, when the app starts the display should show a debug line starting with "Fm:" and I need to see that also.

Thanks !
[Spirit FM] Rage2:
mikereidis!!! It works! (v110626.apk) at Wits A81G.!!! Good work! Mike! :)

But only RDS signal...no sound (Config Audio Method!)

Attach log "ssd 4 0"

Thanks ! )))))))

PS\\ I soldered on-board antenna of two wires ....

Edit: add "alsa_amixer contents" log
[Spirit FM] idkidk:
Hi Mike,

adb shell ssd 4 0 x /dev/snd/controlC1

give me the same result as C0, C2 not exist.

TIA!

Idk
[Spirit FM] mikereidis:
v11.06.30 is now available on the Market. EDIT: Not showing up yet (?) so it's available here also: http://www.mediafire.com/file/dby25uw1xc57pg4/Spirit_FM_Radio_v110630.apk

- App will now act as fully unlocked with no ads and full functionality for seven days after first installation.

- Spirit FM Radio Unlocker restores full functionality and no ads past the 7 day limit.

- Various audio fixes and additions including:

- Support for /dev/msm_audio_dev_ctrl audio devices via qdsp5v2 Audio Method.

For audio testing, the latest ssd utility can be found at /data/data/com.mikersmicros.fm/files/ssd after installation.

For testing it may be convenient to run this command, otherwise an old ssd might be used when you run "adb shell ssd ...":

adb remount

adb shell cp /data/data/com.mikersmicros.fm/files/ssd /system/bin

The ALSA information has been enhanced and includes current values of controls. The command:

adb shell /data/data/com.mikersmicros.fm/files/ssd 4 0

ALSA controls can be changed now. For example, the info command returns this:

cei count: 1

elid numid: 3

elid name: PCM Playback Volume

cei iface: 2 Virtual Mixer

cei access: 0x13 rd,wr,tr

cei owner: -1

cei type: 2 Integer

cei min: -50

cei max: 16

cei step: 0

Values: -50

To change the current value of -50 (the minimum) to the maximum of 16 run:

adb shell /data/data/com.mikersmicros.fm/files/ssd 4 1 3 /dev/snd/controlC0 16

The "3" came from the "elid numid:" value.

Binary values such as switches can be set to 0 for False or 1 for True.

Enumerated values can be set to 0 for first value etc.

More info and ideas to come. AFAIK this is the first and only publicly available Android ALSA control utility that works with the kernel API. Normal ALSA library APIs do not seem to work on most phones supporting "ALSA".
[Spirit FM] mikereidis:
Not really. I give up & have no further suggestions.
[Spirit FM] mikereidis:
Recording is intended to work with analog audio methods, at least low level ALSA based methods. It's worked for me during my tests on CM10.1, but those tests were a month or more ago, and I do little testing of this now.

Recording should ALWAYS work with digital audio methods. If the sound is hearable on speaker or headset, then recording is pretty much guaranteed to work. The same data written to Android audio APIs is also written to the output file.

Someone else has reported no speaker output but I haven't been able to reproduce that problem.

Removing and installing a wired headset plug while FM is playing digitally is known to cause some issues.

For problems that leave audio hardware in a bad state there is a brute force fix that resets all Android audio. Enable Debug-> Power Restart Media and the reset happens when FM is turned off (but not when muted or during an interrupting phone call etc.)

At this time my best responses for digital audio problems remain:

- It's still "experimental" and, based on the many problem reports I've had and my limited time, will likely remain experimental at least until the fall of this year.

- Different ROMs and kernels will give different results. I do most testing on CM10.1 with the stock CM10.1 kernel and pretty much every setting at defaults. So far I also don't test on phones with many apps running and with CPU time and memory in short supply.
[Spirit FM] lavemetoo:
anybody, who made it run under [ROM][Jellybean 4.2.2][JDQ39E] ThinkingBridge ROM [I9100][Apr 24,2013][Stable 1] ?

http://xdaforums.com/show...4#post40875684

I went back to ROM stock kernel 3.0.31-CM and upgraded Spirit FM from oder version to 0421fr.apk.

Now FM is working like a charm, due to whatever. :victory:

Germany settings:

Band: World 50 KHz

Audio Method: Galaxy S2/Note ALSA

All other things: Default
[Spirit FM] boggie81:
I did a full wipe and installed the latest CM 10.1 stock nightly. Unfortunately the same issues persist.

I do remember that a couple of months ago recording did work on analogue mode

At this point, neither mode is fully usable. In analogue, recording doesn't work, while digital mode breaks the microphone, without me messing around with plugging the headset in and out while FM is playing.

Even with these little hiccups, it does give us FM on custom roms, and that's good enough for me.
[Spirit FM] mikereidis:
"Where has all the FM gone ? Gone to streaming, every one ?"

Post 6000. :)

Samsung, Motorola and LG all seem to be removing or disabling FM on recent high end / flagship devices.

The ST-Ericsson proposed Android FM API continues to go nowhere after more than 2 years, and ST-Ericsson seems to be imploding.

And the much bally-hooed Sprint deal with US broadcasters to enable FM on 30 million smartphones in the US doesn't seem to be going anywhere fast either.

Someone such as myself, whose only income is from an OTA FM app, has got to wonder if the writing is on the wall.

Even if lower end phones still have FM, logic and experience dictate that high end phone owners are MUCH more likely to buy apps such as Spirit.

I'm pretty sure there's at least 1 year of life left in Spirit. As time goes on, more and more GS1, GS2, GS3 etc. owners will be installing custom ROMs, so there's a long tail effect I think.

But I have to keep my eyes open to what's going on, and consider what other or related app areas I might need to eventually transition to. Audio related makes sense.

At least 1 more year of life means that I'll have good time to get the bugs out of digital audio modes, and there are still many new features to come.

Since I'm not getting a GS4 this year, I'm considering an Xperia Z or HTC One or similar. The former is getting an AOSP, but Sony might abandon that after a year like they did for Xperia S.

HTC One seems to me better and will sell better, despite some issues with bootloader locks and less info from HTC. I see many more threads for HTC One than Xperia Z.

Strange thing though is that I've had very few queries about either phone yet, despite a few sales.

FreeXperia, the "CM variant" for Sony devices, has a working open source FM app; the first and only CM FM app since the GB days. So, I expect few sales on Sony's.

Maybe I won't even get a new phone this year. If I do it will likely be the HTC One, or a similar device, like the lesser M4.

But, if Spirit works reasonably well on the HTC One without me getting one, and/or if demand is low enough, I may not get a One or any phone at all this year.

In a way it will be nice to concentrate on the very popular phones I already have, instead of constantly having to reverse engineer and make fixes for new devices.
[Spirit FM] mikereidis:
"Galaxy S4 = No OTA FM: In with a bang, and out with a whimper."

There is no usable FM, on the GT-I9500, or Qualcomm S4s such as T-Mobile SGH-M919 or Vodaphone UK GT-I9505. :(

I examined Spirit debug logs from a rooted Indian GT-I9500, T-Mobile SGH-M919 & Vodaphone UK GT-I9505.

Spirit appears to work, as it does on so many devices with no usable FM, but RSSI is always 0 on GT-I9500, and on SGH-M919 & GT-I9505 it was 0 or -17.

This is on the Broadcom BCM4335 FM/combo chip that all S4 variants have. The FM antenna pin is likely grounded / disabled and unusable.

And, other than a tiny clue in the kernel source, there's no indication of a dedicated FM chip on the PCBs, like the SI470x chips on previous International GS1 / GS2 / GS3 / Player / Note / Note2.

Hypothetically, there could be a dedicated Silicon Labs FM chip, or the PCB space and traces for it, hidden on the GT-I9500 PCBs. But Samsung would be crazy to waste a dollar on a dedicated FM only chip when FM is not officially supported. Even if there was a space for a chip.

Hypothetically, FM might just be missing, or disabled, in the bcm4335.hcd "patchram, almost firmware" kind of file. But I've never seen this happen before.

Hypothetically, there could be a software controlled switch somewhere that magically connects the FM antenna pin to headset, but I've never seen this before either.

So, I consider this case closed, for now at least, unless someone comes up with some interesting new observations.

My predictions were wrong, whatever, keeps life interesting and educational. :)

EDIT: May 20:

I had thought the existence of FM specific voice command text in ROM dumps indicated that FM was planned at some point.

But the GS3 GT-I9300 has voice commands in the latest stock JB leaked ROM, and it includes support for FM. See http://xdaforums.com/show...postcount=6078

...

I will be interested to eventually see the service manual schematics. Like those for the Nexus4 and Optimus G, I wouldn't be surprised to see evidence that an FM antenna connection to the BCM4335 had been planned, then scrapped. Then again, the kernel GPIO symbols imply an SI470x dedicated FM chip, so the schematic might show some dangling connections for that.
[Spirit FM] SamsungPisser:
Yes there are some services in my country that use frequencies a bit out of the default channel range. Thanks for the hint with direct entering the frequency. What happens if 1 kHz increments are not supported? Is there no receiving at all or is there rounded to the next frequency? I have Galaxy S3 unbranded, how to I find out the chip of my device? It would be great if you could make a debug option for 50 kHz in the Japan frequenc range and even 1 kHz (if supported by current chip).