1 // SPDX-License-Identifier: GPL-2.0-or-later 1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /* 2 /* 3 * wm9713.c -- ALSA Soc WM9713 codec support 3 * wm9713.c -- ALSA Soc WM9713 codec support 4 * 4 * 5 * Copyright 2006-10 Wolfson Microelectronics 5 * Copyright 2006-10 Wolfson Microelectronics PLC. 6 * Author: Liam Girdwood <lrg@slimlogic.co.uk> 6 * Author: Liam Girdwood <lrg@slimlogic.co.uk> 7 * 7 * 8 * Features:- 8 * Features:- 9 * 9 * 10 * o Support for AC97 Codec, Voice DAC and A 10 * o Support for AC97 Codec, Voice DAC and Aux DAC 11 * o Support for DAPM 11 * o Support for DAPM 12 */ 12 */ 13 13 14 #include <linux/init.h> 14 #include <linux/init.h> 15 #include <linux/slab.h> 15 #include <linux/slab.h> 16 #include <linux/mfd/wm97xx.h> 16 #include <linux/mfd/wm97xx.h> 17 #include <linux/module.h> 17 #include <linux/module.h> 18 #include <linux/device.h> 18 #include <linux/device.h> 19 #include <linux/regmap.h> 19 #include <linux/regmap.h> 20 #include <sound/core.h> 20 #include <sound/core.h> 21 #include <sound/pcm.h> 21 #include <sound/pcm.h> 22 #include <sound/ac97_codec.h> 22 #include <sound/ac97_codec.h> 23 #include <sound/ac97/codec.h> 23 #include <sound/ac97/codec.h> 24 #include <sound/ac97/compat.h> 24 #include <sound/ac97/compat.h> 25 #include <sound/initval.h> 25 #include <sound/initval.h> 26 #include <sound/pcm_params.h> 26 #include <sound/pcm_params.h> 27 #include <sound/tlv.h> 27 #include <sound/tlv.h> 28 #include <sound/soc.h> 28 #include <sound/soc.h> 29 29 30 #include "wm9713.h" 30 #include "wm9713.h" 31 31 32 #define WM9713_VENDOR_ID 0x574d4c13 32 #define WM9713_VENDOR_ID 0x574d4c13 33 #define WM9713_VENDOR_ID_MASK 0xffffffff 33 #define WM9713_VENDOR_ID_MASK 0xffffffff 34 34 35 struct wm9713_priv { 35 struct wm9713_priv { 36 struct snd_ac97 *ac97; 36 struct snd_ac97 *ac97; 37 u32 pll_in; /* PLL input frequency */ 37 u32 pll_in; /* PLL input frequency */ 38 unsigned int hp_mixer[2]; 38 unsigned int hp_mixer[2]; 39 struct mutex lock; 39 struct mutex lock; 40 struct wm97xx_platform_data *mfd_pdata 40 struct wm97xx_platform_data *mfd_pdata; 41 }; 41 }; 42 42 43 #define HPL_MIXER 0 43 #define HPL_MIXER 0 44 #define HPR_MIXER 1 44 #define HPR_MIXER 1 45 45 46 static const char *wm9713_mic_mixer[] = {"Ster 46 static const char *wm9713_mic_mixer[] = {"Stereo", "Mic 1", "Mic 2", "Mute"}; 47 static const char *wm9713_rec_mux[] = {"Stereo 47 static const char *wm9713_rec_mux[] = {"Stereo", "Left", "Right", "Mute"}; 48 static const char *wm9713_rec_src[] = 48 static const char *wm9713_rec_src[] = 49 {"Mic 1", "Mic 2", "Line", "Mono In", 49 {"Mic 1", "Mic 2", "Line", "Mono In", "Headphone", "Speaker", 50 "Mono Out", "Zh"}; 50 "Mono Out", "Zh"}; 51 static const char *wm9713_rec_gain[] = {"+1.5d 51 static const char *wm9713_rec_gain[] = {"+1.5dB Steps", "+0.75dB Steps"}; 52 static const char *wm9713_alc_select[] = {"Non 52 static const char *wm9713_alc_select[] = {"None", "Left", "Right", "Stereo"}; 53 static const char *wm9713_mono_pga[] = {"Vmid" 53 static const char *wm9713_mono_pga[] = {"Vmid", "Zh", "Mono", "Inv"}; 54 static const char *wm9713_spk_pga[] = 54 static const char *wm9713_spk_pga[] = 55 {"Vmid", "Zh", "Headphone", "Speaker", 55 {"Vmid", "Zh", "Headphone", "Speaker", "Inv", "Headphone Vmid", 56 "Speaker Vmid", "Inv Vmid"}; 56 "Speaker Vmid", "Inv Vmid"}; 57 static const char *wm9713_hp_pga[] = {"Vmid", 57 static const char *wm9713_hp_pga[] = {"Vmid", "Zh", "Headphone", 58 "Headphone Vmid"}; 58 "Headphone Vmid"}; 59 static const char *wm9713_out3_pga[] = {"Vmid" 59 static const char *wm9713_out3_pga[] = {"Vmid", "Zh", "Inv 1", "Inv 1 Vmid"}; 60 static const char *wm9713_out4_pga[] = {"Vmid" 60 static const char *wm9713_out4_pga[] = {"Vmid", "Zh", "Inv 2", "Inv 2 Vmid"}; 61 static const char *wm9713_dac_inv[] = 61 static const char *wm9713_dac_inv[] = 62 {"Off", "Mono", "Speaker", "Left Headp 62 {"Off", "Mono", "Speaker", "Left Headphone", "Right Headphone", 63 "Headphone Mono", "NC", "Vmid"}; 63 "Headphone Mono", "NC", "Vmid"}; 64 static const char *wm9713_bass[] = {"Linear Co 64 static const char *wm9713_bass[] = {"Linear Control", "Adaptive Boost"}; 65 static const char *wm9713_ng_type[] = {"Consta 65 static const char *wm9713_ng_type[] = {"Constant Gain", "Mute"}; 66 static const char *wm9713_mic_select[] = {"Mic 66 static const char *wm9713_mic_select[] = {"Mic 1", "Mic 2 A", "Mic 2 B"}; 67 static const char *wm9713_micb_select[] = {"MP 67 static const char *wm9713_micb_select[] = {"MPB", "MPA"}; 68 68 69 static const struct soc_enum wm9713_enum[] = { 69 static const struct soc_enum wm9713_enum[] = { 70 SOC_ENUM_SINGLE(AC97_LINE, 3, 4, wm9713_mic_mi 70 SOC_ENUM_SINGLE(AC97_LINE, 3, 4, wm9713_mic_mixer), /* record mic mixer 0 */ 71 SOC_ENUM_SINGLE(AC97_VIDEO, 14, 4, wm9713_rec_ 71 SOC_ENUM_SINGLE(AC97_VIDEO, 14, 4, wm9713_rec_mux), /* record mux hp 1 */ 72 SOC_ENUM_SINGLE(AC97_VIDEO, 9, 4, wm9713_rec_m 72 SOC_ENUM_SINGLE(AC97_VIDEO, 9, 4, wm9713_rec_mux), /* record mux mono 2 */ 73 SOC_ENUM_SINGLE(AC97_VIDEO, 3, 8, wm9713_rec_s 73 SOC_ENUM_SINGLE(AC97_VIDEO, 3, 8, wm9713_rec_src), /* record mux left 3 */ 74 SOC_ENUM_SINGLE(AC97_VIDEO, 0, 8, wm9713_rec_s 74 SOC_ENUM_SINGLE(AC97_VIDEO, 0, 8, wm9713_rec_src), /* record mux right 4*/ 75 SOC_ENUM_DOUBLE(AC97_CD, 14, 6, 2, wm9713_rec_ 75 SOC_ENUM_DOUBLE(AC97_CD, 14, 6, 2, wm9713_rec_gain), /* record step size 5 */ 76 SOC_ENUM_SINGLE(AC97_PCI_SVID, 14, 4, wm9713_a 76 SOC_ENUM_SINGLE(AC97_PCI_SVID, 14, 4, wm9713_alc_select), /* alc source select 6*/ 77 SOC_ENUM_SINGLE(AC97_REC_GAIN, 14, 4, wm9713_m 77 SOC_ENUM_SINGLE(AC97_REC_GAIN, 14, 4, wm9713_mono_pga), /* mono input select 7 */ 78 SOC_ENUM_SINGLE(AC97_REC_GAIN, 11, 8, wm9713_s 78 SOC_ENUM_SINGLE(AC97_REC_GAIN, 11, 8, wm9713_spk_pga), /* speaker left input select 8 */ 79 SOC_ENUM_SINGLE(AC97_REC_GAIN, 8, 8, wm9713_sp 79 SOC_ENUM_SINGLE(AC97_REC_GAIN, 8, 8, wm9713_spk_pga), /* speaker right input select 9 */ 80 SOC_ENUM_SINGLE(AC97_REC_GAIN, 6, 3, wm9713_hp 80 SOC_ENUM_SINGLE(AC97_REC_GAIN, 6, 3, wm9713_hp_pga), /* headphone left input 10 */ 81 SOC_ENUM_SINGLE(AC97_REC_GAIN, 4, 3, wm9713_hp 81 SOC_ENUM_SINGLE(AC97_REC_GAIN, 4, 3, wm9713_hp_pga), /* headphone right input 11 */ 82 SOC_ENUM_SINGLE(AC97_REC_GAIN, 2, 4, wm9713_ou 82 SOC_ENUM_SINGLE(AC97_REC_GAIN, 2, 4, wm9713_out3_pga), /* out 3 source 12 */ 83 SOC_ENUM_SINGLE(AC97_REC_GAIN, 0, 4, wm9713_ou 83 SOC_ENUM_SINGLE(AC97_REC_GAIN, 0, 4, wm9713_out4_pga), /* out 4 source 13 */ 84 SOC_ENUM_SINGLE(AC97_REC_GAIN_MIC, 13, 8, wm97 84 SOC_ENUM_SINGLE(AC97_REC_GAIN_MIC, 13, 8, wm9713_dac_inv), /* dac invert 1 14 */ 85 SOC_ENUM_SINGLE(AC97_REC_GAIN_MIC, 10, 8, wm97 85 SOC_ENUM_SINGLE(AC97_REC_GAIN_MIC, 10, 8, wm9713_dac_inv), /* dac invert 2 15 */ 86 SOC_ENUM_SINGLE(AC97_GENERAL_PURPOSE, 15, 2, w 86 SOC_ENUM_SINGLE(AC97_GENERAL_PURPOSE, 15, 2, wm9713_bass), /* bass control 16 */ 87 SOC_ENUM_SINGLE(AC97_PCI_SVID, 5, 2, wm9713_ng 87 SOC_ENUM_SINGLE(AC97_PCI_SVID, 5, 2, wm9713_ng_type), /* noise gate type 17 */ 88 SOC_ENUM_SINGLE(AC97_3D_CONTROL, 12, 3, wm9713 88 SOC_ENUM_SINGLE(AC97_3D_CONTROL, 12, 3, wm9713_mic_select), /* mic selection 18 */ 89 SOC_ENUM_SINGLE_VIRT(2, wm9713_micb_select), / 89 SOC_ENUM_SINGLE_VIRT(2, wm9713_micb_select), /* mic selection 19 */ 90 }; 90 }; 91 91 92 static const DECLARE_TLV_DB_SCALE(out_tlv, -46 92 static const DECLARE_TLV_DB_SCALE(out_tlv, -4650, 150, 0); 93 static const DECLARE_TLV_DB_SCALE(main_tlv, -3 93 static const DECLARE_TLV_DB_SCALE(main_tlv, -3450, 150, 0); 94 static const DECLARE_TLV_DB_SCALE(misc_tlv, -1 94 static const DECLARE_TLV_DB_SCALE(misc_tlv, -1500, 300, 0); 95 static const DECLARE_TLV_DB_RANGE(mic_tlv, 95 static const DECLARE_TLV_DB_RANGE(mic_tlv, 96 0, 2, TLV_DB_SCALE_ITEM(1200, 600, 0), 96 0, 2, TLV_DB_SCALE_ITEM(1200, 600, 0), 97 3, 3, TLV_DB_SCALE_ITEM(3000, 0, 0) 97 3, 3, TLV_DB_SCALE_ITEM(3000, 0, 0) 98 ); 98 ); 99 99 100 static const struct snd_kcontrol_new wm9713_sn 100 static const struct snd_kcontrol_new wm9713_snd_ac97_controls[] = { 101 SOC_DOUBLE_TLV("Speaker Playback Volume", AC97 101 SOC_DOUBLE_TLV("Speaker Playback Volume", AC97_MASTER, 8, 0, 31, 1, out_tlv), 102 SOC_DOUBLE("Speaker Playback Switch", AC97_MAS 102 SOC_DOUBLE("Speaker Playback Switch", AC97_MASTER, 15, 7, 1, 1), 103 SOC_DOUBLE_TLV("Headphone Playback Volume", AC 103 SOC_DOUBLE_TLV("Headphone Playback Volume", AC97_HEADPHONE, 8, 0, 31, 1, 104 out_tlv), 104 out_tlv), 105 SOC_DOUBLE("Headphone Playback Switch", AC97_H 105 SOC_DOUBLE("Headphone Playback Switch", AC97_HEADPHONE, 15, 7, 1, 1), 106 SOC_DOUBLE_TLV("Line In Volume", AC97_PC_BEEP, 106 SOC_DOUBLE_TLV("Line In Volume", AC97_PC_BEEP, 8, 0, 31, 1, main_tlv), 107 SOC_DOUBLE_TLV("PCM Playback Volume", AC97_PHO 107 SOC_DOUBLE_TLV("PCM Playback Volume", AC97_PHONE, 8, 0, 31, 1, main_tlv), 108 SOC_SINGLE_TLV("Mic 1 Volume", AC97_MIC, 8, 31 108 SOC_SINGLE_TLV("Mic 1 Volume", AC97_MIC, 8, 31, 1, main_tlv), 109 SOC_SINGLE_TLV("Mic 2 Volume", AC97_MIC, 0, 31 109 SOC_SINGLE_TLV("Mic 2 Volume", AC97_MIC, 0, 31, 1, main_tlv), 110 SOC_SINGLE_TLV("Mic 1 Preamp Volume", AC97_3D_ 110 SOC_SINGLE_TLV("Mic 1 Preamp Volume", AC97_3D_CONTROL, 10, 3, 0, mic_tlv), 111 SOC_SINGLE_TLV("Mic 2 Preamp Volume", AC97_3D_ 111 SOC_SINGLE_TLV("Mic 2 Preamp Volume", AC97_3D_CONTROL, 12, 3, 0, mic_tlv), 112 112 113 SOC_SINGLE("Mic Boost (+20dB) Switch", AC97_LI 113 SOC_SINGLE("Mic Boost (+20dB) Switch", AC97_LINE, 5, 1, 0), 114 SOC_SINGLE("Mic Headphone Mixer Volume", AC97_ 114 SOC_SINGLE("Mic Headphone Mixer Volume", AC97_LINE, 0, 7, 1), 115 115 116 SOC_SINGLE("Capture Switch", AC97_CD, 15, 1, 1 116 SOC_SINGLE("Capture Switch", AC97_CD, 15, 1, 1), 117 SOC_ENUM("Capture Volume Steps", wm9713_enum[5 117 SOC_ENUM("Capture Volume Steps", wm9713_enum[5]), 118 SOC_DOUBLE("Capture Volume", AC97_CD, 8, 0, 31 118 SOC_DOUBLE("Capture Volume", AC97_CD, 8, 0, 31, 0), 119 SOC_SINGLE("Capture ZC Switch", AC97_CD, 7, 1, 119 SOC_SINGLE("Capture ZC Switch", AC97_CD, 7, 1, 0), 120 120 121 SOC_SINGLE_TLV("Capture to Headphone Volume", 121 SOC_SINGLE_TLV("Capture to Headphone Volume", AC97_VIDEO, 11, 7, 1, misc_tlv), 122 SOC_SINGLE("Capture to Mono Boost (+20dB) Swit 122 SOC_SINGLE("Capture to Mono Boost (+20dB) Switch", AC97_VIDEO, 8, 1, 0), 123 SOC_SINGLE("Capture ADC Boost (+20dB) Switch", 123 SOC_SINGLE("Capture ADC Boost (+20dB) Switch", AC97_VIDEO, 6, 1, 0), 124 124 125 SOC_SINGLE("ALC Target Volume", AC97_CODEC_CLA 125 SOC_SINGLE("ALC Target Volume", AC97_CODEC_CLASS_REV, 12, 15, 0), 126 SOC_SINGLE("ALC Hold Time", AC97_CODEC_CLASS_R 126 SOC_SINGLE("ALC Hold Time", AC97_CODEC_CLASS_REV, 8, 15, 0), 127 SOC_SINGLE("ALC Decay Time", AC97_CODEC_CLASS_ 127 SOC_SINGLE("ALC Decay Time", AC97_CODEC_CLASS_REV, 4, 15, 0), 128 SOC_SINGLE("ALC Attack Time", AC97_CODEC_CLASS 128 SOC_SINGLE("ALC Attack Time", AC97_CODEC_CLASS_REV, 0, 15, 0), 129 SOC_ENUM("ALC Function", wm9713_enum[6]), 129 SOC_ENUM("ALC Function", wm9713_enum[6]), 130 SOC_SINGLE("ALC Max Volume", AC97_PCI_SVID, 11 130 SOC_SINGLE("ALC Max Volume", AC97_PCI_SVID, 11, 7, 0), 131 SOC_SINGLE("ALC ZC Timeout", AC97_PCI_SVID, 9, 131 SOC_SINGLE("ALC ZC Timeout", AC97_PCI_SVID, 9, 3, 0), 132 SOC_SINGLE("ALC ZC Switch", AC97_PCI_SVID, 8, 132 SOC_SINGLE("ALC ZC Switch", AC97_PCI_SVID, 8, 1, 0), 133 SOC_SINGLE("ALC NG Switch", AC97_PCI_SVID, 7, 133 SOC_SINGLE("ALC NG Switch", AC97_PCI_SVID, 7, 1, 0), 134 SOC_ENUM("ALC NG Type", wm9713_enum[17]), 134 SOC_ENUM("ALC NG Type", wm9713_enum[17]), 135 SOC_SINGLE("ALC NG Threshold", AC97_PCI_SVID, 135 SOC_SINGLE("ALC NG Threshold", AC97_PCI_SVID, 0, 31, 0), 136 136 137 SOC_DOUBLE("Speaker Playback ZC Switch", AC97_ 137 SOC_DOUBLE("Speaker Playback ZC Switch", AC97_MASTER, 14, 6, 1, 0), 138 SOC_DOUBLE("Headphone Playback ZC Switch", AC9 138 SOC_DOUBLE("Headphone Playback ZC Switch", AC97_HEADPHONE, 14, 6, 1, 0), 139 139 140 SOC_SINGLE("Out4 Playback Switch", AC97_MASTER 140 SOC_SINGLE("Out4 Playback Switch", AC97_MASTER_MONO, 15, 1, 1), 141 SOC_SINGLE("Out4 Playback ZC Switch", AC97_MAS 141 SOC_SINGLE("Out4 Playback ZC Switch", AC97_MASTER_MONO, 14, 1, 0), 142 SOC_SINGLE_TLV("Out4 Playback Volume", AC97_MA 142 SOC_SINGLE_TLV("Out4 Playback Volume", AC97_MASTER_MONO, 8, 31, 1, out_tlv), 143 143 144 SOC_SINGLE("Out3 Playback Switch", AC97_MASTER 144 SOC_SINGLE("Out3 Playback Switch", AC97_MASTER_MONO, 7, 1, 1), 145 SOC_SINGLE("Out3 Playback ZC Switch", AC97_MAS 145 SOC_SINGLE("Out3 Playback ZC Switch", AC97_MASTER_MONO, 6, 1, 0), 146 SOC_SINGLE_TLV("Out3 Playback Volume", AC97_MA 146 SOC_SINGLE_TLV("Out3 Playback Volume", AC97_MASTER_MONO, 0, 31, 1, out_tlv), 147 147 148 SOC_SINGLE_TLV("Mono Capture Volume", AC97_MAS 148 SOC_SINGLE_TLV("Mono Capture Volume", AC97_MASTER_TONE, 8, 31, 1, main_tlv), 149 SOC_SINGLE("Mono Playback Switch", AC97_MASTER 149 SOC_SINGLE("Mono Playback Switch", AC97_MASTER_TONE, 7, 1, 1), 150 SOC_SINGLE("Mono Playback ZC Switch", AC97_MAS 150 SOC_SINGLE("Mono Playback ZC Switch", AC97_MASTER_TONE, 6, 1, 0), 151 SOC_SINGLE_TLV("Mono Playback Volume", AC97_MA 151 SOC_SINGLE_TLV("Mono Playback Volume", AC97_MASTER_TONE, 0, 31, 1, out_tlv), 152 152 153 SOC_SINGLE_TLV("Headphone Mixer Beep Playback 153 SOC_SINGLE_TLV("Headphone Mixer Beep Playback Volume", AC97_AUX, 12, 7, 1, 154 misc_tlv), 154 misc_tlv), 155 SOC_SINGLE_TLV("Speaker Mixer Beep Playback Vo 155 SOC_SINGLE_TLV("Speaker Mixer Beep Playback Volume", AC97_AUX, 8, 7, 1, 156 misc_tlv), 156 misc_tlv), 157 SOC_SINGLE_TLV("Mono Mixer Beep Playback Volum 157 SOC_SINGLE_TLV("Mono Mixer Beep Playback Volume", AC97_AUX, 4, 7, 1, misc_tlv), 158 158 159 SOC_SINGLE_TLV("Voice Playback Headphone Volum 159 SOC_SINGLE_TLV("Voice Playback Headphone Volume", AC97_PCM, 12, 7, 1, 160 misc_tlv), 160 misc_tlv), 161 SOC_SINGLE("Voice Playback Master Volume", AC9 161 SOC_SINGLE("Voice Playback Master Volume", AC97_PCM, 8, 7, 1), 162 SOC_SINGLE("Voice Playback Mono Volume", AC97_ 162 SOC_SINGLE("Voice Playback Mono Volume", AC97_PCM, 4, 7, 1), 163 163 164 SOC_SINGLE_TLV("Headphone Mixer Aux Playback V 164 SOC_SINGLE_TLV("Headphone Mixer Aux Playback Volume", AC97_REC_SEL, 12, 7, 1, 165 misc_tlv), 165 misc_tlv), 166 166 167 SOC_SINGLE_TLV("Speaker Mixer Voice Playback V 167 SOC_SINGLE_TLV("Speaker Mixer Voice Playback Volume", AC97_PCM, 8, 7, 1, 168 misc_tlv), 168 misc_tlv), 169 SOC_SINGLE_TLV("Speaker Mixer Aux Playback Vol 169 SOC_SINGLE_TLV("Speaker Mixer Aux Playback Volume", AC97_REC_SEL, 8, 7, 1, 170 misc_tlv), 170 misc_tlv), 171 171 172 SOC_SINGLE_TLV("Mono Mixer Voice Playback Volu 172 SOC_SINGLE_TLV("Mono Mixer Voice Playback Volume", AC97_PCM, 4, 7, 1, 173 misc_tlv), 173 misc_tlv), 174 SOC_SINGLE_TLV("Mono Mixer Aux Playback Volume 174 SOC_SINGLE_TLV("Mono Mixer Aux Playback Volume", AC97_REC_SEL, 4, 7, 1, 175 misc_tlv), 175 misc_tlv), 176 176 177 SOC_SINGLE("Aux Playback Headphone Volume", AC 177 SOC_SINGLE("Aux Playback Headphone Volume", AC97_REC_SEL, 12, 7, 1), 178 SOC_SINGLE("Aux Playback Master Volume", AC97_ 178 SOC_SINGLE("Aux Playback Master Volume", AC97_REC_SEL, 8, 7, 1), 179 179 180 SOC_ENUM("Bass Control", wm9713_enum[16]), 180 SOC_ENUM("Bass Control", wm9713_enum[16]), 181 SOC_SINGLE("Bass Cut-off Switch", AC97_GENERAL 181 SOC_SINGLE("Bass Cut-off Switch", AC97_GENERAL_PURPOSE, 12, 1, 1), 182 SOC_SINGLE("Tone Cut-off Switch", AC97_GENERAL 182 SOC_SINGLE("Tone Cut-off Switch", AC97_GENERAL_PURPOSE, 4, 1, 1), 183 SOC_SINGLE("Playback Attenuate (-6dB) Switch", 183 SOC_SINGLE("Playback Attenuate (-6dB) Switch", AC97_GENERAL_PURPOSE, 6, 1, 0), 184 SOC_SINGLE("Bass Volume", AC97_GENERAL_PURPOSE 184 SOC_SINGLE("Bass Volume", AC97_GENERAL_PURPOSE, 8, 15, 1), 185 SOC_SINGLE("Tone Volume", AC97_GENERAL_PURPOSE 185 SOC_SINGLE("Tone Volume", AC97_GENERAL_PURPOSE, 0, 15, 1), 186 186 187 SOC_SINGLE("3D Upper Cut-off Switch", AC97_REC 187 SOC_SINGLE("3D Upper Cut-off Switch", AC97_REC_GAIN_MIC, 5, 1, 0), 188 SOC_SINGLE("3D Lower Cut-off Switch", AC97_REC 188 SOC_SINGLE("3D Lower Cut-off Switch", AC97_REC_GAIN_MIC, 4, 1, 0), 189 SOC_SINGLE("3D Depth", AC97_REC_GAIN_MIC, 0, 1 189 SOC_SINGLE("3D Depth", AC97_REC_GAIN_MIC, 0, 15, 1), 190 }; 190 }; 191 191 192 static int wm9713_voice_shutdown(struct snd_so 192 static int wm9713_voice_shutdown(struct snd_soc_dapm_widget *w, 193 struct snd_kc 193 struct snd_kcontrol *kcontrol, int event) 194 { 194 { 195 struct snd_soc_component *component = 195 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 196 196 197 if (WARN_ON(event != SND_SOC_DAPM_PRE_ 197 if (WARN_ON(event != SND_SOC_DAPM_PRE_PMD)) 198 return -EINVAL; 198 return -EINVAL; 199 199 200 /* Gracefully shut down the voice inte 200 /* Gracefully shut down the voice interface. */ 201 snd_soc_component_update_bits(componen 201 snd_soc_component_update_bits(component, AC97_HANDSET_RATE, 0x0f00, 0x0200); 202 schedule_timeout_interruptible(msecs_t 202 schedule_timeout_interruptible(msecs_to_jiffies(1)); 203 snd_soc_component_update_bits(componen 203 snd_soc_component_update_bits(component, AC97_HANDSET_RATE, 0x0f00, 0x0f00); 204 snd_soc_component_update_bits(componen 204 snd_soc_component_update_bits(component, AC97_EXTENDED_MID, 0x1000, 0x1000); 205 205 206 return 0; 206 return 0; 207 } 207 } 208 208 209 static const unsigned int wm9713_mixer_mute_re 209 static const unsigned int wm9713_mixer_mute_regs[] = { 210 AC97_PC_BEEP, 210 AC97_PC_BEEP, 211 AC97_MASTER_TONE, 211 AC97_MASTER_TONE, 212 AC97_PHONE, 212 AC97_PHONE, 213 AC97_REC_SEL, 213 AC97_REC_SEL, 214 AC97_PCM, 214 AC97_PCM, 215 AC97_AUX, 215 AC97_AUX, 216 }; 216 }; 217 217 218 /* We have to create a fake left and right HP 218 /* We have to create a fake left and right HP mixers because 219 * the codec only has a single control that is 219 * the codec only has a single control that is shared by both channels. 220 * This makes it impossible to determine the a 220 * This makes it impossible to determine the audio path using the current 221 * register map, thus we add a new (virtual) r 221 * register map, thus we add a new (virtual) register to help determine the 222 * audio route within the device. 222 * audio route within the device. 223 */ 223 */ 224 static int wm9713_hp_mixer_put(struct snd_kcon 224 static int wm9713_hp_mixer_put(struct snd_kcontrol *kcontrol, 225 struct snd_ctl_elem_value *ucontrol) 225 struct snd_ctl_elem_value *ucontrol) 226 { 226 { 227 struct snd_soc_dapm_context *dapm = sn 227 struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); 228 struct snd_soc_component *component = 228 struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); 229 struct wm9713_priv *wm9713 = snd_soc_c 229 struct wm9713_priv *wm9713 = snd_soc_component_get_drvdata(component); 230 unsigned int val = ucontrol->value.int 230 unsigned int val = ucontrol->value.integer.value[0]; 231 struct soc_mixer_control *mc = 231 struct soc_mixer_control *mc = 232 (struct soc_mixer_control *)kc 232 (struct soc_mixer_control *)kcontrol->private_value; 233 unsigned int mixer, mask, shift, old; 233 unsigned int mixer, mask, shift, old; 234 struct snd_soc_dapm_update update = {} 234 struct snd_soc_dapm_update update = {}; 235 bool change; 235 bool change; 236 236 237 mixer = mc->shift >> 8; 237 mixer = mc->shift >> 8; 238 shift = mc->shift & 0xff; 238 shift = mc->shift & 0xff; 239 mask = (1 << shift); 239 mask = (1 << shift); 240 240 241 mutex_lock(&wm9713->lock); 241 mutex_lock(&wm9713->lock); 242 old = wm9713->hp_mixer[mixer]; 242 old = wm9713->hp_mixer[mixer]; 243 if (ucontrol->value.integer.value[0]) 243 if (ucontrol->value.integer.value[0]) 244 wm9713->hp_mixer[mixer] |= mas 244 wm9713->hp_mixer[mixer] |= mask; 245 else 245 else 246 wm9713->hp_mixer[mixer] &= ~ma 246 wm9713->hp_mixer[mixer] &= ~mask; 247 247 248 change = old != wm9713->hp_mixer[mixer 248 change = old != wm9713->hp_mixer[mixer]; 249 if (change) { 249 if (change) { 250 update.kcontrol = kcontrol; 250 update.kcontrol = kcontrol; 251 update.reg = wm9713_mixer_mute 251 update.reg = wm9713_mixer_mute_regs[shift]; 252 update.mask = 0x8000; 252 update.mask = 0x8000; 253 if ((wm9713->hp_mixer[0] & mas 253 if ((wm9713->hp_mixer[0] & mask) || 254 (wm9713->hp_mixer[1] & mas 254 (wm9713->hp_mixer[1] & mask)) 255 update.val = 0x0; 255 update.val = 0x0; 256 else 256 else 257 update.val = 0x8000; 257 update.val = 0x8000; 258 258 259 snd_soc_dapm_mixer_update_powe 259 snd_soc_dapm_mixer_update_power(dapm, kcontrol, val, 260 &update); 260 &update); 261 } 261 } 262 262 263 mutex_unlock(&wm9713->lock); 263 mutex_unlock(&wm9713->lock); 264 264 265 return change; 265 return change; 266 } 266 } 267 267 268 static int wm9713_hp_mixer_get(struct snd_kcon 268 static int wm9713_hp_mixer_get(struct snd_kcontrol *kcontrol, 269 struct snd_ctl_elem_value *ucontrol) 269 struct snd_ctl_elem_value *ucontrol) 270 { 270 { 271 struct snd_soc_dapm_context *dapm = sn 271 struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); 272 struct snd_soc_component *component = 272 struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); 273 struct wm9713_priv *wm9713 = snd_soc_c 273 struct wm9713_priv *wm9713 = snd_soc_component_get_drvdata(component); 274 struct soc_mixer_control *mc = 274 struct soc_mixer_control *mc = 275 (struct soc_mixer_control *)kc 275 (struct soc_mixer_control *)kcontrol->private_value; 276 unsigned int mixer, shift; 276 unsigned int mixer, shift; 277 277 278 mixer = mc->shift >> 8; 278 mixer = mc->shift >> 8; 279 shift = mc->shift & 0xff; 279 shift = mc->shift & 0xff; 280 280 281 ucontrol->value.integer.value[0] = 281 ucontrol->value.integer.value[0] = 282 (wm9713->hp_mixer[mixer] >> sh 282 (wm9713->hp_mixer[mixer] >> shift) & 1; 283 283 284 return 0; 284 return 0; 285 } 285 } 286 286 287 #define WM9713_HP_MIXER_CTRL(xname, xmixer, xs 287 #define WM9713_HP_MIXER_CTRL(xname, xmixer, xshift) { \ 288 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, . 288 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ 289 .info = snd_soc_info_volsw, \ 289 .info = snd_soc_info_volsw, \ 290 .get = wm9713_hp_mixer_get, .put = wm9 290 .get = wm9713_hp_mixer_get, .put = wm9713_hp_mixer_put, \ 291 .private_value = SOC_DOUBLE_VALUE(SND_ 291 .private_value = SOC_DOUBLE_VALUE(SND_SOC_NOPM, \ 292 xshift, xmixer, 1, 0, 0) \ 292 xshift, xmixer, 1, 0, 0) \ 293 } 293 } 294 294 295 /* Left Headphone Mixers */ 295 /* Left Headphone Mixers */ 296 static const struct snd_kcontrol_new wm9713_hp 296 static const struct snd_kcontrol_new wm9713_hpl_mixer_controls[] = { 297 WM9713_HP_MIXER_CTRL("Beep Playback Switch", H 297 WM9713_HP_MIXER_CTRL("Beep Playback Switch", HPL_MIXER, 5), 298 WM9713_HP_MIXER_CTRL("Voice Playback Switch", 298 WM9713_HP_MIXER_CTRL("Voice Playback Switch", HPL_MIXER, 4), 299 WM9713_HP_MIXER_CTRL("Aux Playback Switch", HP 299 WM9713_HP_MIXER_CTRL("Aux Playback Switch", HPL_MIXER, 3), 300 WM9713_HP_MIXER_CTRL("PCM Playback Switch", HP 300 WM9713_HP_MIXER_CTRL("PCM Playback Switch", HPL_MIXER, 2), 301 WM9713_HP_MIXER_CTRL("MonoIn Playback Switch", 301 WM9713_HP_MIXER_CTRL("MonoIn Playback Switch", HPL_MIXER, 1), 302 WM9713_HP_MIXER_CTRL("Bypass Playback Switch", 302 WM9713_HP_MIXER_CTRL("Bypass Playback Switch", HPL_MIXER, 0), 303 }; 303 }; 304 304 305 /* Right Headphone Mixers */ 305 /* Right Headphone Mixers */ 306 static const struct snd_kcontrol_new wm9713_hp 306 static const struct snd_kcontrol_new wm9713_hpr_mixer_controls[] = { 307 WM9713_HP_MIXER_CTRL("Beep Playback Switch", H 307 WM9713_HP_MIXER_CTRL("Beep Playback Switch", HPR_MIXER, 5), 308 WM9713_HP_MIXER_CTRL("Voice Playback Switch", 308 WM9713_HP_MIXER_CTRL("Voice Playback Switch", HPR_MIXER, 4), 309 WM9713_HP_MIXER_CTRL("Aux Playback Switch", HP 309 WM9713_HP_MIXER_CTRL("Aux Playback Switch", HPR_MIXER, 3), 310 WM9713_HP_MIXER_CTRL("PCM Playback Switch", HP 310 WM9713_HP_MIXER_CTRL("PCM Playback Switch", HPR_MIXER, 2), 311 WM9713_HP_MIXER_CTRL("MonoIn Playback Switch", 311 WM9713_HP_MIXER_CTRL("MonoIn Playback Switch", HPR_MIXER, 1), 312 WM9713_HP_MIXER_CTRL("Bypass Playback Switch", 312 WM9713_HP_MIXER_CTRL("Bypass Playback Switch", HPR_MIXER, 0), 313 }; 313 }; 314 314 315 /* headphone capture mux */ 315 /* headphone capture mux */ 316 static const struct snd_kcontrol_new wm9713_hp 316 static const struct snd_kcontrol_new wm9713_hp_rec_mux_controls = 317 SOC_DAPM_ENUM("Route", wm9713_enum[1]); 317 SOC_DAPM_ENUM("Route", wm9713_enum[1]); 318 318 319 /* headphone mic mux */ 319 /* headphone mic mux */ 320 static const struct snd_kcontrol_new wm9713_hp 320 static const struct snd_kcontrol_new wm9713_hp_mic_mux_controls = 321 SOC_DAPM_ENUM("Route", wm9713_enum[0]); 321 SOC_DAPM_ENUM("Route", wm9713_enum[0]); 322 322 323 /* Speaker Mixer */ 323 /* Speaker Mixer */ 324 static const struct snd_kcontrol_new wm9713_sp 324 static const struct snd_kcontrol_new wm9713_speaker_mixer_controls[] = { 325 SOC_DAPM_SINGLE("Beep Playback Switch", AC97_A 325 SOC_DAPM_SINGLE("Beep Playback Switch", AC97_AUX, 11, 1, 1), 326 SOC_DAPM_SINGLE("Voice Playback Switch", AC97_ 326 SOC_DAPM_SINGLE("Voice Playback Switch", AC97_PCM, 11, 1, 1), 327 SOC_DAPM_SINGLE("Aux Playback Switch", AC97_RE 327 SOC_DAPM_SINGLE("Aux Playback Switch", AC97_REC_SEL, 11, 1, 1), 328 SOC_DAPM_SINGLE("PCM Playback Switch", AC97_PH 328 SOC_DAPM_SINGLE("PCM Playback Switch", AC97_PHONE, 14, 1, 1), 329 SOC_DAPM_SINGLE("MonoIn Playback Switch", AC97 329 SOC_DAPM_SINGLE("MonoIn Playback Switch", AC97_MASTER_TONE, 14, 1, 1), 330 SOC_DAPM_SINGLE("Bypass Playback Switch", AC97 330 SOC_DAPM_SINGLE("Bypass Playback Switch", AC97_PC_BEEP, 14, 1, 1), 331 }; 331 }; 332 332 333 /* Mono Mixer */ 333 /* Mono Mixer */ 334 static const struct snd_kcontrol_new wm9713_mo 334 static const struct snd_kcontrol_new wm9713_mono_mixer_controls[] = { 335 SOC_DAPM_SINGLE("Beep Playback Switch", AC97_A 335 SOC_DAPM_SINGLE("Beep Playback Switch", AC97_AUX, 7, 1, 1), 336 SOC_DAPM_SINGLE("Voice Playback Switch", AC97_ 336 SOC_DAPM_SINGLE("Voice Playback Switch", AC97_PCM, 7, 1, 1), 337 SOC_DAPM_SINGLE("Aux Playback Switch", AC97_RE 337 SOC_DAPM_SINGLE("Aux Playback Switch", AC97_REC_SEL, 7, 1, 1), 338 SOC_DAPM_SINGLE("PCM Playback Switch", AC97_PH 338 SOC_DAPM_SINGLE("PCM Playback Switch", AC97_PHONE, 13, 1, 1), 339 SOC_DAPM_SINGLE("MonoIn Playback Switch", AC97 339 SOC_DAPM_SINGLE("MonoIn Playback Switch", AC97_MASTER_TONE, 13, 1, 1), 340 SOC_DAPM_SINGLE("Bypass Playback Switch", AC97 340 SOC_DAPM_SINGLE("Bypass Playback Switch", AC97_PC_BEEP, 13, 1, 1), 341 SOC_DAPM_SINGLE("Mic 1 Sidetone Switch", AC97_ 341 SOC_DAPM_SINGLE("Mic 1 Sidetone Switch", AC97_LINE, 7, 1, 1), 342 SOC_DAPM_SINGLE("Mic 2 Sidetone Switch", AC97_ 342 SOC_DAPM_SINGLE("Mic 2 Sidetone Switch", AC97_LINE, 6, 1, 1), 343 }; 343 }; 344 344 345 /* mono mic mux */ 345 /* mono mic mux */ 346 static const struct snd_kcontrol_new wm9713_mo 346 static const struct snd_kcontrol_new wm9713_mono_mic_mux_controls = 347 SOC_DAPM_ENUM("Route", wm9713_enum[2]); 347 SOC_DAPM_ENUM("Route", wm9713_enum[2]); 348 348 349 /* mono output mux */ 349 /* mono output mux */ 350 static const struct snd_kcontrol_new wm9713_mo 350 static const struct snd_kcontrol_new wm9713_mono_mux_controls = 351 SOC_DAPM_ENUM("Route", wm9713_enum[7]); 351 SOC_DAPM_ENUM("Route", wm9713_enum[7]); 352 352 353 /* speaker left output mux */ 353 /* speaker left output mux */ 354 static const struct snd_kcontrol_new wm9713_hp 354 static const struct snd_kcontrol_new wm9713_hp_spkl_mux_controls = 355 SOC_DAPM_ENUM("Route", wm9713_enum[8]); 355 SOC_DAPM_ENUM("Route", wm9713_enum[8]); 356 356 357 /* speaker right output mux */ 357 /* speaker right output mux */ 358 static const struct snd_kcontrol_new wm9713_hp 358 static const struct snd_kcontrol_new wm9713_hp_spkr_mux_controls = 359 SOC_DAPM_ENUM("Route", wm9713_enum[9]); 359 SOC_DAPM_ENUM("Route", wm9713_enum[9]); 360 360 361 /* headphone left output mux */ 361 /* headphone left output mux */ 362 static const struct snd_kcontrol_new wm9713_hp 362 static const struct snd_kcontrol_new wm9713_hpl_out_mux_controls = 363 SOC_DAPM_ENUM("Route", wm9713_enum[10]); 363 SOC_DAPM_ENUM("Route", wm9713_enum[10]); 364 364 365 /* headphone right output mux */ 365 /* headphone right output mux */ 366 static const struct snd_kcontrol_new wm9713_hp 366 static const struct snd_kcontrol_new wm9713_hpr_out_mux_controls = 367 SOC_DAPM_ENUM("Route", wm9713_enum[11]); 367 SOC_DAPM_ENUM("Route", wm9713_enum[11]); 368 368 369 /* Out3 mux */ 369 /* Out3 mux */ 370 static const struct snd_kcontrol_new wm9713_ou 370 static const struct snd_kcontrol_new wm9713_out3_mux_controls = 371 SOC_DAPM_ENUM("Route", wm9713_enum[12]); 371 SOC_DAPM_ENUM("Route", wm9713_enum[12]); 372 372 373 /* Out4 mux */ 373 /* Out4 mux */ 374 static const struct snd_kcontrol_new wm9713_ou 374 static const struct snd_kcontrol_new wm9713_out4_mux_controls = 375 SOC_DAPM_ENUM("Route", wm9713_enum[13]); 375 SOC_DAPM_ENUM("Route", wm9713_enum[13]); 376 376 377 /* DAC inv mux 1 */ 377 /* DAC inv mux 1 */ 378 static const struct snd_kcontrol_new wm9713_da 378 static const struct snd_kcontrol_new wm9713_dac_inv1_mux_controls = 379 SOC_DAPM_ENUM("Route", wm9713_enum[14]); 379 SOC_DAPM_ENUM("Route", wm9713_enum[14]); 380 380 381 /* DAC inv mux 2 */ 381 /* DAC inv mux 2 */ 382 static const struct snd_kcontrol_new wm9713_da 382 static const struct snd_kcontrol_new wm9713_dac_inv2_mux_controls = 383 SOC_DAPM_ENUM("Route", wm9713_enum[15]); 383 SOC_DAPM_ENUM("Route", wm9713_enum[15]); 384 384 385 /* Capture source left */ 385 /* Capture source left */ 386 static const struct snd_kcontrol_new wm9713_re 386 static const struct snd_kcontrol_new wm9713_rec_srcl_mux_controls = 387 SOC_DAPM_ENUM("Route", wm9713_enum[3]); 387 SOC_DAPM_ENUM("Route", wm9713_enum[3]); 388 388 389 /* Capture source right */ 389 /* Capture source right */ 390 static const struct snd_kcontrol_new wm9713_re 390 static const struct snd_kcontrol_new wm9713_rec_srcr_mux_controls = 391 SOC_DAPM_ENUM("Route", wm9713_enum[4]); 391 SOC_DAPM_ENUM("Route", wm9713_enum[4]); 392 392 393 /* mic source */ 393 /* mic source */ 394 static const struct snd_kcontrol_new wm9713_mi 394 static const struct snd_kcontrol_new wm9713_mic_sel_mux_controls = 395 SOC_DAPM_ENUM("Route", wm9713_enum[18]); 395 SOC_DAPM_ENUM("Route", wm9713_enum[18]); 396 396 397 /* mic source B virtual control */ 397 /* mic source B virtual control */ 398 static const struct snd_kcontrol_new wm9713_mi 398 static const struct snd_kcontrol_new wm9713_micb_sel_mux_controls = 399 SOC_DAPM_ENUM("Route", wm9713_enum[19]); 399 SOC_DAPM_ENUM("Route", wm9713_enum[19]); 400 400 401 static const struct snd_soc_dapm_widget wm9713 401 static const struct snd_soc_dapm_widget wm9713_dapm_widgets[] = { 402 SND_SOC_DAPM_MUX("Capture Headphone Mux", SND_ 402 SND_SOC_DAPM_MUX("Capture Headphone Mux", SND_SOC_NOPM, 0, 0, 403 &wm9713_hp_rec_mux_controls), 403 &wm9713_hp_rec_mux_controls), 404 SND_SOC_DAPM_MUX("Sidetone Mux", SND_SOC_NOPM, 404 SND_SOC_DAPM_MUX("Sidetone Mux", SND_SOC_NOPM, 0, 0, 405 &wm9713_hp_mic_mux_controls), 405 &wm9713_hp_mic_mux_controls), 406 SND_SOC_DAPM_MUX("Capture Mono Mux", SND_SOC_N 406 SND_SOC_DAPM_MUX("Capture Mono Mux", SND_SOC_NOPM, 0, 0, 407 &wm9713_mono_mic_mux_controls), 407 &wm9713_mono_mic_mux_controls), 408 SND_SOC_DAPM_MUX("Mono Out Mux", SND_SOC_NOPM, 408 SND_SOC_DAPM_MUX("Mono Out Mux", SND_SOC_NOPM, 0, 0, 409 &wm9713_mono_mux_controls), 409 &wm9713_mono_mux_controls), 410 SND_SOC_DAPM_MUX("Left Speaker Out Mux", SND_S 410 SND_SOC_DAPM_MUX("Left Speaker Out Mux", SND_SOC_NOPM, 0, 0, 411 &wm9713_hp_spkl_mux_controls), 411 &wm9713_hp_spkl_mux_controls), 412 SND_SOC_DAPM_MUX("Right Speaker Out Mux", SND_ 412 SND_SOC_DAPM_MUX("Right Speaker Out Mux", SND_SOC_NOPM, 0, 0, 413 &wm9713_hp_spkr_mux_controls), 413 &wm9713_hp_spkr_mux_controls), 414 SND_SOC_DAPM_MUX("Left Headphone Out Mux", SND 414 SND_SOC_DAPM_MUX("Left Headphone Out Mux", SND_SOC_NOPM, 0, 0, 415 &wm9713_hpl_out_mux_controls), 415 &wm9713_hpl_out_mux_controls), 416 SND_SOC_DAPM_MUX("Right Headphone Out Mux", SN 416 SND_SOC_DAPM_MUX("Right Headphone Out Mux", SND_SOC_NOPM, 0, 0, 417 &wm9713_hpr_out_mux_controls), 417 &wm9713_hpr_out_mux_controls), 418 SND_SOC_DAPM_MUX("Out 3 Mux", SND_SOC_NOPM, 0, 418 SND_SOC_DAPM_MUX("Out 3 Mux", SND_SOC_NOPM, 0, 0, 419 &wm9713_out3_mux_controls), 419 &wm9713_out3_mux_controls), 420 SND_SOC_DAPM_MUX("Out 4 Mux", SND_SOC_NOPM, 0, 420 SND_SOC_DAPM_MUX("Out 4 Mux", SND_SOC_NOPM, 0, 0, 421 &wm9713_out4_mux_controls), 421 &wm9713_out4_mux_controls), 422 SND_SOC_DAPM_MUX("DAC Inv Mux 1", SND_SOC_NOPM 422 SND_SOC_DAPM_MUX("DAC Inv Mux 1", SND_SOC_NOPM, 0, 0, 423 &wm9713_dac_inv1_mux_controls), 423 &wm9713_dac_inv1_mux_controls), 424 SND_SOC_DAPM_MUX("DAC Inv Mux 2", SND_SOC_NOPM 424 SND_SOC_DAPM_MUX("DAC Inv Mux 2", SND_SOC_NOPM, 0, 0, 425 &wm9713_dac_inv2_mux_controls), 425 &wm9713_dac_inv2_mux_controls), 426 SND_SOC_DAPM_MUX("Left Capture Source", SND_SO 426 SND_SOC_DAPM_MUX("Left Capture Source", SND_SOC_NOPM, 0, 0, 427 &wm9713_rec_srcl_mux_controls), 427 &wm9713_rec_srcl_mux_controls), 428 SND_SOC_DAPM_MUX("Right Capture Source", SND_S 428 SND_SOC_DAPM_MUX("Right Capture Source", SND_SOC_NOPM, 0, 0, 429 &wm9713_rec_srcr_mux_controls), 429 &wm9713_rec_srcr_mux_controls), 430 SND_SOC_DAPM_MUX("Mic A Source", SND_SOC_NOPM, 430 SND_SOC_DAPM_MUX("Mic A Source", SND_SOC_NOPM, 0, 0, 431 &wm9713_mic_sel_mux_controls), 431 &wm9713_mic_sel_mux_controls), 432 SND_SOC_DAPM_MUX("Mic B Source", SND_SOC_NOPM, 432 SND_SOC_DAPM_MUX("Mic B Source", SND_SOC_NOPM, 0, 0, 433 &wm9713_micb_sel_mux_controls), 433 &wm9713_micb_sel_mux_controls), 434 SND_SOC_DAPM_MIXER("Left HP Mixer", AC97_EXTEN 434 SND_SOC_DAPM_MIXER("Left HP Mixer", AC97_EXTENDED_MID, 3, 1, 435 &wm9713_hpl_mixer_controls[0], ARRAY_S 435 &wm9713_hpl_mixer_controls[0], ARRAY_SIZE(wm9713_hpl_mixer_controls)), 436 SND_SOC_DAPM_MIXER("Right HP Mixer", AC97_EXTE 436 SND_SOC_DAPM_MIXER("Right HP Mixer", AC97_EXTENDED_MID, 2, 1, 437 &wm9713_hpr_mixer_controls[0], ARRAY_S 437 &wm9713_hpr_mixer_controls[0], ARRAY_SIZE(wm9713_hpr_mixer_controls)), 438 SND_SOC_DAPM_MIXER("Mono Mixer", AC97_EXTENDED 438 SND_SOC_DAPM_MIXER("Mono Mixer", AC97_EXTENDED_MID, 0, 1, 439 &wm9713_mono_mixer_controls[0], ARRAY_ 439 &wm9713_mono_mixer_controls[0], ARRAY_SIZE(wm9713_mono_mixer_controls)), 440 SND_SOC_DAPM_MIXER("Speaker Mixer", AC97_EXTEN 440 SND_SOC_DAPM_MIXER("Speaker Mixer", AC97_EXTENDED_MID, 1, 1, 441 &wm9713_speaker_mixer_controls[0], 441 &wm9713_speaker_mixer_controls[0], 442 ARRAY_SIZE(wm9713_speaker_mixer_contro 442 ARRAY_SIZE(wm9713_speaker_mixer_controls)), 443 SND_SOC_DAPM_DAC("Left DAC", "Left HiFi Playba 443 SND_SOC_DAPM_DAC("Left DAC", "Left HiFi Playback", AC97_EXTENDED_MID, 7, 1), 444 SND_SOC_DAPM_DAC("Right DAC", "Right HiFi Play 444 SND_SOC_DAPM_DAC("Right DAC", "Right HiFi Playback", AC97_EXTENDED_MID, 6, 1), 445 SND_SOC_DAPM_MIXER("AC97 Mixer", SND_SOC_NOPM, 445 SND_SOC_DAPM_MIXER("AC97 Mixer", SND_SOC_NOPM, 0, 0, NULL, 0), 446 SND_SOC_DAPM_MIXER("HP Mixer", SND_SOC_NOPM, 0 446 SND_SOC_DAPM_MIXER("HP Mixer", SND_SOC_NOPM, 0, 0, NULL, 0), 447 SND_SOC_DAPM_MIXER("Line Mixer", SND_SOC_NOPM, 447 SND_SOC_DAPM_MIXER("Line Mixer", SND_SOC_NOPM, 0, 0, NULL, 0), 448 SND_SOC_DAPM_MIXER("Capture Mixer", SND_SOC_NO 448 SND_SOC_DAPM_MIXER("Capture Mixer", SND_SOC_NOPM, 0, 0, NULL, 0), 449 SND_SOC_DAPM_DAC_E("Voice DAC", "Voice Playbac 449 SND_SOC_DAPM_DAC_E("Voice DAC", "Voice Playback", AC97_EXTENDED_MID, 12, 1, 450 wm9713_voice_shutdown, SND_ 450 wm9713_voice_shutdown, SND_SOC_DAPM_PRE_PMD), 451 SND_SOC_DAPM_DAC("Aux DAC", "Aux Playback", AC 451 SND_SOC_DAPM_DAC("Aux DAC", "Aux Playback", AC97_EXTENDED_MID, 11, 1), 452 SND_SOC_DAPM_PGA("Left ADC", AC97_EXTENDED_MID 452 SND_SOC_DAPM_PGA("Left ADC", AC97_EXTENDED_MID, 5, 1, NULL, 0), 453 SND_SOC_DAPM_PGA("Right ADC", AC97_EXTENDED_MI 453 SND_SOC_DAPM_PGA("Right ADC", AC97_EXTENDED_MID, 4, 1, NULL, 0), 454 SND_SOC_DAPM_ADC("Left HiFi ADC", "Left HiFi C 454 SND_SOC_DAPM_ADC("Left HiFi ADC", "Left HiFi Capture", SND_SOC_NOPM, 0, 0), 455 SND_SOC_DAPM_ADC("Right HiFi ADC", "Right HiFi 455 SND_SOC_DAPM_ADC("Right HiFi ADC", "Right HiFi Capture", SND_SOC_NOPM, 0, 0), 456 SND_SOC_DAPM_ADC("Left Voice ADC", "Left Voice 456 SND_SOC_DAPM_ADC("Left Voice ADC", "Left Voice Capture", SND_SOC_NOPM, 0, 0), 457 SND_SOC_DAPM_ADC("Right Voice ADC", "Right Voi 457 SND_SOC_DAPM_ADC("Right Voice ADC", "Right Voice Capture", SND_SOC_NOPM, 0, 0), 458 SND_SOC_DAPM_PGA("Left Headphone", AC97_EXTEND 458 SND_SOC_DAPM_PGA("Left Headphone", AC97_EXTENDED_MSTATUS, 10, 1, NULL, 0), 459 SND_SOC_DAPM_PGA("Right Headphone", AC97_EXTEN 459 SND_SOC_DAPM_PGA("Right Headphone", AC97_EXTENDED_MSTATUS, 9, 1, NULL, 0), 460 SND_SOC_DAPM_PGA("Left Speaker", AC97_EXTENDED 460 SND_SOC_DAPM_PGA("Left Speaker", AC97_EXTENDED_MSTATUS, 8, 1, NULL, 0), 461 SND_SOC_DAPM_PGA("Right Speaker", AC97_EXTENDE 461 SND_SOC_DAPM_PGA("Right Speaker", AC97_EXTENDED_MSTATUS, 7, 1, NULL, 0), 462 SND_SOC_DAPM_PGA("Out 3", AC97_EXTENDED_MSTATU 462 SND_SOC_DAPM_PGA("Out 3", AC97_EXTENDED_MSTATUS, 11, 1, NULL, 0), 463 SND_SOC_DAPM_PGA("Out 4", AC97_EXTENDED_MSTATU 463 SND_SOC_DAPM_PGA("Out 4", AC97_EXTENDED_MSTATUS, 12, 1, NULL, 0), 464 SND_SOC_DAPM_PGA("Mono Out", AC97_EXTENDED_MST 464 SND_SOC_DAPM_PGA("Mono Out", AC97_EXTENDED_MSTATUS, 13, 1, NULL, 0), 465 SND_SOC_DAPM_PGA("Left Line In", AC97_EXTENDED 465 SND_SOC_DAPM_PGA("Left Line In", AC97_EXTENDED_MSTATUS, 6, 1, NULL, 0), 466 SND_SOC_DAPM_PGA("Right Line In", AC97_EXTENDE 466 SND_SOC_DAPM_PGA("Right Line In", AC97_EXTENDED_MSTATUS, 5, 1, NULL, 0), 467 SND_SOC_DAPM_PGA("Mono In", AC97_EXTENDED_MSTA 467 SND_SOC_DAPM_PGA("Mono In", AC97_EXTENDED_MSTATUS, 4, 1, NULL, 0), 468 SND_SOC_DAPM_PGA("Mic A PGA", AC97_EXTENDED_MS 468 SND_SOC_DAPM_PGA("Mic A PGA", AC97_EXTENDED_MSTATUS, 3, 1, NULL, 0), 469 SND_SOC_DAPM_PGA("Mic B PGA", AC97_EXTENDED_MS 469 SND_SOC_DAPM_PGA("Mic B PGA", AC97_EXTENDED_MSTATUS, 2, 1, NULL, 0), 470 SND_SOC_DAPM_PGA("Mic A Pre Amp", AC97_EXTENDE 470 SND_SOC_DAPM_PGA("Mic A Pre Amp", AC97_EXTENDED_MSTATUS, 1, 1, NULL, 0), 471 SND_SOC_DAPM_PGA("Mic B Pre Amp", AC97_EXTENDE 471 SND_SOC_DAPM_PGA("Mic B Pre Amp", AC97_EXTENDED_MSTATUS, 0, 1, NULL, 0), 472 SND_SOC_DAPM_MICBIAS("Mic Bias", AC97_EXTENDED 472 SND_SOC_DAPM_MICBIAS("Mic Bias", AC97_EXTENDED_MSTATUS, 14, 1), 473 SND_SOC_DAPM_OUTPUT("MONO"), 473 SND_SOC_DAPM_OUTPUT("MONO"), 474 SND_SOC_DAPM_OUTPUT("HPL"), 474 SND_SOC_DAPM_OUTPUT("HPL"), 475 SND_SOC_DAPM_OUTPUT("HPR"), 475 SND_SOC_DAPM_OUTPUT("HPR"), 476 SND_SOC_DAPM_OUTPUT("SPKL"), 476 SND_SOC_DAPM_OUTPUT("SPKL"), 477 SND_SOC_DAPM_OUTPUT("SPKR"), 477 SND_SOC_DAPM_OUTPUT("SPKR"), 478 SND_SOC_DAPM_OUTPUT("OUT3"), 478 SND_SOC_DAPM_OUTPUT("OUT3"), 479 SND_SOC_DAPM_OUTPUT("OUT4"), 479 SND_SOC_DAPM_OUTPUT("OUT4"), 480 SND_SOC_DAPM_INPUT("LINEL"), 480 SND_SOC_DAPM_INPUT("LINEL"), 481 SND_SOC_DAPM_INPUT("LINER"), 481 SND_SOC_DAPM_INPUT("LINER"), 482 SND_SOC_DAPM_INPUT("MONOIN"), 482 SND_SOC_DAPM_INPUT("MONOIN"), 483 SND_SOC_DAPM_INPUT("PCBEEP"), 483 SND_SOC_DAPM_INPUT("PCBEEP"), 484 SND_SOC_DAPM_INPUT("MIC1"), 484 SND_SOC_DAPM_INPUT("MIC1"), 485 SND_SOC_DAPM_INPUT("MIC2A"), 485 SND_SOC_DAPM_INPUT("MIC2A"), 486 SND_SOC_DAPM_INPUT("MIC2B"), 486 SND_SOC_DAPM_INPUT("MIC2B"), 487 SND_SOC_DAPM_VMID("VMID"), 487 SND_SOC_DAPM_VMID("VMID"), 488 }; 488 }; 489 489 490 static const struct snd_soc_dapm_route wm9713_ 490 static const struct snd_soc_dapm_route wm9713_audio_map[] = { 491 /* left HP mixer */ 491 /* left HP mixer */ 492 {"Left HP Mixer", "Beep Playback Switc 492 {"Left HP Mixer", "Beep Playback Switch", "PCBEEP"}, 493 {"Left HP Mixer", "Voice Playback Swit 493 {"Left HP Mixer", "Voice Playback Switch", "Voice DAC"}, 494 {"Left HP Mixer", "Aux Playback Switch 494 {"Left HP Mixer", "Aux Playback Switch", "Aux DAC"}, 495 {"Left HP Mixer", "Bypass Playback Swi 495 {"Left HP Mixer", "Bypass Playback Switch", "Left Line In"}, 496 {"Left HP Mixer", "PCM Playback Switch 496 {"Left HP Mixer", "PCM Playback Switch", "Left DAC"}, 497 {"Left HP Mixer", "MonoIn Playback Swi 497 {"Left HP Mixer", "MonoIn Playback Switch", "Mono In"}, 498 {"Left HP Mixer", NULL, "Capture Head 498 {"Left HP Mixer", NULL, "Capture Headphone Mux"}, 499 499 500 /* right HP mixer */ 500 /* right HP mixer */ 501 {"Right HP Mixer", "Beep Playback Swit 501 {"Right HP Mixer", "Beep Playback Switch", "PCBEEP"}, 502 {"Right HP Mixer", "Voice Playback Swi 502 {"Right HP Mixer", "Voice Playback Switch", "Voice DAC"}, 503 {"Right HP Mixer", "Aux Playback Switc 503 {"Right HP Mixer", "Aux Playback Switch", "Aux DAC"}, 504 {"Right HP Mixer", "Bypass Playback Sw 504 {"Right HP Mixer", "Bypass Playback Switch", "Right Line In"}, 505 {"Right HP Mixer", "PCM Playback Switc 505 {"Right HP Mixer", "PCM Playback Switch", "Right DAC"}, 506 {"Right HP Mixer", "MonoIn Playback Sw 506 {"Right HP Mixer", "MonoIn Playback Switch", "Mono In"}, 507 {"Right HP Mixer", NULL, "Capture Hea 507 {"Right HP Mixer", NULL, "Capture Headphone Mux"}, 508 508 509 /* virtual mixer - mixes left & right 509 /* virtual mixer - mixes left & right channels for spk and mono */ 510 {"AC97 Mixer", NULL, "Left DAC"}, 510 {"AC97 Mixer", NULL, "Left DAC"}, 511 {"AC97 Mixer", NULL, "Right DAC"}, 511 {"AC97 Mixer", NULL, "Right DAC"}, 512 {"Line Mixer", NULL, "Right Line In"}, 512 {"Line Mixer", NULL, "Right Line In"}, 513 {"Line Mixer", NULL, "Left Line In"}, 513 {"Line Mixer", NULL, "Left Line In"}, 514 {"HP Mixer", NULL, "Left HP Mixer"}, 514 {"HP Mixer", NULL, "Left HP Mixer"}, 515 {"HP Mixer", NULL, "Right HP Mixer"}, 515 {"HP Mixer", NULL, "Right HP Mixer"}, 516 {"Capture Mixer", NULL, "Left Capture 516 {"Capture Mixer", NULL, "Left Capture Source"}, 517 {"Capture Mixer", NULL, "Right Capture 517 {"Capture Mixer", NULL, "Right Capture Source"}, 518 518 519 /* speaker mixer */ 519 /* speaker mixer */ 520 {"Speaker Mixer", "Beep Playback Switc 520 {"Speaker Mixer", "Beep Playback Switch", "PCBEEP"}, 521 {"Speaker Mixer", "Voice Playback Swit 521 {"Speaker Mixer", "Voice Playback Switch", "Voice DAC"}, 522 {"Speaker Mixer", "Aux Playback Switch 522 {"Speaker Mixer", "Aux Playback Switch", "Aux DAC"}, 523 {"Speaker Mixer", "Bypass Playback Swi 523 {"Speaker Mixer", "Bypass Playback Switch", "Line Mixer"}, 524 {"Speaker Mixer", "PCM Playback Switch 524 {"Speaker Mixer", "PCM Playback Switch", "AC97 Mixer"}, 525 {"Speaker Mixer", "MonoIn Playback Swi 525 {"Speaker Mixer", "MonoIn Playback Switch", "Mono In"}, 526 526 527 /* mono mixer */ 527 /* mono mixer */ 528 {"Mono Mixer", "Beep Playback Switch", 528 {"Mono Mixer", "Beep Playback Switch", "PCBEEP"}, 529 {"Mono Mixer", "Voice Playback Switch" 529 {"Mono Mixer", "Voice Playback Switch", "Voice DAC"}, 530 {"Mono Mixer", "Aux Playback Switch", 530 {"Mono Mixer", "Aux Playback Switch", "Aux DAC"}, 531 {"Mono Mixer", "Bypass Playback Switch 531 {"Mono Mixer", "Bypass Playback Switch", "Line Mixer"}, 532 {"Mono Mixer", "PCM Playback Switch", 532 {"Mono Mixer", "PCM Playback Switch", "AC97 Mixer"}, 533 {"Mono Mixer", "Mic 1 Sidetone Switch" 533 {"Mono Mixer", "Mic 1 Sidetone Switch", "Mic A PGA"}, 534 {"Mono Mixer", "Mic 2 Sidetone Switch" 534 {"Mono Mixer", "Mic 2 Sidetone Switch", "Mic B PGA"}, 535 {"Mono Mixer", NULL, "Capture Mono Mu 535 {"Mono Mixer", NULL, "Capture Mono Mux"}, 536 536 537 /* DAC inv mux 1 */ 537 /* DAC inv mux 1 */ 538 {"DAC Inv Mux 1", "Mono", "Mono Mixer" 538 {"DAC Inv Mux 1", "Mono", "Mono Mixer"}, 539 {"DAC Inv Mux 1", "Speaker", "Speaker 539 {"DAC Inv Mux 1", "Speaker", "Speaker Mixer"}, 540 {"DAC Inv Mux 1", "Left Headphone", "L 540 {"DAC Inv Mux 1", "Left Headphone", "Left HP Mixer"}, 541 {"DAC Inv Mux 1", "Right Headphone", " 541 {"DAC Inv Mux 1", "Right Headphone", "Right HP Mixer"}, 542 {"DAC Inv Mux 1", "Headphone Mono", "H 542 {"DAC Inv Mux 1", "Headphone Mono", "HP Mixer"}, 543 543 544 /* DAC inv mux 2 */ 544 /* DAC inv mux 2 */ 545 {"DAC Inv Mux 2", "Mono", "Mono Mixer" 545 {"DAC Inv Mux 2", "Mono", "Mono Mixer"}, 546 {"DAC Inv Mux 2", "Speaker", "Speaker 546 {"DAC Inv Mux 2", "Speaker", "Speaker Mixer"}, 547 {"DAC Inv Mux 2", "Left Headphone", "L 547 {"DAC Inv Mux 2", "Left Headphone", "Left HP Mixer"}, 548 {"DAC Inv Mux 2", "Right Headphone", " 548 {"DAC Inv Mux 2", "Right Headphone", "Right HP Mixer"}, 549 {"DAC Inv Mux 2", "Headphone Mono", "H 549 {"DAC Inv Mux 2", "Headphone Mono", "HP Mixer"}, 550 550 551 /* headphone left mux */ 551 /* headphone left mux */ 552 {"Left Headphone Out Mux", "Headphone" 552 {"Left Headphone Out Mux", "Headphone", "Left HP Mixer"}, 553 553 554 /* headphone right mux */ 554 /* headphone right mux */ 555 {"Right Headphone Out Mux", "Headphone 555 {"Right Headphone Out Mux", "Headphone", "Right HP Mixer"}, 556 556 557 /* speaker left mux */ 557 /* speaker left mux */ 558 {"Left Speaker Out Mux", "Headphone", 558 {"Left Speaker Out Mux", "Headphone", "Left HP Mixer"}, 559 {"Left Speaker Out Mux", "Speaker", "S 559 {"Left Speaker Out Mux", "Speaker", "Speaker Mixer"}, 560 {"Left Speaker Out Mux", "Inv", "DAC I 560 {"Left Speaker Out Mux", "Inv", "DAC Inv Mux 1"}, 561 561 562 /* speaker right mux */ 562 /* speaker right mux */ 563 {"Right Speaker Out Mux", "Headphone", 563 {"Right Speaker Out Mux", "Headphone", "Right HP Mixer"}, 564 {"Right Speaker Out Mux", "Speaker", " 564 {"Right Speaker Out Mux", "Speaker", "Speaker Mixer"}, 565 {"Right Speaker Out Mux", "Inv", "DAC 565 {"Right Speaker Out Mux", "Inv", "DAC Inv Mux 2"}, 566 566 567 /* mono mux */ 567 /* mono mux */ 568 {"Mono Out Mux", "Mono", "Mono Mixer"} 568 {"Mono Out Mux", "Mono", "Mono Mixer"}, 569 {"Mono Out Mux", "Inv", "DAC Inv Mux 1 569 {"Mono Out Mux", "Inv", "DAC Inv Mux 1"}, 570 570 571 /* out 3 mux */ 571 /* out 3 mux */ 572 {"Out 3 Mux", "Inv 1", "DAC Inv Mux 1" 572 {"Out 3 Mux", "Inv 1", "DAC Inv Mux 1"}, 573 573 574 /* out 4 mux */ 574 /* out 4 mux */ 575 {"Out 4 Mux", "Inv 2", "DAC Inv Mux 2" 575 {"Out 4 Mux", "Inv 2", "DAC Inv Mux 2"}, 576 576 577 /* output pga */ 577 /* output pga */ 578 {"HPL", NULL, "Left Headphone"}, 578 {"HPL", NULL, "Left Headphone"}, 579 {"Left Headphone", NULL, "Left Headpho 579 {"Left Headphone", NULL, "Left Headphone Out Mux"}, 580 {"HPR", NULL, "Right Headphone"}, 580 {"HPR", NULL, "Right Headphone"}, 581 {"Right Headphone", NULL, "Right Headp 581 {"Right Headphone", NULL, "Right Headphone Out Mux"}, 582 {"OUT3", NULL, "Out 3"}, 582 {"OUT3", NULL, "Out 3"}, 583 {"Out 3", NULL, "Out 3 Mux"}, 583 {"Out 3", NULL, "Out 3 Mux"}, 584 {"OUT4", NULL, "Out 4"}, 584 {"OUT4", NULL, "Out 4"}, 585 {"Out 4", NULL, "Out 4 Mux"}, 585 {"Out 4", NULL, "Out 4 Mux"}, 586 {"SPKL", NULL, "Left Speaker"}, 586 {"SPKL", NULL, "Left Speaker"}, 587 {"Left Speaker", NULL, "Left Speaker O 587 {"Left Speaker", NULL, "Left Speaker Out Mux"}, 588 {"SPKR", NULL, "Right Speaker"}, 588 {"SPKR", NULL, "Right Speaker"}, 589 {"Right Speaker", NULL, "Right Speaker 589 {"Right Speaker", NULL, "Right Speaker Out Mux"}, 590 {"MONO", NULL, "Mono Out"}, 590 {"MONO", NULL, "Mono Out"}, 591 {"Mono Out", NULL, "Mono Out Mux"}, 591 {"Mono Out", NULL, "Mono Out Mux"}, 592 592 593 /* input pga */ 593 /* input pga */ 594 {"Left Line In", NULL, "LINEL"}, 594 {"Left Line In", NULL, "LINEL"}, 595 {"Right Line In", NULL, "LINER"}, 595 {"Right Line In", NULL, "LINER"}, 596 {"Mono In", NULL, "MONOIN"}, 596 {"Mono In", NULL, "MONOIN"}, 597 {"Mic A PGA", NULL, "Mic A Pre Amp"}, 597 {"Mic A PGA", NULL, "Mic A Pre Amp"}, 598 {"Mic B PGA", NULL, "Mic B Pre Amp"}, 598 {"Mic B PGA", NULL, "Mic B Pre Amp"}, 599 599 600 /* left capture select */ 600 /* left capture select */ 601 {"Left Capture Source", "Mic 1", "Mic 601 {"Left Capture Source", "Mic 1", "Mic A Pre Amp"}, 602 {"Left Capture Source", "Mic 2", "Mic 602 {"Left Capture Source", "Mic 2", "Mic B Pre Amp"}, 603 {"Left Capture Source", "Line", "LINEL 603 {"Left Capture Source", "Line", "LINEL"}, 604 {"Left Capture Source", "Mono In", "MO 604 {"Left Capture Source", "Mono In", "MONOIN"}, 605 {"Left Capture Source", "Headphone", " 605 {"Left Capture Source", "Headphone", "Left HP Mixer"}, 606 {"Left Capture Source", "Speaker", "Sp 606 {"Left Capture Source", "Speaker", "Speaker Mixer"}, 607 {"Left Capture Source", "Mono Out", "M 607 {"Left Capture Source", "Mono Out", "Mono Mixer"}, 608 608 609 /* right capture select */ 609 /* right capture select */ 610 {"Right Capture Source", "Mic 1", "Mic 610 {"Right Capture Source", "Mic 1", "Mic A Pre Amp"}, 611 {"Right Capture Source", "Mic 2", "Mic 611 {"Right Capture Source", "Mic 2", "Mic B Pre Amp"}, 612 {"Right Capture Source", "Line", "LINE 612 {"Right Capture Source", "Line", "LINER"}, 613 {"Right Capture Source", "Mono In", "M 613 {"Right Capture Source", "Mono In", "MONOIN"}, 614 {"Right Capture Source", "Headphone", 614 {"Right Capture Source", "Headphone", "Right HP Mixer"}, 615 {"Right Capture Source", "Speaker", "S 615 {"Right Capture Source", "Speaker", "Speaker Mixer"}, 616 {"Right Capture Source", "Mono Out", " 616 {"Right Capture Source", "Mono Out", "Mono Mixer"}, 617 617 618 /* left ADC */ 618 /* left ADC */ 619 {"Left ADC", NULL, "Left Capture Sourc 619 {"Left ADC", NULL, "Left Capture Source"}, 620 {"Left Voice ADC", NULL, "Left ADC"}, 620 {"Left Voice ADC", NULL, "Left ADC"}, 621 {"Left HiFi ADC", NULL, "Left ADC"}, 621 {"Left HiFi ADC", NULL, "Left ADC"}, 622 622 623 /* right ADC */ 623 /* right ADC */ 624 {"Right ADC", NULL, "Right Capture Sou 624 {"Right ADC", NULL, "Right Capture Source"}, 625 {"Right Voice ADC", NULL, "Right ADC"} 625 {"Right Voice ADC", NULL, "Right ADC"}, 626 {"Right HiFi ADC", NULL, "Right ADC"}, 626 {"Right HiFi ADC", NULL, "Right ADC"}, 627 627 628 /* mic */ 628 /* mic */ 629 {"Mic A Pre Amp", NULL, "Mic A Source" 629 {"Mic A Pre Amp", NULL, "Mic A Source"}, 630 {"Mic A Source", "Mic 1", "MIC1"}, 630 {"Mic A Source", "Mic 1", "MIC1"}, 631 {"Mic A Source", "Mic 2 A", "MIC2A"}, 631 {"Mic A Source", "Mic 2 A", "MIC2A"}, 632 {"Mic A Source", "Mic 2 B", "Mic B Sou 632 {"Mic A Source", "Mic 2 B", "Mic B Source"}, 633 {"Mic B Pre Amp", "MPB", "Mic B Source 633 {"Mic B Pre Amp", "MPB", "Mic B Source"}, 634 {"Mic B Source", NULL, "MIC2B"}, 634 {"Mic B Source", NULL, "MIC2B"}, 635 635 636 /* headphone capture */ 636 /* headphone capture */ 637 {"Capture Headphone Mux", "Stereo", "C 637 {"Capture Headphone Mux", "Stereo", "Capture Mixer"}, 638 {"Capture Headphone Mux", "Left", "Lef 638 {"Capture Headphone Mux", "Left", "Left Capture Source"}, 639 {"Capture Headphone Mux", "Right", "Ri 639 {"Capture Headphone Mux", "Right", "Right Capture Source"}, 640 640 641 /* mono capture */ 641 /* mono capture */ 642 {"Capture Mono Mux", "Stereo", "Captur 642 {"Capture Mono Mux", "Stereo", "Capture Mixer"}, 643 {"Capture Mono Mux", "Left", "Left Cap 643 {"Capture Mono Mux", "Left", "Left Capture Source"}, 644 {"Capture Mono Mux", "Right", "Right C 644 {"Capture Mono Mux", "Right", "Right Capture Source"}, 645 }; 645 }; 646 646 647 static bool wm9713_readable_reg(struct device 647 static bool wm9713_readable_reg(struct device *dev, unsigned int reg) 648 { 648 { 649 switch (reg) { 649 switch (reg) { 650 case AC97_RESET ... AC97_PCM_SURR_DAC_ 650 case AC97_RESET ... AC97_PCM_SURR_DAC_RATE: 651 case AC97_PCM_LR_ADC_RATE: 651 case AC97_PCM_LR_ADC_RATE: 652 case AC97_CENTER_LFE_MASTER: 652 case AC97_CENTER_LFE_MASTER: 653 case AC97_SPDIF ... AC97_LINE1_LEVEL: 653 case AC97_SPDIF ... AC97_LINE1_LEVEL: 654 case AC97_GPIO_CFG ... 0x5c: 654 case AC97_GPIO_CFG ... 0x5c: 655 case AC97_CODEC_CLASS_REV ... AC97_PCI 655 case AC97_CODEC_CLASS_REV ... AC97_PCI_SID: 656 case 0x74 ... AC97_VENDOR_ID2: 656 case 0x74 ... AC97_VENDOR_ID2: 657 return true; 657 return true; 658 default: 658 default: 659 return false; 659 return false; 660 } 660 } 661 } 661 } 662 662 663 static bool wm9713_writeable_reg(struct device 663 static bool wm9713_writeable_reg(struct device *dev, unsigned int reg) 664 { 664 { 665 switch (reg) { 665 switch (reg) { 666 case AC97_VENDOR_ID1: 666 case AC97_VENDOR_ID1: 667 case AC97_VENDOR_ID2: 667 case AC97_VENDOR_ID2: 668 return false; 668 return false; 669 default: 669 default: 670 return wm9713_readable_reg(dev 670 return wm9713_readable_reg(dev, reg); 671 } 671 } 672 } 672 } 673 673 674 static const struct reg_default wm9713_reg_def 674 static const struct reg_default wm9713_reg_defaults[] = { 675 { 0x02, 0x8080 }, /* Speaker Out 675 { 0x02, 0x8080 }, /* Speaker Output Volume */ 676 { 0x04, 0x8080 }, /* Headphone O 676 { 0x04, 0x8080 }, /* Headphone Output Volume */ 677 { 0x06, 0x8080 }, /* Out3/OUT4 V 677 { 0x06, 0x8080 }, /* Out3/OUT4 Volume */ 678 { 0x08, 0xc880 }, /* Mono Volume 678 { 0x08, 0xc880 }, /* Mono Volume */ 679 { 0x0a, 0xe808 }, /* LINEIN Volu 679 { 0x0a, 0xe808 }, /* LINEIN Volume */ 680 { 0x0c, 0xe808 }, /* DAC PGA Vol 680 { 0x0c, 0xe808 }, /* DAC PGA Volume */ 681 { 0x0e, 0x0808 }, /* MIC PGA Vol 681 { 0x0e, 0x0808 }, /* MIC PGA Volume */ 682 { 0x10, 0x00da }, /* MIC Routing 682 { 0x10, 0x00da }, /* MIC Routing Control */ 683 { 0x12, 0x8000 }, /* Record PGA 683 { 0x12, 0x8000 }, /* Record PGA Volume */ 684 { 0x14, 0xd600 }, /* Record Rout 684 { 0x14, 0xd600 }, /* Record Routing */ 685 { 0x16, 0xaaa0 }, /* PCBEEP Volu 685 { 0x16, 0xaaa0 }, /* PCBEEP Volume */ 686 { 0x18, 0xaaa0 }, /* VxDAC Volum 686 { 0x18, 0xaaa0 }, /* VxDAC Volume */ 687 { 0x1a, 0xaaa0 }, /* AUXDAC Volu 687 { 0x1a, 0xaaa0 }, /* AUXDAC Volume */ 688 { 0x1c, 0x0000 }, /* Output PGA 688 { 0x1c, 0x0000 }, /* Output PGA Mux */ 689 { 0x1e, 0x0000 }, /* DAC 3D cont 689 { 0x1e, 0x0000 }, /* DAC 3D control */ 690 { 0x20, 0x0f0f }, /* DAC Tone Co 690 { 0x20, 0x0f0f }, /* DAC Tone Control*/ 691 { 0x22, 0x0040 }, /* MIC Input S 691 { 0x22, 0x0040 }, /* MIC Input Select & Bias */ 692 { 0x24, 0x0000 }, /* Output Volu 692 { 0x24, 0x0000 }, /* Output Volume Mapping & Jack */ 693 { 0x26, 0x7f00 }, /* Powerdown C 693 { 0x26, 0x7f00 }, /* Powerdown Ctrl/Stat*/ 694 { 0x28, 0x0405 }, /* Extended Au 694 { 0x28, 0x0405 }, /* Extended Audio ID */ 695 { 0x2a, 0x0410 }, /* Extended Au 695 { 0x2a, 0x0410 }, /* Extended Audio Start/Ctrl */ 696 { 0x2c, 0xbb80 }, /* Audio DACs 696 { 0x2c, 0xbb80 }, /* Audio DACs Sample Rate */ 697 { 0x2e, 0xbb80 }, /* AUXDAC Samp 697 { 0x2e, 0xbb80 }, /* AUXDAC Sample Rate */ 698 { 0x32, 0xbb80 }, /* Audio ADCs 698 { 0x32, 0xbb80 }, /* Audio ADCs Sample Rate */ 699 { 0x36, 0x4523 }, /* PCM codec c 699 { 0x36, 0x4523 }, /* PCM codec control */ 700 { 0x3a, 0x2000 }, /* SPDIF contr 700 { 0x3a, 0x2000 }, /* SPDIF control */ 701 { 0x3c, 0xfdff }, /* Powerdown 1 701 { 0x3c, 0xfdff }, /* Powerdown 1 */ 702 { 0x3e, 0xffff }, /* Powerdown 2 702 { 0x3e, 0xffff }, /* Powerdown 2 */ 703 { 0x40, 0x0000 }, /* General Pur 703 { 0x40, 0x0000 }, /* General Purpose */ 704 { 0x42, 0x0000 }, /* Fast Power- 704 { 0x42, 0x0000 }, /* Fast Power-Up Control */ 705 { 0x44, 0x0080 }, /* MCLK/PLL Co 705 { 0x44, 0x0080 }, /* MCLK/PLL Control */ 706 { 0x46, 0x0000 }, /* MCLK/PLL Co 706 { 0x46, 0x0000 }, /* MCLK/PLL Control */ 707 { 0x4c, 0xfffe }, /* GPIO Pin Co 707 { 0x4c, 0xfffe }, /* GPIO Pin Configuration */ 708 { 0x4e, 0xffff }, /* GPIO Pin Po 708 { 0x4e, 0xffff }, /* GPIO Pin Polarity / Type */ 709 { 0x50, 0x0000 }, /* GPIO Pin St 709 { 0x50, 0x0000 }, /* GPIO Pin Sticky */ 710 { 0x52, 0x0000 }, /* GPIO Pin Wa 710 { 0x52, 0x0000 }, /* GPIO Pin Wake-Up */ 711 /* GPIO Pin St 711 /* GPIO Pin Status */ 712 { 0x56, 0xfffe }, /* GPIO Pin Sh 712 { 0x56, 0xfffe }, /* GPIO Pin Sharing */ 713 { 0x58, 0x4000 }, /* GPIO PullUp 713 { 0x58, 0x4000 }, /* GPIO PullUp/PullDown */ 714 { 0x5a, 0x0000 }, /* Additional 714 { 0x5a, 0x0000 }, /* Additional Functions 1 */ 715 { 0x5c, 0x0000 }, /* Additional 715 { 0x5c, 0x0000 }, /* Additional Functions 2 */ 716 { 0x60, 0xb032 }, /* ALC Control 716 { 0x60, 0xb032 }, /* ALC Control */ 717 { 0x62, 0x3e00 }, /* ALC / Noise 717 { 0x62, 0x3e00 }, /* ALC / Noise Gate Control */ 718 { 0x64, 0x0000 }, /* AUXDAC inpu 718 { 0x64, 0x0000 }, /* AUXDAC input control */ 719 { 0x74, 0x0000 }, /* Digitiser R 719 { 0x74, 0x0000 }, /* Digitiser Reg 1 */ 720 { 0x76, 0x0006 }, /* Digitiser R 720 { 0x76, 0x0006 }, /* Digitiser Reg 2 */ 721 { 0x78, 0x0001 }, /* Digitiser R 721 { 0x78, 0x0001 }, /* Digitiser Reg 3 */ 722 { 0x7a, 0x0000 }, /* Digitiser R 722 { 0x7a, 0x0000 }, /* Digitiser Read Back */ 723 }; 723 }; 724 724 725 static const struct regmap_config wm9713_regma 725 static const struct regmap_config wm9713_regmap_config = { 726 .reg_bits = 16, 726 .reg_bits = 16, 727 .reg_stride = 2, 727 .reg_stride = 2, 728 .val_bits = 16, 728 .val_bits = 16, 729 .max_register = 0x7e, 729 .max_register = 0x7e, 730 .cache_type = REGCACHE_MAPLE, !! 730 .cache_type = REGCACHE_RBTREE, 731 731 732 .reg_defaults = wm9713_reg_defaults, 732 .reg_defaults = wm9713_reg_defaults, 733 .num_reg_defaults = ARRAY_SIZE(wm9713_ 733 .num_reg_defaults = ARRAY_SIZE(wm9713_reg_defaults), 734 .volatile_reg = regmap_ac97_default_vo 734 .volatile_reg = regmap_ac97_default_volatile, 735 .readable_reg = wm9713_readable_reg, 735 .readable_reg = wm9713_readable_reg, 736 .writeable_reg = wm9713_writeable_reg, 736 .writeable_reg = wm9713_writeable_reg, 737 }; 737 }; 738 738 739 /* PLL divisors */ 739 /* PLL divisors */ 740 struct _pll_div { 740 struct _pll_div { 741 u32 divsel:1; 741 u32 divsel:1; 742 u32 divctl:1; 742 u32 divctl:1; 743 u32 lf:1; 743 u32 lf:1; 744 u32 n:4; 744 u32 n:4; 745 u32 k:24; 745 u32 k:24; 746 }; 746 }; 747 747 748 /* The size in bits of the PLL divide multipli 748 /* The size in bits of the PLL divide multiplied by 10 749 * to allow rounding later */ 749 * to allow rounding later */ 750 #define FIXED_PLL_SIZE ((1 << 22) * 10) 750 #define FIXED_PLL_SIZE ((1 << 22) * 10) 751 751 752 static void pll_factors(struct snd_soc_compone 752 static void pll_factors(struct snd_soc_component *component, 753 struct _pll_div *pll_div, unsigned int 753 struct _pll_div *pll_div, unsigned int source) 754 { 754 { 755 u64 Kpart; 755 u64 Kpart; 756 unsigned int K, Ndiv, Nmod, target; 756 unsigned int K, Ndiv, Nmod, target; 757 757 758 /* The PLL output is always 98.304MHz. !! 758 /* The the PLL output is always 98.304MHz. */ 759 target = 98304000; 759 target = 98304000; 760 760 761 /* If the input frequency is over 14.4 761 /* If the input frequency is over 14.4MHz then scale it down. */ 762 if (source > 14400000) { 762 if (source > 14400000) { 763 source >>= 1; 763 source >>= 1; 764 pll_div->divsel = 1; 764 pll_div->divsel = 1; 765 765 766 if (source > 14400000) { 766 if (source > 14400000) { 767 source >>= 1; 767 source >>= 1; 768 pll_div->divctl = 1; 768 pll_div->divctl = 1; 769 } else 769 } else 770 pll_div->divctl = 0; 770 pll_div->divctl = 0; 771 771 772 } else { 772 } else { 773 pll_div->divsel = 0; 773 pll_div->divsel = 0; 774 pll_div->divctl = 0; 774 pll_div->divctl = 0; 775 } 775 } 776 776 777 /* Low frequency sources require an ad 777 /* Low frequency sources require an additional divide in the 778 * loop. 778 * loop. 779 */ 779 */ 780 if (source < 8192000) { 780 if (source < 8192000) { 781 pll_div->lf = 1; 781 pll_div->lf = 1; 782 target >>= 2; 782 target >>= 2; 783 } else 783 } else 784 pll_div->lf = 0; 784 pll_div->lf = 0; 785 785 786 Ndiv = target / source; 786 Ndiv = target / source; 787 if ((Ndiv < 5) || (Ndiv > 12)) 787 if ((Ndiv < 5) || (Ndiv > 12)) 788 dev_warn(component->dev, 788 dev_warn(component->dev, 789 "WM9713 PLL N value %u 789 "WM9713 PLL N value %u out of recommended range!\n", 790 Ndiv); 790 Ndiv); 791 791 792 pll_div->n = Ndiv; 792 pll_div->n = Ndiv; 793 Nmod = target % source; 793 Nmod = target % source; 794 Kpart = FIXED_PLL_SIZE * (long long)Nm 794 Kpart = FIXED_PLL_SIZE * (long long)Nmod; 795 795 796 do_div(Kpart, source); 796 do_div(Kpart, source); 797 797 798 K = Kpart & 0xFFFFFFFF; 798 K = Kpart & 0xFFFFFFFF; 799 799 800 /* Check if we need to round */ 800 /* Check if we need to round */ 801 if ((K % 10) >= 5) 801 if ((K % 10) >= 5) 802 K += 5; 802 K += 5; 803 803 804 /* Move down to proper range now round 804 /* Move down to proper range now rounding is done */ 805 K /= 10; 805 K /= 10; 806 806 807 pll_div->k = K; 807 pll_div->k = K; 808 } 808 } 809 809 810 /* !! 810 /** 811 * Please note that changing the PLL input fre 811 * Please note that changing the PLL input frequency may require 812 * resynchronisation with the AC97 controller. 812 * resynchronisation with the AC97 controller. 813 */ 813 */ 814 static int wm9713_set_pll(struct snd_soc_compo 814 static int wm9713_set_pll(struct snd_soc_component *component, 815 int pll_id, unsigned int freq_in, unsi 815 int pll_id, unsigned int freq_in, unsigned int freq_out) 816 { 816 { 817 struct wm9713_priv *wm9713 = snd_soc_c 817 struct wm9713_priv *wm9713 = snd_soc_component_get_drvdata(component); 818 u16 reg, reg2; 818 u16 reg, reg2; 819 struct _pll_div pll_div; 819 struct _pll_div pll_div; 820 820 821 /* turn PLL off ? */ 821 /* turn PLL off ? */ 822 if (freq_in == 0) { 822 if (freq_in == 0) { 823 /* disable PLL power and selec 823 /* disable PLL power and select ext source */ 824 snd_soc_component_update_bits( 824 snd_soc_component_update_bits(component, AC97_HANDSET_RATE, 0x0080, 0x0080); 825 snd_soc_component_update_bits( 825 snd_soc_component_update_bits(component, AC97_EXTENDED_MID, 0x0200, 0x0200); 826 wm9713->pll_in = 0; 826 wm9713->pll_in = 0; 827 return 0; 827 return 0; 828 } 828 } 829 829 830 pll_factors(component, &pll_div, freq_ 830 pll_factors(component, &pll_div, freq_in); 831 831 832 if (pll_div.k == 0) { 832 if (pll_div.k == 0) { 833 reg = (pll_div.n << 12) | (pll 833 reg = (pll_div.n << 12) | (pll_div.lf << 11) | 834 (pll_div.divsel << 9) 834 (pll_div.divsel << 9) | (pll_div.divctl << 8); 835 snd_soc_component_write(compon 835 snd_soc_component_write(component, AC97_LINE1_LEVEL, reg); 836 } else { 836 } else { 837 /* write the fractional k to t 837 /* write the fractional k to the reg 0x46 pages */ 838 reg2 = (pll_div.n << 12) | (pl 838 reg2 = (pll_div.n << 12) | (pll_div.lf << 11) | (1 << 10) | 839 (pll_div.divsel << 9) 839 (pll_div.divsel << 9) | (pll_div.divctl << 8); 840 840 841 /* K [21:20] */ 841 /* K [21:20] */ 842 reg = reg2 | (0x5 << 4) | (pll 842 reg = reg2 | (0x5 << 4) | (pll_div.k >> 20); 843 snd_soc_component_write(compon 843 snd_soc_component_write(component, AC97_LINE1_LEVEL, reg); 844 844 845 /* K [19:16] */ 845 /* K [19:16] */ 846 reg = reg2 | (0x4 << 4) | ((pl 846 reg = reg2 | (0x4 << 4) | ((pll_div.k >> 16) & 0xf); 847 snd_soc_component_write(compon 847 snd_soc_component_write(component, AC97_LINE1_LEVEL, reg); 848 848 849 /* K [15:12] */ 849 /* K [15:12] */ 850 reg = reg2 | (0x3 << 4) | ((pl 850 reg = reg2 | (0x3 << 4) | ((pll_div.k >> 12) & 0xf); 851 snd_soc_component_write(compon 851 snd_soc_component_write(component, AC97_LINE1_LEVEL, reg); 852 852 853 /* K [11:8] */ 853 /* K [11:8] */ 854 reg = reg2 | (0x2 << 4) | ((pl 854 reg = reg2 | (0x2 << 4) | ((pll_div.k >> 8) & 0xf); 855 snd_soc_component_write(compon 855 snd_soc_component_write(component, AC97_LINE1_LEVEL, reg); 856 856 857 /* K [7:4] */ 857 /* K [7:4] */ 858 reg = reg2 | (0x1 << 4) | ((pl 858 reg = reg2 | (0x1 << 4) | ((pll_div.k >> 4) & 0xf); 859 snd_soc_component_write(compon 859 snd_soc_component_write(component, AC97_LINE1_LEVEL, reg); 860 860 861 reg = reg2 | (0x0 << 4) | (pll 861 reg = reg2 | (0x0 << 4) | (pll_div.k & 0xf); /* K [3:0] */ 862 snd_soc_component_write(compon 862 snd_soc_component_write(component, AC97_LINE1_LEVEL, reg); 863 } 863 } 864 864 865 /* turn PLL on and select as source */ 865 /* turn PLL on and select as source */ 866 snd_soc_component_update_bits(componen 866 snd_soc_component_update_bits(component, AC97_EXTENDED_MID, 0x0200, 0x0000); 867 snd_soc_component_update_bits(componen 867 snd_soc_component_update_bits(component, AC97_HANDSET_RATE, 0x0080, 0x0000); 868 wm9713->pll_in = freq_in; 868 wm9713->pll_in = freq_in; 869 869 870 /* wait 10ms AC97 link frames for the 870 /* wait 10ms AC97 link frames for the link to stabilise */ 871 schedule_timeout_interruptible(msecs_t 871 schedule_timeout_interruptible(msecs_to_jiffies(10)); 872 return 0; 872 return 0; 873 } 873 } 874 874 875 static int wm9713_set_dai_pll(struct snd_soc_d 875 static int wm9713_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, 876 int source, unsigned int freq_ 876 int source, unsigned int freq_in, unsigned int freq_out) 877 { 877 { 878 struct snd_soc_component *component = 878 struct snd_soc_component *component = codec_dai->component; 879 return wm9713_set_pll(component, pll_i 879 return wm9713_set_pll(component, pll_id, freq_in, freq_out); 880 } 880 } 881 881 882 /* 882 /* 883 * Tristate the PCM DAI lines, tristate can be 883 * Tristate the PCM DAI lines, tristate can be disabled by calling 884 * wm9713_set_dai_fmt() 884 * wm9713_set_dai_fmt() 885 */ 885 */ 886 static int wm9713_set_dai_tristate(struct snd_ 886 static int wm9713_set_dai_tristate(struct snd_soc_dai *codec_dai, 887 int tristate) 887 int tristate) 888 { 888 { 889 struct snd_soc_component *component = 889 struct snd_soc_component *component = codec_dai->component; 890 890 891 if (tristate) 891 if (tristate) 892 snd_soc_component_update_bits( 892 snd_soc_component_update_bits(component, AC97_CENTER_LFE_MASTER, 893 0x6000, 0x 893 0x6000, 0x0000); 894 894 895 return 0; 895 return 0; 896 } 896 } 897 897 898 /* 898 /* 899 * Configure WM9713 clock dividers. 899 * Configure WM9713 clock dividers. 900 * Voice DAC needs 256 FS 900 * Voice DAC needs 256 FS 901 */ 901 */ 902 static int wm9713_set_dai_clkdiv(struct snd_so 902 static int wm9713_set_dai_clkdiv(struct snd_soc_dai *codec_dai, 903 int div_id, int div) 903 int div_id, int div) 904 { 904 { 905 struct snd_soc_component *component = 905 struct snd_soc_component *component = codec_dai->component; 906 906 907 switch (div_id) { 907 switch (div_id) { 908 case WM9713_PCMCLK_DIV: 908 case WM9713_PCMCLK_DIV: 909 snd_soc_component_update_bits( 909 snd_soc_component_update_bits(component, AC97_HANDSET_RATE, 0x0f00, div); 910 break; 910 break; 911 case WM9713_CLKA_MULT: 911 case WM9713_CLKA_MULT: 912 snd_soc_component_update_bits( 912 snd_soc_component_update_bits(component, AC97_HANDSET_RATE, 0x0002, div); 913 break; 913 break; 914 case WM9713_CLKB_MULT: 914 case WM9713_CLKB_MULT: 915 snd_soc_component_update_bits( 915 snd_soc_component_update_bits(component, AC97_HANDSET_RATE, 0x0004, div); 916 break; 916 break; 917 case WM9713_HIFI_DIV: 917 case WM9713_HIFI_DIV: 918 snd_soc_component_update_bits( 918 snd_soc_component_update_bits(component, AC97_HANDSET_RATE, 0x7000, div); 919 break; 919 break; 920 case WM9713_PCMBCLK_DIV: 920 case WM9713_PCMBCLK_DIV: 921 snd_soc_component_update_bits( 921 snd_soc_component_update_bits(component, AC97_CENTER_LFE_MASTER, 0x0e00, div); 922 break; 922 break; 923 case WM9713_PCMCLK_PLL_DIV: 923 case WM9713_PCMCLK_PLL_DIV: 924 snd_soc_component_update_bits( 924 snd_soc_component_update_bits(component, AC97_LINE1_LEVEL, 925 0x007f, di 925 0x007f, div | 0x60); 926 break; 926 break; 927 case WM9713_HIFI_PLL_DIV: 927 case WM9713_HIFI_PLL_DIV: 928 snd_soc_component_update_bits( 928 snd_soc_component_update_bits(component, AC97_LINE1_LEVEL, 929 0x007f, di 929 0x007f, div | 0x70); 930 break; 930 break; 931 default: 931 default: 932 return -EINVAL; 932 return -EINVAL; 933 } 933 } 934 934 935 return 0; 935 return 0; 936 } 936 } 937 937 938 static int wm9713_set_dai_fmt(struct snd_soc_d 938 static int wm9713_set_dai_fmt(struct snd_soc_dai *codec_dai, 939 unsigned int fmt) 939 unsigned int fmt) 940 { 940 { 941 struct snd_soc_component *component = 941 struct snd_soc_component *component = codec_dai->component; 942 u16 gpio = snd_soc_component_read(comp !! 942 u16 gpio = snd_soc_component_read32(component, AC97_GPIO_CFG) & 0xffc5; 943 u16 reg = 0x8000; 943 u16 reg = 0x8000; 944 944 945 /* clock masters */ 945 /* clock masters */ 946 switch (fmt & SND_SOC_DAIFMT_MASTER_MA 946 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { 947 case SND_SOC_DAIFMT_CBM_CFM: 947 case SND_SOC_DAIFMT_CBM_CFM: 948 reg |= 0x4000; 948 reg |= 0x4000; 949 gpio |= 0x0010; 949 gpio |= 0x0010; 950 break; 950 break; 951 case SND_SOC_DAIFMT_CBM_CFS: 951 case SND_SOC_DAIFMT_CBM_CFS: 952 reg |= 0x6000; 952 reg |= 0x6000; 953 gpio |= 0x0018; 953 gpio |= 0x0018; 954 break; 954 break; 955 case SND_SOC_DAIFMT_CBS_CFS: 955 case SND_SOC_DAIFMT_CBS_CFS: 956 reg |= 0x2000; 956 reg |= 0x2000; 957 gpio |= 0x001a; 957 gpio |= 0x001a; 958 break; 958 break; 959 case SND_SOC_DAIFMT_CBS_CFM: 959 case SND_SOC_DAIFMT_CBS_CFM: 960 gpio |= 0x0012; 960 gpio |= 0x0012; 961 break; 961 break; 962 } 962 } 963 963 964 /* clock inversion */ 964 /* clock inversion */ 965 switch (fmt & SND_SOC_DAIFMT_INV_MASK) 965 switch (fmt & SND_SOC_DAIFMT_INV_MASK) { 966 case SND_SOC_DAIFMT_IB_IF: 966 case SND_SOC_DAIFMT_IB_IF: 967 reg |= 0x00c0; 967 reg |= 0x00c0; 968 break; 968 break; 969 case SND_SOC_DAIFMT_IB_NF: 969 case SND_SOC_DAIFMT_IB_NF: 970 reg |= 0x0080; 970 reg |= 0x0080; 971 break; 971 break; 972 case SND_SOC_DAIFMT_NB_IF: 972 case SND_SOC_DAIFMT_NB_IF: 973 reg |= 0x0040; 973 reg |= 0x0040; 974 break; 974 break; 975 } 975 } 976 976 977 /* DAI format */ 977 /* DAI format */ 978 switch (fmt & SND_SOC_DAIFMT_FORMAT_MA 978 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { 979 case SND_SOC_DAIFMT_I2S: 979 case SND_SOC_DAIFMT_I2S: 980 reg |= 0x0002; 980 reg |= 0x0002; 981 break; 981 break; 982 case SND_SOC_DAIFMT_RIGHT_J: 982 case SND_SOC_DAIFMT_RIGHT_J: 983 break; 983 break; 984 case SND_SOC_DAIFMT_LEFT_J: 984 case SND_SOC_DAIFMT_LEFT_J: 985 reg |= 0x0001; 985 reg |= 0x0001; 986 break; 986 break; 987 case SND_SOC_DAIFMT_DSP_A: 987 case SND_SOC_DAIFMT_DSP_A: 988 reg |= 0x0003; 988 reg |= 0x0003; 989 break; 989 break; 990 case SND_SOC_DAIFMT_DSP_B: 990 case SND_SOC_DAIFMT_DSP_B: 991 reg |= 0x0043; 991 reg |= 0x0043; 992 break; 992 break; 993 } 993 } 994 994 995 snd_soc_component_write(component, AC9 995 snd_soc_component_write(component, AC97_GPIO_CFG, gpio); 996 snd_soc_component_write(component, AC9 996 snd_soc_component_write(component, AC97_CENTER_LFE_MASTER, reg); 997 return 0; 997 return 0; 998 } 998 } 999 999 1000 static int wm9713_pcm_hw_params(struct snd_pc 1000 static int wm9713_pcm_hw_params(struct snd_pcm_substream *substream, 1001 struct snd_pc 1001 struct snd_pcm_hw_params *params, 1002 struct snd_so 1002 struct snd_soc_dai *dai) 1003 { 1003 { 1004 struct snd_soc_component *component = 1004 struct snd_soc_component *component = dai->component; 1005 1005 1006 /* enable PCM interface in master mod 1006 /* enable PCM interface in master mode */ 1007 switch (params_width(params)) { 1007 switch (params_width(params)) { 1008 case 16: 1008 case 16: 1009 break; 1009 break; 1010 case 20: 1010 case 20: 1011 snd_soc_component_update_bits 1011 snd_soc_component_update_bits(component, AC97_CENTER_LFE_MASTER, 1012 0x000c, 0 1012 0x000c, 0x0004); 1013 break; 1013 break; 1014 case 24: 1014 case 24: 1015 snd_soc_component_update_bits 1015 snd_soc_component_update_bits(component, AC97_CENTER_LFE_MASTER, 1016 0x000c, 0 1016 0x000c, 0x0008); 1017 break; 1017 break; 1018 case 32: 1018 case 32: 1019 snd_soc_component_update_bits 1019 snd_soc_component_update_bits(component, AC97_CENTER_LFE_MASTER, 1020 0x000c, 0 1020 0x000c, 0x000c); 1021 break; 1021 break; 1022 } 1022 } 1023 return 0; 1023 return 0; 1024 } 1024 } 1025 1025 1026 static int ac97_hifi_prepare(struct snd_pcm_s 1026 static int ac97_hifi_prepare(struct snd_pcm_substream *substream, 1027 struct snd_soc_d 1027 struct snd_soc_dai *dai) 1028 { 1028 { 1029 struct snd_soc_component *component = 1029 struct snd_soc_component *component = dai->component; 1030 struct snd_pcm_runtime *runtime = sub 1030 struct snd_pcm_runtime *runtime = substream->runtime; 1031 int reg; 1031 int reg; 1032 1032 1033 snd_soc_component_update_bits(compone 1033 snd_soc_component_update_bits(component, AC97_EXTENDED_STATUS, 0x0001, 0x0001); 1034 1034 1035 if (substream->stream == SNDRV_PCM_ST 1035 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 1036 reg = AC97_PCM_FRONT_DAC_RATE 1036 reg = AC97_PCM_FRONT_DAC_RATE; 1037 else 1037 else 1038 reg = AC97_PCM_LR_ADC_RATE; 1038 reg = AC97_PCM_LR_ADC_RATE; 1039 1039 1040 return snd_soc_component_write(compon 1040 return snd_soc_component_write(component, reg, runtime->rate); 1041 } 1041 } 1042 1042 1043 static int ac97_aux_prepare(struct snd_pcm_su 1043 static int ac97_aux_prepare(struct snd_pcm_substream *substream, 1044 struct snd_soc_da 1044 struct snd_soc_dai *dai) 1045 { 1045 { 1046 struct snd_soc_component *component = 1046 struct snd_soc_component *component = dai->component; 1047 struct snd_pcm_runtime *runtime = sub 1047 struct snd_pcm_runtime *runtime = substream->runtime; 1048 1048 1049 snd_soc_component_update_bits(compone 1049 snd_soc_component_update_bits(component, AC97_EXTENDED_STATUS, 0x0001, 0x0001); 1050 snd_soc_component_update_bits(compone 1050 snd_soc_component_update_bits(component, AC97_PCI_SID, 0x8000, 0x8000); 1051 1051 1052 if (substream->stream != SNDRV_PCM_ST 1052 if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK) 1053 return -ENODEV; 1053 return -ENODEV; 1054 1054 1055 return snd_soc_component_write(compon 1055 return snd_soc_component_write(component, AC97_PCM_SURR_DAC_RATE, runtime->rate); 1056 } 1056 } 1057 1057 1058 #define WM9713_RATES (SNDRV_PCM_RATE_8000 | 1058 #define WM9713_RATES (SNDRV_PCM_RATE_8000 | \ 1059 SNDRV_PCM_RATE_11025 | 1059 SNDRV_PCM_RATE_11025 | \ 1060 SNDRV_PCM_RATE_22050 | 1060 SNDRV_PCM_RATE_22050 | \ 1061 SNDRV_PCM_RATE_44100 | 1061 SNDRV_PCM_RATE_44100 | \ 1062 SNDRV_PCM_RATE_48000) 1062 SNDRV_PCM_RATE_48000) 1063 1063 1064 #define WM9713_PCM_RATES (SNDRV_PCM_RATE_8000 1064 #define WM9713_PCM_RATES (SNDRV_PCM_RATE_8000 | \ 1065 SNDRV_PCM_RATE_1102 1065 SNDRV_PCM_RATE_11025 | \ 1066 SNDRV_PCM_RATE_1600 1066 SNDRV_PCM_RATE_16000 | \ 1067 SNDRV_PCM_RATE_2205 1067 SNDRV_PCM_RATE_22050 | \ 1068 SNDRV_PCM_RATE_4410 1068 SNDRV_PCM_RATE_44100 | \ 1069 SNDRV_PCM_RATE_4800 1069 SNDRV_PCM_RATE_48000) 1070 1070 1071 #define WM9713_PCM_FORMATS \ 1071 #define WM9713_PCM_FORMATS \ 1072 (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_ 1072 (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ 1073 SNDRV_PCM_FMTBIT_S24_LE) 1073 SNDRV_PCM_FMTBIT_S24_LE) 1074 1074 1075 static const struct snd_soc_dai_ops wm9713_da 1075 static const struct snd_soc_dai_ops wm9713_dai_ops_hifi = { 1076 .prepare = ac97_hifi_prepare, 1076 .prepare = ac97_hifi_prepare, 1077 .set_clkdiv = wm9713_set_dai_clkd 1077 .set_clkdiv = wm9713_set_dai_clkdiv, 1078 .set_pll = wm9713_set_dai_pll, 1078 .set_pll = wm9713_set_dai_pll, 1079 }; 1079 }; 1080 1080 1081 static const struct snd_soc_dai_ops wm9713_da 1081 static const struct snd_soc_dai_ops wm9713_dai_ops_aux = { 1082 .prepare = ac97_aux_prepare, 1082 .prepare = ac97_aux_prepare, 1083 .set_clkdiv = wm9713_set_dai_clkd 1083 .set_clkdiv = wm9713_set_dai_clkdiv, 1084 .set_pll = wm9713_set_dai_pll, 1084 .set_pll = wm9713_set_dai_pll, 1085 }; 1085 }; 1086 1086 1087 static const struct snd_soc_dai_ops wm9713_da 1087 static const struct snd_soc_dai_ops wm9713_dai_ops_voice = { 1088 .hw_params = wm9713_pcm_hw_param 1088 .hw_params = wm9713_pcm_hw_params, 1089 .set_clkdiv = wm9713_set_dai_clkd 1089 .set_clkdiv = wm9713_set_dai_clkdiv, 1090 .set_pll = wm9713_set_dai_pll, 1090 .set_pll = wm9713_set_dai_pll, 1091 .set_fmt = wm9713_set_dai_fmt, 1091 .set_fmt = wm9713_set_dai_fmt, 1092 .set_tristate = wm9713_set_dai_tris 1092 .set_tristate = wm9713_set_dai_tristate, 1093 }; 1093 }; 1094 1094 1095 static struct snd_soc_dai_driver wm9713_dai[] 1095 static struct snd_soc_dai_driver wm9713_dai[] = { 1096 { 1096 { 1097 .name = "wm9713-hifi", 1097 .name = "wm9713-hifi", 1098 .playback = { 1098 .playback = { 1099 .stream_name = "HiFi Playback 1099 .stream_name = "HiFi Playback", 1100 .channels_min = 1, 1100 .channels_min = 1, 1101 .channels_max = 2, 1101 .channels_max = 2, 1102 .rates = WM9713_RATES, 1102 .rates = WM9713_RATES, 1103 .formats = SND_SOC_STD_AC97_F 1103 .formats = SND_SOC_STD_AC97_FMTS,}, 1104 .capture = { 1104 .capture = { 1105 .stream_name = "HiFi Capture" 1105 .stream_name = "HiFi Capture", 1106 .channels_min = 1, 1106 .channels_min = 1, 1107 .channels_max = 2, 1107 .channels_max = 2, 1108 .rates = WM9713_RATES, 1108 .rates = WM9713_RATES, 1109 .formats = SND_SOC_STD_AC97_F 1109 .formats = SND_SOC_STD_AC97_FMTS,}, 1110 .ops = &wm9713_dai_ops_hifi, 1110 .ops = &wm9713_dai_ops_hifi, 1111 }, 1111 }, 1112 { 1112 { 1113 .name = "wm9713-aux", 1113 .name = "wm9713-aux", 1114 .playback = { 1114 .playback = { 1115 .stream_name = "Aux Playback" 1115 .stream_name = "Aux Playback", 1116 .channels_min = 1, 1116 .channels_min = 1, 1117 .channels_max = 1, 1117 .channels_max = 1, 1118 .rates = WM9713_RATES, 1118 .rates = WM9713_RATES, 1119 .formats = SND_SOC_STD_AC97_F 1119 .formats = SND_SOC_STD_AC97_FMTS,}, 1120 .ops = &wm9713_dai_ops_aux, 1120 .ops = &wm9713_dai_ops_aux, 1121 }, 1121 }, 1122 { 1122 { 1123 .name = "wm9713-voice", 1123 .name = "wm9713-voice", 1124 .playback = { 1124 .playback = { 1125 .stream_name = "Voice Playbac 1125 .stream_name = "Voice Playback", 1126 .channels_min = 1, 1126 .channels_min = 1, 1127 .channels_max = 1, 1127 .channels_max = 1, 1128 .rates = WM9713_PCM_RATES, 1128 .rates = WM9713_PCM_RATES, 1129 .formats = WM9713_PCM_FORMATS 1129 .formats = WM9713_PCM_FORMATS,}, 1130 .capture = { 1130 .capture = { 1131 .stream_name = "Voice Capture 1131 .stream_name = "Voice Capture", 1132 .channels_min = 1, 1132 .channels_min = 1, 1133 .channels_max = 2, 1133 .channels_max = 2, 1134 .rates = WM9713_PCM_RATES, 1134 .rates = WM9713_PCM_RATES, 1135 .formats = WM9713_PCM_FORMATS 1135 .formats = WM9713_PCM_FORMATS,}, 1136 .ops = &wm9713_dai_ops_voice, 1136 .ops = &wm9713_dai_ops_voice, 1137 .symmetric_rate = 1, !! 1137 .symmetric_rates = 1, 1138 }, 1138 }, 1139 }; 1139 }; 1140 1140 1141 static int wm9713_set_bias_level(struct snd_s 1141 static int wm9713_set_bias_level(struct snd_soc_component *component, 1142 enum snd_soc 1142 enum snd_soc_bias_level level) 1143 { 1143 { 1144 switch (level) { 1144 switch (level) { 1145 case SND_SOC_BIAS_ON: 1145 case SND_SOC_BIAS_ON: 1146 /* enable thermal shutdown */ 1146 /* enable thermal shutdown */ 1147 snd_soc_component_update_bits 1147 snd_soc_component_update_bits(component, AC97_EXTENDED_MID, 0xe400, 0x0000); 1148 break; 1148 break; 1149 case SND_SOC_BIAS_PREPARE: 1149 case SND_SOC_BIAS_PREPARE: 1150 break; 1150 break; 1151 case SND_SOC_BIAS_STANDBY: 1151 case SND_SOC_BIAS_STANDBY: 1152 /* enable master bias and vmi 1152 /* enable master bias and vmid */ 1153 snd_soc_component_update_bits 1153 snd_soc_component_update_bits(component, AC97_EXTENDED_MID, 0xc400, 0x0000); 1154 snd_soc_component_write(compo 1154 snd_soc_component_write(component, AC97_POWERDOWN, 0x0000); 1155 break; 1155 break; 1156 case SND_SOC_BIAS_OFF: 1156 case SND_SOC_BIAS_OFF: 1157 /* disable everything includi 1157 /* disable everything including AC link */ 1158 snd_soc_component_write(compo 1158 snd_soc_component_write(component, AC97_EXTENDED_MID, 0xffff); 1159 snd_soc_component_write(compo 1159 snd_soc_component_write(component, AC97_EXTENDED_MSTATUS, 0xffff); 1160 snd_soc_component_write(compo 1160 snd_soc_component_write(component, AC97_POWERDOWN, 0xffff); 1161 break; 1161 break; 1162 } 1162 } 1163 return 0; 1163 return 0; 1164 } 1164 } 1165 1165 1166 static int wm9713_soc_suspend(struct snd_soc_ 1166 static int wm9713_soc_suspend(struct snd_soc_component *component) 1167 { 1167 { 1168 /* Disable everything except touchpan 1168 /* Disable everything except touchpanel - that will be handled 1169 * by the touch driver and left disab 1169 * by the touch driver and left disabled if touch is not in 1170 * use. */ 1170 * use. */ 1171 snd_soc_component_update_bits(compone 1171 snd_soc_component_update_bits(component, AC97_EXTENDED_MID, 0x7fff, 1172 0x7fff); 1172 0x7fff); 1173 snd_soc_component_write(component, AC 1173 snd_soc_component_write(component, AC97_EXTENDED_MSTATUS, 0xffff); 1174 snd_soc_component_write(component, AC 1174 snd_soc_component_write(component, AC97_POWERDOWN, 0x6f00); 1175 snd_soc_component_write(component, AC 1175 snd_soc_component_write(component, AC97_POWERDOWN, 0xffff); 1176 1176 1177 return 0; 1177 return 0; 1178 } 1178 } 1179 1179 1180 static int wm9713_soc_resume(struct snd_soc_c 1180 static int wm9713_soc_resume(struct snd_soc_component *component) 1181 { 1181 { 1182 struct wm9713_priv *wm9713 = snd_soc_ 1182 struct wm9713_priv *wm9713 = snd_soc_component_get_drvdata(component); 1183 int ret; 1183 int ret; 1184 1184 1185 ret = snd_ac97_reset(wm9713->ac97, tr 1185 ret = snd_ac97_reset(wm9713->ac97, true, WM9713_VENDOR_ID, 1186 WM9713_VENDOR_ID_MASK); 1186 WM9713_VENDOR_ID_MASK); 1187 if (ret < 0) 1187 if (ret < 0) 1188 return ret; 1188 return ret; 1189 1189 1190 snd_soc_component_force_bias_level(co 1190 snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY); 1191 1191 1192 /* do we need to re-start the PLL ? * 1192 /* do we need to re-start the PLL ? */ 1193 if (wm9713->pll_in) 1193 if (wm9713->pll_in) 1194 wm9713_set_pll(component, 0, 1194 wm9713_set_pll(component, 0, wm9713->pll_in, 0); 1195 1195 1196 /* only synchronise the codec if warm 1196 /* only synchronise the codec if warm reset failed */ 1197 if (ret == 0) { 1197 if (ret == 0) { 1198 regcache_mark_dirty(component 1198 regcache_mark_dirty(component->regmap); 1199 snd_soc_component_cache_sync( 1199 snd_soc_component_cache_sync(component); 1200 } 1200 } 1201 1201 1202 return ret; 1202 return ret; 1203 } 1203 } 1204 1204 1205 static int wm9713_soc_probe(struct snd_soc_co 1205 static int wm9713_soc_probe(struct snd_soc_component *component) 1206 { 1206 { 1207 struct wm9713_priv *wm9713 = snd_soc_ 1207 struct wm9713_priv *wm9713 = snd_soc_component_get_drvdata(component); 1208 struct regmap *regmap = NULL; 1208 struct regmap *regmap = NULL; 1209 1209 1210 if (wm9713->mfd_pdata) { 1210 if (wm9713->mfd_pdata) { 1211 wm9713->ac97 = wm9713->mfd_pd 1211 wm9713->ac97 = wm9713->mfd_pdata->ac97; 1212 regmap = wm9713->mfd_pdata->r 1212 regmap = wm9713->mfd_pdata->regmap; 1213 } else if (IS_ENABLED(CONFIG_SND_SOC_ 1213 } else if (IS_ENABLED(CONFIG_SND_SOC_AC97_BUS)) { 1214 wm9713->ac97 = snd_soc_new_ac 1214 wm9713->ac97 = snd_soc_new_ac97_component(component, WM9713_VENDOR_ID, 1215 1215 WM9713_VENDOR_ID_MASK); 1216 if (IS_ERR(wm9713->ac97)) 1216 if (IS_ERR(wm9713->ac97)) 1217 return PTR_ERR(wm9713 1217 return PTR_ERR(wm9713->ac97); 1218 regmap = regmap_init_ac97(wm9 1218 regmap = regmap_init_ac97(wm9713->ac97, &wm9713_regmap_config); 1219 if (IS_ERR(regmap)) { 1219 if (IS_ERR(regmap)) { 1220 snd_soc_free_ac97_com 1220 snd_soc_free_ac97_component(wm9713->ac97); 1221 return PTR_ERR(regmap 1221 return PTR_ERR(regmap); 1222 } 1222 } 1223 } else { 1223 } else { 1224 return -ENXIO; 1224 return -ENXIO; 1225 } 1225 } 1226 1226 1227 snd_soc_component_init_regmap(compone 1227 snd_soc_component_init_regmap(component, regmap); 1228 1228 1229 /* unmute the adc - move to kcontrol 1229 /* unmute the adc - move to kcontrol */ 1230 snd_soc_component_update_bits(compone 1230 snd_soc_component_update_bits(component, AC97_CD, 0x7fff, 0x0000); 1231 1231 1232 return 0; 1232 return 0; 1233 } 1233 } 1234 1234 1235 static void wm9713_soc_remove(struct snd_soc_ 1235 static void wm9713_soc_remove(struct snd_soc_component *component) 1236 { 1236 { 1237 struct wm9713_priv *wm9713 = snd_soc_ 1237 struct wm9713_priv *wm9713 = snd_soc_component_get_drvdata(component); 1238 1238 1239 if (IS_ENABLED(CONFIG_SND_SOC_AC97_BU 1239 if (IS_ENABLED(CONFIG_SND_SOC_AC97_BUS) && !wm9713->mfd_pdata) { 1240 snd_soc_component_exit_regmap 1240 snd_soc_component_exit_regmap(component); 1241 snd_soc_free_ac97_component(w 1241 snd_soc_free_ac97_component(wm9713->ac97); 1242 } 1242 } 1243 } 1243 } 1244 1244 1245 static const struct snd_soc_component_driver 1245 static const struct snd_soc_component_driver soc_component_dev_wm9713 = { 1246 .probe = wm9713_soc_ 1246 .probe = wm9713_soc_probe, 1247 .remove = wm9713_soc_ 1247 .remove = wm9713_soc_remove, 1248 .suspend = wm9713_soc_ 1248 .suspend = wm9713_soc_suspend, 1249 .resume = wm9713_soc_ 1249 .resume = wm9713_soc_resume, 1250 .set_bias_level = wm9713_set_ 1250 .set_bias_level = wm9713_set_bias_level, 1251 .controls = wm9713_snd_ 1251 .controls = wm9713_snd_ac97_controls, 1252 .num_controls = ARRAY_SIZE( 1252 .num_controls = ARRAY_SIZE(wm9713_snd_ac97_controls), 1253 .dapm_widgets = wm9713_dapm 1253 .dapm_widgets = wm9713_dapm_widgets, 1254 .num_dapm_widgets = ARRAY_SIZE( 1254 .num_dapm_widgets = ARRAY_SIZE(wm9713_dapm_widgets), 1255 .dapm_routes = wm9713_audi 1255 .dapm_routes = wm9713_audio_map, 1256 .num_dapm_routes = ARRAY_SIZE( 1256 .num_dapm_routes = ARRAY_SIZE(wm9713_audio_map), 1257 .idle_bias_on = 1, 1257 .idle_bias_on = 1, 1258 .use_pmdown_time = 1, 1258 .use_pmdown_time = 1, 1259 .endianness = 1, 1259 .endianness = 1, >> 1260 .non_legacy_dai_naming = 1, 1260 }; 1261 }; 1261 1262 1262 static int wm9713_probe(struct platform_devic 1263 static int wm9713_probe(struct platform_device *pdev) 1263 { 1264 { 1264 struct wm9713_priv *wm9713; 1265 struct wm9713_priv *wm9713; 1265 1266 1266 wm9713 = devm_kzalloc(&pdev->dev, siz 1267 wm9713 = devm_kzalloc(&pdev->dev, sizeof(*wm9713), GFP_KERNEL); 1267 if (wm9713 == NULL) 1268 if (wm9713 == NULL) 1268 return -ENOMEM; 1269 return -ENOMEM; 1269 1270 1270 mutex_init(&wm9713->lock); 1271 mutex_init(&wm9713->lock); 1271 1272 1272 wm9713->mfd_pdata = dev_get_platdata( 1273 wm9713->mfd_pdata = dev_get_platdata(&pdev->dev); 1273 platform_set_drvdata(pdev, wm9713); 1274 platform_set_drvdata(pdev, wm9713); 1274 1275 1275 return devm_snd_soc_register_componen 1276 return devm_snd_soc_register_component(&pdev->dev, 1276 &soc_component_dev_wm 1277 &soc_component_dev_wm9713, wm9713_dai, ARRAY_SIZE(wm9713_dai)); 1277 } 1278 } 1278 1279 1279 static struct platform_driver wm9713_codec_dr 1280 static struct platform_driver wm9713_codec_driver = { 1280 .driver = { 1281 .driver = { 1281 .name = "wm9713-codec 1282 .name = "wm9713-codec", 1282 }, 1283 }, 1283 1284 1284 .probe = wm9713_probe, 1285 .probe = wm9713_probe, 1285 }; 1286 }; 1286 1287 1287 module_platform_driver(wm9713_codec_driver); 1288 module_platform_driver(wm9713_codec_driver); 1288 1289 1289 MODULE_DESCRIPTION("ASoC WM9713/WM9714 driver 1290 MODULE_DESCRIPTION("ASoC WM9713/WM9714 driver"); 1290 MODULE_AUTHOR("Liam Girdwood"); 1291 MODULE_AUTHOR("Liam Girdwood"); 1291 MODULE_LICENSE("GPL"); 1292 MODULE_LICENSE("GPL"); 1292 1293
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.