This project is mirrored from https://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git. Pull mirroring updated .
  1. 23 Nov, 2020 4 commits
    • Takashi Iwai's avatar
      ALSA: usb-audio: Refactor endpoint management · bf6313a0
      Takashi Iwai authored
      
      
      This is an intensive surgery for the endpoint and stream management
      for achieving more robust and clean code.
      
      The goals of this patch are:
      - More clear endpoint resource changes
      - The interface altsetting control in a single place
      Below are brief description of the whole changes.
      
      First off, most of the endpoint operations are moved into endpoint.c,
      so that the snd_usb_endpoint object is only referred in other places.
      The endpoint object is acquired and released via the new functions
      snd_usb_endpoint_open() and snd_usb_endpoint_close() that are called
      at PCM hw_params and hw_free callbacks, respectively.  Those are
      ref-counted and EPs can manage the multiple opens.
      
      The open callback receives the audioformat and hw_params arguments,
      and those are used for initializing the EP parameters; especially the
      endpoint, interface and altset numbers are read from there, as well as
      the PCM parameters like the format, rate and channels.  Those are
      stored in snd_usb_endpoint object.  If it's the secondary open, the
      function checks whether the given parameters are compatible with the
      already opened EP setup, too.
      
      The coupling with a sync EP (including an implicit feedback sync) is
      done by the sole snd_usb_endpoint_set_sync() call.
      
      The configuration of each endpoint is done in a single shot via
      snd_usb_endpoint_configure() call.  This is the place where most of
      PCM configurations are done.  A few flags and special handling in the
      snd_usb_substream are dropped along with this change.
      
      A significant difference wrt the configuration from the previous code
      is the order of USB host interface setups.  Now the interface is
      always disabled at beginning and (re-)enabled at the last step of
      snd_usb_endpoint_configure(), in order to be compliant with the
      standard UAC2/3.  For UAC1, the interface is set before the parameter
      setups since there seem devices that require it (e.g. Yamaha THR10),
      just like how it was done in the previous driver code.
      
      The start/stop are almost same as before, also single-shots.  The URB
      callbacks need to be set via snd_usb_endpoint_set_callback() like the
      previous code at the trigger phase, too.
      
      Finally, the flag for the re-setup is set at the device suspend
      through the full EP list, instead of PCM trigger.  This catches the
      overlooked cases where the PCM hasn't been running yet but the device
      needs the full setup after resume.
      Tested-by: default avatarKeith Milner <kamilner@superlative.org>
      Tested-by: default avatarDylan Robinson <dylan_robinson@motu.com>
      Link: https://lore.kernel.org/r/20201123085347.19667-26-tiwai@suse.de
      
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      bf6313a0
    • Takashi Iwai's avatar
      ALSA: usb-audio: Add hw constraint for implicit fb sync · 5a6c3e11
      Takashi Iwai authored
      
      
      In the current code, there is no check at the stream open time whether
      the endpoint is being already used by others.  In the normal
      operations, this shouldn't happen, but in the case of the implicit
      feedback mode, it's a common problem with the full duplex operation,
      because the capture stream is always opened by the playback stream as
      an implicit sync source.
      
      Although we recently introduced the check of such a conflict of
      parameters at the PCM hw_params time, it doesn't give any hint at the
      hw_params itself and just gives the error.  This isn't quite
      comfortable, and it caused problems on many applications.
      
      This patch attempts to make the parameter handling easier by
      introducing the strict hw constraint matching with the counterpart
      stream that is being used.  That said, when an implicit feedback
      playback stream is running before a capture stream is opened, the
      capture stream carries the PCM hw-constraint to allow only the same
      sample rate, format, periods and period frames as the running playback
      stream.  If not opened or there is no conflict of endpoints, the
      behavior remains as same as before.
      
      Note that this kind of "weak link" should work for most cases, but
      this is no concrete solution; e.g. if an application changes the hw
      params multiple times while another stream is opened, this would lead
      to inconsistencies.
      Tested-by: default avatarKeith Milner <kamilner@superlative.org>
      Tested-by: default avatarDylan Robinson <dylan_robinson@motu.com>
      Link: https://lore.kernel.org/r/20201123085347.19667-11-tiwai@suse.de
      
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      5a6c3e11
    • Takashi Iwai's avatar
      ALSA: usb-audio: Track implicit fb sync endpoint in audioformat list · f6581c0e
      Takashi Iwai authored
      
      
      Instead of parsing and evaluating the sync endpoint and the implicit
      feedback mode at each time the audio stream is opened, let's parse it
      once at the probe time, as the all needed information can be obtained
      statically from the descriptor or from the quirk.
      
      This patch extends audioformat struct to record the sync endpoint,
      interface and altsetting as well as the implicit feedback flag, which
      are filled at parsing the streams.  Then, set_sync_endpoint() is much
      simplified just to follow the already parsed data.
      Tested-by: default avatarKeith Milner <kamilner@superlative.org>
      Tested-by: default avatarDylan Robinson <dylan_robinson@motu.com>
      Link: https://lore.kernel.org/r/20201123085347.19667-9-tiwai@suse.de
      
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      f6581c0e
    • Takashi Iwai's avatar
      ALSA: usb-audio: Handle discrete rates properly in hw constraints · bc4e94aa
      Takashi Iwai authored
      
      
      In the current code, when the device provides the discrete sample rate
      tables with unusual sample rates, the driver tries to gather the whole
      values from the audioformat entries and create a hw-constraint rule to
      restrict with this single rate list.  This is rather inefficient and
      may overlook the rates that are associated only with the certain
      audioformat entries.
      
      This patch improves the hw constraint setup by rewriting the existing
      hw_rule_rate().  The discrete sample rates (identified by rate_table
      and nr_rates of format entry) are checked in the existing
      hw_rule_rate() instead of extra rules; in the case of discrete rates,
      the function compares with each rate table entry and calculates the
      min/max values from there.  For the contiguous rates, the behavior
      doesn't change.
      
      Along with it, snd_usb_pcm_check_knot() and snb_usb_substream
      rate_list field become superfluous, thus those are dropped.
      Tested-by: default avatarKeith Milner <kamilner@superlative.org>
      Tested-by: default avatarDylan Robinson <dylan_robinson@motu.com>
      Link: https://lore.kernel.org/r/20201123085347.19667-2-tiwai@suse.de
      
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      bc4e94aa
  2. 10 Aug, 2020 1 commit
  3. 30 Jun, 2020 1 commit
  4. 15 May, 2020 1 commit
  5. 24 Apr, 2020 1 commit
    • Alexander Tsoy's avatar
      ALSA: usb-audio: Improve frames size computation · f0bd62b6
      Alexander Tsoy authored
      
      
      For computation of the the next frame size current value of fs/fps and
      accumulated fractional parts of fs/fps are used, where values are stored
      in Q16.16 format. This is quite natural for computing frame size for
      asynchronous endpoints driven by explicit feedback, since in this case
      fs/fps is a value provided by the feedback endpoint and it's already in
      the Q format. If an error is accumulated over time, the device can
      adjust fs/fps value to prevent buffer overruns/underruns.
      
      But for synchronous endpoints the accuracy provided by these computations
      is not enough. Due to accumulated error the driver periodically produces
      frames with incorrect size (+/- 1 audio sample).
      
      This patch fixes this issue by implementing a different algorithm for
      frame size computation. It is based on accumulating of the remainders
      from division fs/fps and it doesn't accumulate errors over time. This
      new method is enabled for synchronous and adaptive playback endpoints.
      Signed-off-by: default avatarAlexander Tsoy <alexander@tsoy.me>
      Link: https://lore.kernel.org/r/20200424022449.14972-1-alexander@tsoy.me
      
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      f0bd62b6
  6. 18 Dec, 2019 1 commit
    • Hui Wang's avatar
      ALSA: usb-audio: set the interface format after resume on Dell WD19 · 92adc96f
      Hui Wang authored
      
      
      Recently we found the headset-mic on the Dell Dock WD19 doesn't work
      anymore after s3 (s2i or deep), this problem could be workarounded by
      closing (pcm_close) the app and then reopening (pcm_open) the app, so
      this bug is not easy to be detected by users.
      
      When problem happens, retire_capture_urb() could still be called
      periodically, but the size of captured data is always 0, it could be
      a firmware bug on the dock. Anyway I found after resuming, the
      snd_usb_pcm_prepare() will be called, and if we forcibly run
      set_format() to set the interface and its endpoint, the capture
      size will be normal again. This problem and workaound also apply to
      playback.
      
      To fix it in the kernel, add a quirk to let set_format() run
      forcibly once after resume.
      Signed-off-by: default avatarHui Wang <hui.wang@canonical.com>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20191218132650.6303-1-hui.wang@canonical.com
      
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      92adc96f
  7. 22 Apr, 2019 1 commit
    • Shuah Khan's avatar
      media: sound/usb: Use Media Controller API to share media resources · 66354f18
      Shuah Khan authored
      
      
      Media Device Allocator API to allows multiple drivers share a media device.
      This API solves a very common use-case for media devices where one physical
      device (an USB stick) provides both audio and video. When such media device
      exposes a standard USB Audio class, a proprietary Video class, two or more
      independent drivers will share a single physical USB bridge. In such cases,
      it is necessary to coordinate access to the shared resource.
      
      Using this API, drivers can allocate a media device with the shared struct
      device as the key. Once the media device is allocated by a driver, other
      drivers can get a reference to it. The media device is released when all
      the references are released.
      
      Change the ALSA driver to use the Media Controller API to share media
      resources with DVB, and V4L2 drivers on a AU0828 media device.
      
      The Media Controller specific initialization is done after sound card is
      registered. ALSA creates Media interface and entity function graph nodes
      for Control, Mixer, PCM Playback, and PCM Capture devices.
      
      snd_usb_hw_params() will call Media Controller enable source handler
      interface to request the media resource. If resource request is granted,
      it will release it from snd_usb_hw_free(). If resource is busy, -EBUSY is
      returned.
      
      Media specific cleanup is done in usb_audio_disconnect().
      Reviewed-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarShuah Khan <shuah@kernel.org>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      66354f18
  8. 18 Feb, 2019 1 commit
  9. 31 Jul, 2018 1 commit
  10. 13 Jun, 2018 1 commit
  11. 21 Mar, 2018 1 commit
    • Ruslan Bilovol's avatar
      ALSA: usb: initial USB Audio Device Class 3.0 support · 9a2fe9b8
      Ruslan Bilovol authored
      
      
      Recently released USB Audio Class 3.0 specification
      introduces many significant changes comparing to
      previous versions, like
       - new Power Domains, support for LPM/L1
       - new Cluster descriptor
       - changed layout of all class-specific descriptors
       - new High Capability descriptors
       - New class-specific String descriptors
       - new and removed units
       - additional sources for interrupts
       - removed Type II Audio Data Formats
       - ... and many other things (check spec)
      
      It also provides backward compatibility through
      multiple configurations, as well as requires
      mandatory support for BADD (Basic Audio Device
      Definition) on each ADC3.0 compliant device
      
      This patch adds initial support of UAC3 specification
      that is enough for Generic I/O Profile (BAOF, BAIF)
      device support from BADD document.
      Signed-off-by: default avatarRuslan Bilovol <ruslan.bilovol@gmail.com>
      Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      9a2fe9b8
  12. 02 Nov, 2017 1 commit
    • Greg Kroah-Hartman's avatar
      License cleanup: add SPDX GPL-2.0 license identifier to files with no license · b2441318
      Greg Kroah-Hartman authored
      
      
      Many source files in the tree are missing licensing information, which
      makes it harder for compliance tools to determine the correct license.
      
      By default all files without license information are under the default
      license of the kernel, which is GPL version 2.
      
      Update the files which contain no license information with the 'GPL-2.0'
      SPDX license identifier.  The SPDX identifier is a legally binding
      shorthand, which can be used instead of the full boiler plate text.
      
      This patch is based on work done by Thomas Gleixner and Kate Stewart and
      Philippe Ombredanne.
      
      How this work was done:
      
      Patches were generated and checked against linux-4.14-rc6 for a subset of
      the use cases:
       - file had no licensing information it it.
       - file was a */uapi/* one with no licensing information in it,
       - file was a */uapi/* one with existing licensing information,
      
      Further patches will be generated in subsequent months to fix up cases
      where non-standard license headers were used, and references to license
      had to be inferred by heuristics based on keywords.
      
      The analysis to determine which SPDX License Identifier to be applied to
      a file was done in a spreadsheet of side by side results from of the
      output of two independent scanners (ScanCode & Windriver) producing SPDX
      tag:value files created by Philippe Ombredanne.  Philippe prepared the
      base worksheet, and did an initial spot review of a few 1000 files.
      
      The 4.13 kernel was the starting point of the analysis with 60,537 files
      assessed.  Kate Stewart did a file by file comparison of the scanner
      results in the spreadsheet to determine which SPDX license identifier(s)
      to be applied to the file. She confirmed any determination that was not
      immediately clear with lawyers working with the Linux Foundation.
      
      Criteria used to select files for SPDX license identifier tagging was:
       - Files considered eligible had to be source code files.
       - Make and config files were included as candidates if they contained >5
         lines of source
       - File already had some variant of a license header in it (even if <5
         lines).
      
      All documentation files were explicitly excluded.
      
      The following heuristics were used to determine which SPDX license
      identifiers to apply.
      
       - when both scanners couldn't find any license traces, file was
         considered to have no license information in it, and the top level
         COPYING file license applied.
      
         For non */uapi/* files that summary was:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|-------
         GPL-2.0                                              11139
      
         and resulted in the first patch in this series.
      
         If that file was a */uapi/* path one, it was "GPL-2.0 WITH
         Linux-syscall-note" otherwise it was "GPL-2.0".  Results of that was:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|-------
         GPL-2.0 WITH Linux-syscall-note                        930
      
         and resulted in the second patch in this series.
      
       - if a file had some form of licensing information in it, and was one
         of the */uapi/* ones, it was denoted with the Linux-syscall-note if
         any GPL family license was found in the file or had no licensing in
         it (per prior point).  Results summary:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|------
         GPL-2.0 WITH Linux-syscall-note                       270
         GPL-2.0+ WITH Linux-syscall-note                      169
         ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause)    21
         ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)    17
         LGPL-2.1+ WITH Linux-syscall-note                      15
         GPL-1.0+ WITH Linux-syscall-note                       14
         ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause)    5
         LGPL-2.0+ WITH Linux-syscall-note                       4
         LGPL-2.1 WITH Linux-syscall-note                        3
         ((GPL-2.0 WITH Linux-syscall-note) OR MIT)              3
         ((GPL-2.0 WITH Linux-syscall-note) AND MIT)             1
      
         and that resulted in the third patch in this series.
      
       - when the two scanners agreed on the detected license(s), that became
         the concluded license(s).
      
       - when there was disagreement between the two scanners (one detected a
         license but the other didn't, or they both detected different
         licenses) a manual inspection of the file occurred.
      
       - In most cases a manual inspection of the information in the file
         resulted in a clear resolution of the license that should apply (and
         which scanner probably needed to revisit its heuristics).
      
       - When it was not immediately clear, the license identifier was
         confirmed with lawyers working with the Linux Foundation.
      
       - If there was any question as to the appropriate license identifier,
         the file was flagged for further research and to be revisited later
         in time.
      
      In total, over 70 hours of logged manual review was done on the
      spreadsheet to determine the SPDX license identifiers to apply to the
      source files by Kate, Philippe, Thomas and, in some cases, confirmation
      by lawyers working with the Linux Foundation.
      
      Kate also obtained a third independent scan of the 4.13 code base from
      FOSSology, and compared selected files where the other two scanners
      disagreed against that SPDX file, to see if there was new insights.  The
      Windriver scanner is based on an older version of FOSSology in part, so
      they are related.
      
      Thomas did random spot checks in about 500 files from the spreadsheets
      for the uapi headers and agreed with SPDX license identifier in the
      files he inspected. For the non-uapi files Thomas did random spot checks
      in about 15000 files.
      
      In initial set of patches against 4.14-rc6, 3 files were found to have
      copy/paste license identifier errors, and have been fixed to reflect the
      correct identifier.
      
      Additionally Philippe spent 10 hours this week doing a detailed manual
      inspection and review of the 12,461 patched files from the initial patch
      version early this week with:
       - a full scancode scan run, collecting the matched texts, detected
         license ids and scores
       - reviewing anything where there was a license detected (about 500+
         files) to ensure that the applied SPDX license was correct
       - reviewing anything where there was no detection but the patch license
         was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
         SPDX license was correct
      
      This produced a worksheet with 20 files needing minor correction.  This
      worksheet was then exported into 3 different .csv files for the
      different types of files to be modified.
      
      These .csv files were then reviewed by Greg.  Thomas wrote a script to
      parse the csv files and add the proper SPDX tag to the file, in the
      format that the file expected.  This script was further refined by Greg
      based on the output to detect more types of files automatically and to
      distinguish between header and source .c files (which need different
      comment types.)  Finally Greg ran the script using the .csv files to
      generate the patches.
      Reviewed-by: default avatarKate Stewart <kstewart@linuxfoundation.org>
      Reviewed-by: default avatarPhilippe Ombredanne <pombredanne@nexb.com>
      Reviewed-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b2441318
  13. 22 Aug, 2016 1 commit
  14. 31 Mar, 2016 1 commit
  15. 03 Mar, 2016 1 commit
  16. 19 Oct, 2015 1 commit
    • Ricard Wanderlof's avatar
      ALSA: USB-audio: Add quirk for Zoom R16/24 playback · e0570446
      Ricard Wanderlof authored
      
      
      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: default avatarRicard Wanderlof <ricardw@axis.com>
      Tested-by: default avatarPanu Matilainen <pmatilai@laiskiainen.org>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      e0570446
  17. 09 Feb, 2015 1 commit
  18. 02 May, 2014 1 commit
  19. 07 Oct, 2013 1 commit
    • Eldad Zack's avatar
      ALSA: usb-audio: rename alt_idx to altsetting · df23a246
      Eldad Zack authored
      
      
      As Clemens Ladisch kindly explained:
       "Please note that there are two methods to identify alternate settings:
        the number, which is the value in bAlternateSetting, and the index,
        which is the index in the descriptor array.  There might be some wording
        in the USB spec that these two values must be the same, but in reality,
        [insert standard rant about firmware writers], bAlternateSetting
        must be treated as a random ID value."
      
      This patch changes the name to express the correct usage semantics.
      No functional change.
      Signed-off-by: default avatarEldad Zack <eldad@fogrefinery.com>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      df23a246
  20. 26 Sep, 2013 1 commit
    • Alan Stern's avatar
      ALSA: improve buffer size computations for USB PCM audio · 976b6c06
      Alan Stern authored
      
      
      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: default avatarAlan Stern <stern@rowland.harvard.edu>
      CC: Clemens Ladisch <clemens@ladisch.de>
      Tested-by: default avatarDaniel Mack <zonque@gmail.com>
      Tested-by: default avatarEldad Zack <eldad@fogrefinery.com>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      976b6c06
  21. 27 Jun, 2013 1 commit
  22. 18 Apr, 2013 2 commits
    • Daniel Mack's avatar
      ALSA: snd-usb: add support for bit-reversed byte formats · 44dcbbb1
      Daniel Mack authored
      
      
      There is quite some confusion around the bit-ordering in DSD samples,
      and no general agreement that defines whether hardware is supposed to
      expect the oldest sample in the MSB or the LSB of a byte.
      
      ALSA will hence set the rule that on the software API layer, bytes
      always carry the oldest bit in the most significant bit of a byte, and
      the driver has to translate that at runtime in order to match the
      hardware layout.
      
      This patch adds support for this by adding a boolean flag to the
      audio format struct.
      Signed-off-by: default avatarDaniel Mack <zonque@gmail.com>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      44dcbbb1
    • Daniel Mack's avatar
      ALSA: snd-usb: add support for DSD DOP stream transport · d24f5061
      Daniel Mack authored
      In order to provide a compatibility way for pushing DSD
      samples through ordinary PCM channels, the "DoP open Standard" was
      invented. See http://www.dsd-guide.com
      
       for the official document.
      
      The host is required to stuff DSD marker bytes (0x05, 0xfa,
      alternating) in the MSB of 24 bit wide samples on the bus, in addition
      to the 16 bits of actual DSD sample payload.
      
      To support this, the hardware and software stride logic in the driver
      has to be tweaked a bit, as we make the userspace believe we're
      operating on 16 bit samples, while we in fact push one more byte per
      channel down to the hardware.
      
      The DOP runtime information is stored in struct snd_usb_substream, so
      we can keep track of our state across multiple calls to
      prepare_playback_urb_dsd_dop().
      Signed-off-by: default avatarDaniel Mack <zonque@gmail.com>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      d24f5061
  23. 13 Apr, 2013 1 commit
    • Calvin Owens's avatar
      ALSA: usb: Add quirk for 192KHz recording on E-Mu devices · 1539d4f8
      Calvin Owens authored
      
      
      When recording at 176.2KHz or 192Khz, the device adds a 32-bit length
      header to the capture packets, which obviously needs to be ignored for
      recording to work properly.
      
      Userspace expected:  L0 L1 L2 R0 R1 R2
      ...but actually got: R2 L0 L1 L2 R0 R1
      
      Also, the last byte of the length header being interpreted as L0 of
      the first sample caused spikes every 0.5ms, resulting in a loud 16KHz
      tone (about the highest 'B' on a piano) being present throughout
      captures.
      
      Tested at all sample rates on an E-Mu 0404USB, and tested for
      regressions on a generic USB headset.
      Signed-off-by: default avatarCalvin Owens <jcalvinowens@gmail.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      1539d4f8
  24. 26 Nov, 2012 1 commit
    • Takashi Iwai's avatar
      ALSA: usb-audio: add channel map support · 04324ccc
      Takashi Iwai authored
      
      
      Add the support for channel maps of the PCM streams on USB audio
      devices.  The channel map information is already found in
      ChannelConfig descriptor entries, which haven't been referred until
      now.
      
      Each chmap entry is added to audioformat list entry and copied to TLV
      dynamically instead of creating a whole chmap array.
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      04324ccc
  25. 30 Oct, 2012 1 commit
    • Takashi Iwai's avatar
      ALSA: usb-audio: Fix races at disconnection · 978520b7
      Takashi Iwai authored
      
      
      Close some races at disconnection of a USB audio device by adding the
      chip->shutdown_mutex and chip->shutdown check at appropriate places.
      
      The spots to put bandaids are:
      - PCM prepare, hw_params and hw_free
      - where the usb device is accessed for communication or get speed, in
       mixer.c and others; the device speed is now cached in subs->speed
       instead of accessing to chip->dev
      
      The accesses in PCM open and close don't need the mutex protection
      because these are already handled in the core PCM disconnection code.
      
      The autosuspend/autoresume codes are still uncovered by this patch
      because of possible mutex deadlocks.  They'll be covered by the
      upcoming change to rwsem.
      
      Also the mixer codes are untouched, too.  These will be fixed in
      another patch, too.
      Reported-by: default avatarMatthieu CASTET <matthieu.castet@parrot.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      978520b7
  26. 19 Sep, 2012 2 commits
    • Takashi Iwai's avatar
      ALSA: usb-audio: Avoid unnecessary EP setups in prepare · 384dc085
      Takashi Iwai authored
      
      
      The recent fix for USB suspend breakage moved the code to set up EP
      from hw_params to prepare, but it means also the EP setup might be
      called multiple times unnecessarily because the prepare callback can
      be called multiple times without starting the stream (e.g. OSS
      emulation).
      
      This patch adds a new flag to struct snd_usb_substream indicating
      whether the setup of EP is required, and do it only when necessary,
      i.e. right after hw_params or suspend.
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      384dc085
    • Dylan Reid's avatar
      ALSA: usb-audio: Move configuration to prepare. · 61a70950
      Dylan Reid authored
      
      
      Move interface and endpoint configuration from hw_params to prepare
      callback.  During system suspend/resume when the USB device power isn't
      cycled the interface and endpoint configuration need to be set before
      audio playback can continue.  Resume involves another call to prepare
      but not to hw_params, moving it here allows a playing stream to continue
      after resume.
      Signed-off-by: default avatarDylan Reid <dgreid@chromium.org>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      61a70950
  27. 04 Sep, 2012 1 commit
    • Daniel Mack's avatar
      ALSA: snd-usb: Add quirks for Playback Designs devices · 2b58fd5b
      Daniel Mack authored
      
      
      Playback Designs' USB devices have some hardware limitations on their
      USB interface. In particular:
      
       - They need a 20ms delay after each class compliant request as the
         hardware ACKs the USB packets before the device is actually ready
         for the next command. Sending data immediately will result in buffer
         overflows in the hardware.
       - The devices send bogus feedback data at the start of each stream
         which confuse the feedback format auto-detection.
      
      This patch introduces a new quirks hook that is called after each
      control packet and which adds a delay for all devices that match
      Playback Designs' USB VID for now.
      
      In addition, it adds a counter to snd_usb_endpoint to drop received
      packets on the floor. Another new quirks function that is called once
      an endpoint is started initializes that counter for these devices on
      their sync endpoint.
      Signed-off-by: default avatarDaniel Mack <zonque@gmail.com>
      Reported-and-tested-by: default avatarAndreas Koch <andreas@akdesigninc.com>
      Supported-by: default avatarDemian Martin <demianm_1@yahoo.com>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      2b58fd5b
  28. 28 Aug, 2012 1 commit
  29. 08 Jun, 2012 1 commit
    • Takashi Iwai's avatar
      ALSA: usb-audio: Fix substream assignments · 8260ef07
      Takashi Iwai authored
      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-g71fae7e7
      
       #2
      Call Trace:
       [<ffffffff8102a400>] warn_slowpath_common+0x83/0x9c
       [<ffffffff8102a4bc>] warn_slowpath_fmt+0x46/0x48
       [<ffffffff813829ad>] ? add_preempt_count+0x39/0x3b
       [<ffffffff811292f0>] proc_register+0x169/0x1a6
       [<ffffffff8112962e>] create_proc_entry+0x74/0x8c
       [<ffffffffa018eb63>] snd_info_register+0x3e/0xc3 [snd]
       [<ffffffffa01fde2e>] snd_pcm_new_stream+0xb1/0x404 [snd_pcm]
       [<ffffffffa024861f>] snd_usb_add_audio_stream+0xd2/0x230 [snd_usb_audio]
       [<ffffffffa0241d33>] ? snd_usb_parse_audio_format+0x252/0x34f [snd_usb_audio]
       [<ffffffff810d6b17>] ? kmem_cache_alloc_trace+0xab/0xbb
       [<ffffffffa0248c29>] snd_usb_parse_audio_interface+0x4ac/0x567 [snd_usb_audio]
       [<ffffffffa023f0ff>] snd_usb_create_stream+0xe9/0x125 [snd_usb_audio]
       [<ffffffffa023f9b1>] 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: default avatarJamie Heilman <jamie@audible.transient.net>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      8260ef07
  30. 21 Apr, 2012 1 commit
  31. 13 Apr, 2012 3 commits
    • Takashi Iwai's avatar
      ALSA: usb: Remove obsoleted fields from struct snd_usb_substream · 22026c1a
      Takashi Iwai authored
      
      
      Many fields have been moved to struct snd_usb_endpoint.
      Also fix the proc output to correspond to the new structure.
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      22026c1a
    • Daniel Mack's avatar
      ALSA: snd-usb: switch over to new endpoint streaming logic · edcd3633
      Daniel Mack authored
      
      
      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: default avatarDaniel Mack <zonque@gmail.com>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      edcd3633
    • Daniel Mack's avatar
      ALSA: snd-usb: implement new endpoint streaming model · 8fdff6a3
      Daniel Mack authored
      
      
      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: default avatarDaniel Mack <zonque@gmail.com>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      8fdff6a3
  32. 15 Feb, 2012 1 commit
  33. 12 Sep, 2011 1 commit
    • Pierre-Louis Bossart's avatar
      ALSA: usb: refine delay information with USB frame counter · 294c4fb8
      Pierre-Louis Bossart authored
      
      
      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: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
      [clemens: changed debug code]
      Signed-off-by: default avatarClemens Ladisch <clemens@ladisch.de>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      294c4fb8