All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: alsa-devel@alsa-project.org
Subject: [PATCH 07/15] ALSA: usb-audio: Move ITF-USB DSD quirk handling into quirk_flags
Date: Thu, 29 Jul 2021 09:38:53 +0200	[thread overview]
Message-ID: <20210729073855.19043-8-tiwai@suse.de> (raw)
In-Reply-To: <20210729073855.19043-1-tiwai@suse.de>

The devices with ITF-USB DSD type are listed in another function, and
this can be integrated into the quirk_flags easily.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/usb/quirks.c   | 41 +++++++++++++++++++----------------------
 sound/usb/usbaudio.h |  4 ++++
 2 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
index a9d8bde416ce..a0986e079a66 100644
--- a/sound/usb/quirks.c
+++ b/sound/usb/quirks.c
@@ -1501,32 +1501,13 @@ void snd_usb_set_format_quirk(struct snd_usb_substream *subs,
 	}
 }
 
-/* ITF-USB DSD based DACs need a vendor cmd to switch
- * between PCM and native DSD mode
- */
-static bool is_itf_usb_dsd_dac(unsigned int id)
-{
-	switch (id) {
-	case USB_ID(0x154e, 0x1002): /* Denon DCD-1500RE */
-	case USB_ID(0x154e, 0x1003): /* Denon DA-300USB */
-	case USB_ID(0x154e, 0x3005): /* Marantz HD-DAC1 */
-	case USB_ID(0x154e, 0x3006): /* Marantz SA-14S1 */
-	case USB_ID(0x1852, 0x5065): /* Luxman DA-06 */
-	case USB_ID(0x0644, 0x8043): /* TEAC UD-501/UD-501V2/UD-503/NT-503 */
-	case USB_ID(0x0644, 0x8044): /* Esoteric D-05X */
-	case USB_ID(0x0644, 0x804a): /* TEAC UD-301 */
-		return true;
-	}
-	return false;
-}
-
 int snd_usb_select_mode_quirk(struct snd_usb_audio *chip,
 			      const struct audioformat *fmt)
 {
 	struct usb_device *dev = chip->dev;
 	int err;
 
-	if (is_itf_usb_dsd_dac(chip->usb_id)) {
+	if (chip->quirk_flags & QUIRK_FLAG_ITF_USB_DSD_DAC) {
 		/* First switch to alt set 0, otherwise the mode switch cmd
 		 * will not be accepted by the DAC
 		 */
@@ -1633,7 +1614,7 @@ void snd_usb_ctl_msg_quirk(struct usb_device *dev, unsigned int pipe,
 	/* ITF-USB DSD based DACs functionality need a delay
 	 * after each class compliant request
 	 */
-	if (is_itf_usb_dsd_dac(chip->usb_id)
+	if ((chip->quirk_flags & QUIRK_FLAG_ITF_USB_DSD_DAC)
 	    && (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS)
 		msleep(20);
 
@@ -1749,7 +1730,7 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip,
 	}
 
 	/* ITF-USB DSD based DACs */
-	if (is_itf_usb_dsd_dac(chip->usb_id)) {
+	if (chip->quirk_flags & QUIRK_FLAG_ITF_USB_DSD_DAC) {
 		iface = usb_ifnum_to_if(chip->dev, fp->iface);
 
 		/* Altsetting 2 support native DSD if the num of altsets is
@@ -1902,16 +1883,32 @@ static const struct usb_audio_quirk_flags_table quirk_flags_table[] = {
 		   QUIRK_FLAG_ALIGN_TRANSFER),
 	DEVICE_FLG(0x05e1, 0x0480, /* Hauppauge Woodbury */
 		   QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER),
+	DEVICE_FLG(0x0644, 0x8043, /* TEAC UD-501/UD-501V2/UD-503/NT-503 */
+		   QUIRK_FLAG_ITF_USB_DSD_DAC),
+	DEVICE_FLG(0x0644, 0x8044, /* Esoteric D-05X */
+		   QUIRK_FLAG_ITF_USB_DSD_DAC),
+	DEVICE_FLG(0x0644, 0x804a, /* TEAC UD-301 */
+		   QUIRK_FLAG_ITF_USB_DSD_DAC),
 	DEVICE_FLG(0x074d, 0x3553, /* Outlaw RR2150 (Micronas UAC3553B) */
 		   QUIRK_FLAG_GET_SAMPLE_RATE),
 	DEVICE_FLG(0x0fd9, 0x0008, /* Hauppauge HVR-950Q */
 		   QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER),
 	DEVICE_FLG(0x1395, 0x740a, /* Sennheiser DECT */
 		   QUIRK_FLAG_GET_SAMPLE_RATE),
+	DEVICE_FLG(0x154e, 0x1002, /* Denon DCD-1500RE */
+		   QUIRK_FLAG_ITF_USB_DSD_DAC),
+	DEVICE_FLG(0x154e, 0x1003, /* Denon DA-300USB */
+		   QUIRK_FLAG_ITF_USB_DSD_DAC),
+	DEVICE_FLG(0x154e, 0x3005, /* Marantz HD-DAC1 */
+		   QUIRK_FLAG_ITF_USB_DSD_DAC),
+	DEVICE_FLG(0x154e, 0x3006, /* Marantz SA-14S1 */
+		   QUIRK_FLAG_ITF_USB_DSD_DAC),
 	DEVICE_FLG(0x154e, 0x500e, /* Denon DN-X1600 */
 		   QUIRK_FLAG_IGNORE_CLOCK_SOURCE),
 	DEVICE_FLG(0x1686, 0x00dd, /* Zoom R16/24 */
 		   QUIRK_FLAG_TX_LENGTH),
+	DEVICE_FLG(0x1852, 0x5065, /* Luxman DA-06 */
+		   QUIRK_FLAG_ITF_USB_DSD_DAC),
 	DEVICE_FLG(0x1901, 0x0191, /* GE B850V3 CP2114 audio interface */
 		   QUIRK_FLAG_GET_SAMPLE_RATE),
 	DEVICE_FLG(0x2040, 0x7200, /* Hauppauge HVR-950Q */
diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h
index 82073ebeac5b..7b41a95eadee 100644
--- a/sound/usb/usbaudio.h
+++ b/sound/usb/usbaudio.h
@@ -144,6 +144,9 @@ extern bool snd_usb_skip_validation;
  *  Skip clock selector setup; the device may reset to invalid state
  * QUIRK_FLAG_IGNORE_CLOCK_SOURCE:
  *  Ignore errors from clock source search; i.e. hardcoded clock
+ * QUIRK_FLAG_ITF_USB_DSD_DAC:
+ *  Indicates the device is for ITF-USB DSD based DACs that need a vendor cmd
+ *  to switch between PCM and native DSD mode
  */
 
 #define QUIRK_FLAG_GET_SAMPLE_RATE	(1U << 0)
@@ -153,5 +156,6 @@ extern bool snd_usb_skip_validation;
 #define QUIRK_FLAG_PLAYBACK_FIRST	(1U << 4)
 #define QUIRK_FLAG_SKIP_CLOCK_SELECTOR	(1U << 5)
 #define QUIRK_FLAG_IGNORE_CLOCK_SOURCE	(1U << 6)
+#define QUIRK_FLAG_ITF_USB_DSD_DAC	(1U << 7)
 
 #endif /* __USBAUDIO_H */
-- 
2.26.2


  parent reply	other threads:[~2021-07-29 10:07 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-29  7:38 [PATCH 00/15] ALSA: usb-audio: Introduce and convert to quirk_flags Takashi Iwai
2021-07-29  7:38 ` [PATCH 01/15] ALSA: usb-audio: Introduce quirk_flags field Takashi Iwai
2021-07-29  7:38 ` [PATCH 02/15] ALSA: usb-audio: Move media-controller API quirk into quirk_flags Takashi Iwai
2021-07-29  7:38 ` [PATCH 03/15] ALSA: usb-audio: Move txfr_quirk handling to quirk_flags Takashi Iwai
2021-07-29  7:38 ` [PATCH 04/15] ALSA: usb-audio: Move tx_length quirk " Takashi Iwai
2021-07-29  7:38 ` [PATCH 05/15] ALSA: usb-audio: Move playback_first flag into quirk_flags Takashi Iwai
2021-07-29  7:38 ` [PATCH 06/15] ALSA: usb-audio: Move clock setup quirk " Takashi Iwai
2021-07-29  7:38 ` Takashi Iwai [this message]
2021-07-29  7:38 ` [PATCH 08/15] ALSA: usb-audio: Move control message delay " Takashi Iwai
2021-07-29  7:38 ` [PATCH 09/15] ALSA: usb-audio: Move interface setup delay " Takashi Iwai
2021-07-29  7:43 ` [PATCH 10/15] ALSA: usb-audio: Move rate validation quirk " Takashi Iwai
2021-07-29  7:44 ` [PATCH 11/15] ALSA: usb-audio: Move autosuspend " Takashi Iwai
2021-07-29  7:44 ` [PATCH 12/15] ALSA: usb-audio: Move ignore_ctl_error check " Takashi Iwai
2021-07-29  7:44 ` [PATCH 13/15] ALSA: usb-audio: Move generic DSD raw detection " Takashi Iwai
2021-07-29  7:44 ` [PATCH 14/15] ALSA: usb-audio: Add quirk_flags module option Takashi Iwai
2021-07-29  7:44 ` [PATCH 15/15] ALSA: doc: Add the description of quirk_flags option for snd-usb-audio 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=20210729073855.19043-8-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    /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.