soc-pcm needs DAI name and it will be "multicpu/multicodec" if it has
many DAIs. But current code is using very verbose for it.
This patch uses macro and makes code simple.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87im61uobf.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
soc_pcm_apply_symmetry() is used like below in all cases.
if (snd_soc_dai_active(dai)) {
err = soc_pcm_apply_symmetry(fe_substream, dai);
...
}
Because of this style, the code is deep nested.
This patch checks it under soc_pcm_apply_symmetry(), and makes code simple.
static int soc_pcm_apply_symmetry(...)
{
...
=> if (!snd_soc_dai_active(...))
return 0;
...
}
=> ret = soc_pcm_apply_symmetry();
if (ret < 0)
...
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87k0qhuobl.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
cppcheck warning:
sound/soc/soc-pcm.c:1907:6: style: Variable 'err' is assigned a value
that is never used. [unreadVariable]
err = dpcm_be_dai_hw_free(fe, stream);
^
it's not clear why dpcm_be_dai_hw_free() is sometimes called without
testing the error status, and sometimes an error message is provided.
When in doubt, add an error message for consistency. This may have to
be revisited.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20210218221921.88991-5-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
cppcheck warning:
sound/soc/soc-pcm.c:2398:7: style: Variable 'ret' is reassigned a
value before the old one has been used. [redundantAssignment]
ret = -EINVAL;
^
sound/soc/soc-pcm.c:2395:7: note: ret is assigned
ret = -EINVAL;
^
sound/soc/soc-pcm.c:2398:7: note: ret is overwritten
ret = -EINVAL;
^
This looks like a copy/paste or git merge issue.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20210218221921.88991-3-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
dpcm_fe_dai_startup() (= A) calls dpcm_set_fe_runtime() (= B) to setup
DPCM runtime. From *naming point of view*, it sounds like setup function
for FE.
(A) static int dpcm_fe_dai_startup(...)
{
...
(B) dpcm_set_fe_runtime(...);
...
}
But in dpcm_set_fe_runtime() (= B),
It setups FE by dpcm_runtime_setup_fe() (= X),
and setups BE by dpcm_runtime_merge_xxx() (= Y).
(B) static void dpcm_set_fe_runtime(...)
{
...
(X) dpcm_runtime_setup_fe(...);
^ dpcm_runtime_setup_be_format(...);
(Y) dpcm_runtime_setup_be_chan(...);
v dpcm_runtime_setup_be_rate(...);
}
These means that the function which is called as xxx_fe_xxx()
is setups both FE and BE. This is confusable and can be hot bed for bug.
Now dpcm_set_fe_runtime() (= B) is simple enough and confusable naming,
let's unpack it at dpcm_fe_dai_startup().
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87mtvxvsgn.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
dpcm_fe_dai_startup() (= A) calls dpcm_set_fe_runtime() (= B) to setup
DPCM runtime. From *naming point of view*, it sounds like setup function
for FE.
(A) static int dpcm_fe_dai_startup(...)
{
...
(B) dpcm_set_fe_runtime(...);
...
}
But in dpcm_set_fe_runtime() (= B),
It setups FE by dpcm_runtime_setup_fe() (= X),
and setups BE by dpcm_runtime_merge_xxx() (= Y).
(B) static void dpcm_set_fe_runtime(...)
{
...
(X) dpcm_runtime_setup_fe(...);
^ dpcm_runtime_merge_format(...);
(Y) dpcm_runtime_merge_chan(...);
v dpcm_runtime_merge_rate(...);
}
These means that the function which is called as xxx_fe_xxx()
is setups both FE and BE. This is confusable and can be hot bed for bug.
This patch renames unclear dpcm_runtime_merge_xxx() (= Y) to
more clear dpcm_runtime_setup_be_xxx().
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87o8gdvsgr.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
dpcm_fe_dai_startup() (= A) calls dpcm_set_fe_runtime() (= B) to setup
DPCM runtime. From *naming point of view*, it sounds like setup function
for FE.
(A) static int dpcm_fe_dai_startup(...)
{
...
(B) dpcm_set_fe_runtime(...);
...
}
But in dpcm_set_fe_runtime() (= B),
It setups FE by for_each loop (= X),
and setups BE by dpcm_runtime_merge_xxx() (= Y).
(B) static void dpcm_set_fe_runtime(...)
{
...
^ for_each_rtd_cpu_dais(...) {
| ...
(X) soc_pcm_hw_update_rate(...);
| soc_pcm_hw_update_chan(...);
| soc_pcm_hw_update_format(...);
v }
^ dpcm_runtime_merge_format(...);
(Y) dpcm_runtime_merge_chan(...);
v dpcm_runtime_merge_rate(...);
}
These means that the function which is called as xxx_fe_xxx()
is setups both FE and BE. This is confusable and can be hot bed for bug.
To tidyup it, as 1st step, this patch adds new dpcm_runtime_setup_fe()
for (X).
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87pn0tvsgx.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
dpcm_init_runtime_hw() (= A) is used from dpcm_set_fe_runtime() (= B)
with for_each_rtd_cpu_dais() loop (= C), and it checks formats (= D).
(A) static void dpcm_init_runtime_hw(...)
{
...
^ if (runtime->hw.formats)
| (D1) runtime->hw.formats &= stream->formats;
(D) else
| (D2) runtime->hw.formats = stream->formats;
v }
(B) static void dpcm_set_fe_runtime(...)
{
...
(C) for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
...
(A) dpcm_init_runtime_hw(...);
}
}
If this for_each_rtd_cpu_dais() loop (= C) calls
dpcm_init_runtime_hw() (= A) multiple times, this means it is Multi-CPU.
If we focus to format operation at (D), using mask (= D1) is understandable
because it restricts unsupported format.
But, enabling format when zero format case (= D2) is very strange,
because it might enables unsupported format.
This runtime->hw.formats is initialized by ULLONG_MAX at soc_pcm_hw_init(),
thus becoming zero format means it can't use such format.
And doing this strange format operation is only here.
This patch removes strange format operation (= D2), and use standard
soc_pcm_hw_update_format() for it.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87sg5pvshq.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
In case DPCM runtime has multiple CPU DAIs, dpcm_init_runtime_hw() is
called multiple times, once for each CPU DAI. This will lead to
ignoring hw limits of all but the last DAI.
Fix this by moving soc_pcm_hw_init() up by one level to
dpcm_init_runtime_hw().
Fixes: 140f553d12 ("ASoC: soc-pcm: fix hwparams min/max init for dpcm")
Suggested-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20210216172251.3023723-1-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
When runtime is initialized with dpcm_init_runtime_hw(), some of the
min/max calculations assume that defaults are set. For example
calculation of channel min/max values may be done using zero-initialized
data and soc_pcm_hw_update_chan() will always return max-channels of 0
in this case. This will result in failure to open the PCM at all.
Fix the issue by calling soc_pcm_hw_init() before calling any
soc_pcm_hw_update_*() functions.
Remove the conditional code on runtime->hw.formats as this field
is anyways set in soc_pcm_hw_init().
Fixes: 6cb56a4549 ("ASoC: soc-pcm: add soc_pcm_hw_update_chan()")
Reported-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20210214220414.2876690-1-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
We have soc_pcm_hw_update_xxx() now.
This patch creates same function for format.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/87pn1g90oa.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
We have soc_pcm_hw_update_rate() now.
This patch creates same function for chan.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/87r1lw90oo.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
To update hw, we need to follow setting order
1) set hw->rates
2) call snd_pcm_limit_hw_rates()
3) update hw->rate_min/max
To avoid random settings, this patch adds new soc_pcm_hw_update_rate()
and share updating code.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/87sg6c90qv.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This log message should be a debug message, because it
doesn't return directly but continue next loop.
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/1612771965-5776-1-git-send-email-shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
soc-pcm has dpcm_runtime_merge_xxx() functions,
but uses parameters are very verbose.
dpcm_runtime_merge_format(..., &runtime->hw.formats);
dpcm_runtime_merge_chan(..., &runtime->hw.channels_min,
&runtime->hw.channels_max);
dpcm_runtime_merge_rate(..., &runtime->hw.rates,
&runtime->hw.rate_min,
&runtime->hw.rate_max);
We want to replace it into
dpcm_runtime_merge_format(..., runtime);
dpcm_runtime_merge_chan(..., runtime);
dpcm_runtime_merge_rate(..., runtime);
This patch do it.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/874kj9aigd.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
soc_new_pcm() implementation is very long / verbose / complex,
thus, it is very difficult to read.
If we read it carefully, we can notice that it is consisted by
int soc_new_pcm(...)
{
(1) judging playback/caputre part
(2) creating the PCM part
(3) setup pcm/rtd part
}
This patch adds new soc_create_pcm() for (2) part
and offload it from snd_pcm_new().
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/875z3paigi.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
soc_new_pcm() implementation is very long / verbose / complex,
thus, it is very difficult to read.
If we read it carefully, we can notice that it is consisted by
int soc_new_pcm(...)
{
(1) judging playback/caputre part
(2) creating the PCM part
(3) setup pcm/rtd part
}
This patch adds new soc_get_playback_capture() for (1) part
and offload it from soc_new_pcm().
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/877do5aign.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
soc_pcm_params_symmetry() checks rate/channel/sample_bits state.
These are very similar but different, thus, it needs to have very
verbose code.
This patch use macro for it and make code more simple.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/878s8un6si.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
soc_pcm_apply_symmetry() want to call snd_pcm_hw_constraint_single()
for rate/channel/sample_bits, but, it needs many condition checks.
These are very similar but different, thus, it needs to have very
verbose code.
This patch use macro for it and make code more simple.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87a6tan6sm.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
snd_pcm_runtime / snd_soc_dai / snd_soc_dai_driver / snd_soc_dai_link
have related parameter which is similar but not same naming.
struct snd_pcm_runtime {
...
(A) unsigned int rate;
...
(B) unsigned int sample_bits;
...
};
struct snd_soc_dai {
...
(A) unsigned int rate;
(B) unsigned int sample_bits;
...
};
struct snd_soc_dai_driver {
...
(A) unsigned int symmetric_rates:1;
(B) unsigned int symmetric_samplebits:1;
...
};
struct snd_soc_dai_link {
...
(A) unsigned int symmetric_rates:1;
(B) unsigned int symmetric_samplebits:1;
...
};
Because it is similar but not same naming rule,
code can be verbose / can't share macro.
This patch sync naming rule for framework.
- xxx_rates;
+ xxx_rate;
- xxx_samplebits;
+ xxx_sample_bits;
old name will be removed if all drivers were switched
to new naming rule.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87wnweolj6.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
commit a39748d03c ("ASoC: soc-pcm: cleanup soc_pcm_apply_symmetry()")
was applied by miscommunication.
To more cleanup code, and to be easy review, this patch reverts it.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87y2guoljm.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
soc_pcm_apply_symmetry() want to call snd_pcm_hw_constraint_single()
for rate/channel/sample_bits, but, it needs many condition check.
These are very similar but different, thus, it needs to have very
verbose code.
This patch use macro for it and make code more simple.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87wnxo7uyq.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Getting rate/channels/sample_bits from param needs fixed method.
This patch adds new soc_pcm_set_dai_params() and replace existing code.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87y2i47uyw.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
soc-pcm has dpcm_set_fe_update_state() to update FE's runtime_update
(except dpcm_fe_dai_do_trigger() which needs to update it without it).
OTOH, it doesn't have BE's update function.
O: dpcm_set_fe_update_state()
X: dpcm_set_be_update_state()
This patch add BE's dpcm_set_fe_update_state()
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87zh2k7uz1.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This patch moves dpcm_set_fe_update_state() to top side.
This is prepare for cleanup soc-pcm.c
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/871rfw99jn.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
The error path here doesn't set "ret" so it returns uninitialized data
instead of a negative error code.
Fixes: 2c1382840c ("ASoC: soc-pcm: disconnect BEs if the FE is not ready")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/X/wfXQFxeMLvpO+1@mwanda
Signed-off-by: Mark Brown <broonie@kernel.org>
Kernel test robot throws below error ->
sound/soc/soc-pcm.c:2523 dpcm_run_update_startup() error: uninitialized
symbol 'ret'.
Initializing ret = 0 and returning correct -ERRNO in failure path.
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
Link: https://lore.kernel.org/r/1610163901-5523-1-git-send-email-jrdr.linux@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
FE is connected to two BEs, BE1 is active, BE2 is deactive.
When closing BE1, FE/BE1 is in HW_FREE state, then BE2 is
startup by mixer runtime update.
For FE is in HW_FREE state, dpcm_run_update_startup() will skip
BE2's startup because FE's state is HW_FREE, BE2 stays in FE's
be_clients list.
During FE's closed, the dpcm_fe_dai_close() will close all related
BEs, BE2 will be closed. This will lead to BE2's dpcm[stream].users
mismatch.
We need disconnet all pending BEs in the corner case.
Signed-off-by: zhucancan <zhucancan@vivo.com>
Link: https://lore.kernel.org/r/AAoArwDfDnoefyxzy2wyiaqm.1.1608885766936.Hmail.zhucancan@vivo.com
Signed-off-by: Mark Brown <broonie@kernel.org>
soc_pcm_trigger() calls DAI/Component/Link trigger,
but some of them might be failed.
static int soc_pcm_trigger(...)
{
...
switch (cmd) {
case SNDRV_PCM_TRIGGER_START:
case SNDRV_PCM_TRIGGER_RESUME:
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
ret = snd_soc_link_trigger(substream, cmd);
if (ret < 0)
break;
(*) ret = snd_soc_pcm_component_trigger(substream, cmd);
if (ret < 0)
break;
ret = snd_soc_pcm_dai_trigger(substream, cmd);
break;
case SNDRV_PCM_TRIGGER_STOP:
case SNDRV_PCM_TRIGGER_SUSPEND:
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
ret = snd_soc_pcm_dai_trigger(substream, cmd);
if (ret < 0)
break;
ret = snd_soc_pcm_component_trigger(substream, cmd);
if (ret < 0)
break;
ret = snd_soc_link_trigger(substream, cmd);
break;
}
...
}
For example, if soc_pcm_trigger() failed at (*) point,
we need to rollback previous succeeded trigger.
This patch adds trigger mark for DAI/Component/Link,
and do STOP if START/RESUME/PAUSE_RELEASE were failed.
Because it need to use new rollback parameter,
we need to modify DAI/Component/Link trigger functions in the same time.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87a6uycssd.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
dpcm_be_dai_trigger() is calling dpcm_do_trigger()
at each SNDRV_PCM_TRIGGER_xxx (1).
int dpcm_be_dai_trigger(...)
{
for_each_dpcm_be(fe, stream, dpcm) {
(B) ...
switch (cmd) {
case SNDRV_PCM_TRIGGER_START:
...
(1) ret = dpcm_do_trigger(...);
...
case SNDRV_PCM_TRIGGER_RESUME:
...
(1) ret = dpcm_do_trigger(...);
...
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
...
(1) ret = dpcm_do_trigger(...);
...
case SNDRV_PCM_TRIGGER_STOP:
...
(1) ret = dpcm_do_trigger(...);
...
case SNDRV_PCM_TRIGGER_SUSPEND:
...
(1) ret = dpcm_do_trigger(...);
...
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
...
(1) ret = dpcm_do_trigger(...);
...
}
}
}
But it is just very verbose and duplicated function.
Because We can indicate dev_dbg() (A) at dpcm_be_dai_trigger() (B).
And dev_err() (C) is not needed because soc_pcm_trigger() itself
indicates error message when error.
static int dpcm_do_trigger(...)
{
int ret;
(A) dev_dbg(...);
ret = soc_pcm_trigger(substream, cmd);
if (ret < 0)
(C) dev_err(...);
return ret;
}
This patch replace dpcm_do_trigger() to soc_pcm_trigger().
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87blfecssk.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
A recent change removed the call to send the DAPM_STREAM_STOP
event in dpcm_fe_dai_shutdown. But this causes a regression
when a PCM prepare is not paired with a hw_free. So, add
the DAPM_STREAM_STOP event back to dpcm_fe_dai_shutdown()
to fix this.
The new sequence would be:
soc_pcm_prepare()
-> SND_SOC_DAPM_STREAM_START
soc_pcm_hw_free()
-> soc_pcm_hw_free()
-> SND_SOC_DAPM_STREAM_STOP
dpcm_fe_dai_shutdown()
-> SND_SOC_DAPM_STREAM_STOP
Note that the DAPM_STREAM_STOP will be called twice but it seems
harmless.
Fixes: a27b421f1d ('ASoC: pcm: call snd_soc_dapm_stream_stop() in soc_pcm_hw_clean')
Reported-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Tested-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20201202193343.912942-1-ranjani.sridharan@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Currently, the SND_SOC_DAPM_STREAM_START event is sent during
pcm_prepare() but the SND_SOC_DAPM_STREAM_STOP event is
sent only in dpcm_fe_dai_shutdown() after soc_pcm_close().
This results in an imbalance between when the DAPM widgets
receive the PRE/POST_PMU/PMD events. So call
snd_soc_dapm_stream_stop() in soc_pcm_hw_clean() before the
snd_soc_pcm_component_hw_free() to keep the stream_stop DAPM
event balanced with the stream_start event in soc_pm_prepare().
Also, in order to prevent duplicate DAPM stream events,
remove the call for DAPM STREAM_START event in dpcm_fe_dai_prepare()
and the call for DAPM STREAM_STOP event in dpcm_fe_dai_shutdown().
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20201117215001.163107-1-ranjani.sridharan@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
dpcm_end_walk_at_be() stops the graph walk when first BE is found for
the given FE component. In a component model we may want to connect
multiple DAIs from different components. A new flag is introduced in
'snd_soc_card', which when set allows DAI/component chaining. Later
PCM operations can be called for all these listed components for a
valid DAPM path.
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Link: https://lore.kernel.org/r/1604329814-24779-3-git-send-email-spujar@nvidia.com
Signed-off-by: Mark Brown <broonie@kernel.org>
soc-pcm's dpcm_fe_dai_do_trigger() supported DRAIN commnad up to kernel
v5.4 where explicit switch(cmd) has been introduced which takes into
account all SNDRV_PCM_TRIGGER_xxx but SNDRV_PCM_TRIGGER_DRAIN. Update
switch statement to reactive support for it.
As DRAIN is somewhat unique by lacking negative/stop counterpart, bring
behaviour of dpcm_fe_dai_do_trigger() for said command back to its
pre-v5.4 state by adding it to START/RESUME/PAUSE_RELEASE group.
Fixes: acbf27746e ("ASoC: pcm: update FE/BE trigger order based on the command")
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20201026100129.8216-1-cezary.rojewski@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
soc_pcm_hw_params() does rollback when failed (A),
but, it is almost same as soc_pcm_hw_free().
static int soc_pcm_hw_params(xxx)
{
...
if (ret < 0)
goto xxx_err;
...
return ret;
^ component_err:
| ...
| interface_err:
(A) ...
| codec_err:
| ...
v return ret;
}
The difference is
soc_pcm_hw_free() is for all dai/component/substream,
rollback is for succeeded part only.
This kind of duplicated code can be a hotbed of bugs,
thus, we want to share soc_pcm_hw_free() and rollback.
Now, soc_pcm_hw_params/free() are handling
1) snd_soc_link_hw_params/free()
2) snd_soc_pcm_component_hw_params/free()
3) snd_soc_dai_hw_params/free()
Now, 1) to 3) are handled.
This patch adds new soc_pcm_hw_clean() and call it from
soc_pcm_hw_params() as rollback, and from soc_pcm_hw_free() as
normal close handler.
Other difference is that soc_pcm_hw_free() handles digital mute
if it was last user. Rollback also handles it by this patch.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87h7rhgqab.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
soc_pcm_hw_params() does rollback when failed (A),
but, it is almost same as soc_pcm_hw_free().
static int soc_pcm_hw_params(xxx)
{
...
if (ret < 0)
goto xxx_err;
...
return ret;
^ component_err:
| ...
| interface_err:
(A) ...
| codec_err:
| ...
v return ret;
}
The difference is
soc_pcm_hw_free() is for all dai/component/substream,
rollback is for succeeded part only.
This kind of duplicated code can be a hotbed of bugs,
thus, we want to share soc_pcm_hw_free() and rollback.
Now, soc_pcm_hw_params/free() are handling
1) snd_soc_link_hw_params/free()
2) snd_soc_pcm_component_hw_params/free()
=> 3) snd_soc_dai_hw_params/free()
This patch is for 3) snd_soc_dai_hw_params/free().
The idea of having bit-flag or counter is not enough for this purpose.
For example if one DAI is used for 2xPlaybacks for some reasons,
and if 1st Playback was succeeded but 2nd Playback was failed,
2nd Playback rollback doesn't need to call shutdown.
But it has succeeded bit-flag or counter via 1st Playback,
thus, 2nd Playback rollback will call unneeded shutdown.
And 1st Playback's necessary shutdown will not be called,
because bit-flag or counter was cleared by wrong 2nd Playback rollback.
To avoid such case, this patch marks substream pointer when hw_params() was
succeeded. If rollback needed, it will check rollback flag and marked
substream pointer.
One note here is that it cares *previous* hw_params() only now,
but we might want to check *whole* marked substream in the future.
This patch is using macro named "push/pop", so that it can be easily
update.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87imbxgqai.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
soc_pcm_hw_params() does rollback when failed (A),
but, it is almost same as soc_pcm_hw_free().
static int soc_pcm_hw_params(xxx)
{
...
if (ret < 0)
goto xxx_err;
...
return ret;
^ component_err:
| ...
| interface_err:
(A) ...
| codec_err:
| ...
v return ret;
}
The difference is
soc_pcm_hw_free() is for all dai/component/substream,
rollback is for succeeded part only.
This kind of duplicated code can be a hotbed of bugs,
thus, we want to share soc_pcm_hw_free() and rollback.
Now, soc_pcm_hw_params/free() are handling
1) snd_soc_link_hw_params/free()
=> 2) snd_soc_pcm_component_hw_params/free()
3) snd_soc_dai_hw_params/free()
This patch is for 2) snd_soc_pcm_component_hw_params/free().
The idea of having bit-flag or counter is not enough for this purpose.
For example if one DAI is used for 2xPlaybacks for some reasons,
and if 1st Playback was succeeded but 2nd Playback was failed,
2nd Playback rollback doesn't need to call shutdown.
But it has succeeded bit-flag or counter via 1st Playback,
thus, 2nd Playback rollback will call unneeded shutdown.
And 1st Playback's necessary shutdown will not be called,
because bit-flag or counter was cleared by wrong 2nd Playback rollback.
To avoid such case, this patch marks substream pointer when hw_params() was
succeeded. If rollback needed, it will check rollback flag and marked
substream pointer.
One note here is that it cares *previous* hw_params() only now,
but we might want to check *whole* marked substream in the future.
This patch is using macro named "push/pop", so that it can be easily
update.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87k0wdgqav.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
soc_pcm_hw_params() does rollback when failed (A),
but, it is almost same as soc_pcm_hw_free().
static int soc_pcm_hw_params(xxx)
{
...
if (ret < 0)
goto xxx_err;
...
return ret;
^ component_err:
| ...
| interface_err:
(A) ...
| codec_err:
| ...
v return ret;
}
The difference is
soc_pcm_hw_free() is for all dai/component/substream,
rollback is for succeeded part only.
This kind of duplicated code can be a hotbed of bugs,
thus, we want to share soc_pcm_hw_free() and rollback.
Now, soc_pcm_hw_params/free() are handling
=> 1) snd_soc_link_hw_params/free()
2) snd_soc_pcm_component_hw_params/free()
3) snd_soc_dai_hw_params/free()
This patch is for 1) snd_soc_link_hw_params/free().
The idea of having bit-flag or counter is not enough for this purpose.
For example if one DAI is used for 2xPlaybacks for some reasons,
and if 1st Playback was succeeded but 2nd Playback was failed,
2nd Playback rollback doesn't need to call shutdown.
But it has succeeded bit-flag or counter via 1st Playback,
thus, 2nd Playback rollback will call unneeded shutdown.
And 1st Playback's necessary shutdown will not be called,
because bit-flag or counter was cleared by wrong 2nd Playback rollback.
To avoid such case, this patch marks substream pointer when hw_params() was
succeeded. If rollback needed, it will check rollback flag and marked
substream pointer.
One note here ist that it cares *previous* hw_params() only now,
but we might want to check *whole* marked substream in the future.
This patch is using macro named "push/pop", so that it can be easily
update.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87lfgtgqba.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This patch moves soc_pcm_hw_free() next to soc_pcm_hw_params().
This is prepare for soc_pcm_hw_params() cleanup
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87mu19gqbh.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
commit 140a4532cd ("ASoC: soc-pcm: add soc_pcm_clean() and call it
from soc_pcm_open/close()") switched to use soc_pcm_clean() at
soc_pcm_open().
But it removed "return 0", and missing "ret = 0",
because of it, it always return -EINVAL eventhough no error.
This patch adds missing "ret = 0" for success case.
Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Link: https://lore.kernel.org/r/87ft6ya65z.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
commit 140a4532cd ("ASoC: soc-pcm: add soc_pcm_clean() and call it
from soc_pcm_open/close()") switch to call soc_pcm_clean() on
soc_pcm_open() when rollback case.
But, it uses "goto err" (A) *before* mutex_lock() (B) when error of
snd_soc_pcm_component_pm_runtime_get().
The mutex_unlock() (C) is not needed in such case. This patch fix it.
static int soc_pcm_open(...)
{
...
ret = snd_soc_pcm_component_pm_runtime_get(rtd, substream);
if (ret < 0)
(A) goto err;
(B) mutex_lock_nested(...);
...
err:
(C) mutex_unlock(..);
...
}
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87k0waag44.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
snd_soc_component_module_get(), snd_soc_component_open() itself will
indicate error message, thus, soc_pcm_components_open() don't need to
handle it.
This patch removes these.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87d026bwms.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
snd_soc_dai_startup() itself will indicate error message,
thus, soc_pcm_open() don't need to handle it.
This patch removes it.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87eemmbwmy.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
soc_pcm_open() does rollback when failed (A),
but, it is almost same as soc_pcm_close().
static int soc_pcm_open(xxx)
{
...
if (ret < 0)
goto xxx_err;
...
return 0;
^ config_err:
| ...
| rtd_startup_err:
(A) ...
| component_err:
| ...
v return ret;
}
The difference is
soc_pcm_close() is for all dai/component/substream,
rollback is for succeeded part only.
This kind of duplicated code can be a hotbed of bugs,
thus, we want to share soc_pcm_close() and rollback.
Now, soc_pcm_open/close() are handling
1) snd_soc_dai_startup/shutdown()
2) snd_soc_link_startup/shutdown()
3) snd_soc_component_module_get/put()
4) snd_soc_component_open/close()
5) pm_runtime_put/get()
Now, 1) to 5) are handled.
This patch adds new soc_pcm_clean() and call it from
soc_pcm_open() as rollback, and from soc_pcm_close() as
normal close handler.
One note here is that it don't need to call snd_soc_runtime_deactivate()
when rollback case, because it will be called without
snd_soc_runtime_activate().
It also don't need to call snd_soc_dapm_stream_stop() when rollback case.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87ft72bwn4.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
soc_pcm_open() does rollback when failed (A),
but, it is almost same as soc_pcm_close().
static int soc_pcm_open(xxx)
{
...
if (ret < 0)
goto xxx_err;
...
return 0;
^ config_err:
| ...
| rtd_startup_err:
(A) ...
| component_err:
| ...
v return ret;
}
The difference is
soc_pcm_close() is for all dai/component/substream,
rollback is for succeeded part only.
This kind of duplicated code can be a hotbed of bugs,
thus, we want to share soc_pcm_close() and rollback.
Now, soc_pcm_open/close() are handling
1) snd_soc_dai_startup/shutdown()
2) snd_soc_link_startup/shutdown()
3) snd_soc_component_module_get/put()
4) snd_soc_component_open/close()
=> 5) pm_runtime_put/get()
This patch is for 5) pm_runtime_put/get().
The idea of having bit-flag or counter is not enough for this purpose.
For example if one DAI is used for 2xPlaybacks for some reasons,
and if 1st Playback was succeeded but 2nd Playback was failed,
2nd Playback rollback doesn't need to call shutdown.
But it has succeeded bit-flag or counter via 1st Playback,
thus, 2nd Playback rollback will call unneeded shutdown.
And 1st Playback's necessary shutdown will not be called,
because bit-flag or counter was cleared by wrong 2nd Playback rollback.
To avoid such case, this patch marks substream pointer when get() was
succeeded. If rollback needed, it will check rollback flag and marked
substream pointer.
One note here is that it cares *current* get() only now.
but we might want to check *whole* marked substream in the future.
This patch is using macro named "push/pop", so that it can be easily
update.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87h7ribwnb.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
soc_pcm_open() does rollback when failed (A),
but, it is almost same as soc_pcm_close().
static int soc_pcm_open(xxx)
{
...
if (ret < 0)
goto xxx_err;
...
return 0;
^ config_err:
| ...
| rtd_startup_err:
(A) ...
| component_err:
| ...
v return ret;
}
The difference is
soc_pcm_close() is for all dai/component/substream,
rollback is for succeeded part only.
This kind of duplicated code can be a hotbed of bugs,
thus, we want to share soc_pcm_close() and rollback.
Now, soc_pcm_open/close() are handling
1) snd_soc_dai_startup/shutdown()
2) snd_soc_link_startup/shutdown()
=> 3) snd_soc_component_module_get/put()
=> 4) snd_soc_component_open/close()
5) pm_runtime_put/get()
This patch is for 3) snd_soc_component_module_get/put()
4) snd_soc_component_open/close().
The idea of having bit-flag or counter is not enough for this purpose.
For example if one DAI is used for 2xPlaybacks for some reasons,
and if 1st Playback was succeeded but 2nd Playback was failed,
2nd Playback rollback doesn't need to call shutdown.
But it has succeeded bit-flag or counter via 1st Playback,
thus, 2nd Playback rollback will call unneeded shutdown.
And 1st Playback's necessary shutdown will not be called,
because bit-flag or counter was cleared by wrong 2nd Playback rollback.
To avoid such case, this patch marks substream pointer when open() was
succeeded. If rollback needed, it will check rollback flag and marked
substream pointer.
One note here is that it cares *current* open() only now.
but we might want to check *whole* marked substream in the future.
This patch is using macro named "push/pop", so that it can be easily
update.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87imbybwno.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
soc_pcm_open() does rollback when failed (A),
but, it is almost same as soc_pcm_close().
static int soc_pcm_open(xxx)
{
...
if (ret < 0)
goto xxx_err;
...
return 0;
^ config_err:
| ...
| rtd_startup_err:
(A) ...
| component_err:
| ...
v return ret;
}
The difference is
soc_pcm_close() is for all dai/component/substream,
rollback is for succeeded part only.
This kind of duplicated code can be a hotbed of bugs,
thus, we want to share soc_pcm_close() and rollback.
Now, soc_pcm_open/close() are handling
1) snd_soc_dai_startup/shutdown()
=> 2) snd_soc_link_startup/shutdown()
3) snd_soc_component_module_get/put()
4) snd_soc_component_open/close()
5) pm_runtime_put/get()
This patch is for 2) snd_soc_link_startup/shutdown().
The idea of having bit-flag or counter is not enough for this purpose.
For example if one DAI is used for 2xPlaybacks for some reasons,
and if 1st Playback was succeeded but 2nd Playback was failed,
2nd Playback rollback doesn't need to call shutdown.
But it has succeeded bit-flag or counter via 1st Playback,
thus, 2nd Playback rollback will call unneeded shutdown.
And 1st Playback's necessary shutdown will not be called,
because bit-flag or counter was cleared by wrong 2nd Playback rollback.
To avoid such case, this patch marks substream pointer when startup() was
succeeded. If rollback needed, it will check rollback flag and marked
substream pointer.
One note here is that it cares *current* startup() only now.
but we might want to check *whole* marked substream in the future.
This patch is using macro named "push/pop", so that it can be easily
update.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87k0webwnv.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
soc_pcm_open() does rollback when failed (A),
but, it is almost same as soc_pcm_close().
static int soc_pcm_open(xxx)
{
...
if (ret < 0)
goto xxx_err;
...
return 0;
^ config_err:
| ...
| rtd_startup_err:
(A) ...
| component_err:
| ...
v return ret;
}
The difference is
soc_pcm_close() is for all dai/component/substream,
rollback is for succeeded part only.
This kind of duplicated code can be a hotbed of bugs,
thus, we want to share soc_pcm_close() and rollback.
Now, soc_pcm_open/close() are handling
=> 1) snd_soc_dai_startup/shutdown()
2) snd_soc_link_startup/shutdown()
3) snd_soc_component_module_get/put()
4) snd_soc_component_open/close()
5) pm_runtime_put/get()
This patch is for 1) snd_soc_dai_startup/shutdown().
The idea of having bit-flag or counter is not enough for this purpose.
For example if one DAI is used for 2xPlaybacks for some reasons,
and if 1st Playback was succeeded but 2nd Playback was failed,
2nd Playback rollback doesn't need to call shutdown.
But it has succeeded bit-flag or counter via 1st Playback,
thus, 2nd Playback rollback will call unneeded shutdown.
And 1st Playback's necessary shutdown will not be called,
because bit-flag or counter was cleared by wrong 2nd Playback rollback.
To avoid such case, this patch marks substream pointer when startup() was
succeeded. If rollback needed, it will check rollback flag and marked
substream pointer.
One note here is that it cares *current* startup() only now.
but we might want to check *whole* marked substream in the future.
This patch is using macro named "push/pop", so that it can be easily
update.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87lfgubwoc.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Introduce for_each_rtd_dais_rollback macro which behaves exactly like
for_each_codec_dais_rollback and its cpu_dais equivalent but for all
dais instead.
Use newly added macro to fix soc_pcm_open error path and prevent
uninitialized dais from being cleaned-up.
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Fixes: 5d9fa03e6c ("ASoC: soc-pcm: tidyup soc_pcm_open() order")
Acked-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/20200907111939.16169-1-cezary.rojewski@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Previous updates to set dailink capabilities and check dailink
capabilities were based on a flawed assumption that all dais support
the same capabilities as the dailink. This is true for TDM
configurations but existing configurations use an amplifier and a
capture device on the same dailink, and the tests would prevent the
card from probing.
This patch modifies the snd_soc_dai_link_set_capabilities()
helper so that the dpcm_playback (resp. dpcm_capture) dailink
capabilities are set if at least one dai supports playback (resp. capture).
Likewise the checks are modified so that an error is reported only
when dpcm_playback (resp. dpcm_capture) is set but none of the CPU
DAIs support playback (resp. capture).
Fixes: 25612477d2 ('ASoC: soc-dai: set dai_link dpcm_ flags with a helper')
Fixes: b73287f0b0 ('ASoC: soc-pcm: dpcm: fix playback/capture checks')
Suggested-by: Jerome Brunet <jbrunet@baylibre.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20200723180533.220312-1-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Current soc-xxx are getting rtd from substream by
rtd = substream->private_data;
But, getting data from "private_data" is very unclear.
This patch adds asoc_substream_to_rtd() macro which is
easy to understand that rtd from substream.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87wo2z0yve.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Silence documentation build warning by correcting kernel-doc comment
for snd_soc_runtime_action.
./sound/soc/soc-pcm.c:220: warning: Function parameter or member 'action' not described in 'snd_soc_runtime_action'
Signed-off-by: Colton Lewis <colton.w.lewis@protonmail.com>
Link: https://lore.kernel.org/r/20200626053953.68797-1-colton.w.lewis@protonmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Now, soc_pcm_trigger_start/stop() are simple enough.
Let's merge these into soc_pcm_trigger().
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87ftbbw8wj.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
We have 2 type of component functions
snd_soc_component_xxx() is focusing to component itself,
snd_soc_pcm_component_xxx() is focusing to rtd related component.
Now we can update snd_soc_component_trigger() to
snd_soc_pcm_component_trigger(). This patch do it.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87k10nw8xf.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
We have 2 type of component functions
snd_soc_component_xxx() is focusing to component itself,
snd_soc_pcm_component_xxx() is focusing to rtd related component.
Now we can update snd_soc_component_hw_free() to
snd_soc_pcm_component_hw_free(). This patch do it.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87lfl3w8xv.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
We have 2 type of component functions
snd_soc_component_xxx() is focusing to component itself,
snd_soc_pcm_component_xxx() is focusing to rtd related component.
Now we can update snd_soc_component_hw_params() to
snd_soc_pcm_component_hw_params(). This patch do it.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87mu5jw8y8.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
We have 2 type of component functions
snd_soc_component_xxx() is focusing to component itself,
snd_soc_pcm_component_xxx() is focusing to rtd related component.
Now we can update snd_soc_component_prepare() to
snd_soc_pcm_component_prepare(). This patch do it.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87o8pzw8yl.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Provide an explicit dmesg trace with the PCM 'new_name', dailink name
and error code to help with debug.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20200612204050.25901-3-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
soc_dpcm_fe_runtime_update() is called for all dailinks, and we want
to first discard all back-ends, then deal with front-ends.
The existing code first reports an error with multi-cpu front-ends,
and that check needs to be moved after we know that we are dealing
with a front-end.
Fixes: 6e1276a5e6 ('ASoC: Return error if the function does not support multi-cpu')
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
BugLink: https://github.com/thesofproject/linux/issues/1970
Link: https://lore.kernel.org/r/20200612203507.25621-1-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Recent changes in the ASoC core prevent multi-cpu BE dailinks from
being used. DPCM does support multi-cpu DAIs for BE Dailinks, but not
for FE.
Handle the FE checks first, and make sure all DAIs support the same
capabilities within the same dailink.
Fixes: 9b5db05936 ("ASoC: soc-pcm: dpcm: Only allow playback/capture if supported")
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Daniel Baluta <daniel.baluta@gmail.com>
BugLink: https://github.com/thesofproject/linux/issues/2031
Link: https://lore.kernel.org/r/20200608194415.4663-2-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
FE state is SND_SOC_DPCM_STATE_PREPARE now, BE1 is
used by FE.
Later when new BE2 is added to FE by mixer update,
it will call dpcm_run_update_startup() to update
BE2's state, but unfortunately BE2 .prepare() meets
error, it will disconnect all non started BE.
This make BE1 dai skip .hw_free() and .shutdown(),
and the BE1 users will never decrease to zero.
Signed-off-by: zhucancan <zhucancan@vivo.com>
Link: https://lore.kernel.org/r/ALMAWwB5CP9aAcKXCU5FzqqF.1.1590747164172.Hmail.zhucancan@vivo.com
Signed-off-by: Mark Brown <broonie@kernel.org>
dai_link related function should be implemented at soc-link.c.
This patch adds snd_soc_link_be_hw_params_fixup().
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/87wo503k73.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
"rtd" can be created from "substream".
Let's cleanup snd_soc_link_xxx().
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/87y2pg3k78.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
dai_link related function should be implemented at
soc-link.c.
This patch moves soc-pcm soc_rtd_xxx()
to soc-link as snd_soc_link_xxx()
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/87zh9w3k7k.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
We have snd_soc_dai/dai_stream/component_active() macro
This patch uses it.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/8736826n44.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
snd_soc_runtime_action() updates DAI's xxx_active.
We should update these in the same time, and
it can be implemented at soc-dai.c.
This patch adds snd_soc_dai_action() for it.
This is prepare for xxx_active cleanup.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87a72a6n4s.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
snd_soc_runtime_activate()/deactivate() are implemented by global function
which are just calling snd_soc_runtime_action().
We can replace it to macro, and this patch do it.
This patch is prepare for xxx_active cleanup.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87blmq6n4y.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
We have 2 type of component functions
snd_soc_dai_xxx() is focusing to dai itself,
snd_soc_pcm_dai_xxx() is focusing to rtd related dai.
Now we can update soc_pcm_bespoke_trigger() to
snd_soc_pcm_dai_bespoke_trigger(). This patch do it.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-By: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87tv19ssjm.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
We have 2 type of component functions
snd_soc_dai_xxx() is focusing to dai itself,
snd_soc_pcm_dai_xxx() is focusing to rtd related dai.
Now we can update snd_soc_dai_trigger() to
snd_soc_pcm_dai_trigger(). This patch do it.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-By: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87v9lpssjr.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
We have 2 type of component functions
snd_soc_dai_xxx() is focusing to dai itself,
snd_soc_pcm_dai_xxx() is focusing to rtd related dai.
Now we can update snd_soc_dai_prepare() to
snd_soc_pcm_dai_prepare(). This patch do it.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-By: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87wo65ssk2.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Daniel Baluta <daniel.baluta@nxp.com>:
From: Daniel Baluta <daniel.baluta@nxp.com>
This patch series adds support for SOF on i.MX8M family. First board
from this family that has a DSP is i.MX8MP.
First 2 patches are trying to fix some compilation issues, the next two
are adding the imx8m support and the last one adds the devicetree
binding.
Changes since v2:
- add reviewed by from Rob to DT patch
- fix ownership for patch 2
Daniel Baluta (3):
ASoC: SOF: imx: Add i.MX8M HW support
ASoC: SOF: Add i.MX8MP device descriptor
dt-bindings: dsp: fsl: Add fsl,imx8mp-dsp entry
Pierre-Louis Bossart (1):
ASoC: SOF: imx: fix undefined reference issue
YueHaibing (1):
ASoC: SOF: imx8: Fix randbuild error
.../devicetree/bindings/dsp/fsl,dsp.yaml | 2 +
sound/soc/sof/imx/Kconfig | 32 +-
sound/soc/sof/imx/Makefile | 2 +
sound/soc/sof/imx/imx8m.c | 279 ++++++++++++++++++
sound/soc/sof/sof-of-dev.c | 14 +
5 files changed, 325 insertions(+), 4 deletions(-)
create mode 100644 sound/soc/sof/imx/imx8m.c
--
2.17.1
At the moment, PCM devices for DPCM are only created based on the
dpcm_playback/capture parameters of the DAI link, without considering
if the CPU/FE DAI is actually capable of playback/capture.
Normally the dpcm_playback/capture parameter should match the
capabilities of the CPU DAI. However, there is no way to set that
parameter from the device tree (e.g. with simple-audio-card or
qcom sound cards). dpcm_playback/capture are always both set to 1.
This causes problems when the CPU DAI does only support playback
or capture. Attemting to open that PCM device with an unsupported
stream type then results in a null pointer dereference:
Unable to handle kernel NULL pointer dereference at virtual address 0000000000000128
Internal error: Oops: 96000044 [#1] PREEMPT SMP
CPU: 3 PID: 1582 Comm: arecord Not tainted 5.7.0-rc1
pc : invalidate_paths_ep+0x30/0xe0
lr : snd_soc_dapm_dai_get_connected_widgets+0x170/0x1a8
Call trace:
invalidate_paths_ep+0x30/0xe0
snd_soc_dapm_dai_get_connected_widgets+0x170/0x1a8
dpcm_path_get+0x38/0xd0
dpcm_fe_dai_open+0x70/0x920
snd_pcm_open_substream+0x564/0x840
snd_pcm_open+0xfc/0x228
snd_pcm_capture_open+0x4c/0x78
snd_open+0xac/0x1a8
...
... because the DAI playback/capture_widget is not set in that case.
We could add checks there to fix the problem (maybe we should
anyway), but much easier is to not expose the device as
playback/capture in the first place. Attemting to use that
device would always fail later anyway.
Add checks for snd_soc_dai_stream_valid() to the DPCM case
to avoid exposing playback/capture if it is not supported.
Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
Link: https://lore.kernel.org/r/20200415104928.86091-1-stephan@gerhold.net
Signed-off-by: Mark Brown <broonie@kernel.org>
soc_compr_trigger_fe() allows start or stop after pause_push.
In dpcm_be_dai_trigger(), however, only pause_release is allowed
command after pause_push.
So, start or stop after pause in compress offload is always
returned as error if the compress offload is used with dpcm.
To fix the problem, SND_SOC_DPCM_STATE_PAUSED should be allowed
for start or stop command.
Signed-off-by: Gyeongtaek Lee <gt82.lee@samsung.com>
Reviewed-by: Vinod Koul <vkoul@kernel.org>
Link: https://lore.kernel.org/r/004d01d607c1$7a3d5250$6eb7f6f0$@samsung.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Now we can use for_each_rtd_dais().
Let's use it instead of for_each_rtd_cpu/codec_dais().
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/87sgi8olet.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This makes DPCM runtime update functions available for external
calling. As an example, virtualised ASoC component drivers may need
to call these when managing shared DAPM routes that are used by more
than one driver (i.e. when host driver and guest drivers have a DAPM
path from guest PCM to host DAI where some parts are owned by host
driver and others by guest driver).
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Link: https://lore.kernel.org/r/20200312095214.15126-3-guennadi.liakhovetski@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Currently dpcm_prune_paths() has up to 4 nested condition and loop
levels, which forces the code to use flags for flow control.
Extracting widget status verification code from dpcm_prune_paths()
into a separate function simplifies the code.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Link: https://lore.kernel.org/r/20200312095214.15126-2-guennadi.liakhovetski@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This is re-applying the fix that went into 5.6 (commit 6c89ffea60)
as the changes were wiped out after merging the other code
refactoring. Basically the same changes, just replacing the
suspicious calls of snprintf() with scnprintf().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20200310163625.10838-1-tiwai@suse.de
Signed-off-by: Mark Brown <broonie@kernel.org>
Hi Mark
These are v2 resend of soc-pcm cleanup step5.
1) - 4) are rebased to latest for-5.7 branch.
5) - 6) are remaked of previous [6/8], [7/8] which were mistaken patch.
Kuninori Morimoto (6):
1) ASoC: soc-pcm: move dpcm_fe_dai_close()
2) ASoC: soc-pcm: add dpcm_fe_dai_cleanup()
3) ASoC: soc-pcm: use snd_soc_dai_get_pcm_stream() at dpcm_set_fe_runtime()
4) ASoC: soc-pcm: tidyup dulicate handing at dpcm_fe_dai_startup()
5) ASoC: soc-pcm: check DAI's activity more simply
6) ASoC: soc-pcm: Do Digital Mute for both CPU/Codec in same timing.
sound/soc/soc-pcm.c | 97 ++++++++++++++++++++++-----------------------
1 file changed, 47 insertions(+), 50 deletions(-)
--
2.17.1
Digital Mute for CPU is done at soc_pcm_close(), and
Digital Mute for Codec is done at soc_pcm_hw_free().
It is just confusable.
This patch do Digital Mute for both CPU/Codec in same timing.
Then, it cares DAI activity
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87imjip9ty.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
soc_pcm_hw_free() want to call snd_soc_dai_digital_mute()
if it was last user of Playback or Capture.
bool playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
int playback_active = dai->stream_active[SNDRV_PCM_STREAM_PLAYBACK];
int capture_active = dai->stream_active[SNDRV_PCM_STREAM_CAPTURE];
if ((playback && playback_active == 1) ||
(!playback && capture_active == 1))
snd_soc_dai_digital_mute(...)
But it is same as
int active = dai->stream_active[substream->stream];
if (active == 1)
snd_soc_dai_digital_mute(...)
This patch simplify the code.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87k13yp9ub.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
error handling at dpcm_fe_dai_startup() has duplicate code.
This patch tidyup it.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87lfoep9ug.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
We already have snd_soc_dai_get_pcm_stream(),
let's use it
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87mu8up9ul.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
dpcm_fe_dai_close() and error case of dpcm_fe_dai_open()
need to do same cleanup operation.
To avoid duplicate code, this patch adds dpcm_fe_dai_cleanup()
and use it.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87o8tap9uq.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
move dpcm_fe_dai_close() next to dpcm_fe_dai_open().
This is prepare for dpcm_fe_dai_open() cleanup
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87pndqp9uv.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
The logic to calculate the subset of stream parameters supported by all
DAIs associated with a PCM stream is nontrivial. Export a helper
function so it can be used to set up simple codec2codec DAI links.
Signed-off-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/r/20200305051143.60691-3-samuel@sholland.org
Signed-off-by: Mark Brown <broonie@kernel.org>
dpcm_add_paths() checks returned be from dpcm_get_be()
static int dpcm_add_paths(...)
{
...
for_each_dapm_widgets(list, i, widget) {
...
be = dpcm_get_be(...);
...
/* make sure BE is a real BE */
=> if (!be->dai_link->no_pcm)
continue;
...
}
...
}
But, dpcm_get_be() itself is checking it already.
dpcm_get_be(...)
{
...
for_each_card_rtds(card, be) {
=> if (!be->dai_link->no_pcm)
continue;
...
if (...)
=> return be;
}
return NULL
}
This patch removes duplicate check
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87lfoo7q1j.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Many functions defines "stream = substream->stream", but
some of them is using "substream->stream" instead of "stream".
It is pointless. This patch uses defined stream.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87mu947q1t.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Now multi-cpu-dais are supported, we can skip cpi-dais which don't
support the current stream, following the example of multi-codec-dais.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20200225133917.21314-7-yung-chuan.liao@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Multi cpu is not supported by all functions yet. Add an error message
and return.
Suggested-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20200225133917.21314-6-yung-chuan.liao@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Add support in PCM operations to invoke multiple cpu dais as we do
for multiple codec dais. Also the symmetry calculations are updated to
reflect multiple cpu dais.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Shreyas NC <shreyas.nc@intel.com>
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Link: https://lore.kernel.org/r/20200225133917.21314-3-yung-chuan.liao@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>