hal: fm: add parameter to set mute options
Add parameter to handle mute options, this is required to
control fm mute in device loopback mode without affecting
other music streams.
CRs-Fixed: 963849
Change-Id: I1729d0bd3cff40670444a8806a05c7304d4ca6aa
diff --git a/hal/audio_extn/fm.c b/hal/audio_extn/fm.c
index 6381e68..54700ba 100644
--- a/hal/audio_extn/fm.c
+++ b/hal/audio_extn/fm.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
* Not a Contribution.
*
* Copyright (C) 2013 The Android Open Source Project
@@ -35,6 +35,7 @@
#define AUDIO_PARAMETER_KEY_HANDLE_FM "handle_fm"
#define AUDIO_PARAMETER_KEY_FM_VOLUME "fm_volume"
#define AUDIO_PARAMETER_KEY_REC_PLAY_CONC "rec_play_conc_on"
+#define AUDIO_PARAMETER_KEY_FM_MUTE "fm_mute"
#define FM_LOOPBACK_DRAIN_TIME_MS 2
static struct pcm_config pcm_config_fm = {
@@ -52,6 +53,7 @@
struct pcm *fm_pcm_rx;
struct pcm *fm_pcm_tx;
bool is_fm_running;
+ bool is_fm_muted;
float fm_volume;
bool restart_fm;
int scard_state;
@@ -62,6 +64,7 @@
.fm_pcm_tx = NULL,
.fm_volume = 0,
.is_fm_running = 0,
+ .is_fm_muted = 0,
.restart_fm = 0,
.scard_state = SND_CARD_STATE_ONLINE,
};
@@ -86,6 +89,12 @@
if (persist)
fmmod.fm_volume = value;
+ if (fmmod.is_fm_muted == true && vol > 0) {
+ ALOGD("%s: fm is muted, applying '0' volume instead of '%d'.",
+ __func__, vol);
+ vol = 0;
+ }
+
if (!fmmod.is_fm_running) {
ALOGV("%s: FM not active, ignoring set_fm_volume call", __func__);
return -EIO;
@@ -286,6 +295,17 @@
fm_set_volume(adev, vol, true);
}
+ ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_FM_MUTE,
+ value, sizeof(value));
+ if (ret >= 0) {
+ if (value[0] == '1')
+ fmmod.is_fm_muted = true;
+ else
+ fmmod.is_fm_muted = false;
+ ALOGV("%s: set_fm_volume from param mute", __func__);
+ fm_set_volume(adev, fmmod.fm_volume, false);
+ }
+
#ifdef RECORD_PLAY_CONCURRENCY
ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_REC_PLAY_CONC,
value, sizeof(value));