public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] sound: usb: enable DSD output for ddHiFi TC44C
@ 2024-12-04 15:19 Adrian Ratiu
  2024-12-04 15:19 ` [PATCH 2/2] sound: usb: format: don't warn that raw DSD is unsupported Adrian Ratiu
  2024-12-05  7:11 ` [PATCH 1/2] sound: usb: enable DSD output for ddHiFi TC44C Takashi Iwai
  0 siblings, 2 replies; 5+ messages in thread
From: Adrian Ratiu @ 2024-12-04 15:19 UTC (permalink / raw)
  To: Takashi Iwai, Jaroslav Kysela
  Cc: linux-sound, linux-kernel, kernel, Adrian Ratiu

This is a UAC 2 DAC capable of raw DSD on intf 2 alt 4:

Bus 007 Device 004: ID 262a:9302 SAVITECH Corp. TC44C
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass          239 Miscellaneous Device
  bDeviceSubClass         2 [unknown]
  bDeviceProtocol         1 Interface Association
  bMaxPacketSize0        64
  idVendor           0x262a SAVITECH Corp.
  idProduct          0x9302 TC44C
  bcdDevice            0.01
  iManufacturer           1 DDHIFI
  iProduct                2 TC44C
  iSerial                 6 5000000001
.......
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       4
      bNumEndpoints           2
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol      32
      iInterface              0
	AudioStreaming Interface Descriptor:
          bLength                16
          bDescriptorType        36
          bDescriptorSubtype     1 (AS_GENERAL)
          bTerminalLink          3
          bmControls             0x00
          bFormatType            1
          bmFormats              0x80000000
          bNrChannels            2
          bmChannelConfig        0x00000000
          iChannelNames          0
.......

Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
---
 sound/usb/quirks.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
index 00101875d9a8..4897d7de7529 100644
--- a/sound/usb/quirks.c
+++ b/sound/usb/quirks.c
@@ -2265,6 +2265,8 @@ static const struct usb_audio_quirk_flags_table quirk_flags_table[] = {
 		   QUIRK_FLAG_ITF_USB_DSD_DAC | QUIRK_FLAG_CTL_MSG_DELAY),
 	DEVICE_FLG(0x154e, 0x300b, /* Marantz SA-KI RUBY / SA-12 */
 		   QUIRK_FLAG_DSD_RAW),
+	DEVICE_FLG(0x262a, 0x9302, /* ddHiFi TC44C */
+		   QUIRK_FLAG_DSD_RAW),
 	DEVICE_FLG(0x154e, 0x500e, /* Denon DN-X1600 */
 		   QUIRK_FLAG_IGNORE_CLOCK_SOURCE),
 	DEVICE_FLG(0x1686, 0x00dd, /* Zoom R16/24 */
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] sound: usb: format: don't warn that raw DSD is unsupported
  2024-12-04 15:19 [PATCH 1/2] sound: usb: enable DSD output for ddHiFi TC44C Adrian Ratiu
@ 2024-12-04 15:19 ` Adrian Ratiu
  2024-12-05  7:17   ` Takashi Iwai
  2024-12-05  7:11 ` [PATCH 1/2] sound: usb: enable DSD output for ddHiFi TC44C Takashi Iwai
  1 sibling, 1 reply; 5+ messages in thread
From: Adrian Ratiu @ 2024-12-04 15:19 UTC (permalink / raw)
  To: Takashi Iwai, Jaroslav Kysela
  Cc: linux-sound, linux-kernel, kernel, Adrian Ratiu

UAC 2 & 3 DAC's set bit 31 of the format to signal support for a
RAW_DATA type, typically used for DSD playback.

This is correctly tested by (format & UAC*_FORMAT_TYPE_I_RAW_DATA),
fp->dsd_raw = true; and call snd_usb_interface_dsd_format_quirks(),
however a confusing and unnecessary message gets printed because
the bit is not properly tested in the last "unsupported" if test.

For example:

usb 7-1: new high-speed USB device number 5 using xhci_hcd
usb 7-1: New USB device found, idVendor=262a, idProduct=9302, bcdDevice=0.01
usb 7-1: New USB device strings: Mfr=1, Product=2, SerialNumber=6
usb 7-1: Product: TC44C
usb 7-1: Manufacturer: TC44C
usb 7-1: SerialNumber: 5000000001
hid-generic 0003:262A:9302.001E: No inputs registered, leaving
hid-generic 0003:262A:9302.001E: hidraw6: USB HID v1.00 Device [DDHIFI TC44C] on usb-0000:08:00.3-1/input0
usb 7-1: 2:4 : unsupported format bits 0x100000000

This last "unsupported format" is actually wrong: we know the
format is a RAW_DATA which we assume is DSD, so there is no need
to print the confusing message.

Thus we update the condition to take into account bit 31 for DSD
(notice the "format <<= 1;" line above).

Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
---
 sound/usb/format.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/usb/format.c b/sound/usb/format.c
index 0cbf1d4fbe6e..fe2e0580e296 100644
--- a/sound/usb/format.c
+++ b/sound/usb/format.c
@@ -142,7 +142,7 @@ static u64 parse_audio_format_i_type(struct snd_usb_audio *chip,
 		pcm_formats |= SNDRV_PCM_FMTBIT_A_LAW;
 	if (format & BIT(UAC_FORMAT_TYPE_I_MULAW))
 		pcm_formats |= SNDRV_PCM_FMTBIT_MU_LAW;
-	if (format & ~0x3f) {
+	if (format & ~0x10000003F) {
 		usb_audio_info(chip,
 			 "%u:%d : unsupported format bits %#llx\n",
 			 fp->iface, fp->altsetting, format);
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] sound: usb: enable DSD output for ddHiFi TC44C
  2024-12-04 15:19 [PATCH 1/2] sound: usb: enable DSD output for ddHiFi TC44C Adrian Ratiu
  2024-12-04 15:19 ` [PATCH 2/2] sound: usb: format: don't warn that raw DSD is unsupported Adrian Ratiu
@ 2024-12-05  7:11 ` Takashi Iwai
  2024-12-05  7:32   ` Adrian Ratiu
  1 sibling, 1 reply; 5+ messages in thread
From: Takashi Iwai @ 2024-12-05  7:11 UTC (permalink / raw)
  To: Adrian Ratiu
  Cc: Takashi Iwai, Jaroslav Kysela, linux-sound, linux-kernel, kernel

On Wed, 04 Dec 2024 16:19:53 +0100,
Adrian Ratiu wrote:
> 
> This is a UAC 2 DAC capable of raw DSD on intf 2 alt 4:
> 
> Bus 007 Device 004: ID 262a:9302 SAVITECH Corp. TC44C
> Device Descriptor:
>   bLength                18
>   bDescriptorType         1
>   bcdUSB               2.00
>   bDeviceClass          239 Miscellaneous Device
>   bDeviceSubClass         2 [unknown]
>   bDeviceProtocol         1 Interface Association
>   bMaxPacketSize0        64
>   idVendor           0x262a SAVITECH Corp.
>   idProduct          0x9302 TC44C
>   bcdDevice            0.01
>   iManufacturer           1 DDHIFI
>   iProduct                2 TC44C
>   iSerial                 6 5000000001
> .......
>     Interface Descriptor:
>       bLength                 9
>       bDescriptorType         4
>       bInterfaceNumber        2
>       bAlternateSetting       4
>       bNumEndpoints           2
>       bInterfaceClass         1 Audio
>       bInterfaceSubClass      2 Streaming
>       bInterfaceProtocol      32
>       iInterface              0
> 	AudioStreaming Interface Descriptor:
>           bLength                16
>           bDescriptorType        36
>           bDescriptorSubtype     1 (AS_GENERAL)
>           bTerminalLink          3
>           bmControls             0x00
>           bFormatType            1
>           bmFormats              0x80000000
>           bNrChannels            2
>           bmChannelConfig        0x00000000
>           iChannelNames          0
> .......
> 
> Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
> ---
>  sound/usb/quirks.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
> index 00101875d9a8..4897d7de7529 100644
> --- a/sound/usb/quirks.c
> +++ b/sound/usb/quirks.c
> @@ -2265,6 +2265,8 @@ static const struct usb_audio_quirk_flags_table quirk_flags_table[] = {
>  		   QUIRK_FLAG_ITF_USB_DSD_DAC | QUIRK_FLAG_CTL_MSG_DELAY),
>  	DEVICE_FLG(0x154e, 0x300b, /* Marantz SA-KI RUBY / SA-12 */
>  		   QUIRK_FLAG_DSD_RAW),
> +	DEVICE_FLG(0x262a, 0x9302, /* ddHiFi TC44C */
> +		   QUIRK_FLAG_DSD_RAW),
>  	DEVICE_FLG(0x154e, 0x500e, /* Denon DN-X1600 */
>  		   QUIRK_FLAG_IGNORE_CLOCK_SOURCE),
>  	DEVICE_FLG(0x1686, 0x00dd, /* Zoom R16/24 */

The table is sorted in the ID number order.
Could you put it at the right position?


thanks,

Takashi

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] sound: usb: format: don't warn that raw DSD is unsupported
  2024-12-04 15:19 ` [PATCH 2/2] sound: usb: format: don't warn that raw DSD is unsupported Adrian Ratiu
@ 2024-12-05  7:17   ` Takashi Iwai
  0 siblings, 0 replies; 5+ messages in thread
From: Takashi Iwai @ 2024-12-05  7:17 UTC (permalink / raw)
  To: Adrian Ratiu
  Cc: Takashi Iwai, Jaroslav Kysela, linux-sound, linux-kernel, kernel

On Wed, 04 Dec 2024 16:19:54 +0100,
Adrian Ratiu wrote:
> 
> UAC 2 & 3 DAC's set bit 31 of the format to signal support for a
> RAW_DATA type, typically used for DSD playback.
> 
> This is correctly tested by (format & UAC*_FORMAT_TYPE_I_RAW_DATA),
> fp->dsd_raw = true; and call snd_usb_interface_dsd_format_quirks(),
> however a confusing and unnecessary message gets printed because
> the bit is not properly tested in the last "unsupported" if test.
> 
> For example:
> 
> usb 7-1: new high-speed USB device number 5 using xhci_hcd
> usb 7-1: New USB device found, idVendor=262a, idProduct=9302, bcdDevice=0.01
> usb 7-1: New USB device strings: Mfr=1, Product=2, SerialNumber=6
> usb 7-1: Product: TC44C
> usb 7-1: Manufacturer: TC44C
> usb 7-1: SerialNumber: 5000000001
> hid-generic 0003:262A:9302.001E: No inputs registered, leaving
> hid-generic 0003:262A:9302.001E: hidraw6: USB HID v1.00 Device [DDHIFI TC44C] on usb-0000:08:00.3-1/input0
> usb 7-1: 2:4 : unsupported format bits 0x100000000
> 
> This last "unsupported format" is actually wrong: we know the
> format is a RAW_DATA which we assume is DSD, so there is no need
> to print the confusing message.
> 
> Thus we update the condition to take into account bit 31 for DSD
> (notice the "format <<= 1;" line above).
> 
> Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>

IMO, it's better to clear the already checked format bit instead, as
there are two distinct bits depending on the protocol.
That is, something like:

--- a/sound/usb/format.c
+++ b/sound/usb/format.c
@@ -54,6 +54,7 @@ static u64 parse_audio_format_i_type(struct snd_usb_audio *chip,
 
 		if (format & UAC2_FORMAT_TYPE_I_RAW_DATA) {
 			pcm_formats |= SNDRV_PCM_FMTBIT_SPECIAL;
+			format &= ~UAC2_FORMAT_TYPE_I_RAW_DATA;
 			/* flag potentially raw DSD capable altsettings */
 			fp->dsd_raw = true;
 		}
@@ -67,8 +68,10 @@ static u64 parse_audio_format_i_type(struct snd_usb_audio *chip,
 		sample_width = as->bBitResolution;
 		sample_bytes = as->bSubslotSize;
 
-		if (format & UAC3_FORMAT_TYPE_I_RAW_DATA)
+		if (format & UAC3_FORMAT_TYPE_I_RAW_DATA) {
 			pcm_formats |= SNDRV_PCM_FMTBIT_SPECIAL;
+			format &= ~UAC3_FORMAT_TYPE_I_RAW_DATA;
+		}
 
 		format <<= 1;
 		break;


thanks,

Takashi


> ---
>  sound/usb/format.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sound/usb/format.c b/sound/usb/format.c
> index 0cbf1d4fbe6e..fe2e0580e296 100644
> --- a/sound/usb/format.c
> +++ b/sound/usb/format.c
> @@ -142,7 +142,7 @@ static u64 parse_audio_format_i_type(struct snd_usb_audio *chip,
>  		pcm_formats |= SNDRV_PCM_FMTBIT_A_LAW;
>  	if (format & BIT(UAC_FORMAT_TYPE_I_MULAW))
>  		pcm_formats |= SNDRV_PCM_FMTBIT_MU_LAW;
> -	if (format & ~0x3f) {
> +	if (format & ~0x10000003F) {
>  		usb_audio_info(chip,
>  			 "%u:%d : unsupported format bits %#llx\n",
>  			 fp->iface, fp->altsetting, format);
> -- 
> 2.45.2
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] sound: usb: enable DSD output for ddHiFi TC44C
  2024-12-05  7:11 ` [PATCH 1/2] sound: usb: enable DSD output for ddHiFi TC44C Takashi Iwai
@ 2024-12-05  7:32   ` Adrian Ratiu
  0 siblings, 0 replies; 5+ messages in thread
From: Adrian Ratiu @ 2024-12-05  7:32 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Jaroslav Kysela, linux-sound, linux-kernel, kernel

On Thu, 05 Dec 2024, Takashi Iwai <tiwai@suse.de> wrote:
> The table is sorted in the ID number order.  Could you put it at 
> the right position? 
 
Yes and I will also clear the format bit as you suggested
for the other patch.

Will wait a few days in case others have more feedback
then I will send a v2.

Many thanks,
Adrian

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-12-05  7:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-04 15:19 [PATCH 1/2] sound: usb: enable DSD output for ddHiFi TC44C Adrian Ratiu
2024-12-04 15:19 ` [PATCH 2/2] sound: usb: format: don't warn that raw DSD is unsupported Adrian Ratiu
2024-12-05  7:17   ` Takashi Iwai
2024-12-05  7:11 ` [PATCH 1/2] sound: usb: enable DSD output for ddHiFi TC44C Takashi Iwai
2024-12-05  7:32   ` Adrian Ratiu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox