History log of /linux-master/sound/usb/mixer_quirks.c
Revision Date Author Comments
# 4e809a29 26-Dec-2023 Geoffrey D. Bennett <g@b4.vu>

ALSA: scarlett2: Add support for Solo, 2i2, and 4i4 Gen 4

Add new Focusrite Scarlett Gen 4 USB IDs, notification arrays, config
sets, and device info data.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/b33526d3b7a56bb2c86aa4eb2137a415bd23f1ce.1703612638.git.g@b4.vu


# bbb8e719 01-Dec-2023 Sarah Grant <s@srd.tw>

ALSA: usb-audio: Add Pioneer DJM-450 mixer controls

These values mirror those of the Pioneer DJM-250MK2 as the channel layout
appears identical based on my observations. This duplication could be removed in
later contributions if desired.

Signed-off-by: Sarah Grant <s@srd.tw>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20231201181654.5058-1-s@srd.tw
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# efc3d7d2 26-Oct-2023 Geoffrey D. Bennett <g@b4.vu>

ALSA: scarlett2: Rename scarlett_gen2 to scarlett2

This driver was originally developed for the Focusrite Scarlett Gen 2
series. Since then Focusrite have used a similar protocol for their
Gen 3, Gen 4, Clarett USB, Clarett+, and Vocaster series.

Let's call this common protocol the "Scarlett 2 Protocol" and rename
the driver to scarlett2 to not imply that it is restricted to Gen 2
series devices.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/e1ad7f69a1e20cdb39094164504389160c1a0a0b.1698342632.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 2b17b489 07-Oct-2023 Geoffrey D. Bennett <g@b4.vu>

ALSA: scarlett2: Add Focusrite Clarett 2Pre and 4Pre USB support

It has been confirmed that all devices in the Focusrite Clarett USB
series work the same as the devices in the Clarett+ series. Add the
missing PIDs to enable support for the Clarett 2Pre and 4Pre USB.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/ZSFB8EVTG1PK1eq/@m.b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# b61a3aca 26-Sep-2023 Geoffrey D. Bennett <g@b4.vu>

ALSA: scarlett2: Add Focusrite Clarett+ 2Pre and 4Pre support

The Focusrite Clarett+ series uses the same protocol as the Scarlett
Gen 2 and Gen 3 series. This patch adds support for the Clarett+ 2Pre
and Clarett+ 4Pre similarly to the existing 8Pre support by adding
appropriate entries to the scarlett2 driver.

The Clarett 2Pre USB and 4Pre USB presumably use the same protocol as
well, so support for them can easily be added if someone can test.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/ZRL7qjC3tYQllT3H@m.b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# b9a98cdd 14-Sep-2023 Geoffrey D. Bennett <g@b4.vu>

ALSA: scarlett2: Add support for Clarett 8Pre USB

The Clarett 8Pre USB works the same as the Clarett+ 8Pre, only the USB
ID is different.

Tested-by: Philippe Perrot <philippe@perrot-net.fr>
Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/e59f47b29e2037f031b56bde10474c6e96e31ba5.1694705811.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# f71c70df 08-Aug-2022 Christian Colglazier <christian@cacolglazier.com>

ALSA: scarlett2: Add Focusrite Clarett+ 8Pre support

The Focusrite Clarett+ 8Pre uses the same protocol as the Scarlett Gen
2 and Gen 3 product range. This patch adds support for the Clarett+
8Pre by adding appropriate entries to the scarlett2 driver.

The Clarett+ 2Pre and 4Pre, and the Clarett USB product line
presumably use the same protocol as well, so support for them can
easily be added if someone can test.

Signed-off-by: Christian Colglazier <christian@cacolglazier.com>
Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/20220809043241.GA2749152@m.b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 61c606a4 05-Jul-2022 Jan Schär <jan@jschaer.ch>

ALSA: usb-audio: Add endianness annotations

Fixes: 4b8ea38fabab ("ALSA: usb-audio: Support jack detection on Dell dock")
Reported-by: kernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/r/202207051932.qUilU0am-lkp@intel.com
Signed-off-by: Jan Schär <jan@jschaer.ch>
Link: https://lore.kernel.org/r/20220705135746.13713-1-jan@jschaer.ch
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 2e57a335 27-Jun-2022 Jan Schär <jan@jschaer.ch>

ALSA: usb-audio: Turn off 'manual mode' on Dell dock

This removes the need to power cycle the Dell WD15 dock if it has been
attached to a Windows machine.

The Windows driver puts the ALC4020 USB audio controller into
'manual mode', and then does all the power management and other
configuration itself, by sending HD audio commands directly to the
ALC3263 audio codec via vendor-type USB messages. If manual mode is off,
this is all handled by the firmware, and works well enough.

If manual mode is turned on, the latency of the SET INTERFACE command
goes from several hundred ms to less than 1 ms
(see https://bugzilla.suse.com/show_bug.cgi?id=1089467), but I'm not
sure if the additional code that would be required is worth it.

Funnily enough, the Windows driver tries to turn off manual mode when
the dock is disconnected, which doesn't work for obvious reasons.

Additionally, fix a bug in dell_dock_init_vol, which didn't work because
the Control Selector was missing.
Now, it properly resets the volume to 0dB.

Fixes: 964af639ad69 ("ALSA: usb-audio: Initialize Dell Dock playback volumes")
Signed-off-by: Jan Schär <jan@jschaer.ch>
Link: https://lore.kernel.org/r/20220627171855.42338-2-jan@jschaer.ch
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 4b8ea38f 27-Jun-2022 Jan Schär <jan@jschaer.ch>

ALSA: usb-audio: Support jack detection on Dell dock

The Dell WD15 dock has a headset and a line out port. Add support for
detecting if a jack is inserted into one of these ports.
For the headset jack, additionally determine if a mic is present.

The WD15 contains an ALC4020 USB audio controller and ALC3263 audio codec
from Realtek. It is a UAC 1 device, and UAC 1 does not support jack
detection. Instead, jack detection works by sending HD Audio commands over
vendor-type USB messages.

I found out how it works by looking at USB captures on Windows.
The audio codec is very similar to the one supported by
sound/soc/codecs/rt298.c / rt298.h, some constant names and the mic
detection are adapted from there. The realtek_add_jack function is adapted
from build_connector_control in sound/usb/mixer.c.

I tested this on a WD15 dock with the latest firmware.

Signed-off-by: Jan Schär <jan@jschaer.ch>
Link: https://lore.kernel.org/r/20220627171855.42338-1-jan@jschaer.ch
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 0f306cca 11-Mar-2022 Lars-Peter Clausen <lars@metafoo.de>

ALSA: usb-audio: Add mute TLV for playback volumes on RODE NT-USB

For the RODE NT-USB the lowest Playback mixer volume setting mutes the
audio output. But it is not reported as such causing e.g. PulseAudio to
accidentally mute the device when selecting a low volume.

Fix this by applying the existing quirk for this kind of issue when the
device is detected.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20220311201400.235892-1-lars@metafoo.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 86a9bb5b 02-Dec-2021 Takashi Iwai <tiwai@suse.de>

ALSA: usb-audio: Drop CONFIG_PM ifdefs

Practically seen, CONFIG_PM is almost mandatory.
Let's drop the ugly ifdef lines and simplify the code.

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


# 1e583aef 02-Dec-2021 Takashi Iwai <tiwai@suse.de>

ALSA: usb-audio: Drop superfluous '0' in Presonus Studio 1810c's ID

The vendor ID of Presonus Studio 1810c had a superfluous '0' in its
USB ID. Drop it.

Fixes: 8dc5efe3d17c ("ALSA: usb-audio: Add support for Presonus Studio 1810c")
Link: https://lore.kernel.org/r/20211202083833.17784-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# fb1af5be 04-Dec-2021 Geraldo Nascimento <geraldogabriel@gmail.com>

ALSA: usb-audio: Reorder snd_djm_devices[] entries

Olivia Mackintosh has posted to alsa-devel reporting that
there's a potential bug that could break mixer quirks for Pioneer
devices introduced by 6d27788160362a7ee6c0d317636fe4b1ddbe59a7
"ALSA: usb-audio: Add support for the Pioneer DJM 750MK2
Mixer/Soundcard".

This happened because the DJM 750 MK2 was added last to the Pioneer DJM
device table index and defined as 0x4 but was added to snd_djm_devices[]
just after the DJM 750 (MK1) entry instead of last, after the DJM 900
NXS2. This escaped review.

To prevent that from ever happening again, Takashi Iwai suggested to use
C99 array designators in snd_djm_devices[] instead of simply reordering
the entries.

Fixes: 6d2778816036 ("ALSA: usb-audio: Add support for the Pioneer DJM 750MK2")
Reported-by: Olivia Mackintosh <livvy@base.nu>
Suggested-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Geraldo Nascimento <geraldogabriel@gmail.com>
Link: https://lore.kernel.org/r/Yau46FDzoql0SNnW@geday
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 6d277881 10-Oct-2021 William Overton <willovertonuk@gmail.com>

ALSA: usb-audio: Add support for the Pioneer DJM 750MK2 Mixer/Soundcard

The kernel already has support for very similar Pioneer djm products
and this work is based on that.

Added device to quirks-table.h and added control info to
mixer_quirks.c.

Tested on my hardware and all working.

Signed-off-by: William Overton <willovertonuk@gmail.com>
Link: https://lore.kernel.org/r/20211010145841.11907-1-willovertonuk@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 7b9cf903 09-Sep-2021 Takashi Iwai <tiwai@suse.de>

ALSA: usb-audio: Unify mixer resume and reset_resume procedure

USB-audio driver assumes that the normal resume would preserve the
device configuration while reset_resume wouldn't, and tries to restore
the mixer elements only at reset_resume callback. However, this seems
too naive, and some devices do behave differently, resetting the
volume at the normal resume; this resulted in the inconsistent volume
that surprised users.

This patch changes the mixer resume code to handle both the normal and
reset resume in the same way, always restoring the original mixer
element values. This allows us to unify the both callbacks as well as
dropping the no longer used reset_resume field, which ends up with a
good code reduction.

A slight behavior change by this patch is that now we assign
restore_mixer_value() as the default resume callback, and the function
is no longer called at reset-resume when the resume callback is
overridden by the quirk function. That is, if needed, the quirk
resume function would have to handle similarly as
restore_mixer_value() by itself.

Reported-by: En-Shuo Hsu <enshuo@chromium.org>
Cc: Yu-Hsuan Hsu <yuhsuan@chromium.org>
Link: https://lore.kernel.org/r/CADDZ45UPsbpAAqP6=ZkTT8BE-yLii4Y7xSDnjK550G2DhQsMew@mail.gmail.com
Link: https://lore.kernel.org/r/20210910105155.12862-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 7ac2246f 13-Aug-2021 Damien Zammit <damien@zamaudio.com>

ALSA: usb-audio: Input source control - digidesign mbox

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

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

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

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

Signed-off-by: Damien Zammit <damien@zamaudio.com>
Tested-by: Damien Zammit <damien@zamaudio.com>
Link: https://lore.kernel.org/r/20210813113402.11849-1-damien@zamaudio.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 2fa96277 22-Jun-2021 Geoffrey D. Bennett <g@b4.vu>

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>


# 4be47798 22-Jun-2021 Geoffrey D. Bennett <g@b4.vu>

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>


# 265d1a90 21-May-2021 Geoffrey D. Bennett <g@b4.vu>

ALSA: usb-audio: scarlett2: Improve driver startup messages

Add separate init function to call the existing controls_create
function so a custom error can be displayed if initialisation fails.

Use info level instead of error for notifications.

Display the VID/PID so device_setup is targeted to the right device.

Display "enabled" message to easily confirm that the driver is loaded.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/b5d140c65f640faf2427e085fbbc0297b32e5fce.1621584566.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 44609fc0 25-Mar-2021 Kai-Heng Feng <kai.heng.feng@canonical.com>

ALSA: usb-audio: Check connector value on resume

Rear Mic on Lenovo P620 cannot record after S3, despite that there's no
error and the other two functions of the USB audio, Line In and Line
Out, work just fine.

The mic starts to work again after running userspace app like "alsactl
store". Following the lead, the evidence shows that as soon as connector
status is queried, the mic can work again.

So also check connector value on resume to "wake up" the USB audio to
make it functional.

This can be device specific, however I think this generic approach may
benefit more than one device.

Now the resume callback checks connector, and a new callback,
reset_resume, to also restore switches and volumes.

Suggested-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Link: https://lore.kernel.org/r/20210325165918.22593-2-kai.heng.feng@canonical.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# b8db8be8 01-Mar-2021 Nicolas MURE <nicolas.mure2019@gmail.com>

ALSA: usb-audio: fix Pioneer DJM-850 control label info

Unlike the other DJM, the value to set the "CD/LINE" and "LINE" capture
control options are inverted. This fix makes sure that the displayed
info label while using `alsamixer` matches the input switches label
on the DJM-850 mixer.

Signed-off-by: Nicolas MURE <nicolas.mure2019@gmail.com>
Link: https://lore.kernel.org/r/20210301152729.18094-5-nicolas.mure2019@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 7687850b 01-Mar-2021 Nicolas MURE <nicolas.mure2019@gmail.com>

ALSA: usb-audio: Declare Pioneer DJM-850 mixer controls

Declare audio capture controls to choose the audio source, and also to
set the capture level (in dB).

See https://github.com/nm2107/Pioneer-DJM-850-driver-reverse-engineering/blob/172fb9a61055960c88c67b7c416fe5bf3609807b/doc/windows-djm-850-setting-utility/mixer-output-tab/README.md

Signed-off-by: Nicolas MURE <nicolas.mure2019@gmail.com>
Link: https://lore.kernel.org/r/20210301152729.18094-3-nicolas.mure2019@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 50b1affc 18-Mar-2021 Colin Ian King <colin.king@canonical.com>

ALSA: usb-audio: Fix unintentional sign extension issue

The shifting of the u8 integer device by 24 bits to the left will
be promoted to a 32 bit signed int and then sign-extended to a
64 bit unsigned long. In the event that the top bit of device is
set then all then all the upper 32 bits of the unsigned long will
end up as also being set because of the sign-extension. Fix this
by casting device to an unsigned long before the shift.

Addresses-Coverity: ("Unintended sign extension")
Fixes: a07df82c7990 ("ALSA: usb-audio: Add DJM750 to Pioneer mixer quirk")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/20210318132008.15266-1-colin.king@canonical.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# fee03efc 05-Feb-2021 Fabian Lesniak <fabian@lesniak-it.de>

ALSA: usb-audio: add mixer quirks for Pioneer DJM-900NXS2

This commit adds mixer quirks for the Pioneer DJM-900NXS2 mixer. This
device has 6 capture channels, 5 of them allow setting the signal
source. This adds controls for these, similar to the DJM-250Mk2.
However, playpack channels are not controllable via software like on the
250Mk2, as they can only be set manually on the mixing console.
Read-only controls showing the currently selected playback channels are
omitted.

Signed-off-by: Fabian Lesniak <fabian@lesniak-it.de>
Link: https://lore.kernel.org/r/20210205215116.258724-2-fabian@lesniak-it.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# a07df82c 05-Feb-2021 Olivia Mackintosh <livvy@base.nu>

ALSA: usb-audio: Add DJM750 to Pioneer mixer quirk

This allows for N different devices to use the pioneer mixer quirk for
setting capture/record type and recording level. The impementation has
not changed much with the exception of an additional mask on
private_value to allow storing of a device index:
DEVICE MASK 0xff000000
GROUP_MASK 0x00ff0000
VALUE_MASK 0x0000ffff

This could be improved by changing the arrays of wValues for each
channel to contain named definitions (e.g. SND_DJM_CAP_LINE). It would
improve readability and perhaps would allow using the same array for
multiple channels. The channel number can be specified on the control
next to the wIndex.

Feedback is very much appreciated as I'm not the most proficient C
programmer but am learning as I go.

Signed-off-by: Olivia Mackintosh <livvy@base.nu>
Link: https://lore.kernel.org/r/20210205184256.10201-2-livvy@base.nu
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 75b1a8f9 04-Jan-2021 Joe Perches <joe@perches.com>

ALSA: Convert strlcpy to strscpy when return value is unused

strlcpy is deprecated. see: Documentation/process/deprecated.rst

Change the calls that do not use the strlcpy return value to the
preferred strscpy.

Done with cocci script:

@@
expression e1, e2, e3;
@@

- strlcpy(
+ strscpy(
e1, e2, e3);

This cocci script leaves the instances where the return value is
used unchanged.

After this patch, sound/ has 3 uses of strlcpy() that need to be
manually inspected for conversion and changed one day.

$ git grep -w strlcpy sound/
sound/usb/card.c: len = strlcpy(card->longname, s, sizeof(card->longname));
sound/usb/mixer.c: return strlcpy(buf, p->name, buflen);
sound/usb/mixer.c: return strlcpy(buf, p->names[index], buflen);

Miscellenea:

o Remove trailing whitespace in conversion of sound/core/hwdep.c

Link: https://lore.kernel.org/lkml/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/

Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/22b393d1790bb268769d0bab7bacf0866dcb0c14.camel@perches.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# cdc01a15 22-Sep-2020 František Kučera <franta-linux@frantovo.cz>

ALSA: usb-audio: Add mixer support for Pioneer DJ DJM-250MK2

This patch extends support for DJM-250MK2 and allows mapping
playback and capture channels to available sources.
Configures the card through USB commands.

Signed-off-by: František Kučera <franta-linux@frantovo.cz>
Link: https://lore.kernel.org/r/20200922144206.10472-1-konference@frantovo.cz
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# fec90088 06-Aug-2020 Mirko Dietrich <buzz@l4m1.de>

ALSA: usb-audio: Creative USB X-Fi Pro SB1095 volume knob support

Adds an entry for Creative USB X-Fi to the rc_config array in
mixer_quirks.c to allow use of volume knob on the device.
Adds support for newer X-Fi Pro card, known as "Model No. SB1095"
with USB ID "041e:3263"

Signed-off-by: Mirko Dietrich <buzz@l4m1.de>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200806124850.20334-1-buzz@l4m1.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 220345e9 24-Jun-2020 Takashi Iwai <tiwai@suse.de>

ALSA: usb-audio: Fix OOB access of mixer element list

The USB-audio mixer code holds a linked list of usb_mixer_elem_list,
and several operations are performed for each mixer element. A few of
them (snd_usb_mixer_notify_id() and snd_usb_mixer_interrupt_v2())
assume each mixer element being a usb_mixer_elem_info object that is a
subclass of usb_mixer_elem_list, cast via container_of() and access it
members. This may result in an out-of-bound access when a
non-standard list element has been added, as spotted by syzkaller
recently.

This patch adds a new field, is_std_info, in usb_mixer_elem_list to
indicate that the element is the usb_mixer_elem_info type or not, and
skip the access to such an element if needed.

Reported-by: syzbot+fb14314433463ad51625@syzkaller.appspotmail.com
Reported-by: syzbot+2405ca3401e943c538b5@syzkaller.appspotmail.com
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200624122340.9615-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# f99e24a6 29-May-2020 Thomas Ebeling <penguins@bollie.de>

ALSA: usb-audio: Fixing usage of plain int instead of NULL

As reported by kbuild test robot, mixer quirks for RME Babyface
Pro used plain integer instead of NULL.

Fixes: 3e8f3bd04716 ("ALSA: usb-audio: RME Babyface Pro mixer patch")
Signed-off-by: Thomas Ebeling <penguins@bollie.de>
Reported-by: kbuild test robot <lkp@intel.com>
Link: https://lore.kernel.org/r/20200529173248.zzawijfvw73kzjxt@bollie.ca9.eu
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 47b4f5f5 15-May-2020 Thomas Ebeling <penguins@bollie.de>

ALSA: usb-audio: fixing upper volume limit for RME Babyface Pro routing crosspoints

In my initial patch, these were set too low.

Fixes: 3e8f3bd04716 ("ALSA: usb-audio: RME Babyface Pro mixer patch")
Signed-off-by: Thomas Ebeling <penguins@bollie.de>
Link: https://lore.kernel.org/r/20200515114556.vtspnonzvp4xp44m@bollie.ca9.eu
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 59e1947c 22-Apr-2020 Xiyu Yang <xiyuyang19@fudan.edu.cn>

ALSA: usb-audio: Fix usb audio refcnt leak when getting spdif

snd_microii_spdif_default_get() invokes snd_usb_lock_shutdown(), which
increases the refcount of the snd_usb_audio object "chip".

When snd_microii_spdif_default_get() returns, local variable "chip"
becomes invalid, so the refcount should be decreased to keep refcount
balanced.

The reference counting issue happens in several exception handling paths
of snd_microii_spdif_default_get(). When those error scenarios occur
such as usb_ifnum_to_if() returns NULL, the function forgets to decrease
the refcnt increased by snd_usb_lock_shutdown(), causing a refcnt leak.

Fix this issue by jumping to "end" label when those error scenarios
occur.

Fixes: 447d6275f0c2 ("ALSA: usb-audio: Add sanity checks for endpoint accesses")
Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/1587617711-13200-1-git-send-email-xiyuyang19@fudan.edu.cn
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 3e8f3bd0 14-Apr-2020 Thomas Ebeling <penguins@bollie.de>

ALSA: usb-audio: RME Babyface Pro mixer patch

Added mixer quirks to allow controlling the internal DSP of the
RME Babyface Pro and its successor Babyface Pro FS.

Signed-off-by: Thomas Ebeling <penguins@bollie.de>
Link: https://lore.kernel.org/r/20200414211019.qprg7whepg2y7nei@bollie.ca9.eu
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 8dc5efe3 14-Feb-2020 Nick Kossifidis <mickflemm@gmail.com>

ALSA: usb-audio: Add support for Presonus Studio 1810c

This patch adds support for Presonus Studio 1810c, a usb interface
that's UAC2 compliant with a few quirks and a few extra hw-specific
controls. I've tested all 3 altsettings and the added switch
controls and they work as expected.

More infos on the card:
https://www.presonus.com/products/Studio-1810c

Note that this work is based on packet inspection with
usbmon. I just wanted to get this card to work for using
it on our open-source radio station:
https://github.com/UoC-Radio

v2 address issues reported by Takashi:
* Properly get/set enum type controls
* Prevent race condition on switch_get/set
* Various control naming changes
* Various coding style fixes

v3 improve readability of sample rate filtering
and some other minor changes.

Signed-off-by: Nick Kossifidis <mickflemm@gmail.com>
Link: https://lore.kernel.org/r/5e47481a.1c69fb81.befb3.8dac@mx.google.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# ff40e0d4 11-Jan-2020 Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

ALSA: usb: update old-style static const declaration

GCC reports the following warning with W=1

sound/usb/mixer_quirks.c: In function ‘snd_microii_controls_create’:
sound/usb/mixer_quirks.c:1694:2: warning: ‘static’ is not at beginning
of declaration [-Wold-style-declaration]
1694 | const static usb_mixer_elem_resume_func_t resume_funcs[] = {
| ^~~~~

Move static to the beginning of declaration

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20200111214736.3002-3-pierre-louis.bossart@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# a01df925 05-Jan-2020 Takashi Iwai <tiwai@suse.de>

ALSA: usb-audio: More constifications

Apply const prefix to the remaining places: the static table for the
unit information, the mixer maps, the validator tables, etc.

Just for minor optimization and no functional changes.

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


# 195727e8 03-Jan-2020 Takashi Iwai <tiwai@suse.de>

ALSA: usb: Constify snd_kcontrol_new items

Most of snd_kcontrol_new definitions are read-only and passed as-is.
Let's declare them as const for further optimization.

There should be no functional changes by this patch.

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


# 6de3c9e3 15-Aug-2019 Takashi Iwai <tiwai@suse.de>

ALSA: usb-audio: Fix invalid NULL check in snd_emuusb_set_samplerate()

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

This patch fixes the check before the conversion.

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

Fixes: 8c558076c740 ("ALSA: usb-audio: Clean up mixer element list traverse")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 9e4d5c1b 28-Jul-2019 Geoffrey D. Bennett <g@b4.vu>

ALSA: usb-audio: Scarlett Gen 2 mixer interface

Add mixer quirk for the Focusrite Scarlett 6i6, 18i8, and 18i20 Gen 2
audio interfaces. Although the interfaces are USB compliant,
additional input/output level controls and hardware routing/mixing
functionality are available using proprietary USB requests.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 2acf5a3e 27-Jun-2019 Colin Ian King <colin.king@canonical.com>

ALSA: usb-audio: fix sign unintended sign extension on left shifts

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

Addresses-Coverity: ("Unintended sign extension")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 1a59d1b8 27-May-2019 Thomas Gleixner <tglx@linutronix.de>

treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156

Based on 1 normalized pattern(s):

this program is free software you can redistribute it and or modify
it under the terms of the gnu general public license as published by
the free software foundation either version 2 of the license or at
your option any later version this program is distributed in the
hope that it will be useful but without any warranty without even
the implied warranty of merchantability or fitness for a particular
purpose see the gnu general public license for more details you
should have received a copy of the gnu general public license along
with this program if not write to the free software foundation inc
59 temple place suite 330 boston ma 02111 1307 usa

extracted by the scancode license scanner the SPDX license identifier

GPL-2.0-or-later

has been chosen to replace the boilerplate/reference in 1334 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Allison Randal <allison@lohutok.net>
Reviewed-by: Richard Fontana <rfontana@redhat.com>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190527070033.113240726@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 7449054a 04-Feb-2019 Takashi Iwai <tiwai@suse.de>

ALSA: usb: Clean up with new procfs helpers

Simplify the proc fs creation code with new helper functions,
snd_card_ro_proc_new() and snd_card_rw_proc_new().
Just a code refactoring and no functional changes.

Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# d39f1d68 05-Oct-2018 Jussi Laako <jussi@sonarnerd.net>

ALSA: usb-audio: Add custom mixer status quirks for RME CC devices

Adds several vendor specific mixer quirks for RME's Class Compliant
USB devices. These provide extra status information from the device
otherwise not available.

These include AES/SPDIF rate and status information, current system
sampling rate and measured frequency. This information is especially
useful in cases where device's clock is slaved to external clock
source.

Signed-off-by: Jussi Laako <jussi@sonarnerd.net>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 00966dcd 25-Jul-2018 Takashi Iwai <tiwai@suse.de>

ALSA: usb-audio: Declare the common variable in header file

Declare snd_usb_feature_unit_ctl properly in mixer.h. Otherwise it's
error-prone.

This fixes the sparse warning:
sound/usb/mixer.c:1464:25: warning: symbol 'snd_usb_feature_unit_ctl' was not declared. Should it be static?

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 7a6fc28b 03-Jun-2018 Colin Ian King <colin.king@canonical.com>

ALSA: usb-audio: remove redundant check on err

The check on err is redundant as both the true and false paths
end up on a break statement. Remove the redundant check.

Detected by CoverityScan, CID#1268773 ("Identical code for different
branches")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# f25ecf8f 27-May-2018 Takashi Iwai <tiwai@suse.de>

ALSA: usb-audio: Follow standard coding style

Avoid if ((err = ...) style and expand to multiple lines instead.
No change in the end result, but just the beautification.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 8c558076 02-May-2018 Takashi Iwai <tiwai@suse.de>

ALSA: usb-audio: Clean up mixer element list traverse

Introduce a new macro for iterating over mixer element list for
avoiding the open codes in many places. Also the open-coded
container_of() and the forced cast to struct usb_mixer_elem_info are
replaced with another simple macro, too.

No functional changes but just readability improvement.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 964af639 27-Apr-2018 Takashi Iwai <tiwai@suse.de>

ALSA: usb-audio: Initialize Dell Dock playback volumes

In the early commit adcdd0d5a1cb ("ALSA: usb-audio: Skip volume
controls triggers hangup on Dell USB Dock"), we add the mixer quirks
for Dell dock to skip two mixer FU's for playback. This supposed that
the device has always the proper initial volume, but it doesn't seem
always correct.

This patch adds the explicit initialization of the volumes to the
fixed 0dB at the device probe time. Also, such a fixup is needed
after the resume, so a new function is hooked to the resume callback
as well.

Bugzilla: http://bugzilla.suse.com/show_bug.cgi?id=1089467
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# a9a08845 11-Feb-2018 Linus Torvalds <torvalds@linux-foundation.org>

vfs: do bulk POLL* -> EPOLL* replacement

This is the mindless scripted replacement of kernel use of POLL*
variables as described by Al, done by this script:

for V in IN OUT PRI ERR RDNORM RDBAND WRNORM WRBAND HUP RDHUP NVAL MSG; do
L=`git grep -l -w POLL$V | grep -v '^t' | grep -v /um/ | grep -v '^sa' | grep -v '/poll.h$'|grep -v '^D'`
for f in $L; do sed -i "-es/^\([^\"]*\)\(\<POLL$V\>\)/\\1E\\2/" $f; done
done

with de-mangling cleanups yet to come.

NOTE! On almost all architectures, the EPOLL* constants have the same
values as the POLL* constants do. But they keyword here is "almost".
For various bad reasons they aren't the same, and epoll() doesn't
actually work quite correctly in some cases due to this on Sparc et al.

The next patch from Al will sort out the final differences, and we
should be all done.

Scripted-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 388fdb8f 16-Jan-2018 Ian Douglas Scott <ian@iandouglasscott.com>

ALSA: usb-audio: Support changing input on Sound Blaster E1

The E1 has two headphone jacks, one of which can be set as a microphone
input. In the default mode, it uses the built-in microphone as an input.
By sending a special command, the second headphone jack is instead used
as an input.

This might work with the E3 as well, but I don't have one of those to
test it.

Signed-off-by: Ian Douglas Scott <ian@iandouglasscott.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 680ef72a 02-Jul-2017 Al Viro <viro@zeniv.linux.org.uk>

sound: annotate ->poll() instances

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>


# 0f174b35 16-Aug-2017 Takashi Iwai <tiwai@suse.de>

ALSA: usb-audio: Add mute TLV for playback volumes on C-Media devices

C-Media devices (at least some models) mute the playback stream when
volumes are set to the minimum value. But this isn't informed via TLV
and the user-space, typically PulseAudio, gets confused as if it's
still played in a low volume.

This patch adds the new flag, min_mute, to struct usb_mixer_elem_info
for indicating that the mixer element is with the minimum-mute volume.
This flag is set for known C-Media devices in
snd_usb_mixer_fu_apply_quirk() in turn.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=196669
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 905e46ac 27-May-2017 Bhumika Goyal <bhumirks@gmail.com>

ALSA: declare snd_kcontrol_new structures as const

Declare snd_kcontrol_new structures as const as they are only passed an
argument to the function snd_ctl_new1. This argument is of type const,
so snd_kcontrol_new structures having this property can be made const.
Done using Coccinelle:

@r disable optional_qualifier@
identifier x;
position p;
@@
static struct snd_kcontrol_new x@p={...};

@ok@
identifier r.x;
position p;
@@
snd_ctl_new1(&x@p,...)

@bad@
position p != {r.p,ok.p};
identifier r.x;
@@
x@p

@depends on !bad disable optional_qualifier@
identifier r.x;
@@
+const
struct snd_kcontrol_new x;

Cross compiled these files:
sound/aoa/codecs/tas.c - powerpc
sound/mips/{hal2.c/sgio2audio.c} - mips
sound/ppc/{awacs.c/beep.c/tumbler.c} - powerpc
sound/soc/sh/siu_dai.c - sh
Could not find an architecture to compile sound/sh/aica.c.

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Acked-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# d2bb390a 20-Feb-2017 Detlef Urban <onkel@paraair.de>

ALSA: usb-audio: Tascam US-16x08 DSP mixer quirk

Add mixer quirk for Tascam US-16x08 usb interface.
Even that this is an usb compliant device,
the input channels and DSP functions (EQ/Compressor) aren't accessible
by default.

Signed-off-by: Detlef Urban <onkel@paraair.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# eb1a74b7 22-Sep-2016 Anssi Hannula <anssi.hannula@iki.fi>

ALSA: usb-audio: Extend DragonFly dB scale quirk to cover other variants

The DragonFly quirk added in 42e3121d90f4 ("ALSA: usb-audio: Add a more
accurate volume quirk for AudioQuest DragonFly") applies a custom dB map
on the volume control when its range is reported as 0..50 (0 .. 0.2dB).

However, there exists at least one other variant (hw v1.0c, as opposed
to the tested v1.2) which reports a different non-sensical volume range
(0..53) and the custom map is therefore not applied for that device.

This results in all of the volume change appearing close to 100% on
mixer UIs that utilize the dB TLV information.

Add a fallback case where no dB TLV is reported at all if the control
range is not 0..50 but still 0..N where N <= 1000 (3.9 dB). Also
restrict the quirk to only apply to the volume control as there is also
a mute control which would match the check otherwise.

Fixes: 42e3121d90f4 ("ALSA: usb-audio: Add a more accurate volume quirk for AudioQuest DragonFly")
Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
Reported-by: David W <regulars@d-dub.org.uk>
Tested-by: David W <regulars@d-dub.org.uk>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 447d6275 15-Mar-2016 Takashi Iwai <tiwai@suse.de>

ALSA: usb-audio: Add sanity checks for endpoint accesses

Add some sanity check codes before actually accessing the endpoint via
get_endpoint() in order to avoid the invalid access through a
malformed USB descriptor. Mostly just checking bNumEndpoints, but in
one place (snd_microii_spdif_default_get()), the validity of iface and
altsetting index is checked as well.

Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=971125
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# c4a359a0 12-Jan-2016 Takashi Iwai <tiwai@suse.de>

ALSA: usb-audio: Fix mixer ctl regression of Native Instrument devices

The commit [da6d276957ea: ALSA: usb-audio: Add resume support for
Native Instruments controls] brought a regression where the Native
Instrument audio devices don't get the correct value at update due to
the missing shift at writing. This patch addresses it.

Fixes: da6d276957ea ('ALSA: usb-audio: Add resume support for Native Instruments controls')
Reported-and-tested-by: Owen Williams <owilliams@mixxx.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 42e3121d 13-Dec-2015 Anssi Hannula <anssi.hannula@iki.fi>

ALSA: usb-audio: Add a more accurate volume quirk for AudioQuest DragonFly

AudioQuest DragonFly DAC reports a volume control range of 0..50
(0x0000..0x0032) which in USB Audio means a range of 0 .. 0.2dB, which
is obviously incorrect and would cause software using the dB information
in e.g. volume sliders to have a massive volume difference in 100..102%
range.

Commit 2d1cb7f658fb ("ALSA: usb-audio: add dB range mapping for some
devices") added a dB range mapping for it with range 0..50 dB.

However, the actual volume mapping seems to be neither linear volume nor
linear dB scale, but instead quite close to the cubic mapping e.g.
alsamixer uses, with a range of approx. -53...0 dB.

Replace the previous quirk with a custom dB mapping based on some basic
output measurements, using a 10-item range TLV (which will still fit in
alsa-lib MAX_TLV_RANGE_SIZE).

Tested on AudioQuest DragonFly HW v1.2. The quirk is only applied if the
range is 0..50, so if this gets fixed/changed in later HW revisions it
will no longer be applied.

v2: incorporated Takashi Iwai's suggestion for the quirk application
method

Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# e87359ef 28-Sep-2015 Dan Carpenter <dan.carpenter@oracle.com>

ALSA: usb-audio: harmless underflow in snd_audigy2nx_led_put()

We want to verify that "value" is either zero or one, so we test if it
is greater than one. Unfortunately, this is a signed int so it could
also be negative. I think this is harmless but it introduces a static
checker warning. Let's make "value" unsigned.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 47ab1545 25-Aug-2015 Takashi Iwai <tiwai@suse.de>

ALSA: usb-audio: Avoid nested autoresume calls

After the recent fix of runtime PM for USB-audio driver, we got a
lockdep warning like:

=============================================
[ INFO: possible recursive locking detected ]
4.2.0-rc8+ #61 Not tainted
---------------------------------------------
pulseaudio/980 is trying to acquire lock:
(&chip->shutdown_rwsem){.+.+.+}, at: [<ffffffffa0355dac>] snd_usb_autoresume+0x1d/0x52 [snd_usb_audio]
but task is already holding lock:
(&chip->shutdown_rwsem){.+.+.+}, at: [<ffffffffa0355dac>] snd_usb_autoresume+0x1d/0x52 [snd_usb_audio]

This comes from snd_usb_autoresume() invoking down_read() and it's
used in a nested way. Although it's basically safe, per se (as these
are read locks), it's better to reduce such spurious warnings.

The read lock is needed to guarantee the execution of "shutdown"
(cleanup at disconnection) task after all concurrent tasks are
finished. This can be implemented in another better way.

Also, the current check of chip->in_pm isn't good enough for
protecting the racy execution of multiple auto-resumes.

This patch rewrites the logic of snd_usb_autoresume() & co; namely,
- The recursive call of autopm is avoided by the new refcount,
chip->active. The chip->in_pm flag is removed accordingly.
- Instead of rwsem, another refcount, chip->usage_count, is introduced
for tracking the period to delay the shutdown procedure. At
the last clear of this refcount, wake_up() to the shutdown waiter is
called.
- The shutdown flag is replaced with shutdown atomic count; this is
for reducing the lock.
- Two new helpers are introduced to simplify the management of these
refcounts; snd_usb_lock_shutdown() increases the usage_count, checks
the shutdown state, and does autoresume. snd_usb_unlock_shutdown()
does the opposite. Most of mixer and other codes just need this,
and simply returns an error if it receives an error from lock.

Fixes: 9003ebb13f61 ('ALSA: usb-audio: Fix runtime PM unbalance')
Reported-and-tested-by: Alexnader Kuleshov <kuleshovmail@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 3dc8523f 09-Apr-2015 Dmitry M. Fedin <dmitry.fedin@gmail.com>

ALSA: usb - Creative USB X-Fi Pro SB1095 volume knob support

Adds an entry for Creative USB X-Fi to the rc_config array in
mixer_quirks.c to allow use of volume knob on the device.
Adds support for newer X-Fi Pro card, known as "Model No. SB1095"
with USB ID "041e:3237"

Signed-off-by: Dmitry M. Fedin <dmitry.fedin@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 288673be 18-Nov-2014 Takashi Iwai <tiwai@suse.de>

ALSA: usb-audio: Add resume support for MicroII SPDIF ctls

Like the previous fixes, the mixer accessors are converted to use
usb_mixer_elem_list objects. In addition, the proper shutdown check
are put in get and put callbacks.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 0b4e9cfc 18-Nov-2014 Takashi Iwai <tiwai@suse.de>

ALSA: usb-audio: Add resume support for FTU controls

A few FTU mixer controls have the own value handling, so they have to
be rewritten to follow the support for resume callbacks. This ended
up in a fair amount of refactoring. Its own struct is now removed,
instead the values are embedded in kctl private_value totally.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# da6d2769 18-Nov-2014 Takashi Iwai <tiwai@suse.de>

ALSA: usb-audio: Add resume support for Native Instruments controls

The changes at this time are a bit more wider than previous ones.
Firstly, the NI controls didn't cache the values, so I had to
implement the caching. It's stored in bit 24 of private_value.
In addition to that, the initial values have to be read from
registers.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 25a9a4f9 18-Nov-2014 Takashi Iwai <tiwai@suse.de>

ALSA: usb-audio: Add Digidesign Mbox 1 resume support

Again another quirk fix, just convert to usb_mixer_elem_list with the
resume callback for Mbox 1 stuff.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 2bfb14c3 18-Nov-2014 Takashi Iwai <tiwai@suse.de>

ALSA: usb-audio: Add Xonar U1 resume support

This time it's about Xonar U1: add the proper resume support for
"Digital Playback Switch" element.

Also, the status is moved into kcontrol private_value from
usb_mixer_interface struct field. One more cut.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 5f503ee9 18-Nov-2014 Takashi Iwai <tiwai@suse.de>

ALSA: usb-audio: Add Emu0204 channel switch resume support

Similar as the previous fix, this adds the proper resume support to
Emu0202 "Front Jack Channels" enum mixer element.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 9cf3689b 17-Nov-2014 Takashi Iwai <tiwai@suse.de>

ALSA: usb-audio: Add audigy2nx resume support

Rewrite the code to handle LEDs on audigy2nx and co for supporting the
proper resume. A new internal helper function
add_single_ctl_with_resume() is introduced to manage the
usb_mixer_elem_list more easily.

Also while we're at it, move audigy2nx_leds[] in usb_mixer_interface
struct into the private_value of each kctl, too.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 3360b84b 18-Nov-2014 Takashi Iwai <tiwai@suse.de>

ALSA: usb-audio: Allow quirks to handle own resume and proc dump

So far, we blindly assumed that the all usb-audio mixer elements
follow the standard and apply the standard resume method for the
registered elements in the id_elems[] list. However, some quirks
really need the own resume and it's incomplete for now.

This patch enhances the resume handling in two folds:
- split some fields in struct usb_mixer_elem_info into a smaller
header struct (usb_mixer_elem_list) for keeping the minimal
information in the linked-list; the usb_mixer_elem_info embeds this
header struct instead
- add resume and dump callbacks to usb_mixer_elem_list struct to allow
quirks providing the own methods

For the standard mixer elements, these new callbacks are set to the
standard ones as default, thus there is no functional change by this
patch yet.

The dump and resume callbacks are typedef'ed for ease of later patches
using arrays of such function pointers.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 01cb156e 20-Nov-2014 Takashi Iwai <tiwai@suse.de>

ALSA: usb-audio: Use snd_usb_ctl_msg() for Native Instruments quirk

snd_nativeinstruments_control_get() uses a stack as a buffer for
usb_control_msg(), but it's basically not allowed. Replace the call
with a safer helper, snd_usb_ctl_msg(), instead.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 76b188c4 11-Nov-2014 Chris J Arges <chris.j.arges@canonical.com>

ALSA: usb-audio: Scarlett mixer interface for 6i6, 18i6, 18i8 and 18i20

This code contains the Scarlett mixer interface code that was originally
written by Tobias Hoffman and Robin Gareus. Because the device doesn't
properly implement UAC2 this code adds a mixer quirk for the device.

Changes from the original code include removing the metering code along with
dead code and comments. Compiler warnings were fixed. The code to initialize
the sampling rate was causing a crash this was fixed as discussed on the
mailing list. Error, and info messages were convered to dev_err and dev_info
interfaces. The custom scarlett_mixer_elem_info struct was replaced with the
more generic usb_mixer_elem_info to be able to recycle more code from mixer.c.

This patch also makes additional modifications based on upstream comments.
Individual control creation functions are removed and a generic
function is no used. Macros for function calls are removed to improve
readability. Hardcoded control initialization is removed. Save to HW
functionality has been removed. Strings for enums are created dynamically for
the mixer. Strings used for controls are now SNDRV_CTL_ELEM_ID_NAME_MAXLEN
length.

Signed-off-by: Chris J Arges <chris.j.arges@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# eef90451 11-Nov-2014 Chris J Arges <chris.j.arges@canonical.com>

ALSA: usb-audio: make set_*_mix_values functions public

Make the functions set_cur_mix_value and get_cur_mix_value accessible by files
that include mixer.h. In addition make usb_mixer_elem_free accessible.
This allows reuse of these functions by mixers that may require quirks.

The following summarizes the renamed functions:
- set_cur_mix_value -> snd_usb_set_cur_mix_value
- get_cur_mix_value -> snd_usb_get_cur_mix_value
- usb_mixer_elem_free -> snd_usb_mixer_elem_free

Signed-off-by: Chris J Arges <chris.j.arges@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 1a290581 11-Nov-2014 Takashi Iwai <tiwai@suse.de>

ALSA: usb-audio: Fix memory leak in FTU quirk

M-audio FastTrack Ultra quirk doesn't release the kzalloc'ed memory.
This patch adds the private_free callback to release it properly.

Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# d497a82f 11-Nov-2014 Damien Zammit <damien@zamaudio.com>

ALSA: usb-audio: Add mixer control for Digidesign Mbox 1 clock source

This patch provides the infrastructure for the Digidesign Mbox 1
to have a mixer control for selecting the clock source.
Valid options are Internal and S/PDIF external sync.
A non-documented command is sent to the device to enable this feature
found by reverse engineering and bus snooping.

Signed-off-by: Damien Zammit <damien@zamaudio.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 7bbd03e0 20-Oct-2014 Takashi Iwai <tiwai@suse.de>

ALSA: usb-audio: Use snd_ctl_enum_info()

... and reduce the open codes. Also add missing const to text arrays.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 0ba41d91 26-Feb-2014 Takashi Iwai <tiwai@suse.de>

ALSA: usb-audio: Use standard printk helpers

Convert with dev_err() and co from snd_printk(), etc.
As there are too deep indirections (e.g. ep->chip->dev->dev),
a few new local macros, usb_audio_err() & co, are introduced.

Also, the device numbers in some messages are dropped, as they are
shown in the prefix automatically.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 18e4753f 05-Dec-2013 Mikulas Patocka <mpatocka@redhat.com>

ALSA: usb-audio: fix uninitialized variable compile warning

Fix the following warning when optimizing for size with gcc-4.6.4:
sound/usb/mixer_quirks.c:1514:6: warning: 'err' may be used uninitialized in this function [-Wuninitialized]

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 44832a71 13-Nov-2013 Vasily Khoruzhick <anarsoul@gmail.com>

ALSA: usb-audio: add front jack channel selector for EMU0204

Add support for front jack channel selector which is present on EMU0204.
It allows to get 4 channels out of this soundcard.

Tested-by: Yury Bushmelev <jay@jay-tech.ru>
Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 066624c6 27-Jun-2013 Przemek Rudy <prudy1@o2.pl>

ALSA: usb-audio: Add Audio Advantage Micro II

This patch is adding extensive support (beside standard usb audio class)
for Audio Advantage Micro II usb sound card.
Features included:
- Access to AES bits (so now sending the IEC61937 compliant stream is
possible).
- Mixer SPDIF control added to turn on/off the optical transmitter.

Signed-off-by: Przemek Rudy <prudy1@o2.pl>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 889d6684 05-Apr-2013 Eldad Zack <eldad@fogrefinery.com>

ALSA: usb-audio: fix endianness bug in snd_nativeinstruments_*

The usb_control_msg() function expects __u16 types and performs
the endianness conversions by itself.
However, in three places, a conversion is performed before it is
handed over to usb_control_msg(), which leads to a double conversion
(= no conversion):
* snd_usb_nativeinstruments_boot_quirk()
* snd_nativeinstruments_control_get()
* snd_nativeinstruments_control_put()

Caught by sparse:

sound/usb/mixer_quirks.c:512:38: warning: incorrect type in argument 6 (different base types)
sound/usb/mixer_quirks.c:512:38: expected unsigned short [unsigned] [usertype] index
sound/usb/mixer_quirks.c:512:38: got restricted __le16 [usertype] <noident>
sound/usb/mixer_quirks.c:543:35: warning: incorrect type in argument 5 (different base types)
sound/usb/mixer_quirks.c:543:35: expected unsigned short [unsigned] [usertype] value
sound/usb/mixer_quirks.c:543:35: got restricted __le16 [usertype] <noident>
sound/usb/mixer_quirks.c:543:56: warning: incorrect type in argument 6 (different base types)
sound/usb/mixer_quirks.c:543:56: expected unsigned short [unsigned] [usertype] index
sound/usb/mixer_quirks.c:543:56: got restricted __le16 [usertype] <noident>
sound/usb/quirks.c:502:35: warning: incorrect type in argument 5 (different base types)
sound/usb/quirks.c:502:35: expected unsigned short [unsigned] [usertype] value
sound/usb/quirks.c:502:35: got restricted __le16 [usertype] <noident>

Signed-off-by: Eldad Zack <eldad@fogrefinery.com>
Acked-by: Daniel Mack <zonque@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# e9a25e04 08-Feb-2013 Matt Gruskin <matthew.gruskin@gmail.com>

ALSA: usb-audio: add support for M-Audio FT C600

Adds quirks and mixer support for the M-Audio Fast Track C600 USB
audio interface. This device is very similar to the C400 - the C600
simply has some more inputs and outputs, so the existing C400 support
is extended to support this device as well.

Signed-off-by: Matt Gruskin <matthew.gruskin@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# e8e7da23 09-Jan-2013 Sachin Kamat <sachin.kamat@linaro.org>

ALSA: usb-audio: Make ebox44_table static

Fixes the following sparse warning:
sound/usb/mixer_quirks.c:1209:23: warning:
symbol 'ebox44_table' was not declared. Should it be static?

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 1d31affb 11-Dec-2012 Denis Washington <denisw@online.de>

ALSA: usb-audio: Enable S/PDIF on the ASUS Xonar U3

The only required change is to extend the existing Xonar U1
mixer quirks to the U3, which seems to be controlled the same
way.

Signed-off-by: Denis Washington <denisw@online.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 09d8e3a7 28-Nov-2012 Eldad Zack <eldad@fogrefinery.com>

ALSA: usb-audio: Fast Track C400 mixer controls

Add a mixer quirks for the M-Audio Fast Track C400
and create the following:

* Volume controls
* Effect Type (reusing FTU controls)
* Effect Volume
* Effect Send/Return
* Effect Program
* Effect Feedback

Signed-off-by: Eldad Zack <eldad@fogrefinery.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# d847ce0e 28-Nov-2012 Eldad Zack <eldad@fogrefinery.com>

ALSA: usb-audio: parameterize FTU effect unit control

Adds the unit ID and the control as parameters to the creation of the
effect unit control for the M-Audio Fast Track Ultra. This allows the
code to be shared with other devices that use different unit ID and
control, such as the M-Audio Fast Track C400.

Signed-off-by: Eldad Zack <eldad@fogrefinery.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 9f814105 28-Nov-2012 Eldad Zack <eldad@fogrefinery.com>

ALSA: usb-audio: add control index offset

Currently, channel IDs exceeding 31 (0x1f) cannot be used.
The channel ID is derived from the cmask. Extending cmask
to a 64-bit type would only allow it to go up to 63 (0x3f).
Some devices have channel IDs exceeding that as well.
To address that, add an offset to the mixer element which
is then accounted for in the UAC set/get functions.

Signed-off-by: Eldad Zack <eldad@fogrefinery.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 888ea7d5 14-Oct-2012 Takashi Iwai <tiwai@suse.de>

ALSA: usb-audio: Fix races at disconnection in mixer_quirks.c

Similar like the previous commit, cover with chip->shutdown_rwsem
and chip->shutdown checks.

Reported-by: Matthieu CASTET <matthieu.castet@parrot.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 989b0138 09-Jun-2012 Mark Hills <mark@pogo.org.uk>

ALSA: usb-audio: Convert table to preferred C99 format

Signed-off-by: Mark Hills <mark@pogo.org.uk>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# b71dad18 09-Jun-2012 Mark Hills <mark@pogo.org.uk>

ALSA: usb-audio: Use a table of mixer controls

Allow mixer controls to be provided clearly in a table, to avoid
quantity of error checking at each use.

Signed-off-by: Mark Hills <mark@pogo.org.uk>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 7df4a691 11-May-2012 Mark Hills <mark@pogo.org.uk>

ALSA: usb-audio: Fix comment

Explained by Takashi in <s5hfwbtmz0q.wl%tiwai@suse.de>

> The reason is because get_min_max*() isn't called in the place you
> created these controls, and get_min_max() would be called only for
> integer volumes later even if uninitialized. A short cut for booleans.

Signed-off-by: Mark Hills <mark@pogo.org.uk>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# baba2e0d 24-Apr-2012 Takashi Iwai <tiwai@suse.de>

ALSA: usb-audio: Add missing error checks in snd_ebox44_create_mixer()

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# d34bf148 23-Apr-2012 Felix Homann <linuxaudio@showlabor.de>

ALSA: usb-audio: M-Audio Fast Track Ultra: Add effect controls

This adds controls for the effects section on the FTU devices.
Some of these controls need volume quirks. They are added to
mixer.c.

[fixed missing break by tiwai]

Signed-off-by: Felix Homann <linuxaudio@showlabor.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# cfe8f97c 23-Apr-2012 Felix Homann <linuxaudio@showlabor.de>

ALSA: usb-audio: Rename Fast Track Ultra mixer quirk functions

This is in preparation for more FTU controls to come.
Should help keeping names a bit shorter.

Signed-off-by: Felix Homann <linuxaudio@showlabor.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 25ee7ef8 23-Apr-2012 Felix Homann <linuxaudio@showlabor.de>

ALSA: usb-audio: Add TLV to M-Audio Fast Track Ultra controls

This adds db gain information to M-Audio Fast Track Ultra (8R) devices.

Signed-off-by: Felix Homann <linuxaudio@showlabor.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 8a4d1d39 23-Apr-2012 Felix Homann <linuxaudio@showlabor.de>

ALSA: usb-audio: Unify M-Audio Fast Track Ultra and Ebox-44 mixer quirks.

Merge snd_maudio_ftu_create_ctl() and snd_ebox44_create_ctl() into
snd_create_std_mono_ctl().
As opposed to the ftu and ebox-44 specific functions, a TLV callback
can be specified for controls created by snd_create_std_mono_ctl().

[fixed minor checkpatch.pl warnings by tiwai]

Signed-off-by: Felix Homann <linuxaudio@showlabor.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 7536c301 14-Apr-2012 Mark Hills <mark@pogo.org.uk>

ALSA: snd-usb-audio: Replace mixer for Electrix Ebox-44

The mixer units from the firmware are corrupt, and even where they
are valid they presents mono controls as L and R channels of
stereo.

Signed-off-by: Mark Hills <mark@pogo.org.uk>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 17d900c4 26-Sep-2011 Clemens Ladisch <clemens@ladisch.de>

ALSA: usb-audio: increase control transfer timeout

There are certain devices that are reportedly so slow that they need
more than 100 ms to handle control transfers. Therefore, increase the
timeout in mixer(_quirks).c to 1000 ms.

The timeout parameter of snd_usb_ctl_msg() is now constant, so we can
drop it.

Reported-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# d5a0bf6c 25-May-2011 Daniel Mack <zonque@gmail.com>

ALSA: usb-audio: more control quirks for M-Audio FastTrack devices

Make use of the freshly introduced methods to re-use standard mixer
handling and add some controls that are hidden but implemented in a
standard conform way on M-Audio's FastTrack devices.

Signed-off-by: Daniel Mack <zonque@gmail.com>
Original-code-by: Felix Homann <linuxaudio@showlabor.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 7cdd8d73 18-May-2011 Mathieu Bouffard <mbouffard@strangequarks.org>

ALSA: usb-audio - Add support for USB X-Fi S51 Pro

USB X-Fi S51 Pro volume and mute from the volume knob on the unit.
Compiled and tested with 2.6.39-rc7-git12

Signed-off-by: Mathieu Bouffard <mbouffard@strangequarks.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 759e890f 18-May-2011 Daniel Mack <zonque@gmail.com>

ALSA: usb-audio: remove invalid extra mixers for Komplete Audio 6

This was a flaw in the reading of the spec tables - Native Instrument's
"Komplete Audio 6" device has no such extra controls.

This patch also fixes the device name in two comments.

Signed-off-by: Daniel Mack <zonque@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 9cdc3529 11-Apr-2011 Daniel Mack <zonque@gmail.com>

ALSA: usb-audio: Add quirks for Audio Kontrol 6

This new device by Native Instruments is also compliant to the USB
standard v2.0, but hides this detail at when connected.

It needs the same boot quirks than other models, and also has two
non-class-compliant mixer controls.

Signed-off-by: Daniel Mack <zonque@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 3347b26c 11-Feb-2011 Daniel Mack <daniel@caiaq.de>

ALSA: usb-audio: reconstruct some dispatcher functions to use switch-case

The number of cases has increased so use switch-case rather than
if-statements.

Signed-off-by: Daniel Mack <daniel@caiaq.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 54a8c500 11-Feb-2011 Daniel Mack <daniel@caiaq.de>

ALSA: usb-audio: add support for Native Instruments MK2 devices

The MK2 generation of Native Instruments' sound cards are in fact
compliant to the USB audio standard of version 2 and other approved USB
standards. However, they come up as vendor-specific device when first
connected but can be told to come up with a new set of descriptors
upon their next enumeration. The interfaces announced by the new
descriptors will be handled by the kernel's class drivers. This is done
by issuing a vendor specific device request and sending the device to
reset.

There are also some vendor-specific USB requests for some mixer elements
that can't be exported in a standard compliant way. The driver now
supports them with quirks handling mechanisms.

Signed-off-by: Daniel Mack <daniel@caiaq.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# ca8dc34e 02-Nov-2010 Mandar Joshi <emailmandar@gmail.com>

ALSA: usb-audio - Support for Power/Status LED on Creative USB X-Fi S51

This patch adds support for Power/Status LED on Creative USB X-Fi S51.
There is just one LED on the device. The LED can either be On or it
can be set to Blink. There doesn't seem to be a way to switch it off.
The control message to change LED status is similar to that of
audigy2nx except that the index is to be set to 0 and value is 1 for
Blink and 0 for On.

The 'Power LED' control in alsamixer when muted will cause the LED to
Blink continuously. When unmuted the LED will stay On. The Creative
driver under Windows sets the LED to blink whenever audio is muted.
This LED can be treated as the CMSS LED but I figured since there is
just one LED, it should be treated as the Power LED. Is that alright?

I've also changed the comment "Usb X-Fi" to "Usb X-Fi S51" as there
are other external X-Fi devices from Creative like Usb X-Fi Go and
Xmod. The volume knob and LED support patch doesn't apply to them.

Signed-off-by: Mandar Joshi <emailmandar@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 97c44b2d 23-Oct-2010 Mandar Joshi <emailmandar@gmail.com>

ALSA: usb - Creative USB X-Fi volume knob support

Adds an entry for Creative USB X-Fi to the rc_config array in
mixer_quirks.c to allow use of volume knob on the device.
The action of the volume knob is received by lirc when its using the
alsa_usb driver.

Signed-off-by: Mandar Joshi <emailmandar@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 36db0456 28-Mar-2010 Stephen Rothwell <sfr@canb.auug.org.au>

ALSA: usb - use of kmalloc/kfree requires the include of slab.h

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# f0b5e634 11-Mar-2010 Daniel Mack <daniel@caiaq.de>

ALSA: usbmixer: rename usbmixer.[ch] -> mixer.[ch]

For clearer namespace, also rename usbmixer_maps.c -> mixer_maps.c

Signed-off-by: Daniel Mack <daniel@caiaq.de>
Cc: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 7b1eda22 11-Mar-2010 Daniel Mack <daniel@caiaq.de>

ALSA: usb-mixer: factor out quirks

Move all non-standard mixer controls and vendor-specific extensions to a
separate file. Some structs need to be exported now.

Signed-off-by: Daniel Mack <daniel@caiaq.de>
Cc: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>