diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-08-15 21:08:48 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-08-16 11:48:47 -0400 |
commit | 1ddc07d0f13a753f8e345e0538562e1899d2bc26 (patch) | |
tree | 30e9a0799f19f189a8be03ae619d350c47edc685 | |
parent | 70ce6aee664a3e61ca5b4278d61db6da0996cade (diff) |
ASoC: Add WM8958 noise gate support
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r-- | include/linux/mfd/wm8994/registers.h | 45 | ||||
-rw-r--r-- | sound/soc/codecs/wm8994-tables.c | 12 | ||||
-rw-r--r-- | sound/soc/codecs/wm8994.c | 38 |
3 files changed, 89 insertions, 6 deletions
diff --git a/include/linux/mfd/wm8994/registers.h b/include/linux/mfd/wm8994/registers.h index 64bf91e4dfa9..83ecdcd8aaf9 100644 --- a/include/linux/mfd/wm8994/registers.h +++ b/include/linux/mfd/wm8994/registers.h | |||
@@ -134,6 +134,8 @@ | |||
134 | #define WM8994_AIF1_DAC1_FILTERS_2 0x421 | 134 | #define WM8994_AIF1_DAC1_FILTERS_2 0x421 |
135 | #define WM8994_AIF1_DAC2_FILTERS_1 0x422 | 135 | #define WM8994_AIF1_DAC2_FILTERS_1 0x422 |
136 | #define WM8994_AIF1_DAC2_FILTERS_2 0x423 | 136 | #define WM8994_AIF1_DAC2_FILTERS_2 0x423 |
137 | #define WM8958_AIF1_DAC1_NOISE_GATE 0x430 | ||
138 | #define WM8958_AIF1_DAC2_NOISE_GATE 0x431 | ||
137 | #define WM8994_AIF1_DRC1_1 0x440 | 139 | #define WM8994_AIF1_DRC1_1 0x440 |
138 | #define WM8994_AIF1_DRC1_2 0x441 | 140 | #define WM8994_AIF1_DRC1_2 0x441 |
139 | #define WM8994_AIF1_DRC1_3 0x442 | 141 | #define WM8994_AIF1_DRC1_3 0x442 |
@@ -191,6 +193,7 @@ | |||
191 | #define WM8994_AIF2_ADC_FILTERS 0x510 | 193 | #define WM8994_AIF2_ADC_FILTERS 0x510 |
192 | #define WM8994_AIF2_DAC_FILTERS_1 0x520 | 194 | #define WM8994_AIF2_DAC_FILTERS_1 0x520 |
193 | #define WM8994_AIF2_DAC_FILTERS_2 0x521 | 195 | #define WM8994_AIF2_DAC_FILTERS_2 0x521 |
196 | #define WM8958_AIF2_DAC_NOISE_GATE 0x530 | ||
194 | #define WM8994_AIF2_DRC_1 0x540 | 197 | #define WM8994_AIF2_DRC_1 0x540 |
195 | #define WM8994_AIF2_DRC_2 0x541 | 198 | #define WM8994_AIF2_DRC_2 0x541 |
196 | #define WM8994_AIF2_DRC_3 0x542 | 199 | #define WM8994_AIF2_DRC_3 0x542 |
@@ -2988,6 +2991,34 @@ | |||
2988 | #define WM8994_AIF1DAC2_3D_ENA_WIDTH 1 /* AIF1DAC2_3D_ENA */ | 2991 | #define WM8994_AIF1DAC2_3D_ENA_WIDTH 1 /* AIF1DAC2_3D_ENA */ |
2989 | 2992 | ||
2990 | /* | 2993 | /* |
2994 | * R1072 (0x430) - AIF1 DAC1 Noise Gate | ||
2995 | */ | ||
2996 | #define WM8958_AIF1DAC1_NG_HLD_MASK 0x0060 /* AIF1DAC1_NG_HLD - [6:5] */ | ||
2997 | #define WM8958_AIF1DAC1_NG_HLD_SHIFT 5 /* AIF1DAC1_NG_HLD - [6:5] */ | ||
2998 | #define WM8958_AIF1DAC1_NG_HLD_WIDTH 2 /* AIF1DAC1_NG_HLD - [6:5] */ | ||
2999 | #define WM8958_AIF1DAC1_NG_THR_MASK 0x000E /* AIF1DAC1_NG_THR - [3:1] */ | ||
3000 | #define WM8958_AIF1DAC1_NG_THR_SHIFT 1 /* AIF1DAC1_NG_THR - [3:1] */ | ||
3001 | #define WM8958_AIF1DAC1_NG_THR_WIDTH 3 /* AIF1DAC1_NG_THR - [3:1] */ | ||
3002 | #define WM8958_AIF1DAC1_NG_ENA 0x0001 /* AIF1DAC1_NG_ENA */ | ||
3003 | #define WM8958_AIF1DAC1_NG_ENA_MASK 0x0001 /* AIF1DAC1_NG_ENA */ | ||
3004 | #define WM8958_AIF1DAC1_NG_ENA_SHIFT 0 /* AIF1DAC1_NG_ENA */ | ||
3005 | #define WM8958_AIF1DAC1_NG_ENA_WIDTH 1 /* AIF1DAC1_NG_ENA */ | ||
3006 | |||
3007 | /* | ||
3008 | * R1073 (0x431) - AIF1 DAC2 Noise Gate | ||
3009 | */ | ||
3010 | #define WM8958_AIF1DAC2_NG_HLD_MASK 0x0060 /* AIF1DAC2_NG_HLD - [6:5] */ | ||
3011 | #define WM8958_AIF1DAC2_NG_HLD_SHIFT 5 /* AIF1DAC2_NG_HLD - [6:5] */ | ||
3012 | #define WM8958_AIF1DAC2_NG_HLD_WIDTH 2 /* AIF1DAC2_NG_HLD - [6:5] */ | ||
3013 | #define WM8958_AIF1DAC2_NG_THR_MASK 0x000E /* AIF1DAC2_NG_THR - [3:1] */ | ||
3014 | #define WM8958_AIF1DAC2_NG_THR_SHIFT 1 /* AIF1DAC2_NG_THR - [3:1] */ | ||
3015 | #define WM8958_AIF1DAC2_NG_THR_WIDTH 3 /* AIF1DAC2_NG_THR - [3:1] */ | ||
3016 | #define WM8958_AIF1DAC2_NG_ENA 0x0001 /* AIF1DAC2_NG_ENA */ | ||
3017 | #define WM8958_AIF1DAC2_NG_ENA_MASK 0x0001 /* AIF1DAC2_NG_ENA */ | ||
3018 | #define WM8958_AIF1DAC2_NG_ENA_SHIFT 0 /* AIF1DAC2_NG_ENA */ | ||
3019 | #define WM8958_AIF1DAC2_NG_ENA_WIDTH 1 /* AIF1DAC2_NG_ENA */ | ||
3020 | |||
3021 | /* | ||
2991 | * R1088 (0x440) - AIF1 DRC1 (1) | 3022 | * R1088 (0x440) - AIF1 DRC1 (1) |
2992 | */ | 3023 | */ |
2993 | #define WM8994_AIF1DRC1_SIG_DET_RMS_MASK 0xF800 /* AIF1DRC1_SIG_DET_RMS - [15:11] */ | 3024 | #define WM8994_AIF1DRC1_SIG_DET_RMS_MASK 0xF800 /* AIF1DRC1_SIG_DET_RMS - [15:11] */ |
@@ -3599,6 +3630,20 @@ | |||
3599 | #define WM8994_AIF2DAC_3D_ENA_WIDTH 1 /* AIF2DAC_3D_ENA */ | 3630 | #define WM8994_AIF2DAC_3D_ENA_WIDTH 1 /* AIF2DAC_3D_ENA */ |
3600 | 3631 | ||
3601 | /* | 3632 | /* |
3633 | * R1328 (0x530) - AIF2 DAC Noise Gate | ||
3634 | */ | ||
3635 | #define WM8958_AIF2DAC_NG_HLD_MASK 0x0060 /* AIF2DAC_NG_HLD - [6:5] */ | ||
3636 | #define WM8958_AIF2DAC_NG_HLD_SHIFT 5 /* AIF2DAC_NG_HLD - [6:5] */ | ||
3637 | #define WM8958_AIF2DAC_NG_HLD_WIDTH 2 /* AIF2DAC_NG_HLD - [6:5] */ | ||
3638 | #define WM8958_AIF2DAC_NG_THR_MASK 0x000E /* AIF2DAC_NG_THR - [3:1] */ | ||
3639 | #define WM8958_AIF2DAC_NG_THR_SHIFT 1 /* AIF2DAC_NG_THR - [3:1] */ | ||
3640 | #define WM8958_AIF2DAC_NG_THR_WIDTH 3 /* AIF2DAC_NG_THR - [3:1] */ | ||
3641 | #define WM8958_AIF2DAC_NG_ENA 0x0001 /* AIF2DAC_NG_ENA */ | ||
3642 | #define WM8958_AIF2DAC_NG_ENA_MASK 0x0001 /* AIF2DAC_NG_ENA */ | ||
3643 | #define WM8958_AIF2DAC_NG_ENA_SHIFT 0 /* AIF2DAC_NG_ENA */ | ||
3644 | #define WM8958_AIF2DAC_NG_ENA_WIDTH 1 /* AIF2DAC_NG_ENA */ | ||
3645 | |||
3646 | /* | ||
3602 | * R1344 (0x540) - AIF2 DRC (1) | 3647 | * R1344 (0x540) - AIF2 DRC (1) |
3603 | */ | 3648 | */ |
3604 | #define WM8994_AIF2DRC_SIG_DET_RMS_MASK 0xF800 /* AIF2DRC_SIG_DET_RMS - [15:11] */ | 3649 | #define WM8994_AIF2DRC_SIG_DET_RMS_MASK 0xF800 /* AIF2DRC_SIG_DET_RMS - [15:11] */ |
diff --git a/sound/soc/codecs/wm8994-tables.c b/sound/soc/codecs/wm8994-tables.c index 13e5a0186eb3..df5a8b9a250f 100644 --- a/sound/soc/codecs/wm8994-tables.c +++ b/sound/soc/codecs/wm8994-tables.c | |||
@@ -1073,8 +1073,8 @@ const struct wm8994_access_mask wm8994_access_masks[WM8994_CACHE_SIZE] = { | |||
1073 | { 0x0000, 0x0000 }, /* R1069 */ | 1073 | { 0x0000, 0x0000 }, /* R1069 */ |
1074 | { 0x0000, 0x0000 }, /* R1070 */ | 1074 | { 0x0000, 0x0000 }, /* R1070 */ |
1075 | { 0x0000, 0x0000 }, /* R1071 */ | 1075 | { 0x0000, 0x0000 }, /* R1071 */ |
1076 | { 0x0000, 0x0000 }, /* R1072 */ | 1076 | { 0x006F, 0x006F }, /* R1072 - AIF1 DAC1 Noise Gate */ |
1077 | { 0x0000, 0x0000 }, /* R1073 */ | 1077 | { 0x006F, 0x006F }, /* R1073 - AIF1 DAC2 Noise Gate */ |
1078 | { 0x0000, 0x0000 }, /* R1074 */ | 1078 | { 0x0000, 0x0000 }, /* R1074 */ |
1079 | { 0x0000, 0x0000 }, /* R1075 */ | 1079 | { 0x0000, 0x0000 }, /* R1075 */ |
1080 | { 0x0000, 0x0000 }, /* R1076 */ | 1080 | { 0x0000, 0x0000 }, /* R1076 */ |
@@ -1329,7 +1329,7 @@ const struct wm8994_access_mask wm8994_access_masks[WM8994_CACHE_SIZE] = { | |||
1329 | { 0x0000, 0x0000 }, /* R1325 */ | 1329 | { 0x0000, 0x0000 }, /* R1325 */ |
1330 | { 0x0000, 0x0000 }, /* R1326 */ | 1330 | { 0x0000, 0x0000 }, /* R1326 */ |
1331 | { 0x0000, 0x0000 }, /* R1327 */ | 1331 | { 0x0000, 0x0000 }, /* R1327 */ |
1332 | { 0x0000, 0x0000 }, /* R1328 */ | 1332 | { 0x006F, 0x006F }, /* R1328 - AIF2 DAC Noise Gate */ |
1333 | { 0x0000, 0x0000 }, /* R1329 */ | 1333 | { 0x0000, 0x0000 }, /* R1329 */ |
1334 | { 0x0000, 0x0000 }, /* R1330 */ | 1334 | { 0x0000, 0x0000 }, /* R1330 */ |
1335 | { 0x0000, 0x0000 }, /* R1331 */ | 1335 | { 0x0000, 0x0000 }, /* R1331 */ |
@@ -2646,8 +2646,8 @@ const u16 wm8994_reg_defaults[WM8994_CACHE_SIZE] = { | |||
2646 | 0x0000, /* R1069 */ | 2646 | 0x0000, /* R1069 */ |
2647 | 0x0000, /* R1070 */ | 2647 | 0x0000, /* R1070 */ |
2648 | 0x0000, /* R1071 */ | 2648 | 0x0000, /* R1071 */ |
2649 | 0x0000, /* R1072 */ | 2649 | 0x0068, /* R1072 - AIF1 DAC1 Noise Gate */ |
2650 | 0x0000, /* R1073 */ | 2650 | 0x0068, /* R1073 - AIF1 DAC2 Noise Gate */ |
2651 | 0x0000, /* R1074 */ | 2651 | 0x0000, /* R1074 */ |
2652 | 0x0000, /* R1075 */ | 2652 | 0x0000, /* R1075 */ |
2653 | 0x0000, /* R1076 */ | 2653 | 0x0000, /* R1076 */ |
@@ -2902,7 +2902,7 @@ const u16 wm8994_reg_defaults[WM8994_CACHE_SIZE] = { | |||
2902 | 0x0000, /* R1325 */ | 2902 | 0x0000, /* R1325 */ |
2903 | 0x0000, /* R1326 */ | 2903 | 0x0000, /* R1326 */ |
2904 | 0x0000, /* R1327 */ | 2904 | 0x0000, /* R1327 */ |
2905 | 0x0000, /* R1328 */ | 2905 | 0x0068, /* R1328 - AIF2 DAC Noise Gate */ |
2906 | 0x0000, /* R1329 */ | 2906 | 0x0000, /* R1329 */ |
2907 | 0x0000, /* R1330 */ | 2907 | 0x0000, /* R1330 */ |
2908 | 0x0000, /* R1331 */ | 2908 | 0x0000, /* R1331 */ |
diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c index 0f36eeeb5fae..a0d6274ec280 100644 --- a/sound/soc/codecs/wm8994.c +++ b/sound/soc/codecs/wm8994.c | |||
@@ -282,6 +282,7 @@ static const DECLARE_TLV_DB_SCALE(digital_tlv, -7200, 75, 1); | |||
282 | static const DECLARE_TLV_DB_SCALE(st_tlv, -3600, 300, 0); | 282 | static const DECLARE_TLV_DB_SCALE(st_tlv, -3600, 300, 0); |
283 | static const DECLARE_TLV_DB_SCALE(wm8994_3d_tlv, -1600, 183, 0); | 283 | static const DECLARE_TLV_DB_SCALE(wm8994_3d_tlv, -1600, 183, 0); |
284 | static const DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0); | 284 | static const DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0); |
285 | static const DECLARE_TLV_DB_SCALE(ng_tlv, -10200, 600, 0); | ||
285 | 286 | ||
286 | #define WM8994_DRC_SWITCH(xname, reg, shift) \ | 287 | #define WM8994_DRC_SWITCH(xname, reg, shift) \ |
287 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ | 288 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ |
@@ -661,8 +662,45 @@ SOC_SINGLE_TLV("AIF2 EQ5 Volume", WM8994_AIF2_EQ_GAINS_2, 6, 31, 0, | |||
661 | eq_tlv), | 662 | eq_tlv), |
662 | }; | 663 | }; |
663 | 664 | ||
665 | static const char *wm8958_ng_text[] = { | ||
666 | "30ms", "125ms", "250ms", "500ms", | ||
667 | }; | ||
668 | |||
669 | static const struct soc_enum wm8958_aif1dac1_ng_hold = | ||
670 | SOC_ENUM_SINGLE(WM8958_AIF1_DAC1_NOISE_GATE, | ||
671 | WM8958_AIF1DAC1_NG_THR_SHIFT, 4, wm8958_ng_text); | ||
672 | |||
673 | static const struct soc_enum wm8958_aif1dac2_ng_hold = | ||
674 | SOC_ENUM_SINGLE(WM8958_AIF1_DAC2_NOISE_GATE, | ||
675 | WM8958_AIF1DAC2_NG_THR_SHIFT, 4, wm8958_ng_text); | ||
676 | |||
677 | static const struct soc_enum wm8958_aif2dac_ng_hold = | ||
678 | SOC_ENUM_SINGLE(WM8958_AIF2_DAC_NOISE_GATE, | ||
679 | WM8958_AIF2DAC_NG_THR_SHIFT, 4, wm8958_ng_text); | ||
680 | |||
664 | static const struct snd_kcontrol_new wm8958_snd_controls[] = { | 681 | static const struct snd_kcontrol_new wm8958_snd_controls[] = { |
665 | SOC_SINGLE_TLV("AIF3 Boost Volume", WM8958_AIF3_CONTROL_2, 10, 3, 0, aif_tlv), | 682 | SOC_SINGLE_TLV("AIF3 Boost Volume", WM8958_AIF3_CONTROL_2, 10, 3, 0, aif_tlv), |
683 | |||
684 | SOC_SINGLE("AIF1DAC1 Noise Gate Switch", WM8958_AIF1_DAC1_NOISE_GATE, | ||
685 | WM8958_AIF1DAC1_NG_ENA_SHIFT, 1, 0), | ||
686 | SOC_ENUM("AIF1DAC1 Noise Gate Hold Time", wm8958_aif1dac1_ng_hold), | ||
687 | SOC_SINGLE_TLV("AIF1DAC1 Noise Gate Threshold Volume", | ||
688 | WM8958_AIF1_DAC1_NOISE_GATE, WM8958_AIF1DAC1_NG_THR_SHIFT, | ||
689 | 7, 1, ng_tlv), | ||
690 | |||
691 | SOC_SINGLE("AIF1DAC2 Noise Gate Switch", WM8958_AIF1_DAC2_NOISE_GATE, | ||
692 | WM8958_AIF1DAC2_NG_ENA_SHIFT, 1, 0), | ||
693 | SOC_ENUM("AIF1DAC2 Noise Gate Hold Time", wm8958_aif1dac2_ng_hold), | ||
694 | SOC_SINGLE_TLV("AIF1DAC2 Noise Gate Threshold Volume", | ||
695 | WM8958_AIF1_DAC2_NOISE_GATE, WM8958_AIF1DAC2_NG_THR_SHIFT, | ||
696 | 7, 1, ng_tlv), | ||
697 | |||
698 | SOC_SINGLE("AIF2DAC Noise Gate Switch", WM8958_AIF2_DAC_NOISE_GATE, | ||
699 | WM8958_AIF2DAC_NG_ENA_SHIFT, 1, 0), | ||
700 | SOC_ENUM("AIF2DAC Noise Gate Hold Time", wm8958_aif2dac_ng_hold), | ||
701 | SOC_SINGLE_TLV("AIF2DAC Noise Gate Threshold Volume", | ||
702 | WM8958_AIF2_DAC_NOISE_GATE, WM8958_AIF2DAC_NG_THR_SHIFT, | ||
703 | 7, 1, ng_tlv), | ||
666 | }; | 704 | }; |
667 | 705 | ||
668 | static int clk_sys_event(struct snd_soc_dapm_widget *w, | 706 | static int clk_sys_event(struct snd_soc_dapm_widget *w, |