All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nobutaka Okabe <nob77413@gmail.com>
To: alsa-devel@alsa-project.org
Cc: Nobutaka Okabe <nob77413@gmail.com>, Jurgen Kramer <gtmkramer@xs4all.nl>
Subject: [PATCH 2/3] ALSA: usb-audio: FIX native DSD support for TEAC UD-501 DAC
Date: Fri, 23 Mar 2018 19:20:00 +0900	[thread overview]
Message-ID: <20180323102000.6577-1-nob77413@gmail.com> (raw)
In-Reply-To: <20180323101822.6529-1-nob77413@gmail.com>

There are two versions of TEAC UD-501, the normal version and
the vendor updated version(UD-501V2).

They have the same VID/PID, but the num of the altsetting is different,
UD-501 has 2 altsets for stream, and UD-501V2 has 3.

So, add the logic to distinguish them by the Product Name, not by the PID.

Signed-off-by: Nobutaka Okabe <nob77413@gmail.com>
---
 sound/usb/quirks.c | 37 +++++++++++++++++++++++++++----------
 1 file changed, 27 insertions(+), 10 deletions(-)

diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
index 006da37ad0d9..3d2437e88122 100644
--- a/sound/usb/quirks.c
+++ b/sound/usb/quirks.c
@@ -1153,14 +1153,23 @@ bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio *chip)
  * between PCM and native DSD mode
  * (2 altsets version)
  */
-static bool is_itf_usb_dsd_2alts_dac(unsigned int id)
+static bool is_itf_usb_dsd_2alts_dac(struct snd_usb_audio *chip)
 {
-	switch (id) {
+	char *product = chip->dev->product; /* DAC product name */
+
+	switch (chip->usb_id) {
 	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 */
 		return true;
+	case USB_ID(0x0644, 0x8043):
+		/* TEAC UD-501 */
+		if (product && strcmp("UD-501", product)) {
+			return true;
+		} else {
+			return false;
+		}
 	}
 	return false;
 }
@@ -1169,13 +1178,21 @@ static bool is_itf_usb_dsd_2alts_dac(unsigned int id)
  * between PCM and native DSD mode
  * (3 altsets version)
  */
-static bool is_itf_usb_dsd_3alts_dac(unsigned int id)
+static bool is_itf_usb_dsd_3alts_dac(struct snd_usb_audio *chip)
 {
-	switch (id) {
-	case USB_ID(0x0644, 0x8043): /* TEAC UD-501/UD-503/NT-503 */
+	char *product = chip->dev->product; /* DAC product name */
+
+	switch (chip->usb_id) {
 	case USB_ID(0x0644, 0x8044): /* Esoteric D-05X */
 	case USB_ID(0x0644, 0x804a): /* TEAC UD-301 */
 		return true;
+	case USB_ID(0x0644, 0x8043):
+		/* TEAC UD-501V2/UD-503/NT-503 */
+		if (product && !strcmp("UD-501", product)) {
+			return true;
+		} else {
+			return false;
+		}
 	}
 	return false;
 }
@@ -1186,7 +1203,7 @@ int snd_usb_select_mode_quirk(struct snd_usb_substream *subs,
 	struct usb_device *dev = subs->dev;
 	int err;
 
-	if (is_itf_usb_dsd_2alts_dac(subs->stream->chip->usb_id)) {
+	if (is_itf_usb_dsd_2alts_dac(subs->stream->chip)) {
 		/* First switch to alt set 0, otherwise the mode switch cmd
 		 * will not be accepted by the DAC
 		 */
@@ -1207,7 +1224,7 @@ int snd_usb_select_mode_quirk(struct snd_usb_substream *subs,
 			break;
 		}
 		mdelay(20);
-	} else if (is_itf_usb_dsd_3alts_dac(subs->stream->chip->usb_id)) {
+	} else if (is_itf_usb_dsd_3alts_dac(subs->stream->chip)) {
 		/* Vendor mode switch cmd is required. */
 		switch (fmt->altsetting) {
 		case 3: /* DSD mode (DSD_U32) requested */
@@ -1306,7 +1323,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_2alts_dac(chip->usb_id)
+	if (is_itf_usb_dsd_2alts_dac(chip)
 	    && (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS)
 		mdelay(20);
 
@@ -1394,13 +1411,13 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip,
 	}
 
 	/* ITF-USB DSD based DACs (2 altsets version) */
-	if (is_itf_usb_dsd_2alts_dac(chip->usb_id)) {
+	if (is_itf_usb_dsd_2alts_dac(chip)) {
 		if (fp->altsetting == 2)
 			return SNDRV_PCM_FMTBIT_DSD_U32_BE;
 	}
 
 	/* ITF-USB DSD based DACs (3 altsets version) */
-	if (is_itf_usb_dsd_3alts_dac(chip->usb_id)) {
+	if (is_itf_usb_dsd_3alts_dac(chip)) {
 		if (fp->altsetting == 3)
 			return SNDRV_PCM_FMTBIT_DSD_U32_BE;
 	}
-- 
2.11.1

  reply	other threads:[~2018-03-23 10:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-23 10:18 [PATCH 1/3] ALSA: usb-audio: Add native DSD support for Luxman DA-06 Nobutaka Okabe
2018-03-23 10:20 ` Nobutaka Okabe [this message]
2018-03-23 10:21   ` [PATCH 3/3] ALSA: usb-audio: Integrate native DSD support for ITF-USB based DACs Nobutaka Okabe
2018-03-23 21:14     ` Takashi Iwai
2018-03-23 21:11   ` [PATCH 2/3] ALSA: usb-audio: FIX native DSD support for TEAC UD-501 DAC Takashi Iwai
2018-03-23 21:11 ` [PATCH 1/3] ALSA: usb-audio: Add native DSD support for Luxman DA-06 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=20180323102000.6577-1-nob77413@gmail.com \
    --to=nob77413@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=gtmkramer@xs4all.nl \
    /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.