ASoC: pxa2xx-ac97: Remove unused DAI ID defines
[linux-2.6-block.git] / sound / soc / pxa / e750_wm9705.c
CommitLineData
a7e2e735
IM
1/*
2 * e750-wm9705.c -- SoC audio for e750
3 *
4 * Copyright 2007 (c) Ian Molton <spyro@f2s.com>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; version 2 ONLY.
9 *
10 */
11
12#include <linux/module.h>
13#include <linux/moduleparam.h>
14#include <linux/gpio.h>
15
16#include <sound/core.h>
17#include <sound/pcm.h>
18#include <sound/soc.h>
a7e2e735 19
a7e2e735
IM
20#include <mach/audio.h>
21#include <mach/eseries-gpio.h>
22
23#include <asm/mach-types.h>
24
a7e2e735
IM
25static int e750_spk_amp_event(struct snd_soc_dapm_widget *w,
26 struct snd_kcontrol *kcontrol, int event)
27{
28 if (event & SND_SOC_DAPM_PRE_PMU)
29 gpio_set_value(GPIO_E750_SPK_AMP_OFF, 0);
30 else if (event & SND_SOC_DAPM_POST_PMD)
31 gpio_set_value(GPIO_E750_SPK_AMP_OFF, 1);
32
33 return 0;
34}
35
36static int e750_hp_amp_event(struct snd_soc_dapm_widget *w,
37 struct snd_kcontrol *kcontrol, int event)
38{
39 if (event & SND_SOC_DAPM_PRE_PMU)
40 gpio_set_value(GPIO_E750_HP_AMP_OFF, 0);
41 else if (event & SND_SOC_DAPM_POST_PMD)
42 gpio_set_value(GPIO_E750_HP_AMP_OFF, 1);
43
44 return 0;
45}
46
47static const struct snd_soc_dapm_widget e750_dapm_widgets[] = {
48 SND_SOC_DAPM_HP("Headphone Jack", NULL),
49 SND_SOC_DAPM_SPK("Speaker", NULL),
50 SND_SOC_DAPM_MIC("Mic (Internal)", NULL),
51 SND_SOC_DAPM_PGA_E("Headphone Amp", SND_SOC_NOPM, 0, 0, NULL, 0,
52 e750_hp_amp_event, SND_SOC_DAPM_PRE_PMU |
53 SND_SOC_DAPM_POST_PMD),
54 SND_SOC_DAPM_PGA_E("Speaker Amp", SND_SOC_NOPM, 0, 0, NULL, 0,
55 e750_spk_amp_event, SND_SOC_DAPM_PRE_PMU |
56 SND_SOC_DAPM_POST_PMD),
57};
58
59static const struct snd_soc_dapm_route audio_map[] = {
60 {"Headphone Amp", NULL, "HPOUTL"},
61 {"Headphone Amp", NULL, "HPOUTR"},
62 {"Headphone Jack", NULL, "Headphone Amp"},
63
64 {"Speaker Amp", NULL, "MONOOUT"},
65 {"Speaker", NULL, "Speaker Amp"},
66
67 {"MIC1", NULL, "Mic (Internal)"},
68};
69
a7e2e735
IM
70static struct snd_soc_dai_link e750_dai[] = {
71 {
72 .name = "AC97",
73 .stream_name = "AC97 HiFi",
4bfc4e25 74 .cpu_dai_name = "pxa2xx-ac97",
f0fba2ad
LG
75 .codec_dai_name = "wm9705-hifi",
76 .platform_name = "pxa-pcm-audio",
77 .codec_name = "wm9705-codec",
a7e2e735
IM
78 /* use ops to check startup state */
79 },
80 {
81 .name = "AC97 Aux",
82 .stream_name = "AC97 Aux",
4bfc4e25 83 .cpu_dai_name = "pxa2xx-ac97-aux",
f0fba2ad
LG
84 .codec_dai_name ="wm9705-aux",
85 .platform_name = "pxa-pcm-audio",
86 .codec_name = "wm9705-codec",
a7e2e735
IM
87 },
88};
89
90static struct snd_soc_card e750 = {
91 .name = "Toshiba e750",
561c6a17 92 .owner = THIS_MODULE,
a7e2e735
IM
93 .dai_link = e750_dai,
94 .num_links = ARRAY_SIZE(e750_dai),
98308c82
LPC
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),
7523f69e 100 .fully_routed = true,
a7e2e735
IM
101};
102
5eb2c3d9
AL
103static 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};
a7e2e735 107
570f6fe1 108static int e750_probe(struct platform_device *pdev)
a7e2e735 109{
5eb2c3d9 110 struct snd_soc_card *card = &e750;
a7e2e735
IM
111 int ret;
112
5eb2c3d9
AL
113 ret = gpio_request_array(e750_audio_gpios,
114 ARRAY_SIZE(e750_audio_gpios));
a7e2e735
IM
115 if (ret)
116 return ret;
117
5eb2c3d9 118 card->dev = &pdev->dev;
a7e2e735 119
2fd7076a 120 ret = devm_snd_soc_register_card(&pdev->dev, card);
5eb2c3d9
AL
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));
a7e2e735 125 }
a7e2e735
IM
126 return ret;
127}
128
570f6fe1 129static int e750_remove(struct platform_device *pdev)
a7e2e735 130{
5eb2c3d9 131 gpio_free_array(e750_audio_gpios, ARRAY_SIZE(e750_audio_gpios));
5eb2c3d9 132 return 0;
a7e2e735
IM
133}
134
5eb2c3d9
AL
135static struct platform_driver e750_driver = {
136 .driver = {
137 .name = "e750-audio",
7db1698f 138 .pm = &snd_soc_pm_ops,
5eb2c3d9
AL
139 },
140 .probe = e750_probe,
570f6fe1 141 .remove = e750_remove,
5eb2c3d9
AL
142};
143
144module_platform_driver(e750_driver);
a7e2e735
IM
145
146/* Module information */
147MODULE_AUTHOR("Ian Molton <spyro@f2s.com>");
148MODULE_DESCRIPTION("ALSA SoC driver for e750");
149MODULE_LICENSE("GPL v2");
5eb2c3d9 150MODULE_ALIAS("platform:e750-audio");