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

TOMOYO Linux Cross Reference
Linux/sound/soc/pxa/e750_wm9705.c

Version: ~ [ linux-5.10-rc5 ] ~ [ linux-5.9.10 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.79 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.159 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.208 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.245 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.245 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.85 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ 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.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-only
  2 /*
  3  * e750-wm9705.c  --  SoC audio for e750
  4  *
  5  * Copyright 2007 (c) Ian Molton <spyro@f2s.com>
  6  */
  7 
  8 #include <linux/module.h>
  9 #include <linux/moduleparam.h>
 10 #include <linux/gpio.h>
 11 
 12 #include <sound/core.h>
 13 #include <sound/pcm.h>
 14 #include <sound/soc.h>
 15 
 16 #include <mach/audio.h>
 17 #include <mach/eseries-gpio.h>
 18 
 19 #include <asm/mach-types.h>
 20 
 21 static int e750_spk_amp_event(struct snd_soc_dapm_widget *w,
 22                                 struct snd_kcontrol *kcontrol, int event)
 23 {
 24         if (event & SND_SOC_DAPM_PRE_PMU)
 25                 gpio_set_value(GPIO_E750_SPK_AMP_OFF, 0);
 26         else if (event & SND_SOC_DAPM_POST_PMD)
 27                 gpio_set_value(GPIO_E750_SPK_AMP_OFF, 1);
 28 
 29         return 0;
 30 }
 31 
 32 static int e750_hp_amp_event(struct snd_soc_dapm_widget *w,
 33                                 struct snd_kcontrol *kcontrol, int event)
 34 {
 35         if (event & SND_SOC_DAPM_PRE_PMU)
 36                 gpio_set_value(GPIO_E750_HP_AMP_OFF, 0);
 37         else if (event & SND_SOC_DAPM_POST_PMD)
 38                 gpio_set_value(GPIO_E750_HP_AMP_OFF, 1);
 39 
 40         return 0;
 41 }
 42 
 43 static const struct snd_soc_dapm_widget e750_dapm_widgets[] = {
 44         SND_SOC_DAPM_HP("Headphone Jack", NULL),
 45         SND_SOC_DAPM_SPK("Speaker", NULL),
 46         SND_SOC_DAPM_MIC("Mic (Internal)", NULL),
 47         SND_SOC_DAPM_PGA_E("Headphone Amp", SND_SOC_NOPM, 0, 0, NULL, 0,
 48                         e750_hp_amp_event, SND_SOC_DAPM_PRE_PMU |
 49                         SND_SOC_DAPM_POST_PMD),
 50         SND_SOC_DAPM_PGA_E("Speaker Amp", SND_SOC_NOPM, 0, 0, NULL, 0,
 51                         e750_spk_amp_event, SND_SOC_DAPM_PRE_PMU |
 52                         SND_SOC_DAPM_POST_PMD),
 53 };
 54 
 55 static const struct snd_soc_dapm_route audio_map[] = {
 56         {"Headphone Amp", NULL, "HPOUTL"},
 57         {"Headphone Amp", NULL, "HPOUTR"},
 58         {"Headphone Jack", NULL, "Headphone Amp"},
 59 
 60         {"Speaker Amp", NULL, "MONOOUT"},
 61         {"Speaker", NULL, "Speaker Amp"},
 62 
 63         {"MIC1", NULL, "Mic (Internal)"},
 64 };
 65 
 66 SND_SOC_DAILINK_DEFS(ac97,
 67         DAILINK_COMP_ARRAY(COMP_CPU("pxa2xx-ac97")),
 68         DAILINK_COMP_ARRAY(COMP_CODEC("wm9705-codec", "wm9705-hifi")),
 69         DAILINK_COMP_ARRAY(COMP_PLATFORM("pxa-pcm-audio")));
 70 
 71 SND_SOC_DAILINK_DEFS(ac97_aux,
 72         DAILINK_COMP_ARRAY(COMP_CPU("pxa2xx-ac97-aux")),
 73         DAILINK_COMP_ARRAY(COMP_CODEC("wm9705-codec", "wm9705-aux")),
 74         DAILINK_COMP_ARRAY(COMP_PLATFORM("pxa-pcm-audio")));
 75 
 76 static struct snd_soc_dai_link e750_dai[] = {
 77         {
 78                 .name = "AC97",
 79                 .stream_name = "AC97 HiFi",
 80                 SND_SOC_DAILINK_REG(ac97),
 81                 /* use ops to check startup state */
 82         },
 83         {
 84                 .name = "AC97 Aux",
 85                 .stream_name = "AC97 Aux",
 86                 SND_SOC_DAILINK_REG(ac97_aux),
 87         },
 88 };
 89 
 90 static struct snd_soc_card e750 = {
 91         .name = "Toshiba e750",
 92         .owner = THIS_MODULE,
 93         .dai_link = e750_dai,
 94         .num_links = ARRAY_SIZE(e750_dai),
 95 
 96         .dapm_widgets = e750_dapm_widgets,
 97         .num_dapm_widgets = ARRAY_SIZE(e750_dapm_widgets),
 98         .dapm_routes = audio_map,
 99         .num_dapm_routes = ARRAY_SIZE(audio_map),
100         .fully_routed = true,
101 };
102 
103 static struct gpio e750_audio_gpios[] = {
104         { GPIO_E750_HP_AMP_OFF, GPIOF_OUT_INIT_HIGH, "Headphone amp" },
105         { GPIO_E750_SPK_AMP_OFF, GPIOF_OUT_INIT_HIGH, "Speaker amp" },
106 };
107 
108 static int e750_probe(struct platform_device *pdev)
109 {
110         struct snd_soc_card *card = &e750;
111         int ret;
112 
113         ret = gpio_request_array(e750_audio_gpios,
114                                  ARRAY_SIZE(e750_audio_gpios));
115         if (ret)
116                 return ret;
117 
118         card->dev = &pdev->dev;
119 
120         ret = devm_snd_soc_register_card(&pdev->dev, card);
121         if (ret) {
122                 dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
123                         ret);
124                 gpio_free_array(e750_audio_gpios, ARRAY_SIZE(e750_audio_gpios));
125         }
126         return ret;
127 }
128 
129 static int e750_remove(struct platform_device *pdev)
130 {
131         gpio_free_array(e750_audio_gpios, ARRAY_SIZE(e750_audio_gpios));
132         return 0;
133 }
134 
135 static struct platform_driver e750_driver = {
136         .driver         = {
137                 .name   = "e750-audio",
138                 .pm     = &snd_soc_pm_ops,
139         },
140         .probe          = e750_probe,
141         .remove         = e750_remove,
142 };
143 
144 module_platform_driver(e750_driver);
145 
146 /* Module information */
147 MODULE_AUTHOR("Ian Molton <spyro@f2s.com>");
148 MODULE_DESCRIPTION("ALSA SoC driver for e750");
149 MODULE_LICENSE("GPL v2");
150 MODULE_ALIAS("platform:e750-audio");
151 

~ [ 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