linux-2.6-block.git
4 years agoALSA: hda - Update descriptions about new position_fix values
Takashi Iwai [Wed, 28 Aug 2019 14:34:36 +0000 (16:34 +0200)]
ALSA: hda - Update descriptions about new position_fix values

The new values for the recent Intel and AMD chips are missing in the
documentation.  Add the new descriptions.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: usb-audio: Update DSD support quirks for Oppo and Rotel
Jussi Laako [Tue, 27 Aug 2019 21:08:47 +0000 (00:08 +0300)]
ALSA: usb-audio: Update DSD support quirks for Oppo and Rotel

Oppo has issued firmware updates that change alt setting used for DSD
support. However, these devices seem to support auto-detection, so
support is moved from explicit whitelisting to auto-detection.

Also Rotel devices have USB interfaces that support DSD with
auto-detection.

Signed-off-by: Jussi Laako <jussi@sonarnerd.net>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: usb-audio: DSD auto-detection for Playback Designs
Jussi Laako [Tue, 27 Aug 2019 21:08:46 +0000 (00:08 +0300)]
ALSA: usb-audio: DSD auto-detection for Playback Designs

Add DSD support auto-detection for newer Playback Designs devices. Older
device generations have a different USB interface implementation.

Keep the auto-detection VID whitelist sorted.

Signed-off-by: Jussi Laako <jussi@sonarnerd.net>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: hda - Allow runtime PM for controller if component notifier is used
Takashi Iwai [Tue, 27 Aug 2019 14:37:50 +0000 (16:37 +0200)]
ALSA: hda - Allow runtime PM for controller if component notifier is used

Currently we disallow the runtime PM of the HD-audio controller if
it's bound with HDMI/DP on Nvidia / AMD unless it's for dGPU.  This is
for keeping the link up to get the proper notification for ELD
hotplug.

As explained in the commit 37a3a98ef601 ("ALSA: hda - Enable runtime
PM only for discrete GPU"), this keep-power-up behavior is rather a
stop-gap solution until the ELD notification via audio component.
And now we finally got the audio component for these graphics drivers
via commit ade49db337a9 ("ALSA: hda/hdmi - Allow audio component for
AMD/ATI and Nvidia HDMI"), so it's time to change.

This patch makes HD-audio controller again runtime-suspendable when
the device gets bound with audio component in HDMI codec driver.  For
making it easier to access from the codec driver, move the flag into
the common hda_bus object instead of hda_intel flag.  Also rename it
to keep_power, to indicate the actual meaning.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: oxfw: fix NULL pointer dereference to unused stream structure
Takashi Sakamoto [Mon, 26 Aug 2019 13:54:15 +0000 (22:54 +0900)]
ALSA: oxfw: fix NULL pointer dereference to unused stream structure

ALSA oxfw driver supports Griffin FireWave. This device supports one
isochronous stream for PCM playback. Current driver executes code to
wait event for stream structure of opposite direction. This causes
NULL pointer dereference.

This commit fixes the bug.

Fixes: ac5d77864cfc ("ALSA: oxfw: support AMDTP domain")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: usb-audio: remove some dead code
Dan Carpenter [Mon, 26 Aug 2019 13:45:50 +0000 (16:45 +0300)]
ALSA: usb-audio: remove some dead code

We recently cleaned up the error handling in commit 52c3e317a857 ("ALSA:
usb-audio: Unify the release of usb_mixer_elem_info objects") but
accidentally left this stray return.

Fixes: 52c3e317a857 ("ALSA: usb-audio: Unify the release of usb_mixer_elem_info objects")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: usb-audio: Fix possible NULL dereference at create_yamaha_midi_quirk()
Takashi Iwai [Mon, 26 Aug 2019 11:55:21 +0000 (13:55 +0200)]
ALSA: usb-audio: Fix possible NULL dereference at create_yamaha_midi_quirk()

The previous addition of descriptor validation may lead to a NULL
dereference at create_yamaha_midi_quirk() when either injd or outjd is
NULL.  Add proper non-NULL checks.

Fixes: 57f8770620e9 ("ALSA: usb-audio: More validations of descriptor units")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: usb-audio: Clean up check_input_term()
Takashi Iwai [Fri, 23 Aug 2019 10:38:07 +0000 (12:38 +0200)]
ALSA: usb-audio: Clean up check_input_term()

The primary changes in this patch are cleanups of __check_input_term()
and move to a non-nested switch-case block by evaluating the pair of
UAC version and the unit type, as we've done for parse_audio_unit().
Also each parser is split into the function for readability.

Now, a slight behavior change by this cleanup is the handling of
processing and extension units.  Formerly we've dealt with them
differently between UAC1/2 and UAC3; the latter returns an error if no
input sources are available, while the former continues to parse.

In this patch, unify the behavior in all cases: when input sources are
available, it parses recursively, then override the type and the id,
as well as channel information if not provided yet.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoMerge branch 'topic/usb-validation' into for-next
Takashi Iwai [Thu, 22 Aug 2019 13:41:56 +0000 (15:41 +0200)]
Merge branch 'topic/usb-validation' into for-next

Pull USB validation patches.  It's based on the latest 5.3 development
branch, so we shall catch up the whole things.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: usb-audio: Remove superfluous bLength checks
Takashi Iwai [Thu, 22 Aug 2019 07:25:27 +0000 (09:25 +0200)]
ALSA: usb-audio: Remove superfluous bLength checks

Now that we got the more comprehensive validation code for USB-audio
descriptors, the check of overflow in each descriptor unit parser
became superfluous.  Drop some of the obvious cases.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: usb-audio: Unify the release of usb_mixer_elem_info objects
Takashi Iwai [Thu, 22 Aug 2019 06:23:10 +0000 (08:23 +0200)]
ALSA: usb-audio: Unify the release of usb_mixer_elem_info objects

Instead of the direct kfree() calls, introduce a new local helper to
release the usb_mixer_elem_info object.  This will be extended to do
more than a single kfree() in the later patches.

Also, use the standard goto instead of multiple calls in
parse_audio_selector_unit() error paths.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: usb-audio: Simplify parse_audio_unit()
Takashi Iwai [Thu, 15 Aug 2019 14:30:39 +0000 (16:30 +0200)]
ALSA: usb-audio: Simplify parse_audio_unit()

Minor code refactoring by combining the UAC version and the type in
the switch-case flow, so that we reduce the indentation and
redundancy.  One good bonus is that the duplicated definition of the
same type value (e.g. UAC2_EFFECT_UNIT) can be handled more cleanly.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: usb-audio: More validations of descriptor units
Takashi Iwai [Tue, 20 Aug 2019 15:17:09 +0000 (17:17 +0200)]
ALSA: usb-audio: More validations of descriptor units

Introduce a new helper to validate each audio descriptor unit before
and check the unit before actually accessing it.  This should harden
against the OOB access cases with malformed descriptors that have been
recently frequently reported by fuzzers.

The existing descriptor checks are still kept although they become
superfluous after this patch.  They'll be cleaned up eventually
later.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: usb-audio: Check mixer unit bitmap yet more strictly
Takashi Iwai [Tue, 20 Aug 2019 19:43:42 +0000 (21:43 +0200)]
ALSA: usb-audio: Check mixer unit bitmap yet more strictly

The bmControls (for UAC1) or bmMixerControls (for UAC2/3) bitmap has a
variable size depending on both input and output pins.  Its size is to
fit with input * output bits.  The problem is that the input size
can't be determined simply from the unit descriptor itself but it
needs to parse the whole connected sources.  Although the
uac_mixer_unit_get_channels() tries to check some possible overflow of
this bitmap, it's incomplete due to the lack of the  evaluation of
input pins.

For covering possible overflows, this patch adds the bitmap overflow
check in the loop of input pins in parse_audio_mixer_unit().

Fixes: 0bfe5e434e66 ("ALSA: usb-audio: Check mixer unit descriptors more strictly")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: hda/realtek - Blacklist PC beep for Lenovo ThinkCentre M73/93
Takashi Iwai [Thu, 22 Aug 2019 07:58:07 +0000 (09:58 +0200)]
ALSA: hda/realtek - Blacklist PC beep for Lenovo ThinkCentre M73/93

Lenovo ThinkCentre M73 and M93 don't seem to have a proper beep
although the driver tries to probe and set up blindly.
Blacklist these machines for suppressing the beep creation.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=204635
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: hda/realtek - Check beep whitelist before assigning in all codecs
Takashi Iwai [Thu, 22 Aug 2019 07:55:37 +0000 (09:55 +0200)]
ALSA: hda/realtek - Check beep whitelist before assigning in all codecs

Some Realtek codec parsers didn't check the availability of PC beep.
Add has_cdefine_beep() check appropriately.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: line6: Fix memory leak at line6_init_pcm() error path
Takashi Iwai [Wed, 21 Aug 2019 18:00:02 +0000 (20:00 +0200)]
ALSA: line6: Fix memory leak at line6_init_pcm() error path

I forgot to release the allocated object at the early error path in
line6_init_pcm().  For addressing it, slightly shuffle the code so
that the PCM destructor (pcm->private_free) is assigned properly
before all error paths.

Fixes: 3450121997ce ("ALSA: line6: Fix write on zero-sized buffer")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: usb-audio: Fix invalid NULL check in snd_emuusb_set_samplerate()
Takashi Iwai [Thu, 15 Aug 2019 09:41:06 +0000 (11:41 +0200)]
ALSA: usb-audio: Fix invalid NULL check in snd_emuusb_set_samplerate()

The quirk function snd_emuusb_set_samplerate() has a NULL check for
the mixer element, but this is useless in the current code.  It used
to be a check against mixer->id_elems[unitid] but it was changed later
to the value after mixer_eleme_list_to_info() which is always non-NULL
due to the container_of() usage.

This patch fixes the check before the conversion.

While we're at it, correct a typo in the comment in the function,
too.

Fixes: 8c558076c740 ("ALSA: usb-audio: Clean up mixer element list traverse")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: hda/ca0132 - Add new SBZ quirk
Paweł Rekowski [Mon, 19 Aug 2019 20:40:07 +0000 (22:40 +0200)]
ALSA: hda/ca0132 - Add new SBZ quirk

This patch adds a new PCI subsys ID for the SBZ, as found and tested by
me and some reddit users.

Link: https://lore.kernel.org/lkml/20190819204008.14426-1-p.rekowski@gmail.com
Signed-off-by: Paweł Rekowski <p.rekowski@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: usb-audio: Add implicit fb quirk for Behringer UFX1604
Takashi Iwai [Tue, 20 Aug 2019 06:58:12 +0000 (08:58 +0200)]
ALSA: usb-audio: Add implicit fb quirk for Behringer UFX1604

Behringer UFX1604 requires the similar quirk to apply implicit fb like
another Behringer model UFX1204 in order to fix the noisy playback.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=204631
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: hda - Fixes inverted Conexant GPIO mic mute led
Jeronimo Borque [Mon, 19 Aug 2019 01:35:38 +0000 (22:35 -0300)]
ALSA: hda - Fixes inverted Conexant GPIO mic mute led

"enabled" parameter historically referred to the device input or
output, not to the led indicator. After the changes added with the led
helper functions the mic mute led logic refers to the led and not to
the mic input which caused led indicator to be negated.
Fixing logic in cxt_update_gpio_led and updated
cxt_fixup_gpio_mute_hook
Also updated debug messages to ease further debugging if necessary.

Fixes: 184e302b46c9 ("ALSA: hda/conexant - Use the mic-mute LED helper")
Suggested-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jeronimo Borque <jeronimo@borque.com.ar>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: hda - Define a fallback_pin_fixup_tbl for alc269 family
Hui Wang [Fri, 16 Aug 2019 06:27:40 +0000 (14:27 +0800)]
ALSA: hda - Define a fallback_pin_fixup_tbl for alc269 family

We have another Dell laptop which needs the DELL4_MIC_NO_PRESENCE,
and this laptop has different pincfg definitions from existing
ones in the pintbl, rather adding a new entry, let us define
a tbl in the fallback_pin_fixup_tbl and this tbl will match
all dell machines with alc289 codec and the pins of 0x19 and 0x1b
are undef by default.

Signed-off-by: Hui Wang <hui.wang@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: hda - Expand pin_match function to match upcoming new tbls
Hui Wang [Fri, 16 Aug 2019 06:27:39 +0000 (14:27 +0800)]
ALSA: hda - Expand pin_match function to match upcoming new tbls

With the existing pintbl, we already have many entries in it. it is
better to figure out a new way to reduce the size of the pintbl.

We plan to define a new tbl which will match more machines with a
single tbl, To do that, this function doesn't need to match all valid
pins between machine and tbl, it just needs to match all pins defined
in the tbl with the machine.

And the plan is to move some tbls from pin_fixup_tbl to
fallback_pin_fixup_tbl gradually.

Signed-off-by: Hui Wang <hui.wang@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: usb-audio: Fix a stack buffer overflow bug in check_input_term
Hui Peng [Thu, 15 Aug 2019 04:31:34 +0000 (00:31 -0400)]
ALSA: usb-audio: Fix a stack buffer overflow bug in check_input_term

`check_input_term` recursively calls itself with input from
device side (e.g., uac_input_terminal_descriptor.bCSourceID)
as argument (id). In `check_input_term`, if `check_input_term`
is called with the same `id` argument as the caller, it triggers
endless recursive call, resulting kernel space stack overflow.

This patch fixes the bug by adding a bitmap to `struct mixer_build`
to keep track of the checked ids and stop the execution if some id
has been checked (similar to how parse_audio_unit handles unitid
argument).

Reported-by: Hui Peng <benquike@gmail.com>
Reported-by: Mathias Payer <mathias.payer@nebelwelt.net>
Signed-off-by: Hui Peng <benquike@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoRevert "ALSA: hda: Add codec on bus address table lately"
Takashi Iwai [Thu, 15 Aug 2019 19:42:51 +0000 (21:42 +0200)]
Revert "ALSA: hda: Add codec on bus address table lately"

This reverts commit ee5f85d9290f ("ALSA: hda: Add codec on bus address
table lately").  The commit caused several regression since I've
overlooked that the function doesn't manage only the caddr_tbl but
also the codec linked list that is referred indirectly in the other
drivers.

Revert for now to make everything back to work.

Fixes: ee5f85d9290f ("ALSA: hda: Add codec on bus address table lately")
Reported-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: usb-audio: Fix an OOB bug in parse_audio_mixer_unit
Hui Peng [Wed, 14 Aug 2019 02:34:04 +0000 (22:34 -0400)]
ALSA: usb-audio: Fix an OOB bug in parse_audio_mixer_unit

The `uac_mixer_unit_descriptor` shown as below is read from the
device side. In `parse_audio_mixer_unit`, `baSourceID` field is
accessed from index 0 to `bNrInPins` - 1, the current implementation
assumes that descriptor is always valid (the length  of descriptor
is no shorter than 5 + `bNrInPins`). If a descriptor read from
the device side is invalid, it may trigger out-of-bound memory
access.

```
struct uac_mixer_unit_descriptor {
__u8 bLength;
__u8 bDescriptorType;
__u8 bDescriptorSubtype;
__u8 bUnitID;
__u8 bNrInPins;
__u8 baSourceID[];
}
```

This patch fixes the bug by add a sanity check on the length of
the descriptor.

Reported-by: Hui Peng <benquike@gmail.com>
Reported-by: Mathias Payer <mathias.payer@nebelwelt.net>
Cc: <stable@vger.kernel.org>
Signed-off-by: Hui Peng <benquike@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: hda: Unexport a few more stuff
Takashi Iwai [Wed, 14 Aug 2019 17:59:44 +0000 (19:59 +0200)]
ALSA: hda: Unexport a few more stuff

Drop EXPORT_SYMBOL*() from a few more stuff in HD-audio core that
aren't used outside.  Particular the unsol event handler can be
staticized now because the recent change removed all external
callers.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: hda: Drop export of snd_hdac_bus_add/remove_device()
Takashi Iwai [Wed, 14 Aug 2019 16:27:08 +0000 (18:27 +0200)]
ALSA: hda: Drop export of snd_hdac_bus_add/remove_device()

snd_hdac_bus_add_device() and snd_hdac_remove_device() are called only
internally in hda-core.  Let's drop the exports of them and move the
declarations into local.h.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: hda: Add codec on bus address table lately
Takashi Iwai [Tue, 13 Aug 2019 15:25:39 +0000 (17:25 +0200)]
ALSA: hda: Add codec on bus address table lately

The call of snd_hdac_bus_add_device() is needed only for registering
the codec onto the bus caddr_tbl[] that is referred essentially only
in the unsol event handler.  That is, the reason of this call and the
release by the counter-part function snd_hdac_bus_remove_device() is
just to assure that the unsol event gets notified to the codec.

But the current implementation of the unsol notification wouldn't work
properly when the codec is still in a premature init state.  So this
patch tries to work around it by delaying the caddr_tbl[] registration
at the point of snd_hdac_device_register().

Also, the order of snd_hdac_bus_remove_device() and device_del() calls
are shuffled to make sure that the unsol event is masked before
deleting the device.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=204565
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: hda - Drop unsol event handler for Intel HDMI codecs
Takashi Iwai [Tue, 13 Aug 2019 15:11:28 +0000 (17:11 +0200)]
ALSA: hda - Drop unsol event handler for Intel HDMI codecs

We don't need to deal with the unsol events for Intel chips that are
tied with the graphics via audio component notifier.  Although the
presence of the audio component is checked at the beginning of
hdmi_unsol_event(), better to short cut by dropping unsol_event ops.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=204565
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: sb: remove redundant assignment to variable result
Colin Ian King [Tue, 13 Aug 2019 14:01:51 +0000 (15:01 +0100)]
ALSA: sb: remove redundant assignment to variable result

Variable result is initialized to a value that is never read and it is
re-assigned later. The initialization is redundant and can be removed.

Addresses-Coverity: ("Unused value")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: hda - Add a generic reboot_notify
Hui Wang [Wed, 14 Aug 2019 04:09:08 +0000 (12:09 +0800)]
ALSA: hda - Add a generic reboot_notify

Make codec enter D3 before rebooting or poweroff can fix the noise
issue on some laptops. And in theory it is harmless for all codecs
to enter D3 before rebooting or poweroff, let us add a generic
reboot_notify, then realtek and conexant drivers can call this
function.

Cc: stable@vger.kernel.org
Signed-off-by: Hui Wang <hui.wang@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: hda - Let all conexant codec enter D3 when rebooting
Hui Wang [Wed, 14 Aug 2019 04:09:07 +0000 (12:09 +0800)]
ALSA: hda - Let all conexant codec enter D3 when rebooting

We have 3 new lenovo laptops which have conexant codec 0x14f11f86,
these 3 laptops also have the noise issue when rebooting, after
letting the codec enter D3 before rebooting or poweroff, the noise
disappers.

Instead of adding a new ID again in the reboot_notify(), let us make
this function apply to all conexant codec. In theory make codec enter
D3 before rebooting or poweroff is harmless, and I tested this change
on a couple of other Lenovo laptops which have different conexant
codecs, there is no side effect so far.

Cc: stable@vger.kernel.org
Signed-off-by: Hui Wang <hui.wang@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: hda/sigmatel - remove unused variable 'stac9200_core_init'
YueHaibing [Tue, 13 Aug 2019 14:43:23 +0000 (22:43 +0800)]
ALSA: hda/sigmatel - remove unused variable 'stac9200_core_init'

sound/pci/hda/patch_sigmatel.c:981:30: warning:
 stac9200_core_init defined but not used [-Wunused-const-variable=]

It is never used, so can be removed.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: hda/realtek - Add quirk for HP Envy x360
Takashi Iwai [Tue, 13 Aug 2019 15:39:56 +0000 (17:39 +0200)]
ALSA: hda/realtek - Add quirk for HP Envy x360

HP Envy x360 (AMD Ryzen-based model) with 103c:8497 needs the same
quirk like HP Spectre x360 for enabling the mute LED over Mic3 pin.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=204373
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: hda: Set fifo_size for both playback and capture streams
Takashi Iwai [Mon, 12 Aug 2019 16:01:47 +0000 (18:01 +0200)]
ALSA: hda: Set fifo_size for both playback and capture streams

Currently we set hdac_stream.fifo_size field only for the playback
stream by some odd reason I forgot, while this field isn't referred in
any places.  Actually this fifo_size field would have been required in
the position report correction for VIA chipset, but due to the lack of
the fifo_size set for capture streams, snd-hda-intel driver fetches
the register by itself.

This patch straightens and simplifies the code by setting the
fifo_size field for both playback and capture streams, and use it in
the HD-audio controller driver.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: hda - Fix a memory leak bug
Wenwen Wang [Sat, 10 Aug 2019 04:29:48 +0000 (23:29 -0500)]
ALSA: hda - Fix a memory leak bug

In snd_hda_parse_generic_codec(), 'spec' is allocated through kzalloc().
Then, the pin widgets in 'codec' are parsed. However, if the parsing
process fails, 'spec' is not deallocated, leading to a memory leak.

To fix the above issue, free 'spec' before returning the error.

Fixes: 352f7f914ebb ("ALSA: hda - Merge Realtek parser code to generic parser")
Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: hda - Add a quirk model for fixing Huawei Matebook X right speaker
Tomas Espeleta [Fri, 9 Aug 2019 14:37:54 +0000 (16:37 +0200)]
ALSA: hda - Add a quirk model for fixing Huawei Matebook X right speaker

[ This is rather a revival of the patch Tomas sent in months ago, but
  applying only with the quirk model option -- tiwai ]

Hard coded coefficients to make Huawuei Matebook X right speaker
work. The Matebook X has a ALC298, please refer to bug 197801 on
how these numbers were reverse engineered from the Windows driver

The reversed engineered sequence represents a repeating pattern
of verbs, and the only values that are changing periodically are
written on indexes 0x23 and 0x25:

0x500, 0x23
0x400, VALUE1
0x500, 0x25
0x400, VALUE2

* skipped reading sequences (0x500 - 0xc00 sequences are ignored)
* static values from reverse engineering are used

NOTE: since a significant risk is still considered, this is provided
as an experimental fix that isn't applied as default for now.  For
enabling the fix, you'll have to choose huawei-mbx-stereo via model
option of snd-hda-intel module.

If we get feedback from users that this works stably, we may apply it
per default.

[ Some coding style fixes and replacement with AC_VERB_* by tiwai ]

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=197801
Signed-off-by: Tomas Espeleta <tomas.espeleta@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: hda - Inform too slow responses
Takashi Iwai [Fri, 9 Aug 2019 14:13:16 +0000 (16:13 +0200)]
ALSA: hda - Inform too slow responses

For the sake of debugging, show each response that took too long time
and its corresponding last verb.  Since such an error happens in
series once when started, use the ratelimited variant for suppressing
the flood.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoMerge branch 'topic/hda-bus-ops-cleanup' into for-next
Takashi Iwai [Fri, 9 Aug 2019 12:56:24 +0000 (14:56 +0200)]
Merge branch 'topic/hda-bus-ops-cleanup' into for-next

Pull yet another compile error fix in the previous HD-audio patchset.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoASoC: SOF: Intel: Add missing include file hdac_hda.h
YueHaibing [Fri, 9 Aug 2019 11:01:00 +0000 (19:01 +0800)]
ASoC: SOF: Intel: Add missing include file hdac_hda.h

Building with SND_SOC_SOF_HDA_AUDIO_CODEC fails:

sound/soc/sof/intel/hda-bus.c: In function sof_hda_bus_init:
sound/soc/sof/intel/hda-bus.c:16:25: error: implicit declaration of function
 snd_soc_hdac_hda_get_ops; did you mean snd_soc_jack_add_gpiods? [-Werror=implicit-function-declaration]
 #define sof_hda_ext_ops snd_soc_hdac_hda_get_ops()

Reported-by: Hulk Robot <hulkci@huawei.com>
Suggested-by: Takashi Iwai <tiwai@suse.de>
Fixes: d4ff1b3917a5 ("ASoC: SOF: Intel: Initialize hdaudio bus properly")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: ac97: remove unused variable 'snd_ac97_controls_master_mono'
YueHaibing [Fri, 9 Aug 2019 09:01:13 +0000 (17:01 +0800)]
ALSA: ac97: remove unused variable 'snd_ac97_controls_master_mono'

sound/pci/ac97/ac97_codec.c:599:38: warning:
 snd_ac97_controls_master_mono defined but not used [-Wunused-const-variable=]

It is never used, so can be removed.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: hda - Apply workaround for another AMD chip 1022:1487
Takashi Iwai [Fri, 9 Aug 2019 09:23:00 +0000 (11:23 +0200)]
ALSA: hda - Apply workaround for another AMD chip 1022:1487

MSI MPG X570 board is with another AMD HD-audio controller (PCI ID
1022:1487) and it requires the same workaround applied for X370, etc
(PCI ID 1022:1457).

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=195303
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoMerge branch 'topic/hda-bus-ops-cleanup' into for-next
Takashi Iwai [Fri, 9 Aug 2019 05:51:52 +0000 (07:51 +0200)]
Merge branch 'topic/hda-bus-ops-cleanup' into for-next

Pull the compile fix on arm due to missing include.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: hda: readl/writel need linux/io.h
Stephen Rothwell [Fri, 9 Aug 2019 02:54:58 +0000 (12:54 +1000)]
ALSA: hda: readl/writel need linux/io.h

Fixes: 19abfefd4c76 ("ALSA: hda: Direct MMIO accesses")
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoMerge branch 'topic/hda-bus-ops-cleanup' into for-next
Takashi Iwai [Thu, 8 Aug 2019 20:35:44 +0000 (22:35 +0200)]
Merge branch 'topic/hda-bus-ops-cleanup' into for-next

Pull HD-audio bus ops cleanups.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoASoC: SOF: Intel: Initialize hdaudio bus properly
Takashi Iwai [Wed, 7 Aug 2019 18:50:50 +0000 (20:50 +0200)]
ASoC: SOF: Intel: Initialize hdaudio bus properly

The SOF HD-audio bus has its house-made initialization code.  It's
supposedly for making the code independent from HD-audio bus drivers.
However, this is error-prone, and above all, the SOF driver has
already dependency on HD-audio bus driver when CONFIG_SND_SOF_HDA is
set.  That is, if this Kconfig is set, there is no reason to avoid the
call to the proper bus init function.

Also, the ext_ops that is set at bus initialization can be better
handled inside sof_hda_bus_init().  We don't need to refer this
outside the bus initialization.

So this patch addresses these issues:
- sof_hda_bus_init() calls nothing but snd_hdac_ext_bus_init()
  when CONFIG_SND_SOF_HDA is set.  Otherwise some fields are
  initialized locally like before for avoiding the dependency.
- ext_ops is referred inside sof_hda_bus_init().  The ext_ops argument
  of snd_hda_bus_init() is dropped.

Acked-by: Mark Brown <broonie@kernel.org>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: hda: Direct MMIO accesses
Takashi Iwai [Wed, 7 Aug 2019 18:32:08 +0000 (20:32 +0200)]
ALSA: hda: Direct MMIO accesses

HD-audio drivers access to the mmio registers indirectly via the
corresponding bus->io_ops callbacks.  This is because some platform
(notably Tegra SoC) requires the word-aligned access.  But it's rather
a rare case, and other platforms suffer from the penalties by indirect
calls unnecessarily.

This patch is an attempt to optimize and cleanup for this situation.
Now the special aligned access is used only when a new kconfig
CONFIG_SND_HDA_ALIGNED_MMIO is set.  And the HD-audio core itself
provides the aligned MMIO access helpers instead of the driver side.
If Kconfig isn't set (as default), the standard helpers like readl()
or writel() are used directly.

A couple of places in ASoC Intel drivers have the access via io_ops
reg_writel(), and they are replaced with the direct writel() calls.

And now with this patch, the whole bus->io_ops becomes empty, so it's
dropped completely.  The bus initialization functions are changed
accordingly as well to drop the whole bus->io_ops.

Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: hda: Remove page allocation redirection
Takashi Iwai [Wed, 7 Aug 2019 18:02:31 +0000 (20:02 +0200)]
ALSA: hda: Remove page allocation redirection

The HD-audio core allocates and releases pages via driver's specific
dma_alloc_pages and dma_free_pages ops defined in bus->io_ops.  This
was because some platforms require the uncached pages and the handling
of page flags had to be done locally in the driver code.

Since the recent change in ALSA core memory allocator, we can simply
pass SNDRV_DMA_TYPE_DEV_UC for the uncached pages, and the only
difference became about this type to be passed to the core allocator.
That is, it's good time for cleaning up the mess.

This patch changes the allocation code in HD-audio core to call the
core allocator directly so that we get rid of dma_alloc_pages and
dma_free_pages io_ops.  If a driver needs the uncached pages, it has
to set bus->dma_type right after the bus initialization.

This is merely a code refactoring and shouldn't bring any behavior
changes.

Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: firewire: fix a memory leak bug
Wenwen Wang [Thu, 8 Aug 2019 05:50:58 +0000 (00:50 -0500)]
ALSA: firewire: fix a memory leak bug

In iso_packets_buffer_init(), 'b->packets' is allocated through
kmalloc_array(). Then, the aligned packet size is checked. If it is
larger than PAGE_SIZE, -EINVAL will be returned to indicate the error.
However, the allocated 'b->packets' is not deallocated on this path,
leading to a memory leak.

To fix the above issue, free 'b->packets' before returning the error code.

Fixes: 31ef9134eb52 ("ALSA: add LaCie FireWire Speakers/Griffin FireWave Surround driver")
Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Cc: <stable@vger.kernel.org> # v2.6.39+
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agosound: fix a memory leak bug
Wenwen Wang [Thu, 8 Aug 2019 05:15:21 +0000 (00:15 -0500)]
sound: fix a memory leak bug

In sound_insert_unit(), the controlling structure 's' is allocated through
kmalloc(). Then it is added to the sound driver list by invoking
__sound_insert_unit(). Later on, if __register_chrdev() fails, 's' is
removed from the list through __sound_remove_unit(). If 'index' is not less
than 0, -EBUSY is returned to indicate the error. However, 's' is not
deallocated on this execution path, leading to a memory leak bug.

To fix the above issue, free 's' before -EBUSY is returned.

Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: hda - Workaround for crackled sound on AMD controller (1022:1457)
Takashi Iwai [Tue, 6 Aug 2019 15:31:48 +0000 (17:31 +0200)]
ALSA: hda - Workaround for crackled sound on AMD controller (1022:1457)

A long-time problem on the recent AMD chip (X370, X470, B450, etc with
PCI ID 1022:1457) with Realtek codecs is the crackled or distorted
sound for capture streams, as well as occasional playback hiccups.
After lengthy debugging sessions, the workarounds we've found are like
the following:

- Set up the proper driver caps for this controller, similar as the
  other AMD controller.

- Correct the DMA position reporting with the fixed FIFO size, which
  is similar like as workaround used for VIA chip set.

- Even after the position correction, PulseAudio still shows
  mysterious stalls of playback streams when a capture is triggered in
  timer-scheduled mode.  Since we have no clear way to eliminate the
  stall, pass the BATCH PCM flag for PA to suppress the tsched mode as
  a temporary workaround.

This patch implements the workarounds.  For the driver caps, it
defines a new preset, AXZ_DCAPS_PRESET_AMD_SB.  It enables the FIFO-
corrected position reporting (corresponding to the new position_fix=6)
and enforces the SNDRV_PCM_INFO_BATCH flag.

Note that the current implementation is merely a workaround.
Hopefully we'll find a better alternative in future, especially about
removing the BATCH flag hack again.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=195303
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: hiface: fix multiple memory leak bugs
Wenwen Wang [Wed, 7 Aug 2019 09:08:51 +0000 (04:08 -0500)]
ALSA: hiface: fix multiple memory leak bugs

In hiface_pcm_init(), 'rt' is firstly allocated through kzalloc(). Later
on, hiface_pcm_init_urb() is invoked to initialize 'rt->out_urbs[i]'. In
hiface_pcm_init_urb(), 'rt->out_urbs[i].buffer' is allocated through
kzalloc().  However, if hiface_pcm_init_urb() fails, both 'rt' and
'rt->out_urbs[i].buffer' are not deallocated, leading to memory leak bugs.
Also, 'rt->out_urbs[i].buffer' is not deallocated if snd_pcm_new() fails.

To fix the above issues, free 'rt' and 'rt->out_urbs[i].buffer'.

Fixes: a91c3fb2f842 ("Add M2Tech hiFace USB-SPDIF driver")
Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: hda - Don't override global PCM hw info flag
Takashi Iwai [Tue, 6 Aug 2019 12:03:56 +0000 (14:03 +0200)]
ALSA: hda - Don't override global PCM hw info flag

The commit bfcba288b97f ("ALSA - hda: Add support for link audio time
reporting") introduced the conditional PCM hw info setup, but it
overwrites the global azx_pcm_hw object.  This will cause a problem if
any other HD-audio controller, as it'll inherit the same bit flag
although another controller doesn't support that feature.

Fix the bug by setting the PCM hw info flag locally.

Fixes: bfcba288b97f ("ALSA - hda: Add support for link audio time reporting")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: usb-audio: Add Pioneer DDJ-SX3 PCM quirck
Ard van Breemen [Fri, 2 Aug 2019 11:52:15 +0000 (13:52 +0200)]
ALSA: usb-audio: Add Pioneer DDJ-SX3 PCM quirck

The Pioneer DDJ-SX3 is a plain 12 32bit channel out and 10 channel in
PCM/midi controller. The PCM part is "vendor specific".
It needs the "ignore invalid bsynchaddress" patch as it uses 0 for that.

Signed-off-by: Ard van Breemen <ard@kwaak.net>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: usb-audio: Skip bSynchAddress endpoint check if it is invalid
Ard van Breemen [Fri, 2 Aug 2019 11:52:14 +0000 (13:52 +0200)]
ALSA: usb-audio: Skip bSynchAddress endpoint check if it is invalid

The Linux kernel assumes that get_endpoint(alts,0) and
get_endpoint(alts,1) are eachothers feedback endpoints.
To reassure that validity it will test bsynchaddress to comply with that
assumption. But if the bsyncaddress is 0 (invalid), it will flag that as
a wrong assumption and return an error.
Fix: Skip the test if bSynchAddress is 0.
Note: those with a valid bSynchAddress should have a code quirck added.

Signed-off-by: Ard van Breemen <ard@kwaak.net>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: usb-audio: fix PCM device order
Alexander Tsoy [Thu, 10 Aug 2017 23:36:14 +0000 (02:36 +0300)]
ALSA: usb-audio: fix PCM device order

Some cards have alternate setting with non-PCM format as the first
altsetting in the interface descriptors. This confuses userspace, since
alsa-lib uses device 0 by default. So lets parse interfaces in two steps:
 1. Parse altsettings with PCM formats.
 2. Parse altsettings with non-PCM formats.

This fixes at least following cards:
 - Audinst HUD-mx2
 - Audinst HUD-mini

[ Adapted to 5.3 kernel by tiwai ]

Signed-off-by: Alexander Tsoy <alexander@tsoy.me>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: usb-audio: Unify audioformat release code
Takashi Iwai [Sat, 27 Jul 2019 08:55:49 +0000 (10:55 +0200)]
ALSA: usb-audio: Unify audioformat release code

There are many open code for releasing audioformat object.
Provide a unified helper and call it from the all places.

Only a cleanup, no functional changes.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoMerge branch 'for-linus' into for-next
Takashi Iwai [Tue, 6 Aug 2019 10:46:26 +0000 (12:46 +0200)]
Merge branch 'for-linus' into for-next

Pull 5.3 development branch for further fixes of USB-audio stuff.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: usb-audio: fix a memory leak bug
Wenwen Wang [Tue, 6 Aug 2019 07:00:27 +0000 (03:00 -0400)]
ALSA: usb-audio: fix a memory leak bug

In snd_usb_get_audioformat_uac3(), a structure for channel maps 'chmap' is
allocated through kzalloc() before the execution goto 'found_clock'.
However, this structure is not deallocated if the memory allocation for
'pd' fails, leading to a memory leak bug.

To fix the above issue, free 'fp->chmap' before returning NULL.

Fixes: 7edf3b5e6a45 ("ALSA: usb-audio: AudioStreaming Power Domain parsing")
Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoMerge tag 'asoc-fix-v5.3-rc3-2' of https://git.kernel.org/pub/scm/linux/kernel/git...
Takashi Iwai [Tue, 6 Aug 2019 10:28:28 +0000 (12:28 +0200)]
Merge tag 'asoc-fix-v5.3-rc3-2' of https://git./linux/kernel/git/broonie/sound into for-linus

ASoC: Fixes for v5.3

Incremental fix removing executable bits added in a prior patch
accidentally.

4 years agoMerge tag 'asoc-fix-v5.3-rc3' of https://git.kernel.org/pub/scm/linux/kernel/git...
Takashi Iwai [Tue, 6 Aug 2019 10:28:08 +0000 (12:28 +0200)]
Merge tag 'asoc-fix-v5.3-rc3' of https://git./linux/kernel/git/broonie/sound into for-linus

ASoC: Fixes for v5.3

A relatively large batch of mostly unremarkable fixes here, a couple of
small core fixes for fairly obscure issues, more comment/email updates
with no code impact than usual and a bunch of small driver fixes.

The support for new sample rates in the max98373 driver is a fix for the
fact that the driver declared support for those rates but would in fact
return an error if these rates were selected.

4 years agoASoC: max98373: Remove executable bits
Mark Brown [Tue, 6 Aug 2019 10:15:06 +0000 (11:15 +0100)]
ASoC: max98373: Remove executable bits

Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoALSA: firewire-lib: localize kernel APIs to start/stop each AMDTP stream
Takashi Sakamoto [Sun, 4 Aug 2019 06:21:38 +0000 (15:21 +0900)]
ALSA: firewire-lib: localize kernel APIs to start/stop each AMDTP stream

As a result to support AMDTP domain, no drivers call kernel APIs to
start/stop each AMDTP stream. This commit localize these APIs.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: fireface: support AMDTP domain
Takashi Sakamoto [Sun, 4 Aug 2019 06:21:37 +0000 (15:21 +0900)]
ALSA: fireface: support AMDTP domain

This commit adds AMDTP domain support for ALSA fireface driver.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: firewire-motu: support AMDTP domain
Takashi Sakamoto [Sun, 4 Aug 2019 06:21:36 +0000 (15:21 +0900)]
ALSA: firewire-motu: support AMDTP domain

This commit adds AMDTP domain support for ALSA firewire-motu driver.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: firewire-tascam: support AMDTP domain
Takashi Sakamoto [Sun, 4 Aug 2019 06:21:35 +0000 (15:21 +0900)]
ALSA: firewire-tascam: support AMDTP domain

This commit adds AMDTP domain support for ALSA firewire-tascam driver.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: firewire-digi00x: support AMDTP domain
Takashi Sakamoto [Sun, 4 Aug 2019 06:21:34 +0000 (15:21 +0900)]
ALSA: firewire-digi00x: support AMDTP domain

This commit adds AMDTP domain support for ALSA firewire-digi00x driver.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: dice: support AMDTP domain
Takashi Sakamoto [Sun, 4 Aug 2019 06:21:33 +0000 (15:21 +0900)]
ALSA: dice: support AMDTP domain

This commit adds AMDTP domain support for ALSA dice driver.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: oxfw: support AMDTP domain
Takashi Sakamoto [Sun, 4 Aug 2019 06:21:32 +0000 (15:21 +0900)]
ALSA: oxfw: support AMDTP domain

This commit adds AMDTP domain support for ALSA oxfw driver.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: fireworks: support AMDTP domain
Takashi Sakamoto [Sun, 4 Aug 2019 06:21:31 +0000 (15:21 +0900)]
ALSA: fireworks: support AMDTP domain

This commit adds AMDTP domain support for ALSA fireworks driver.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: bebob: support AMDTP domain
Takashi Sakamoto [Sun, 4 Aug 2019 06:21:30 +0000 (15:21 +0900)]
ALSA: bebob: support AMDTP domain

This commit adds AMDTP domain support for ALSA bebob driver.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: fireface: code refactoring for initialization/destruction of AMDTP stream
Takashi Sakamoto [Sun, 4 Aug 2019 06:21:29 +0000 (15:21 +0900)]
ALSA: fireface: code refactoring for initialization/destruction of AMDTP stream

This commit is a preparation to support AMDTP domain.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: firewire-motu: code refactoring for initialization/destruction of AMDTP stream
Takashi Sakamoto [Sun, 4 Aug 2019 06:21:28 +0000 (15:21 +0900)]
ALSA: firewire-motu: code refactoring for initialization/destruction of AMDTP stream

This commit is a preparation to support AMDTP domain.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: firewire-tascam: code refactoring for initialization/destruction of AMDTP stream
Takashi Sakamoto [Sun, 4 Aug 2019 06:21:27 +0000 (15:21 +0900)]
ALSA: firewire-tascam: code refactoring for initialization/destruction of AMDTP stream

This commit is a preparation to support AMDTP domain.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: firewire-digi00x: code refactoring for initialization/destruction of AMDTP...
Takashi Sakamoto [Sun, 4 Aug 2019 06:21:26 +0000 (15:21 +0900)]
ALSA: firewire-digi00x: code refactoring for initialization/destruction of AMDTP stream

This commit is a preparation to support AMDTP domain.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: fireworks: code refactoring for bus reset handler
Takashi Sakamoto [Sun, 4 Aug 2019 06:21:25 +0000 (15:21 +0900)]
ALSA: fireworks: code refactoring for bus reset handler

This commit is a preparation to support AMDTP domain.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: fireworks: code refactoring for initialization/destruction of AMDTP streams
Takashi Sakamoto [Sun, 4 Aug 2019 06:21:24 +0000 (15:21 +0900)]
ALSA: fireworks: code refactoring for initialization/destruction of AMDTP streams

This commit is a preparation to support AMDTP domain.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: firewire-lib: add a kernel API to start AMDTP streams in AMDTP domain
Takashi Sakamoto [Sun, 4 Aug 2019 06:21:23 +0000 (15:21 +0900)]
ALSA: firewire-lib: add a kernel API to start AMDTP streams in AMDTP domain

This commit adds a kernel API to start a couple of isochronous contexts
for some AMDTP streams.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: firewire-lib: add a kernel API to add AMDTP stream into AMDTP domain
Takashi Sakamoto [Sun, 4 Aug 2019 06:21:22 +0000 (15:21 +0900)]
ALSA: firewire-lib: add a kernel API to add AMDTP stream into AMDTP domain

This commit adds a kernel API to insert AMDTP stream to list in AMDTP
domain.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: firewire-lib: add a kernel API to stop a couple of AMDTP streams in AMDTP domain
Takashi Sakamoto [Sun, 4 Aug 2019 06:21:21 +0000 (15:21 +0900)]
ALSA: firewire-lib: add a kernel API to stop a couple of AMDTP streams in AMDTP domain

This commit adds a kernel API to stop a couple of isochronous contexts
for AMDTP streams. The API is not protected with any lock primitive.
Callers should use this with enough lock against concurrent access.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: firewire-lib: add AMDTP domain structure to handle several isoc contexts
Takashi Sakamoto [Sun, 4 Aug 2019 06:21:20 +0000 (15:21 +0900)]
ALSA: firewire-lib: add AMDTP domain structure to handle several isoc contexts

This commit adds 'struct amdtp_domain' structure. This structure
has list of instance of AMDTP stream to handle a couple of
isochronous contexts.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoASoC: amd: acp3x: use dma address for acp3x dma driver
Vijendar Mukunda [Fri, 2 Aug 2019 13:51:24 +0000 (19:21 +0530)]
ASoC: amd: acp3x: use dma address for acp3x dma driver

We shouldn't assume CPU physical address we get from page_to_phys()
is same as DMA address we get from dma_alloc_coherent(). On x86_64,
we won't run into any problem with the assumption when dma_ops is
nommu_dma_ops. However, DMA address is IOVA when IOMMU is enabled.
And it's most likely different from CPU physical address when AMD
IOMMU is not in passthrough mode.

This patch fixes page faults when IOMMU is enabled.

Signed-off-by: Vijendar Mukunda <vijendar.mukunda@amd.com>
Link: https://lore.kernel.org/r/1564753899-17124-2-git-send-email-Vijendar.Mukunda@amd.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: amd: acp3x: use dma_ops of parent device for acp3x dma driver
Vijendar Mukunda [Fri, 2 Aug 2019 13:51:23 +0000 (19:21 +0530)]
ASoC: amd: acp3x: use dma_ops of parent device for acp3x dma driver

AMD platform device acp3x_rv_i2s created by parent PCI device
driver. Pass struct device of the parent to
snd_pcm_lib_preallocate_pages() so dma_alloc_coherent() can use
correct dma_ops. Otherwise, it will use default dma_ops which
is nommu_dma_ops on x86_64 even when IOMMU is enabled and
set to non passthrough mode.

Signed-off-by: Vijendar Mukunda <vijendar.mukunda@amd.com>
Link: https://lore.kernel.org/r/1564753899-17124-1-git-send-email-Vijendar.Mukunda@amd.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoALSA: hda: Add support of Zhaoxin controller
Tony W Wang-oc [Fri, 2 Aug 2019 03:04:08 +0000 (03:04 +0000)]
ALSA: hda: Add support of Zhaoxin controller

Add the new PCI ID 0x1d17 0x3288 Zhaoxin controller support

Signed-off-by: Tony W Wang-oc <TonyWWang-oc@zhaoxin.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: isa/wavefront: remove redundant assignment to pointer bptr
Colin Ian King [Thu, 1 Aug 2019 16:28:24 +0000 (17:28 +0100)]
ALSA: isa/wavefront: remove redundant assignment to pointer bptr

The pointer bptr is being assigned a value that is never read
and it is being updated in the next statement with a new value.
The initialization is redundant and can be removed.

Addresses-Coverity: ("Unused value")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoMerge branch 'topic/hda-dmic' into for-next
Takashi Iwai [Wed, 31 Jul 2019 13:46:14 +0000 (15:46 +0200)]
Merge branch 'topic/hda-dmic' into for-next

Pull HD-audio DMIC probe patchset from Pierre-Louis Bossart

Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: hda/intel: stop probe if DMICS are detected on Skylake+ platforms
Pierre-Louis Bossart [Mon, 29 Jul 2019 15:51:51 +0000 (10:51 -0500)]
ALSA: hda/intel: stop probe if DMICS are detected on Skylake+ platforms

The legacy HD-Audio driver cannot handle Skylake+ platforms with
digital microphones. For those platforms, the SOF or SST drivers need
to be used.

This patch provides an automatic way of detecting the presence of
DMICs using NHTL information reported by the BIOS. A kernel kconfig
option or a kernel module parameter provide an opt-in means of
stopping the probe. The kernel would then look for an alternate driver
registered for the same PCI ID to probe.

With this capability, distros no longer have to blacklist
snd-hda-intel, but still need to make sure the SOF/SST drivers are
functional by providing the relevant firmware and topology files in
/lib/firmware/intel

The coexistence between SOF and SST drivers and their dynamic
detection is not addressed by this patch, different mechanisms need to
be used, e.g. DMI-based quirks.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoASoC: Intel: Skylake: use common NHLT module
Pierre-Louis Bossart [Mon, 29 Jul 2019 15:51:50 +0000 (10:51 -0500)]
ASoC: Intel: Skylake: use common NHLT module

No functionality change, only use common functions now.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: hda: intel-nhlt: handle NHLT VENDOR_DEFINED DMIC geometry
Pierre-Louis Bossart [Mon, 29 Jul 2019 15:51:49 +0000 (10:51 -0500)]
ALSA: hda: intel-nhlt: handle NHLT VENDOR_DEFINED DMIC geometry

The NHLT spec defines a VENDOR_DEFINED geometry, which requires
reading additional information to figure out the number of
microphones.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: hda: move parts of NHLT code to new module
Pierre-Louis Bossart [Mon, 29 Jul 2019 15:51:48 +0000 (10:51 -0500)]
ALSA: hda: move parts of NHLT code to new module

Move parts of the code outside of the Skylake driver to help detect
the presence of DMICs (which are not supported by the HDaudio legacy
driver).

No functionality change (except for the removal of useless OR
operations), only indentation and checkpatch fixes, making sure
that the code compiles without ACPI and fixing an ACPI leak

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoASoC: Intel: Skylake: move NHLT header to common directory
Pierre-Louis Bossart [Mon, 29 Jul 2019 15:51:47 +0000 (10:51 -0500)]
ASoC: Intel: Skylake: move NHLT header to common directory

Prepare move from NHLT code to common directory, starting with header.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoASoC: max98373: add 88200 and 96000 sampling rate support
fengchunguo [Wed, 31 Jul 2019 07:41:56 +0000 (15:41 +0800)]
ASoC: max98373: add 88200 and 96000 sampling rate support

88200 and 96000 sampling rate was not enabled on driver, so can't be played.

The error information:
max98373 3-0031:rate 96000 not supported
max98373 3-0031:ASoC: can't set max98373-aif1 hw params: -22

Signed-off-by: fengchunguo <chunguo.feng@amlogic.com>
Link: https://lore.kernel.org/r/20190731074156.5620-1-chunguo.feng@amlogic.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoASoC: sun4i-i2s: Incorrect SR and WSS computation
Marcus Cooper [Mon, 29 Jul 2019 15:21:30 +0000 (17:21 +0200)]
ASoC: sun4i-i2s: Incorrect SR and WSS computation

The A64 audio codec uses the original I2S block but the SR and
WSS computation currently assigned is for the newer block.

Fixes: 619c15f7fac9 (ASoC: sun4i-i2s: Change SR and WSS computation)
Signed-off-by: Marcus Cooper <codekipper@gmail.com>
Link: https://lore.kernel.org/r/20190729152130.27955-1-codekipper@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoMAINTAINERS: Update Intel ASoC drivers maintainers
Cezary Rojewski [Fri, 26 Jul 2019 18:15:17 +0000 (20:15 +0200)]
MAINTAINERS: Update Intel ASoC drivers maintainers

Adding myself to Intel ASoC drivers maintainers list.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20190726181517.27655-1-cezary.rojewski@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
4 years agoALSA: usb-audio: Fix gpf in snd_usb_pipe_sanity_check
Hillf Danton [Tue, 30 Jul 2019 09:24:36 +0000 (17:24 +0800)]
ALSA: usb-audio: Fix gpf in snd_usb_pipe_sanity_check

syzbot found the following crash on:

  general protection fault: 0000 [#1] SMP KASAN
  RIP: 0010:snd_usb_pipe_sanity_check+0x80/0x130 sound/usb/helper.c:75
  Call Trace:
    snd_usb_motu_microbookii_communicate.constprop.0+0xa0/0x2fb  sound/usb/quirks.c:1007
    snd_usb_motu_microbookii_boot_quirk sound/usb/quirks.c:1051 [inline]
    snd_usb_apply_boot_quirk.cold+0x163/0x370 sound/usb/quirks.c:1280
    usb_audio_probe+0x2ec/0x2010 sound/usb/card.c:576
    usb_probe_interface+0x305/0x7a0 drivers/usb/core/driver.c:361
    really_probe+0x281/0x650 drivers/base/dd.c:548
    ....

It was introduced in commit 801ebf1043ae for checking pipe and endpoint
types. It is fixed by adding a check of the ep pointer in question.

BugLink: https://syzkaller.appspot.com/bug?extid=d59c4387bfb6eced94e2
Reported-by: syzbot <syzbot+d59c4387bfb6eced94e2@syzkaller.appspotmail.com>
Fixes: 801ebf1043ae ("ALSA: usb-audio: Sanity checks for each pipe and EP types")
Cc: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Hillf Danton <hdanton@sina.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: sparc: Mark expected switch fall-throughs
Gustavo A. R. Silva [Tue, 30 Jul 2019 01:49:44 +0000 (20:49 -0500)]
ALSA: sparc: Mark expected switch fall-throughs

Mark switch cases where we are expecting to fall through.

This patch fixes the following warnings (Building: sparc64):

sound/sparc/dbri.c: In function ‘reverse_bytes’:
sound/sparc/dbri.c:582:5: warning: this statement may fall through [-Wimplicit-fallthrough=]
   b = ((b & 0xffff0000) >> 16) | ((b & 0x0000ffff) << 16);
   ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sound/sparc/dbri.c:583:2: note: here
  case 16:
  ^~~~
sound/sparc/dbri.c:584:5: warning: this statement may fall through [-Wimplicit-fallthrough=]
   b = ((b & 0xff00ff00) >> 8) | ((b & 0x00ff00ff) << 8);
   ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sound/sparc/dbri.c:585:2: note: here
  case 8:
  ^~~~
sound/sparc/dbri.c:586:5: warning: this statement may fall through [-Wimplicit-fallthrough=]
   b = ((b & 0xf0f0f0f0) >> 4) | ((b & 0x0f0f0f0f) << 4);
   ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sound/sparc/dbri.c:587:2: note: here
  case 4:
  ^~~~
sound/sparc/dbri.c:588:5: warning: this statement may fall through [-Wimplicit-fallthrough=]
   b = ((b & 0xcccccccc) >> 2) | ((b & 0x33333333) << 2);
   ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sound/sparc/dbri.c:589:2: note: here
  case 2:
  ^~~~

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agosound: dmasound_atari: Mark expected switch fall-through
Gustavo A. R. Silva [Mon, 29 Jul 2019 20:54:54 +0000 (15:54 -0500)]
sound: dmasound_atari: Mark expected switch fall-through

Mark switch cases where we are expecting to fall through.

This patch fixes the following warning (Building: m68k):

sound/oss/dmasound/dmasound_atari.c: warning: this statement may fall
through [-Wimplicit-fallthrough=]:  => 1449:24

Notice that, in this particular case, the code comment is
modified in accordance with what GCC is expecting to find.

Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Tested-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: pcm: fix lost wakeup event scenarios in snd_pcm_drain
Yuki Tsunashima [Mon, 29 Jul 2019 15:10:36 +0000 (17:10 +0200)]
ALSA: pcm: fix lost wakeup event scenarios in snd_pcm_drain

lost wakeup can occur after enabling irq, therefore put task
into interruptible before enabling interrupts,

without this change, task can be put to sleep and snd_pcm_drain
will delay

Fixes: f2b3614cefb6 ("ALSA: PCM - Don't check DMA time-out too shortly")
Signed-off-by: Yuki Tsunashima <ytsunashima@jp.adit-jv.com>
Signed-off-by: Suresh Udipi <sudipi@jp.adit-jv.com>
[ported from 4.9]
Signed-off-by: Adam Miartus <amiartus@de.adit-jv.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoALSA: aoa: onyx: always initialize register read value
Johannes Berg [Mon, 29 Jul 2019 07:14:22 +0000 (09:14 +0200)]
ALSA: aoa: onyx: always initialize register read value

A lot of places in the driver use onyx_read_register() without
checking the return value, and it's been working OK for ~10 years
or so, so probably never fails ... Rather than trying to check the
return value everywhere, which would be relatively intrusive, at
least make sure we don't use an uninitialized value.

Fixes: f3d9478b2ce4 ("[ALSA] snd-aoa: add snd-aoa")
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Takashi Iwai <tiwai@suse.de>