Message ID | 20230602090322.1876359-2-alvin@pqrs.dk |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp891831vqr; Fri, 2 Jun 2023 02:12:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5dGDg7fPfVbHSxBds2dWnL/PFRhoaaIPmqXhX6d7eeSHsQlNcQLMqvaSX2Y0/AVQTNW/TC X-Received: by 2002:a92:4b08:0:b0:335:fc8:9b4 with SMTP id m8-20020a924b08000000b003350fc809b4mr8084850ilg.19.1685697127045; Fri, 02 Jun 2023 02:12:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685697127; cv=none; d=google.com; s=arc-20160816; b=R+cY/puhbc+rFxAkyjo9iUzlKrqWc5Wg/CHm1/i6RSbgcTRtnf+2thOI83veAippZM F+8s2Gj6vgZtj48i7x+F79ljG/2+8hv4uV8GJ0SYY5MYPVeDv2qu34gG7I5bGf8cW7RE e98KXyRaBvvrXy9/9E7/ySQZNI2XR6FstyY/ORMUgkCUehNyiUuHxDudKfnc7VfdTixQ SLrSbGaJ5yRREfc+SwpRdMN6vlyoaf2tqZS5MWN7N8Mvm4JaOeTIS3ETi0cCBOXQs0uS isDOU3E6lAOOJNR9DgH49Z7sBn0j8RFk/pRbcdoZnfx3unQJ1cfJmaU5qGVzI3c8uhwg +CHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lmqqRgiUwINg0zM6iswD1JyF/sKo+vBLZEf0BZFnUDQ=; b=chXhO7O+3MuOEN6eMhsT4VsvMakDFcwS/Q7tlFpxS9B+a2vkgnEHtMj7hjOb5oZhnj Pl1d7NBbrnKztEvDVlDgzDZ8v+kxeXyySUmKEANaIu73GzF6oUyZ1jaCFErJJGLh1JUo iu+eKbeDCjtuvwFOwDNKBbVl417PlosY7XPO+tVA5u+Ca/8n6A4QKsa92m7fp3nu2RH4 ELnQ4Mns+Nk8Wc6XPaKTiCjPwqiRo6RnXMA2AOvo/+gNLpMjCxFfNtdXIQXV6HPrsPn2 Lzv6GP6fpwzadjFlgTBoN8AQzftjGUs8U0c4YGilsGg1bhL4+UIkBElwKaHTakDOuS7A 6wug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pqrs.dk header.s=google header.b=PsUDUxex; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u9-20020a637909000000b0053f0cdab823si675212pgc.469.2023.06.02.02.11.54; Fri, 02 Jun 2023 02:12:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@pqrs.dk header.s=google header.b=PsUDUxex; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234532AbjFBJFE (ORCPT <rfc822;limurcpp@gmail.com> + 99 others); Fri, 2 Jun 2023 05:05:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234994AbjFBJEG (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 2 Jun 2023 05:04:06 -0400 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44F4110C0 for <linux-kernel@vger.kernel.org>; Fri, 2 Jun 2023 02:03:46 -0700 (PDT) Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-973f78329e3so269473566b.3 for <linux-kernel@vger.kernel.org>; Fri, 02 Jun 2023 02:03:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pqrs.dk; s=google; t=1685696624; x=1688288624; 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=lmqqRgiUwINg0zM6iswD1JyF/sKo+vBLZEf0BZFnUDQ=; b=PsUDUxexLrW3qJIJMMeH0z/bQvrHVeGXXEVIg6jC84q5cZT/2pA22ihuOt5kr8K32z Ce58wDcU3/NbbC6NfAn2EtyPPHo5Zn7rxiAZX5lGNOfrP4b5fjYvUvWXikGAVAM3G/Dm GNMbfO1VysCFDsZ4p7szujfKrewggNF76QAes8VQrtNFYr6KnXSoSBepumy6jmSiMVaY a/R3IGl5ZLeyrxQ1HmZXYhyxaWsgMa5S33yJBUxJ8gfb8HVSISXiTYJvDkBIZlaMA2OL 3vzdxjXtcJCM66l8HcBeqsGP4fLMSsjDFKJqgXQwwfUVMzPNMcq18/KSFndgrgThlS89 pMQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685696624; x=1688288624; 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=lmqqRgiUwINg0zM6iswD1JyF/sKo+vBLZEf0BZFnUDQ=; b=YR6cqwPHZOj5RnFNV26npycDThf4THGtG1e4wfTWpLV+uwGmHytTWgqGKSTqzsoPeB 4R6d9palTuu0IrADSIOL/k0ch596zwEBt3XNLXyFGVzld0nZYCCTVMNE536Oq+MACz5M Jj48hsSE9JmogJhl6VV2wIedqfPoClAoT4lrOiAG665+0mk9mbmIrY4vo2RbJuJ7FgqR 9kr196ugUO18hYGBhFvC2t/uZU53AwSuD7TxSD4tLjgFIQMyqyOJxfDEsBa/c1KpNB+P RLtixs19mZnTSBjnB8AnLcbnt+4JpzMbVVmB4xQO5OqFVyVw6DQpCekKSVMb6Dr8ZWbV c8Nw== X-Gm-Message-State: AC+VfDwkacSTXzsPvVeWJNpE+MLhSSKpVaFv8Btqa5sjMoFGC3FoLk7s hYO0XOnyM8EyrMIV8gd2xbVWCg== X-Received: by 2002:a17:907:9618:b0:953:8249:1834 with SMTP id gb24-20020a170907961800b0095382491834mr12522628ejc.16.1685696624649; Fri, 02 Jun 2023 02:03:44 -0700 (PDT) Received: from localhost.localdomain (80.71.142.18.ipv4.parknet.dk. [80.71.142.18]) by smtp.gmail.com with ESMTPSA id w23-20020a170906385700b009707fa1c316sm488031ejc.213.2023.06.02.02.03.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jun 2023 02:03:44 -0700 (PDT) From: =?utf-8?q?Alvin_=C5=A0ipraga?= <alvin@pqrs.dk> To: Liam Girdwood <lgirdwood@gmail.com>, Mark Brown <broonie@kernel.org>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Conor Dooley <conor+dt@kernel.org>, Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>, Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Cc: =?utf-8?q?Alvin_=C5=A0ipraga?= <alsi@bang-olufsen.dk>, alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] ASoC: dt-bindings: document new symmetric-clock-role flag Date: Fri, 2 Jun 2023 11:03:18 +0200 Message-Id: <20230602090322.1876359-2-alvin@pqrs.dk> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230602090322.1876359-1-alvin@pqrs.dk> References: <20230602090322.1876359-1-alvin@pqrs.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767581550953183599?= X-GMAIL-MSGID: =?utf-8?q?1767581550953183599?= |
Series |
ASoC: support dai-links with symmetric clock roles
|
|
Commit Message
Alvin Šipraga
June 2, 2023, 9:03 a.m. UTC
From: Alvin Šipraga <alsi@bang-olufsen.dk> The new flag specifies that both ends of the dai-link have the same clock consumer/provider role. This should be used to describe hardware where e.g. the CPU and codec both receive their bit- and frame-clocks from an external source. Signed-off-by: Alvin Šipraga <alsi@bang-olufsen.dk> --- .../devicetree/bindings/sound/simple-card.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+)
Comments
On Fri, 02 Jun 2023 11:03:18 +0200, Alvin Šipraga wrote: > From: Alvin Šipraga <alsi@bang-olufsen.dk> > > The new flag specifies that both ends of the dai-link have the same > clock consumer/provider role. This should be used to describe hardware > where e.g. the CPU and codec both receive their bit- and frame-clocks > from an external source. > > Signed-off-by: Alvin Šipraga <alsi@bang-olufsen.dk> > --- > .../devicetree/bindings/sound/simple-card.yaml | 11 +++++++++++ > 1 file changed, 11 insertions(+) > My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13): yamllint warnings/errors: ./Documentation/devicetree/bindings/sound/simple-card.yaml:33:5: [error] syntax error: could not find expected ':' (syntax) dtschema/dtc warnings/errors: make[1]: *** Deleting file 'Documentation/devicetree/bindings/sound/simple-card.example.dts' Documentation/devicetree/bindings/sound/simple-card.yaml:33:5: could not find expected ':' make[1]: *** [Documentation/devicetree/bindings/Makefile:26: Documentation/devicetree/bindings/sound/simple-card.example.dts] Error 1 make[1]: *** Waiting for unfinished jobs.... ./Documentation/devicetree/bindings/sound/simple-card.yaml:33:5: could not find expected ':' /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/sound/simple-card.yaml: ignoring, error parsing file make: *** [Makefile:1512: dt_binding_check] Error 2 doc reference errors (make refcheckdocs): See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/20230602090322.1876359-2-alvin@pqrs.dk The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch. If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date: pip3 install dtschema --upgrade Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.
On Fri, Jun 02, 2023 at 11:03:18AM +0200, Alvin Šipraga wrote: > From: Alvin Šipraga <alsi@bang-olufsen.dk> > > The new flag specifies that both ends of the dai-link have the same > clock consumer/provider role. This should be used to describe hardware > where e.g. the CPU and codec both receive their bit- and frame-clocks > from an external source. Why would we have a property for this and not just describe whatever the actual clocking arrangement is?
Hi Mark, On Fri, Jun 02, 2023 at 12:43:51PM +0100, Mark Brown wrote: > On Fri, Jun 02, 2023 at 11:03:18AM +0200, Alvin Šipraga wrote: > > From: Alvin Šipraga <alsi@bang-olufsen.dk> > > > > The new flag specifies that both ends of the dai-link have the same > > clock consumer/provider role. This should be used to describe hardware > > where e.g. the CPU and codec both receive their bit- and frame-clocks > > from an external source. > > Why would we have a property for this and not just describe whatever the > actual clocking arrangement is? Sure - let me just elaborate on my thinking and maybe you can help me with a better approach: The clocking arrangement is encoded in the dai_fmt field of snd_soc_dai_link, but this is a single value that describes the format on both ends. The current behaviour of ASoC is to flip the clock roles encoded in dai_fmt when applying it to the CPU side of the link. Looking from a DT perspective, if I do not specify e.g. bitclock-master on either side of the link, then the dai_fmt will describe the codec as a bitclock consumer and (after flipping) the CPU as a provider. That's the default implication of the DT bindings and I can't break compatibility there. The other issue is that for the simple-card the DAI format is only parsed in one place and applied to the whole link. Are you proposing that it be modified to explicitly try and parse both ends in order to determine if both sides want to be clock consumers? In that case I'd have to also introduce bitclock-consumer and frameclock-consumer properties to mirror the existing bitclock-master and frameclock-master properties, as an explicit absence of the *-master property on both sides would have to default to the original ASoC behaviour described above. Or did you have something else in mind? Thanks for your review. Kind regards, Alvin
On Fri, Jun 02, 2023 at 12:12:52PM +0000, Alvin Šipraga wrote: > On Fri, Jun 02, 2023 at 12:43:51PM +0100, Mark Brown wrote: > > Why would we have a property for this and not just describe whatever the > > actual clocking arrangement is? > Sure - let me just elaborate on my thinking and maybe you can help me with a > better approach: > The clocking arrangement is encoded in the dai_fmt field of snd_soc_dai_link, > but this is a single value that describes the format on both ends. The current > behaviour of ASoC is to flip the clock roles encoded in dai_fmt when applying it > to the CPU side of the link. > Looking from a DT perspective, if I do not specify e.g. bitclock-master on > either side of the link, then the dai_fmt will describe the codec as a bitclock > consumer and (after flipping) the CPU as a provider. That's the default > implication of the DT bindings and I can't break compatibility there. None of this addresses my question. To repeat why would we not just describe the actual clocking arrangement here - this property does not specify where the clock actually comes from at all, we're still going to need additional information for that and if we've described that clock then we already know it's there without having to specify any more properties. > The other issue is that for the simple-card the DAI format is only parsed in one > place and applied to the whole link. Are you proposing that it be modified to > explicitly try and parse both ends in order to determine if both sides want to > be clock consumers? In that case I'd have to also introduce bitclock-consumer > and frameclock-consumer properties to mirror the existing bitclock-master and > frameclock-master properties, as an explicit absence of the *-master property on > both sides would have to default to the original ASoC behaviour described above. If simple-card can't be made to work that's fine, it's deprecated anyway.
On Fri, Jun 02, 2023 at 01:19:08PM +0100, Mark Brown wrote: > On Fri, Jun 02, 2023 at 12:12:52PM +0000, Alvin Šipraga wrote: > > On Fri, Jun 02, 2023 at 12:43:51PM +0100, Mark Brown wrote: > > > > Why would we have a property for this and not just describe whatever the > > > actual clocking arrangement is? > > > Sure - let me just elaborate on my thinking and maybe you can help me with a > > better approach: > > > The clocking arrangement is encoded in the dai_fmt field of snd_soc_dai_link, > > but this is a single value that describes the format on both ends. The current > > behaviour of ASoC is to flip the clock roles encoded in dai_fmt when applying it > > to the CPU side of the link. > > > Looking from a DT perspective, if I do not specify e.g. bitclock-master on > > either side of the link, then the dai_fmt will describe the codec as a bitclock > > consumer and (after flipping) the CPU as a provider. That's the default > > implication of the DT bindings and I can't break compatibility there. > > None of this addresses my question. To repeat why would we not just > describe the actual clocking arrangement here - this property does not > specify where the clock actually comes from at all, we're still going to > need additional information for that and if we've described that clock > then we already know it's there without having to specify any more > properties. Yes I see what you mean. On my platform the clock source is actually described by the common clock framework, so I would want to use that. If it were a component driver then it would most likely be a codec that is part of the dai-link anyway. So what about having two struct clk pointers in struct snd_soc_dai? struct snd_soc_dai { /* ... */ struct clk *bitclock_provider; struct clk *frameclock_provider; /* ... */ }; If non-NULL I could then have the ASoC core enable/disable the clocks on demand? I would say in hw_params/hw_free, albeit that runs after set_fmt. Having said that, I see ASoC doesn't really use the CCF much... am I way off? I don't think it's feasible to modify every component driver to explicitly handle this and then ignore any CBP_CFP bits set in its call to set_fmt - this is why I want help from the ASoC core. > > > The other issue is that for the simple-card the DAI format is only parsed in one > > place and applied to the whole link. Are you proposing that it be modified to > > explicitly try and parse both ends in order to determine if both sides want to > > be clock consumers? In that case I'd have to also introduce bitclock-consumer > > and frameclock-consumer properties to mirror the existing bitclock-master and > > frameclock-master properties, as an explicit absence of the *-master property on > > both sides would have to default to the original ASoC behaviour described above. > > If simple-card can't be made to work that's fine, it's deprecated > anyway. Ah OK, I didn't know that. Right now I'm using graph-card2, that's not deprecated, right? Kind regards, Alvin
On Fri, Jun 02, 2023 at 01:19:08PM +0100, Mark Brown wrote: > On Fri, Jun 02, 2023 at 12:12:52PM +0000, Alvin Šipraga wrote: > > On Fri, Jun 02, 2023 at 12:43:51PM +0100, Mark Brown wrote: > > > > Why would we have a property for this and not just describe whatever the > > > actual clocking arrangement is? > > > Sure - let me just elaborate on my thinking and maybe you can help me with a > > better approach: > > > The clocking arrangement is encoded in the dai_fmt field of snd_soc_dai_link, > > but this is a single value that describes the format on both ends. The current > > behaviour of ASoC is to flip the clock roles encoded in dai_fmt when applying it > > to the CPU side of the link. > > > Looking from a DT perspective, if I do not specify e.g. bitclock-master on > > either side of the link, then the dai_fmt will describe the codec as a bitclock > > consumer and (after flipping) the CPU as a provider. That's the default > > implication of the DT bindings and I can't break compatibility there. > > None of this addresses my question. To repeat why would we not just > describe the actual clocking arrangement here - this property does not > specify where the clock actually comes from at all, we're still going to > need additional information for that and if we've described that clock > then we already know it's there without having to specify any more > properties. Maybe I overcomplicated your point with my previous reply. Some questions to clarify: 1. You don't like the DT property because it should be inferrable by other means. Correct? 2. As for the flag added to snd_soc_dai_link, do you think that is an OK approach? Just want to understand which direction you would like me to focus the effort. Kind regards, Alvin
On Fri, Jun 02, 2023 at 12:42:49PM +0000, Alvin Šipraga wrote: > Yes I see what you mean. On my platform the clock source is actually described > by the common clock framework, so I would want to use that. If it were a > component driver then it would most likely be a codec that is part of the > dai-link anyway. So what about having two struct clk pointers in struct > snd_soc_dai? > > struct snd_soc_dai { > /* ... */ > struct clk *bitclock_provider; > struct clk *frameclock_provider; > /* ... */ > }; > If non-NULL I could then have the ASoC core enable/disable the clocks on demand? > I would say in hw_params/hw_free, albeit that runs after set_fmt. hw_params() can be called repeatedly so that's not a good fit but broadly yes. > Having said that, I see ASoC doesn't really use the CCF much... am I way off? Ideally we'd be representing more of the clocking via the clock framework but at present yes. > I don't think it's feasible to modify every component driver to explicitly > handle this and then ignore any CBP_CFP bits set in its call to set_fmt - this > is why I want help from the ASoC core. Sure, but that's not going to impact the DT bindings. All these things are driven from the machine driver. > > If simple-card can't be made to work that's fine, it's deprecated > > anyway. > Ah OK, I didn't know that. Right now I'm using graph-card2, that's not > deprecated, right? Yes, audio-graph-card replaces simple-card.
diff --git a/Documentation/devicetree/bindings/sound/simple-card.yaml b/Documentation/devicetree/bindings/sound/simple-card.yaml index b05e05c81cc4..ce738d1a394d 100644 --- a/Documentation/devicetree/bindings/sound/simple-card.yaml +++ b/Documentation/devicetree/bindings/sound/simple-card.yaml @@ -27,6 +27,11 @@ definitions: description: dai-link uses bit clock inversion $ref: /schemas/types.yaml#/definitions/flag + symmetric-clock-roles: + description: | + dai-link uses same clock consumer/provider role for both CPU and Codec + $ref: /schemas/types.yaml#/definitions/flag + dai-tdm-slot-num: description: see tdm-slot.txt. $ref: /schemas/types.yaml#/definitions/uint32 @@ -128,6 +133,8 @@ definitions: $ref: "#/definitions/frame-inversion" bitclock-inversion: $ref: "#/definitions/bitclock-inversion" + symmetric-clock-roles: + $ref: "#/definitions/symmetric-clock-roles" frame-master: $ref: /schemas/types.yaml#/definitions/flag bitclock-master: @@ -181,6 +188,8 @@ properties: $ref: "#/definitions/frame-inversion" simple-audio-card,bitclock-inversion: $ref: "#/definitions/bitclock-inversion" + simple-audio-card,symmetric-clock-roles: + $ref: "#/definitions/symmetric-clock-roles" simple-audio-card,format: $ref: "#/definitions/format" simple-audio-card,mclk-fs: @@ -230,6 +239,8 @@ patternProperties: $ref: "#/definitions/frame-inversion" bitclock-inversion: $ref: "#/definitions/bitclock-inversion" + symmetric-clock-roles: + $ref: "#/definitions/symmetric-clock-roles" format: $ref: "#/definitions/format" mclk-fs: