sfrench/cifs-2.6.git
4 years agoMerge branch 'for-5.4' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie...
Mark Brown [Wed, 6 Nov 2019 16:29:34 +0000 (16:29 +0000)]
Merge branch 'for-5.4' of https://git./linux/kernel/git/broonie/sound into asoc-5.5

4 years agoASoC: soc-core: fixup dead-lock at snd_soc_unregister_component()
Kuninori Morimoto [Wed, 6 Nov 2019 07:05:05 +0000 (16:05 +0900)]
ASoC: soc-core: fixup dead-lock at snd_soc_unregister_component()

snd_soc_unregister_component() is calling snd_soc_lookup_component()
under mutex_lock(). But, snd_soc_lookup_component() itself is using
mutex_lock(), thus it will be dead-lock.
This patch adds _nolocked version of it, and avoid dead-lock issue.

Fixes: ac6a4dd3e9f0("ASoC: soc-core: use snd_soc_lookup_component() at snd_soc_unregister_component()")
Reported-by: "kernelci.org bot" <bot@kernelci.org>"
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87bltph4da.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: soc-core: fix RIP warning on card removal
Pierre-Louis Bossart [Wed, 6 Nov 2019 14:58:01 +0000 (08:58 -0600)]
ASoC: soc-core: fix RIP warning on card removal

SOF module load/unload tests show nasty recurring warnings:

WARNING: CPU: 5 PID: 1339 at sound/core/control.c:466
snd_ctl_remove+0xf0/0x100 [snd]
RIP: 0010:snd_ctl_remove+0xf0/0x100 [snd]

This regression was introduced by the removal of the call to
soc_remove_link_components() before soc_card_free() is invoked.

Go back to the initial order but only call
soc_remove_link_components() once.

Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Fixes: 5a4c9f054ceea ("ASoC: soc-core: snd_soc_unbind_card() cleanup")
GitHub issue: https://github.com/thesofproject/linux/issues/1424
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191106145801.9316-1-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: SOF: topology: Fix bytes control size checks
Dragos Tarcatu [Wed, 6 Nov 2019 14:58:16 +0000 (08:58 -0600)]
ASoC: SOF: topology: Fix bytes control size checks

When using the example SOF amp widget topology, KASAN dumps this
when the AMP bytes kcontrol gets loaded:

[ 9.579548] BUG: KASAN: slab-out-of-bounds in
sof_control_load+0x8cc/0xac0 [snd_sof]
[ 9.588194] Write of size 40 at addr ffff8882314559dc by task
systemd-udevd/2411

Fix that by rejecting the topology if the bytes data size > max_size

Fixes: 311ce4fe7637d ("ASoC: SOF: Add support for loading topologies")
Reviewed-by: Jaska Uimonen <jaska.uimonen@intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Dragos Tarcatu <dragos_tarcatu@mentor.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191106145816.9367-1-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: soc.h: dobj is used only when SND_SOC_TOPOLOGY
Kuninori Morimoto [Tue, 5 Nov 2019 06:47:26 +0000 (15:47 +0900)]
ASoC: soc.h: dobj is used only when SND_SOC_TOPOLOGY

snd_soc_dobj is used only when SND_SOC_TOPOLOGY was selected.
Let's enable it under SND_SOC_TOPOLOGY.

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/87o8xq251d.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: soc-core: remove topology specific operation
Kuninori Morimoto [Tue, 5 Nov 2019 06:47:22 +0000 (15:47 +0900)]
ASoC: soc-core: remove topology specific operation

soc-core has some API which is used from topology, but it is doing
topology specific operation at soc-core.
soc-core should care about core things, and topology should care
about topology things, otherwise, it is very confusable.

For example topology type is not related to soc-core,
it is topology side issue.

This patch removes meaningless check from soc-core.

This patch keeps extra initialization/destruction at
snd_soc_add_dai_link() / snd_soc_remove_dai_link()
which were for topology.
From this patch, non-topology card can 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/87pni6251h.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: soc-core: call snd_soc_register_dai() from snd_soc_register_dais()
Kuninori Morimoto [Tue, 5 Nov 2019 06:47:18 +0000 (15:47 +0900)]
ASoC: soc-core: call snd_soc_register_dai() from snd_soc_register_dais()

ALSA SoC has 2 functions.
snd_soc_register_dai()  is used from topology
snd_soc_register_dais() is used from snd_soc_add_component()

In general, people think like _dai() is called from _dais()
with for loop. But in reality, these are very similar
but different implementation.
We shouldn't have duplicated and confusing implementation.

This patch calls snd_soc_register_dai() from snd_soc_register_dais()

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/87r22m251l.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: soc-core: don't call snd_soc_dapm_new_dai_widgets() at snd_soc_register_dai()
Kuninori Morimoto [Tue, 5 Nov 2019 06:47:14 +0000 (15:47 +0900)]
ASoC: soc-core: don't call snd_soc_dapm_new_dai_widgets() at snd_soc_register_dai()

ALSA SoC has 2 functions.
snd_soc_register_dai()  is used from topology
snd_soc_register_dais() is used from snd_soc_add_component()

In general, people think like _dai() is called from _dais()
with for loop. But in reality, these are very similar
but different implementation.
We shouldn't have duplicated and confusing implementation.

snd_soc_register_dai() is now used from topology.
But to reduce duplicated code, it should be used from _dais(), too.

Because of topology side specific reason,
it is calling snd_soc_dapm_new_dai_widgets(),
but it is not needed _dais() side.

This patch factorizes snd_soc_register_dai() to
topology / _dais() common part, and topology specific part.
And do topology specific part at soc-topology.

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/87sgn2251p.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: soc-core: have legacy_dai_naming at snd_soc_register_dai()
Kuninori Morimoto [Tue, 5 Nov 2019 06:47:09 +0000 (15:47 +0900)]
ASoC: soc-core: have legacy_dai_naming at snd_soc_register_dai()

ALSA SoC has 2 functions.
snd_soc_register_dai()  is used from topology
snd_soc_register_dais() is used from snd_soc_add_component()

In general, people think like _dai() is called from _dais()
with for loop. But in reality, these are very similar
but different implementation.
We shouldn't have duplicated and confusing implementation.

snd_soc_register_dai() is now used from topology.
But to reduce duplicated code, it should be used from _dais(), too.
To prepare it, this patch adds missing parameter legacy_dai_naming
to snd_soc_register_dai().

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/87tv7i251u.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: soc-core: add snd_soc_unregister_dai()
Kuninori Morimoto [Tue, 5 Nov 2019 06:47:04 +0000 (15:47 +0900)]
ASoC: soc-core: add snd_soc_unregister_dai()

It is easy to read code if it is cleanly using paired function/naming,
like start <-> stop, register <-> unregister, etc, etc.
But, current ALSA SoC code is very random, unbalance, not paired, etc.
It is easy to create bug at the such code, and is difficult to debug.

This patch adds missing soc_del_dai() and snd_soc_unregister_dai().

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/87v9ry251z.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: soc-core: move snd_soc_unregister_dais()
Kuninori Morimoto [Tue, 5 Nov 2019 06:47:00 +0000 (15:47 +0900)]
ASoC: soc-core: move snd_soc_unregister_dais()

This patch moves snd_soc_unregister_dais() next to
snd_soc_register_dais().
This is prepare for snd_soc_register_dais() 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/87woce2524.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: soc-core: move snd_soc_register_dai()
Kuninori Morimoto [Tue, 5 Nov 2019 06:46:55 +0000 (15:46 +0900)]
ASoC: soc-core: move snd_soc_register_dai()

This patch moves snd_soc_register_dai() next to
snd_soc_register_dais().
This is prepare for snd_soc_register_dais() 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/87y2wu2528.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: soc-core: use snd_soc_lookup_component() at snd_soc_unregister_component()
Kuninori Morimoto [Tue, 5 Nov 2019 06:46:51 +0000 (15:46 +0900)]
ASoC: soc-core: use snd_soc_lookup_component() at snd_soc_unregister_component()

snd_soc_unregister_component() is now finding component manually,
but we already have snd_soc_lookup_component() to find component;
Let's use existing function.

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/87zhha252c.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: soc-core: remove snd_soc_component_add/del()
Kuninori Morimoto [Tue, 5 Nov 2019 06:46:45 +0000 (15:46 +0900)]
ASoC: soc-core: remove snd_soc_component_add/del()

soc-core has
snd_soc_add_component(), snd_soc_component_add(),
snd_soc_del_component(), snd_soc_component_del().

These are very confusing naming.
snd_soc_component_xxx() are called from snd_soc_xxx_component(),
and these are very small.
Let's merge these into snd_soc_xxx_component(), and
remove snd_soc_component_xxx().

Reported-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
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/871rum3jmy.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: soc-core: add snd_soc_del_component_unlocked()
Kuninori Morimoto [Tue, 5 Nov 2019 06:46:39 +0000 (15:46 +0900)]
ASoC: soc-core: add snd_soc_del_component_unlocked()

It is easy to read code if it is cleanly using paired function/naming,
like start <-> stop, register <-> unregister, etc, etc.
But, current ALSA SoC code is very random, unbalance, not paired, etc.
It is easy to create bug at the such code, and is difficult to debug.

Now ALSA SoC has snd_soc_add_component(), but there is no paired
snd_soc_del_component(). Thus, snd_soc_unregister_component() is
calling cleanup function randomly. it is difficult to read.
This patch adds missing snd_soc_del_component_unlocked() and
balance up code.

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/8736f23jn4.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: soc-core: tidyup snd_soc_lookup_component()
Kuninori Morimoto [Tue, 5 Nov 2019 06:46:35 +0000 (15:46 +0900)]
ASoC: soc-core: tidyup snd_soc_lookup_component()

snd_soc_lookup_component() is using mix of continue and break
in the same loop. It is odd.
This patch cleanup it.

Reported-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
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/874kzi3jn8.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: soc-core: move snd_soc_lookup_component()
Kuninori Morimoto [Tue, 5 Nov 2019 06:46:30 +0000 (15:46 +0900)]
ASoC: soc-core: move snd_soc_lookup_component()

This patch moves snd_soc_lookup_component() to upper side.
This is prepare for snd_soc_unregister_component()

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/875zjy3jnd.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: soc-core: add soc_unbind_dai_link()
Kuninori Morimoto [Tue, 5 Nov 2019 06:46:25 +0000 (15:46 +0900)]
ASoC: soc-core: add soc_unbind_dai_link()

It is easy to read code if it is cleanly using paired function/naming,
like start <-> stop, register <-> unregister, etc, etc.
But, current ALSA SoC code is very random, unbalance, not paired, etc.
It is easy to create bug at the such code, and it will be difficult to
debug.

ALSA SoC has soc_bind_dai_link(), but its paired soc_unbind_dai_link()
is not implemented.
More confusable is that soc_remove_pcm_runtimes() which should be
soc_unbind_dai_link() is implemented without synchronised
to soc_bind_dai_link().

This patch cleanup this unbalance.

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/877e4e3jni.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: soc-core: call soc_bind_dai_link() under snd_soc_add_dai_link()
Kuninori Morimoto [Tue, 5 Nov 2019 06:46:20 +0000 (15:46 +0900)]
ASoC: soc-core: call soc_bind_dai_link() under snd_soc_add_dai_link()

If we focus to soc_bind_dai_link() at snd_soc_instantiate_card(),
we will notice very complex operation.

static int snd_soc_instantiate_card(...)
{
...
/*
 * (1) Bind dai_link via card pre-linked dai_link
 *
 * Bind dai_link via card pre-linked.
 * 1 dai_link will be 1 rtd, and connected to card.
 * for_each_card_prelinks() is for card pre-linked dai_link.
 *
 * Image
 *
 * card
 * - rtd(A)
 * - rtd(A)
 */
for_each_card_prelinks(card, i, dai_link) {
ret = soc_bind_dai_link(card, dai_link);
...
}
...
/*
 * (2) Connect card pre-linked dai_link to card list
 *
 * Connect all card pre-linked dai_link to *card list*.
 * Here, (A) means from card pre-linked.
 *
 * Image
 *
 * card card list
 *  - rtd(A)  - dai_link(A)
 *  - rtd(A)  - dai_link(A)
 *  - ...  - ...
 */
for_each_card_prelinks(card, i, dai_link) {
ret = snd_soc_add_dai_link(card, dai_link);
...
}
...
/*
 * (3) Probe binded component
 *
 * Each rtd has many components.
 * Here probes each rtd connected components.
 * rtd(A) in Image is the probe target.
 *
 * During this component probe, topology may add new dai_link to
 * *card list* by using snd_soc_add_dai_link() which is
 * used at (2).
 * Here, (B) means from topology
 *
 * Image
 *
 * card card list
 *  - rtd(A)  - dai_link(A)
 *  - rtd(A)  - dai_link(A)
 *  - ...  - ...
 *  - dai_link(B)
 *  - dai_link(B)
 */
ret = soc_probe_link_components(card);
...

/*
 * (4) Bind dai_link again
 *
 * Bind dai_link again for topology.
 * Note, (1) used for_each_card_prelinks(),
 * here is using  for_each_card_links()
 *
 * This means from card list.
 * As Image indicating, it has dai_link(A) (from card pre-link)
 * and dai_link(B) (from topology).
 * main target here is dai_link(B).
 * soc_bind_dai_link() ignores already used
 * dai_link (= dai_link(A))
 *
 * Image
 *
 * card card list
 *  - rtd(A)  - dai_link(A)
 *  - rtd(A)  - dai_link(A)
 *  - ...  - ...
 *  - rtd(B)  - dai_link(B)
 *  - rtd(B)  - dai_link(B)
 */
for_each_card_links(card, dai_link) {
ret = soc_bind_dai_link(card, dai_link);
...
}
...
}

As you see above, it is doing very complex method.
The problem is binding dai_link via "card pre-linked" (= (1)) and
"topology added dai_link" (= (3)) are separated.
The code can be simple if we can bind dai_link when dai_link
is connected to *card list*.
This patch do 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/878sou3jnn.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: soc-core: remove duplicated soc_is_dai_link_bound()
Kuninori Morimoto [Tue, 5 Nov 2019 06:46:15 +0000 (15:46 +0900)]
ASoC: soc-core: remove duplicated soc_is_dai_link_bound()

soc_is_dai_link_bound() check will be called both
*before* soc_bind_dai_link() (A), and
*under*  soc_bind_dai_link() (B).
These are very verbose code. Let's remove one of them.

* static int soc_bind_dai_link(...)
{
...
(B) if (soc_is_dai_link_bound(...)) {
...
return 0;
}
...
}

static int snd_soc_instantiate_card(...)
{
...
for_each_card_links(...) {
(A) if (soc_is_dai_link_bound(...))
continue;

* ret = soc_bind_dai_link(...);
if (ret)
goto probe_end;
}
...
}

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/87a79a3jns.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: soc-core: typo fix at soc_dai_link_sanity_check()
Kuninori Morimoto [Tue, 5 Nov 2019 06:46:00 +0000 (15:46 +0900)]
ASoC: soc-core: typo fix at soc_dai_link_sanity_check()

Reported-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
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/87bltq3jo7.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: soc-core: tidyup soc_init_dai_link()
Kuninori Morimoto [Tue, 5 Nov 2019 06:45:50 +0000 (15:45 +0900)]
ASoC: soc-core: tidyup soc_init_dai_link()

soc_init_dai_link() is needed to be called before soc_bind_dai_link().

int snd_soc_instantiate_card()
{
for_each_card_prelinks(...) {
(1) ret = soc_init_dai_link(...);
...
}
...
for_each_card_prelinks(...) {
(2) ret = soc_bind_dai_link(...);
...
}
...
for_each_card_links(...) {
...
(A) ret = soc_init_dai_link(...);
...
(B) ret = soc_bind_dai_link(...);
}
...

(1) is for (2), and (A) is for (B)
(1) and (2) are for card prelink   dai_link.
(A) and (B) are for topology added dai_link.

soc_init_dai_link() is sanity check for dai_link, not initializing today.
Therefore, it is confusable naming. We can rename it as sanity_check.

And this check is for soc_bind_dai_link().
It can be more simple code if we can call it from soc_bind_dai_link().

This patch renames it to soc_dai_link_sanity_check(), and
call it from soc_bind_dai_link().

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/87d0e63joh.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: soc-core: move soc_init_dai_link()
Kuninori Morimoto [Tue, 5 Nov 2019 06:45:41 +0000 (15:45 +0900)]
ASoC: soc-core: move soc_init_dai_link()

This patch moves soc_init_dai_link() next to soc_bind_dai_link().
This is prepare for soc_bind_dai_link() 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/87eeym3joq.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: adau7118: Fix example warning
Maxime Ripard [Tue, 5 Nov 2019 10:56:15 +0000 (11:56 +0100)]
ASoC: adau7118: Fix example warning

The ADAU7118 has an example where the codec has an i2c address of 14, and
the unit address set to 14 as well.

However, while the address is expressed in decimal, the unit-address is
supposed to be in hexadecimal, which ends up with two different addresses
that trigger a DTC warning. Fix this by setting the address to 0x14.

Cc: Nuno Sá <nuno.sa@analog.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Fixes: 969d49b2cdc8 ("dt-bindings: asoc: Add ADAU7118 documentation")
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Acked-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20191105105615.21391-1-maxime@cerno.tech
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: SOF: topology: set trigger order for FE DAI link
Ranjani Sridharan [Mon, 4 Nov 2019 22:48:12 +0000 (14:48 -0800)]
ASoC: SOF: topology: set trigger order for FE DAI link

Set trigger order for FE DAI links to SND_SOC_DPCM_TRIGGER_POST
to trigger the BE DAI's before the FE DAI's. This prevents the
xruns seen on playback pipelines using the link DMA.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191104224812.3393-3-ranjani.sridharan@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: pcm: update FE/BE trigger order based on the command
Ranjani Sridharan [Mon, 4 Nov 2019 22:48:11 +0000 (14:48 -0800)]
ASoC: pcm: update FE/BE trigger order based on the command

Currently, the trigger orders SND_SOC_DPCM_TRIGGER_PRE/POST
determine the order in which FE DAI and BE DAI are triggered.
In the case of SND_SOC_DPCM_TRIGGER_PRE, the FE DAI is
triggered before the BE DAI and in the case of
SND_SOC_DPCM_TRIGGER_POST, the BE DAI is triggered before
the FE DAI. And this order remains the same irrespective of the
trigger command.

In the case of the SOF driver, during playback, the FW
expects the BE DAI to be triggered before the FE DAI during
the START trigger. The BE DAI trigger handles the starting of
Link DMA and so it must be started before the FE DAI is started
to prevent xruns during pause/release. This can be addressed
by setting the trigger order for the FE dai link to
SND_SOC_DPCM_TRIGGER_POST. But during the STOP trigger,
the FW expects the FE DAI to be triggered before the BE DAI.
Retaining the same order during the START and STOP commands,
results in FW error as the DAI component in the FW is still
active.

The issue can be fixed by mirroring the trigger order of
FE and BE DAI's during the START and STOP trigger. So, with the
trigger order set to SND_SOC_DPCM_TRIGGER_PRE, the FE DAI will be
trigger first during SNDRV_PCM_TRIGGER_START/STOP/RESUME
and the BE DAI will be triggered first during the
STOP/SUSPEND/PAUSE commands. Conversely, with the trigger order
set to SND_SOC_DPCM_TRIGGER_POST, the BE DAI will be triggered
first during the SNDRV_PCM_TRIGGER_START/STOP/RESUME commands
and the FE DAI will be triggered first during the
SNDRV_PCM_TRIGGER_STOP/SUSPEND/PAUSE commands.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191104224812.3393-2-ranjani.sridharan@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: max98373: replace gpio_request with devm_gpio_request
Yong Zhi [Mon, 4 Nov 2019 22:09:59 +0000 (16:09 -0600)]
ASoC: max98373: replace gpio_request with devm_gpio_request

Use devm_gpio_request() to automatic unroll when fails and avoid
resource leaks at error paths.

Signed-off-by: Yong Zhi <yong.zhi@intel.com>
Link: https://lore.kernel.org/r/1572905399-22402-1-git-send-email-yong.zhi@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: stm32: sai: add restriction on mmap support
Olivier Moysan [Mon, 4 Nov 2019 13:36:54 +0000 (14:36 +0100)]
ASoC: stm32: sai: add restriction on mmap support

Do not support mmap in S/PDIF mode. In S/PDIF mode
the buffer has to be copied, to allow the channel status
bits insertion.

Signed-off-by: Olivier Moysan <olivier.moysan@st.com>
Link: https://lore.kernel.org/r/20191104133654.28750-1-olivier.moysan@st.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: Intel: boards: sof_rt5682: use dependency on SOF_HDA_LINK
Pierre-Louis Bossart [Fri, 1 Nov 2019 17:30:45 +0000 (12:30 -0500)]
ASoC: Intel: boards: sof_rt5682: use dependency on SOF_HDA_LINK

The wrong dependency is used and the build can be broken

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191101173045.27099-12-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: Intel: boards: Geminilake is only supported by SOF
Pierre-Louis Bossart [Fri, 1 Nov 2019 17:30:44 +0000 (12:30 -0500)]
ASoC: Intel: boards: Geminilake is only supported by SOF

Geminilake machine drivers are only tested and recommended with SOF.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191101173045.27099-11-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: Intel: boards: fix configs for bxt-da7219-max98057a
Pierre-Louis Bossart [Fri, 1 Nov 2019 17:30:43 +0000 (12:30 -0500)]
ASoC: Intel: boards: fix configs for bxt-da7219-max98057a

The same driver is reused for 3 different configurations, but the
driver will only be build if ApolloLake is selected.

Fix and make sure each device can work without dependencies on others
(useful for minimal configurations).

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191101173045.27099-10-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: Intel: boards: remove select SND_HDA_DSP_LOADER
Pierre-Louis Bossart [Fri, 1 Nov 2019 17:30:42 +0000 (12:30 -0500)]
ASoC: Intel: boards: remove select SND_HDA_DSP_LOADER

This option is only required with the Skylake platform driver, there
is no reason to have this option in machine drivers. This is
e.g. useless for SOF-based solutions.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191101173045.27099-9-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: Intel: Skylake: mark HDAudio codec support as deprecated.
Pierre-Louis Bossart [Fri, 1 Nov 2019 17:30:41 +0000 (12:30 -0500)]
ASoC: Intel: Skylake: mark HDAudio codec support as deprecated.

This option famously broke audio on Linus' laptop and the problem have
not been fixed.

Mark as DEPRECATED to avoid any ambiguity with distros.

Use SOF if you need HDaudio support w/ the DSP enabled, e.g. for DMIC
capture.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191101173045.27099-8-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: SOF: Intel: use def_tristate, avoid using select
Pierre-Louis Bossart [Fri, 1 Nov 2019 17:30:40 +0000 (12:30 -0500)]
ASoC: SOF: Intel: use def_tristate, avoid using select

So far we used select to use the relevant built-in/module options, but
this led to blurring layers between core and Intel Kconfigs.

Use def_tristate works just as well and removes Intel stuff from the code.

Suggested-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191101173045.27099-7-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: SOF: imx: fix reverse CONFIG_SND_SOC_SOF_OF dependency
Pierre-Louis Bossart [Fri, 1 Nov 2019 17:30:39 +0000 (12:30 -0500)]
ASoC: SOF: imx: fix reverse CONFIG_SND_SOC_SOF_OF dependency

updated solution to the problem reported with randconfig:

CONFIG_SND_SOC_SOF_IMX depends on CONFIG_SND_SOC_SOF, but is in
turn referenced by the sof-of-dev driver. This creates a reverse
dependency that manifests in a link error when CONFIG_SND_SOC_SOF_OF
is built-in but CONFIG_SND_SOC_SOF_IMX=m:

sound/soc/sof/sof-of-dev.o:(.data+0x118): undefined reference to `sof_imx8_ops'

use def_trisate to propagate the right settings without select.

Fixes: f4df4e4042b0 ("ASoC: SOF: imx8: Fix COMPILE_TEST error")
Fixes: 202acc565a1f ("ASoC: SOF: imx: Add i.MX8 HW support")
Suggested-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191101173045.27099-6-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: SOF: Kconfig: add EXPERT dependency for developer options, clarify help
Pierre-Louis Bossart [Fri, 1 Nov 2019 17:30:38 +0000 (12:30 -0500)]
ASoC: SOF: Kconfig: add EXPERT dependency for developer options, clarify help

Some distros select all possible options, despite existing warnings to
be careful. This leads to e.g. user reports that the HDaudio codec and
DMIC are not handled by SOF.

Add an explicit menu item to unlock developer options, and make them
dependent on CONFIG_EXPERT. Hopefully with this double-lock these
options will only be selected by developers.

GitHub issue: https://github.com/thesofproject/sof/issues/1885
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191101173045.27099-5-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: Intel: add mutual exclusion between SOF and legacy Baytrail driver
Pierre-Louis Bossart [Fri, 1 Nov 2019 17:30:37 +0000 (12:30 -0500)]
ASoC: Intel: add mutual exclusion between SOF and legacy Baytrail driver

This legacy driver is already deprecated, let's make sure there is no
conflict with SOF.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191101173045.27099-4-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: SOF: Intel: Broadwell: clarify mutual exclusion with legacy driver
Pierre-Louis Bossart [Fri, 1 Nov 2019 17:30:36 +0000 (12:30 -0500)]
ASoC: SOF: Intel: Broadwell: clarify mutual exclusion with legacy driver

Some distros select all options blindly, which leads to confusion and
bug reports. SOF does not fully support Broadwell due to firmware
dependencies, the machine drivers can only support one option, and
UCM/topology files are still being propagated to downstream distros,
so make SOF on Broadwell an opt-in option that first require distros
to opt-out of existing defaults.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=204237
Fixes: f35bf70f61d3 ('ASoC: Intel: Make sure BDW based machine drivers build for SOF')
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191101173045.27099-3-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: SOF: Intel: Baytrail: clarify mutual exclusion with Atom/SST driver
Pierre-Louis Bossart [Fri, 1 Nov 2019 17:30:35 +0000 (12:30 -0500)]
ASoC: SOF: Intel: Baytrail: clarify mutual exclusion with Atom/SST driver

Some distros select all options blindly, which leads to confusion and
bug reports. Since SOF does not support Baytrail-CR for now, and
UCM/topology files are still being propagated to downstream distros,
make SOF on Baytrail an opt-in option that first require distros to
opt-out of existing defaults.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191101173045.27099-2-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: SOF: Intel: hda: Simplify the hda_dsp_wait_d0i3c_done() function
Ranjani Sridharan [Fri, 1 Nov 2019 17:09:16 +0000 (12:09 -0500)]
ASoC: SOF: Intel: hda: Simplify the hda_dsp_wait_d0i3c_done() function

Remove the retry argument for the hda_dsp_wait_d0i3c_done()
function and use the HDA_DSP_REG_POLL_RETRY_COUNT macro
directly.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191101170916.26517-4-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: Intel: boards: Add CML m/c using RT1011 and RT5682
Naveen Manohar [Fri, 1 Nov 2019 17:18:47 +0000 (12:18 -0500)]
ASoC: Intel: boards: Add CML m/c using RT1011 and RT5682

Machine driver to enable
RT5682 on SSP0, DMIC, HDMI and
RT1011 AMP on SSP1 with
2 CH / 24 bit TDM Playback over 4 individual codecs and
4 CH / 24 bit Capture to provide feedback.

Signed-off-by: Naveen Manohar <naveen.m@intel.com>
Signed-off-by: Sathya Prakash M R <sathya.prakash.m.r@intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191101171847.26767-3-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: Intel: Add acpi match for rt1011 based m/c driver
Naveen Manohar [Fri, 1 Nov 2019 17:18:46 +0000 (12:18 -0500)]
ASoC: Intel: Add acpi match for rt1011 based m/c driver

Add match for CML m/c with RT1011 and RT5682

Signed-off-by: Naveen Manohar <naveen.m@intel.com>
Signed-off-by: Sathya Prakash M R <sathya.prakash.m.r@intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191101171847.26767-2-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: ux500: Remove redundant variable "status"
zhong jiang [Thu, 31 Oct 2019 13:34:15 +0000 (21:34 +0800)]
ASoC: ux500: Remove redundant variable "status"

local variable "status" is not used. hence it is safe to remove and
just return 0.

Signed-off-by: zhong jiang <zhongjiang@huawei.com>
Link: https://lore.kernel.org/r/1572528855-25990-1-git-send-email-zhongjiang@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: hdac_hda: fix race in device removal
Kai Vehmanen [Fri, 1 Nov 2019 17:06:35 +0000 (12:06 -0500)]
ASoC: hdac_hda: fix race in device removal

When ASoC card instance is removed containing a HDA codec,
hdac_hda_codec_remove() may run in parallel with codec resume.
This will cause problems if the HDA link is freed with
snd_hdac_ext_bus_link_put() while the codec is still in
middle of its resume process.

To fix this, change the order such that pm_runtime_disable()
is called before the link is freed. This will ensure any
pending runtime PM action is completed before proceeding
to free the link.

This issue can be easily hit with e.g. SOF driver by loading and
unloading the drivers.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191101170635.26389-1-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: rt1011: some minor changes to improve readability
Shuming Fan [Thu, 31 Oct 2019 11:54:46 +0000 (19:54 +0800)]
ASoC: rt1011: some minor changes to improve readability

There is no other code use the RT1011_INIT_REG_LEN definition,
except rt1011_reg_init().
Hence, we remove it and fix the typo.

Signed-off-by: Shuming Fan <shumingf@realtek.com>
Link: https://lore.kernel.org/r/20191031115446.21108-1-shumingf@realtek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: rt1011: add the range check for temperature_calib from device property
Shuming Fan [Thu, 31 Oct 2019 11:54:36 +0000 (19:54 +0800)]
ASoC: rt1011: add the range check for temperature_calib from device property

The driver will check the range for temperature_calib.
It should be from 1 to 255.

Signed-off-by: Shuming Fan <shumingf@realtek.com>
Link: https://lore.kernel.org/r/20191031115436.21055-1-shumingf@realtek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: rt1011: remove unnecessary tabs using spaces instead
Shuming Fan [Thu, 31 Oct 2019 11:54:25 +0000 (19:54 +0800)]
ASoC: rt1011: remove unnecessary tabs using spaces instead

There are unnecessary tabs inside some statements.
It uses sapces instead.

Signed-off-by: Shuming Fan <shumingf@realtek.com>
Link: https://lore.kernel.org/r/20191031115425.21003-1-shumingf@realtek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: rt1011: improve the rt1011_set_dai_fmt() function
Shuming Fan [Thu, 31 Oct 2019 11:54:14 +0000 (19:54 +0800)]
ASoC: rt1011: improve the rt1011_set_dai_fmt() function

If there is a wrong format setting,
the driver will goto the end of the function directly.

Signed-off-by: Shuming Fan <shumingf@realtek.com>
Link: https://lore.kernel.org/r/20191031115414.20951-1-shumingf@realtek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: rt1011: remove redundant code in kcontrol
Shuming Fan [Thu, 31 Oct 2019 11:54:01 +0000 (19:54 +0800)]
ASoC: rt1011: remove redundant code in kcontrol

The !component->card->instantiated statement should remove in kcontrol.
It is no need to check the card->instantiated in kcontrol.

Signed-off-by: Shuming Fan <shumingf@realtek.com>
Link: https://lore.kernel.org/r/20191031115401.20898-1-shumingf@realtek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: dt-bindings: rt5682: add button delay device property
Shuming Fan [Wed, 30 Oct 2019 08:55:56 +0000 (16:55 +0800)]
ASoC: dt-bindings: rt5682: add button delay device property

The btndet-delay device property could control the HW debounce time.
It is easy to adjust the sensitivity of push button.

Signed-off-by: Shuming Fan <shumingf@realtek.com>
Link: https://lore.kernel.org/r/20191030085556.14351-1-shumingf@realtek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: rt5682: improve the sensitivity of push button
Shuming Fan [Wed, 30 Oct 2019 08:55:33 +0000 (16:55 +0800)]
ASoC: rt5682: improve the sensitivity of push button

The sensitivity could improve by decreasing the HW debounce time
and reduce the delay time of workequeue.
This patch added a device property for HW debounce time control.
We could change this value to tune the sensitivity of push button.

Signed-off-by: Shuming Fan <shumingf@realtek.com>
Link: https://lore.kernel.org/r/20191030085533.14299-1-shumingf@realtek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: soc-core: remove unneeded snd_soc_tplg_component_remove()
Kuninori Morimoto [Wed, 30 Oct 2019 01:26:10 +0000 (10:26 +0900)]
ASoC: soc-core: remove unneeded snd_soc_tplg_component_remove()

snd_soc_tplg_component_remove() is pair of snd_soc_tplg_component_load(),
and it is topology related cleanup function.

The driver which called _load() needs to call _remove() by its responsibility.
Today, skl-pcm and topology are the user, and these are calling both
_load() and _remove().

soc-core doesn't need to call it.
This patch remove it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/8736fbdnwt.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: rt5677-spi: fixup compile warning
Kuninori Morimoto [Wed, 30 Oct 2019 06:14:58 +0000 (15:14 +0900)]
ASoC: rt5677-spi: fixup compile warning

This patch fixup this warning

LINUX/sound/soc/codecs/rt5677-spi.c: In function ‘rt5677_spi_pcm_close’:
LINUX/sound/soc/codecs/rt5677-spi.c:114:30: warning: unused variable ‘rtd’ [-Wunused-variable]
  struct snd_soc_pcm_runtime *rtd = substream->private_data;
                              ^~~

Fixes: a0e0d135427c ("ASoC: rt5677: Add a PCM device for streaming hotword via SPI")
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87a79idajh.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: Intel: bxt_rt298: common hdmi codec support
Kai Vehmanen [Tue, 29 Oct 2019 13:40:17 +0000 (15:40 +0200)]
ASoC: Intel: bxt_rt298: common hdmi codec support

Add support for using snd-hda-codec-hdmi driver for HDMI/DP
instead of ASoC hdac-hdmi. This is aligned with how other
HDA codecs are already handled.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191029134017.18901-10-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: intel: sof_rt5682: common hdmi codec support
Kai Vehmanen [Tue, 29 Oct 2019 13:40:16 +0000 (15:40 +0200)]
ASoC: intel: sof_rt5682: common hdmi codec support

Add support for using snd-hda-codec-hdmi driver for HDMI/DP
instead of ASoC hdac-hdmi. This is aligned with how other
HDA codecs are already handled.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191029134017.18901-9-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: Intel: glk_rt5682_max98357a: common hdmi codec support
Kai Vehmanen [Tue, 29 Oct 2019 13:40:15 +0000 (15:40 +0200)]
ASoC: Intel: glk_rt5682_max98357a: common hdmi codec support

Add support for using snd-hda-codec-hdmi driver for HDMI/DP
instead of ASoC hdac-hdmi. This is aligned with how other
HDA codecs are already handled.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191029134017.18901-8-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: Intel: bxt-da7219-max98357a: common hdmi codec support
Kai Vehmanen [Tue, 29 Oct 2019 13:40:14 +0000 (15:40 +0200)]
ASoC: Intel: bxt-da7219-max98357a: common hdmi codec support

Add support for using snd-hda-codec-hdmi driver for HDMI/DP
instead of ASoC hdac-hdmi. This is aligned with how other
HDA codecs are already handled.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191029134017.18901-7-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: SOF: Intel: add support for snd-hda-codec-hdmi
Kai Vehmanen [Tue, 29 Oct 2019 13:40:13 +0000 (15:40 +0200)]
ASoC: SOF: Intel: add support for snd-hda-codec-hdmi

Add support to implement HDMI/DP audio by using the common
snd-hda-codec-hdmi driver.

Change of codec driver affects user-space as the two
drivers expose different mixer controls. A new kernel
module option "use_common_hdmi" is added to user-space
to indicate which interface should be used. The default
driver can be selected via a Kconfig option.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191029134017.18901-6-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: Intel: skl-hda-dsp-generic: fix include guard name
Kai Vehmanen [Tue, 29 Oct 2019 13:40:12 +0000 (15:40 +0200)]
ASoC: Intel: skl-hda-dsp-generic: fix include guard name

Match the include guard define to actual filename. The source
directory now has an actual hda_dsp_common.h header, so the old
include guard may cause confusion.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191029134017.18901-5-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: Intel: skl-hda-dsp-generic: use snd-hda-codec-hdmi
Kai Vehmanen [Tue, 29 Oct 2019 13:40:11 +0000 (15:40 +0200)]
ASoC: Intel: skl-hda-dsp-generic: use snd-hda-codec-hdmi

Add support for using snd-hda-codec-hdmi driver for HDMI/DP
instead of ASoC hdac-hdmi. This is aligned with how other
HDA codecs are already handled.

When snd-hda-codec-hdmi is used, the PCM device numbers are
parsed from card topology and passed to the codec driver.
This needs to be done at runtime as topology changes may
affect PCM device allocation.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191029134017.18901-4-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: hdac_hda: add support for HDMI/DP as a HDA codec
Kai Vehmanen [Tue, 29 Oct 2019 13:40:10 +0000 (15:40 +0200)]
ASoC: hdac_hda: add support for HDMI/DP as a HDA codec

Handle all HDA codecs using same logic, including HDMI/DP.

Call to snd_hda_codec_build_controls() is delayed for HDMI/DP HDA
devices. This is needed to discover the PCM device numbers as
defined in topology.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191029134017.18901-3-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoALSA: hda/hdmi - implement mst_no_extra_pcms flag
Kai Vehmanen [Tue, 29 Oct 2019 13:40:09 +0000 (15:40 +0200)]
ALSA: hda/hdmi - implement mst_no_extra_pcms flag

To support the DP-MST multiple streams via single connector feature,
the HDMI driver was extended with the concept of backup PCMs. See
commit 9152085defb6 ("ALSA: hda - add DP MST audio support").

This implementation works fine with snd_hda_intel.c as PCM topology
is fully managed within the single driver.

When the HDA codec driver is used from ASoC components, the concept
of backup PCMs no longer fits. For ASoC topologies, the physical
HDMI converters are presented as backend DAIs and these should match
with hardware capabilities. The ASoC topology may define arbitrary
PCMs (i.e. frontend DAIs) and have processing elements before eventual
routing to the HDMI BE DAIs. With backup PCMs, the link between
FE and BE DAIs would become dynamic and change when monitors are
(un)plugged. This would lead to modifying the topology every time
hotplug events happen, which is not currently possible in ASoC and
there does not seem to be any obvious benefits from this design.

To overcome above problems and enable the HDMI driver to be used
from ASoC, this patch adds a new mode (mst_no_extra_pcms flags) to
patch_hdmi.c. In this mode, the codec driver does not assume
the backup PCMs to be created.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191029134017.18901-2-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: rockchip_max98090: Add HDMI jack support
Cheng-Yi Chiang [Mon, 28 Oct 2019 07:19:28 +0000 (15:19 +0800)]
ASoC: rockchip_max98090: Add HDMI jack support

In machine driver, create a jack and let hdmi-codec report jack status.

Signed-off-by: Cheng-Yi Chiang <cychiang@chromium.org>
Link: https://lore.kernel.org/r/20191028071930.145899-5-cychiang@chromium.org
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: rockchip_max98090: Optionally support HDMI use case
Cheng-Yi Chiang [Mon, 28 Oct 2019 07:19:27 +0000 (15:19 +0800)]
ASoC: rockchip_max98090: Optionally support HDMI use case

Support three different use cases with rockchip_max98090 driver.

The three use cases:
- max98090 only: Current usage, where HDMI link is missing.
- HDMI only: Needed use case for veyron_mickey board.
- max98090 + HDMI: Ideal use case for veyron_jerry, veyron_minnie..etc.

The presence of max98090 is determined by the presence of
rockchip,audio-codec device property.

The presence of HDMI is determined by the presence of
rockchip,hdmi-codec device property.

Create different sound card based on the configuration.
Note that we keep max98090 only usage for backward compatibility.

Signed-off-by: Cheng-Yi Chiang <cychiang@chromium.org>
Link: https://lore.kernel.org/r/20191028071930.145899-4-cychiang@chromium.org
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: rockchip-max98090: Support usage with and without HDMI
Cheng-Yi Chiang [Mon, 28 Oct 2019 07:19:26 +0000 (15:19 +0800)]
ASoC: rockchip-max98090: Support usage with and without HDMI

Add one optional property "rockchip,hdmi-codec" to let user specify HDMI
device node in DTS so machine driver can find hdmi-codec device node for
HDMI codec DAI.

Use the presence of rockchip,audio-codec and rockchip,hdmi-codec to
specify the use case.

Use max98090 only : specify rockchip,audio-codec.
Use HDMI only: specify rockchip,hdmi-codec.
Use both max98090 and HDMI: specify rockchip,audio-codec and
rockchip,hdmi-codec.

Move these properties to optional because they are not needed for
HDMI-only use case.
"rockchip,audio-codec": The phandle of the MAX98090 audio codec
"rockchip,headset-codec": The phandle of Ext chip for jack detection

Signed-off-by: Cheng-Yi Chiang <cychiang@chromium.org>
Link: https://lore.kernel.org/r/20191028071930.145899-3-cychiang@chromium.org
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agodrm: bridge: dw-hdmi: Report connector status using callback
Cheng-Yi Chiang [Mon, 28 Oct 2019 07:19:25 +0000 (15:19 +0800)]
drm: bridge: dw-hdmi: Report connector status using callback

Allow codec driver register callback function for plug event.

The callback registration flow:
dw-hdmi <--- hw-hdmi-i2s-audio <--- hdmi-codec

dw-hdmi-i2s-audio implements hook_plugged_cb op
so codec driver can register the callback.

dw-hdmi exports a function dw_hdmi_set_plugged_cb so platform device
can register the callback.

When connector plug/unplug event happens, report this event using the
callback.

Make sure that audio and drm are using the single source of truth for
connector status.

Signed-off-by: Cheng-Yi Chiang <cychiang@chromium.org>
Link: https://lore.kernel.org/r/20191028071930.145899-2-cychiang@chromium.org
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: SOF - remove the dead code (skylake/kabylake)
Jaroslav Kysela [Mon, 28 Oct 2019 17:33:29 +0000 (18:33 +0100)]
ASoC: SOF - remove the dead code (skylake/kabylake)

Appearently the CONFIG_SND_SOC_SOF_KABYLAKE and CONFIG_SND_SOC_SOF_SKYLAKE
options are not present in Kconfig and 'struct snd_sof_dsp_ops sof_skl_ops'
is not declared in the code, too.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20191028173329.29538-1-perex@perex.cz
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: intel - fix the card names
Jaroslav Kysela [Mon, 28 Oct 2019 16:46:24 +0000 (17:46 +0100)]
ASoC: intel - fix the card names

Those strings are exposed to the user space as the
card name thus used in the GUIs. The common
standard is to avoid '_' here. The worst case
is 'sof-skl_hda_card' string.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Mark Brown <broonie@kernel.org>
Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191028164624.14334-1-perex@perex.cz
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: SOF: pci: Add prepare/complete PM callbacks
Keyon Jie [Fri, 25 Oct 2019 22:41:22 +0000 (17:41 -0500)]
ASoC: SOF: pci: Add prepare/complete PM callbacks

Use the new implemented snd_sof_prepare() and snd_sof_complete() as the
power management callbacks for pci probing platforms.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191025224122.7718-27-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: SOF: PM: Add support for DSP D0i3 state when entering S0ix
Keyon Jie [Fri, 25 Oct 2019 22:41:21 +0000 (17:41 -0500)]
ASoC: SOF: PM: Add support for DSP D0i3 state when entering S0ix

When system is entering into S0ix, the PCI device may transition to the
D0i3 substate instead of D3. In D0i3, some always-on functionality can
be enabled, such as acoustic event detection, voice activity detection
or hotwording. When an event is detected, the DSP firmware can wake-up
the device for a transition to D0 with an interrupt.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191025224122.7718-26-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: SOF: return -ENOTSUPP if D0I3 is not supported
Keyon Jie [Fri, 25 Oct 2019 22:41:20 +0000 (17:41 -0500)]
ASoC: SOF: return -ENOTSUPP if D0I3 is not supported

No set_power_state ops means that the platform doesn't support D0i3,
return -ENOTSUPP for the case.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191025224122.7718-25-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: SOF: Intel: hda-dsp: implement suspend/resume for S0ix<->S0 transition
Keyon Jie [Fri, 25 Oct 2019 22:41:19 +0000 (17:41 -0500)]
ASoC: SOF: Intel: hda-dsp: implement suspend/resume for S0ix<->S0 transition

Enable system wake up via IPC interrupt from DSP when the system is
suspending to the S0ix state, and disable it in the corresponding
resuming.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191025224122.7718-24-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: SOF: ignore suspend/resume for D0ix compatible streams
Keyon Jie [Fri, 25 Oct 2019 22:41:18 +0000 (17:41 -0500)]
ASoC: SOF: ignore suspend/resume for D0ix compatible streams

During system suspend, the PM framework will freeze all applications and
the ALSA/ASoC core will suspend all RUNNING PCM streams.

However, D0ix-compatible PCM streams should keep the related pipelines
active in the DSP when the system is entering S0ix. The TRIGGER_SUSPEND
event is trapped in such cases to prevent the pipelines from being
stopped. Likewise, the TRIGGER_RESUME/START events should not affect the
pipeline state.

The SOF driver also triggers some DSP Firmware pipelines based on the
DAPM widgets power events. In such cases, we also ignore PRE_PMU and
POST_PMD events to keep the pipelines active.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191025224122.7718-23-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: SOF: PM: implement prepare/complete callbacks
Keyon Jie [Fri, 25 Oct 2019 22:41:17 +0000 (17:41 -0500)]
ASoC: SOF: PM: implement prepare/complete callbacks

Implement the prepare() and complete() callbacks for power management,
initialize s0_suspend flag at prepare(), and reset it at complete().

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191025224122.7718-22-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: SOF: add a flag suspend_ignored for sof stream
Keyon Jie [Fri, 25 Oct 2019 22:41:16 +0000 (17:41 -0500)]
ASoC: SOF: add a flag suspend_ignored for sof stream

Add a suspend_ignored flag to snd_sof_pcm_stream that will be used to
decide if the corresponding FW pipeline should be kept active to perform
always on tasks when the system is entering the S0ix state.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191025224122.7718-21-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: SOF: add a flag to indicate the system suspend target
Keyon Jie [Fri, 25 Oct 2019 22:41:15 +0000 (17:41 -0500)]
ASoC: SOF: add a flag to indicate the system suspend target

Add flag 's0_suspend' to indicate if the system is entering S0ix or
not.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191025224122.7718-20-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: SOF: Intel: CNL: add support for sending compact IPC
Keyon Jie [Fri, 25 Oct 2019 22:41:14 +0000 (17:41 -0500)]
ASoC: SOF: Intel: CNL: add support for sending compact IPC

For compact IPCs, we will send the IPC header/command via the HIPCIDR
register and the first 32bit payload via the HIPCIDD register, no
mailbox will be used.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191025224122.7718-19-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: SOF: PM: add helpers for setting D0 substate for ADSP
Keyon Jie [Fri, 25 Oct 2019 22:41:13 +0000 (17:41 -0500)]
ASoC: SOF: PM: add helpers for setting D0 substate for ADSP

Add snd_sof_set_d0_substate() helper for setting ADSP to a specific D0
substate, it will call into the platform specific implementation, and
update the d0_substate at success.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191025224122.7718-18-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: SOF: configure D0ix IPC flags in set_power_state
Keyon Jie [Fri, 25 Oct 2019 22:41:12 +0000 (17:41 -0500)]
ASoC: SOF: configure D0ix IPC flags in set_power_state

The configuration for D0ix in FW is platform specific, let's do this and
send IPC in the platform set_power_state() ops.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191025224122.7718-17-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: SOF: Intel: HDA: add cAVS specific compact IPC header file
Keyon Jie [Fri, 25 Oct 2019 22:41:11 +0000 (17:41 -0500)]
ASoC: SOF: Intel: HDA: add cAVS specific compact IPC header file

On cAVS platforms, some IPCs are required to be sent via IPC registers
only(e.g. when in D0i3, mailbox is unaccessible), add hda-ipc.h to hold
definition of those compact IPCs.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191025224122.7718-16-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: SOF: Intel: hda-ipc: Don't read mailbox for PM_GATE reply
Keyon Jie [Fri, 25 Oct 2019 22:41:10 +0000 (17:41 -0500)]
ASoC: SOF: Intel: hda-ipc: Don't read mailbox for PM_GATE reply

Memory windows could be powered off before receiving PM_GATE IPC reply
from FW, we can't read the mailbox to get reply.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191025224122.7718-15-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: SOF: ipc: introduce message for DSP power gating
Keyon Jie [Fri, 25 Oct 2019 22:41:09 +0000 (17:41 -0500)]
ASoC: SOF: ipc: introduce message for DSP power gating

Add new ipc messages which will be sent from driver to FW, to ask FW to
enter specific power saving state.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191025224122.7718-14-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: SOF: PM: rename sof_send_pm_ipc to sof_send_pm_ctx_ipc
Keyon Jie [Fri, 25 Oct 2019 22:41:08 +0000 (17:41 -0500)]
ASoC: SOF: PM: rename sof_send_pm_ipc to sof_send_pm_ctx_ipc

The helper sof_send_pm_ipc() is only suitable for context save/restore
IPCs' sending, so rename it to sof_send_pm_ctx_ipc here.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191025224122.7718-13-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: SOF: Intel: HDA: use macro for register polling retry count
Keyon Jie [Fri, 25 Oct 2019 22:41:07 +0000 (17:41 -0500)]
ASoC: SOF: Intel: HDA: use macro for register polling retry count

Define macro and use it for the register polling retry count.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191025224122.7718-12-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: SOF: Intel: hda-dsp: align the comments for D0I3C update
Keyon Jie [Fri, 25 Oct 2019 22:41:06 +0000 (17:41 -0500)]
ASoC: SOF: Intel: hda-dsp: align the comments for D0I3C update

Align the logs for CIP timeout at D0I3C.I3 updating.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191025224122.7718-11-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: SOF: topology: parse and store d0i3_compatible flag
Keyon Jie [Fri, 25 Oct 2019 22:41:05 +0000 (17:41 -0500)]
ASoC: SOF: topology: parse and store d0i3_compatible flag

Parses the token from tplg file and store it to snd_sof_pcm_stream
d0i3_compatible flag, which can be used later for d0ix transition
management.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191025224122.7718-10-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: SOF: token: add tokens for PCM compatible with D0i3 substate
Keyon Jie [Fri, 25 Oct 2019 22:41:04 +0000 (17:41 -0500)]
ASoC: SOF: token: add tokens for PCM compatible with D0i3 substate

Add stream token SOF_TKN_STREAM_PLAYBACK_COMPATIBLE_D0I3 and
SOF_TKN_STREAM_CAPTURE_COMPATIBLE_D0I3 to denote if the stream can be
opened at low power d0i3 status or not.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191025224122.7718-9-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: SOF: add flag to snd_sof_pcm_stream for D0i3 compatible stream
Keyon Jie [Fri, 25 Oct 2019 22:41:03 +0000 (17:41 -0500)]
ASoC: SOF: add flag to snd_sof_pcm_stream for D0i3 compatible stream

Add flag d0i3_compatible to struct snd_sof_pcm_stream to denote if the
stream can tolerate a transition to the D0i3 substate while opened (thus
seen as 'active' by pm_runtime).

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191025224122.7718-8-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: SOF: Intel: APL: add set_power_state() ops
Keyon Jie [Fri, 25 Oct 2019 22:41:02 +0000 (17:41 -0500)]
ASoC: SOF: Intel: APL: add set_power_state() ops

Using hda_dsp_set_power_state() as set_power_state() ops for apl to do
d0ix platform configuration updates.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191025224122.7718-7-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: SOF: Intel: CNL: add set_power_state() ops
Keyon Jie [Fri, 25 Oct 2019 22:41:01 +0000 (17:41 -0500)]
ASoC: SOF: Intel: CNL: add set_power_state() ops

Using hda_dsp_set_power_state() as set_power_state() ops for cnl to do
d0ix platform configuration updates.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191025224122.7718-6-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: SOF: Intel: hda-dsp: Add helper for setting DSP D0ix substate
Keyon Jie [Fri, 25 Oct 2019 22:41:00 +0000 (17:41 -0500)]
ASoC: SOF: Intel: hda-dsp: Add helper for setting DSP D0ix substate

Adding helper to implement setting dsp to d0i3 or d0i0 status, this will
be needed for driver D0ix support.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191025224122.7718-5-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: SOF: add set_power_state() to dsp_ops for power state update
Keyon Jie [Fri, 25 Oct 2019 22:40:59 +0000 (17:40 -0500)]
ASoC: SOF: add set_power_state() to dsp_ops for power state update

D0i3 is a platform-defined substate of D0, so we need a
platform-specific callback in dsp_ops to handle the relevant
configurations.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191025224122.7718-4-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: SOF: reset default d0_substate at probe() and resume()
Keyon Jie [Fri, 25 Oct 2019 22:40:58 +0000 (17:40 -0500)]
ASoC: SOF: reset default d0_substate at probe() and resume()

We initialize/reset d0_substate to default d0i0 value when doing
transition D3-->D0, e.g. at success of probing and resuming.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191025224122.7718-3-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: SOF: add a field to store the current D0 substate of DSP
Keyon Jie [Fri, 25 Oct 2019 22:40:57 +0000 (17:40 -0500)]
ASoC: SOF: add a field to store the current D0 substate of DSP

Add field d0_substate to struct snd_sof_dev to store the current DSP
D0 sub-state(only meaningful when DSP in D0), which could be D0I0 or
D0I3.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191025224122.7718-2-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: rsnd: core.c: add WARN_ON() on rsnd_channel_normalization()
Kuninori Morimoto [Mon, 28 Oct 2019 05:29:55 +0000 (14:29 +0900)]
ASoC: rsnd: core.c: add WARN_ON() on rsnd_channel_normalization()

chan > 8 or chan < 0 shouldn't happen.
This patch uses WARN_ON() for such case.

Reported-by: Pavel Machek <pavel@denx.de>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87y2x530a4.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: fsl_esai: Add spin lock to protect reset, stop and start
Shengjiu Wang [Mon, 28 Oct 2019 09:11:05 +0000 (17:11 +0800)]
ASoC: fsl_esai: Add spin lock to protect reset, stop and start

xrun may happen at the end of stream, the
trigger->fsl_esai_trigger_stop maybe called in the middle of
fsl_esai_hw_reset, this may cause esai in wrong state
after stop, and there may be endless xrun interrupt.

This issue may also happen with trigger->fsl_esai_trigger_start.

So Add spin lock to lock those functions.

Fixes: 7ccafa2b3879 ("ASoC: fsl_esai: recover the channel swap after xrun")
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Acked-by: Nicolin Chen <nicoleotsuka@gmail.com>
Link: https://lore.kernel.org/r/52e92c4221a83e39a84a6cd92fc3d5479b44894c.1572252321.git.shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: fsl_asrc: refine the setting of internal clock divider
Shengjiu Wang [Mon, 28 Oct 2019 09:10:29 +0000 (17:10 +0800)]
ASoC: fsl_asrc: refine the setting of internal clock divider

The output divider should align with the output sample
rate, if use ideal sample rate, there will be a lot of overload,
which would cause underrun.

The maximum divider of asrc clock is 1024, but there is no
judgement for this limitation in driver, which may cause the divider
setting not correct.

For non-ideal ratio mode, the clock rate should divide the sample
rate with no remainder, and the quotient should be less than 1024.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Acked-by: Nicolin Chen <nicoleotsuka@gmail.com>
Link: https://lore.kernel.org/r/23c634e4bf58afce5b3ae67f5f42e8d1cae2639a.1572252307.git.shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: eve: implement set_bias_level function for rt5514
Brent Lu [Fri, 25 Oct 2019 09:11:31 +0000 (17:11 +0800)]
ASoC: eve: implement set_bias_level function for rt5514

The first DMIC capture always fail (zero sequence data from PCM port)
after using DSP hotwording function (i.e. Google assistant).

This rt5514 codec requires to control mclk directly in the set_bias_level
function. Implement this function in machine driver to control the
ssp1_mclk clock explicitly could fix this issue.

Signed-off-by: Brent Lu <brent.lu@intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/1571994691-20199-1-git-send-email-brent.lu@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: sunxi: sun4i-codec: remove unneeded semicolon
YueHaibing [Fri, 25 Oct 2019 12:08:01 +0000 (20:08 +0800)]
ASoC: sunxi: sun4i-codec: remove unneeded semicolon

remove unneeded semicolon.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Link: https://lore.kernel.org/r/20191025120801.16236-1-yuehaibing@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: fsl: fsl_dma: fix build failure
Michael Ellerman [Fri, 25 Oct 2019 05:13:53 +0000 (16:13 +1100)]
ASoC: fsl: fsl_dma: fix build failure

Commit 4ac85de9977e ("ASoC: fsl: fsl_dma: remove snd_pcm_ops") removed
fsl_dma_ops but left a usage, leading to a build error for some
configs, eg. mpc85xx_defconfig:

  sound/soc/fsl/fsl_dma.c: In function ‘fsl_soc_dma_probe’:
  sound/soc/fsl/fsl_dma.c:905:18: error: ‘fsl_dma_ops’ undeclared (first use in this function)
    dma->dai.ops = &fsl_dma_ops;
                    ^~~~~~~~~~~

Remove the usage to fix the build.

Fixes: 4ac85de9977e ("ASoC: fsl: fsl_dma: remove snd_pcm_ops")
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20191025051353.2878-1-mpe@ellerman.id.au
Signed-off-by: Mark Brown <broonie@kernel.org>