diff options
author | Daniel Hillenbrand <codeworkx@cyanogenmod.org> | 2013-05-23 10:10:00 +0530 |
---|---|---|
committer | Rashed Abdel-Tawab <rashed@linux.com> | 2015-10-09 17:38:53 -0400 |
commit | be0a3a45377ca67931adbc5ecddd311d30ca87e7 (patch) | |
tree | 8f424fb75c315c7d6caeacc029fc37ffceacb27e | |
parent | 0981aefcd89531e7c16142bd6de609acae712993 (diff) | |
download | hardware_qcom_audio-be0a3a45377ca67931adbc5ecddd311d30ca87e7.tar.gz hardware_qcom_audio-be0a3a45377ca67931adbc5ecddd311d30ca87e7.tar.bz2 hardware_qcom_audio-be0a3a45377ca67931adbc5ecddd311d30ca87e7.zip |
hal: Support the audio amplifier hook
* Original legacy HAL commit:
Ib236598a5888b2af19bcfb81e285f644a0e84c0d
* Example: http://review.cyanogenmod.org/38221
Change-Id: Ic944a9f7059c78b79322dae9c787cdd8bb029cff
-rw-r--r-- | hal/Android.mk | 6 | ||||
-rw-r--r-- | hal/audio_hw.c | 24 |
2 files changed, 30 insertions, 0 deletions
diff --git a/hal/Android.mk b/hal/Android.mk index 80d73a4b..763ff149 100644 --- a/hal/Android.mk +++ b/hal/Android.mk @@ -221,6 +221,12 @@ LOCAL_SHARED_LIBRARIES := \ libdl \ libexpat +ifneq ($(BOARD_AUDIO_AMPLIFIER),) + LOCAL_CFLAGS += -DUSES_AUDIO_AMPLIFIER + LOCAL_SHARED_LIBRARIES += libaudioamp + LOCAL_C_INCLUDES += $(BOARD_AUDIO_AMPLIFIER) +endif + LOCAL_C_INCLUDES += \ external/tinyalsa/include \ external/tinycompress/include \ diff --git a/hal/audio_hw.c b/hal/audio_hw.c index 35d26618..522a72cf 100644 --- a/hal/audio_hw.c +++ b/hal/audio_hw.c @@ -73,6 +73,10 @@ #include "sound/compress_params.h" #include "sound/asound.h" +#ifdef USES_AUDIO_AMPLIFIER +#include <audio_amplifier.h> +#endif + #define COMPRESS_OFFLOAD_NUM_FRAGMENTS 4 /* ToDo: Check and update a proper value in msec */ #define COMPRESS_OFFLOAD_PLAYBACK_LATENCY 50 @@ -975,6 +979,13 @@ int select_devices(struct audio_device *adev, audio_usecase_t uc_id) enable_audio_route(adev, usecase); +#ifdef USES_AUDIO_AMPLIFIER + /* Rely on amplifier_set_devices to distinguish between in/out devices */ + amplifier_set_devices(in_snd_device); + amplifier_set_devices(out_snd_device); +#endif + + /* Applicable only on the targets that has external modem. * Enable device command should be sent to modem only after * enabling voice call mixer controls @@ -3350,6 +3361,10 @@ static int adev_set_mode(struct audio_hw_device *dev, audio_mode_t mode) pthread_mutex_lock(&adev->lock); if (adev->mode != mode) { ALOGD("%s: mode %d\n", __func__, mode); +#ifdef USES_AUDIO_AMPLIFIER + if (amplifier_set_mode(mode) != 0) + ALOGE("Failed setting amplifier mode"); +#endif adev->mode = mode; if ((mode == AUDIO_MODE_NORMAL || mode == AUDIO_MODE_IN_COMMUNICATION) && voice_is_in_call(adev)) { @@ -3590,6 +3605,10 @@ static int adev_close(hw_device_t *device) pthread_mutex_lock(&adev_init_lock); if ((--audio_device_ref_count) == 0) { +#ifdef USES_AUDIO_AMPLIFIER + if (amplifier_close() != 0) + ALOGE("Amplifier close failed"); +#endif audio_extn_sound_trigger_deinit(adev); audio_extn_listen_deinit(adev); audio_extn_utils_release_streams_output_cfg_list(&adev->streams_output_cfg_list); @@ -3746,6 +3765,11 @@ static int adev_open(const hw_module_t *module, const char *name, audio_extn_utils_update_streams_output_cfg_list(adev->platform, adev->mixer, &adev->streams_output_cfg_list); +#ifdef USES_AUDIO_AMPLIFIER + if (amplifier_open() != 0) + ALOGE("Amplifier initialization failed"); +#endif + audio_device_ref_count++; char value[PROPERTY_VALUE_MAX]; |