Message ID | 20230602090322.1876359-2-alvin@pqrs.dk |
---|---|
State | New |
Headers | show |
Series | ASoC: support dai-links with symmetric clock roles | expand |
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 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: