summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorSteve Kondik <shade@chemlab.org>2010-11-29 07:18:20 -0500
committerChristopher Lais <chris+android@zenthought.org>2010-11-29 16:12:50 -0600
commit8e333bc98ee11ff1fa266fbdef1c7ee59076dd10 (patch)
treefd0f54361412ecb17d96ba7244f9d31e20ffb963 /libs
parentd98418db26a3af03d3c981efe3c4d5f6215327be (diff)
downloadframeworks_base-8e333bc98ee11ff1fa266fbdef1c7ee59076dd10.zip
frameworks_base-8e333bc98ee11ff1fa266fbdef1c7ee59076dd10.tar.gz
frameworks_base-8e333bc98ee11ff1fa266fbdef1c7ee59076dd10.tar.bz2
audioflinger: Nasty hack for adjusting BCM FM volume
Normally this kind of nasty hack could go into libaudio, but on this particular device, we have no access to the source code of libaudio. Put the nasty hack into audioflinger and wrap it in ifdefs. Change-Id: I5e3e495e3bd6b671823967b61ba5ceb49e59a401
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;