yashsingh1/xdaforums huggingface dataset:
[Galaxy S I9000 General] miki4242:
(shamelessly crossposted from General forum):

There is yet hope the FM radio is stereo!

At least in the mid-level drivers there is evidence of stereo support.

For the techies out there (taken from stock JF3 ROM):

$ nm -CD lib/libfmradio_jni.so | grep -i stereo
000030d9 T FmRadioController::SetStereo(unsigned long)

There you have it, no denying it. I only hope this isn't yet another example of something Samsung left in when there is no actual hardware support for it...

Strangely, the FMRadio app doesn't seem to call this method at all.

edit: using some toolz, saw that there is actual code there, poking at real hardware (well, sending an ioctl up to the kernel anyway). No disappointing empty stub, so the news just got better!

edit: Anyone know more about Java than I do (it wakes me up in the morning, and my Mom was born somewhere over there) who could write an app so we can twiddle this thing and see what it does?
[Galaxy S I9000 General] cba1986:
That it's up to you. You can believe what you want.

That are good news, if you need a hand. Don't hasitate.
[Galaxy S I9000 General] cba1986:
In that point you are right. I can only hope that this is a soft issue.

I you need a hand. Just let me know.
[Galaxy S I9000 General] andrewluecke:
deleted]]]]
[Galaxy S I9000 General] Arr MiHardies:
Be lucky you have fm radio at all. The telcos quietly removed them the us galaxy s phones. Didn't know it didn't have it until the phones came out

Sent from my Vibrant using the XDA app.

Typos, incorrect words, gibberish, and other nonsense brought to you courtesy of Swype.
[Galaxy S I9000 General] format:
just a quick note to tell you that in the Official JM6 firmware, that appeared in KIES Aug.20th, there is no FM Stereo :(

Bad news. But then again I didn't noticed any changes from JM2... bahhh!!!

Abandoning all hope!!!!
[Galaxy S I9000 General] izmenar:
gsmarena now says on the specs:

Mono FM radio with RDS

i dont know how the phone was advertised, or what happened , but i am very dissapointed
[Galaxy S I9000 General] AllGamer:
most likely they changed it after ready XDA forums :D
[Galaxy S I9000 General] andrewluecke:
That's Gsmarena.. Here in Australia it was advertised as stereo. Those guys are just some random mobile phone review site.

The real question here, is that people are complaining about mono radio, GPS and Lag, but would they have preferred the phone's release was delayed 4 months until the drivers were flawless? I would have bought it anyway honestly (especially since the competitors didn't have proper multi-touch, and the GPU on this is faster)..
[Galaxy S I9000 General] miki4242:
More Good News!

More good news yet! The setStereo to native SetStereo JNI _is_ implemented in framework/services.odex/jar but simply never used anywhere (whoops!).

I have an idea for a quick test without too much mucking about: by "hijacking" the AF button in FMRadio app we could try switching stereo on and off. Simply make the click handlers call setStereo(true) instead of enableAF() , setStereo(false) instead of disableAF() and we should be set.

>>>Any baksmali / smali / apk rebuilding wizards out there, please reply or PM me, now is the time!<<<

I have all the info you need, all that's required is two tiny changes to FMRadio app to make it happen :-)
[Galaxy S I9000 General] cba1986:
Arghh!!

I wish i could help. But i don't know anything about that.

You can make a new thread soliciting help for this!!
[Galaxy S I9000 General] miki4242:
I just did :) Here it is (link)
[Galaxy S I9000 General] miki4242:
For those of you interested in helping to get to the bottom of all this, I've started a new thread over in the Development forum. (link)
[Galaxy S I9000 General] GAda:
Pls read and add some extra links and informations to:

http://en.wikipedia.org/wiki/Samsung_i9000_Galaxy_S#FM_Radio_is_mono_.28single-channel.29

Hope, it read some of Samsung employees to.
[Galaxy S I9000 General] cba1986:
Very good testing. If you need a hand just let me know.
[Galaxy S I9000 General] AllGamer:
i'll help on testing if you come up with any files we can load.

looking at the Chip diagram, it does have the DSP & DAC & Left/Right channel output, the low frecuency input (bad reception fine tuning)

perhaps we need software optimization to better control the DSP for the sound quality
[Galaxy S I9000 General] supercurio:
Hello miki4242 !

The linux module driver is included in Samsung's source.

After your analysis, it seems that the problem is in the right in the driver.

You can get this bad boy in the big open source archive by Samsung : http://opensource.samsung.com/

(in /modules/fm_si4709)

Edit : added the source of the driver as a zip file. Should be easier for people to look into it :)
[Galaxy S I9000 General] CatalystWon:
I am a lifelong audiophile and thoroughly appreciate Stereo for music. Mono is OK for talk radio programs.

While lack of Stereo is a disappointment it certainly does not detract from this otherwise excellent device, and FM Mono is preferable to no FM at all.

I suspect one reason Samsung may have chosen to disable FM Stereo is due to the unreliability of a clear continuous FM Stereo signal in a mobile device. That is why many mobile devices with FM Stereo have a Stereo/Mono switch. I have two old AM/FM Stereo/Cassette devices that both have the Stereo/Mono switch. Another reason, aside from the GPS possibility, is they added a cheap FM chip just so they could include FM Radio in the feature list.

For those that think some users are going on too much about lack of FM Stereo, remember, this is one single topic in a forum of thousands of topics. As such, THIS IS THE PLACE to go on and on about this. If this thread bothers you, feel free to move on to the next thread that may be of interest.

For what its worth, Stereo FM is NOT mentioned anywhere in the Bell Canada GT-I9000M User Manual.
[Galaxy S I9000 General] andrewluecke:
These days though, you can apparently change between a variable state of stereo and mono (ie, half stereo). Doing so is probably too expensive on normal devices (because I'd imagine you'd need a CPU), but on phones we already have one..

The simplest explanation is normally the solution, and it's just possible they haven't implemented stereo yet..
[Galaxy S I9000 General] dnsp:
Maybe they set it to be mono in purpose because there is only one speaker in the Galaxy so we would not listen only the left or right channel when outputting from there?
[Galaxy S I9000 General] xan:
But... Headphones are stereo obviously ;p Until u cut one off.
[Galaxy S I9000 General] dnsp:
I think you did not understand my post. The headphones themselves at the moment are not stereo although they are capable of being. The phone outputs mono, mono is what you get. The phone had to be able of separating the channels when in mini-jack out and mixing them in mono when in internal speaker.
[Galaxy S I9000 General] xan:
Be more precise then.

Mixing is done somewhere else, not in radio app/driver.
[Galaxy S I9000 General] BronzedDroid:
Just a thought on how to verify if there's a short period with stereo when turning radio on: Use an FM-transmitter that submits sound only on one channel. That should make it pretty easy to hear, no?
[Galaxy S I9000 General] format:
Didn't update to froyo yet but the changelog to version JPC clearly says radio is stereo now.

If anybody can confirm this discussion is finished.
[Galaxy S I9000 General] rdy2go:
Radio is still mono unfortunately.
[Galaxy S I9000 General] format:
Too good to be true

Oh well....

If you go to the changelog now, the "FM radio is stereo now" vanished.

I guess it shouldn't be there in the first place. Just another flop.
[Galaxy S I9000 General] andrewluecke:
You are talking about the changelog for a leaked pre-release froyo build...

It's possible though they were working on the code expecting it to make it into that build, but missed out last second (or it might have been reverted).
[Galaxy S I9000 General] CatalystWon:
Not a CPU, just additional circuitry providing adaptive multiplex blend control for stereo decoding to maintain signal to noise ratio. 25 years ago my car AM/FM Stereo/Cassette deck had this. It could dynamically blend the high frequencies resulting in less stereo separation but less noise.
[Galaxy S I9000 General] andrewluecke:
Didn't know it was so easy..
[Galaxy S I9000 General] Valeo:
Lucky I spotted this while I was on the phone to Samsung UK to ***** and moan... anyway I've just gotten off the phone after finally reaching someone who seemed smarter than your average customer support monkey. I asked a bunch of questions, namely:

a) on which date will I be able to upgrade to Froyo (through Kies);

b) is there a planned fix for the 'my SGS shutdown and needed a hard reset to turn on' bug;

c) Why is Vodafone UK advertising FM Stereo when the signal played back is clearly mono.

The answers were "end of September to early October", "not at this moment" and "you'll have to ask Vodafone as the radio in the I9000 is mono only".

Since some Samsung reps are obviously not that clued up, I don't know how accurate any of this information is, but thought I'd share my findings.
[Galaxy S I9000 General] cba1986:
Any news on this?
[Galaxy S I9000 General] miki4242:
Thanks!

Sorry guys for my late reply, I only noticed your replies to this thread just now. Thanks for joining in!

Here's some more updates (I will clean up and add them to the OP):

It appears that in the source drop for the I9000, Samsung removed the mainline 2.6.29 Si470x FM chip family driver which lives in drivers/media/radio/radio_si470x.c and replaced it with their own driver specific for the Si4709, which lives under modules/fm_si4709.

This must be because in the SGS the Si4709 communicates via i2c and at the time (2.6.29) the 470x family driver in mainline supported only USB devices.

In newer kernels, the Si470x family driver has been enhanced to also support i2c devices and has been split up into common, USB and i2c support. It now lives in its own directory under drivers/media/radio/si470x .

Oddly, from the kernel changelog it appears the split/enhancement was signed off by Joonyoung Shim from none other than...Samsung(!)

Why the new driver hasn't been integrated into our I9000 specific kernel is a mystery to me (well, the kernel tree at android.git.kernel.org doesn't have it yet either). I think it is quite possible that in maintaining two separate drivers, some bug fixes or minor additions may have slipped through...
[Galaxy S I9000 General] cba1986:
is there a way too replace the samsung drivers with Si470x FM chip family driver?
[Galaxy S I9000 General] miki4242:
Quite possible I think! :) I'd be very happy if you could help me with this.

I do have quite a bit of kernel hacking experience, just none with Android devices. I can help you with any porting problems you may have. Just let me know.

I think the main things to be done are:

- integrate the driver with SGS's i2c controller and any weird hacks that Samsung may have done to it.

- Make sure the device id, major/minor and IOCTLs match the ones which Samsung use in the Android framework.

- get the driver to compile against this kernel version

The last part should not be too hard I think, I have experience succesfully building the V4L-DVB tree against all sorts of kernels (distro-specific patched ones are the worst!), so just ask if you need any help with that.

edit: It shouldn't be difficult at all to either drop it into the SGS tree and configure it there or to build it as an external module. Your choice :)
[Galaxy S I9000 General] cba1986:
J

Of course i want to help, just let me know what you need. And i will do my best.
[Galaxy S I9000 General] miki4242:
Are you on IRC or any other messaging service? Makes this a lot easier :) If you like to chat, please PM me the details.
[Galaxy S I9000 General] miki4242:
Nevermind. It appears Samsung use their own private IOCTLs, setup routines etc., while the new driver is video4linux based. That's a bit much to fix in one hackchat.

Unless we want to re-engineer all of libfmradio_jni, patch the framework, the radio app and then some, best bet for now is to simply compare both drivers and spot any differences in hardware access.

Or wait for Froyo final, it may yet use a slightly less ancient kernel with the new driver.

Samsung: why oh why reinvent the wheel??
[Galaxy S I9000 General] marty1976:
Amen, brother. Amen!
[Galaxy S I9000 General] lpy:
Ok here's what I've discovered so far.

It IS receiving in stereo. It has no problem detecting the 19KHz pilot tone. However, the output is the LEFT channel on BOTH channels. In other words, you are only hearing the radio's left output on both speakers.

There's no need to try and force Stereo mode on, it's already going on. What needs to be done is getting the RIGHT channel to work on the RIGHT speaker, and the LEFT channel/speaker to remain as is.

EDIT: Thinking about this, I suppose it's possible that it has nothing to do with the driver and maybe something to do with the OS's audio configuration. One channel is fine for the built-in speaker (although it really should be left&right mixed, instead of only left), but when earphones are connected, it's still in that one-channel mode? Just a thought..
[Galaxy S I9000 General] miki4242:
Good find!!

Maybe it's time to investigate the WM8994 driver and ALSA setup some more too. Not the first time there was a bug in there (Fring & Sipdroid still output to back speaker instead of earpiece for example, even after Java code fix).

My guess is that the OS or the radio app needs to do some funky audio routing switch when the audio is switched from headphones to speaker and back, maybe some little insect crept in there.. :)
[Galaxy S I9000 General] captive:
As android audio subsystem is alsa-based, there could/should be something like an alsarc configuration file, and maybe some ttable line addressing each channel to the right output, I think.

If the problem is "just" in audio routing, maybe it could be just a matter of editing this file to force the correct output. It may be even something hardcoded into radio app, though, and that would be a different story..
[Galaxy S I9000 General] yiannisthegreek:
Hey peoples... I listened to the radio on my Galaxy last night with the headphones in and I got STEREO sound just fine. YES... True stereo sound you know the kind where part of the song plays in one ear and the other part or "Track" if you will plays in the other ear.
[Galaxy S I9000 General] miki4242:
Hmm, does remind me of the hint of stereo sound there seems to be for a fraction of a second after switching on the radio...

Anyone care to single-step through the radio app init code? (Be sure to disable RDS because that seems to run in separate thread(s), and also generates a LOT of noise in logcat.)
[Galaxy S I9000 General] lpy:
I tried a few different settings is /etc/asound.conf , but nothing helped.

So it appears to be one of these scenarios:

a) RADIO APP: LEFT=LEFT RIGHT=LEFT ---> ALSA: LEFT=LEFT RIGHT=RIGHT

b) RADIO APP: LEFT=LEFT RIGHT=RIGHT ---> ALSA: LEFT=LEFT RIGHT=LEFT

c) RADIO APP: LEFT=LEFT RIGHT=LEFT ---> ALSA: LEFT=LEFT RIGHT=LEFT

I'm leaning more towards a) at the moment, which I guess would be more difficult to solve than b). I hope that makes sense lol, I know little about Android OS compared to you guys.
[Galaxy S I9000 General] robert_schl:
Just a thought:

In FM radio mode, the headphone wire is acting as the antenna, right? Is it possible that the headphones _need_ to be configured to mono mode to work as an antenna...?

Or, if that's not the case, the bug may be in the code which polls to check if the headset has been unplugged, mistakingly switching it to mono mode...
[Galaxy S I9000 General] andrewluecke:
Are you using the original headphones included, or 3rd party?
[Galaxy S I9000 General] lpy:
Nah, it doesn't to be configured in mono for the antenna to function correctly.

In speaker mode, the output is still only the left channel. Technically it should be left+right.

As a reference here's the pdf of the SI4709 - http://electroniccircuits.angelfire.com/SI4709_Silicon_Labs.pdf

It's an impressive little chip. If Samsung wanted to - and it would be a nice little feature - they could incorporate the RSSI level into the app, but they've left that out.

Also looking at that diagram, I see the possibility that there could be a circuit board error on the phone, and that the right-channel pin from the chip has been left disconnected. If that is the case (and I hope it isn't) then there's nothing that can be done except physically opening the phone and soldering it to the correct input. Easier said than done, though.

Personally I don't listen to FM radio much, but I still expect a fully functioning radio. Between this and the GPS issue and other bugs, it almost seems like they rushed things with this phone...more of a "build now, fix later" attitude. Having said that, I still love the phone :)

Either way, unless it's something that we've done by messing around with different firmwares, Samsung has screwed up something that should've otherwise been an easy task.
[Galaxy S I9000 General] nCoder:
Hi

Is it only me that don't have any problem with the FM Stereo receiver? (It's stereo for sure)

The first times I used the radio, was Mono because I didn't inserted the jack all in - requires some force to push it all way down the first times.

I still have the original firmware version.

Update: tested again. No stereo after all. Yesterday it seemed clearly to me it was stereo. Could it be signal power?
[Galaxy S I9000 General] lpy:
I guess it's possible that after messing around with so many firmwares, we've messed things up somehow. I'm just throwing some possibilities out there.
[Galaxy S I9000 General] lpy:
Hey guys, I've added some info in the other forum http://xdaforums.com/showthread.php?t=764548 including what I've discovered, which is that the phone actually is receiving the FM stereo signal, but is only playing the left channel through the left & right earphones.

To confirm this for yourself, if you have a little FM transmitter, you can play an audio through the left channel, and then the right. You'll hear the audio disappear when playing through the right channel only. It's rather odd that this is happening, but I guess only Samsung knows the real reason as to why, and whether it's hardware or software related.
[Galaxy S I9000 General] robert_schl:
I still have the stock firmware on my Galaxy S, never toyed around with any other ones, didn't root it or anything.

Still, my FM radio is only mono. So it doesn't come from messing around, it's an OOTB problem.
[Galaxy S I9000 General] dnsp:
Are you sure? Stereo is not just hearing in both sides. Mine for sure isn't.
[Galaxy S I9000 General] cba1986:
i hope that the problem is alsa related. that we can find a way to cheat the radio app to force stereo. :)
[Galaxy S I9000 General] miki4242:
Well, I'm currently quite sure the problem is at least mixer related. Unless you're listening to the radio using a Bluetooth headset, there is nothing digital going through ALSA, i.e. all pcm devices (both playback and capture) are 'closed'.

Anyone tried listening to the radio using a stereo Bluetooth headset? (Of course you'll need to have the wired headphones connected also, for use as antenna.) This way we can force the app to show us on which input the radio chip is connected using 'cat /proc/asound/*/*/*/status' and counting your fingers, twice (the symlinks to card0 and card1 cause the count to double)

I may even try turning my PC+HiFi into a badass Bluetooth headset (imagine 150 Watt earpieces!) using this.

May just as well ask my friend to get his old FM pirate radio transmitter from the attic, to do some left-right tests :D

Anyway, what I think we really need by now, is some statically-linked ARM binaries for some ALSA utilities like amixer, arecord, etc.

to do some more testing.

arecord in particular is very nice as a text-mode recording level meter, no need for GUI, ncurses (=YuCk with adb shell!) etc.

Just run 'arecord -Ddevice -vv /dev/null' and you see what I mean.. :)
[Galaxy S I9000 General] miki4242:
Well, I tried setting up PC as A2DP stereo headset using the link above. All seemed to be fine, Galaxy S found PC as headset, paired, connected etc., but of course Skylab crashed to Earth, taking Pulseaudio and all the rest with it, that happens with experimental stuff :) Will try again.
[Galaxy S I9000 General] lpy:
miki4242 - In case this turns out to be a hardware error, would it be possible to force mono, and maybe add code that displays the RSSI? :-)

It would be better to have mono than left-channel stereo.

Cheers.
[Galaxy S I9000 General] itsjusttim:
Sorry to impose on your thread guys but I would just like to say I will donate $50 for a working fm radio app for my vibrant.

Thank you guys for all of your help in this matter..
[Galaxy S I9000 General] miki4242:
More news (and yes, update and cleanup of the OP is well overdue!)

No need to compile ALSA stuff yourself, just install the update zip that accompanies the MixGet headset volume fix widget from this thread on XDA using your favorite recovery. It contains libalsa and all the tools you will need. Thanks, gilsken!

edit: rant deleted

I've been diving into kernel source and datasheet again, this time looking for more details on the WM8994 audio chip. What a beauty, absolutely mind-blowing documentation, and an entire website dedicated to open-source projects and kernel drivers for their hardware to boot. Way..To..Go!!

Anyway, like the story with the FM radio driver, the WM8994 driver wasn't in the 2.6.29 kernel, so Samsung added their own. It is at linux-2.6.29/sound/soc/s3c in the GT-I9000 opensource zip. I've made diffs against vanilla 2.6.29 to make porting their changes over to a newer kernel easier.

Hopefully they will have merged the updated, neatly separated and commented Wolfson drivers from either mainline or Wolfson's own Git repository (yeah that's right Samsung, Git, not one huge unversioned tree to merge back to AOSP ;) ) when Froyo gets here.
[Galaxy S I9000 General] cba1986:
Very good research. I'm Impressed. So Samsung put an undeveloped driver into the kernel to the WM8994?

You are saying that when final FROYO come we wil have stereo FM?
[Galaxy S I9000 General] jdrake001:
Sorry for the OT post, just thought that it is quite sad to have to depend on our devs to fix all the fundamental thing like GPS, FM Radio, file system etc. Compared to HTC, I think Samsung definitely has a much weaker development group/team. Makes me all the more grateful for xda developers efforts.