platform/kernel/linux-rpi.git
2 years agoALSA: hda: Disable runtime resume at shutdown
Takashi Iwai [Thu, 26 Aug 2021 15:47:52 +0000 (17:47 +0200)]
ALSA: hda: Disable runtime resume at shutdown

Although we modified the codec shutdown callback to perform
runtime-suspend, it's still not fully effective, as this may be
resumed again at any time later.

For fixing such an unwanted resume, this patch replaces
pm_runtime_suspend() with pm_runtime_force_suspend(), and call
pm_runtime_disable() afterward.  It assures to keep the device
suspended.

Also for code simplification, we apply the code unconditionally; when
it's been already suspended, nothing would happen by calls of
snd_pcm_suspend_all() and pm_runtime_force_suspend(), just proceed to
pm_runtime_disable().

Fixes: b98444ed597d ("ALSA: hda: Suspend codec at shutdown")
Reported-and-tested-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210826154752.25674-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: usb-audio: Move set-interface-first workaround into common quirk
Takashi Iwai [Tue, 24 Aug 2021 05:57:20 +0000 (07:57 +0200)]
ALSA: usb-audio: Move set-interface-first workaround into common quirk

The recent quirk for WALKMAN (commit 7af5a14371c1: "ALSA: usb-audio:
Fix regression on Sony WALKMAN NW-A45 DAC") may be required for other
devices and is worth to be put into the common quirk flags.
This patch adds a new quirk flag bit QUIRK_FLAG_SET_IFACE_FIRST and a
quirk table entry for the device.

Link: https://lore.kernel.org/r/20210824055720.9240-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoMerge branch 'for-linus' into for-next
Takashi Iwai [Tue, 24 Aug 2021 05:52:41 +0000 (07:52 +0200)]
Merge branch 'for-linus' into for-next

2 years agoALSA: hda/realtek: Quirk for HP Spectre x360 14 amp setup
Johnathon Clark [Mon, 23 Aug 2021 16:21:10 +0000 (17:21 +0100)]
ALSA: hda/realtek: Quirk for HP Spectre x360 14 amp setup

This patch extends support for the HP Spectre x360 14
amp enable quirk to support a model of the device with
an additional subdevice ID.

Signed-off-by: Johnathon Clark <john.clark@cantab.net>
Link: https://lore.kernel.org/r/20210823162110.8870-1-john.clark@cantab.net
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: usb-audio: Fix regression on Sony WALKMAN NW-A45 DAC
Takashi Iwai [Tue, 24 Aug 2021 05:47:00 +0000 (07:47 +0200)]
ALSA: usb-audio: Fix regression on Sony WALKMAN NW-A45 DAC

We've got a regression report for USB-audio with Sony WALKMAN NW-A45
DAC device where no sound is audible on recent kernel.  The bisection
resulted in the code change wrt endpoint management, and the further
debug session revealed that it was caused by the order of the USB
audio interface.  In the earlier code, we always set up the USB
interface at first before other setups, but it was changed to be done
at the last for UAC2/3, which is more standard way, while keeping the
old way for UAC1.  OTOH, this device seems requiring the setup of the
interface at first just like UAC1.

This patch works around the regression by applying the interface setup
specifically for the WALKMAN at the beginning of the endpoint setup
procedure.  This change is written straightforwardly to be easily
backported in old kernels.  A further cleanup to move the workaround
into a generic quirk section will follow in a later patch.

Fixes: bf6313a0ff76 ("ALSA: usb-audio: Refactor endpoint management")
Cc: <stable@vger.kernel.org>
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=214105
Link: https://lore.kernel.org/r/20210824054700.8236-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoASoC: intel: atom: Revert PCM buffer address setup workaround again
Takashi Iwai [Sun, 22 Aug 2021 07:21:27 +0000 (09:21 +0200)]
ASoC: intel: atom: Revert PCM buffer address setup workaround again

We worked around the breakage of PCM buffer setup by the commit
65ca89c2b12c ("ASoC: intel: atom: Fix breakage for PCM buffer address
setup"), but this isn't necessary since the CONTINUOUS buffer type
also sets runtime->dma_addr since commit f84ba106a018 ("ALSA:
memalloc: Store snd_dma_buffer.addr for continuous pages, too").
Let's revert the change again.

Link: https://lore.kernel.org/r/20210822072127.9786-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoMerge branch 'for-linus' into for-next
Takashi Iwai [Mon, 23 Aug 2021 11:36:20 +0000 (13:36 +0200)]
Merge branch 'for-linus' into for-next

2 years agoALSA: doc: Fix indentation warning
Takashi Iwai [Mon, 23 Aug 2021 11:35:18 +0000 (13:35 +0200)]
ALSA: doc: Fix indentation warning

Fix a trivial warning for the indentation by putting an empty line:
  Documentation/sound/alsa-configuration.rst:2258: WARNING: Unexpected indentation.

Fixes: a39978ed6df1 ("ALSA: doc: Add the description of quirk_flags option for snd-usb-audio")
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Link: https://lore.kernel.org/r/20210823113518.30134-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda: Update documentation for aliasing via the model option
Takashi Iwai [Mon, 23 Aug 2021 07:37:22 +0000 (09:37 +0200)]
ALSA: hda: Update documentation for aliasing via the model option

The previous patch allowed user to specify the aliasing of SSID via
model option for applying a quirk.  Update the documentation
accordingly.

Link: https://lore.kernel.org/r/20210823073722.14873-4-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda: Allow model option to specify PCI SSID alias
Takashi Iwai [Mon, 23 Aug 2021 07:37:21 +0000 (09:37 +0200)]
ALSA: hda: Allow model option to specify PCI SSID alias

There are tons of quirks for HD-audio and many of them are without
model string, hence it's not trivial to apply the same quirk for a new
device.  This patch makes it easier: namely, the model string accepts
a form as "XXXX:YYYY" (a pair of hex numbers of the subsystem-vendor
and subsystem-device IDs), to specify the alias of PCI (or codec)
SSID.  e.g. passing model=1234:abcd would apply the quirk that matches
with the given SSID 1234:abcd instead of the actual SSID.

Link: https://lore.kernel.org/r/20210823073722.14873-3-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda: Code refactoring snd_hda_pick_fixup()
Takashi Iwai [Mon, 23 Aug 2021 07:37:20 +0000 (09:37 +0200)]
ALSA: hda: Code refactoring snd_hda_pick_fixup()

This contains a slight code refactoring of snd_hda_pick_fixup():
- Unify the ID setup
- Unify the debug print message
- Use snd_pci_quirk_lookup_id() for the codec SSID matching

Mostly for simplifying the code flow but also it makes easier to add
the codec alias handling in the upcoming patch.

Link: https://lore.kernel.org/r/20210823073722.14873-2-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: firewire-motu: add support for MOTU 896HD
Takashi Sakamoto [Mon, 23 Aug 2021 08:57:41 +0000 (17:57 +0900)]
ALSA: firewire-motu: add support for MOTU 896HD

Mark of the Unicorn (MOTU) shipped 896HD 2003 as one of models in second
generation of its FireWire series, and already discontinued it. The model
consists of below ICs:

 * Texas Instruments TSB41AB2
 * Phillips Semiconductors PDI1394L40
 * Altera cyclone EP1C3
 * Texas Instruments TMS320VC5402

It supports sampling transmission frequency up to 192.0 kHz. The packet
format differs depending on both of sampling transfer frequency and enabling
ADAT channels. The model doesn't support MIDI message transmission.

This commit adds support for it.

$ python3 crpp < /sys/bus/firewire/devices/fw1/config_rom
               ROM header and bus information block
               -----------------------------------------------------------------
400  04101b66  bus_info_length 4, crc_length 16, crc 7014
404  31333934  bus_name "1394"
408  20001000  irmc 0, cmc 0, isc 1, bmc 0, cyc_clk_acc 0, max_rec 1 (4)
40c  0001f200  company_id 0001f2     |
410  0001dbce  device_id 000001dbce  | EUI-64 0001f2000001dbce

               root directory
               -----------------------------------------------------------------
414  0004c65c  directory_length 4, crc 50780
418  030001f2  vendor
41c  0c0083c0  node capabilities per IEEE 1394
420  8d000006  --> eui-64 leaf at 438
424  d1000001  --> unit directory at 428

               unit directory at 428
               -----------------------------------------------------------------
428  0003dcc1  directory_length 3, crc 56513
42c  120001f2  specifier id
430  13000005  version
434  17102800  model

               eui-64 leaf at 438
               -----------------------------------------------------------------
438  000264f2  leaf_length 2, crc 25842
43c  0001f200  company_id 0001f2     |
440  0001dbce  device_id 000001dbce  | EUI-64 0001f2000001dbce

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210823085741.33864-1-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda/realtek: Workaround for conflicting SSID on ASUS ROG Strix G17
Takashi Iwai [Fri, 20 Aug 2021 14:32:14 +0000 (16:32 +0200)]
ALSA: hda/realtek: Workaround for conflicting SSID on ASUS ROG Strix G17

ASUS ROG Strix G17 has the very same PCI and codec SSID (1043:103f) as
ASUS TX300, and unfortunately, the existing quirk for TX300 is broken
on ASUS ROG.  Actually the device works without the quirk, so we'll
need to clear the quirk before applying for this device.
Since ASUS ROG has a different codec (ALC294 - while TX300 has
ALC282), this patch adds a workaround for the device, just clearing
the codec->fixup_id by checking the codec vendor_id.

It's a bit ugly to add such a workaround there, but it seems to be the
simplest way.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=214101
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210820143214.3654-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoASoC: intel: atom: Fix breakage for PCM buffer address setup
Takashi Iwai [Thu, 19 Aug 2021 15:29:45 +0000 (17:29 +0200)]
ASoC: intel: atom: Fix breakage for PCM buffer address setup

The commit 2e6b836312a4 ("ASoC: intel: atom: Fix reference to PCM
buffer address") changed the reference of PCM buffer address to
substream->runtime->dma_addr as the buffer address may change
dynamically.  However, I forgot that the dma_addr field is still not
set up for the CONTINUOUS buffer type (that this driver uses) yet in
5.14 and earlier kernels, and it resulted in garbage I/O.  The problem
will be fixed in 5.15, but we need to address it quickly for now.

The fix is to deduce the address again from the DMA pointer with
virt_to_phys(), but from the right one, substream->runtime->dma_area.

Fixes: 2e6b836312a4 ("ASoC: intel: atom: Fix reference to PCM buffer address")
Reported-and-tested-by: Hans de Goede <hdegoede@redhat.com>
Cc: <stable@vger.kernel.org>
Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/2048c6aa-2187-46bd-6772-36a4fb3c5aeb@redhat.com
Link: https://lore.kernel.org/r/20210819152945.8510-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda/realtek: Limit mic boost on HP ProBook 445 G8
Kai-Heng Feng [Wed, 18 Aug 2021 14:41:18 +0000 (22:41 +0800)]
ALSA: hda/realtek: Limit mic boost on HP ProBook 445 G8

The mic has lots of noises if mic boost is enabled. So disable mic boost
to get crystal clear audio capture.

Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210818144119.121738-1-kai.heng.feng@canonical.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda/analog - Sink ad198x_shutup() and shuffle CONFIG_PM guards
Nathan Chancellor [Wed, 18 Aug 2021 01:27:05 +0000 (18:27 -0700)]
ALSA: hda/analog - Sink ad198x_shutup() and shuffle CONFIG_PM guards

When CONFIG_PM is not set, there is an unused function warning:

sound/pci/hda/patch_analog.c:115:13: warning: unused function
'ad198x_shutup' [-Wunused-function]
static void ad198x_shutup(struct hda_codec *codec)
            ^
1 warning generated.

Sink ad198x_shutup() into ad198x_suspend(), as it is only called in that
one space. Move the CONFIG_PM guards above ad198x_power_eapd_write() as
it is only called in ad198x_power_eapd(), which is in turn only called
in ad198x_power_eapd(). Those two functions are large enough that they
are left alone.

Fixes: 327b34f2a97d ("ALSA: hda: Nuke unused reboot_notify callback")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20210818012705.311963-2-nathan@kernel.org
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda/sigmatel - Sink stac_shutup() into stac_suspend()
Nathan Chancellor [Wed, 18 Aug 2021 01:27:04 +0000 (18:27 -0700)]
ALSA: hda/sigmatel - Sink stac_shutup() into stac_suspend()

When CONFIG_PM is not set, there is an unused function warning:

sound/pci/hda/patch_sigmatel.c:4383:13: warning: unused function
'stac_shutup' [-Wunused-function]
static void stac_shutup(struct hda_codec *codec)
            ^
1 warning generated.

Sink the contents of stac_shutup() into stac_suspend() since
stac_shutup() is only called in that one location now.

Fixes: 327b34f2a97d ("ALSA: hda: Nuke unused reboot_notify callback")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20210818012705.311963-1-nathan@kernel.org
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda: Drop workaround for a hang at shutdown again
Takashi Iwai [Tue, 17 Aug 2021 07:56:30 +0000 (09:56 +0200)]
ALSA: hda: Drop workaround for a hang at shutdown again

The commit 0165c4e19f6e ("ALSA: hda: Fix hang during shutdown due to
link reset") modified the shutdown callback of the HD-audio controller
for working around a hang.  Meanwhile, the actual culprit of the hang
was identified to be the leftover active codecs that may interfere
with the powered down controller somehow, but we took a minimal fix
approach for 5.14, and that was the commit above.

Now, since the codec drivers go runtime-suspend at shutdown for 5.15,
we can revert the change and make sure that the full runtime-suspend
is performed at shutdown of HD-audio controller again.  This patch
essentially reverts the commit above to restore the behavior.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=214045
Link: https://lore.kernel.org/r/20210817075630.7115-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoMerge branch 'for-linus' into for-next
Takashi Iwai [Tue, 17 Aug 2021 07:46:27 +0000 (09:46 +0200)]
Merge branch 'for-linus' into for-next

2 years agoALSA: hda/via: Apply runtime PM workaround for ASUS B23E
Takashi Iwai [Tue, 17 Aug 2021 05:24:32 +0000 (07:24 +0200)]
ALSA: hda/via: Apply runtime PM workaround for ASUS B23E

ASUS B23E requires the same workaround like other machines with
VT1802, otherwise it looses the codec power on a few nodes and the
sound kept silence.

Fixes: a0645daf1610 ("ALSA: HDA: Early Forbid of runtime PM")
Link: https://lore.kernel.org/r/ac2232f142efcd67fe6ac38897f704f7176bd200.camel@gmail.com
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210817052432.14751-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda: Fix hang during shutdown due to link reset
Imre Deak [Mon, 16 Aug 2021 17:42:59 +0000 (20:42 +0300)]
ALSA: hda: Fix hang during shutdown due to link reset

During system shutdown codecs may be still active, and resetting the
controller->codec HW link in this state - based on the bug reporter's
tests - leads to the shutdown sequence to get stuck. This happens at
least on the reporter's KBL system with an ALC662 codec.

For now fix the issue by skipping the link reset step.

Fixes: 472e18f63c42 ("ALSA: hda: Release controller display power during shutdown/reboot")
References: https://bugzilla.kernel.org/show_bug.cgi?id=214045
References: https://gitlab.freedesktop.org/drm/intel/-/issues/3618#note_1024665
Reported-and-tested-by: youling257@gmail.com
Cc: youling257@gmail.com
Signed-off-by: Imre Deak <imre.deak@intel.com>
Link: https://lore.kernel.org/r/20210816174259.2759103-1-imre.deak@intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda/realtek: Enable 4-speaker output for Dell XPS 15 9510 laptop
Kristin Paget [Sat, 14 Aug 2021 22:46:05 +0000 (15:46 -0700)]
ALSA: hda/realtek: Enable 4-speaker output for Dell XPS 15 9510 laptop

The 2021-model XPS 15 appears to use the same 4-speakers-on-ALC289 audio
setup as the Precision models, so requires the same quirk to enable woofer
output. Tested on my own 9510.

Signed-off-by: Kristin Paget <kristin@tombom.co.uk>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/e1fc95c5-c10a-1f98-a5c2-dd6e336157e1@tombom.co.uk
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda: Nuke unused reboot_notify callback
Takashi Iwai [Fri, 13 Aug 2021 08:12:30 +0000 (10:12 +0200)]
ALSA: hda: Nuke unused reboot_notify callback

As reboot_notify callback is no longer used by the codec core, let's
get rid of the unused code.  Conexant codec needs a slight code change
as it used to call the reboot_notify at the codec removal, too.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=214045
Link: https://lore.kernel.org/r/20210813081230.4268-4-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda: Suspend codec at shutdown
Takashi Iwai [Fri, 13 Aug 2021 08:12:29 +0000 (10:12 +0200)]
ALSA: hda: Suspend codec at shutdown

So far we have a few workarounds at shutdown for each codec,
e.g. turning off the display power and setting the codec to D3.
But all those are basically a part of the suspend procedure.
Moreover, the streams are still active after that call, hence it might
hit the update on the codec that has been already put to D3.

In this patch, instead of calling each reboot_notify callback, simply
put the codec into the runtime-suspended state after the manual
suspend of all PCM streams.  It makes the code and the behavior more
consistent.

The reboot_notify callback is no longer used after this patch, and
will be cleaned up later.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=214045
Link: https://lore.kernel.org/r/20210813081230.4268-3-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda: conexant: Turn off EAPD at suspend, too
Takashi Iwai [Fri, 13 Aug 2021 08:12:28 +0000 (10:12 +0200)]
ALSA: hda: conexant: Turn off EAPD at suspend, too

Conexant codecs have a workaround for the noise at shutdown to turn
off EAPD, but it wasn't applied at suspend.  In the later patch, we'll
switch from reboot_notify callback to the general suspend-at-shutdown,
so let's apply the workaround to the suspend case, too.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=214045
Link: https://lore.kernel.org/r/20210813081230.4268-2-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: pcm: Add SNDRV_PCM_INFO_EXPLICIT_SYNC flag
Takashi Iwai [Fri, 13 Aug 2021 08:21:42 +0000 (10:21 +0200)]
ALSA: pcm: Add SNDRV_PCM_INFO_EXPLICIT_SYNC flag

ALSA PCM core has an optimized way to communicate with user-space for
its control and status data via mmap on the supported architectures
like x86.  Depending on the situation, however, we'd rather want to
enforce user-space notifying the applptr or hwptr change explicitly
via ioctl.  For example, the upcoming non-contig and non-coherent
buffer handling would need an explicit sync, and this needs to catch
the applptr and hwptr changes.  Also, ASoC SOF driver will have the
SPIB support that has the similar requirement for the explicit control
of the applptr and hwptr.

This patch adds the new PCM hardware info flag,
SNDRV_PCM_INFO_EXPLICIT_SYNC.  When this flag is set, PCM core
disables both the control and the status mmap, which enforces
user-space to update via SYNC_PTR ioctl.  In that way, drivers can
catch the applptr and hwptr update and apply the sync operation if
needed.

Link: https://lore.kernel.org/r/20210812113818.6479-1-tiwai@suse.de
Link: https://lore.kernel.org/r/20210610205326.1176400-1-pierre-louis.bossart@linux.intel.com
Link: https://lore.kernel.org/r/20210813082142.5375-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: usb-audio: Input source control - digidesign mbox
Damien Zammit [Fri, 13 Aug 2021 11:34:02 +0000 (21:34 +1000)]
ALSA: usb-audio: Input source control - digidesign mbox

This adds a second mixer control to Digidesign Mbox
to select between Analog/SPDIF capture.

Users will note that selecting the SPDIF input source
automatically switches the clock mode to sync to SPDIF,
which is a feature of the hardware.

(You can change the clock source back to internal if you want
to capture from spdif but not sync to its clock although this mode
is probably not recommended).

Unfortunately, starting the stream resets both modes
to Internally clocked and Analog input mode.

Signed-off-by: Damien Zammit <damien@zamaudio.com>
Tested-by: Damien Zammit <damien@zamaudio.com>
Link: https://lore.kernel.org/r/20210813113402.11849-1-damien@zamaudio.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: memalloc: Count continuous pages in vmalloc buffer handler
Takashi Iwai [Fri, 13 Aug 2021 08:16:45 +0000 (10:16 +0200)]
ALSA: memalloc: Count continuous pages in vmalloc buffer handler

This is an enhancement for the SG-style page handling in vmalloc
buffer handler to calculate the continuous pages.
When snd_sgbuf_get_chunk_size() is called for a vmalloc buffer,
currently we return only the size that fits into a single page.
However, this API call is rather supposed for obtaining the continuous
pages and most of vmalloc or noncontig buffers do have lots of
continuous pages indeed.  So, in this patch, the callback now
calculates the possibly continuous pages up to the given size limit.

Note that the end address in the function is calculated from the last
byte, hence it's one byte shorter.  This is because ofs + size can be
above the actual buffer size boundary.

Until now, this feature isn't really used, but it'll become useful in
a later patch that adds the non-contiguous buffer type that shares the
same callback function as vmalloc.

Link: https://lore.kernel.org/r/20210812113818.6479-1-tiwai@suse.de
Link: https://lore.kernel.org/r/20210813081645.4680-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda/cs8409: Prevent pops and clicks during suspend
Stefan Binding [Thu, 12 Aug 2021 18:34:32 +0000 (19:34 +0100)]
ALSA: hda/cs8409: Prevent pops and clicks during suspend

Some of the register values set for type detection cause pops during suspend,
ensure these are cleaned up after type detection completes, as well
ensuring that these are cleared when we suspend.

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210812183433.6330-1-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda_audio_ext: fix kernel-doc
Pierre-Louis Bossart [Thu, 12 Aug 2021 22:59:04 +0000 (17:59 -0500)]
ALSA: hda_audio_ext: fix kernel-doc

Add missing @

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20210812225904.171529-3-pierre-louis.bossart@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: core: control_led: use strscpy instead of strlcpy
Pierre-Louis Bossart [Thu, 12 Aug 2021 22:59:03 +0000 (17:59 -0500)]
ALSA: core: control_led: use strscpy instead of strlcpy

strlcpy is deprecated, use its safe replacement

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Bard Liao <bard.liao@intel.com>
Reviewed-by: Paul Olaru <paul.olaru@oss.nxp.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20210812225904.171529-2-pierre-louis.bossart@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda/cs8409: Unmute/Mute codec when stream starts/stops
Stefan Binding [Wed, 11 Aug 2021 18:56:54 +0000 (19:56 +0100)]
ALSA: hda/cs8409: Unmute/Mute codec when stream starts/stops

Codec is muted on init, and then unmuted when the stream starts.

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210811185654.6837-28-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda/cs8409: Follow correct CS42L42 power down sequence for suspend
Stefan Binding [Wed, 11 Aug 2021 18:56:53 +0000 (19:56 +0100)]
ALSA: hda/cs8409: Follow correct CS42L42 power down sequence for suspend

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210811185654.6837-27-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda/cs8409: Remove unnecessary delays
Stefan Binding [Wed, 11 Aug 2021 18:56:52 +0000 (19:56 +0100)]
ALSA: hda/cs8409: Remove unnecessary delays

Since delays when starting jack detection after initialization
have been reduced/removed, it is necessary to add back in an extra
20ms delay after the init sequence to allow the CS42L42 to power up
correctly.

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210811185654.6837-26-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda/cs8409: Use timeout rather than retries for I2C transaction waits
Stefan Binding [Wed, 11 Aug 2021 18:56:51 +0000 (19:56 +0100)]
ALSA: hda/cs8409: Use timeout rather than retries for I2C transaction waits

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210811185654.6837-25-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda/cs8409: Set fixed sample rate of 48kHz for CS42L42
Stefan Binding [Wed, 11 Aug 2021 18:56:50 +0000 (19:56 +0100)]
ALSA: hda/cs8409: Set fixed sample rate of 48kHz for CS42L42

CS42L42 is configured to use a fixed sample rate of 48kHz.

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210811185654.6837-24-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda/cs8409: Enable Full Scale Volume for Line Out Codec on Dolphin
Stefan Binding [Wed, 11 Aug 2021 18:56:49 +0000 (19:56 +0100)]
ALSA: hda/cs8409: Enable Full Scale Volume for Line Out Codec on Dolphin

Headphones codec will keep reduced maximum volume.
Line Out codec will have increased maximum volume.

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210811185654.6837-23-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda/cs8409: Add support for dolphin
Lucas Tanure [Wed, 11 Aug 2021 18:56:48 +0000 (19:56 +0100)]
ALSA: hda/cs8409: Add support for dolphin

Dolphin devices have CS8409 HDA Bridge connected to two CS42L42 codecs.
Codec 1 supports Headphone and Headset Mic.
Codec 2 supports Line Out.

Features:
 - Front and Read Jacks appear as separate jacks; Removal or connection
   of on jack should not affect the connection of the other.
 - Front Jack only shows up on jack detection.
 - Rear Jack is Phantom Jack.
 - Separate Volume Controls for each Jack

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210811185654.6837-22-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda/cs8409: Add Support to disable jack type detection for CS42L42
Stefan Binding [Wed, 11 Aug 2021 18:56:47 +0000 (19:56 +0100)]
ALSA: hda/cs8409: Add Support to disable jack type detection for CS42L42

Some hardware configurations do not support jack type detection.
Instead, for those configurations, only tip detection is supported.

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210811185654.6837-21-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda/cs8409: Support multiple sub_codecs for Suspend/Resume/Unsol events
Stefan Binding [Wed, 11 Aug 2021 18:56:46 +0000 (19:56 +0100)]
ALSA: hda/cs8409: Support multiple sub_codecs for Suspend/Resume/Unsol events

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210811185654.6837-20-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda/cs8409: Move codec properties to its own struct
Lucas Tanure [Wed, 11 Aug 2021 18:56:45 +0000 (19:56 +0100)]
ALSA: hda/cs8409: Move codec properties to its own struct

To accommodate move, cs42l42_resume has been added to mirror
the existing function cs42l42_suspend.
Function cs42l42_reset is no longer required, since cs42l42_resume
and cs42l42_suspend perform the same operations.

Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210811185654.6837-19-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda/cs8409: Separate CS8409, CS42L42 and project functions
Lucas Tanure [Wed, 11 Aug 2021 18:56:44 +0000 (19:56 +0100)]
ALSA: hda/cs8409: Separate CS8409, CS42L42 and project functions

Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210811185654.6837-18-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda/cs8409: Support i2c bulk read/write functions
Lucas Tanure [Wed, 11 Aug 2021 18:56:43 +0000 (19:56 +0100)]
ALSA: hda/cs8409: Support i2c bulk read/write functions

This allows mutex locks to be moved into i2c functions, as
the bulk read/write functions can lock/unlock themselves to
prevent interruption of sequence reads/writes.

Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210811185654.6837-17-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda/cs8409: Avoid re-setting the same page as the last access
Lucas Tanure [Wed, 11 Aug 2021 18:56:42 +0000 (19:56 +0100)]
ALSA: hda/cs8409: Avoid re-setting the same page as the last access

Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210811185654.6837-16-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda/cs8409: Avoid setting the same I2C address for every access
Lucas Tanure [Wed, 11 Aug 2021 18:56:41 +0000 (19:56 +0100)]
ALSA: hda/cs8409: Avoid setting the same I2C address for every access

Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210811185654.6837-15-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda/cs8409: Dont disable I2C clock between consecutive accesses
Lucas Tanure [Wed, 11 Aug 2021 18:56:40 +0000 (19:56 +0100)]
ALSA: hda/cs8409: Dont disable I2C clock between consecutive accesses

Only disable I2C clock 25 ms after not being used.

The current implementation enables and disables the I2C clock for each
I2C transaction. Each enable/disable call requires two verb transactions.
This means each I2C transaction requires a total of four verb transactions
to enable and disable the clock.
However, if there are multiple consecutive I2C transactions, it is not
necessary to enable and disable the clock each time, instead it is more
efficient to enable the clock for the first transaction, and disable it
after the final transaction, which would improve performance.
This is achieved by using a timeout which disables the clock if no request
to enable the clock has occurred for 25 ms.

Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210811185654.6837-14-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda/cs8409: Generalize volume controls
Lucas Tanure [Wed, 11 Aug 2021 18:56:39 +0000 (19:56 +0100)]
ALSA: hda/cs8409: Generalize volume controls

Use amp offsets as indexes for saved volumes.
Remove dependencies on NID inside volume control functions.

Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210811185654.6837-13-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda/cs8409: Prevent I2C access during suspend time
Lucas Tanure [Wed, 11 Aug 2021 18:56:38 +0000 (19:56 +0100)]
ALSA: hda/cs8409: Prevent I2C access during suspend time

Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210811185654.6837-12-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda/cs8409: Simplify CS42L42 jack detect.
Stefan Binding [Wed, 11 Aug 2021 18:56:37 +0000 (19:56 +0100)]
ALSA: hda/cs8409: Simplify CS42L42 jack detect.

Cleanup interrupt masks.
Remove unnecessary read/writes.
Ensure Tip Sense/Type Detection interrupts are enabled/disabled
when needed.

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210811185654.6837-11-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda/cs8409: Mask CS42L42 wake events
Stefan Binding [Wed, 11 Aug 2021 18:56:36 +0000 (19:56 +0100)]
ALSA: hda/cs8409: Mask CS42L42 wake events

Wake events are not needed for jack detect.

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210811185654.6837-10-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda/cs8409: Disable unsolicited response for the first boot
Lucas Tanure [Wed, 11 Aug 2021 18:56:35 +0000 (19:56 +0100)]
ALSA: hda/cs8409: Disable unsolicited response for the first boot

The subsequence suspend and remuse have their enable/disable
unsolicited responses at the correct place already

Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210811185654.6837-9-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda/cs8409: Disable unsolicited responses during suspend
Stefan Binding [Wed, 11 Aug 2021 18:56:34 +0000 (19:56 +0100)]
ALSA: hda/cs8409: Disable unsolicited responses during suspend

Ensure unsolicited responses cannot occur whilst the sub codecs are
being disabled.

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210811185654.6837-8-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda/cs8409: Disable unnecessary Ring Sense for Cyborg/Warlock/Bullseye
Stefan Binding [Wed, 11 Aug 2021 18:56:33 +0000 (19:56 +0100)]
ALSA: hda/cs8409: Disable unnecessary Ring Sense for Cyborg/Warlock/Bullseye

Also remove unnecessary repeated register writes.

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210811185654.6837-7-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda/cs8409: Reduce HS pops/clicks for Cyborg
Stefan Binding [Wed, 11 Aug 2021 18:56:32 +0000 (19:56 +0100)]
ALSA: hda/cs8409: Reduce HS pops/clicks for Cyborg

Enable HSBIAS_SENSE_EN for Cyborg during jack detect to reduce
pops and clicks.
Do not enable this for Warlock/Bullseye, as it causes ESD issues.

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210811185654.6837-6-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda/cs8409: Mask all CS42L42 interrupts on initialization
Stefan Binding [Wed, 11 Aug 2021 18:56:31 +0000 (19:56 +0100)]
ALSA: hda/cs8409: Mask all CS42L42 interrupts on initialization

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210811185654.6837-5-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda/cs8409: Use enums for register names and coefficients
Stefan Binding [Wed, 11 Aug 2021 18:56:30 +0000 (19:56 +0100)]
ALSA: hda/cs8409: Use enums for register names and coefficients

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210811185654.6837-4-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda/cs8409: Move arrays of configuration to a new file
Lucas Tanure [Wed, 11 Aug 2021 18:56:29 +0000 (19:56 +0100)]
ALSA: hda/cs8409: Move arrays of configuration to a new file

Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210811185654.6837-3-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda/cirrus: Move CS8409 HDA bridge to separate module
Lucas Tanure [Wed, 11 Aug 2021 18:56:28 +0000 (19:56 +0100)]
ALSA: hda/cirrus: Move CS8409 HDA bridge to separate module

Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210811185654.6837-2-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: oxfw: fix functioal regression for silence in Apogee Duet FireWire
Takashi Sakamoto [Thu, 12 Aug 2021 02:28:39 +0000 (11:28 +0900)]
ALSA: oxfw: fix functioal regression for silence in Apogee Duet FireWire

OXFW 971 has no function to use the value in syt field of received
isochronous packet for playback timing generation. In kernel prepatch for
v5.14, ALSA OXFW driver got change to send NO_INFO value in the field
instead of actual timing value. The change brings Apogee Duet FireWire to
generate no playback sound, while output meter moves.

As long as I investigate, _any_ value in the syt field takes the device to
generate sound. It's reasonable to think that the device just ignores data
blocks in packet with NO_INFO value in its syt field for audio data
processing.

This commit adds a new flag for the quirk to fix regression.

Fixes: 029ffc429440 ("ALSA: oxfw: perform sequence replay for media clock recovery")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210812022839.42043-1-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda - fix the 'Capture Switch' value change notifications
Jaroslav Kysela [Wed, 11 Aug 2021 16:14:41 +0000 (18:14 +0200)]
ALSA: hda - fix the 'Capture Switch' value change notifications

The original code in the cap_put_caller() function does not
handle correctly the positive values returned from the passed
function for multiple iterations. It means that the change
notifications may be lost.

Fixes: 352f7f914ebb ("ALSA: hda - Merge Realtek parser code to generic parser")
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=213851
Cc: <stable@kernel.org>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Link: https://lore.kernel.org/r/20210811161441.1325250-1-perex@perex.cz
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda/realtek: fix mute/micmute LEDs for HP ProBook 650 G8 Notebook PC
Jeremy Szu [Tue, 10 Aug 2021 10:08:45 +0000 (18:08 +0800)]
ALSA: hda/realtek: fix mute/micmute LEDs for HP ProBook 650 G8 Notebook PC

The HP ProBook 650 G8 Notebook PC is using ALC236 codec which is
using 0x02 to control mute LED and 0x01 to control micmute LED.
Therefore, add a quirk to make it works.

Signed-off-by: Jeremy Szu <jeremy.szu@canonical.com>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210810100846.65844-1-jeremy.szu@canonical.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: msnd: Use proper mmap method
Takashi Iwai [Mon, 9 Aug 2021 14:05:32 +0000 (16:05 +0200)]
ALSA: msnd: Use proper mmap method

The old ISA MSND driver basically maps the iomem as the DMA buffer.
For this type of buffer, we have already the standard mmap helper,
snd_pcm_lib_mmap_iomem().  Correct the PCM info, set the DMA address
and use the standard helper for handling the mmap on all architectures
properly.

Link: https://lore.kernel.org/r/20210809140532.11006-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: pci: cs46xx: Fix set up buffer type properly
Takashi Iwai [Mon, 9 Aug 2021 07:18:29 +0000 (09:18 +0200)]
ALSA: pci: cs46xx: Fix set up buffer type properly

CS46xx driver switches the buffer depending on the number of periods,
and in some cases it switches to the own buffer without updating the
buffer type properly.  This may cause a problem with the mmap on
exotic architectures that require the own mmap call for the coherent
DMA buffer.

This patch addresses the potential breakage by replacing the buffer
setup with the proper macro.  It also simplifies the source code,
too.

Link: https://lore.kernel.org/r/20210809071829.22238-4-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: pci: rme: Set up buffer type properly
Takashi Iwai [Mon, 9 Aug 2021 07:18:28 +0000 (09:18 +0200)]
ALSA: pci: rme: Set up buffer type properly

Although the regression of the mmap was fixed in the recent commit
dc0dc8a73e8e ("ALSA: pcm: Fix mmap breakage without explicit buffer
setup"), RME9652 and HDSP drivers have still potential issues with
their mmap handling.  Namely, they use the default mmap handler
without the standard buffer preallocation, and PCM core wouldn't use
the coherent DMA mapping.  It's practically OK on x86, but on some
exotic architectures, it wouldn't work.

This patch addresses the potential breakage by replacing the buffer
setup with the proper macro.  It also simplifies the source code,
too.

Link: https://lore.kernel.org/r/20210809071829.22238-3-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: pcm: Check mmap capability of runtime dma buffer at first
Takashi Iwai [Mon, 9 Aug 2021 07:18:27 +0000 (09:18 +0200)]
ALSA: pcm: Check mmap capability of runtime dma buffer at first

Currently we check only the substream->dma_buffer as the preset of the
buffer configuration for verifying the availability of mmap.  But a
few drivers rather set up the buffer in the own way without the
standard buffer preallocation using substream->dma_buffer, and they
miss the proper checks.  (Now it's working more or less fine as most
of them are running only on x86).

Actually, they may set up the runtime dma_buffer (referred via
snd_pcm_get_dma_buf()) at the open callback, though.  That is, this
could have been used as the primary source.

This patch changes the hw_support_mmap() function to check the runtime
dma buffer at first.  It's usually NULL with the standard buffer
preallocation, and in that case, we continue checking
substream->dma_buffer as fallback.

Link: https://lore.kernel.org/r/20210809071829.22238-2-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: harmony: Drop superfluous address setup
Takashi Iwai [Mon, 9 Aug 2021 07:12:50 +0000 (09:12 +0200)]
ALSA: harmony: Drop superfluous address setup

Harmony driver never uses CONTINUOUS buffer type any longer, hence the
code setting the address is superfluous.  Moreover, the recent change
in the ALSA core already covered the missing address field; it's
already set up.  So let's drop the superfluous line, which includes
the full hw_params callback.

Link: https://lore.kernel.org/r/20210809071250.21846-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoMerge branch 'for-linus' into for-next
Takashi Iwai [Mon, 9 Aug 2021 05:53:22 +0000 (07:53 +0200)]
Merge branch 'for-linus' into for-next

2 years agoALSA: pcm: Fix mmap breakage without explicit buffer setup
Takashi Iwai [Sun, 8 Aug 2021 07:01:16 +0000 (09:01 +0200)]
ALSA: pcm: Fix mmap breakage without explicit buffer setup

The recent fix c4824ae7db41 ("ALSA: pcm: Fix mmap capability check")
restricts the mmap capability only to the drivers that properly set up
the buffers, but it caused a regression for a few drivers that manage
the buffer on its own way.

For those with UNKNOWN buffer type (i.e. the uninitialized / unused
substream->dma_buffer), just assume that the driver handles the mmap
properly and blindly trust the hardware info bit.

Fixes: c4824ae7db41 ("ALSA: pcm: Fix mmap capability check")
Reported-and-tested-by: Jeff Woods <jwoods@fnordco.com>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/s5him0gpghv.wl-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: memalloc: Fix mmap of SG-buffer with WC pages
Takashi Iwai [Sun, 8 Aug 2021 08:00:34 +0000 (10:00 +0200)]
ALSA: memalloc: Fix mmap of SG-buffer with WC pages

The code refactoring to move the WC page handling into the common
memalloc layer caused a breakage for HD-audio HDMI.  I overlooked that
the driver is using the SG-buffer, which isn't covered by the patch.

This patch adds the mmap workaround for WC pages to SG-buffer
handler.  A caveat is that it falls back to the default handler by
returning an error after setting the pgprot, so it won't work in all
cases but merely for PCM (which is currently the only use case).

Fixes: 623c10108338 ("ALSA: memalloc: Fix pgprot for WC mmap on x86")
Reported-and-tested-by: Andy Lavr <andy.lavr@gmail.com>
Link: https://lore.kernel.org/r/20210808080034.20337-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: hda: Add quirk for ASUS Flow x13
Luke D Jones [Sat, 7 Aug 2021 02:58:05 +0000 (14:58 +1200)]
ALSA: hda: Add quirk for ASUS Flow x13

The ASUS GV301QH sound appears to work well with the quirk for
ALC294_FIXUP_ASUS_DUAL_SPK.

Signed-off-by: Luke D Jones <luke@ljones.dev>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210807025805.27321-1-luke@ljones.dev
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoMerge tag 'asoc-fix-v5.14-rc4' of https://git.kernel.org/pub/scm/linux/kernel/git...
Takashi Iwai [Fri, 6 Aug 2021 15:00:51 +0000 (17:00 +0200)]
Merge tag 'asoc-fix-v5.14-rc4' of https://git./linux/kernel/git/broonie/sound into for-linus

ASoC: Fixes for v5.14

Quite a lot of fixes here, the biggest set being for the cs42l42 driver
which is reasonably old but has seen a sudden uptick in activity.
There's also some fixes for correctly referencing PCM buffer addresses
and the removal of some driver-local bodges that had been done for the
lack of prefix handling in DAPM which were broken by the core handling
that as expected.

2 years agoASoC: cs42l42: Fix mono playback
Richard Fitzgerald [Thu, 5 Aug 2021 16:11:07 +0000 (17:11 +0100)]
ASoC: cs42l42: Fix mono playback

I2S always has two LRCLK phases and both CH1 and CH2 of the RX
must be enabled (corresponding to the low and high phases of LRCLK.)
The selection of the valid data channels is done by setting the DAC
CHA_SEL and CHB_SEL. CHA_SEL is always the first (left) channel,
CHB_SEL depends on the number of active channels.

Previously for mono ASP CH2 was not enabled, the result was playing
mono data would not produce any audio output.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: 621d65f3b868 ("ASoC: cs42l42: Provide finer control on playback path")
Link: https://lore.kernel.org/r/20210805161111.10410-4-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: cs42l42: Constrain sample rate to prevent illegal SCLK
Richard Fitzgerald [Thu, 5 Aug 2021 16:11:06 +0000 (17:11 +0100)]
ASoC: cs42l42: Constrain sample rate to prevent illegal SCLK

The lowest valid SCLK corresponds to 44.1 kHz at 16-bit. Sample
rates less than this would produce SCLK below the minimum when using
a normal I2S frame. A constraint must be applied to prevent this.

The constraint is not applied if the machine driver sets SCLK, to
allow setups where the host generates additional bits per LRCLK
phase to increase the SCLK frequency. In these cases the machine
driver would always have to inform this driver of the actual SCLK,
and it must select a legal SCLK.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210805161111.10410-3-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: cs42l42: Fix LRCLK frame start edge
Richard Fitzgerald [Thu, 5 Aug 2021 16:11:05 +0000 (17:11 +0100)]
ASoC: cs42l42: Fix LRCLK frame start edge

An I2S frame starts on the falling edge of LRCLK so ASP_STP must
be 0.

At the same time, move other format settings in the same register
from cs42l42_pll_config() to cs42l42_set_dai_fmt() where you'd
expect to find them, and merge into a single write.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: 2c394ca79604 ("ASoC: Add support for CS42L42 codec")
Link: https://lore.kernel.org/r/20210805161111.10410-2-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: cs42l42: PLL must be running when changing MCLK_SRC_SEL
Richard Fitzgerald [Thu, 5 Aug 2021 16:11:04 +0000 (17:11 +0100)]
ASoC: cs42l42: PLL must be running when changing MCLK_SRC_SEL

Both SCLK and PLL clocks must be running to drive the glitch-free mux
behind MCLK_SRC_SEL and complete the switchover.

This patch moves the writing of MCLK_SRC_SEL to when the PLL is started
and stopped, so that it only transitions while the PLL is running.
The unconditional write MCLK_SRC_SEL=0 in cs42l42_mute_stream() is safe
because if the PLL is not running MCLK_SRC_SEL is already 0.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: 43fc357199f9 ("ASoC: cs42l42: Set clock source for both ways of stream")
Link: https://lore.kernel.org/r/20210805161111.10410-1-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoALSA: es1688: Avoid devres management for es1688 object creation
Takashi Iwai [Thu, 5 Aug 2021 06:21:48 +0000 (08:21 +0200)]
ALSA: es1688: Avoid devres management for es1688 object creation

The recent refactoring of es1688 object creation with the use of
devres caused a problem with the non-PnP probe of GUS driver, as it
tries to probe multiple times with different parameters  That is, this
object needs the immediate resource release and the devres doesn't fit
for it.

This patch reverts partially the commit for restoring the classic
resource management for es1688 object.

Fixes: 1bb11c1c7f6e ("ALSA: es1688: Allocate resources with device-managed APIs")
Reported-by: kernel test robot <oliver.sang@intel.com>
Link: https://lore.kernel.org/r/20210805032513.GA30485@xsang-OptiPlex-9020
Link: https://lore.kernel.org/r/20210805062148.30951-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: pci/korg1212: completely remove 'set but not used' warnings
Pierre-Louis Bossart [Wed, 4 Aug 2021 18:54:42 +0000 (13:54 -0500)]
ALSA: pci/korg1212: completely remove 'set but not used' warnings

Commit 6cdc01ebdfb0 ("ALSA: pci/korg1212: remove 'set but not used'
warnings") missed one __maybe_unused, add to enable make W=1 sound/
compilation with x86_64 allmodconfig

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20210804185442.274057-1-pierre-louis.bossart@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: memalloc: Store snd_dma_buffer.addr for continuous pages, too
Takashi Iwai [Wed, 4 Aug 2021 07:41:25 +0000 (09:41 +0200)]
ALSA: memalloc: Store snd_dma_buffer.addr for continuous pages, too

In the recent fix commit eda80d7c9c4d ("ALSA: memalloc: Fix regression
with SNDRV_DMA_TYPE_CONTINUOUS"), we replaced the pfn argument of the
remap_page_pfn() call from the uninitialized dmab->addr.  It was the
right fix, but it'd be more generic if we actually initialize
dmab->area for SNDRV_DMA_TYPE_CONTINOUS, too.  e.g. the field is used
in the common snd_sgbuf_get_addr(), too.

This patch adds the initialization of addr field and does revert of
the previous change to refer to it again in the mmap call.

Link: https://lore.kernel.org/r/20210804074125.8170-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: memalloc: Fix pgprot for WC mmap on x86
Takashi Iwai [Wed, 4 Aug 2021 06:13:29 +0000 (08:13 +0200)]
ALSA: memalloc: Fix pgprot for WC mmap on x86

We have a special handling of WC pages on x86, and it's currently
specific to HD-audio.  The last forgotten piece was the pgprot setup
for the mmap with WC pages.

This patch moves the pgprot setup for WC pages from HD-audio-specific
mmap callback to the common helper code.  It allows us to remove the
superfluous mmap callback in HD-audio and its prepare_mmap
redirection.

Link: https://lore.kernel.org/r/20210804061329.29265-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoASoC: sprd: Use managed buffer allocation
Takashi Iwai [Mon, 2 Aug 2021 07:28:15 +0000 (09:28 +0200)]
ASoC: sprd: Use managed buffer allocation

This patch simplifies the buffer pre-allocation code of sprd driver
with the standard managed buffer helper.  It uses the newly
introduced fixed-size buffer allocation helper.

Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20210802072815.13551-16-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoASoC: qcom: qdsp6: Use managed buffer allocation
Takashi Iwai [Mon, 2 Aug 2021 07:28:14 +0000 (09:28 +0200)]
ASoC: qcom: qdsp6: Use managed buffer allocation

This patch simplifies the buffer pre-allocation code of qcom qdsp6
driver with the standard managed buffer helper.  It uses the newly
introduced fixed-size buffer allocation helper.

Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Banajit Goswami <bgoswami@codeaurora.org>
Acked-by: Mark Brown <broonie@kernel.org>
Tested-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20210802072815.13551-15-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoASoC: qcom: lpass: Use managed buffer allocation
Takashi Iwai [Mon, 2 Aug 2021 07:28:13 +0000 (09:28 +0200)]
ASoC: qcom: lpass: Use managed buffer allocation

This patch simplifies the buffer pre-allocation code of qcom lpass
driver with the standard managed buffer helper.  It uses the newly
introduced fixed-size buffer allocation helper.

Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Banajit Goswami <bgoswami@codeaurora.org>
Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20210802072815.13551-14-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoASoC: mpc5200: Use managed buffer allocation
Takashi Iwai [Mon, 2 Aug 2021 07:28:12 +0000 (09:28 +0200)]
ASoC: mpc5200: Use managed buffer allocation

This patch simplifies the buffer pre-allocation code of fsl mpc5200
driver with the standard managed buffer helper.  It uses the newly
introduced fixed-size buffer allocation helper.

Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20210802072815.13551-13-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoASoC: fsl_dma: Use managed buffer allocation
Takashi Iwai [Mon, 2 Aug 2021 07:28:11 +0000 (09:28 +0200)]
ASoC: fsl_dma: Use managed buffer allocation

This patch simplifies the buffer pre-allocation code of fsl_dma
driver with the standard managed buffer helper.  It uses the newly
introduced fixed-size buffer allocation helper.

Cc: Nicolin Chen <nicoleotsuka@gmail.com>
Cc: Xiubo Li <Xiubo.Lee@gmail.com>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: Shengjiu Wang <shengjiu.wang@gmail.com>
Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20210802072815.13551-12-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoASoC: fsl_asrc_dma: Use managed buffer allocation
Takashi Iwai [Mon, 2 Aug 2021 07:28:10 +0000 (09:28 +0200)]
ASoC: fsl_asrc_dma: Use managed buffer allocation

This patch simplifies the buffer pre-allocation code of fsl_asrc_dma
driver with the standard managed buffer helper.  It uses the newly
introduced fixed-size buffer allocation helper.

Cc: Nicolin Chen <nicoleotsuka@gmail.com>
Cc: Xiubo Li <Xiubo.Lee@gmail.com>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: Shengjiu Wang <shengjiu.wang@gmail.com>
Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20210802072815.13551-11-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoASoC: tegra: Use managed buffer allocation
Takashi Iwai [Mon, 2 Aug 2021 07:28:09 +0000 (09:28 +0200)]
ASoC: tegra: Use managed buffer allocation

As the standard buffer allocation helper supports WC pages now, we can
convert imx-pcm-rpmsg driver to use that.  This allows us to remove
lots of superfluous code.

Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20210802072815.13551-10-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoASoC: fsl: imx-pcm-rpmsg: Use managed buffer allocation
Takashi Iwai [Mon, 2 Aug 2021 07:28:08 +0000 (09:28 +0200)]
ASoC: fsl: imx-pcm-rpmsg: Use managed buffer allocation

As the standard buffer allocation helper supports WC pages now, we can
convert imx-pcm-rpmsg driver to use that.  This allows us to remove
lots of superfluous code.

Cc: Nicolin Chen <nicoleotsuka@gmail.com>
Cc: Xiubo Li <Xiubo.Lee@gmail.com>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: Shengjiu Wang <shengjiu.wang@gmail.com>
Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20210802072815.13551-9-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoASoC: fsl: imx-pcm-fiq: Use managed buffer allocation
Takashi Iwai [Mon, 2 Aug 2021 07:28:07 +0000 (09:28 +0200)]
ASoC: fsl: imx-pcm-fiq: Use managed buffer allocation

As the standard buffer allocation helper supports WC pages now, we can
convert imx-pcm-fiq driver to use that.  This allows us to remove lots
of superfluous code.

Cc: Nicolin Chen <nicoleotsuka@gmail.com>
Cc: Xiubo Li <Xiubo.Lee@gmail.com>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: Shengjiu Wang <shengjiu.wang@gmail.com>
Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20210802072815.13551-8-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoASoC: bcm: Use managed PCM buffer allocation
Takashi Iwai [Mon, 2 Aug 2021 07:28:06 +0000 (09:28 +0200)]
ASoC: bcm: Use managed PCM buffer allocation

As the standard buffer allocation helper supports WC pages now, we can
convert bcm driver to use that.  This allows us to remove lots of
superfluous code.

Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20210802072815.13551-7-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: pxa2xx: Use managed PCM buffer allocation
Takashi Iwai [Mon, 2 Aug 2021 07:28:05 +0000 (09:28 +0200)]
ALSA: pxa2xx: Use managed PCM buffer allocation

Now with the recent addition of WC buffer allocation support, we can
use the standard PCM buffer allocation helpers for pxa2xx drivers.
This allows us to remove lots of superfluous code.

Cc: Daniel Mack <daniel@zonque.org>
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20210802072815.13551-6-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: memalloc: Support WC allocation on all architectures
Takashi Iwai [Mon, 2 Aug 2021 07:28:04 +0000 (09:28 +0200)]
ALSA: memalloc: Support WC allocation on all architectures

There are the generic DMA API calls for allocating and managing the
pages with the write-combined attribute.  Let's use them for all
architectures but x86; x86 still needs the special handling to
override the page attributes.

Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20210802072815.13551-5-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: pcm: Allow exact buffer preallocation
Takashi Iwai [Mon, 2 Aug 2021 07:28:03 +0000 (09:28 +0200)]
ALSA: pcm: Allow exact buffer preallocation

A few drivers want to have rather the exact buffer preallocation at
the driver probe time and keep using it for the whole operations
without allowing dynamic buffer allocation.  For satisfying the
demands, this patch extends the managed buffer allocation API
slightly.

Namely, when 0 is passed to max argument of the allocation helper
functions snd_pcm_set_managed_buffer*(), it treats as if the fixed
size allocation of the given size.  If the pre-allocation fails in
this mode, the function returns now -ENOMEM.  Otherwise, i.e. max
argument is non-zero, the function never returns -ENOMEM but tries to
fall back to the smaller chunks and allows the dynamic allocation
later -- which is still the default behavior until now.

For more intuitive use, also two new helpers are added for handling
the fixed size buffer allocation, too: snd_pcm_set_fixed_buffer() and
snd_pcm_set_fixed_buffer_all().

Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20210802072815.13551-4-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: memalloc: Correctly name as WC
Takashi Iwai [Mon, 2 Aug 2021 07:28:02 +0000 (09:28 +0200)]
ALSA: memalloc: Correctly name as WC

SNDRV_DMA_TYPE_DEV_UC and SNDRV_DMA_TYPE_DEV_UC_SG are incorrectly
named as if they were for the uncached memory, while actually we set
the pages as write-combined.  Rename them to reflect the right
attribute.

Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20210802072815.13551-3-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: memalloc: Minor refactoring
Takashi Iwai [Mon, 2 Aug 2021 07:28:01 +0000 (09:28 +0200)]
ALSA: memalloc: Minor refactoring

Return the pointer directly from alloc ops instead of setting
dmab->area at each place.  It simplifies the code a bit.

Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20210802072815.13551-2-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoASoC: cs42l42: Remove duplicate control for WNF filter frequency
Richard Fitzgerald [Tue, 3 Aug 2021 16:08:34 +0000 (17:08 +0100)]
ASoC: cs42l42: Remove duplicate control for WNF filter frequency

The driver was defining two ALSA controls that both change the same
register field for the wind noise filter corner frequency. The filter
response has two corners, at different frequencies, and the duplicate
controls most likely were an attempt to be able to set the value using
either of the frequencies.

However, having two controls changing the same field can be problematic
and it is unnecessary. Both frequencies are related to each other so
setting one implies exactly what the other would be.

Removing a control affects user-side code, but there is currently no
known use of the removed control so it would be best to remove it now
before it becomes a problem.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: 2c394ca79604 ("ASoC: Add support for CS42L42 codec")
Link: https://lore.kernel.org/r/20210803160834.9005-2-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: cs42l42: Fix inversion of ADC Notch Switch control
Richard Fitzgerald [Tue, 3 Aug 2021 16:08:33 +0000 (17:08 +0100)]
ASoC: cs42l42: Fix inversion of ADC Notch Switch control

The underlying register field has inverted sense (0 = enabled) so
the control definition must be marked as inverted.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: 2c394ca79604 ("ASoC: Add support for CS42L42 codec")
Link: https://lore.kernel.org/r/20210803160834.9005-1-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoALSA: usb-audio: make array static const, makes object smaller
Colin Ian King [Tue, 3 Aug 2021 12:28:39 +0000 (13:28 +0100)]
ALSA: usb-audio: make array static const, makes object smaller

Don't populate array names_to_check on the stack but instead it
static.  Makes the object code smaller by 56 bytes.  Also clean
up checkpatch warning by adding extra const for names_to_check
and pointer s.

Before:
    text    data     bss     dec     hex filename
  103512   34380       0  137892   21aa4 ./sound/usb/mixer.o

After:
    text    data     bss     dec     hex filename
  103264   34572       0  137836   21a6c ./sound/usb/mixer.o

(gcc version 10.2.0)

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/20210803122839.7143-1-colin.king@canonical.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoALSA: seq: Fix racy deletion of subscriber
Takashi Iwai [Tue, 3 Aug 2021 11:43:12 +0000 (13:43 +0200)]
ALSA: seq: Fix racy deletion of subscriber

It turned out that the current implementation of the port subscription
is racy.  The subscription contains two linked lists, and we have to
add to or delete from both lists.  Since both connection and
disconnection procedures perform the same order for those two lists
(i.e. src list, then dest list), when a deletion happens during a
connection procedure, the src list may be deleted before the dest list
addition completes, and this may lead to a use-after-free or an Oops,
even though the access to both lists are protected via mutex.

The simple workaround for this race is to change the access order for
the disconnection, namely, dest list, then src list.  This assures
that the connection has been established when disconnecting, and also
the concurrent deletion can be avoided.

Reported-and-tested-by: folkert <folkert@vanheusden.com>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210801182754.GP890690@belle.intranet.vanheusden.com
Link: https://lore.kernel.org/r/20210803114312.2536-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2 years agoASoC: SOF: Intel: hda-ipc: fix reply size checking
Guennadi Liakhovetski [Mon, 2 Aug 2021 15:17:49 +0000 (10:17 -0500)]
ASoC: SOF: Intel: hda-ipc: fix reply size checking

Checking that two values don't have common bits makes no sense,
strict equality is meant.

Fixes: f3b433e4699f  ("ASoC: SOF: Implement Probe IPC API")
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20210802151749.15417-1-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: SOF: Intel: Kconfig: fix SoundWire dependencies
Pierre-Louis Bossart [Mon, 2 Aug 2021 15:16:28 +0000 (10:16 -0500)]
ASoC: SOF: Intel: Kconfig: fix SoundWire dependencies

The previous Kconfig cleanup added simplifications but also introduced
a new one by moving a boolean to a tristate. This leads to randconfig
problems.

This patch moves the select operations in the SOUNDWIRE_LINK_BASELINE
option. The INTEL_SOUNDWIRE config remains a tristate for backwards
compatibility with older configurations but is essentially an on/off
switch.

Fixes: cf5807f5f814f ('ASoC: SOF: Intel: SoundWire: simplify Kconfig')
Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Bard Liao <bard.liao@intel.com>
Tested-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20210802151628.15291-1-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>