Bug 218603 - synaptics/conexant hi-res audio reports incorrect MaxPacketSize for 16bit output alt
Summary: synaptics/conexant hi-res audio reports incorrect MaxPacketSize for 16bit out...
Status: NEW
Alias: None
Product: Drivers
Classification: Unclassified
Component: Sound(ALSA) (show other bugs)
Hardware: All Linux
: P3 normal
Assignee: Jaroslav Kysela
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-03-15 15:18 UTC by Ian Malone
Modified: 2024-03-15 15:27 UTC (History)
0 users

See Also:
Kernel Version:
Subsystem:
Regression: No
Bisected commit-id:


Attachments
non working quirk patch (1.84 KB, patch)
2024-03-15 15:27 UTC, Ian Malone
Details | Diff

Description Ian Malone 2024-03-15 15:18:22 UTC
Related to bug 218544, which is partly a scheduler issue, but this device (Anker USB-C to 3.5 adapter), ID 0572:1b08 Conexant Systems (Rockwell), Inc. Hi-Res Audio, appears to incorrectly report MaxPacketSize for EP 1 OUT Alt 1 (16 bit stereo). 

wMaxPacketSize / (Max sampling frequency * sample bytes * channels )
EP 1 in
Alt 1 (16b)  192 / (48kHz * 2 * 2) = 1ms
Alt 2 (24b)  288 / (48kHz * 3 * 2) = 1ms
EP 1 out
Alt 1 (16b) 768 / (96kHz * 2 * 2) = 2ms
Alt 2 (24b) 576 / (96kHz * 3 * 2) = 1ms

EP 1 out, Alt 1 is an anomaly as the maximum packet size claims to be 2 frames. If I make the change to force it to 384 (obviously just a hack) then the output sound is still good:
--- sound/usb.orig/stream.c     2024-03-08 10:19:27.430507385 +0000
+++ sound/usb/stream.c  2024-03-12 16:13:43.212737555 +0000
@@ -690,6 +690,10 @@
        fp->ep_attr = get_endpoint(alts, 0)->bmAttributes;
        fp->datainterval = snd_usb_parse_datainterval(chip, alts);
        fp->protocol = protocol;
+       if(le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize)==768){
+         get_endpoint(alts, 0)->wMaxPacketSize = cpu_to_le16(384);
+         usb_audio_err_ratelimited(chip,"overwrote in stream");
+       }
        fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize);
        fp->channels = num_channels;
        if (snd_usb_get_speed(chip->dev) == USB_SPEED_HIGH)

I guess this should be correctly addressed as a device quirk, however I haven't been able to get that working yet.
Comment 1 Ian Malone 2024-03-15 15:27:45 UTC
Created attachment 305997 [details]
non working quirk patch

This is my non-working attempt at a quirk patch for the device. However it doesn't result in working sound output; although the device does get created and pipewire will connect things to it, playback just results in silence. I suspect I'm missing some feature, even just a mixer control. Changing the ifnum2 .type to QUIRK_AUDIO_STANDARD_INTERFACE works as previously. (Also Alt 2 needs defined, I'm not sure how to override a single alt without redefining the entire device, just defining ifnum = 2 causes errors probing the device.)
Lastly, not sure this quirk alone actually works, it seems the usb driver structure's MaxPacketSize needs overwritten, other things I've tried to reduce sound/usb's maxpacksize alone don't seem to change the amount of bandwidth that gets scheduled.

Note You need to log in before you can comment on or make changes to this bug.