aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2014-03-12 10:27:31 -0400
committerMark Brown <broonie@linaro.org>2014-03-21 14:04:20 -0400
commit43b956349de28884265e8237a5cd1f669fbaa485 (patch)
tree26794a65e721d6217a8352522370c601d721bc7a /sound
parent234bf1f0f03f879da2be698fb749f9a4b7322221 (diff)
ASoC: mfld_machine: Convert to table based DAPM and control setup
Use table based setup to register the controls and DAPM widgets and routes. This on one hand makes the code a bit cleaner and on the other hand the board level DAPM elements get registered in the card's DAPM context rather than in the CODEC's DAPM context. The mfld_machine driver is a bit special in that it directly writes to one of the CODEC registers from one of the control handlers. Previous to this patch it was able to get a pointer to the CODEC from the control, since the control was registered with the CODEC. This won't be possible anymore once the control is registered with the card. Since there are already global variables in the driver accessed in the same function the patch adds a global variable that holds a pointer to the CODEC and uses that. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/intel/mfld_machine.c49
1 files changed, 20 insertions, 29 deletions
diff --git a/sound/soc/intel/mfld_machine.c b/sound/soc/intel/mfld_machine.c
index 0cef32e9d402..461694263c46 100644
--- a/sound/soc/intel/mfld_machine.c
+++ b/sound/soc/intel/mfld_machine.c
@@ -53,6 +53,7 @@ enum soc_mic_bias_zones {
53 53
54static unsigned int hs_switch; 54static unsigned int hs_switch;
55static unsigned int lo_dac; 55static unsigned int lo_dac;
56static struct snd_soc_codec *mfld_codec;
56 57
57struct mfld_mc_private { 58struct mfld_mc_private {
58 void __iomem *int_base; 59 void __iomem *int_base;
@@ -100,8 +101,8 @@ static int headset_get_switch(struct snd_kcontrol *kcontrol,
100static int headset_set_switch(struct snd_kcontrol *kcontrol, 101static int headset_set_switch(struct snd_kcontrol *kcontrol,
101 struct snd_ctl_elem_value *ucontrol) 102 struct snd_ctl_elem_value *ucontrol)
102{ 103{
103 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 104 struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
104 struct snd_soc_dapm_context *dapm = &codec->dapm; 105 struct snd_soc_dapm_context *dapm = &card->dapm;
105 106
106 if (ucontrol->value.integer.value[0] == hs_switch) 107 if (ucontrol->value.integer.value[0] == hs_switch)
107 return 0; 108 return 0;
@@ -127,10 +128,8 @@ static int headset_set_switch(struct snd_kcontrol *kcontrol,
127 return 0; 128 return 0;
128} 129}
129 130
130static void lo_enable_out_pins(struct snd_soc_codec *codec) 131static void lo_enable_out_pins(struct snd_soc_dapm_context *dapm)
131{ 132{
132 struct snd_soc_dapm_context *dapm = &codec->dapm;
133
134 snd_soc_dapm_enable_pin_unlocked(dapm, "IHFOUTL"); 133 snd_soc_dapm_enable_pin_unlocked(dapm, "IHFOUTL");
135 snd_soc_dapm_enable_pin_unlocked(dapm, "IHFOUTR"); 134 snd_soc_dapm_enable_pin_unlocked(dapm, "IHFOUTR");
136 snd_soc_dapm_enable_pin_unlocked(dapm, "LINEOUTL"); 135 snd_soc_dapm_enable_pin_unlocked(dapm, "LINEOUTL");
@@ -156,8 +155,8 @@ static int lo_get_switch(struct snd_kcontrol *kcontrol,
156static int lo_set_switch(struct snd_kcontrol *kcontrol, 155static int lo_set_switch(struct snd_kcontrol *kcontrol,
157 struct snd_ctl_elem_value *ucontrol) 156 struct snd_ctl_elem_value *ucontrol)
158{ 157{
159 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 158 struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
160 struct snd_soc_dapm_context *dapm = &codec->dapm; 159 struct snd_soc_dapm_context *dapm = &card->dapm;
161 160
162 if (ucontrol->value.integer.value[0] == lo_dac) 161 if (ucontrol->value.integer.value[0] == lo_dac)
163 return 0; 162 return 0;
@@ -167,35 +166,35 @@ static int lo_set_switch(struct snd_kcontrol *kcontrol,
167 /* we dont want to work with last state of lineout so just enable all 166 /* we dont want to work with last state of lineout so just enable all
168 * pins and then disable pins not required 167 * pins and then disable pins not required
169 */ 168 */
170 lo_enable_out_pins(codec); 169 lo_enable_out_pins(dapm);
171 170
172 switch (ucontrol->value.integer.value[0]) { 171 switch (ucontrol->value.integer.value[0]) {
173 case 0: 172 case 0:
174 pr_debug("set vibra path\n"); 173 pr_debug("set vibra path\n");
175 snd_soc_dapm_disable_pin_unlocked(dapm, "VIB1OUT"); 174 snd_soc_dapm_disable_pin_unlocked(dapm, "VIB1OUT");
176 snd_soc_dapm_disable_pin_unlocked(dapm, "VIB2OUT"); 175 snd_soc_dapm_disable_pin_unlocked(dapm, "VIB2OUT");
177 snd_soc_update_bits(codec, SN95031_LOCTL, 0x66, 0); 176 snd_soc_update_bits(mfld_codec, SN95031_LOCTL, 0x66, 0);
178 break; 177 break;
179 178
180 case 1: 179 case 1:
181 pr_debug("set hs path\n"); 180 pr_debug("set hs path\n");
182 snd_soc_dapm_disable_pin_unlocked(dapm, "Headphones"); 181 snd_soc_dapm_disable_pin_unlocked(dapm, "Headphones");
183 snd_soc_dapm_disable_pin_unlocked(dapm, "EPOUT"); 182 snd_soc_dapm_disable_pin_unlocked(dapm, "EPOUT");
184 snd_soc_update_bits(codec, SN95031_LOCTL, 0x66, 0x22); 183 snd_soc_update_bits(mfld_codec, SN95031_LOCTL, 0x66, 0x22);
185 break; 184 break;
186 185
187 case 2: 186 case 2:
188 pr_debug("set spkr path\n"); 187 pr_debug("set spkr path\n");
189 snd_soc_dapm_disable_pin_unlocked(dapm, "IHFOUTL"); 188 snd_soc_dapm_disable_pin_unlocked(dapm, "IHFOUTL");
190 snd_soc_dapm_disable_pin_unlocked(dapm, "IHFOUTR"); 189 snd_soc_dapm_disable_pin_unlocked(dapm, "IHFOUTR");
191 snd_soc_update_bits(codec, SN95031_LOCTL, 0x66, 0x44); 190 snd_soc_update_bits(mfld_codec, SN95031_LOCTL, 0x66, 0x44);
192 break; 191 break;
193 192
194 case 3: 193 case 3:
195 pr_debug("set null path\n"); 194 pr_debug("set null path\n");
196 snd_soc_dapm_disable_pin_unlocked(dapm, "LINEOUTL"); 195 snd_soc_dapm_disable_pin_unlocked(dapm, "LINEOUTL");
197 snd_soc_dapm_disable_pin_unlocked(dapm, "LINEOUTR"); 196 snd_soc_dapm_disable_pin_unlocked(dapm, "LINEOUTR");
198 snd_soc_update_bits(codec, SN95031_LOCTL, 0x66, 0x66); 197 snd_soc_update_bits(mfld_codec, SN95031_LOCTL, 0x66, 0x66);
199 break; 198 break;
200 } 199 }
201 200
@@ -238,26 +237,11 @@ static void mfld_jack_check(unsigned int intr_status)
238 237
239static int mfld_init(struct snd_soc_pcm_runtime *runtime) 238static int mfld_init(struct snd_soc_pcm_runtime *runtime)
240{ 239{
241 struct snd_soc_codec *codec = runtime->codec; 240 struct snd_soc_dapm_context *dapm = &runtime->card->dapm;
242 struct snd_soc_dapm_context *dapm = &codec->dapm;
243 int ret_val; 241 int ret_val;
244 242
245 /* Add jack sense widgets */ 243 mfld_codec = runtime->codec;
246 snd_soc_dapm_new_controls(dapm, mfld_widgets, ARRAY_SIZE(mfld_widgets));
247
248 /* Set up the map */
249 snd_soc_dapm_add_routes(dapm, mfld_map, ARRAY_SIZE(mfld_map));
250 244
251 /* always connected */
252 snd_soc_dapm_enable_pin(dapm, "Headphones");
253 snd_soc_dapm_enable_pin(dapm, "Mic");
254
255 ret_val = snd_soc_add_codec_controls(codec, mfld_snd_controls,
256 ARRAY_SIZE(mfld_snd_controls));
257 if (ret_val) {
258 pr_err("soc_add_controls failed %d", ret_val);
259 return ret_val;
260 }
261 /* default is earpiece pin, userspace sets it explcitly */ 245 /* default is earpiece pin, userspace sets it explcitly */
262 snd_soc_dapm_disable_pin(dapm, "Headphones"); 246 snd_soc_dapm_disable_pin(dapm, "Headphones");
263 /* default is lineout NC, userspace sets it explcitly */ 247 /* default is lineout NC, userspace sets it explcitly */
@@ -352,6 +336,13 @@ static struct snd_soc_card snd_soc_card_mfld = {
352 .owner = THIS_MODULE, 336 .owner = THIS_MODULE,
353 .dai_link = mfld_msic_dailink, 337 .dai_link = mfld_msic_dailink,
354 .num_links = ARRAY_SIZE(mfld_msic_dailink), 338 .num_links = ARRAY_SIZE(mfld_msic_dailink),
339
340 .controls = mfld_snd_controls,
341 .num_controls = ARRAY_SIZE(mfld_snd_controls),
342 .dapm_widgets = mfld_widgets,
343 .num_dapm_widgets = ARRAY_SIZE(mfld_widgets),
344 .dapm_routes = mfld_map,
345 .num_dapm_routes = ARRAY_SIZE(mfld_map),
355}; 346};
356 347
357static irqreturn_t snd_mfld_jack_intr_handler(int irq, void *dev) 348static irqreturn_t snd_mfld_jack_intr_handler(int irq, void *dev)