1. 28 5月, 2018 3 次提交
  2. 17 5月, 2018 1 次提交
  3. 02 5月, 2018 2 次提交
    • T
      ALSA: usb-audio: Add keep_iface flag · 8a463225
      Takashi Iwai 提交于
      Introduce a new flag to struct snd_usb_audio for allowing the device
      to skip usb_set_interface() calls at changing or closing the stream.
      As of this patch, the flag is nowhere set, so it's just a place
      holder.  The dynamic switching will be added in the following patch.
      
      A background information for this change:
      
      Dell WD15 dock with Realtek chip gives a very long pause at each time
      the driver changes the altset, which eventually happens at every PCM
      stream open/close and parameter change.  As the long pause happens in
      each usb_set_interface() call, there is nothing we can do as long as
      it's called.  The workaround is to reduce calling it as much as
      possible, and this flag indicates that behavior.
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      8a463225
    • T
      ALSA: usb-audio: Avoid superfluous usb_set_interface() calls · b099b969
      Takashi Iwai 提交于
      This is a preliminary change for the upcoming quirk implementation.
      
      Currently USB-audio driver tries to call usb_set_interface() whenever
      the format change with interface/altset modification happens.  In this
      patch, the check is replaced with the comparison of cur_altsetting and
      the targeted altsetting pointer, so that the driver may skip the
      unnecessary function calls.
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      b099b969
  4. 19 4月, 2018 2 次提交
  5. 12 2月, 2018 1 次提交
  6. 19 8月, 2017 1 次提交
  7. 17 8月, 2017 1 次提交
  8. 05 1月, 2017 1 次提交
    • I
      ALSA: usb-audio: Fix irq/process data synchronization · 1d0f9530
      Ioan-Adrian Ratiu 提交于
      Commit 16200948 ("ALSA: usb-audio: Fix race at stopping the stream") was
      incomplete causing another more severe kernel panic, so it got reverted.
      This fixes both the original problem and its fallout kernel race/crash.
      
      The original fix is to move the endpoint member NULL clearing logic inside
      wait_clear_urbs() so the irq triggering the urb completion doesn't call
      retire_capture/playback_urb() after the NULL clearing and generate a panic.
      
      However this creates a new race between snd_usb_endpoint_start()'s call
      to wait_clear_urbs() and the irq urb completion handler which again calls
      retire_capture/playback_urb() leading to a new NULL dereference.
      
      We keep the EP deactivation code in snd_usb_endpoint_start() because
      removing it will break the EP reference counting (see [1] [2] for info),
      however we don't need the "can_sleep" mechanism anymore because a new
      function was introduced (snd_usb_endpoint_sync_pending_stop()) which
      synchronizes pending stops and gets called inside the pcm prepare callback.
      
      It also makes sense to remove can_sleep because it was also removed from
      deactivate_urbs() signature in [3] so we benefit from more simplification.
      
      [1] commit 015618b9 ("ALSA: snd-usb: Fix URB cancellation at stream start")
      [2] commit e9ba389c ("ALSA: usb-audio: Fix scheduling-while-atomic bug in PCM capture stream")
      [3] commit ccc1696d ("ALSA: usb-audio: simplify endpoint deactivation code")
      
      Fixes: f8114f85 ("Revert "ALSA: usb-audio: Fix race at stopping the stream"")
      Signed-off-by: NIoan-Adrian Ratiu <adi@adirat.com>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      1d0f9530
  9. 09 12月, 2016 1 次提交
  10. 06 12月, 2016 1 次提交
  11. 01 4月, 2016 1 次提交
  12. 16 3月, 2016 1 次提交
  13. 04 3月, 2016 1 次提交
  14. 19 10月, 2015 4 次提交
    • R
      ALSA: USB-audio: Add quirk for Zoom R16/24 playback · e0570446
      Ricard Wanderlof 提交于
      The Zoom R16/24 have a nonstandard playback format where each isochronous
      packet contains a length descriptor in the first four bytes. (Curiously,
      capture data does not contain this and requires no quirk.)
      
      The quirk involves adding the extra length descriptor whenever outgoing
      isochronous packets are generated, both in pcm.c (outgoing audio) and
      endpoint.c (silent data).
      
      In order to make the quirk as unintrusive as possible, for
      pcm.c:prepare_playback_urb(), the isochronous packet descriptors are
      initially set up in the same way no matter if the quirk is enabled or not.
      Once it is time to actually copy the data into the outgoing packet buffer
      (together with the added length descriptors) the isochronous descriptors
      are adjusted in order take the increased payload length into account.
      
      For endpoint.c:prepare_silent_urb() it makes more sense to modify the
      actual function, partly because the function is less complex to start with
      and partly because it is not as time-critical as prepare_playback_urb()
      (whose bulk is run with interrupts disabled), so the (minute) additional
      time spent in the non-quirk case is motivated by the simplicity of having
      a single function for all cases.
      
      The quirk is controlled by the new tx_length_quirk member in struct
      snd_usb_substream and struct snd_usb_audio, which is conveyed to pcm.c
      and endpoint.c from quirks.c in a similar manner to the txfr_quirk member
      in the same structs.
      
      In contrast to txfr_quirk however, the quirk is enabled directly in
      quirks.c:create_standard_audio_quirk() by checking the USB ID in that
      function. Another option would be to introduce a new
      QUIRK_AUDIO_ZOOM_INTERFACE or somesuch, which would have made the quirk
      very plain to see in the quirk table, but it was felt that the additional
      code needed to implement it this way would just make the implementation
      more complex with no real gain.
      
      Tested with a Zoom R16, both by doing capture and playback separately
      using arecord and aplay (8 channel capture and 2 channel playback,
      respectively), as well as capture and playback together using Ardour, as
      well as Audacity and Qtractor together with jackd.
      
      The R24 is reportedly compatible with the R16 when used as an audio
      interface. Both devices share the same USB ID and have the same number of
      inputs (8) and outputs (2). Therefore "R16/24" is mentioned throughout the
      patch.
      
      Regression tested using an Edirol UA-5 in both class compliant (16-bit)
      and "advanced" (24 bit, forces the use of quirks) modes.
      Signed-off-by: NRicard Wanderlof <ricardw@axis.com>
      Tested-by: NPanu Matilainen <pmatilai@laiskiainen.org>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      e0570446
    • R
      ALSA: USB-audio: Add offset parameter to copy_to_urb() · b97a9369
      Ricard Wanderlof 提交于
      Preparation for adding Zoom R16/24 quirk.
      No functional change.
      Signed-off-by: NRicard Wanderlof <ricardw@axis.com>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      b97a9369
    • R
      ALSA: USB-audio: Also move out hwptr_done wrap from prepare_playback_urb() · 4c4e4391
      Ricard Wanderlof 提交于
      Refactoring in preparation for adding Zoom R16/24 quirk.
      No functional change.
      Signed-off-by: NRicard Wanderlof <ricardw@axis.com>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      4c4e4391
    • R
      ALSA: USB-audio: Break out copying to urb from prepare_playback_urb() · 07a40c2f
      Ricard Wanderlof 提交于
      Refactoring in preparation for adding Zoom R16/24 quirk.
      No functional change.
      Signed-off-by: NRicard Wanderlof <ricardw@axis.com>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      07a40c2f
  15. 26 8月, 2015 1 次提交
    • T
      ALSA: usb-audio: Avoid nested autoresume calls · 47ab1545
      Takashi Iwai 提交于
      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: 9003ebb1 ('ALSA: usb-audio: Fix runtime PM unbalance')
      Reported-and-tested-by: NAlexnader Kuleshov <kuleshovmail@gmail.com>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      47ab1545
  16. 16 8月, 2015 2 次提交
    • P
      ALSA: usb: handle descriptor with SYNC_NONE illegal value · 395ae54b
      Pierre-Louis Bossart 提交于
      The M-Audio Transit exposes an interface with a SYNC_NONE attribute.
      This is not a valid value according to the USB audio classspec. However
      there is a sync endpoint associated to this record. Changing the logic to
      try to use this sync endpoint allows for seamless transitions between
      altset 2 and altset 3. If any errors happen, the behavior remains the same.
      
      $ more /proc/asound/card1/stream0
      M-Audio Transit USB at usb-0000:00:14.0-2, full speed : USB Audio
      
      Playback:
        Status: Stop
        Interface 1
          Altset 1
          Format: S24_3LE
          Channels: 2
          Endpoint: 3 OUT (ADAPTIVE)
          Rates: 48001 - 96000 (continuous)
        Interface 1
          Altset 2
          Format: S24_3LE
          Channels: 2
          Endpoint: 3 OUT (NONE)
          Rates: 8000 - 48000 (continuous)
        Interface 1
          Altset 3
          Format: S16_LE
          Channels: 2
          Endpoint: 3 OUT (ASYNC)
          Rates: 8000 - 48000 (continuous)
      Signed-off-by: NPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      395ae54b
    • P
      ALSA: usb: fix corrupted pointers due to interface setting change · 63018447
      Pierre-Louis Bossart 提交于
      When a transition occurs between alternate settings that do not use the
      same synchronization method, the substream pointers were not reset.
      This prevents audio from being played during the second transition.
      
      Identified and tested with M-Audio Transit device
      (0763:2006 Midiman M-Audio Transit)
      
      Details of the issue:
      
      First playback to adaptive endpoint:
      $ aplay -Dhw:1,0 ~/24_96.wav
      Playing WAVE '/home/plb/24_96.wav' : Signed 24 bit Little Endian in 3bytes,
      Rate 96000 Hz, Stereo
      
      [ 3169.297556] usb 1-2: setting usb interface 1:1
      [ 3169.297568] usb 1-2: Creating new playback data endpoint #3
      [ 3169.298563] usb 1-2: Setting params for ep #3 (type 0, 3 urbs), ret=0
      [ 3169.298574] usb 1-2: Starting data EP @ffff880035fc8000
      
      first playback to asynchronous endpoint:
      $ aplay -Dhw:1,0 ~/16_48.wav
      Playing WAVE '/home/plb/16_48.wav' : Signed 16 bit Little Endian,
      Rate 48000 Hz, Stereo
      
      [ 3204.520251] usb 1-2: setting usb interface 1:3
      [ 3204.520264] usb 1-2: Creating new playback data endpoint #3
      [ 3204.520272] usb 1-2: Creating new capture sync endpoint #83
      [ 3204.521162] usb 1-2: Setting params for ep #3 (type 0, 4 urbs), ret=0
      [ 3204.521177] usb 1-2: Setting params for ep #83 (type 1, 4 urbs), ret=0
      [ 3204.521182] usb 1-2: Starting data EP @ffff880035fce000
      [ 3204.521204] usb 1-2: Starting sync EP @ffff8800bd616000
      
      second playback to adaptive endpoint: no audio and error on terminal:
      $ aplay -Dhw:1,0 ~/24_96.wav
      Playing WAVE '/home/plb/24_96.wav' : Signed 24 bit Little Endian in 3bytes,
      Rate 96000 Hz, Stereo
      aplay: pcm_write:1939: write error: Input/output error
      
      [ 3239.483589] usb 1-2: setting usb interface 1:1
      [ 3239.483601] usb 1-2: Re-using EP 3 in iface 1,1 @ffff880035fc8000
      [ 3239.484590] usb 1-2: Setting params for ep #3 (type 0, 4 urbs), ret=0
      [ 3239.484606] usb 1-2: Setting params for ep #83 (type 1, 4 urbs), ret=0
      
      This last line shows that a sync endpoint is used when it shouldn't.
      The sync endpoint is no longer valid and the pointers are corrupted
      Signed-off-by: NPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      63018447
  17. 09 2月, 2015 1 次提交
  18. 29 11月, 2014 1 次提交
  19. 03 5月, 2014 1 次提交
    • S
      ALSA: usb-audio: Prevent printk ratelimiting from spamming kernel log while DEBUG not defined · b7a77235
      Sander Eikelenboom 提交于
      This (widely used) construction:
      
      if(printk_ratelimit())
      	dev_dbg()
      
      Causes the ratelimiting to spam the kernel log with the "callbacks suppressed"
      message below, even while the dev_dbg it is supposed to rate limit wouldn't
      print anything because DEBUG is not defined for this device.
      
      [  533.803964] retire_playback_urb: 852 callbacks suppressed
      [  538.807930] retire_playback_urb: 852 callbacks suppressed
      [  543.811897] retire_playback_urb: 852 callbacks suppressed
      [  548.815745] retire_playback_urb: 852 callbacks suppressed
      [  553.819826] retire_playback_urb: 852 callbacks suppressed
      
      So use dev_dbg_ratelimited() instead of this construction.
      Signed-off-by: NSander Eikelenboom <linux@eikelenboom.it>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      b7a77235
  20. 10 4月, 2014 1 次提交
  21. 26 2月, 2014 1 次提交
    • T
      ALSA: usb-audio: Use standard printk helpers · 0ba41d91
      Takashi Iwai 提交于
      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: NTakashi Iwai <tiwai@suse.de>
      0ba41d91
  22. 07 10月, 2013 3 次提交
  23. 26 9月, 2013 1 次提交
    • A
      ALSA: improve buffer size computations for USB PCM audio · 976b6c06
      Alan Stern 提交于
      This patch changes the way URBs are allocated and their sizes are
      determined for PCM playback in the snd-usb-audio driver.  Currently
      the driver allocates too few URBs for endpoints that don't use
      implicit sync, making underruns more likely to occur.  This may be a
      holdover from before I/O delays could be measured accurately; in any
      case, it is no longer necessary.
      
      The patch allocates as many URBs as possible, subject to four
      limitations:
      
      	The total number of URBs for the endpoint is not allowed to
      	exceed MAX_URBS (which the patch increases from 8 to 12).
      
      	The total number of packets per URB is not allowed to exceed
      	MAX_PACKS (or MAX_PACKS_HS for high-speed devices), which is
      	decreased from 20 to 6.
      
      	The total duration of queued data is not allowed to exceed
      	MAX_QUEUE, which is decreased from 24 ms to 18 ms.
      
      	The total number of ALSA frames in the output queue is not
      	allowed to exceed the ALSA buffer size.
      
      The last requirement is the hardest to implement.  Currently the
      number of URBs needed to fill a buffer cannot be determined in
      advance, because a buffer contains a fixed number of frames whereas
      the number of frames in an URB varies to match shifts in the device's
      clock rate.  To solve this problem, the patch changes the logic for
      deciding how many packets an URB should contain.  Rather than using as
      many as possible without exceeding an ALSA period boundary, now the
      driver uses only as many packets as needed to transfer a predetermined
      number of frames.  As a result, unless the device's clock has an
      exceedingly variable rate, the number of URBs making up each period
      (and hence each buffer) will remain constant.
      
      The overall effect of the patch is that playback works better in
      low-latency settings.  The user can still specify values for
      frames/period and periods/buffer that exceed the capabilities of the
      hardware, of course.  But for values that are within those
      capabilities, the performance will be improved.  For example, testing
      shows that a high-speed device can handle 32 frames/period and 3
      periods/buffer at 48 KHz, whereas the current driver starts to get
      glitchy at 64 frames/period and 2 periods/buffer.
      
      A side effect of these changes is that the "nrpacks" module parameter
      is no longer used.  The patch removes it.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      CC: Clemens Ladisch <clemens@ladisch.de>
      Tested-by: NDaniel Mack <zonque@gmail.com>
      Tested-by: NEldad Zack <eldad@fogrefinery.com>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      976b6c06
  24. 06 8月, 2013 7 次提交