ASoC: simple-card: Fix up checks for HW param fixups
authorAidan MacDonald <aidanmacdonald.0x0@gmail.com>
Wed, 19 Oct 2022 01:23:02 +0000 (02:23 +0100)
committerMark Brown <broonie@kernel.org>
Wed, 19 Oct 2022 12:39:34 +0000 (13:39 +0100)
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")
Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>
Acked-by: Sameer Pujar <spujar@nvidia.com>
Link: https://lore.kernel.org/r/20221019012302.633830-1-aidanmacdonald.0x0@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/simple_card_utils.h
sound/soc/generic/audio-graph-card.c
sound/soc/generic/simple-card-utils.c
sound/soc/generic/simple-card.c

index a0b827f0c2f60189ceeeed1b2ccce1b570c5441e..25e049f441784537a11d5194a31bb42360c20e3b 100644 (file)
@@ -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_is_convert_required(const struct asoc_simple_data *data);
 
 int asoc_simple_parse_routing(struct snd_soc_card *card,
                                      char *prefix);
index b327372f2e4ae52aafa2511a564d6024b076d94d..fe7cf972d44ce61e550e206174f0b5bc98eb4b13 100644 (file)
@@ -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_is_convert_required(adata))
                return true;
 
        return false;
index bef16833c487e27eaf6ff7a2716e88a1d5cd5356..be69bbc47f8138d1f6561c60b606d0595e624049 100644 (file)
@@ -85,6 +85,21 @@ void asoc_simple_parse_convert(struct device_node *np,
 }
 EXPORT_SYMBOL_GPL(asoc_simple_parse_convert);
 
+/**
+ * asoc_simple_is_convert_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_is_convert_required(const struct asoc_simple_data *data)
+{
+       return data->convert_rate ||
+              data->convert_channels ||
+              data->convert_sample_format;
+}
+EXPORT_SYMBOL_GPL(asoc_simple_is_convert_required);
+
 int asoc_simple_parse_daifmt(struct device *dev,
                             struct device_node *node,
                             struct device_node *codec,
index 78419e18717d65d7bfb56033be72eb2c1629691b..feb55b66239b8598716d772f8d8be9edd238267e 100644 (file)
@@ -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_is_convert_required(&adata))) {
                                /*
                                 * np
                                 *       |1(CPU)|0(Codec)  li->cpu