diff options
author | yixuanjiang <yixuanjiang@google.com> | 2023-11-21 17:23:43 +0800 |
---|---|---|
committer | yixuanjiang <yixuanjiang@google.com> | 2023-11-30 17:25:09 +0800 |
commit | c69225db7dde64287e2cdb8d17472cc65324f999 (patch) | |
tree | 8f12f7281ebfd884ee6cfb002e4368952b59e4dd | |
parent | 6d2d774d935dffec66058aabecf3699ebef9bb8f (diff) | |
download | aoc-c69225db7dde64287e2cdb8d17472cc65324f999.tar.gz |
alsa: add support for microphone mask updateandroid-u-qpr2-beta-3_r0.7android-u-qpr2-beta-3_r0.6android-u-qpr2-beta-3_r0.5android-u-qpr2-beta-3_r0.4android-u-qpr2-beta-3_r0.3android-u-qpr2-beta-3_r0.2
Support dynamic change PDM mask for normal recording
and voice uplink. In AoC with differnt projects.
PDM and microphone may not map with same order, so it
need to adjust mask order. Add control to adjust it.
Bug: 299035199
Change-Id: I6c425126f9151b7433034718abe231e084ecd555
Signed-off-by: yixuanjiang <yixuanjiang@google.com>
-rw-r--r-- | alsa/aoc_alsa.h | 1 | ||||
-rw-r--r-- | alsa/aoc_alsa_hw.c | 27 |
2 files changed, 28 insertions, 0 deletions
diff --git a/alsa/aoc_alsa.h b/alsa/aoc_alsa.h index 2ac015c..0707e05 100644 --- a/alsa/aoc_alsa.h +++ b/alsa/aoc_alsa.h @@ -484,6 +484,7 @@ int aoc_incall_init(void); void aoc_incall_exit(void); int aoc_voip_init(void); void aoc_voip_exit(void); +int aoc_audio_mic_mask_set(struct aoc_chip *chip, bool is_voice); int aoc_audio_us_record(struct aoc_chip *chip, bool enable); #endif diff --git a/alsa/aoc_alsa_hw.c b/alsa/aoc_alsa_hw.c index adbdbcd..db0230d 100644 --- a/alsa/aoc_alsa_hw.c +++ b/alsa/aoc_alsa_hw.c @@ -422,6 +422,10 @@ int aoc_audio_capture_mic_prepare(struct aoc_chip *chip) goto exit; } + /* Update mask before start capture */ + if (mic_input_source == AP_INPUT_PROCESSOR_MIC_INPUT_INDEX) + aoc_audio_mic_mask_set(chip, false); + // CMD_AUDIO_INPUT_AP_INPUT_START_ID with mic_input_source pr_info("mic_input_source = %d\n", mic_input_source); @@ -3014,6 +3018,12 @@ static int aoc_telephony_mic_open(struct aoc_chip *chip, int mic) } mic_input_source = hw_id_to_phone_mic_source(mic); + + /* Update mask before start capture */ + if (mic_input_source == MODEM_MIC_INPUT_INDEX || + mic_input_source == MODEM_INCALL_INPUT_INDEX) + aoc_audio_mic_mask_set(chip, true); + pr_info("open telephony mic: %d - %d\n", mic_input_source, mic); if (mic_input_source != NULL_PATH) { err = aoc_audio_modem_mic_input(chip, START, mic_input_source); @@ -3771,3 +3781,20 @@ int aoc_audio_set_chre_src_aec_timeout(struct aoc_chip *chip, int timeout) return 0; } } + +/* Update PDM mic mask */ +int aoc_audio_mic_mask_set(struct aoc_chip *chip, bool is_voice) +{ + uint32_t value = UINT_MAX; + uint8_t *mask = (uint8_t *)(&value); + int key = is_voice, i; + const int cmd_id = CMD_AUDIO_INPUT_SET_PARAMETER_ID; + const int block = 139; /* ABLOCK_INPUT_PDM_MIC */ + const int component = ASP_ID_NONE; + const int total_lists = min(NUM_OF_BUILTIN_MIC, (int)sizeof(uint32_t)); + + for (i = 0; i < total_lists; i++) + mask[i] = chip->buildin_mic_id_list[i]; + + return aoc_audio_set_parameters(cmd_id, block, component, key, value, chip); +} |