Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1841531pxk; Fri, 4 Sep 2020 23:25:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPffQSSMETUs8cy3FH7krd5vZUxFoCcjw/CNDq39KaFDe8KSaz38q2rQ+OxlRhyWvrayY/ X-Received: by 2002:aa7:c308:: with SMTP id l8mr12140241edq.361.1599287112096; Fri, 04 Sep 2020 23:25:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599287112; cv=none; d=google.com; s=arc-20160816; b=v1lgme6ExUa2ahhHoXI7dpoBTjpbxSMP9ymD+f+2vFw/EVgQeT85ODFSukNlgvRCLT G1U3EPT1EzhPOuuFswswK+5/P0ufLiqXSexVChVEhB8dUu2w3Do7zH5tuaoKnDt6kJSY sVqZekSZJyEsL1GhYv+47mLUj0hGZ8q1nUNUu+pt+B4tR+42kd6oCkdv60M3nQt4csCc jPBj+hj8kNbtz2AxUDsWbavx8sWuXTfZx+LFecihynHdTEcJanoAf3Kz6AipJ08t1+7W NlajAvyDYhM7aiCTBk1GBAF6C5T8w1OiokNGyIlWF2osG6Ap2RoWiI28Bm5kiX+CbfIj MTyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:ironport-sdr:ironport-sdr; bh=Zs25ilOuOfweo/ES3pitk5WlppyrWbqbuuQtwnPfk58=; b=e9NvHcOLkg7OQr+ybf4pmVTX7CT+fdjc4NtbPEh3tc7sxJ57hqUD3JmCZaFnyG0A4M MUAPoLkC+cpb3573y7eEYMjP297fmPov4SRfVgTyhzk1T1+waPqd8M1Ix50im6vTPPlU 5fSgCfrpQ2XpLTzrG0yyLJleRPEWXZvVlYtSnVvrXf6OYWGNJwJnJcGlN97u9PmfVn/1 /tAbL3uIk0z3tGkrcCW8pdG0hLOsQpQ3xuoVBORI8nOPnAhE3fN0KOVbyIXwofWT23KZ INlFBcPkPCHTYQyvb/jWQlcMlXJoYSOz4ZqsoIAhHJZg8ZPs0Dsz8PSxVr5UUyNhQTu4 0wKA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d19si5929605edj.40.2020.09.04.23.24.49; Fri, 04 Sep 2020 23:25:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726652AbgIEGWz (ORCPT + 99 others); Sat, 5 Sep 2020 02:22:55 -0400 Received: from mga18.intel.com ([134.134.136.126]:49017 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725818AbgIEGWw (ORCPT ); Sat, 5 Sep 2020 02:22:52 -0400 IronPort-SDR: 2OFQ4m1nvSiut1YDwvID1eEQr00bkDz6RzMla967eGVnwCrgQYShfOj1y1DVXvQjd1x4M4otFt yWgj2vOUx+KA== X-IronPort-AV: E=McAfee;i="6000,8403,9734"; a="145547461" X-IronPort-AV: E=Sophos;i="5.76,392,1592895600"; d="scan'208";a="145547461" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Sep 2020 23:22:51 -0700 IronPort-SDR: XHKZPE1pnjJxVEqYHA9SQHCGYf1cI1IGLzueIWa1oY4RSdmcaJrtWtCdTpA97zCD3b+7FS0S/v ddaKZCMdNjgg== X-IronPort-AV: E=Sophos;i="5.76,392,1592895600"; d="scan'208";a="478804292" Received: from bard-ubuntu.sh.intel.com ([10.239.13.33]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Sep 2020 23:22:47 -0700 From: Bard Liao To: alsa-devel@alsa-project.org, vkoul@kernel.org Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, tiwai@suse.de, broonie@kernel.org, gregkh@linuxfoundation.org, jank@cadence.com, srinivas.kandagatla@linaro.org, rander.wang@linux.intel.com, ranjani.sridharan@linux.intel.com, hui.wang@canonical.com, pierre-louis.bossart@linux.intel.com, sanyog.r.kale@intel.com, mengdong.lin@intel.com, bard.liao@intel.com Subject: [PATCH v3 3/3] ASoC: Intel: sof_sdw: add dailink .prepare and .hw_free callback Date: Sat, 5 Sep 2020 02:28:54 +0800 Message-Id: <20200904182854.3944-4-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200904182854.3944-1-yung-chuan.liao@linux.intel.com> References: <20200904182854.3944-1-yung-chuan.liao@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pierre-Louis Bossart Add .prepare and .hw_free callback to dailink. The companion patch for this patch is the removal of stream operations in the .prepare and .hw_free callbacks at the DAI level in drivers/soundwire/intel.c Signed-off-by: Pierre-Louis Bossart Reviewed-by: Rander Wang Signed-off-by: Bard Liao --- sound/soc/intel/boards/sof_sdw.c | 40 ++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/sound/soc/intel/boards/sof_sdw.c b/sound/soc/intel/boards/sof_sdw.c index f251e046d74d..16503772965c 100644 --- a/sound/soc/intel/boards/sof_sdw.c +++ b/sound/soc/intel/boards/sof_sdw.c @@ -195,6 +195,25 @@ int sdw_startup(struct snd_pcm_substream *substream) return sdw_startup_stream(substream); } +static 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; + struct snd_soc_dai *dai; + + /* Find stream from first CPU DAI */ + dai = asoc_rtd_to_cpu(rtd, 0); + + sdw_stream = snd_soc_dai_get_sdw_stream(dai, substream->stream); + + if (IS_ERR(sdw_stream)) { + dev_err(rtd->dev, "no stream found for DAI %s", dai->name); + return PTR_ERR(sdw_stream); + } + + return sdw_prepare_stream(sdw_stream); +} + static int sdw_trigger(struct snd_pcm_substream *substream, int cmd) { struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); @@ -235,6 +254,25 @@ static int sdw_trigger(struct snd_pcm_substream *substream, int cmd) return ret; } +static 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; + struct snd_soc_dai *dai; + + /* Find stream from first CPU DAI */ + dai = asoc_rtd_to_cpu(rtd, 0); + + sdw_stream = snd_soc_dai_get_sdw_stream(dai, substream->stream); + + if (IS_ERR(sdw_stream)) { + dev_err(rtd->dev, "no stream found for DAI %s", dai->name); + return PTR_ERR(sdw_stream); + } + + return sdw_deprepare_stream(sdw_stream); +} + void sdw_shutdown(struct snd_pcm_substream *substream) { sdw_shutdown_stream(substream); @@ -242,7 +280,9 @@ void sdw_shutdown(struct snd_pcm_substream *substream) static const struct snd_soc_ops sdw_ops = { .startup = sdw_startup, + .prepare = sdw_prepare, .trigger = sdw_trigger, + .hw_free = sdw_hw_free, .shutdown = sdw_shutdown, }; -- 2.17.1