From d52d2bd85ad4d1cfc37a87a6b7bfcc37207c6025 Mon Sep 17 00:00:00 2001 From: Ali Tekin <140681099+alitekin-saha@users.noreply.github.com> Date: Thu, 26 Sep 2024 10:51:13 +0300 Subject: [PATCH 1284/1350] googlevoicehat: Fix playback muting when recording is stopped Fixed audio amplifier control logic in the voicehat trigger function Resolves improper handling of the SDMODE pin, which caused issues when the microphone and speaker were used simultaneously. The playback stream check is now correctly based on `substream->stream == SNDRV_PCM_STREAM_PLAYBACK`, ensuring proper control of the audio amplifier. Signed-off-by: Ali Tekin --- sound/soc/bcm/googlevoicehat-codec.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) --- a/sound/soc/bcm/googlevoicehat-codec.c +++ b/sound/soc/bcm/googlevoicehat-codec.c @@ -95,8 +95,7 @@ static int voicehat_daiops_trigger(struc struct snd_soc_dai *dai) { struct snd_soc_component *component = dai->component; - struct voicehat_priv *voicehat = - snd_soc_component_get_drvdata(component); + struct voicehat_priv *voicehat = snd_soc_component_get_drvdata(component); if (voicehat->sdmode_delay_jiffies == 0) return 0; @@ -109,7 +108,7 @@ static int voicehat_daiops_trigger(struc case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_RESUME: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - if (dai->stream[SNDRV_PCM_STREAM_PLAYBACK].active) { + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { dev_info(dai->dev, "Enabling audio amp...\n"); queue_delayed_work( system_power_efficient_wq, @@ -120,7 +119,7 @@ static int voicehat_daiops_trigger(struc case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - if (dai->stream[SNDRV_PCM_STREAM_PLAYBACK].active) { + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { cancel_delayed_work(&voicehat->enable_sdmode_work); dev_info(dai->dev, "Disabling audio amp...\n"); gpiod_set_value(voicehat->sdmode_gpio, 0);