linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/2] usb: gadget: f_uac2: Fixes for SuperSpeed
@ 2021-09-09 17:48 Jack Pham
  2021-09-09 17:48 ` [PATCH v3 1/2] usb: gadget: f_uac2: Add missing companion descriptor for feedback EP Jack Pham
  2021-09-09 17:48 ` [PATCH v3 2/2] usb: gadget: f_uac2: Populate SS descriptors' wBytesPerInterval Jack Pham
  0 siblings, 2 replies; 3+ messages in thread
From: Jack Pham @ 2021-09-09 17:48 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Felipe Balbi, Thinh Nguyen, Ruslan Bilovol,
	Jerome Brunet, Pavel Hofman
  Cc: linux-usb, Ferry Toth, Wesley Cheng, Pawel Laszczak, Jack Pham

This series fixes SuperSpeed (and SuperSpeedPlus) functionality for the
UAC2 function driver.  The first patch fixes enumeration failures due
to a missing companion descriptor, while the second patch is necessary
for actual data transfer functionality to work.

V3: Fixed elementary "." vs "->" mistake in patch 2
V2: Made this a series. Patch 1 revised to create a separate descriptor just
    for the feedback endpoint. Patch 2 is new.

Jack Pham (2):
  usb: gadget: f_uac2: Add missing companion descriptor for feedback EP
  usb: gadget: f_uac2: Populate SS descriptors' wBytesPerInterval

 drivers/usb/gadget/function/f_uac2.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

-- 
2.24.0


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

* [PATCH v3 1/2] usb: gadget: f_uac2: Add missing companion descriptor for feedback EP
  2021-09-09 17:48 [PATCH v3 0/2] usb: gadget: f_uac2: Fixes for SuperSpeed Jack Pham
@ 2021-09-09 17:48 ` Jack Pham
  2021-09-09 17:48 ` [PATCH v3 2/2] usb: gadget: f_uac2: Populate SS descriptors' wBytesPerInterval Jack Pham
  1 sibling, 0 replies; 3+ messages in thread
From: Jack Pham @ 2021-09-09 17:48 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Felipe Balbi, Thinh Nguyen, Ruslan Bilovol,
	Jerome Brunet, Pavel Hofman
  Cc: linux-usb, Ferry Toth, Wesley Cheng, Pawel Laszczak, Jack Pham

The f_uac2 function fails to enumerate when connected in SuperSpeed
due to the feedback endpoint missing the companion descriptor.
Add a new ss_epin_fback_desc_comp descriptor and append it behind the
ss_epin_fback_desc both in the static definition of the ss_audio_desc
structure as well as its dynamic construction in setup_headers().

Fixes: 24f779dac8f3 ("usb: gadget: f_uac2/u_audio: add feedback endpoint support")
Signed-off-by: Jack Pham <jackp@codeaurora.org>
---
v3: No change
v2: Created a separate descriptor just for the feedback endpoint. This is
    in preparation for patch 2 which populates the wBytesPerInterval
    which may be different per endpoint.

 drivers/usb/gadget/function/f_uac2.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c
index 3c34995276e7..d89c1ebb07f4 100644
--- a/drivers/usb/gadget/function/f_uac2.c
+++ b/drivers/usb/gadget/function/f_uac2.c
@@ -406,6 +406,14 @@ static struct usb_endpoint_descriptor ss_epin_fback_desc = {
 	.bInterval = 4,
 };
 
+static struct usb_ss_ep_comp_descriptor ss_epin_fback_desc_comp = {
+	.bLength		= sizeof(ss_epin_fback_desc_comp),
+	.bDescriptorType	= USB_DT_SS_ENDPOINT_COMP,
+	.bMaxBurst		= 0,
+	.bmAttributes		= 0,
+	.wBytesPerInterval	= cpu_to_le16(4),
+};
+
 
 /* Audio Streaming IN Interface - Alt0 */
 static struct usb_interface_descriptor std_as_in_if0_desc = {
@@ -597,6 +605,7 @@ static struct usb_descriptor_header *ss_audio_desc[] = {
 	(struct usb_descriptor_header *)&ss_epout_desc_comp,
 	(struct usb_descriptor_header *)&as_iso_out_desc,
 	(struct usb_descriptor_header *)&ss_epin_fback_desc,
+	(struct usb_descriptor_header *)&ss_epin_fback_desc_comp,
 
 	(struct usb_descriptor_header *)&std_as_in_if0_desc,
 	(struct usb_descriptor_header *)&std_as_in_if1_desc,
@@ -705,6 +714,7 @@ static void setup_headers(struct f_uac2_opts *opts,
 {
 	struct usb_ss_ep_comp_descriptor *epout_desc_comp = NULL;
 	struct usb_ss_ep_comp_descriptor *epin_desc_comp = NULL;
+	struct usb_ss_ep_comp_descriptor *epin_fback_desc_comp = NULL;
 	struct usb_endpoint_descriptor *epout_desc;
 	struct usb_endpoint_descriptor *epin_desc;
 	struct usb_endpoint_descriptor *epin_fback_desc;
@@ -730,6 +740,7 @@ static void setup_headers(struct f_uac2_opts *opts,
 		epout_desc_comp = &ss_epout_desc_comp;
 		epin_desc_comp = &ss_epin_desc_comp;
 		epin_fback_desc = &ss_epin_fback_desc;
+		epin_fback_desc_comp = &ss_epin_fback_desc_comp;
 		ep_int_desc = &ss_ep_int_desc;
 	}
 
@@ -773,8 +784,11 @@ static void setup_headers(struct f_uac2_opts *opts,
 
 		headers[i++] = USBDHDR(&as_iso_out_desc);
 
-		if (EPOUT_FBACK_IN_EN(opts))
+		if (EPOUT_FBACK_IN_EN(opts)) {
 			headers[i++] = USBDHDR(epin_fback_desc);
+			if (epin_fback_desc_comp)
+				headers[i++] = USBDHDR(epin_fback_desc_comp);
+		}
 	}
 
 	if (EPIN_EN(opts)) {
-- 
2.24.0


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

* [PATCH v3 2/2] usb: gadget: f_uac2: Populate SS descriptors' wBytesPerInterval
  2021-09-09 17:48 [PATCH v3 0/2] usb: gadget: f_uac2: Fixes for SuperSpeed Jack Pham
  2021-09-09 17:48 ` [PATCH v3 1/2] usb: gadget: f_uac2: Add missing companion descriptor for feedback EP Jack Pham
@ 2021-09-09 17:48 ` Jack Pham
  1 sibling, 0 replies; 3+ messages in thread
From: Jack Pham @ 2021-09-09 17:48 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Felipe Balbi, Thinh Nguyen, Ruslan Bilovol,
	Jerome Brunet, Pavel Hofman
  Cc: linux-usb, Ferry Toth, Wesley Cheng, Pawel Laszczak, Jack Pham

For Isochronous endpoints, the SS companion descriptor's
wBytesPerInterval field is required to reserve bus time in order
to transmit the required payload during the service interval.
If left at 0, the UAC2 function is unable to transact data on its
playback or capture endpoints in SuperSpeed mode.

Since f_uac2 currently does not support any bursting this value can
be exactly equal to the calculated wMaxPacketSize.

Tested with Windows 10 as a host.

Fixes: f8cb3d556be3 ("usb: f_uac2: adds support for SS and SSP")
Signed-off-by: Jack Pham <jackp@codeaurora.org>
---
v3: Fix to use "." instead of "->" for non-pointer to structure
v2: New patch

 drivers/usb/gadget/function/f_uac2.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c
index d89c1ebb07f4..33d60b926bae 100644
--- a/drivers/usb/gadget/function/f_uac2.c
+++ b/drivers/usb/gadget/function/f_uac2.c
@@ -1178,6 +1178,9 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
 	agdev->out_ep_maxpsize = max_t(u16, agdev->out_ep_maxpsize,
 				le16_to_cpu(ss_epout_desc.wMaxPacketSize));
 
+	ss_epin_desc_comp.wBytesPerInterval = ss_epin_desc.wMaxPacketSize;
+	ss_epout_desc_comp.wBytesPerInterval = ss_epout_desc.wMaxPacketSize;
+
 	// HS and SS endpoint addresses are copied from autoconfigured FS descriptors
 	hs_ep_int_desc.bEndpointAddress = fs_ep_int_desc.bEndpointAddress;
 	hs_epout_desc.bEndpointAddress = fs_epout_desc.bEndpointAddress;
-- 
2.24.0


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

end of thread, other threads:[~2021-09-09 17:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-09 17:48 [PATCH v3 0/2] usb: gadget: f_uac2: Fixes for SuperSpeed Jack Pham
2021-09-09 17:48 ` [PATCH v3 1/2] usb: gadget: f_uac2: Add missing companion descriptor for feedback EP Jack Pham
2021-09-09 17:48 ` [PATCH v3 2/2] usb: gadget: f_uac2: Populate SS descriptors' wBytesPerInterval Jack Pham

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).