Skip to contentSkip to conversation

add native DSD support for XMOS based DACs

PATCH Superseded Jurgen Kramer 3 participants 9 messages Sep 5, 2014 Sound

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 add native DSD support for XMOS based DACs

Add quirks for XMOS based DACs for native DSD playback support using the new DSD_U32_LE sample format.

This version adds native DSD support for:
- iFi Audio micro iDSD/nano iDSD (they use the same prod. id)
- DIYINHK USB to I2S/DSD converter

Changes from v1:
- use specific product id and alt setting per XMOS based device

---
 sound/usb/quirks.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
sound/usb/quirks.c +15 -0
index 19a921e..5ae0536 100644
@@ -1174,5 +1174,20 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip,
 		}
 	}
 
+	/* XMOS based USB DACs */
+	if (le16_to_cpu(chip->dev->descriptor.idVendor) == 0x20b1) {
+		switch (le16_to_cpu(chip->dev->descriptor.idProduct)) {
+		/* iFi Audio micro/nano iDSD */
+		case 0x3008:
+			if (fp->altsetting == 2)
+				return SNDRV_PCM_FMTBIT_DSD_U32_LE;
+		/* DIYINHK DSD DXD 384kHz USB to I2S/DSD */
+		case 0x2009:
+			if (fp->altsetting == 3)
+				return SNDRV_PCM_FMTBIT_DSD_U32_LE;
+		default:
+			return 0;
+		}
+	}
 	return 0;
 }
Signature · 1 line
1.9.3
#1 lore raw

At Fri, 5 Sep 2014 14:24:57 +0200,

Quoted 21 lines · Jurgen Kramer

Add quirks for XMOS based DACs for native DSD playback support using the new DSD_U32_LE sample format.

This version adds native DSD support for:
- iFi Audio micro iDSD/nano iDSD (they use the same prod. id)
- DIYINHK USB to I2S/DSD converter

Changes from v1:
- use specific product id and alt setting per XMOS based device

---
 sound/usb/quirks.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
sound/usb/quirks.c +0 -0
index 19a921e..5ae0536 100644

sound/usb/quirks.c u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip, · line 1183

Quoted 10 lines
sound/usb/quirks.c +7 -0
@@ -1174,5 +1174,20 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip,
 		}
 	}
 
+	/* XMOS based USB DACs */
+	if (le16_to_cpu(chip->dev->descriptor.idVendor) == 0x20b1) {
+		switch (le16_to_cpu(chip->dev->descriptor.idProduct)) {
+		/* iFi Audio micro/nano iDSD */
+		case 0x3008:
+			if (fp->altsetting == 2)
+				return SNDRV_PCM_FMTBIT_DSD_U32_LE;

Missing break?

sound/usb/quirks.c u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip, · line 1187

Quoted 4 lines
sound/usb/quirks.c +4 -0
+		/* DIYINHK DSD DXD 384kHz USB to I2S/DSD */
+		case 0x2009:
+			if (fp->altsetting == 3)
+				return SNDRV_PCM_FMTBIT_DSD_U32_LE;

Ditto.

Quoted 8 lines
sound/usb/quirks.c +4 -0
+		default:
+			return 0;
+		}
+	}
 	return 0;
 }
Signature · 1 line
1.9.3

Takashi

#2 lore raw
Quoted 26 lines · Takashi Iwai

At Fri, 5 Sep 2014 14:24:57 +0200,

Quoted 24 lines · Jurgen Kramer

Add quirks for XMOS based DACs for native DSD playback support using the new DSD_U32_LE sample format.

This version adds native DSD support for:
- iFi Audio micro iDSD/nano iDSD (they use the same prod. id)
- DIYINHK USB to I2S/DSD converter

Changes from v1:
- use specific product id and alt setting per XMOS based device

---
 sound/usb/quirks.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
sound/usb/quirks.c +0 -0
index 19a921e..5ae0536 100644
@@ -1174,5 +1174,20 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip,
 		}
 	}
 
Quoted 9 lines

sound/usb/quirks.c u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip, · line 1183

Quoted 7 lines
sound/usb/quirks.c +7 -0
+	/* XMOS based USB DACs */
+	if (le16_to_cpu(chip->dev->descriptor.idVendor) == 0x20b1) {
+		switch (le16_to_cpu(chip->dev->descriptor.idProduct)) {
+		/* iFi Audio micro/nano iDSD */
+		case 0x3008:
+			if (fp->altsetting == 2)
+				return SNDRV_PCM_FMTBIT_DSD_U32_LE;

Missing break?

It is already returning. Where would the break go?

Quoted 7 lines

sound/usb/quirks.c u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip, · line 1187

Quoted 5 lines
sound/usb/quirks.c +4 -0
+		/* DIYINHK DSD DXD 384kHz USB to I2S/DSD */
+		case 0x2009:
+			if (fp->altsetting == 3)
+				return SNDRV_PCM_FMTBIT_DSD_U32_LE;

Ditto.

See above.

Quoted 8 lines

sound/usb/quirks.c u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip, · line 1193

Quoted 8 lines
sound/usb/quirks.c +4 -0
+		default:
+			return 0;
+		}
+	}
 	return 0;
 }

Jurgen

#3 lore raw

At Fri, 05 Sep 2014 15:58:39 +0200,

Quoted 37 lines · Jurgen Kramer
Quoted 26 lines · Takashi Iwai

At Fri, 5 Sep 2014 14:24:57 +0200,

Quoted 24 lines · Jurgen Kramer

Add quirks for XMOS based DACs for native DSD playback support using the new DSD_U32_LE sample format.

This version adds native DSD support for:
- iFi Audio micro iDSD/nano iDSD (they use the same prod. id)
- DIYINHK USB to I2S/DSD converter

Changes from v1:
- use specific product id and alt setting per XMOS based device

---
 sound/usb/quirks.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
sound/usb/quirks.c +0 -0
index 19a921e..5ae0536 100644
@@ -1174,5 +1174,20 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip,
 		}
 	}
 
Quoted 9 lines

sound/usb/quirks.c u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip, · line 1183

Quoted 7 lines
sound/usb/quirks.c +7 -0
+	/* XMOS based USB DACs */
+	if (le16_to_cpu(chip->dev->descriptor.idVendor) == 0x20b1) {
+		switch (le16_to_cpu(chip->dev->descriptor.idProduct)) {
+		/* iFi Audio micro/nano iDSD */
+		case 0x3008:
+			if (fp->altsetting == 2)
+				return SNDRV_PCM_FMTBIT_DSD_U32_LE;

Missing break?

Quoted 1 line

It is already returning. Where would the break go?

What if fp->altsetting == 3 with 20b1:3008 chip?
Then it falls down to below, and return SNDRV_PCM_FMTBIT_DSD_U32_LE. Is this expected?

Quoted 8 lines
Quoted 7 lines

sound/usb/quirks.c u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip, · line 1187

Quoted 5 lines
sound/usb/quirks.c +4 -0
+		/* DIYINHK DSD DXD 384kHz USB to I2S/DSD */
+		case 0x2009:
+			if (fp->altsetting == 3)
+				return SNDRV_PCM_FMTBIT_DSD_U32_LE;

Ditto.

See above.

If the fallthrough is intentional, you *must* put a comment it's really a fallthrough.

Takashi

Quoted 10 lines
Quoted 8 lines

sound/usb/quirks.c u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip, · line 1193

Quoted 8 lines
sound/usb/quirks.c +4 -0
+		default:
+			return 0;
+		}
+	}
 	return 0;
 }

Jurgen

#4 lore raw
Quoted 39 lines · Takashi Iwai

At Fri, 05 Sep 2014 15:58:39 +0200,

Quoted 37 lines · Jurgen Kramer
Quoted 35 lines · Takashi Iwai

At Fri, 5 Sep 2014 14:24:57 +0200,

Quoted 21 lines · Jurgen Kramer

Add quirks for XMOS based DACs for native DSD playback support using the new DSD_U32_LE sample format.

This version adds native DSD support for:
- iFi Audio micro iDSD/nano iDSD (they use the same prod. id)
- DIYINHK USB to I2S/DSD converter

Changes from v1:
- use specific product id and alt setting per XMOS based device

---
 sound/usb/quirks.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
sound/usb/quirks.c +0 -0
index 19a921e..5ae0536 100644

sound/usb/quirks.c u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip, · line 1183

Quoted 10 lines
sound/usb/quirks.c +7 -0
@@ -1174,5 +1174,20 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip,
 		}
 	}
 
+	/* XMOS based USB DACs */
+	if (le16_to_cpu(chip->dev->descriptor.idVendor) == 0x20b1) {
+		switch (le16_to_cpu(chip->dev->descriptor.idProduct)) {
+		/* iFi Audio micro/nano iDSD */
+		case 0x3008:
+			if (fp->altsetting == 2)
+				return SNDRV_PCM_FMTBIT_DSD_U32_LE;

Missing break?

Quoted 5 lines
Quoted 1 line

It is already returning. Where would the break go?

What if fp->altsetting == 3 with 20b1:3008 chip?
Then it falls down to below, and return SNDRV_PCM_FMTBIT_DSD_U32_LE. Is this expected?

With fp->altsetting == 3 for 20b1:3008 I do not see it returning SNDRV_PCM_FMTBIT_DSD_U32_LE, it falls through to 'return 0'.

However, would this be more appropriate/readable?:

case 0x3008:

	if (fp->altsetting == 2)
		return SNDRV_PCM_FMTBIT_DSD_U32_LE;
	else
		break;

or even:

case 0x3008:

	if (fp->altsetting == 2)
		return SNDRV_PCM_FMTBIT_DSD_U32_LE;
	else
		return 0;
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

sound/usb/quirks.c u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip, · line 1187

Quoted 5 lines
sound/usb/quirks.c +4 -0
+		/* DIYINHK DSD DXD 384kHz USB to I2S/DSD */
+		case 0x2009:
+			if (fp->altsetting == 3)
+				return SNDRV_PCM_FMTBIT_DSD_U32_LE;

Ditto.

Quoted 6 lines
Quoted 1 line

See above.

If the fallthrough is intentional, you *must* put a comment it's really a fallthrough.

Jurgen

#5 lore raw

At Fri, 05 Sep 2014 16:37:13 +0200,

Quoted 41 lines · Jurgen Kramer
Quoted 39 lines · Takashi Iwai

At Fri, 05 Sep 2014 15:58:39 +0200,

Quoted 37 lines · Jurgen Kramer
Quoted 35 lines · Takashi Iwai

At Fri, 5 Sep 2014 14:24:57 +0200,

Quoted 21 lines · Jurgen Kramer

Add quirks for XMOS based DACs for native DSD playback support using the new DSD_U32_LE sample format.

This version adds native DSD support for:
- iFi Audio micro iDSD/nano iDSD (they use the same prod. id)
- DIYINHK USB to I2S/DSD converter

Changes from v1:
- use specific product id and alt setting per XMOS based device

---
 sound/usb/quirks.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
sound/usb/quirks.c +0 -0
index 19a921e..5ae0536 100644

sound/usb/quirks.c u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip, · line 1183

Quoted 10 lines
sound/usb/quirks.c +7 -0
@@ -1174,5 +1174,20 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip,
 		}
 	}
 
+	/* XMOS based USB DACs */
+	if (le16_to_cpu(chip->dev->descriptor.idVendor) == 0x20b1) {
+		switch (le16_to_cpu(chip->dev->descriptor.idProduct)) {
+		/* iFi Audio micro/nano iDSD */
+		case 0x3008:
+			if (fp->altsetting == 2)
+				return SNDRV_PCM_FMTBIT_DSD_U32_LE;

Missing break?

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

It is already returning. Where would the break go?

What if fp->altsetting == 3 with 20b1:3008 chip?
Then it falls down to below, and return SNDRV_PCM_FMTBIT_DSD_U32_LE. Is this expected?

With fp->altsetting == 3 for 20b1:3008 I do not see it returning SNDRV_PCM_FMTBIT_DSD_U32_LE, it falls through to 'return 0'.

Well, read your C text book carefully again :)

The tricky part of switch/case behavior is that it falls through to the next case, not going out of switch block.

Quoted 7 lines

However, would this be more appropriate/readable?:

case 0x3008:

	if (fp->altsetting == 2)
		return SNDRV_PCM_FMTBIT_DSD_U32_LE;
	else
		break;

Just put break. The standard form of switch/case is like:

	switch (cond) {
	case xxx:
		if (something)
			return abc;
		break;
	case yyy:
		if (another)
			return def;
		break;
	default:
		break;
	}

	return 0;

Takashi

Quoted 24 lines

or even:

case 0x3008:

	if (fp->altsetting == 2)
		return SNDRV_PCM_FMTBIT_DSD_U32_LE;
	else
		return 0;
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

sound/usb/quirks.c u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip, · line 1187

Quoted 5 lines
sound/usb/quirks.c +4 -0
+		/* DIYINHK DSD DXD 384kHz USB to I2S/DSD */
+		case 0x2009:
+			if (fp->altsetting == 3)
+				return SNDRV_PCM_FMTBIT_DSD_U32_LE;

Ditto.

Quoted 6 lines
Quoted 1 line

See above.

If the fallthrough is intentional, you *must* put a comment it's really a fallthrough.

Jurgen

#6 lore raw
Quoted 45 lines · Takashi Iwai

At Fri, 05 Sep 2014 16:37:13 +0200,

Quoted 43 lines · Jurgen Kramer
Quoted 41 lines · Takashi Iwai

At Fri, 05 Sep 2014 15:58:39 +0200,

Quoted 38 lines · Jurgen Kramer
Quoted 26 lines · Takashi Iwai

At Fri, 5 Sep 2014 14:24:57 +0200,

Quoted 24 lines · Jurgen Kramer

Add quirks for XMOS based DACs for native DSD playback support using the new DSD_U32_LE sample format.

This version adds native DSD support for:
- iFi Audio micro iDSD/nano iDSD (they use the same prod. id)
- DIYINHK USB to I2S/DSD converter

Changes from v1:
- use specific product id and alt setting per XMOS based device

---
 sound/usb/quirks.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
sound/usb/quirks.c +0 -0
index 19a921e..5ae0536 100644
@@ -1174,5 +1174,20 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip,
 		}
 	}
 
Quoted 9 lines

sound/usb/quirks.c u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip, · line 1183

Quoted 7 lines
sound/usb/quirks.c +7 -0
+	/* XMOS based USB DACs */
+	if (le16_to_cpu(chip->dev->descriptor.idVendor) == 0x20b1) {
+		switch (le16_to_cpu(chip->dev->descriptor.idProduct)) {
+		/* iFi Audio micro/nano iDSD */
+		case 0x3008:
+			if (fp->altsetting == 2)
+				return SNDRV_PCM_FMTBIT_DSD_U32_LE;

Missing break?

It is already returning. Where would the break go?

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

What if fp->altsetting == 3 with 20b1:3008 chip?
Then it falls down to below, and return SNDRV_PCM_FMTBIT_DSD_U32_LE. Is this expected?

With fp->altsetting == 3 for 20b1:3008 I do not see it returning SNDRV_PCM_FMTBIT_DSD_U32_LE, it falls through to 'return 0'.

Well, read your C text book carefully again :)

Haha!

Quoted 13 lines

The tricky part of switch/case behavior is that it falls through to the next case, not going out of switch block.

Quoted 7 lines

However, would this be more appropriate/readable?:

case 0x3008:

	if (fp->altsetting == 2)
		return SNDRV_PCM_FMTBIT_DSD_U32_LE;
	else
		break;

Just put break. The standard form of switch/case is like:

Quoted 14 lines
	switch (cond) {
	case xxx:
		if (something)
			return abc;
		break;
	case yyy:
		if (another)
			return def;
		break;
	default:
		break;
	}

	return 0;

Thanks, new patch coming up.

Jurgen

#7 lore raw
In reply to Jurgen Kramer

sound/usb/quirks.c u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip, · line 1181

Quoted 5 lines · Jurgen Kramer
sound/usb/quirks.c +5 -0
+	/* XMOS based USB DACs */
+	if (le16_to_cpu(chip->dev->descriptor.idVendor) == 0x20b1) {
+		switch (le16_to_cpu(chip->dev->descriptor.idProduct)) {
+		/* iFi Audio micro/nano iDSD */
+		case 0x3008:

And you don't need to go through the descriptors; you can test chip->usb_id directly (see snd_usb_set_format_quirk()).

Regards,
Clemens

#8 lore raw
Quoted 9 lines · Clemens Ladisch

sound/usb/quirks.c u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip, · line 1181

Quoted 5 lines · Jurgen Kramer
sound/usb/quirks.c +5 -0
+	/* XMOS based USB DACs */
+	if (le16_to_cpu(chip->dev->descriptor.idVendor) == 0x20b1) {
+		switch (le16_to_cpu(chip->dev->descriptor.idProduct)) {
+		/* iFi Audio micro/nano iDSD */
+		case 0x3008:

And you don't need to go through the descriptors; you can test chip->usb_id directly (see snd_usb_set_format_quirk()).

Thanks, will do!

Jurgen