summaryrefslogtreecommitdiff
path: root/sound/soc/soc-pcm.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/soc-pcm.c')
-rw-r--r--sound/soc/soc-pcm.c111
1 files changed, 59 insertions, 52 deletions
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 54704250c0a2..8c168dc553f6 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -71,11 +71,11 @@ static inline void snd_soc_dpcm_stream_unlock_irq(struct snd_soc_pcm_runtime *rt
static inline const char *soc_cpu_dai_name(struct snd_soc_pcm_runtime *rtd)
{
- return (rtd)->dai_link->num_cpus == 1 ? asoc_rtd_to_cpu(rtd, 0)->name : "multicpu";
+ return (rtd)->dai_link->num_cpus == 1 ? snd_soc_rtd_to_cpu(rtd, 0)->name : "multicpu";
}
static inline const char *soc_codec_dai_name(struct snd_soc_pcm_runtime *rtd)
{
- return (rtd)->dai_link->num_codecs == 1 ? asoc_rtd_to_codec(rtd, 0)->name : "multicodec";
+ return (rtd)->dai_link->num_codecs == 1 ? snd_soc_rtd_to_codec(rtd, 0)->name : "multicodec";
}
#ifdef CONFIG_DEBUG_FS
@@ -184,7 +184,7 @@ static ssize_t dpcm_state_read_file(struct file *file, char __user *user_buf,
snd_soc_dpcm_mutex_lock(fe);
for_each_pcm_streams(stream)
- if (snd_soc_dai_stream_valid(asoc_rtd_to_cpu(fe, 0), stream))
+ if (snd_soc_dai_stream_valid(snd_soc_rtd_to_cpu(fe, 0), stream))
offset += dpcm_show_state(fe, stream,
buf + offset,
out_count - offset);
@@ -386,7 +386,7 @@ static void soc_pcm_set_dai_params(struct snd_soc_dai *dai,
static int soc_pcm_apply_symmetry(struct snd_pcm_substream *substream,
struct snd_soc_dai *soc_dai)
{
- struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
+ struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
int ret;
if (!snd_soc_dai_active(soc_dai))
@@ -419,7 +419,7 @@ static int soc_pcm_apply_symmetry(struct snd_pcm_substream *substream,
static int soc_pcm_params_symmetry(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
- struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
+ struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
struct snd_soc_dai d;
struct snd_soc_dai *dai;
struct snd_soc_dai *cpu_dai;
@@ -452,7 +452,7 @@ static int soc_pcm_params_symmetry(struct snd_pcm_substream *substream,
static void soc_pcm_update_symmetry(struct snd_pcm_substream *substream)
{
- struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
+ struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
struct snd_soc_dai_link *link = rtd->dai_link;
struct snd_soc_dai *dai;
unsigned int symmetry, i;
@@ -473,7 +473,7 @@ static void soc_pcm_update_symmetry(struct snd_pcm_substream *substream)
static void soc_pcm_set_msb(struct snd_pcm_substream *substream, int bits)
{
- struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
+ struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
int ret;
if (!bits)
@@ -487,7 +487,7 @@ static void soc_pcm_set_msb(struct snd_pcm_substream *substream, int bits)
static void soc_pcm_apply_msb(struct snd_pcm_substream *substream)
{
- struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
+ struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
struct snd_soc_dai *cpu_dai;
struct snd_soc_dai *codec_dai;
int stream = substream->stream;
@@ -636,7 +636,7 @@ EXPORT_SYMBOL_GPL(snd_soc_runtime_calc_hw);
static void soc_pcm_init_runtime_hw(struct snd_pcm_substream *substream)
{
struct snd_pcm_hardware *hw = &substream->runtime->hw;
- struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
+ struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
u64 formats = hw->formats;
/*
@@ -652,7 +652,7 @@ static void soc_pcm_init_runtime_hw(struct snd_pcm_substream *substream)
static int soc_pcm_components_open(struct snd_pcm_substream *substream)
{
- struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
+ struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
struct snd_soc_component *component;
int i, ret = 0;
@@ -672,7 +672,7 @@ static int soc_pcm_components_open(struct snd_pcm_substream *substream)
static int soc_pcm_components_close(struct snd_pcm_substream *substream,
int rollback)
{
- struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
+ struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
struct snd_soc_component *component;
int i, ret = 0;
@@ -698,14 +698,12 @@ static int soc_pcm_clean(struct snd_soc_pcm_runtime *rtd,
if (!rollback) {
snd_soc_runtime_deactivate(rtd, substream->stream);
- /* clear the corresponding DAIs parameters when going to be inactive */
- for_each_rtd_dais(rtd, i, dai) {
- if (snd_soc_dai_active(dai) == 0)
- soc_pcm_set_dai_params(dai, NULL);
- if (snd_soc_dai_stream_active(dai, substream->stream) == 0)
- snd_soc_dai_digital_mute(dai, 1, substream->stream);
- }
+ /* Make sure DAI parameters cleared if the DAI becomes inactive */
+ for_each_rtd_dais(rtd, i, dai)
+ if (snd_soc_dai_active(dai) == 0 &&
+ (dai->rate || dai->channels || dai->sample_bits))
+ soc_pcm_set_dai_params(dai, NULL);
}
for_each_rtd_dais(rtd, i, dai)
@@ -738,7 +736,7 @@ static int __soc_pcm_close(struct snd_soc_pcm_runtime *rtd,
/* PCM close ops for non-DPCM streams */
static int soc_pcm_close(struct snd_pcm_substream *substream)
{
- struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
+ struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
snd_soc_dpcm_mutex_lock(rtd);
__soc_pcm_close(rtd, substream);
@@ -748,7 +746,7 @@ static int soc_pcm_close(struct snd_pcm_substream *substream)
static int soc_hw_sanity_check(struct snd_pcm_substream *substream)
{
- struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
+ struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
struct snd_pcm_hardware *hw = &substream->runtime->hw;
const char *name_cpu = soc_cpu_dai_name(rtd);
const char *name_codec = soc_codec_dai_name(rtd);
@@ -854,7 +852,7 @@ err:
/* PCM open ops for non-DPCM streams */
static int soc_pcm_open(struct snd_pcm_substream *substream)
{
- struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
+ struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
int ret;
snd_soc_dpcm_mutex_lock(rtd);
@@ -908,7 +906,7 @@ out:
/* PCM prepare ops for non-DPCM streams */
static int soc_pcm_prepare(struct snd_pcm_substream *substream)
{
- struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
+ struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
int ret;
snd_soc_dpcm_mutex_lock(rtd);
@@ -936,6 +934,15 @@ static int soc_pcm_hw_clean(struct snd_soc_pcm_runtime *rtd,
snd_soc_dpcm_mutex_assert_held(rtd);
+ /* clear the corresponding DAIs parameters when going to be inactive */
+ for_each_rtd_dais(rtd, i, dai) {
+ if (snd_soc_dai_active(dai) == 1)
+ soc_pcm_set_dai_params(dai, NULL);
+
+ if (snd_soc_dai_stream_active(dai, substream->stream) == 1)
+ snd_soc_dai_digital_mute(dai, 1, substream->stream);
+ }
+
/* run the stream event */
snd_soc_dapm_stream_stop(rtd, substream->stream);
@@ -965,7 +972,7 @@ static int __soc_pcm_hw_free(struct snd_soc_pcm_runtime *rtd,
/* hw_free PCM ops for non-DPCM streams */
static int soc_pcm_hw_free(struct snd_pcm_substream *substream)
{
- struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
+ struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
int ret;
snd_soc_dpcm_mutex_lock(rtd);
@@ -1085,7 +1092,7 @@ out:
static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
- struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
+ struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
int ret;
snd_soc_dpcm_mutex_lock(rtd);
@@ -1110,7 +1117,7 @@ static int (* const trigger[][TRIGGER_MAX])(struct snd_pcm_substream *substream,
static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
{
- struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
+ struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
struct snd_soc_component *component;
int ret = 0, r = 0, i;
int rollback = 0;
@@ -1397,7 +1404,7 @@ EXPORT_SYMBOL_GPL(dpcm_end_walk_at_be);
int dpcm_path_get(struct snd_soc_pcm_runtime *fe,
int stream, struct snd_soc_dapm_widget_list **list)
{
- struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(fe, 0);
+ struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(fe, 0);
int paths;
if (fe->dai_link->num_cpus > 1) {
@@ -1670,7 +1677,7 @@ unwind:
static void dpcm_runtime_setup_fe(struct snd_pcm_substream *substream)
{
- struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream);
+ struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream);
struct snd_pcm_runtime *runtime = substream->runtime;
struct snd_pcm_hardware *hw = &runtime->hw;
struct snd_soc_dai *dai;
@@ -1704,7 +1711,7 @@ static void dpcm_runtime_setup_fe(struct snd_pcm_substream *substream)
static void dpcm_runtime_setup_be_format(struct snd_pcm_substream *substream)
{
- struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream);
+ struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream);
struct snd_pcm_runtime *runtime = substream->runtime;
struct snd_pcm_hardware *hw = &runtime->hw;
struct snd_soc_dpcm *dpcm;
@@ -1741,7 +1748,7 @@ static void dpcm_runtime_setup_be_format(struct snd_pcm_substream *substream)
static void dpcm_runtime_setup_be_chan(struct snd_pcm_substream *substream)
{
- struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream);
+ struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream);
struct snd_pcm_runtime *runtime = substream->runtime;
struct snd_pcm_hardware *hw = &runtime->hw;
struct snd_soc_dpcm *dpcm;
@@ -1780,7 +1787,7 @@ static void dpcm_runtime_setup_be_chan(struct snd_pcm_substream *substream)
*/
if (be->dai_link->num_codecs == 1) {
struct snd_soc_pcm_stream *codec_stream = snd_soc_dai_get_pcm_stream(
- asoc_rtd_to_codec(be, 0), stream);
+ snd_soc_rtd_to_codec(be, 0), stream);
soc_pcm_hw_update_chan(hw, codec_stream);
}
@@ -1789,7 +1796,7 @@ static void dpcm_runtime_setup_be_chan(struct snd_pcm_substream *substream)
static void dpcm_runtime_setup_be_rate(struct snd_pcm_substream *substream)
{
- struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream);
+ struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream);
struct snd_pcm_runtime *runtime = substream->runtime;
struct snd_pcm_hardware *hw = &runtime->hw;
struct snd_soc_dpcm *dpcm;
@@ -1828,7 +1835,7 @@ static int dpcm_apply_symmetry(struct snd_pcm_substream *fe_substream,
int stream)
{
struct snd_soc_dpcm *dpcm;
- struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(fe_substream);
+ struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(fe_substream);
struct snd_soc_dai *fe_cpu_dai;
int err = 0;
int i;
@@ -1855,7 +1862,7 @@ static int dpcm_apply_symmetry(struct snd_pcm_substream *fe_substream,
if (!be_substream)
continue;
- rtd = asoc_substream_to_rtd(be_substream);
+ rtd = snd_soc_substream_to_rtd(be_substream);
if (rtd->dai_link->be_hw_params_fixup)
continue;
@@ -1874,7 +1881,7 @@ error:
static int dpcm_fe_dai_startup(struct snd_pcm_substream *fe_substream)
{
- struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(fe_substream);
+ struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(fe_substream);
int stream = fe_substream->stream, ret = 0;
dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE);
@@ -1911,7 +1918,7 @@ be_err:
static int dpcm_fe_dai_shutdown(struct snd_pcm_substream *substream)
{
- struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream);
+ struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream);
int stream = substream->stream;
snd_soc_dpcm_mutex_assert_held(fe);
@@ -1977,7 +1984,7 @@ void dpcm_be_dai_hw_free(struct snd_soc_pcm_runtime *fe, int stream)
static int dpcm_fe_dai_hw_free(struct snd_pcm_substream *substream)
{
- struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream);
+ struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream);
int stream = substream->stream;
snd_soc_dpcm_mutex_lock(fe);
@@ -2080,7 +2087,7 @@ unwind:
static int dpcm_fe_dai_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
- struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream);
+ struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream);
int ret, stream = substream->stream;
snd_soc_dpcm_mutex_lock(fe);
@@ -2283,7 +2290,7 @@ EXPORT_SYMBOL_GPL(dpcm_be_dai_trigger);
static int dpcm_dai_trigger_fe_be(struct snd_pcm_substream *substream,
int cmd, bool fe_first)
{
- struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream);
+ struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream);
int ret;
/* call trigger on the frontend before the backend. */
@@ -2314,7 +2321,7 @@ static int dpcm_dai_trigger_fe_be(struct snd_pcm_substream *substream,
static int dpcm_fe_dai_do_trigger(struct snd_pcm_substream *substream, int cmd)
{
- struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream);
+ struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream);
int stream = substream->stream;
int ret = 0;
enum snd_soc_dpcm_trigger trigger = fe->dai_link->trigger[stream];
@@ -2401,7 +2408,7 @@ out:
static int dpcm_fe_dai_trigger(struct snd_pcm_substream *substream, int cmd)
{
- struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream);
+ struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream);
int stream = substream->stream;
/* if FE's runtime_update is already set, we're in race;
@@ -2455,7 +2462,7 @@ int dpcm_be_dai_prepare(struct snd_soc_pcm_runtime *fe, int stream)
static int dpcm_fe_dai_prepare(struct snd_pcm_substream *substream)
{
- struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream);
+ struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream);
int stream = substream->stream, ret = 0;
snd_soc_dpcm_mutex_lock(fe);
@@ -2632,7 +2639,7 @@ static int soc_dpcm_fe_runtime_update(struct snd_soc_pcm_runtime *fe, int new)
}
/* only check active links */
- if (!snd_soc_dai_active(asoc_rtd_to_cpu(fe, 0)))
+ if (!snd_soc_dai_active(snd_soc_rtd_to_cpu(fe, 0)))
return 0;
/* DAPM sync will call this to update DSP paths */
@@ -2642,13 +2649,13 @@ static int soc_dpcm_fe_runtime_update(struct snd_soc_pcm_runtime *fe, int new)
for_each_pcm_streams(stream) {
/* skip if FE doesn't have playback/capture capability */
- if (!snd_soc_dai_stream_valid(asoc_rtd_to_cpu(fe, 0), stream) ||
- !snd_soc_dai_stream_valid(asoc_rtd_to_codec(fe, 0), stream))
+ if (!snd_soc_dai_stream_valid(snd_soc_rtd_to_cpu(fe, 0), stream) ||
+ !snd_soc_dai_stream_valid(snd_soc_rtd_to_codec(fe, 0), stream))
continue;
/* skip if FE isn't currently playing/capturing */
- if (!snd_soc_dai_stream_active(asoc_rtd_to_cpu(fe, 0), stream) ||
- !snd_soc_dai_stream_active(asoc_rtd_to_codec(fe, 0), stream))
+ if (!snd_soc_dai_stream_active(snd_soc_rtd_to_cpu(fe, 0), stream) ||
+ !snd_soc_dai_stream_active(snd_soc_rtd_to_codec(fe, 0), stream))
continue;
paths = dpcm_path_get(fe, stream, &list);
@@ -2706,7 +2713,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dpcm_runtime_update);
static void dpcm_fe_dai_cleanup(struct snd_pcm_substream *fe_substream)
{
- struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(fe_substream);
+ struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(fe_substream);
struct snd_soc_dpcm *dpcm;
int stream = fe_substream->stream;
@@ -2721,7 +2728,7 @@ static void dpcm_fe_dai_cleanup(struct snd_pcm_substream *fe_substream)
static int dpcm_fe_dai_close(struct snd_pcm_substream *fe_substream)
{
- struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(fe_substream);
+ struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(fe_substream);
int ret;
snd_soc_dpcm_mutex_lock(fe);
@@ -2735,7 +2742,7 @@ static int dpcm_fe_dai_close(struct snd_pcm_substream *fe_substream)
static int dpcm_fe_dai_open(struct snd_pcm_substream *fe_substream)
{
- struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(fe_substream);
+ struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(fe_substream);
struct snd_soc_dapm_widget_list *list;
int ret;
int stream = fe_substream->stream;
@@ -2819,9 +2826,9 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd,
for_each_rtd_codec_dais(rtd, i, codec_dai) {
if (dai_link->num_cpus == 1) {
- cpu_dai = asoc_rtd_to_cpu(rtd, 0);
+ cpu_dai = snd_soc_rtd_to_cpu(rtd, 0);
} else if (dai_link->num_cpus == dai_link->num_codecs) {
- cpu_dai = asoc_rtd_to_cpu(rtd, i);
+ cpu_dai = snd_soc_rtd_to_cpu(rtd, i);
} else if (rtd->dai_link->num_codecs > rtd->dai_link->num_cpus) {
int cpu_id;
@@ -2832,7 +2839,7 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd,
}
cpu_id = rtd->dai_link->codec_ch_maps[i].connected_cpu_id;
- cpu_dai = asoc_rtd_to_cpu(rtd, cpu_id);
+ cpu_dai = snd_soc_rtd_to_cpu(rtd, cpu_id);
} else {
dev_err(rtd->card->dev,
"%s codec number %d < cpu number %d is not supported\n",