platform/kernel/linux-starfive.git
5 years agoMerge branch 'for-linus' into for-next
Takashi Iwai [Mon, 1 Jul 2019 15:01:00 +0000 (17:01 +0200)]
Merge branch 'for-linus' into for-next

This back-merge is necessary for adjusting the latest FireWire fix
with the recent refactoring in 5.3 development branch.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-lib/fireworks: fix miss detection of received MIDI messages
Takashi Sakamoto [Mon, 1 Jul 2019 14:43:53 +0000 (23:43 +0900)]
ALSA: firewire-lib/fireworks: fix miss detection of received MIDI messages

In IEC 61883-6, 8 MIDI data streams are multiplexed into single
MIDI conformant data channel. The index of stream is calculated by
modulo 8 of the value of data block counter.

In fireworks, the value of data block counter in CIP header has a quirk
with firmware version v5.0.0, v5.7.3 and v5.8.0. This brings ALSA
IEC 61883-1/6 packet streaming engine to miss detection of MIDI
messages.

This commit fixes the miss detection to modify the value of data block
counter for the modulo calculation.

For maintainers, this bug exists since a commit 18f5ed365d3f ("ALSA:
fireworks/firewire-lib: add support for recent firmware quirk") in Linux
kernel v4.2. There're many changes since the commit.  This fix can be
backported to Linux kernel v4.4 or later. I tagged a base commit to the
backport for your convenience.

Besides, my work for Linux kernel v5.3 brings heavy code refactoring and
some structure members are renamed in 'sound/firewire/amdtp-stream.h'.
The content of this patch brings conflict when merging -rc tree with
this patch and the latest tree. I request maintainers to solve the
conflict to replace 'tx_first_dbc' with 'ctx_data.tx.first_dbc'.

Fixes: df075feefbd3 ("ALSA: firewire-lib: complete AM824 data block processing layer")
Cc: <stable@vger.kernel.org> # v4.4+
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: hda: Fix a headphone detection issue when using SOF
Rander Wang [Mon, 1 Jul 2019 07:46:30 +0000 (15:46 +0800)]
ALSA: hda: Fix a headphone detection issue when using SOF

To save power, the hda hdmi driver in ASoC invokes snd_hdac_ext_bus_link_put
to disable CORB/RIRB buffers DMA if there is no user of bus and invokes
snd_hdac_ext_bus_link_get to set up CORB/RIRB buffers when it is used.
Unsolicited responses is disabled in snd_hdac_bus_stop_cmd_io called by
snd_hdac_ext_bus_link_put , but it is not enabled in snd_hdac_bus_init_cmd_io
called by snd_hdac_ext_bus_link_get. So for put-get sequence, Unsolicited
responses is disabled and headphone can't be detected by hda codecs.

Now unsolicited responses is only enabled in snd_hdac_bus_reset_link
which resets controller. The function is only called for setup of
controller. This patch enables Unsolicited responses after RIRB is
initialized in snd_hdac_bus_init_cmd_io which works together with
snd_hdac_bus_reset_link to set up controller.

Tested legacy hda driver and SOF driver on intel whiskeylake.

Reviewed-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Rander Wang <rander.wang@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: seq: fix incorrect order of dest_client/dest_ports arguments
Colin Ian King [Fri, 28 Jun 2019 09:54:29 +0000 (10:54 +0100)]
ALSA: seq: fix incorrect order of dest_client/dest_ports arguments

There are two occurrances of a call to snd_seq_oss_fill_addr where
the dest_client and dest_port arguments are in the wrong order. Fix
this by swapping them around.

Addresses-Coverity: ("Arguments in wrong order")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: hda/realtek - Change front mic location for Lenovo M710q
Dennis Wassenberg [Fri, 28 Jun 2019 08:54:53 +0000 (10:54 +0200)]
ALSA: hda/realtek - Change front mic location for Lenovo M710q

On M710q Lenovo ThinkCentre machine, there are two front mics,
we change the location for one of them to avoid conflicts.

Signed-off-by: Dennis Wassenberg <dennis.wassenberg@secunet.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-lib: fix to process MIDI conformant data channel for AM824 format
Takashi Sakamoto [Fri, 28 Jun 2019 05:53:31 +0000 (14:53 +0900)]
ALSA: firewire-lib: fix to process MIDI conformant data channel for AM824 format

In IEC 61883-6, 8 MIDI data streams are multiplexed into single MIDI
conformant data channel. The index of stream is calculated by modulo 8
of the value of data block counter. Therefore data block processing
layer requires valid value of data block counter.

In recent changes of ALSA IEC 61883-1/6 engine, the value of data block
counter is changed before calling data block processing layer. This
brings miss detection of MIDI messages in non-blocking transmission
method is used.

This commit fixes the bug by changing chached data block counter after
calling data block processing layer.

Fixes: e335425b6596 ("ALSA: firewire-lib: split helper function to check incoming CIP header")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-lib: cache next data_block_counter after probing tracepoints event...
Takashi Sakamoto [Fri, 28 Jun 2019 05:53:30 +0000 (14:53 +0900)]
ALSA: firewire-lib: cache next data_block_counter after probing tracepoints event for IR context

For debugging purpose, ALSA IEC 61883-1/6 engine has tracepoints event.
In current implementation, next data block counter is stored as current
data block counter before probing the event for IR isoc context. It's not
good to check current packet parameter.

This commit changes to assign the next data block counter after probing
the event.

Besides, Fireworks devices has a quirk to transfer isoc packet with
data block counter for the last data block. For this quirk, the
assignment is done before calling data block processing layer.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: xen-front: fix unintention integer overflow on left shifts
Colin Ian King [Thu, 27 Jun 2019 16:58:53 +0000 (17:58 +0100)]
ALSA: xen-front: fix unintention integer overflow on left shifts

Shifting the integer value 1 is evaluated using 32-bit
arithmetic and then used in an expression that expects a 64-bit
value, so there is potentially an integer overflow. Fix this
by using the BIT_ULL macro to perform the shift.

[ Note: as of the time being, no actual integer overflow hits because
  all values are less than 32bit, not including the extended 3-byte or
  DSD formats.  But this is the right fix for future usage, of
  course. -- tiwai ]

Addresses-Coverity: ("Unintentional integer overflow")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: usb-audio: fix sign unintended sign extension on left shifts
Colin Ian King [Thu, 27 Jun 2019 16:43:08 +0000 (17:43 +0100)]
ALSA: usb-audio: fix sign unintended sign extension on left shifts

There are a couple of left shifts of unsigned 8 bit values that
first get promoted to signed ints and hence get sign extended
on the shift if the top bit of the 8 bit values are set. Fix
this by casting the 8 bit values to unsigned ints to stop the
unintentional sign extension.

Addresses-Coverity: ("Unintended sign extension")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: hda/realtek: Add quirks for several Clevo notebook barebones
Richard Sailer [Wed, 19 Jun 2019 11:33:11 +0000 (13:33 +0200)]
ALSA: hda/realtek: Add quirks for several Clevo notebook barebones

This adds 4 SND_PCI_QUIRK(...) lines for several barebone models of the ODM
Clevo. The model names are written in regex syntax to describe/match all clevo
models that are similar enough and use the same PCI SSID that this fixup works
for them.

Additionally the lines regarding SSID 0x96e1 and 0x97e1 didn't fix audio for the
all our Clevo notebooks using these SSIDs (models Clevo P960* and P970*) since
ALC1220_FIXP_CLEVO_PB51ED_PINS swapped pins that are not necesarry to be
swapped. This patch initiates ALC1220_FIXUP_CLEVO_P950 instead for these model
and fixes the audio.

Fixes: 80690a276f44 ("ALSA: hda/realtek - Add quirk for Tuxedo XC 1509")
Signed-off-by: Richard Sailer <rs@tuxedocomputers.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: usb-audio: Sanity checks for each pipe and EP types
Takashi Iwai [Mon, 24 Jun 2019 13:08:28 +0000 (15:08 +0200)]
ALSA: usb-audio: Sanity checks for each pipe and EP types

The recent USB core code performs sanity checks for the given pipe and
EP types, and it can be hit by manipulated USB descriptors by syzbot.
For making syzbot happier, this patch introduces a local helper for a
sanity check in the driver side and calls it at each place before the
message handling, so that we can avoid the WARNING splats.

Reported-by: syzbot+d952e5e28f5fb7718d23@syzkaller.appspotmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-motu: unify common tracepoints for both direction
Takashi Sakamoto [Mon, 24 Jun 2019 09:16:46 +0000 (18:16 +0900)]
ALSA: firewire-motu: unify common tracepoints for both direction

In ALSA firewire-motu driver, some tracepoints are supported to probe
vendor-specific data fields for SPH and status/control messages in
payload of isochronous packet. At present, the events of tracepoints
are unique each of direction, however the pair of events has the
same structure and print format. It's possible to unify the pair.

This commit unifies the pair. From userspace, direction is specified
by filtering for src/dst fields in the structure.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoRevert "ALSA: firewire-lib: fix inverted node IDs for amdtp_packet events"
Takashi Sakamoto [Mon, 24 Jun 2019 09:20:15 +0000 (18:20 +0900)]
Revert "ALSA: firewire-lib: fix inverted node IDs for amdtp_packet events"

This reverts commit e703965a129cdd72ff74e248f8fbf0d617844527.

When creating this patch, I compared the value of src field to the
value of first byte of cip_header field (SID) in tracing event.
But in this test I used a device which has a quirk to transfer
isochronous packet with invalid SID. The original change is valid.

Fixes: e703965a129c ("ALSA: firewire-lib: fix inverted node IDs for amdtp_packet events")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: oxfw: ensure to release isochronous resources in pcm.hw_params callback
Takashi Sakamoto [Tue, 18 Jun 2019 13:26:22 +0000 (22:26 +0900)]
ALSA: oxfw: ensure to release isochronous resources in pcm.hw_params callback

When stopping packet streaming in reserve function for duplex streams,
isochronous resources should be released.

Fixes: 7bc93821a70a ("ALSA: firewire-lib: split allocation of isochronous resources from establishment of connection")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: fireworks: ensure to release isochronous resources in pcm.hw_params callback
Takashi Sakamoto [Tue, 18 Jun 2019 13:26:21 +0000 (22:26 +0900)]
ALSA: fireworks: ensure to release isochronous resources in pcm.hw_params callback

When stopping packet streaming in reserve function for duplex streams,
isochronous resources should be released.

Fixes: 7bc93821a70a ("ALSA: firewire-lib: split allocation of isochronous resources from establishment of connection")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: bebob: ensure to release isochronous resources in pcm.hw_params callback
Takashi Sakamoto [Tue, 18 Jun 2019 13:26:20 +0000 (22:26 +0900)]
ALSA: bebob: ensure to release isochronous resources in pcm.hw_params callback

When stopping packet streaming in reserve function for duplex streams,
isochronous resources should be released.

Fixes: 7bc93821a70a ("ALSA: firewire-lib: split allocation of isochronous resources from establishment of connection")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: dice: unify stop and release method for duplex streams
Takashi Sakamoto [Tue, 18 Jun 2019 13:26:19 +0000 (22:26 +0900)]
ALSA: dice: unify stop and release method for duplex streams

>From callbacks for pcm and rawmidi interfaces, the functions to stop
and release duplex streams are called at the same time. This commit
merges the two functions.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-digi00x: unify stop and release method for duplex streams
Takashi Sakamoto [Tue, 18 Jun 2019 13:26:18 +0000 (22:26 +0900)]
ALSA: firewire-digi00x: unify stop and release method for duplex streams

>From callbacks for pcm and rawmidi interfaces, the functions to stop
and release duplex streams are called at the same time. This commit
merges the two functions.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-motu: unify stop and release method for duplex streams
Takashi Sakamoto [Tue, 18 Jun 2019 13:26:17 +0000 (22:26 +0900)]
ALSA: firewire-motu: unify stop and release method for duplex streams

>From callbacks for pcm and rawmidi interfaces, the functions to stop
and release duplex streams are called at the same time. This commit
merges the two functions.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: fireface: unify stop and release method for duplex streams
Takashi Sakamoto [Tue, 18 Jun 2019 13:26:16 +0000 (22:26 +0900)]
ALSA: fireface: unify stop and release method for duplex streams

>From callbacks for pcm and rawmidi interfaces, the functions to stop
and release duplex streams are called at the same time. This commit
merges the two functions.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-tascam: unify stop and release method for duplex streams
Takashi Sakamoto [Tue, 18 Jun 2019 13:26:15 +0000 (22:26 +0900)]
ALSA: firewire-tascam: unify stop and release method for duplex streams

>From callbacks for pcm and rawmidi interfaces, the functions to stop
and release duplex streams are called at the same time. This commit
merges the two functions.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-motu: code refactoring for pcm.hw_params/hw_free callbacks
Takashi Sakamoto [Mon, 17 Jun 2019 08:15:10 +0000 (17:15 +0900)]
ALSA: firewire-motu: code refactoring for pcm.hw_params/hw_free callbacks

The pairs of pcm.hw_params callbacks and .hw_free callbacks for both
direction have no differences.

This commit unifies the pairs.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-motu: update isochronous resources when starting packet streaming...
Takashi Sakamoto [Mon, 17 Jun 2019 08:15:09 +0000 (17:15 +0900)]
ALSA: firewire-motu: update isochronous resources when starting packet streaming after bus-reset

After bus reset, isochronous resource manager releases all of allocated
isochronous resources. The nodes to transfer isochronous packet should
request reallocation of the resources.

However, between the bus-reset and invocation of 'struct fw_driver.update'
handler, ALSA PCM application can detect this situation by XRUN because
the target device cancelled to transmit packets once bus-reset occurs.

Due to the above mechanism, ALSA fireface driver just stops packet
streaming in the update handler, thus pcm.prepare handler should
request the reallocation.

This commit requests the reallocation in pcm.prepare callback when
bus generation is changed.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-motu: reserve/release isochronous resources in pcm.hw_params/hw_free...
Takashi Sakamoto [Mon, 17 Jun 2019 08:15:08 +0000 (17:15 +0900)]
ALSA: firewire-motu: reserve/release isochronous resources in pcm.hw_params/hw_free callbacks

Once allocated, isochronous resources are available for packet
streaming, even if the streaming is cancelled. For this reason,
current implementation handles allocation of the resources and
starting packet streaming at the same time. However, this brings
complicated procedure to start packet streaming.

This commit separates the allocation and starting. The allocation is
done in pcm.hw_params callback and available till pcm.hw_free callback.
Even if any XRUN occurs, pcm.prepare callback is done to restart
packet streaming without releasing/allocating the resources.

There are two points to stop packet streaming; in pcm.hw_params and
pcm.prepare callbacks. The former point is a case that packet streaming
is already started for any MIDI substream then packet streaming is
requested with different sampling transfer frequency for any PCM
substream. The latter point is cases of any XRUN or packet queueing
error.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-motu: code refactoring to finish streaming session
Takashi Sakamoto [Mon, 17 Jun 2019 08:15:07 +0000 (17:15 +0900)]
ALSA: firewire-motu: code refactoring to finish streaming session

The operation to finish packet streaming includes stopping isochronous
contexts. This commit merges it to the helper function.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-motu: minor code refactoring to stop isochronous context
Takashi Sakamoto [Mon, 17 Jun 2019 08:15:06 +0000 (17:15 +0900)]
ALSA: firewire-motu: minor code refactoring to stop isochronous context

The helper function to stop isochronous context is superfluous. This
commit removes it with simpler codes.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-motu: rename helper functions to begin/finish streaming session
Takashi Sakamoto [Mon, 17 Jun 2019 08:15:05 +0000 (17:15 +0900)]
ALSA: firewire-motu: rename helper functions to begin/finish streaming session

Like the other drivers in ALSA firewire stack, this commit renames
functions to begin/finish packet streaming.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-motu: code refactoring for condition to stop streaming
Takashi Sakamoto [Mon, 17 Jun 2019 08:15:04 +0000 (17:15 +0900)]
ALSA: firewire-motu: code refactoring for condition to stop streaming

In snd_motu_stream_start_duplex() function, there're two points to stop
packet streaming, however they can be merged.  This commit merges them.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-motu: add helper function to keep isochronous resources
Takashi Sakamoto [Mon, 17 Jun 2019 08:15:03 +0000 (17:15 +0900)]
ALSA: firewire-motu: add helper function to keep isochronous resources

This commit is a part of preparation to perform allocation/release
of isochronous resources in pcm.hw_params/hw_free callbacks.

This commit adds a helper function to allocate isochronous resources.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-motu: unify midi callback function
Takashi Sakamoto [Mon, 17 Jun 2019 08:15:02 +0000 (17:15 +0900)]
ALSA: firewire-motu: unify midi callback function

Two sets of callbacks for rawmidi.open/close but they have the same
codes. This commit unifies each of the callbacks.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-motu: unify the count of subscriber for packet streaming
Takashi Sakamoto [Mon, 17 Jun 2019 08:15:01 +0000 (17:15 +0900)]
ALSA: firewire-motu: unify the count of subscriber for packet streaming

Two counters are used to maintain isochronous packet streaming for both
directions. However, like the other drivers, they can be replaced with
one counter. This commit unifies them.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-lib: split allocation of isochronous resources from establishment...
Takashi Sakamoto [Sat, 15 Jun 2019 09:11:01 +0000 (18:11 +0900)]
ALSA: firewire-lib: split allocation of isochronous resources from establishment of connection

In current implementation, establishment connection corresponds to
allocation of isochronous resources. Although this is an ideal
implementation of CMP described in IEC 61883-1, it's not enough
efficient to recover PCM substream multiplexed in packet streaming.
The packet streaming can always restart on the same allocated
isochronous resources even if the previous packet streaming
corrupted.

This commit splits allocation of isochronous resources from
establishment of connection so that CMP runs with allocated
isochronous resources.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: fireworks: change the range of critical section for stream data in PCM.hw_free...
Takashi Sakamoto [Sat, 15 Jun 2019 09:11:00 +0000 (18:11 +0900)]
ALSA: fireworks: change the range of critical section for stream data in PCM.hw_free callback

The operation of duplex streams should be in critical section.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: bebob: code refactoring for error path to start duplex stream
Takashi Sakamoto [Sat, 15 Jun 2019 09:10:59 +0000 (18:10 +0900)]
ALSA: bebob: code refactoring for error path to start duplex stream

This commit removes useless procedures to stop packet streaming.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: bebob: change the range of critical section for stream data in PCM.hw_free...
Takashi Sakamoto [Sat, 15 Jun 2019 09:10:58 +0000 (18:10 +0900)]
ALSA: bebob: change the range of critical section for stream data in PCM.hw_free callback

The operation of duplex streams should be in critical section.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: bebob: code refactoring for callback function to rawmidi interface
Takashi Sakamoto [Sat, 15 Jun 2019 09:10:57 +0000 (18:10 +0900)]
ALSA: bebob: code refactoring for callback function to rawmidi interface

The pairs of rawmidi.hw_params callback functions and .hw_free callback
functions for both direction have no differences.

This commit unifies the pairs.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: bebob: code rafactoring for callback functions to PCM interface
Takashi Sakamoto [Sat, 15 Jun 2019 09:10:56 +0000 (18:10 +0900)]
ALSA: bebob: code rafactoring for callback functions to PCM interface

The pairs of pcm.hw_params callback functions and .hw_free callback
functions for both direction have no differences.

This commit unifies the pairs.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoRevert "ALSA: hda/realtek - Improve the headset mic for Acer Aspire laptops"
Hui Wang [Fri, 14 Jun 2019 08:44:12 +0000 (16:44 +0800)]
Revert "ALSA: hda/realtek - Improve the headset mic for Acer Aspire laptops"

This reverts commit 9cb40eb184c4220d244a532bd940c6345ad9dbd9.

This patch introduces noise and headphone playback issue after
rebooting or suspending/resuming. Let us revert it.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=203831
Fixes: 9cb40eb184c4 ("ALSA: hda/realtek - Improve the headset mic for Acer Aspire laptops")
Cc: <stable@vger.kernel.org>
Signed-off-by: Hui Wang <hui.wang@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: pci: echoaudio: remove variable which is a constant
Wolfram Sang [Thu, 13 Jun 2019 16:04:23 +0000 (18:04 +0200)]
ALSA: pci: echoaudio: remove variable which is a constant

Checking a variable which is always '1' has no use.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoMerge tag 'asoc-fix-v5.2-rc4' of https://git.kernel.org/pub/scm/linux/kernel/git...
Takashi Iwai [Thu, 13 Jun 2019 15:33:34 +0000 (17:33 +0200)]
Merge tag 'asoc-fix-v5.2-rc4' of https://git./linux/kernel/git/broonie/sound into for-linus

ASoC: Fixes for v5.2

There's an awful lot of fixes here, almost all for the newly introduced
SoF DSP drivers (including a few things it turned up in shared code).
This is a large and complex piece of code so it's not surprising that
there have been quite a few issues here, fortunately things seem to have
mostly calmed down now.  Otherwise there's just a smattering of small fixes.

5 years agoALSA: hda/hdmi - consider eld_valid also in sync_eld_via_acomp()
Jaroslav Kysela [Thu, 13 Jun 2019 13:09:01 +0000 (15:09 +0200)]
ALSA: hda/hdmi - consider eld_valid also in sync_eld_via_acomp()

In the commit 7f641e26a6df9269cb25dd7a4b0a91d6586ed441 (ALSA: hda/hdmi
- Consider eld_valid when reporting jack event) the eld_valid check was
added for the jack event reports. Do the same in sync_eld_via_acomp()
function. Apparently, it is required for the NVIDIA proprietary driver
(monitor presence reported first, but ELD is available later).

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: hda: remove an unused field from struct hda_codec
Guennadi Liakhovetski [Wed, 12 Jun 2019 16:36:54 +0000 (11:36 -0500)]
ALSA: hda: remove an unused field from struct hda_codec

The .jacks field in struct hda_codec is unused and seems to be a
duplicate of .jacktbl, remove it.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: hda: Add Elkhart Lake PCI ID
Lai, Poey Seng [Thu, 13 Jun 2019 16:21:39 +0000 (00:21 +0800)]
ALSA: hda: Add Elkhart Lake PCI ID

Add HD Audio Device PCI ID for the Intel Elkhart Lake
platform.

Signed-off-by: Lai, Poey Seng <poey.seng.lai@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: dice: fix compiler warning due to returning uninitialized value
Takashi Sakamoto [Thu, 13 Jun 2019 03:35:22 +0000 (12:35 +0900)]
ALSA: dice: fix compiler warning due to returning uninitialized value

This commit fixes the warning due to returning uninitialized value
from start_streams() helper function.

   sound/firewire/dice/dice-stream.c: In function 'start_streams.isra.0':
>> sound/firewire/dice/dice-stream.c:350:6: warning: 'err' may be used uninitialized in this function [-Wmaybe-uninitialized]
     int err;
         ^~~

Reported-by: kbuild test robot <lkp@intel.com>
Fixes: 3cd2c2d780a2 ("ALSA: dice: reserve/release isochronous resources in pcm.hw_params/hw_free callbacks")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: oxfw: configure stream parameter in pcm.hw_params callback
Takashi Sakamoto [Wed, 12 Jun 2019 08:44:22 +0000 (17:44 +0900)]
ALSA: oxfw: configure stream parameter in pcm.hw_params callback

This commit is a part of preparation to perform allocation/release
of isochronous resources in pcm.hw_params/hw_free callbacks.

This commit splits out an operation to configure stream parameters into
pcm.hw_params callback. In pcm.prepare callback, establishing
connections and start isochronous contexts.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: oxfw: configure packet format in pcm.hw_params callback
Takashi Sakamoto [Wed, 12 Jun 2019 08:44:21 +0000 (17:44 +0900)]
ALSA: oxfw: configure packet format in pcm.hw_params callback

This commit is a part of preparation to perform allocation/release
of isochronous resources in pcm.hw_params/hw_free callbacks.

At present, several operations are done in pcm.prepare callback. To
reduce load of the callback, This commit splits out an operation to
set packet format in pcm.hw_params callback.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: oxfw: unify substreams counter
Takashi Sakamoto [Wed, 12 Jun 2019 08:44:20 +0000 (17:44 +0900)]
ALSA: oxfw: unify substreams counter

In former commits, two isochronous contexts are handles at the same
time. This commit unifies stream counters to obsolete them.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: oxfw: rename helper functions for duplex streams
Takashi Sakamoto [Wed, 12 Jun 2019 08:44:19 +0000 (17:44 +0900)]
ALSA: oxfw: rename helper functions for duplex streams

In former commits, ALSA oxfw driver handles two isochronous contexts
at the same time, except for some devices which supports one endpoint
of isochronous packet stream.

This commit renames some helper functions so that they handles duplex
streams.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: oxfw: expand stop procedure for packet streaming
Takashi Sakamoto [Wed, 12 Jun 2019 08:44:18 +0000 (17:44 +0900)]
ALSA: oxfw: expand stop procedure for packet streaming

The helper function stop packet streaming is not enough useful. This
commit obsoletes it and expands its code.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: oxfw: break packet streaming at bus-reset handler
Takashi Sakamoto [Wed, 12 Jun 2019 08:44:17 +0000 (17:44 +0900)]
ALSA: oxfw: break packet streaming at bus-reset handler

In most cases, recovery from bus reset is not successful. This commit
aborts packet streaming in bus reset handler.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: oxfw: start duplex streams if supported
Takashi Sakamoto [Wed, 12 Jun 2019 08:44:16 +0000 (17:44 +0900)]
ALSA: oxfw: start duplex streams if supported

It's inconvenient to handle two isochronous context separately
each other. This commit unifies the counters to handle the two
at the same time.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: oxfw: set packet parameter according to current configuration
Takashi Sakamoto [Wed, 12 Jun 2019 08:44:15 +0000 (17:44 +0900)]
ALSA: oxfw: set packet parameter according to current configuration

After a call of pcm.hw_params, the state of target device is expected
for applications. This commit retrieves the state and start packet
streaming.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: oxfw: code refactoring for stop condition of packet streaming
Takashi Sakamoto [Wed, 12 Jun 2019 08:44:14 +0000 (17:44 +0900)]
ALSA: oxfw: code refactoring for stop condition of packet streaming

This commit unifies stop condition due to queueing error and unmatched
state of the target device.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: fireworks: don't set XRUN in stop streaming
Takashi Sakamoto [Wed, 12 Jun 2019 08:44:13 +0000 (17:44 +0900)]
ALSA: fireworks: don't set XRUN in stop streaming

When stopping packet streaming, no need to stop PCM substream with XRUN
state. This commit suppresses it.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: fireworks: configure stream parameters in pcm.hw_params callback
Takashi Sakamoto [Wed, 12 Jun 2019 08:44:12 +0000 (17:44 +0900)]
ALSA: fireworks: configure stream parameters in pcm.hw_params callback

This commit is a part of preparation to perform allocation/release
of isochronous resources in pcm.hw_params/hw_free callbacks.

This commit splits out an operation to configure stream parameters into
pcm.hw_params callback. In pcm.prepare callback, establishing
connections and start isochronous contexts.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: fireworks: configure sampling transfer frequency in pcm.hw_params callback
Takashi Sakamoto [Wed, 12 Jun 2019 08:44:11 +0000 (17:44 +0900)]
ALSA: fireworks: configure sampling transfer frequency in pcm.hw_params callback

This commit is a part of preparation to perform allocation/release
of isochronous resources in pcm.hw_params/hw_free callbacks.

At present, several operations are done in pcm.prepare callback. To
reduce load of the callback, This commit splits out an operation to
set sampling transfer frequency in pcm.hw_params callback.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: fireworks: code refactoring for pcm.hw_params/hw_free
Takashi Sakamoto [Wed, 12 Jun 2019 08:44:10 +0000 (17:44 +0900)]
ALSA: fireworks: code refactoring for pcm.hw_params/hw_free

Two sets of callbacks for pcm.hw_params/hw_free but they have the same
codes. This commit unifies each of the callbacks.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: fireworks: code refactoring for rawmidi.open/close
Takashi Sakamoto [Wed, 12 Jun 2019 08:44:09 +0000 (17:44 +0900)]
ALSA: fireworks: code refactoring for rawmidi.open/close

Two sets of callbacks for rawmidi.open/close but they have the same
codes. This commit unifies each of the callbacks.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: fireworks: unify substream counter
Takashi Sakamoto [Wed, 12 Jun 2019 08:44:08 +0000 (17:44 +0900)]
ALSA: fireworks: unify substream counter

This commit is a part of preparation to perform allocation/release
of isochronous resources in pcm.hw_params/hw_free callbacks.

It's inconvenient to handle two isochronous context separately
each other. This commit unifies the counters to handle the two
at the same time.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: bebob: code refactoring to initialize/destroy stream data
Takashi Sakamoto [Wed, 12 Jun 2019 08:44:07 +0000 (17:44 +0900)]
ALSA: bebob: code refactoring to initialize/destroy stream data

This commit changes helper functions to initialize/destroy stream
data so that it has an argument for direction.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: bebob: obsolete useless member of private structure
Takashi Sakamoto [Wed, 12 Jun 2019 08:44:06 +0000 (17:44 +0900)]
ALSA: bebob: obsolete useless member of private structure

The private structure of this driver has 'connected' member but nowadays
it's useless. This commit removes it.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: bebob: don't set XRUN in stop streaming
Takashi Sakamoto [Wed, 12 Jun 2019 08:44:05 +0000 (17:44 +0900)]
ALSA: bebob: don't set XRUN in stop streaming

When stopping packet streaming, no need to stop PCM substream with XRUN
state. This commit suppresses it.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: bebob: configure sampling transfer frequency in pcm.hw_params callback
Takashi Sakamoto [Wed, 12 Jun 2019 08:44:04 +0000 (17:44 +0900)]
ALSA: bebob: configure sampling transfer frequency in pcm.hw_params callback

This commit is a part of preparation to perform allocation/release
of isochronous resources in pcm.hw_params/hw_free callbacks.

At present, several operations are done in pcm.prepare callback. To
reduce load of the callback, This commit splits out an operation to
set sampling transfer frequency in pcm.hw_params callback.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: hda: fix a mask for unsolicited event tags
Guennadi Liakhovetski [Tue, 11 Jun 2019 17:09:07 +0000 (19:09 +0200)]
ALSA: hda: fix a mask for unsolicited event tags

Response tag only occupies 6 bits, not 7. This bug is harmless, since
the value has just been shifted to the right by 26 bits, so this is
only a cosmetic fix.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: dice: code refactoring for pcm.hw_params/hw_free callbacks
Takashi Sakamoto [Tue, 11 Jun 2019 13:21:18 +0000 (22:21 +0900)]
ALSA: dice: code refactoring for pcm.hw_params/hw_free callbacks

The pairs of pcm.hw_params callbacks and .hw_free callbacks for both
direction have no differences.

This commit unifies the pairs.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: dice: update isochronous resources when starting packet streaming after bus...
Takashi Sakamoto [Tue, 11 Jun 2019 13:21:17 +0000 (22:21 +0900)]
ALSA: dice: update isochronous resources when starting packet streaming after bus-reset

After bus reset, isochronous resource manager releases all of allocated
isochronous resources. The nodes to transfer isochronous packet should
request reallocation of the resources.

However, between the bus-reset and invocation of 'struct fw_driver.update'
handler, ALSA PCM application can detect this situation by XRUN because
the target device cancelled to transmit packets once bus-reset occurs.

Due to the above mechanism, ALSA fireface driver just stops packet
streaming in the update handler, thus pcm.prepare handler should
request the reallocation.

This commit requests the reallocation in pcm.prepare callback when
bus generation is changed.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: dice: reserve/release isochronous resources in pcm.hw_params/hw_free callbacks
Takashi Sakamoto [Tue, 11 Jun 2019 13:21:16 +0000 (22:21 +0900)]
ALSA: dice: reserve/release isochronous resources in pcm.hw_params/hw_free callbacks

Once allocated, isochronous resources are available for packet
streaming, even if the streaming is cancelled. For this reason,
current implementation handles allocation of the resources and
starting packet streaming at the same time. However, this brings
complicated procedure to start packet streaming.

This commit separates the allocation and starting. The allocation is
done in pcm.hw_params callback and available till pcm.hw_free callback.
Even if any XRUN occurs, pcm.prepare callback is done to restart
packet streaming without releasing/allocating the resources.

There are two points to stop packet streaming; in pcm.hw_params and
pcm.prepare callbacks. The former point is a case that packet streaming
is already started for any MIDI substream then packet streaming is
requested with different sampling transfer frequency for any PCM
substream. The latter point is cases of any XRUN or packet queueing
error.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: dice: code refactoring to keep isochronous resources
Takashi Sakamoto [Tue, 11 Jun 2019 13:21:15 +0000 (22:21 +0900)]
ALSA: dice: code refactoring to keep isochronous resources

This commit is a part of preparation to perform allocation/release
of isochronous resources in pcm.hw_params/hw_free callbacks.

This commit adds a helper function to allocate isochronous resources,
separated from operations to start packet streaming, I note that some
dice-based devices have two pair of endpoints for isochronous packet
straeming.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: dice: code refactoring to stop packet streaming
Takashi Sakamoto [Tue, 11 Jun 2019 13:21:14 +0000 (22:21 +0900)]
ALSA: dice: code refactoring to stop packet streaming

This commit is a part of preparation to perform allocation/release
of isochronous resources in pcm.hw_params/hw_free callbacks.

There're three points to finish packet streaming but no helper
functions for common operations for it. This commit adds a helper
function for operations to finish packet streaming.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-digi00x: code refactoring for pcm.hw_params/hw_free callbacks
Takashi Sakamoto [Tue, 11 Jun 2019 13:21:13 +0000 (22:21 +0900)]
ALSA: firewire-digi00x: code refactoring for pcm.hw_params/hw_free callbacks

The pairs of pcm.hw_params callbacks and .hw_free callbacks for both
direction have no differences.

This commit unifies the pairs.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-digi00x: update isochronous resources when starting packet streaming...
Takashi Sakamoto [Tue, 11 Jun 2019 13:21:12 +0000 (22:21 +0900)]
ALSA: firewire-digi00x: update isochronous resources when starting packet streaming after bus-reset

After bus reset, isochronous resource manager releases all of allocated
isochronous resources. The nodes to transfer isochronous packet should
request reallocation of the resources.

However, between the bus-reset and invocation of 'struct fw_driver.update'
handler, ALSA PCM application can detect this situation by XRUN because
the target device cancelled to transmit packets once bus-reset occurs.

Due to the above mechanism, ALSA fireface driver just stops packet
streaming in the update handler, thus pcm.prepare handler should
request the reallocation.

This commit requests the reallocation in pcm.prepare callback when
bus generation is changed.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-digi00x: reserve/release isochronous resources in pcm.hw_params/hw_fre...
Takashi Sakamoto [Tue, 11 Jun 2019 13:21:11 +0000 (22:21 +0900)]
ALSA: firewire-digi00x: reserve/release isochronous resources in pcm.hw_params/hw_free callbacks

Once allocated, isochronous resources are available for packet
streaming, even if the streaming is cancelled. For this reason,
current implementation handles allocation of the resources and
starting packet streaming at the same time. However, this brings
complicated procedure to start packet streaming.

This commit separates the allocation and starting. The allocation is
done in pcm.hw_params callback and available till pcm.hw_free callback.
Even if any XRUN occurs, pcm.prepare callback is done to restart
packet streaming without releasing/allocating the resources.

There are two points to stop packet streaming; in pcm.hw_params and
pcm.prepare callbacks. The former point is a case that packet streaming
is already started for any MIDI substream then packet streaming is
requested with different sampling transfer frequency for any PCM
substream. The latter point is cases of any XRUN or packet queueing
error.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-digi00x: code refactoring to keep isochronous resources
Takashi Sakamoto [Tue, 11 Jun 2019 13:21:10 +0000 (22:21 +0900)]
ALSA: firewire-digi00x: code refactoring to keep isochronous resources

This commit is a part of preparation to perform allocation/release
of isochronous resources in pcm.hw_params/hw_free callbacks.

All of models in Digidesign Digi00x family have the same formation of
data channels in isochronous packet for both directions. This commit
simplifies allocation of isochronous resources in this point.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-digi00x: simplify error path to begin streaming session
Takashi Sakamoto [Tue, 11 Jun 2019 13:21:09 +0000 (22:21 +0900)]
ALSA: firewire-digi00x: simplify error path to begin streaming session

This commit is a part of preparation to perform allocation/release
of isochronous resources in pcm.hw_params/hw_free callbacks.

The caller of begin_session() calls finish_session() in its error path,
thus no need to call finish_session() in error path of begin_session().

This commit simplifies error path of begin_session().

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-digi00x: code refactoring to finish streaming session
Takashi Sakamoto [Tue, 11 Jun 2019 13:21:08 +0000 (22:21 +0900)]
ALSA: firewire-digi00x: code refactoring to finish streaming session

This commit is a part of preparation to perform allocation/release
of isochronous resources in pcm.hw_params/hw_free callbacks.

The operation to finish packet streaming corresponds to stopping
isochronous contexts. This commit applies code refactoring to
move codes to stop into a helper function to finish the session.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-digi00x: refactoring to move timing of registration for isochronous...
Takashi Sakamoto [Tue, 11 Jun 2019 13:21:07 +0000 (22:21 +0900)]
ALSA: firewire-digi00x: refactoring to move timing of registration for isochronous channel

This commit is a part of preparation to perform allocation/release
of isochronous resources in pcm.hw_params/hw_free callbacks.

The registration of isochronous channels is done just after allocation
of isochronous resources. This commit separates the registration just
before starting packet streaming.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: usb-audio: Enable .product_name override for Emagic, Unitor 8.
Stefan Sauer [Mon, 10 Jun 2019 09:51:46 +0000 (11:51 +0200)]
ALSA: usb-audio: Enable .product_name override for Emagic, Unitor 8.

The Emagic Unitor 8 does not provide iManufacturer and iProduct fields
in its device descriptor. These fields are used by alsa to make build the
device name. Thus uncomment the .product-name in the quirks-table.

Without this change the device shows up as 'USB Device 0x86a:0x01'.

Output of lsusb and amidi:
https://gist.github.com/ensonic/7820a102e91f31575be355da2b6b33bc

Signed-off-by: Stefan Sauer <ensonic@google.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: ice1712: Check correct return value to snd_i2c_sendbytes (EWS/DMX 6Fire)
Rui Nuno Capela [Fri, 7 Jun 2019 14:13:37 +0000 (15:13 +0100)]
ALSA: ice1712: Check correct return value to snd_i2c_sendbytes (EWS/DMX 6Fire)

Check for exact and correct return value to snd_i2c_sendbytes
call for EWS/DMX 6Fire (snd_ice1712).

Fixes a systemic error on every boot starting from kernel 5.1
onwards to snd_ice1712 driver ("cannot send pca") on Terratec
EWS/DMX 6Fire PCI soundcards.

Check for exact and correct return value to snd_i2c_sendbytes
call for EWS/DMX 6Fire (snd_ice1712).

Fixes a systemic error on every boot to snd_ice1712 driver
("cannot send pca") on Terratec EWS/DMX 6Fire PCI soundcards.

Fixes: c99776cc4018 ("ALSA: ice1712: fix a missing check of snd_i2c_sendbytes")
Signed-off-by: Rui Nuno Capela <rncbc@rncbc.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: oxfw: allow PCM capture for Stanton SCS.1m
Takashi Sakamoto [Sun, 9 Jun 2019 10:29:12 +0000 (19:29 +0900)]
ALSA: oxfw: allow PCM capture for Stanton SCS.1m

Stanton SCS.1m can transfer isochronous packet with Multi Bit Linear
Audio data channels, therefore it allows software to capture PCM
substream. However, ALSA oxfw driver doesn't.

This commit changes the driver to add one PCM substream for capture
direction.

Fixes: de5126cc3c0b ("ALSA: oxfw: add stream format quirk for SCS.1 models")
Cc: <stable@vger.kernel.org> # v4.5+
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: fireface: code refactoring for pcm.hw_params/hw_free callbacks
Takashi Sakamoto [Sun, 2 Jun 2019 07:12:59 +0000 (16:12 +0900)]
ALSA: fireface: code refactoring for pcm.hw_params/hw_free callbacks

The pairs of pcm.hw_params callbacks and .hw_free callbacks for both
direction have no differences.

This commit unifies the pairs.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: fireface: minor code refactoring to finish streaming session
Takashi Sakamoto [Sun, 2 Jun 2019 07:12:58 +0000 (16:12 +0900)]
ALSA: fireface: minor code refactoring to finish streaming session

The operation to finish packet streaming corresponds to stopping
isochronous contexts.

This commit applies code refactoring to move codes to stop into
a helper function to finish the session.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: fireface: update isochronous resources when starting packet streaming after...
Takashi Sakamoto [Sun, 2 Jun 2019 07:12:57 +0000 (16:12 +0900)]
ALSA: fireface: update isochronous resources when starting packet streaming after bus-reset

After bus reset, isochronous resource manager releases all of allocated
isochronous resources. The nodes to restart packet streaming should
request reallocation of the resources.

However, between the bus-reset and invocation of 'struct fw_driver.update'
handler, ALSA PCM application can detect this situation by XRUN because
the target device cancelled to transmit packets once bus-reset occurs.

Due to the above mechanism, ALSA fireface driver just stops packet
streaming in the update handler, thus pcm.prepare handler should
request the reallocation.

This commit requests the reallocation in pcm.prepare callback when
bus generation is changed.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: fireface: reserve/release isochronous resources in pcm.hw_params/hw_free callbacks
Takashi Sakamoto [Sun, 2 Jun 2019 07:12:56 +0000 (16:12 +0900)]
ALSA: fireface: reserve/release isochronous resources in pcm.hw_params/hw_free callbacks

Once allocated, isochronous resources are available for packet
streaming, even if the streaming is cancelled. For this reason,
current implementation handles allocation of the resources and
starting packet streaming at the same time. However, this brings
complicated procedure to start packet streaming.

This commit separates the allocation and starting. The allocation is
done in pcm.hw_params callback and available till pcm.hw_free callback.
Even if any XRUN occurs, pcm.prepare callback is done to restart
packet streaming for allocated the resources.

There are two points to stop packet streaming; in pcm.hw_params and
pcm.prepare callbacks.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: fireface: support allocate_resources operation in latter protocol
Takashi Sakamoto [Sun, 2 Jun 2019 07:12:55 +0000 (16:12 +0900)]
ALSA: fireface: support allocate_resources operation in latter protocol

This commit is a part of preparation to perform allocation/release
of isochronous channels in pcm.hw_params/hw_free callbacks.

This commit implements allocate_resources callback for the protocol
specific to latter models. The encoded values of constant table is
split into several condition statements to separate the operation
to configure sampling transfer frequency from the operation to
configure the number of data channels in rx packet.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: fireface: support allocate_resources operation in ff400 protocol
Takashi Sakamoto [Sun, 2 Jun 2019 07:12:54 +0000 (16:12 +0900)]
ALSA: fireface: support allocate_resources operation in ff400 protocol

This commit is a part of preparation to perform allocation/release
of isochronous channels in pcm.hw_params/hw_free callbacks.

This commit implements allocate_resources callback for ff400 protocol.
In this callback, sampling transfer frequency is configured to the
device as well.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: fireface: support allocate_resources operation in ff800 protocol
Takashi Sakamoto [Sun, 2 Jun 2019 07:12:53 +0000 (16:12 +0900)]
ALSA: fireface: support allocate_resources operation in ff800 protocol

This commit is a part of preparation to perform allocation/release
of isochronous channels in pcm.hw_params/hw_free callbacks.

This commit implements allocate_resources callback for ff800 protocol.
As I noted in commit fc716397a5c7 ("ALSA: fireface: add support for
packet streaming on Fireface 800"), this unit allocates isochronous
resources for tx stream voluntarily. Therefore, this commit is to
maintain isochronous rsources for rx stream. In the callback,
sampling transfer frequency is configured to the device as well.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: fireface: add protocol-specific operation to allocate isochronous resources
Takashi Sakamoto [Sun, 2 Jun 2019 07:12:52 +0000 (16:12 +0900)]
ALSA: fireface: add protocol-specific operation to allocate isochronous resources

This commit is a part of preparation to perform allocation/release
of isochronous channels in pcm.hw_params/hw_free callbacks.

In ALSA fireface driver, the allocation of isochronous resources is
programmed in each implementation of protocol. This commit adds
protocol-specific operation for the allocation separated from
the operation to begin session.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-tascam: code refactoring for pcm.hw_params/hw_free callbacks
Takashi Sakamoto [Sun, 2 Jun 2019 07:12:51 +0000 (16:12 +0900)]
ALSA: firewire-tascam: code refactoring for pcm.hw_params/hw_free callbacks

The pairs of pcm.hw_params callbacks and .hw_free callbacks for both
direction have no differences.

This commit unifies the pairs.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-tascam: minor code refactoring to finish streaming session
Takashi Sakamoto [Sun, 2 Jun 2019 07:12:50 +0000 (16:12 +0900)]
ALSA: firewire-tascam: minor code refactoring to finish streaming session

The operation to finish packet streaming corresponds to stopping
isochronous contexts.

This commit applies code refactoring to move codes to stop into
a helper function to finish the session.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-tascam: update isochronous resources when starting packet streaming...
Takashi Sakamoto [Sun, 2 Jun 2019 07:12:49 +0000 (16:12 +0900)]
ALSA: firewire-tascam: update isochronous resources when starting packet streaming after bus reset

After bus reset, isochronous resource manager releases all of allocated
isochronous resources. The nodes to restart packet streaming should
request reallocation of the resources.

However, between the bus-reset and invocation of 'struct fw_driver.update'
handler, ALSA PCM application can detect this situation by XRUN because
the target device cancelled to transmit packets once bus-reset occurs.

Due to the above mechanism, ALSA firewire-tascam driver just stops
packet streaming in the update handler, thus pcm.prepare handler
should request the reallocation.

This commit requests the reallocation in pcm.prepare callback when
bus generation is changed.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-tascam: reserve/release isochronous resources in pcm.hw_params/hw_free...
Takashi Sakamoto [Sun, 2 Jun 2019 07:12:48 +0000 (16:12 +0900)]
ALSA: firewire-tascam: reserve/release isochronous resources in pcm.hw_params/hw_free callbacks

Once allocated, isochronous resources are available for packet
streaming, even if the streaming is cancelled. For this reason,
current implementation handles allocation of the resources and
starting packet streaming at the same time. However, this brings
complicated procedure to start packet streaming.

This commit separates the allocation and starting. The allocation is
done in pcm.hw_params callback and available till pcm.hw_free callback.
Even if any XRUN occurs, pcm.prepare callback is done to restart
packet streaming for allocated the resources.

There are two points to stop packet streaming; in pcm.hw_params and
pcm.prepare callbacks.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-tascam: code refactoring for release of isochronous resources
Takashi Sakamoto [Sun, 2 Jun 2019 07:12:47 +0000 (16:12 +0900)]
ALSA: firewire-tascam: code refactoring for release of isochronous resources

This commit is a part of preparation to perform allocation/release
of isochronous channels in pcm.hw_params/hw_free callbacks.

This commit obsoletes a helper function to release isochronous resources
for both direction.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-tascam: code refactoring for reservation of isochronous resources
Takashi Sakamoto [Sun, 2 Jun 2019 07:12:46 +0000 (16:12 +0900)]
ALSA: firewire-tascam: code refactoring for reservation of isochronous resources

This commit is a part of preparation to perform allocation/release
of isochronous channels in pcm.hw_params/hw_free callbacks.

This commit applies minor code refactoring for a helper function to
allocate isochronous resources.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-tascam: code refactoring for registration of isochronous channels
Takashi Sakamoto [Sun, 2 Jun 2019 07:12:45 +0000 (16:12 +0900)]
ALSA: firewire-tascam: code refactoring for registration of isochronous channels

This commit is a part of preparation to perform allocation/release
of isochronous channels in pcm.hw_params/hw_free callbacks.

The registration of isochronous channels is done just after allocation
of isochronous resources. This commit separates the registration just
before starting packet streaming.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: lx6464es - Remove set but not used variables 'orun_mask, urun_mask'
YueHaibing [Sat, 1 Jun 2019 04:12:14 +0000 (04:12 +0000)]
ALSA: lx6464es - Remove set but not used variables 'orun_mask, urun_mask'

Fixes gcc '-Wunused-but-set-variable' warning:

sound/pci/lx6464es/lx_core.c: In function 'lx_interrupt_handle_async_events':
sound/pci/lx6464es/lx_core.c:990:6: warning:
 variable 'urun_mask' set but not used [-Wunused-but-set-variable]
sound/pci/lx6464es/lx_core.c:989:6: warning:
 variable 'orun_mask' set but not used [-Wunused-but-set-variable]

They are never used, so can be removed.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-motu: fix destruction of data for isochronous resources
Takashi Sakamoto [Sat, 1 Jun 2019 03:08:01 +0000 (12:08 +0900)]
ALSA: firewire-motu: fix destruction of data for isochronous resources

The data for isochronous resources is not destroyed in expected place.
This commit fixes the bug.

Cc: <stable@vger.kernel.org> # v4.12+
Fixes: 9b2bb4f2f4a2 ("ALSA: firewire-motu: add stream management functionality")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoASoC: Intel: sst: fix kmalloc call with wrong flags
Alex Levin [Fri, 7 Jun 2019 22:19:11 +0000 (15:19 -0700)]
ASoC: Intel: sst: fix kmalloc call with wrong flags

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

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

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

Fixes: 972b0d456e64 ("ASoC: Intel: remove GFP_ATOMIC, use GFP_KERNEL")

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

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

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

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

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

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

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

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

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

Fixes: 6298542fa33b ("ALSA: hdac: remove memory allocation from snd_hdac_ext_bus_device_init")
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>