[alsa-devel] [PATCH 0/6] ASoC: simple-card: use asoc_simple_card_parse_xxx()
Hi Mark
These are v3 of [PATCH 00/39 v2] ASoC: add simple-card-core and standardize "simple" card but as new patch series.
These are separated into small pieces. Basically, these patches are util.c has new function -> simple-card use it. I will post next remain patches if previous patches was accepted. It will be 6 - 9 patches / 1 series.
Now, util.c on mark/topic/simple branch has daifmt() function. So, 1) - 2) : use new daifmt() 3) - 5) : add new dailink_name() and use it. 6) : tidyup rsrc-card
This existing rcar-card will be renamed to simple-dpcm-card in final patch. (Maybe we need to consider more better nameing)
Kuninori Morimoto (6): 1) ASoC: simple-card: use asoc_simple_card_parse_daifmt() 2) ASoC: rsrc-card: use asoc_simple_card_parse_daifmt() 3) ASoC: simple-card-utils: add asoc_simple_card_parse_dailink_name() 4) ASoC: simple-card: use asoc_simple_card_parse_dailink_name() 5) ASoC: rsrc-card: use asoc_simple_card_parse_dailink_name() 6) ASoC: rsrc-card: use asoc_simple_dai instead of rsrc_card_dai
include/sound/simple_card.h | 11 +---- include/sound/simple_card_utils.h | 12 +++++ sound/soc/generic/Kconfig | 1 + sound/soc/generic/simple-card-utils.c | 30 +++++++++++++ sound/soc/generic/simple-card.c | 60 ++----------------------- sound/soc/sh/Kconfig | 1 + sound/soc/sh/rcar/rsrc-card.c | 83 ++++++++--------------------------- 7 files changed, 67 insertions(+), 131 deletions(-)
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
We can use simpel utils asoc_simple_card_parse_daifmt(). Let's use it
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/simple_card.h | 11 +--------- include/sound/simple_card_utils.h | 10 +++++++++ sound/soc/generic/Kconfig | 1 + sound/soc/generic/simple-card.c | 46 ++------------------------------------- 4 files changed, 14 insertions(+), 54 deletions(-)
diff --git a/include/sound/simple_card.h b/include/sound/simple_card.h index 0399352..a6a2e15 100644 --- a/include/sound/simple_card.h +++ b/include/sound/simple_card.h @@ -13,16 +13,7 @@ #define __SIMPLE_CARD_H
#include <sound/soc.h> - -struct asoc_simple_dai { - const char *name; - unsigned int sysclk; - int slots; - int slot_width; - unsigned int tx_slot_mask; - unsigned int rx_slot_mask; - struct clk *clk; -}; +#include <sound/simple_card_utils.h>
struct asoc_simple_card_info { const char *name; diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index 7acc798..50aa7b2 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -12,6 +12,16 @@
#include <sound/soc.h>
+struct asoc_simple_dai { + const char *name; + unsigned int sysclk; + int slots; + int slot_width; + unsigned int tx_slot_mask; + unsigned int rx_slot_mask; + struct clk *clk; +}; + int asoc_simple_card_parse_daifmt(struct device *dev, struct device_node *node, struct device_node *codec, diff --git a/sound/soc/generic/Kconfig b/sound/soc/generic/Kconfig index 26c2fe6..c01c5dd 100644 --- a/sound/soc/generic/Kconfig +++ b/sound/soc/generic/Kconfig @@ -3,5 +3,6 @@ config SND_SIMPLE_CARD_UTILS
config SND_SIMPLE_CARD tristate "ASoC Simple sound card support" + select SND_SIMPLE_CARD_UTILS help This option enables generic simple sound card support diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 8d0311c..e3a32d3 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -308,48 +308,6 @@ asoc_simple_card_sub_parse_of(struct device_node *np, return 0; }
-static int asoc_simple_card_parse_daifmt(struct device_node *node, - struct simple_card_data *priv, - struct device_node *codec, - char *prefix, int idx) -{ - struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, idx); - struct device *dev = simple_priv_to_dev(priv); - struct device_node *bitclkmaster = NULL; - struct device_node *framemaster = NULL; - unsigned int daifmt; - - daifmt = snd_soc_of_parse_daifmt(node, prefix, - &bitclkmaster, &framemaster); - daifmt &= ~SND_SOC_DAIFMT_MASTER_MASK; - - if (strlen(prefix) && !bitclkmaster && !framemaster) { - /* - * No dai-link level and master setting was not found from - * sound node level, revert back to legacy DT parsing and - * take the settings from codec node. - */ - dev_dbg(dev, "Revert to legacy daifmt parsing\n"); - - daifmt = snd_soc_of_parse_daifmt(codec, NULL, NULL, NULL) | - (daifmt & ~SND_SOC_DAIFMT_CLOCK_MASK); - } else { - if (codec == bitclkmaster) - daifmt |= (codec == framemaster) ? - SND_SOC_DAIFMT_CBM_CFM : SND_SOC_DAIFMT_CBM_CFS; - else - daifmt |= (codec == framemaster) ? - SND_SOC_DAIFMT_CBS_CFM : SND_SOC_DAIFMT_CBS_CFS; - } - - dai_link->dai_fmt = daifmt; - - of_node_put(bitclkmaster); - of_node_put(framemaster); - - return 0; -} - static int asoc_simple_card_dai_link_of(struct device_node *node, struct simple_card_data *priv, int idx, @@ -386,8 +344,8 @@ static int asoc_simple_card_dai_link_of(struct device_node *node, goto dai_link_of_err; }
- ret = asoc_simple_card_parse_daifmt(node, priv, - codec, prefix, idx); + ret = asoc_simple_card_parse_daifmt(dev, node, codec, + prefix, &dai_link->dai_fmt); if (ret < 0) goto dai_link_of_err;
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/sh/Kconfig | 1 + sound/soc/sh/rcar/rsrc-card.c | 38 ++++---------------------------------- 2 files changed, 5 insertions(+), 34 deletions(-)
diff --git a/sound/soc/sh/Kconfig b/sound/soc/sh/Kconfig index c9902a6..9311f11 100644 --- a/sound/soc/sh/Kconfig +++ b/sound/soc/sh/Kconfig @@ -44,6 +44,7 @@ config SND_SOC_RCAR
config SND_SOC_RSRC_CARD tristate "Renesas Sampling Rate Convert Sound Card" + select SND_SIMPLE_CARD_UTILS help This option enables simple sound if you need sampling rate convert
diff --git a/sound/soc/sh/rcar/rsrc-card.c b/sound/soc/sh/rcar/rsrc-card.c index b85b5ee..c065a6d 100644 --- a/sound/soc/sh/rcar/rsrc-card.c +++ b/sound/soc/sh/rcar/rsrc-card.c @@ -20,6 +20,7 @@ #include <sound/jack.h> #include <sound/soc.h> #include <sound/soc-dai.h> +#include <sound/simple_card_utils.h>
struct rsrc_card_of_data { const char *prefix; @@ -158,38 +159,6 @@ static int rsrc_card_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, return 0; }
-static int rsrc_card_parse_daifmt(struct device_node *node, - struct device_node *codec, - struct rsrc_card_priv *priv, - struct snd_soc_dai_link *dai_link, - unsigned int *retfmt) -{ - struct device_node *bitclkmaster = NULL; - struct device_node *framemaster = NULL; - unsigned int daifmt; - - daifmt = snd_soc_of_parse_daifmt(node, NULL, - &bitclkmaster, &framemaster); - daifmt &= ~SND_SOC_DAIFMT_MASTER_MASK; - - if (!bitclkmaster && !framemaster) - return -EINVAL; - - if (codec == bitclkmaster) - daifmt |= (codec == framemaster) ? - SND_SOC_DAIFMT_CBM_CFM : SND_SOC_DAIFMT_CBM_CFS; - else - daifmt |= (codec == framemaster) ? - SND_SOC_DAIFMT_CBS_CFM : SND_SOC_DAIFMT_CBS_CFS; - - of_node_put(bitclkmaster); - of_node_put(framemaster); - - *retfmt = daifmt; - - return 0; -} - static int rsrc_card_parse_links(struct device_node *np, struct rsrc_card_priv *priv, int idx, bool is_fe) @@ -357,6 +326,7 @@ static int rsrc_card_dai_sub_link_of(struct device_node *node, static int rsrc_card_dai_link_of(struct device_node *node, struct rsrc_card_priv *priv) { + struct device *dev = rsrc_priv_to_dev(priv); struct snd_soc_dai_link *dai_link; struct device_node *np; unsigned int daifmt = 0; @@ -369,8 +339,8 @@ static int rsrc_card_dai_link_of(struct device_node *node, dai_link = rsrc_priv_to_link(priv, i);
if (strcmp(np->name, "codec") == 0) { - ret = rsrc_card_parse_daifmt(node, np, priv, - dai_link, &daifmt); + ret = asoc_simple_card_parse_daifmt(dev, node, np, + NULL, &daifmt); if (ret < 0) return ret; break;
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Current simple-card is creating dai_link->name / dai_link->stream_name. These are based on CPU + Codec name. It can be "fe.CPU" or "be.Codec" if it was DPCM. This patch adds simple card common function for it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/simple_card_utils.h | 2 ++ sound/soc/generic/simple-card-utils.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+)
diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index 50aa7b2..3abe224 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -27,5 +27,7 @@ int asoc_simple_card_parse_daifmt(struct device *dev, struct device_node *codec, char *prefix, unsigned int *retfmt); +int asoc_simple_card_parse_dailink_name(struct device *dev, + struct snd_soc_dai_link *dai_link);
#endif /* __SIMPLE_CARD_CORE_H */ diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index 3f6b725..14d3a75 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -52,3 +52,33 @@ int asoc_simple_card_parse_daifmt(struct device *dev, return 0; } EXPORT_SYMBOL_GPL(asoc_simple_card_parse_daifmt); + +int asoc_simple_card_parse_dailink_name(struct device *dev, + struct snd_soc_dai_link *dai_link) +{ + char *name = NULL; + int ret = -ENOMEM; + + if (dai_link->dynamic && dai_link->cpu_dai_name) + name = devm_kasprintf(dev, GFP_KERNEL, + "fe.%s", dai_link->cpu_dai_name); + + else if (dai_link->no_pcm && dai_link->codec_dai_name) + name = devm_kasprintf(dev, GFP_KERNEL, + "be.%s", dai_link->codec_dai_name); + else if (dai_link->cpu_dai_name && dai_link->codec_dai_name) + name = devm_kasprintf(dev, GFP_KERNEL, + "%s-%s", + dai_link->cpu_dai_name, + dai_link->codec_dai_name); + + if (name) { + ret = 0; + + dai_link->name = + dai_link->stream_name = name; + } + + return ret; +} +EXPORT_SYMBOL_GPL(asoc_simple_card_parse_dailink_name);
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/generic/simple-card.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-)
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index e3a32d3..7dd5dc1 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -319,7 +319,6 @@ static int asoc_simple_card_dai_link_of(struct device_node *node, struct device_node *cpu = NULL; struct device_node *plat = NULL; struct device_node *codec = NULL; - char *name; char prop[128]; char *prefix = ""; int ret, cpu_args; @@ -380,19 +379,10 @@ static int asoc_simple_card_dai_link_of(struct device_node *node, if (!dai_link->platform_of_node) dai_link->platform_of_node = dai_link->cpu_of_node;
- /* DAI link name is created from CPU/CODEC dai name */ - name = devm_kzalloc(dev, - strlen(dai_link->cpu_dai_name) + - strlen(dai_link->codec_dai_name) + 2, - GFP_KERNEL); - if (!name) { - ret = -ENOMEM; + ret = asoc_simple_card_parse_dailink_name(dev, dai_link); + if (ret < 0) goto dai_link_of_err; - }
- sprintf(name, "%s-%s", dai_link->cpu_dai_name, - dai_link->codec_dai_name); - dai_link->name = dai_link->stream_name = name; dai_link->ops = &asoc_simple_card_ops; dai_link->init = asoc_simple_card_dai_init;
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/sh/rcar/rsrc-card.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-)
diff --git a/sound/soc/sh/rcar/rsrc-card.c b/sound/soc/sh/rcar/rsrc-card.c index c065a6d..aad8f8c 100644 --- a/sound/soc/sh/rcar/rsrc-card.c +++ b/sound/soc/sh/rcar/rsrc-card.c @@ -47,7 +47,6 @@ static const struct of_device_id rsrc_card_of_match[] = { }; MODULE_DEVICE_TABLE(of, rsrc_card_of_match);
-#define DAI_NAME_NUM 32 struct rsrc_card_dai { unsigned int sysclk; unsigned int tx_slot_mask; @@ -55,7 +54,7 @@ struct rsrc_card_dai { int slots; int slot_width; struct clk *clk; - char dai_name[DAI_NAME_NUM]; + const char *name; };
#define IDX_CPU 0 @@ -163,6 +162,7 @@ static int rsrc_card_parse_links(struct device_node *np, struct rsrc_card_priv *priv, int idx, bool is_fe) { + struct device *dev = rsrc_priv_to_dev(priv); struct snd_soc_dai_link *dai_link = rsrc_priv_to_link(priv, idx); struct rsrc_card_dai *dai_props = rsrc_priv_to_props(priv, idx); struct of_phandle_args args; @@ -200,10 +200,6 @@ static int rsrc_card_parse_links(struct device_node *np, if (ret < 0) return ret;
- /* set dai_name */ - snprintf(dai_props->dai_name, DAI_NAME_NUM, "fe.%s", - dai_link->cpu_dai_name); - /* * In soc_bind_dai_link() will check cpu name after * of_node matching if dai_link has cpu_dai_name. @@ -216,7 +212,6 @@ static int rsrc_card_parse_links(struct device_node *np, if (!args.args_count) dai_link->cpu_dai_name = NULL; } else { - struct device *dev = rsrc_priv_to_dev(priv); const struct rsrc_card_of_data *of_data;
of_data = of_device_get_match_data(dev); @@ -244,18 +239,16 @@ static int rsrc_card_parse_links(struct device_node *np, dai_link->codec_of_node, "audio-prefix"); } - - /* set dai_name */ - snprintf(dai_props->dai_name, DAI_NAME_NUM, "be.%s", - dai_link->codec_dai_name); }
+ ret = asoc_simple_card_parse_dailink_name(dev, dai_link); + if (ret < 0) + return ret; + /* Simple Card assumes platform == cpu */ dai_link->platform_of_node = dai_link->cpu_of_node; dai_link->dpcm_playback = 1; dai_link->dpcm_capture = 1; - dai_link->name = dai_props->dai_name; - dai_link->stream_name = dai_props->dai_name; dai_link->ops = &rsrc_card_ops; dai_link->init = rsrc_card_dai_init;
@@ -316,7 +309,7 @@ static int rsrc_card_dai_sub_link_of(struct device_node *node, return ret;
dev_dbg(dev, "\t%s / %04x / %d\n", - dai_props->dai_name, + dai_link->name, dai_link->dai_fmt, dai_props->sysclk);
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/sh/rcar/rsrc-card.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-)
diff --git a/sound/soc/sh/rcar/rsrc-card.c b/sound/soc/sh/rcar/rsrc-card.c index aad8f8c..e28c9c0 100644 --- a/sound/soc/sh/rcar/rsrc-card.c +++ b/sound/soc/sh/rcar/rsrc-card.c @@ -47,22 +47,12 @@ static const struct of_device_id rsrc_card_of_match[] = { }; MODULE_DEVICE_TABLE(of, rsrc_card_of_match);
-struct rsrc_card_dai { - unsigned int sysclk; - unsigned int tx_slot_mask; - unsigned int rx_slot_mask; - int slots; - int slot_width; - struct clk *clk; - const char *name; -}; - #define IDX_CPU 0 #define IDX_CODEC 1 struct rsrc_card_priv { struct snd_soc_card snd_card; struct snd_soc_codec_conf codec_conf; - struct rsrc_card_dai *dai_props; + struct asoc_simple_dai *dai_props; struct snd_soc_dai_link *dai_link; u32 convert_rate; u32 convert_channels; @@ -76,7 +66,7 @@ static int rsrc_card_startup(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct rsrc_card_priv *priv = snd_soc_card_get_drvdata(rtd->card); - struct rsrc_card_dai *dai_props = + struct asoc_simple_dai *dai_props = rsrc_priv_to_props(priv, rtd->num);
return clk_prepare_enable(dai_props->clk); @@ -86,7 +76,7 @@ static void rsrc_card_shutdown(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct rsrc_card_priv *priv = snd_soc_card_get_drvdata(rtd->card); - struct rsrc_card_dai *dai_props = + struct asoc_simple_dai *dai_props = rsrc_priv_to_props(priv, rtd->num);
clk_disable_unprepare(dai_props->clk); @@ -102,7 +92,7 @@ static int rsrc_card_dai_init(struct snd_soc_pcm_runtime *rtd) struct rsrc_card_priv *priv = snd_soc_card_get_drvdata(rtd->card); struct snd_soc_dai *dai; struct snd_soc_dai_link *dai_link; - struct rsrc_card_dai *dai_props; + struct asoc_simple_dai *dai_props; int num = rtd->num; int ret;
@@ -164,7 +154,7 @@ static int rsrc_card_parse_links(struct device_node *np, { struct device *dev = rsrc_priv_to_dev(priv); struct snd_soc_dai_link *dai_link = rsrc_priv_to_link(priv, idx); - struct rsrc_card_dai *dai_props = rsrc_priv_to_props(priv, idx); + struct asoc_simple_dai *dai_props = rsrc_priv_to_props(priv, idx); struct of_phandle_args args; int ret;
@@ -260,7 +250,7 @@ static int rsrc_card_parse_clk(struct device_node *np, int idx, bool is_fe) { struct snd_soc_dai_link *dai_link = rsrc_priv_to_link(priv, idx); - struct rsrc_card_dai *dai_props = rsrc_priv_to_props(priv, idx); + struct asoc_simple_dai *dai_props = rsrc_priv_to_props(priv, idx); struct clk *clk; struct device_node *of_np = is_fe ? dai_link->cpu_of_node : dai_link->codec_of_node; @@ -297,7 +287,7 @@ static int rsrc_card_dai_sub_link_of(struct device_node *node, { struct device *dev = rsrc_priv_to_dev(priv); struct snd_soc_dai_link *dai_link = rsrc_priv_to_link(priv, idx); - struct rsrc_card_dai *dai_props = rsrc_priv_to_props(priv, idx); + struct asoc_simple_dai *dai_props = rsrc_priv_to_props(priv, idx); int ret;
ret = rsrc_card_parse_links(np, priv, idx, is_fe); @@ -364,7 +354,7 @@ static int rsrc_card_parse_of(struct device_node *node, struct device *dev) { const struct rsrc_card_of_data *of_data = of_device_get_match_data(dev); - struct rsrc_card_dai *props; + struct asoc_simple_dai *props; struct snd_soc_dai_link *links; int ret; int num;
The patch
ASoC: simple-card: use asoc_simple_card_parse_daifmt()
has been applied to the asoc tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks, Mark
From cecdef3656956b0978bf86ecd1ce0542d2c61e97 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Date: Thu, 30 Jun 2016 06:02:46 +0000 Subject: [PATCH] ASoC: simple-card: use asoc_simple_card_parse_daifmt()
We can use simpel utils asoc_simple_card_parse_daifmt(). Let's use it
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown broonie@kernel.org --- include/sound/simple_card.h | 11 +--------- include/sound/simple_card_utils.h | 10 +++++++++ sound/soc/generic/Kconfig | 1 + sound/soc/generic/simple-card.c | 46 ++------------------------------------- 4 files changed, 14 insertions(+), 54 deletions(-)
diff --git a/include/sound/simple_card.h b/include/sound/simple_card.h index 0399352f3a62..a6a2e1547092 100644 --- a/include/sound/simple_card.h +++ b/include/sound/simple_card.h @@ -13,16 +13,7 @@ #define __SIMPLE_CARD_H
#include <sound/soc.h> - -struct asoc_simple_dai { - const char *name; - unsigned int sysclk; - int slots; - int slot_width; - unsigned int tx_slot_mask; - unsigned int rx_slot_mask; - struct clk *clk; -}; +#include <sound/simple_card_utils.h>
struct asoc_simple_card_info { const char *name; diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index 7acc798016e0..50aa7b22a94c 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -12,6 +12,16 @@
#include <sound/soc.h>
+struct asoc_simple_dai { + const char *name; + unsigned int sysclk; + int slots; + int slot_width; + unsigned int tx_slot_mask; + unsigned int rx_slot_mask; + struct clk *clk; +}; + int asoc_simple_card_parse_daifmt(struct device *dev, struct device_node *node, struct device_node *codec, diff --git a/sound/soc/generic/Kconfig b/sound/soc/generic/Kconfig index 26c2fe6a0b93..c01c5dd68601 100644 --- a/sound/soc/generic/Kconfig +++ b/sound/soc/generic/Kconfig @@ -3,5 +3,6 @@ config SND_SIMPLE_CARD_UTILS
config SND_SIMPLE_CARD tristate "ASoC Simple sound card support" + select SND_SIMPLE_CARD_UTILS help This option enables generic simple sound card support diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 8d0311ceded1..e3a32d340482 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -308,48 +308,6 @@ asoc_simple_card_sub_parse_of(struct device_node *np, return 0; }
-static int asoc_simple_card_parse_daifmt(struct device_node *node, - struct simple_card_data *priv, - struct device_node *codec, - char *prefix, int idx) -{ - struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, idx); - struct device *dev = simple_priv_to_dev(priv); - struct device_node *bitclkmaster = NULL; - struct device_node *framemaster = NULL; - unsigned int daifmt; - - daifmt = snd_soc_of_parse_daifmt(node, prefix, - &bitclkmaster, &framemaster); - daifmt &= ~SND_SOC_DAIFMT_MASTER_MASK; - - if (strlen(prefix) && !bitclkmaster && !framemaster) { - /* - * No dai-link level and master setting was not found from - * sound node level, revert back to legacy DT parsing and - * take the settings from codec node. - */ - dev_dbg(dev, "Revert to legacy daifmt parsing\n"); - - daifmt = snd_soc_of_parse_daifmt(codec, NULL, NULL, NULL) | - (daifmt & ~SND_SOC_DAIFMT_CLOCK_MASK); - } else { - if (codec == bitclkmaster) - daifmt |= (codec == framemaster) ? - SND_SOC_DAIFMT_CBM_CFM : SND_SOC_DAIFMT_CBM_CFS; - else - daifmt |= (codec == framemaster) ? - SND_SOC_DAIFMT_CBS_CFM : SND_SOC_DAIFMT_CBS_CFS; - } - - dai_link->dai_fmt = daifmt; - - of_node_put(bitclkmaster); - of_node_put(framemaster); - - return 0; -} - static int asoc_simple_card_dai_link_of(struct device_node *node, struct simple_card_data *priv, int idx, @@ -386,8 +344,8 @@ static int asoc_simple_card_dai_link_of(struct device_node *node, goto dai_link_of_err; }
- ret = asoc_simple_card_parse_daifmt(node, priv, - codec, prefix, idx); + ret = asoc_simple_card_parse_daifmt(dev, node, codec, + prefix, &dai_link->dai_fmt); if (ret < 0) goto dai_link_of_err;
Hi Mark
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Current simple-card is creating dai_link->name / dai_link->stream_name. These are based on CPU + Codec name. It can be "fe.CPU" or "be.Codec" if it was DPCM. This patch adds simple card common function for it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
(snip)
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index 3f6b725..14d3a75 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -52,3 +52,33 @@ int asoc_simple_card_parse_daifmt(struct device *dev, return 0; } EXPORT_SYMBOL_GPL(asoc_simple_card_parse_daifmt);
+int asoc_simple_card_parse_dailink_name(struct device *dev,
struct snd_soc_dai_link *dai_link)
+{
- char *name = NULL;
- int ret = -ENOMEM;
- if (dai_link->dynamic && dai_link->cpu_dai_name)
name = devm_kasprintf(dev, GFP_KERNEL,
"fe.%s", dai_link->cpu_dai_name);
- else if (dai_link->no_pcm && dai_link->codec_dai_name)
name = devm_kasprintf(dev, GFP_KERNEL,
"be.%s", dai_link->codec_dai_name);
- else if (dai_link->cpu_dai_name && dai_link->codec_dai_name)
name = devm_kasprintf(dev, GFP_KERNEL,
"%s-%s",
dai_link->cpu_dai_name,
dai_link->codec_dai_name);
- if (name) {
ret = 0;
dai_link->name =
dai_link->stream_name = name;
- }
- return ret;
+} +EXPORT_SYMBOL_GPL(asoc_simple_card_parse_dailink_name);
Please let me know if your favored style is name format should be handled on each sound card, not in utils.c I can arrange it.
On Tue, Jul 05, 2016 at 12:24:54AM +0000, Kuninori Morimoto wrote:
Please let me know if your favored style is name format should be handled on each sound card, not in utils.c I can arrange it.
I'd definitely prefer to limit the usage of DPCM in generic code so keeping it in the card seems safer.
Hi Mark
Please let me know if your favored style is name format should be handled on each sound card, not in utils.c I can arrange it.
I'd definitely prefer to limit the usage of DPCM in generic code so keeping it in the card seems safer.
As you wish !! I will do it in next version.
participants (2)
-
Kuninori Morimoto
-
Mark Brown