[alsa-devel] [RFC PATCH 0/2] Introduce for-dpcm DT property
We need to be able to create DPCM links even if we have a single CPU DAI or just a dummy CPU DAI.
Daniel Baluta (2): ASoC: simple-card: Introduce force-dpcm DT property ASoC: simple-card: Add documentation for force-dpcm property
.../devicetree/bindings/sound/simple-card.txt | 1 + include/sound/simple_card_utils.h | 4 +++ sound/soc/generic/simple-card-utils.c | 17 +++++++++++++ sound/soc/generic/simple-card.c | 25 +++++++++++++++++-- 4 files changed, 45 insertions(+), 2 deletions(-)
Until now dai_link uses dynamic PCM in the following conditions: * it is dpcm_selectable (this means compatible string is simple-scu-card) * it has convert-xxx property * or it has more than one CPU DAIs
Our use case requires to be able to build a DPCM link with just 1 CPU. Add force-dpcm DT property to realize this.
Signed-off-by: Daniel Baluta daniel.baluta@nxp.com --- include/sound/simple_card_utils.h | 4 ++++ sound/soc/generic/simple-card-utils.c | 17 +++++++++++++++++ sound/soc/generic/simple-card.c | 25 +++++++++++++++++++++++-- 3 files changed, 44 insertions(+), 2 deletions(-)
diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index 985a5f583de4..0578bbfa4a24 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -48,6 +48,7 @@ struct asoc_simple_priv { struct asoc_simple_data adata; struct snd_soc_codec_conf *codec_conf; unsigned int mclk_fs; + unsigned int force_dpcm; } *dai_props; struct asoc_simple_jack hp_jack; struct asoc_simple_jack mic_jack; @@ -120,6 +121,9 @@ void asoc_simple_convert_fixup(struct asoc_simple_data *data, void asoc_simple_parse_convert(struct device *dev, struct device_node *np, char *prefix, struct asoc_simple_data *data); +void asoc_simple_parse_force_dpcm(struct device *dev, + struct device_node *np, char *prefix, + unsigned int *force_dpcm);
int asoc_simple_parse_routing(struct snd_soc_card *card, char *prefix); diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index 9b794775df53..2f03a73f8a8a 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -52,6 +52,23 @@ void asoc_simple_parse_convert(struct device *dev, } EXPORT_SYMBOL_GPL(asoc_simple_parse_convert);
+void asoc_simple_parse_force_dpcm(struct device *dev, + struct device_node *np, + char *prefix, + unsigned int *force_dpcm) +{ + char prop[128]; + + if (!prefix) + prefix = ""; + + /* dpcm property */ + snprintf(prop, sizeof(prop), "%s%s", prefix, "force-dpcm"); + if (of_find_property(np, prop, NULL)) + *force_dpcm = 1; +} +EXPORT_SYMBOL_GPL(asoc_simple_parse_force_dpcm); + int asoc_simple_parse_daifmt(struct device *dev, struct device_node *node, struct device_node *codec, diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index fc9c753db8dd..e40e22c8813b 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -92,6 +92,21 @@ static void simple_parse_convert(struct device *dev, of_node_put(node); }
+static void simple_parse_force_dpcm(struct device *dev, + struct device_node *np, + unsigned int *force_dpcm) +{ + struct device_node *top = dev->of_node; + struct device_node *node = of_get_parent(np); + + asoc_simple_parse_force_dpcm(dev, top, PREFIX, force_dpcm); + asoc_simple_parse_force_dpcm(dev, node, PREFIX, force_dpcm); + asoc_simple_parse_force_dpcm(dev, node, NULL, force_dpcm); + asoc_simple_parse_force_dpcm(dev, np, NULL, force_dpcm); + + of_node_put(node); +} + static void simple_parse_mclk_fs(struct device_node *top, struct device_node *cpu, struct device_node *codec, @@ -372,6 +387,7 @@ static int simple_for_each_link(struct asoc_simple_priv *priv, struct asoc_simple_data adata; struct device_node *codec; struct device_node *np; + unsigned int force_dpcm = 0; int num = of_get_child_count(node);
/* get codec */ @@ -387,15 +403,20 @@ static int simple_for_each_link(struct asoc_simple_priv *priv, for_each_child_of_node(node, np) simple_parse_convert(dev, np, &adata);
+ /* get force-dpcm property */ + for_each_child_of_node(node, np) + simple_parse_force_dpcm(dev, np, &force_dpcm); + /* loop for all CPU/Codec node */ for_each_child_of_node(node, np) { /* * It is DPCM * if it has many CPUs, - * or has convert-xxx property + * or it has convert-xxx property + * or it has force-dpcm property */ if (dpcm_selectable && - (num > 2 || + (num > 2 || force_dpcm || adata.convert_rate || adata.convert_channels)) ret = func_dpcm(priv, np, codec, li, is_top); /* else normal sound */
This property can be global in which case all links created will be DPCM or present in certian dai-link subnode in which case only that specific link is forced to be DPCM.
Signed-off-by: Daniel Baluta daniel.baluta@nxp.com --- Documentation/devicetree/bindings/sound/simple-card.txt | 1 + 1 file changed, 1 insertion(+)
diff --git a/Documentation/devicetree/bindings/sound/simple-card.txt b/Documentation/devicetree/bindings/sound/simple-card.txt index 79954cd6e37b..15e6f5329857 100644 --- a/Documentation/devicetree/bindings/sound/simple-card.txt +++ b/Documentation/devicetree/bindings/sound/simple-card.txt @@ -63,6 +63,7 @@ Optional dai-link subnode properties: - mclk-fs : Multiplication factor between stream rate and codec mclk, applied only for the dai-link. +- force-dpcm : Indicates dai-link is always DPCM.
For backward compatibility the frame-master and bitclock-master properties can be used as booleans in codec subnode to indicate if the
On Sun, Oct 13, 2019 at 10:00:14PM +0300, Daniel Baluta wrote:
This property can be global in which case all links created will be DPCM or present in certian dai-link subnode in which case only that specific link is forced to be DPCM.
+- force-dpcm : Indicates dai-link is always DPCM.
DPCM is an implementation detail of Linux (and one that we want to phase out going forwards too), we shouldn't be putting it in the DT bindings where it becomes an ABI.
On Mon, Oct 14, 2019 at 2:57 PM Mark Brown broonie@kernel.org wrote:
On Sun, Oct 13, 2019 at 10:00:14PM +0300, Daniel Baluta wrote:
This property can be global in which case all links created will be DPCM or present in certian dai-link subnode in which case only that specific link is forced to be DPCM.
+- force-dpcm : Indicates dai-link is always DPCM.
DPCM is an implementation detail of Linux (and one that we want to phase out going forwards too), we shouldn't be putting it in the DT bindings where it becomes an ABI.
Hi Mark,
I see your point. This is way I marked the patch series as RFC. I need to find another way to reuse simple-card as machine driver for SOF.
thanks, Daniel.
On Mon, Oct 14, 2019 at 04:17:31PM +0300, Daniel Baluta wrote:
On Mon, Oct 14, 2019 at 2:57 PM Mark Brown broonie@kernel.org wrote:
DPCM is an implementation detail of Linux (and one that we want to phase out going forwards too), we shouldn't be putting it in the DT bindings where it becomes an ABI.
I see your point. This is way I marked the patch series as RFC. I need to find another way to reuse simple-card as machine driver for SOF.
Have a look at the way the Renesas systems are using this and the audio graph card - they have DPCM.
Hi
DPCM is an implementation detail of Linux (and one that we want to phase out going forwards too), we shouldn't be putting it in the DT bindings where it becomes an ABI.
I see your point. This is way I marked the patch series as RFC. I need to find another way to reuse simple-card as machine driver for SOF.
Have a look at the way the Renesas systems are using this and the audio graph card - they have DPCM.
Indeed we (= Renesas) are using this as DPCM, but unfortunately it is not upstreamed. Using local patch.
Thank you for your help !! Best regards --- Kuninori Morimoto
Hi
DPCM is an implementation detail of Linux (and one that we want to phase out going forwards too), we shouldn't be putting it in the DT bindings where it becomes an ABI.
I see your point. This is way I marked the patch series as RFC. I need to find another way to reuse simple-card as machine driver for SOF.
Have a look at the way the Renesas systems are using this and the audio graph card - they have DPCM.
Indeed we (= Renesas) are using this as DPCM, but unfortunately it is not upstreamed. Using local patch.
I mean DT part.
Thank you for your help !! Best regards --- Kuninori Morimoto
participants (4)
-
Daniel Baluta
-
Daniel Baluta
-
Kuninori Morimoto
-
Mark Brown