Enable microphone selection
Expose the device's microphones for testing purposes through the
HAL. One has to pass a specific parameter to the `AudioManager`,
namely 'fp_test'. Accepted values are:
* 'primary_mic'
* 'secondary_mic'
* any other value to disable the microphone selection and reset
the default behaviour
Note that there is no safeguard check, if one selects a microphone,
the test mode will be entered and will only be left when the
`AudioManager` receiveds the third possible 'fp_test' value.
Issue: FPIIM-641
Issue: FP2N-293
Change-Id: I291162ca42c200ff3bed62901f71aa84ebc5ccb6
Depends-On: I5c4067702910a269386c6517d9368012066da976
(cherry picked from commit b4dac619d496add06f6dd8fb8db172153983f096)
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index c82ba34..cfb1bd5 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -947,7 +947,25 @@
} else if(usecase->id == USECASE_AUDIO_RECORD_AFE_PROXY) {
out_device = AUDIO_DEVICE_OUT_TELEPHONY_TX;
}
- in_snd_device = platform_get_input_snd_device(adev->platform, out_device);
+
+ /*
+ * Select a specific device microphone if we are in test mode.
+ */
+ switch (mFpTestMicSource) {
+ case FP_TEST_PRIMARY_MIC:
+ ALOGD("FP test selected primary mic.");
+ in_snd_device = SND_DEVICE_IN_HANDSET_MIC;
+ break;
+ case FP_TEST_SECONDARY_MIC:
+ ALOGD("FP test selected secondary mic.");
+ in_snd_device = SND_DEVICE_IN_SPEAKER_MIC;
+ break;
+ case FP_TEST_DEFAULT_MIC:
+ default:
+ ALOGV("FP test disabled");
+ in_snd_device = platform_get_input_snd_device(adev->platform, out_device);
+ break;
+ }
}
}
}
@@ -3207,6 +3225,21 @@
}
}
+ /* Microphone selection in test mode */
+ ret = str_parms_get_str(parms, FP_TEST_KEY, value, sizeof(value));
+ if (ret >= 0) {
+ if (strncmp(FP_TEST_KEY_PRIMARY, value, sizeof(value)) == 0) {
+ ALOGD("FP test requests primary mic.");
+ mFpTestMicSource = FP_TEST_PRIMARY_MIC;
+ } else if (strncmp(FP_TEST_KEY_SECONDARY, value, sizeof(value)) == 0) {
+ ALOGD("FP test requests secondary mic.");
+ mFpTestMicSource = FP_TEST_SECONDARY_MIC;
+ } else {
+ ALOGD("FP test requests to be disabled");
+ mFpTestMicSource = FP_TEST_DEFAULT_MIC;
+ }
+ }
+
audio_extn_set_parameters(adev, parms);
done:
diff --git a/hal/audio_hw.h b/hal/audio_hw.h
index be468fe..e3fdc87 100644
--- a/hal/audio_hw.h
+++ b/hal/audio_hw.h
@@ -52,6 +52,16 @@
#define MAX_SUPPORTED_CHANNEL_MASKS 2
#define DEFAULT_HDMI_OUT_CHANNELS 2
+/* Expose microphone selection for testing purposes */
+#define FP_TEST_KEY "fp_test"
+#define FP_TEST_KEY_PRIMARY "primary_mic"
+#define FP_TEST_KEY_SECONDARY "secondary_mic"
+#define FP_TEST_DEFAULT_MIC 0X00000000
+#define FP_TEST_PRIMARY_MIC 0X00000100
+#define FP_TEST_SECONDARY_MIC 0X00000200
+
+static uint32_t mFpTestMicSource = FP_TEST_DEFAULT_MIC;
+
#define SND_CARD_STATE_OFFLINE 0
#define SND_CARD_STATE_ONLINE 1