From 97ca55da44ab4b32ed3c3a36e7acd1731a66a2c1 Mon Sep 17 00:00:00 2001
From: Jacopo Maroli <info@jacopomaroli.com>
Date: Tue, 31 Jan 2023 21:22:50 +0000
Subject: [PATCH] fix channel ordering

---
 ac101.c           | 2 ++
 ac108.c           | 9 +++------
 seeed-voicecard.c | 8 ++++----
 3 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/ac101.c b/ac101.c
index 23837a7..88a9919 100644
--- a/ac101.c
+++ b/ac101.c
@@ -1280,11 +1280,13 @@ int ac101_trigger(struct snd_pcm_substream *substream, int cmd,
 			ret = ret || ac101_update_bits(codec, MOD_RST_CTRL, (0x1<<MOD_RESET_AIF1), (0x1<<MOD_RESET_AIF1));
 		}
 		spin_unlock_irqrestore(&ac10x->lock, flags);
+		ac101_set_clock(1, substream, cmd, dai);
 		#endif
 		break;
 	case SNDRV_PCM_TRIGGER_STOP:
 	case SNDRV_PCM_TRIGGER_SUSPEND:
 	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
+		ac101_set_clock(0, NULL, 0, NULL);
 		break;
 	default:
 		ret = -EINVAL;
diff --git a/ac108.c b/ac108.c
index d5dd12d..4048d70 100644
--- a/ac108.c
+++ b/ac108.c
@@ -999,7 +999,7 @@ static int ac108_set_clock(int y_start_n_stop, struct snd_pcm_substream *substre
 
 	/* spin_lock move to machine trigger */
 
-	if (y_start_n_stop && ac10x->i2c101 && _MASTER_MULTI_CODEC == _MASTER_AC101) {
+	if (ac10x->i2c101 && _MASTER_MULTI_CODEC == _MASTER_AC101) {
 		ac101_trigger(substream, cmd, dai);
 	}
 	if (y_start_n_stop && ac10x->sysclk_en == 0) {
@@ -1073,15 +1073,12 @@ static int ac108_trigger(struct snd_pcm_substream *substream, int cmd,
 			ac108_multi_update_bits(I2S_CTRL, 0x1 << TXEN | 0x1 << GEN, 0x0 << TXEN | 0x0 << GEN, ac10x);
 		}
 		spin_unlock_irqrestore(&ac10x->lock, flags);
-
-		/* delayed clock starting, move to machine trigger() */
+		ac108_set_clock(1, substream, cmd, dai);
 		break;
 	case SNDRV_PCM_TRIGGER_STOP:
 	case SNDRV_PCM_TRIGGER_SUSPEND:
 	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
-		if (ac10x->i2c101 && _MASTER_MULTI_CODEC == _MASTER_AC101) {
-			ac101_trigger(substream, cmd, dai);
-		}
+		ac108_set_clock(0, substream, cmd, dai);
 		break;
 	default:
 		ret = -EINVAL;
diff --git a/seeed-voicecard.c b/seeed-voicecard.c
index 399bc7e..31bba47 100644
--- a/seeed-voicecard.c
+++ b/seeed-voicecard.c
@@ -231,8 +231,8 @@ static int seeed_voice_card_trigger(struct snd_pcm_substream *substream, int cmd
 		/* I know it will degrades performance, but I have no choice */
 		spin_lock_irqsave(&priv->lock, flags);
 		#endif
-		if (_set_clock[SNDRV_PCM_STREAM_CAPTURE]) _set_clock[SNDRV_PCM_STREAM_CAPTURE](1, substream, cmd, dai);
-		if (_set_clock[SNDRV_PCM_STREAM_PLAYBACK]) _set_clock[SNDRV_PCM_STREAM_PLAYBACK](1, substream, cmd, dai);
+		// if (_set_clock[SNDRV_PCM_STREAM_CAPTURE]) _set_clock[SNDRV_PCM_STREAM_CAPTURE](1, substream, cmd, dai);
+		// if (_set_clock[SNDRV_PCM_STREAM_PLAYBACK]) _set_clock[SNDRV_PCM_STREAM_PLAYBACK](1, substream, cmd, dai);
 		#if CONFIG_AC10X_TRIG_LOCK
 		spin_unlock_irqrestore(&priv->lock, flags);
 		#endif
@@ -252,8 +252,8 @@ static int seeed_voice_card_trigger(struct snd_pcm_substream *substream, int cmd
 			if (0 != schedule_work(&priv->work_codec_clk)) {
 			}
 		} else {
-			if (_set_clock[SNDRV_PCM_STREAM_CAPTURE]) _set_clock[SNDRV_PCM_STREAM_CAPTURE](0, NULL, 0, NULL); /* not using 2nd to 4th arg if 1st == 0 */
-			if (_set_clock[SNDRV_PCM_STREAM_PLAYBACK]) _set_clock[SNDRV_PCM_STREAM_PLAYBACK](0, NULL, 0, NULL); /* not using 2nd to 4th arg if 1st == 0 */
+			// if (_set_clock[SNDRV_PCM_STREAM_CAPTURE]) _set_clock[SNDRV_PCM_STREAM_CAPTURE](0, NULL, 0, NULL); /* not using 2nd to 4th arg if 1st == 0 */
+			// if (_set_clock[SNDRV_PCM_STREAM_PLAYBACK]) _set_clock[SNDRV_PCM_STREAM_PLAYBACK](0, NULL, 0, NULL); /* not using 2nd to 4th arg if 1st == 0 */
 		}
 		break;
 	default: