[alsa-devel] [PATCH 00/39 v2] ASoC: add simple-card-core and standardize "simple" card
Hi Mark
These are v2 of simple-card cleanup patches.
Main purpose of these patches are - cleanup simple-card - rename rsrc-card to simple-dpcm-card
Main diff v1 <-> v2 are - remove duplicate header patch - rename simple-card-core.c -> simple-card-utils.c - remove dpcm function from simple-card-utils. - remove jack/pin/gpio/ function from simple-card-utils. - remove widgets/route function from simple-card-utils.
I removed widgets/routing related function. it was very thin cosmetic functions. About jack/pin/gpio on simple-card, it is still have same method, but keeping it as static function. dpcm related function too, it is keeping static.
1) - 3) cleaup patch as prepare 4) - 14) simple-card-utils 15) - 24) simple-card 25) - 36) rsrc-card 37) - 39) rsrc-card -> simple-dpcm-card
Kuninori Morimoto (39): 1) ASoC: rsrc-card: remove unused dai_num 2) ASoC: simple-card: use common PREFIX for each DT property 3) ASoC: simple-card: add new asoc_simple_jack and use it 4) ASoC: add new simple-card-utils.c 5) ASoC: simple-card-utils: add asoc_simple_card_parse_tdm() 6) ASoC: simple-card-utils: add asoc_simple_card_parse_dailink_name() 7) ASoC: simple-card-utils: add asoc_simple_card_parse_card_name() 8) ASoC: simple-card-utils: add asoc_simple_card_parse_card_prefix() 9) ASoC: simple-card-utils: add asoc_simple_card_parse_clk() 10) ASoC: simple-card-utils: add asoc_simple_card_parse_endpoint() 11) ASoC: simple-card-utils: add asoc_simple_card_init_dai() 12) ASoC: simple-card-utils: add asoc_simple_card_canonicalize_dailink() 13) ASoC: simple-card-utils: add asoc_simple_card_canonicalize_cpu() 14) ASoC: simple-card-utils: add asoc_simple_card_clean_reference() 15) ASoC: simple-card: use asoc_simple_card_parse_daifmt() 16) ASoC: simple-card: use asoc_simple_card_parse_clk() 17) ASoC: simple-card: use asoc_simple_card_parse_endpoint() 18) ASoC: simple-card: use asoc_simple_card_parse_tdm() 19) ASoC: simple-card: use asoc_simple_card_parse_card_name() 20) ASoC: simple-card: use asoc_simple_card_parse_dailink_name() 21) ASoC: simple-card: use asoc_simple_card_init_dai() 22) ASoC: simple-card: use asoc_simple_card_canonicalize_dailink() 23) ASoC: simple-card: use asoc_simple_card_canonicalize_cpu() 24) ASoC: simple-card: use asoc_simple_card_clean_reference() 25) ASoC: rsrc-card: use asoc_simple_card_parse_daifmt() 26) ASoC: rsrc-card: use asoc_simple_card_parse_dailink_name() 27) ASoC: rsrc-card: use asoc_simple_dai instead of rsrc_card_dai 28) ASoC: rsrc-card: use asoc_simple_card_parse_clk() 29) ASoC: rsrc-card: use asoc_simple_card_parse_endpoint() 30) ASoC: rsrc-card: use asoc_simple_card_parse_card_name() 31) ASoC: rsrc-card: use asoc_simple_card_parse_card_prefix() 32) ASoC: rsrc-card: use asoc_simple_card_parse_tdm() 33) ASoC: rsrc-card: use asoc_simple_card_init_dai() 34) ASoC: rsrc-card: use asoc_simple_card_canonicalize_cpu() 35) ASoC: rsrc-card: use asoc_simple_card_canonicalize_dailink() 36) ASoC: rsrc-card: use asoc_simple_card_clean_reference() 37) ASoC: rsrc-card: rename rsrc-card to simple-dpcm-card phase1 38) ASoC: rsrc-card: rename rsrc-card to simple-dpcm-card phase2 39) ASoC: rsrc-card: rename rsrc-card to simple-dpcm-card phase3
Documentation/devicetree/bindings/sound/renesas,rsrc-card.txt | 75 -------------- Documentation/devicetree/bindings/sound/simple-dpcm-card.txt | 79 +++++++++++++++ include/sound/simple_card.h | 11 +-- include/sound/simple_card_utils.h | 77 +++++++++++++++ sound/soc/generic/Kconfig | 10 ++ sound/soc/generic/Makefile | 4 + sound/soc/generic/simple-card-utils.c | 288 +++++++++++++++++++++++++++++++++++++++++++++++++++++ sound/soc/generic/simple-card.c | 424 ++++++++++++++++++++++++------------------------------------------------------ sound/soc/generic/simple-dpcm-card.c | 351 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ sound/soc/sh/Kconfig | 5 - sound/soc/sh/rcar/Makefile | 3 - sound/soc/sh/rcar/rsrc-card.c | 529 -------------------------------------------------------------------------------------------------- 12 files changed, 937 insertions(+), 919 deletions(-)
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/sh/rcar/rsrc-card.c | 2 -- 1 file changed, 2 deletions(-)
diff --git a/sound/soc/sh/rcar/rsrc-card.c b/sound/soc/sh/rcar/rsrc-card.c index 1bc7ecf..b85b5ee 100644 --- a/sound/soc/sh/rcar/rsrc-card.c +++ b/sound/soc/sh/rcar/rsrc-card.c @@ -64,7 +64,6 @@ struct rsrc_card_priv { struct snd_soc_codec_conf codec_conf; struct rsrc_card_dai *dai_props; struct snd_soc_dai_link *dai_link; - int dai_num; u32 convert_rate; u32 convert_channels; }; @@ -418,7 +417,6 @@ static int rsrc_card_parse_of(struct device_node *node,
priv->dai_props = props; priv->dai_link = links; - priv->dai_num = num;
/* Init snd_soc_card */ priv->snd_card.owner = THIS_MODULE;
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/generic/simple-card.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 4e39c0f..b6e6d9a 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -40,6 +40,8 @@ struct simple_card_data { #define simple_priv_to_link(priv, i) ((priv)->snd_card.dai_link + i) #define simple_priv_to_props(priv, i) ((priv)->dai_props + i)
+#define PREFIX "simple-audio-card," + static int asoc_simple_card_startup(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; @@ -344,7 +346,7 @@ static int asoc_simple_card_dai_link_of(struct device_node *node,
/* For single DAI link & old style of DT node */ if (is_top_level_node) - prefix = "simple-audio-card,"; + prefix = PREFIX;
snprintf(prop, sizeof(prop), "%scpu", prefix); cpu = of_get_child_by_name(node, prop); @@ -453,26 +455,26 @@ static int asoc_simple_card_parse_of(struct device_node *node, return -EINVAL;
/* Parse the card name from DT */ - snd_soc_of_parse_card_name(&priv->snd_card, "simple-audio-card,name"); + snd_soc_of_parse_card_name(&priv->snd_card, PREFIX "name");
/* The off-codec widgets */ - if (of_property_read_bool(node, "simple-audio-card,widgets")) { + if (of_property_read_bool(node, PREFIX "widgets")) { ret = snd_soc_of_parse_audio_simple_widgets(&priv->snd_card, - "simple-audio-card,widgets"); + PREFIX "widgets"); if (ret) return ret; }
/* DAPM routes */ - if (of_property_read_bool(node, "simple-audio-card,routing")) { + if (of_property_read_bool(node, PREFIX "routing")) { ret = snd_soc_of_parse_audio_routing(&priv->snd_card, - "simple-audio-card,routing"); + PREFIX "routing"); if (ret) return ret; }
/* Factor to mclk, used in hw_params() */ - ret = of_property_read_u32(node, "simple-audio-card,mclk-fs", &val); + ret = of_property_read_u32(node, PREFIX "mclk-fs", &val); if (ret == 0) priv->mclk_fs = val;
@@ -480,7 +482,7 @@ static int asoc_simple_card_parse_of(struct device_node *node, priv->snd_card.name : "");
/* Single/Muti DAI link(s) & New style of DT node */ - if (of_get_child_by_name(node, "simple-audio-card,dai-link")) { + if (of_get_child_by_name(node, PREFIX "dai-link")) { struct device_node *np = NULL; int i = 0;
@@ -502,13 +504,13 @@ static int asoc_simple_card_parse_of(struct device_node *node, }
priv->gpio_hp_det = of_get_named_gpio_flags(node, - "simple-audio-card,hp-det-gpio", 0, &flags); + PREFIX "hp-det-gpio", 0, &flags); priv->gpio_hp_det_invert = !!(flags & OF_GPIO_ACTIVE_LOW); if (priv->gpio_hp_det == -EPROBE_DEFER) return -EPROBE_DEFER;
priv->gpio_mic_det = of_get_named_gpio_flags(node, - "simple-audio-card,mic-det-gpio", 0, &flags); + PREFIX "mic-det-gpio", 0, &flags); priv->gpio_mic_det_invert = !!(flags & OF_GPIO_ACTIVE_LOW); if (priv->gpio_mic_det == -EPROBE_DEFER) return -EPROBE_DEFER; @@ -543,7 +545,7 @@ static int asoc_simple_card_probe(struct platform_device *pdev) int num_links, ret;
/* Get the number of DAI links */ - if (np && of_get_child_by_name(np, "simple-audio-card,dai-link")) + if (np && of_get_child_by_name(np, PREFIX "dai-link")) num_links = of_get_child_count(np); else num_links = 1;
The patch
ASoC: simple-card: use common PREFIX for each DT property
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 548563fa3e430ce61db79aa11331da6e5f535a3b Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Date: Tue, 31 May 2016 08:59:01 +0000 Subject: [PATCH] ASoC: simple-card: use common PREFIX for each DT property
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/generic/simple-card.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 4e39c0fa78c9..b6e6d9a12ec2 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -40,6 +40,8 @@ struct simple_card_data { #define simple_priv_to_link(priv, i) ((priv)->snd_card.dai_link + i) #define simple_priv_to_props(priv, i) ((priv)->dai_props + i)
+#define PREFIX "simple-audio-card," + static int asoc_simple_card_startup(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; @@ -344,7 +346,7 @@ static int asoc_simple_card_dai_link_of(struct device_node *node,
/* For single DAI link & old style of DT node */ if (is_top_level_node) - prefix = "simple-audio-card,"; + prefix = PREFIX;
snprintf(prop, sizeof(prop), "%scpu", prefix); cpu = of_get_child_by_name(node, prop); @@ -453,26 +455,26 @@ static int asoc_simple_card_parse_of(struct device_node *node, return -EINVAL;
/* Parse the card name from DT */ - snd_soc_of_parse_card_name(&priv->snd_card, "simple-audio-card,name"); + snd_soc_of_parse_card_name(&priv->snd_card, PREFIX "name");
/* The off-codec widgets */ - if (of_property_read_bool(node, "simple-audio-card,widgets")) { + if (of_property_read_bool(node, PREFIX "widgets")) { ret = snd_soc_of_parse_audio_simple_widgets(&priv->snd_card, - "simple-audio-card,widgets"); + PREFIX "widgets"); if (ret) return ret; }
/* DAPM routes */ - if (of_property_read_bool(node, "simple-audio-card,routing")) { + if (of_property_read_bool(node, PREFIX "routing")) { ret = snd_soc_of_parse_audio_routing(&priv->snd_card, - "simple-audio-card,routing"); + PREFIX "routing"); if (ret) return ret; }
/* Factor to mclk, used in hw_params() */ - ret = of_property_read_u32(node, "simple-audio-card,mclk-fs", &val); + ret = of_property_read_u32(node, PREFIX "mclk-fs", &val); if (ret == 0) priv->mclk_fs = val;
@@ -480,7 +482,7 @@ static int asoc_simple_card_parse_of(struct device_node *node, priv->snd_card.name : "");
/* Single/Muti DAI link(s) & New style of DT node */ - if (of_get_child_by_name(node, "simple-audio-card,dai-link")) { + if (of_get_child_by_name(node, PREFIX "dai-link")) { struct device_node *np = NULL; int i = 0;
@@ -502,13 +504,13 @@ static int asoc_simple_card_parse_of(struct device_node *node, }
priv->gpio_hp_det = of_get_named_gpio_flags(node, - "simple-audio-card,hp-det-gpio", 0, &flags); + PREFIX "hp-det-gpio", 0, &flags); priv->gpio_hp_det_invert = !!(flags & OF_GPIO_ACTIVE_LOW); if (priv->gpio_hp_det == -EPROBE_DEFER) return -EPROBE_DEFER;
priv->gpio_mic_det = of_get_named_gpio_flags(node, - "simple-audio-card,mic-det-gpio", 0, &flags); + PREFIX "mic-det-gpio", 0, &flags); priv->gpio_mic_det_invert = !!(flags & OF_GPIO_ACTIVE_LOW); if (priv->gpio_mic_det == -EPROBE_DEFER) return -EPROBE_DEFER; @@ -543,7 +545,7 @@ static int asoc_simple_card_probe(struct platform_device *pdev) int num_links, ret;
/* Get the number of DAI links */ - if (np && of_get_child_by_name(np, "simple-audio-card,dai-link")) + if (np && of_get_child_by_name(np, PREFIX "dai-link")) num_links = of_get_child_count(np); else num_links = 1;
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Current simple-card supports snd_soc_jack/pin/gpio. These code are very similar, but driver has verbosity code. So, this patch adds new snd_soc_jack and cleanups code
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/generic/simple-card.c | 153 ++++++++++++++++++++-------------------- 1 file changed, 78 insertions(+), 75 deletions(-)
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index b6e6d9a..8d0311c 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -21,6 +21,12 @@ #include <sound/soc-dai.h> #include <sound/soc.h>
+struct asoc_simple_jack { + struct snd_soc_jack jack; + struct snd_soc_jack_pin pin; + struct snd_soc_jack_gpio gpio; +}; + struct simple_card_data { struct snd_soc_card snd_card; struct simple_dai_props { @@ -29,10 +35,8 @@ struct simple_card_data { unsigned int mclk_fs; } *dai_props; unsigned int mclk_fs; - int gpio_hp_det; - int gpio_hp_det_invert; - int gpio_mic_det; - int gpio_mic_det_invert; + struct asoc_simple_jack hp_jack; + struct asoc_simple_jack mic_jack; struct snd_soc_dai_link dai_link[]; /* dynamically allocated */ };
@@ -42,6 +46,67 @@ struct simple_card_data {
#define PREFIX "simple-audio-card,"
+#define asoc_simple_card_init_hp(card, sjack, prefix)\ + asoc_simple_card_init_jack(card, sjack, 1, prefix) +#define asoc_simple_card_init_mic(card, sjack, prefix)\ + asoc_simple_card_init_jack(card, sjack, 0, prefix) +static int asoc_simple_card_init_jack(struct snd_soc_card *card, + struct asoc_simple_jack *sjack, + int is_hp, char *prefix) +{ + struct device *dev = card->dev; + enum of_gpio_flags flags; + char prop[128]; + char *pin_name; + char *gpio_name; + int mask; + int det; + + sjack->gpio.gpio = -ENOENT; + + if (is_hp) { + snprintf(prop, sizeof(prop), "%shp-det-gpio", prefix); + pin_name = "Headphones"; + gpio_name = "Headphone detection"; + mask = SND_JACK_HEADPHONE; + } else { + snprintf(prop, sizeof(prop), "%smic-det-gpio", prefix); + pin_name = "Mic Jack"; + gpio_name = "Mic detection"; + mask = SND_JACK_MICROPHONE; + } + + det = of_get_named_gpio_flags(dev->of_node, prop, 0, &flags); + if (det == -EPROBE_DEFER) + return -EPROBE_DEFER; + + if (gpio_is_valid(det)) { + sjack->pin.pin = pin_name; + sjack->pin.mask = mask; + + sjack->gpio.name = gpio_name; + sjack->gpio.report = mask; + sjack->gpio.gpio = det; + sjack->gpio.invert = !!(flags & OF_GPIO_ACTIVE_LOW); + sjack->gpio.debounce_time = 150; + + snd_soc_card_jack_new(card, pin_name, mask, + &sjack->jack, + &sjack->pin, 1); + + snd_soc_jack_add_gpios(&sjack->jack, 1, + &sjack->gpio); + } + + return 0; +} + +static void asoc_simple_card_remove_jack(struct asoc_simple_jack *sjack) +{ + if (gpio_is_valid(sjack->gpio.gpio)) + snd_soc_jack_free_gpios(&sjack->jack, 1, &sjack->gpio); +} + static int asoc_simple_card_startup(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; @@ -112,32 +177,6 @@ static struct snd_soc_ops asoc_simple_card_ops = { .hw_params = asoc_simple_card_hw_params, };
-static struct snd_soc_jack simple_card_hp_jack; -static struct snd_soc_jack_pin simple_card_hp_jack_pins[] = { - { - .pin = "Headphones", - .mask = SND_JACK_HEADPHONE, - }, -}; -static struct snd_soc_jack_gpio simple_card_hp_jack_gpio = { - .name = "Headphone detection", - .report = SND_JACK_HEADPHONE, - .debounce_time = 150, -}; - -static struct snd_soc_jack simple_card_mic_jack; -static struct snd_soc_jack_pin simple_card_mic_jack_pins[] = { - { - .pin = "Mic Jack", - .mask = SND_JACK_MICROPHONE, - }, -}; -static struct snd_soc_jack_gpio simple_card_mic_jack_gpio = { - .name = "Mic detection", - .report = SND_JACK_MICROPHONE, - .debounce_time = 150, -}; - static int __asoc_simple_card_dai_init(struct snd_soc_dai *dai, struct asoc_simple_dai *set) { @@ -186,30 +225,14 @@ static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd) if (ret < 0) return ret;
- if (gpio_is_valid(priv->gpio_hp_det)) { - snd_soc_card_jack_new(rtd->card, "Headphones", - SND_JACK_HEADPHONE, - &simple_card_hp_jack, - simple_card_hp_jack_pins, - ARRAY_SIZE(simple_card_hp_jack_pins)); - - simple_card_hp_jack_gpio.gpio = priv->gpio_hp_det; - simple_card_hp_jack_gpio.invert = priv->gpio_hp_det_invert; - snd_soc_jack_add_gpios(&simple_card_hp_jack, 1, - &simple_card_hp_jack_gpio); - } + ret = asoc_simple_card_init_hp(rtd->card, &priv->hp_jack, PREFIX); + if (ret < 0) + return ret; + + ret = asoc_simple_card_init_mic(rtd->card, &priv->hp_jack, PREFIX); + if (ret < 0) + return ret;
- if (gpio_is_valid(priv->gpio_mic_det)) { - snd_soc_card_jack_new(rtd->card, "Mic Jack", - SND_JACK_MICROPHONE, - &simple_card_mic_jack, - simple_card_mic_jack_pins, - ARRAY_SIZE(simple_card_mic_jack_pins)); - simple_card_mic_jack_gpio.gpio = priv->gpio_mic_det; - simple_card_mic_jack_gpio.invert = priv->gpio_mic_det_invert; - snd_soc_jack_add_gpios(&simple_card_mic_jack, 1, - &simple_card_mic_jack_gpio); - } return 0; }
@@ -447,7 +470,6 @@ static int asoc_simple_card_parse_of(struct device_node *node, struct simple_card_data *priv) { struct device *dev = simple_priv_to_dev(priv); - enum of_gpio_flags flags; u32 val; int ret;
@@ -503,18 +525,6 @@ static int asoc_simple_card_parse_of(struct device_node *node, return ret; }
- priv->gpio_hp_det = of_get_named_gpio_flags(node, - PREFIX "hp-det-gpio", 0, &flags); - priv->gpio_hp_det_invert = !!(flags & OF_GPIO_ACTIVE_LOW); - if (priv->gpio_hp_det == -EPROBE_DEFER) - return -EPROBE_DEFER; - - priv->gpio_mic_det = of_get_named_gpio_flags(node, - PREFIX "mic-det-gpio", 0, &flags); - priv->gpio_mic_det_invert = !!(flags & OF_GPIO_ACTIVE_LOW); - if (priv->gpio_mic_det == -EPROBE_DEFER) - return -EPROBE_DEFER; - if (!priv->snd_card.name) priv->snd_card.name = priv->snd_card.dai_link->name;
@@ -564,9 +574,6 @@ static int asoc_simple_card_probe(struct platform_device *pdev) priv->snd_card.dai_link = dai_link; priv->snd_card.num_links = num_links;
- priv->gpio_hp_det = -ENOENT; - priv->gpio_mic_det = -ENOENT; - /* Get room for the other properties */ priv->dai_props = devm_kzalloc(dev, sizeof(*priv->dai_props) * num_links, @@ -633,12 +640,8 @@ static int asoc_simple_card_remove(struct platform_device *pdev) struct snd_soc_card *card = platform_get_drvdata(pdev); struct simple_card_data *priv = snd_soc_card_get_drvdata(card);
- if (gpio_is_valid(priv->gpio_hp_det)) - snd_soc_jack_free_gpios(&simple_card_hp_jack, 1, - &simple_card_hp_jack_gpio); - if (gpio_is_valid(priv->gpio_mic_det)) - snd_soc_jack_free_gpios(&simple_card_mic_jack, 1, - &simple_card_mic_jack_gpio); + asoc_simple_card_remove_jack(&priv->hp_jack); + asoc_simple_card_remove_jack(&priv->mic_jack);
return asoc_simple_card_unref(card); }
The patch
ASoC: simple-card: add new asoc_simple_jack and use it
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 9eac361877b3c96c8f68dffd7a7a3e92a2b85d0b Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Date: Tue, 31 May 2016 08:59:46 +0000 Subject: [PATCH] ASoC: simple-card: add new asoc_simple_jack and use it
Current simple-card supports snd_soc_jack/pin/gpio. These code are very similar, but driver has verbosity code. So, this patch adds new snd_soc_jack and cleanups code
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/generic/simple-card.c | 153 ++++++++++++++++++++-------------------- 1 file changed, 78 insertions(+), 75 deletions(-)
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index b6e6d9a12ec2..8d0311ceded1 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -21,6 +21,12 @@ #include <sound/soc-dai.h> #include <sound/soc.h>
+struct asoc_simple_jack { + struct snd_soc_jack jack; + struct snd_soc_jack_pin pin; + struct snd_soc_jack_gpio gpio; +}; + struct simple_card_data { struct snd_soc_card snd_card; struct simple_dai_props { @@ -29,10 +35,8 @@ struct simple_card_data { unsigned int mclk_fs; } *dai_props; unsigned int mclk_fs; - int gpio_hp_det; - int gpio_hp_det_invert; - int gpio_mic_det; - int gpio_mic_det_invert; + struct asoc_simple_jack hp_jack; + struct asoc_simple_jack mic_jack; struct snd_soc_dai_link dai_link[]; /* dynamically allocated */ };
@@ -42,6 +46,67 @@ struct simple_card_data {
#define PREFIX "simple-audio-card,"
+#define asoc_simple_card_init_hp(card, sjack, prefix)\ + asoc_simple_card_init_jack(card, sjack, 1, prefix) +#define asoc_simple_card_init_mic(card, sjack, prefix)\ + asoc_simple_card_init_jack(card, sjack, 0, prefix) +static int asoc_simple_card_init_jack(struct snd_soc_card *card, + struct asoc_simple_jack *sjack, + int is_hp, char *prefix) +{ + struct device *dev = card->dev; + enum of_gpio_flags flags; + char prop[128]; + char *pin_name; + char *gpio_name; + int mask; + int det; + + sjack->gpio.gpio = -ENOENT; + + if (is_hp) { + snprintf(prop, sizeof(prop), "%shp-det-gpio", prefix); + pin_name = "Headphones"; + gpio_name = "Headphone detection"; + mask = SND_JACK_HEADPHONE; + } else { + snprintf(prop, sizeof(prop), "%smic-det-gpio", prefix); + pin_name = "Mic Jack"; + gpio_name = "Mic detection"; + mask = SND_JACK_MICROPHONE; + } + + det = of_get_named_gpio_flags(dev->of_node, prop, 0, &flags); + if (det == -EPROBE_DEFER) + return -EPROBE_DEFER; + + if (gpio_is_valid(det)) { + sjack->pin.pin = pin_name; + sjack->pin.mask = mask; + + sjack->gpio.name = gpio_name; + sjack->gpio.report = mask; + sjack->gpio.gpio = det; + sjack->gpio.invert = !!(flags & OF_GPIO_ACTIVE_LOW); + sjack->gpio.debounce_time = 150; + + snd_soc_card_jack_new(card, pin_name, mask, + &sjack->jack, + &sjack->pin, 1); + + snd_soc_jack_add_gpios(&sjack->jack, 1, + &sjack->gpio); + } + + return 0; +} + +static void asoc_simple_card_remove_jack(struct asoc_simple_jack *sjack) +{ + if (gpio_is_valid(sjack->gpio.gpio)) + snd_soc_jack_free_gpios(&sjack->jack, 1, &sjack->gpio); +} + static int asoc_simple_card_startup(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; @@ -112,32 +177,6 @@ static struct snd_soc_ops asoc_simple_card_ops = { .hw_params = asoc_simple_card_hw_params, };
-static struct snd_soc_jack simple_card_hp_jack; -static struct snd_soc_jack_pin simple_card_hp_jack_pins[] = { - { - .pin = "Headphones", - .mask = SND_JACK_HEADPHONE, - }, -}; -static struct snd_soc_jack_gpio simple_card_hp_jack_gpio = { - .name = "Headphone detection", - .report = SND_JACK_HEADPHONE, - .debounce_time = 150, -}; - -static struct snd_soc_jack simple_card_mic_jack; -static struct snd_soc_jack_pin simple_card_mic_jack_pins[] = { - { - .pin = "Mic Jack", - .mask = SND_JACK_MICROPHONE, - }, -}; -static struct snd_soc_jack_gpio simple_card_mic_jack_gpio = { - .name = "Mic detection", - .report = SND_JACK_MICROPHONE, - .debounce_time = 150, -}; - static int __asoc_simple_card_dai_init(struct snd_soc_dai *dai, struct asoc_simple_dai *set) { @@ -186,30 +225,14 @@ static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd) if (ret < 0) return ret;
- if (gpio_is_valid(priv->gpio_hp_det)) { - snd_soc_card_jack_new(rtd->card, "Headphones", - SND_JACK_HEADPHONE, - &simple_card_hp_jack, - simple_card_hp_jack_pins, - ARRAY_SIZE(simple_card_hp_jack_pins)); - - simple_card_hp_jack_gpio.gpio = priv->gpio_hp_det; - simple_card_hp_jack_gpio.invert = priv->gpio_hp_det_invert; - snd_soc_jack_add_gpios(&simple_card_hp_jack, 1, - &simple_card_hp_jack_gpio); - } + ret = asoc_simple_card_init_hp(rtd->card, &priv->hp_jack, PREFIX); + if (ret < 0) + return ret; + + ret = asoc_simple_card_init_mic(rtd->card, &priv->hp_jack, PREFIX); + if (ret < 0) + return ret;
- if (gpio_is_valid(priv->gpio_mic_det)) { - snd_soc_card_jack_new(rtd->card, "Mic Jack", - SND_JACK_MICROPHONE, - &simple_card_mic_jack, - simple_card_mic_jack_pins, - ARRAY_SIZE(simple_card_mic_jack_pins)); - simple_card_mic_jack_gpio.gpio = priv->gpio_mic_det; - simple_card_mic_jack_gpio.invert = priv->gpio_mic_det_invert; - snd_soc_jack_add_gpios(&simple_card_mic_jack, 1, - &simple_card_mic_jack_gpio); - } return 0; }
@@ -447,7 +470,6 @@ static int asoc_simple_card_parse_of(struct device_node *node, struct simple_card_data *priv) { struct device *dev = simple_priv_to_dev(priv); - enum of_gpio_flags flags; u32 val; int ret;
@@ -503,18 +525,6 @@ static int asoc_simple_card_parse_of(struct device_node *node, return ret; }
- priv->gpio_hp_det = of_get_named_gpio_flags(node, - PREFIX "hp-det-gpio", 0, &flags); - priv->gpio_hp_det_invert = !!(flags & OF_GPIO_ACTIVE_LOW); - if (priv->gpio_hp_det == -EPROBE_DEFER) - return -EPROBE_DEFER; - - priv->gpio_mic_det = of_get_named_gpio_flags(node, - PREFIX "mic-det-gpio", 0, &flags); - priv->gpio_mic_det_invert = !!(flags & OF_GPIO_ACTIVE_LOW); - if (priv->gpio_mic_det == -EPROBE_DEFER) - return -EPROBE_DEFER; - if (!priv->snd_card.name) priv->snd_card.name = priv->snd_card.dai_link->name;
@@ -564,9 +574,6 @@ static int asoc_simple_card_probe(struct platform_device *pdev) priv->snd_card.dai_link = dai_link; priv->snd_card.num_links = num_links;
- priv->gpio_hp_det = -ENOENT; - priv->gpio_mic_det = -ENOENT; - /* Get room for the other properties */ priv->dai_props = devm_kzalloc(dev, sizeof(*priv->dai_props) * num_links, @@ -633,12 +640,8 @@ static int asoc_simple_card_remove(struct platform_device *pdev) struct snd_soc_card *card = platform_get_drvdata(pdev); struct simple_card_data *priv = snd_soc_card_get_drvdata(card);
- if (gpio_is_valid(priv->gpio_hp_det)) - snd_soc_jack_free_gpios(&simple_card_hp_jack, 1, - &simple_card_hp_jack_gpio); - if (gpio_is_valid(priv->gpio_mic_det)) - snd_soc_jack_free_gpios(&simple_card_mic_jack, 1, - &simple_card_mic_jack_gpio); + asoc_simple_card_remove_jack(&priv->hp_jack); + asoc_simple_card_remove_jack(&priv->mic_jack);
return asoc_simple_card_unref(card); }
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);
The patch
ASoC: add new simple-card-utils.c
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 abd3147e69481caade441e8d8296fa3f541aea03 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Date: Tue, 31 May 2016 09:00:14 +0000 Subject: [PATCH] ASoC: add new simple-card-utils.c
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 Signed-off-by: Mark Brown broonie@kernel.org --- 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 000000000000..7acc798016e0 --- /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 610f61251640..26c2fe6a0b93 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 9c3b246792bf..45602ca8536e 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 000000000000..3f6b72526f71 --- /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);
On Tue, May 31, 2016 at 09:00:40AM +0000, Kuninori Morimoto wrote:
+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);
This is (obviously) a very thin wrapper around the existing interface. If that makes sense then perhaps we should just update the existing interface?
Hi Mark
+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);
This is (obviously) a very thin wrapper around the existing interface. If that makes sense then perhaps we should just update the existing interface?
Indeed it is very thin. I will just remove it in v3
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 Tue, May 31, 2016 at 09:01:09AM +0000, Kuninori Morimoto wrote:
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.
This looks like it's about putting DPCM into the DT. Given that DPCM is very much an implementation detail we're trying to get rid of this seems like it's going in the wrong direction. What's the intended use?
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.
This looks like it's about putting DPCM into the DT. Given that DPCM is very much an implementation detail we're trying to get rid of this seems like it's going in the wrong direction. What's the intended use?
My rsrc-card already supporting DPCM on DT. This function is for name setting, for both DPCM card and normal simple-card. It doesn't related to DPCM feature, just for name. simple-card name will be created from CPU/Codec dai name, then, we need to allocate memory for it, and dai_link name setting So, this is for it.
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);
On Tue, May 31, 2016 at 09:01:34AM +0000, Kuninori Morimoto wrote:
- if (!card->name)
card->name = card->dai_link->name;
This will unconditionally defererence dai_link but it's optional - we can have analogue only cards.
Hi Mark
- if (!card->name)
card->name = card->dai_link->name;
This will unconditionally defererence dai_link but it's optional - we can have analogue only cards.
This is not new feature. Current simple-card already has it.
-------------------- commit 2772555b6c5ba79783c04ea6c60549530d737e2e Author: Xiubo Li Li.Xiubo@freescale.com Date: Fri Jan 24 15:43:02 2014 +0800
ASoC: simple-card: Add snd_card's name parsing from DT node support
If the DT is used and the CPU DAI device has only one DAI, the card name will be like :
ALSA device list: 0: 40031000.sai-sgtl5000
And this name maybe a little ugly to some customers, so here the card name parsing from DT node is supported.
Signed-off-by: Xiubo Li Li.Xiubo@freescale.com Signed-off-by: Mark Brown broonie@linaro.org --------------------
On Thu, Jun 30, 2016 at 02:55:06AM +0000, Kuninori Morimoto wrote:
- if (!card->name)
card->name = card->dai_link->name;
This will unconditionally defererence dai_link but it's optional - we can have analogue only cards.
This is not new feature. Current simple-card already has it.
Right, but simple-card does need DAIs IIRC while this is intended to be more general. All it needs is a check before the dereference to be safe so it's trivial to handle.
Hi Mark
- if (!card->name)
card->name = card->dai_link->name;
This will unconditionally defererence dai_link but it's optional - we can have analogue only cards.
This is not new feature. Current simple-card already has it.
Right, but simple-card does need DAIs IIRC while this is intended to be more general. All it needs is a check before the dereference to be safe so it's trivial to handle.
Sorry, I'm not 100% understand. Do you mean we don't need handle card->name ? (= we should remove above ?) If so, we can't register card on simple-card. Because snd_soc_register_card() requests it.
Hi Mark, again
sorry previous was not good question
- if (!card->name)
card->name = card->dai_link->name;
This will unconditionally defererence dai_link but it's optional - we can have analogue only cards.
This is not new feature. Current simple-card already has it.
Right, but simple-card does need DAIs IIRC while this is intended to be more general. All it needs is a check before the dereference to be safe so it's trivial to handle.
Sorry, I'm not 100% understand. Do you mean we don't need handle card->name ? (= we should remove above ?) If so, we can't register card on simple-card. Because snd_soc_register_card() requests it.
This function tries to get card name from snd_soc_of_parse_card_name(). and it tries to set card->name from dai_link if card still doesn't have name. So, above is optional 2nd try. Or, do you mean this if (!card->name) can goes to simple-card, instead of utils ? I have no objection about it , but it can be double handling ? Because other simple family have same situation.
On Mon, Jul 04, 2016 at 12:20:29AM +0000, Kuninori Morimoto wrote:
- if (!card->name)
card->name = card->dai_link->name;
This will unconditionally defererence dai_link but it's optional - we can have analogue only cards.
This is not new feature. Current simple-card already has it.
Right, but simple-card does need DAIs IIRC while this is intended to be more general. All it needs is a check before the dereference to be safe so it's trivial to handle.
Sorry, I'm not 100% understand. Do you mean we don't need handle card->name ? (= we should remove above ?) If so, we can't register card on simple-card. Because snd_soc_register_card() requests it.
This function tries to get card name from snd_soc_of_parse_card_name(). and it tries to set card->name from dai_link if card still doesn't have name. So, above is optional 2nd try. Or, do you mean this if (!card->name) can goes to simple-card, instead of utils ? I have no objection about it , but it can be double handling ? Because other simple family have same situation.
If we try to dereference card->dai_link without checking to see if it's set then we'll crash.
Hi Mark
Thank you for your feedback
This function tries to get card name from snd_soc_of_parse_card_name(). and it tries to set card->name from dai_link if card still doesn't have name. So, above is optional 2nd try. Or, do you mean this if (!card->name) can goes to simple-card, instead of utils ? I have no objection about it , but it can be double handling ? Because other simple family have same situation.
If we try to dereference card->dai_link without checking to see if it's set then we'll crash.
Ahh, do you mean we need like this ?
if (!card->name && card->dai_link) card->name = card->dai_link->name;
On Mon, Jul 04, 2016 at 08:59:53AM +0000, Kuninori Morimoto wrote:
If we try to dereference card->dai_link without checking to see if it's set then we'll crash.
Ahh, do you mean we need like this ?
if (!card->name && card->dai_link) card->name = card->dai_link->name;
Yes, exactly.
Hi Mark
Ahh, do you mean we need like this ?
if (!card->name && card->dai_link) card->name = card->dai_link->name;
Yes, exactly.
OK, I understand. next version will do it.
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);
On Tue, May 31, 2016 at 09:01:58AM +0000, Kuninori Morimoto wrote:
+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);
Similar thin wrapper comment as before: what is this offering over the underlying function?
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);
On Tue, May 31, 2016 at 09:02:22AM +0000, Kuninori Morimoto wrote:
- 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);
- }
This looks like we're leaking the clocks - devm_ might help here perhaps?
Hi Mark
- 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);
- }
This looks like we're leaking the clocks - devm_ might help here perhaps?
Good catch. This came from original simple-card, but yes, we should use devm_* I will fix it on v3
Hi Mark, again
- 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);
- }
This looks like we're leaking the clocks - devm_ might help here perhaps?
Good catch. This came from original simple-card, but yes, we should use devm_* I will fix it on v3
Oops, of_clk_get() doesn't have devm_of_clk_get() ? (and no of_clk_put() ... ) I will keep above as-is in v3. We can fix it incrementally (?)
On Thu, Jun 30, 2016 at 12:39:12AM +0000, Kuninori Morimoto wrote:
Oops, of_clk_get() doesn't have devm_of_clk_get() ?
Perhaps add it?
(and no of_clk_put() ... ) I will keep above as-is in v3. We can fix it incrementally (?)
You can just use regular clk_put() with of_clk_get().
Hi Mark
Oops, of_clk_get() doesn't have devm_of_clk_get() ?
Perhaps add it?
(and no of_clk_put() ... ) I will keep above as-is in v3. We can fix it incrementally (?)
You can just use regular clk_put() with of_clk_get().
Ohh.. OK, but can I do it in additional patch ? Because main purpose of this patch is cleanup by using util.c, not adding new feature. Maybe it can be 0001 add devm_of_clk_get() 0002 use devm_of_clk_get() on simple-card-utils.c
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);
On Tue, May 31, 2016 at 09:03:00AM +0000, Kuninori Morimoto wrote:
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
I'm finding these descriptions very clear and hard to follow, and the lack of any changes to the simple-card code is a bit unclear. Can I suggest that future versions of this should have patches that move code out of simple-card to helper functions as a single patch rather than adding the helper in one and (I presume) the use in another?
In this case I'm not entirely clear what an endpoint is.
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);
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/simple_card.h | 11 +--------- sound/soc/generic/Kconfig | 1 + sound/soc/generic/simple-card.c | 46 ++--------------------------------------- 3 files changed, 4 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/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/generic/simple-card.c | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-)
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index e3a32d3..6a4d1d4 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -244,8 +244,6 @@ asoc_simple_card_sub_parse_of(struct device_node *np, int *args_count) { struct of_phandle_args args; - struct clk *clk; - u32 val; int ret;
if (!np) @@ -282,29 +280,6 @@ asoc_simple_card_sub_parse_of(struct device_node *np, if (ret) return ret;
- /* - * Parse dai->sysclk come from "clocks = <&xxx>" - * (if system has common clock) - * or "system-clock-frequency = <xxx>" - * or device's module clock. - */ - if (of_property_read_bool(np, "clocks")) { - clk = of_clk_get(np, 0); - if (IS_ERR(clk)) { - ret = PTR_ERR(clk); - return ret; - } - - dai->sysclk = clk_get_rate(clk); - dai->clk = clk; - } else if (!of_property_read_u32(np, "system-clock-frequency", &val)) { - dai->sysclk = val; - } else { - clk = of_clk_get(args.np, 0); - if (!IS_ERR(clk)) - dai->sysclk = clk_get_rate(clk); - } - return 0; }
@@ -316,6 +291,8 @@ static int asoc_simple_card_dai_link_of(struct device_node *node, struct device *dev = simple_priv_to_dev(priv); struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, idx); struct simple_dai_props *dai_props = simple_priv_to_props(priv, idx); + struct asoc_simple_dai *cpu_dai = &dai_props->cpu_dai; + struct asoc_simple_dai *codec_dai = &dai_props->codec_dai; struct device_node *cpu = NULL; struct device_node *plat = NULL; struct device_node *codec = NULL; @@ -371,6 +348,14 @@ static int asoc_simple_card_dai_link_of(struct device_node *node, if (ret < 0) goto dai_link_of_err;
+ ret = asoc_simple_card_parse_clk_cpu(cpu, dai_link, cpu_dai); + if (ret < 0) + goto dai_link_of_err; + + ret = asoc_simple_card_parse_clk_codec(codec, dai_link, codec_dai); + if (ret < 0) + goto dai_link_of_err; + if (!dai_link->cpu_dai_name || !dai_link->codec_dai_name) { ret = -EINVAL; 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/generic/simple-card.c | 43 +++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 25 deletions(-)
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 6a4d1d4..f0f45bf 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -44,6 +44,8 @@ struct simple_card_data { #define simple_priv_to_link(priv, i) ((priv)->snd_card.dai_link + i) #define simple_priv_to_props(priv, i) ((priv)->dai_props + i)
+#define DAI "sound-dai" +#define CELL "#sound-dai-cells" #define PREFIX "simple-audio-card,"
#define asoc_simple_card_init_hp(card, sjack, prefix)\ @@ -243,33 +245,11 @@ asoc_simple_card_sub_parse_of(struct device_node *np, const char **name, int *args_count) { - struct of_phandle_args args; int ret;
if (!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(np, "sound-dai", - "#sound-dai-cells", 0, &args); - if (ret) - return ret; - - *p_node = args.np; - - if (args_count) - *args_count = args.args_count; - - /* Get dai->name */ - if (name) { - ret = snd_soc_of_get_dai_name(np, name); - if (ret < 0) - return ret; - } - if (!dai) return 0;
@@ -299,7 +279,7 @@ static int asoc_simple_card_dai_link_of(struct device_node *node, char *name; char prop[128]; char *prefix = ""; - int ret, cpu_args; + int ret, single_cpu; u32 val;
/* For single DAI link & old style of DT node */ @@ -329,10 +309,23 @@ static int asoc_simple_card_dai_link_of(struct device_node *node, if (!of_property_read_u32(node, "mclk-fs", &val)) dai_props->mclk_fs = val;
+ ret = asoc_simple_card_parse_cpu(cpu, dai_link, + DAI, CELL, &single_cpu); + if (ret < 0) + goto dai_link_of_err; + + ret = asoc_simple_card_parse_codec(codec, dai_link, DAI, CELL); + if (ret < 0) + goto dai_link_of_err; + + ret = asoc_simple_card_parse_platform(plat, dai_link, DAI, CELL); + if (ret < 0) + goto dai_link_of_err; + ret = asoc_simple_card_sub_parse_of(cpu, &dai_props->cpu_dai, &dai_link->cpu_of_node, &dai_link->cpu_dai_name, - &cpu_args); + &single_cpu); if (ret < 0) goto dai_link_of_err;
@@ -399,7 +392,7 @@ static int asoc_simple_card_dai_link_of(struct device_node *node, * fmt_single_name() * fmt_multiple_name() */ - if (!cpu_args) + if (single_cpu) dai_link->cpu_dai_name = NULL;
dai_link_of_err:
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/generic/simple-card.c | 40 ++-------------------------------------- 1 file changed, 2 insertions(+), 38 deletions(-)
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index f0f45bf..2aa21a4 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -238,31 +238,6 @@ static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd) return 0; }
-static int -asoc_simple_card_sub_parse_of(struct device_node *np, - struct asoc_simple_dai *dai, - struct device_node **p_node, - const char **name, - int *args_count) -{ - int ret; - - if (!np) - return 0; - - if (!dai) - return 0; - - /* Parse TDM slot */ - ret = snd_soc_of_parse_tdm_slot(np, &dai->tx_slot_mask, - &dai->rx_slot_mask, - &dai->slots, &dai->slot_width); - if (ret) - return ret; - - return 0; -} - static int asoc_simple_card_dai_link_of(struct device_node *node, struct simple_card_data *priv, int idx, @@ -322,22 +297,11 @@ static int asoc_simple_card_dai_link_of(struct device_node *node, if (ret < 0) goto dai_link_of_err;
- ret = asoc_simple_card_sub_parse_of(cpu, &dai_props->cpu_dai, - &dai_link->cpu_of_node, - &dai_link->cpu_dai_name, - &single_cpu); - if (ret < 0) - goto dai_link_of_err; - - ret = asoc_simple_card_sub_parse_of(codec, &dai_props->codec_dai, - &dai_link->codec_of_node, - &dai_link->codec_dai_name, NULL); + ret = asoc_simple_card_parse_tdm(cpu, cpu_dai); if (ret < 0) goto dai_link_of_err;
- ret = asoc_simple_card_sub_parse_of(plat, NULL, - &dai_link->platform_of_node, - NULL, NULL); + ret = asoc_simple_card_parse_tdm(codec, codec_dai); 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/generic/simple-card.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 2aa21a4..35ec012c 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -376,9 +376,6 @@ static int asoc_simple_card_parse_of(struct device_node *node, if (!node) return -EINVAL;
- /* Parse the card name from DT */ - snd_soc_of_parse_card_name(&priv->snd_card, PREFIX "name"); - /* The off-codec widgets */ if (of_property_read_bool(node, PREFIX "widgets")) { ret = snd_soc_of_parse_audio_simple_widgets(&priv->snd_card, @@ -400,9 +397,6 @@ static int asoc_simple_card_parse_of(struct device_node *node, if (ret == 0) priv->mclk_fs = val;
- dev_dbg(dev, "New simple-card: %s\n", priv->snd_card.name ? - priv->snd_card.name : ""); - /* Single/Muti DAI link(s) & New style of DT node */ if (of_get_child_by_name(node, PREFIX "dai-link")) { struct device_node *np = NULL; @@ -425,8 +419,9 @@ static int asoc_simple_card_parse_of(struct device_node *node, return ret; }
- if (!priv->snd_card.name) - priv->snd_card.name = priv->snd_card.dai_link->name; + ret = asoc_simple_card_parse_card_name(&priv->snd_card, PREFIX); + if (ret) + return ret;
return 0; }
The patch
ASoC: simple-card: use asoc_simple_card_parse_card_name()
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 3527d85b85e65401b7d93073b3ab4e687cdd2521 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Date: Mon, 11 Jul 2016 23:59:40 +0000 Subject: [PATCH] ASoC: simple-card: use asoc_simple_card_parse_card_name()
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/generic/simple-card.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 07469cd9272c..43295f024982 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -427,9 +427,6 @@ static int asoc_simple_card_parse_of(struct device_node *node, if (!node) return -EINVAL;
- /* Parse the card name from DT */ - snd_soc_of_parse_card_name(&priv->snd_card, PREFIX "name"); - /* The off-codec widgets */ if (of_property_read_bool(node, PREFIX "widgets")) { ret = snd_soc_of_parse_audio_simple_widgets(&priv->snd_card, @@ -451,9 +448,6 @@ static int asoc_simple_card_parse_of(struct device_node *node, if (ret == 0) priv->mclk_fs = val;
- dev_dbg(dev, "New simple-card: %s\n", priv->snd_card.name ? - priv->snd_card.name : ""); - /* Single/Muti DAI link(s) & New style of DT node */ if (of_get_child_by_name(node, PREFIX "dai-link")) { struct device_node *np = NULL; @@ -476,8 +470,9 @@ static int asoc_simple_card_parse_of(struct device_node *node, return ret; }
- if (!priv->snd_card.name) - priv->snd_card.name = priv->snd_card.dai_link->name; + ret = asoc_simple_card_parse_card_name(&priv->snd_card, PREFIX); + if (ret) + return ret;
return 0; }
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 35ec012c..8d2ce0a 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -251,7 +251,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, single_cpu; @@ -322,19 +321,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/generic/simple-card.c | 38 +++----------------------------------- 1 file changed, 3 insertions(+), 35 deletions(-)
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 8d2ce0a..09ccbb0 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -179,51 +179,19 @@ static struct snd_soc_ops asoc_simple_card_ops = { .hw_params = asoc_simple_card_hw_params, };
-static int __asoc_simple_card_dai_init(struct snd_soc_dai *dai, - struct asoc_simple_dai *set) -{ - int ret; - - if (set->sysclk) { - ret = snd_soc_dai_set_sysclk(dai, 0, set->sysclk, 0); - if (ret && ret != -ENOTSUPP) { - dev_err(dai->dev, "simple-card: set_sysclk error\n"); - goto err; - } - } - - if (set->slots) { - ret = snd_soc_dai_set_tdm_slot(dai, - set->tx_slot_mask, - set->rx_slot_mask, - set->slots, - set->slot_width); - if (ret && ret != -ENOTSUPP) { - dev_err(dai->dev, "simple-card: set_tdm_slot error\n"); - goto err; - } - } - - ret = 0; - -err: - return ret; -} - static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd) { struct simple_card_data *priv = snd_soc_card_get_drvdata(rtd->card); struct snd_soc_dai *codec = rtd->codec_dai; struct snd_soc_dai *cpu = rtd->cpu_dai; - struct simple_dai_props *dai_props; + struct simple_dai_props *dai_props = &priv->dai_props[rtd->num]; int ret;
- dai_props = &priv->dai_props[rtd->num]; - ret = __asoc_simple_card_dai_init(codec, &dai_props->codec_dai); + ret = asoc_simple_card_init_dai(codec, &dai_props->codec_dai); if (ret < 0) return ret;
- ret = __asoc_simple_card_dai_init(cpu, &dai_props->cpu_dai); + ret = asoc_simple_card_init_dai(cpu, &dai_props->cpu_dai); if (ret < 0) return ret;
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/generic/simple-card.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 09ccbb0..11fd7de 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -280,14 +280,9 @@ static int asoc_simple_card_dai_link_of(struct device_node *node, if (ret < 0) goto dai_link_of_err;
- if (!dai_link->cpu_dai_name || !dai_link->codec_dai_name) { - ret = -EINVAL; + ret = asoc_simple_card_canonicalize_dailink(dai_link); + if (ret < 0) goto dai_link_of_err; - } - - /* Assumes platform == cpu */ - if (!dai_link->platform_of_node) - dai_link->platform_of_node = dai_link->cpu_of_node;
ret = asoc_simple_card_parse_dailink_name(dev, dai_link); if (ret < 0)
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, 3 insertions(+), 11 deletions(-)
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 11fd7de..c9178af 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -300,17 +300,9 @@ static int asoc_simple_card_dai_link_of(struct device_node *node, dai_link->codec_dai_name, dai_props->codec_dai.sysclk);
- /* - * 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 (single_cpu) - dai_link->cpu_dai_name = NULL; + ret = asoc_simple_card_canonicalize_cpu(dai_link, single_cpu); + if (ret < 0) + goto dai_link_of_err;
dai_link_of_err: of_node_put(cpu);
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/generic/simple-card.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-)
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index c9178af..02fab53 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -371,21 +371,6 @@ static int asoc_simple_card_parse_of(struct device_node *node, return 0; }
-/* Decrease the reference count of the device nodes */ -static int asoc_simple_card_unref(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; -} - static int asoc_simple_card_probe(struct platform_device *pdev) { struct simple_card_data *priv; @@ -471,7 +456,7 @@ static int asoc_simple_card_probe(struct platform_device *pdev) return ret;
err: - asoc_simple_card_unref(&priv->snd_card); + asoc_simple_card_clean_reference(&priv->snd_card); return ret; }
@@ -483,7 +468,7 @@ static int asoc_simple_card_remove(struct platform_device *pdev) asoc_simple_card_remove_jack(&priv->hp_jack); asoc_simple_card_remove_jack(&priv->mic_jack);
- return asoc_simple_card_unref(card); + return asoc_simple_card_clean_reference(card); }
static const struct of_device_id asoc_simple_of_match[] = {
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;
The patch
ASoC: rsrc-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 d6a4a9a45d072e3a27ea6e5f98192d78be621a9c Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Date: Thu, 30 Jun 2016 06:03:13 +0000 Subject: [PATCH] ASoC: rsrc-card: use asoc_simple_card_parse_daifmt()
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown broonie@kernel.org --- 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 c9902a6d6fa0..9311f119feb5 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 1bc7ecfc42a9..984d8fed0dbd 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; @@ -159,38 +160,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) @@ -358,6 +327,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; @@ -370,8 +340,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
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;
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 | 68 +++++++------------------------------------ 1 file changed, 10 insertions(+), 58 deletions(-)
diff --git a/sound/soc/sh/rcar/rsrc-card.c b/sound/soc/sh/rcar/rsrc-card.c index e28c9c0..c326562 100644 --- a/sound/soc/sh/rcar/rsrc-card.c +++ b/sound/soc/sh/rcar/rsrc-card.c @@ -190,6 +190,10 @@ static int rsrc_card_parse_links(struct device_node *np, if (ret < 0) return ret;
+ ret = asoc_simple_card_parse_clk_cpu(np, dai_link, dai_props); + if (ret < 0) + return ret; + /* * In soc_bind_dai_link() will check cpu name after * of_node matching if dai_link has cpu_dai_name. @@ -219,6 +223,10 @@ static int rsrc_card_parse_links(struct device_node *np, if (ret < 0) return ret;
+ ret = asoc_simple_card_parse_clk_codec(np, dai_link, dai_props); + if (ret < 0) + return ret; + /* additional name prefix */ if (of_data) { priv->codec_conf.of_node = dai_link->codec_of_node; @@ -242,68 +250,12 @@ static int rsrc_card_parse_links(struct device_node *np, dai_link->ops = &rsrc_card_ops; dai_link->init = rsrc_card_dai_init;
- return 0; -} - -static int rsrc_card_parse_clk(struct device_node *np, - struct rsrc_card_priv *priv, - int idx, bool is_fe) -{ - struct snd_soc_dai_link *dai_link = rsrc_priv_to_link(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; - u32 val; - - /* - * Parse dai->sysclk come from "clocks = <&xxx>" - * (if system has common clock) - * or "system-clock-frequency = <xxx>" - * or device's module clock. - */ - if (of_property_read_bool(np, "clocks")) { - clk = of_clk_get(np, 0); - if (IS_ERR(clk)) - return PTR_ERR(clk); - - dai_props->sysclk = clk_get_rate(clk); - dai_props->clk = clk; - } else if (!of_property_read_u32(np, "system-clock-frequency", &val)) { - dai_props->sysclk = val; - } else { - clk = of_clk_get(of_np, 0); - if (!IS_ERR(clk)) - dai_props->sysclk = clk_get_rate(clk); - } - - return 0; -} - -static int rsrc_card_dai_sub_link_of(struct device_node *node, - 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 asoc_simple_dai *dai_props = rsrc_priv_to_props(priv, idx); - int ret; - - ret = rsrc_card_parse_links(np, priv, idx, is_fe); - if (ret < 0) - return ret; - - ret = rsrc_card_parse_clk(np, priv, idx, is_fe); - if (ret < 0) - return ret; - dev_dbg(dev, "\t%s / %04x / %d\n", dai_link->name, dai_link->dai_fmt, dai_props->sysclk);
- return ret; + return 0; }
static int rsrc_card_dai_link_of(struct device_node *node, @@ -340,7 +292,7 @@ static int rsrc_card_dai_link_of(struct device_node *node, if (strcmp(np->name, "cpu") == 0) is_fe = true;
- ret = rsrc_card_dai_sub_link_of(node, np, priv, i, is_fe); + ret = rsrc_card_parse_links(np, priv, i, is_fe); if (ret < 0) return ret; i++;
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 | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-)
diff --git a/sound/soc/sh/rcar/rsrc-card.c b/sound/soc/sh/rcar/rsrc-card.c index c326562..87b9d87 100644 --- a/sound/soc/sh/rcar/rsrc-card.c +++ b/sound/soc/sh/rcar/rsrc-card.c @@ -62,6 +62,9 @@ struct rsrc_card_priv { #define rsrc_priv_to_link(priv, i) ((priv)->snd_card.dai_link + (i)) #define rsrc_priv_to_props(priv, i) ((priv)->dai_props + (i))
+#define DAI "sound-dai" +#define CELL "#sound-dai-cells" + static int rsrc_card_startup(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; @@ -155,18 +158,9 @@ 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 asoc_simple_dai *dai_props = rsrc_priv_to_props(priv, idx); - struct of_phandle_args args; + int is_single_links = 0; int ret;
- /* - * 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(np, "sound-dai", - "#sound-dai-cells", 0, &args); - if (ret) - return ret; - /* Parse TDM slot */ ret = snd_soc_of_parse_tdm_slot(np, &dai_props->tx_slot_mask, @@ -185,9 +179,10 @@ static int rsrc_card_parse_links(struct device_node *np, /* FE settings */ dai_link->dynamic = 1; dai_link->dpcm_merged_format = 1; - dai_link->cpu_of_node = args.np; - ret = snd_soc_of_get_dai_name(np, &dai_link->cpu_dai_name); - if (ret < 0) + + ret = asoc_simple_card_parse_cpu(np, dai_link, DAI, CELL, + &is_single_links); + if (ret) return ret;
ret = asoc_simple_card_parse_clk_cpu(np, dai_link, dai_props); @@ -203,7 +198,7 @@ static int rsrc_card_parse_links(struct device_node *np, * fmt_single_name() * fmt_multiple_name() */ - if (!args.args_count) + if (is_single_links) dai_link->cpu_dai_name = NULL; } else { const struct rsrc_card_of_data *of_data; @@ -218,8 +213,8 @@ static int rsrc_card_parse_links(struct device_node *np, /* BE settings */ dai_link->no_pcm = 1; dai_link->be_hw_params_fixup = rsrc_card_be_hw_params_fixup; - dai_link->codec_of_node = args.np; - ret = snd_soc_of_get_dai_name(np, &dai_link->codec_dai_name); + + ret = asoc_simple_card_parse_codec(np, dai_link, DAI, CELL); if (ret < 0) return ret;
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 | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/sound/soc/sh/rcar/rsrc-card.c b/sound/soc/sh/rcar/rsrc-card.c index 87b9d87..3aef7b7 100644 --- a/sound/soc/sh/rcar/rsrc-card.c +++ b/sound/soc/sh/rcar/rsrc-card.c @@ -334,9 +334,6 @@ static int rsrc_card_parse_of(struct device_node *node, "audio-routing"); }
- /* Parse the card name from DT */ - snd_soc_of_parse_card_name(&priv->snd_card, "card-name"); - /* sampling rate convert */ of_property_read_u32(node, "convert-rate", &priv->convert_rate);
@@ -352,8 +349,9 @@ static int rsrc_card_parse_of(struct device_node *node, if (ret < 0) return ret;
- if (!priv->snd_card.name) - priv->snd_card.name = priv->snd_card.dai_link->name; + ret = asoc_simple_card_parse_card_name(&priv->snd_card, "card-"); + if (ret < 0) + return ret;
return 0; }
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 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/sound/soc/sh/rcar/rsrc-card.c b/sound/soc/sh/rcar/rsrc-card.c index 3aef7b7..16279d3 100644 --- a/sound/soc/sh/rcar/rsrc-card.c +++ b/sound/soc/sh/rcar/rsrc-card.c @@ -227,10 +227,11 @@ static int rsrc_card_parse_links(struct device_node *np, priv->codec_conf.of_node = dai_link->codec_of_node; priv->codec_conf.name_prefix = of_data->prefix; } else { - snd_soc_of_parse_audio_prefix(&priv->snd_card, - &priv->codec_conf, - dai_link->codec_of_node, - "audio-prefix"); + ret = asoc_simple_card_parse_card_prefix(&priv->snd_card, + dai_link, &priv->codec_conf, + "audio-"); + if (ret < 0) + return ret; } }
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 | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/sound/soc/sh/rcar/rsrc-card.c b/sound/soc/sh/rcar/rsrc-card.c index 16279d3..da3f219 100644 --- a/sound/soc/sh/rcar/rsrc-card.c +++ b/sound/soc/sh/rcar/rsrc-card.c @@ -161,15 +161,6 @@ static int rsrc_card_parse_links(struct device_node *np, int is_single_links = 0; int ret;
- /* Parse TDM slot */ - ret = snd_soc_of_parse_tdm_slot(np, - &dai_props->tx_slot_mask, - &dai_props->rx_slot_mask, - &dai_props->slots, - &dai_props->slot_width); - if (ret) - return ret; - if (is_fe) { /* BE is dummy */ dai_link->codec_of_node = NULL; @@ -235,6 +226,10 @@ static int rsrc_card_parse_links(struct device_node *np, } }
+ ret = asoc_simple_card_parse_tdm(np, dai_props); + if (ret < 0) + return ret; + ret = asoc_simple_card_parse_dailink_name(dev, dai_link); if (ret < 0) return ret;
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, 1 insertion(+), 25 deletions(-)
diff --git a/sound/soc/sh/rcar/rsrc-card.c b/sound/soc/sh/rcar/rsrc-card.c index da3f219..e5432c1 100644 --- a/sound/soc/sh/rcar/rsrc-card.c +++ b/sound/soc/sh/rcar/rsrc-card.c @@ -97,7 +97,6 @@ static int rsrc_card_dai_init(struct snd_soc_pcm_runtime *rtd) struct snd_soc_dai_link *dai_link; struct asoc_simple_dai *dai_props; int num = rtd->num; - int ret;
dai_link = rsrc_priv_to_link(priv, num); dai_props = rsrc_priv_to_props(priv, num); @@ -105,30 +104,7 @@ static int rsrc_card_dai_init(struct snd_soc_pcm_runtime *rtd) rtd->cpu_dai : rtd->codec_dai;
- if (dai_props->sysclk) { - ret = snd_soc_dai_set_sysclk(dai, 0, dai_props->sysclk, 0); - if (ret && ret != -ENOTSUPP) { - dev_err(dai->dev, "set_sysclk error\n"); - goto err; - } - } - - if (dai_props->slots) { - ret = snd_soc_dai_set_tdm_slot(dai, - dai_props->tx_slot_mask, - dai_props->rx_slot_mask, - dai_props->slots, - dai_props->slot_width); - if (ret && ret != -ENOTSUPP) { - dev_err(dai->dev, "set_tdm_slot error\n"); - goto err; - } - } - - ret = 0; - -err: - return ret; + return asoc_simple_card_init_dai(dai, dai_props); }
static int rsrc_card_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
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 | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/sound/soc/sh/rcar/rsrc-card.c b/sound/soc/sh/rcar/rsrc-card.c index e5432c1..a452150 100644 --- a/sound/soc/sh/rcar/rsrc-card.c +++ b/sound/soc/sh/rcar/rsrc-card.c @@ -156,17 +156,6 @@ static int rsrc_card_parse_links(struct device_node *np, if (ret < 0) return ret;
- /* - * 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; } else { const struct rsrc_card_of_data *of_data;
@@ -222,6 +211,11 @@ static int rsrc_card_parse_links(struct device_node *np, dai_link->dai_fmt, dai_props->sysclk);
+ ret = asoc_simple_card_canonicalize_cpu(dai_link, + is_single_links); + if (ret) + return ret; + return 0; }
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 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/sound/soc/sh/rcar/rsrc-card.c b/sound/soc/sh/rcar/rsrc-card.c index a452150..86f3df3 100644 --- a/sound/soc/sh/rcar/rsrc-card.c +++ b/sound/soc/sh/rcar/rsrc-card.c @@ -199,8 +199,10 @@ static int rsrc_card_parse_links(struct device_node *np, if (ret < 0) return ret;
- /* Simple Card assumes platform == cpu */ - dai_link->platform_of_node = dai_link->cpu_of_node; + ret = asoc_simple_card_canonicalize_dailink(dai_link); + if (ret < 0) + return ret; + dai_link->dpcm_playback = 1; dai_link->dpcm_capture = 1; dai_link->ops = &rsrc_card_ops;
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 | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-)
diff --git a/sound/soc/sh/rcar/rsrc-card.c b/sound/soc/sh/rcar/rsrc-card.c index 86f3df3..ba4c7be 100644 --- a/sound/soc/sh/rcar/rsrc-card.c +++ b/sound/soc/sh/rcar/rsrc-card.c @@ -324,21 +324,6 @@ static int rsrc_card_parse_of(struct device_node *node, return 0; }
-/* Decrease the reference count of the device nodes */ -static int rsrc_card_unref(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; -} - static int rsrc_card_probe(struct platform_device *pdev) { struct rsrc_card_priv *priv; @@ -364,7 +349,7 @@ static int rsrc_card_probe(struct platform_device *pdev) if (ret >= 0) return ret; err: - rsrc_card_unref(&priv->snd_card); + asoc_simple_card_clean_reference(&priv->snd_card);
return ret; } @@ -373,7 +358,7 @@ static int rsrc_card_remove(struct platform_device *pdev) { struct snd_soc_card *card = platform_get_drvdata(pdev);
- return rsrc_card_unref(card); + return asoc_simple_card_clean_reference(card); }
static struct platform_driver rsrc_card = {
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
rsrc-card which is using DPCM feature was created for Renesas sound. But not only Renesas, but many SoC can use this driver, because it is based on simple-card driver. To use it as more open driver, rsrc-card should be renamed to simple-dpcm-card. In order to easy patch review, as 1st step, this patch renames "rsrc" function prefix to "asoc_simple".
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/sh/rcar/rsrc-card.c | 108 +++++++++++++++++++++--------------------- 1 file changed, 54 insertions(+), 54 deletions(-)
diff --git a/sound/soc/sh/rcar/rsrc-card.c b/sound/soc/sh/rcar/rsrc-card.c index ba4c7be..e409b46 100644 --- a/sound/soc/sh/rcar/rsrc-card.c +++ b/sound/soc/sh/rcar/rsrc-card.c @@ -1,5 +1,5 @@ /* - * Renesas Sampling Rate Convert Sound Card for DPCM + * ASoC simple DPCM sound card support * * Copyright (C) 2015 Renesas Solutions Corp. * Kuninori Morimoto kuninori.morimoto.gx@renesas.com @@ -22,7 +22,7 @@ #include <sound/soc-dai.h> #include <sound/simple_card_utils.h>
-struct rsrc_card_of_data { +struct asoc_simple_card_of_data { const char *prefix; const struct snd_soc_dapm_route *routes; int num_routes; @@ -33,23 +33,23 @@ static const struct snd_soc_dapm_route routes_ssi0_ak4642[] = { {"DAI0 Capture", NULL, "ak4642 Capture"}, };
-static const struct rsrc_card_of_data routes_of_ssi0_ak4642 = { +static const struct asoc_simple_card_of_data routes_of_ssi0_ak4642 = { .prefix = "ak4642", .routes = routes_ssi0_ak4642, .num_routes = ARRAY_SIZE(routes_ssi0_ak4642), };
-static const struct of_device_id rsrc_card_of_match[] = { +static const struct of_device_id asoc_simple_card_of_match[] = { { .compatible = "renesas,rsrc-card,lager", .data = &routes_of_ssi0_ak4642 }, { .compatible = "renesas,rsrc-card,koelsch", .data = &routes_of_ssi0_ak4642 }, { .compatible = "renesas,rsrc-card", }, {}, }; -MODULE_DEVICE_TABLE(of, rsrc_card_of_match); +MODULE_DEVICE_TABLE(of, asoc_simple_card_of_match);
#define IDX_CPU 0 #define IDX_CODEC 1 -struct rsrc_card_priv { +struct asoc_simple_card_priv { struct snd_soc_card snd_card; struct snd_soc_codec_conf codec_conf; struct asoc_simple_dai *dai_props; @@ -58,48 +58,48 @@ struct rsrc_card_priv { u32 convert_channels; };
-#define rsrc_priv_to_dev(priv) ((priv)->snd_card.dev) -#define rsrc_priv_to_link(priv, i) ((priv)->snd_card.dai_link + (i)) -#define rsrc_priv_to_props(priv, i) ((priv)->dai_props + (i)) +#define simple_priv_to_dev(priv) ((priv)->snd_card.dev) +#define simple_priv_to_link(priv, i) ((priv)->snd_card.dai_link + (i)) +#define simple_priv_to_props(priv, i) ((priv)->dai_props + (i))
#define DAI "sound-dai" #define CELL "#sound-dai-cells"
-static int rsrc_card_startup(struct snd_pcm_substream *substream) +static int asoc_simple_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 asoc_simple_card_priv *priv = snd_soc_card_get_drvdata(rtd->card); struct asoc_simple_dai *dai_props = - rsrc_priv_to_props(priv, rtd->num); + simple_priv_to_props(priv, rtd->num);
return clk_prepare_enable(dai_props->clk); }
-static void rsrc_card_shutdown(struct snd_pcm_substream *substream) +static void asoc_simple_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 asoc_simple_card_priv *priv = snd_soc_card_get_drvdata(rtd->card); struct asoc_simple_dai *dai_props = - rsrc_priv_to_props(priv, rtd->num); + simple_priv_to_props(priv, rtd->num);
clk_disable_unprepare(dai_props->clk); }
-static struct snd_soc_ops rsrc_card_ops = { - .startup = rsrc_card_startup, - .shutdown = rsrc_card_shutdown, +static struct snd_soc_ops asoc_simple_card_ops = { + .startup = asoc_simple_card_startup, + .shutdown = asoc_simple_card_shutdown, };
-static int rsrc_card_dai_init(struct snd_soc_pcm_runtime *rtd) +static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd) { - struct rsrc_card_priv *priv = snd_soc_card_get_drvdata(rtd->card); + struct asoc_simple_card_priv *priv = snd_soc_card_get_drvdata(rtd->card); struct snd_soc_dai *dai; struct snd_soc_dai_link *dai_link; struct asoc_simple_dai *dai_props; int num = rtd->num;
- dai_link = rsrc_priv_to_link(priv, num); - dai_props = rsrc_priv_to_props(priv, num); + dai_link = simple_priv_to_link(priv, num); + dai_props = simple_priv_to_props(priv, num); dai = dai_link->dynamic ? rtd->cpu_dai : rtd->codec_dai; @@ -107,10 +107,10 @@ static int rsrc_card_dai_init(struct snd_soc_pcm_runtime *rtd) return asoc_simple_card_init_dai(dai, dai_props); }
-static int rsrc_card_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, +static int asoc_simple_card_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params) { - struct rsrc_card_priv *priv = snd_soc_card_get_drvdata(rtd->card); + struct asoc_simple_card_priv *priv = snd_soc_card_get_drvdata(rtd->card); struct snd_interval *rate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); struct snd_interval *channels = hw_param_interval(params, @@ -127,13 +127,13 @@ static int rsrc_card_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, return 0; }
-static int rsrc_card_parse_links(struct device_node *np, - struct rsrc_card_priv *priv, +static int asoc_simple_card_parse_links(struct device_node *np, + struct asoc_simple_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 asoc_simple_dai *dai_props = rsrc_priv_to_props(priv, idx); + struct device *dev = simple_priv_to_dev(priv); + struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, idx); + struct asoc_simple_dai *dai_props = simple_priv_to_props(priv, idx); int is_single_links = 0; int ret;
@@ -157,7 +157,7 @@ static int rsrc_card_parse_links(struct device_node *np, return ret;
} else { - const struct rsrc_card_of_data *of_data; + const struct asoc_simple_card_of_data *of_data;
of_data = of_device_get_match_data(dev);
@@ -168,7 +168,7 @@ static int rsrc_card_parse_links(struct device_node *np,
/* BE settings */ dai_link->no_pcm = 1; - dai_link->be_hw_params_fixup = rsrc_card_be_hw_params_fixup; + dai_link->be_hw_params_fixup = asoc_simple_card_be_hw_params_fixup;
ret = asoc_simple_card_parse_codec(np, dai_link, DAI, CELL); if (ret < 0) @@ -205,8 +205,8 @@ static int rsrc_card_parse_links(struct device_node *np,
dai_link->dpcm_playback = 1; dai_link->dpcm_capture = 1; - dai_link->ops = &rsrc_card_ops; - dai_link->init = rsrc_card_dai_init; + dai_link->ops = &asoc_simple_card_ops; + dai_link->init = asoc_simple_card_dai_init;
dev_dbg(dev, "\t%s / %04x / %d\n", dai_link->name, @@ -221,10 +221,10 @@ static int rsrc_card_parse_links(struct device_node *np, return 0; }
-static int rsrc_card_dai_link_of(struct device_node *node, - struct rsrc_card_priv *priv) +static int asoc_simple_card_dai_link_of(struct device_node *node, + struct asoc_simple_card_priv *priv) { - struct device *dev = rsrc_priv_to_dev(priv); + struct device *dev = simple_priv_to_dev(priv); struct snd_soc_dai_link *dai_link; struct device_node *np; unsigned int daifmt = 0; @@ -234,7 +234,7 @@ static int rsrc_card_dai_link_of(struct device_node *node, /* find 1st codec */ i = 0; for_each_child_of_node(node, np) { - dai_link = rsrc_priv_to_link(priv, i); + dai_link = simple_priv_to_link(priv, i);
if (strcmp(np->name, "codec") == 0) { ret = asoc_simple_card_parse_daifmt(dev, node, np, @@ -248,14 +248,14 @@ static int rsrc_card_dai_link_of(struct device_node *node,
i = 0; for_each_child_of_node(node, np) { - dai_link = rsrc_priv_to_link(priv, i); + dai_link = simple_priv_to_link(priv, i); dai_link->dai_fmt = daifmt;
is_fe = false; if (strcmp(np->name, "cpu") == 0) is_fe = true;
- ret = rsrc_card_parse_links(np, priv, i, is_fe); + ret = asoc_simple_card_parse_links(np, priv, i, is_fe); if (ret < 0) return ret; i++; @@ -264,11 +264,11 @@ static int rsrc_card_dai_link_of(struct device_node *node, return 0; }
-static int rsrc_card_parse_of(struct device_node *node, - struct rsrc_card_priv *priv, +static int asoc_simple_card_parse_of(struct device_node *node, + struct asoc_simple_card_priv *priv, struct device *dev) { - const struct rsrc_card_of_data *of_data = of_device_get_match_data(dev); + const struct asoc_simple_card_of_data *of_data = of_device_get_match_data(dev); struct asoc_simple_dai *props; struct snd_soc_dai_link *links; int ret; @@ -313,7 +313,7 @@ static int rsrc_card_parse_of(struct device_node *node, dev_dbg(dev, "SRC : convert_rate %d\n", priv->convert_rate); dev_dbg(dev, "CTU : convert_channels %d\n", priv->convert_channels);
- ret = rsrc_card_dai_link_of(node, priv); + ret = asoc_simple_card_dai_link_of(node, priv); if (ret < 0) return ret;
@@ -324,9 +324,9 @@ static int rsrc_card_parse_of(struct device_node *node, return 0; }
-static int rsrc_card_probe(struct platform_device *pdev) +static int asoc_simple_card_probe(struct platform_device *pdev) { - struct rsrc_card_priv *priv; + struct asoc_simple_card_priv *priv; struct device_node *np = pdev->dev.of_node; struct device *dev = &pdev->dev; int ret; @@ -336,7 +336,7 @@ static int rsrc_card_probe(struct platform_device *pdev) if (!priv) return -ENOMEM;
- ret = rsrc_card_parse_of(np, priv, dev); + ret = asoc_simple_card_parse_of(np, priv, dev); if (ret < 0) { if (ret != -EPROBE_DEFER) dev_err(dev, "parse error %d\n", ret); @@ -354,25 +354,25 @@ err: return ret; }
-static int rsrc_card_remove(struct platform_device *pdev) +static int asoc_simple_card_remove(struct platform_device *pdev) { struct snd_soc_card *card = platform_get_drvdata(pdev);
return asoc_simple_card_clean_reference(card); }
-static struct platform_driver rsrc_card = { +static struct platform_driver asoc_simple_card = { .driver = { .name = "renesas-src-audio-card", - .of_match_table = rsrc_card_of_match, + .of_match_table = asoc_simple_card_of_match, }, - .probe = rsrc_card_probe, - .remove = rsrc_card_remove, + .probe = asoc_simple_card_probe, + .remove = asoc_simple_card_remove, };
-module_platform_driver(rsrc_card); +module_platform_driver(asoc_simple_card);
-MODULE_ALIAS("platform:renesas-src-audio-card"); +MODULE_ALIAS("platform:asoc-simple-dpcm-card"); MODULE_LICENSE("GPL"); -MODULE_DESCRIPTION("Renesas Sampling Rate Convert Sound Card"); +MODULE_DESCRIPTION("ASoC Simple DPCM Sound Card"); MODULE_AUTHOR("Kuninori Morimoto kuninori.morimoto.gx@renesas.com");
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
rsrc-card which is using DPCM feature was created for Renesas sound. But not only Renesas, but many SoC can use this driver, because it is based on simple-card driver. To use it as more open driver, rsrc-card should be renamed to simple-dpcm-card. In order to easy patch review, as 2nd step, this patch renames compatible from "renesas,rsrc-car" to "simple-dpcm-audio-card";
rcar-card used specific property, not "simple-audio-card", but it should be now. Actually, rsrc-card is upstreamed driver, but noone is using it on upstream. The user is only local, and it is only me. Thus, there is no compatible break by this patch. This patch uses "simple-audio-card" prefix. And it removes rcar-card specifix compatible too.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- .../bindings/sound/renesas,rsrc-card.txt | 56 +++++++++-------- sound/soc/sh/rcar/rsrc-card.c | 71 +++++++--------------- 2 files changed, 52 insertions(+), 75 deletions(-)
diff --git a/Documentation/devicetree/bindings/sound/renesas,rsrc-card.txt b/Documentation/devicetree/bindings/sound/renesas,rsrc-card.txt index 255ece3..cfdf441 100644 --- a/Documentation/devicetree/bindings/sound/renesas,rsrc-card.txt +++ b/Documentation/devicetree/bindings/sound/renesas,rsrc-card.txt @@ -1,38 +1,35 @@ -Renesas Sampling Rate Convert Sound Card: +ASoC simple DPCM Sound Card
-Renesas Sampling Rate Convert Sound Card specifies audio DAI connections of SoC <-> codec. +Simple-Card specifies audio DAI connections of SoC <-> codec.
Required properties:
-- compatible : "renesas,rsrc-card{,<board>}" - Examples with boards are: - - "renesas,rsrc-card" - - "renesas,rsrc-card,lager" - - "renesas,rsrc-card,koelsch" +- compatible : "simple-dpcm-audio-card" + Optional properties:
-- card_name : User specified audio sound card name, one string +- simple-audio-card,name : User specified audio sound card name, one string property. -- cpu : CPU sub-node -- codec : CODEC sub-node +- simple-audio-card,cpu : CPU sub-node +- simple-audio-card,codec : CODEC sub-node
Optional subnode properties:
-- format : CPU/CODEC common audio format. +- simple-audio-card,format : CPU/CODEC common audio format. "i2s", "right_j", "left_j" , "dsp_a" "dsp_b", "ac97", "pdm", "msb", "lsb" -- frame-master : Indicates dai-link frame master. +- simple-audio-card,frame-master : Indicates dai-link frame master. phandle to a cpu or codec subnode. -- bitclock-master : Indicates dai-link bit clock master. +- simple-audio-card,bitclock-master : Indicates dai-link bit clock master. phandle to a cpu or codec subnode. -- bitclock-inversion : bool property. Add this if the +- simple-audio-card,bitclock-inversion : bool property. Add this if the dai-link uses bit clock inversion. -- frame-inversion : bool property. Add this if the +- simple-audio-card,frame-inversion : bool property. Add this if the dai-link uses frame clock inversion. -- convert-rate : platform specified sampling rate convert -- convert-channels : platform specified converted channel size (2 - 8 ch) -- audio-prefix : see audio-routing -- audio-routing : A list of the connections between audio components. +- simple-audio-card,convert-rate : platform specified sampling rate convert +- simple-audio-card,convert-channels : platform specified converted channel size (2 - 8 ch) +- simple-audio-card,prefix : see audio-routing +- simple-audio-card,routing : A list of the connections between audio components. Each entry is a pair of strings, the first being the connection's sink, the second being the connection's source. Valid names for sources. use audio-prefix if some components is using same sink/sources naming. @@ -57,18 +54,25 @@ Optional CPU/CODEC subnodes properties: Example
sound { - compatible = "renesas,rsrc-card,lager"; + compatible = "simple-dpcm-audio-card"; + + simple-audio-card,name = "rsnd-ak4643"; + simple-audio-card,format = "left_j"; + simple-audio-card,format = "left_j"; + simple-audio-card,bitclock-master = <&sndcodec>; + simple-audio-card,frame-master = <&sndcodec>; + + simple-audio-card,convert-rate = <48000>; /* see audio_clk_a */
- card-name = "rsnd-ak4643"; - format = "left_j"; - bitclock-master = <&sndcodec>; - frame-master = <&sndcodec>; + simple-audio-card,prefix = "ak4642"; + simple-audio-card,routing = "ak4642 Playback", "DAI0 Playback", + "DAI0 Capture", "ak4642 Capture";
- sndcpu: cpu { + sndcpu: simple-audio-card,cpu { sound-dai = <&rcar_sound>; };
- sndcodec: codec { + sndcodec: simple-audio-card,codec { sound-dai = <&ak4643>; system-clock-frequency = <11289600>; }; diff --git a/sound/soc/sh/rcar/rsrc-card.c b/sound/soc/sh/rcar/rsrc-card.c index e409b46..cef7ff5 100644 --- a/sound/soc/sh/rcar/rsrc-card.c +++ b/sound/soc/sh/rcar/rsrc-card.c @@ -28,21 +28,8 @@ struct asoc_simple_card_of_data { int num_routes; };
-static const struct snd_soc_dapm_route routes_ssi0_ak4642[] = { - {"ak4642 Playback", NULL, "DAI0 Playback"}, - {"DAI0 Capture", NULL, "ak4642 Capture"}, -}; - -static const struct asoc_simple_card_of_data routes_of_ssi0_ak4642 = { - .prefix = "ak4642", - .routes = routes_ssi0_ak4642, - .num_routes = ARRAY_SIZE(routes_ssi0_ak4642), -}; - static const struct of_device_id asoc_simple_card_of_match[] = { - { .compatible = "renesas,rsrc-card,lager", .data = &routes_of_ssi0_ak4642 }, - { .compatible = "renesas,rsrc-card,koelsch", .data = &routes_of_ssi0_ak4642 }, - { .compatible = "renesas,rsrc-card", }, + { .compatible = "simple-dpcm-audio-card", }, {}, }; MODULE_DEVICE_TABLE(of, asoc_simple_card_of_match); @@ -64,6 +51,7 @@ struct asoc_simple_card_priv {
#define DAI "sound-dai" #define CELL "#sound-dai-cells" +#define PREFIX "simple-audio-card,"
static int asoc_simple_card_startup(struct snd_pcm_substream *substream) { @@ -157,10 +145,6 @@ static int asoc_simple_card_parse_links(struct device_node *np, return ret;
} else { - const struct asoc_simple_card_of_data *of_data; - - of_data = of_device_get_match_data(dev); - /* FE is dummy */ dai_link->cpu_of_node = NULL; dai_link->cpu_dai_name = "snd-soc-dummy-dai"; @@ -178,17 +162,11 @@ static int asoc_simple_card_parse_links(struct device_node *np, if (ret < 0) return ret;
- /* additional name prefix */ - if (of_data) { - priv->codec_conf.of_node = dai_link->codec_of_node; - priv->codec_conf.name_prefix = of_data->prefix; - } else { - ret = asoc_simple_card_parse_card_prefix(&priv->snd_card, - dai_link, &priv->codec_conf, - "audio-"); - if (ret < 0) - return ret; - } + ret = asoc_simple_card_parse_card_prefix(&priv->snd_card, + dai_link, &priv->codec_conf, + PREFIX); + if (ret < 0) + return ret; }
ret = asoc_simple_card_parse_tdm(np, dai_props); @@ -236,9 +214,9 @@ static int asoc_simple_card_dai_link_of(struct device_node *node, for_each_child_of_node(node, np) { dai_link = simple_priv_to_link(priv, i);
- if (strcmp(np->name, "codec") == 0) { + if (strcmp(np->name, PREFIX "codec") == 0) { ret = asoc_simple_card_parse_daifmt(dev, node, np, - NULL, &daifmt); + PREFIX, &daifmt); if (ret < 0) return ret; break; @@ -252,7 +230,7 @@ static int asoc_simple_card_dai_link_of(struct device_node *node, dai_link->dai_fmt = daifmt;
is_fe = false; - if (strcmp(np->name, "cpu") == 0) + if (strcmp(np->name, PREFIX "cpu") == 0) is_fe = true;
ret = asoc_simple_card_parse_links(np, priv, i, is_fe); @@ -268,7 +246,6 @@ static int asoc_simple_card_parse_of(struct device_node *node, struct asoc_simple_card_priv *priv, struct device *dev) { - const struct asoc_simple_card_of_data *of_data = of_device_get_match_data(dev); struct asoc_simple_dai *props; struct snd_soc_dai_link *links; int ret; @@ -294,33 +271,29 @@ static int asoc_simple_card_parse_of(struct device_node *node, priv->snd_card.codec_conf = &priv->codec_conf; priv->snd_card.num_configs = 1;
- if (of_data) { - priv->snd_card.of_dapm_routes = of_data->routes; - priv->snd_card.num_of_dapm_routes = of_data->num_routes; - } else { - snd_soc_of_parse_audio_routing(&priv->snd_card, - "audio-routing"); - } + ret = snd_soc_of_parse_audio_routing(&priv->snd_card, PREFIX "routing"); + if (ret < 0) + return ret;
/* sampling rate convert */ - of_property_read_u32(node, "convert-rate", &priv->convert_rate); + of_property_read_u32(node, PREFIX "convert-rate", &priv->convert_rate);
/* channels transfer */ - of_property_read_u32(node, "convert-channels", &priv->convert_channels); - - dev_dbg(dev, "New rsrc-audio-card: %s\n", - priv->snd_card.name ? priv->snd_card.name : ""); - dev_dbg(dev, "SRC : convert_rate %d\n", priv->convert_rate); - dev_dbg(dev, "CTU : convert_channels %d\n", priv->convert_channels); + of_property_read_u32(node, PREFIX "convert-channels", &priv->convert_channels);
ret = asoc_simple_card_dai_link_of(node, priv); if (ret < 0) return ret;
- ret = asoc_simple_card_parse_card_name(&priv->snd_card, "card-"); + ret = asoc_simple_card_parse_card_name(&priv->snd_card, PREFIX); if (ret < 0) return ret;
+ dev_dbg(dev, "New card: %s\n", + priv->snd_card.name ? priv->snd_card.name : ""); + dev_dbg(dev, "convert_rate %d\n", priv->convert_rate); + dev_dbg(dev, "convert_channels %d\n", priv->convert_channels); + return 0; }
@@ -363,7 +336,7 @@ static int asoc_simple_card_remove(struct platform_device *pdev)
static struct platform_driver asoc_simple_card = { .driver = { - .name = "renesas-src-audio-card", + .name = "simple-dpcm-audio-card", .of_match_table = asoc_simple_card_of_match, }, .probe = asoc_simple_card_probe,
rsrc-card which is using DPCM feature was created for Renesas sound. But not only Renesas, but many SoC can use this driver, because it is based on simple-card driver. To use it as more open driver, rsrc-card should be renamed to simple-dpcm-card. In order to easy patch review, as 3rd step, this patch moves rsrc-card driver to generic folder.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- .../bindings/sound/{renesas,rsrc-card.txt => simple-dpcm-card.txt} | 0 sound/soc/generic/Kconfig | 6 ++++++ sound/soc/generic/Makefile | 2 ++ sound/soc/{sh/rcar/rsrc-card.c => generic/simple-dpcm-card.c} | 0 sound/soc/sh/Kconfig | 6 ------ sound/soc/sh/rcar/Makefile | 3 --- 6 files changed, 8 insertions(+), 9 deletions(-) rename Documentation/devicetree/bindings/sound/{renesas,rsrc-card.txt => simple-dpcm-card.txt} (100%) rename sound/soc/{sh/rcar/rsrc-card.c => generic/simple-dpcm-card.c} (100%)
diff --git a/Documentation/devicetree/bindings/sound/renesas,rsrc-card.txt b/Documentation/devicetree/bindings/sound/simple-dpcm-card.txt similarity index 100% rename from Documentation/devicetree/bindings/sound/renesas,rsrc-card.txt rename to Documentation/devicetree/bindings/sound/simple-dpcm-card.txt diff --git a/sound/soc/generic/Kconfig b/sound/soc/generic/Kconfig index c01c5dd..bb35494 100644 --- a/sound/soc/generic/Kconfig +++ b/sound/soc/generic/Kconfig @@ -6,3 +6,9 @@ config SND_SIMPLE_CARD select SND_SIMPLE_CARD_UTILS help This option enables generic simple sound card support + +config SND_SIMPLE_DPCM_CARD + tristate "ASoC Simple DPCM sound card support" + select SND_SIMPLE_CARD_UTILS + help + This option enables generic simple DPCM sound card support diff --git a/sound/soc/generic/Makefile b/sound/soc/generic/Makefile index 45602ca..b82640a 100644 --- a/sound/soc/generic/Makefile +++ b/sound/soc/generic/Makefile @@ -1,5 +1,7 @@ obj-$(CONFIG_SND_SIMPLE_CARD_UTILS) := simple-card-utils.o
snd-soc-simple-card-objs := simple-card.o +snd-soc-simple-dpcm-card-objs := simple-dpcm-card.o
obj-$(CONFIG_SND_SIMPLE_CARD) += snd-soc-simple-card.o +obj-$(CONFIG_SND_SIMPLE_DPCM_CARD) += snd-soc-simple-dpcm-card.o diff --git a/sound/soc/sh/rcar/rsrc-card.c b/sound/soc/generic/simple-dpcm-card.c similarity index 100% rename from sound/soc/sh/rcar/rsrc-card.c rename to sound/soc/generic/simple-dpcm-card.c diff --git a/sound/soc/sh/Kconfig b/sound/soc/sh/Kconfig index 9311f11..6db6405 100644 --- a/sound/soc/sh/Kconfig +++ b/sound/soc/sh/Kconfig @@ -42,12 +42,6 @@ config SND_SOC_RCAR help This option enables R-Car SRU/SCU/SSIU/SSI sound support
-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 - ## ## Boards ## diff --git a/sound/soc/sh/rcar/Makefile b/sound/soc/sh/rcar/Makefile index a89ddf7..9c3d5ae 100644 --- a/sound/soc/sh/rcar/Makefile +++ b/sound/soc/sh/rcar/Makefile @@ -1,5 +1,2 @@ snd-soc-rcar-objs := core.o gen.o dma.o adg.o ssi.o ssiu.o src.o ctu.o mix.o dvc.o cmd.o obj-$(CONFIG_SND_SOC_RCAR) += snd-soc-rcar.o - -snd-soc-rsrc-card-objs := rsrc-card.o -obj-$(CONFIG_SND_SOC_RSRC_CARD) += snd-soc-rsrc-card.o
Hi Mark
I know you are Mr busy man, but do you have plan to review this patch-set ? Should I re-send these ?
These are v2 of simple-card cleanup patches.
Main purpose of these patches are
- cleanup simple-card
- rename rsrc-card to simple-dpcm-card
Main diff v1 <-> v2 are
- remove duplicate header patch
- rename simple-card-core.c -> simple-card-utils.c
- remove dpcm function from simple-card-utils.
- remove jack/pin/gpio/ function from simple-card-utils.
- remove widgets/route function from simple-card-utils.
I removed widgets/routing related function. it was very thin cosmetic functions. About jack/pin/gpio on simple-card, it is still have same method, but keeping it as static function. dpcm related function too, it is keeping static.
- cleaup patch as prepare
- simple-card-utils
- simple-card
- rsrc-card
- rsrc-card -> simple-dpcm-card
Kuninori Morimoto (39): 1) ASoC: rsrc-card: remove unused dai_num 2) ASoC: simple-card: use common PREFIX for each DT property 3) ASoC: simple-card: add new asoc_simple_jack and use it 4) ASoC: add new simple-card-utils.c 5) ASoC: simple-card-utils: add asoc_simple_card_parse_tdm() 6) ASoC: simple-card-utils: add asoc_simple_card_parse_dailink_name() 7) ASoC: simple-card-utils: add asoc_simple_card_parse_card_name() 8) ASoC: simple-card-utils: add asoc_simple_card_parse_card_prefix() 9) ASoC: simple-card-utils: add asoc_simple_card_parse_clk() 10) ASoC: simple-card-utils: add asoc_simple_card_parse_endpoint() 11) ASoC: simple-card-utils: add asoc_simple_card_init_dai() 12) ASoC: simple-card-utils: add asoc_simple_card_canonicalize_dailink() 13) ASoC: simple-card-utils: add asoc_simple_card_canonicalize_cpu() 14) ASoC: simple-card-utils: add asoc_simple_card_clean_reference() 15) ASoC: simple-card: use asoc_simple_card_parse_daifmt() 16) ASoC: simple-card: use asoc_simple_card_parse_clk() 17) ASoC: simple-card: use asoc_simple_card_parse_endpoint() 18) ASoC: simple-card: use asoc_simple_card_parse_tdm() 19) ASoC: simple-card: use asoc_simple_card_parse_card_name() 20) ASoC: simple-card: use asoc_simple_card_parse_dailink_name() 21) ASoC: simple-card: use asoc_simple_card_init_dai() 22) ASoC: simple-card: use asoc_simple_card_canonicalize_dailink() 23) ASoC: simple-card: use asoc_simple_card_canonicalize_cpu() 24) ASoC: simple-card: use asoc_simple_card_clean_reference() 25) ASoC: rsrc-card: use asoc_simple_card_parse_daifmt() 26) ASoC: rsrc-card: use asoc_simple_card_parse_dailink_name() 27) ASoC: rsrc-card: use asoc_simple_dai instead of rsrc_card_dai 28) ASoC: rsrc-card: use asoc_simple_card_parse_clk() 29) ASoC: rsrc-card: use asoc_simple_card_parse_endpoint() 30) ASoC: rsrc-card: use asoc_simple_card_parse_card_name() 31) ASoC: rsrc-card: use asoc_simple_card_parse_card_prefix() 32) ASoC: rsrc-card: use asoc_simple_card_parse_tdm() 33) ASoC: rsrc-card: use asoc_simple_card_init_dai() 34) ASoC: rsrc-card: use asoc_simple_card_canonicalize_cpu() 35) ASoC: rsrc-card: use asoc_simple_card_canonicalize_dailink() 36) ASoC: rsrc-card: use asoc_simple_card_clean_reference() 37) ASoC: rsrc-card: rename rsrc-card to simple-dpcm-card phase1 38) ASoC: rsrc-card: rename rsrc-card to simple-dpcm-card phase2 39) ASoC: rsrc-card: rename rsrc-card to simple-dpcm-card phase3
Documentation/devicetree/bindings/sound/renesas,rsrc-card.txt | 75 -------------- Documentation/devicetree/bindings/sound/simple-dpcm-card.txt | 79 +++++++++++++++ include/sound/simple_card.h | 11 +-- include/sound/simple_card_utils.h | 77 +++++++++++++++ sound/soc/generic/Kconfig | 10 ++ sound/soc/generic/Makefile | 4 + sound/soc/generic/simple-card-utils.c | 288 +++++++++++++++++++++++++++++++++++++++++++++++++++++ sound/soc/generic/simple-card.c | 424 ++++++++++++++++++++++++------------------------------------------------------ sound/soc/generic/simple-dpcm-card.c | 351 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ sound/soc/sh/Kconfig | 5 - sound/soc/sh/rcar/Makefile | 3 - sound/soc/sh/rcar/rsrc-card.c | 529 -------------------------------------------------------------------------------------------------- 12 files changed, 937 insertions(+), 919 deletions(-)
On Tue, May 31, 2016 at 08:56:55AM +0000, Kuninori Morimoto wrote:
Hi Mark
These are v2 of simple-card cleanup patches.
I've said this a few times before but *please* try to make these patch serieses smaller. A 20 patch series is a large patch series, this is twice that size...
Hi Mark
These are v2 of simple-card cleanup patches.
I've said this a few times before but *please* try to make these patch serieses smaller. A 20 patch series is a large patch series, this is twice that size...
I'm sorry, this was from my misunderstanding. v3 will be more small patch-set.
participants (2)
-
Kuninori Morimoto
-
Mark Brown