linux-2.6-microblaze.git
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 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 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: 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: hda/ca0132: Use struct_size()
Takashi Iwai [Fri, 31 May 2019 09:47:24 +0000 (11:47 +0200)]
ALSA: hda/ca0132: Use struct_size()

For code simplification and safety, use struct_size() macro for
calculating the dsp_image_seg object size.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: hda: Use struct_size()
Takashi Iwai [Fri, 31 May 2019 09:46:49 +0000 (11:46 +0200)]
ALSA: hda: Use struct_size()

For code simplification and safety, use struct_size() macro for
calculating the hda_conn_list object size with the variable array.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: control: Use struct_size()
Takashi Iwai [Fri, 31 May 2019 09:44:44 +0000 (11:44 +0200)]
ALSA: control: Use struct_size()

For code simplification and safety, use struct_size() macro for
calculating the snd_kcontrol object size with the variable array.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoMerge branch 'topic/hda-polling-mode' into for-next
Takashi Iwai [Thu, 30 May 2019 09:01:18 +0000 (11:01 +0200)]
Merge branch 'topic/hda-polling-mode' into for-next

A follow-up fix for the HD-audio previous polling mode changes.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: hda: fix: lock reg_lock before calling snd_hdac_bus_update_rirb
Bard Liao [Wed, 29 May 2019 20:59:00 +0000 (04:59 +0800)]
ALSA: hda: fix: lock reg_lock before calling snd_hdac_bus_update_rirb

The patch is to fix commit 5e13cf6cd64c
(ALSA: hda: add polling mode in snd_hdac_bus_get_response)
spin_lock_irq should be called before snd_hdac_bus_update_rirb.

Fixes: 5e13cf6cd64c ("ALSA: hda: add polling mode in snd_hdac_bus_get_response")
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoMerge branch 'topic/line6-cleanup' into for-next
Takashi Iwai [Tue, 28 May 2019 07:42:23 +0000 (09:42 +0200)]
Merge branch 'topic/line6-cleanup' into for-next

Pull LINE6 driver cleanups and fixes.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: line6: Use container_of()
Takashi Iwai [Tue, 28 May 2019 07:05:31 +0000 (09:05 +0200)]
ALSA: line6: Use container_of()

... instead of unconditional cast.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: line6: Drop superfluous timer helper function
Takashi Iwai [Wed, 8 May 2019 13:56:29 +0000 (15:56 +0200)]
ALSA: line6: Drop superfluous timer helper function

Now all timer usages in line6 drivers are gone, we can get rid of some
helper macro and function that became superfluous.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: line6: variax: Rewrite complex timer & work combo with a delayed work
Takashi Iwai [Wed, 8 May 2019 13:55:36 +0000 (15:55 +0200)]
ALSA: line6: variax: Rewrite complex timer & work combo with a delayed work

Variax driver had a very complex and staged startup sequence using
multiple timers and a work.  This patch simplifies the procedure to a
single delayed work.

Now the startup stage consists of:
- VARIAX_STARTUP_VERSIONREQ:
  requesting the version and the message handler raises up to the next
  stage upon receiving the reply.  The request is repeated until a
  reply arrives.
- VARIAX_STARTUP_ACTIVATE:
  does activation, and queue for the next stage.
- VARIAX_STARTUP_SETUP:
  registers the card.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: line6: podhd: Rewrite complex timer & work combo with a delayed work
Takashi Iwai [Wed, 8 May 2019 13:31:00 +0000 (15:31 +0200)]
ALSA: line6: podhd: Rewrite complex timer & work combo with a delayed work

POD HD driver had a complex staged startup sequence with both timer
and work.  This patch simplifies it to a single delayed work with a
single stage.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: line6: pod: Rewrite complex timer & work combo with a delayed work
Takashi Iwai [Wed, 8 May 2019 13:24:00 +0000 (15:24 +0200)]
ALSA: line6: pod: Rewrite complex timer & work combo with a delayed work

The POD driver had a complex staged startup procedure using both timer
and work.  This patch simplifies it via a single delayed work with the
reduced stages.

Now basically only two intermediate stages:
- POD_STARTUP_VERSIONREQ:
  requesting the version information and the process_message callback
  triggers the next stage,
- POD_STARTUP_SETUP:
  registering the actual card object.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: line6: Assure canceling delayed work at disconnection
Takashi Iwai [Tue, 28 May 2019 06:39:44 +0000 (08:39 +0200)]
ALSA: line6: Assure canceling delayed work at disconnection

The current code performs the cancel of a delayed work at the late
stage of disconnection procedure, which may lead to the access to the
already cleared state.

This patch assures to call cancel_delayed_work_sync() at the beginning
of the disconnection procedure for avoiding that race.  The delayed
work object is now assigned in the common line6 object instead of its
derivative, so that we can call cancel_delayed_work_sync().

Along with the change, the startup function is called via the new
callback instead.  This will make it easier to port other LINE6
drivers to use the delayed work for startup in later patches.

Reported-by: syzbot+5255458d5e0a2b10bbb9@syzkaller.appspotmail.com
Fixes: 7f84ff68be05 ("ALSA: line6: toneport: Fix broken usage of timer for delayed execution")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoMerge branch 'topic/hda-polling-mode' into for-next
Takashi Iwai [Tue, 28 May 2019 05:53:38 +0000 (07:53 +0200)]
Merge branch 'topic/hda-polling-mode' into for-next

Pull the HD-audio polling mode changes, moving the stuff into HD-audio
core for re-using it in ASoC.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoASoC: SOF: Force polling mode on CFL and CNL
Bard Liao [Sun, 26 May 2019 16:58:36 +0000 (00:58 +0800)]
ASoC: SOF: Force polling mode on CFL and CNL

There is a workaround in legacy HDA codec for too long time respone
with CFL machine. We need the same workaround on SOF driver. The same
issue is also seen on CNL machine.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: hda - Force polling mode on CNL for fixing codec communication
Bard Liao [Sun, 26 May 2019 16:58:32 +0000 (00:58 +0800)]
ALSA: hda - Force polling mode on CNL for fixing codec communication

We observed the same issue as reported by commit a8d7bde23e7130686b7662
("ALSA: hda - Force polling mode on CFL for fixing codec communication")
We don't have a better solution. So apply the same workaround to CNL.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: hda: add polling mode in snd_hdac_bus_get_response
Bard Liao [Sun, 26 May 2019 16:58:35 +0000 (00:58 +0800)]
ALSA: hda: add polling mode in snd_hdac_bus_get_response

Polling mode is useful if a machine somehow missed an expected IRQ.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: hda: move polling_mode flag to struct hdac_bus
Bard Liao [Sun, 26 May 2019 16:58:34 +0000 (00:58 +0800)]
ALSA: hda: move polling_mode flag to struct hdac_bus

polling mode is a useful function in the get_response function. Move
polling_mode flag from struct azx to struct hdac_bus so people can
implement polling mode in their own get_response function without
adding a polling_mode flag in their local chip structure.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: hda: assign polling_mode after azx_bus_init
Bard Liao [Sun, 26 May 2019 16:58:33 +0000 (00:58 +0800)]
ALSA: hda: assign polling_mode after azx_bus_init

We will move the polling_mode flag from struct azx to struct hdac_bus,
and the flag should be assigned after bus init.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-lib: refactoring to obsolete IR packet handler
Takashi Sakamoto [Fri, 24 May 2019 09:03:42 +0000 (18:03 +0900)]
ALSA: firewire-lib: refactoring to obsolete IR packet handler

As a result of heavy refactoring based on IR context header, the packet
handler becomes simpler.

This commit merges the packet handler into function for IR context
callback. The logic to parse IR context header and tracepoints event is
split to a function.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-lib: refactoring to obsolete IT packet handler
Takashi Sakamoto [Fri, 24 May 2019 09:03:41 +0000 (18:03 +0900)]
ALSA: firewire-lib: refactoring to obsolete IT packet handler

As a result of heavy refactoring based on IT packet header, the packet
handler becomes simpler.

This commit merges the packet handler into function for IT context
callback. The logic to build IT packet header and tracepoints event is
split to a function.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-lib: fix inverted node IDs for amdtp_packet events
Takashi Sakamoto [Fri, 24 May 2019 09:03:40 +0000 (18:03 +0900)]
ALSA: firewire-lib: fix inverted node IDs for amdtp_packet events

The amdtp_packet events have inverted node IDs for src/dst. This commit
fixes the bug.

Fixes: 8d3f1fdf5211 ("ALSA: firewire-lib: unify tracing events to 'amdtp_packet' event")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-lib: fix data block counter for incoming packet without CIP header
Takashi Sakamoto [Fri, 24 May 2019 09:03:39 +0000 (18:03 +0900)]
ALSA: firewire-lib: fix data block counter for incoming packet without CIP header

The value of data block counter is not calculated for incoming packet
without CIP header. This commit fixes the bug.

Fixes: 947b437e1263 ("ALSA: firewire-lib: unify packet handler for IR context")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-lib: use 8 byte packet header for IT context to separate CIP header...
Takashi Sakamoto [Thu, 23 May 2019 15:14:40 +0000 (00:14 +0900)]
ALSA: firewire-lib: use 8 byte packet header for IT context to separate CIP header from CIP payload

In Linux firewire subsystem, for IT context, some quadlets of isochronous
packet payload can be indicated as a part of packet header to queue to
the context.

This commit uses the packet header to split CIP headers from CIP
payload. As a result, regardless of CIP or non-CIP, context payload
includes data blocks only.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-lib: code refactoring to queueing packets
Takashi Sakamoto [Thu, 23 May 2019 15:14:39 +0000 (00:14 +0900)]
ALSA: firewire-lib: code refactoring to queueing packets

This commit is a preparation to queue IT packet with header. To enable
packet handler to fill the header, this commit uses kernel stack for
data structure of packet parameter in several part of this file.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-lib: unify packet handler for IT context
Takashi Sakamoto [Thu, 23 May 2019 15:14:38 +0000 (00:14 +0900)]
ALSA: firewire-lib: unify packet handler for IT context

The handlers for packet with CIP and without CIP include common codes.
This commit unifies them and remove an member for pointer to callback
function from data structure.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-lib: split helper function to generate CIP header
Takashi Sakamoto [Thu, 23 May 2019 15:14:37 +0000 (00:14 +0900)]
ALSA: firewire-lib: split helper function to generate CIP header

This is minor code refactoring to split a function to generate CIP
header.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: hda/realtek - Enable micmute LED for Huawei laptops
Ayman Bagabas [Thu, 23 May 2019 09:30:11 +0000 (05:30 -0400)]
ALSA: hda/realtek - Enable micmute LED for Huawei laptops

Since this LED is found on all Huawei laptops, we can hook it to
huawei-wmi platform driver to control it.

Also, some renames have been made to use product name instead of common
name to avoid confusions.

Fixes: 8ac51bbc4cfe ("ALSA: hda: fix front speakers on Huawei MBXP")
Signed-off-by: Ayman Bagabas <ayman.bagabas@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: hdspm: Fix single speed ADAT capture and playback with RME HDSPe AIO
Philippe Bekaert [Thu, 23 May 2019 21:56:49 +0000 (23:56 +0200)]
ALSA: hdspm: Fix single speed ADAT capture and playback with RME HDSPe AIO

By taking into account the mapping from logical to DMA channels when
enabling or disabling audio channels, ADAT channels 3 to 8 on the RME
HDSPe AIO card are now correctly captured and played back in single speed
mode.

Since the mapping is an identity mapping for all cards except AIO and
RayDAT, only those cards should be affected by this patch. It was tested on
an AIO card. The patch needs testing on other cards, in particular RayDAT.

Note: this patch does not solve ADAT capture and playback issues in double
or triple speed mode. That seems to be another problem.

Signed-off-by: Philippe Bekaert <Philippe.Bekaert@panokkel.be>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: pcm: oss: Use struct_size() helper
Gustavo A. R. Silva [Thu, 23 May 2019 20:29:17 +0000 (15:29 -0500)]
ALSA: pcm: oss: Use struct_size() helper

Make use of the struct_size() helper instead of an open-coded version
in order to avoid any potential type mistakes, in particular in the
context in which this code is being used.

So, replace the following form:

sizeof(struct rate_priv) + src_format->channels * sizeof(struct rate_channel)

with:

struct_size(data, channels, src_format->channels)

This code was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-lib: unify packet handler for IR context
Takashi Sakamoto [Wed, 22 May 2019 14:17:08 +0000 (23:17 +0900)]
ALSA: firewire-lib: unify packet handler for IR context

Usage of 16 bytes IR context header allows to handle context payload by
the same code for with-CIP and without-CIP packets.

This commit unifies both handlers of with-CIP and without-CIP packets.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-lib: use 16 bytes IR context header to separate CIP header
Takashi Sakamoto [Wed, 22 May 2019 14:17:07 +0000 (23:17 +0900)]
ALSA: firewire-lib: use 16 bytes IR context header to separate CIP header

In IR context, some quadlets of packet payload can be included into
context header. This is good for packet with CIP header because the
context payload buffer can includes data blocks only for with-CIP and
without-CIP pakets.

This commit uses 16 bytes IR context header for this purpose.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-lib: split helper function to check incoming CIP header
Takashi Sakamoto [Wed, 22 May 2019 14:17:06 +0000 (23:17 +0900)]
ALSA: firewire-lib: split helper function to check incoming CIP header

A parser for CIP header in incoming packet is enough large.

This commit splits it into a helper function to better looks of packet
handler.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-lib: compute pointer to payload buffer in context handler
Takashi Sakamoto [Wed, 22 May 2019 14:17:05 +0000 (23:17 +0900)]
ALSA: firewire-lib: compute pointer to payload buffer in context handler

The value of pointer to payload buffer is computed in each packet
handler, however the pointer can be decided before call of packet
handler.

This commit adds an argument for the pointer to the packet handler to
reduce codes to compute for the pointer.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-lib: calculate the length of packet payload in packet handler
Takashi Sakamoto [Wed, 22 May 2019 14:17:04 +0000 (23:17 +0900)]
ALSA: firewire-lib: calculate the length of packet payload in packet handler

In current packet handler, the length of payload is given as an argument
of callback function, however this value is just required to process
payload of transferred isoc packet, thus just for IR context.

This commit replaces the argument for payload of packet with the
argument of context header. As a result, the length of payload is
computed in packet handler for IR context.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-lib: use clear name for variable of CIP header
Takashi Sakamoto [Wed, 22 May 2019 14:17:03 +0000 (23:17 +0900)]
ALSA: firewire-lib: use clear name for variable of CIP header

This commit is to distinguish variable of CIP header from variable of
isochronous context header.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: hda/realtek - Set default power save node to 0
Kailang Yang [Thu, 23 May 2019 06:43:04 +0000 (14:43 +0800)]
ALSA: hda/realtek - Set default power save node to 0

I measured power consumption between power_save_node=1 and power_save_node=0.
It's almost the same.
Codec will enter to runtime suspend and suspend.
That pin also will enter to D3. Don't need to enter to D3 by single pin.
So, Disable power_save_node as default. It will avoid more issues.
Windows Driver also has not this option at runtime PM.

Signed-off-by: Kailang Yang <kailang@realtek.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: hda/realtek - Check headset type by unplug and resume
Kailang Yang [Thu, 16 May 2019 08:10:44 +0000 (16:10 +0800)]
ALSA: hda/realtek - Check headset type by unplug and resume

When system enable HDA power save mode.
This issue will happen on new platform which DMIC connect to PCH.
In Dell headset mode, it will recheck during runtime resume when
headset was plugged.
This patch will move check headset type on unplug and system resume.

[ A few minor code cleanups by tiwai ]

Signed-off-by: Kailang Yang <kailang@realtek.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-lib: use IT context header to compute cycle count for scheduling packet
Takashi Sakamoto [Tue, 21 May 2019 14:57:37 +0000 (23:57 +0900)]
ALSA: firewire-lib: use IT context header to compute cycle count for scheduling packet

In IT context, header includes information of cycle to have processed
queued packet.

This commit uses the per-packet information to compute the cycle for
packet to be queued, instead of callback argument. In current
implementaion of ALSA IEC 61883-1/6 packet streaming engine, 48 packets
are queued at first to skip recent cycle. When IT context calls handler,
cycle information in header plus 48 cycle means the cycle to be going
to queue packet.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-lib: obsolete macro for header of IT context
Takashi Sakamoto [Tue, 21 May 2019 14:57:36 +0000 (23:57 +0900)]
ALSA: firewire-lib: obsolete macro for header of IT context

The header size parameter of 1394 OHCI IT context has no effect.
Besides the header size of queued packet is different from context
header.

This commit cleans codes relevant to these two headers.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-lib: add helper function to cancel context inner callback handler
Takashi Sakamoto [Tue, 21 May 2019 14:57:35 +0000 (23:57 +0900)]
ALSA: firewire-lib: add helper function to cancel context inner callback handler

In callback handler of isochronous context for both direction, there're
common codes to cancel context.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-lib: use union for directional parameters
Takashi Sakamoto [Tue, 21 May 2019 14:57:34 +0000 (23:57 +0900)]
ALSA: firewire-lib: use union for directional parameters

Some parameters of struct amdtp_stream is dependent on direction.

This commit uses union for such parameters to distinguish from
common parameters.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-lib: unify tracing events to 'amdtp_packet' event
Takashi Sakamoto [Sun, 19 May 2019 10:01:09 +0000 (19:01 +0900)]
ALSA: firewire-lib: unify tracing events to 'amdtp_packet' event

Now four events of this module have the same arguments and probe timing.
This commit adds a new event, 'amdtp_packet', and replace them. Filtering
functionality of tracing framework is available to pick up events for
inbound/outbound isochronous packets.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-lib: use dynamic array for CIP header of tracing events
Takashi Sakamoto [Sun, 19 May 2019 10:01:08 +0000 (19:01 +0900)]
ALSA: firewire-lib: use dynamic array for CIP header of tracing events

This modules handles two types of isochronous packet; one has CIP header
in IEC 61883-1/6 and another doesn't. The module also have tracing events
corresponding to the types of packet. To unify the events, one event
should be probed with or without CIP header.

This commit uses dynamic array for the events to be available for the
types of packet.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-lib: use the same unit for payload argument in tracing events
Takashi Sakamoto [Sun, 19 May 2019 10:01:07 +0000 (19:01 +0900)]
ALSA: firewire-lib: use the same unit for payload argument in tracing events

The most of tracing event in this module have the size of payload in
byte unit, however 'in_packet_without_header' event have the argument
in quadlet unit.

This commit change the unit for argument to be consistent.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoALSA: firewire-lib: add data_blocks/data_block_counter parameter to in_packet/out_pac...
Takashi Sakamoto [Sun, 19 May 2019 10:01:06 +0000 (19:01 +0900)]
ALSA: firewire-lib: add data_blocks/data_block_counter parameter to in_packet/out_packet tracing events

Tracing events for packets without CIP header have a parameter of
data_blocks/data_block_counter, but events for packets with CIP header
don't. This is not good to unify these events.

This commit adds the missing parameters to the events. In timing to
probe 'in_packet' event, data_blocks and data_block_counter are not
calculated yet. This commit also changes the timing.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>