]> git.ipfire.org Git - thirdparty/kernel/linux.git/log
thirdparty/kernel/linux.git
4 years agoASoC: audio-graph-card: fix use-after-free in graph_for_each_link
Wen Yang [Thu, 4 Jul 2019 08:38:50 +0000 (16:38 +0800)] 
ASoC: audio-graph-card: fix use-after-free in graph_for_each_link

After calling of_node_put() on the codec_ep and codec_port variables,
they are still being used, which may result in use-after-free.
We fix this issue by calling of_node_put() after the last usage.

Fixes: fce9b90c1ab7 ("ASoC: audio-graph-card: cleanup DAI link loop method - step2")
Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Cc: alsa-devel@alsa-project.org
Cc: linux-kernel@vger.kernel.org
Link: https://lore.kernel.org/r/1562229530-8121-1-git-send-email-wen.yang99@zte.com.cn
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: codecs: ad193x: Fix memory corruption on BE 64b systems
Codrin Ciubotariu [Wed, 26 Jun 2019 10:49:46 +0000 (13:49 +0300)] 
ASoC: codecs: ad193x: Fix memory corruption on BE 64b systems

Since change_bit() requires unsigned long*, making this cast on an
unsigned int variable will change a wrong bit on BE platforms, causing
memory corruption. Replace this function with a simple XOR.

Fixes: 90f6e6803139 ("ASoC: codecs: ad193x: Fix frame polarity for DSP_A format")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: dapm: Adapt for debugfs API change
Mark Brown [Fri, 21 Jun 2019 11:33:57 +0000 (12:33 +0100)] 
ASoC: dapm: Adapt for debugfs API change

Back in ff9fb72bc07705c (debugfs: return error values, not NULL) the
debugfs APIs were changed to return error pointers rather than NULL
pointers on error, breaking the error checking in ASoC. Update the
code to use IS_ERR() and log the codes that are returned as part of
the error messages.

Fixes: ff9fb72bc07705c (debugfs: return error values, not NULL)
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: core: Adapt for debugfs API change
Mark Brown [Fri, 21 Jun 2019 11:33:56 +0000 (12:33 +0100)] 
ASoC: core: Adapt for debugfs API change

Back in ff9fb72bc07705c (debugfs: return error values, not NULL) the
debugfs APIs were changed to return error pointers rather than NULL
pointers on error, breaking the error checking in ASoC. Update the
code to use IS_ERR() and log the codes that are returned as part of
the error messages.

Fixes: ff9fb72bc07705c (debugfs: return error values, not NULL)
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: soc-core: call snd_soc_unbind_card() under mutex_lock;
Kuninori Morimoto [Wed, 19 Jun 2019 01:07:19 +0000 (10:07 +0900)] 
ASoC: soc-core: call snd_soc_unbind_card() under mutex_lock;

commit 34ac3c3eb8f0c07 ("ASoC: core: lock client_mutex while removing
link components") added mutex_lock() at soc_remove_link_components().

Is is called from snd_soc_unbind_card()

snd_soc_unbind_card()
=> soc_remove_link_components()
soc_cleanup_card_resources()
soc_remove_dai_links()
=> soc_remove_link_components()

And, there are 2 way to call it.

(1)
snd_soc_unregister_component()
** mutex_lock()
snd_soc_component_del_unlocked()
=> snd_soc_unbind_card()
** mutex_unlock()

(2)
snd_soc_unregister_card()
=> snd_soc_unbind_card()

(1) case is already using mutex_lock() when it calles
snd_soc_unbind_card(), thus, we will get lockdep warning.

commit 495f926c68ddb90 ("ASoC: core: Fix deadlock in
snd_soc_instantiate_card()") tried to fixup it, but still not
enough. We still have lockdep warning when we try unbind/bind.

We need mutex_lock() under snd_soc_unregister_card()
instead of snd_remove_link_components()/snd_soc_unbind_card().

Fixes: 34ac3c3eb8f0c07 ("ASoC: core: lock client_mutex while removing link components")
Fixes: 495f926c68ddb90 ("ASoC: core: Fix deadlock in snd_soc_instantiate_card()")
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: Intel: sof_rt5682: use GFP_KERNEL instead of GFP_ATOMIC
Tzung-Bi Shih [Tue, 18 Jun 2019 07:04:26 +0000 (15:04 +0800)] 
ASoC: Intel: sof_rt5682: use GFP_KERNEL instead of GFP_ATOMIC

Change the memory allocation flag from GFP_ATOMIC to GFP_KERNEL because
probe of platform device is unlikely a place where cannot sleep.

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: qcom: common: Mark links as nonatomic
Bjorn Andersson [Tue, 18 Jun 2019 05:29:09 +0000 (22:29 -0700)] 
ASoC: qcom: common: Mark links as nonatomic

The interface used to communicate with the DSP can sleep, so mark the
links as nonatomic. This prevents various sleep while atomic errors when
bringing up the audio interface.

Suggested-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: Intel: Skylake: Fix incorrect capture position reporting
Cezary Rojewski [Thu, 13 Jun 2019 19:04:30 +0000 (21:04 +0200)] 
ASoC: Intel: Skylake: Fix incorrect capture position reporting

HW recommends to set DUM bit on device power up, so that DPIB write
request occurs every frame regardless of whether DPIB has changed or
not. This addresses incorrect position reporting for capture streams.

Signed-off-by: Leoni Prodduvaka <leoni.prodduvaka@intel.com>
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: ti: Fix SDMA users not providing channel names
Janusz Krzysztofik [Sun, 2 Jun 2019 14:55:49 +0000 (16:55 +0200)] 
ASoC: ti: Fix SDMA users not providing channel names

McBSP used to work correctly as long as compat DMA probing, removed by
commit 642aafea8889 ("ASoC: ti: remove compat dma probing"), was
available.  New method of DMA probing apparently requires users to
provide channel names when registering with SDMA, while McBSP passes
NULLs.  Fix it.

The same probably applies to McASP (not tested), hence the patch fixes
both.

Fixes: 642aafea8889 ("ASoC: ti: remove compat dma probing")
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: codec: hdac_hdmi: fix pin connections at cvt enable
Kai Vehmanen [Thu, 13 Jun 2019 11:54:12 +0000 (14:54 +0300)] 
ASoC: codec: hdac_hdmi: fix pin connections at cvt enable

In display codecs supported by hdac_hdmi, the connection indices are
shared by all converters. At boot and resume from suspend,
the connection state may be reset to default values.

In case of multiple connected pins (multiple monitors connected
with audio capability), routing and mute status of pins that
are not connected to any PCM, may interfere with other pins.
E.g. after resume from S3 with multiple monitors, unless
all converters are in active use, playback to some PCMs may
be muted due to the default settings of unrelated converters.

Avoid this by ensuring all pin:cvt selections are correct
in codec whenever a converter is enabled for playback.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: meson: axg-tdm: fix sample clock inversion
Jerome Brunet [Thu, 13 Jun 2019 11:42:32 +0000 (13:42 +0200)] 
ASoC: meson: axg-tdm: fix sample clock inversion

The content of SND_SOC_DAIFMT_FORMAT_MASK is a number, not a bitfield,
so the test to check if the format is i2s is wrong. Because of this the
clock setting may be wrong. For example, the sample clock gets inverted
in DSP B mode, when it should not.

Fix the lrclk invert helper function

Fixes: 1a11d88f499c ("ASoC: meson: add tdm formatter base driver")
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: meson: axg-tdmout: right_j is not supported
Jerome Brunet [Thu, 13 Jun 2019 11:42:31 +0000 (13:42 +0200)] 
ASoC: meson: axg-tdmout: right_j is not supported

Right justified format is actually not supported by the amlogic tdm output
encoder.

Fixes: c41c2a355b86 ("ASoC: meson: add tdm output driver")
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: meson: axg-tdmin: right_j is not supported
Jerome Brunet [Thu, 13 Jun 2019 11:42:30 +0000 (13:42 +0200)] 
ASoC: meson: axg-tdmin: right_j is not supported

Right justified format is actually not supported by the amlogic tdm input
decoder.

Fixes: 13a22e6a98f8 ("ASoC: meson: add tdm input driver")
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: nau8825: fix fake interruption when booting
John Hsu [Mon, 10 Jun 2019 03:40:40 +0000 (11:40 +0800)] 
ASoC: nau8825: fix fake interruption when booting

There is no pull-up resistor at IRQ line where it connects from
the codec to SoC. When booting, the signal of IRQ pin will keep low
which makes the SoC invoke the ISR repeatedly because the IRQ is
registered trigger low. It will not stop until the codec sets up
the interruption and pulls the signal high. In the patch,
nau8825 will internally pull the signal to high at booting in case
the fake interrupts happen.

Signed-off-by: John Hsu <KCHSU0@nuvoton.com>
Tested-by: Cheng-Yi Chiang <cychiang@chromium.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: Intel: sst: fix kmalloc call with wrong flags
Alex Levin [Fri, 7 Jun 2019 22:19:11 +0000 (15:19 -0700)] 
ASoC: Intel: sst: fix kmalloc call with wrong flags

When calling kmalloc with GFP_KERNEL in case CONFIG_SLOB is unset,
kmem_cache_alloc_trace is called.

In case CONFIG_TRACING is set, kmem_cache_alloc_trace will ball
slab_alloc, which will call slab_pre_alloc_hook which might_sleep_if.

The context in which it is called in this case, the
intel_sst_interrupt_mrfld, calling a sleeping kmalloc generates a BUG():

Fixes: 972b0d456e64 ("ASoC: Intel: remove GFP_ATOMIC, use GFP_KERNEL")
[   20.250671] BUG: sleeping function called from invalid context at mm/slab.h:422
[   20.250683] in_atomic(): 1, irqs_disabled(): 1, pid: 1791, name: Chrome_IOThread
[   20.250690] CPU: 0 PID: 1791 Comm: Chrome_IOThread Tainted: G        W         4.19.43 #61
[   20.250693] Hardware name: GOOGLE Kefka, BIOS Google_Kefka.7287.337.0 03/02/2017
[   20.250697] Call Trace:
[   20.250704]  <IRQ>
[   20.250716]  dump_stack+0x7e/0xc3
[   20.250725]  ___might_sleep+0x12a/0x140
[   20.250731]  kmem_cache_alloc_trace+0x53/0x1c5
[   20.250736]  ? update_cfs_rq_load_avg+0x17e/0x1aa
[   20.250740]  ? cpu_load_update+0x6c/0xc2
[   20.250746]  sst_create_ipc_msg+0x2d/0x88
[   20.250752]  intel_sst_interrupt_mrfld+0x12a/0x22c
[   20.250758]  __handle_irq_event_percpu+0x133/0x228
[   20.250764]  handle_irq_event_percpu+0x35/0x7a
[   20.250768]  handle_irq_event+0x36/0x55
[   20.250773]  handle_fasteoi_irq+0xab/0x16c
[   20.250779]  handle_irq+0xd9/0x11e
[   20.250785]  do_IRQ+0x54/0xe0
[   20.250791]  common_interrupt+0xf/0xf
[   20.250795]  </IRQ>
[   20.250800] RIP: 0010:__lru_cache_add+0x4e/0xad
[   20.250806] Code: 00 01 48 c7 c7 b8 df 01 00 65 48 03 3c 25 28 f1 00 00 48 8b 48 08 48 89 ca 48 ff ca f6 c1 01 48 0f 44 d0 f0 ff 42 34 0f b6 0f <89> ca fe c2 88 17 48 89 44 cf 08 80 fa 0f 74 0e 48 8b 08 66 85 c9
[   20.250809] RSP: 0000:ffffa568810bfd98 EFLAGS: 00000202 ORIG_RAX: ffffffffffffffd6
[   20.250814] RAX: ffffd3b904eb1940 RBX: ffffd3b904eb1940 RCX: 0000000000000004
[   20.250817] RDX: ffffd3b904eb1940 RSI: ffffa10ee5c47450 RDI: ffffa10efba1dfb8
[   20.250821] RBP: ffffa568810bfda8 R08: ffffa10ef9c741c1 R09: dead000000000100
[   20.250824] R10: 0000000000000000 R11: 0000000000000000 R12: ffffa10ee8d52a40
[   20.250827] R13: ffffa10ee8d52000 R14: ffffa10ee5c47450 R15: 800000013ac65067
[   20.250835]  lru_cache_add_active_or_unevictable+0x4e/0xb8
[   20.250841]  handle_mm_fault+0xd98/0x10c4
[   20.250848]  __do_page_fault+0x235/0x42d
[   20.250853]  ? page_fault+0x8/0x30
[   20.250858]  do_page_fault+0x3d/0x17a
[   20.250862]  ? page_fault+0x8/0x30
[   20.250866]  page_fault+0x1e/0x30
[   20.250872] RIP: 0033:0x7962fdea9304
[   20.250875] Code: 0f 11 4c 17 f0 c3 48 3b 15 f1 26 31 00 0f 83 e2 00 00 00 48 39 f7 72 0f 74 12 4c 8d 0c 16 4c 39 cf 0f 82 63 01 00 00 48 89 d1 <f3> a4 c3 80 fa 08 73 12 80 fa 04 73 1e 80 fa 01 77 26 72 05 0f b6
[   20.250879] RSP: 002b:00007962f4db5468 EFLAGS: 00010206
[   20.250883] RAX: 00003c8cc9d47008 RBX: 0000000000000000 RCX: 0000000000001b48
[   20.250886] RDX: 0000000000002b40 RSI: 00003c8cc9551000 RDI: 00003c8cc9d48000
[   20.250890] RBP: 00007962f4db5820 R08: 0000000000000000 R09: 00003c8cc9552b48
[   20.250893] R10: 0000562dd1064d30 R11: 00003c8cc825b908 R12: 00003c8cc966d3c0
[   20.250896] R13: 00003c8cc9e280c0 R14: 0000000000000000 R15: 0000000000000000

Signed-off-by: Alex Levin <levinale@chromium.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: core: Fix deadlock in snd_soc_instantiate_card()
Ranjani Sridharan [Sat, 8 Jun 2019 05:07:06 +0000 (22:07 -0700)] 
ASoC: core: Fix deadlock in snd_soc_instantiate_card()

Move the client_mutex lock to snd_soc_unbind_card() before
removing link components. This prevents the deadlock
in the error path in snd_soc_instantiate_card().

Fixes: 34ac3c3eb8 (ASoC: core: lock client_mutex while removing
link components)
Reported-by: kernelci.org bot <bot@kernelci.org>
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoSoC: rt274: Fix internal jack assignment in set_jack callback
Amadeusz Sławiński [Wed, 5 Jun 2019 13:45:52 +0000 (15:45 +0200)] 
SoC: rt274: Fix internal jack assignment in set_jack callback

When we call snd_soc_component_set_jack(component, NULL, NULL) we should
set rt274->jack to passed jack, so when interrupt is triggered it calls
snd_soc_jack_report(rt274->jack, ...) with proper value.

This fixes problem in machine where in register, we call
snd_soc_register(component, &headset, NULL), which just calls
rt274_mic_detect via callback.
Now when machine driver is removed "headset" will be gone, so we
need to tell codec driver that it's gone with:
snd_soc_register(component, NULL, NULL), but we also need to be able
to handle NULL jack argument here gracefully.
If we don't set it to NULL, next time the rt274_irq runs it will call
snd_soc_jack_report with first argument being invalid pointer and there
will be Oops.

Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoALSA: hdac: fix memory release for SST and SOF drivers
Amadeusz Sławiński [Wed, 22 May 2019 16:21:41 +0000 (11:21 -0500)] 
ALSA: hdac: fix memory release for SST and SOF drivers

During the integration of HDaudio support, we changed the way in which
we get hdev in snd_hdac_ext_bus_device_init() to use one preallocated
with devm_kzalloc(), however it still left kfree(hdev) in
snd_hdac_ext_bus_device_exit(). It leads to oopses when trying to
rmmod and modprobe. Fix it, by just removing kfree call.

SOF also uses some of the snd_hdac_ functions for HDAudio support but
allocated the memory with kzalloc. A matching fix is provided
separately to align all users of the snd_hdac_ library.

Fixes: 6298542fa33b ("ALSA: hdac: remove memory allocation from snd_hdac_ext_bus_device_init")
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: SOF: Intel: hda: use the defined ppcap functions
Zhu Yingjiang [Wed, 22 May 2019 16:21:40 +0000 (11:21 -0500)] 
ASoC: SOF: Intel: hda: use the defined ppcap functions

There are already defined ppcap and ppcap interrupt functions, use
the already defined functions for easy code read.

Fixes: 8a300c8fb17 ("ASoC: SOF: Intel: Add HDA controller for Intel DSP")
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Zhu Yingjiang <yingjiang.zhu@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: core: move DAI pre-links initiation to snd_soc_instantiate_card
Tzung-Bi Shih [Tue, 4 Jun 2019 03:31:02 +0000 (11:31 +0800)] 
ASoC: core: move DAI pre-links initiation to snd_soc_instantiate_card

Kernel crashes when an ASoC component rebinding.

The dai_link->platforms has been reset to NULL by soc_cleanup_platform()
in soc_cleanup_card_resources() when un-registering component.  However,
it has no chance to re-allocate the dai_link->platforms when registering
the component again.

Move the DAI pre-links initiation from snd_soc_register_card() to
snd_soc_instantiate_card() to make sure all DAI pre-links get initiated
when component rebinding.

As an example, by using the following commands:
- echo -n max98357a > /sys/bus/platform/drivers/max98357a/unbind
- echo -n max98357a > /sys/bus/platform/drivers/max98357a/bind

Got the error message:
"Unable to handle kernel NULL pointer dereference at virtual address".

The call trace:
snd_soc_is_matching_component+0x30/0x6c
soc_bind_dai_link+0x16c/0x240
snd_soc_bind_card+0x1e4/0xb10
snd_soc_add_component+0x270/0x300
snd_soc_register_component+0x54/0x6c

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: Intel: cht_bsw_rt5672: fix kernel oops with platform_name override
Pierre-Louis Bossart [Tue, 4 Jun 2019 20:08:58 +0000 (15:08 -0500)] 
ASoC: Intel: cht_bsw_rt5672: fix kernel oops with platform_name override

The platform override code uses devm_ functions to allocate memory for
the new name but the card device is not initialized. Fix by moving the
init earlier.

Fixes: f403906da05cd ("ASoC: Intel: cht_bsw_rt5672: platform name fixup support")
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: Intel: cht_bsw_nau8824: fix kernel oops with platform_name override
Pierre-Louis Bossart [Tue, 4 Jun 2019 20:08:57 +0000 (15:08 -0500)] 
ASoC: Intel: cht_bsw_nau8824: fix kernel oops with platform_name override

The platform override code uses devm_ functions to allocate memory for
the new name but the card device is not initialized. Fix by moving the
init earlier.

Fixes: 4506db8043341 ("ASoC: Intel: cht_bsw_nau8824: platform name fixup support")
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: Intel: bytcht_es8316: fix kernel oops with platform_name override
Pierre-Louis Bossart [Tue, 4 Jun 2019 20:08:56 +0000 (15:08 -0500)] 
ASoC: Intel: bytcht_es8316: fix kernel oops with platform_name override

The platform override code uses devm_ functions to allocate memory for
the new name but the card device is not initialized. Fix by moving the
init earlier.

Fixes: e4bc6b1195f64 ("ASoC: Intel: bytcht_es8316: platform name fixup support")
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: Intel: cht_bsw_max98090: fix kernel oops with platform_name override
Pierre-Louis Bossart [Tue, 4 Jun 2019 20:08:55 +0000 (15:08 -0500)] 
ASoC: Intel: cht_bsw_max98090: fix kernel oops with platform_name override

The platform override code uses devm_ functions to allocate memory for
the new name but the card device is not initialized. Fix by moving the
init earlier.

Fixes: 7e7e24d7c7ff0 ("ASoC: Intel: cht_bsw_max98090_ti: platform name fixup support")
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: sun4i-i2s: Add offset to RX channel select
Marcus Cooper [Mon, 3 Jun 2019 17:47:28 +0000 (19:47 +0200)] 
ASoC: sun4i-i2s: Add offset to RX channel select

Whilst testing the capture functionality of the i2s on the newer
SoCs it was noticed that the recording was somewhat distorted.
This was due to the offset not being set correctly on the receiver
side.

Signed-off-by: Marcus Cooper <codekipper@gmail.com>
Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
Acked-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: sun4i-i2s: Fix sun8i tx channel offset mask
Marcus Cooper [Mon, 3 Jun 2019 17:47:27 +0000 (19:47 +0200)] 
ASoC: sun4i-i2s: Fix sun8i tx channel offset mask

Although not causing any noticeable issues, the mask for the
channel offset is covering too many bits.

Signed-off-by: Marcus Cooper <codekipper@gmail.com>
Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
Acked-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: max98090: remove 24-bit format support if RJ is 0
Yu-Hsuan Hsu [Tue, 4 Jun 2019 10:49:09 +0000 (18:49 +0800)] 
ASoC: max98090: remove 24-bit format support if RJ is 0

The supported formats are S16_LE and S24_LE now. However, by datasheet
of max98090, S24_LE is only supported when it is in the right justified
mode. We should remove 24-bit format if it is not in that mode to avoid
triggering error.

Signed-off-by: Yu-Hsuan Hsu <yuhsuan@chromium.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: da7219: Fix build error without CONFIG_I2C
YueHaibing [Sat, 1 Jun 2019 08:51:44 +0000 (16:51 +0800)] 
ASoC: da7219: Fix build error without CONFIG_I2C

Fix gcc build error while CONFIG_I2C is not set

sound/soc/codecs/da7219.c:2640:1: warning: data definition has no type or storage class
 module_i2c_driver(da7219_i2c_driver);
 ^~~~~~~~~~~~~~~~~
sound/soc/codecs/da7219.c:2640:1: error: type defaults to int in declaration of module_i2c_driver [-Werror=implicit-int]
sound/soc/codecs/da7219.c:2640:1: warning: parameter names (without types) in function declaration
sound/soc/codecs/da7219.c:2629:26: warning: da7219_i2c_driver defined but not used [-Wunused-variable]

Reported-by: Hulk Robot <hulkci@huawei.com>
Fixes: 6d817c0e9fd7 ("ASoC: codecs: Add da7219 codec driver")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: SOF: Intel: hda: Fix COMPILE_TEST build error
YueHaibing [Fri, 31 May 2019 14:25:26 +0000 (22:25 +0800)] 
ASoC: SOF: Intel: hda: Fix COMPILE_TEST build error

while building without PCI:

sound/soc/sof/intel/hda.o: In function `hda_dsp_probe':
hda.c:(.text+0x79c): undefined reference to `pci_ioremap_bar'
hda.c:(.text+0x79c): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `pci_ioremap_bar'
hda.c:(.text+0x7c4): undefined reference to `pci_ioremap_bar'
hda.c:(.text+0x7c4): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `pci_ioremap_bar'

Reported-by: Hulk Robot <hulkci@huawei.com>
Fixes: e13ef82a9ab8 ("ASoC: SOF: add COMPILE_TEST for PCI options")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: SOF: fix DSP oops definitions in FW ABI
Kai Vehmanen [Mon, 3 Jun 2019 16:18:15 +0000 (11:18 -0500)] 
ASoC: SOF: fix DSP oops definitions in FW ABI

The definitions for DSP oops structures were not aligned
correctly to current FW ABI version 3.6.0, leading to
invalid data being printed out to debug logs. Fix the structs
and update related platform code accordingly.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: hda: fix unbalanced codec dev refcount for HDA_DEV_ASOC
Ranjani Sridharan [Fri, 31 May 2019 16:01:37 +0000 (09:01 -0700)] 
ASoC: hda: fix unbalanced codec dev refcount for HDA_DEV_ASOC

HDA_DEV_ASOC type codec device refcounts are managed differently
from HDA_DEV_LEGACY devices. The refcount is released explicitly
in snd_hdac_ext_bus_device_remove() for ASOC type devices.
So, remove the put_device() call in snd_hda_codec_dev_free()
for such devices to make the refcount balanced. This will prevent
the NULL pointer exception when the codec driver is released
after the card is freed.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: SOF: ipc: replace fw ready bitfield with explicit bit ordering
Slawomir Blauciak [Mon, 3 Jun 2019 16:20:32 +0000 (11:20 -0500)] 
ASoC: SOF: ipc: replace fw ready bitfield with explicit bit ordering

Previously the structure used bitfields, which do not guarantee bit
ordering.

This change makes sure the order is clearly defined.  It also renames
and repurposes the field for general use.

Signed-off-by: Slawomir Blauciak <slawomir.blauciak@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: SOF: bump to ABI 3.6
Pierre-Louis Bossart [Mon, 3 Jun 2019 16:18:16 +0000 (11:18 -0500)] 
ASoC: SOF: bump to ABI 3.6

We had a couple of misses with ABI changes, e.g. for Xtensa oops
information and the integration of sound trigger, before we set-up a
formal process to track evolutions.

With this patch, the SOF kernel patches are officially aligned with
the firmware 3.6 level. Changing this level has no impact on existing
users and is fully backwards-compatible.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: SOF: soundwire: add initial soundwire support
Pan Xiuli [Mon, 3 Jun 2019 16:18:14 +0000 (11:18 -0500)] 
ASoC: SOF: soundwire: add initial soundwire support

Add soundwire dai type and update ABI version.

Signed-off-by: Pan Xiuli <xiuli.pan@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: SOF: uapi: mirror firmware changes
Pierre-Louis Bossart [Mon, 3 Jun 2019 16:18:13 +0000 (11:18 -0500)] 
ASoC: SOF: uapi: mirror firmware changes

We missed these two definitions for GDB support and component
notifications, they are defined for the SOF firmware. Since they are
not used by the kernel so far, we can still add them without any ABI
change.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: Intel: Baytrail: add quirk for Aegex 10 (RU2) tablet
Kovács Tamás [Fri, 31 May 2019 17:22:26 +0000 (19:22 +0200)] 
ASoC: Intel: Baytrail: add quirk for Aegex 10 (RU2) tablet

This tablet has an incorrect acpi identifier just like
Thinkpad10 tablet, which is why it is trying to load the RT5640 driver
instead of the RT5762 driver. The RT5640 driver, on the other hand, checks
the hardware ID, so no driver are loaded during boot. This fix resolves to
load the RT5672 driver on this tablet during boot. It also provides the
correct IO configuration, like the jack detect mode 3, for 1.8V pullup. I
would like to thank Pierre-Louis Bossart for helping with this patch.

Signed-off-by: Kovács Tamás <kepszlok@zohomail.eu>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: sun4i-codec: fix first delay on Speaker
Georgii Staroselskii [Tue, 28 May 2019 10:47:39 +0000 (13:47 +0300)] 
ASoC: sun4i-codec: fix first delay on Speaker

Allwinner DAC seems to have a delay in the Speaker audio routing. When
playing a sound for the first time, the sound gets chopped. On a second
play the sound is played correctly. After some time (~5s) the issue gets
back.

This commit seems to be fixing the same issue as bf14da7 but
for another codepath.

This is the DTS that was used to debug the problem.

&codec {
        allwinner,pa-gpios = <&r_pio 0 11 GPIO_ACTIVE_HIGH>; /* PL11 */
        allwinner,audio-routing =
                "Speaker", "LINEOUT";

        status = "okay";
}

Signed-off-by: Georgii Staroselskii <georgii.staroselskii@emlid.com>
Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: SOF: Intel: hda: fix the hda init chip
Zhu Yingjiang [Fri, 24 May 2019 19:09:24 +0000 (14:09 -0500)] 
ASoC: SOF: Intel: hda: fix the hda init chip

re-write hda_init_caps and remove the HDA reset, clean HDA
streams and clear interrupt steps in hda_dsp_probe so the
HDA init steps will not be called twice if the
CONFIG_SND_SOC_SOF_HDA is true.

Fixes: 8a300c8fb17 ("ASoC: SOF: Intel: Add HDA controller for Intel DSP")
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Zhu Yingjiang <yingjiang.zhu@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: SOF: ipc: fix a race, leading to IPC timeouts
Guennadi Liakhovetski [Fri, 24 May 2019 19:09:23 +0000 (14:09 -0500)] 
ASoC: SOF: ipc: fix a race, leading to IPC timeouts

Currently on all supported platforms the IPC IRQ thread first signals
the sender when an IPC response is received from the DSP, then unmasks
the IPC interrupt. Those actions are performed without holding any
locks, so the thread can be interrupted between them. IPC timeouts
have been observed in such scenarios: if the sender is woken up and it
proceeds with sending the next message without unmasking the IPC
interrupt, it can miss the next response. This patch takes a spin-lock
to prevent the IRQ thread from being preempted at that point. It also
makes sure, that the next IPC transmission by the host cannot take
place before the IRQ thread has finished updating all the required IPC
registers.

Fixes: 53e0c72d98b ("ASoC: SOF: Add support for IPC IO between DSP and Host")
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: SOF: control: correct the copy size for bytes kcontrol put
Keyon Jie [Fri, 24 May 2019 19:09:22 +0000 (14:09 -0500)] 
ASoC: SOF: control: correct the copy size for bytes kcontrol put

The size for the bytes kcontrol should include the abi header, that is,
data->size + sizeof(*data), it is also aligned with get method after
this change.

Fixes: c3078f53970 ("ASoC: SOF: Add Sound Open Firmware KControl support")
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: SOF: pcm: remove warning - initialize workqueue on open
Pierre-Louis Bossart [Fri, 24 May 2019 19:09:21 +0000 (14:09 -0500)] 
ASoC: SOF: pcm: remove warning - initialize workqueue on open

If the SOF hw_params() fail, typically with an IPC error thrown by the
firmware, the period_elapsed workqueue is not initialized, but we
still cancel it in hw_free(), which results in a kernel warning.

Move the initialization to the .open callback. Tested on Broadwell
(Samus) and IceLake.

Fixes: e2803e610ae ("ASoC: SOF: PCM: add period_elapsed work to fix
race condition in interrupt context")

GitHub issue: https://github.com/thesofproject/linux/issues/932
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: SOF: pcm: clear hw_params_upon_resume flag correctly
Libin Yang [Fri, 24 May 2019 19:09:20 +0000 (14:09 -0500)] 
ASoC: SOF: pcm: clear hw_params_upon_resume flag correctly

sof_pcm_hw_params() can only be called once to setup the FW hw_params.
So after calling sof_pcm_hw_params(), hw_params_upon_resume flag must
be cleared to avoid multiple invoking sof_pcm_hw_params() by prepare.

For example, after resume, there is an xrun happened, prepare() will
be called. As the hw_params_upon_resume flag is not cleared,
sof_pcm_hw_params() will be called and this will cause IPC timeout.

This patch fixes such issues.

Fixes: 868bd00f495 ("ASoC: SOF: Add PCM operations support")
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Libin Yang <libin.yang@intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: SOF: core: fix error handling with the probe workqueue
Pierre-Louis Bossart [Fri, 24 May 2019 19:09:19 +0000 (14:09 -0500)] 
ASoC: SOF: core: fix error handling with the probe workqueue

In some configurations, it's a requirement to split the probe in two,
with a second part handled in a workqueue (e.g. for HDMI support
which depends on the DRM modules).

SOF already handles these configurations but the error flow is
incorrect. When an error occurs in the workqueue, the probe has
technically already completed. If we release the resources on errors,
this generates kernel oops/use-after-free when the resources are
released a second time on module removal.

GitHub issue: https://github.com/thesofproject/linux/issues/945
Fixes: c16211d6226 ("ASoC: SOF: Add Sound Open Firmware driver core")
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: SOF: core: remove snd_soc_unregister_component in case of error
Ranjani Sridharan [Fri, 24 May 2019 19:09:18 +0000 (14:09 -0500)] 
ASoC: SOF: core: remove snd_soc_unregister_component in case of error

No need to call snd_soc_unregister_component in case of error
because the component device is resource-managed.

Fixes: c16211d6226 ("ASoC: SOF: Add Sound Open Firmware driver core")
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: SOF: core: remove DSP after unregistering machine driver
Ranjani Sridharan [Fri, 24 May 2019 19:09:17 +0000 (14:09 -0500)] 
ASoC: SOF: core: remove DSP after unregistering machine driver

snd_sof_remove() disables the DSP and unmaps the DSP BAR.
Removing topology after disabling the DSP results in a
kernel panic while unloading the pipeline widget. This is
because pipeline widget unload attempts to power down
the core it is scheduled on by accessing the DSP registers.

So, the suggested fix here is to unregister the machine driver
first to remove the topology and then disable the DSP
to avoid the situation described above.

Note that the kernel panic only happens in cases where the
HDaudio link is not managed by the hdac library,
e.g. no codec or when HDMI is not supported.
When the hdac library is used, snd_sof_remove() calls
snd_hdac_ext_bus_device_remove() to remove the codec which
unregisters the component driver thereby also removing the
topology before the DSP is disabled.

Fixes: c16211d6226 ("ASoC: SOF: Add Sound Open Firmware driver core")
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: soc-core: fixup references at soc_cleanup_card_resources()
Kuninori Morimoto [Mon, 27 May 2019 07:51:34 +0000 (16:51 +0900)] 
ASoC: soc-core: fixup references at soc_cleanup_card_resources()

commit 53e947a0e1f7 ("ASoC: soc-core: merge card resources cleanup
method") merged cleanup method of snd_soc_instantiate_card() and
soc_cleanup_card_resources().

But, after this commit, if user uses unbind/bind to Component factor
drivers, Kernel might indicates refcount error at
soc_cleanup_card_resources().

The 1st reason is card->snd_card is still exist even though
snd_card_free() was called, but it is already cleaned.
We need to set NULL to it.

2nd is card->dapm and card create debugfs, but its dentry is still
exist even though it was removed. We need to set NULL to it.

Fixes: 53e947a0e1f7 ("ASoC: soc-core: merge card resources cleanup method")
Cc: stable@vger.kernel.org # for v5.1
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: core: lock client_mutex while removing link components
Ranjani Sridharan [Thu, 23 May 2019 17:12:01 +0000 (10:12 -0700)] 
ASoC: core: lock client_mutex while removing link components

Removing link components results in topology unloading. So,
acquire the client_mutex before removing components in
soc_remove_link_components. This will prevent the lockdep warning
seen when dai links are removed during topology removal.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: simple-card: Restore original configuration of DAI format
Jon Hunter [Fri, 24 May 2019 08:54:04 +0000 (09:54 +0100)] 
ASoC: simple-card: Restore original configuration of DAI format

Revert commit 069d037aea98 ("ASoC: simple-card: Fix configuration of
DAI format"). During further review, it turns out that the actual issue
was caused by an incorrectly formatted device-tree node describing the
soundcard.

The following is incorrect because the simple-audio-card
'bitclock-master' and 'frame-master' properties should not reference the
actual codec phandle ...

sound {
compatible = "simple-audio-card";
...
=> simple-audio-card,bitclock-master = <&codec>;
=> simple-audio-card,frame-master = <&codec>;
...

simple-audio-card,cpu {
sound-dai = <&xxx>;
};

simple-audio-card,codec {
=> sound-dai = <&codec>;
};
};

Rather, these properties should reference the phandle to the
'simple-audio-card,codec' property as shown below ...

sound {
compatible = "simple-audio-card";
...
=> simple-audio-card,bitclock-master = <&codec>;
=> simple-audio-card,frame-master = <&codec>;
...

simple-audio-card,cpu {
sound-dai = <&xxx>;
};

=> codec: simple-audio-card,codec { /* simple-card wants here */
sound-dai = <&xxx>;  /* not here */
};
};

Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: Intel: sof-rt5682: fix AMP quirk support
Sathya Prakash M R [Mon, 20 May 2019 19:46:42 +0000 (14:46 -0500)] 
ASoC: Intel: sof-rt5682: fix AMP quirk support

The use of BIT/GENMASK was incorrect, fix.

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>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: Intel: sof-rt5682: fix for codec button mapping
Sathya Prakash M R [Mon, 20 May 2019 19:46:41 +0000 (14:46 -0500)] 
ASoC: Intel: sof-rt5682: fix for codec button mapping

The RT5682 codec button mapping, initially copied from the DA7219 one,
needs to be corrected.

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>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: simple-card: Fix configuration of DAI format
Jon Hunter [Thu, 16 May 2019 17:51:26 +0000 (18:51 +0100)] 
ASoC: simple-card: Fix configuration of DAI format

When configuring a codec to be both bit-clock and frame-master, it was
found that the codec was always configured as bit-clock and frame-slave.
Looking at the simple_dai_link_of() function there appears to be two
problems with the configuration of the DAI format, which are ...

1. The function asoc_simple_parse_daifmt() is called before the function
   asoc_simple_parse_codec() and this means that the device-tree node
   for the codec has not been parsed yet, which is needed by the
   function asoc_simple_parse_daifmt() to determine who is the codec.
2. The phandle passed to asoc_simple_parse_daifmt() is the phandle to
   the 'codec' node and not the phandle of the actual codec defined by
   the 'sound-dai' property under the 'codec' node.

Fix the above by moving the call to asoc_simple_parse_daifmt() after the
the call to asoc_simple_parse_codec() and pass the phandle for the codec
to asoc_simple_parse_daifmt().

Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: Intel: soc-acpi: Fix machine selection order
Sathya Prakash M R [Sat, 18 May 2019 18:30:08 +0000 (13:30 -0500)] 
ASoC: Intel: soc-acpi: Fix machine selection order

The selection order of m/c in match table is corrected
to use common codec as last in the list.

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>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: rt5677-spi: Handle over reading when flipping bytes
Curtis Malainey [Fri, 17 May 2019 01:43:40 +0000 (18:43 -0700)] 
ASoC: rt5677-spi: Handle over reading when flipping bytes

There is a case when a we want to read a large number of bytes that
require a burst but is not a multiple of the word size (8). When this
happens rt5677_spi_reverse will run off the end of the buffer. The
solution is to tell spi_reverse the actual size of the destination and
stop if we reach it even if we have data left that we read.

Cc: Ben Zhang <benzh@chromium.org>
Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: soc-dpm: fixup DAI active unbalance
Kuninori Morimoto [Fri, 17 May 2019 01:21:12 +0000 (10:21 +0900)] 
ASoC: soc-dpm: fixup DAI active unbalance

snd_soc_dai_link_event() is updating snd_soc_dai :: active,
but it is unbalance.
It counts up if it has startup callback.

case SND_SOC_DAPM_PRE_PMU:
...
snd_soc_dapm_widget_for_each_source_path(w, path) {
...
if (source->driver->ops->startup) {
...
=> source->active++;
}
...
}
...

But, always counts down

case SND_SOC_DAPM_PRE_PMD:
...
snd_soc_dapm_widget_for_each_source_path(w, path) {
...
=> source->active--;
...
}

This patch always counts up when SND_SOC_DAPM_PRE_PMD.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: cs42xx8: Add regcache mask dirty
S.j. Wang [Thu, 16 May 2019 06:04:29 +0000 (06:04 +0000)] 
ASoC: cs42xx8: Add regcache mask dirty

Add regcache_mark_dirty before regcache_sync for power
of codec may be lost at suspend, then all the register
need to be reconfigured.

Fixes: 0c516b4ff85c ("ASoC: cs42xx8: Add codec driver
support for CS42448/CS42888")
Cc: <stable@vger.kernel.org>
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: fsl_asrc: Fix the issue about unsupported rate
S.j. Wang [Wed, 15 May 2019 06:42:18 +0000 (06:42 +0000)] 
ASoC: fsl_asrc: Fix the issue about unsupported rate

When the output sample rate is [8kHz, 30kHz], the limitation
of the supported ratio range is [1/24, 8]. In the driver
we use (8kHz, 30kHz) instead of [8kHz, 30kHz].
So this patch is to fix this issue and the potential rounding
issue with divider.

Fixes: fff6e03c7b65 ("ASoC: fsl_asrc: add support for 8-30kHz
output sample rate")
Cc: <stable@vger.kernel.org>
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Acked-by: Nicolin Chen <nicoleotsuka@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: ak4458: rstn_control - return a non-zero on error only
Viorel Suman [Mon, 13 May 2019 10:02:42 +0000 (10:02 +0000)] 
ASoC: ak4458: rstn_control - return a non-zero on error only

snd_soc_component_update_bits() may return 1 if operation
was successful and the value of the register changed.
Return a non-zero in ak4458_rstn_control for an error only.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: soc-pcm: BE dai needs prepare when pause release after resume
Libin Yang [Wed, 8 May 2019 02:32:41 +0000 (10:32 +0800)] 
ASoC: soc-pcm: BE dai needs prepare when pause release after resume

If playback/capture is paused and system enters S3, after system returns
from suspend, BE dai needs to call prepare() callback when playback/capture
is released from pause if RESUME_INFO flag is not set.

Currently, the dpcm_be_dai_prepare() function will block calling prepare()
if the pcm is in SND_SOC_DPCM_STATE_PAUSED state. This will cause the
following test case fail if the pcm uses BE:

playback -> pause -> S3 suspend -> S3 resume -> pause release

The playback may exit abnormally when pause is released because the BE dai
prepare() is not called.

This patch allows dpcm_be_dai_prepare() to call dai prepare() callback in
SND_SOC_DPCM_STATE_PAUSED state.

Signed-off-by: Libin Yang <libin.yang@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: ak4458: add return value for ak4458_probe
Viorel Suman [Thu, 9 May 2019 13:30:36 +0000 (13:30 +0000)] 
ASoC: ak4458: add return value for ak4458_probe

AK4458 is probed successfully even if AK4458 is not present - this
is caused by probe function returning no error on i2c access failure.
Return an error on probe if i2c access has failed.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC : cs4265 : readable register too low
Matt Flax [Wed, 8 May 2019 06:33:13 +0000 (16:33 +1000)] 
ASoC : cs4265 : readable register too low

The cs4265_readable_register function stopped short of the maximum
register.

An example bug is taken from :
https://github.com/Audio-Injector/Ultra/issues/25

Where alsactl store fails with :
Cannot read control '2,0,0,C Data Buffer,0': Input/output error

This patch fixes the bug by setting the cs4265 to have readable
registers up to the maximum hardware register CS4265_MAX_REGISTER.

Signed-off-by: Matt Flax <flatmax@flatmax.org>
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: SOF: fix error in verbose ipc command parsing
Ranjani Sridharan [Thu, 9 May 2019 20:10:25 +0000 (15:10 -0500)] 
ASoC: SOF: fix error in verbose ipc command parsing

Remove the erroneous addition of "SET_VALUE" to the GLB
IPC command string.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: SOF: fix race in FW boot timeout handling
Kai Vehmanen [Thu, 9 May 2019 20:10:23 +0000 (15:10 -0500)] 
ASoC: SOF: fix race in FW boot timeout handling

A race condition exists in handling firmware boot timeout.
If FW sends FW_READY just after boot timeout has expired in
driver, a kernel exception will result as FW_READY handler
will be run while the state is still being cleaned up in
snd_sof_run_firmware(). Avoid the race by setting
boot_complete also in the error case.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: SOF: nocodec: fix undefined reference
Pierre-Louis Bossart [Fri, 10 May 2019 16:38:03 +0000 (11:38 -0500)] 
ASoC: SOF: nocodec: fix undefined reference

The nocodec option can be selected individually, leading to the following
issue:

sound/soc/sof/core.o: In function `snd_sof_device_probe':
core.c:(.text+0x4af): undefined reference to `sof_nocodec_setup'

Fix by selecting the SND_SOF_NOCODEC option as needed.

Reported-by: Hulk Robot <hulkci@huawei.com>
Reported-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: SOF: Fix unused variable warnings
Takashi Iwai [Wed, 8 May 2019 08:50:37 +0000 (10:50 +0200)] 
ASoC: SOF: Fix unused variable warnings

The recent fix for the build fix caused a couple of unused variable
compiler warnings when CONFIG_SND_SOC_SOF_NOCODEC isn't set:
  sound/soc/sof/core.c:263:6: warning: unused variable ‘ret’ [-Wunused-variable]
  sound/soc/sof/core.c:262:28: warning: unused variable ‘machine’ [-Wunused-variable]

Fix them by adding another ifdef.

Fixes: ce38a75089f7 ("ASoC: SOF: core: fix undefined nocodec reference")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: stm32: i2s: update pcm hardware constraints
Olivier Moysan [Mon, 6 May 2019 12:54:11 +0000 (14:54 +0200)] 
ASoC: stm32: i2s: update pcm hardware constraints

- Set period minimum size. Ensure at least 5ms period
up to 48kHz/16 bits to prevent underrun/overrun.
- Remove MDMA constraints on period maximum size and
set period maximum to half the buffer maximum size.

Signed-off-by: Olivier Moysan <olivier.moysan@st.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: codec: hdac_hdmi: no checking monitor in hw_params
Libin Yang [Tue, 7 May 2019 06:33:11 +0000 (14:33 +0800)] 
ASoC: codec: hdac_hdmi: no checking monitor in hw_params

Some userspace apps, like pulseaudio, may call open, hw_params,
prepare to judge whether the pcm is ready or not. Current hdac_hdmi
will return -ENODEV if monitor is not connected, which will cause
the apps believe the pcm is not ready. Actually PCM for hdmi is ready,
even the monitor is not connected.

This patch removes the check of monitor presence in hw_params, just like
what the legacy HD-Audio driver does.

Signed-off-by: Libin Yang <libin.yang@intel.com>
Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: mediatek: mt6358: save PGA for mixer control
Tzung-Bi Shih [Tue, 7 May 2019 10:12:20 +0000 (18:12 +0800)] 
ASoC: mediatek: mt6358: save PGA for mixer control

mt6358_amic_disable() resets PGA to 0.

Save the gain settings from mixer control and restore them when using
the microphone.

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: mediatek: mt6358: save output volume for mixer controls
Tzung-Bi Shih [Tue, 7 May 2019 10:12:19 +0000 (18:12 +0800)] 
ASoC: mediatek: mt6358: save output volume for mixer controls

Output volume settings from mixer controls would be lost.

Imagine that "Headphone Volume" has set to -10dB via amixer:
- in mtk_hp_enable()
  - hp_store_gain() saves the volume setting -10dB from regmap_read()
    to ana_gain[AUDIO_ANALOG_VOLUME_HPOUTL]
  - headset_volume_ramp() ramps up from -10dB to -10dB
- in mtk_hp_disable()
  - headset_volume_ramp() ramps down from -10dB to -40dB

Next time in mtk_hp_enable(), hp_store_gain() would save -40dB but
not -10dB.  As a result, headset_volume_ramp() would ramp from -10dB to
-40dB (which is mute).

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: mediatek: mt6358: initialize setting when ramping volume
Tzung-Bi Shih [Tue, 7 May 2019 10:12:18 +0000 (18:12 +0800)] 
ASoC: mediatek: mt6358: initialize setting when ramping volume

Mt6358 ramps up from the smallest volume (i.e. -10dB) to target dB when
opening and ramps down from target dB to mute (i.e. -40dB) when closing.
If target is equal to -10dB when opening, headset_volume_ramp() simply
leaves current setting (which may not be -10dB) unchanged.

Execute the loop at least once to initialize the setting to the
starting point (i.e. from).

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: SOF: core: fix undefined nocodec reference
Pierre-Louis Bossart [Tue, 7 May 2019 16:32:36 +0000 (11:32 -0500)] 
ASoC: SOF: core: fix undefined nocodec reference

The existing code mistakenly uses IS_ENABLED in C code instead of as
in conditional compilation, leading to the following error:

ld: sound/soc/sof/core.o: in function `sof_machine_check':
sound/soc/sof/core.c:279: undefined reference to `sof_nocodec_setup'

Fix by using #if !IS_ENABLED()

Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: SOF: xtensa: fix undefined references
Pierre-Louis Bossart [Tue, 7 May 2019 16:32:35 +0000 (11:32 -0500)] 
ASoC: SOF: xtensa: fix undefined references

The SND_SOC_INTEL_COMMON Kconfig was removed months ago from SOF
Kconfig files but is still selected instead of the correct
SND_SOC_SOF_INTEL_COMMON kconfig which does select xtensa stuff,
leading to the following errors.

ld: sound/soc/sof/sof-acpi-dev.o:(.rodata+0x120): undefined reference
to `sof_xtensa_arch_ops'
ld: sound/soc/sof/sof-acpi-dev.o:(.rodata+0x180): undefined reference
to `sof_xtensa_arch_ops'
ld: sound/soc/sof/sof-acpi-dev.o:(.rodata+0x1e0): undefined reference
to `sof_xtensa_arch_ops'

Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: SOF: Propagate sof_get_ctrl_copy_params() error properly
Takashi Iwai [Tue, 7 May 2019 19:39:10 +0000 (21:39 +0200)] 
ASoC: SOF: Propagate sof_get_ctrl_copy_params() error properly

This fixes a compile warning below by properly handling the error code
from sof_get_ctrl_copy_params():
  include/linux/kernel.h:843:43: warning: 'sparams.pl_size' may be used uninitialized in this function [-Wmaybe-uninitialized]
  sound/soc/sof/ipc.c:639:34: note: 'sparams.pl_size' was declared here

The function returns an error before setting sparams.pl_size, so it'd
assign an uninitialized value at a later point.

Fixes: 53e0c72d98ba ("ASoC: SOF: Add support for IPC IO between DSP and Host")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: rockchip: Fix an uninitialized variable compile warning
Takashi Iwai [Mon, 6 May 2019 15:02:24 +0000 (17:02 +0200)] 
ASoC: rockchip: Fix an uninitialized variable compile warning

Paper over a trivial case leading to an uninitialized variable compile
warning:
  sound/soc/rockchip/rockchip_pdm.c:179:3: warning: ‘clk_out’ may be used uninitialized in this function [-Wmaybe-uninitialized]

Fixes: 624e8e00acaf ("ASoC: rockchip: pdm: fixup pdm fractional div")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: SOF: Fix a compile warning with CONFIG_PCI=n
Takashi Iwai [Mon, 6 May 2019 15:02:23 +0000 (17:02 +0200)] 
ASoC: SOF: Fix a compile warning with CONFIG_PCI=n

A trivial fix for the randconfig build error:
  sound/soc/sof/ops.c:20:6: warning: ‘ret’ is used uninitialized in this function [-Wuninitialized]

Fixes: d1d95fcb63e3 ("ASoC: SOF: Add DSP HW abstraction operations")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: da7219: Fix a compile warning at CONFIG_COMMON_CLK=n
Takashi Iwai [Mon, 6 May 2019 15:02:22 +0000 (17:02 +0200)] 
ASoC: da7219: Fix a compile warning at CONFIG_COMMON_CLK=n

A trivial fix for the randconfig build error:
  sound/soc/codecs/da7219.c:2366:6: warning: unused variable ‘i’ [-Wunused-variable]

Fixes: d90ba6c8b53e ("ASoC: da7219: Expose BCLK and WCLK control through CCF")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: sound/soc/sof/: fix kconfig dependency warning
Randy Dunlap [Mon, 6 May 2019 19:01:40 +0000 (12:01 -0700)] 
ASoC: sound/soc/sof/: fix kconfig dependency warning

Fix kconfig warning for unmet dependency for IOSF_MBI when
PCI is not set/enabled.  Fixes this warning:

WARNING: unmet direct dependencies detected for IOSF_MBI
  Depends on [n]: PCI [=n]
  Selected by [y]:
  - SND_SOC_SOF_ACPI [=y] && SOUND [=y] && !UML && SND [=y] && SND_SOC [=y] && SND_SOC_SOF_TOPLEVEL [=y] && (ACPI [=y] || COMPILE_TEST [=n]) && X86 [=y]

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: alsa-devel@alsa-project.org
Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: stm32: spdifrx: change trace level on iec control
Olivier Moysan [Mon, 6 May 2019 12:44:05 +0000 (14:44 +0200)] 
ASoC: stm32: spdifrx: change trace level on iec control

Change trace level to debug to avoid spurious messages.
Return quietly when accessing iec958 control, while no
S/PDIF signal is available.

Signed-off-by: Olivier Moysan <olivier.moysan@st.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: stm32: spdifrx: update pcm hardware constraints
Olivier Moysan [Mon, 6 May 2019 12:44:04 +0000 (14:44 +0200)] 
ASoC: stm32: spdifrx: update pcm hardware constraints

- Set period minimum size. Ensure at least 5ms period
up to 48kHz/16 bits to prevent underrun/overrun.
- Remove MDMA constraints on period maximum size and
set period maximum to half the buffer maximum size.

Signed-off-by: Olivier Moysan <olivier.moysan@st.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: max98090: Fix restore of DAPM Muxes
Jon Hunter [Wed, 1 May 2019 14:29:38 +0000 (15:29 +0100)] 
ASoC: max98090: Fix restore of DAPM Muxes

The max98090 driver defines 3 DAPM muxes; one for the right line output
(LINMOD Mux), one for the left headphone mixer source (MIXHPLSEL Mux)
and one for the right headphone mixer source (MIXHPRSEL Mux). The same
bit is used for the mux as well as the DAPM enable, and although the mux
can be correctly configured, after playback has completed, the mux will
be reset during the disable phase. This is preventing the state of these
muxes from being saved and restored correctly on system reboot. Fix this
by marking these muxes as SND_SOC_NOPM.

Note this has been verified this on the Tegra124 Nyan Big which features
the MAX98090 codec.

Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
5 years agoASoC: RT5677-SPI: Disable 16Bit SPI Transfers
Curtis Malainey [Fri, 3 May 2019 19:32:14 +0000 (12:32 -0700)] 
ASoC: RT5677-SPI: Disable 16Bit SPI Transfers

The current algorithm allows 3 types of transfers, 16bit, 32bit and
burst. According to Realtek, 16bit transfers have a special restriction
in that it is restricted to the memory region of
0x18020000 ~ 0x18021000. This region is the memory location of the I2C
registers. The current algorithm does not uphold this restriction and
therefore fails to complete writes.

Since this has been broken for some time it likely no one is using it.
Better to simply disable the 16 bit writes. This will allow users to
properly load firmware over SPI without data corruption.

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
Reviewed-by: Ben Zhang <benzh@chromium.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
5 years agoASoC: sprd: Add reserved DMA memory support
Baolin Wang [Fri, 12 Apr 2019 06:40:17 +0000 (14:40 +0800)] 
ASoC: sprd: Add reserved DMA memory support

For Spreadtrum audio platform driver, it need allocate a larger DMA buffer
dynamically to copy audio data between userspace and kernel space, but that
will increase the risk of memory allocation failure especially the system
is under heavy load situation.

To make sure the audio can work in this scenario, we usually reserve one
region of memory to be used as a shared pool of DMA buffers for the
platform component. So add of_reserved_mem_device_init_by_idx() function
to initialize the shared pool of DMA buffers to be used by the platform
component.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: Intel: kbl_da7219_max98357a: Map BTN_0 to KEY_PLAYPAUSE
Mac Chiang [Thu, 2 May 2019 06:12:04 +0000 (14:12 +0800)] 
ASoC: Intel: kbl_da7219_max98357a: Map BTN_0 to KEY_PLAYPAUSE

On kbl_rt5663_max98927, commit 38a5882e4292
    ("ASoC: Intel: kbl_rt5663_max98927: Map BTN_0 to KEY_PLAYPAUSE")
    This key pair mapping to play/pause when playing Youtube

The Android 3.5mm Headset jack specification mentions that BTN_0 should
be mapped to KEY_MEDIA, but this is less logical than KEY_PLAYPAUSE,
which has much broader userspace support.

For example, the Chrome OS userspace now supports KEY_PLAYPAUSE to toggle
play/pause of videos and audio, but does not handle KEY_MEDIA.

Furthermore, Android itself now supports KEY_PLAYPAUSE equivalently, as the
new USB headset spec requires KEY_PLAYPAUSE for BTN_0.
https://source.android.com/devices/accessories/headset/usb-headset-spec

The same fix is required on Chrome kbl_da7219_max98357a.

Signed-off-by: Mac Chiang <mac.chiang@intel.com>
Reviewed-by: Benson Leung <bleung@chromium.org>
Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: Intel: add sof-rt5682 machine driver
Bard liao [Tue, 30 Apr 2019 22:37:44 +0000 (17:37 -0500)] 
ASoC: Intel: add sof-rt5682 machine driver

The machine driver is a generic machine driver for SOF with rt5682
codec. it currently supports BYT/CHT/ICL/CML. Depending on the SOC
hdmi/speaker and DMIC support are added dynamically.

Only add information related to SOF since the machine driver was
only tested with SOF.

Signed-off-by: Sathya Prakash M R <sathya.prakash.m.r@intel.com>
Signed-off-by: Bard liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: Intel: skl_hda_dsp_generic:refine code style
Rander Wang [Tue, 30 Apr 2019 22:37:43 +0000 (17:37 -0500)] 
ASoC: Intel: skl_hda_dsp_generic:refine code style

Semicolon is better than comma.

Signed-off-by: Rander Wang <rander.wang@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: Intel: skl_hda_dsp_generic: add DMIC support
Rander Wang [Tue, 30 Apr 2019 22:37:42 +0000 (17:37 -0500)] 
ASoC: Intel: skl_hda_dsp_generic: add DMIC support

Add dmic dai links using naming conventions used in
previous machine drivers.

Tested on whiskylake & icelake with SOF driver. Due
to a missing topology file, the DMIC functionality
could not be tested with the Skylake driver but was
tested for non-regressions on a GeminiLake platform
without DMICs.

Signed-off-by: Rander Wang <rander.wang@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: SOF: Intel: CNL: add ipc dump function
Pan Xiuli [Tue, 30 Apr 2019 23:09:34 +0000 (18:09 -0500)] 
ASoC: SOF: Intel: CNL: add ipc dump function

Add ipc dump function to CNL+ platforms.

Signed-off-by: Pan Xiuli <xiuli.pan@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: SOF: Intel: APL: add ipc dump function
Pan Xiuli [Tue, 30 Apr 2019 23:09:33 +0000 (18:09 -0500)] 
ASoC: SOF: Intel: APL: add ipc dump function

Add IPC dump function for APL plaform

Signed-off-by: Pan Xiuli <xiuli.pan@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: SOF: IPC: add ipc dump function
Pan Xiuli [Tue, 30 Apr 2019 23:09:32 +0000 (18:09 -0500)] 
ASoC: SOF: IPC: add ipc dump function

Dump IPC status when IPC timed out. IPC status is platform specific and
need bind to plaform.

Signed-off-by: Pan Xiuli <xiuli.pan@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: SOF: intel: hda: add hw_params_upon_resume flag for hda stream
Ranjani Sridharan [Tue, 30 Apr 2019 23:09:31 +0000 (18:09 -0500)] 
ASoC: SOF: intel: hda: add hw_params_upon_resume flag for hda stream

The prepare() ioctl for BE dai link gets called both
when the stream is started and when it is resumed from
suspend. SOF uses this ioctl to set the hw params
again only if the stream has been suspended.

When the stream is started, the hw_params ioctl gets called
before prepare() and hw_params is set for the BE dai link.
So the prepare call does not need to do anything further.

When the stream resumes after system suspend, SOF requires
that the hw_params be set again for the BE dai. In order
to determine which streams should set the hw params
during prepare(), an internal flag called "hw_params_upon_resume"
is introduced in struct sof_intel_hda_stream. The flag is set
for hda streams when the sof device suspends and is
cleared after hw_params is set.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: SOF: Intel: hda-stream: handle real stream interrupts only
Keyon Jie [Tue, 30 Apr 2019 23:09:30 +0000 (18:09 -0500)] 
ASoC: SOF: Intel: hda-stream: handle real stream interrupts only

The stream and IPC share the same interrupt. The stream interrupt
handler mistakenly uses the ipc interrupt and return IRQ_HANDLED,
causing the ipc interrupt to be missed.

Make sure the stream interrupt handler only deals with stream-related
interrupts.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: SOF: Intel: hda-stream: store stream capabilities
Keyon Jie [Tue, 30 Apr 2019 23:09:29 +0000 (18:09 -0500)] 
ASoC: SOF: Intel: hda-stream: store stream capabilities

Add stream_max into struct sof_intel_hda_dev to store the total hda
stream number that the platform can support, and initialize it at
stream_init.

This can be used later e.g. for stream bitmask.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: SOF: Intel: hda-ipc: simplify handling of IPC IRQ
Keyon Jie [Tue, 30 Apr 2019 23:09:28 +0000 (18:09 -0500)] 
ASoC: SOF: Intel: hda-ipc: simplify handling of IPC IRQ

When using a shared IRQ between IPC interrupt and stream IOC interrupt,
the interrupt handlers need to check the interrupt source before
scheduling their respective IRQ threads. In the case of IPC handler, it
should check if it is an IPC interrupt before waking up the IPC IRQ
thread.

The IPC IRQ thread, once scheduled, does not need to check the IRQ
source again. So, remove the superfluous check in the thread. Remove the
irq_status field from snd_sof_dev struct also as it is no longer needed.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: SOF: ipc: use snd_sof_pcm_period_elapsed
Keyon Jie [Tue, 30 Apr 2019 23:09:27 +0000 (18:09 -0500)] 
ASoC: SOF: ipc: use snd_sof_pcm_period_elapsed

Switch to a wrapper function which schedules the actual call of
snd_pcm_period_elapsed after the current IPC is completed.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: SOF: Intel: use snd_sof_pcm_period_elapsed
Keyon Jie [Tue, 30 Apr 2019 23:09:26 +0000 (18:09 -0500)] 
ASoC: SOF: Intel: use snd_sof_pcm_period_elapsed

Switch to a wrapper function which schedules the actual call of
snd_pcm_period_elapsed after the current IPC is completed.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: SOF: PCM: add period_elapsed work to fix race condition in interrupt context
Keyon Jie [Tue, 30 Apr 2019 23:09:25 +0000 (18:09 -0500)] 
ASoC: SOF: PCM: add period_elapsed work to fix race condition in interrupt context

The IPC implementation in SOF requires sending IPCs serially: we should
not send a new IPC command to the firmware before we get an ACK (or time
out) from firmware, and the IRQ processing is complete.

snd_pcm_period_elapsed() can be called in interrupt context before
IRQ_HANDLED is returned. When the PCM is done draining, a STOP
IPC will then be sent, which breaks the expectation that IPCs are
handled serially and leads to IPC timeouts.

This patch adds a workqueue to defer the call to snd_pcm_elapsed() after
the IRQ is handled.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: SOF: Intel: hda-pcm: remove useless dependency on hdac_ext
Pierre-Louis Bossart [Tue, 30 Apr 2019 23:09:24 +0000 (18:09 -0500)] 
ASoC: SOF: Intel: hda-pcm: remove useless dependency on hdac_ext

Nothing depends on definitions in hdaudio_ext.h, don't include it

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: SOF: Intel: hda: set bus->idx as 0
Zhu Yingjiang [Tue, 30 Apr 2019 23:09:23 +0000 (18:09 -0500)] 
ASoC: SOF: Intel: hda: set bus->idx as 0

Setting the bus->idx as 0, for we only have one HDA
bus atm. This need to be fixed when there are more
than one HDA bus.

Signed-off-by: Zhu Yingjiang <yingjiang.zhu@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: SOF: Intel: hda: set I2S slave before enabling DSP
Zhu Yingjiang [Tue, 30 Apr 2019 23:09:22 +0000 (18:09 -0500)] 
ASoC: SOF: Intel: hda: set I2S slave before enabling DSP

By default, the I2S ports are configured in master mode during
DSP powerup sequences, the FS and BCLK lines will be driven on
startup, even when the topology file explicitly requires the
SSP to be slave.

This may be problematic for external components configured in
master mode who don't expect the Intel SOC/PCH to drive. Fix by
configuring the SSP as slave before the SSP outputs are enabled
to avoid this transient behavior.

When the topology file configures the SSP as clock master, the
initial slave configuration will be overridden.

Signed-off-by: Zhu Yingjiang <yingjiang.zhu@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: SOF: Intel: hda: add SSP info to the chip info struct
Zhu Yingjiang [Tue, 30 Apr 2019 23:09:21 +0000 (18:09 -0500)] 
ASoC: SOF: Intel: hda: add SSP info to the chip info struct

add SSP info of APL and CNL, to the sof_intel_dsp_desc
structure. The max SSP count the platform support and
the SSP base address.

Signed-off-by: Zhu Yingjiang <yingjiang.zhu@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
5 years agoASoC: SOF: Intel: hda: add the SSP Host Device memory space
Zhu Yingjiang [Tue, 30 Apr 2019 23:09:20 +0000 (18:09 -0500)] 
ASoC: SOF: Intel: hda: add the SSP Host Device memory space

The DSP SSP device memory can be conditionally accessed by
the host(depending on access policy).

Add the SSP base memory offset of APL and CNL.

Signed-off-by: Zhu Yingjiang <yingjiang.zhu@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>