diff options
author | millerliang <millerliang@google.com> | 2023-03-21 23:21:04 +0800 |
---|---|---|
committer | millerliang <millerliang@google.com> | 2024-03-29 04:59:20 +0000 |
commit | d17e905f29d7b3fadb3c83008a1d26af725d4737 (patch) | |
tree | b68cd5dc721b46ac6fadb44e814510b8979ca06d | |
parent | 6a8e1fae7aedf278186d28088f2bbf7a2c066cd7 (diff) | |
download | aoc-android-gs-shusky-5.15-android15-beta.tar.gz |
alsa: send the paramters to AoC for interrupt-drivenandroid-15-beta-2_r0.8android-15-beta-2_r0.7android-gs-shusky-5.15-android15-betaandroid-gs-akita-5.15-android15-beta
1. Sending the buffer size and period size of each entry point
to AoC for interrupt-driven.
AoC will set the thresold of the read/write pointer in the
ring buffer according to the parameters.
The detail information is in go/audio-int-driven-v2
2. Enlarge period_bytes_max of snd_aoc_playback_hw
Bug: 200718439
Bug: 249436330
Test: PCM playback, PCM recording, hifi, voip, incallscren
Change-Id: If7753e62104452d0eafc635db9b6c5721dfa6215
Signed-off-by: Miller Liang <millerliang@google.com>
-rw-r--r-- | alsa/aoc_alsa.h | 5 | ||||
-rw-r--r-- | alsa/aoc_alsa_hw.c | 81 | ||||
-rw-r--r-- | alsa/aoc_alsa_incall.c | 15 | ||||
-rw-r--r-- | alsa/aoc_alsa_pcm.c | 7 | ||||
-rw-r--r-- | alsa/aoc_alsa_voip.c | 10 |
5 files changed, 112 insertions, 6 deletions
diff --git a/alsa/aoc_alsa.h b/alsa/aoc_alsa.h index 24a21ed..c7ea617 100644 --- a/alsa/aoc_alsa.h +++ b/alsa/aoc_alsa.h @@ -388,6 +388,11 @@ int aoc_audio_close(struct aoc_alsa_stream *alsa_stream); int aoc_audio_set_params(struct aoc_alsa_stream *alsa_stream, uint32_t channels, uint32_t samplerate, uint32_t bps, bool pcm_float_fmt, int source_mode); +#if !IS_ENABLED(CONFIG_SOC_GS101) +int aoc_voip_set_params(struct aoc_alsa_stream *alsa_stream); +int aoc_hifi_incall_set_params(struct aoc_alsa_stream *alsa_stream); +#endif + int aoc_audio_start(struct aoc_alsa_stream *alsa_stream); int aoc_audio_stop(struct aoc_alsa_stream *alsa_stream); int aoc_audio_incall_start(struct aoc_alsa_stream *alsa_stream); diff --git a/alsa/aoc_alsa_hw.c b/alsa/aoc_alsa_hw.c index 1057349..4552841 100644 --- a/alsa/aoc_alsa_hw.c +++ b/alsa/aoc_alsa_hw.c @@ -1670,6 +1670,46 @@ int aoc_audio_path_close(struct aoc_chip *chip, int src, int dest, bool be_on) hw_id_to_sink(dest_idx), STOP, chip); } +#if !IS_ENABLED(CONFIG_SOC_GS101) +static int aoc_audio_playback_set_params2(struct aoc_alsa_stream *alsa_stream, int source_mode) +{ + struct CMD_AUDIO_OUTPUT_EP_SETUP2 cmd; + + AocCmdHdrSet(&(cmd.parent), CMD_AUDIO_OUTPUT_EP_SETUP2_ID, sizeof(cmd)); + cmd.channel = alsa_stream->entry_point_idx; + + cmd.buffer_size = alsa_stream->buffer_size; + cmd.period_size = alsa_stream->period_size; + + cmd.mode = source_mode; + + pr_debug("audio set param2:idx %d, buffer_size=%d, period_size=%d\n", cmd.channel, + cmd.buffer_size, cmd.period_size); + return aoc_audio_control(CMD_OUTPUT_CHANNEL, (uint8_t *)&cmd, + sizeof(cmd), NULL, alsa_stream->chip); +} + +int aoc_hifi_incall_set_params(struct aoc_alsa_stream *alsa_stream) +{ + int source_mode; + + if (alsa_stream->stream_type == INCALL) + source_mode = ENTRYPOINT_MODE_INCALL_SCREEN; + else + source_mode = ENTRYPOINT_MODE_HIFI; + + return aoc_audio_playback_set_params2(alsa_stream, source_mode); +} + +int aoc_voip_set_params(struct aoc_alsa_stream *alsa_stream) +{ + int source_mode; + + source_mode = ENTRYPOINT_MODE_VOIP; + return aoc_audio_playback_set_params2(alsa_stream, source_mode); +} +#endif + static int aoc_audio_playback_set_params(struct aoc_alsa_stream *alsa_stream, uint32_t channels, uint32_t samplerate, uint32_t bps, bool pcm_float_fmt, @@ -1743,12 +1783,43 @@ static int aoc_audio_playback_set_params(struct aoc_alsa_stream *alsa_stream, err = aoc_audio_control(CMD_OUTPUT_CHANNEL, (uint8_t *)&cmd, sizeof(cmd), NULL, alsa_stream->chip); - if (err < 0) + if (err < 0) { pr_err("ERR:%d in playback set parameters\n", err); + goto exit; + } + +#if !IS_ENABLED(CONFIG_SOC_GS101) + err = aoc_audio_playback_set_params2(alsa_stream, cmd.mode); + if (err < 0) + pr_err("ERR:%d in playback set parameters2\n", err); +#endif +exit: return err; } +#if !IS_ENABLED(CONFIG_SOC_GS101) +static int aoc_audio_capture_set_params2(struct aoc_alsa_stream *alsa_stream) { + struct CMD_AUDIO_INPUT_MIC_RECORD_AP_SET_PARAMS2 cmd; + int cmd_id; + + cmd.channel = alsa_stream->idx; + cmd.buffer_size = alsa_stream->buffer_size; + cmd.period_size = alsa_stream->period_size; + + if (alsa_stream->idx == UC_ULTRASONIC_RECORD) + cmd_id = CMD_AUDIO_INPUT_ULTRASONIC_AP_SET_PARAMS2_ID; + else + cmd_id = CMD_AUDIO_INPUT_MIC_RECORD_AP_SET_PARAMS2_ID; + AocCmdHdrSet(&(cmd.parent), cmd_id, sizeof(cmd)); + + pr_debug("audio set param2:idx %d, buffer_size=%d, period_size=%d\n", cmd.channel, + cmd.buffer_size, cmd.period_size); + return aoc_audio_control(CMD_INPUT_CHANNEL, (uint8_t *)&cmd, + sizeof(cmd), NULL, alsa_stream->chip); +} +#endif + static int aoc_audio_capture_set_params(struct aoc_alsa_stream *alsa_stream, uint32_t channels, uint32_t samplerate, uint32_t bps, bool pcm_float_fmt) { @@ -1867,6 +1938,14 @@ static int aoc_audio_capture_set_params(struct aoc_alsa_stream *alsa_stream, uin goto exit; } +#if !IS_ENABLED(CONFIG_SOC_GS101) + err = aoc_audio_capture_set_params2(alsa_stream); + if (err < 0) { + pr_err("ERR:%d in capture parameter2 setup\n", err); + goto exit; + } +#endif + chip->capture_param_set |= (1 << alsa_stream->idx); if (alsa_stream->idx == UC_ULTRASONIC_RECORD) { diff --git a/alsa/aoc_alsa_incall.c b/alsa/aoc_alsa_incall.c index 29e1bbd..7aa3404 100644 --- a/alsa/aoc_alsa_incall.c +++ b/alsa/aoc_alsa_incall.c @@ -397,12 +397,25 @@ static int snd_aoc_pcm_prepare(struct snd_soc_component *component, struct aoc_service_dev *dev = alsa_stream->dev; struct aoc_chip *chip = alsa_stream->chip; int channels; +#if !IS_ENABLED(CONFIG_SOC_GS101) + int err; +#endif aoc_timer_stop_sync(alsa_stream); if (mutex_lock_interruptible(&chip->audio_mutex)) return -EINTR; + alsa_stream->buffer_size = snd_pcm_lib_buffer_bytes(substream); + alsa_stream->period_size = snd_pcm_lib_period_bytes(substream); + +#if !IS_ENABLED(CONFIG_SOC_GS101) + /* Set the audio formats and flush the DRAM buffer */ + err = aoc_hifi_incall_set_params(alsa_stream); + if (err < 0) + pr_notice("Failed to set %d Hifi/Incall params\n", err); +#endif + channels = alsa_stream->channels; dev_dbg(component->dev, "channels = %d, rate = %d, bits = %d, float-fmt = %d\n", channels, @@ -413,8 +426,6 @@ static int snd_aoc_pcm_prepare(struct snd_soc_component *component, /* in preparation of the stream */ /* aoc_audio_set_ctls(alsa_stream->chip); */ - alsa_stream->buffer_size = snd_pcm_lib_buffer_bytes(substream); - alsa_stream->period_size = snd_pcm_lib_period_bytes(substream); alsa_stream->pos = 0; alsa_stream->prev_pos = 0; alsa_stream->pos_delta = 0; diff --git a/alsa/aoc_alsa_pcm.c b/alsa/aoc_alsa_pcm.c index 98d4bae..31ebaa9 100644 --- a/alsa/aoc_alsa_pcm.c +++ b/alsa/aoc_alsa_pcm.c @@ -183,7 +183,7 @@ static struct snd_pcm_hardware snd_aoc_playback_hw = { .channels_max = 6, .buffer_bytes_max = 16384 * 6, .period_bytes_min = 16, - .period_bytes_max = 11520, + .period_bytes_max = 15360, .periods_min = 2, .periods_max = 1024 * 6, }; @@ -568,6 +568,9 @@ static int snd_aoc_pcm_prepare(struct snd_soc_component *component, } } + alsa_stream->buffer_size = snd_pcm_lib_buffer_bytes(substream); + alsa_stream->period_size = snd_pcm_lib_period_bytes(substream); + /* Set the audio formats and flush the DRAM buffer */ err = aoc_audio_set_params(alsa_stream, channels, alsa_stream->params_rate, alsa_stream->pcm_format_width, alsa_stream->pcm_float_fmt, @@ -585,8 +588,6 @@ static int snd_aoc_pcm_prepare(struct snd_soc_component *component, /* in preparation of the stream */ /* aoc_audio_set_ctls(alsa_stream->chip); */ - alsa_stream->buffer_size = snd_pcm_lib_buffer_bytes(substream); - alsa_stream->period_size = snd_pcm_lib_period_bytes(substream); alsa_stream->pos = 0; alsa_stream->prev_pos = 0; alsa_stream->pos_delta = 0; diff --git a/alsa/aoc_alsa_voip.c b/alsa/aoc_alsa_voip.c index f9f85ba..b186330 100644 --- a/alsa/aoc_alsa_voip.c +++ b/alsa/aoc_alsa_voip.c @@ -376,6 +376,16 @@ static int snd_aoc_pcm_prepare(struct snd_soc_component *component, if (mutex_lock_interruptible(&chip->audio_mutex)) return -EINTR; + alsa_stream->buffer_size = snd_pcm_lib_buffer_bytes(substream); + alsa_stream->period_size = snd_pcm_lib_period_bytes(substream); + +#if !IS_ENABLED(CONFIG_SOC_GS101) + /* Set the audio formats and flush the DRAM buffer */ + err = aoc_voip_set_params(alsa_stream); + if (err < 0) + pr_notice("Failed to set %d VoIP Rx params\n", err); +#endif + channels = alsa_stream->channels; pr_debug("channels = %d, rate = %d, bits = %d, float-fmt = %d\n", |