Merge remote-tracking branch 'asoc/topic/dapm' into asoc-next

This commit is contained in:
Mark Brown 2014-03-12 23:03:58 +00:00
commit 53a2c4db8c
16 changed files with 327 additions and 187 deletions

View File

@ -461,6 +461,7 @@ int snd_soc_dapm_nc_pin_unlocked(struct snd_soc_dapm_context *dapm,
int snd_soc_dapm_get_pin_status(struct snd_soc_dapm_context *dapm, int snd_soc_dapm_get_pin_status(struct snd_soc_dapm_context *dapm,
const char *pin); const char *pin);
int snd_soc_dapm_sync(struct snd_soc_dapm_context *dapm); int snd_soc_dapm_sync(struct snd_soc_dapm_context *dapm);
int snd_soc_dapm_sync_unlocked(struct snd_soc_dapm_context *dapm);
int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm, int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm,
const char *pin); const char *pin);
int snd_soc_dapm_force_enable_pin_unlocked(struct snd_soc_dapm_context *dapm, int snd_soc_dapm_force_enable_pin_unlocked(struct snd_soc_dapm_context *dapm,
@ -470,7 +471,6 @@ int snd_soc_dapm_ignore_suspend(struct snd_soc_dapm_context *dapm,
void snd_soc_dapm_auto_nc_codec_pins(struct snd_soc_codec *codec); void snd_soc_dapm_auto_nc_codec_pins(struct snd_soc_codec *codec);
/* Mostly internal - should not normally be used */ /* Mostly internal - should not normally be used */
void dapm_mark_dirty(struct snd_soc_dapm_widget *w, const char *reason);
void dapm_mark_io_dirty(struct snd_soc_dapm_context *dapm); void dapm_mark_io_dirty(struct snd_soc_dapm_context *dapm);
/* dapm path query */ /* dapm path query */

View File

@ -1208,4 +1208,15 @@ extern struct dentry *snd_soc_debugfs_root;
extern const struct dev_pm_ops snd_soc_pm_ops; extern const struct dev_pm_ops snd_soc_pm_ops;
/* Helper functions */
static inline void snd_soc_dapm_mutex_lock(struct snd_soc_dapm_context *dapm)
{
mutex_lock(&dapm->card->dapm_mutex);
}
static inline void snd_soc_dapm_mutex_unlock(struct snd_soc_dapm_context *dapm)
{
mutex_unlock(&dapm->card->dapm_mutex);
}
#endif #endif

View File

@ -541,6 +541,7 @@ static int adav80x_set_sysclk(struct snd_soc_codec *codec,
unsigned int freq, int dir) unsigned int freq, int dir)
{ {
struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec);
struct snd_soc_dapm_context *dapm = &codec->dapm;
if (dir == SND_SOC_CLOCK_IN) { if (dir == SND_SOC_CLOCK_IN) {
switch (clk_id) { switch (clk_id) {
@ -573,7 +574,7 @@ static int adav80x_set_sysclk(struct snd_soc_codec *codec,
regmap_write(adav80x->regmap, ADAV80X_ICLK_CTRL2, regmap_write(adav80x->regmap, ADAV80X_ICLK_CTRL2,
iclk_ctrl2); iclk_ctrl2);
snd_soc_dapm_sync(&codec->dapm); snd_soc_dapm_sync(dapm);
} }
} else { } else {
unsigned int mask; unsigned int mask;
@ -600,17 +601,21 @@ static int adav80x_set_sysclk(struct snd_soc_codec *codec,
adav80x->sysclk_pd[clk_id] = false; adav80x->sysclk_pd[clk_id] = false;
} }
snd_soc_dapm_mutex_lock(dapm);
if (adav80x->sysclk_pd[0]) if (adav80x->sysclk_pd[0])
snd_soc_dapm_disable_pin(&codec->dapm, "PLL1"); snd_soc_dapm_disable_pin_unlocked(dapm, "PLL1");
else else
snd_soc_dapm_force_enable_pin(&codec->dapm, "PLL1"); snd_soc_dapm_force_enable_pin_unlocked(dapm, "PLL1");
if (adav80x->sysclk_pd[1] || adav80x->sysclk_pd[2]) if (adav80x->sysclk_pd[1] || adav80x->sysclk_pd[2])
snd_soc_dapm_disable_pin(&codec->dapm, "PLL2"); snd_soc_dapm_disable_pin_unlocked(dapm, "PLL2");
else else
snd_soc_dapm_force_enable_pin(&codec->dapm, "PLL2"); snd_soc_dapm_force_enable_pin_unlocked(dapm, "PLL2");
snd_soc_dapm_sync(&codec->dapm); snd_soc_dapm_sync_unlocked(dapm);
snd_soc_dapm_mutex_unlock(dapm);
} }
return 0; return 0;

View File

@ -2100,6 +2100,7 @@ static void wm5100_micd_irq(struct wm5100_priv *wm5100)
int wm5100_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack) int wm5100_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack)
{ {
struct wm5100_priv *wm5100 = snd_soc_codec_get_drvdata(codec); struct wm5100_priv *wm5100 = snd_soc_codec_get_drvdata(codec);
struct snd_soc_dapm_context *dapm = &codec->dapm;
if (jack) { if (jack) {
wm5100->jack = jack; wm5100->jack = jack;
@ -2117,9 +2118,14 @@ int wm5100_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack)
WM5100_ACCDET_RATE_MASK); WM5100_ACCDET_RATE_MASK);
/* We need the charge pump to power MICBIAS */ /* We need the charge pump to power MICBIAS */
snd_soc_dapm_force_enable_pin(&codec->dapm, "CP2"); snd_soc_dapm_mutex_lock(dapm);
snd_soc_dapm_force_enable_pin(&codec->dapm, "SYSCLK");
snd_soc_dapm_sync(&codec->dapm); snd_soc_dapm_force_enable_pin_unlocked(dapm, "CP2");
snd_soc_dapm_force_enable_pin_unlocked(dapm, "SYSCLK");
snd_soc_dapm_sync_unlocked(dapm);
snd_soc_dapm_mutex_unlock(dapm);
/* We start off just enabling microphone detection - even a /* We start off just enabling microphone detection - even a
* plain headphone will trigger detection. * plain headphone will trigger detection.

View File

@ -3089,6 +3089,7 @@ static irqreturn_t wm8962_irq(int irq, void *data)
int wm8962_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack) int wm8962_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack)
{ {
struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
struct snd_soc_dapm_context *dapm = &codec->dapm;
int irq_mask, enable; int irq_mask, enable;
wm8962->jack = jack; wm8962->jack = jack;
@ -3109,14 +3110,18 @@ int wm8962_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack)
snd_soc_jack_report(wm8962->jack, 0, snd_soc_jack_report(wm8962->jack, 0,
SND_JACK_MICROPHONE | SND_JACK_BTN_0); SND_JACK_MICROPHONE | SND_JACK_BTN_0);
snd_soc_dapm_mutex_lock(dapm);
if (jack) { if (jack) {
snd_soc_dapm_force_enable_pin(&codec->dapm, "SYSCLK"); snd_soc_dapm_force_enable_pin_unlocked(dapm, "SYSCLK");
snd_soc_dapm_force_enable_pin(&codec->dapm, "MICBIAS"); snd_soc_dapm_force_enable_pin_unlocked(dapm, "MICBIAS");
} else { } else {
snd_soc_dapm_disable_pin(&codec->dapm, "SYSCLK"); snd_soc_dapm_disable_pin_unlocked(dapm, "SYSCLK");
snd_soc_dapm_disable_pin(&codec->dapm, "MICBIAS"); snd_soc_dapm_disable_pin_unlocked(dapm, "MICBIAS");
} }
snd_soc_dapm_mutex_unlock(dapm);
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(wm8962_mic_detect); EXPORT_SYMBOL_GPL(wm8962_mic_detect);

View File

@ -2554,43 +2554,52 @@ static int wm8994_set_bias_level(struct snd_soc_codec *codec,
int wm8994_vmid_mode(struct snd_soc_codec *codec, enum wm8994_vmid_mode mode) int wm8994_vmid_mode(struct snd_soc_codec *codec, enum wm8994_vmid_mode mode)
{ {
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
struct snd_soc_dapm_context *dapm = &codec->dapm;
switch (mode) { switch (mode) {
case WM8994_VMID_NORMAL: case WM8994_VMID_NORMAL:
snd_soc_dapm_mutex_lock(dapm);
if (wm8994->hubs.lineout1_se) { if (wm8994->hubs.lineout1_se) {
snd_soc_dapm_disable_pin(&codec->dapm, snd_soc_dapm_disable_pin_unlocked(dapm,
"LINEOUT1N Driver"); "LINEOUT1N Driver");
snd_soc_dapm_disable_pin(&codec->dapm, snd_soc_dapm_disable_pin_unlocked(dapm,
"LINEOUT1P Driver"); "LINEOUT1P Driver");
} }
if (wm8994->hubs.lineout2_se) { if (wm8994->hubs.lineout2_se) {
snd_soc_dapm_disable_pin(&codec->dapm, snd_soc_dapm_disable_pin_unlocked(dapm,
"LINEOUT2N Driver"); "LINEOUT2N Driver");
snd_soc_dapm_disable_pin(&codec->dapm, snd_soc_dapm_disable_pin_unlocked(dapm,
"LINEOUT2P Driver"); "LINEOUT2P Driver");
} }
/* Do the sync with the old mode to allow it to clean up */ /* Do the sync with the old mode to allow it to clean up */
snd_soc_dapm_sync(&codec->dapm); snd_soc_dapm_sync_unlocked(dapm);
wm8994->vmid_mode = mode; wm8994->vmid_mode = mode;
snd_soc_dapm_mutex_unlock(dapm);
break; break;
case WM8994_VMID_FORCE: case WM8994_VMID_FORCE:
snd_soc_dapm_mutex_lock(dapm);
if (wm8994->hubs.lineout1_se) { if (wm8994->hubs.lineout1_se) {
snd_soc_dapm_force_enable_pin(&codec->dapm, snd_soc_dapm_force_enable_pin_unlocked(dapm,
"LINEOUT1N Driver"); "LINEOUT1N Driver");
snd_soc_dapm_force_enable_pin(&codec->dapm, snd_soc_dapm_force_enable_pin_unlocked(dapm,
"LINEOUT1P Driver"); "LINEOUT1P Driver");
} }
if (wm8994->hubs.lineout2_se) { if (wm8994->hubs.lineout2_se) {
snd_soc_dapm_force_enable_pin(&codec->dapm, snd_soc_dapm_force_enable_pin_unlocked(dapm,
"LINEOUT2N Driver"); "LINEOUT2N Driver");
snd_soc_dapm_force_enable_pin(&codec->dapm, snd_soc_dapm_force_enable_pin_unlocked(dapm,
"LINEOUT2P Driver"); "LINEOUT2P Driver");
} }
wm8994->vmid_mode = mode; wm8994->vmid_mode = mode;
snd_soc_dapm_sync(&codec->dapm); snd_soc_dapm_sync_unlocked(dapm);
snd_soc_dapm_mutex_unlock(dapm);
break; break;
default: default:

View File

@ -2251,6 +2251,7 @@ int wm8996_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack,
wm8996_polarity_fn polarity_cb) wm8996_polarity_fn polarity_cb)
{ {
struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec);
struct snd_soc_dapm_context *dapm = &codec->dapm;
wm8996->jack = jack; wm8996->jack = jack;
wm8996->detecting = true; wm8996->detecting = true;
@ -2267,8 +2268,12 @@ int wm8996_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack,
WM8996_MICB2_DISCH, 0); WM8996_MICB2_DISCH, 0);
/* LDO2 powers the microphones, SYSCLK clocks detection */ /* LDO2 powers the microphones, SYSCLK clocks detection */
snd_soc_dapm_force_enable_pin(&codec->dapm, "LDO2"); snd_soc_dapm_mutex_lock(dapm);
snd_soc_dapm_force_enable_pin(&codec->dapm, "SYSCLK");
snd_soc_dapm_force_enable_pin_unlocked(dapm, "LDO2");
snd_soc_dapm_force_enable_pin_unlocked(dapm, "SYSCLK");
snd_soc_dapm_mutex_unlock(dapm);
/* We start off just enabling microphone detection - even a /* We start off just enabling microphone detection - even a
* plain headphone will trigger detection. * plain headphone will trigger detection.

View File

@ -101,20 +101,27 @@ static int headset_set_switch(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
struct snd_soc_dapm_context *dapm = &codec->dapm;
if (ucontrol->value.integer.value[0] == hs_switch) if (ucontrol->value.integer.value[0] == hs_switch)
return 0; return 0;
snd_soc_dapm_mutex_lock(dapm);
if (ucontrol->value.integer.value[0]) { if (ucontrol->value.integer.value[0]) {
pr_debug("hs_set HS path\n"); pr_debug("hs_set HS path\n");
snd_soc_dapm_enable_pin(&codec->dapm, "Headphones"); snd_soc_dapm_enable_pin_unlocked(dapm, "Headphones");
snd_soc_dapm_disable_pin(&codec->dapm, "EPOUT"); snd_soc_dapm_disable_pin_unlocked(dapm, "EPOUT");
} else { } else {
pr_debug("hs_set EP path\n"); pr_debug("hs_set EP path\n");
snd_soc_dapm_disable_pin(&codec->dapm, "Headphones"); snd_soc_dapm_disable_pin_unlocked(dapm, "Headphones");
snd_soc_dapm_enable_pin(&codec->dapm, "EPOUT"); snd_soc_dapm_enable_pin_unlocked(dapm, "EPOUT");
} }
snd_soc_dapm_sync(&codec->dapm);
snd_soc_dapm_sync_unlocked(dapm);
snd_soc_dapm_mutex_unlock(dapm);
hs_switch = ucontrol->value.integer.value[0]; hs_switch = ucontrol->value.integer.value[0];
return 0; return 0;
@ -122,18 +129,20 @@ static int headset_set_switch(struct snd_kcontrol *kcontrol,
static void lo_enable_out_pins(struct snd_soc_codec *codec) static void lo_enable_out_pins(struct snd_soc_codec *codec)
{ {
snd_soc_dapm_enable_pin(&codec->dapm, "IHFOUTL"); struct snd_soc_dapm_context *dapm = &codec->dapm;
snd_soc_dapm_enable_pin(&codec->dapm, "IHFOUTR");
snd_soc_dapm_enable_pin(&codec->dapm, "LINEOUTL"); snd_soc_dapm_enable_pin_unlocked(dapm, "IHFOUTL");
snd_soc_dapm_enable_pin(&codec->dapm, "LINEOUTR"); snd_soc_dapm_enable_pin_unlocked(dapm, "IHFOUTR");
snd_soc_dapm_enable_pin(&codec->dapm, "VIB1OUT"); snd_soc_dapm_enable_pin_unlocked(dapm, "LINEOUTL");
snd_soc_dapm_enable_pin(&codec->dapm, "VIB2OUT"); snd_soc_dapm_enable_pin_unlocked(dapm, "LINEOUTR");
snd_soc_dapm_enable_pin_unlocked(dapm, "VIB1OUT");
snd_soc_dapm_enable_pin_unlocked(dapm, "VIB2OUT");
if (hs_switch) { if (hs_switch) {
snd_soc_dapm_enable_pin(&codec->dapm, "Headphones"); snd_soc_dapm_enable_pin_unlocked(dapm, "Headphones");
snd_soc_dapm_disable_pin(&codec->dapm, "EPOUT"); snd_soc_dapm_disable_pin_unlocked(dapm, "EPOUT");
} else { } else {
snd_soc_dapm_disable_pin(&codec->dapm, "Headphones"); snd_soc_dapm_disable_pin_unlocked(dapm, "Headphones");
snd_soc_dapm_enable_pin(&codec->dapm, "EPOUT"); snd_soc_dapm_enable_pin_unlocked(dapm, "EPOUT");
} }
} }
@ -148,44 +157,52 @@ static int lo_set_switch(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
struct snd_soc_dapm_context *dapm = &codec->dapm;
if (ucontrol->value.integer.value[0] == lo_dac) if (ucontrol->value.integer.value[0] == lo_dac)
return 0; return 0;
snd_soc_dapm_mutex_lock(dapm);
/* we dont want to work with last state of lineout so just enable all /* we dont want to work with last state of lineout so just enable all
* pins and then disable pins not required * pins and then disable pins not required
*/ */
lo_enable_out_pins(codec); lo_enable_out_pins(codec);
switch (ucontrol->value.integer.value[0]) { switch (ucontrol->value.integer.value[0]) {
case 0: case 0:
pr_debug("set vibra path\n"); pr_debug("set vibra path\n");
snd_soc_dapm_disable_pin(&codec->dapm, "VIB1OUT"); snd_soc_dapm_disable_pin_unlocked(dapm, "VIB1OUT");
snd_soc_dapm_disable_pin(&codec->dapm, "VIB2OUT"); snd_soc_dapm_disable_pin_unlocked(dapm, "VIB2OUT");
snd_soc_update_bits(codec, SN95031_LOCTL, 0x66, 0); snd_soc_update_bits(codec, SN95031_LOCTL, 0x66, 0);
break; break;
case 1: case 1:
pr_debug("set hs path\n"); pr_debug("set hs path\n");
snd_soc_dapm_disable_pin(&codec->dapm, "Headphones"); snd_soc_dapm_disable_pin_unlocked(dapm, "Headphones");
snd_soc_dapm_disable_pin(&codec->dapm, "EPOUT"); snd_soc_dapm_disable_pin_unlocked(dapm, "EPOUT");
snd_soc_update_bits(codec, SN95031_LOCTL, 0x66, 0x22); snd_soc_update_bits(codec, SN95031_LOCTL, 0x66, 0x22);
break; break;
case 2: case 2:
pr_debug("set spkr path\n"); pr_debug("set spkr path\n");
snd_soc_dapm_disable_pin(&codec->dapm, "IHFOUTL"); snd_soc_dapm_disable_pin_unlocked(dapm, "IHFOUTL");
snd_soc_dapm_disable_pin(&codec->dapm, "IHFOUTR"); snd_soc_dapm_disable_pin_unlocked(dapm, "IHFOUTR");
snd_soc_update_bits(codec, SN95031_LOCTL, 0x66, 0x44); snd_soc_update_bits(codec, SN95031_LOCTL, 0x66, 0x44);
break; break;
case 3: case 3:
pr_debug("set null path\n"); pr_debug("set null path\n");
snd_soc_dapm_disable_pin(&codec->dapm, "LINEOUTL"); snd_soc_dapm_disable_pin_unlocked(dapm, "LINEOUTL");
snd_soc_dapm_disable_pin(&codec->dapm, "LINEOUTR"); snd_soc_dapm_disable_pin_unlocked(dapm, "LINEOUTR");
snd_soc_update_bits(codec, SN95031_LOCTL, 0x66, 0x66); snd_soc_update_bits(codec, SN95031_LOCTL, 0x66, 0x66);
break; break;
} }
snd_soc_dapm_sync(&codec->dapm);
snd_soc_dapm_sync_unlocked(dapm);
snd_soc_dapm_mutex_unlock(dapm);
lo_dac = ucontrol->value.integer.value[0]; lo_dac = ucontrol->value.integer.value[0];
return 0; return 0;
} }

View File

@ -106,57 +106,59 @@ static int ams_delta_set_audio_mode(struct snd_kcontrol *kcontrol,
if (ucontrol->value.enumerated.item[0] >= control->max) if (ucontrol->value.enumerated.item[0] >= control->max)
return -EINVAL; return -EINVAL;
mutex_lock(&codec->mutex); snd_soc_dapm_mutex_lock(dapm);
/* Translate selection to bitmap */ /* Translate selection to bitmap */
pins = ams_delta_audio_mode_pins[ucontrol->value.enumerated.item[0]]; pins = ams_delta_audio_mode_pins[ucontrol->value.enumerated.item[0]];
/* Setup pins after corresponding bits if changed */ /* Setup pins after corresponding bits if changed */
pin = !!(pins & (1 << AMS_DELTA_MOUTHPIECE)); pin = !!(pins & (1 << AMS_DELTA_MOUTHPIECE));
if (pin != snd_soc_dapm_get_pin_status(dapm, "Mouthpiece")) { if (pin != snd_soc_dapm_get_pin_status(dapm, "Mouthpiece")) {
changed = 1; changed = 1;
if (pin) if (pin)
snd_soc_dapm_enable_pin(dapm, "Mouthpiece"); snd_soc_dapm_enable_pin_unlocked(dapm, "Mouthpiece");
else else
snd_soc_dapm_disable_pin(dapm, "Mouthpiece"); snd_soc_dapm_disable_pin_unlocked(dapm, "Mouthpiece");
} }
pin = !!(pins & (1 << AMS_DELTA_EARPIECE)); pin = !!(pins & (1 << AMS_DELTA_EARPIECE));
if (pin != snd_soc_dapm_get_pin_status(dapm, "Earpiece")) { if (pin != snd_soc_dapm_get_pin_status(dapm, "Earpiece")) {
changed = 1; changed = 1;
if (pin) if (pin)
snd_soc_dapm_enable_pin(dapm, "Earpiece"); snd_soc_dapm_enable_pin_unlocked(dapm, "Earpiece");
else else
snd_soc_dapm_disable_pin(dapm, "Earpiece"); snd_soc_dapm_disable_pin_unlocked(dapm, "Earpiece");
} }
pin = !!(pins & (1 << AMS_DELTA_MICROPHONE)); pin = !!(pins & (1 << AMS_DELTA_MICROPHONE));
if (pin != snd_soc_dapm_get_pin_status(dapm, "Microphone")) { if (pin != snd_soc_dapm_get_pin_status(dapm, "Microphone")) {
changed = 1; changed = 1;
if (pin) if (pin)
snd_soc_dapm_enable_pin(dapm, "Microphone"); snd_soc_dapm_enable_pin_unlocked(dapm, "Microphone");
else else
snd_soc_dapm_disable_pin(dapm, "Microphone"); snd_soc_dapm_disable_pin_unlocked(dapm, "Microphone");
} }
pin = !!(pins & (1 << AMS_DELTA_SPEAKER)); pin = !!(pins & (1 << AMS_DELTA_SPEAKER));
if (pin != snd_soc_dapm_get_pin_status(dapm, "Speaker")) { if (pin != snd_soc_dapm_get_pin_status(dapm, "Speaker")) {
changed = 1; changed = 1;
if (pin) if (pin)
snd_soc_dapm_enable_pin(dapm, "Speaker"); snd_soc_dapm_enable_pin_unlocked(dapm, "Speaker");
else else
snd_soc_dapm_disable_pin(dapm, "Speaker"); snd_soc_dapm_disable_pin_unlocked(dapm, "Speaker");
} }
pin = !!(pins & (1 << AMS_DELTA_AGC)); pin = !!(pins & (1 << AMS_DELTA_AGC));
if (pin != ams_delta_audio_agc) { if (pin != ams_delta_audio_agc) {
ams_delta_audio_agc = pin; ams_delta_audio_agc = pin;
changed = 1; changed = 1;
if (pin) if (pin)
snd_soc_dapm_enable_pin(dapm, "AGCIN"); snd_soc_dapm_enable_pin_unlocked(dapm, "AGCIN");
else else
snd_soc_dapm_disable_pin(dapm, "AGCIN"); snd_soc_dapm_disable_pin_unlocked(dapm, "AGCIN");
} }
if (changed)
snd_soc_dapm_sync(dapm);
mutex_unlock(&codec->mutex); if (changed)
snd_soc_dapm_sync_unlocked(dapm);
snd_soc_dapm_mutex_unlock(dapm);
return changed; return changed;
} }
@ -315,12 +317,17 @@ static void cx81801_close(struct tty_struct *tty)
v253_ops.close(tty); v253_ops.close(tty);
/* Revert back to default audio input/output constellation */ /* Revert back to default audio input/output constellation */
snd_soc_dapm_disable_pin(dapm, "Mouthpiece"); snd_soc_dapm_mutex_lock(dapm);
snd_soc_dapm_enable_pin(dapm, "Earpiece");
snd_soc_dapm_enable_pin(dapm, "Microphone"); snd_soc_dapm_disable_pin_unlocked(dapm, "Mouthpiece");
snd_soc_dapm_disable_pin(dapm, "Speaker"); snd_soc_dapm_enable_pin_unlocked(dapm, "Earpiece");
snd_soc_dapm_disable_pin(dapm, "AGCIN"); snd_soc_dapm_enable_pin_unlocked(dapm, "Microphone");
snd_soc_dapm_sync(dapm); snd_soc_dapm_disable_pin_unlocked(dapm, "Speaker");
snd_soc_dapm_disable_pin_unlocked(dapm, "AGCIN");
snd_soc_dapm_sync_unlocked(dapm);
snd_soc_dapm_mutex_unlock(codec);
} }
/* Line discipline .hangup() */ /* Line discipline .hangup() */

View File

@ -68,26 +68,30 @@ static void n810_ext_control(struct snd_soc_dapm_context *dapm)
break; break;
} }
snd_soc_dapm_mutex_lock(dapm);
if (n810_spk_func) if (n810_spk_func)
snd_soc_dapm_enable_pin(dapm, "Ext Spk"); snd_soc_dapm_enable_pin_unlocked(dapm, "Ext Spk");
else else
snd_soc_dapm_disable_pin(dapm, "Ext Spk"); snd_soc_dapm_disable_pin_unlocked(dapm, "Ext Spk");
if (hp) if (hp)
snd_soc_dapm_enable_pin(dapm, "Headphone Jack"); snd_soc_dapm_enable_pin_unlocked(dapm, "Headphone Jack");
else else
snd_soc_dapm_disable_pin(dapm, "Headphone Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Headphone Jack");
if (line1l) if (line1l)
snd_soc_dapm_enable_pin(dapm, "LINE1L"); snd_soc_dapm_enable_pin_unlocked(dapm, "LINE1L");
else else
snd_soc_dapm_disable_pin(dapm, "LINE1L"); snd_soc_dapm_disable_pin_unlocked(dapm, "LINE1L");
if (n810_dmic_func) if (n810_dmic_func)
snd_soc_dapm_enable_pin(dapm, "DMic"); snd_soc_dapm_enable_pin_unlocked(dapm, "DMic");
else else
snd_soc_dapm_disable_pin(dapm, "DMic"); snd_soc_dapm_disable_pin_unlocked(dapm, "DMic");
snd_soc_dapm_sync(dapm); snd_soc_dapm_sync_unlocked(dapm);
snd_soc_dapm_mutex_unlock(dapm);
} }
static int n810_startup(struct snd_pcm_substream *substream) static int n810_startup(struct snd_pcm_substream *substream)

View File

@ -74,26 +74,30 @@ static void rx51_ext_control(struct snd_soc_dapm_context *dapm)
break; break;
} }
snd_soc_dapm_mutex_lock(dapm);
if (rx51_spk_func) if (rx51_spk_func)
snd_soc_dapm_enable_pin(dapm, "Ext Spk"); snd_soc_dapm_enable_pin_unlocked(dapm, "Ext Spk");
else else
snd_soc_dapm_disable_pin(dapm, "Ext Spk"); snd_soc_dapm_disable_pin_unlocked(dapm, "Ext Spk");
if (rx51_dmic_func) if (rx51_dmic_func)
snd_soc_dapm_enable_pin(dapm, "DMic"); snd_soc_dapm_enable_pin_unlocked(dapm, "DMic");
else else
snd_soc_dapm_disable_pin(dapm, "DMic"); snd_soc_dapm_disable_pin_unlocked(dapm, "DMic");
if (hp) if (hp)
snd_soc_dapm_enable_pin(dapm, "Headphone Jack"); snd_soc_dapm_enable_pin_unlocked(dapm, "Headphone Jack");
else else
snd_soc_dapm_disable_pin(dapm, "Headphone Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Headphone Jack");
if (hs) if (hs)
snd_soc_dapm_enable_pin(dapm, "HS Mic"); snd_soc_dapm_enable_pin_unlocked(dapm, "HS Mic");
else else
snd_soc_dapm_disable_pin(dapm, "HS Mic"); snd_soc_dapm_disable_pin_unlocked(dapm, "HS Mic");
gpio_set_value(RX51_TVOUT_SEL_GPIO, tvout); gpio_set_value(RX51_TVOUT_SEL_GPIO, tvout);
snd_soc_dapm_sync(dapm); snd_soc_dapm_sync_unlocked(dapm);
snd_soc_dapm_mutex_unlock(dapm);
} }
static int rx51_startup(struct snd_pcm_substream *substream) static int rx51_startup(struct snd_pcm_substream *substream)

View File

@ -47,51 +47,55 @@ static int corgi_spk_func;
static void corgi_ext_control(struct snd_soc_dapm_context *dapm) static void corgi_ext_control(struct snd_soc_dapm_context *dapm)
{ {
snd_soc_dapm_mutex_lock(dapm);
/* set up jack connection */ /* set up jack connection */
switch (corgi_jack_func) { switch (corgi_jack_func) {
case CORGI_HP: case CORGI_HP:
/* set = unmute headphone */ /* set = unmute headphone */
gpio_set_value(CORGI_GPIO_MUTE_L, 1); gpio_set_value(CORGI_GPIO_MUTE_L, 1);
gpio_set_value(CORGI_GPIO_MUTE_R, 1); gpio_set_value(CORGI_GPIO_MUTE_R, 1);
snd_soc_dapm_disable_pin(dapm, "Mic Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Mic Jack");
snd_soc_dapm_disable_pin(dapm, "Line Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Line Jack");
snd_soc_dapm_enable_pin(dapm, "Headphone Jack"); snd_soc_dapm_enable_pin_unlocked(dapm, "Headphone Jack");
snd_soc_dapm_disable_pin(dapm, "Headset Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Headset Jack");
break; break;
case CORGI_MIC: case CORGI_MIC:
/* reset = mute headphone */ /* reset = mute headphone */
gpio_set_value(CORGI_GPIO_MUTE_L, 0); gpio_set_value(CORGI_GPIO_MUTE_L, 0);
gpio_set_value(CORGI_GPIO_MUTE_R, 0); gpio_set_value(CORGI_GPIO_MUTE_R, 0);
snd_soc_dapm_enable_pin(dapm, "Mic Jack"); snd_soc_dapm_enable_pin_unlocked(dapm, "Mic Jack");
snd_soc_dapm_disable_pin(dapm, "Line Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Line Jack");
snd_soc_dapm_disable_pin(dapm, "Headphone Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Headphone Jack");
snd_soc_dapm_disable_pin(dapm, "Headset Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Headset Jack");
break; break;
case CORGI_LINE: case CORGI_LINE:
gpio_set_value(CORGI_GPIO_MUTE_L, 0); gpio_set_value(CORGI_GPIO_MUTE_L, 0);
gpio_set_value(CORGI_GPIO_MUTE_R, 0); gpio_set_value(CORGI_GPIO_MUTE_R, 0);
snd_soc_dapm_disable_pin(dapm, "Mic Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Mic Jack");
snd_soc_dapm_enable_pin(dapm, "Line Jack"); snd_soc_dapm_enable_pin_unlocked(dapm, "Line Jack");
snd_soc_dapm_disable_pin(dapm, "Headphone Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Headphone Jack");
snd_soc_dapm_disable_pin(dapm, "Headset Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Headset Jack");
break; break;
case CORGI_HEADSET: case CORGI_HEADSET:
gpio_set_value(CORGI_GPIO_MUTE_L, 0); gpio_set_value(CORGI_GPIO_MUTE_L, 0);
gpio_set_value(CORGI_GPIO_MUTE_R, 1); gpio_set_value(CORGI_GPIO_MUTE_R, 1);
snd_soc_dapm_enable_pin(dapm, "Mic Jack"); snd_soc_dapm_enable_pin_unlocked(dapm, "Mic Jack");
snd_soc_dapm_disable_pin(dapm, "Line Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Line Jack");
snd_soc_dapm_disable_pin(dapm, "Headphone Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Headphone Jack");
snd_soc_dapm_enable_pin(dapm, "Headset Jack"); snd_soc_dapm_enable_pin_unlocked(dapm, "Headset Jack");
break; break;
} }
if (corgi_spk_func == CORGI_SPK_ON) if (corgi_spk_func == CORGI_SPK_ON)
snd_soc_dapm_enable_pin(dapm, "Ext Spk"); snd_soc_dapm_enable_pin_unlocked(dapm, "Ext Spk");
else else
snd_soc_dapm_disable_pin(dapm, "Ext Spk"); snd_soc_dapm_disable_pin_unlocked(dapm, "Ext Spk");
/* signal a DAPM event */ /* signal a DAPM event */
snd_soc_dapm_sync(dapm); snd_soc_dapm_sync_unlocked(dapm);
snd_soc_dapm_mutex_unlock(dapm);
} }
static int corgi_startup(struct snd_pcm_substream *substream) static int corgi_startup(struct snd_pcm_substream *substream)

View File

@ -45,27 +45,31 @@ static void magician_ext_control(struct snd_soc_codec *codec)
{ {
struct snd_soc_dapm_context *dapm = &codec->dapm; struct snd_soc_dapm_context *dapm = &codec->dapm;
snd_soc_dapm_mutex_lock(dapm);
if (magician_spk_switch) if (magician_spk_switch)
snd_soc_dapm_enable_pin(dapm, "Speaker"); snd_soc_dapm_enable_pin_unlocked(dapm, "Speaker");
else else
snd_soc_dapm_disable_pin(dapm, "Speaker"); snd_soc_dapm_disable_pin_unlocked(dapm, "Speaker");
if (magician_hp_switch) if (magician_hp_switch)
snd_soc_dapm_enable_pin(dapm, "Headphone Jack"); snd_soc_dapm_enable_pin_unlocked(dapm, "Headphone Jack");
else else
snd_soc_dapm_disable_pin(dapm, "Headphone Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Headphone Jack");
switch (magician_in_sel) { switch (magician_in_sel) {
case MAGICIAN_MIC: case MAGICIAN_MIC:
snd_soc_dapm_disable_pin(dapm, "Headset Mic"); snd_soc_dapm_disable_pin_unlocked(dapm, "Headset Mic");
snd_soc_dapm_enable_pin(dapm, "Call Mic"); snd_soc_dapm_enable_pin_unlocked(dapm, "Call Mic");
break; break;
case MAGICIAN_MIC_EXT: case MAGICIAN_MIC_EXT:
snd_soc_dapm_disable_pin(dapm, "Call Mic"); snd_soc_dapm_disable_pin_unlocked(dapm, "Call Mic");
snd_soc_dapm_enable_pin(dapm, "Headset Mic"); snd_soc_dapm_enable_pin_unlocked(dapm, "Headset Mic");
break; break;
} }
snd_soc_dapm_sync(dapm); snd_soc_dapm_sync_unlocked(dapm);
snd_soc_dapm_mutex_unlock(dapm);
} }
static int magician_startup(struct snd_pcm_substream *substream) static int magician_startup(struct snd_pcm_substream *substream)

View File

@ -46,61 +46,66 @@ static int spitz_mic_gpio;
static void spitz_ext_control(struct snd_soc_dapm_context *dapm) static void spitz_ext_control(struct snd_soc_dapm_context *dapm)
{ {
snd_soc_dapm_mutex_lock(dapm);
if (spitz_spk_func == SPITZ_SPK_ON) if (spitz_spk_func == SPITZ_SPK_ON)
snd_soc_dapm_enable_pin(dapm, "Ext Spk"); snd_soc_dapm_enable_pin_unlocked(dapm, "Ext Spk");
else else
snd_soc_dapm_disable_pin(dapm, "Ext Spk"); snd_soc_dapm_disable_pin_unlocked(dapm, "Ext Spk");
/* set up jack connection */ /* set up jack connection */
switch (spitz_jack_func) { switch (spitz_jack_func) {
case SPITZ_HP: case SPITZ_HP:
/* enable and unmute hp jack, disable mic bias */ /* enable and unmute hp jack, disable mic bias */
snd_soc_dapm_disable_pin(dapm, "Headset Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Headset Jack");
snd_soc_dapm_disable_pin(dapm, "Mic Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Mic Jack");
snd_soc_dapm_disable_pin(dapm, "Line Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Line Jack");
snd_soc_dapm_enable_pin(dapm, "Headphone Jack"); snd_soc_dapm_enable_pin_unlocked(dapm, "Headphone Jack");
gpio_set_value(SPITZ_GPIO_MUTE_L, 1); gpio_set_value(SPITZ_GPIO_MUTE_L, 1);
gpio_set_value(SPITZ_GPIO_MUTE_R, 1); gpio_set_value(SPITZ_GPIO_MUTE_R, 1);
break; break;
case SPITZ_MIC: case SPITZ_MIC:
/* enable mic jack and bias, mute hp */ /* enable mic jack and bias, mute hp */
snd_soc_dapm_disable_pin(dapm, "Headphone Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Headphone Jack");
snd_soc_dapm_disable_pin(dapm, "Headset Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Headset Jack");
snd_soc_dapm_disable_pin(dapm, "Line Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Line Jack");
snd_soc_dapm_enable_pin(dapm, "Mic Jack"); snd_soc_dapm_enable_pin_unlocked(dapm, "Mic Jack");
gpio_set_value(SPITZ_GPIO_MUTE_L, 0); gpio_set_value(SPITZ_GPIO_MUTE_L, 0);
gpio_set_value(SPITZ_GPIO_MUTE_R, 0); gpio_set_value(SPITZ_GPIO_MUTE_R, 0);
break; break;
case SPITZ_LINE: case SPITZ_LINE:
/* enable line jack, disable mic bias and mute hp */ /* enable line jack, disable mic bias and mute hp */
snd_soc_dapm_disable_pin(dapm, "Headphone Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Headphone Jack");
snd_soc_dapm_disable_pin(dapm, "Headset Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Headset Jack");
snd_soc_dapm_disable_pin(dapm, "Mic Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Mic Jack");
snd_soc_dapm_enable_pin(dapm, "Line Jack"); snd_soc_dapm_enable_pin_unlocked(dapm, "Line Jack");
gpio_set_value(SPITZ_GPIO_MUTE_L, 0); gpio_set_value(SPITZ_GPIO_MUTE_L, 0);
gpio_set_value(SPITZ_GPIO_MUTE_R, 0); gpio_set_value(SPITZ_GPIO_MUTE_R, 0);
break; break;
case SPITZ_HEADSET: case SPITZ_HEADSET:
/* enable and unmute headset jack enable mic bias, mute L hp */ /* enable and unmute headset jack enable mic bias, mute L hp */
snd_soc_dapm_disable_pin(dapm, "Headphone Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Headphone Jack");
snd_soc_dapm_enable_pin(dapm, "Mic Jack"); snd_soc_dapm_enable_pin_unlocked(dapm, "Mic Jack");
snd_soc_dapm_disable_pin(dapm, "Line Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Line Jack");
snd_soc_dapm_enable_pin(dapm, "Headset Jack"); snd_soc_dapm_enable_pin_unlocked(dapm, "Headset Jack");
gpio_set_value(SPITZ_GPIO_MUTE_L, 0); gpio_set_value(SPITZ_GPIO_MUTE_L, 0);
gpio_set_value(SPITZ_GPIO_MUTE_R, 1); gpio_set_value(SPITZ_GPIO_MUTE_R, 1);
break; break;
case SPITZ_HP_OFF: case SPITZ_HP_OFF:
/* jack removed, everything off */ /* jack removed, everything off */
snd_soc_dapm_disable_pin(dapm, "Headphone Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Headphone Jack");
snd_soc_dapm_disable_pin(dapm, "Headset Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Headset Jack");
snd_soc_dapm_disable_pin(dapm, "Mic Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Mic Jack");
snd_soc_dapm_disable_pin(dapm, "Line Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Line Jack");
gpio_set_value(SPITZ_GPIO_MUTE_L, 0); gpio_set_value(SPITZ_GPIO_MUTE_L, 0);
gpio_set_value(SPITZ_GPIO_MUTE_R, 0); gpio_set_value(SPITZ_GPIO_MUTE_R, 0);
break; break;
} }
snd_soc_dapm_sync(dapm);
snd_soc_dapm_sync_unlocked(dapm);
snd_soc_dapm_mutex_unlock(dapm);
} }
static int spitz_startup(struct snd_pcm_substream *substream) static int spitz_startup(struct snd_pcm_substream *substream)

View File

@ -48,31 +48,35 @@ static void tosa_ext_control(struct snd_soc_codec *codec)
{ {
struct snd_soc_dapm_context *dapm = &codec->dapm; struct snd_soc_dapm_context *dapm = &codec->dapm;
snd_soc_dapm_mutex_lock(dapm);
/* set up jack connection */ /* set up jack connection */
switch (tosa_jack_func) { switch (tosa_jack_func) {
case TOSA_HP: case TOSA_HP:
snd_soc_dapm_disable_pin(dapm, "Mic (Internal)"); snd_soc_dapm_disable_pin_unlocked(dapm, "Mic (Internal)");
snd_soc_dapm_enable_pin(dapm, "Headphone Jack"); snd_soc_dapm_enable_pin_unlocked(dapm, "Headphone Jack");
snd_soc_dapm_disable_pin(dapm, "Headset Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Headset Jack");
break; break;
case TOSA_MIC_INT: case TOSA_MIC_INT:
snd_soc_dapm_enable_pin(dapm, "Mic (Internal)"); snd_soc_dapm_enable_pin_unlocked(dapm, "Mic (Internal)");
snd_soc_dapm_disable_pin(dapm, "Headphone Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Headphone Jack");
snd_soc_dapm_disable_pin(dapm, "Headset Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Headset Jack");
break; break;
case TOSA_HEADSET: case TOSA_HEADSET:
snd_soc_dapm_disable_pin(dapm, "Mic (Internal)"); snd_soc_dapm_disable_pin_unlocked(dapm, "Mic (Internal)");
snd_soc_dapm_disable_pin(dapm, "Headphone Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Headphone Jack");
snd_soc_dapm_enable_pin(dapm, "Headset Jack"); snd_soc_dapm_enable_pin_unlocked(dapm, "Headset Jack");
break; break;
} }
if (tosa_spk_func == TOSA_SPK_ON) if (tosa_spk_func == TOSA_SPK_ON)
snd_soc_dapm_enable_pin(dapm, "Speaker"); snd_soc_dapm_enable_pin_unlocked(dapm, "Speaker");
else else
snd_soc_dapm_disable_pin(dapm, "Speaker"); snd_soc_dapm_disable_pin_unlocked(dapm, "Speaker");
snd_soc_dapm_sync(dapm); snd_soc_dapm_sync_unlocked(dapm);
snd_soc_dapm_mutex_unlock(dapm);
} }
static int tosa_startup(struct snd_pcm_substream *substream) static int tosa_startup(struct snd_pcm_substream *substream)

View File

@ -115,6 +115,12 @@ static int dapm_down_seq[] = {
[snd_soc_dapm_post] = 14, [snd_soc_dapm_post] = 14,
}; };
static void dapm_assert_locked(struct snd_soc_dapm_context *dapm)
{
if (dapm->card && dapm->card->instantiated)
lockdep_assert_held(&dapm->card->dapm_mutex);
}
static void pop_wait(u32 pop_time) static void pop_wait(u32 pop_time)
{ {
if (pop_time) if (pop_time)
@ -146,15 +152,16 @@ static bool dapm_dirty_widget(struct snd_soc_dapm_widget *w)
return !list_empty(&w->dirty); return !list_empty(&w->dirty);
} }
void dapm_mark_dirty(struct snd_soc_dapm_widget *w, const char *reason) static void dapm_mark_dirty(struct snd_soc_dapm_widget *w, const char *reason)
{ {
dapm_assert_locked(w->dapm);
if (!dapm_dirty_widget(w)) { if (!dapm_dirty_widget(w)) {
dev_vdbg(w->dapm->dev, "Marking %s dirty due to %s\n", dev_vdbg(w->dapm->dev, "Marking %s dirty due to %s\n",
w->name, reason); w->name, reason);
list_add_tail(&w->dirty, &w->dapm->card->dapm_dirty); list_add_tail(&w->dirty, &w->dapm->card->dapm_dirty);
} }
} }
EXPORT_SYMBOL_GPL(dapm_mark_dirty);
void dapm_mark_io_dirty(struct snd_soc_dapm_context *dapm) void dapm_mark_io_dirty(struct snd_soc_dapm_context *dapm)
{ {
@ -361,6 +368,8 @@ static void dapm_reset(struct snd_soc_card *card)
{ {
struct snd_soc_dapm_widget *w; struct snd_soc_dapm_widget *w;
lockdep_assert_held(&card->dapm_mutex);
memset(&card->dapm_stats, 0, sizeof(card->dapm_stats)); memset(&card->dapm_stats, 0, sizeof(card->dapm_stats));
list_for_each_entry(w, &card->widgets, list) { list_for_each_entry(w, &card->widgets, list) {
@ -386,7 +395,8 @@ static int soc_widget_read(struct snd_soc_dapm_widget *w, int reg,
return -1; return -1;
} }
static int soc_widget_write(struct snd_soc_dapm_widget *w, int reg, int val) static int soc_widget_write(struct snd_soc_dapm_widget *w, int reg,
unsigned int val)
{ {
if (w->codec) if (w->codec)
return snd_soc_write(w->codec, reg, val); return snd_soc_write(w->codec, reg, val);
@ -506,7 +516,7 @@ static void dapm_set_path_status(struct snd_soc_dapm_widget *w,
case snd_soc_dapm_switch: case snd_soc_dapm_switch:
case snd_soc_dapm_mixer: case snd_soc_dapm_mixer:
case snd_soc_dapm_mixer_named_ctl: { case snd_soc_dapm_mixer_named_ctl: {
int val; unsigned int val;
struct soc_mixer_control *mc = (struct soc_mixer_control *) struct soc_mixer_control *mc = (struct soc_mixer_control *)
w->kcontrol_news[i].private_value; w->kcontrol_news[i].private_value;
int reg = mc->reg; int reg = mc->reg;
@ -530,7 +540,7 @@ static void dapm_set_path_status(struct snd_soc_dapm_widget *w,
case snd_soc_dapm_mux: { case snd_soc_dapm_mux: {
struct soc_enum *e = (struct soc_enum *) struct soc_enum *e = (struct soc_enum *)
w->kcontrol_news[i].private_value; w->kcontrol_news[i].private_value;
int val, item; unsigned int val, item;
soc_widget_read(w, e->reg, &val); soc_widget_read(w, e->reg, &val);
item = (val >> e->shift_l) & e->mask; item = (val >> e->shift_l) & e->mask;
@ -559,7 +569,7 @@ static void dapm_set_path_status(struct snd_soc_dapm_widget *w,
case snd_soc_dapm_value_mux: { case snd_soc_dapm_value_mux: {
struct soc_enum *e = (struct soc_enum *) struct soc_enum *e = (struct soc_enum *)
w->kcontrol_news[i].private_value; w->kcontrol_news[i].private_value;
int val, item; unsigned int val, item;
soc_widget_read(w, e->reg, &val); soc_widget_read(w, e->reg, &val);
val = (val >> e->shift_l) & e->mask; val = (val >> e->shift_l) & e->mask;
@ -1823,6 +1833,8 @@ static int dapm_power_widgets(struct snd_soc_card *card, int event)
ASYNC_DOMAIN_EXCLUSIVE(async_domain); ASYNC_DOMAIN_EXCLUSIVE(async_domain);
enum snd_soc_bias_level bias; enum snd_soc_bias_level bias;
lockdep_assert_held(&card->dapm_mutex);
trace_snd_soc_dapm_start(card); trace_snd_soc_dapm_start(card);
list_for_each_entry(d, &card->dapm_list, list) { list_for_each_entry(d, &card->dapm_list, list) {
@ -1897,10 +1909,14 @@ static int dapm_power_widgets(struct snd_soc_card *card, int event)
trace_snd_soc_dapm_walk_done(card); trace_snd_soc_dapm_walk_done(card);
/* Run all the bias changes in parallel */ /* Run card bias changes at first */
list_for_each_entry(d, &card->dapm_list, list) dapm_pre_sequence_async(&card->dapm, 0);
async_schedule_domain(dapm_pre_sequence_async, d, /* Run other bias changes in parallel */
&async_domain); list_for_each_entry(d, &card->dapm_list, list) {
if (d != &card->dapm)
async_schedule_domain(dapm_pre_sequence_async, d,
&async_domain);
}
async_synchronize_full_domain(&async_domain); async_synchronize_full_domain(&async_domain);
list_for_each_entry(w, &down_list, power_list) { list_for_each_entry(w, &down_list, power_list) {
@ -1920,10 +1936,14 @@ static int dapm_power_widgets(struct snd_soc_card *card, int event)
dapm_seq_run(card, &up_list, event, true); dapm_seq_run(card, &up_list, event, true);
/* Run all the bias changes in parallel */ /* Run all the bias changes in parallel */
list_for_each_entry(d, &card->dapm_list, list) list_for_each_entry(d, &card->dapm_list, list) {
async_schedule_domain(dapm_post_sequence_async, d, if (d != &card->dapm)
&async_domain); async_schedule_domain(dapm_post_sequence_async, d,
&async_domain);
}
async_synchronize_full_domain(&async_domain); async_synchronize_full_domain(&async_domain);
/* Run card bias changes at last */
dapm_post_sequence_async(&card->dapm, 0);
/* do we need to notify any clients that DAPM event is complete */ /* do we need to notify any clients that DAPM event is complete */
list_for_each_entry(d, &card->dapm_list, list) { list_for_each_entry(d, &card->dapm_list, list) {
@ -2110,6 +2130,8 @@ static int soc_dapm_mux_update_power(struct snd_soc_card *card,
struct snd_soc_dapm_path *path; struct snd_soc_dapm_path *path;
int found = 0; int found = 0;
lockdep_assert_held(&card->dapm_mutex);
/* find dapm widget path assoc with kcontrol */ /* find dapm widget path assoc with kcontrol */
dapm_kcontrol_for_each_path(path, kcontrol) { dapm_kcontrol_for_each_path(path, kcontrol) {
if (!path->name || !e->texts[mux]) if (!path->name || !e->texts[mux])
@ -2160,6 +2182,8 @@ static int soc_dapm_mixer_update_power(struct snd_soc_card *card,
struct snd_soc_dapm_path *path; struct snd_soc_dapm_path *path;
int found = 0; int found = 0;
lockdep_assert_held(&card->dapm_mutex);
/* find dapm widget path assoc with kcontrol */ /* find dapm widget path assoc with kcontrol */
dapm_kcontrol_for_each_path(path, kcontrol) { dapm_kcontrol_for_each_path(path, kcontrol) {
found = 1; found = 1;
@ -2325,6 +2349,8 @@ static int snd_soc_dapm_set_pin(struct snd_soc_dapm_context *dapm,
{ {
struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true); struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true);
dapm_assert_locked(dapm);
if (!w) { if (!w) {
dev_err(dapm->dev, "ASoC: DAPM unknown pin %s\n", pin); dev_err(dapm->dev, "ASoC: DAPM unknown pin %s\n", pin);
return -EINVAL; return -EINVAL;
@ -2340,6 +2366,30 @@ static int snd_soc_dapm_set_pin(struct snd_soc_dapm_context *dapm,
return 0; return 0;
} }
/**
* snd_soc_dapm_sync_unlocked - scan and power dapm paths
* @dapm: DAPM context
*
* Walks all dapm audio paths and powers widgets according to their
* stream or path usage.
*
* Requires external locking.
*
* Returns 0 for success.
*/
int snd_soc_dapm_sync_unlocked(struct snd_soc_dapm_context *dapm)
{
/*
* Suppress early reports (eg, jacks syncing their state) to avoid
* silly DAPM runs during card startup.
*/
if (!dapm->card || !dapm->card->instantiated)
return 0;
return dapm_power_widgets(dapm->card, SND_SOC_DAPM_STREAM_NOP);
}
EXPORT_SYMBOL_GPL(snd_soc_dapm_sync_unlocked);
/** /**
* snd_soc_dapm_sync - scan and power dapm paths * snd_soc_dapm_sync - scan and power dapm paths
* @dapm: DAPM context * @dapm: DAPM context
@ -2353,15 +2403,8 @@ int snd_soc_dapm_sync(struct snd_soc_dapm_context *dapm)
{ {
int ret; int ret;
/*
* Suppress early reports (eg, jacks syncing their state) to avoid
* silly DAPM runs during card startup.
*/
if (!dapm->card || !dapm->card->instantiated)
return 0;
mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
ret = dapm_power_widgets(dapm->card, SND_SOC_DAPM_STREAM_NOP); ret = snd_soc_dapm_sync_unlocked(dapm);
mutex_unlock(&dapm->card->dapm_mutex); mutex_unlock(&dapm->card->dapm_mutex);
return ret; return ret;
} }
@ -4098,7 +4141,7 @@ void snd_soc_dapm_free(struct snd_soc_dapm_context *dapm)
} }
EXPORT_SYMBOL_GPL(snd_soc_dapm_free); EXPORT_SYMBOL_GPL(snd_soc_dapm_free);
static void soc_dapm_shutdown_codec(struct snd_soc_dapm_context *dapm) static void soc_dapm_shutdown_dapm(struct snd_soc_dapm_context *dapm)
{ {
struct snd_soc_card *card = dapm->card; struct snd_soc_card *card = dapm->card;
struct snd_soc_dapm_widget *w; struct snd_soc_dapm_widget *w;
@ -4138,14 +4181,21 @@ static void soc_dapm_shutdown_codec(struct snd_soc_dapm_context *dapm)
*/ */
void snd_soc_dapm_shutdown(struct snd_soc_card *card) void snd_soc_dapm_shutdown(struct snd_soc_card *card)
{ {
struct snd_soc_codec *codec; struct snd_soc_dapm_context *dapm;
list_for_each_entry(codec, &card->codec_dev_list, card_list) { list_for_each_entry(dapm, &card->dapm_list, list) {
soc_dapm_shutdown_codec(&codec->dapm); if (dapm != &card->dapm) {
if (codec->dapm.bias_level == SND_SOC_BIAS_STANDBY) soc_dapm_shutdown_dapm(dapm);
snd_soc_dapm_set_bias_level(&codec->dapm, if (dapm->bias_level == SND_SOC_BIAS_STANDBY)
SND_SOC_BIAS_OFF); snd_soc_dapm_set_bias_level(dapm,
SND_SOC_BIAS_OFF);
}
} }
soc_dapm_shutdown_dapm(&card->dapm);
if (card->dapm.bias_level == SND_SOC_BIAS_STANDBY)
snd_soc_dapm_set_bias_level(&card->dapm,
SND_SOC_BIAS_OFF);
} }
/* Module information */ /* Module information */