From patchwork Sat Mar 28 01:58:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Flax X-Patchwork-Id: 11463385 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3EE4A913 for ; Sat, 28 Mar 2020 02:00:02 +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 312D2206E6 for ; Sat, 28 Mar 2020 02:00:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="oLU4sTAb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 312D2206E6 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=flatmax.org 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 E4EB91669; Sat, 28 Mar 2020 02:59:14 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E4EB91669 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1585360799; bh=5ZzPWdNu1vD9wBc2yP4W318f0/wIB5ClATXt7mJYiEk=; h=From:To:Subject:Date:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=oLU4sTAbAVx9hbzeZmXzrmm0Q6eCE+Dnb1xPw3vIKgAmRjokdD6LVh9u2kXPIfo+9 uxOIXaueZK6ZwSyduu0qFEosmYuMHXG7X3a2ciHU+YfNUlQ06TmV/IMUq4BeSXzxE6 s1ZIhUGvSxgweDzFolVT6TP5pO8PFjk6HMseI5kc= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 53E89F8011E; Sat, 28 Mar 2020 02:59:14 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id E3F34F80158; Sat, 28 Mar 2020 02:59:11 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: * X-Spam-Status: No, score=1.2 required=5.0 tests=KHOP_HELO_FCRDNS, SPF_HELO_NONE, SPF_SOFTFAIL,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from pecan.exetel.com.au (pecan-mail.exetel.com.au [220.233.0.8]) by alsa1.perex.cz (Postfix) with ESMTP id C0AA2F8011E for ; Sat, 28 Mar 2020 02:59:03 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C0AA2F8011E Received: from 41.68.233.220.static.exetel.com.au ([220.233.68.41] helo=localhost.localdomain) by pecan.exetel.com.au with esmtp (Exim 4.91) (envelope-from ) id 1jI0kT-0001pT-BI; Sat, 28 Mar 2020 12:58:57 +1100 From: Matt Flax To: lgirdwood@gmail.com, broonie@kernel.org, lars@metafoo.de, pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org Subject: [PATCH] ASoC: snd_soc_dai_set_fmt add substream independence. Date: Sat, 28 Mar 2020 12:58:31 +1100 Message-Id: <20200328015831.6230-1-flatmax@flatmax.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Cc: Matt Flax 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" This patch is aims to start a stronger discussion on allowing both CPU and Codec dais to set formats independently based on direction. Currently it is very difficult to change stream formats because there is no way to specify it independently. A previous discussion w.r.t. a codec's stream dependent format setting required a codec's dai to be split. See here : https://mailman.alsa-project.org/pipermail/alsa-devel/2020-March/164492.html A previous discussion w.r.t. changing format based on the stream direction w.r.t. a CPU's dai showed the difficulty in setting fmt based on direection in thw hw_params function. See here : https://mailman.alsa-project.org/pipermail/alsa-devel/2020-March/165101.html It seems that it may be necessary to allow the stream direction as an input argument to snd_soc_dai_set_fmt. This patch is not complete, as there are many codecs and cpus which would require this change. However this patch is aimed as a discussion point. One example of a sound card which requires independent stream formats is an isolated sound card, such as the Audio Injector Isolated sound card. The magnetic isolation chips on the sound card require stream fomats to be different because of digital latency variations on the I2S lines. Signed-off-by: Matt Flax --- include/sound/soc-dai.h | 4 ++-- sound/soc/soc-core.c | 5 +++-- sound/soc/soc-dai.c | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h index eaaeb00e9e84..5071e006389b 100644 --- a/include/sound/soc-dai.h +++ b/include/sound/soc-dai.h @@ -123,7 +123,7 @@ int snd_soc_dai_set_pll(struct snd_soc_dai *dai, int snd_soc_dai_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio); /* Digital Audio interface formatting */ -int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt); +int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt, int stream); int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width); @@ -186,7 +186,7 @@ struct snd_soc_dai_ops { * DAI format configuration * Called by soc_card drivers, normally in their hw_params. */ - int (*set_fmt)(struct snd_soc_dai *dai, unsigned int fmt); + int (*set_fmt)(struct snd_soc_dai *dai, unsigned int fmt, int stream); int (*xlate_tdm_slot_mask)(unsigned int slots, unsigned int *tx_mask, unsigned int *rx_mask); int (*set_tdm_slot)(struct snd_soc_dai *dai, diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 068d809c349a..27a6f01dc2d3 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1474,10 +1474,11 @@ int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_dai *codec_dai; unsigned int i; - int ret; + int ret, stream; for_each_rtd_codec_dai(rtd, i, codec_dai) { - ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); + int stream = 0; + ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt, stream); if (ret != 0 && ret != -ENOTSUPP) { dev_warn(codec_dai->dev, "ASoC: Failed to set DAI format: %d\n", ret); diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c index 51031e330179..1f8ee7875656 100644 --- a/sound/soc/soc-dai.c +++ b/sound/soc/soc-dai.c @@ -94,11 +94,11 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_set_bclk_ratio); * * Configures the DAI hardware format and clocking. */ -int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) +int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt, int stream) { if (dai->driver->ops->set_fmt == NULL) return -ENOTSUPP; - return dai->driver->ops->set_fmt(dai, fmt); + return dai->driver->ops->set_fmt(dai, fmt, stream); } EXPORT_SYMBOL_GPL(snd_soc_dai_set_fmt);