History log of /linux-master/sound/soc/soc-compress.c
Revision Date Author Comments
# 9a8b202f 06-Mar-2024 Shalini Manjunatha <quic_c_shalma@quicinc.com>

ASoC: soc-compress: Fix and add DPCM locking

We find mising DPCM locking inside soc_compr_set_params_fe
before calling dpcm_be_dai_hw_params() and dpcm_be_dai_prepare()
which cause lockdep assert for DPCM lock not held in
__soc_pcm_hw_params() and __soc_pcm_prepare()

Signed-off-by: Shalini Manjunatha <quic_c_shalma@quicinc.com>
Link: https://msgid.link/r/d985beeafdd32316eb45f20811eb7926da7a796e.1709720380.git.quic_c_shalma@quicinc.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 28b11fd4 11-Sep-2023 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-compress: convert not to use asoc_xxx()

ASoC is now unified asoc_xxx() into snd_soc_xxx().
This patch convert asoc_xxx() to snd_soc_xxx().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87fs3kp8sz.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 22222147 18-Jun-2023 yixuanjiang <yixuanjiang@google.com>

ASoC: soc-compress: Fix deadlock in soc_compr_open_fe

Modify the error handling flow by release lock.
The require mutex will keep holding if open fail.

Fixes: aa9ff6a4955f ("ASoC: soc-compress: Reposition and add pcm_mutex")
Signed-off-by: yixuanjiang <yixuanjiang@google.com>
Link: https://lore.kernel.org/r/20230619033127.2522477-1-yixuanjiang@google.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 2f3092e7 16-May-2023 Claudiu Beznea <claudiu.beznea@microchip.com>

ASoC: do not include pm_runtime.h if not used

Do not include pm_runtime.h header in files where APIs exported by
pm_runtime.h are not used.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Acked-by: Jarkko Nikula <jarkko.nikula@bitmer.com> # for omap-mcbsp-st.c
Link: https://lore.kernel.org/r/20230517094903.2895238-2-claudiu.beznea@microchip.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 0f3b8184 05-Apr-2023 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: add snd_soc_card_mutex_lock/unlock()

ASoC need to use card->mutex with _INIT or _RUNTIME,
but there is no helper function for it.

This patch adds its helper function and use it.

Because people might misunderstand that _init() is mutex initialization,
this patch renames _INIT to _ROOT and adds new
snd_soc_card_mutex_lock_root() for it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87a5zlx3tw.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 38e42f6d 05-Apr-2023 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: expand snd_soc_dpcm_mutex_lock/unlock()

soc-pcm.c has snd_soc_dpcm_mutex_lock/unlock(),
but other files can't use it because it is static function.

It requests snd_soc_pcm_runtime as parameter (A), but sometimes we
want to use it by snd_soc_card (B).

(A) static inline void snd_soc_dpcm_mutex_lock(struct snd_soc_pcm_runtime *rtd)
{
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
} ^^^^^^^^^

(B) mutex_lock_nested(&card->pcm_mutex, card->pcm_subclass);
^^^^

We want to use it with both "rtd" and "card" for dapm lock/unlock.
To enable it, this patch uses _Generic macro.

This patch makes snd_soc_dpcm_mutex_{un}lock() global function, and use it on
each files.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87bkk1x3ud.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 37b58bec 24-Mar-2023 Daniel Baluta <daniel.baluta@nxp.com>

ASoC: soc-compress: Inherit atomicity from DAI link for Compress FE

After commit bbf7d3b1c4f40 ("ASoC: soc-pcm: align BE 'atomicity' with
that of the FE") BE and FE atomicity must match.

In the case of Compress PCM there is a mismatch in atomicity between FE
and BE and we get errors like this:

[ 36.434566] sai1-wm8960-hifi: dpcm_be_connect: FE is atomic but BE
is nonatomic, invalid configuration
[ 36.444278] PCM Deep Buffer: ASoC: can't connect SAI1.OUT

In order to fix this we must inherit the atomicity from DAI link
associated with current PCM Compress FE.

Fixes: bbf7d3b1c4f4 ("ASoC: soc-pcm: align BE 'atomicity' with that of the FE")
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20230324124019.30826-1-daniel.baluta@oss.nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 0d3a5178 05-Mar-2023 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-pcm.c: remove indirect runtime copy

substream->runtime will be attached when substream was opened
at snd_pcm_attach_substream(). When it uses DPCM,
FE substream->runtime is attached, but BE substream->runtime is not.
Thus, we are copying FE substream->runtime to BE.

But, we are copyig FE substream->runtime to FE dpcm->runtime first (A),
and copy it to BE dpcm->runtime (B), and copy it to
BE substream->runtime (C).

static int dpcm_fe_dai_open(...) {
...
(A) fe->dpcm[stream].runtime = fe_substream->runtime;
...
}

static int dpcm_be_connect(...) {
...
(B) be->dpcm[stream].runtime = fe->dpcm[stream].runtime;
...
}

int dpcm_be_dai_startup(...) {
...
(C) be_substream->runtime = be->dpcm[stream].runtime;
...
}

It is too roundabout and troublesome.
OTOH, it is directly copying fe_substream->runtime at dpcm_be_reparent()
without using be->dpcm[stream].runtime.

static void dpcm_be_reparent(...)
{
...
for_each_dpcm_fe(be, stream, dpcm) {
...
=> be_substream->runtime = fe_substream->runtime;
break;
}
}

This patch removes indirect copying.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87v8je64dh.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# ffe4c0f0 23-Jan-2023 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-compress.c: fixup private_data on snd_soc_new_compress()

commit d3268a40d4b19f ("ASoC: soc-compress.c: fix NULL dereference")
enables DPCM capture, but it should independent from playback.
This patch fixup it.

Fixes: d3268a40d4b1 ("ASoC: soc-compress.c: fix NULL dereference")
Link: https://lore.kernel.org/r/87tu0i6j7j.wl-kuninori.morimoto.gx@renesas.com
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/871qnkvo1s.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# aa9ff6a4 07-Dec-2022 강신형 <s47.kang@samsung.com>

ASoC: soc-compress: Reposition and add pcm_mutex

If panic_on_warn is set and compress stream(DPCM) is started,
then kernel panic occurred because card->pcm_mutex isn't held appropriately.
In the following functions, warning were issued at this line
"snd_soc_dpcm_mutex_assert_held".

static int dpcm_be_connect(struct snd_soc_pcm_runtime *fe,
struct snd_soc_pcm_runtime *be, int stream)
{
...
snd_soc_dpcm_mutex_assert_held(fe);
...
}

void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream)
{
...
snd_soc_dpcm_mutex_assert_held(fe);
...
}

void snd_soc_runtime_action(struct snd_soc_pcm_runtime *rtd,
int stream, int action)
{
...
snd_soc_dpcm_mutex_assert_held(rtd);
...
}

int dpcm_dapm_stream_event(struct snd_soc_pcm_runtime *fe, int dir,
int event)
{
...
snd_soc_dpcm_mutex_assert_held(fe);
...
}

These functions are called by soc_compr_set_params_fe, soc_compr_open_fe
and soc_compr_free_fe
without pcm_mutex locking. And this is call stack.

[ 414.527841][ T2179] pc : dpcm_process_paths+0x5a4/0x750
[ 414.527848][ T2179] lr : dpcm_process_paths+0x37c/0x750
[ 414.527945][ T2179] Call trace:
[ 414.527949][ T2179] dpcm_process_paths+0x5a4/0x750
[ 414.527955][ T2179] soc_compr_open_fe+0xb0/0x2cc
[ 414.527972][ T2179] snd_compr_open+0x180/0x248
[ 414.527981][ T2179] snd_open+0x15c/0x194
[ 414.528003][ T2179] chrdev_open+0x1b0/0x220
[ 414.528023][ T2179] do_dentry_open+0x30c/0x594
[ 414.528045][ T2179] vfs_open+0x34/0x44
[ 414.528053][ T2179] path_openat+0x914/0xb08
[ 414.528062][ T2179] do_filp_open+0xc0/0x170
[ 414.528068][ T2179] do_sys_openat2+0x94/0x18c
[ 414.528076][ T2179] __arm64_sys_openat+0x78/0xa4
[ 414.528084][ T2179] invoke_syscall+0x48/0x10c
[ 414.528094][ T2179] el0_svc_common+0xbc/0x104
[ 414.528099][ T2179] do_el0_svc+0x34/0xd8
[ 414.528103][ T2179] el0_svc+0x34/0xc4
[ 414.528125][ T2179] el0t_64_sync_handler+0x8c/0xfc
[ 414.528133][ T2179] el0t_64_sync+0x1a0/0x1a4
[ 414.528142][ T2179] Kernel panic - not syncing: panic_on_warn set ...

So, I reposition and add pcm_mutex to resolve lockdep error.

Signed-off-by: Shinhyung Kang <s47.kang@samsung.com>
Link: https://lore.kernel.org/r/016401d90ac4$7b6848c0$7238da40$@samsung.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 3989ade2 20-Sep-2022 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc.h: remove num_cpus/codecs

Current rtd has both dai_link pointer (A) and num_cpus/codecs (B).

(A) rtd->dai_link = dai_link;
(B) rtd->num_cpus = dai_link->num_cpus;
(B) rtd->num_codecs = dai_link->num_codecs;

But, we can get num_cpus/codecs (B) via dai_link (A).
This means we don't need to keep num_cpus/codecs on rtd.
This patch removes these.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87sfkmv9n3.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# ccb4214f 09-Mar-2022 Jiasheng Jiang <jiasheng@iscas.ac.cn>

ASoC: soc-compress: Change the check for codec_dai

It should be better to reverse the check on codec_dai
and returned early in order to be easier to understand.

Fixes: de2c6f98817f ("ASoC: soc-compress: prevent the potentially use of null pointer")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220310030041.1556323-1-jiasheng@iscas.ac.cn
Signed-off-by: Mark Brown <broonie@kernel.org>


# de2c6f98 15-Oct-2021 Jiasheng Jiang <jiasheng@iscas.ac.cn>

ASoC: soc-compress: prevent the potentially use of null pointer

There is one call trace that snd_soc_register_card()
->snd_soc_bind_card()->soc_init_pcm_runtime()
->snd_soc_dai_compress_new()->snd_soc_new_compress().
In the trace the 'codec_dai' transfers from card->dai_link,
and we can see from the snd_soc_add_pcm_runtime() in
snd_soc_bind_card() that, if value of card->dai_link->num_codecs
is 0, then 'codec_dai' could be null pointer caused
by index out of bound in 'asoc_rtd_to_codec(rtd, 0)'.
And snd_soc_register_card() is called by various platforms.
Therefore, it is better to add the check in the case of misusing.
And because 'cpu_dai' has already checked in soc_init_pcm_runtime(),
there is no need to check again.
Adding the check as follow, then if 'codec_dai' is null,
snd_soc_new_compress() will not pass through the check
'if (playback + capture != 1)', avoiding the leftover use of
'codec_dai'.

Fixes: 467fece ("ASoC: soc-dai: move snd_soc_dai_stream_valid() to soc-dai.c")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/1634285633-529368-1-git-send-email-jiasheng@iscas.ac.cn
Signed-off-by: Mark Brown <broonie@kernel.org>


# cd46f382 31-Aug-2021 Peter Ujfalusi <peter.ujfalusi@linux.intel.com>

ASoC: compress/component: Use module_get_when_open/put_when_close for cstream

Currently the try_module_get() and module_put() is not possible for
compressed streams if the module_get_upon_open is set to 1 which means that\
the components are not protected in a same way as components when normal
audio is used.

SOF is setting module_get_upon_open to 1 for component drivers which works
correctly for audio stream but when compressed stream is used then the
module is not protected.

Convert the compress open and free operation to mimic the steps of it's
pcm counterpart to fix this issue.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20210901095255.3617-3-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 2c4e3154 14-Jul-2021 Takashi Iwai <tiwai@suse.de>

ALSA: compress: Initialize mutex in snd_compress_new()

Currently the snd_compr.lock mutex isn't initialized in the API
functions although the lock is used many places in other code in
compress offload API. It's because the object was expected to be
initialized via snd_compress_register(), but this was never used by
ASoC, which is the only user. Instead, ASoC initializes the mutex by
itself, and this is error-prone.

This patch moves the mutex initialization into the more appropriate
place, snd_compress_new(), for avoiding the missing init.

Reviewed-by: Mark Brown <broonie@kernel.org>
Acked-by: Vinod Koul <vkoul@kernel.org>
Reviewed-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20210714162424.4412-3-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 45475bf6 06-Apr-2021 Gyeongtaek Lee <gt82.lee@samsung.com>

ASoC: soc-compress: lock pcm_mutex to resolve lockdep error

If panic_on_warn=1 is added in bootargs and compress offload playback with
DPCM is started, kernel panic would be occurred because rtd->card->pcm_mutex
isn't held in soc_compr_open_fe() and soc_compr_free_fe() and it generates
lockdep warning in the following code.

void snd_soc_runtime_action(struct snd_soc_pcm_runtime *rtd,
int stream, int action)
{
struct snd_soc_dai *dai;
int i;

lockdep_assert_held(&rtd->card->pcm_mutex);

To prevent lockdep warning but minimize side effect by adding mutex,
pcm_mutex is held just before snd_soc_runtime_activate() and
snd_soc_runtime_deactivate() and is released right after them.

Signed-off-by: Gyeongtaek Lee <gt82.lee@samsung.com>
Link: https://lore.kernel.org/r/1891546521.01617772502282.JavaMail.epsvc@epcpadp3
Signed-off-by: Mark Brown <broonie@kernel.org>


# f52366e6 14-Mar-2021 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-pcm: don't indicate error message for dpcm_be_dai_hw_free()

dpcm_be_dai_hw_free() never fail, error message is not needed.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87blblutaf.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# d479f00b 14-Mar-2021 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-pcm: indicate error message at dpcm_path_get()

Indicating error message when failed case is very useful for debuging.
In many case, its style is like below.

int function(...)
{
...
return ret;
}

int caller(...)
{
...
ret = function(...);
if (ret < 0)
dev_err(...)
...
}

This is not so bad, but in this style *each caller* needs to indicate
duplicate same error message, and some caller is forgetting to do it.
And caller can't indicate detail function() error information.

If function() indicates error message, we can get same and
detail information without forgot.

int function(...)
{
...
if (ret < 0)
dev_err(...)

return ret;
}

int caller(...)
{
...
ret = function(...);
...
}

Now, many place uses dpcm_path_get() like below

ret = dpcm_path_get(...);
if (ret < 0)
goto error;
(A) else if (ret == 0)
dev_dbg(...)

But here, (A) part can be indicated at dpcm_path_get() not caller.
It is simple and readable code.

This patch do it.
Small detail behaviors will be exchanged by this patch.

1) indicates debug info (= path numbers) if path > 0 case only
(It was *always* indicated).
2) soc_dpcm_fe_runtime_update() is indicating error message
for paths < 0 case, but it is already done at dpcm_path_get().
Thus just remove it. but dev_dbg() vs dev_warn() is exchanged.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87mtv5utbj.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 531590bb 08-Mar-2021 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-pcm: share DPCM BE DAI stop operation

soc-pcm has very similar but different DPCM BE DAI stop operation at
1) dpcm_be_dai_startup() error case rollback
2) dpcm_be_dai_startup_unwind()
3) dpcm_be_dai_shutdown()

The differences are
1) for rollback
2) Doesn't check by snd_soc_dpcm_be_can_update() (Is this bug ?)
3) Do soc_pcm_hw_free() if it was not !OPENed and !HW_FREEed,
and call soc_pcm_close().

We can share same code by
1) hw_free is not needed. Needs last dpcm as rollback.
2) hw_free is not needed.
3) hw_free is needed.

This patch adds new dpcm_be_dai_stop() and share these 3.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87a6rduoam.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 453d32c2 18-Nov-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-compress: add soc_compr_clean() and call it from soc_compr_open/free()

soc_compr_open() does rollback when failed (A),
but, it is almost same as soc_compr_free().

static int soc_compr_open(xxx)
{
...
if (ret < 0)
goto xxx_err;
...
return 0;

^ machine_err:
| ...
| out:
(A) ...
| pm_err:
| ...
v return ret;
}

The difference is
soc_compr_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_compr_free() and rollback.

Now, soc_compr_open/free() are handling
1) snd_soc_dai_compr_startup/shutdown()
2) snd_soc_component_compr_open/free()
3) snd_soc_link_compr_startup/shutdown()

Now, 1) to 3) are handled.
This patch adds new soc_compr_clean() and call it from
soc_compr_open() as rollback, and from soc_compr_free_free() as
normal close handler.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87ima25iwa.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# cd7c7d10 18-Nov-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-component: add mark for snd_soc_link_compr_startup/shutdown()

soc_compr_open() does rollback when failed (A),
but, it is almost same as soc_compr_free().

static int soc_compr_open(xxx)
{
...
if (ret < 0)
goto xxx_err;
...
return 0;

^ machine_err:
| ...
| out:
(A) ...
| pm_err:
| ...
v return ret;
}

The difference is
soc_compr_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_compr_free() and rollback.
1) snd_soc_dai_compr_startup/shutdown()
2) snd_soc_component_compr_open/free()
=> 3) snd_soc_link_compr_startup/shutdown()

This patch is for 3) snd_soc_link_compr_startup/shutdown()
and adds new cstream mark.
It will mark cstream when startup() was suceeded.
If rollback happen *after* that, it will check rollback flag
and marked cstream.

It cares *previous* startup() only now,
but we might want to check *whole* marked cstream in the future.
This patch is using macro so that it can be easily adjust to it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87k0ui5iwf.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# f94ba9ac 18-Nov-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-component: add mark for snd_soc_component_compr_open/free()

soc_compr_open() does rollback when failed (A),
but, it is almost same as soc_compr_free().

static int soc_compr_open(xxx)
{
...
if (ret < 0)
goto xxx_err;
...
return 0;

^ machine_err:
| ...
| out:
(A) ...
| pm_err:
| ...
v return ret;
}

The difference is
soc_compr_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_compr_free() and rollback.
1) snd_soc_dai_compr_startup/shutdown()
=> 2) snd_soc_component_compr_open/free()
3) snd_soc_link_compr_startup/shutdown()

This patch is for 2) snd_soc_component_compr_open/free(),
and adds new cstream mark.
It will mark cstream when startup() was suceeded.
If rollback happen *after* that, it will check rollback flag
and marked cstream.

It cares *previous* startup() only now,
but we might want to check *whole* marked cstream in the future.
This patch is using macro so that it can be easily adjust to it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87lfey5iwk.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 1e6a93cf 18-Nov-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-dai: add mark for snd_soc_dai_compr_startup/shutdown()

soc_compr_open() does rollback when failed (A),
but, it is almost same as soc_compr_free().

static int soc_compr_open(xxx)
{
...
if (ret < 0)
goto xxx_err;
...
return 0;

^ machine_err:
| ...
| out:
(A) ...
| pm_err:
| ...
v return ret;
}

The difference is
soc_compr_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_compr_free() and rollback.
=> 1) snd_soc_dai_compr_startup/shutdown()
2) snd_soc_component_compr_open/free()
3) snd_soc_link_compr_startup/shutdown()

This patch is for 1) snd_soc_dai_compr_startup/shutdown(),
and adds new cstream mark.
It will mark cstream when startup() was suceeded.
If rollback happen *after* that, it will check rollback flag
and marked cstream.

It cares *previous* startup() only now,
but we might want to check *whole* marked cstream in the future.
This patch is using macro so that it can be easily adjust to it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87mtze5iwp.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 15a7b8c1 18-Nov-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-compress: move soc_compr_free() next to soc_compr_open()

This patch moves soc_compr_free() next to soc_compr_open().
This is prepare for soc_compr_open() cleanup.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87o8ju5iwv.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# bab78c23 12-Nov-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-component: add snd_soc_component_compr_get_metadata()

component related function should be implemented at
soc-component.c.
This patch adds snd_soc_component_compr_get_metadata().

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/87zh3l6gl8.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 1b308fb1 12-Nov-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-component: add snd_soc_component_compr_set_metadata()

component related function should be implemented at
soc-component.c.
This patch adds snd_soc_component_compr_set_metadata().

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/871rgx7v5t.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# b5852e66 12-Nov-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-component: add snd_soc_component_compr_copy()

component related function should be implemented at
soc-component.c.
This patch adds snd_soc_component_compr_copy().

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/87361d7v5z.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 03ecea64 12-Nov-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-component: add snd_soc_component_compr_pointer()

component related function should be implemented at
soc-component.c.
This patch adds snd_soc_component_compr_pointer().

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/874klt7v65.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 0506b885 12-Nov-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-component: add snd_soc_component_compr_ack()

component related function should be implemented at
soc-component.c.
This patch adds snd_soc_component_compr_ack().

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/875z697v6c.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 0f6fe097 12-Nov-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-component: add snd_soc_component_compr_get_codec_caps()

component related function should be implemented at
soc-component.c.
This patch adds snd_soc_component_compr_get_codec_caps().

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/877dqp7v6i.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# d67fcb2d 12-Nov-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-component: add snd_soc_component_compr_get_caps()

component related function should be implemented at
soc-component.c.
This patch adds snd_soc_component_compr_get_caps().

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/878sb57v6q.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 77c221ec 12-Nov-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-component: add snd_soc_component_compr_get_params()

component related function should be implemented at
soc-component.c.
This patch adds snd_soc_component_compr_get_params().

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/87a6vl7v6x.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# ff08cf80 12-Nov-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-component: add snd_soc_component_compr_set_params()

component related function should be implemented at
soc-component.c.
This patch moves soc-compress soc_compr_components_set_params()
to soc-component as snd_soc_component_compr_set_params().

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/87blg17v74.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 08aee251 12-Nov-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-component: add snd_soc_component_compr_trigger()

component related function should be implemented at
soc-component.c.
This patch moves soc-compress soc_compr_components_trigger()
to soc-component as snd_soc_component_compr_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/87d00h7v7k.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# dbde5e21 12-Nov-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-component: add snd_soc_component_compr_free()

component related function should be implemented at
soc-component.c.
This patch moves soc-compress soc_compr_components_free()
to soc-component as snd_soc_component_compr_free().

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/87eekx7v7r.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# a4e427c5 12-Nov-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-component: add snd_soc_component_compr_open()

component related function should be implemented at
soc-component.c.
This patch moves soc-compress soc_compr_components_open()
to soc-component as snd_soc_component_compr_open().

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/87ft5d7v7x.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 7428d8c8 29-Oct-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-compress: assume SNDRV_PCM_STREAM_xxx and SND_COMPRESS_xxx are same

soc-compress.c is using both SND_COMPRESS_xxx and SND_PCM_STREAM_xxx.
These are defined as UAPI, and has same value.

enum {
SNDRV_PCM_STREAM_PLAYBACK = 0,
SNDRV_PCM_STREAM_CAPTURE,
...
};

enum snd_compr_direction {
SND_COMPRESS_PLAYBACK = 0,
SND_COMPRESS_CAPTURE
};

Essentially both COMPRESS and PCM_STREAM definitions are identical,
and can be never different because of ABI compatibility,
which means it's safe to mix both variants in the code.

This patch checks it by BUILD_BUG_ON(), and merge to use.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87361wmsyg.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# eb84959a 29-Oct-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-compress: tidyup STREAM vs COMPRESS

snd_soc_runtime_activate() and
snd_soc_dai_digital_mute() need SNDRV_PCM_STREAM_xxx
instead of SND_COMPRESS_xxx.

These are bug but nothing happen because these are same value.

enum {
SNDRV_PCM_STREAM_PLAYBACK = 0,
SNDRV_PCM_STREAM_CAPTURE,
...
};

enum snd_compr_direction {
SND_COMPRESS_PLAYBACK = 0,
SND_COMPRESS_CAPTURE
};

This patch tidyup it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/874kmcmsyn.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 939a5cfb 27-Sep-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-component: add mark for snd_soc_pcm_component_pm_runtime_get/put()

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>


# 1d5cd525 12-Jun-2020 Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

ASoC: soc-pcm/compress: reduce verbosity on mapping ok messages

With dynamic debug not enabled, we still get these messages:

[ 48.133586] sof_sdw sof_sdw: rt711-aif1 <-> SDW0 Pin2 mapping ok
[ 48.133595] sof_sdw sof_sdw: rt711-aif1 <-> SDW0 Pin3 mapping ok
[ 48.133650] sof_sdw sof_sdw: sdw:1:25d:1308:0 <-> SDW1 Pin2 mapping ok
[ 48.133658] sof_sdw sof_sdw: rt715-aif2 <-> SDW3 Pin2 mapping ok
[ 48.133666] sof_sdw sof_sdw: intel-hdmi-hifi1 <-> iDisp1 Pin mapping ok
[ 48.133672] sof_sdw sof_sdw: intel-hdmi-hifi2 <-> iDisp2 Pin mapping ok
[ 48.133677] sof_sdw sof_sdw: intel-hdmi-hifi3 <-> iDisp3 Pin mapping ok
[ 48.133712] sof_sdw sof_sdw: snd-soc-dummy-dai <-> Headphone 0 mapping ok
[ 48.133733] sof_sdw sof_sdw: snd-soc-dummy-dai <-> Headset mic 1 mapping ok
[ 48.133746] sof_sdw sof_sdw: snd-soc-dummy-dai <-> SDW1-speakers 2 mapping ok
[ 48.133762] sof_sdw sof_sdw: snd-soc-dummy-dai <-> Microphones 4 mapping ok
[ 48.133774] sof_sdw sof_sdw: snd-soc-dummy-dai <-> HDMI1 5 mapping ok
[ 48.133798] sof_sdw sof_sdw: snd-soc-dummy-dai <-> HDMI2 6 mapping ok
[ 48.133809] sof_sdw sof_sdw: snd-soc-dummy-dai <-> HDMI3 7 mapping ok

This is not really useful for most users, demote to dev_dbg()

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-4-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# eab810f3 24-May-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-link: add snd_soc_link_compr_set_params()

dai_link related function should be implemented at soc-link.c.
This patch adds snd_soc_link_compr_set_params().

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/87sgfo3k6q.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 0e532c99 24-May-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-link: add snd_soc_link_compr_shutdown()

dai_link related function should be implemented at soc-link.c.
This patch adds snd_soc_link_compr_shutdown().

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/87tv043k6u.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 9ab711cb 24-May-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-link: add snd_soc_link_compr_startup()

dai_link related function should be implemented at soc-link.c.
This patch adds snd_soc_link_compr_startup().

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/87v9kk3k6y.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# b3dea624 14-May-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: use snd_soc_xxx_active()

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>


# 94d72819 23-Apr-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-dai: add snd_soc_dai_compr_get_metadata()

dai related function should be implemented at soc-dai.c.
This patch adds snd_soc_dai_compr_get_metadata().

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/87eesdssi8.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 88b3a7df 23-Apr-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-dai: add snd_soc_dai_compr_set_metadata()

dai related function should be implemented at soc-dai.c.
This patch adds snd_soc_dai_compr_set_metadata().

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/87ftctssid.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# ed38cc59 23-Apr-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-dai: add snd_soc_dai_compr_pointer()

dai related function should be implemented at soc-dai.c.
This patch adds snd_soc_dai_compr_pointer().

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/87h7x9ssii.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 53294353 23-Apr-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-dai: add snd_soc_dai_compr_ack()

dai related function should be implemented at soc-dai.c.
This patch adds snd_soc_dai_compr_ack().

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/87imhpssim.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# adbef543 23-Apr-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-dai: add snd_soc_dai_compr_get_params()

dai related function should be implemented at soc-dai.c.
This patch adds snd_soc_dai_compr_get_params().

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/87k125ssir.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 8dfedafb 23-Apr-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-dai: add snd_soc_dai_compr_set_params()

dai related function should be implemented at soc-dai.c.
This patch adds snd_soc_dai_compr_set_params().

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/87lfmlssiv.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# eb08411b 23-Apr-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-dai: add snd_soc_dai_compr_trigger()

dai related function should be implemented at soc-dai.c.
This patch adds snd_soc_dai_compr_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/87mu71ssiz.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 2b25f81d 23-Apr-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-dai: add snd_soc_dai_compr_shutdown()

dai related function should be implemented at soc-dai.c.
This patch adds snd_soc_dai_compr_shutdown().

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/87o8rhssj3.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# b5ae4cce 23-Apr-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-dai: add snd_soc_dai_compr_start()

dai related function should be implemented at soc-dai.c.
This patch adds snd_soc_dai_compr_start().

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/87pnbxssj7.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 3e645a4a 23-Apr-2020 Rong Chen <rong.a.chen@intel.com>

ASoC: soc-compress: avoid false-positive Wuninitialized warning

gcc-6.5 and earlier show a new warning:

sound/soc/soc-compress.c: In function ‘soc_compr_open’:
sound/soc/soc-compress.c:75:28: warning: ‘component’ is used uninitialized in this function [-Wuninitialized]
struct snd_soc_component *component, *save = NULL;
^~~~~~~~~

Simplest fix is to initialize it to avoid the warning.

Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Rong Chen <rong.a.chen@intel.com>
Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/lkml/202004201540.vYPhhYMs%25lkp@intel.com
Link: https://lore.kernel.org/r/20200424005437.3941-1-rong.a.chen@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# e7cbe528 20-Apr-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-compress: remove snd_compr_ops

snd_compr_ops couldn't care called component,
but now we can care it via snd_compress_ops.
All drivers switched to it.
This patch removes snd_compr_ops.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87lfmqvdig.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# c6cb522c 20-Apr-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-compress: add snd_compress_ops

Current snd_soc_component_driver has compr_ops, and each driver can
have callback via it. But, it is mainly created for ALSA, thus, it
doesn't have "component" as parameter.
Thus, each callback can't know it is called for which component.
Each callback currently is getting "component" by using
snd_soc_rtdcom_lookup() with driver name.

--- ALSA SoC ---
...
if (component->driver->compr_ops &&
component->driver->compr_ops->open)
=> return component->driver->compr_ops->open(stream);
...

--- driver ---
static int xxx_open(struct snd_compr_stream *stream)
{
struct snd_soc_pcm_runtime *rtd = stream->private_data;
=> struct snd_soc_component *component = snd_soc_rtdcom_lookup(..);
...
}

It works today, but, will not work in the future if we support multi
CPU/Codec/Platform, because 1 rtd might have multiple same driver
name component.

To solve this issue, each callback need to be called with component.
We already have many component driver callbacks.
This patch adds new snd_compress_ops, and call it with "component".

--- ALSA SoC ---
...
if (component->driver->compress_ops->open)
=> return component->driver->compress_ops->open(
component, substream);
~~~~~~~~~
...

--- driver ---
static int xxx_open(struct snd_soc_component *component,
struct snd_compr_stream *stream)
{
=> /* it don't need to use snd_soc_rtdcom_lookup() */
...
}

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87v9luvdmh.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# c2233a26 29-Mar-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc: use asoc_rtd_to_cpu() / asoc_rtd_to_codec() macro for DAI pointer

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/87imimboli.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 6e1276a5 25-Feb-2020 Bard Liao <yung-chuan.liao@linux.intel.com>

ASoC: Return error if the function does not support multi-cpu

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>


# 1c531230 20-Feb-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-pcm/soc-compress: don't use snd_soc_dapm_stream_stop()

commit b0edff42360ab4 ("ASoC: soc-pcm/soc-compress: use
snd_soc_dapm_stream_stop() for SND_SOC_DAPM_STREAM_STOP")
uses snd_soc_dapm_stream_stop() for soc_compr_free_fe()
and dpcm_fe_dai_shutdown() because it didn't care about pmdown_time.
But, it didn't need to care.
This patch rollback to original code.
Some system will wait unneeded timed-out without this patch.
Special Thanks for reporting to Chris Gorman.
...
intel_sst_acpi 808622A8:00: Wait timed-out condition:0x0, msg_id:0x1 fw_state 0x3
intel_sst_acpi 808622A8:00: fw returned err -16
sst-mfld-platform sst-mfld-platform: ASoC: PRE_PMD: pcm0_in event failed: -16
...

Fixes: commit b0edff42360ab4 ("ASoC: soc-pcm/soc-compress: use snd_soc_dapm_stream_stop() for SND_SOC_DAPM_STREAM_STOP")
Reported-by: Chris Gorman <chrisjohgorman@gmail.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87lfowspeb.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# b0edff42 09-Jan-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-pcm/soc-compress: use snd_soc_dapm_stream_stop() for SND_SOC_DAPM_STREAM_STOP

dpcm_fe_dai_shutdown() / soc_compr_free_fe() didn't care pmdown_time.
We already have snd_soc_dapm_stream_stop() for it.
Let's use common method.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87zhewrq9j.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 3f4cf797 09-Jan-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-dapm: add snd_soc_dapm_stream_stop()

When we stop stream, if it was Playback, we might need to care
about power down time. In such case, we need to use delayed work.

We have same implementation for it at soc-pcm.c and soc-compress.c,
but we don't want to have duplicate code.
This patch adds snd_soc_dapm_stream_stop(), and share same code.

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/871rs8t4uw.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 83f94a2e 09-Jan-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-core: add snd_soc_close_delayed_work()

We need to setup rtd->close_delayed_work_func.
It will be set at snd_soc_dai_compress_new() or soc_new_pcm().
But these setups close_delayed_work() which is same name /
same implemantaion, but different local code.
To reduce duplicate code, this patch moves it as
snd_soc_close_delayed_work() and share same code.

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/8736cot4v2.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 613fb500 09-Jan-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-core: remove snd_soc_rtdcom_list

Current ALSA SoC is using struct snd_soc_rtdcom_list to
connecting component to rtd by using list_head.

struct snd_soc_rtdcom_list {
struct snd_soc_component *component;
struct list_head list; /* rtd::component_list */
};

struct snd_soc_pcm_runtime {
...
struct list_head component_list; /* list of connected components */
...
};

The CPU/Codec/Platform component which will be connected to rtd (a)
is indicated via dai_link at snd_soc_add_pcm_runtime()

int snd_soc_add_pcm_runtime(...)
{
...
/* Find CPU from registered CPUs */
rtd->cpu_dai = snd_soc_find_dai(dai_link->cpus);
...
(a) snd_soc_rtdcom_add(rtd, rtd->cpu_dai->component);
...

/* Find CODEC from registered CODECs */
(b) for_each_link_codecs(dai_link, i, codec) {
rtd->codec_dais[i] = snd_soc_find_dai(codec);
...
(a) snd_soc_rtdcom_add(rtd, rtd->codec_dais[i]->component);
}
...

/* Find PLATFORM from registered PLATFORMs */
(b) for_each_link_platforms(dai_link, i, platform) {
for_each_component(component) {
...
(a) snd_soc_rtdcom_add(rtd, component);
}
}

}

It shows, it is possible to know how many components will be
connected to rtd by using

dai_link->num_cpus
dai_link->num_codecs
dai_link->num_platforms

If so, we can use component pointer array instead of list_head,
in such case, code can be more simple.
This patch removes struct snd_soc_rtdcom_list that is only
of temporary value, and convert to pointer array.

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/87a76wt4wm.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 4137f4b6 17-Dec-2019 Cezary Rojewski <cezary.rojewski@intel.com>

ASoC: compress: Add pm_runtime support

For some devices, components need to be powered-up before stream startup
sequence commences. Update soc_compr_open to provide such functionality.
Based on soc_pcm_open. Adjust soc_compr_free accordingly to power down
components once compress stream is closed.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20191217095851.19629-7-cezary.rojewski@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 4bf2e385 03-Dec-2019 Curtis Malainey <cujomalainey@chromium.org>

ASoC: core: Init pcm runtime work early to avoid warnings

There are cases where we fail before we reach soc_new_pcm which would
init the workqueue. When we fail we attempt to flush the queue which
generates warnings from the workqueue subsystem when we have not inited
the queue. Solution is to use a proxy function to get around this issue.

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20191203173007.46504-1-cujomalainey@chromium.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# 2b544dd7 14-Oct-2019 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-core: add for_each_rtd_components() and replace

ALSA SoC has for_each_rtdcom() which is link list for
rtd-component which is called as rtdcom. The relationship image is like below

rtdcom rtdcom rtdcom
component component component
rtd->component_list -> list -> list -> list ...

Here, the pointer get via normal link list is rtdcom,
Thus, current for_each loop is like below, and need to get
component via rtdcom->component

for_each_rtdcom(rtd, rtdcom) {
component = rtdcom->component;
...
}

but usually, user want to get pointer from for_each_xxx is component
directly, like below.

for_each_rtd_component(rtd, rtdcom, component) {
...
}

This patch expands list_for_each_entry manually, and enable to get
component directly from for_each macro.
Because of it, the macro becoming difficult to read,
but macro itself becoming useful.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/878spm64m4.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 72b745e3 13-Aug-2019 Peter Ujfalusi <peter.ujfalusi@ti.com>

ASoC: core: Move pcm_mutex up to card level from snd_soc_pcm_runtime

The pcm_mutex is used to prevent concurrent execution of snd_pcm_ops
callbacks. This works fine most of the cases but it can not handle setups
when the same DAI is used by different rtd, for example:
pcm3168a have two DAIs: one for Playback and one for Capture.
If the codec is connected to a single CPU DAI we need to have two dai_link
to support both playback and capture.

In this case the snd_pcm_ops callbacks can be executed in parallel causing
unexpected races in DAI drivers.

By moving the pcm_mutex up to card level this can be solved
while - hopefully - not breaking other setups.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Tested-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20190813104532.16669-1-peter.ujfalusi@ti.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 467fece8 21-Jul-2019 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-dai: move snd_soc_dai_stream_valid() to soc-dai.c

snd_soc_dai_stream_valid() is function to check stream validity.
But, some code is using it, some code are checking stream->channels_min
directly. Doing samethings by different method is confusable.
This patch uses same funcntion for same purpose.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87ftmyhmzz.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 09f448a4 17-Jun-2019 Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>

ASoC: compress: Fix memory leak from snd_soc_new_compress

Change kzalloc to devm_kzalloc, so compr gets automatically freed when
it's no longer needed.

Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 4ef0ecb8 05-Feb-2019 Charles Keepax <ckeepax@opensource.cirrus.com>

ASoC: compress: Add helper functions for component trigger/set_params

The trigger and set_params callbacks are called from 3 and 2 separate
loops respectively, tidy up the code a little by factoring these out
into helper functions.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 52cadf1f 05-Feb-2019 Charles Keepax <ckeepax@opensource.cirrus.com>

ASoC: compress: Clarify the intent of current compressed ops handling

For callbacks configuring the state of the components (trigger,
set_params, ack and set_metadata) simplify the code a little and make
intention clearer by aborting as soon as an error is encountered. The
operation has already failed and there is nothing to be gained from
processing the callbacks on additional components. The operations
currently abort after the callbacks, so this simply shortens the
error path.

For callbacks returning information from the driver (copy,
get_metadata, pointer, get_codec_caps, get_caps and get_params)
only look for the first callback provided, currently the code will
call every callback only returning the information provided by the
last. Since we can only return one set of data, it makes no sense to
request the data from every component. Again this just makes the
currently supported feature set a little more clear.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 8d6258a4 17-Sep-2018 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: add for_each_dpcm_be() macro

To be more readable code, this patch adds
new for_each_dpcm_be() macro, and replace existing code to it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 0b0722e1 03-Aug-2018 Srinivas Kandagatla <srinivas.kandagatla@linaro.org>

ASoC: compress: make BE and FE order inline with dpcm

For some reason order of startup/hw_params/prepare are reversed
in dynamic compress usecase when compared to dpcm usecase. This is
a issue with platforms like QCOM where it expects the BE to be
initialized before FE.

Interestingly the compress trigger callback order is inline with dpcm.

Am not 100% sure why the compress audio case has been reversed.
This patch is making the order inline with dpcm.

If the reverse ordering is just co-incendental then this change
makes sense and will avoid inventing some new mechanism to cope
with ordering.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>


# b3ed4c86 02-Jul-2018 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: soc-compress: convert to SPDX identifiers

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 89027d9e 26-Apr-2018 Charles Keepax <ckeepax@opensource.cirrus.com>

ASoC: compress: Fix up some trivial formatting issues

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Acked-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Mark Brown <broonie@kernel.org>


# ca76db6c 26-Apr-2018 Charles Keepax <ckeepax@opensource.cirrus.com>

ASoC: compress: Only assign compr->ops->copy once

There are only one set of ops on the compressed stream so no need to
reassign the copy callback repeatedly, stop after copy is seen to be
necessary.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Acked-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 1e57b828 24-Apr-2018 Charles Keepax <ckeepax@opensource.cirrus.com>

ASoC: compress: Add helper functions for component open/free

There are 2 loops calling open and 4 loops calling free for all the
components on a DAI link. Factor out these loops into helper functions
to make the code a little clearer.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Acked-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Mark Brown <broonie@kernel.org>


# ef050bec 24-Apr-2018 Charles Keepax <ckeepax@opensource.cirrus.com>

ASoC: Remove platform code now everything is componentised

As all drivers have been moved over to the new generic component
code remove the now unused platform specific code.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Acked-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 572e6c8d 24-Apr-2018 Charles Keepax <ckeepax@opensource.cirrus.com>

ASoC: compress: Only call free for components which have been opened

The core should only call free on a component if said component has
already had open called on it. This is not presently the case and most
compressed drivers in the kernel assume it will be. This causes null
pointer dereferences in the drivers as they attempt clean up for stuff
that was never put in place.

This is fixed by aborting calling open callbacks once a failure is
encountered and then during clean up only iterating through the
component list to that point.

This is a fairly quick fix to the issue, to allow backporting. There
is more refactoring to follow to tidy the code up a little.

Fixes: 9e7e3738ab0e ("ASoC: snd_soc_component_driver has snd_compr_ops")
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Acked-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 141dfc9e 26-Jan-2018 Charles Keepax <ckeepax@opensource.cirrus.com>

ASoC: compress: Fixup error messages

The error message prints are a little inconsisent, tidy them up to be a
little more consistent with current style recommendations.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# b2154d72 26-Jan-2018 Charles Keepax <ckeepax@opensource.cirrus.com>

ASoC: compress: Remove some extraneous blank lines

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 290df4d3 26-Jan-2018 Charles Keepax <ckeepax@opensource.cirrus.com>

ASoC: compress: Correct handling of copy callback

The soc_compr_copy callback is currently broken. Since the
changes to move the compr_ops over to the component the return
value is not correctly propagated, always returning zero on
success rather than the number of bytes copied. This causes
user-space to stall continuously reading as it does not believe
it has received any data.

Furthermore, the changes to move the compr_ops over to the
component iterate through the list of components and will call
the copy callback for any that have compressed ops. There isn't
currently any consensus on the mechanism to combine the results
of multiple copy callbacks.

To fix this issue for now halt searching the component list when
we locate a copy callback and return the result of that single
callback. Additional work should probably be done to look at the
other ops, tidy things up, and work out if we want to support
multiple components on a single compressed, but this is the only
fix required to get things working again.

Fixes: 9e7e3738ab0e ("ASoC: snd_soc_component_driver has snd_compr_ops")
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org


# e5acfc7d 04-Dec-2017 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: don't use rtd->codec on snd_soc_new_compress()

rtd->codec will be removed soon.
rtd->codec = rtd->codec_dai->codec, thus,
we can use rtd->codec_dai->component instead of it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 9e7e3738 10-Oct-2017 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: snd_soc_component_driver has snd_compr_ops

Platform will be replaced into Component in the future.
snd_soc_platform_driver has snd_compr_ops, but snd_soc_component_driver
doesn't have. To prepare for replacing, this patch adds snd_compr_ops on
component driver.

platform will be replaced into component, and its code will be removed.
But during replacing, both platform and component process code exists.
To keep compatibility, to avoid platform NULL access and to avoid
platform/component duplicate operation during replacing process, this
patch has such code. Some of this code will be removed when platform was
removed.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# aeb6fa0f 16-Aug-2017 Peng Donglin <dolinux.peng@gmail.com>

ASoC: compress: Set reasonable compress id string

For dynamic compress rtd, the codec_dai may not have any actual
meaning(like snd-soc-dummy-dai), so compress id can just use the
value of dai_link->stream_name. But for others, its codec_dai
has actual meaning, so compress id can include codec_dai name.

Signed-off-by: Peng Donglin <dolinux.peng@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 7a0cf42e 10-Aug-2017 Markus Elfring <elfring@users.sourceforge.net>

ASoC: compress: Delete error messages for a failed memory allocation in snd_soc_new_compress()

Omit extra messages for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 01b8cedf 16-Jun-2017 Satish Babu Patakokila <sbpata@codeaurora.org>

ASoC: compress: Derive substream from stream based on direction

Currently compress driver hardcodes direction as playback to get
substream from the stream. This results in getting the incorrect
substream for compressed capture usecase.
To fix this, remove the hardcoding and derive substream based on
the stream direction.

Signed-off-by: Satish Babu Patakokila <sbpata@codeaurora.org>
Signed-off-by: Banajit Goswami <bgoswami@codeaurora.org>
Acked-By: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org


# 2e622ae4 12-Nov-2016 Vinod Koul <vkoul@kernel.org>

ASoC: compress: Add support for compress dai ops

ASoC Compress ops have only platform ops and no DAI ops unlike PCM device
where we have both platform ops as well as DAI ops.

So add compress dai ops and add this new structure to the ASoC core to make
compressed devices a first class ASoC citizen

Again like PCM ops, drivers are free to implement either or both of
these ops based on device needs.

Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# b0f12c61 16-Aug-2016 Charles Keepax <ckeepax@opensource.wolfsonmicro.com>

ASoC: compress: Fix leak of a widget list in soc_compr_open_fe

After we have called dpcm_path_get we should make sure to call
dpcm_path_put on all error paths. This was not happening causing the
allocated widget list to be leaked, this patch corrects this by adding a
dpcm_path_put to the error path.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 7c9190f7 20-Jun-2016 Charles Keepax <ckeepax@opensource.wolfsonmicro.com>

ASoC: compress: Pass error out of soc_compr_pointer

Both soc_compr_pointer and the platform driver pointer callback return
ints but current soc_compr_pointer always returns 0. Update this so we
return the actual value from the platform driver callback. This doesn't
fix any issues simply makes the code more consistent.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# a1068045 07-Jan-2016 Vinod Koul <vkoul@kernel.org>

ASoC: compress: Fix compress device direction check

The detection of direction for compress was only taking into account codec
capabilities and not CPU ones. Fix this by checking the CPU side capabilities
as well

Cc: <stable@vger.kernel.org>
Tested-by: Ashish Panwar <ashish.panwar@intel.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# e5241a8c 25-Nov-2015 Richard Fitzgerald <rf@opensource.wolfsonmicro.com>

ALSA: compress: Pass id string to snd_compress_new

Make snd_compress_new take an id string (like snd_pcm_new).
This string can be included in the procfs info.

This patch also updates soc_new_compress() to create an ID
based on the stream and dai name, as done for PCM streams.

Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 6f0c4226 13-Oct-2015 Jie Yang <yang.jie@intel.com>

ASoC: compress: add config item for soc-compress to make it compiled only when needed

We don't always need soc-compress in soc, here add a config item
SND_SOC_COMPRESS, when nobody select it, the soc-compress will
not be compiled.

Here also change Kconfig to 'select SND_SOC_COMPRESS' for drivers
that needed soc-compress.

Signed-off-by: Jie Yang <yang.jie@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# d3268a40 14-Jan-2015 Qais Yousef <qsyousef@gmail.com>

ASoC: soc-compress.c: fix NULL dereference

In soc_new_compress() when rtd->dai_link->dynamic is set, we create the pcm
substreams with this call:

ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, num,
1, 0, &be_pcm);

which passes 0 as capture_count leading to

be_pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream

being NULL, hence when trying to set rtd a few lines below we get an oops.

Fix by using rtd->dai_link->dpcm_playback and rtd->dai_link->dpcm_capture as
playback_count and capture_count to snd_pcm_new_internal().

Signed-off-by: Qais Yousef <qais.yousef@imgtec.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org


# 15f6b09a 19-Oct-2014 Daniel Mack <daniel@zonque.org>

ASoC: soc-compress: consolidate two identical branches

The actions taken in both branches are identical, so we can simplify the
code. Spotted by Coverity.

Signed-off-by: Daniel Mack <daniel@zonque.org>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 2e4ec1c0 11-Sep-2014 Qiao Zhou <zhouqiao@marvell.com>

ASoC: soc-compress: fix double unlock of fe card mutex

Fix double unlock of fe card mutex introduced by patch 8f70e515a8bb
"ASoC: soc-pcm: fix dpcm_path_get error handling"

The first unlock is at line 106, and the unlock is at line 149. we
should remove the first unlock.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Qiao Zhou <zhouqiao@marvell.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 8f70e515 10-Sep-2014 Qiao Zhou <zhouqiao@marvell.com>

ASoC: soc-pcm: fix dpcm_path_get error handling

dpcm_path_get may return -ENOMEM when allocating memory for list
fails. We should not keep processing path or start up dpcm dai in
this case.

Signed-off-by: Qiao Zhou <zhouqiao@marvell.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 8151d5e6 08-Jul-2014 Benoit Cousson <bcousson@baylibre.com>

ASoC: compress: Prevent multicodec for compressed stream

Multiple codecs does not make sense in the case of compressed
stream.

Exit with error if it happens.

Signed-off-by: Benoit Cousson <bcousson@baylibre.com>
Tested-by: Lars-Peter Clausen <lars@metafoo.de>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# f4333203 16-Jun-2014 Lars-Peter Clausen <lars@metafoo.de>

ASoC: Move name and id from CODEC/platform to component

The component struct already has a name and id field which are initialized to
the same values as the same fields in the CODEC and platform structs. So remove
them from the CODEC and platform structs and used the ones from the component
struct instead.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 15b8e94f 14-May-2014 Dan Carpenter <dan.carpenter@oracle.com>

ASoC: compress: indent an if statement

The return statement was not indented correctly. I lined up the
condition a bit as well.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 797f283b 06-May-2014 Lars-Peter Clausen <lars@metafoo.de>

ASoC: Remove runtime field from DAI

This was initially removed in commit 6423c1875 ("ASoC: Remove runtime field from
DAI"), but was, presumably by accident, brought back in commit f0fba2ad1 ("ASoC:
multi-component - ASoC Multi-Component Support"). But has never been
initialized to anything but NULL ever since. This commit removes it again.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 24894b76 05-Mar-2014 Lars-Peter Clausen <lars@metafoo.de>

ASoC: Add helper functions for PCM runtime 'active' management

We have the same code that increments and decrements the active field of the
various PCM runtime components (all with the same bugs). Factor this out into
common helper functions.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 208a1589 05-Mar-2014 Lars-Peter Clausen <lars@metafoo.de>

ASoC: Handle ignore_pmdown_time for CODEC to CODEC links

For CODEC to CODEC links we should only immediately power down if both CODECs
are configured to ignore the power down delay. Factor the logic for this
into a helper function that can be used for both compressed and normal PCMs.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 2a99ef0f 17-Jan-2014 Liam Girdwood <liam.r.girdwood@linux.intel.com>

ASoC: compress: Add suport for DPCM into compressed audio

Currently compressed audio streams are statically routed from the /dev
to the DAI link. Some DSPs can route compressed data to multiple BE DAIs
like they do for PCM data.

Add support to allow dynamically routed compressed streams using the existing
DPCM infrastructure. This patch adds special FE versions of the compressed ops
that work out the runtime routing.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 3d24cfe4 09-Aug-2013 Mark Brown <broonie@linaro.org>

ASoC: compress: Use power efficient workqueue

There is no need for the power down work to be done on a per CPU workqueue
especially considering the fairly long delay before powerdown.

Signed-off-by: Mark Brown <broonie@linaro.org>
Acked-by: Vinod Koul <vinod.koul@intel.com>


# 02bd90e8 28-Jul-2013 Vinod Koul <vkoul@kernel.org>

ASoC: compress: use soc_xxx handlers for metadata

the compress metadata handlers were wrongly named sst_xxx

Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 2c071ed7 20-May-2013 Charles Keepax <ckeepax@opensource.wolfsonmicro.com>

ASoC: soc-compress: Send correct stream event for capture start

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>


# daa2db59 18-Apr-2013 Charles Keepax <ckeepax@opensource.wolfsonmicro.com>

ASoC: soc-compress: Deduce stream direction

Previously we just hard coded all streams as playback streams, this
patch checks the DAI to see if it is a capture or playback stream. It is
worth noting that at this time only unidirectional streams are
supported.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 4daf891c 18-Apr-2013 Charles Keepax <ckeepax@opensource.wolfsonmicro.com>

ALSA: compress_core: Deconstify copy callback buffer

The buffer passed to the copy callback should not be const because the
copy callback can be used for capture and playback.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# fa40ef20 27-Mar-2013 Charles Keepax <ckeepax@opensource.wolfsonmicro.com>

ASoC: compress: Cancel delayed power down if needed

When a new stream is being opened it is necessary to cancel any delayed
power down of the audio.

[Fixed unused variable -- broonie]

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>


# 36953d98 26-Mar-2013 Jeeja KP <jeeja.kp@intel.com>

ASoC: compress - add support for metadata apis

Compress core added metadata apis in 9727b4, so add same in ASoC

Signed-off-by: Jeeja KP <jeeja.kp@intel.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>


# da18396f 06-Feb-2013 Mark Brown <broonie@opensource.wolfsonmicro.com>

ASoC: core: Allow digital mute for capture

Help avoid noise from the power up of the capture path propagating through
into the start of the recording (especially noise caused by the ramp of
microphone biases) by keeping the capture muted until after we've finished
powering things up with DAPM in the same manner we do for playback. This
allows us to take advantage of soft mute support in the hardware more
effectively and is more consistent.

The core code using the existing digital mute operation is updated to take
advantage of this. Some additional cases in the soc-pcm code and suspend
will need separate handling but these are less practically relevant than
the main runtime stream start/stop case.

Rather than refactor the digital mute function in every single driver a
new operation is added for drivers taking advantage of this functionality,
the old operation should be phased out over time.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by Vinod Koul <vinod.koul@intel.com>
Acked-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>


# e38b9b74 06-Feb-2013 Mark Brown <broonie@opensource.wolfsonmicro.com>

ASoC: compress: Only mute playback streams

Otherwise capture activity on a compressed DAI would mute any playback
on the same DAI.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Acked-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>


# 1f88eb0f 05-Feb-2013 Charles Keepax <ckeepax@opensource.wolfsonmicro.com>

ASoC: soc-compress: Add support for not memory mapped DSPs

The ASoC compressed API did not implement the copy callback in its
compressed ops which is required for DSPs that are not memory mapped.

This patch creates a local copy of the compress ops for each runtime and
modifies them with a copy callback as appropriate.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>


# 202c8f70 24-Jan-2013 Charles Keepax <ckeepax@opensource.wolfsonmicro.com>

ASoC: soc-compress: Initialise delayed work to power down audio

Delayed work was scheduled but not initialised, this patch adds the
actual work and initialises it.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Tested-by: Jeeja KP <jeeja.kp@intel.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>


# 15e2e619 24-Jan-2013 Charles Keepax <ckeepax@opensource.wolfsonmicro.com>

ASoC: soc-compress: Serialise compressed ops

Use the pcm_mutex to serialise the compressed ops.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Tested-by: Jeeja KP <jeeja.kp@intel.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>


# 8c3d2aa4 24-Jan-2013 Charles Keepax <ckeepax@opensource.wolfsonmicro.com>

ASoC: soc-compress: Add missing brackets around else

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Tested-by: Jeeja KP <jeeja.kp@intel.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>


# 9bffb1fb 12-Dec-2012 Misael Lopez Cruz <misael.lopez@ti.com>

ASoC: Prevent pop_wait overwrite

pop_wait is used to determine if a deferred playback close
needs to be cancelled when the a PCM is open or if after
the power-down delay expires it needs to run. pop_wait is
associated with the CODEC DAI, so the CODEC DAI must be
unique. This holds true for most CODECs, except for the
dummy CODEC and its DAI.

In DAI links with non-unique dummy CODECs (e.g. front-ends),
pop_wait can be overwritten by another DAI link using also a
dummy CODEC. Failure to cancel a deferred close can cause
mute due to the DAPM STOP event sent in the deferred work.

One scenario where pop_wait is overwritten and causing mute
is below (where hw:0,0 and hw:0,1 are two front-ends with
default pmdown_time = 5 secs):

aplay /dev/urandom -D hw:0,0 -c 2 -r 48000 -f S16_LE -d 1
sleep 1
aplay /dev/urandom -D hw:0,1 -c 2 -r 48000 -f S16_LE -d 3 &
aplay /dev/urandom -D hw:0,0 -c 2 -r 48000 -f S16_LE

Since CODECs may not be unique, pop_wait is moved to the PCM
runtime structure. Creating separate dummy CODECs for each
DAI link can also solve the problem, but at this point it's
only pop_wait variable in the CODEC DAI that has negative
effects by not being unique.

Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>


# 1be437fa 20-Aug-2012 Sachin Kamat <sachin.kamat@linaro.org>

ASoC: soc-compress: Remove unused variable

codec_dai is not used in the function.

sound/soc/soc-compress.c: In function ‘soc_compr_set_params’:
sound/soc/soc-compress.c:156:22: warning:
unused variable ‘codec_dai’ [-Wunused-variable]

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>


# 9d2667a9 20-Aug-2012 Vinod Koul <vkoul@kernel.org>

ASoC: compress - fix code alignment

Reported-by: Fengguang Wu <wfg@linux.intel.com>
Signed-off-by: Namarta Kohli <namartax.kohli@intel.com>
Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>


# 1245b700 16-Aug-2012 Namarta Kohli <namartax.kohli@intel.com>

ASoC: add compress stream support

This patch adds the support to parse the compress dai's and then also adds the
soc-compress.c file while handles the compress stream operations, mostly analogus
to what is done in the soc-pcm.c and aditional handling of the compress
opertaions

Signed-off-by: Namarta Kohli <namartax.kohli@intel.com>
Signed-off-by: Ramesh Babu K V <ramesh.babu@intel.com>
Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>