Skip to content

Commit

Permalink
ALSA: usb-audio: Create a registration quirk for Kingston HyperX Amp …
Browse files Browse the repository at this point in the history
…(0951:16d8)

Create a quirk that allows special processing and/or
skipping the call to snd_card_register.

For HyperX AMP, which uses two interfaces, but only has
a capture stream in the second, this allows the capture
stream to merge with the first PCM.

Signed-off-by: Chris Wulff <crwulff@gmail.com>
Link: https://lore.kernel.org/r/20200314165449.4086-3-crwulff@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Chris Wulff authored and Takashi Iwai committed Mar 14, 2020
1 parent 0aef31b commit 55f7326
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
12 changes: 8 additions & 4 deletions sound/usb/card.c
Original file line number Diff line number Diff line change
Expand Up @@ -662,10 +662,14 @@ static int usb_audio_probe(struct usb_interface *intf,
goto __error;
}

/* we are allowed to call snd_card_register() many times */
err = snd_card_register(chip->card);
if (err < 0)
goto __error;
/* we are allowed to call snd_card_register() many times, but first
* check to see if a device needs to skip it or do anything special
*/
if (snd_usb_registration_quirk(chip, ifnum) == 0) {
err = snd_card_register(chip->card);
if (err < 0)
goto __error;
}

if (quirk && quirk->shares_media_device) {
/* don't want to fail when snd_media_device_create() fails */
Expand Down
14 changes: 14 additions & 0 deletions sound/usb/quirks.c
Original file line number Diff line number Diff line change
Expand Up @@ -1808,3 +1808,17 @@ void snd_usb_audioformat_attributes_quirk(struct snd_usb_audio *chip,
break;
}
}

int snd_usb_registration_quirk(struct snd_usb_audio *chip,
int iface)
{
switch (chip->usb_id) {
case USB_ID(0x0951, 0x16d8): /* Kingston HyperX AMP */
/* Register only when we reach interface 2 so that streams can
* merge correctly into PCMs from interface 0
*/
return (iface != 2);
}
/* Register as normal */
return 0;
}
3 changes: 3 additions & 0 deletions sound/usb/quirks.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,7 @@ void snd_usb_audioformat_attributes_quirk(struct snd_usb_audio *chip,
struct audioformat *fp,
int stream);

int snd_usb_registration_quirk(struct snd_usb_audio *chip,
int iface);

#endif /* __USBAUDIO_QUIRKS_H */

0 comments on commit 55f7326

Please sign in to comment.