aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@linaro.org>2014-02-20 04:47:45 -0500
committerMark Brown <broonie@linaro.org>2014-02-20 04:47:45 -0500
commite96cb48482f8852716d89d0e6baf6d2c425ae33e (patch)
treefe59837b96c556dee53f85922391da45f72740b8
parent30ac6b6ebd175eaf5db7e0d7c015cd1460548b98 (diff)
parent113911006442a36c2b4669faf1699d9042ef80ab (diff)
Merge branch 'fix/dapm' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into asoc-dapm
-rw-r--r--drivers/extcon/extcon-arizona.c12
-rw-r--r--drivers/input/misc/arizona-haptics.c19
-rw-r--r--include/sound/soc-dapm.h8
-rw-r--r--sound/soc/soc-dapm.c139
4 files changed, 134 insertions, 44 deletions
diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index c20602f601ee..98a14f6143a7 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -222,27 +222,19 @@ static void arizona_extcon_pulse_micbias(struct arizona_extcon_info *info)
222 struct snd_soc_dapm_context *dapm = arizona->dapm; 222 struct snd_soc_dapm_context *dapm = arizona->dapm;
223 int ret; 223 int ret;
224 224
225 mutex_lock(&dapm->card->dapm_mutex);
226
227 ret = snd_soc_dapm_force_enable_pin(dapm, widget); 225 ret = snd_soc_dapm_force_enable_pin(dapm, widget);
228 if (ret != 0) 226 if (ret != 0)
229 dev_warn(arizona->dev, "Failed to enable %s: %d\n", 227 dev_warn(arizona->dev, "Failed to enable %s: %d\n",
230 widget, ret); 228 widget, ret);
231 229
232 mutex_unlock(&dapm->card->dapm_mutex);
233
234 snd_soc_dapm_sync(dapm); 230 snd_soc_dapm_sync(dapm);
235 231
236 if (!arizona->pdata.micd_force_micbias) { 232 if (!arizona->pdata.micd_force_micbias) {
237 mutex_lock(&dapm->card->dapm_mutex);
238
239 ret = snd_soc_dapm_disable_pin(arizona->dapm, widget); 233 ret = snd_soc_dapm_disable_pin(arizona->dapm, widget);
240 if (ret != 0) 234 if (ret != 0)
241 dev_warn(arizona->dev, "Failed to disable %s: %d\n", 235 dev_warn(arizona->dev, "Failed to disable %s: %d\n",
242 widget, ret); 236 widget, ret);
243 237
244 mutex_unlock(&dapm->card->dapm_mutex);
245
246 snd_soc_dapm_sync(dapm); 238 snd_soc_dapm_sync(dapm);
247 } 239 }
248} 240}
@@ -304,16 +296,12 @@ static void arizona_stop_mic(struct arizona_extcon_info *info)
304 ARIZONA_MICD_ENA, 0, 296 ARIZONA_MICD_ENA, 0,
305 &change); 297 &change);
306 298
307 mutex_lock(&dapm->card->dapm_mutex);
308
309 ret = snd_soc_dapm_disable_pin(dapm, widget); 299 ret = snd_soc_dapm_disable_pin(dapm, widget);
310 if (ret != 0) 300 if (ret != 0)
311 dev_warn(arizona->dev, 301 dev_warn(arizona->dev,
312 "Failed to disable %s: %d\n", 302 "Failed to disable %s: %d\n",
313 widget, ret); 303 widget, ret);
314 304
315 mutex_unlock(&dapm->card->dapm_mutex);
316
317 snd_soc_dapm_sync(dapm); 305 snd_soc_dapm_sync(dapm);
318 306
319 if (info->micd_reva) { 307 if (info->micd_reva) {
diff --git a/drivers/input/misc/arizona-haptics.c b/drivers/input/misc/arizona-haptics.c
index 7a04f54ef961..ef2e281b0a43 100644
--- a/drivers/input/misc/arizona-haptics.c
+++ b/drivers/input/misc/arizona-haptics.c
@@ -37,7 +37,6 @@ static void arizona_haptics_work(struct work_struct *work)
37 struct arizona_haptics, 37 struct arizona_haptics,
38 work); 38 work);
39 struct arizona *arizona = haptics->arizona; 39 struct arizona *arizona = haptics->arizona;
40 struct mutex *dapm_mutex = &arizona->dapm->card->dapm_mutex;
41 int ret; 40 int ret;
42 41
43 if (!haptics->arizona->dapm) { 42 if (!haptics->arizona->dapm) {
@@ -67,13 +66,10 @@ static void arizona_haptics_work(struct work_struct *work)
67 return; 66 return;
68 } 67 }
69 68
70 mutex_lock_nested(dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
71
72 ret = snd_soc_dapm_enable_pin(arizona->dapm, "HAPTICS"); 69 ret = snd_soc_dapm_enable_pin(arizona->dapm, "HAPTICS");
73 if (ret != 0) { 70 if (ret != 0) {
74 dev_err(arizona->dev, "Failed to start HAPTICS: %d\n", 71 dev_err(arizona->dev, "Failed to start HAPTICS: %d\n",
75 ret); 72 ret);
76 mutex_unlock(dapm_mutex);
77 return; 73 return;
78 } 74 }
79 75
@@ -81,21 +77,14 @@ static void arizona_haptics_work(struct work_struct *work)
81 if (ret != 0) { 77 if (ret != 0) {
82 dev_err(arizona->dev, "Failed to sync DAPM: %d\n", 78 dev_err(arizona->dev, "Failed to sync DAPM: %d\n",
83 ret); 79 ret);
84 mutex_unlock(dapm_mutex);
85 return; 80 return;
86 } 81 }
87
88 mutex_unlock(dapm_mutex);
89
90 } else { 82 } else {
91 /* This disable sequence will be a noop if already enabled */ 83 /* This disable sequence will be a noop if already enabled */
92 mutex_lock_nested(dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
93
94 ret = snd_soc_dapm_disable_pin(arizona->dapm, "HAPTICS"); 84 ret = snd_soc_dapm_disable_pin(arizona->dapm, "HAPTICS");
95 if (ret != 0) { 85 if (ret != 0) {
96 dev_err(arizona->dev, "Failed to disable HAPTICS: %d\n", 86 dev_err(arizona->dev, "Failed to disable HAPTICS: %d\n",
97 ret); 87 ret);
98 mutex_unlock(dapm_mutex);
99 return; 88 return;
100 } 89 }
101 90
@@ -103,12 +92,9 @@ static void arizona_haptics_work(struct work_struct *work)
103 if (ret != 0) { 92 if (ret != 0) {
104 dev_err(arizona->dev, "Failed to sync DAPM: %d\n", 93 dev_err(arizona->dev, "Failed to sync DAPM: %d\n",
105 ret); 94 ret);
106 mutex_unlock(dapm_mutex);
107 return; 95 return;
108 } 96 }
109 97
110 mutex_unlock(dapm_mutex);
111
112 ret = regmap_update_bits(arizona->regmap, 98 ret = regmap_update_bits(arizona->regmap,
113 ARIZONA_HAPTICS_CONTROL_1, 99 ARIZONA_HAPTICS_CONTROL_1,
114 ARIZONA_HAP_CTRL_MASK, 100 ARIZONA_HAP_CTRL_MASK,
@@ -155,16 +141,11 @@ static int arizona_haptics_play(struct input_dev *input, void *data,
155static void arizona_haptics_close(struct input_dev *input) 141static void arizona_haptics_close(struct input_dev *input)
156{ 142{
157 struct arizona_haptics *haptics = input_get_drvdata(input); 143 struct arizona_haptics *haptics = input_get_drvdata(input);
158 struct mutex *dapm_mutex = &haptics->arizona->dapm->card->dapm_mutex;
159 144
160 cancel_work_sync(&haptics->work); 145 cancel_work_sync(&haptics->work);
161 146
162 mutex_lock_nested(dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
163
164 if (haptics->arizona->dapm) 147 if (haptics->arizona->dapm)
165 snd_soc_dapm_disable_pin(haptics->arizona->dapm, "HAPTICS"); 148 snd_soc_dapm_disable_pin(haptics->arizona->dapm, "HAPTICS");
166
167 mutex_unlock(dapm_mutex);
168} 149}
169 150
170static int arizona_haptics_probe(struct platform_device *pdev) 151static int arizona_haptics_probe(struct platform_device *pdev)
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
index 68d92e36facd..6e89ef6c11c1 100644
--- a/include/sound/soc-dapm.h
+++ b/include/sound/soc-dapm.h
@@ -449,14 +449,22 @@ void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm,
449/* dapm audio pin control and status */ 449/* dapm audio pin control and status */
450int snd_soc_dapm_enable_pin(struct snd_soc_dapm_context *dapm, 450int snd_soc_dapm_enable_pin(struct snd_soc_dapm_context *dapm,
451 const char *pin); 451 const char *pin);
452int snd_soc_dapm_enable_pin_unlocked(struct snd_soc_dapm_context *dapm,
453 const char *pin);
452int snd_soc_dapm_disable_pin(struct snd_soc_dapm_context *dapm, 454int snd_soc_dapm_disable_pin(struct snd_soc_dapm_context *dapm,
453 const char *pin); 455 const char *pin);
456int snd_soc_dapm_disable_pin_unlocked(struct snd_soc_dapm_context *dapm,
457 const char *pin);
454int snd_soc_dapm_nc_pin(struct snd_soc_dapm_context *dapm, const char *pin); 458int snd_soc_dapm_nc_pin(struct snd_soc_dapm_context *dapm, const char *pin);
459int snd_soc_dapm_nc_pin_unlocked(struct snd_soc_dapm_context *dapm,
460 const char *pin);
455int snd_soc_dapm_get_pin_status(struct snd_soc_dapm_context *dapm, 461int snd_soc_dapm_get_pin_status(struct snd_soc_dapm_context *dapm,
456 const char *pin); 462 const char *pin);
457int snd_soc_dapm_sync(struct snd_soc_dapm_context *dapm); 463int snd_soc_dapm_sync(struct snd_soc_dapm_context *dapm);
458int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm, 464int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm,
459 const char *pin); 465 const char *pin);
466int snd_soc_dapm_force_enable_pin_unlocked(struct snd_soc_dapm_context *dapm,
467 const char *pin);
460int snd_soc_dapm_ignore_suspend(struct snd_soc_dapm_context *dapm, 468int snd_soc_dapm_ignore_suspend(struct snd_soc_dapm_context *dapm,
461 const char *pin); 469 const char *pin);
462void snd_soc_dapm_auto_nc_codec_pins(struct snd_soc_codec *codec); 470void snd_soc_dapm_auto_nc_codec_pins(struct snd_soc_codec *codec);
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 2c2d751c6d54..48a4eeb05192 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -1219,7 +1219,7 @@ int dapm_regulator_event(struct snd_soc_dapm_widget *w,
1219 ret = regulator_allow_bypass(w->regulator, false); 1219 ret = regulator_allow_bypass(w->regulator, false);
1220 if (ret != 0) 1220 if (ret != 0)
1221 dev_warn(w->dapm->dev, 1221 dev_warn(w->dapm->dev,
1222 "ASoC: Failed to bypass %s: %d\n", 1222 "ASoC: Failed to unbypass %s: %d\n",
1223 w->name, ret); 1223 w->name, ret);
1224 } 1224 }
1225 1225
@@ -1229,7 +1229,7 @@ int dapm_regulator_event(struct snd_soc_dapm_widget *w,
1229 ret = regulator_allow_bypass(w->regulator, true); 1229 ret = regulator_allow_bypass(w->regulator, true);
1230 if (ret != 0) 1230 if (ret != 0)
1231 dev_warn(w->dapm->dev, 1231 dev_warn(w->dapm->dev,
1232 "ASoC: Failed to unbypass %s: %d\n", 1232 "ASoC: Failed to bypass %s: %d\n",
1233 w->name, ret); 1233 w->name, ret);
1234 } 1234 }
1235 1235
@@ -3211,15 +3211,11 @@ int snd_soc_dapm_put_pin_switch(struct snd_kcontrol *kcontrol,
3211 struct snd_soc_card *card = snd_kcontrol_chip(kcontrol); 3211 struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
3212 const char *pin = (const char *)kcontrol->private_value; 3212 const char *pin = (const char *)kcontrol->private_value;
3213 3213
3214 mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
3215
3216 if (ucontrol->value.integer.value[0]) 3214 if (ucontrol->value.integer.value[0])
3217 snd_soc_dapm_enable_pin(&card->dapm, pin); 3215 snd_soc_dapm_enable_pin(&card->dapm, pin);
3218 else 3216 else
3219 snd_soc_dapm_disable_pin(&card->dapm, pin); 3217 snd_soc_dapm_disable_pin(&card->dapm, pin);
3220 3218
3221 mutex_unlock(&card->dapm_mutex);
3222
3223 snd_soc_dapm_sync(&card->dapm); 3219 snd_soc_dapm_sync(&card->dapm);
3224 return 0; 3220 return 0;
3225} 3221}
@@ -3249,7 +3245,7 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
3249 ret = regulator_allow_bypass(w->regulator, true); 3245 ret = regulator_allow_bypass(w->regulator, true);
3250 if (ret != 0) 3246 if (ret != 0)
3251 dev_warn(w->dapm->dev, 3247 dev_warn(w->dapm->dev,
3252 "ASoC: Failed to unbypass %s: %d\n", 3248 "ASoC: Failed to bypass %s: %d\n",
3253 w->name, ret); 3249 w->name, ret);
3254 } 3250 }
3255 break; 3251 break;
@@ -3768,23 +3764,52 @@ void snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream,
3768} 3764}
3769 3765
3770/** 3766/**
3767 * snd_soc_dapm_enable_pin_unlocked - enable pin.
3768 * @dapm: DAPM context
3769 * @pin: pin name
3770 *
3771 * Enables input/output pin and its parents or children widgets iff there is
3772 * a valid audio route and active audio stream.
3773 *
3774 * Requires external locking.
3775 *
3776 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
3777 * do any widget power switching.
3778 */
3779int snd_soc_dapm_enable_pin_unlocked(struct snd_soc_dapm_context *dapm,
3780 const char *pin)
3781{
3782 return snd_soc_dapm_set_pin(dapm, pin, 1);
3783}
3784EXPORT_SYMBOL_GPL(snd_soc_dapm_enable_pin_unlocked);
3785
3786/**
3771 * snd_soc_dapm_enable_pin - enable pin. 3787 * snd_soc_dapm_enable_pin - enable pin.
3772 * @dapm: DAPM context 3788 * @dapm: DAPM context
3773 * @pin: pin name 3789 * @pin: pin name
3774 * 3790 *
3775 * Enables input/output pin and its parents or children widgets iff there is 3791 * Enables input/output pin and its parents or children widgets iff there is
3776 * a valid audio route and active audio stream. 3792 * a valid audio route and active audio stream.
3793 *
3777 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to 3794 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
3778 * do any widget power switching. 3795 * do any widget power switching.
3779 */ 3796 */
3780int snd_soc_dapm_enable_pin(struct snd_soc_dapm_context *dapm, const char *pin) 3797int snd_soc_dapm_enable_pin(struct snd_soc_dapm_context *dapm, const char *pin)
3781{ 3798{
3782 return snd_soc_dapm_set_pin(dapm, pin, 1); 3799 int ret;
3800
3801 mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
3802
3803 ret = snd_soc_dapm_set_pin(dapm, pin, 1);
3804
3805 mutex_unlock(&dapm->card->dapm_mutex);
3806
3807 return ret;
3783} 3808}
3784EXPORT_SYMBOL_GPL(snd_soc_dapm_enable_pin); 3809EXPORT_SYMBOL_GPL(snd_soc_dapm_enable_pin);
3785 3810
3786/** 3811/**
3787 * snd_soc_dapm_force_enable_pin - force a pin to be enabled 3812 * snd_soc_dapm_force_enable_pin_unlocked - force a pin to be enabled
3788 * @dapm: DAPM context 3813 * @dapm: DAPM context
3789 * @pin: pin name 3814 * @pin: pin name
3790 * 3815 *
@@ -3792,11 +3817,13 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_enable_pin);
3792 * intended for use with microphone bias supplies used in microphone 3817 * intended for use with microphone bias supplies used in microphone
3793 * jack detection. 3818 * jack detection.
3794 * 3819 *
3820 * Requires external locking.
3821 *
3795 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to 3822 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
3796 * do any widget power switching. 3823 * do any widget power switching.
3797 */ 3824 */
3798int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm, 3825int snd_soc_dapm_force_enable_pin_unlocked(struct snd_soc_dapm_context *dapm,
3799 const char *pin) 3826 const char *pin)
3800{ 3827{
3801 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true); 3828 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true);
3802 3829
@@ -3812,25 +3839,103 @@ int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm,
3812 3839
3813 return 0; 3840 return 0;
3814} 3841}
3842EXPORT_SYMBOL_GPL(snd_soc_dapm_force_enable_pin_unlocked);
3843
3844/**
3845 * snd_soc_dapm_force_enable_pin - force a pin to be enabled
3846 * @dapm: DAPM context
3847 * @pin: pin name
3848 *
3849 * Enables input/output pin regardless of any other state. This is
3850 * intended for use with microphone bias supplies used in microphone
3851 * jack detection.
3852 *
3853 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
3854 * do any widget power switching.
3855 */
3856int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm,
3857 const char *pin)
3858{
3859 int ret;
3860
3861 mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
3862
3863 ret = snd_soc_dapm_force_enable_pin_unlocked(dapm, pin);
3864
3865 mutex_unlock(&dapm->card->dapm_mutex);
3866
3867 return ret;
3868}
3815EXPORT_SYMBOL_GPL(snd_soc_dapm_force_enable_pin); 3869EXPORT_SYMBOL_GPL(snd_soc_dapm_force_enable_pin);
3816 3870
3817/** 3871/**
3872 * snd_soc_dapm_disable_pin_unlocked - disable pin.
3873 * @dapm: DAPM context
3874 * @pin: pin name
3875 *
3876 * Disables input/output pin and its parents or children widgets.
3877 *
3878 * Requires external locking.
3879 *
3880 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
3881 * do any widget power switching.
3882 */
3883int snd_soc_dapm_disable_pin_unlocked(struct snd_soc_dapm_context *dapm,
3884 const char *pin)
3885{
3886 return snd_soc_dapm_set_pin(dapm, pin, 0);
3887}
3888EXPORT_SYMBOL_GPL(snd_soc_dapm_disable_pin_unlocked);
3889
3890/**
3818 * snd_soc_dapm_disable_pin - disable pin. 3891 * snd_soc_dapm_disable_pin - disable pin.
3819 * @dapm: DAPM context 3892 * @dapm: DAPM context
3820 * @pin: pin name 3893 * @pin: pin name
3821 * 3894 *
3822 * Disables input/output pin and its parents or children widgets. 3895 * Disables input/output pin and its parents or children widgets.
3896 *
3823 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to 3897 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
3824 * do any widget power switching. 3898 * do any widget power switching.
3825 */ 3899 */
3826int snd_soc_dapm_disable_pin(struct snd_soc_dapm_context *dapm, 3900int snd_soc_dapm_disable_pin(struct snd_soc_dapm_context *dapm,
3827 const char *pin) 3901 const char *pin)
3828{ 3902{
3829 return snd_soc_dapm_set_pin(dapm, pin, 0); 3903 int ret;
3904
3905 mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
3906
3907 ret = snd_soc_dapm_set_pin(dapm, pin, 0);
3908
3909 mutex_unlock(&dapm->card->dapm_mutex);
3910
3911 return ret;
3830} 3912}
3831EXPORT_SYMBOL_GPL(snd_soc_dapm_disable_pin); 3913EXPORT_SYMBOL_GPL(snd_soc_dapm_disable_pin);
3832 3914
3833/** 3915/**
3916 * snd_soc_dapm_nc_pin_unlocked - permanently disable pin.
3917 * @dapm: DAPM context
3918 * @pin: pin name
3919 *
3920 * Marks the specified pin as being not connected, disabling it along
3921 * any parent or child widgets. At present this is identical to
3922 * snd_soc_dapm_disable_pin() but in future it will be extended to do
3923 * additional things such as disabling controls which only affect
3924 * paths through the pin.
3925 *
3926 * Requires external locking.
3927 *
3928 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
3929 * do any widget power switching.
3930 */
3931int snd_soc_dapm_nc_pin_unlocked(struct snd_soc_dapm_context *dapm,
3932 const char *pin)
3933{
3934 return snd_soc_dapm_set_pin(dapm, pin, 0);
3935}
3936EXPORT_SYMBOL_GPL(snd_soc_dapm_nc_pin_unlocked);
3937
3938/**
3834 * snd_soc_dapm_nc_pin - permanently disable pin. 3939 * snd_soc_dapm_nc_pin - permanently disable pin.
3835 * @dapm: DAPM context 3940 * @dapm: DAPM context
3836 * @pin: pin name 3941 * @pin: pin name
@@ -3846,7 +3951,15 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_disable_pin);
3846 */ 3951 */
3847int snd_soc_dapm_nc_pin(struct snd_soc_dapm_context *dapm, const char *pin) 3952int snd_soc_dapm_nc_pin(struct snd_soc_dapm_context *dapm, const char *pin)
3848{ 3953{
3849 return snd_soc_dapm_set_pin(dapm, pin, 0); 3954 int ret;
3955
3956 mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
3957
3958 ret = snd_soc_dapm_set_pin(dapm, pin, 0);
3959
3960 mutex_unlock(&dapm->card->dapm_mutex);
3961
3962 return ret;
3850} 3963}
3851EXPORT_SYMBOL_GPL(snd_soc_dapm_nc_pin); 3964EXPORT_SYMBOL_GPL(snd_soc_dapm_nc_pin);
3852 3965