From patchwork Sat Oct 22 16:27:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 13016018 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 92EE5C04A95 for ; Sat, 22 Oct 2022 16:28:53 +0000 (UTC) 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 E2EF16E4C; Sat, 22 Oct 2022 18:28:00 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E2EF16E4C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1666456131; bh=6p4eEXg83yIDAGM8xySBXPY0ojda1VHoJPXL8c4QIEA=; h=From:To:Subject:Date:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=ZrAlDlvw837VencavbGGkrnasu3IQ/pLVUDRVQcekTcL92GaCgBPouYyD65ygTdbi 2Kvp6JYSBEvKibac6DIgB6LBQPvaIjJVlTeuBdUXxF1qJKhgHGVmvxOW4QxUMzYyUD +Grw41Ux3CBiZC3bPKQo5tkoZders7VbL2NU0S2Q= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 8A069F80246; Sat, 22 Oct 2022 18:28:00 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id BDDB1F80290; Sat, 22 Oct 2022 18:27:59 +0200 (CEST) Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 21390F80134 for ; Sat, 22 Oct 2022 18:27:56 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 21390F80134 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kxWSvkr4" Received: by mail-wr1-x431.google.com with SMTP id bp11so8930344wrb.9 for ; Sat, 22 Oct 2022 09:27:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ktkNejLf5LU86KvYGlX282kufTNr47TRhHJaTddj0/Y=; b=kxWSvkr4ZOGssABhmV4JWeqGJPQM9aKQZQmbQYexW7JPTaBwh9ZYKPQuHAfWeFWPgD JIgXQ/SuMLfVpB+nn3zxnjNMro5vxhLmdGdZj3LaAJ17pHjaeatcLQ6PO8DZbrMjGADE nRcWXHS2LHxoXJnO838vP4dVTuBVz77hDE71zZKFRZD6llC3QR1cEdryfUXc0fEXayTH p4iH2QaBeiEPrcFU9FPPQHaPOj67bf4outShJbWtj6ICbMChTPjuqCNK1J+GUml2nv+s CDeYswtfxTLFQCi0QcpyIgsnCJvegj62wWoTa0SvYBOmjQjWVJmuyjjmX/OUGHWMWiWc YoQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ktkNejLf5LU86KvYGlX282kufTNr47TRhHJaTddj0/Y=; b=U0juigf7x2fvxF6bDph/F1M1sBEIXoXIkiucy+C6eUFwgQaL2jvY4ER7W2/5SlYPeC ominLVBsEQCcki6+0cWAVlE9Gz18OVm6Vm8NLh3ZBlJLW+7SEC2Y4K4iO4aO4svXk6Ve gteKbD4ZwGZtc0Rvvf1OdhIR7p/2I1liaxJohEhH4FOWTYgqMyJoRCCRplztUT0IusMN y+BXWZBaDeOB+nS1YkEvZuGgbnKpfQ2XSgAHujNtelYs/aLJAnympgEDpXIDTNfiiySj P+UAZ0tGJMTgDhGVDX9/Aleni+d2xD5mKyr3/Xt90BqyGqWeDXMiiK6R7ydB5zQWrhgi XVAQ== X-Gm-Message-State: ACrzQf0H7eSB2723NHXQ/YcSUuX3wpiD4d8WuFcEUtxYQeQsnae7hK/a hy6KJq85QU7aOryIm6T1iQI= X-Google-Smtp-Source: AMsMyM5pJJuwPjRKj6P8P4nUqOnixt9lCmG0gQ7Zju6LnYGjzPLoWiCaVEzp4J6jVj/JRk3SKA7OBA== X-Received: by 2002:a05:6000:1acb:b0:231:faaa:8976 with SMTP id i11-20020a0560001acb00b00231faaa8976mr15583292wry.426.1666456075308; Sat, 22 Oct 2022 09:27:55 -0700 (PDT) Received: from localhost (94.197.3.61.threembb.co.uk. [94.197.3.61]) by smtp.gmail.com with ESMTPSA id l7-20020a05600c47c700b003b95ed78275sm5583279wmo.20.2022.10.22.09.27.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Oct 2022 09:27:54 -0700 (PDT) From: Aidan MacDonald To: broonie@kernel.org, lgirdwood@gmail.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, kuninori.morimoto.gx@renesas.com Subject: [PATCH v1 1/2] ASoC: simple-card: Support custom DAI system clock IDs Date: Sat, 22 Oct 2022 17:27:41 +0100 Message-Id: <20221022162742.21671-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, tiwai@suse.com, linux-kernel@vger.kernel.org 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" Some DAIs have multiple system clock sources, which can be chosen using the "clk_id" argument to snd_soc_dai_set_sysclk(). Currently this is hardcoded to 0 when using simple cards, but that choice is not always suitable. Add the "system-clock-id" property to allow selecting a different clock ID on a per-DAI basis. To simplify the logic on DPCM cards, add a dummy "asoc_simple_dai" instance and use that for the dummy components on DPCM links. This ensures that when we're iterating over DAIs in the PCM runtime there is always a matching "asoc_simple_dai" we can dereference. Signed-off-by: Aidan MacDonald --- include/sound/simple_card_utils.h | 2 ++ sound/soc/generic/simple-card-utils.c | 26 ++++++++++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index a0b827f0c2f6..9f9a72299637 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -26,6 +26,7 @@ struct asoc_simple_dai { const char *name; unsigned int sysclk; int clk_direction; + int sysclk_id; int slots; int slot_width; unsigned int tx_slot_mask; @@ -67,6 +68,7 @@ struct asoc_simple_priv { struct prop_nums num; unsigned int mclk_fs; } *dai_props; + struct asoc_simple_dai dummy_dai; struct asoc_simple_jack hp_jack; struct asoc_simple_jack mic_jack; struct snd_soc_dai_link *dai_link; diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index bef16833c487..d4d898e06e76 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -262,6 +262,9 @@ int asoc_simple_parse_clk(struct device *dev, if (of_property_read_bool(node, "system-clock-direction-out")) simple_dai->clk_direction = SND_SOC_CLOCK_OUT; + if (!of_property_read_u32(node, "system-clock-id", &val)) + simple_dai->sysclk_id = val; + return 0; } EXPORT_SYMBOL_GPL(asoc_simple_parse_clk); @@ -355,7 +358,7 @@ void asoc_simple_shutdown(struct snd_pcm_substream *substream) if (props->mclk_fs && !dai->clk_fixed && !snd_soc_dai_active(cpu_dai)) snd_soc_dai_set_sysclk(cpu_dai, - 0, 0, SND_SOC_CLOCK_OUT); + dai->sysclk_id, 0, SND_SOC_CLOCK_OUT); asoc_simple_clk_disable(dai); } @@ -364,7 +367,7 @@ void asoc_simple_shutdown(struct snd_pcm_substream *substream) if (props->mclk_fs && !dai->clk_fixed && !snd_soc_dai_active(codec_dai)) snd_soc_dai_set_sysclk(codec_dai, - 0, 0, SND_SOC_CLOCK_IN); + dai->sysclk_id, 0, SND_SOC_CLOCK_IN); asoc_simple_clk_disable(dai); } @@ -439,7 +442,7 @@ int asoc_simple_hw_params(struct snd_pcm_substream *substream, struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); struct simple_dai_props *props = simple_priv_to_props(priv, rtd->num); unsigned int mclk, mclk_fs = 0; - int i, ret; + int i, ret, sysclk_id; if (props->mclk_fs) mclk_fs = props->mclk_fs; @@ -472,13 +475,21 @@ int asoc_simple_hw_params(struct snd_pcm_substream *substream, } for_each_rtd_codec_dais(rtd, i, sdai) { - ret = snd_soc_dai_set_sysclk(sdai, 0, mclk, SND_SOC_CLOCK_IN); + pdai = simple_props_to_dai_codec(props, i); + sysclk_id = pdai->sysclk_id; + + ret = snd_soc_dai_set_sysclk(sdai, sysclk_id, mclk, + SND_SOC_CLOCK_IN); if (ret && ret != -ENOTSUPP) return ret; } for_each_rtd_cpu_dais(rtd, i, sdai) { - ret = snd_soc_dai_set_sysclk(sdai, 0, mclk, SND_SOC_CLOCK_OUT); + pdai = simple_props_to_dai_cpu(props, i); + sysclk_id = pdai->sysclk_id; + + ret = snd_soc_dai_set_sysclk(sdai, pdai->sysclk_id, mclk, + SND_SOC_CLOCK_OUT); if (ret && ret != -ENOTSUPP) return ret; } @@ -523,7 +534,8 @@ static int asoc_simple_init_dai(struct snd_soc_dai *dai, return 0; if (simple_dai->sysclk) { - ret = snd_soc_dai_set_sysclk(dai, 0, simple_dai->sysclk, + ret = snd_soc_dai_set_sysclk(dai, simple_dai->sysclk_id, + simple_dai->sysclk, simple_dai->clk_direction); if (ret && ret != -ENOTSUPP) { dev_err(dai->dev, "simple-card: set_sysclk error\n"); @@ -858,6 +870,7 @@ int asoc_simple_init_priv(struct asoc_simple_priv *priv, dai_link[i].cpus = &priv->dummy; dai_props[i].num.cpus = dai_link[i].num_cpus = 1; + dai_props[i].cpu_dai = &priv->dummy_dai; } if (li->num[i].codecs) { @@ -882,6 +895,7 @@ int asoc_simple_init_priv(struct asoc_simple_priv *priv, dai_link[i].codecs = &priv->dummy; dai_props[i].num.codecs = dai_link[i].num_codecs = 1; + dai_props[i].codec_dai = &priv->dummy_dai; } if (li->num[i].platforms) { From patchwork Sat Oct 22 16:27:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 13016019 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 965E3C04A95 for ; Sat, 22 Oct 2022 16:29:18 +0000 (UTC) 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 72BA17218; Sat, 22 Oct 2022 18:28:26 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 72BA17218 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1666456156; bh=r1bWMm0lw26cf7nBaQRoorDfLfMoHP/yXQh87xrgVjQ=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=KsH+2pt3rqMlTbW6cLx9XlNFudlpOv3BoVeLlzKIHfQUMactbW/RwcGqS534hhJMq X2FHFs4SfHov2L5LvL5CZCQx2DlXNg6DcN+3NUX3coD+rMbU1mYNgdsFjqHBkCK0UP F9mfK1FS27svKW60yJQdi/o1Pl8JXEipV2xzViVA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id ABA6CF80130; Sat, 22 Oct 2022 18:28:03 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 0E0D2F804B0; Sat, 22 Oct 2022 18:28:01 +0200 (CEST) Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 72B75F80130 for ; Sat, 22 Oct 2022 18:27:58 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 72B75F80130 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qwKBPuGa" Received: by mail-wr1-x42a.google.com with SMTP id o4so1052415wrq.6 for ; Sat, 22 Oct 2022 09:27:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=u3LZtQhmhTtG0av/Vhn5L+1eJ4O3uKOFFREHllICaQw=; b=qwKBPuGa1JTF0Lz0r3+ZjdptUqdyXE/Rvkl5x/B8w7r8FeSm49MVyLrsinFqRgQXxy lOopTc/54bAT4biIxpZeI9MX7D5PBJ5AmXFxsVd+1BhbGqA8dm/hfy2CkPuQOHG8wf8V G8gwFY3mKrO+ib6aO1EE+60Ar2bFZ5GwSichX1192pkD8BP5JfUdlq6viMFDBcCRpzrX HZpgAfszR4MTEn98go/JcL0rE+5JQ/5yJSl2O0qzufwxN1Ihy0Do7Me5izt2XRi2QW/y mLidQEuvuK0ABThySmoD6VEQ2X7sWRCGRyp8ngN9uPUnw2rt+5u3xNKjGMSMB9x/7qdE gaUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=u3LZtQhmhTtG0av/Vhn5L+1eJ4O3uKOFFREHllICaQw=; b=WdR9doCtzeMEmwnSSRSel4iAGaMuVHOLv8csmuyO4fE8V5Fm2guDC+PkpIVkYq5IlO Z1idnSnJlbSlKEkepFmykPbvUOjqTHcKG1XqeLLJ8YzrWtBnxkNgzS+YoEVsfYCymL1s fROHzcJp7YZs//ELlxyPl0U1Fi+TGQgrNlSDDCwlPOeM6/FcKP4H7AkeIGGLtlVxgI45 kKGrDxO0/OOXadzulWO5YxnAPePoyfEtZ73u/z8ceot32GiQplws88ARrtWYk7vh1CAV uQFe5UBWA5iLggKl5xjNgflmPEFqeHxEUPDYModjWMaJ96XZSLz6TMIeYkrPXJ97RacZ xl2A== X-Gm-Message-State: ACrzQf2zpRU2hJKQDE8rrjQS5+LwuJiF1XI4hkDjXwHtBfAWXvrBFcIT A7RXzPsC2UB99LfkTYBvh2w= X-Google-Smtp-Source: AMsMyM4uW22MGCD0X1eioOOK6RWgjhEs5hH/6KkJcF4htf1J5Ex31+YCsFIIq8V4G3w0t6GQBzlXXw== X-Received: by 2002:a5d:6da1:0:b0:231:c189:e077 with SMTP id u1-20020a5d6da1000000b00231c189e077mr16103020wrs.114.1666456076553; Sat, 22 Oct 2022 09:27:56 -0700 (PDT) Received: from localhost (94.197.3.61.threembb.co.uk. [94.197.3.61]) by smtp.gmail.com with ESMTPSA id be5-20020a05600c1e8500b003a531c7aa66sm6141184wmb.1.2022.10.22.09.27.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Oct 2022 09:27:56 -0700 (PDT) From: Aidan MacDonald To: broonie@kernel.org, lgirdwood@gmail.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, kuninori.morimoto.gx@renesas.com Subject: [PATCH v1 2/2] dt-bindings: ASoC: simple-card: Add system-clock-id property Date: Sat, 22 Oct 2022 17:27:42 +0100 Message-Id: <20221022162742.21671-2-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20221022162742.21671-1-aidanmacdonald.0x0@gmail.com> References: <20221022162742.21671-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, tiwai@suse.com, linux-kernel@vger.kernel.org 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 is a new per-DAI property used to specify the clock ID argument to snd_soc_dai_set_sysclk(). Signed-off-by: Aidan MacDonald Acked-by: Krzysztof Kozlowski --- Documentation/devicetree/bindings/sound/simple-card.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/simple-card.yaml b/Documentation/devicetree/bindings/sound/simple-card.yaml index ed19899bc94b..cb7774e235d0 100644 --- a/Documentation/devicetree/bindings/sound/simple-card.yaml +++ b/Documentation/devicetree/bindings/sound/simple-card.yaml @@ -57,6 +57,12 @@ definitions: single fixed sampling rate. $ref: /schemas/types.yaml#/definitions/flag + system-clock-id: + description: | + Specify the clock ID used for setting the DAI system clock. + Defaults to 0 if unspecified. + $ref: /schemas/types.yaml#/definitions/uint32 + mclk-fs: description: | Multiplication factor between stream rate and codec mclk. @@ -145,6 +151,8 @@ definitions: $ref: "#/definitions/system-clock-direction-out" system-clock-fixed: $ref: "#/definitions/system-clock-fixed" + system-clock-id: + $ref: "#/definitions/system-clock-id" required: - sound-dai