summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Kondik <shade@chemlab.org>2010-11-30 15:27:05 +0000
committerGerrit Code Review <gerrit@review.cyanogenmod.com>2010-11-30 15:27:05 +0000
commitddaaf6c446c7bc615cfcb3305cfb03d0f48e75e6 (patch)
tree5642d100f65bf8729aca42d2d98006885fc8bec9
parentbe1da028a13ee95e094e9cbae8cc09ea3ef239fe (diff)
parent8e333bc98ee11ff1fa266fbdef1c7ee59076dd10 (diff)
downloadframeworks_base-ddaaf6c446c7bc615cfcb3305cfb03d0f48e75e6.zip
frameworks_base-ddaaf6c446c7bc615cfcb3305cfb03d0f48e75e6.tar.gz
frameworks_base-ddaaf6c446c7bc615cfcb3305cfb03d0f48e75e6.tar.bz2
Merge "audioflinger: Nasty hack for adjusting BCM FM volume" into froyo
-rw-r--r--include/media/AudioSystem.h4
-rw-r--r--libs/audioflinger/Android.mk4
-rw-r--r--libs/audioflinger/AudioFlinger.cpp47
-rw-r--r--media/libmedia/AudioSystem.cpp2
4 files changed, 52 insertions, 5 deletions
diff --git a/include/media/AudioSystem.h b/include/media/AudioSystem.h
index 9ec31d2..948e4e2 100644
--- a/include/media/AudioSystem.h
+++ b/include/media/AudioSystem.h
@@ -259,11 +259,13 @@ public:
DEVICE_OUT_AUX_DIGITAL = 0x400,
#ifdef HAVE_FM_RADIO
DEVICE_OUT_FM = 0x800,
+ DEVICE_OUT_FM_SPEAKER = 0x1000,
+ DEVICE_OUT_FM_ALL = (DEVICE_OUT_FM | DEVICE_OUT_FM_SPEAKER),
#endif
DEVICE_OUT_DEFAULT = 0x8000,
DEVICE_OUT_ALL = (DEVICE_OUT_EARPIECE | DEVICE_OUT_SPEAKER | DEVICE_OUT_WIRED_HEADSET |
#ifdef HAVE_FM_RADIO
- DEVICE_OUT_WIRED_HEADPHONE | DEVICE_OUT_FM | DEVICE_OUT_BLUETOOTH_SCO | DEVICE_OUT_BLUETOOTH_SCO_HEADSET |
+ DEVICE_OUT_WIRED_HEADPHONE | DEVICE_OUT_FM | DEVICE_OUT_FM_SPEAKER | DEVICE_OUT_BLUETOOTH_SCO | DEVICE_OUT_BLUETOOTH_SCO_HEADSET |
#else
DEVICE_OUT_WIRED_HEADPHONE | DEVICE_OUT_BLUETOOTH_SCO | DEVICE_OUT_BLUETOOTH_SCO_HEADSET |
#endif
diff --git a/libs/audioflinger/Android.mk b/libs/audioflinger/Android.mk
index 33384b7..7152be5 100644
--- a/libs/audioflinger/Android.mk
+++ b/libs/audioflinger/Android.mk
@@ -130,6 +130,10 @@ ifeq ($(BOARD_HAVE_FM_RADIO),true)
LOCAL_CFLAGS += -DHAVE_FM_RADIO
endif
+ifeq ($(BOARD_USE_BROADCOM_FM_VOLUME_HACK),true)
+ LOCAL_CFLAGS += -DUSE_BROADCOM_FM_VOLUME_HACK
+endif
+
ifeq ($(TARGET_SIMULATOR),true)
ifeq ($(HOST_OS),linux)
LOCAL_LDLIBS += -lrt -lpthread
diff --git a/libs/audioflinger/AudioFlinger.cpp b/libs/audioflinger/AudioFlinger.cpp
index 9aebfe4..4906f87 100644
--- a/libs/audioflinger/AudioFlinger.cpp
+++ b/libs/audioflinger/AudioFlinger.cpp
@@ -615,9 +615,9 @@ status_t AudioFlinger::setParameters(int ioHandle, const String8& keyValuePairs)
String8 key = String8(AudioParameter::keyRouting);
int device;
if (param.getInt(key, device) == NO_ERROR) {
- if((device & AudioSystem::DEVICE_OUT_FM) && mFmOn == false){
+ if((device & AudioSystem::DEVICE_OUT_FM_ALL) && mFmOn == false){
mFmOn = true;
- } else if (mFmOn == true && !(device & AudioSystem::DEVICE_OUT_FM)){
+ } else if (mFmOn == true && !(device & AudioSystem::DEVICE_OUT_FM_ALL)){
mFmOn = false;
}
}
@@ -744,8 +744,43 @@ status_t AudioFlinger::getRenderPosition(uint32_t *halFrames, uint32_t *dspFrame
}
#ifdef HAVE_FM_RADIO
+#ifdef USE_BROADCOM_FM_VOLUME_HACK
+/*
+ * NASTY HACK: Send raw HCI data to adjust the FM volume.
+ *
+ * Normally we would do this in libaudio, but this is for the case where
+ * we have a prebuilt libaudio and cannot modify it.
+ */
+static status_t set_volume_fm(uint32_t volume)
+{
+ int returnval = 0;
+ float ratio = 2.5;
+
+ char s1[100] = "hcitool cmd 0x3f 0xa 0x5 0xc0 0x41 0xf 0 0x20 0 0 0";
+ char s2[100] = "hcitool cmd 0x3f 0xa 0x5 0xe4 0x41 0xf 0 0x00 0 0 0";
+ char s3[100] = "hcitool cmd 0x3f 0xa 0x5 0xe0 0x41 0xf 0 ";
+
+ char stemp[10] = "";
+ char *pstarget = s3;
+
+ volume = (unsigned int)(volume * ratio);
+
+ sprintf(stemp, "0x%x ", volume);
+ pstarget = strcat(s3, stemp);
+ pstarget = strcat(s3, "0 0 0");
+
+ system(s1);
+ system(s2);
+ system(s3);
+
+ return returnval;
+}
+#endif
+
status_t AudioFlinger::setFmVolume(float value)
{
+ status_t ret;
+
// check calling permissions
if (!settingsAllowed()) {
return PERMISSION_DENIED;
@@ -753,7 +788,13 @@ status_t AudioFlinger::setFmVolume(float value)
AutoMutex lock(mHardwareLock);
mHardwareStatus = AUDIO_SET_FM_VOLUME;
- status_t ret = mAudioHardware->setFmVolume(value);
+#ifdef USE_BROADCOM_FM_VOLUME_HACK
+ int vol = AudioSystem::logToLinear(value);
+ LOGI("setFmVolume %d", vol);
+ ret = set_volume_fm(vol);
+#else
+ ret = mAudioHardware->setFmVolume(value);
+#endif
mHardwareStatus = AUDIO_HW_IDLE;
return ret;
diff --git a/media/libmedia/AudioSystem.cpp b/media/libmedia/AudioSystem.cpp
index dfeb727..9cea8f9 100644
--- a/media/libmedia/AudioSystem.cpp
+++ b/media/libmedia/AudioSystem.cpp
@@ -717,7 +717,7 @@ bool AudioSystem::isInputDevice(audio_devices device)
bool AudioSystem::isFmDevice(audio_devices device)
{
if ((popCount(device) == 1 ) &&
- ((device & ~AudioSystem::DEVICE_OUT_FM) == 0)) {
+ ((device & ~AudioSystem::DEVICE_OUT_FM_ALL) == 0)) {
return true;
} else {
return false;