[alsa-devel] [PATCH 00/39 v2][RESEND] ASoC: add simple-card-core and standardize "simple" card
Hi Mark
These are resend of v2 of simple-card cleanup patches. My previous patch-set was sent almost 1month ago. Some of them are aleady accepted, but nothing happen for almost all other patches.
Because of this stagnation, I already have almost 90 patches for simple-card + graph driver in locally... I would like to post them as soon as possible.
OTOH, I know you don't like super big patchset, Thus, I will post small batch patch set only today. I will post next small batch patch set if 1st batch was accepted.
I listed my local patch set below. It is for simple-card + graph support, and HDMI support for Renesas.
This time I will post * mark patches. These are for simple-card cleanup.
Kuninori Morimoto (90): * ASoC: add new simple-card-utils.c * ASoC: simple-card-utils: add asoc_simple_card_parse_tdm() * ASoC: simple-card-utils: add asoc_simple_card_parse_dailink_name() * ASoC: simple-card-utils: add asoc_simple_card_parse_card_name() * ASoC: simple-card-utils: add asoc_simple_card_parse_card_prefix() * ASoC: simple-card-utils: add asoc_simple_card_parse_clk() * ASoC: simple-card-utils: add asoc_simple_card_parse_endpoint() * ASoC: simple-card-utils: add asoc_simple_card_init_dai() * ASoC: simple-card-utils: add asoc_simple_card_canonicalize_dailink() * ASoC: simple-card-utils: add asoc_simple_card_canonicalize_cpu() * ASoC: simple-card-utils: add asoc_simple_card_clean_reference() ASoC: simple-card: use common PREFIX for each DT property ASoC: simple-card: add new asoc_simple_jack and use it ASoC: simple-card: use asoc_simple_card_parse_daifmt() ASoC: simple-card: use asoc_simple_card_parse_clk() ASoC: simple-card: use asoc_simple_card_parse_endpoint() ASoC: simple-card: use asoc_simple_card_parse_tdm() ASoC: simple-card: use asoc_simple_card_parse_card_name() ASoC: simple-card: use asoc_simple_card_parse_dailink_name() ASoC: simple-card: use asoc_simple_card_init_dai() ASoC: simple-card: use asoc_simple_card_canonicalize_dailink() ASoC: simple-card: use asoc_simple_card_canonicalize_cpu() ASoC: simple-card: use asoc_simple_card_clean_reference() ASoC: rsrc-card: use asoc_simple_card_parse_daifmt() ASoC: rsrc-card: use asoc_simple_card_parse_dailink_name() ASoC: rsrc-card: use asoc_simple_dai instead of rsrc_card_dai ASoC: rsrc-card: use asoc_simple_card_parse_clk() ASoC: rsrc-card: use asoc_simple_card_parse_endpoint() ASoC: rsrc-card: use asoc_simple_card_parse_card_name() ASoC: rsrc-card: use asoc_simple_card_parse_card_prefix() ASoC: rsrc-card: use asoc_simple_card_parse_tdm() ASoC: rsrc-card: use asoc_simple_card_init_dai() ASoC: rsrc-card: use asoc_simple_card_canonicalize_cpu() ASoC: rsrc-card: use asoc_simple_card_canonicalize_dailink() ASoC: rsrc-card: use asoc_simple_card_clean_reference() ASoC: rsrc-card: rename rsrc-card to simple-dpcm-card phase1 ASoC: rsrc-card: rename rsrc-card to simple-dpcm-card phase2 ASoC: rsrc-card: rename rsrc-card to simple-dpcm-card phase3 Documentation: of: add type property of_graph: add of_graph_get_remote_endpoint() of_graph: add of_graph_port/endpoint_type_is() of_graph: add of_graph_get_endpoint_count() of_graph: add of_graph_get_port_parent() of_graph: add of_graph_get_top_port() of_graph: add for_each_of_port() / for_each_of_endpoint_in_port() drm: bridge: add DesignWare HDMI I2S audio support ASoC: hdmi-codec: callback function will be called with private data ASoC: hdmi-codec: enable multi probe for same device ASoC: soc-core: snd_soc_get_dai_name() become non static ASoC: soc-core: adjust for graph on snd_soc_of_parse_card_name ASoC: soc-core: adjust for graph on snd_soc_of_parse_audio_simple_widgets ASoC: soc-core: adjust for graph on snd_soc_of_parse_audio_routing ASoC: soc-core: adjust for graph on snd_soc_of_parse_audio_prefix ASoC: simple-card-utils: rename asoc_simple_card_parse_endpoint to dai ASoC: simple-card-utils: add asoc_simple_card_parse_graph_dai() ASoC: simple-card-utils: adjust for graph on asoc_simple_card_parse_card_name ASoC: simple-card-utils: add asoc_simple_card_try_to_probe_graph_card() ASoC: simple-card-utils: adjust for graph on asoc_simple_card_parse_card_prefix ASoC: simple-card: call of_node_put() for dai_link ASoC: simple-card: tidyup mclk-fs of_property_read_u32() usage ASoC: simple-card: code sync: tidyup simple_priv_to_xxx() macro ASoC: simple-card: code sync: use simple_priv_to_props() macro ASoC: simple-card: is GPL v2 ASoC: simple-card: code sync: tidyup white line ASoC: simple-card: use kzalloc() for dai_props / dai_link ASoC: simple-dpcm-card: tidyup codec daifmt handling method ASoC: simple-dpcm-card: tidyup asoc_simple_card_parse_links() method ASoC: simple-dpcm-card: depends on CONFIG_OF ASoC: simple-dpcm-card: add 2 CPU 1 Codec example ASoC: simple-dpcm-card: code sync: follow to simple family style ASoC: simple-dpcm-card: is GPL v2 ASoC: simple-dpcm-card: code sync: move asoc_simple_card_of_match ASoC: simple-dpcm-card: remove unused definitions ASoC: simple-dpcm-card: code sync: rename asoc_simple_card_priv ASoC: simple-dpcm-card: code sync: tidyup props/link naming ASoC: add simple-graph-card document ASoC: add simple-graph-card support ASoC: add simple-graph-dpcm-card document ASoC: add simple-graph-dpcm-card support ASoC: rsnd: remove duplicate define of rsnd_dvc_of_node() ASoC: rsnd: amend .probe/.remove call for DPCM ASoC: rsnd: add rsnd_mod_next() for for_each_rsnd_mod_xxx() ASoC: rsnd: use for_each_rsnd_mod_xxx() on rsnd_dai_call() ASoC: rsnd: use for_each_rsnd_mod_xxx() on rsnd_rdai_continuance_probe() ASoC: rsnd: add rsnd_parse_of_node() and integrate rsnd_xxx_of_node ASoC: rsnd: add support graph base DT phase 1 ASoC: rsnd: add support graph base DT phase 2 ASoC: rsnd: depends on OF ASoC: rsnd: use simple-graph-card if possible ASoC: rsnd: add HDMI output support
Documentation/devicetree/bindings/graph.txt | 26 + .../devicetree/bindings/sound/renesas,rsnd.txt | 2 + .../bindings/sound/renesas,rsrc-card.txt | 75 --- .../devicetree/bindings/sound/simple-dpcm-card.txt | 109 +++++ .../bindings/sound/simple-graph-card.txt | 65 +++ .../bindings/sound/simple-graph-dpcm-card.txt | 53 +++ drivers/gpu/drm/bridge/Kconfig | 8 + drivers/gpu/drm/bridge/Makefile | 1 + drivers/gpu/drm/bridge/dw-hdmi-audio.h | 7 + drivers/gpu/drm/bridge/dw-hdmi-i2s-audio.c | 123 +++++ drivers/gpu/drm/bridge/dw-hdmi.c | 22 +- drivers/gpu/drm/bridge/dw-hdmi.h | 21 + drivers/of/base.c | 197 +++++++- include/linux/of_graph.h | 67 +++ include/sound/hdmi-codec.h | 13 +- include/sound/simple_card.h | 11 +- include/sound/simple_card_utils.h | 92 ++++ include/sound/soc.h | 31 +- sound/soc/codecs/hdmi-codec.c | 81 +++- sound/soc/generic/Kconfig | 25 + sound/soc/generic/Makefile | 12 +- sound/soc/generic/simple-card-utils.c | 387 +++++++++++++++ sound/soc/generic/simple-card.c | 501 +++++++------------- sound/soc/generic/simple-dpcm-card.c | 323 +++++++++++++ sound/soc/generic/simple-graph-card.c | 452 ++++++++++++++++++ sound/soc/generic/simple-graph-dpcm-card.c | 409 ++++++++++++++++ sound/soc/sh/Kconfig | 8 +- sound/soc/sh/rcar/Makefile | 3 - sound/soc/sh/rcar/core.c | 318 ++++++++----- sound/soc/sh/rcar/dma.c | 11 + sound/soc/sh/rcar/dvc.c | 2 - sound/soc/sh/rcar/gen.c | 2 + sound/soc/sh/rcar/rsnd.h | 62 ++- sound/soc/sh/rcar/rsrc-card.c | 527 --------------------- sound/soc/sh/rcar/ssi.c | 27 +- sound/soc/sh/rcar/ssiu.c | 37 ++ sound/soc/soc-core.c | 39 +- 37 files changed, 3003 insertions(+), 1146 deletions(-)
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Current ALSA SoC has simple-card driver which is supporting both platform and DT probe. Now, some sound cards driver are created based on simple-card. They have similar feature or function, but implemented separately on each drivers. This is a waste of code. OTOH, merging these driver into same driver is highly risk, because it will be very difficult to keep compatibility. More over, ALSA SoC want to have graph base of DT feature in the future. Maybe it want to use simple-card like feature / function. Because of these background, this patch creates simple-card helper utils, and provides common function to each drivers. 1st is asoc_simple_card_parse_daifmt()
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/simple_card_utils.h | 21 ++++++++++++++ sound/soc/generic/Kconfig | 3 ++ sound/soc/generic/Makefile | 2 ++ sound/soc/generic/simple-card-utils.c | 54 +++++++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+) create mode 100644 include/sound/simple_card_utils.h create mode 100644 sound/soc/generic/simple-card-utils.c
diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h new file mode 100644 index 0000000..7acc798 --- /dev/null +++ b/include/sound/simple_card_utils.h @@ -0,0 +1,21 @@ +/* + * simple_card_core.h + * + * Copyright (c) 2016 Kuninori Morimoto kuninori.morimoto.gx@renesas.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +#ifndef __SIMPLE_CARD_CORE_H +#define __SIMPLE_CARD_CORE_H + +#include <sound/soc.h> + +int asoc_simple_card_parse_daifmt(struct device *dev, + struct device_node *node, + struct device_node *codec, + char *prefix, + unsigned int *retfmt); + +#endif /* __SIMPLE_CARD_CORE_H */ diff --git a/sound/soc/generic/Kconfig b/sound/soc/generic/Kconfig index 610f612..26c2fe6 100644 --- a/sound/soc/generic/Kconfig +++ b/sound/soc/generic/Kconfig @@ -1,3 +1,6 @@ +config SND_SIMPLE_CARD_UTILS + tristate + config SND_SIMPLE_CARD tristate "ASoC Simple sound card support" help diff --git a/sound/soc/generic/Makefile b/sound/soc/generic/Makefile index 9c3b246..45602ca 100644 --- a/sound/soc/generic/Makefile +++ b/sound/soc/generic/Makefile @@ -1,3 +1,5 @@ +obj-$(CONFIG_SND_SIMPLE_CARD_UTILS) := simple-card-utils.o + snd-soc-simple-card-objs := simple-card.o
obj-$(CONFIG_SND_SIMPLE_CARD) += snd-soc-simple-card.o diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c new file mode 100644 index 0000000..3f6b725 --- /dev/null +++ b/sound/soc/generic/simple-card-utils.c @@ -0,0 +1,54 @@ +/* + * simple-card-core.c + * + * Copyright (c) 2016 Kuninori Morimoto kuninori.morimoto.gx@renesas.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +#include <linux/of.h> +#include <sound/simple_card_utils.h> + +int asoc_simple_card_parse_daifmt(struct device *dev, + struct device_node *node, + struct device_node *codec, + char *prefix, + unsigned int *retfmt) +{ + struct device_node *bitclkmaster = NULL; + struct device_node *framemaster = NULL; + int prefix_len = prefix ? strlen(prefix) : 0; + unsigned int daifmt; + + daifmt = snd_soc_of_parse_daifmt(node, prefix, + &bitclkmaster, &framemaster); + daifmt &= ~SND_SOC_DAIFMT_MASTER_MASK; + + if (prefix_len && !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; + } + + of_node_put(bitclkmaster); + of_node_put(framemaster); + + *retfmt = daifmt; + + return 0; +} +EXPORT_SYMBOL_GPL(asoc_simple_card_parse_daifmt);
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
simple-card is supporting TDM. This patch makes this method simple style standard.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/simple_card_utils.h | 12 ++++++++++++ sound/soc/generic/simple-card-utils.c | 11 +++++++++++ 2 files changed, 23 insertions(+)
diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index 7acc798..6bb2c5f 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -12,10 +12,22 @@
#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, char *prefix, unsigned int *retfmt); +int asoc_simple_card_parse_tdm(struct device_node *port_np, + struct asoc_simple_dai *simple_dai);
#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..86fb2cf 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -52,3 +52,14 @@ int asoc_simple_card_parse_daifmt(struct device *dev, return 0; } EXPORT_SYMBOL_GPL(asoc_simple_card_parse_daifmt); + +int asoc_simple_card_parse_tdm(struct device_node *port_np, + struct asoc_simple_dai *simple_dai) +{ + return snd_soc_of_parse_tdm_slot(port_np, + &simple_dai->tx_slot_mask, + &simple_dai->rx_slot_mask, + &simple_dai->slots, + &simple_dai->slot_width); +} +EXPORT_SYMBOL_GPL(asoc_simple_card_parse_tdm);
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 | 42 +++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+)
diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index 6bb2c5f..41e567b 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -29,5 +29,7 @@ int asoc_simple_card_parse_daifmt(struct device *dev, unsigned int *retfmt); int asoc_simple_card_parse_tdm(struct device_node *port_np, struct asoc_simple_dai *simple_dai); +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 86fb2cf..9b49b5a 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -63,3 +63,45 @@ int asoc_simple_card_parse_tdm(struct device_node *port_np, &simple_dai->slot_width); } EXPORT_SYMBOL_GPL(asoc_simple_card_parse_tdm); + +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_kzalloc(dev, + strlen(dai_link->cpu_dai_name) + 4, + GFP_KERNEL); + if (name) + sprintf(name, "fe.%s", dai_link->cpu_dai_name); + + } else if (dai_link->no_pcm && dai_link->codec_dai_name) { + name = devm_kzalloc(dev, + strlen(dai_link->codec_dai_name) + 4, + GFP_KERNEL); + if (name) + sprintf(name, "be.%s", dai_link->codec_dai_name); + } else if (dai_link->cpu_dai_name && dai_link->codec_dai_name) { + name = devm_kzalloc(dev, + strlen(dai_link->cpu_dai_name) + + strlen(dai_link->codec_dai_name) + 2, + GFP_KERNEL); + if (name) { + sprintf(name, "%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);
On 06/24/2016 03:16 AM, Kuninori Morimoto wrote:
+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_kzalloc(dev,
strlen(dai_link->cpu_dai_name) + 4,
GFP_KERNEL);
if (name)
sprintf(name, "fe.%s", dai_link->cpu_dai_name);
- } else if (dai_link->no_pcm && dai_link->codec_dai_name) {
name = devm_kzalloc(dev,
strlen(dai_link->codec_dai_name) + 4,
GFP_KERNEL);
if (name)
sprintf(name, "be.%s", dai_link->codec_dai_name);
- } else if (dai_link->cpu_dai_name && dai_link->codec_dai_name) {
name = devm_kzalloc(dev,
strlen(dai_link->cpu_dai_name) +
strlen(dai_link->codec_dai_name) + 2,
GFP_KERNEL);
if (name) {
sprintf(name, "%s-%s",
dai_link->cpu_dai_name,
dai_link->codec_dai_name);
}
- }
This could be simplified by using devm_kasprintf().
Hi Sylwester
+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_kzalloc(dev,
strlen(dai_link->cpu_dai_name) + 4,
GFP_KERNEL);
if (name)
sprintf(name, "fe.%s", dai_link->cpu_dai_name);
- } else if (dai_link->no_pcm && dai_link->codec_dai_name) {
name = devm_kzalloc(dev,
strlen(dai_link->codec_dai_name) + 4,
GFP_KERNEL);
if (name)
sprintf(name, "be.%s", dai_link->codec_dai_name);
- } else if (dai_link->cpu_dai_name && dai_link->codec_dai_name) {
name = devm_kzalloc(dev,
strlen(dai_link->cpu_dai_name) +
strlen(dai_link->codec_dai_name) + 2,
GFP_KERNEL);
if (name) {
sprintf(name, "%s-%s",
dai_link->cpu_dai_name,
dai_link->codec_dai_name);
}
- }
This could be simplified by using devm_kasprintf().
Thanks. I didn't know this function. I will replace above, but it will be incremental patch (?) (Based on Mark's patch control)
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
simple-card needs to get its card name. This patch makes this method simple style standard.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/simple_card_utils.h | 2 ++ sound/soc/generic/simple-card-utils.c | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+)
diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index 41e567b..2f991da 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -31,5 +31,7 @@ int asoc_simple_card_parse_tdm(struct device_node *port_np, struct asoc_simple_dai *simple_dai); int asoc_simple_card_parse_dailink_name(struct device *dev, struct snd_soc_dai_link *dai_link); +int asoc_simple_card_parse_card_name(struct snd_soc_card *card, + char *prefix);
#endif /* __SIMPLE_CARD_CORE_H */ diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index 9b49b5a..c782b3a 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -105,3 +105,23 @@ int asoc_simple_card_parse_dailink_name(struct device *dev, return ret; } EXPORT_SYMBOL_GPL(asoc_simple_card_parse_dailink_name); + +int asoc_simple_card_parse_card_name(struct snd_soc_card *card, + char *prefix) +{ + char prop[128]; + int ret; + + snprintf(prop, sizeof(prop), "%sname", prefix); + + /* Parse the card name from DT */ + ret = snd_soc_of_parse_card_name(card, prop); + if (ret < 0) + return ret; + + if (!card->name) + card->name = card->dai_link->name; + + return 0; +} +EXPORT_SYMBOL_GPL(asoc_simple_card_parse_card_name);
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
DPCM might need audio prefix for route matching. This patch makes this method simple style standard.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/simple_card_utils.h | 4 ++++ sound/soc/generic/simple-card-utils.c | 17 +++++++++++++++++ 2 files changed, 21 insertions(+)
diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index 2f991da..89172aa 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -33,5 +33,9 @@ int asoc_simple_card_parse_dailink_name(struct device *dev, struct snd_soc_dai_link *dai_link); int asoc_simple_card_parse_card_name(struct snd_soc_card *card, char *prefix); +int asoc_simple_card_parse_card_prefix(struct snd_soc_card *card, + struct snd_soc_dai_link *dai_link, + struct snd_soc_codec_conf *codec_conf, + char *prefix);
#endif /* __SIMPLE_CARD_CORE_H */ diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index c782b3a..439fc01 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -125,3 +125,20 @@ int asoc_simple_card_parse_card_name(struct snd_soc_card *card, return 0; } EXPORT_SYMBOL_GPL(asoc_simple_card_parse_card_name); + +int asoc_simple_card_parse_card_prefix(struct snd_soc_card *card, + struct snd_soc_dai_link *dai_link, + struct snd_soc_codec_conf *codec_conf, + char *prefix) +{ + char prop[128]; + + snprintf(prop, sizeof(prop), "%sprefix", prefix); + + snd_soc_of_parse_audio_prefix(card, codec_conf, + dai_link->codec_of_node, + prop); + + return 0; +} +EXPORT_SYMBOL_GPL(asoc_simple_card_parse_card_prefix);
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Current simple-card can get clock via DT clocks or "system-clock-frequency" property. This patch makes it simple style standard
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/simple_card_utils.h | 8 ++++++++ sound/soc/generic/simple-card-utils.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+)
diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index 89172aa..b8a8649 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -38,4 +38,12 @@ int asoc_simple_card_parse_card_prefix(struct snd_soc_card *card, struct snd_soc_codec_conf *codec_conf, char *prefix);
+#define asoc_simple_card_parse_clk_cpu(port_np, dai_link, simple_dai)\ + asoc_simple_card_parse_clk(port_np, dai_link->cpu_of_node, simple_dai) +#define asoc_simple_card_parse_clk_codec(port_np, dai_link, simple_dai) \ + asoc_simple_card_parse_clk(port_np, dai_link->codec_of_node, simple_dai) +int asoc_simple_card_parse_clk(struct device_node *port_np, + struct device_node *endpoint_np, + struct asoc_simple_dai *simple_dai); + #endif /* __SIMPLE_CARD_CORE_H */ diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index 439fc01..dbf4b00 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -7,6 +7,7 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ +#include <linux/clk.h> #include <linux/of.h> #include <sound/simple_card_utils.h>
@@ -142,3 +143,32 @@ int asoc_simple_card_parse_card_prefix(struct snd_soc_card *card, return 0; } EXPORT_SYMBOL_GPL(asoc_simple_card_parse_card_prefix); + +int asoc_simple_card_parse_clk(struct device_node *port_np, + struct device_node *endpoint_np, + struct asoc_simple_dai *simple_dai) +{ + struct clk *clk; + u32 val; + + /* + * Parse dai->sysclk come from "clocks = <&xxx>" + * (if system has common clock) + * or "system-clock-frequency = <xxx>" + * or device's module clock. + */ + clk = of_clk_get(port_np, 0); + if (!IS_ERR(clk)) { + simple_dai->sysclk = clk_get_rate(clk); + simple_dai->clk = clk; + } else if (!of_property_read_u32(port_np, "system-clock-frequency", &val)) { + simple_dai->sysclk = val; + } else { + clk = of_clk_get(endpoint_np, 0); + if (!IS_ERR(clk)) + simple_dai->sysclk = clk_get_rate(clk); + } + + return 0; +} +EXPORT_SYMBOL_GPL(asoc_simple_card_parse_clk);
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
simple-card needs to get its dai name and endpoint node. This patch makes it simple style standard
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/simple_card_utils.h | 19 ++++++++++++++++++ sound/soc/generic/simple-card-utils.c | 38 +++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+)
diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index b8a8649..1a77d72 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -46,4 +46,23 @@ int asoc_simple_card_parse_clk(struct device_node *port_np, struct device_node *endpoint_np, struct asoc_simple_dai *simple_dai);
+#define asoc_simple_card_parse_cpu(port_np, dai_link, \ + list_name, cells_name, is_single_link) \ + asoc_simple_card_parse_endpoint(port_np, &dai_link->cpu_of_node, \ + &dai_link->cpu_dai_name, list_name, cells_name, is_single_link) +#define asoc_simple_card_parse_codec(port_np, dai_link, \ + list_name, cells_name) \ + asoc_simple_card_parse_endpoint(port_np, &dai_link->codec_of_node, \ + &dai_link->codec_dai_name, list_name, cells_name, NULL) +#define asoc_simple_card_parse_platform(port_np, dai_link, \ + list_name, cells_name) \ + asoc_simple_card_parse_endpoint(port_np, &dai_link->platform_of_node, \ + NULL, list_name, cells_name, NULL) +int asoc_simple_card_parse_endpoint(struct device_node *port_np, + struct device_node **endpoint_np, + const char **dai_name, + const char *list_name, + const char *cells_name, + int *is_single_links); + #endif /* __SIMPLE_CARD_CORE_H */ diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index dbf4b00..a3d917d 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -172,3 +172,41 @@ int asoc_simple_card_parse_clk(struct device_node *port_np, return 0; } EXPORT_SYMBOL_GPL(asoc_simple_card_parse_clk); + +int asoc_simple_card_parse_endpoint(struct device_node *port_np, + struct device_node **endpoint_np, + const char **dai_name, + const char *list_name, + const char *cells_name, + int *is_single_link) +{ + struct of_phandle_args args; + int ret; + + if (!port_np) + return 0; + + /* + * Get node via "sound-dai = <&phandle port>" + * it will be used as xxx_of_node on soc_bind_dai_link() + */ + ret = of_parse_phandle_with_args(port_np, + list_name, cells_name, 0, &args); + if (ret) + return ret; + + /* Get dai->name */ + if (dai_name) { + ret = snd_soc_of_get_dai_name(port_np, dai_name); + if (ret < 0) + return ret; + } + + *endpoint_np = args.np; + + if (is_single_link) + *is_single_link = !args.args_count; + + return 0; +} +EXPORT_SYMBOL_GPL(asoc_simple_card_parse_endpoint);
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
simple-card is supporting clock/tdm slot initialization. This patch makes this method simple style standard.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/simple_card_utils.h | 2 ++ sound/soc/generic/simple-card-utils.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+)
diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index 1a77d72..289e61d 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -65,4 +65,6 @@ int asoc_simple_card_parse_endpoint(struct device_node *port_np, const char *cells_name, int *is_single_links);
+int asoc_simple_card_init_dai(struct snd_soc_dai *dai, + struct asoc_simple_dai *simple_dai); #endif /* __SIMPLE_CARD_CORE_H */ diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index a3d917d..4f434c4 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -210,3 +210,32 @@ int asoc_simple_card_parse_endpoint(struct device_node *port_np, return 0; } EXPORT_SYMBOL_GPL(asoc_simple_card_parse_endpoint); + +int asoc_simple_card_init_dai(struct snd_soc_dai *dai, + struct asoc_simple_dai *simple_dai) +{ + int ret; + + if (simple_dai->sysclk) { + ret = snd_soc_dai_set_sysclk(dai, 0, simple_dai->sysclk, 0); + if (ret && ret != -ENOTSUPP) { + dev_err(dai->dev, "simple-card: set_sysclk error\n"); + return ret; + } + } + + if (simple_dai->slots) { + ret = snd_soc_dai_set_tdm_slot(dai, + simple_dai->tx_slot_mask, + simple_dai->rx_slot_mask, + simple_dai->slots, + simple_dai->slot_width); + if (ret && ret != -ENOTSUPP) { + dev_err(dai->dev, "simple-card: set_tdm_slot error\n"); + return ret; + } + } + + return 0; +} +EXPORT_SYMBOL_GPL(asoc_simple_card_init_dai);
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
simple-card is assuming that sometimes platform and cpu are same. This patch makes this method simple style standard.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/simple_card_utils.h | 3 +++ sound/soc/generic/simple-card-utils.c | 13 +++++++++++++ 2 files changed, 16 insertions(+)
diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index 289e61d..d5d88bb 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -67,4 +67,7 @@ int asoc_simple_card_parse_endpoint(struct device_node *port_np,
int asoc_simple_card_init_dai(struct snd_soc_dai *dai, struct asoc_simple_dai *simple_dai); + +int asoc_simple_card_canonicalize_dailink(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 4f434c4..2524f21 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -239,3 +239,16 @@ int asoc_simple_card_init_dai(struct snd_soc_dai *dai, return 0; } EXPORT_SYMBOL_GPL(asoc_simple_card_init_dai); + +int asoc_simple_card_canonicalize_dailink(struct snd_soc_dai_link *dai_link) +{ + if (!dai_link->cpu_dai_name || !dai_link->codec_dai_name) + return -EINVAL; + + /* Assumes platform == cpu */ + if (!dai_link->platform_of_node) + dai_link->platform_of_node = dai_link->cpu_of_node; + + return 0; +} +EXPORT_SYMBOL_GPL(asoc_simple_card_canonicalize_dailink);
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
simple-card needs remove dai_link->cpu_dai_name if it CPU was single DAI. This patch makes this method simple style standard.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/simple_card_utils.h | 2 ++ sound/soc/generic/simple-card-utils.c | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+)
diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index d5d88bb..7846467 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -69,5 +69,7 @@ int asoc_simple_card_init_dai(struct snd_soc_dai *dai, struct asoc_simple_dai *simple_dai);
int asoc_simple_card_canonicalize_dailink(struct snd_soc_dai_link *dai_link); +int asoc_simple_card_canonicalize_cpu(struct snd_soc_dai_link *dai_link, + int is_single_links);
#endif /* __SIMPLE_CARD_CORE_H */ diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index 2524f21..b8977ca 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -252,3 +252,22 @@ int asoc_simple_card_canonicalize_dailink(struct snd_soc_dai_link *dai_link) return 0; } EXPORT_SYMBOL_GPL(asoc_simple_card_canonicalize_dailink); + +int asoc_simple_card_canonicalize_cpu(struct snd_soc_dai_link *dai_link, + int is_single_links) +{ + /* + * In soc_bind_dai_link() will check cpu name after + * of_node matching if dai_link has cpu_dai_name. + * but, it will never match if name was created by + * fmt_single_name() remove cpu_dai_name if cpu_args + * was 0. See: + * fmt_single_name() + * fmt_multiple_name() + */ + if (is_single_links) + dai_link->cpu_dai_name = NULL; + + return 0; +} +EXPORT_SYMBOL_GPL(asoc_simple_card_canonicalize_cpu);
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
simple-card needs to decrease the reference count of the device nodes. This patch makes this method simple style standard.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/simple_card_utils.h | 2 ++ sound/soc/generic/simple-card-utils.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+)
diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index 7846467..7dbb349 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -72,4 +72,6 @@ int asoc_simple_card_canonicalize_dailink(struct snd_soc_dai_link *dai_link); int asoc_simple_card_canonicalize_cpu(struct snd_soc_dai_link *dai_link, int is_single_links);
+int asoc_simple_card_clean_reference(struct snd_soc_card *card); + #endif /* __SIMPLE_CARD_CORE_H */ diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index b8977ca..8bd4c83 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -271,3 +271,18 @@ int asoc_simple_card_canonicalize_cpu(struct snd_soc_dai_link *dai_link, return 0; } EXPORT_SYMBOL_GPL(asoc_simple_card_canonicalize_cpu); + +int asoc_simple_card_clean_reference(struct snd_soc_card *card) +{ + struct snd_soc_dai_link *dai_link; + int num_links; + + for (num_links = 0, dai_link = card->dai_link; + num_links < card->num_links; + num_links++, dai_link++) { + of_node_put(dai_link->cpu_of_node); + of_node_put(dai_link->codec_of_node); + } + return 0; +} +EXPORT_SYMBOL_GPL(asoc_simple_card_clean_reference);
On Fri, Jun 24, 2016 at 01:13:55AM +0000, Kuninori Morimoto wrote:
These are resend of v2 of simple-card cleanup patches.
You last sent these (and more serieses) on Monday - this is *way* too soon to be resending them, especially such a large series.
Because of this stagnation, I already have almost 90 patches for simple-card + graph driver in locally... I would like to post them as soon as possible.
OTOH, I know you don't like super big patchset, Thus, I will post small batch patch set only today. I will post next small batch patch set if 1st batch was accepted.
They're already in my queue to review, resending another jumbo series is just going to slow things down even further. I'm getting through things as fast as I can but I've been busy for the past little while and I do tend to prioritise patch sets that are easier to review and where there's broad and visible interest. These are the same things I was telling the Intel people when they were sending lots of driver serieses.
Hi Mark
These are resend of v2 of simple-card cleanup patches.
You last sent these (and more serieses) on Monday - this is *way* too soon to be resending them, especially such a large series.
Oops ?? I sent it 1month ago ??
Because of this stagnation, I already have almost 90 patches for simple-card + graph driver in locally... I would like to post them as soon as possible.
OTOH, I know you don't like super big patchset, Thus, I will post small batch patch set only today. I will post next small batch patch set if 1st batch was accepted.
They're already in my queue to review, resending another jumbo series is just going to slow things down even further. I'm getting through things as fast as I can but I've been busy for the past little while and I do tend to prioritise patch sets that are easier to review and where there's broad and visible interest. These are the same things I was telling the Intel people when they were sending lots of driver serieses.
OK, thanks. I didn't know that you already queued this serieses to review. Then, please drop this serieses, because it is same as before.
I thought this serieses was ignored or forgotten etc because there was no response form you during this 1month. Thus I tried "resend" patch-set.
On Sun, Jun 26, 2016 at 11:53:56PM +0000, Kuninori Morimoto wrote:
These are resend of v2 of simple-card cleanup patches.
You last sent these (and more serieses) on Monday - this is *way* too soon to be resending them, especially such a large series.
Oops ?? I sent it 1month ago ??
I got another copy a week ago.
I thought this serieses was ignored or forgotten etc because there was no response form you during this 1month. Thus I tried "resend" patch-set.
That's fine, but please do bear in mind that it's a 39 patch series which makes it a lot to get through and therefore slows things down.
participants (3)
-
Kuninori Morimoto
-
Mark Brown
-
Sylwester Nawrocki