summaryrefslogtreecommitdiffstats
path: root/libs
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 /libs
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
Diffstat (limited to 'libs')
-rw-r--r--libs/audioflinger/Android.mk4
-rw-r--r--libs/audioflinger/AudioFlinger.cpp47
2 files changed, 48 insertions, 3 deletions
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;