0001
0002
0003
0004
0005
0006
0007
0008 #include <linux/module.h>
0009 #include <linux/moduleparam.h>
0010 #include <linux/gpio/consumer.h>
0011
0012 #include <sound/core.h>
0013 #include <sound/pcm.h>
0014 #include <sound/soc.h>
0015
0016 #include <linux/platform_data/asoc-pxa.h>
0017
0018 #include <asm/mach-types.h>
0019
0020 static struct gpio_desc *gpiod_spk_amp, *gpiod_hp_amp;
0021
0022 static int e750_spk_amp_event(struct snd_soc_dapm_widget *w,
0023 struct snd_kcontrol *kcontrol, int event)
0024 {
0025 if (event & SND_SOC_DAPM_PRE_PMU)
0026 gpiod_set_value(gpiod_spk_amp, 1);
0027 else if (event & SND_SOC_DAPM_POST_PMD)
0028 gpiod_set_value(gpiod_spk_amp, 0);
0029
0030 return 0;
0031 }
0032
0033 static int e750_hp_amp_event(struct snd_soc_dapm_widget *w,
0034 struct snd_kcontrol *kcontrol, int event)
0035 {
0036 if (event & SND_SOC_DAPM_PRE_PMU)
0037 gpiod_set_value(gpiod_hp_amp, 1);
0038 else if (event & SND_SOC_DAPM_POST_PMD)
0039 gpiod_set_value(gpiod_hp_amp, 0);
0040
0041 return 0;
0042 }
0043
0044 static const struct snd_soc_dapm_widget e750_dapm_widgets[] = {
0045 SND_SOC_DAPM_HP("Headphone Jack", NULL),
0046 SND_SOC_DAPM_SPK("Speaker", NULL),
0047 SND_SOC_DAPM_MIC("Mic (Internal)", NULL),
0048 SND_SOC_DAPM_PGA_E("Headphone Amp", SND_SOC_NOPM, 0, 0, NULL, 0,
0049 e750_hp_amp_event, SND_SOC_DAPM_PRE_PMU |
0050 SND_SOC_DAPM_POST_PMD),
0051 SND_SOC_DAPM_PGA_E("Speaker Amp", SND_SOC_NOPM, 0, 0, NULL, 0,
0052 e750_spk_amp_event, SND_SOC_DAPM_PRE_PMU |
0053 SND_SOC_DAPM_POST_PMD),
0054 };
0055
0056 static const struct snd_soc_dapm_route audio_map[] = {
0057 {"Headphone Amp", NULL, "HPOUTL"},
0058 {"Headphone Amp", NULL, "HPOUTR"},
0059 {"Headphone Jack", NULL, "Headphone Amp"},
0060
0061 {"Speaker Amp", NULL, "MONOOUT"},
0062 {"Speaker", NULL, "Speaker Amp"},
0063
0064 {"MIC1", NULL, "Mic (Internal)"},
0065 };
0066
0067 SND_SOC_DAILINK_DEFS(ac97,
0068 DAILINK_COMP_ARRAY(COMP_CPU("pxa2xx-ac97")),
0069 DAILINK_COMP_ARRAY(COMP_CODEC("wm9705-codec", "wm9705-hifi")),
0070 DAILINK_COMP_ARRAY(COMP_PLATFORM("pxa-pcm-audio")));
0071
0072 SND_SOC_DAILINK_DEFS(ac97_aux,
0073 DAILINK_COMP_ARRAY(COMP_CPU("pxa2xx-ac97-aux")),
0074 DAILINK_COMP_ARRAY(COMP_CODEC("wm9705-codec", "wm9705-aux")),
0075 DAILINK_COMP_ARRAY(COMP_PLATFORM("pxa-pcm-audio")));
0076
0077 static struct snd_soc_dai_link e750_dai[] = {
0078 {
0079 .name = "AC97",
0080 .stream_name = "AC97 HiFi",
0081 SND_SOC_DAILINK_REG(ac97),
0082
0083 },
0084 {
0085 .name = "AC97 Aux",
0086 .stream_name = "AC97 Aux",
0087 SND_SOC_DAILINK_REG(ac97_aux),
0088 },
0089 };
0090
0091 static struct snd_soc_card e750 = {
0092 .name = "Toshiba e750",
0093 .owner = THIS_MODULE,
0094 .dai_link = e750_dai,
0095 .num_links = ARRAY_SIZE(e750_dai),
0096
0097 .dapm_widgets = e750_dapm_widgets,
0098 .num_dapm_widgets = ARRAY_SIZE(e750_dapm_widgets),
0099 .dapm_routes = audio_map,
0100 .num_dapm_routes = ARRAY_SIZE(audio_map),
0101 .fully_routed = true,
0102 };
0103
0104 static int e750_probe(struct platform_device *pdev)
0105 {
0106 struct snd_soc_card *card = &e750;
0107 int ret;
0108
0109 gpiod_hp_amp = devm_gpiod_get(&pdev->dev, "Headphone amp", GPIOD_OUT_LOW);
0110 ret = PTR_ERR_OR_ZERO(gpiod_hp_amp);
0111 if (ret)
0112 return ret;
0113 gpiod_spk_amp = devm_gpiod_get(&pdev->dev, "Speaker amp", GPIOD_OUT_LOW);
0114 ret = PTR_ERR_OR_ZERO(gpiod_spk_amp);
0115 if (ret)
0116 return ret;
0117
0118 card->dev = &pdev->dev;
0119
0120 ret = devm_snd_soc_register_card(&pdev->dev, card);
0121 if (ret)
0122 dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
0123 ret);
0124 return ret;
0125 }
0126
0127 static int e750_remove(struct platform_device *pdev)
0128 {
0129 return 0;
0130 }
0131
0132 static struct platform_driver e750_driver = {
0133 .driver = {
0134 .name = "e750-audio",
0135 .pm = &snd_soc_pm_ops,
0136 },
0137 .probe = e750_probe,
0138 .remove = e750_remove,
0139 };
0140
0141 module_platform_driver(e750_driver);
0142
0143
0144 MODULE_AUTHOR("Ian Molton <spyro@f2s.com>");
0145 MODULE_DESCRIPTION("ALSA SoC driver for e750");
0146 MODULE_LICENSE("GPL v2");
0147 MODULE_ALIAS("platform:e750-audio");