diff options
Diffstat (limited to 'hal/audio_hw.c')
-rw-r--r-- | hal/audio_hw.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/hal/audio_hw.c b/hal/audio_hw.c index 6fbbee33..1ec9b182 100644 --- a/hal/audio_hw.c +++ b/hal/audio_hw.c @@ -85,6 +85,8 @@ #include "sound/asound.h" +#include "audio_amplifier.h" + #ifdef DYNAMIC_LOG_ENABLED #include <log_xml_parser.h> #define LOG_MASK HAL_MOD_FILE_AUDIO_HW @@ -1385,6 +1387,7 @@ int enable_snd_device(struct audio_device *adev, goto err; } audio_extn_dev_arbi_acquire(snd_device); + amplifier_enable_devices(snd_device, true); if (audio_extn_spkr_prot_start_processing(snd_device)) { ALOGE("%s: spkr_start_processing failed", __func__); audio_extn_dev_arbi_release(snd_device); @@ -1450,6 +1453,7 @@ int enable_snd_device(struct audio_device *adev, } audio_extn_dev_arbi_acquire(snd_device); audio_route_apply_and_update_path(adev->audio_route, device_name); + amplifier_set_feedback(adev, snd_device, true); if (SND_DEVICE_OUT_HEADPHONES == snd_device && !adev->native_playback_enabled && @@ -1521,6 +1525,7 @@ int disable_snd_device(struct audio_device *adev, platform_set_speaker_gain_in_combo(adev, snd_device, false); } else { audio_route_reset_and_update_path(adev->audio_route, device_name); + amplifier_enable_devices(snd_device, false); } if (snd_device == SND_DEVICE_OUT_BT_A2DP) { @@ -1551,6 +1556,7 @@ int disable_snd_device(struct audio_device *adev, } audio_extn_utils_release_snd_device(snd_device); + amplifier_set_feedback(adev, snd_device, false); } else { if (platform_split_snd_device(adev->platform, snd_device, @@ -2924,6 +2930,10 @@ int select_devices(struct audio_device *adev, audio_usecase_t uc_id) disable_snd_device(adev, usecase->in_snd_device); } + /* Rely on amplifier_set_devices to distinguish between in/out devices */ + amplifier_set_input_devices(in_snd_device); + amplifier_set_output_devices(out_snd_device); + /* Applicable only on the targets that has external modem. * New device information should be sent to modem before enabling * the devices to reduce in-call device switch time. @@ -4538,6 +4548,9 @@ static int out_standby(struct audio_stream *stream) } pthread_mutex_lock(&adev->lock); + + amplifier_output_stream_standby((struct audio_stream_out *) stream); + out->standby = true; if (out->usecase == USECASE_COMPRESS_VOIP_CALL) { voice_extn_compress_voip_close_output_stream(stream); @@ -5038,6 +5051,8 @@ static int out_set_parameters(struct audio_stream *stream, const char *kvpairs) if (!parms) goto error; + amplifier_out_set_parameters(parms); + err = platform_get_controller_stream_from_params(parms, &ext_controller, &ext_stream); if (err == 0) { @@ -5891,6 +5906,11 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer, ret = voice_extn_compress_voip_start_output_stream(out); else ret = start_output_stream(out); + + if (ret == 0) + amplifier_output_stream_start(stream, + is_offload_usecase(out->usecase)); + /* ToDo: If use case is compress offload should return 0 */ if (ret != 0) { out->standby = true; @@ -6792,6 +6812,8 @@ static int in_standby(struct audio_stream *stream) adev->adm_deregister_stream(adev->adm_data, in->capture_handle); pthread_mutex_lock(&adev->lock); + amplifier_input_stream_standby((struct audio_stream_in *) stream); + in->standby = true; if (in->usecase == USECASE_COMPRESS_VOIP_CALL) { do_stop = false; @@ -6976,6 +6998,9 @@ static int in_set_parameters(struct audio_stream *stream, const char *kvpairs) if (!parms) goto error; + + amplifier_in_set_parameters(parms); + lock_input_stream(in); pthread_mutex_lock(&adev->lock); @@ -7124,6 +7149,10 @@ static ssize_t in_read(struct audio_stream_in *stream, void *buffer, if (adev->num_va_sessions < UINT_MAX) adev->num_va_sessions++; } + + if (ret == 0) + amplifier_input_stream_start(stream); + pthread_mutex_unlock(&adev->lock); if (ret != 0) { goto exit; @@ -9007,6 +9036,7 @@ static int adev_set_parameters(struct audio_hw_device *dev, const char *kvpairs) } } + amplifier_set_parameters(parms); audio_extn_set_parameters(adev, parms); done: str_parms_destroy(parms); @@ -9135,6 +9165,8 @@ static int adev_set_mode(struct audio_hw_device *dev, audio_mode_t mode) if (adev->mode != mode) { ALOGD("%s: mode %d , prev_mode %d \n", __func__, mode , adev->mode); adev->prev_mode = adev->mode; /* prev_mode is kept to handle voip concurrency*/ + if (amplifier_set_mode(mode) != 0) + ALOGE("Failed setting amplifier mode"); adev->mode = mode; if (mode == AUDIO_MODE_CALL_SCREEN) { adev->current_call_output = adev->primary_output; @@ -10293,6 +10325,8 @@ static int adev_close(hw_device_t *device) if ((--audio_device_ref_count) == 0) { if (audio_extn_spkr_prot_is_enabled()) audio_extn_spkr_prot_deinit(); + if (amplifier_close() != 0) + ALOGE("Amplifier close failed"); audio_extn_battery_properties_listener_deinit(); audio_extn_snd_mon_unregister_listener(adev); audio_extn_sound_trigger_deinit(adev); @@ -10724,6 +10758,10 @@ static int adev_open(const hw_module_t *module, const char *name, adev->vr_audio_mode_enabled = false; audio_extn_ds2_enable(adev); + + if (amplifier_open(adev) != 0) + ALOGE("Amplifier initialization failed"); + *device = &adev->device.common; if (k_enable_extended_precision) |