From bff3d3009b0d3a2be3ed92e4817fcabee9e76955 Mon Sep 17 00:00:00 2001
From: huangcm <1263938474@qq.com>
Date: Sat, 26 Apr 2025 03:02:48 +0000
Subject: [PATCH] feat(audio): fix audio pop pro

---
 longan/kernel/linux-4.9/sound/soc/sunxi/sun50iw10-codec.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/longan/kernel/linux-4.9/sound/soc/sunxi/sun50iw10-codec.c b/longan/kernel/linux-4.9/sound/soc/sunxi/sun50iw10-codec.c
index 42687c9..0ff96ff 100644
--- a/longan/kernel/linux-4.9/sound/soc/sunxi/sun50iw10-codec.c
+++ b/longan/kernel/linux-4.9/sound/soc/sunxi/sun50iw10-codec.c
@@ -888,7 +888,7 @@
 		       0xFF, 0, adc_vol_tlv),
 	/* Headphone Gain */
 	SOC_SINGLE_TLV("headphone gain", SUNXI_DAC_REG, HEADPHONE_GAIN,
-			0x7, 1, headphone_gain_tlv),
+			0x0, 1, headphone_gain_tlv),
 
 	SOC_SINGLE_BOOL_EXT("audiocodec rx_sync switch", 0,
 		sunxi_codec_rx_sync_get_data, sunxi_codec_rx_sync_put_data),
@@ -1333,6 +1333,7 @@
 				int cmd, struct snd_soc_dai *dai)
 {
 	struct sunxi_codec_info *sunxi_codec = snd_soc_codec_get_drvdata(dai->codec);
+    struct codec_spk_config *spk_cfg = &(sunxi_codec->spk_config);
 
 	switch (cmd) {
 	case SNDRV_PCM_TRIGGER_START:
@@ -1347,10 +1348,19 @@
 			if (sunxi_codec->rx_sync_en)
 				sunxi_rx_sync_control(RX_SYNC_AUDIOCODEC, 1);
 		}
+
+        if (spk_cfg->used) {
+            gpio_set_value(spk_cfg->spk_gpio, spk_cfg->pa_level);
+            /* time delay to wait spk pa work fine */
+            // msleep(spk_cfg->pa_msleep);
+        }
 		break;
 	case SNDRV_PCM_TRIGGER_STOP:
 	case SNDRV_PCM_TRIGGER_SUSPEND:
 	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
+        if (spk_cfg->used)
+            gpio_set_value(spk_cfg->spk_gpio, !(spk_cfg->pa_level));
+
 		if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
 			regmap_update_bits(sunxi_codec->regmap, SUNXI_DAC_FIFOC,
 				(1 << DAC_DRQ_EN), (0 << DAC_DRQ_EN));

--
Gitblit v1.6.2