Jump to content

FM Radio for ZTE Blade/SF


Guest andorko

Recommended Posts

Guest StevenHarperUK

also

# find /proc/irq/ | grep -v spurious
.
./130
./130/msm-sdccsdiowakeup
./106
./104
./104/gpio_kp
./105
./105/gpio_kp
./101
./101/gpio_kp
./93
./93/cypress_touch
./47/msm_otg
./34/msm_i2c
./26/msm-sdcc (pio)
./26/msm-sdcc (cmd)
./24/msm-sdcc (pio)
./24/msm-sdcc (cmd)
./23
./23/adsp
./21/msmdatamover
./20
./20/kgsl
./19
./19/MDP
./5/smsm_dev[/code]

Link to comment
Share on other sites

Guest StevenHarperUK
cat /proc/bus/input/devices
I: Bus=0000 Vendor=0000 Product=0000 Version=0000
N: Name="cypress_touch"
P: Phys=cypress_touch/input0
S: Sysfs=/devices/virtual/input/input0
U: Uniq=
H: Handlers=event0 cpufreq
B: EV=b
B: KEY=400 0 0 0 0 0 0 0 0 0 0
B: ABS=6500f6 0

I: Bus=0000 Vendor=0000 Product=0000 Version=0000
N: Name="blade_keypad"
P: Phys=
S: Sysfs=/devices/virtual/input/input1
U: Uniq=
H: Handlers=kbd event1 cpufreq
B: EV=3
B: KEY=40000800 c0040 0 0 0

I: Bus=0000 Vendor=0000 Product=0000 Version=0000
N: Name="compass"
P: Phys=
S: Sysfs=/devices/virtual/input/input2
U: Uniq=
H: Handlers=event2 cpufreq
B: EV=9
B: ABS=305ff

I: Bus=0000 Vendor=0000 Product=0000 Version=0000
N: Name="alsprox"
P: Phys=
S: Sysfs=/devices/virtual/input/input3
U: Uniq=
H: Handlers=event3 cpufreq
B: EV=9
B: ABS=3

I: Bus=0000 Vendor=0001 Product=0001 Version=0001
N: Name="7k_handset"
P: Phys=
S: Sysfs=/devices/virtual/input/input4
U: Uniq=
H: Handlers=kbd event4 cpufreq
B: EV=23
B: KEY=4 0 0 c000 1c0000 0 0 0
B: SW=4[/code]

Link to comment
Share on other sites

Guest andorko
This any use ?

cat /proc/interrupts

		   CPU0

  0:	 197600		 msm  smd_dev

  5:		  1		 msm  smsm_dev

  7:		 95		 msm  gp_timer

  8:	1809478		 msm  dg_timer

 19:	  74464		 msm  MDP

 20:	  84109		 msm  kgsl

 21:	 618520		 msm  msmdatamover

 23:	  11256		 msm  adsp

 24:	 107295		 msm  msm-sdcc (cmd), msm-sdcc (pio)

 26:	1295700		 msm  msm-sdcc (cmd), msm-sdcc (pio)

 34:	1111712		 msm  msm_i2c

 47:		 15		 msm  msm_otg

 93:	  64373	 msmgpio  cypress_touch

101:		 30	 msmgpio  gpio_kp

104:		 33	 msmgpio  gpio_kp

105:		  0	 msmgpio  gpio_kp

106:		798	 msmgpio  taos

130:		  1	 msmgpio  msm-sdccsdiowakeup

Err:		  0

I found /proc/interrupts and /proc/stat but there is no info about the fm chip (or i don't see it)

Link to comment
Share on other sites

Guest kallt_kaffe

Andorko, what kernel changes needs to be done to get RDS working? Does this change require a RDS capable app or will or work "just like before" with non-RDS apps?

Also I've found a way to change the kernel so that the original Radio app works so that whatever workaround you used to not being turned off after 3 seconds are no longer needed.

It seems that on the 2.2 ROM the radio triggers the use of a different device ID for headset which likely some firmware on our phones cannot handle. So what I did was that I catched and changed the radio headset id and changed in to the normal headset id.

In arch/arm/mach-msm/qdsp5/snd.c:

Change:

		mutex_lock(&snd->lock);
switch (cmd) {
case SND_SET_DEVICE:
if (copy_from_user(&dev, (void __user *) arg, sizeof(dev))) {
MM_ERR("set device: invalid pointer\n");
rc = -EFAULT;
break;
}

dmsg.args.device = cpu_to_be32(dev.device);
dmsg.args.ear_mute = cpu_to_be32(dev.ear_mute);[/code] To:
[code] mutex_lock(&snd->lock);
switch (cmd) {
case SND_SET_DEVICE:
if (copy_from_user(&dev, (void __user *) arg, sizeof(dev))) {
MM_ERR("set device: invalid pointer\n");
rc = -EFAULT;
break;
}

// FM_STEREO_HEADSET -> HEADSET
if(SND_DEVICE_FM_STEREO_HEADSET_ZTE == dev.device)
dev.device = 3;

dmsg.args.device = cpu_to_be32(dev.device);
dmsg.args.ear_mute = cpu_to_be32(dev.ear_mute);

After this the stock Japanese unmodifed radio app works again. (I was actually looking for some way to boost the volume in the kernel when I stumbled upon this)

Edited by kallt_kaffe
Link to comment
Share on other sites

Guest oh!dougal
...

It seems that on the 2.2 ROM the radio triggers the use of a different device ID for headset which likely some firmware on our phones cannot handle. So what I did was that I catched and changed the radio headset id and changed in to the normal headset id.

...

Is it therefore possible to direct the FM radio output to a more general audio output ? --- thereby opening up the possibilities of internal speaker or Bluetooth --- though obviously, you'd need the headset connected to have an antenna ...

Link to comment
Share on other sites

Guest kallt_kaffe
Is it therefore possible to direct the FM radio output to a more general audio output ? --- thereby opening up the possibilities of internal speaker or Bluetooth --- though obviously, you'd need the headset connected to have an antenna ...

I really don't know if this opens any new doors but I believe this is the device ID the radio identifies itself with in 2.1 but someone would need to do "cat /proc/kmsg|grep snd_set_device" to be sure and I am bit sick and tired of reflashing at moment. The first number is the device and without headset inserted it reports 6 and with it inserted it reports 3 but once you start the unmodified radio app it reports 32 and there is a check for that in the code that isn't present in the 2.1 kernel. (just removing the check results in a total reboot if you start the radio app, but changing the device id to 3 (headset) works like a charm.

Link to comment
Share on other sites

Guest andorko

I have made a second RDS test version:

-The tuning and and seeking is faster

-More stable RDS StationText, it handles dynamic StationText too.

You can download it from my download page (it is on the bottom of the page)

Edited by andorko
Link to comment
Share on other sites

Guest oh!dougal
I have made a second RDS test version:

-The tuning and and seeking is faster

-More stable RDS StationText, it handles dynamic StationText too.

You can download it from my download page (it is on the bottom of the page)

Excellent news -- I'll give it a try today!

Thanks for your efforts!

Link to comment
Share on other sites

Please could you offer your RDS kernel patches to the ROM devs?

Or post them here so that we can point Paul, KK and the rest to them?

My donate threshold is when I have RDS radio on Pauls MCR 2.2 but using a Paul-provided kernel on one of his kitchen roms

Thanks

Link to comment
Share on other sites

Guest miker01

HUMPH.

This may just be me because I have NOT plugged headphones in [looking for mine!]

But nothing happens when I use the "circle" at the top or the "wheel" at the bottom - the frquency does not change.

What is the problem please?

Mike

Link to comment
Share on other sites

Guest andorko
HUMPH.

This may just be me because I have NOT plugged headphones in [looking for mine!]

But nothing happens when I use the "circle" at the top or the "wheel" at the bottom - the frquency does not change.

What is the problem please?

Mike

If you don't put the headphones in, then all the controls are disabled.

Link to comment
Share on other sites

Guest andorko
Please could you offer your RDS kernel patches to the ROM devs?

Or post them here so that we can point Paul, KK and the rest to them?

My donate threshold is when I have RDS radio on Pauls MCR 2.2 but using a Paul-provided kernel on one of his kitchen roms

Thanks

Of course I will share my kernel modifications with the ROM devs, but, because it is a kernel modification it should be bug-free before it is put into the newest ROMs.

Link to comment
Share on other sites

Guest andorko
Just to let everyone know, kaltkaffe has fixed the problem with the original FM Radio app in Japanese Jellyfish R9.

My modifications are more than just listening to radio on 2.2. There is RDS in the fm chip, and i hope there is TMC too. But to use this features , fm driver in the kernel have to be modified.

Link to comment
Share on other sites

Guest GSpYacc

You did great job!!! Works great! no issue until now.

If you accept feature requests, i will love to be able to assign names on the 'stored' stations, and also to be able to store more than 5 stations.

Also, can i install this app along with the stock fm app?

Thanks!

Link to comment
Share on other sites

Guest reallordx

The not working loudspeaker was really bugging me, so I installed the Android SDK and started playing with a simple app.

My goal was to play a mp3 file through the loudspeaker, while the headphones are connected.

What this app does:

Plays a predefined (marchin.mp3, not attached, use your own) from sdcard. Shows a very simple app with a toggle button. Upon toggle app switches playback between wired headset and loudspeaker.

I'm actually not sure, if andorko can adapt this, but I hope so. I'm attaching all related code in codetags in this post.

@andorko and other devs

feel free to use (a credit if this works would be nice though :lol: )

If you for some reason don't want to read through all the code, I added the most relevant bits at the end of this post.

@all

If anyone wants to try this in android sdk, fell free. But be aware that I'm not attaching the mp3 I used.

You need to place a "marchin.mp3" on your root sdcard directory or adapt the code.

audio1.java:

package com.example.audio1;

import java.io.IOException;

import android.app.Activity;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

public class audio1 extends Activity implements OnClickListener {
private static final String TAG = "AudioDemo";
private static final String isOn = "Speaker is on";
private static final String isOff = "Speaker is off";

MediaPlayer player;
Button playerButton;
AudioManager mAudioManager;

public void onClick(View v) {
Log.d(TAG, "onClick: " + v);
if (v.getId() == R.id.play) {
toggle();
}
}

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

mAudioManager = (AudioManager) getSystemService(AUDIO_SERVICE);

String path = "/sdcard/marchin.mp3";
player = new MediaPlayer();
try {
player.setDataSource(path);
player.prepare();
}
catch (IOException e) {
e.printStackTrace();
}

// Get the button from the view
playerButton = (Button) this.findViewById(R.id.play);
playerButton.setText(R.string.on_label);
playerButton.setOnClickListener(this);

// Begin playing selected media
player.start();
}


private void speaker_On() {
/* Without setting MODE_IN_CALL setSpeakerphoneOn does have NO EFFECT!!
* Dirty workaround.
*/
mAudioManager.setMode(AudioManager.MODE_IN_CALL);
mAudioManager.setSpeakerphoneOn(true);

playerButton.setText(R.string.on_label);
Toast.makeText(this, isOn, Toast.LENGTH_LONG).show();
Log.d(TAG, isOn);
}

private void speaker_Off(){
/* Set Mode back to normal
*
*/
mAudioManager.setMode(AudioManager.MODE_NORMAL);
mAudioManager.setSpeakerphoneOn(false);

playerButton.setText(R.string.off_label);
Toast.makeText(this, isOff, Toast.LENGTH_LONG).show();
Log.d(TAG, isOff);
}

// Toggle between the play and pause
private void toggle() {
if(mAudioManager.isSpeakerphoneOn()) {
speaker_Off();
} else {
speaker_On();
}
}

@Override
protected void onDestroy() {
super.onDestroy();
// TODO Auto-generated method stub
if (player != null) {
player.release();
player = null;
}

}

}[/codebox]

main.xml:

[codebox]<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="@string/hello" />
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/play"
android:text="@string/on_label"></Button>
</LinearLayout>

strings.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, AudioDemo</string>
<string name="app_name">Audio Demo</string>
<string name="on_label">set Speaker On</string>
<string name="off_label">set Speaker Off</string>
</resources>[/codebox]

AndroidManifest.xml:

[codebox]<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.audio1"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".audio1"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

</application>
<uses-sdk android:minSdkVersion="8" />




<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"></uses-permission>
</manifest>

I'm on MCR 2.2 R7. I don't know if this works on 2.1.

If you're too lazy to read all this code. Relevant stuff:

Set "android.permission.MODIFY_AUDIO_SETTINGS" in Manifest.

Set "mAudioManager.setMode(AudioManager.MODE_IN_CALL);" before setting "mAudioManager.setSpeakerphoneOn(true);"

Without MODE_IN_CALL setting Speakerphone doesn't work. This is a dirty workaround. I don't know how the phone will behave, when playing mp3/radio(if andorko can adapt this) through Speakerphone and getting a call in. Didn't test this.

But maybe this leads some dev onto the right path. (Or it actually works flawlessly this way).

Edited by reallordx
Link to comment
Share on other sites

Guest andorko
The not working loudspeaker was really bugging me, so I installed the Android SDK and started playing with a simple app.

This trick doesn't work with the fm radio. If i play radio and an mp3 simultaneusly on the headphones and then execute the :

mAudioManager.setMode(AudioManager.MODE_IN_CALL);

mAudioManager.setSpeakerphoneOn(true);

then the mp3 plays through the speakerphone but the radio disappears.

Edited by andorko
Link to comment
Share on other sites

Guest reallordx

Bummer :lol:

Sounds like the mp3 sound is re-routed correctly and the fm sound is not.

Why are you playing an mp3 file anyway? I only used this method cause I wanted to try the toggling and i didn't have the radio source code to try directly.

anyway, thanks for trying andorko

I'm off to bed now, getting late here. gn8

Edited by reallordx
Link to comment
Share on other sites

Guest andorko
Bummer :lol:

Sounds like the mp3 sound is re-routed correctly and the fm sound is not.

Why are you playing an mp3 file anyway? I only used this method cause I wanted to try the toggling and i didn't have the radio source code to try directly.

anyway, thanks for trying andorko

I'm off to bed now, getting late here. gn8

I was playing an mp3 with the "Music" player just for testing that i didn't make a mistake in the code.

Link to comment
Share on other sites

Guest wishmasterf
I have made a second RDS test version:

-The tuning and and seeking is faster

-More stable RDS StationText, it handles dynamic StationText too.

You can download it from my download page (it is on the bottom of the page)

You are great!! it work very well now. Only 1 (really little) thing i see if i start with rds disabled the app tells me "RDS: loading..." there should be "RDS: disable".

Do you plan more with the rds-feature? as i said it seems to be very stable yet. i dont know if anyone else found a bug, but i think you could remove the testversion line, center the rds line and resize ist a little bit bigger.

I hope you solve the loudspeaker problem. ;-)

Thank you very much for your time and the great app!

EDIT: I found a Bug: i click on the arrow of the volumne-circle (highest volumne). then i click on the "turn on/off button" and turn again on with klicking on "turn on/off" butten volumne seems to be 0. if i klick on the volumecircle i volumne is again normal. i think the volumne should be evertime the state in the circle.

Edited by wishmasterf
Link to comment
Share on other sites

Guest Arr Too
I believe this is the device ID the radio identifies itself with in 2.1 but someone would need to do "cat /proc/kmsg|grep snd_set_device" to be sure

Confirmation for you:

<6>[155684.363662] [msm-audio:snd.c:snd_ioctl] snd_set_device 3 0 1

<6>[155684.366139] [msm-audio:snd.c:snd_ioctl] snd_set_device 3 0 0

<6>[155721.655236] [msm-audio:snd.c:snd_ioctl] snd_set_device 3 1 1

<6>[155721.656588] [msm-audio:snd.c:snd_ioctl] snd_set_device 3 1 0

Link to comment
Share on other sites

Guest andorko
You are great!! it work very well now. Only 1 (really little) thing i see if i start with rds disabled the app tells me "RDS: loading..." there should be "RDS: disable".

Do you plan more with the rds-feature? as i said it seems to be very stable yet. i dont know if anyone else found a bug, but i think you could remove the testversion line, center the rds line and resize ist a little bit bigger.

I hope you solve the loudspeaker problem. ;-)

Thank you very much for your time and the great app!

EDIT: I found a Bug: i click on the arrow of the volumne-circle (highest volumne). then i click on the "turn on/off button" and turn again on with klicking on "turn on/off" butten volumne seems to be 0. if i klick on the volumecircle i volumne is again normal. i think the volumne should be evertime the state in the circle.

Thank you for the bug report. I will fix it.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.