| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009, Lars-Peter Clausen <lars@metafoo.de> | 2 * Copyright (C) 2009, Lars-Peter Clausen <lars@metafoo.de> |
| 3 * | 3 * |
| 4 * This program is free software; you can redistribute it and/or modify | 4 * This program is free software; you can redistribute it and/or modify |
| 5 * it under the terms of the GNU General Public License version 2 as | 5 * it under the terms of the GNU General Public License version 2 as |
| 6 * published by the Free Software Foundation. | 6 * published by the Free Software Foundation. |
| 7 * | 7 * |
| 8 * You should have received a copy of the GNU General Public License along | 8 * You should have received a copy of the GNU General Public License along |
| 9 * with this program; if not, write to the Free Software Foundation, Inc., | 9 * with this program; if not, write to the Free Software Foundation, Inc., |
| 10 * 675 Mass Ave, Cambridge, MA 02139, USA. | 10 * 675 Mass Ave, Cambridge, MA 02139, USA. |
| 11 * | 11 * |
| 12 */ | 12 */ |
| 13 | 13 |
| 14 #include <linux/module.h> | 14 #include <linux/module.h> |
| 15 #include <linux/moduleparam.h> | 15 #include <linux/moduleparam.h> |
| 16 #include <linux/timer.h> | 16 #include <linux/timer.h> |
| 17 #include <linux/interrupt.h> | 17 #include <linux/interrupt.h> |
| 18 #include <linux/platform_device.h> | 18 #include <linux/platform_device.h> |
| 19 #include <sound/core.h> | 19 #include <sound/core.h> |
| 20 #include <sound/pcm.h> | 20 #include <sound/pcm.h> |
| 21 #include <sound/soc.h> | 21 #include <sound/soc.h> |
| 22 #include <sound/soc-dapm.h> | |
| 23 #include <linux/gpio.h> | 22 #include <linux/gpio.h> |
| 24 | 23 |
| 25 #define QI_LB60_SND_GPIO JZ_GPIO_PORTB(29) | 24 #define QI_LB60_SND_GPIO JZ_GPIO_PORTB(29) |
| 26 #define QI_LB60_AMP_GPIO JZ_GPIO_PORTD(4) | 25 #define QI_LB60_AMP_GPIO JZ_GPIO_PORTD(4) |
| 27 | 26 |
| 28 static int qi_lb60_spk_event(struct snd_soc_dapm_widget *widget, | 27 static int qi_lb60_spk_event(struct snd_soc_dapm_widget *widget, |
| 29 struct snd_kcontrol *ctrl, int event) | 28 struct snd_kcontrol *ctrl, int event) |
| 30 { | 29 { |
| 31 int on = 0; | 30 int on = 0; |
| 32 if (event & SND_SOC_DAPM_POST_PMU) | 31 if (event & SND_SOC_DAPM_POST_PMU) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 52 }; | 51 }; |
| 53 | 52 |
| 54 #define QI_LB60_DAIFMT (SND_SOC_DAIFMT_I2S | \ | 53 #define QI_LB60_DAIFMT (SND_SOC_DAIFMT_I2S | \ |
| 55 SND_SOC_DAIFMT_NB_NF | \ | 54 SND_SOC_DAIFMT_NB_NF | \ |
| 56 SND_SOC_DAIFMT_CBM_CFM) | 55 SND_SOC_DAIFMT_CBM_CFM) |
| 57 | 56 |
| 58 static int qi_lb60_codec_init(struct snd_soc_pcm_runtime *rtd) | 57 static int qi_lb60_codec_init(struct snd_soc_pcm_runtime *rtd) |
| 59 { | 58 { |
| 60 struct snd_soc_codec *codec = rtd->codec; | 59 struct snd_soc_codec *codec = rtd->codec; |
| 61 struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 60 struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
| 61 struct snd_soc_dapm_context *dapm = &codec->dapm; |
| 62 int ret; | 62 int ret; |
| 63 | 63 |
| 64 » snd_soc_dapm_nc_pin(codec, "LIN"); | 64 » snd_soc_dapm_nc_pin(dapm, "LIN"); |
| 65 » snd_soc_dapm_nc_pin(codec, "RIN"); | 65 » snd_soc_dapm_nc_pin(dapm, "RIN"); |
| 66 | 66 |
| 67 ret = snd_soc_dai_set_fmt(cpu_dai, QI_LB60_DAIFMT); | 67 ret = snd_soc_dai_set_fmt(cpu_dai, QI_LB60_DAIFMT); |
| 68 if (ret < 0) { | 68 if (ret < 0) { |
| 69 dev_err(codec->dev, "Failed to set cpu dai format: %d\n", ret); | 69 dev_err(codec->dev, "Failed to set cpu dai format: %d\n", ret); |
| 70 return ret; | 70 return ret; |
| 71 } | 71 } |
| 72 | 72 |
| 73 » snd_soc_dapm_new_controls(codec, qi_lb60_widgets, ARRAY_SIZE(qi_lb60_wid
gets)); | 73 » snd_soc_dapm_new_controls(dapm, qi_lb60_widgets, |
| 74 » snd_soc_dapm_add_routes(codec, qi_lb60_routes, ARRAY_SIZE(qi_lb60_routes
)); | 74 » » » » ARRAY_SIZE(qi_lb60_widgets)); |
| 75 » snd_soc_dapm_sync(codec); | 75 » snd_soc_dapm_add_routes(dapm, qi_lb60_routes, |
| 76 » » » » ARRAY_SIZE(qi_lb60_routes)); |
| 77 » snd_soc_dapm_sync(dapm); |
| 76 | 78 |
| 77 return 0; | 79 return 0; |
| 78 } | 80 } |
| 79 | 81 |
| 80 static struct snd_soc_dai_link qi_lb60_dai = { | 82 static struct snd_soc_dai_link qi_lb60_dai = { |
| 81 .name = "jz4740", | 83 .name = "jz4740", |
| 82 .stream_name = "jz4740", | 84 .stream_name = "jz4740", |
| 83 .cpu_dai_name = "jz4740-i2s", | 85 .cpu_dai_name = "jz4740-i2s", |
| 84 .platform_name = "jz4740-pcm-audio", | 86 .platform_name = "jz4740-pcm-audio", |
| 85 .codec_dai_name = "jz4740-hifi", | 87 .codec_dai_name = "jz4740-hifi", |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 { | 150 { |
| 149 gpio_free(QI_LB60_AMP_GPIO); | 151 gpio_free(QI_LB60_AMP_GPIO); |
| 150 gpio_free(QI_LB60_SND_GPIO); | 152 gpio_free(QI_LB60_SND_GPIO); |
| 151 platform_device_unregister(qi_lb60_snd_device); | 153 platform_device_unregister(qi_lb60_snd_device); |
| 152 } | 154 } |
| 153 module_exit(qi_lb60_exit); | 155 module_exit(qi_lb60_exit); |
| 154 | 156 |
| 155 MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>"); | 157 MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>"); |
| 156 MODULE_DESCRIPTION("ALSA SoC QI LB60 Audio support"); | 158 MODULE_DESCRIPTION("ALSA SoC QI LB60 Audio support"); |
| 157 MODULE_LICENSE("GPL v2"); | 159 MODULE_LICENSE("GPL v2"); |
| OLD | NEW |