Fix: remove spin lock in machine trigger

This commit is contained in:
turmary 2018-11-27 09:47:44 +00:00
parent 3392bf394b
commit 95f4fe0688
4 changed files with 14 additions and 3 deletions

View File

@ -646,8 +646,6 @@ static int ac101_aif1clk(struct snd_soc_codec* codec, int event, int quick) {
struct ac10x_priv *ac10x = snd_soc_codec_get_drvdata(codec); struct ac10x_priv *ac10x = snd_soc_codec_get_drvdata(codec);
int ret = 0; int ret = 0;
/* spin_lock move to machine trigger */
switch (event) { switch (event) {
case SND_SOC_DAPM_PRE_PMU: case SND_SOC_DAPM_PRE_PMU:
if (ac10x->aif1_clken == 0){ if (ac10x->aif1_clken == 0){

View File

@ -1216,7 +1216,6 @@ static int ac108_add_widgets(struct snd_soc_codec *codec) {
} }
static int ac108_codec_probe(struct snd_soc_codec *codec) { static int ac108_codec_probe(struct snd_soc_codec *codec) {
spin_lock_init(&ac10x->lock); spin_lock_init(&ac10x->lock);
ac10x->codec = codec; ac10x->codec = codec;

View File

@ -29,6 +29,9 @@
/* enable headset detecting & headset button pressing */ /* enable headset detecting & headset button pressing */
#define CONFIG_AC101_SWITCH_DETECT #define CONFIG_AC101_SWITCH_DETECT
/* obsolete */
#define CONFIG_AC10X_TRIG_LOCK 0
#ifdef AC101_DEBG #ifdef AC101_DEBG
#define AC101_DBG(format,args...) printk("[AC101] %s() L%d " format, __func__, __LINE__, ##args) #define AC101_DBG(format,args...) printk("[AC101] %s() L%d " format, __func__, __LINE__, ##args)

View File

@ -26,6 +26,7 @@
#include <sound/soc.h> #include <sound/soc.h>
#include <sound/soc-dai.h> #include <sound/soc-dai.h>
#include <sound/simple_card_utils.h> #include <sound/simple_card_utils.h>
#include "ac10x.h"
/* /*
* single codec: * single codec:
@ -47,7 +48,9 @@ struct seeed_card_data {
unsigned channels_capture_default; unsigned channels_capture_default;
unsigned channels_capture_override; unsigned channels_capture_override;
struct snd_soc_dai_link *dai_link; struct snd_soc_dai_link *dai_link;
#if CONFIG_AC10X_TRIG_LOCK
spinlock_t lock; spinlock_t lock;
#endif
struct work_struct work_codec_clk; struct work_struct work_codec_clk;
#define TRY_STOP_MAX 3 #define TRY_STOP_MAX 3
int try_stop; int try_stop;
@ -190,7 +193,9 @@ static int seeed_voice_card_trigger(struct snd_pcm_substream *substream, int cmd
struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_dai *dai = rtd->codec_dai; struct snd_soc_dai *dai = rtd->codec_dai;
struct seeed_card_data *priv = snd_soc_card_get_drvdata(rtd->card); struct seeed_card_data *priv = snd_soc_card_get_drvdata(rtd->card);
#if CONFIG_AC10X_TRIG_LOCK
unsigned long flags; unsigned long flags;
#endif
int ret = 0; int ret = 0;
dev_dbg(rtd->card->dev, "%s() stream=%s cmd=%d play:%d, capt:%d\n", dev_dbg(rtd->card->dev, "%s() stream=%s cmd=%d play:%d, capt:%d\n",
@ -202,11 +207,15 @@ static int seeed_voice_card_trigger(struct snd_pcm_substream *substream, int cmd
case SNDRV_PCM_TRIGGER_RESUME: case SNDRV_PCM_TRIGGER_RESUME:
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
if (cancel_work_sync(&priv->work_codec_clk) != 0) {} if (cancel_work_sync(&priv->work_codec_clk) != 0) {}
#if CONFIG_AC10X_TRIG_LOCK
/* I know it will degrades performance, but I have no choice */ /* I know it will degrades performance, but I have no choice */
spin_lock_irqsave(&priv->lock, flags); spin_lock_irqsave(&priv->lock, flags);
#endif
if (_set_clock[SNDRV_PCM_STREAM_CAPTURE]) _set_clock[SNDRV_PCM_STREAM_CAPTURE](1); if (_set_clock[SNDRV_PCM_STREAM_CAPTURE]) _set_clock[SNDRV_PCM_STREAM_CAPTURE](1);
if (_set_clock[SNDRV_PCM_STREAM_PLAYBACK]) _set_clock[SNDRV_PCM_STREAM_PLAYBACK](1); if (_set_clock[SNDRV_PCM_STREAM_PLAYBACK]) _set_clock[SNDRV_PCM_STREAM_PLAYBACK](1);
#if CONFIG_AC10X_TRIG_LOCK
spin_unlock_irqrestore(&priv->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
#endif
break; break;
case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_STOP:
@ -587,7 +596,9 @@ static int seeed_voice_card_probe(struct platform_device *pdev)
snd_soc_card_set_drvdata(&priv->snd_card, priv); snd_soc_card_set_drvdata(&priv->snd_card, priv);
#if CONFIG_AC10X_TRIG_LOCK
spin_lock_init(&priv->lock); spin_lock_init(&priv->lock);
#endif
INIT_WORK(&priv->work_codec_clk, work_cb_codec_clk); INIT_WORK(&priv->work_codec_clk, work_cb_codec_clk);