am b6506416: hal: enable setting gain in case of combo device
* commit 'b65064161c19b4c688f8a436ed002264d9f49055':
hal: enable setting gain in case of combo device
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index c66f7ec..7c017fd 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -346,6 +346,7 @@
for (i = 0; i < num_devices; i++) {
enable_snd_device(adev, new_snd_devices[i]);
}
+ platform_set_speaker_gain_in_combo(adev, snd_device, true);
} else {
const char * dev_path = platform_get_snd_device_name(snd_device);
ALOGD("%s: snd_device(%d: %s)", __func__, snd_device, dev_path);
@@ -384,12 +385,14 @@
for (i = 0; i < num_devices; i++) {
disable_snd_device(adev, new_snd_devices[i]);
}
+ platform_set_speaker_gain_in_combo(adev, snd_device, false);
} else {
audio_route_reset_and_update_path(adev->audio_route, dev_path);
}
audio_extn_sound_trigger_update_device_status(snd_device,
ST_EVENT_SND_DEVICE_FREE);
}
+
return 0;
}
diff --git a/hal/msm8960/platform.c b/hal/msm8960/platform.c
index 06663a4..c75efbe 100644
--- a/hal/msm8960/platform.c
+++ b/hal/msm8960/platform.c
@@ -547,6 +547,11 @@
return ret;
}
+void platform_set_speaker_gain_in_combo(struct audio_device *adev __unused,
+ snd_device_t snd_device,
+ bool enable __unused) {
+}
+
int platform_set_voice_volume(void *platform, int volume)
{
struct platform_data *my_data = (struct platform_data *)platform;
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 6e8a9bb..90349d1 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -1500,6 +1500,43 @@
return ret;
}
+void platform_set_speaker_gain_in_combo(struct audio_device *adev,
+ snd_device_t snd_device,
+ bool enable)
+{
+ const char* name;
+ switch (snd_device) {
+ case SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES:
+ if (enable)
+ name = "spkr-gain-in-headphone-combo";
+ else
+ name = "speaker-gain-default";
+ break;
+ case SND_DEVICE_OUT_SPEAKER_AND_LINE:
+ if (enable)
+ name = "spkr-gain-in-line-combo";
+ else
+ name = "speaker-gain-default";
+ break;
+ case SND_DEVICE_OUT_SPEAKER_SAFE_AND_HEADPHONES:
+ if (enable)
+ name = "spkr-safe-gain-in-headphone-combo";
+ else
+ name = "speaker-safe-gain-default";
+ break;
+ case SND_DEVICE_OUT_SPEAKER_SAFE_AND_LINE:
+ if (enable)
+ name = "spkr-safe-gain-in-line-combo";
+ else
+ name = "speaker-safe-gain-default";
+ break;
+ default:
+ return;
+ }
+
+ audio_route_apply_and_update_path(adev->audio_route, name);
+}
+
int platform_set_voice_volume(void *platform, int volume)
{
struct platform_data *my_data = (struct platform_data *)platform;
diff --git a/hal/platform_api.h b/hal/platform_api.h
index 569577e..1e41358 100644
--- a/hal/platform_api.h
+++ b/hal/platform_api.h
@@ -41,6 +41,9 @@
int platform_start_voice_call(void *platform, uint32_t vsid);
int platform_stop_voice_call(void *platform, uint32_t vsid);
int platform_set_voice_volume(void *platform, int volume);
+void platform_set_speaker_gain_in_combo(struct audio_device *adev,
+ snd_device_t snd_device,
+ bool enable);
int platform_set_mic_mute(void *platform, bool state);
int platform_get_sample_rate(void *platform, uint32_t *rate);
int platform_set_device_mute(void *platform, bool state, char *dir);