summaryrefslogtreecommitdiff
path: root/sound/usb/stream.c
AgeCommit message (Collapse)Author
2016-04-05Merge tag 'media/v4.6-3' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media Pull media fixes from Mauro Carvalho Chehab: "Some bug fixes on au0828 and snd-usb-audio: - the au0828+snd-usb-audio MC patch broke several things and produced some race conditions. Better to revert the patches, and re-work on them for a next version - fix a regression at tuner disable links logic - properly handle dev_state as a bitmask" * tag 'media/v4.6-3' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: [media] Revert "[media] media: au0828 change to use Managed Media Controller API" [media] Revert "[media] sound/usb: Use Media Controller API to share media resources" [media] au0828: Fix dev_state handling [media] au0828: fix au0828_v4l2_close() dev_state race condition [media] media: au0828 fix to clear enable/disable/change source handlers [media] v4l2-mc: cleanup a warning [media] au0828: disable tuner links and cache tuner/decoder
2016-04-01Merge tag 'sound-4.6-rc2' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound Pull sound fixes from Takashi Iwai: "A collection of small fixes: - a fix in ALSA timer core to avoid possible BUG() trigger - a fix in ALSA timer core 32bit compat layer - a few HD-audio quirks for ASUS and HP machines - AMD HD-audio HDMI controller quirks - fixes of USB-audio double-free at some error paths - a fix for memory leak in DICE driver at hotunplug" * tag 'sound-4.6-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound: ALSA: timer: Use mod_timer() for rearming the system timer ALSA: hda - fix front mic problem for a HP desktop ALSA: usb-audio: Fix double-free in error paths after snd_usb_add_audio_stream() call ALSA: hda: add AMD Polaris-10/11 AZ PCI IDs with proper driver caps ALSA: dice: fix memory leak when unplugging ALSA: hda - Apply fix for white noise on Asus N550JV, too ALSA: hda - Fix white noise on Asus N750JV headphone ALSA: hda - Asus N750JV external subwoofer fixup ALSA: timer: fix gparams ioctl compatibility for different architectures
2016-03-31[media] Revert "[media] sound/usb: Use Media Controller API to share media ↵Mauro Carvalho Chehab
resources" Unfortunately, this patch caused several regressions at au0828 and snd-usb-audio, like this one: https://bugzilla.kernel.org/show_bug.cgi?id=115561 It also showed several troubles at the MC core that handles pretty poorly the memory protections and data lifetime management. So, better to revert it and fix the core before reapplying this change. This reverts commit aebb2b89bff0 ("[media] sound/usb: Use Media Controller API to share media resources")' Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2016-03-31ALSA: usb-audio: Fix double-free in error paths after ↵Vladis Dronov
snd_usb_add_audio_stream() call create_fixed_stream_quirk(), snd_usb_parse_audio_interface() and create_uaxx_quirk() functions allocate the audioformat object by themselves and free it upon error before returning. However, once the object is linked to a stream, it's freed again in snd_usb_audio_pcm_free(), thus it'll be double-freed, eventually resulting in a memory corruption. This patch fixes these failures in the error paths by unlinking the audioformat object before freeing it. Based on a patch by Takashi Iwai <tiwai@suse.de> [Note for stable backports: this patch requires the commit 902eb7fd1e4a ('ALSA: usb-audio: Minor code cleanup in create_fixed_stream_quirk()')] Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1283358 Reported-by: Ralf Spenneberg <ralf@spenneberg.net> Cc: <stable@vger.kernel.org> # see the note above Signed-off-by: Vladis Dronov <vdronov@redhat.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-03-03[media] sound/usb: Use Media Controller API to share media resourcesShuah Khan
Change ALSA driver to use Media Controller API to share media resources with DVB and V4L2 drivers on a AU0828 media device. 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(). Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com> Acked-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-12-22ALSA: usb-audio: use list_for_each_entry_continue_reverseGeliang Tang
For better readability, use list_for_each_entry_continue_reverse() in have_dup_chmap(). Signed-off-by: Geliang Tang <geliangtang@163.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-19ALSA: USB-audio: Add quirk for Zoom R16/24 playbackRicard 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: Ricard Wanderlof <ricardw@axis.com> Tested-by: Panu Matilainen <pmatilai@laiskiainen.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-09-07ALSA: usb-audio: Change internal PCM orderJohan Rastén
New PCMs will now be added to the end of the chip's PCM list instead of to the front. This changes the way streams are combined so that the first capture stream will now be merged with the first playback stream instead of the last. This fixes a problem with ASUS U7. Cards with one playback stream and cards without capture streams should be unaffected by this change. Exception added for M-Audio Audiophile USB (tm) since it seems to have a fix to swap capture stream numbering in alsa-lib conf/cards/USB-audio.conf Signed-off-by: Johan Rastén <johan@oljud.se> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-02-26ALSA: usb-audio: Use standard printk helpersTakashi 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: Takashi Iwai <tiwai@suse.de>
2013-11-11ALSA: usb: Fix wrong mapping of RLC and RRC channelsAnssi Hannula
According to USB Audio spec v2 bits 25 and 26 of bmChannelConfig are "Back Left of Center - BLC" and "Back Right of Center - BRC", respectively. They are currently assigned to ALSA channels BLC/BRC. However, the ALSA BLC/BRC are actually the rather nonsensical "bottom left center" and "bottom right center", so the channels will be assigned wrongly. The comments in the USB code are also similarly wrong, so this is not readily apparent without looking at the actual specification. Fix the channel mapping by mapping bits 25 and 26 to RLC (Rear Left Center) and RRC (Rear Right Center), respectively, instead. Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-11-05ALSA: usb - Don't trust the channel config if the channel count changedDavid Henningsson
In case the channel count of the input terminal is not the same as the channel count of the streaming descriptor, the channel config of the input terminal can not be trusted. Instead fall back to a default (guessed) channel map. This was found on a Logitech USB Headset. Signed-off-by: David Henningsson <david.henningsson@canonical.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-11-05ALSA: usb - For class 2 devices, use channel map from altsettingsDavid Henningsson
The channel config from the streaming descriptor is probably a better indicator of the channel map than the input terminal. Use the input terminal's channel map as fallback only. Signed-off-by: David Henningsson <david.henningsson@canonical.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-11-05ALSA: usb: supply channel maps even when wChannelConfig is unspecifiedDavid Henningsson
If wChannelconfig is given for some formats but not others, userspace might not be able to set the channel map. This is RFC because I'm not sure what the best behaviour is - to guess the channel map from the given number of channels (it's quite likely that one channel is MONO and two channels is FL FR), or just to supply UNKNOWN for all channels. But the complete lack of channel map for a format leads userspace to believe that the format is not available at all. Or am I misunderstanding how this should be used? Signed-off-by: David Henningsson <david.henningsson@canonical.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-06-27ALSA: usb-audio: add support for many Roland/Yamaha devicesClemens Ladisch
Add quirks to detect the various vendor-specific descriptors used by Roland and Yamaha in most of their recent USB audio and MIDI devices. Together with the previous patch, this should add audio/MIDI support for the following USB devices: - Edirol motion dive .tokyo performance package - Roland MC-808 Synthesizer - Roland BK-7m Synthesizer - Roland VIMA JM-5/8 Synthesizer - Roland SP-555 Sequencer - Roland V-Synth GT Synthesizer - Roland Music Atelier AT-75/100/300/350C/500/800/900/900C Organ - Edirol V-Mixer M-200i/300/380/400/480/R-1000 - BOSS GT-10B Effects Processor - Roland Fantom G6/G7/G8 Keyboard - Cakewalk Sonar V-Studio 20/100/700 Audio Interface - Roland GW-8 Keyboard - Roland AX-Synth Keyboard - Roland JUNO-Di/STAGE/Gi Keyboard - Roland VB-99 Effects Processor - Cakewalk UM-2G MIDI Interface - Roland A-500S Keyboard - Roland SD-50 Synthesizer - Roland OCTAPAD SPD-30 Controller - Roland Lucina AX-09 Synthesizer - BOSS BR-800 Digital Recorder - Roland DUO/TRI-CAPTURE (EX) Audio Interface - BOSS RC-300 Loop Station - Roland JUPITER-50/80 Keyboard - Roland R-26 Recorder - Roland SPD-SX Controller - BOSS JS-10 Audio Player - Roland TD-11/15/30 Drum Module - Roland A-49/88 Keyboard - Roland INTEGRA-7 Synthesizer - Roland R-88 Recorder Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
2013-06-27ALSA: usb-audio: store protocol version in struct audioformatClemens Ladisch
Instead of reading bInterfaceProtocol from the descriptor whenever it's needed, store this value in the audioformat structure. Besides simplifying some code, this will allow us to correctly handle vendor- specific devices where the descriptors are marked with other values. Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
2013-04-25ALSA: snd-usb: try harder to find USB_DT_CS_ENDPOINTDaniel Mack
The USB_DT_CS_ENDPOINT class-specific endpoint descriptor is usually stuffed directly after the standard USB endpoint descriptor, and this is where the driver currently expects it to be. There are, however, devices in the wild that have it the other way around in their descriptor sets, so the USB_DT_CS_ENDPOINT comes *before* the standard enpoint. Devices known to implement it that way are "Sennheiser BTD-500" and Plantronics USB headsets. When the driver can't find the USB_DT_CS_ENDPOINT, it won't be able to change sample rates, as the bitmask for the validity of this command is storen in bmAttributes of that descriptor. Fix this by searching the entire interface instead of just the extra bytes of the first endpoint, in case the latter fails. Signed-off-by: Daniel Mack <zonque@gmail.com> Reported-and-tested-by: Torstein Hegge <hegge@resisty.net> Reported-and-tested-by: Yves G <alsa-user@vivigatt.com> Cc: stable@kernel.org Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-04-13ALSA: usb: Add quirk for 192KHz recording on E-Mu devicesCalvin Owens
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: Calvin Owens <jcalvinowens@gmail.com> Cc: <stable@vger.kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-04-04ALSA: usb-audio: convert list_for_each to entry variantEldad Zack
Change occurances of list_for_each into list_for_each_entry where applicable. Signed-off-by: Eldad Zack <eldad@fogrefinery.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-03-18ALSA: snd-usb: handle the bmFormats field as unsigned intDaniel Mack
This field may use up to 32 bits, so it should be handled as unsigned int. Signed-off-by: Daniel Mack <zonque@gmail.com> Reported-by: Andreas Koch <andreas@akdesigninc.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-11-26ALSA: usb-audio: add channel map supportTakashi Iwai
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: Takashi Iwai <tiwai@suse.de>
2012-10-30ALSA: usb-audio: Fix races at disconnectionTakashi Iwai
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: Matthieu CASTET <matthieu.castet@parrot.com> Cc: <stable@vger.kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-06-08ALSA: usb-audio: Fix substream assignmentsTakashi Iwai
In 3.5 kernel, the endpoint is assigned dynamically for the substreams, but the PCM assignment still checks the presence of the endpoint pointer. This ended up in duplicated PCM substream creations at probing time, resulting in kernel warnings like: WARNING: at fs/proc/generic.c:586 proc_register+0x169/0x1a6() Pid: 1152, comm: modprobe Not tainted 3.5.0-rc1-00110-g71fae7e #2 Call Trace: [<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: Jamie Heilman <jamie@audible.transient.net> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-04-13ALSA: snd-usb: switch over to new endpoint streaming logicDaniel Mack
With the previous commit that added the new streaming model, all endpoint and streaming related code is now in endpoint.c, and pcm.c only acts as a wrapper for handling the packet's payload. Signed-off-by: Daniel Mack <zonque@gmail.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-09-14ALSA: snd-usb: move code from urb.c to endpoint.cDaniel Mack
No code altered at this point, simply preparing for upcoming refactorizations. Signed-off-by: Daniel Mack <zonque@gmail.com> Acked-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-09-14ALSA: snd-usb: re-order codeDaniel Mack
Move code from endpoint.c into a new file called stream.c and rename functions so that their names actually reflect what they're doing. This way, endpoint.c will be available to functions that hold all the endpoint logic. Signed-off-by: Daniel Mack <zonque@gmail.com> Acked-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>