From patchwork Wed Sep 23 17:33:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai Vehmanen X-Patchwork-Id: 250900 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3CC48C2D0A8 for ; Wed, 23 Sep 2020 17:36:47 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8A3AF206D9 for ; Wed, 23 Sep 2020 17:36:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="WY1wD0NC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8A3AF206D9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id BFEED1750; Wed, 23 Sep 2020 19:35:53 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz BFEED1750 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1600882603; bh=R3EA29NBFCWmiFH84X3iE/XbBpn8Uoi4rP6pP9jxNqE=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=WY1wD0NCsbeCZjEPmR3SwI6HS67vdlSjnze2avQaaX/8cZCNiA47DBXkNvVEmEHT0 Ierff6wN874SYKHH1bkGjPeFedHiXC9vtyDjKU3kB0ubzo8cjrvvaADfYqRFjW7YRk cuT/F7cdqPLK/1Uvp+tZ1MnOGVCSbNCQqWdP//qA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id CD689F8015F; Wed, 23 Sep 2020 19:35:52 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 651A6F802A2; Wed, 23 Sep 2020 19:35:50 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 0297FF8010A for ; Wed, 23 Sep 2020 19:35:39 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 0297FF8010A IronPort-SDR: EutKE9Lqn35Yp0NZlU1Me9PVWOnf/tU/49t87XOp6pIOaCEgszMaEvzlmWXOl3hi0jp7odXxgT kN/j078pUmnw== X-IronPort-AV: E=McAfee;i="6000,8403,9753"; a="148628853" X-IronPort-AV: E=Sophos;i="5.77,293,1596524400"; d="scan'208";a="148628853" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Sep 2020 10:35:35 -0700 IronPort-SDR: uawMLg+7tBkFyXV9J2K4lVdPJP+So1eBRda/pTWAGwvS6SGa/gO9DOFSWur/QlXz9icKQ1hMdu ApmVD1X6TMNA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,293,1596524400"; d="scan'208";a="335562332" Received: from eliteleevi.tm.intel.com ([10.237.54.20]) by fmsmga004.fm.intel.com with ESMTP; 23 Sep 2020 10:35:32 -0700 From: Kai Vehmanen To: alsa-devel@alsa-project.org, broonie@kernel.org Subject: [PATCH v2 1/6] ASOC: Intel: sof_sdw: restore playback functionality with max98373 amps Date: Wed, 23 Sep 2020 20:33:53 +0300 Message-Id: <20200923173358.3247215-2-kai.vehmanen@linux.intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200923173358.3247215-1-kai.vehmanen@linux.intel.com> References: <20200923173358.3247215-1-kai.vehmanen@linux.intel.com> MIME-Version: 1.0 Cc: pierre-louis.bossart@linux.intel.com, kai.vehmanen@linux.intel.com, Guennadi Liakhovetski , Keyon Jie , lgirdwood@gmail.com, Rander Wang , ranjani.sridharan@linux.intel.com, daniel.baluta@nxp.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Rander Wang The Max98373 amplifier provides I/V feedback information, which keeps a DAPM path active even when there is no playback happening. This prevents entry in low-power mode. Rather than adding new controls and require UCM/user interaction, the method previously applied is to enable/disable the Speaker pin during the dailink trigger operations. Recent changes in the SoundWire stream management moved the stream trigger to the dailink trigger. This change removed the Maxim-specific pin handling and resulted in a regression. This patch restores functionality by combining the SoundWire stream trigger with the pin enable/disable. Fixes: ae3a3918edf5 ('ASOC: Intel: sof_sdw: add dailink .trigger callback') Fixes: 06998d49bcac ('ASOC: Intel: sof_sdw: add dailink .prepare and .hw_free callback'). Signed-off-by: Rander Wang Signed-off-by: Pierre-Louis Bossart Reviewed-by: Guennadi Liakhovetski Reviewed-by: Ranjani Sridharan Reviewed-by: Keyon Jie Signed-off-by: Kai Vehmanen --- sound/soc/intel/boards/sof_sdw.c | 6 ++-- sound/soc/intel/boards/sof_sdw_common.h | 3 ++ sound/soc/intel/boards/sof_sdw_max98373.c | 36 ++++++++++++++++++++++- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/sound/soc/intel/boards/sof_sdw.c b/sound/soc/intel/boards/sof_sdw.c index 210b66d1f9a2..efd96c9c6e39 100644 --- a/sound/soc/intel/boards/sof_sdw.c +++ b/sound/soc/intel/boards/sof_sdw.c @@ -225,7 +225,7 @@ int sdw_startup(struct snd_pcm_substream *substream) return sdw_startup_stream(substream); } -static int sdw_prepare(struct snd_pcm_substream *substream) +int sdw_prepare(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); struct sdw_stream_runtime *sdw_stream; @@ -244,7 +244,7 @@ static int sdw_prepare(struct snd_pcm_substream *substream) return sdw_prepare_stream(sdw_stream); } -static int sdw_trigger(struct snd_pcm_substream *substream, int cmd) +int sdw_trigger(struct snd_pcm_substream *substream, int cmd) { struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); struct sdw_stream_runtime *sdw_stream; @@ -284,7 +284,7 @@ static int sdw_trigger(struct snd_pcm_substream *substream, int cmd) return ret; } -static int sdw_hw_free(struct snd_pcm_substream *substream) +int sdw_hw_free(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); struct sdw_stream_runtime *sdw_stream; diff --git a/sound/soc/intel/boards/sof_sdw_common.h b/sound/soc/intel/boards/sof_sdw_common.h index 6a5d46589baf..f3cb6796363e 100644 --- a/sound/soc/intel/boards/sof_sdw_common.h +++ b/sound/soc/intel/boards/sof_sdw_common.h @@ -79,6 +79,9 @@ struct mc_private { extern unsigned long sof_sdw_quirk; int sdw_startup(struct snd_pcm_substream *substream); +int sdw_prepare(struct snd_pcm_substream *substream); +int sdw_trigger(struct snd_pcm_substream *substream, int cmd); +int sdw_hw_free(struct snd_pcm_substream *substream); void sdw_shutdown(struct snd_pcm_substream *substream); /* generic HDMI support */ diff --git a/sound/soc/intel/boards/sof_sdw_max98373.c b/sound/soc/intel/boards/sof_sdw_max98373.c index 905582aaf58c..cfdf970c5800 100644 --- a/sound/soc/intel/boards/sof_sdw_max98373.c +++ b/sound/soc/intel/boards/sof_sdw_max98373.c @@ -55,9 +55,43 @@ static int spk_init(struct snd_soc_pcm_runtime *rtd) return ret; } +static int max98373_sdw_trigger(struct snd_pcm_substream *substream, int cmd) +{ + int ret; + + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: + case SNDRV_PCM_TRIGGER_RESUME: + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + /* enable max98373 first */ + ret = max98373_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 = max98373_trigger(substream, cmd); + break; + default: + ret = -EINVAL; + break; + } + + return ret; +} + static const struct snd_soc_ops max_98373_sdw_ops = { .startup = sdw_startup, - .trigger = max98373_trigger, + .prepare = sdw_prepare, + .trigger = max98373_sdw_trigger, + .hw_free = sdw_hw_free, .shutdown = sdw_shutdown, };