Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp164297pxk; Tue, 1 Sep 2020 19:59:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyayaa6nBWVq2LCpeI7zhd82G3WxJH0gCHeLu9bdf59zvovRfOiweB1pnGBkDmXdaCX1tXb X-Received: by 2002:a17:906:6a52:: with SMTP id n18mr4188785ejs.58.1599015581641; Tue, 01 Sep 2020 19:59:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599015581; cv=none; d=google.com; s=arc-20160816; b=xWup5/AfNu2/r7cZi1V5BBXxlD6StIoO3vSjOOmXfAAdc2LH7LZ02GByuxtLZWSAGF ECmsYWIYVHeiOUTRi6jPiZOp7l3kaIeGv8Vblx62+TO6UZ28oAUAJ9ncPbYf5DctP/ET ow2/xlPaU2YhzO61P+H82JCfg1qt528r4TtSl+RSl7oKUm2Pn/Ei3z1UJHUUl6oA4uVf dYdsc6eurhxrefqJuIME3eT8jobTNrWnDHyjQLIhBcXvaHDseqR3YUsW9w1a2JNtfB2Y jt3Oy1v6FI/V3L0ggZ4RcCtch1AsMz6bcJUfwWx2eSC2PqWQmkSGvamS3JQGr0bN3S2I +eBg== 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=BR+DkoH5ZpbR2LrEwG87KWQDd8PmrdK0FLpJQ8opY/aY/QT8XOOvqSdqeYzfLTa5iW cgjOAmGwkYTezacK19QuE28FCmphIJHWtIc7RjLSz9j/Cte/tvChokn1wY0uV4JI+kgK MXCWLZEBpi2fkRdqBMy260sh32fsruk5adgnWs8MUW+QucCTqnXrXZCKjealZ+B8nL50 cd3HoCtioDCbB10deksRAC3tMAq8zrPi58IYkwdK6VBWSRSNCv3olS+qS+GsGoipBu63 8qMKBV/0g9cx7uLTDppROHkCQaUe3RsZ4gOyI94AeZzhccbckuv1117WVI69vXzm3Qe7 RQhQ== 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 dd13si1853028edb.457.2020.09.01.19.59.18; Tue, 01 Sep 2020 19:59:41 -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 S1727019AbgIBC4p (ORCPT + 99 others); Tue, 1 Sep 2020 22:56:45 -0400 Received: from mga07.intel.com ([134.134.136.100]:49594 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726941AbgIBC4o (ORCPT ); Tue, 1 Sep 2020 22:56:44 -0400 IronPort-SDR: Yhznjv7dKUGa/l8vYiMrDLqRdIsN8vcUrZeseTLZwxw/5kblYsqpRQJNMTGLLdbL0hPWwYaLnP t/m4VTA93sCA== X-IronPort-AV: E=McAfee;i="6000,8403,9731"; a="221528382" X-IronPort-AV: E=Sophos;i="5.76,381,1592895600"; d="scan'208";a="221528382" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Sep 2020 19:56:43 -0700 IronPort-SDR: tjP7i/wo++4lunbnZEQfUwqlKHxew/92yzEpf8ytkXpq3IvXAFZvcuaTq8D5r04mZSeB0t/WWN 2zEU6d4NfJYQ== X-IronPort-AV: E=Sophos;i="5.76,381,1592895600"; d="scan'208";a="477457301" 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; 01 Sep 2020 19:56:39 -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 5/7] ASOC: Intel: sof_sdw: add dailink .prepare and .hw_free callback Date: Tue, 1 Sep 2020 23:02:38 +0800 Message-Id: <20200901150240.19288-6-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200901150240.19288-1-yung-chuan.liao@linux.intel.com> References: <20200901150240.19288-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