summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarter Hsu <carterhsu@google.com>2023-09-20 09:56:16 +0800
committerCarter Hsu <carterhsu@google.com>2023-09-21 02:02:51 +0000
commitc9dd2fed370952e9b995322dfb29a2f74f0e57f4 (patch)
tree1743b409668b3f9bd40ce76fd786e13b4e96479d
parent09fa9ec757b637967c9eed486274a9ba9ed8a3e9 (diff)
downloadaoc-c9dd2fed370952e9b995322dfb29a2f74f0e57f4.tar.gz
Bug: 299407821 Test: 1. Verified VoIP record(incall_cap0) only scenario on T6 Pro 2. Verified the live caption(incall_cap0) for voice-call on C10 3. atest VtsHalAudioV7_1TargetTest Change-Id: Ib1c3e9760390d8a733b1027210ff1561d55256b4 Signed-off-by: Carter Hsu <carterhsu@google.com>
-rw-r--r--alsa/aoc_alsa.h4
-rw-r--r--alsa/aoc_alsa_incall.c16
2 files changed, 19 insertions, 1 deletions
diff --git a/alsa/aoc_alsa.h b/alsa/aoc_alsa.h
index 3cc3da9..9272bbb 100644
--- a/alsa/aoc_alsa.h
+++ b/alsa/aoc_alsa.h
@@ -196,7 +196,8 @@ enum aec_ref_source {
BT_PLAYBACK,
NUM_AEC_REF_SOURCE
};
-enum { INCALL_CAPTURE_OFF = 0, INCALL_CAPTURE_UL, INCALL_CAPTURE_DL, INCALL_CAPTURE_UL_DL };
+enum { INCALL_CAPTURE_OFF = 0, INCALL_CAPTURE_UL, INCALL_CAPTURE_DL, INCALL_CAPTURE_UL_DL,
+ INCALL_CAPTURE_3MIC };
enum { NONBLOCKING = 0, BLOCKING = 1 };
enum { STOP = 0, START };
enum { PLAYBACK_MODE, VOICE_TX_MODE, VOICE_RX_MODE, HAPTICS_MODE, OFFLOAD_MODE };
@@ -300,6 +301,7 @@ struct aoc_alsa_stream {
int params_rate; /* Sampling rate */
int pcm_format_width; /* Number of bits */
bool pcm_float_fmt; /* Floating point */
+ bool reused_for_voip;
struct vm_area_struct *vma; /* for MMAP */
unsigned int period_size;
diff --git a/alsa/aoc_alsa_incall.c b/alsa/aoc_alsa_incall.c
index eb8be56..29e1bbd 100644
--- a/alsa/aoc_alsa_incall.c
+++ b/alsa/aoc_alsa_incall.c
@@ -239,6 +239,10 @@ static int snd_aoc_pcm_open(struct snd_soc_component *component,
/* TODO: refactor needed on mapping between device number and entrypoint */
alsa_stream->entry_point_idx = (idx == 7) ? HAPTICS : idx;
+ if (rtd->dai_link->id == IDX_INCALL_CAP0_TX &&
+ chip->incall_capture_state[0] == INCALL_CAPTURE_3MIC) {
+ alsa_stream->reused_for_voip = true;
+ }
mutex_unlock(&chip->audio_mutex);
return 0;
@@ -319,6 +323,12 @@ static int snd_aoc_pcm_close(struct snd_soc_component *component,
*/
chip->opened &= ~(1 << alsa_stream->idx);
+ if (alsa_stream->reused_for_voip) {
+ /* Userspace should only select one EP for VoIP capture and one EP for
+ * VoIP playback.
+ */
+ teardown_voipcall(alsa_stream);
+ }
mutex_unlock(&chip->audio_mutex);
return 0;
@@ -421,6 +431,12 @@ static int snd_aoc_pcm_prepare(struct snd_soc_component *component,
alsa_stream->buffer_size, alsa_stream->period_size, alsa_stream->pos,
runtime->frame_bits);
+ if (alsa_stream->reused_for_voip) {
+ /* Userspace should only select one EP for VoIP capture and one EP for
+ * VoIP playback.
+ */
+ prepare_voipcall(alsa_stream);
+ }
mutex_unlock(&chip->audio_mutex);
return 0;
}