Re: [PATCH v2 1/2 RESEND] usb: gadget: u_audio: pass channel counts explicitly

From: kaf

Date: Fri Oct 30 2026 - 12:31:25 EST


On 2026-10-23 03:39, Francesco Lavra wrote:
On Fri, 2026-10-16 at 09:25 -0700, Kyle Farrell wrote:
u_audio currently derives the channel count from the channel mask in
struct uac_params in several places.  Instead, pass the resolved count
explicitly, so the shared audio implementation does not depend on how
an individual USB audio function represents its channel configuration.

Initialize the new channel count fields from the existing channel masks.
This preserves generated descriptors and makes no change to user-visible
behavior.

Assisted-by: LLM
Signed-off-by: Kyle Farrell <kaf@xxxxxxxxxx>
---
...
diff --git a/drivers/usb/gadget/function/u_audio.h
b/drivers/usb/gadget/function/u_audio.h
index 9512b8fccfaa..46e1d6b5ca4e 100644
--- a/drivers/usb/gadget/function/u_audio.h
+++ b/drivers/usb/gadget/function/u_audio.h
@@ -41,12 +41,14 @@ struct uac_fu_params {
 struct uac_params {
        /* playback */
        int p_chmask;   /* channel mask */

With these changes, the channel masks are no longer used in u_audio.c, so
we can remove them.

+       unsigned int p_channels;        /* resolved number of channels */
        int p_srate;    /* rate in Hz */
        int p_ssize;    /* sample size */
        struct uac_fu_params p_fu;      /* Feature Unit parameters */
 
        /* capture */
        int c_chmask;   /* channel mask */
+       unsigned int c_channels;        /* resolved number of channels */
        int c_srate;    /* rate in Hz */
        int c_ssize;    /* sample size */
        struct uac_fu_params c_fu;      /* Feature Unit parameters */

Agreed, and thanks for taking a look. The resolved channel counts replace the channel masks.
I'll remove them in v3.