aboutsummaryrefslogtreecommitdiffstats
path: root/sound/usb (follow)
AgeCommit message (Collapse)AuthorFilesLines
2021-01-08ALSA: usb-audio: Fix implicit feedback sync setup for Pioneer devicesTakashi Iwai1-10/+38
Pioneer devices have both playback and capture streams sharing the same iface/altsetting, and those need to be paired as implicit feedback. Instead of a half-baked (and broken) static quirk entry, set up more generically for those devices by checking the number of endpoints and the attribute of the secondary EP. Fixes: bf6313a0ff76 ("ALSA: usb-audio: Refactor endpoint management") Reported-by: František Kučera <konference@frantovo.cz> Link: https://lore.kernel.org/r/20210108075219.21463-6-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-01-08ALSA: usb-audio: Annotate the endpoint index in audioformatTakashi Iwai4-3/+10
There are devices that have multiple endpoints sharing the same iface/altset not only for sync but also for the actual streams, and the audioformat for such an endpoint needs to be handled with the proper endpoint index; otherwise it confuses the endpoint management. This patch extends the audioformat to annotate the endpoint index, and put the proper ep_idx=1 to Pioneer device quirk entries accordingly. Fixes: bf6313a0ff76 ("ALSA: usb-audio: Refactor endpoint management") Link: https://lore.kernel.org/r/20210108075219.21463-5-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-01-08ALSA: usb-audio: Avoid unnecessary interface re-setupTakashi Iwai5-15/+77
The current endpoint handling assumed (more or less) a unique 1:1 relation between the endpoint and the iface/altset. The exception was the sync EP without the implicit feedback which has usually the secondary EP of the same altset. This works fine for most devices, but it turned out that some unusual devices like Pinoeer's ones have both playback and capture endpoints in the same iface/altsetting and use both for the implicit feedback mode. For handling such a case, we need to extend the endpoint management to take the shared interface into account. This patch does that: it adds a new object snd_usb_iface_ref for managing the reference counts of the each USB interface that is used by each endpoint. The interface setup is performed only once for the (sharing) endpoints, and the doubly initialization is avoided. Along with this, the resource release of endpoints and interface refcounts are put into a single function, snd_usb_endpoint_free_all() instead of looping in the caller side. Fixes: bf6313a0ff76 ("ALSA: usb-audio: Refactor endpoint management") Link: https://lore.kernel.org/r/20210108075219.21463-4-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-01-08ALSA: usb-audio: Choose audioformat of a counter-part substreamTakashi Iwai1-5/+4
The implicit feedback mode needs to handle two endpoints and the choice of the audioformat object for the sync EP is important since this determines the compatibility of the hw_params. The current code uses the same audioformat object if both the main EP and the sync EP point to the same iface/altsetting. This was done in consideration of the non-implicit-fb sync EP handling, and it doesn't match well with the cases where actually to endpoints are defined in the sameiface / altsetting like a few Pioneer devices. Modify snd_usb_find_implicit_fb_sync_format() to pick up the audioformat that is assigned in the counter-part substreams primarily, so that the actual capture stream can be opened properly. We keep the same audioformat object only as a fallback in case nothing found, though. Fixes: 9fddc15e8039 ("ALSA: usb-audio: Factor out the implicit feedback quirk code") Link: https://lore.kernel.org/r/20210108075219.21463-3-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-01-08ALSA: usb-audio: Fix the missing endpoints creations for quirksTakashi Iwai1-10/+44
The recent change in the endpoint management moved the endpoint object creation from the stream open time to the parser of the audio descriptor. It works fine for the standard audio, but it overlooked the other places that create audio streams via quirks (QUIRK_AUDIO_FIXED_ENDPOINT) like the reported a few Pioneer devices; those call snd_usb_add_audio_stream() manually, hence they miss the endpoints, eventually resulting in the error at opening streams. Moreover, now the sync EP setup was moved to the explicit call of snd_usb_audioformat_set_sync_ep(), and this needs to be added for those places, too. This patch addresses those regressions for quirks. It adds a local helper function add_audio_stream_from_fixed_fmt(), which does the all needed tasks, and replaces the calls of snd_usb_add_audio_stream() with this new function. Fixes: 54cb31901b83 ("ALSA: usb-audio: Create endpoint objects at parsing phase") Reported-by: František Kučera <konference@frantovo.cz> Link: https://lore.kernel.org/r/20210108075219.21463-2-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-01-03ALSA: usb-audio: Add quirk for RC-505Timon Reinold1-0/+2
BOSS RC-505 (shown by lsusb as "Roland Corp. RC-505") does require the same quirk as these other BOSS devices. Without this quirk it is neither possible to capture audio from nor to write audio to the RC-505. Both just result in an empty audio stream. With these changes both capture and playback seem to work quite fine. MIDI funtionality was not tested. Tested-by: Harry Reinold <harry.reinold@posteo.de> Signed-off-by: Timon Reinold <tirei@agon.one> Link: https://lore.kernel.org/r/20210102210835.21268-1-tirei@agon.one Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-12-29ALSA: usb-audio: Add quirk for BOSS AD-10Takashi Iwai1-0/+2
BOSS AD-10 requires the very same quirk like other BOSS devices to enable the special implicit feedback mode. Reported-and-tested-by: Martin Passing <martin@passing.name> Link: https://lore.kernel.org/r/20201229083428.20467-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-12-23ALSA: usb-audio: Fix UBSAN warnings for MIDI jacksTakashi Iwai1-0/+4
The calculation of in_cables and out_cables bitmaps are done with the bit shift by the value from the descriptor, which is an arbitrary value, and can lead to UBSAN shift-out-of-bounds warnings. Fix it by filtering the bad descriptor values with the check of the upper bound 0x10 (the cable bitmaps are 16 bits). Reported-by: syzbot+92e45ae45543f89e8c88@syzkaller.appspotmail.com Cc: <stable@vger.kernel.org> Link: https://lore.kernel.org/r/20201223174557.10249-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-12-22ALSA: usb-audio: Add implicit feeback support for the BOSS GT-1Mike Oliphant1-0/+2
The BOSS GT-1 (USB ID 0582:01d6) requires implicit feedback like other similar BOSS devices. This patch adds this support. [ rearranged the table entry in the ID order -- tiwai ] Signed-off-by: Mike Oliphant <oliphant@nostatic.org> Link: https://lore.kernel.org/r/20201221215533.2511-1-oliphant@nostatic.org Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-12-21ALSA: usb-audio: Add alias entry for ASUS PRIME TRX40 PRO-STakashi Iwai1-0/+3
ASUS PRIME TRX40 PRO-S mobo with 0b05:1918 needs the same quirk alias for another ASUS mobo (0b05:1917) for the proper mixer mapping, etc. Add the corresponding entry. BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=210783 Cc: <stable@vger.kernel.org> Link: https://lore.kernel.org/r/20201221080159.24468-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-12-18ALSA: usb-audio: Disable sample read check if firmware doesn't give backTakashi Iwai1-0/+6
Some buggy firmware don't give the current sample rate but leaves zero. Handle this case more gracefully without warning but just skip the current rate verification from the next time. Cc: <stable@vger.kernel.org> Link: https://lore.kernel.org/r/20201218145858.2357-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-12-17ALSA: usb-audio: Add VID to support native DSD reproduction on FiiO devicesAmadej Kastelic1-0/+1
Add VID to support native DSD reproduction on FiiO devices. Tested-by: Amadej Kastelic <amadejkastelic7@gmail.com> Signed-off-by: Emilio Moretti <emilio.moretti@gmail.com> Signed-off-by: Amadej Kastelic <amadejkastelic7@gmail.com> Cc: <stable@vger.kernel.org> Link: https://lore.kernel.org/r/X9j7wdXSr4XyK7Bd@ryzen.localdomain Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-12-14ALSA: usb-audio: Fix potential out-of-bounds shiftTakashi Iwai1-0/+2
syzbot spotted a potential out-of-bounds shift in the USB-audio format parser that receives the arbitrary shift value from the USB descriptor. Add a range check for avoiding the undefined behavior. Reported-by: syzbot+df7dc146ebdd6435eea3@syzkaller.appspotmail.com Cc: <stable@vger.kernel.org> Link: https://lore.kernel.org/r/20201209084552.17109-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-12-14Merge branch 'for-linus' into for-nextTakashi Iwai2-4/+4
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-12-11ALSA: usb-audio: Fix control 'access overflow' errors from chmapTakashi Iwai1-3/+3
The current channel-map control implementation in USB-audio driver may lead to an error message like "control 3:0:0:Playback Channel Map:0: access overflow" when CONFIG_SND_CTL_VALIDATION is set. It's because the chmap get callback clears the whole array no matter which count is set, and rather the false-positive detection. This patch fixes the problem by clearing only the needed array range at usb_chmap_ctl_get(). Cc: <stable@vger.kernel.org> Link: https://lore.kernel.org/r/20201211130048.6358-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-12-10ALSA: usb-audio: Add implicit fb support for Steinberg UR22Takashi Iwai1-0/+1
Steinberg UR22 (with USB ID 0499:1509) requires the implicit feedback for the proper playback, otherwise it causes occasional cracks. This patch adds the corresponding the quirk table entry with the recently added generic implicit fb support. Reported-and-tested-by: Kilian <meschi@posteo.de> Link: https://lore.kernel.org/r/20201209161835.13625-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-11-30ALSA: usb-audio: Add quirk for Pioneer DJ DDJ-SR2Takashi Iwai1-0/+57
Yet another quirk for Pioneer DJ DDJ-SR2, which is quite similar like other DJ DDJ models but with slightly different EPs or channels. Reported-by: Geraldo <geraldogabriel@gmail.com> Link: https://lore.kernel.org/r/20201130083714.10640-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-11-28ALSA: usb-audio: Add support for Pioneer DJ DDJ-RR controllerDaniel Martin1-0/+56
This patch allows the Pioneer DJ DDJ-RR to be seen as a USB audio device under Linux and therefore usable in such applications as Mixxx. Tested Master Audio out, headphones (both output jacks) and microphone input. All work perfectly. Signed-off-by: Daniel Martin <dmanlfc@gmail.com> Link: https://lore.kernel.org/r/20201128084035.2958-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-11-27ALSA: usb-audio: US16x08: fix value count for level metersHector Martin1-1/+1
The level meter control returns 34 integers of info. This fixes: snd-usb-audio 3-1:1.0: control 2:0:0:Level Meter:0: access overflow Fixes: d2bb390a2081 ("ALSA: usb-audio: Tascam US-16x08 DSP mixer quirk") Cc: stable@vger.kernel.org Signed-off-by: Hector Martin <marcan@marcan.st> Link: https://lore.kernel.org/r/20201127132635.18947-1-marcan@marcan.st Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-11-23ALSA: usb-audio: Fix MOTU M-Series quirksDylan Robinson2-17/+0
Now that the usb audio driver correctly finds implicit feedback endpoints, the implicit feedback quirk for the MOTU M-Series is no longer required. This also removes some unnecessary vendor specific messages from the MOTU M-Series boot quirk. The removed vendor specific messages turned on vendor specific interrupts to the host every 32 samples. The only thing the boot quirk needs to do is wait for 2 seconds. Tested-by: Dylan Robinson <dylan_robinson@motu.com> Signed-off-by: Dylan Robinson <dylan_robinson@motu.com> Link: https://lore.kernel.org/r/20201123085347.19667-42-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-11-23ALSA: usb-audio: Fix quirks for other BOSS devicesTakashi Iwai1-3/+6
A few other BOSS devices (BR-80, GT-100v2, Katana) seem requiring the same quirk as BOSS GT-001, i.e. no implicit feedback for playback but tying with capture. Add and correct the corresponding quirk table entries for them. Reported-and-tested-by: Keith Milner <kamilner@superlative.org> Link: https://lore.kernel.org/r/20201123085347.19667-41-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-11-23ALSA: usb-audio: Add implicit_fb module optionTakashi Iwai3-0/+9
A new module option, implicit_fb, is added to specify the driver looking for the implicit feedback sync. This can be useful for a device that could be working better in the implicit feed back mode and user wants to test it quickly. When this works, we can add the quirk entry easily. Tested-by: Keith Milner <kamilner@superlative.org> Tested-by: Dylan Robinson <dylan_robinson@motu.com> Link: https://lore.kernel.org/r/20201123085347.19667-40-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-11-23ALSA: usb-audio: Add generic implicit fb parsingTakashi Iwai1-5/+54
This patch extends the implicit feedback mode parser code to check the description more generically, so that the quirk entries can be added without the explicit EP and interface numbers. The search is done for the next and the previous interface of the given altset, and if both entries are ASYNC mode and the direction matches, it just takes as the sync endpoint. The generic parser is applicable only for the playback stream. As of now, only a few M-Audio devices have been converted to use this mode. Tested-by: Keith Milner <kamilner@superlative.org> Tested-by: Dylan Robinson <dylan_robinson@motu.com> Link: https://lore.kernel.org/r/20201123085347.19667-39-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-11-23ALSA: usb-audio: Factor out the implicit feedback quirk codeTakashi Iwai4-306/+376
The code dealing with the implicit feedback mode grew recently, and it's becoming messy. As we receive more and more devices that need the similar handling, it's better to be processed through a table instead of the open code. This patch moves the code that is relevant with parsing the implicit feedback mode and some helpers into another file, implicit.c. The detection and the setup of the implicit feedback sync EPs are rewritten to use the ID/class matching table instead. There should be no functional changes. Tested-by: Keith Milner <kamilner@superlative.org> Tested-by: Dylan Robinson <dylan_robinson@motu.com> Link: https://lore.kernel.org/r/20201123085347.19667-38-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-11-23ALSA: usb-audio: Quirk for BOSS GT-001Takashi Iwai1-0/+31
The capture stream of BOSS GT-001 seems always requiring to be tied with the playback stream. OTOH, the playback stream of this device doesn't seem working in the implicit fb mode, per se, since the playback must be running before the capture stream. This patch tries to address the points above: - Avoid the implicit fb mode for the playback - Set up a fake sync EP for the capture stream with the hard-coded playback stream using the implicit fb mode Reported-by: Keith Milner <kamilner@superlative.org> Tested-by: Keith Milner <kamilner@superlative.org> Tested-by: Dylan Robinson <dylan_robinson@motu.com> Link: https://lore.kernel.org/r/20201123085347.19667-37-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-11-23ALSA: usb-audio: Show sync endpoint information in proc outputsTakashi Iwai1-1/+15
Now the sync endpoints have been parsed at the beginning and won't be changed dynamically, let's show them in the proc outputs for helping debugging. Tested-by: Keith Milner <kamilner@superlative.org> Tested-by: Dylan Robinson <dylan_robinson@motu.com> Link: https://lore.kernel.org/r/20201123085347.19667-36-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-11-23ALSA: usb-audio: Use unsigned char for iface and altsettings fieldsTakashi Iwai2-5/+8
Just for consistency, use unsigned char for iface and altsetting in allover places. Also rearrange the field positions of snd_usb_endpiont and tidy up with some comments. Tested-by: Keith Milner <kamilner@superlative.org> Tested-by: Dylan Robinson <dylan_robinson@motu.com> Link: https://lore.kernel.org/r/20201123085347.19667-35-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-11-23ALSA: usb-audio: Replace slave/master termsTakashi Iwai2-16/+16
Follow the inclusive terminology, just replace sync_master/sync_slave with sync_source/sync_sink. It's also a bit clearer from its meaning, too. Tested-by: Keith Milner <kamilner@superlative.org> Tested-by: Dylan Robinson <dylan_robinson@motu.com> Link: https://lore.kernel.org/r/20201123085347.19667-34-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-11-23ALSA: usb-audio: Simplify rate_min/max and rates set upTakashi Iwai1-29/+24
There are multiple places in format.c performing the similar code for setting the rate_min, rate_max and rates fields. This patch unifies those in a helper function and calls it at the end of the parser phase so that all rate_table entries have been already determined. No functional changes, just a minor code refactoring. Tested-by: Keith Milner <kamilner@superlative.org> Tested-by: Dylan Robinson <dylan_robinson@motu.com> Link: https://lore.kernel.org/r/20201123085347.19667-33-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-11-23ALSA: usb-audio: Unify the code for the next packet size calculationTakashi Iwai3-25/+27
There are two places calculating the next packet size for the playback stream in the exactly same way. Provide the single helper for this purpose and use it from both places gracefully. Tested-by: Keith Milner <kamilner@superlative.org> Tested-by: Dylan Robinson <dylan_robinson@motu.com> Link: https://lore.kernel.org/r/20201123085347.19667-32-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-11-23ALSA: usb-audio: Drop unneeded snd_usb_substream fieldsTakashi Iwai5-38/+24
Some fields like interface and alt_idx in snd_usb_substream are mostly useless now as they can be referred via either cur_audiofmt or data_endpoint assigned to the substream. Drop those, and also assure the concurrency about the access of cur_audiofmt field. Tested-by: Keith Milner <kamilner@superlative.org> Tested-by: Dylan Robinson <dylan_robinson@motu.com> Link: https://lore.kernel.org/r/20201123085347.19667-31-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-11-23ALSA: usb-audio: Refactoring endpoint URB deactivationTakashi Iwai1-18/+23
Minor code refactoring to consolidate the URB deactivation code in endpoint.c. A slight behavior change is that the error handling in snd_usb_endpoint_start() leaves EP_FLAG_STOPPING now. This should be synced with the later PCM sync_stop callback. Tested-by: Keith Milner <kamilner@superlative.org> Tested-by: Dylan Robinson <dylan_robinson@motu.com> Link: https://lore.kernel.org/r/20201123085347.19667-30-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-11-23ALSA: usb-audio: Use atomic_t for endpoint use_countTakashi Iwai2-13/+15
The endpoint objects may be started/stopped concurrently by different substreams in the case of implicit feedback mode, while the current code handles the reference counter without any protection. This patch changes the refcount to atomic_t for avoiding the inconsistency. We need no reference_t here as the refcount goes only up to 2. Also the name "use_count" is renamed to "running" since this is about actually the running status, not the open refcount. Tested-by: Keith Milner <kamilner@superlative.org> Tested-by: Dylan Robinson <dylan_robinson@motu.com> Link: https://lore.kernel.org/r/20201123085347.19667-29-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-11-23ALSA: usb-audio: Constify audioformat pointer referencesTakashi Iwai9-38/+39
The audioformat is referred in many places but most of usages are read-only. Let's add const prefix in the possible places. Tested-by: Keith Milner <kamilner@superlative.org> Tested-by: Dylan Robinson <dylan_robinson@motu.com> Link: https://lore.kernel.org/r/20201123085347.19667-28-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-11-23ALSA: usb-audio: Fix possible stall of implicit fb packet ring-bufferTakashi Iwai2-25/+63
The implicit feedback mode uses a ring buffer for storing the received packet sizes from the feedback source, and the code has a slight flaw; when a playback stream stalls by some reason and the URBs aren't processed, the next_packet FIFO might become empty, but the driver can't distinguish whether it's empty or full because it's managed with read_poss and write_pos. This patch addresses those by changing the next_packet array management. Instead of keeping read and write positions, now the head position and the queued amount are kept. It's easier to understand about the emptiness. Also, the URB active flag is now cleared before calling queue_pending_output_urbs() for avoiding (theoretically) possible inconsistency. Tested-by: Keith Milner <kamilner@superlative.org> Tested-by: Dylan Robinson <dylan_robinson@motu.com> Link: https://lore.kernel.org/r/20201123085347.19667-27-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-11-23ALSA: usb-audio: Refactor endpoint managementTakashi Iwai6-734/+616
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: Keith Milner <kamilner@superlative.org> Tested-by: Dylan Robinson <dylan_robinson@motu.com> Link: https://lore.kernel.org/r/20201123085347.19667-26-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-11-23ALSA: usb-audio: Fix EP matching for continuous ratesTakashi Iwai1-24/+13
The function to evaluate the match of the parameters with an EP assumes only the discrete rate tables and doesn't handle the continuous rates properly. This patch fixes match_endpoint_audioformats() to handle the continuous rates. Also the almost useless debug prints there are dropped. Tested-by: Keith Milner <kamilner@superlative.org> Tested-by: Dylan Robinson <dylan_robinson@motu.com> Link: https://lore.kernel.org/r/20201123085347.19667-25-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-11-23ALSA: usb-audio: Always set up the parameters after resumeTakashi Iwai4-34/+6
The commit 92adc96f8eec ("ALSA: usb-audio: set the interface format after resume on Dell WD19") introduced the workaround for the broken setup after the resume specifically on a Dell dock model. However, the full setup should have been performed after the resume on all devices, as we can't guarantee the same state. So this patch removes the conditional check and applies the workaround always. Tested-by: Keith Milner <kamilner@superlative.org> Tested-by: Dylan Robinson <dylan_robinson@motu.com> Link: https://lore.kernel.org/r/20201123085347.19667-24-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-11-23ALSA: usb-audio: Set callbacks via snd_usb_endpoint_set_callback()Takashi Iwai3-34/+66
The prepare_data_urb and retire_data_urb fields of the endpoint object are set dynamically at PCM trigger start/stop. Those are evaluated in the endpoint handler, but there can be a race, especially if two different PCM substreams are handling the same endpoint for the implicit feedback case. Also, the data_subs field of the endpoint is set and accessed dynamically, too, which has the same risk. As a slight improvement for the concurrency, this patch introduces the function to set the callbacks and the data in a shot with the memory barrier. In the reader side, it's also fetched with the memory barrier. There is still a room of race if prepare and retire callbacks are set during executing the URB completion. But such an inconsistency may happen only for the implicit fb source, i.e. it's only about the capture stream. And luckily, the capture stream never sets the prepare callback, hence the problem doesn't happen practically. Tested-by: Keith Milner <kamilner@superlative.org> Tested-by: Dylan Robinson <dylan_robinson@motu.com> Link: https://lore.kernel.org/r/20201123085347.19667-23-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-11-23ALSA: usb-audio: Stop both endpoints properly at errorTakashi Iwai2-22/+23
start_endpoints() may leave the data endpoint running if an error happens at starting the sync endpoint. We should stop both streams properly, instead. While we're at it, move the debug prints into the endpoint.c that is a more suitable place. Tested-by: Keith Milner <kamilner@superlative.org> Tested-by: Dylan Robinson <dylan_robinson@motu.com> Link: https://lore.kernel.org/r/20201123085347.19667-22-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-11-23ALSA: usb-audio: Simplify snd_usb_init_pitch() argumentsTakashi Iwai4-18/+12
A preliminary change for the later big changes. This is a minor code refactoring to drop the unnecessary arguments that can be retrieved in a different way. Tested-by: Keith Milner <kamilner@superlative.org> Tested-by: Dylan Robinson <dylan_robinson@motu.com> Link: https://lore.kernel.org/r/20201123085347.19667-21-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-11-23ALSA: usb-audio: Simplify snd_usb_init_sample_rate() argumentsTakashi Iwai5-20/+18
A preliminary change for the later big changes. This is a minor code refactoring to drop the unnecessary arguments that can be retrieved in a different way. Tested-by: Keith Milner <kamilner@superlative.org> Tested-by: Dylan Robinson <dylan_robinson@motu.com> Link: https://lore.kernel.org/r/20201123085347.19667-20-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-11-23ALSA: usb-audio: Pass snd_usb_audio object to quirk functionsTakashi Iwai4-18/+17
A preliminary patch for the later big change. Just a minor code refactoring. Tested-by: Keith Milner <kamilner@superlative.org> Tested-by: Dylan Robinson <dylan_robinson@motu.com> Link: https://lore.kernel.org/r/20201123085347.19667-19-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-11-23ALSA: usb-audio: Don't set altsetting before initializing sample rateTakashi Iwai1-1/+2
Setting the active altsetting at changing sample rate seems unrecommended. The host should deselect the altsetting at first before that, then select it again. Tested-by: Keith Milner <kamilner@superlative.org> Tested-by: Dylan Robinson <dylan_robinson@motu.com> Link: https://lore.kernel.org/r/20201123085347.19667-18-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-11-23ALSA: usb-audio: Add snd_usb_get_host_interface() helperTakashi Iwai3-27/+24
Add a helper function to retrieve the usb_host_interface object from the given interface and altsetting number pair, which is a commonly used procedure in the driver code. No functional changes, just minor code refactoring. Tested-by: Keith Milner <kamilner@superlative.org> Tested-by: Dylan Robinson <dylan_robinson@motu.com> Link: https://lore.kernel.org/r/20201123085347.19667-17-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-11-23ALSA: usb-audio: Drop keep_interface flag againTakashi Iwai3-59/+7
This behavior turned out to be invalid from the USB spec POV and shouldn't be applied. As it's an optional flag that is set only via an card control element that must be hardly used, let's drop it again. Tested-by: Keith Milner <kamilner@superlative.org> Tested-by: Dylan Robinson <dylan_robinson@motu.com> Link: https://lore.kernel.org/r/20201123085347.19667-16-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-11-23ALSA: usb-audio: Create endpoint objects at parsing phaseTakashi Iwai4-73/+67
Currently snd_usb_endpoint objects are created at first when the substream is opened and tries to assign the endpoints corresponding to the matching audioformat. But since basically the all endpoints have been already parsed and the information have been obtained, we may create the endpoint objects statically at the init phase. It's easier to manage for the implicit fb case, for example. This patch changes the endpoint object management and lets the parser to create the all endpoint objects. This change shouldn't bring any functional changes. Tested-by: Keith Milner <kamilner@superlative.org> Tested-by: Dylan Robinson <dylan_robinson@motu.com> Link: https://lore.kernel.org/r/20201123085347.19667-15-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-11-23ALSA: usb-audio: Avoid doubly initialization for implicit fbTakashi Iwai1-9/+20
The implicit feedback mode initializes both the main data stream and the sync data stream. When a sync stream was already opened, this would result in the doubly initialization and might screw up things. Add the check of already opened sync streams and skip the unnecessary initialization. Tested-by: Keith Milner <kamilner@superlative.org> Tested-by: Dylan Robinson <dylan_robinson@motu.com> Link: https://lore.kernel.org/r/20201123085347.19667-14-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-11-23ALSA: usb-audio: Drop debug.hTakashi Iwai4-20/+13
The file debug.h contains a simple macro for debug prints, and it's used only in two places, the format parser and the hw_params rules. The former actually should print a more informative message instead, so the only users are the hw_parmas rules. This patch moves the contents of debug.h into the hw_params rules local code and remove the unneeded includes. Also, the debug print in the format parser is replaced with the information print with more useful information, and the raw printk() call is replaced with pr_debug(). Tested-by: Keith Milner <kamilner@superlative.org> Tested-by: Dylan Robinson <dylan_robinson@motu.com> Link: https://lore.kernel.org/r/20201123085347.19667-13-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-11-23ALSA: usb-audio: Simplify hw_params rulesTakashi Iwai1-72/+38
Several hw_params functions narrows the interval via min/max rule in the very similar way, so factor out those into a helper function and use commonly. No functional changes, just minor code refactoring. Tested-by: Keith Milner <kamilner@superlative.org> Tested-by: Dylan Robinson <dylan_robinson@motu.com> Link: https://lore.kernel.org/r/20201123085347.19667-12-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>