| OLD | NEW |
| 1 /* | 1 /* |
| 2 * wm8974.c -- WM8974 ALSA Soc Audio driver | 2 * wm8974.c -- WM8974 ALSA Soc Audio driver |
| 3 * | 3 * |
| 4 * Copyright 2006-2009 Wolfson Microelectronics PLC. | 4 * Copyright 2006-2009 Wolfson Microelectronics PLC. |
| 5 * | 5 * |
| 6 * Author: Liam Girdwood <linux@wolfsonmicro.com> | 6 * Author: Liam Girdwood <linux@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/kernel.h> | 15 #include <linux/kernel.h> |
| 16 #include <linux/init.h> | 16 #include <linux/init.h> |
| 17 #include <linux/delay.h> | 17 #include <linux/delay.h> |
| 18 #include <linux/pm.h> | 18 #include <linux/pm.h> |
| 19 #include <linux/i2c.h> | 19 #include <linux/i2c.h> |
| 20 #include <linux/platform_device.h> | 20 #include <linux/platform_device.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 "wm8974.h" | 29 #include "wm8974.h" |
| 31 | 30 |
| 32 static const u16 wm8974_reg[WM8974_CACHEREGNUM] = { | 31 static const u16 wm8974_reg[WM8974_CACHEREGNUM] = { |
| 33 0x0000, 0x0000, 0x0000, 0x0000, | 32 0x0000, 0x0000, 0x0000, 0x0000, |
| 34 0x0050, 0x0000, 0x0140, 0x0000, | 33 0x0050, 0x0000, 0x0140, 0x0000, |
| 35 0x0000, 0x0000, 0x0000, 0x00ff, | 34 0x0000, 0x0000, 0x0000, 0x00ff, |
| 36 0x0000, 0x0000, 0x0100, 0x00ff, | 35 0x0000, 0x0000, 0x0100, 0x00ff, |
| 37 0x0000, 0x0000, 0x012c, 0x002c, | 36 0x0000, 0x0000, 0x012c, 0x002c, |
| 38 0x002c, 0x002c, 0x002c, 0x0000, | 37 0x002c, 0x002c, 0x002c, 0x0000, |
| 39 0x0032, 0x0000, 0x0000, 0x0000, | 38 0x0032, 0x0000, 0x0000, 0x0000, |
| 40 0x0000, 0x0000, 0x0000, 0x0000, | 39 0x0000, 0x0000, 0x0000, 0x0000, |
| 41 0x0038, 0x000b, 0x0032, 0x0000, | 40 0x0038, 0x000b, 0x0032, 0x0000, |
| 42 0x0008, 0x000c, 0x0093, 0x00e9, | 41 0x0008, 0x000c, 0x0093, 0x00e9, |
| 43 0x0000, 0x0000, 0x0000, 0x0000, | 42 0x0000, 0x0000, 0x0000, 0x0000, |
| 44 0x0003, 0x0010, 0x0000, 0x0000, | 43 0x0003, 0x0010, 0x0000, 0x0000, |
| 45 0x0000, 0x0002, 0x0000, 0x0000, | 44 0x0000, 0x0002, 0x0000, 0x0000, |
| 46 0x0000, 0x0000, 0x0039, 0x0000, | 45 0x0000, 0x0000, 0x0039, 0x0000, |
| 47 0x0000, | 46 0x0000, |
| 48 }; | 47 }; |
| 49 | 48 |
| 50 #define WM8974_POWER1_BIASEN 0x08 | 49 #define WM8974_POWER1_BIASEN 0x08 |
| 51 #define WM8974_POWER1_BUFIOEN 0x04 | 50 #define WM8974_POWER1_BUFIOEN 0x04 |
| 52 | 51 |
| 53 struct wm8974_priv { | 52 struct wm8974_priv { |
| 54 enum snd_soc_control_type control_type; | 53 enum snd_soc_control_type control_type; |
| 55 u16 reg_cache[WM8974_CACHEREGNUM]; | |
| 56 }; | 54 }; |
| 57 | 55 |
| 58 #define wm8974_reset(c) snd_soc_write(c, WM8974_RESET, 0) | 56 #define wm8974_reset(c) snd_soc_write(c, WM8974_RESET, 0) |
| 59 | 57 |
| 60 static const char *wm8974_companding[] = {"Off", "NC", "u-law", "A-law" }; | 58 static const char *wm8974_companding[] = {"Off", "NC", "u-law", "A-law" }; |
| 61 static const char *wm8974_deemp[] = {"None", "32kHz", "44.1kHz", "48kHz" }; | 59 static const char *wm8974_deemp[] = {"None", "32kHz", "44.1kHz", "48kHz" }; |
| 62 static const char *wm8974_eqmode[] = {"Capture", "Playback" }; | 60 static const char *wm8974_eqmode[] = {"Capture", "Playback" }; |
| 63 static const char *wm8974_bw[] = {"Narrow", "Wide" }; | 61 static const char *wm8974_bw[] = {"Narrow", "Wide" }; |
| 64 static const char *wm8974_eq1[] = {"80Hz", "105Hz", "135Hz", "175Hz" }; | 62 static const char *wm8974_eq1[] = {"80Hz", "105Hz", "135Hz", "175Hz" }; |
| 65 static const char *wm8974_eq2[] = {"230Hz", "300Hz", "385Hz", "500Hz" }; | 63 static const char *wm8974_eq2[] = {"230Hz", "300Hz", "385Hz", "500Hz" }; |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 {"Input PGA", "Aux Switch", "Aux Input"}, | 265 {"Input PGA", "Aux Switch", "Aux Input"}, |
| 268 {"Input PGA", "MicN Switch", "MICN"}, | 266 {"Input PGA", "MicN Switch", "MICN"}, |
| 269 {"Input PGA", "MicP Switch", "MICP"}, | 267 {"Input PGA", "MicP Switch", "MICP"}, |
| 270 | 268 |
| 271 /* Inputs */ | 269 /* Inputs */ |
| 272 {"Aux Input", NULL, "AUX"}, | 270 {"Aux Input", NULL, "AUX"}, |
| 273 }; | 271 }; |
| 274 | 272 |
| 275 static int wm8974_add_widgets(struct snd_soc_codec *codec) | 273 static int wm8974_add_widgets(struct snd_soc_codec *codec) |
| 276 { | 274 { |
| 277 » snd_soc_dapm_new_controls(codec, wm8974_dapm_widgets, | 275 » struct snd_soc_dapm_context *dapm = &codec->dapm; |
| 276 |
| 277 » snd_soc_dapm_new_controls(dapm, wm8974_dapm_widgets, |
| 278 ARRAY_SIZE(wm8974_dapm_widgets)); | 278 ARRAY_SIZE(wm8974_dapm_widgets)); |
| 279 | 279 » snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); |
| 280 » snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); | |
| 281 | 280 |
| 282 return 0; | 281 return 0; |
| 283 } | 282 } |
| 284 | 283 |
| 285 struct pll_ { | 284 struct pll_ { |
| 286 unsigned int pre_div:1; | 285 unsigned int pre_div:1; |
| 287 unsigned int n:4; | 286 unsigned int n:4; |
| 288 unsigned int k; | 287 unsigned int k; |
| 289 }; | 288 }; |
| 290 | 289 |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 switch (level) { | 522 switch (level) { |
| 524 case SND_SOC_BIAS_ON: | 523 case SND_SOC_BIAS_ON: |
| 525 case SND_SOC_BIAS_PREPARE: | 524 case SND_SOC_BIAS_PREPARE: |
| 526 power1 |= 0x1; /* VMID 50k */ | 525 power1 |= 0x1; /* VMID 50k */ |
| 527 snd_soc_write(codec, WM8974_POWER1, power1); | 526 snd_soc_write(codec, WM8974_POWER1, power1); |
| 528 break; | 527 break; |
| 529 | 528 |
| 530 case SND_SOC_BIAS_STANDBY: | 529 case SND_SOC_BIAS_STANDBY: |
| 531 power1 |= WM8974_POWER1_BIASEN | WM8974_POWER1_BUFIOEN; | 530 power1 |= WM8974_POWER1_BIASEN | WM8974_POWER1_BUFIOEN; |
| 532 | 531 |
| 533 » » if (codec->bias_level == SND_SOC_BIAS_OFF) { | 532 » » if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { |
| 534 /* Initial cap charge at VMID 5k */ | 533 /* Initial cap charge at VMID 5k */ |
| 535 snd_soc_write(codec, WM8974_POWER1, power1 | 0x3); | 534 snd_soc_write(codec, WM8974_POWER1, power1 | 0x3); |
| 536 mdelay(100); | 535 mdelay(100); |
| 537 } | 536 } |
| 538 | 537 |
| 539 power1 |= 0x2; /* VMID 500k */ | 538 power1 |= 0x2; /* VMID 500k */ |
| 540 snd_soc_write(codec, WM8974_POWER1, power1); | 539 snd_soc_write(codec, WM8974_POWER1, power1); |
| 541 break; | 540 break; |
| 542 | 541 |
| 543 case SND_SOC_BIAS_OFF: | 542 case SND_SOC_BIAS_OFF: |
| 544 snd_soc_write(codec, WM8974_POWER1, 0); | 543 snd_soc_write(codec, WM8974_POWER1, 0); |
| 545 snd_soc_write(codec, WM8974_POWER2, 0); | 544 snd_soc_write(codec, WM8974_POWER2, 0); |
| 546 snd_soc_write(codec, WM8974_POWER3, 0); | 545 snd_soc_write(codec, WM8974_POWER3, 0); |
| 547 break; | 546 break; |
| 548 } | 547 } |
| 549 | 548 |
| 550 » codec->bias_level = level; | 549 » codec->dapm.bias_level = level; |
| 551 return 0; | 550 return 0; |
| 552 } | 551 } |
| 553 | 552 |
| 554 #define WM8974_RATES (SNDRV_PCM_RATE_8000_48000) | 553 #define WM8974_RATES (SNDRV_PCM_RATE_8000_48000) |
| 555 | 554 |
| 556 #define WM8974_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ | 555 #define WM8974_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ |
| 557 SNDRV_PCM_FMTBIT_S24_LE) | 556 SNDRV_PCM_FMTBIT_S24_LE) |
| 558 | 557 |
| 559 static struct snd_soc_dai_ops wm8974_ops = { | 558 static struct snd_soc_dai_ops wm8974_ops = { |
| 560 .hw_params = wm8974_pcm_hw_params, | 559 .hw_params = wm8974_pcm_hw_params, |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 { | 708 { |
| 710 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 709 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) |
| 711 i2c_del_driver(&wm8974_i2c_driver); | 710 i2c_del_driver(&wm8974_i2c_driver); |
| 712 #endif | 711 #endif |
| 713 } | 712 } |
| 714 module_exit(wm8974_exit); | 713 module_exit(wm8974_exit); |
| 715 | 714 |
| 716 MODULE_DESCRIPTION("ASoC WM8974 driver"); | 715 MODULE_DESCRIPTION("ASoC WM8974 driver"); |
| 717 MODULE_AUTHOR("Liam Girdwood"); | 716 MODULE_AUTHOR("Liam Girdwood"); |
| 718 MODULE_LICENSE("GPL"); | 717 MODULE_LICENSE("GPL"); |
| OLD | NEW |