Skip to content

Commit 55f7326

Browse files
crwulfftiwai
authored andcommitted
ALSA: usb-audio: Create a registration quirk for Kingston HyperX Amp (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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 0aef31b commit 55f7326

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

sound/usb/card.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -662,10 +662,14 @@ static int usb_audio_probe(struct usb_interface *intf,
662662
goto __error;
663663
}
664664

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

670674
if (quirk && quirk->shares_media_device) {
671675
/* don't want to fail when snd_media_device_create() fails */

sound/usb/quirks.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1808,3 +1808,17 @@ void snd_usb_audioformat_attributes_quirk(struct snd_usb_audio *chip,
18081808
break;
18091809
}
18101810
}
1811+
1812+
int snd_usb_registration_quirk(struct snd_usb_audio *chip,
1813+
int iface)
1814+
{
1815+
switch (chip->usb_id) {
1816+
case USB_ID(0x0951, 0x16d8): /* Kingston HyperX AMP */
1817+
/* Register only when we reach interface 2 so that streams can
1818+
* merge correctly into PCMs from interface 0
1819+
*/
1820+
return (iface != 2);
1821+
}
1822+
/* Register as normal */
1823+
return 0;
1824+
}

sound/usb/quirks.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,7 @@ void snd_usb_audioformat_attributes_quirk(struct snd_usb_audio *chip,
5151
struct audioformat *fp,
5252
int stream);
5353

54+
int snd_usb_registration_quirk(struct snd_usb_audio *chip,
55+
int iface);
56+
5457
#endif /* __USBAUDIO_QUIRKS_H */

0 commit comments

Comments
 (0)