08 Jun, 2012

1 commit

  • In 3.5 kernel, the endpoint is assigned dynamically for the
    substreams, but the PCM assignment still checks the presence of the
    endpoint pointer. This ended up in duplicated PCM substream creations
    at probing time, resulting in kernel warnings like:

    WARNING: at fs/proc/generic.c:586 proc_register+0x169/0x1a6()
    Pid: 1152, comm: modprobe Not tainted 3.5.0-rc1-00110-g71fae7e #2
    Call Trace:
    [] warn_slowpath_common+0x83/0x9c
    [] warn_slowpath_fmt+0x46/0x48
    [] ? add_preempt_count+0x39/0x3b
    [] proc_register+0x169/0x1a6
    [] create_proc_entry+0x74/0x8c
    [] snd_info_register+0x3e/0xc3 [snd]
    [] snd_pcm_new_stream+0xb1/0x404 [snd_pcm]
    [] snd_usb_add_audio_stream+0xd2/0x230 [snd_usb_audio]
    [] ? snd_usb_parse_audio_format+0x252/0x34f [snd_usb_audio]
    [] ? kmem_cache_alloc_trace+0xab/0xbb
    [] snd_usb_parse_audio_interface+0x4ac/0x567 [snd_usb_audio]
    [] snd_usb_create_stream+0xe9/0x125 [snd_usb_audio]
    [] usb_audio_probe+0x62a/0x72c [snd_usb_audio]
    .....

    This patch fixes the regression by checking the fixed endpoint number
    for each substream instead of the endpoint pointer.

    Reported-and-tested-by: Jamie Heilman
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

21 Apr, 2012

1 commit


13 Apr, 2012

3 commits

  • Many fields have been moved to struct snd_usb_endpoint.
    Also fix the proc output to correspond to the new structure.

    Signed-off-by: Takashi Iwai

    Takashi Iwai
     
  • With the previous commit that added the new streaming model, all
    endpoint and streaming related code is now in endpoint.c, and pcm.c
    only acts as a wrapper for handling the packet's payload.

    Signed-off-by: Daniel Mack
    Signed-off-by: Takashi Iwai

    Daniel Mack
     
  • This patch adds a new generic streaming logic for audio over USB.

    It defines a model (snd_usb_endpoint) that handles everything that
    is related to an USB endpoint and its streaming. There are functions to
    activate and deactivate an endpoint (which call usb_set_interface()),
    and to start and stop its URBs. It also has function pointers to be
    called when data was received or is about to be sent, and pointer to
    a sync slave (another snd_usb_endpoint) that is informed when data has
    been received.

    A snd_usb_endpoint knows about its state and implements a refcounting,
    so only the first user will actually start the URBs and only the last
    one to stop it will tear them down again.

    With this sort of abstraction, the actual streaming is decoupled from
    the pcm handling, which makes the "implicit feedback" mechanisms easy to
    implement.

    In order to split changes properly, this patch only adds the new
    implementation but leaves the old one around, so the the driver doesn't
    change its behaviour. The switch to actually use the new code is
    submitted separately.

    Signed-off-by: Daniel Mack
    Signed-off-by: Takashi Iwai

    Daniel Mack
     

15 Feb, 2012

1 commit

  • A malicious USB device could feed in a large nr_rates value. This would
    cause the subsequent call to kmemdup() to allocate a smaller buffer than
    expected, leading to out-of-bounds access.

    This patch validates the nr_rates value and reuses the limit introduced
    in commit 4fa0e81b ("ALSA: usb-audio: fix possible hang and overflow
    in parse_uac2_sample_rate_range()").

    Signed-off-by: Xi Wang
    Signed-off-by: Takashi Iwai

    Xi Wang
     

12 Sep, 2011

1 commit

  • Existing code only updates the audio delay when URBs were
    submitted/retired. This can introduce an uncertainty of 8ms
    on the number of samples played out with the default settings,
    and a lot more when URBs convey more packets to reduce the
    interrupt rate and power consumption.

    This patch relies on the USB frame counter to reduce the
    uncertainty to less than 2ms worst-case. The delay information
    essentially becomes independent of the URB size and number of
    packets. This should help applications like PulseAudio which
    require accurate audio timing. Clemens Ladisch reported
    a decrease of mplayer's A-V difference from nrpacks down to at
    most 1ms.

    Thanks to Clemens for also pointing out that the implementation
    of frame counters varies between different HCDs. Only the
    8 lowest-bits are used to estimate the delay.

    Signed-off-by: Pierre-Louis Bossart
    [clemens: changed debug code]
    Signed-off-by: Clemens Ladisch
    Signed-off-by: Takashi Iwai

    Pierre-Louis Bossart
     

27 Oct, 2010

1 commit

  • There are two USB Audio Class specifications (v1 and v2), but neither of
    them clearly defines the feedback format for high-speed UAC v1 devices.
    Add to this whatever the Creative and M-Audio firmware writers have been
    smoking, and it becomes impossible to predict the exact feedback format
    used by a particular device.

    Therefore, automatically detect the feedback format by looking at the
    magnitude of the first received feedback value.

    Also, this allows us to get rid of some special cases for E-Mu devices.

    Signed-off-by: Clemens Ladisch
    Signed-off-by: Takashi Iwai

    Clemens Ladisch
     

01 Jun, 2010

1 commit

  • Audio devices which comply to the UAC2 standard can export complex clock
    topologies in its descriptors and set up links between them.

    The entities that are defined are

    - clock sources, which define the end-leafs.
    - clock selectors, which act as switch to select one out of many
    possible clocks sources.
    - clock multipliers, which have an input clock source, and act as clock
    source again. They can be used to derive one clock from another.

    All sample rate changes, clock validity queries and the like must go to
    clock source elements, while clock selectors and multipliers can be used
    as terminal clock source.

    The following patch adds a parser for these elements and functions to
    iterate over the tree and find the leaf nodes (clock sources).

    The samplerate set functions were moved to the new clock.c file.

    Signed-off-by: Daniel Mack
    Signed-off-by: Takashi Iwai

    Daniel Mack
     

05 Mar, 2010

3 commits

  • In preparation for USB audio 2.0 support, change the audioformat
    structure so that it uses a bitmask to specify possible formats.

    Signed-off-by: Clemens Ladisch
    Signed-off-by: Takashi Iwai

    Clemens Ladisch
     
  • The snd_usb_substream::format field actually contains the index of the
    current alternate setting, so rename it to altset_idx to avoid
    confusion.

    Signed-off-by: Clemens Ladisch
    Signed-off-by: Takashi Iwai

    Clemens Ladisch
     
  • Clean up the usb audio driver by factoring out a lot of functions to
    separate files. Code for procfs, quirks, urbs, format parsers etc all
    got a new home now.

    Moved almost all special quirk handling to quirks.c and introduced new
    generic functions to handle them, so the exceptions do not pollute the
    whole driver.

    Renamed usbaudio.c to card.c because this is what it actually does now.
    Renamed usbmidi.c to midi.c for namespace clarity.
    Removed more things from usbaudio.h.

    The non-standard drivers were adopted accordingly.

    Signed-off-by: Daniel Mack
    Cc: Clemens Ladisch
    Signed-off-by: Takashi Iwai

    Daniel Mack