linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, "Bard Liao" <bard.liao@intel.com>,
	"Péter Ujfalusi" <peter.ujfalusi@linux.intel.com>,
	"Rander Wang" <rander.wang@intel.com>,
	"Pierre-Louis Bossart" <pierre-louis.bossart@linux.intel.com>,
	"Mark Brown" <broonie@kernel.org>,
	"Sasha Levin" <sashal@kernel.org>
Subject: [PATCH 5.13 13/35] ASoC: Intel: boards: fix xrun issue on platform with max98373
Date: Fri,  6 Aug 2021 10:16:56 +0200	[thread overview]
Message-ID: <20210806081114.153290079@linuxfoundation.org> (raw)
In-Reply-To: <20210806081113.718626745@linuxfoundation.org>

From: Rander Wang <rander.wang@intel.com>

[ Upstream commit 33c8516841ea4fa12fdb8961711bf95095c607ee ]

On TGL platform with max98373 codec the trigger start sequence is
fe first, then codec component and sdw link is the last. Recently
a delay was introduced in max98373 codec driver and this resulted
to the start of sdw stream transmission was delayed and the data
transmitted by fw can't be consumed by sdw controller, so xrun happened.

Adding delay in trigger function is a bad idea. This patch enable spk
pin in prepare function and disable it in hw_free to avoid xrun issue
caused by delay in trigger.

Fixes: 3a27875e91fb ("ASoC: max98373: Added 30ms turn on/off time delay")
BugLink: https://github.com/thesofproject/sof/issues/4066
Reviewed-by: Bard Liao <bard.liao@intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Signed-off-by: Rander Wang <rander.wang@intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20210625205042.65181-2-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 sound/soc/intel/boards/sof_sdw_max98373.c | 81 +++++++++++++++--------
 1 file changed, 53 insertions(+), 28 deletions(-)

diff --git a/sound/soc/intel/boards/sof_sdw_max98373.c b/sound/soc/intel/boards/sof_sdw_max98373.c
index 0e7ed906b341..25daef910aee 100644
--- a/sound/soc/intel/boards/sof_sdw_max98373.c
+++ b/sound/soc/intel/boards/sof_sdw_max98373.c
@@ -55,43 +55,68 @@ static int spk_init(struct snd_soc_pcm_runtime *rtd)
 	return ret;
 }
 
-static int max98373_sdw_trigger(struct snd_pcm_substream *substream, int cmd)
+static int mx8373_enable_spk_pin(struct snd_pcm_substream *substream, bool enable)
 {
+	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
+	struct snd_soc_dai *codec_dai;
+	struct snd_soc_dai *cpu_dai;
 	int ret;
+	int j;
 
-	switch (cmd) {
-	case SNDRV_PCM_TRIGGER_START:
-	case SNDRV_PCM_TRIGGER_RESUME:
-	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
-		/* enable max98373 first */
-		ret = max_98373_trigger(substream, cmd);
-		if (ret < 0)
-			break;
-
-		ret = sdw_trigger(substream, cmd);
-		break;
-	case SNDRV_PCM_TRIGGER_STOP:
-	case SNDRV_PCM_TRIGGER_SUSPEND:
-	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
-		ret = sdw_trigger(substream, cmd);
-		if (ret < 0)
-			break;
-
-		ret = max_98373_trigger(substream, cmd);
-		break;
-	default:
-		ret = -EINVAL;
-		break;
+	/* set spk pin by playback only */
+	if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
+		return 0;
+
+	cpu_dai = asoc_rtd_to_cpu(rtd, 0);
+	for_each_rtd_codec_dais(rtd, j, codec_dai) {
+		struct snd_soc_dapm_context *dapm =
+				snd_soc_component_get_dapm(cpu_dai->component);
+		char pin_name[16];
+
+		snprintf(pin_name, ARRAY_SIZE(pin_name), "%s Spk",
+			 codec_dai->component->name_prefix);
+
+		if (enable)
+			ret = snd_soc_dapm_enable_pin(dapm, pin_name);
+		else
+			ret = snd_soc_dapm_disable_pin(dapm, pin_name);
+
+		if (!ret)
+			snd_soc_dapm_sync(dapm);
 	}
 
-	return ret;
+	return 0;
+}
+
+static int mx8373_sdw_prepare(struct snd_pcm_substream *substream)
+{
+	int ret = 0;
+
+	/* according to soc_pcm_prepare dai link prepare is called first */
+	ret = sdw_prepare(substream);
+	if (ret < 0)
+		return ret;
+
+	return mx8373_enable_spk_pin(substream, true);
+}
+
+static int mx8373_sdw_hw_free(struct snd_pcm_substream *substream)
+{
+	int ret = 0;
+
+	/* according to soc_pcm_hw_free dai link free is called first */
+	ret = sdw_hw_free(substream);
+	if (ret < 0)
+		return ret;
+
+	return mx8373_enable_spk_pin(substream, false);
 }
 
 static const struct snd_soc_ops max_98373_sdw_ops = {
 	.startup = sdw_startup,
-	.prepare = sdw_prepare,
-	.trigger = max98373_sdw_trigger,
-	.hw_free = sdw_hw_free,
+	.prepare = mx8373_sdw_prepare,
+	.trigger = sdw_trigger,
+	.hw_free = mx8373_sdw_hw_free,
 	.shutdown = sdw_shutdown,
 };
 
-- 
2.30.2




  parent reply	other threads:[~2021-08-06  8:23 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-06  8:16 [PATCH 5.13 00/35] 5.13.9-rc1 review Greg Kroah-Hartman
2021-08-06  8:16 ` [PATCH 5.13 01/35] drm/i915: Revert "drm/i915/gem: Asynchronous cmdparser" Greg Kroah-Hartman
2021-08-06  8:16 ` [PATCH 5.13 02/35] Revert "drm/i915: Propagate errors on awaiting already signaled fences" Greg Kroah-Hartman
2021-08-06  8:16 ` [PATCH 5.13 03/35] power: supply: ab8500: Call battery population once Greg Kroah-Hartman
2021-08-06  8:16 ` [PATCH 5.13 04/35] skmsg: Increase sk->sk_drops when dropping packets Greg Kroah-Hartman
2021-08-06  8:16 ` [PATCH 5.13 05/35] skmsg: Pass source psock to sk_psock_skb_redirect() Greg Kroah-Hartman
2021-08-06  8:16 ` [PATCH 5.13 06/35] bpf, sockmap: On cleanup we additionally need to remove cached skb Greg Kroah-Hartman
2021-08-07 17:45   ` Naresh Kamboju
2021-08-09 17:33     ` John Fastabend
2021-08-06  8:16 ` [PATCH 5.13 07/35] cifs: use helpers when parsing uid/gid mount options and validate them Greg Kroah-Hartman
2021-08-06  8:16 ` [PATCH 5.13 08/35] cifs: add missing parsing of backupuid Greg Kroah-Hartman
2021-08-06  8:16 ` [PATCH 5.13 09/35] net: dsa: sja1105: parameterize the number of ports Greg Kroah-Hartman
2021-08-06  8:16 ` [PATCH 5.13 10/35] net: dsa: sja1105: fix address learning getting disabled on the CPU port Greg Kroah-Hartman
2021-08-06  8:16 ` [PATCH 5.13 11/35] ASoC: Intel: boards: handle hda-dsp-common as a module Greg Kroah-Hartman
2021-08-06  8:16 ` [PATCH 5.13 12/35] ASoC: Intel: boards: create sof-maxim-common module Greg Kroah-Hartman
2021-08-06  8:16 ` Greg Kroah-Hartman [this message]
2021-08-06  8:16 ` [PATCH 5.13 14/35] regulator: rtmv20: Fix wrong mask for strobe-polarity-high Greg Kroah-Hartman
2021-08-06  8:16 ` [PATCH 5.13 15/35] regulator: rt5033: Fix n_voltages settings for BUCK and LDO Greg Kroah-Hartman
2021-08-06  8:16 ` [PATCH 5.13 16/35] spi: stm32h7: fix full duplex irq handler handling Greg Kroah-Hartman
2021-08-06  8:17 ` [PATCH 5.13 17/35] ASoC: tlv320aic31xx: fix reversed bclk/wclk master bits Greg Kroah-Hartman
2021-08-06  8:17 ` [PATCH 5.13 18/35] regulator: mtk-dvfsrc: Fix wrong dev pointer for devm_regulator_register Greg Kroah-Hartman
2021-08-06  8:17 ` [PATCH 5.13 19/35] r8152: Fix potential PM refcount imbalance Greg Kroah-Hartman
2021-08-06  8:17 ` [PATCH 5.13 20/35] r8152: Fix a deadlock by doubly PM resume Greg Kroah-Hartman
2021-08-06  8:17 ` [PATCH 5.13 21/35] qed: fix possible unpaired spin_{un}lock_bh in _qed_mcp_cmd_and_union() Greg Kroah-Hartman
2021-08-06  8:17 ` [PATCH 5.13 22/35] ASoC: rt5682: Fix the issue of garbled recording after powerd_dbus_suspend Greg Kroah-Hartman
2021-08-06  8:17 ` [PATCH 5.13 23/35] net: Fix zero-copy head len calculation Greg Kroah-Hartman
2021-08-06  8:17 ` [PATCH 5.13 24/35] ASoC: ti: j721e-evm: Fix unbalanced domain activity tracking during startup Greg Kroah-Hartman
2021-08-06  8:17 ` [PATCH 5.13 25/35] ASoC: ti: j721e-evm: Check for not initialized parent_clk_id Greg Kroah-Hartman
2021-08-06  8:17 ` [PATCH 5.13 26/35] efi/mokvar: Reserve the table only if it is in boot services data Greg Kroah-Hartman
2021-08-06  8:17 ` [PATCH 5.13 27/35] nvme: fix nvme_setup_command metadata trace event Greg Kroah-Hartman
2021-08-06  8:17 ` [PATCH 5.13 28/35] drm/amd/display: Fix comparison error in dcn21 DML Greg Kroah-Hartman
2021-08-06  8:17 ` [PATCH 5.13 29/35] drm/amd/display: Fix max vstartup calculation for modes with borders Greg Kroah-Hartman
2021-08-06  8:17 ` [PATCH 5.13 30/35] io_uring: never attempt iopoll reissue from release path Greg Kroah-Hartman
2021-08-06  8:17 ` [PATCH 5.13 31/35] io_uring: explicitly catch any illegal async queue attempt Greg Kroah-Hartman
2021-08-06  8:17 ` [PATCH 5.13 32/35] Revert "spi: mediatek: fix fifo rx mode" Greg Kroah-Hartman
2021-08-06 18:54   ` Guenter Roeck
2021-08-07  8:20     ` Greg Kroah-Hartman
2021-08-06  8:17 ` [PATCH 5.13 33/35] Revert "Bluetooth: Shutdown controller after workqueues are flushed or cancelled" Greg Kroah-Hartman
2021-08-06  8:17 ` [PATCH 5.13 34/35] Revert "watchdog: iTCO_wdt: Account for rebooting on second timeout" Greg Kroah-Hartman
2021-08-06  8:17 ` [PATCH 5.13 35/35] drm/amd/display: Fix ASSR regression on embedded panels Greg Kroah-Hartman
2021-08-06 10:44 ` [PATCH 5.13 00/35] 5.13.9-rc1 review Fox Chen
2021-08-06 18:59 ` Guenter Roeck
2021-08-06 23:45 ` Justin Forbes
2021-08-07 13:16 ` Aakash Hemadri
2021-08-07 17:55 ` Naresh Kamboju

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210806081114.153290079@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=bard.liao@intel.com \
    --cc=broonie@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peter.ujfalusi@linux.intel.com \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=rander.wang@intel.com \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).