| OLD | NEW |
| 1 /* | 1 /* |
| 2 * wm8728.c -- WM8728 ALSA SoC Audio driver | 2 * wm8728.c -- WM8728 ALSA SoC Audio driver |
| 3 * | 3 * |
| 4 * Copyright 2008 Wolfson Microelectronics plc | 4 * Copyright 2008 Wolfson Microelectronics plc |
| 5 * | 5 * |
| 6 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> | 6 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> |
| 7 * | 7 * |
| 8 * This program is free software; you can redistribute it and/or modify | 8 * This program is free software; you can redistribute it and/or modify |
| 9 * it under the terms of the GNU General Public License version 2 as | 9 * it under the terms of the GNU General Public License version 2 as |
| 10 * published by the Free Software Foundation. | 10 * published by the Free Software Foundation. |
| 11 */ | 11 */ |
| 12 | 12 |
| 13 #include <linux/module.h> | 13 #include <linux/module.h> |
| 14 #include <linux/moduleparam.h> | 14 #include <linux/moduleparam.h> |
| 15 #include <linux/init.h> | 15 #include <linux/init.h> |
| 16 #include <linux/delay.h> | 16 #include <linux/delay.h> |
| 17 #include <linux/pm.h> | 17 #include <linux/pm.h> |
| 18 #include <linux/i2c.h> | 18 #include <linux/i2c.h> |
| 19 #include <linux/platform_device.h> | 19 #include <linux/platform_device.h> |
| 20 #include <linux/spi/spi.h> | 20 #include <linux/spi/spi.h> |
| 21 #include <linux/slab.h> | 21 #include <linux/slab.h> |
| 22 #include <sound/core.h> | 22 #include <sound/core.h> |
| 23 #include <sound/pcm.h> | 23 #include <sound/pcm.h> |
| 24 #include <sound/pcm_params.h> | 24 #include <sound/pcm_params.h> |
| 25 #include <sound/soc.h> | 25 #include <sound/soc.h> |
| 26 #include <sound/soc-dapm.h> | |
| 27 #include <sound/initval.h> | 26 #include <sound/initval.h> |
| 28 #include <sound/tlv.h> | 27 #include <sound/tlv.h> |
| 29 | 28 |
| 30 #include "wm8728.h" | 29 #include "wm8728.h" |
| 31 | 30 |
| 32 /* | 31 /* |
| 33 * We can't read the WM8728 register space so we cache them instead. | 32 * We can't read the WM8728 register space so we cache them instead. |
| 34 * Note that the defaults here aren't the physical defaults, we latch | 33 * Note that the defaults here aren't the physical defaults, we latch |
| 35 * the volume update bits, mute the output and enable infinite zero | 34 * the volume update bits, mute the output and enable infinite zero |
| 36 * detect. | 35 * detect. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 66 SND_SOC_DAPM_OUTPUT("VOUTR"), | 65 SND_SOC_DAPM_OUTPUT("VOUTR"), |
| 67 }; | 66 }; |
| 68 | 67 |
| 69 static const struct snd_soc_dapm_route intercon[] = { | 68 static const struct snd_soc_dapm_route intercon[] = { |
| 70 {"VOUTL", NULL, "DAC"}, | 69 {"VOUTL", NULL, "DAC"}, |
| 71 {"VOUTR", NULL, "DAC"}, | 70 {"VOUTR", NULL, "DAC"}, |
| 72 }; | 71 }; |
| 73 | 72 |
| 74 static int wm8728_add_widgets(struct snd_soc_codec *codec) | 73 static int wm8728_add_widgets(struct snd_soc_codec *codec) |
| 75 { | 74 { |
| 76 » snd_soc_dapm_new_controls(codec, wm8728_dapm_widgets, | 75 » struct snd_soc_dapm_context *dapm = &codec->dapm; |
| 76 |
| 77 » snd_soc_dapm_new_controls(dapm, wm8728_dapm_widgets, |
| 77 ARRAY_SIZE(wm8728_dapm_widgets)); | 78 ARRAY_SIZE(wm8728_dapm_widgets)); |
| 78 | 79 » snd_soc_dapm_add_routes(dapm, intercon, ARRAY_SIZE(intercon)); |
| 79 » snd_soc_dapm_add_routes(codec, intercon, ARRAY_SIZE(intercon)); | |
| 80 | 80 |
| 81 return 0; | 81 return 0; |
| 82 } | 82 } |
| 83 | 83 |
| 84 static int wm8728_mute(struct snd_soc_dai *dai, int mute) | 84 static int wm8728_mute(struct snd_soc_dai *dai, int mute) |
| 85 { | 85 { |
| 86 struct snd_soc_codec *codec = dai->codec; | 86 struct snd_soc_codec *codec = dai->codec; |
| 87 u16 mute_reg = snd_soc_read(codec, WM8728_DACCTL); | 87 u16 mute_reg = snd_soc_read(codec, WM8728_DACCTL); |
| 88 | 88 |
| 89 if (mute) | 89 if (mute) |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 static int wm8728_set_bias_level(struct snd_soc_codec *codec, | 173 static int wm8728_set_bias_level(struct snd_soc_codec *codec, |
| 174 enum snd_soc_bias_level level) | 174 enum snd_soc_bias_level level) |
| 175 { | 175 { |
| 176 u16 reg; | 176 u16 reg; |
| 177 int i; | 177 int i; |
| 178 | 178 |
| 179 switch (level) { | 179 switch (level) { |
| 180 case SND_SOC_BIAS_ON: | 180 case SND_SOC_BIAS_ON: |
| 181 case SND_SOC_BIAS_PREPARE: | 181 case SND_SOC_BIAS_PREPARE: |
| 182 case SND_SOC_BIAS_STANDBY: | 182 case SND_SOC_BIAS_STANDBY: |
| 183 » » if (codec->bias_level == SND_SOC_BIAS_OFF) { | 183 » » if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { |
| 184 /* Power everything up... */ | 184 /* Power everything up... */ |
| 185 reg = snd_soc_read(codec, WM8728_DACCTL); | 185 reg = snd_soc_read(codec, WM8728_DACCTL); |
| 186 snd_soc_write(codec, WM8728_DACCTL, reg & ~0x4); | 186 snd_soc_write(codec, WM8728_DACCTL, reg & ~0x4); |
| 187 | 187 |
| 188 /* ..then sync in the register cache. */ | 188 /* ..then sync in the register cache. */ |
| 189 for (i = 0; i < ARRAY_SIZE(wm8728_reg_defaults); i++) | 189 for (i = 0; i < ARRAY_SIZE(wm8728_reg_defaults); i++) |
| 190 snd_soc_write(codec, i, | 190 snd_soc_write(codec, i, |
| 191 snd_soc_read(codec, i)); | 191 snd_soc_read(codec, i)); |
| 192 } | 192 } |
| 193 break; | 193 break; |
| 194 | 194 |
| 195 case SND_SOC_BIAS_OFF: | 195 case SND_SOC_BIAS_OFF: |
| 196 reg = snd_soc_read(codec, WM8728_DACCTL); | 196 reg = snd_soc_read(codec, WM8728_DACCTL); |
| 197 snd_soc_write(codec, WM8728_DACCTL, reg | 0x4); | 197 snd_soc_write(codec, WM8728_DACCTL, reg | 0x4); |
| 198 break; | 198 break; |
| 199 } | 199 } |
| 200 » codec->bias_level = level; | 200 » codec->dapm.bias_level = level; |
| 201 return 0; | 201 return 0; |
| 202 } | 202 } |
| 203 | 203 |
| 204 #define WM8728_RATES (SNDRV_PCM_RATE_8000_192000) | 204 #define WM8728_RATES (SNDRV_PCM_RATE_8000_192000) |
| 205 | 205 |
| 206 #define WM8728_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ | 206 #define WM8728_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ |
| 207 SNDRV_PCM_FMTBIT_S24_LE) | 207 SNDRV_PCM_FMTBIT_S24_LE) |
| 208 | 208 |
| 209 static struct snd_soc_dai_ops wm8728_dai_ops = { | 209 static struct snd_soc_dai_ops wm8728_dai_ops = { |
| 210 .hw_params = wm8728_hw_params, | 210 .hw_params = wm8728_hw_params, |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 #endif | 387 #endif |
| 388 #if defined(CONFIG_SPI_MASTER) | 388 #if defined(CONFIG_SPI_MASTER) |
| 389 spi_unregister_driver(&wm8728_spi_driver); | 389 spi_unregister_driver(&wm8728_spi_driver); |
| 390 #endif | 390 #endif |
| 391 } | 391 } |
| 392 module_exit(wm8728_exit); | 392 module_exit(wm8728_exit); |
| 393 | 393 |
| 394 MODULE_DESCRIPTION("ASoC WM8728 driver"); | 394 MODULE_DESCRIPTION("ASoC WM8728 driver"); |
| 395 MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>"); | 395 MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>"); |
| 396 MODULE_LICENSE("GPL"); | 396 MODULE_LICENSE("GPL"); |
| OLD | NEW |