yashsingh1/xdaforums huggingface dataset:
[Spirit FM] psyke83:
Mike,

I noticed something interesting re: the I5500, that could possibly be related to the FM radio.

The regular Bluetooth device is /dev/ttyHS0, but I noticed that /dev/ttyHS1 also exists.

If I run "hciattach /dev/ttyHS1 any", it sets up the hci connection properly ("Device setup complete"). Trying to use it as a regular Bluetooth device in Android doesn't work, however. Maybe it's a simple hci device that only deals with FM commands? Am I barking up the wrong tree here, or is there anything I can do to help discover if it's important?

Edit: maybe it's not really a Bluetooth device...

conn@virtual:~/Desktop/system-images/system-jpe2$ adb shell hciconfig
hci0:	Type: BR/EDR Bus: UART
BD Address: E1:28:18:EA:4F:18 ACL MTU: 1021:8 SCO MTU: 64:1
UP RUNNING PSCAN
RX bytes:2232 acl:0 sco:0 events:88 errors:0
TX bytes:5040 acl:0 sco:0 commands:89 errors:0

hci1:	Type: BR/EDR Bus: UART
BD Address: 00:00:00:00:00:00 ACL MTU: 0:0 SCO MTU: 0:0
DOWN
RX bytes:0 acl:0 sco:0 events:0 errors:0
TX bytes:4 acl:0 sco:0 commands:1 errors:0
[Spirit FM] mikereidis:
I don't recall the requirements that need to be met for hciattach to be successful. Do the kernel sources offer any clue as to whats on HS1 ?

AFAIK, Broadcom chips only have one real HCI UART interface. There IS however an I2S and I2C interface specifically for FM only; it shouldn't work for Bluetooth.

This interface offers the possibility of FM control through a different channel than the Bluetooth HCI commands. But AFAIK there aren't any smartphones that connect these pins anywhere.

The G5 service manual, page 52 of 56 shows the U201 Combo chip. The 3 I2S pins and 2 I2C pins appear unconnected. But the schematic might be lying.

It could also be a USB or GPS or sensor etc. device that supports simple HCI packets. Some Broadcom combo chips support GPS, if I recall.

Here's a way you can see if it responds to FM commands with my app in UART mode:

mkdir /data/data/com.mikersmicros.fm/files/opt/

mkdir /data/data/com.mikersmicros.fm/files/opt/uart/

touch /data/data/com.mikersmicros.fm/files/opt/uart/custom

echo /dev/ttyHS1 > /data/data/com.mikersmicros.fm/files/opt/uart/device

logcat messages should indicate what level of success or failure was achieved.

There are things like patchram that might fail when sent through an FM only interface, but I could create options to disable them if this looks promising.
[Spirit FM] _wyrm:
/dev/ttyHSX aren't HCI devices. They are serial devices. HCI is implemented as a LINE DISCIPLINE in the kernel, HCI isn't exposed as a /dev/whatever device.

"hciattach /dev/null any" should probably also work with the test you made. ;)
[Spirit FM] mikereidis:
Yes, perhaps both subpsyke and I aren't using the term HCI as you would. I think what I meant instead of "HCI device" was something more like "a serial device over which HCI like packets can be exchanged, or with which an HCI like interface can be created".

Does that sound better ? AFAIK, the HS stands for "High Speed".

# hciattach /dev/null any

Can't get port settings: Not a typewriter

Can't initialize device: Not a typewriter

# hciattach /dev/tty9 any

Device setup complete

# hciattach /dev/ttyFIQ0 bcm2035

Initialization timed out.

# hciattach /dev/ttyFIQ0 any

Device setup complete

# ps | grep hciattach

root 859 1 1688 268 c015fbc0 afd0c63c S hciattach

root 875 1 1688 268 c015fbc0 afd0c63c S hciattach
[Spirit FM] mikereidis:
version August 24 is now on the Market: https://market.android.com/details?id=com.mikersmicros.fm&feature=search_result

Please update and let me know how it's working. I will be vacationing within 36 hours and hope to catch and fix any major bugs before then.

Re: Galaxy S:

- I hope the audio is more stable on CM7 now. I'm not sure if phone calls still cause audio issues. It appears I need to install a Radio/Modem that supports Bell Canada.

- Various fixes included. Very little changed for Broadcom and TI phones.
[Spirit FM] mikereidis:
"Competitor" alert. Hello Sutton Shin... :)

Edit: It's a clear ripoff of the Motorola app and I've reported it. See next post. I'll leave my original post below, but it's boring reading unless you want to know...

I'd hate that anyone would think I'm starting a war, but I think the "other side" has fired the first shot, with this comment added for my free app:

Now I can see this comment in my developer console, but I'm not sure anyone else can see it as a review. Maybe you can, I don't know.

I put "competitor" in quotes because I noticed that the app name is com.motorola.fmradio . So I'm assuming this is just the Motorola app re-packaged. I reported it as a copyright violation.

But I have to admit it's technically possible that name is used to allow use on unrooted Motorola phones. So if I'm wrong, I apologise.

I couldn't see this app in the Market on my LG P500.

I purchased this app and tried to install it on my HTC Legend. It failed with a package signature verification error. I later realised that this was likely because I already had the Motorola app on my phone, with that same name, and the signature was different because the dev didn't have the Motorola key of course.

I can't find anything on this Sutton Shin dev or his app anywhere. If anyone has any further information, please share.

I sincerely hope this doesn't turn into anything worse than it is right now. Sutton Shin, please show me the same civility I've shown you. If I've jumped the gun by assuming you've re-packaged commercial software, I am sorry.

:)
[Spirit FM] mikereidis:
Nope. It's a clear ripoff of the Motorola app.

Once I removed the real Motorola app, it installed, but of course stalled at startup because my HTC Legend is not a Motorola device.

a ls -l -R /data/data/com.motorola.fmradio

/data/data/com.motorola.fmradio:

drwxrwx--x 1 app_65 app_65 2048 Aug 24 05:43 databases

drwxr-xr-x 1 system system 2048 Aug 24 05:43 lib

/data/data/com.motorola.fmradio/databases:

-rw-rw---- 1 app_65 app_65 5120 Aug 24 05:43 FM_RadioDB.db

/data/data/com.motorola.fmradio/lib:

mike@v:/a/Documents/cell/workspace/shin$ l src/res/drawable

total 432

-rw-r--r-- 1 mike mike 2708 2011-08-24 05:46 fm_autosearch_plus_disable.png

-rw-r--r-- 1 mike mike 1077 2011-08-24 05:46 fm_autosearch_plus_enable.png

-rw-r--r-- 1 mike mike 2772 2011-08-24 05:46 fm_autosearch_reduce_disable.png

-rw-r--r-- 1 mike mike 1131 2011-08-24 05:46 fm_autosearch_reduce_enable.png

-rw-r--r-- 1 mike mike 3622 2011-08-24 05:46 fm_background_button.png

....
[Spirit FM] FadeFx:
Audio method for Samsung phones is missing in market version...

Also debug line starts with FM:BC

Edit: Huh, seems i just was too fast...

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

tapatalked
[Spirit FM] pirrera:
Here is what i noticed in Galaxy S with CM7:

-Turn on the Spirit FM and listen radio.

-Turn off an make a phone call (everithing OK)

-Turn Spirit on again and cant hear a thing

-After this, if i make more phone calls, some time i cant hear, some time i can - maybe random -

Ive tried kill the active processes and one of them give me back the radio sound: DSP Manager - till the next time a make a call.

But after a while, all the SGS sound go away and the only solution is reboot.

Im not a developer and cant give you better description, but hope this can help in any way.
[Spirit FM] mikereidis:
Yes, Market updates are pretty quick, but not instant. Perhaps 5-20 minutes.

I'll try not to announce before I verify the new version is available.
[Spirit FM] mikereidis:
I've spent some more time trying to figure this out. Seeing your video I think I now understand that by "75 on the preamp output" you mean you set the Volume Scale option to 75%.

The only thing that reducing Volume Scale below 100 does is to scale down the volume value sent to the FM chip registers. It won't really fix overdrive issues if they are happening at the TI audio chip input amps.

I think that these log lines likely indicate the gain value we want to reduce:

07-11 09:23:48.062 1161 1258 D AudioHardwareMot: Read FM Gain 0xb for output path 0

07-11 09:23:48.062 1161 1258 D AudioHardwareMot: Writing b0000 to SOUND_MIXER_FMPATH

I have a theory that if we could get log output that said "FM Gain 0x1" then this issue may be resolved. The default of 0xb (11 decimal) may be too high. I could easily be wrong about this though.

Google searches for SOUND_MIXER_FMPATH produce almost no hits. Searches for a line like this:

D/AudioHardwareMot( 1533): doRouting devs: stereo 0, mono 0, input 0. Chose speaker None (gain 0xb) mic None (gain 0x1c1c)

produce more hits but it appears the second gain value is always 0x1c1c. I wonder if the library might be producing the right messages, but the kernel driver doesn't properly set mic/FM input amp gain...

Can you point me to the kernel source used on CM7 ?

I note there is a device named /dev/snd/mixer that may help resolve this issue. But the mixer name indicates it is not ALSA, but the OSS predecessor that is now almost unused on Linux. This might be our best bet for reducing the input gain.
[Spirit FM] mikereidis:
Re: CM7 on Motorola Droid X:

OH ! OK... I was most concerned about headphones, as I think that's what most people use, and it's really the only way to get decent audio.

But I've been surprised to see how many people use the speaker mode. I've been thinking I could support left or right selection, and with 2 phones, you'd have stereo... LOL.

If this was an input amp gain issue, then I'd think the gain was automatically increased when switching to speaker. But I'm not convinced that is what is happening, so perhaps it's just something to do with speaker gain or some other speaker setting.

I'm getting a similar REALLY bad speaker distortion issue on the Samsung Galaxy S, but it's a completely different device.
[Spirit FM] FadeFx:
Mike, you should find your desired modem here : http://xdaforums.com/showthread.php?t=1158783 look for kc1 modem...

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

tapatalked
[Spirit FM] mikereidis:
EDIT: Pause/Play/Pause/Play (4 presses) is another workaround. I added this sequence to my app and it seems to work OK. I'll try to post a new version with this fix in the next 12 hours.

Thanks. I'm using the modem here now and it seems to work well: http://dl.dropbox.com/u/12945191/radio-cm-7-GalaxyS-KG3-signed.zip

I found this August 11 post here and it seemed to be a pretty good vote of confidence by ceribik regarding chambo622's pointer:

http://xdaforums.com/showpost.php?p=16543930&postcount=14322

These Canadian phones almost always seem to be a bit different. :D

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

I just tested FM with a phone call on GalaxyS CM7. The FM mutes OK, but doesn't return after the call ends. Power cycling my app seems to fix it, but Pause/Play or Speaker/Headset don't. I will find out why and fix it.

I had the Music Player running with the FM. They can both play at the same time and mix together (which isn't useful except as a test). I had the player on pause and after the phone call, the play button worked as expected.

Just for reference, my app still plays a sound in the normal digital way in order to keep the audio path from shutting down after 4 seconds. I'm not using tones anymore though. I am playing a FLAC file with 30 seconds of silence, and restarting it every 30 seconds. I found the FLAC file only adds about 5% to CPU utilisation, better than mp3 or ogg. I hope to find a better way.
[Spirit FM] mikereidis:
Apparently there are some Android devices with a working FM transmitter.

The Sharp IS01, IS03, and IS05. AFAIK these are the only Android devices supporting FM transmit. (The hardware is designed for this. AFAIK no other Android devices have the hardware/PCB connections.)

I hardly even noticed Sharp was in this market. Perhaps more popular in Japan ?

Here's an FM transmit app for those Sharp phones only:

https://market.android.com/details?id=funa.fmtransmitter

The app is free but I can't download it to any of my phones, and I don't see it for download anywhere. I'm just curious to take a quick peek at it.

If anyone has further info or knows how I can get the APK, please share.
[Spirit FM] F_R_I_T_Z:
CM7 galaxy s.

Nice, really nice. Actually seems spirit work better the one cm7 in galaxy night build.

Thank you...

Exchange your expertise with Teamhacksamsung can be a good thing..

Maybe to use spirit by default or something like this.

thank you again.
[Spirit FM] xmguy:
Mike,

Is there a way to change the antenna path location in the sw for Spirit to use the phone/pcb ground as a rf antenna? I'm not sure if Motorola used a direct antenna trace to the headphone ground. I'd just like to beable to use the app without headphones and have fair signal. I know your app has a cmd to bypass the headphone jack requirement. It may be like the Droid 1 which I had that didn't have an FM antenna trace on the board. Then again I'm not sure if using the phone ground would even be possible because of the general em noise. A dedicated rf lead would almost certain be needed. Also has there been any more info on FM TX for the Droid X and on? I would think if it can receive it could also transmit too. I've read that the TI WL supports FM RX AND TX. I figure it would/could use the same trace paths. Have a simple circuit path switch to go between the modes to use the same paths. Just wondered though. I have some electronics knowledge and can work my way around simple script commands. Linux is a bit more complex it seems. But what what else can the TI chip do for the FM app?

I also read your early work with the HTC legend. Bravo sir!
[Spirit FM] mikereidis:
Wonderful... :D There was born my realisation how passionate so many people were about getting old school airwaves on their digital devices. AND how hard it was to do that...

Not that I'm aware of. TI chips have a WL1273_RX_ANTENNA_SELECT register but it does nothing for me writing various values, and anyone else who I've had try it. Some devices might have some special switch for some reason or another. When I ran this command:

adb shell strings /system/lib/libbluedroid.so| grep -i antenna

I got this response on one of my devices:

set_fmtx_antenna

check_fmtx_antenna

set_fmtx_antenna(%d)

which implies there might be something there. (But I note it seems for transmit.)

I've looked at various Samsung schematics and the LG P990 schematic and they all seem to show two receive antenna pins: RXP and RXN. One of them, likely RXN, goes to A ground via coils/caps or whatever. I guess the other goes to the headset ground. So I think the standard practice is to do what you propose. IE, this might be as good as it gets.

My impression is that Broadcom chips are better with weak signals, but that may be partly due to the aluminum body of the TI based HTC Legend.
[Spirit FM] xmguy:
I ran the BT script in ADB. Got this back. Again my cmd knowledge linux especially is VERY limited.

C:\>adb shell

# su

su

# strings /system/lib/libbluedroid.so| grep -i antenna

strings /system/lib/libbluedroid.so| grep -i antenna

# strings /system/lib/libbluedroid.so

strings /system/lib/libbluedroid.so

str2ba

strtoul

__aeabi_unwind_cpp_pr0

ba2str

sprintf

snprintf

open

__errno

strerror

__android_log_print

read

close

memcmp

asprintf

__stack_chk_fail

__stack_chk_guard

socket

bt_is_enabled

ioctl

write

bt_disable

property_set

usleep

bt_enable

sleep

__cxa_finalize

__dso_handle

__INIT_ARRAY__

__FINI_ARRAY__

__exidx_start

__exidx_end

__data_start

_edata

__bss_start

__bss_start__

_bss_end__

__bss_end__

__end__

_end

_stack

liblog.so

libcutils.so

libc.so

libstdc++.so

libm.so

libbluedroid.so

yDEx

O/L0I

|D/O0N

@!:F+F@F

!I!JyDzD

PF1F "

`yD*F

-M}D-h

!}D(h

!I!JyDzD

JyDzD

JyDzD

IjF,

1 0

}D-h

!}D(h

JyDzD

JyDzD

'L'J

|D'MzD!F

%I}DyD(F

!FzD

!FzD

I(FyD

4 Fp

/J|DzD!F

-H.IxDyD

!FzD

KyDzD{D

J}DzD)F

IxDyD

)FzD

60Fp

bt_enable

%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X

/sys/class/rfkill/rfkill%d/type

bluedroid

open(%s) failed: %s (%d)

bluetooth

/sys/class/rfkill/rfkill%d/state

open(%s) failed: %s (%d)

read(%s) failed: %s (%d)

Failed to create bluetooth hci socket: %s (%d)

open(%s) for write failed: %s (%d)

write(%s) failed: %s (%d)

Stopping bluetoothd deamon

ctl.stop

bluetoothd

Error stopping bluetoothd

Stopping hciattach deamon

hciattach

Error stopping hciattach

Starting hciattach daemon

ctl.start

Failed to start hciattach

%s: Timeout waiting for HCI device to come up

Starting bluetoothd deamon

Failed to start bluetoothd

gold 1.9A1

aeabi

ARM v7

.data

.rodata

.shstrtab

.dynamic

.hash

.dynsym

.note.gnu.gold-version

.rel.dyn

.dynstr

.ARM.attributes

.bss

.rel.plt

.got

.text

.ARM.exidx

.fini_array

.init_array

PRE

#
[Spirit FM] xmguy:
yeah don't misunderstand me. Your app is way cool now. I just thought maybe more untapped functions are on the horizon. I guess however TX isn't possible. With all that is going on in a phone it's a wonder FM RX works it all. Even with it on a different frequency all the RF devices in the phone generate RF.
[Spirit FM] mikereidis:
bluedroid is just one place functions can be hidden. For a more comprehensive search:

strings /system/lib/* | grep -i anten

strings /system/bin/* | grep -i anten

strings /system/xbin/* | grep -i anten

These are the commands for TI chips that I tested for transmit. Turn Bluetooth on and then enter these commands at the ADB shell prompt, and see if you can detect any carrier in the area of 88.5 MHz:

(But first, consign yourself to the possibility that it might damage any good Tx circuitry in the chip that might be grounded or otherwise improperly connected.)

It's best to copy and paste of course. Anything starting with "#" is just a comment or commented out code.

# FM_POWER_MODE: FM Core power up (0=down)

adb shell hcitool cmd 0x3f 0x137 0x01 0x01

# FM_WRITE: WL1273_PUPD_SET: PUPD_SET_ON (Tx On)	This is equiv to POWER_SET for Rx

# Always get error 3 first time, Yeah, some commands require waiting for completion. Not sure if hcitool can do that.

adb shell hcitool cmd 0x3f 0x135 0x5b 0x02 0x00 0x00 0x01

# FM_READ: CHANL

adb shell hcitool cmd 0x3f 0x133 0x37 0x02 0x00

# FM_WRITE: CHANL_SET, 87.55 MHZ (code shows freq in KHZ/10 !?), so 1 = 10 Khz & 65535 = 655.35 MHhz ?

#adb shell hcitool cmd 0x3f 0x135 0x37 0x02 0x00 0x00 0x01

# FM_WRITE: CHANL_SET, 88.0 MHZ (code shows freq in KHZ/10 !?), so 1 = 10 Khz & 65535 = 655.35 MHhz ?

adb shell hcitool cmd 0x3f 0x135 0x37 0x02 0x00 0x22 0x60

sleep 3

# 88.5 Mhz

adb shell hcitool cmd 0x3f 0x135 0x37 0x02 0x00 0x22 0x92

# FM_WRITE: POWER_ENB_SET: 1	Use after setting chan

adb shell hcitool cmd 0x3f 0x135 0x5a 0x02 0x00 0x00 0x01

sleep 3

#Convert the dBuV value to chip presentation. Default = 4, so def pwr = 118 ?

# FM_WRITE: WL1273_POWER_LEV_SET,	this = 122 - power

#adb shell hcitool cmd 0x3f 0x135 0x3b 0x02 0x00 0x00 0x01

# Get the TX tuning capacitor value.

# fm_read_reg	READ_FMANT_TUNE_VALUE

# Set Tx pre-emphasis

# fm_write_cmd	WL1273_PREMPH_SET, em

# !!!!!!!! STOP HERE or transmitter will turn OFF !!!!

# FM_WRITE: POWER_SET: POWER_SET_OFF (Rx off)

adb shell hcitool cmd 0x3f 0x135 0x20 0x02 0x00 0x00 0x00

# FM_WRITE: PUPD_SET: PUPD_SET_OFF (Tx Off)	(Or PUPD_SET_RETENTION = 0x10)

adb shell hcitool cmd 0x3f 0x135 0x5b 0x02 0x00 0x00 0x00

#For Suspend Rx could go to POWER_SET_RETENTION	(1 << 4)

#Can't go from OFF to RETENTION
[Spirit FM] xmguy:
Do I enter everything that has a # beside it? Some just seems like instructions. Also you said this could damage the TX circuitry. How bout the phone it's self or the FM RX circuitry?
[Spirit FM] KSTu:
hi! in my country does not work! pls add romania in regional band!
[Spirit FM] App Critic:
you jumped the gun, mike reid

i andrew wrote the comment. not Sutton Shin. sorry sutton:)
[Spirit FM] xmguy:
Hello Fellas! Please support this app by BUYING A COPY. (I AM promoting the app, NOT PAID or ASKED TO ENDORSE THE APP). This dev works day and night working on this app and NEEDS support from users. If you like the app BUY it. Also CONSIDER DONATING to the dev. mikereidis

xmguy
[Spirit FM] xmguy:
@ KSTu ... You might beable to use the app in world mode. It has 5 Khz stepping.
[Spirit FM] mikereidis:
Thanks xmguy. But I don't really like the donation model.
[Spirit FM] mikereidis:
You can. They are comments so they won't change anything.

I think damage is unlikely. I just want to cover my a** if anyone tries it and thinks something broke.
[Spirit FM] mikereidis:
As xmguy said, try "World" for 50 KHz channels. Or "Europe".

There is almost no difference between the settings outside North America/US/Mexico.
[Spirit FM] mikereidis:
ALERT/WARNING: IF YOU HAVE A GALAXY S !!!

Do NOT run my app, nor the CM FM app. I think that permanent speaker damage may be possible !!! See this post for further details:

http://xdaforums.com/showpost.php?p=17000575&postcount=1055

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

EDIT: Version August 27 is the last before I come back from a 4 day vacation on Tuesday: (It is also on the Market)

http://www.mediafire.com/file/619kuf1zzsduonz/Spirit_FM_Radio_v110827.apk

See the next post for Galnet MIUI on Samsung Galaxy S.

There are only two small differences between this and the latest August 24 version on the Market:

- For Galaxy S, when a phone call terminates, the app effectively does Pause/Play/Pause/Play (4 presses) to restore FM audio. Hopefully a more elegant method can be found. This works on CM7; I'm not sure about other ROMs such as MIUI.

- To help debug or fix audio issues such as overdrive, Volume Scale settings less than 1.0 can be tried. This sets the FM chip volume to a fixed value and allows the ROM to set speaker/headset output amp volume itself.

After setting Volume Scale in Menu->Settings, you must change the volume with the phone hardware volume buttons. Here are some values and the resultant FM chip volume:

0.5 - Full volume

0.4 - 50% of full volume

0.3 - 25%

0.2 - 12%

0.1 or less - 6%
[Spirit FM] mikereidis:
For Galnet MIUI (ONLY!) on Samsung Galaxy S:

I loaded this ROM last night, and got far enough to find an experimental workaround. It appears the MIUI audio libraries don't support FM audio routing like the stock and CM7 ROMs do. Some trickery is required, and it results in "Chipmunk Music" in the Player.

I hope to support this ROM much better when I have time to do so. Unfortunately, there seems to be no desire at present by the Galnet MIUI devs to support FM audio routing.

(1) - Set my apps' Audio Method to SamsungCM7 in Menu->Settings.

(2) - Ensure headphones are plugged in as an antenna.

(3) - Tune to a strong frequency. The RSSI number at upper left should show at least 15-20 or so. Hopefully you see RDS data.

(4) - ABSOLUTELY NEEDED: Do a full cold reboot.

(5) - Start the Music Player and play something. Leave it running to the headphones and start my app.

(6) - Hopefully now you will hear both the Music Player and FM audio mixed together. If not you can try toggling Pause/Play and Speaker/Headset, several times if necessary. If all else fails, try power-cycling my app.

(7) - You can now return to the Music Player, hit pause and/or otherwise stop the Music. Hopefully you will hear FM audio clearly.

(8) - Enjoy the music.

(9) - Purchase my Unlocker app for good karma, better capabilities and to keep me interested in this ROM. :)

Once the above is done, you should be able to start and stop my app at will, as well as Pause/Play and Speaker/Headset.

Audio for other apps may not work without a cold reboot or two.

Please note that if phone calls are important to you, you should test what happens when you make, or answer a call when FM is active, as well as after FM has been switched off.
[Spirit FM] pirrera:
Here you go.

I get it from here:

http://androiddev.orkitra.com/download/apps/?appid=3780183963877946355

Regards.
[Spirit FM] mikereidis:
Thanks ! It seems corrupted in your origin, but your attachment is good.

There's nothing to this app. All it does it send a "jp.co.sharp.android.FMtransmitter.FMtransmitter" Intent.

So all it does is launch something already in the stock ROM.