Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Side by Side Diff: sound/soc/omap/sdp4430.c

Issue 6577007: CHROMIUM: ASoC: Import entire upstream ASoC tree (Closed)
Patch Set: Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sound/soc/omap/sdp3430.c ('k') | sound/soc/omap/zoom2.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * sdp4430.c -- SoC audio for TI OMAP4430 SDP 2 * sdp4430.c -- SoC audio for TI OMAP4430 SDP
3 * 3 *
4 * Author: Misael Lopez Cruz <x0052729@ti.com> 4 * Author: Misael Lopez Cruz <x0052729@ti.com>
5 * 5 *
6 * This program is free software; you can redistribute it and/or 6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License 7 * modify it under the terms of the GNU General Public License
8 * version 2 as published by the Free Software Foundation. 8 * version 2 as published by the Free Software Foundation.
9 * 9 *
10 * This program is distributed in the hope that it will be useful, but 10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of 11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details. 13 * General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18 * 02110-1301 USA 18 * 02110-1301 USA
19 * 19 *
20 */ 20 */
21 21
22 #include <linux/clk.h> 22 #include <linux/clk.h>
23 #include <linux/platform_device.h> 23 #include <linux/platform_device.h>
24 #include <sound/core.h> 24 #include <sound/core.h>
25 #include <sound/pcm.h> 25 #include <sound/pcm.h>
26 #include <sound/soc.h> 26 #include <sound/soc.h>
27 #include <sound/soc-dapm.h> 27 #include <sound/jack.h>
28 28
29 #include <asm/mach-types.h> 29 #include <asm/mach-types.h>
30 #include <plat/hardware.h> 30 #include <plat/hardware.h>
31 #include <plat/mux.h> 31 #include <plat/mux.h>
32 32
33 #include "mcpdm.h" 33 #include "mcpdm.h"
34 #include "omap-pcm.h" 34 #include "omap-pcm.h"
35 #include "../codecs/twl6040.h" 35 #include "../codecs/twl6040.h"
36 36
37 static int twl6040_power_mode; 37 static int twl6040_power_mode;
(...skipping 21 matching lines...) Expand all
59 printk(KERN_ERR "can't set codec system clock\n"); 59 printk(KERN_ERR "can't set codec system clock\n");
60 return ret; 60 return ret;
61 } 61 }
62 return ret; 62 return ret;
63 } 63 }
64 64
65 static struct snd_soc_ops sdp4430_ops = { 65 static struct snd_soc_ops sdp4430_ops = {
66 .hw_params = sdp4430_hw_params, 66 .hw_params = sdp4430_hw_params,
67 }; 67 };
68 68
69 /* Headset jack */
70 static struct snd_soc_jack hs_jack;
71
72 /*Headset jack detection DAPM pins */
73 static struct snd_soc_jack_pin hs_jack_pins[] = {
74 {
75 .pin = "Headset Mic",
76 .mask = SND_JACK_MICROPHONE,
77 },
78 {
79 .pin = "Headset Stereophone",
80 .mask = SND_JACK_HEADPHONE,
81 },
82 };
83
69 static int sdp4430_get_power_mode(struct snd_kcontrol *kcontrol, 84 static int sdp4430_get_power_mode(struct snd_kcontrol *kcontrol,
70 struct snd_ctl_elem_value *ucontrol) 85 struct snd_ctl_elem_value *ucontrol)
71 { 86 {
72 ucontrol->value.integer.value[0] = twl6040_power_mode; 87 ucontrol->value.integer.value[0] = twl6040_power_mode;
73 return 0; 88 return 0;
74 } 89 }
75 90
76 static int sdp4430_set_power_mode(struct snd_kcontrol *kcontrol, 91 static int sdp4430_set_power_mode(struct snd_kcontrol *kcontrol,
77 struct snd_ctl_elem_value *ucontrol) 92 struct snd_ctl_elem_value *ucontrol)
78 { 93 {
(...skipping 16 matching lines...) Expand all
95 sdp4430_get_power_mode, sdp4430_set_power_mode), 110 sdp4430_get_power_mode, sdp4430_set_power_mode),
96 }; 111 };
97 112
98 /* SDP4430 machine DAPM */ 113 /* SDP4430 machine DAPM */
99 static const struct snd_soc_dapm_widget sdp4430_twl6040_dapm_widgets[] = { 114 static const struct snd_soc_dapm_widget sdp4430_twl6040_dapm_widgets[] = {
100 SND_SOC_DAPM_MIC("Ext Mic", NULL), 115 SND_SOC_DAPM_MIC("Ext Mic", NULL),
101 SND_SOC_DAPM_SPK("Ext Spk", NULL), 116 SND_SOC_DAPM_SPK("Ext Spk", NULL),
102 SND_SOC_DAPM_MIC("Headset Mic", NULL), 117 SND_SOC_DAPM_MIC("Headset Mic", NULL),
103 SND_SOC_DAPM_HP("Headset Stereophone", NULL), 118 SND_SOC_DAPM_HP("Headset Stereophone", NULL),
104 SND_SOC_DAPM_SPK("Earphone Spk", NULL), 119 SND_SOC_DAPM_SPK("Earphone Spk", NULL),
120 SND_SOC_DAPM_INPUT("Aux/FM Stereo In"),
105 }; 121 };
106 122
107 static const struct snd_soc_dapm_route audio_map[] = { 123 static const struct snd_soc_dapm_route audio_map[] = {
108 /* External Mics: MAINMIC, SUBMIC with bias*/ 124 /* External Mics: MAINMIC, SUBMIC with bias*/
109 {"MAINMIC", NULL, "Main Mic Bias"}, 125 {"MAINMIC", NULL, "Main Mic Bias"},
110 {"SUBMIC", NULL, "Main Mic Bias"}, 126 {"SUBMIC", NULL, "Main Mic Bias"},
111 {"Main Mic Bias", NULL, "Ext Mic"}, 127 {"Main Mic Bias", NULL, "Ext Mic"},
112 128
113 /* External Speakers: HFL, HFR */ 129 /* External Speakers: HFL, HFR */
114 {"Ext Spk", NULL, "HFL"}, 130 {"Ext Spk", NULL, "HFL"},
115 {"Ext Spk", NULL, "HFR"}, 131 {"Ext Spk", NULL, "HFR"},
116 132
117 /* Headset Mic: HSMIC with bias */ 133 /* Headset Mic: HSMIC with bias */
118 {"HSMIC", NULL, "Headset Mic Bias"}, 134 {"HSMIC", NULL, "Headset Mic Bias"},
119 {"Headset Mic Bias", NULL, "Headset Mic"}, 135 {"Headset Mic Bias", NULL, "Headset Mic"},
120 136
121 /* Headset Stereophone (Headphone): HSOL, HSOR */ 137 /* Headset Stereophone (Headphone): HSOL, HSOR */
122 {"Headset Stereophone", NULL, "HSOL"}, 138 {"Headset Stereophone", NULL, "HSOL"},
123 {"Headset Stereophone", NULL, "HSOR"}, 139 {"Headset Stereophone", NULL, "HSOR"},
124 140
125 /* Earphone speaker */ 141 /* Earphone speaker */
126 {"Earphone Spk", NULL, "EP"}, 142 {"Earphone Spk", NULL, "EP"},
143
144 /* Aux/FM Stereo In: AFML, AFMR */
145 {"AFML", NULL, "Aux/FM Stereo In"},
146 {"AFMR", NULL, "Aux/FM Stereo In"},
127 }; 147 };
128 148
129 static int sdp4430_twl6040_init(struct snd_soc_pcm_runtime *rtd) 149 static int sdp4430_twl6040_init(struct snd_soc_pcm_runtime *rtd)
130 { 150 {
131 struct snd_soc_codec *codec = rtd->codec; 151 struct snd_soc_codec *codec = rtd->codec;
152 struct snd_soc_dapm_context *dapm = &codec->dapm;
132 int ret; 153 int ret;
133 154
134 /* Add SDP4430 specific controls */ 155 /* Add SDP4430 specific controls */
135 ret = snd_soc_add_controls(codec, sdp4430_controls, 156 ret = snd_soc_add_controls(codec, sdp4430_controls,
136 ARRAY_SIZE(sdp4430_controls)); 157 ARRAY_SIZE(sdp4430_controls));
137 if (ret) 158 if (ret)
138 return ret; 159 return ret;
139 160
140 /* Add SDP4430 specific widgets */ 161 /* Add SDP4430 specific widgets */
141 » ret = snd_soc_dapm_new_controls(codec, sdp4430_twl6040_dapm_widgets, 162 » ret = snd_soc_dapm_new_controls(dapm, sdp4430_twl6040_dapm_widgets,
142 ARRAY_SIZE(sdp4430_twl6040_dapm_widgets)); 163 ARRAY_SIZE(sdp4430_twl6040_dapm_widgets));
143 if (ret) 164 if (ret)
144 return ret; 165 return ret;
145 166
146 /* Set up SDP4430 specific audio path audio_map */ 167 /* Set up SDP4430 specific audio path audio_map */
147 » snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); 168 » snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));
148 169
149 /* SDP4430 connected pins */ 170 /* SDP4430 connected pins */
150 » snd_soc_dapm_enable_pin(codec, "Ext Mic"); 171 » snd_soc_dapm_enable_pin(dapm, "Ext Mic");
151 » snd_soc_dapm_enable_pin(codec, "Ext Spk"); 172 » snd_soc_dapm_enable_pin(dapm, "Ext Spk");
152 » snd_soc_dapm_enable_pin(codec, "Headset Mic"); 173 » snd_soc_dapm_enable_pin(dapm, "AFML");
153 » snd_soc_dapm_enable_pin(codec, "Headset Stereophone"); 174 » snd_soc_dapm_enable_pin(dapm, "AFMR");
175 » snd_soc_dapm_enable_pin(dapm, "Headset Mic");
176 » snd_soc_dapm_enable_pin(dapm, "Headset Stereophone");
154 177
155 » /* TWL6040 not connected pins */ 178 » ret = snd_soc_dapm_sync(dapm);
156 » snd_soc_dapm_nc_pin(codec, "AFML"); 179 » if (ret)
157 » snd_soc_dapm_nc_pin(codec, "AFMR"); 180 » » return ret;
158 181
159 » ret = snd_soc_dapm_sync(codec); 182 » /* Headset jack detection */
183 » ret = snd_soc_jack_new(codec, "Headset Jack",
184 » » » » SND_JACK_HEADSET, &hs_jack);
185 » if (ret)
186 » » return ret;
187
188 » ret = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins),
189 » » » » hs_jack_pins);
190
191 » if (machine_is_omap_4430sdp())
192 » » twl6040_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADSET);
193 » else
194 » » snd_soc_jack_report(&hs_jack, SND_JACK_HEADSET, SND_JACK_HEADSET );
160 195
161 return ret; 196 return ret;
162 } 197 }
163 198
164 /* Digital audio interface glue - connects codec <--> CPU */ 199 /* Digital audio interface glue - connects codec <--> CPU */
165 static struct snd_soc_dai_link sdp4430_dai = { 200 static struct snd_soc_dai_link sdp4430_dai = {
166 .name = "TWL6040", 201 .name = "TWL6040",
167 .stream_name = "TWL6040", 202 .stream_name = "TWL6040",
168 .cpu_dai_name ="omap-mcpdm-dai", 203 .cpu_dai_name ="omap-mcpdm-dai",
169 .codec_dai_name = "twl6040-hifi", 204 .codec_dai_name = "twl6040-hifi",
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 static void __exit sdp4430_soc_exit(void) 252 static void __exit sdp4430_soc_exit(void)
218 { 253 {
219 platform_device_unregister(sdp4430_snd_device); 254 platform_device_unregister(sdp4430_snd_device);
220 } 255 }
221 module_exit(sdp4430_soc_exit); 256 module_exit(sdp4430_soc_exit);
222 257
223 MODULE_AUTHOR("Misael Lopez Cruz <x0052729@ti.com>"); 258 MODULE_AUTHOR("Misael Lopez Cruz <x0052729@ti.com>");
224 MODULE_DESCRIPTION("ALSA SoC SDP4430"); 259 MODULE_DESCRIPTION("ALSA SoC SDP4430");
225 MODULE_LICENSE("GPL"); 260 MODULE_LICENSE("GPL");
226 261
OLDNEW
« no previous file with comments | « sound/soc/omap/sdp3430.c ('k') | sound/soc/omap/zoom2.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698