ASoC: simple-card: Fix up checks for HW param fixups
PATCH 1/1 ASoC: simple-card: Fix up checks for HW param fixups
The "convert-xxx" properties only have an effect for DPCM DAI links. A DAI link is only created as DPCM if the device tree requires it; part of this involves checking for the use of "convert-xxx" properties.
When the convert-sample-format property was added, the checks got out of sync. A DAI link that specified only convert-sample-format but did not pass any of the other DPCM checks would not go into DPCM mode and the convert-sample-format property would be silently ignored.
Fix this by adding a function to do the "convert-xxx" property checks, instead of open-coding it in simple-card and audio-graph-card. And add "convert-sample-format" to the check function so that DAI links using it will be initialized correctly.
--- include/sound/simple_card_utils.h | 1 + sound/soc/generic/audio-graph-card.c | 2 +- sound/soc/generic/simple-card-utils.c | 15 +++++++++++++++ sound/soc/generic/simple-card.c | 3 +-- 4 files changed, 18 insertions(+), 3 deletions(-)
include/sound/simple_card_utils.h +1 -0
@@ -177,6 +177,7 @@ void asoc_simple_convert_fixup(struct asoc_simple_data *data, struct snd_pcm_hw_params *params);void asoc_simple_parse_convert (struct device_node *np,char *prefix,struct asoc_simple_data *data); +bool asoc_simple_convert_is_required (const struct asoc_simple_data *data);int asoc_simple_parse_routing (struct snd_soc_card *card,char *prefix);
sound/soc/generic/audio-graph-card.c +1 -1
@@ -417,7 +417,7 @@ static inline bool parse_as_dpcm_link(struct asoc_simple_priv *priv,* or has convert-xxx property */ if ((of_get_child_count (codec_port) >1 ) || - (adata->convert_rate || adata->convert_channels)) +asoc_simple_convert_is_required (adata))return true;return false;
sound/soc/generic/simple-card-utils.c +15 -0
@@ -85,6 +85,21 @@ void asoc_simple_parse_convert(struct device_node *np, }EXPORT_SYMBOL_GPL (asoc_simple_parse_convert); +/** +* asoc_simple_convert_is_required() - Query if HW param conversion was requested +* @data: Link data. +* +* Returns true if any HW param conversion was requested for this DAI link with +* any "convert-xxx" properties. +*/ +bool asoc_simple_convert_is_required (const struct asoc_simple_data *data) +{ +return data->convert_rate || + data->convert_channels || + data->convert_sample_format; +} +EXPORT_SYMBOL_GPL (asoc_simple_convert_is_required); + int asoc_simple_parse_daifmt(struct device *dev, struct device_node *node, struct device_node *codec,
sound/soc/generic/simple-card.c +1 -2
@@ -393,8 +393,7 @@ static int __simple_for_each_link(struct asoc_simple_priv *priv,* or has convert-xxx property */ if (dpcm_selectable && - (num >2 || - adata.convert_rate || adata.convert_channels)) { + (num >2 ||asoc_simple_convert_is_required (&adata))) {/* * np * |1(CPU)|0(Codec) li->cpu
Signature · 1 line
2.38.0
Hi Aidan
Quoted 17 lines
The "convert-xxx" properties only have an effect for DPCM DAI links. A DAI link is only created as DPCM if the device tree requires it; part of this involves checking for the use of "convert-xxx" properties.
When the convert-sample-format property was added, the checks got out of sync. A DAI link that specified only convert-sample-format but did not pass any of the other DPCM checks would not go into DPCM mode and the convert-sample-format property would be silently ignored.
Fix this by adding a function to do the "convert-xxx" property checks, instead of open-coding it in simple-card and audio-graph-card. And add "convert-sample-format" to the check function so that DAI links using it will be initialized correctly.
Fixes 047a05366f4b ("ASoC: simple-card-utils: Fixup DAI sample format")Signed-off-by Aidan MacDonald <[email protected]>---
(snip)
Quoted 1 line
+bool
asoc_simple_convert_is_required(const struct asoc_simple_data *data);
This is not a big deal, but "is_conert_required" is better for me :)
Thank you for your help !!
Best regards
---
Kuninori Morimoto
Quoted 24 lines · Kuninori Morimoto
Hi Aidan
Quoted 17 lines
The "convert-xxx" properties only have an effect for DPCM DAI links. A DAI link is only created as DPCM if the device tree requires it; part of this involves checking for the use of "convert-xxx" properties.
When the convert-sample-format property was added, the checks got out of sync. A DAI link that specified only convert-sample-format but did not pass any of the other DPCM checks would not go into DPCM mode and the convert-sample-format property would be silently ignored.
Fix this by adding a function to do the "convert-xxx" property checks, instead of open-coding it in simple-card and audio-graph-card. And add "convert-sample-format" to the check function so that DAI links using it will be initialized correctly.
Fixes 047a05366f4b ("ASoC: simple-card-utils: Fixup DAI sample format")Signed-off-by Aidan MacDonald <[email protected]>---
(snip)
Quoted 1 line
+bool
asoc_simple_convert_is_required(const struct asoc_simple_data *data);This is not a big deal, but "
is_conert_required" is better for me :)
Quoted 7 lines
Thank you for your help !!
Best regards
---
Kuninori Morimoto
That sounds better, thanks. I'm sending patch v2 now.
- Aidan