From: crwulff@gmail.com
To: patch@alsa-project.org
Cc: tiwai@suse.de, alsa-devel@alsa-project.org,
Chris Wulff <crwulff@gmail.com>
Subject: [PATCH Fix for Kingston HyperX Amp (0951:16d8) (Try #2) 2/2] snd-usb-audio: Create a registration quirk
Date: Sat, 14 Mar 2020 12:54:49 -0400 [thread overview]
Message-ID: <20200314165449.4086-3-crwulff@gmail.com> (raw)
In-Reply-To: <20200314165449.4086-1-crwulff@gmail.com>
From: Chris Wulff <crwulff@gmail.com>
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>
diff --git a/sound/usb/card.c b/sound/usb/card.c
index 827fb0bc8b56..16bbe2a50fb7 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -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 */
diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
index 7f558f4b4520..c73da0721e30 100644
--- a/sound/usb/quirks.c
+++ b/sound/usb/quirks.c
@@ -1756,3 +1756,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;
+}
diff --git a/sound/usb/quirks.h b/sound/usb/quirks.h
index df0355843a4c..3afc01eabc7e 100644
--- a/sound/usb/quirks.h
+++ b/sound/usb/quirks.h
@@ -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 */
--
2.20.1
next prev parent reply other threads:[~2020-03-15 8:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-14 16:54 [PATCH Fix for Kingston HyperX Amp (0951:16d8) 0/2 (Try #2)] crwulff
2020-03-14 16:54 ` [PATCH Fix for Kingston HyperX Amp (0951:16d8) (Try #2) 1/2] snd-usb-audio: Fix mixer controls' USB interface crwulff
2020-03-14 16:54 ` crwulff [this message]
2020-03-14 17:26 ` [PATCH Fix for Kingston HyperX Amp (0951:16d8) 0/2 (Try #2)] Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200314165449.4086-3-crwulff@gmail.com \
--to=crwulff@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=patch@alsa-project.org \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.