~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/sound/soc/codecs/dio2125.c

Version: ~ [ linux-6.1-rc5 ] ~ [ linux-6.0.8 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.78 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.154 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.224 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.265 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.299 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.333 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.302 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * Copyright (c) 2017 BayLibre, SAS.
  3  * Author: Jerome Brunet <jbrunet@baylibre.com>
  4  *
  5  * This program is free software; you can redistribute it and/or modify
  6  * it under the terms of version 2 of the GNU General Public License as
  7  * published by the Free Software Foundation.
  8  *
  9  * This program is distributed in the hope that it will be useful, but
 10  * WITHOUT ANY WARRANTY; without even the implied warranty of
 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 12  * General Public License for more details.
 13  *
 14  * You should have received a copy of the GNU General Public License
 15  * along with this program; if not, see <http://www.gnu.org/licenses/>.
 16  * The full GNU General Public License is included in this distribution
 17  * in the file called COPYING.
 18  */
 19 
 20 #include <linux/gpio/consumer.h>
 21 #include <linux/module.h>
 22 #include <sound/soc.h>
 23 
 24 #define DRV_NAME "dio2125"
 25 
 26 struct dio2125 {
 27         struct gpio_desc *gpiod_enable;
 28 };
 29 
 30 static int drv_event(struct snd_soc_dapm_widget *w,
 31                      struct snd_kcontrol *control, int event)
 32 {
 33         struct snd_soc_component *c = snd_soc_dapm_to_component(w->dapm);
 34         struct dio2125 *priv = snd_soc_component_get_drvdata(c);
 35         int val;
 36 
 37         switch (event) {
 38         case SND_SOC_DAPM_POST_PMU:
 39                 val = 1;
 40                 break;
 41         case SND_SOC_DAPM_PRE_PMD:
 42                 val = 0;
 43                 break;
 44         default:
 45                 WARN(1, "Unexpected event");
 46                 return -EINVAL;
 47         }
 48 
 49         gpiod_set_value_cansleep(priv->gpiod_enable, val);
 50 
 51         return 0;
 52 }
 53 
 54 static const struct snd_soc_dapm_widget dio2125_dapm_widgets[] = {
 55         SND_SOC_DAPM_INPUT("INL"),
 56         SND_SOC_DAPM_INPUT("INR"),
 57         SND_SOC_DAPM_OUT_DRV_E("DRV", SND_SOC_NOPM, 0, 0, NULL, 0, drv_event,
 58                                (SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD)),
 59         SND_SOC_DAPM_OUTPUT("OUTL"),
 60         SND_SOC_DAPM_OUTPUT("OUTR"),
 61 };
 62 
 63 static const struct snd_soc_dapm_route dio2125_dapm_routes[] = {
 64         { "DRV", NULL, "INL" },
 65         { "DRV", NULL, "INR" },
 66         { "OUTL", NULL, "DRV" },
 67         { "OUTR", NULL, "DRV" },
 68 };
 69 
 70 static const struct snd_soc_component_driver dio2125_component_driver = {
 71         .dapm_widgets           = dio2125_dapm_widgets,
 72         .num_dapm_widgets       = ARRAY_SIZE(dio2125_dapm_widgets),
 73         .dapm_routes            = dio2125_dapm_routes,
 74         .num_dapm_routes        = ARRAY_SIZE(dio2125_dapm_routes),
 75 };
 76 
 77 static int dio2125_probe(struct platform_device *pdev)
 78 {
 79         struct device *dev = &pdev->dev;
 80         struct dio2125 *priv;
 81         int err;
 82 
 83         priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
 84         if (priv == NULL)
 85                 return -ENOMEM;
 86         platform_set_drvdata(pdev, priv);
 87 
 88         priv->gpiod_enable = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW);
 89         if (IS_ERR(priv->gpiod_enable)) {
 90                 err = PTR_ERR(priv->gpiod_enable);
 91                 if (err != -EPROBE_DEFER)
 92                         dev_err(dev, "Failed to get 'enable' gpio: %d", err);
 93                 return err;
 94         }
 95 
 96         return devm_snd_soc_register_component(dev, &dio2125_component_driver,
 97                                                NULL, 0);
 98 }
 99 
100 #ifdef CONFIG_OF
101 static const struct of_device_id dio2125_ids[] = {
102         { .compatible = "dioo,dio2125", },
103         { }
104 };
105 MODULE_DEVICE_TABLE(of, dio2125_ids);
106 #endif
107 
108 static struct platform_driver dio2125_driver = {
109         .driver = {
110                 .name = DRV_NAME,
111                 .of_match_table = of_match_ptr(dio2125_ids),
112         },
113         .probe = dio2125_probe,
114 };
115 
116 module_platform_driver(dio2125_driver);
117 
118 MODULE_DESCRIPTION("ASoC DIO2125 output driver");
119 MODULE_AUTHOR("Jerome Brunet <jbrunet@baylibre.com>");
120 MODULE_LICENSE("GPL");
121 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp