ASoC: simple-amplifier: rename dio2125 to simple-amplifer
authorJerome Brunet <jbrunet@baylibre.com>
Tue, 26 Jun 2018 12:11:27 +0000 (14:11 +0200)
committerMark Brown <broonie@kernel.org>
Wed, 27 Jun 2018 11:26:38 +0000 (12:26 +0100)
The dio2125 is simple enough that we can make it a generic component.
Just rename and sed the dio2125 amplifier driver to simple_amplifier.

Suggested-by: Nicolò Veronese <nicveronese@gmail.com>
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/Kconfig
sound/soc/codecs/Makefile
sound/soc/codecs/dio2125.c [deleted file]
sound/soc/codecs/simple-amplifier.c [new file with mode: 0644]

index f6b8d4b..53c2d72 100644 (file)
@@ -74,7 +74,6 @@ config SND_SOC_ALL_CODECS
        select SND_SOC_DA7219 if I2C
        select SND_SOC_DA732X if I2C
        select SND_SOC_DA9055 if I2C
-       select SND_SOC_DIO2125
        select SND_SOC_DMIC if GPIOLIB
        select SND_SOC_ES8316 if I2C
        select SND_SOC_ES8328_SPI if SPI_MASTER
@@ -144,6 +143,7 @@ config SND_SOC_ALL_CODECS
        select SND_SOC_RT5682 if I2C
        select SND_SOC_SGTL5000 if I2C
        select SND_SOC_SI476X if MFD_SI476X_CORE
+       select SND_SOC_SIMPLE_AMPLIFIER
        select SND_SOC_SIRF_AUDIO_CODEC
        select SND_SOC_SPDIF
        select SND_SOC_SSM2305
@@ -573,10 +573,6 @@ config SND_SOC_DA732X
 config SND_SOC_DA9055
        tristate
 
-config SND_SOC_DIO2125
-       tristate "Dioo DIO2125 Amplifier"
-       select GPIOLIB
-
 config SND_SOC_DMIC
        tristate
 
@@ -897,6 +893,10 @@ config SND_SOC_SIGMADSP_REGMAP
        tristate
        select SND_SOC_SIGMADSP
 
+config SND_SOC_SIMPLE_AMPLIFIER
+       tristate "Simple Audio Amplifier"
+       select GPIOLIB
+
 config SND_SOC_SIRF_AUDIO_CODEC
        tristate "SiRF SoC internal audio codec"
        select REGMAP_MMIO
index e43d99a..f26ded8 100644 (file)
@@ -250,9 +250,9 @@ snd-soc-wm9713-objs := wm9713.o
 snd-soc-wm-hubs-objs := wm_hubs.o
 snd-soc-zx-aud96p22-objs := zx_aud96p22.o
 # Amp
-snd-soc-dio2125-objs := dio2125.o
 snd-soc-max9877-objs := max9877.o
 snd-soc-max98504-objs := max98504.o
+snd-soc-simple-amplifier-objs := simple-amplifier.o
 snd-soc-tpa6130a2-objs := tpa6130a2.o
 snd-soc-tas2552-objs := tas2552.o
 
@@ -509,7 +509,7 @@ obj-$(CONFIG_SND_SOC_WM_HUBS)       += snd-soc-wm-hubs.o
 obj-$(CONFIG_SND_SOC_ZX_AUD96P22) += snd-soc-zx-aud96p22.o
 
 # Amp
-obj-$(CONFIG_SND_SOC_DIO2125)  += snd-soc-dio2125.o
 obj-$(CONFIG_SND_SOC_MAX9877)  += snd-soc-max9877.o
 obj-$(CONFIG_SND_SOC_MAX98504) += snd-soc-max98504.o
+obj-$(CONFIG_SND_SOC_SIMPLE_AMPLIFIER) += snd-soc-simple-amplifier.o
 obj-$(CONFIG_SND_SOC_TPA6130A2)        += snd-soc-tpa6130a2.o
diff --git a/sound/soc/codecs/dio2125.c b/sound/soc/codecs/dio2125.c
deleted file mode 100644 (file)
index 09451cd..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (c) 2017 BayLibre, SAS.
- * Author: Jerome Brunet <jbrunet@baylibre.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- * The full GNU General Public License is included in this distribution
- * in the file called COPYING.
- */
-
-#include <linux/gpio/consumer.h>
-#include <linux/module.h>
-#include <sound/soc.h>
-
-#define DRV_NAME "dio2125"
-
-struct dio2125 {
-       struct gpio_desc *gpiod_enable;
-};
-
-static int drv_event(struct snd_soc_dapm_widget *w,
-                    struct snd_kcontrol *control, int event)
-{
-       struct snd_soc_component *c = snd_soc_dapm_to_component(w->dapm);
-       struct dio2125 *priv = snd_soc_component_get_drvdata(c);
-       int val;
-
-       switch (event) {
-       case SND_SOC_DAPM_POST_PMU:
-               val = 1;
-               break;
-       case SND_SOC_DAPM_PRE_PMD:
-               val = 0;
-               break;
-       default:
-               WARN(1, "Unexpected event");
-               return -EINVAL;
-       }
-
-       gpiod_set_value_cansleep(priv->gpiod_enable, val);
-
-       return 0;
-}
-
-static const struct snd_soc_dapm_widget dio2125_dapm_widgets[] = {
-       SND_SOC_DAPM_INPUT("INL"),
-       SND_SOC_DAPM_INPUT("INR"),
-       SND_SOC_DAPM_OUT_DRV_E("DRV", SND_SOC_NOPM, 0, 0, NULL, 0, drv_event,
-                              (SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD)),
-       SND_SOC_DAPM_OUTPUT("OUTL"),
-       SND_SOC_DAPM_OUTPUT("OUTR"),
-};
-
-static const struct snd_soc_dapm_route dio2125_dapm_routes[] = {
-       { "DRV", NULL, "INL" },
-       { "DRV", NULL, "INR" },
-       { "OUTL", NULL, "DRV" },
-       { "OUTR", NULL, "DRV" },
-};
-
-static const struct snd_soc_component_driver dio2125_component_driver = {
-       .dapm_widgets           = dio2125_dapm_widgets,
-       .num_dapm_widgets       = ARRAY_SIZE(dio2125_dapm_widgets),
-       .dapm_routes            = dio2125_dapm_routes,
-       .num_dapm_routes        = ARRAY_SIZE(dio2125_dapm_routes),
-};
-
-static int dio2125_probe(struct platform_device *pdev)
-{
-       struct device *dev = &pdev->dev;
-       struct dio2125 *priv;
-       int err;
-
-       priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
-       if (priv == NULL)
-               return -ENOMEM;
-       platform_set_drvdata(pdev, priv);
-
-       priv->gpiod_enable = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW);
-       if (IS_ERR(priv->gpiod_enable)) {
-               err = PTR_ERR(priv->gpiod_enable);
-               if (err != -EPROBE_DEFER)
-                       dev_err(dev, "Failed to get 'enable' gpio: %d", err);
-               return err;
-       }
-
-       return devm_snd_soc_register_component(dev, &dio2125_component_driver,
-                                              NULL, 0);
-}
-
-#ifdef CONFIG_OF
-static const struct of_device_id dio2125_ids[] = {
-       { .compatible = "dioo,dio2125", },
-       { }
-};
-MODULE_DEVICE_TABLE(of, dio2125_ids);
-#endif
-
-static struct platform_driver dio2125_driver = {
-       .driver = {
-               .name = DRV_NAME,
-               .of_match_table = of_match_ptr(dio2125_ids),
-       },
-       .probe = dio2125_probe,
-};
-
-module_platform_driver(dio2125_driver);
-
-MODULE_DESCRIPTION("ASoC DIO2125 output driver");
-MODULE_AUTHOR("Jerome Brunet <jbrunet@baylibre.com>");
-MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/simple-amplifier.c b/sound/soc/codecs/simple-amplifier.c
new file mode 100644 (file)
index 0000000..6c27d4a
--- /dev/null
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2017 BayLibre, SAS.
+ * Author: Jerome Brunet <jbrunet@baylibre.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ * The full GNU General Public License is included in this distribution
+ * in the file called COPYING.
+ */
+
+#include <linux/gpio/consumer.h>
+#include <linux/module.h>
+#include <sound/soc.h>
+
+#define DRV_NAME "simple-amplifier"
+
+struct simple_amp {
+       struct gpio_desc *gpiod_enable;
+};
+
+static int drv_event(struct snd_soc_dapm_widget *w,
+                    struct snd_kcontrol *control, int event)
+{
+       struct snd_soc_component *c = snd_soc_dapm_to_component(w->dapm);
+       struct simple_amp *priv = snd_soc_component_get_drvdata(c);
+       int val;
+
+       switch (event) {
+       case SND_SOC_DAPM_POST_PMU:
+               val = 1;
+               break;
+       case SND_SOC_DAPM_PRE_PMD:
+               val = 0;
+               break;
+       default:
+               WARN(1, "Unexpected event");
+               return -EINVAL;
+       }
+
+       gpiod_set_value_cansleep(priv->gpiod_enable, val);
+
+       return 0;
+}
+
+static const struct snd_soc_dapm_widget simple_amp_dapm_widgets[] = {
+       SND_SOC_DAPM_INPUT("INL"),
+       SND_SOC_DAPM_INPUT("INR"),
+       SND_SOC_DAPM_OUT_DRV_E("DRV", SND_SOC_NOPM, 0, 0, NULL, 0, drv_event,
+                              (SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD)),
+       SND_SOC_DAPM_OUTPUT("OUTL"),
+       SND_SOC_DAPM_OUTPUT("OUTR"),
+};
+
+static const struct snd_soc_dapm_route simple_amp_dapm_routes[] = {
+       { "DRV", NULL, "INL" },
+       { "DRV", NULL, "INR" },
+       { "OUTL", NULL, "DRV" },
+       { "OUTR", NULL, "DRV" },
+};
+
+static const struct snd_soc_component_driver simple_amp_component_driver = {
+       .dapm_widgets           = simple_amp_dapm_widgets,
+       .num_dapm_widgets       = ARRAY_SIZE(simple_amp_dapm_widgets),
+       .dapm_routes            = simple_amp_dapm_routes,
+       .num_dapm_routes        = ARRAY_SIZE(simple_amp_dapm_routes),
+};
+
+static int simple_amp_probe(struct platform_device *pdev)
+{
+       struct device *dev = &pdev->dev;
+       struct simple_amp *priv;
+       int err;
+
+       priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+       if (priv == NULL)
+               return -ENOMEM;
+       platform_set_drvdata(pdev, priv);
+
+       priv->gpiod_enable = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW);
+       if (IS_ERR(priv->gpiod_enable)) {
+               err = PTR_ERR(priv->gpiod_enable);
+               if (err != -EPROBE_DEFER)
+                       dev_err(dev, "Failed to get 'enable' gpio: %d", err);
+               return err;
+       }
+
+       return devm_snd_soc_register_component(dev,
+                                              &simple_amp_component_driver,
+                                              NULL, 0);
+}
+
+#ifdef CONFIG_OF
+static const struct of_device_id simple_amp_ids[] = {
+       { .compatible = "dioo,dio2125", },
+       { }
+};
+MODULE_DEVICE_TABLE(of, simple_amp_ids);
+#endif
+
+static struct platform_driver simple_amp_driver = {
+       .driver = {
+               .name = DRV_NAME,
+               .of_match_table = of_match_ptr(simple_amp_ids),
+       },
+       .probe = simple_amp_probe,
+};
+
+module_platform_driver(simple_amp_driver);
+
+MODULE_DESCRIPTION("ASoC Simple Audio Amplifier driver");
+MODULE_AUTHOR("Jerome Brunet <jbrunet@baylibre.com>");
+MODULE_LICENSE("GPL");