平台: freescale imx6q
系统: Android4.4
主要关注的是自下而上添加的方法,添加的顺序是:
HAL -> AudioFlinger -> AudioSystem -> AudioRecord -> JNI -> Framework
这样Application申请了AudioRecord之后就可以使用了。
HAL:
hardware/imx 目录:
diff --git a/alsa/config_aic3254.h b/alsa/config_aic3254.h
index 48465d3..ae0fff5 100644
--- a/alsa/config_aic3254.h
+++ b/alsa/config_aic3254.h
@@ -23,6 +23,10 @@
#define MIXER_AIC3254_PGA_CAP_VOLUME "PGA Capture Volume"
/*Kris, 20150702, add interface to set mic volume. }*/
+/*Kris, 20160224, add interface to set mic channel. {*/
+#define MIXER_AIC3254_LEFT_INPUT_SWITCH "Left Input Mixer IN1_L switch"
+#define MIXER_AIC3254_RIGHT_INPUT_SWITCH "Right Input Mixer IN1_R switch"
+/*Kris, 20160224, add interface to set mic channel. }*/
/* ALSA cards for IMX, these must be defined according different board / kernel config*/
static struct audio_card aic3254_card = {
diff --git a/alsa/tinyalsa_hal.c b/alsa/tinyalsa_hal.c
index 58ab54c..bb2ddaf 100644
--- a/alsa/tinyalsa_hal.c
+++ b/alsa/tinyalsa_hal.c
@@ -2867,6 +2867,31 @@ static int adev_set_mic_volume(struct audio_hw_device *dev, int volume)
}
/*Kris, 20150702, add interface to set mic volume. }*/
+/*Kris, 20160224, add interface to set mic channel. {*/
+static int adev_set_mic_channel(struct audio_hw_device *dev, int channel)
+{
+ struct imx_audio_device *adev = (struct imx_audio_device *)dev;
+ struct mixer_ctl *ctl;
+
+ ALOGV("adev_set_input_channel channel:%d", channel);
+
+ if (!channel) {
+ /*left input channel open.*/
+ ctl = mixer_get_ctl_by_name(adev->mixer[0], MIXER_AIC3254_LEFT_INPUT_SWITCH);
+ mixer_ctl_set_value(ctl, 0, 1);
+ ctl = mixer_get_ctl_by_name(adev->mixer[0], MIXER_AIC3254_RIGHT_INPUT_SWITCH);
+ mixer_ctl_set_value(ctl, 0, 0);
+ } else {
+ /*right input channel open.*/
+ ctl = mixer_get_ctl_by_name(adev->mixer[0], MIXER_AIC3254_LEFT_INPUT_SWITCH);
+ mixer_ctl_set_value(ctl, 0, 0);
+ ctl = mixer_get_ctl_by_name(adev->mixer[0], MIXER_AIC3254_RIGHT_INPUT_SWITCH);
+ mixer_ctl_set_value(ctl, 0, 1);
+ }
+
+ return 0;
+}
+/*Kris, 20160224, add interface to set mic channel. }*/
static int adev_set_master_volume(struct audio_hw_device *dev, float volume)
{
@@ -3222,6 +3247,9 @@ static int adev_open(const hw_module_t* module, const char* name,
/*Kris, 20150702, add interface to set mic volume. {*/
adev->hw_device.set_mic_volume = adev_set_mic_volume;
/*Kris, 20150702, add interface to set mic volume. }*/
+ /*Kris, 20160224, add interface to set mic channel. {*/
+ adev->hw_device.set_mic_channel = adev_set_mic_channel;
+ /