ASoC: audio-graph-card: support external amplifier with DAPM widget
Subsystems (4)
cover ASoC: audio-graph-card: support external amplifier with DAPM widget
From: Shawn Guo <[email protected]>
It's basically the result of discussion around how external amplifier controlled by GPIO should be supported by audio card, that uses generic machine driver like audio-graph-card.
The patch series updates audio-graph-card bindings and driver to support DAPM widget and audio routing, and then based on that, creates an output driver widget with event to control the amplifier via GPIO.
[1] https://www.spinics.net/lists/arm-kernel/msg589717.html
Shawn Guo (2):
ASoC: audio-graph-card: update bindings for amplifier support
ASoC: audio-graph-card: add widgets and routing for external amplifier
support
.../devicetree/bindings/sound/audio-graph-card.txt | 5 +++ sound/soc/generic/audio-graph-card.c | 48 +++++++++++++++++++++- 2 files changed, 52 insertions(+), 1 deletion(-)
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 1/2 ASoC: audio-graph-card: update bindings for amplifier support
In reply to a message not in the archiveFrom: Shawn Guo <[email protected]>
The audio-graph-card should be able to support widgets and routing in the same way as what simple-audio-card does. The patch adds the properties into audio-graph-card bindings. Then an optional property 'pa-gpios' for controlling external amplifier, which depends on DAPM widgets and routing, is added.
--- Documentation/devicetree/bindings/sound/audio-graph-card.txt | 5 +++++ 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/sound/audio-graph-card.txt +5 -0
@@ -10,6 +10,8 @@ see ${LINUX}/Documentation/devicetree/bindings/sound/simple-card.txt Below are same as Simple-Card. - label +- widgets +- routing - dai-format - frame-master - bitclock-master
@@ -24,6 +26,9 @@ Required properties: - compatible : "audio-graph-card"; - dais : list of CPU DAI port{s} +Optional properties: +- pa-gpios: GPIO used to control external amplifier. + Example: Single DAI case sound_card {
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 2/2 ASoC: audio-graph-card: add widgets and routing for external amplifier support
In reply to a message not in the archiveFrom: Shawn Guo <[email protected]>
It's very common that audio card has a machine level amplifier which is controlled by GPIO. The patch adds DAPM widgets and routing support into audio-graph-card driver, and creates an output driver widget with event to control the amplifier via GPIO.
--- sound/soc/generic/audio-graph-card.c | 48 +++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-)
sound/soc/generic/audio-graph-card.c +47 -1
@@ -13,6 +13,7 @@#include <linux/clk.h> #include <linux/device.h> #include <linux/gpio.h> +#include <linux/gpio/consumer.h> #include <linux/module.h> #include <linux/of.h> #include <linux/of_device.h>
@@ -30,6 +31,34 @@ struct graph_card_data {struct asoc_simple_dai codec_dai; } *dai_props;struct snd_soc_dai_link *dai_link; +struct gpio_desc *pa_gpio; +}; + +static int asoc_graph_card_outdrv_event (struct snd_soc_dapm_widget *w, +struct snd_kcontrol *kcontrol, +int event) +{ +struct snd_soc_dapm_context *dapm = w->dapm; +struct graph_card_data *priv =snd_soc_card_get_drvdata (dapm->card); + +switch (event) { +case SND_SOC_DAPM_POST_PMU : +gpiod_set_value_cansleep (priv->pa_gpio,1 ); +break ; +case SND_SOC_DAPM_PRE_PMD : +gpiod_set_value_cansleep (priv->pa_gpio,0 ); +break ; +default : +return -EINVAL ; + } + +return 0 ; +} + +static const struct snd_soc_dapm_widget asoc_graph_card_dapm_widgets[] = { +SND_SOC_DAPM_OUT_DRV_E ("Amplifier" ,SND_SOC_NOPM , +0 ,0 ,NULL ,0 , asoc_graph_card_outdrv_event, +SND_SOC_DAPM_POST_PMU |SND_SOC_DAPM_PRE_PMD ), };#define graph_priv_to_card (priv) (&(priv)->snd_card)
@@ -181,8 +210,16 @@ static int asoc_graph_card_parse_of(struct graph_card_data *priv)int rc, idx =0 ;int ret; + ret =asoc_simple_card_of_parse_widgets (card,NULL ); +if (ret <0 ) +return ret; + + ret =asoc_simple_card_of_parse_routing (card,NULL ,1 ); +if (ret <0 ) +return ret; +/* -* we need to consider "widgets", "routing", "mclk-fs" around here +* we need to consider "mclk-fs" around here * see simple-card */
@@ -234,6 +271,13 @@ static int asoc_graph_card_probe(struct platform_device *pdev)if (!dai_props || !dai_link)return -ENOMEM ; + priv->pa_gpio =devm_gpiod_get_optional (dev,"pa" ,GPIOD_OUT_LOW ); +if (IS_ERR (priv->pa_gpio)) { + ret =PTR_ERR (priv->pa_gpio); +dev_err (dev,"failed to get amplifier gpio: %d\n" , ret); +return ret; + } + priv->dai_props = dai_props; priv->dai_link = dai_link;
@@ -243,6 +287,8 @@ static int asoc_graph_card_probe(struct platform_device *pdev) card->dev = dev; card->dai_link = dai_link; card->num_links = num; + card->dapm_widgets = asoc_graph_card_dapm_widgets; + card->num_dapm_widgets =ARRAY_SIZE (asoc_graph_card_dapm_widgets); ret =asoc_graph_card_parse_of (priv);if (ret <0 ) {
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Kuninori Morimoto
Acked-byRe: [PATCH 2/2] ASoC: audio-graph-card: add widgets and routing for external amplifier support
In reply to a message not in the archiveHi Shawn
Quoted 9 lines
From: Shawn Guo <[email protected]>
It's very common that audio card has a machine level amplifier which is controlled by GPIO. The patch adds DAPM widgets and routing support into audio-graph-card driver, and creates an output driver widget with event to control the amplifier via GPIO.
Signed-off-by Shawn Guo <[email protected]>---
Thank you for your patch.
I think patch adds 3 features (= widget/routing/gpio) in 1 patch. widget/routing features are already supported in -utils,
so, break down this patch into "widget/routing" patch, and "gpio" patch is easy to understand, IMO.
Not a big deal though
Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Mark Brown
maintainerApplied "ASoC: audio-graph-card: add widgets and routing for external amplifier support" to the asoc tree
In reply to Shawn GuoThe patch
ASoC: audio-graph-card: add widgets and routing for external amplifier support
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
Quoted 1 line
From
f986907c9225cf48e9a55233b086039152bb5b99Mon Sep 17 00:00:00 2001
From: Shawn Guo <[email protected]>
Date: Thu, 29 Jun 2017 21:26:38 +0800
Subject: [PATCH] ASoC: audio-graph-card: add widgets and routing for external
amplifier support
It's very common that audio card has a machine level amplifier which is controlled by GPIO. The patch adds DAPM widgets and routing support into audio-graph-card driver, and creates an output driver widget with event to control the amplifier via GPIO.
--- sound/soc/generic/audio-graph-card.c | 48 +++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-)
sound/soc/generic/audio-graph-card.c +47 -1
@@ -13,6 +13,7 @@#include <linux/clk.h> #include <linux/device.h> #include <linux/gpio.h> +#include <linux/gpio/consumer.h> #include <linux/module.h> #include <linux/of.h> #include <linux/of_device.h>
@@ -30,6 +31,34 @@ struct graph_card_data {struct asoc_simple_dai codec_dai; } *dai_props;struct snd_soc_dai_link *dai_link; +struct gpio_desc *pa_gpio; +}; + +static int asoc_graph_card_outdrv_event (struct snd_soc_dapm_widget *w, +struct snd_kcontrol *kcontrol, +int event) +{ +struct snd_soc_dapm_context *dapm = w->dapm; +struct graph_card_data *priv =snd_soc_card_get_drvdata (dapm->card); + +switch (event) { +case SND_SOC_DAPM_POST_PMU : +gpiod_set_value_cansleep (priv->pa_gpio,1 ); +break ; +case SND_SOC_DAPM_PRE_PMD : +gpiod_set_value_cansleep (priv->pa_gpio,0 ); +break ; +default : +return -EINVAL ; + } + +return 0 ; +} + +static const struct snd_soc_dapm_widget asoc_graph_card_dapm_widgets[] = { +SND_SOC_DAPM_OUT_DRV_E ("Amplifier" ,SND_SOC_NOPM , +0 ,0 ,NULL ,0 , asoc_graph_card_outdrv_event, +SND_SOC_DAPM_POST_PMU |SND_SOC_DAPM_PRE_PMD ), };#define graph_priv_to_card (priv) (&(priv)->snd_card)
@@ -180,8 +209,16 @@ static int asoc_graph_card_parse_of(struct graph_card_data *priv)int rc, idx =0 ;int ret; + ret =asoc_simple_card_of_parse_widgets (card,NULL ); +if (ret <0 ) +return ret; + + ret =asoc_simple_card_of_parse_routing (card,NULL ,1 ); +if (ret <0 ) +return ret; +/* -* we need to consider "widgets", "routing", "mclk-fs" around here +* we need to consider "mclk-fs" around here * see simple-card */
@@ -233,6 +270,13 @@ static int asoc_graph_card_probe(struct platform_device *pdev)if (!dai_props || !dai_link)return -ENOMEM ; + priv->pa_gpio =devm_gpiod_get_optional (dev,"pa" ,GPIOD_OUT_LOW ); +if (IS_ERR (priv->pa_gpio)) { + ret =PTR_ERR (priv->pa_gpio); +dev_err (dev,"failed to get amplifier gpio: %d\n" , ret); +return ret; + } + priv->dai_props = dai_props; priv->dai_link = dai_link;
@@ -242,6 +286,8 @@ static int asoc_graph_card_probe(struct platform_device *pdev) card->dev = dev; card->dai_link = dai_link; card->num_links = num; + card->dapm_widgets = asoc_graph_card_dapm_widgets; + card->num_dapm_widgets =ARRAY_SIZE (asoc_graph_card_dapm_widgets); ret =asoc_graph_card_parse_of (priv);if (ret <0 ) {
Signature · 1 line
2.13.2
Mark Brown
maintainerApplied "ASoC: audio-graph-card: update bindings for amplifier support" to the asoc tree
In reply to Shawn GuoThe patch
ASoC: audio-graph-card: update bindings for amplifier support
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
Quoted 1 line
From
a0c683d734e0b3589892c17d0e1187f20d2c3a54Mon Sep 17 00:00:00 2001
From: Shawn Guo <[email protected]>
Date: Thu, 29 Jun 2017 21:26:37 +0800
Subject: [PATCH] ASoC: audio-graph-card: update bindings for amplifier support
The audio-graph-card should be able to support widgets and routing in the same way as what simple-audio-card does. The patch adds the properties into audio-graph-card bindings. Then an optional property 'pa-gpios' for controlling external amplifier, which depends on DAPM widgets and routing, is added.
--- Documentation/devicetree/bindings/sound/audio-graph-card.txt | 5 +++++ 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/sound/audio-graph-card.txt +5 -0
@@ -10,6 +10,8 @@ see ${LINUX}/Documentation/devicetree/bindings/sound/simple-card.txt Below are same as Simple-Card. - label +- widgets +- routing - dai-format - frame-master - bitclock-master
@@ -24,6 +26,9 @@ Required properties: - compatible : "audio-graph-card"; - dais : list of CPU DAI port{s} +Optional properties: +- pa-gpios: GPIO used to control external amplifier. + Example: Single DAI case sound_card {
Signature · 1 line
2.13.2