23 Sep, 2020

1 commit


07 Aug, 2020

1 commit


24 Jun, 2020

1 commit

  • 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:
    Link: https://lore.kernel.org/r/20200624122340.9615-1-tiwai@suse.de
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

30 May, 2020

1 commit

  • 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
    Reported-by: kbuild test robot
    Link: https://lore.kernel.org/r/20200529173248.zzawijfvw73kzjxt@bollie.ca9.eu
    Signed-off-by: Takashi Iwai

    Thomas Ebeling
     

15 May, 2020

1 commit


24 Apr, 2020

1 commit


23 Apr, 2020

1 commit

  • 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
    Signed-off-by: Xin Tan
    Cc:
    Link: https://lore.kernel.org/r/1587617711-13200-1-git-send-email-xiyuyang19@fudan.edu.cn
    Signed-off-by: Takashi Iwai

    Xiyu Yang
     

15 Apr, 2020

1 commit


15 Feb, 2020

1 commit

  • 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
    Link: https://lore.kernel.org/r/5e47481a.1c69fb81.befb3.8dac@mx.google.com
    Signed-off-by: Takashi Iwai

    Nick Kossifidis
     

12 Jan, 2020

1 commit

  • 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
    Link: https://lore.kernel.org/r/20200111214736.3002-3-pierre-louis.bossart@linux.intel.com
    Signed-off-by: Takashi Iwai

    Pierre-Louis Bossart
     

05 Jan, 2020

1 commit

  • 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

    Takashi Iwai
     

03 Jan, 2020

1 commit

  • 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

    Takashi Iwai
     

22 Aug, 2019

1 commit


21 Aug, 2019

1 commit

  • 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:
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

28 Jul, 2019

1 commit

  • 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
    Signed-off-by: Takashi Iwai

    Geoffrey D. Bennett
     

08 Jul, 2019

1 commit

  • …/sound into for-linus

    ASoC: Updates for v5.3

    This is a very big update, mainly thanks to Morimoto-san's refactoring
    work and some fairly large new drivers.

    - Lots more work on moving towards a component based framework from
    Morimoto-san.
    - Support for force disconnecting muxes from Jerome Brunet.
    - New drivers for Cirrus Logic CS47L35, CS47L85 and CS47L90, Conexant
    CX2072X, Realtek RT1011 and RT1308.

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

    Takashi Iwai
     

28 Jun, 2019

1 commit

  • 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
    Cc:
    Signed-off-by: Takashi Iwai

    Colin Ian King
     

31 May, 2019

1 commit

  • 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
    Reviewed-by: Allison Randal
    Reviewed-by: Richard Fontana
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190527070033.113240726@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

07 Feb, 2019

1 commit


05 Oct, 2018

1 commit

  • 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
    Signed-off-by: Takashi Iwai

    Jussi Laako
     

26 Jul, 2018

1 commit


04 Jun, 2018

1 commit


28 May, 2018

1 commit


03 May, 2018

1 commit

  • 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

    Takashi Iwai
     

02 May, 2018

1 commit

  • 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

    Takashi Iwai
     

12 Feb, 2018

1 commit

  • 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/^\([^\"]*\)\(\\)/\\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
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

31 Jan, 2018

1 commit

  • Pull poll annotations from Al Viro:
    "This introduces a __bitwise type for POLL### bitmap, and propagates
    the annotations through the tree. Most of that stuff is as simple as
    'make ->poll() instances return __poll_t and do the same to local
    variables used to hold the future return value'.

    Some of the obvious brainos found in process are fixed (e.g. POLLIN
    misspelled as POLL_IN). At that point the amount of sparse warnings is
    low and most of them are for genuine bugs - e.g. ->poll() instance
    deciding to return -EINVAL instead of a bitmap. I hadn't touched those
    in this series - it's large enough as it is.

    Another problem it has caught was eventpoll() ABI mess; select.c and
    eventpoll.c assumed that corresponding POLL### and EPOLL### were
    equal. That's true for some, but not all of them - EPOLL### are
    arch-independent, but POLL### are not.

    The last commit in this series separates userland POLL### values from
    the (now arch-independent) kernel-side ones, converting between them
    in the few places where they are copied to/from userland. AFAICS, this
    is the least disruptive fix preserving poll(2) ABI and making epoll()
    work on all architectures.

    As it is, it's simply broken on sparc - try to give it EPOLLWRNORM and
    it will trigger only on what would've triggered EPOLLWRBAND on other
    architectures. EPOLLWRBAND and EPOLLRDHUP, OTOH, are never triggered
    at all on sparc. With this patch they should work consistently on all
    architectures"

    * 'misc.poll' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (37 commits)
    make kernel-side POLL... arch-independent
    eventpoll: no need to mask the result of epi_item_poll() again
    eventpoll: constify struct epoll_event pointers
    debugging printk in sg_poll() uses %x to print POLL... bitmap
    annotate poll(2) guts
    9p: untangle ->poll() mess
    ->si_band gets POLL... bitmap stored into a user-visible long field
    ring_buffer_poll_wait() return value used as return value of ->poll()
    the rest of drivers/*: annotate ->poll() instances
    media: annotate ->poll() instances
    fs: annotate ->poll() instances
    ipc, kernel, mm: annotate ->poll() instances
    net: annotate ->poll() instances
    apparmor: annotate ->poll() instances
    tomoyo: annotate ->poll() instances
    sound: annotate ->poll() instances
    acpi: annotate ->poll() instances
    crypto: annotate ->poll() instances
    block: annotate ->poll() instances
    x86: annotate ->poll() instances
    ...

    Linus Torvalds
     

18 Jan, 2018

1 commit

  • 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
    Signed-off-by: Takashi Iwai

    Ian Douglas Scott
     

28 Nov, 2017

1 commit


17 Aug, 2017

1 commit

  • 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:
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

30 May, 2017

1 commit

  • 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
    Acked-by: Mark Brown
    Signed-off-by: Takashi Iwai

    Bhumika Goyal
     

20 Feb, 2017

1 commit


23 Sep, 2016

1 commit

  • 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
    Reported-by: David W
    Tested-by: David W
    Cc:
    Signed-off-by: Takashi Iwai

    Anssi Hannula
     

16 Mar, 2016

1 commit

  • 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:
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

13 Jan, 2016

1 commit

  • 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
    Cc:
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

14 Dec, 2015

1 commit

  • 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
    Cc:
    Signed-off-by: Takashi Iwai

    Anssi Hannula
     

28 Sep, 2015

1 commit


26 Aug, 2015

1 commit

  • 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: [] snd_usb_autoresume+0x1d/0x52 [snd_usb_audio]
    but task is already holding lock:
    (&chip->shutdown_rwsem){.+.+.+}, at: [] 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
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

09 Apr, 2015

1 commit


21 Nov, 2014

1 commit