summaryrefslogtreecommitdiff
path: root/sound/soc/soc-compress.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/soc-compress.c')
-rw-r--r--sound/soc/soc-compress.c70
1 files changed, 33 insertions, 37 deletions
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index e7aa6f360cab..d8715db5e415 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -62,7 +62,7 @@ static int soc_compr_clean(struct snd_compr_stream *cstream, int rollback)
struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */
- mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
+ snd_soc_dpcm_mutex_lock(rtd);
if (!rollback)
snd_soc_runtime_deactivate(rtd, stream);
@@ -84,7 +84,7 @@ static int soc_compr_clean(struct snd_compr_stream *cstream, int rollback)
if (!rollback)
snd_soc_dapm_stream_stop(rtd, stream);
- mutex_unlock(&rtd->card->pcm_mutex);
+ snd_soc_dpcm_mutex_unlock(rtd);
snd_soc_pcm_component_pm_runtime_put(rtd, cstream, rollback);
@@ -107,7 +107,7 @@ static int soc_compr_open(struct snd_compr_stream *cstream)
if (ret < 0)
goto err_no_lock;
- mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
+ snd_soc_dpcm_mutex_lock(rtd);
ret = snd_soc_dai_compr_startup(cpu_dai, cstream);
if (ret < 0)
@@ -123,7 +123,7 @@ static int soc_compr_open(struct snd_compr_stream *cstream)
snd_soc_runtime_activate(rtd, stream);
err:
- mutex_unlock(&rtd->card->pcm_mutex);
+ snd_soc_dpcm_mutex_unlock(rtd);
err_no_lock:
if (ret < 0)
soc_compr_clean(cstream, 1);
@@ -134,26 +134,22 @@ err_no_lock:
static int soc_compr_open_fe(struct snd_compr_stream *cstream)
{
struct snd_soc_pcm_runtime *fe = cstream->private_data;
- struct snd_pcm_substream *fe_substream =
- fe->pcm->streams[cstream->direction].substream;
struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(fe, 0);
struct snd_soc_dpcm *dpcm;
struct snd_soc_dapm_widget_list *list;
int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */
int ret;
- mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME);
- fe->dpcm[stream].runtime = fe_substream->runtime;
+ snd_soc_card_mutex_lock(fe->card);
ret = dpcm_path_get(fe, stream, &list);
if (ret < 0)
goto be_err;
- mutex_lock_nested(&fe->card->pcm_mutex, fe->card->pcm_subclass);
+ snd_soc_dpcm_mutex_lock(fe);
/* calculate valid and active FE <-> BE dpcms */
dpcm_process_paths(fe, stream, &list, 1);
- fe->dpcm[stream].runtime = fe_substream->runtime;
fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE;
@@ -164,7 +160,6 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream)
dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE;
dpcm_be_disconnect(fe, stream);
- fe->dpcm[stream].runtime = NULL;
goto out;
}
@@ -187,9 +182,9 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream)
fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO;
snd_soc_runtime_activate(fe, stream);
- mutex_unlock(&fe->card->pcm_mutex);
+ snd_soc_dpcm_mutex_unlock(fe);
- mutex_unlock(&fe->card->mutex);
+ snd_soc_card_mutex_unlock(fe->card);
return 0;
@@ -201,7 +196,7 @@ out:
dpcm_path_put(&list);
be_err:
fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO;
- mutex_unlock(&fe->card->mutex);
+ snd_soc_card_mutex_unlock(fe->card);
return ret;
}
@@ -212,9 +207,9 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream)
struct snd_soc_dpcm *dpcm;
int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */
- mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME);
+ snd_soc_card_mutex_lock(fe->card);
- mutex_lock_nested(&fe->card->pcm_mutex, fe->card->pcm_subclass);
+ snd_soc_dpcm_mutex_lock(fe);
snd_soc_runtime_deactivate(fe, stream);
fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE;
@@ -234,9 +229,7 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream)
dpcm_be_disconnect(fe, stream);
- mutex_unlock(&fe->card->pcm_mutex);
-
- fe->dpcm[stream].runtime = NULL;
+ snd_soc_dpcm_mutex_unlock(fe);
snd_soc_link_compr_shutdown(cstream, 0);
@@ -244,7 +237,7 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream)
snd_soc_dai_compr_shutdown(cpu_dai, cstream, 0);
- mutex_unlock(&fe->card->mutex);
+ snd_soc_card_mutex_unlock(fe->card);
return 0;
}
@@ -256,7 +249,7 @@ static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd)
int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */
int ret;
- mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
+ snd_soc_dpcm_mutex_lock(rtd);
ret = snd_soc_component_compr_trigger(cstream, cmd);
if (ret < 0)
@@ -276,7 +269,7 @@ static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd)
}
out:
- mutex_unlock(&rtd->card->pcm_mutex);
+ snd_soc_dpcm_mutex_unlock(rtd);
return ret;
}
@@ -291,7 +284,7 @@ static int soc_compr_trigger_fe(struct snd_compr_stream *cstream, int cmd)
cmd == SND_COMPR_TRIGGER_DRAIN)
return snd_soc_component_compr_trigger(cstream, cmd);
- mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME);
+ snd_soc_card_mutex_lock(fe->card);
ret = snd_soc_dai_compr_trigger(cpu_dai, cstream, cmd);
if (ret < 0)
@@ -322,7 +315,7 @@ static int soc_compr_trigger_fe(struct snd_compr_stream *cstream, int cmd)
out:
fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO;
- mutex_unlock(&fe->card->mutex);
+ snd_soc_card_mutex_unlock(fe->card);
return ret;
}
@@ -334,7 +327,7 @@ static int soc_compr_set_params(struct snd_compr_stream *cstream,
int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */
int ret;
- mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
+ snd_soc_dpcm_mutex_lock(rtd);
/*
* First we call set_params for the CPU DAI, then the component
@@ -359,14 +352,14 @@ static int soc_compr_set_params(struct snd_compr_stream *cstream,
/* cancel any delayed stream shutdown that is pending */
rtd->pop_wait = 0;
- mutex_unlock(&rtd->card->pcm_mutex);
+ snd_soc_dpcm_mutex_unlock(rtd);
cancel_delayed_work_sync(&rtd->delayed_work);
return 0;
err:
- mutex_unlock(&rtd->card->pcm_mutex);
+ snd_soc_dpcm_mutex_unlock(rtd);
return ret;
}
@@ -380,7 +373,7 @@ static int soc_compr_set_params_fe(struct snd_compr_stream *cstream,
int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */
int ret;
- mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME);
+ snd_soc_card_mutex_lock(fe->card);
/*
* Create an empty hw_params for the BE as the machine driver must
@@ -411,14 +404,14 @@ static int soc_compr_set_params_fe(struct snd_compr_stream *cstream,
ret = snd_soc_link_compr_set_params(cstream);
if (ret < 0)
goto out;
- mutex_lock_nested(&fe->card->pcm_mutex, fe->card->pcm_subclass);
+ snd_soc_dpcm_mutex_lock(fe);
dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_START);
- mutex_unlock(&fe->card->pcm_mutex);
+ snd_soc_dpcm_mutex_unlock(fe);
fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PREPARE;
out:
fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO;
- mutex_unlock(&fe->card->mutex);
+ snd_soc_card_mutex_unlock(fe->card);
return ret;
}
@@ -429,7 +422,7 @@ static int soc_compr_get_params(struct snd_compr_stream *cstream,
struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
int ret = 0;
- mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
+ snd_soc_dpcm_mutex_lock(rtd);
ret = snd_soc_dai_compr_get_params(cpu_dai, cstream, params);
if (ret < 0)
@@ -437,7 +430,7 @@ static int soc_compr_get_params(struct snd_compr_stream *cstream,
ret = snd_soc_component_compr_get_params(cstream, params);
err:
- mutex_unlock(&rtd->card->pcm_mutex);
+ snd_soc_dpcm_mutex_unlock(rtd);
return ret;
}
@@ -447,7 +440,7 @@ static int soc_compr_ack(struct snd_compr_stream *cstream, size_t bytes)
struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
int ret;
- mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
+ snd_soc_dpcm_mutex_lock(rtd);
ret = snd_soc_dai_compr_ack(cpu_dai, cstream, bytes);
if (ret < 0)
@@ -455,7 +448,7 @@ static int soc_compr_ack(struct snd_compr_stream *cstream, size_t bytes)
ret = snd_soc_component_compr_ack(cstream, bytes);
err:
- mutex_unlock(&rtd->card->pcm_mutex);
+ snd_soc_dpcm_mutex_unlock(rtd);
return ret;
}
@@ -466,7 +459,7 @@ static int soc_compr_pointer(struct snd_compr_stream *cstream,
int ret;
struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
- mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
+ snd_soc_dpcm_mutex_lock(rtd);
ret = snd_soc_dai_compr_pointer(cpu_dai, cstream, tstamp);
if (ret < 0)
@@ -474,7 +467,7 @@ static int soc_compr_pointer(struct snd_compr_stream *cstream,
ret = snd_soc_component_compr_pointer(cstream, tstamp);
out:
- mutex_unlock(&rtd->card->pcm_mutex);
+ snd_soc_dpcm_mutex_unlock(rtd);
return ret;
}
@@ -622,6 +615,9 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
return ret;
}
+ /* inherit atomicity from DAI link */
+ be_pcm->nonatomic = rtd->dai_link->nonatomic;
+
rtd->pcm = be_pcm;
rtd->fe_compr = 1;
if (rtd->dai_link->dpcm_playback)