| OLD | NEW |
| 1 /* | 1 /* |
| 2 * n810.c -- SoC audio for Nokia N810 | 2 * n810.c -- SoC audio for Nokia N810 |
| 3 * | 3 * |
| 4 * Copyright (C) 2008 Nokia Corporation | 4 * Copyright (C) 2008 Nokia Corporation |
| 5 * | 5 * |
| 6 * Contact: Jarkko Nikula <jhnikula@gmail.com> | 6 * Contact: Jarkko Nikula <jhnikula@gmail.com> |
| 7 * | 7 * |
| 8 * This program is free software; you can redistribute it and/or | 8 * This program is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU General Public License | 9 * modify it under the terms of the GNU General Public License |
| 10 * version 2 as published by the Free Software Foundation. | 10 * version 2 as published by the Free Software Foundation. |
| 11 * | 11 * |
| 12 * This program is distributed in the hope that it will be useful, but | 12 * This program is distributed in the hope that it will be useful, but |
| 13 * WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 * General Public License for more details. | 15 * General Public License for more details. |
| 16 * | 16 * |
| 17 * You should have received a copy of the GNU General Public License | 17 * You should have received a copy of the GNU General Public License |
| 18 * along with this program; if not, write to the Free Software | 18 * along with this program; if not, write to the Free Software |
| 19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | 19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA |
| 20 * 02110-1301 USA | 20 * 02110-1301 USA |
| 21 * | 21 * |
| 22 */ | 22 */ |
| 23 | 23 |
| 24 #include <linux/clk.h> | 24 #include <linux/clk.h> |
| 25 #include <linux/i2c.h> | 25 #include <linux/i2c.h> |
| 26 #include <linux/platform_device.h> | 26 #include <linux/platform_device.h> |
| 27 #include <sound/core.h> | 27 #include <sound/core.h> |
| 28 #include <sound/pcm.h> | 28 #include <sound/pcm.h> |
| 29 #include <sound/soc.h> | 29 #include <sound/soc.h> |
| 30 #include <sound/soc-dapm.h> | |
| 31 | 30 |
| 32 #include <asm/mach-types.h> | 31 #include <asm/mach-types.h> |
| 33 #include <mach/hardware.h> | 32 #include <mach/hardware.h> |
| 34 #include <linux/gpio.h> | 33 #include <linux/gpio.h> |
| 35 #include <plat/mcbsp.h> | 34 #include <plat/mcbsp.h> |
| 36 | 35 |
| 37 #include "omap-mcbsp.h" | 36 #include "omap-mcbsp.h" |
| 38 #include "omap-pcm.h" | 37 #include "omap-pcm.h" |
| 39 #include "../codecs/tlv320aic3x.h" | |
| 40 | 38 |
| 41 #define N810_HEADSET_AMP_GPIO 10 | 39 #define N810_HEADSET_AMP_GPIO 10 |
| 42 #define N810_SPEAKER_AMP_GPIO 101 | 40 #define N810_SPEAKER_AMP_GPIO 101 |
| 43 | 41 |
| 44 enum { | 42 enum { |
| 45 N810_JACK_DISABLED, | 43 N810_JACK_DISABLED, |
| 46 N810_JACK_HP, | 44 N810_JACK_HP, |
| 47 N810_JACK_HS, | 45 N810_JACK_HS, |
| 48 N810_JACK_MIC, | 46 N810_JACK_MIC, |
| 49 }; | 47 }; |
| 50 | 48 |
| 51 static struct clk *sys_clkout2; | 49 static struct clk *sys_clkout2; |
| 52 static struct clk *sys_clkout2_src; | 50 static struct clk *sys_clkout2_src; |
| 53 static struct clk *func96m_clk; | 51 static struct clk *func96m_clk; |
| 54 | 52 |
| 55 static int n810_spk_func; | 53 static int n810_spk_func; |
| 56 static int n810_jack_func; | 54 static int n810_jack_func; |
| 57 static int n810_dmic_func; | 55 static int n810_dmic_func; |
| 58 | 56 |
| 59 static void n810_ext_control(struct snd_soc_codec *codec) | 57 static void n810_ext_control(struct snd_soc_codec *codec) |
| 60 { | 58 { |
| 59 struct snd_soc_dapm_context *dapm = &codec->dapm; |
| 61 int hp = 0, line1l = 0; | 60 int hp = 0, line1l = 0; |
| 62 | 61 |
| 63 switch (n810_jack_func) { | 62 switch (n810_jack_func) { |
| 64 case N810_JACK_HS: | 63 case N810_JACK_HS: |
| 65 line1l = 1; | 64 line1l = 1; |
| 66 case N810_JACK_HP: | 65 case N810_JACK_HP: |
| 67 hp = 1; | 66 hp = 1; |
| 68 break; | 67 break; |
| 69 case N810_JACK_MIC: | 68 case N810_JACK_MIC: |
| 70 line1l = 1; | 69 line1l = 1; |
| 71 break; | 70 break; |
| 72 } | 71 } |
| 73 | 72 |
| 74 if (n810_spk_func) | 73 if (n810_spk_func) |
| 75 » » snd_soc_dapm_enable_pin(codec, "Ext Spk"); | 74 » » snd_soc_dapm_enable_pin(dapm, "Ext Spk"); |
| 76 else | 75 else |
| 77 » » snd_soc_dapm_disable_pin(codec, "Ext Spk"); | 76 » » snd_soc_dapm_disable_pin(dapm, "Ext Spk"); |
| 78 | 77 |
| 79 if (hp) | 78 if (hp) |
| 80 » » snd_soc_dapm_enable_pin(codec, "Headphone Jack"); | 79 » » snd_soc_dapm_enable_pin(dapm, "Headphone Jack"); |
| 81 else | 80 else |
| 82 » » snd_soc_dapm_disable_pin(codec, "Headphone Jack"); | 81 » » snd_soc_dapm_disable_pin(dapm, "Headphone Jack"); |
| 83 if (line1l) | 82 if (line1l) |
| 84 » » snd_soc_dapm_enable_pin(codec, "LINE1L"); | 83 » » snd_soc_dapm_enable_pin(dapm, "LINE1L"); |
| 85 else | 84 else |
| 86 » » snd_soc_dapm_disable_pin(codec, "LINE1L"); | 85 » » snd_soc_dapm_disable_pin(dapm, "LINE1L"); |
| 87 | 86 |
| 88 if (n810_dmic_func) | 87 if (n810_dmic_func) |
| 89 » » snd_soc_dapm_enable_pin(codec, "DMic"); | 88 » » snd_soc_dapm_enable_pin(dapm, "DMic"); |
| 90 else | 89 else |
| 91 » » snd_soc_dapm_disable_pin(codec, "DMic"); | 90 » » snd_soc_dapm_disable_pin(dapm, "DMic"); |
| 92 | 91 |
| 93 » snd_soc_dapm_sync(codec); | 92 » snd_soc_dapm_sync(dapm); |
| 94 } | 93 } |
| 95 | 94 |
| 96 static int n810_startup(struct snd_pcm_substream *substream) | 95 static int n810_startup(struct snd_pcm_substream *substream) |
| 97 { | 96 { |
| 98 struct snd_pcm_runtime *runtime = substream->runtime; | 97 struct snd_pcm_runtime *runtime = substream->runtime; |
| 99 struct snd_soc_pcm_runtime *rtd = substream->private_data; | 98 struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 100 struct snd_soc_codec *codec = rtd->codec; | 99 struct snd_soc_codec *codec = rtd->codec; |
| 101 | 100 |
| 102 snd_pcm_hw_constraint_minmax(runtime, | 101 snd_pcm_hw_constraint_minmax(runtime, |
| 103 SNDRV_PCM_HW_PARAM_CHANNELS, 2, 2); | 102 SNDRV_PCM_HW_PARAM_CHANNELS, 2, 2); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 n810_get_spk, n810_set_spk), | 266 n810_get_spk, n810_set_spk), |
| 268 SOC_ENUM_EXT("Jack Function", n810_enum[1], | 267 SOC_ENUM_EXT("Jack Function", n810_enum[1], |
| 269 n810_get_jack, n810_set_jack), | 268 n810_get_jack, n810_set_jack), |
| 270 SOC_ENUM_EXT("Input Select", n810_enum[2], | 269 SOC_ENUM_EXT("Input Select", n810_enum[2], |
| 271 n810_get_input, n810_set_input), | 270 n810_get_input, n810_set_input), |
| 272 }; | 271 }; |
| 273 | 272 |
| 274 static int n810_aic33_init(struct snd_soc_pcm_runtime *rtd) | 273 static int n810_aic33_init(struct snd_soc_pcm_runtime *rtd) |
| 275 { | 274 { |
| 276 struct snd_soc_codec *codec = rtd->codec; | 275 struct snd_soc_codec *codec = rtd->codec; |
| 276 struct snd_soc_dapm_context *dapm = &codec->dapm; |
| 277 int err; | 277 int err; |
| 278 | 278 |
| 279 /* Not connected */ | 279 /* Not connected */ |
| 280 » snd_soc_dapm_nc_pin(codec, "MONO_LOUT"); | 280 » snd_soc_dapm_nc_pin(dapm, "MONO_LOUT"); |
| 281 » snd_soc_dapm_nc_pin(codec, "HPLCOM"); | 281 » snd_soc_dapm_nc_pin(dapm, "HPLCOM"); |
| 282 » snd_soc_dapm_nc_pin(codec, "HPRCOM"); | 282 » snd_soc_dapm_nc_pin(dapm, "HPRCOM"); |
| 283 » snd_soc_dapm_nc_pin(codec, "MIC3L"); | 283 » snd_soc_dapm_nc_pin(dapm, "MIC3L"); |
| 284 » snd_soc_dapm_nc_pin(codec, "MIC3R"); | 284 » snd_soc_dapm_nc_pin(dapm, "MIC3R"); |
| 285 » snd_soc_dapm_nc_pin(codec, "LINE1R"); | 285 » snd_soc_dapm_nc_pin(dapm, "LINE1R"); |
| 286 » snd_soc_dapm_nc_pin(codec, "LINE2L"); | 286 » snd_soc_dapm_nc_pin(dapm, "LINE2L"); |
| 287 » snd_soc_dapm_nc_pin(codec, "LINE2R"); | 287 » snd_soc_dapm_nc_pin(dapm, "LINE2R"); |
| 288 | 288 |
| 289 /* Add N810 specific controls */ | 289 /* Add N810 specific controls */ |
| 290 err = snd_soc_add_controls(codec, aic33_n810_controls, | 290 err = snd_soc_add_controls(codec, aic33_n810_controls, |
| 291 ARRAY_SIZE(aic33_n810_controls)); | 291 ARRAY_SIZE(aic33_n810_controls)); |
| 292 if (err < 0) | 292 if (err < 0) |
| 293 return err; | 293 return err; |
| 294 | 294 |
| 295 /* Add N810 specific widgets */ | 295 /* Add N810 specific widgets */ |
| 296 » snd_soc_dapm_new_controls(codec, aic33_dapm_widgets, | 296 » snd_soc_dapm_new_controls(dapm, aic33_dapm_widgets, |
| 297 ARRAY_SIZE(aic33_dapm_widgets)); | 297 ARRAY_SIZE(aic33_dapm_widgets)); |
| 298 | 298 |
| 299 /* Set up N810 specific audio path audio_map */ | 299 /* Set up N810 specific audio path audio_map */ |
| 300 » snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); | 300 » snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); |
| 301 | 301 |
| 302 » snd_soc_dapm_sync(codec); | 302 » snd_soc_dapm_sync(dapm); |
| 303 | 303 |
| 304 return 0; | 304 return 0; |
| 305 } | 305 } |
| 306 | 306 |
| 307 /* Digital audio interface glue - connects codec <--> CPU */ | 307 /* Digital audio interface glue - connects codec <--> CPU */ |
| 308 static struct snd_soc_dai_link n810_dai = { | 308 static struct snd_soc_dai_link n810_dai = { |
| 309 .name = "TLV320AIC33", | 309 .name = "TLV320AIC33", |
| 310 .stream_name = "AIC33", | 310 .stream_name = "AIC33", |
| 311 .cpu_dai_name = "omap-mcbsp-dai.1", | 311 .cpu_dai_name = "omap-mcbsp-dai.1", |
| 312 .platform_name = "omap-pcm-audio", | 312 .platform_name = "omap-pcm-audio", |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 | 398 |
| 399 platform_device_unregister(n810_snd_device); | 399 platform_device_unregister(n810_snd_device); |
| 400 } | 400 } |
| 401 | 401 |
| 402 module_init(n810_soc_init); | 402 module_init(n810_soc_init); |
| 403 module_exit(n810_soc_exit); | 403 module_exit(n810_soc_exit); |
| 404 | 404 |
| 405 MODULE_AUTHOR("Jarkko Nikula <jhnikula@gmail.com>"); | 405 MODULE_AUTHOR("Jarkko Nikula <jhnikula@gmail.com>"); |
| 406 MODULE_DESCRIPTION("ALSA SoC Nokia N810"); | 406 MODULE_DESCRIPTION("ALSA SoC Nokia N810"); |
| 407 MODULE_LICENSE("GPL"); | 407 MODULE_LICENSE("GPL"); |
| OLD | NEW |