platform/kernel/linux-rpi.git
3 years agoALSA: firewire-motu: add support for AES/EBU clock source in v2 protocol
Takashi Sakamoto [Wed, 23 Jun 2021 07:59:35 +0000 (16:59 +0900)]
ALSA: firewire-motu: add support for AES/EBU clock source in v2 protocol

Although MOTU Traveler supports AES/EBU source for sampling clock,
current implementation of driver doesn't code it.

This commit adds support for AES/EBU source in protocol version 2.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210623075941.72562-4-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: firewire-motu: code refactoring for detection of clock source in v2 protocol
Takashi Sakamoto [Wed, 23 Jun 2021 07:59:34 +0000 (16:59 +0900)]
ALSA: firewire-motu: code refactoring for detection of clock source in v2 protocol

Current implementation of driver has two similar helper functions for
source detection of sampling clock. This commit merges them as a code
refactoring.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210623075941.72562-3-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: firewire-motu: fix detection for S/PDIF source on optical interface in v2 protocol
Takashi Sakamoto [Wed, 23 Jun 2021 07:59:33 +0000 (16:59 +0900)]
ALSA: firewire-motu: fix detection for S/PDIF source on optical interface in v2 protocol

The devices in protocol version 2 has a register with flag for IEC 60958
signal detection as source of sampling clock without discrimination
between coaxial and optical interfaces. On the other hand, current
implementation of driver manage to interpret type of signal on optical
interface instead.

This commit fixes the detection of optical/coaxial interface for S/PDIF
signal.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210623075941.72562-2-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoMAINTAINERS: Add Focusrite Scarlett Gen 2/3 Mixer Driver entry
Geoffrey D. Bennett [Tue, 22 Jun 2021 17:17:24 +0000 (02:47 +0930)]
MAINTAINERS: Add Focusrite Scarlett Gen 2/3 Mixer Driver entry

Add Focusrite Scarlett Gen 2/3 Mixer Driver entry.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/20210622171724.GA15534@m.b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Add support for the talkback feature
Geoffrey D. Bennett [Tue, 22 Jun 2021 17:04:13 +0000 (02:34 +0930)]
ALSA: usb-audio: scarlett2: Add support for the talkback feature

Add support for the talkback feature of the 18i20 Gen 3.

Co-developed-by: Vladimir Sadovnikov <sadko4u@gmail.com>
Signed-off-by: Vladimir Sadovnikov <sadko4u@gmail.com>
Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/e39599893a7479c290e1aaec6c79dcee87681b47.1624379707.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Update get_config to do endian conversion
Geoffrey D. Bennett [Tue, 22 Jun 2021 17:04:09 +0000 (02:34 +0930)]
ALSA: usb-audio: scarlett2: Update get_config to do endian conversion

For configuration items with a size of 16, scarlett2_usb_get_config()
was filling *buf with little-endian data. Update it to convert to CPU
endian. This function is not currently used so affects nothing yet;
will be used by the upcoming talkback feature.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/cbc8b6eedd859dd27086ab4126d724a86dd50bcb.1624379707.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Add speaker switching support
Geoffrey D. Bennett [Tue, 22 Jun 2021 17:03:58 +0000 (02:33 +0930)]
ALSA: usb-audio: scarlett2: Add speaker switching support

The 18i8 and 18i20 Gen 3 support "speaker switching". Add a Speaker
Switch control which can be set to Off/Main/Alt.

When speaker switching is enabled or disabled, the interface may
change the state of the Analog Outputs 3 and 4 routing and the global
mute button, so use a flag private->speaker_switching_switched to note
that those should be checked when the next "monitor other"
notification is received.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/874193a534cd0aeb6f2e108ae761cadd2dc25ad2.1624379707.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Update mux controls to allow updates
Geoffrey D. Bennett [Tue, 22 Jun 2021 17:03:50 +0000 (02:33 +0930)]
ALSA: usb-audio: scarlett2: Update mux controls to allow updates

Enabling/disabling speaker switching will update the mux
configuration. To prepare for this, add a private->mux_updated flag
and update the scarlett2_mux_src_enum_ctl_get() callback to check it.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/5ce3bb9fe4006b550d18c783c5ff640fe0bfbfcb.1624379707.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Add sw_hw_ctls and mux_ctls
Geoffrey D. Bennett [Tue, 22 Jun 2021 17:03:45 +0000 (02:33 +0930)]
ALSA: usb-audio: scarlett2: Add sw_hw_ctls and mux_ctls

Save the struct snd_kcontrol pointers for the sw_hw and mux controls.
This is in preparation for speaker switching support which needs to be
able to update those controls.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/269d89181bf29dbea80ba6f8cfff84fb23b77f86.1624379707.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Split up sw_hw_enum_ctl_put()
Geoffrey D. Bennett [Tue, 22 Jun 2021 17:03:36 +0000 (02:33 +0930)]
ALSA: usb-audio: scarlett2: Split up sw_hw_enum_ctl_put()

Split part of scarlett2_sw_hw_enum_ctl_put() out into
scarlett2_sw_hw_change() so that the code which actually makes the
change is available in its own function. This will be used by the
speaker switching support which needs to set the SW/HW switch to HW
when speaker switching is enabled.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/f2cf91841ba067b490e7709bc4b14f4532b4ddd5.1624379707.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Label 18i8 Gen 3 line outputs correctly
Geoffrey D. Bennett [Tue, 22 Jun 2021 17:03:16 +0000 (02:33 +0930)]
ALSA: usb-audio: scarlett2: Label 18i8 Gen 3 line outputs correctly

The 18i8 Gen 3 analogue 7/8 outputs are identified as line 3/4 on the
rear of the unit. Add support for remapping the channel numbers to
match the labelling.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/461acb911509e60e9ab48109ece3bbadae7440c8.1624379707.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Add direct monitor support
Geoffrey D. Bennett [Tue, 22 Jun 2021 17:03:08 +0000 (02:33 +0930)]
ALSA: usb-audio: scarlett2: Add direct monitor support

The Solo and 2i2 devices don't have a mixer but they do have a "direct
monitor" switch. Add support for getting and setting the state of this
switch.

Co-developed-by: Vladimir Sadovnikov <sadko4u@gmail.com>
Signed-off-by: Vladimir Sadovnikov <sadko4u@gmail.com>
Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/61d23dc4feb3b046d870ad7203e66ff2bd1d278c.1624379707.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Add phantom power switch support
Geoffrey D. Bennett [Tue, 22 Jun 2021 17:02:40 +0000 (02:32 +0930)]
ALSA: usb-audio: scarlett2: Add phantom power switch support

Some inputs on Gen 3 models support software-selectable phantom power.
Add support for getting and setting the state of those switches and
the "Phantom Power Persistence" switch.

Co-developed-by: Vladimir Sadovnikov <sadko4u@gmail.com>
Signed-off-by: Vladimir Sadovnikov <sadko4u@gmail.com>
Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/5837ce8a8c686560fc8f40b4204dd2a10721869b.1624379707.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Add "air" switch support
Geoffrey D. Bennett [Tue, 22 Jun 2021 17:02:36 +0000 (02:32 +0930)]
ALSA: usb-audio: scarlett2: Add "air" switch support

Some inputs on Gen 3 models have an "air" feature which can be enabled
from the driver or (model-dependent) from the front panel. Add support
for getting and setting the state of those switches.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/44d448a4150b9c068754759c9fdd2bfe21484487.1624379707.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Add support for Solo and 2i2 Gen 3
Geoffrey D. Bennett [Tue, 22 Jun 2021 17:02:31 +0000 (02:32 +0930)]
ALSA: usb-audio: scarlett2: Add support for Solo and 2i2 Gen 3

Add initial support for the Focusrite Scarlett Solo and 2i2 devices:
- They have no mixer
- They don't support reporting sync status or levels
- The configuration space is laid out differently to the other models
- There is no level (line/inst) switch on input 1 of the Solo

Co-developed-by: Vladimir Sadovnikov <sadko4u@gmail.com>
Signed-off-by: Vladimir Sadovnikov <sadko4u@gmail.com>
Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/190b90f6f1f8f8d4dfb5f0a7761ff8ae5c40fdde.1624379707.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Allow bit-level access to config
Geoffrey D. Bennett [Tue, 22 Jun 2021 17:02:25 +0000 (02:32 +0930)]
ALSA: usb-audio: scarlett2: Allow bit-level access to config

Add support for accessing configuration values when multiple values
are stored in one byte. Needed by the upcoming Solo and 2i2 Gen 3
support.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/4e54e9e106ec7029c1a668c51b4fc769a7eb4ed0.1624379707.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Move get config above set config
Geoffrey D. Bennett [Tue, 22 Jun 2021 17:02:09 +0000 (02:32 +0930)]
ALSA: usb-audio: scarlett2: Move get config above set config

Move scarlett2_usb_get() and scarlett2_usb_get_config() above the
functions relating to updating the configuration so that
scarlett2_usb_set_config() can call scarlett2_usb_get() in a
subsequent patch.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/1549f8e44548be679119f0b1462f888f4a03812d.1624379707.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Add Gen 3 MSD mode switch
Geoffrey D. Bennett [Tue, 22 Jun 2021 17:01:52 +0000 (02:31 +0930)]
ALSA: usb-audio: scarlett2: Add Gen 3 MSD mode switch

Add a control to disable the Gen 3 MSD mode so that the full
functionality of the device is available. Don't create the other
controls until MSD mode is disabled.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/1cb93bbe585f6b0a74f5dc27450bc87e1f3776dc.1624379707.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Add support for "input-other" notify
Geoffrey D. Bennett [Tue, 22 Jun 2021 17:01:44 +0000 (02:31 +0930)]
ALSA: usb-audio: scarlett2: Add support for "input-other" notify

Some models allow the level and pad settings to be controlled from the
front-panel of the device. For these, the device will send an
"input-other" notification to prompt the driver to re-read the status
of those settings.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/06289a7697455e96b7dbdfd2d384d4b20f8df6e0.1624379707.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Add Gen 3 mixer support
Geoffrey D. Bennett [Tue, 22 Jun 2021 17:01:37 +0000 (02:31 +0930)]
ALSA: usb-audio: scarlett2: Add Gen 3 mixer support

Add mixer support for the Focusrite Scarlett 4i4, 8i6, 18i8, and 18i20
Gen 3 devices.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/22d0dc877dec026eb19630edec217ab72ebcd50a.1624379707.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Fix wrong resume call
Takashi Iwai [Tue, 22 Jun 2021 17:00:49 +0000 (02:30 +0930)]
ALSA: usb-audio: scarlett2: Fix wrong resume call

The current way of the scarlett2 mixer code managing the
usb_mixer_elem_info object is wrong in two ways: it passes its
internal index to the head.id field, and the val_type field is
uninitialized.  This ended up with the wrong execution at the resume
because a bogus unit id is passed wrongly.  Also, in the later code
extensions, we'll have more mixer elements, and passing the index will
overflow the unit id size (of 256).

This patch corrects those issues.  It introduces a new value type,
USB_MIXER_BESPOKEN, which indicates a non-standard mixer element, and
use this type for all scarlett2 mixer elements, as well as
initializing the fixed unit id 0 for avoiding the overflow.

Tested-by: Geoffrey D. Bennett <g@b4.vu>
Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/49721219f45b7e175e729b0d9d9c142fd8f4342a.1624379707.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Fix Level Meter control
Geoffrey D. Bennett [Mon, 21 Jun 2021 18:09:46 +0000 (03:39 +0930)]
ALSA: usb-audio: scarlett2: Fix Level Meter control

The Level Meter control had a fixed number of channels and therefore
only worked with the 18i20 Gen 2. Fix the control to contain the
correct number of channels.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/5e9a2d5c136270db2d048db53a3b4b6e6d4a63de.1624294591.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Split struct scarlett2_ports
Geoffrey D. Bennett [Mon, 21 Jun 2021 18:09:43 +0000 (03:39 +0930)]
ALSA: usb-audio: scarlett2: Split struct scarlett2_ports

The scarlett2_ports struct contains both generic (hardware IDs and
descriptions) and model-specific (port count) data. Remove the generic
data from the scarlett2_device_info struct so it is not repeated for
every model.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/7a9e57e4e55a482390c692a9e60731d72b664a15.1624294591.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Allow arbitrary ordering of mux entries
Geoffrey D. Bennett [Mon, 21 Jun 2021 18:09:41 +0000 (03:39 +0930)]
ALSA: usb-audio: scarlett2: Allow arbitrary ordering of mux entries

Some Gen 3 devices do not put all of the mux entries for the same port
types together in order in the "set mux" message data. To prepare for
this, replace the struct scarlett2_ports num[] array and the
assignment_order[] array with mux_assignment[], a list of port types
and ranges that is defined in the struct scarlett2_device_info.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/08e8d784d78262cb57496d28ef1ad7b6213a90ab.1624294591.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Add mute support
Geoffrey D. Bennett [Mon, 21 Jun 2021 18:09:39 +0000 (03:39 +0930)]
ALSA: usb-audio: scarlett2: Add mute support

For each analogue output, in addition to the output volume (gain)
control, the hardware also has a mute control. Add ALSA mute controls
for each analogue output.

If the device has the line_out_hw_vol feature, then the mute control
is disabled along with the output volume control when the switch is
set to HW.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/6fad82174b44633e46cfd96332a038de74d544f2.1624294591.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Add scarlett2_vol_ctl_write() helper
Geoffrey D. Bennett [Mon, 21 Jun 2021 18:09:37 +0000 (03:39 +0930)]
ALSA: usb-audio: scarlett2: Add scarlett2_vol_ctl_write() helper

Add helper function for setting the read/write status of a volume
control. This will simplify the upcoming mute control support.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/00dd57e1abb3fa379fb51d4ac8537dbddc09f0ea.1624294591.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Remove repeated device info comments
Geoffrey D. Bennett [Mon, 21 Jun 2021 18:09:35 +0000 (03:39 +0930)]
ALSA: usb-audio: scarlett2: Remove repeated device info comments

Document the fields of struct scarlett2_device_info in the definition
of the struct, not in each instantiation.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/3486e4d38973333d4ec38f32578c16a9f97bf6c8.1624294591.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Move info lookup out of init function
Geoffrey D. Bennett [Mon, 21 Jun 2021 18:09:33 +0000 (03:39 +0930)]
ALSA: usb-audio: scarlett2: Move info lookup out of init function

The info variable is not used by snd_scarlett_gen2_init() except to
pass it to snd_scarlett_gen2_controls_create(), so move the lookup
into that function.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/c4b6d17708e104503d9a2b88f9b3320bb9904cfa.1624294591.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Improve device info lookup
Geoffrey D. Bennett [Mon, 21 Jun 2021 18:09:31 +0000 (03:39 +0930)]
ALSA: usb-audio: scarlett2: Improve device info lookup

Add the USB device ID to the scarlett2_device_info struct so that the
switch statement which finds the appropriate struct can be replaced
with a loop that looks through an array of pointers to those structs.

Suggested-by: Vladimir Sadovnikov <sadko4u@gmail.com>
Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/474c408c29fb280a611e47e49e59ca2fb9810d27.1624294591.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Reformat scarlett2_config_items[]
Geoffrey D. Bennett [Mon, 21 Jun 2021 18:09:29 +0000 (03:39 +0930)]
ALSA: usb-audio: scarlett2: Reformat scarlett2_config_items[]

Use designated initializers and merge lines in preparation for more
configuration items coming soon.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/512d14eeb3571a266810c954d0f83140a3af7afc.1624294591.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Merge common line in capture strings
Geoffrey D. Bennett [Mon, 21 Jun 2021 18:09:26 +0000 (03:39 +0930)]
ALSA: usb-audio: scarlett2: Merge common line in capture strings

Use a common sprintf() format for the mixer element names generated in
scarlett2_add_line_in_ctls() in preparation for more of them.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/d91dce45ac75a541c21f47540ecbda24bd83f68c.1624294591.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Add "Sync Status" control
Geoffrey D. Bennett [Mon, 21 Jun 2021 18:09:24 +0000 (03:39 +0930)]
ALSA: usb-audio: scarlett2: Add "Sync Status" control

Add "Sync Status" control to display the sync locked/unlocked status.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/d6967d7a34b2ea7e0672ba819e4ed8b99e8dcd35.1624294591.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Always enable interrupt polling
Geoffrey D. Bennett [Mon, 21 Jun 2021 18:09:20 +0000 (03:39 +0930)]
ALSA: usb-audio: scarlett2: Always enable interrupt polling

Always enable interrupt polling as every model has some sort of
status to report.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/8f49a6b9a9805ee0db221706193b7bb43b7fff75.1624294591.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Fix 6i6 Gen 2 line out descriptions
Geoffrey D. Bennett [Mon, 21 Jun 2021 18:09:18 +0000 (03:39 +0930)]
ALSA: usb-audio: scarlett2: Fix 6i6 Gen 2 line out descriptions

There are two headphone outputs, and they map to the four analogue
outputs.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/205e5e5348f08ded0cc4da5446f604d4b91db5bf.1624294591.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Update initialisation sequence
Geoffrey D. Bennett [Mon, 21 Jun 2021 18:09:13 +0000 (03:39 +0930)]
ALSA: usb-audio: scarlett2: Update initialisation sequence

The old initialisation code only works with Gen 2 devices. Replace it
with an initialisation sequence that works on both Gen 2 and Gen 3
devices.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/6e5c4fedb74b813872f6a4b7fba30b6c471fa63a.1624294591.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Add usb_tx/rx functions
Geoffrey D. Bennett [Mon, 21 Jun 2021 18:09:06 +0000 (03:39 +0930)]
ALSA: usb-audio: scarlett2: Add usb_tx/rx functions

Pull out snd_usb_ctl_msg() calls from scarlett2_usb() and put into
scarlett2_usb_tx() and scarlett2_usb_rx() functions.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/720d1d6f227fc8f5d7d6191a8de62db796940235.1624294591.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: hdsp: fix a test for copy_to_user() failure
Dan Carpenter [Tue, 22 Jun 2021 19:02:02 +0000 (22:02 +0300)]
ALSA: hdsp: fix a test for copy_to_user() failure

The copy_to_user() function returns the number of bytes remaining to be
copied.  It doesn't return negatives.

Fixes: 66c8f75919dd ("ALSA: hdsp: Fix assignment in if condition")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/YNIzqpVR6L2t/RwJ@mwanda
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: hda: Add IRQ check for platform_get_irq()
Jiajun Cao [Tue, 22 Jun 2021 13:19:42 +0000 (21:19 +0800)]
ALSA: hda: Add IRQ check for platform_get_irq()

The function hda_tegra_first_init() neglects to check the return
value after executing platform_get_irq().

hda_tegra_first_init() should check the return value (if negative
error number) for errors so as to not pass a negative value to
the devm_request_irq().

Fix it by adding a check for the return value irq_id.

Signed-off-by: Jiajun Cao <jjcao20@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
Reviewed-by: Thierry Reding <treding@nvidia.com>
Link: https://lore.kernel.org/r/20210622131947.94346-1-jjcao20@fudan.edu.cn
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: Fix OOB access at proc output
Takashi Iwai [Tue, 22 Jun 2021 09:06:47 +0000 (11:06 +0200)]
ALSA: usb-audio: Fix OOB access at proc output

At extending the available mixer values for 32bit types, we forgot to
add the corresponding entries for the format dump in the proc output.
This may result in OOB access.  Here adds the missing entries.

Fixes: bc18e31c3042 ("ALSA: usb-audio: Fix parameter block size for UAC2 control requests")
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210622090647.14021-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Remove hard-coded USB #defines
Geoffrey D. Bennett [Sun, 20 Jun 2021 16:46:52 +0000 (02:16 +0930)]
ALSA: usb-audio: scarlett2: Remove hard-coded USB #defines

Remove the hard-coded interface number and related constants for the
vendor-specific interface and look them up from the USB endpoint
descriptor.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/20210620164652.GA9237@m.b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Don't copy struct scarlett2_config
Geoffrey D. Bennett [Sun, 20 Jun 2021 16:46:48 +0000 (02:16 +0930)]
ALSA: usb-audio: scarlett2: Don't copy struct scarlett2_config

scarlett2_usb_set_config() and scarlett2_usb_get_config() were copying
struct scarlett2_config. Use a pointer instead.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/20210620164648.GA9231@m.b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Fix union usage in mixer control callbacks
Geoffrey D. Bennett [Sun, 20 Jun 2021 16:46:47 +0000 (02:16 +0930)]
ALSA: usb-audio: scarlett2: Fix union usage in mixer control callbacks

Fix mixer control callbacks to use the correct members of the struct
snd_ctl_elem_value. The use of value.integer and value.enumerated were
swapped in a few places.

Update scarlett2_mux_src_enum_ctl_put() to use min() instead of
clamp() as value.enumerated.item is unsigned.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/20210620164647.GA9226@m.b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Fix scarlett2_*_ctl_put() return values
Geoffrey D. Bennett [Sun, 20 Jun 2021 16:46:45 +0000 (02:16 +0930)]
ALSA: usb-audio: scarlett2: Fix scarlett2_*_ctl_put() return values

Mixer control put callbacks should return 1 if the value is changed.
Fix the sw_hw, level, pad, and button controls accordingly.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/20210620164645.GA9221@m.b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Fix data_mutex lock
Geoffrey D. Bennett [Sun, 20 Jun 2021 16:46:43 +0000 (02:16 +0930)]
ALSA: usb-audio: scarlett2: Fix data_mutex lock

The private->vol_updated flag was being checked outside of the
mutex_lock/unlock() of private->data_mutex leading to the volume data
being fetched twice from the device unnecessarily or old volume data
being returned.

Update scarlett2_*_ctl_get() and include the private->vol_updated flag
check inside the critical region.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/20210620164643.GA9216@m.b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Add temp variable for consistency
Geoffrey D. Bennett [Sun, 20 Jun 2021 16:46:41 +0000 (02:16 +0930)]
ALSA: usb-audio: scarlett2: Add temp variable for consistency

Add index temporary variable to scarlett2_mixer_ctl_put() for
consistency with the other *_ctl_put() functions.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/20210620164641.GA9211@m.b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Rename struct scarlett2_mixer_data
Geoffrey D. Bennett [Sun, 20 Jun 2021 16:46:39 +0000 (02:16 +0930)]
ALSA: usb-audio: scarlett2: Rename struct scarlett2_mixer_data

Rename struct scarlett2_mixer_data to struct scarlett2_data. A
less-wordy name is better because it is used everywhere, and although
this is a mixer driver, it also controls other vendor-specific
features.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/20210620164639.GA9206@m.b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Rename buttons/interrupts/vol
Geoffrey D. Bennett [Sun, 20 Jun 2021 16:46:36 +0000 (02:16 +0930)]
ALSA: usb-audio: scarlett2: Rename buttons/interrupts/vol

To match the vendor's terminology, change #defines, identifiers, and
comments:
- mute/dim/hardware buttons are now called dim/mute
- mixer status/interrupt is now notify
- vol is now monitor

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/20210620164636.GA9199@m.b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Remove redundant info->button_count
Geoffrey D. Bennett [Sun, 20 Jun 2021 16:46:34 +0000 (02:16 +0930)]
ALSA: usb-audio: scarlett2: Remove redundant info->button_count

The per-model button_count value was used to determine whether
dim/mute controls should be added, but these are present iff
line_out_hw_vol is true. Remove button_count and replace with
SCARLETT2_BUTTON_MAX and a check for line_out_hw_vol true.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/20210620164634.GA9193@m.b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Remove interrupt debug message
Geoffrey D. Bennett [Sun, 20 Jun 2021 16:46:32 +0000 (02:16 +0930)]
ALSA: usb-audio: scarlett2: Remove interrupt debug message

Just ignore instead of printing an error if the interrupt data is not
the expected length. This check was for development and the condition
has not been observed.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/20210620164632.GA9186@m.b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Remove unused/useless code
Geoffrey D. Bennett [Sun, 20 Jun 2021 16:46:30 +0000 (02:16 +0930)]
ALSA: usb-audio: scarlett2: Remove unused/useless code

Remove #define not used.
Remove useless assignments and copies.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/20210620164630.GA9180@m.b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Coding style improvements
Geoffrey D. Bennett [Sun, 20 Jun 2021 16:46:28 +0000 (02:16 +0930)]
ALSA: usb-audio: scarlett2: Coding style improvements

Improve alignment and readability with:
- Whitespace fixes
- Add leading zeros to 32-bit flag values
- Rename SCARLETT2_USB_GET_METER_LEVELS to SCARLETT2_USB_GET_METER
- Rename SCARLETT2_PORT_DIRECTIONS to SCARLETT2_PORT_DIRNS

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/20210620164628.GA9172@m.b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Fix 18i8 Gen 2 PCM Input count
Geoffrey D. Bennett [Sun, 20 Jun 2021 16:46:25 +0000 (02:16 +0930)]
ALSA: usb-audio: scarlett2: Fix 18i8 Gen 2 PCM Input count

The 18i8 Gen 2 has 8 PCM Inputs, not 20. Fix the ports entry in
s18i8_gen2_info.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/20210620164625.GA9165@m.b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: scarlett2: Remove incorrect S/PDIF comment
Geoffrey D. Bennett [Sun, 20 Jun 2021 16:46:22 +0000 (02:16 +0930)]
ALSA: usb-audio: scarlett2: Remove incorrect S/PDIF comment

The 18i8 Gen 2 S/PDIF outputs are available at 192kHz, unlike
the 18i20 Gen 2. Remove the comment that says otherwise.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/20210620164622.GA9155@m.b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: hda/realtek: Fix bass speaker DAC mapping for Asus UM431D
Takashi Iwai [Sun, 20 Jun 2021 06:59:52 +0000 (08:59 +0200)]
ALSA: hda/realtek: Fix bass speaker DAC mapping for Asus UM431D

Asus Zenbook 14 UM431D has two speaker pins and a headphone pin, and
the auto-parser ends up assigning the bass to the third DAC 0x06.
Although the tone comes out, it's inconvenient because this DAC has no
volume control unlike two other DACs.

For obtaining the volume control for the bass speaker, this patch
enforces the mapping to let both front and bass speaker pins sharing
the same DAC.  It's not ideal but a little bit of improvement.

Since we've already applied the same workaround for another ASUS
machine, we just need to hook the chain to the existing quirk.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=212547
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210620065952.18948-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: hda/realtek: Improve fixup for HP Spectre x360 15-df0xxx
Elia Devito [Sat, 19 Jun 2021 20:41:04 +0000 (22:41 +0200)]
ALSA: hda/realtek: Improve fixup for HP Spectre x360 15-df0xxx

On HP Spectre x360 15-df0xxx, after system boot with plugged headset, the
headset mic are not detected.
Moving pincfg and DAC's config to single fixup function fix this.

[ The actual bug in the original code was that it used a chain to
  ALC286_FIXUP_SPEAKER2_TO_DAC1, and it contains not only the DAC1
  route fix but also another chain to ALC269_FIXUP_THINKPAD_ACPI.
  I thought the latter one is harmless for non-Thinkpad, but it
  doesn't seem so; it contains again yet another chain to
  ALC269_FIXUP_SKI_IGNORE, and this might be bad for some machines,
  including this HP machine.  -- tiwai ]

Signed-off-by: Elia Devito <eliadevito@gmail.com>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210619204105.5682-1-eliadevito@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: bebob: add support for ToneWeal FW66
Takashi Sakamoto [Sat, 19 Jun 2021 08:39:22 +0000 (17:39 +0900)]
ALSA: bebob: add support for ToneWeal FW66

A user of FFADO project reported the issue of ToneWeal FW66. As a result,
the device is identified as one of applications of BeBoB solution.

I note that in the report the device returns contradictory result in plug
discovery process for audio subunit. Fortunately ALSA BeBoB driver doesn't
perform it thus it's likely to handle the device without issues.

I receive no reaction to test request for this patch yet, however it would
be worth to add support for it.

daniel@gibbonmoon:/sys/bus/firewire/devices/fw1$ grep -r . *
Binary file config_rom matches
dev:244:1
guid:0x0023270002000000
hardware_version:0x000002
is_local:0
model:0x020002
model_name:FW66
power/runtime_active_time:0
power/runtime_active_kids:0
power/runtime_usage:0
power/runtime_status:unsupported
power/async:disabled
power/runtime_suspended_time:0
power/runtime_enabled:disabled
power/control:auto
subsystem/drivers_autoprobe:1
uevent:MAJOR=244
uevent:MINOR=1
uevent:DEVNAME=fw1
units:0x00a02d:0x010001
vendor:0x002327
vendor_name:ToneWeal
fw1.0/uevent:MODALIAS=ieee1394:ven00002327mo00020002sp0000A02Dver00010001
fw1.0/power/runtime_active_time:0
fw1.0/power/runtime_active_kids:0
fw1.0/power/runtime_usage:0
fw1.0/power/runtime_status:unsupported
fw1.0/power/async:disabled
fw1.0/power/runtime_suspended_time:0
fw1.0/power/runtime_enabled:disabled
fw1.0/power/control:auto
fw1.0/model:0x020002
fw1.0/rom_index:15
fw1.0/specifier_id:0x00a02d
fw1.0/model_name:FW66
fw1.0/version:0x010001
fw1.0/modalias:ieee1394:ven00002327mo00020002sp0000A02Dver00010001

Cc: Daniel Jozsef <daniel.jozsef@gmail.com>
Reference: https://lore.kernel.org/alsa-devel/20200119164335.GA11974@workstation/
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210619083922.16060-1-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: hda/realtek: Add another ALC236 variant support
Takashi Iwai [Fri, 18 Jun 2021 16:17:20 +0000 (18:17 +0200)]
ALSA: hda/realtek: Add another ALC236 variant support

The codec chip 10ec:0230 is another variant of ALC236, combined with a
card reader.  Apply the equivalent setup as 10ec:0236.

BugLink: https://bugzilla.suse.com/show_bug.cgi?id=1184869
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210618161720.28694-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: firewire-motu: fix rx packet format at higher rate for MOTU 828 mk3 Hybrid
Takashi Sakamoto [Fri, 18 Jun 2021 04:07:13 +0000 (13:07 +0900)]
ALSA: firewire-motu: fix rx packet format at higher rate for MOTU 828 mk3 Hybrid

I assumed that the combination of packet formats for MOTU 828 mk3 Hybrid
is the same as MOTU 828 mk3 FireWire. However at higher sampling rate, it
is different. MOTU 828 mk3 Hybrid has additional 4 dummy data chunks for
rx packet.

This commit fixes the issue to which I address at a commit f2ac3b839540
("ALSA: firewire-motu: sequence replay for source packet header").

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210618040713.114611-1-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: bebob: fix rx packet format for Yamaha GO44/GO46, Terratec Phase 24/x24
Takashi Sakamoto [Fri, 18 Jun 2021 04:04:47 +0000 (13:04 +0900)]
ALSA: bebob: fix rx packet format for Yamaha GO44/GO46, Terratec Phase 24/x24

Below devices reports zero as the number of channels for external output
plug with MIDI type:

 * Yamaha GO44/GO46
 * Terratec Phase 24/X24

As a result, rx packet format is invalid and they generate silent sound.
This is a regression added in v5.13.

This commit fixes the bug, addressed at a commit 1bd1b3be8655 ("ALSA:
bebob: perform sequence replay for media clock recovery").

Cc: <stable@vger.kernel.org>
Fixes: 5c6ea94f2b7c ("ALSA: bebob: detect the number of available MIDI ports")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210618040447.113306-1-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: hda/realtek: fix mute/micmute LEDs for HP EliteBook x360 830 G8
Jeremy Szu [Thu, 17 Jun 2021 17:14:20 +0000 (01:14 +0800)]
ALSA: hda/realtek: fix mute/micmute LEDs for HP EliteBook x360 830 G8

The HP EliteBook x360 830 G8 using ALC285 codec which using 0x04 to
control mute LED and 0x01 to control micmute LED.
Therefore, add a quirk to make it works.

Signed-off-by: Jeremy Szu <jeremy.szu@canonical.com>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210617171422.16652-1-jeremy.szu@canonical.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: aoa: remove unnecessary oom message
Zhen Lei [Thu, 17 Jun 2021 10:27:45 +0000 (18:27 +0800)]
ALSA: aoa: remove unnecessary oom message

Fixes scripts/checkpatch.pl warning:
WARNING: Possible unnecessary 'out of memory' message

Remove it can help us save a bit of memory.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Link: https://lore.kernel.org/r/20210617102746.1709-1-thunder.leizhen@huawei.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: seq: oss: Fix error check at system port creation
Takashi Iwai [Thu, 17 Jun 2021 13:47:42 +0000 (15:47 +0200)]
ALSA: seq: oss: Fix error check at system port creation

The system port creation in ALSA OSS sequencer was wrongly checked
against to the port number that can be never negative.  The error code
should be checked rather against the ioctl call.

This patch corrects the error check.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20210617134742.6321-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: firewire-motu: fix stream format for MOTU 8pre FireWire
Takashi Sakamoto [Mon, 14 Jun 2021 08:31:33 +0000 (17:31 +0900)]
ALSA: firewire-motu: fix stream format for MOTU 8pre FireWire

My previous refactoring for ALSA firewire-motu driver brought regression
to handle MOTU 8pre FireWire. The packet format is not operated correctly.

Cc: <stable@vger.kernel.org>
Fixes: dfbaa4dc11eb ("ALSA: firewire-motu: add model-specific table of chunk count")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210614083133.39753-1-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: fix rate on Ozone Z90 USB headset
Daehwan Jung [Wed, 16 Jun 2021 09:34:55 +0000 (18:34 +0900)]
ALSA: usb-audio: fix rate on Ozone Z90 USB headset

It mislabels its 96 kHz altsetting and that's why it causes some noise

Signed-off-by: Daehwan Jung <dh10.jung@samsung.com>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/1623836097-61918-1-git-send-email-dh10.jung@samsung.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: firewire-motu: add support for MOTU 896
Takashi Sakamoto [Wed, 16 Jun 2021 08:28:47 +0000 (17:28 +0900)]
ALSA: firewire-motu: add support for MOTU 896

MOTU 896 is a second model in MOTU FireWire series, produced in 2001. This
model consists of three chips:

 * Texas Instruments TSB41AB2 (Physical layer for IEEE 1394 bus)
 * Philips Semiconductors PDI 1394L21BE (Link layer for IEEE 1394 bus and
   packet processing layer)
 * QuickLogic QuickRAM QL4016 (Data block processing layer and digital
   signal processing)

This commit adds a support for the model, with its unique protocol as
version 1. The features of this protocol are:

 * no MIDI support.
 * Rx packets have no data chunks for control and status messages.
 * Tx packets have 2 bytes for control and status messages in the end of
   each data block.
 * The most of settings are represented in bit flag in one quadlet address
   (0x'ffff'f000'0b14).
 * It's selectable to use signal on optical interface, however the device
   has no register specific to it. The state has effect just to whether
   to exclude differed data chunks.
 * The internal multiplexer is not configured by software.

Just after powering on, the device has a quirk to fail handling
transaction. I recommend users to connect the device enough after powering
on.

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

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

               unit directory at 428
               -----------------------------------------------------------------
428  0003ab34  directory_length 3, crc 43828
42c  120001f2  specifier id
430  13000002  version
434  17102801  model

               eui-64 leaf at 438
               -----------------------------------------------------------------
438  0002057d  leaf_length 2, crc 1405
43c  0001f200  company_id 0001f2     |
440  0000d645  device_id 000000d645  | EUI-64 0001f2000000d645

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210616082847.124688-3-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: firewire-motu: add support for MOTU 828
Takashi Sakamoto [Wed, 16 Jun 2021 08:28:46 +0000 (17:28 +0900)]
ALSA: firewire-motu: add support for MOTU 828

MOTU 828 is a first model in MOTU FireWire series, produced in 2001. This
model consists of three chips:
 * Texas Instruments TSB41AB1 (Physical layer for IEEE 1394 bus)
 * Philips Semiconductors 1394L21BE (Link layer for IEEE 1394 bus and
   packet processing layer)
 * QuickLogic QuickRAM QL4016 (Data block processing layer and digital
   signal processing)

This commit adds a support for this model, with its unique protocol as
version 1. The features of this protocol are:

 * no MIDI support.
 * Rx packets have no data chunks for control and status messages.
 * Tx packets have 2 data chunks for control and status messages in the
   end of each data block. The chunks consist of data block counter
   (4 byte) and message (2 byte).
 * All of settings are represented in bit flag in one quadlet address
   (0x'ffff'f000'0b00).
 * When optical interface is configured as S/PDIF, signals of the interface
   is multiplexed for packets, instead of signals of coaxial interface.
 * The internal multiplexer is not configured by software.

I note that the device has a quirk to mute output voluntarily during
receiving batch of packets in the beginning of packet streaming. The
operation to unmute should be done by software enough after the device
shifts the state, however it's not deterministic. Furthermore, just
after switching rate of sampling clock, the device keeps the state longer.
This patch manages to sleep 100 msec before unmute operation, but it may
fail to release the mute in the case that the rate is changed. As a
workaround, users can restart packet streaming at the same rate, or write
to specific register from userspace.

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

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

               unit directory at 428
               -----------------------------------------------------------------
428  00035052  directory_length 3, crc 20562
42c  120001f2  specifier id
430  13000001  version
434  17101800  model

               eui-64 leaf at 438
               -----------------------------------------------------------------
438  0002eeb6  leaf_length 2, crc 61110
43c  0001f200  company_id 0001f2     |
440  00005015  device_id 0000005015  | EUI-64 0001f20000005015

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210616082847.124688-2-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: bebob: Fix bit flag quirk constants
Colin Ian King [Tue, 15 Jun 2021 14:20:48 +0000 (15:20 +0100)]
ALSA: bebob: Fix bit flag quirk constants

The quirking bit-flags are currently set as contiguous integer enum values
and so currently SND_BEBOB_QUIRK_INITIAL_DISCONTINUOUS_DBC is zero and so
he quirking never getting set or tested correctly for this quirk. Fix this
by setting the quirking constants as shifted bit values.

Addresses-Coverity: ("Bitwise-and with zero")
Fixes: 93cd12d6e88a ("ALSA: bebob: code refactoring for model-dependent quirks")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210615142048.59900-1-colin.king@canonical.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: ppc: fix error return code in snd_pmac_probe()
Yang Yingliang [Wed, 16 Jun 2021 02:11:21 +0000 (10:11 +0800)]
ALSA: ppc: fix error return code in snd_pmac_probe()

If snd_pmac_tumbler_init() or snd_pmac_tumbler_post_init() fails,
snd_pmac_probe() need return error code.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20210616021121.1991502-1-yangyingliang@huawei.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: control_led - fix initialization in the mode show callback
Jaroslav Kysela [Mon, 14 Jun 2021 07:17:10 +0000 (09:17 +0200)]
ALSA: control_led - fix initialization in the mode show callback

The str variable should be always initialized before use even if
the switch covers all cases. This is a minimalistic fix: Assign NULL,
the sprintf() may print '(null)' if something is corrupted.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Link: https://lore.kernel.org/r/20210614071710.1786866-1-perex@perex.cz
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: firewire: fill Kconfig with entries for devices based on DICE ASICs
Takashi Sakamoto [Sun, 13 Jun 2021 08:26:21 +0000 (17:26 +0900)]
ALSA: firewire: fill Kconfig with entries for devices based on DICE ASICs

Nowadays a lot of devices are supported by ALSA dice driver. This commit
fills Kconfig with entries for them.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210613082621.10900-1-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: bebob: correct device entries for Phonic Helix Board and FireFly series
Takashi Sakamoto [Fri, 11 Jun 2021 09:37:30 +0000 (18:37 +0900)]
ALSA: bebob: correct device entries for Phonic Helix Board and FireFly series

Phonic shipped Helix board and FireFly series with IEEE 1394
functionality. Regarding to the parameters in unit directory, these
series have two cases below:

1. the same parameters in unit directory
 * Firefly 202
 * Firefly 302
 * Firefly 808 Universal
 * HelixBoard 12 FireWire, 12 Universal
 * HelixBoard 18 FireWire, 18 Universal
 * HelixBoard 24 FireWire, 24 Universal

2. Unique parameters in unit directory
 * FireFly 808
 * HelixBoard 12 FireWire MkII
 * HelixBoard 18 FireWire MkII
 * HelixBoard 24 FireWire MkII

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210611093730.78254-7-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: bebob: code refactoring for M-Audio models
Takashi Sakamoto [Fri, 11 Jun 2021 09:37:29 +0000 (18:37 +0900)]
ALSA: bebob: code refactoring for M-Audio models

For M-Audio FireWire 410, the value of immediate entry for vendor in unit
directory is the value for BridgeCo. AG OUI. It seems that M-Audio uses
initial settings as is for its product.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210611093730.78254-6-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: bebob: correct device entry for Acoustic Reality eAR Master One, Eroica, Figaro...
Takashi Sakamoto [Fri, 11 Jun 2021 09:37:28 +0000 (18:37 +0900)]
ALSA: bebob: correct device entry for Acoustic Reality eAR Master One, Eroica, Figaro, and Ciaccona

The value of vendor OUI is invalid. Furthermore it seems to be Terratec
OEM.

 * http://subversion.ffado.org/wiki/AvcModels/AcousticRealityeARMasterOne

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210611093730.78254-5-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: bebob: correct device entry for Mackie D.2 FireWire option card
Takashi Sakamoto [Fri, 11 Jun 2021 09:37:27 +0000 (18:37 +0900)]
ALSA: bebob: correct device entry for Mackie D.2 FireWire option card

For Mackie D.2 FireWire option card, 0x00000f is used for the value of
immediate entry for vendor in unit directory. The value comes from report
by FFADO user in below page:

 * http://subversion.ffado.org/wiki/AvcModels/MackieD.2.

However, it seems to be wrong. There are two causes; vendor's mistake to
decide value for GUID field in configuration ROM against standard, as
Stefan Richter mentioned in below post:

 * https://lore.kernel.org/alsa-devel/1443917823-13516-1-git-send-email-o-takashi@sakamocchi.jp/#t

Another is implementation of libffado. The library doesn't print out the
value from immediate entry for vendor in unit directory. It just print out
the first 6 bytes of GUID as vendor ID.

This commit replaces with correct vendor OUI.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210611093730.78254-4-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: fireworks: fulfil device entries
Takashi Sakamoto [Fri, 11 Jun 2021 09:37:26 +0000 (18:37 +0900)]
ALSA: fireworks: fulfil device entries

All of devices with Echo Audio Fireworks board module has the same
combination of specifier_id (0x00a02d) and version (0x010000) in
unit directory.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210611093730.78254-3-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: bebob: fulfil device entries
Takashi Sakamoto [Fri, 11 Jun 2021 09:37:25 +0000 (18:37 +0900)]
ALSA: bebob: fulfil device entries

Although unit directory in root directory of configuration ROM has the
same value (0x00a02d) for its specifier_id entry to express AV/C device,
it has two cases for the value (0x010001/0x014001) to version entry.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210611093730.78254-2-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: i2c: tea6330t: Remove redundant initialization of variable err
Colin Ian King [Fri, 11 Jun 2021 16:52:23 +0000 (17:52 +0100)]
ALSA: i2c: tea6330t: Remove redundant initialization of variable err

The variable err is being initialized with a value that is never read,
it is being updated later on. The assignment is redundant and can be
removed.

Addresses-Coverity: ("Unused value")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/20210611165223.38983-1-colin.king@canonical.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: firewire-lib: replace in_interrupt() with in_softirq()
Takashi Sakamoto [Fri, 11 Jun 2021 08:34:25 +0000 (17:34 +0900)]
ALSA: firewire-lib: replace in_interrupt() with in_softirq()

Tasklet is used to handle isochronous context of 1394 OHCI. The explicit
usage of in_softirq() may be preferable than in_interrupt().

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210611083425.61204-1-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: n64: check return value after calling platform_get_resource()
Yang Yingliang [Thu, 10 Jun 2021 12:49:58 +0000 (20:49 +0800)]
ALSA: n64: check return value after calling platform_get_resource()

It will cause null-ptr-deref if platform_get_resource() returns NULL,
we need check the return value.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20210610124958.116142-1-yangyingliang@huawei.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: hda/tegra: Use devm_platform_get_and_ioremap_resource()
Yang Yingliang [Thu, 10 Jun 2021 13:19:22 +0000 (21:19 +0800)]
ALSA: hda/tegra: Use devm_platform_get_and_ioremap_resource()

Use devm_platform_get_and_ioremap_resource() to simplify
code.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20210610131922.134788-1-yangyingliang@huawei.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: trident: Fix build error
YueHaibing [Sat, 12 Jun 2021 03:34:58 +0000 (11:34 +0800)]
ALSA: trident: Fix build error

sound/pci/trident/trident_memory.c: In function ‘set_tlb_bus’:
sound/pci/trident/trident_memory.c:85:35: error: ‘pagetr’ undeclared (first use in this function); did you mean ‘page’?
  for (i = 0; i < UNIT_PAGES; i++, pagetr++) {
                                   ^~~~~~
                                   page

Fixes: 74fb98311c4e ("ALSA: trident: Drop shadow TLB pointer table")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Link: https://lore.kernel.org/r/20210612033458.42928-1-yuehaibing@huawei.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: bebob: code refactoring for model-dependent quirks
Takashi Sakamoto [Fri, 11 Jun 2021 03:50:03 +0000 (12:50 +0900)]
ALSA: bebob: code refactoring for model-dependent quirks

This commit adds enumeration and structure member as code refactoring
regarding to model-dependent quirks.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210611035003.26852-4-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: bebob: delete workaround for protocol version 3
Takashi Sakamoto [Fri, 11 Jun 2021 03:50:02 +0000 (12:50 +0900)]
ALSA: bebob: delete workaround for protocol version 3

In a commit c4d860a0d256 ("ALSA: bebob: loosen up severity of checking
continuity for BeBoB v3 quirk"), a workaround was added for the quirk in
BeBoB protocol version 3 against the discontinuity of data block counter.
As long as seeing with sequence replay for media clock recovery, such
quirk disappears.

This commit deletes the workaround.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210611035003.26852-3-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: bebob: dismiss sleep after breaking connections
Takashi Sakamoto [Fri, 11 Jun 2021 03:50:01 +0000 (12:50 +0900)]
ALSA: bebob: dismiss sleep after breaking connections

In a commit d3eabe939aee ("ALSA: bebob: expand sleep just after breaking
connections for protocol version 1"), a workaround was added for a quirk
of freeze in BeBoB protocol version 1. As long as seeing with sequence
replay for media clock recovery, the quirk disappears.

This commit removes the workaround.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210611035003.26852-2-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: core: Fix build error due to missing PAGE_SIZE
Takashi Iwai [Thu, 10 Jun 2021 11:09:35 +0000 (13:09 +0200)]
ALSA: core: Fix build error due to missing PAGE_SIZE

The recent refactoring of memalloc stuff removed the inclusion of
asm/page.h for simplicity, but it turned out this caused a compile
error due the lack of PAGE_SIZE definition on some architectures.
Do a partial revert for recovering from that.

Fixes: 37af81c5998f ("ALSA: core: Abstract memory alloc helpers")
Reported-by: kernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/r/202106101858.PfXMMuAa-lkp@intel.com
Link: https://lore.kernel.org/r/20210610110935.10393-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: Add support for Denon DN-X1600
Damien Zammit [Thu, 10 Jun 2021 08:35:28 +0000 (18:35 +1000)]
ALSA: usb-audio: Add support for Denon DN-X1600

This provides support for Denon DN-X1600 hardware mixer.

The device itself supports 44100, 48000 and 96000 (Hz)
sample rates, but switching rates via software is currently not working.
Therefore, this patch hardcodes the sample rate to 48000Hz which
enables all 8 channels to function correctly when the correct
sample rate is selected on the hardware itself.

MIDI also tested and works.

Signed-off-by: Damien Zammit <damien@zamaudio.com>
Tested-by: xalmoxis@gmail.com
Link: https://lore.kernel.org/r/20210610083528.603942-2-damien@zamaudio.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: core: Add continuous and vmalloc mmap ops
Takashi Iwai [Wed, 9 Jun 2021 16:25:51 +0000 (18:25 +0200)]
ALSA: core: Add continuous and vmalloc mmap ops

The mmap of continuous pages and vmalloc'ed pages are relatively
easily done in a shot with the existing helper functions.
Implement the mmap ops for those types, so that the mmap works without
relying on the page fault handling.

Link: https://lore.kernel.org/r/20210609162551.7842-6-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: core: Move mmap handler into memalloc ops
Takashi Iwai [Wed, 9 Jun 2021 16:25:50 +0000 (18:25 +0200)]
ALSA: core: Move mmap handler into memalloc ops

This patch moves the mmap handling code into the common memalloc
handler.  It allows us to reduce the memory-type specific code in PCM
code gracefully.

Link: https://lore.kernel.org/r/20210609162551.7842-5-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: core: Abstract memory alloc helpers
Takashi Iwai [Wed, 9 Jun 2021 16:25:49 +0000 (18:25 +0200)]
ALSA: core: Abstract memory alloc helpers

This patch introduces the ops table to each memory allocation type
(SNDRV_DMA_TYPE_XXX) and abstract the handling for the better code
management.  Then we get separate the page allocation, release and
other tasks for each type, especially for the SG buffer.

Each buffer type has now callbacks in the struct snd_malloc_ops, and
the common helper functions call those ops accordingly.  The former
inline code that is specific to SG-buffer is moved into the local
sgbuf.c, and we can simplify the PCM code without details of memory
handling.

Link: https://lore.kernel.org/r/20210609162551.7842-4-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: core: Drop snd_sgbuf_get_ptr()
Takashi Iwai [Wed, 9 Jun 2021 16:25:48 +0000 (18:25 +0200)]
ALSA: core: Drop snd_sgbuf_get_ptr()

snd_sgbuf_get_ptr() and its sibling snd_pcm_sgbuf_get_ptr() are no
longer used by any drivers.  Let's drop them.

Link: https://lore.kernel.org/r/20210609162551.7842-3-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: trident: Drop shadow TLB pointer table
Takashi Iwai [Wed, 9 Jun 2021 16:25:47 +0000 (18:25 +0200)]
ALSA: trident: Drop shadow TLB pointer table

The shadow TLB pointer table is allocated and set up, but never really
used any longer by the driver.  Let's drop it.

Since this is the only user of snd_pcm_sgbuf_get_ptr(), we can clean
up the API after this change.

Link: https://lore.kernel.org/r/20210609162551.7842-2-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: doc: Fix spelling mistakes
huangjianghui [Thu, 10 Jun 2021 06:20:36 +0000 (14:20 +0800)]
ALSA: doc: Fix spelling mistakes

correct Reatek to Realtek

Signed-off-by: huangjianghui <huangjianghui@uniontech.com>
Link: https://lore.kernel.org/r/20210610062036.30300-1-huangjianghui@uniontech.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: arm: Remove unnecessary variables
zuoqilin [Thu, 10 Jun 2021 02:40:53 +0000 (10:40 +0800)]
ALSA: arm: Remove unnecessary variables

There is no need to define the variable "ret" to receive.

Signed-off-by: zuoqilin <zuoqilin@yulong.com>
Link: https://lore.kernel.org/r/20210610024053.1217-1-zuoqilin1@163.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: firewire-lib: obsolete workqueue for period update
Takashi Sakamoto [Thu, 10 Jun 2021 03:17:33 +0000 (12:17 +0900)]
ALSA: firewire-lib: obsolete workqueue for period update

The workqueue to notify PCM period elapse is not used anymore.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210610031733.56297-4-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: firewire-lib: operate for period elapse event in process context
Takashi Sakamoto [Thu, 10 Jun 2021 03:17:32 +0000 (12:17 +0900)]
ALSA: firewire-lib: operate for period elapse event in process context

All of drivers in ALSA firewire stack processes two chances to process
isochronous packets in any isochronous context; in software IRQ context
for 1394 OHCI, and in process context of ALSA PCM application.

In the process context, callbacks of .pointer and .ack are utilized. The
callbacks are done by ALSA PCM core under acquiring lock of PCM substream,

In design of ALSA PCM core, call of snd_pcm_period_elapsed() is used for
drivers to awaken user processes from waiting for available frames. The
function voluntarily acquires lock of PCM substream, therefore it is not
called in the process context since it causes dead lock.

As a workaround to avoid the dead lock, all of drivers in ALSA firewire
stack uses workqueue to delegate the call. A variant of
snd_pcm_period_elapsed() without lock acquisition can obsolete the
workqueue.

An extra care is needed for the callback of .pointer since it's called
from snd_pcm_period_elapsed(). The isochronous context in Linux FireWire
subsystem is safe mostly for nested call except in software IRQ context.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210610031733.56297-3-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: pcm: add snd_pcm_period_elapsed() variant without acquiring lock of PCM substream
Takashi Sakamoto [Thu, 10 Jun 2021 03:17:31 +0000 (12:17 +0900)]
ALSA: pcm: add snd_pcm_period_elapsed() variant without acquiring lock of PCM substream

Current implementation of ALSA PCM core has a kernel API,
snd_pcm_period_elapsed(), for drivers to queue event to awaken processes
from waiting for available frames. The function voluntarily acquires lock
of PCM substream, therefore it is not called in process context for any
PCM operation since the lock is already acquired.

It is convenient for packet-oriented driver, at least for drivers to audio
and music unit in IEEE 1394 bus. The drivers are allowed by Linux
FireWire subsystem to process isochronous packets queued till recent
isochronous cycle in process context in any time.

This commit adds snd_pcm_period_elapsed() variant,
snd_pcm_period_elapsed_without_lock(), for drivers to queue the event in
the process context.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210610031733.56297-2-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: parisc: Fix assignment in if condition
Takashi Iwai [Tue, 8 Jun 2021 14:05:40 +0000 (16:05 +0200)]
ALSA: parisc: Fix assignment in if condition

PARISC harmony driver code contains an assignment in if condition,
which is a bad coding style that may confuse readers and occasionally
lead to bugs.

This patch is merely for coding-style fixes, no functional changes.

Link: https://lore.kernel.org/r/20210608140540.17885-67-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: i2c: Fix assignment in if condition
Takashi Iwai [Tue, 8 Jun 2021 14:05:39 +0000 (16:05 +0200)]
ALSA: i2c: Fix assignment in if condition

ALSA I2C helper drivers contain a few assignments in if condition,
which is a bad coding style that may confuse readers and occasionally
lead to bugs.

This patch is merely for coding-style fixes, no functional changes.

Link: https://lore.kernel.org/r/20210608140540.17885-66-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: poewrmac: Fix assignment in if condition
Takashi Iwai [Tue, 8 Jun 2021 14:05:38 +0000 (16:05 +0200)]
ALSA: poewrmac: Fix assignment in if condition

PPC powermac driver code contains a few assignments in if condition,
which is a bad coding style that may confuse readers and occasionally
lead to bugs.

This patch is merely for coding-style fixes, no functional changes.

Link: https://lore.kernel.org/r/20210608140540.17885-65-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: synth: Fix assignment in if condition
Takashi Iwai [Tue, 8 Jun 2021 14:05:37 +0000 (16:05 +0200)]
ALSA: synth: Fix assignment in if condition

EMUx synth driver code contains lots of assignments in if condition,
which is a bad coding style that may confuse readers and occasionally
lead to bugs.

This patch is merely for coding-style fixes, no functional changes.

Link: https://lore.kernel.org/r/20210608140540.17885-64-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>