diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c index db2d4980cb35..0927d4c0c1db 100644 --- a/drivers/usb/gadget/function/f_uac2.c +++ b/drivers/usb/gadget/function/f_uac2.c @@ -14,6 +14,9 @@ #include "u_audio.h" #include "u_uac2.h" +/* Keep everyone on toes */ +#define USB_XFERS 8 + /* * The driver implements a simple UAC_2 topology. * USB-OUT -> IT_1 -> OT_3 -> ALSA_Capture @@ -287,6 +290,13 @@ static struct usb_endpoint_descriptor hs_epout_desc = { .bInterval = 4, }; +static struct usb_ss_ep_comp_descriptor ss_epout_comp_desc = { + .bLength = sizeof(ss_epout_comp_desc), + .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, + + .wBytesPerInterval = cpu_to_le16(1024), +}; + /* CS AS ISO OUT Endpoint */ static struct uac2_iso_endpoint_descriptor as_iso_out_desc = { .bLength = sizeof as_iso_out_desc, @@ -364,6 +374,13 @@ static struct usb_endpoint_descriptor hs_epin_desc = { .bInterval = 4, }; +static struct usb_ss_ep_comp_descriptor ss_epin_comp_desc = { + .bLength = sizeof(ss_epin_comp_desc), + .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, + + .wBytesPerInterval = cpu_to_le16(1024), +}; + /* CS AS ISO IN Endpoint */ static struct uac2_iso_endpoint_descriptor as_iso_in_desc = { .bLength = sizeof as_iso_in_desc, @@ -436,6 +453,38 @@ static struct usb_descriptor_header *hs_audio_desc[] = { NULL, }; +static struct usb_descriptor_header *ss_audio_desc[] = { + (struct usb_descriptor_header *)&iad_desc, + (struct usb_descriptor_header *)&std_ac_if_desc, + + (struct usb_descriptor_header *)&ac_hdr_desc, + (struct usb_descriptor_header *)&in_clk_src_desc, + (struct usb_descriptor_header *)&out_clk_src_desc, + (struct usb_descriptor_header *)&usb_out_it_desc, + (struct usb_descriptor_header *)&io_in_it_desc, + (struct usb_descriptor_header *)&usb_in_ot_desc, + (struct usb_descriptor_header *)&io_out_ot_desc, + + (struct usb_descriptor_header *)&std_as_out_if0_desc, + (struct usb_descriptor_header *)&std_as_out_if1_desc, + + (struct usb_descriptor_header *)&as_out_hdr_desc, + (struct usb_descriptor_header *)&as_out_fmt1_desc, + (struct usb_descriptor_header *)&hs_epout_desc, + (struct usb_descriptor_header *)&ss_epout_comp_desc, + (struct usb_descriptor_header *)&as_iso_out_desc, + + (struct usb_descriptor_header *)&std_as_in_if0_desc, + (struct usb_descriptor_header *)&std_as_in_if1_desc, + + (struct usb_descriptor_header *)&as_in_hdr_desc, + (struct usb_descriptor_header *)&as_in_fmt1_desc, + (struct usb_descriptor_header *)&hs_epin_desc, + (struct usb_descriptor_header *)&ss_epin_comp_desc, + (struct usb_descriptor_header *)&as_iso_in_desc, + NULL, +}; + struct cntrl_cur_lay3 { __le32 dCUR; }; @@ -587,6 +636,41 @@ static void setup_descriptor(struct f_uac2_opts *opts) hs_audio_desc[i++] = USBDHDR(&as_iso_in_desc); } hs_audio_desc[i] = NULL; + + i = 0; + ss_audio_desc[i++] = USBDHDR(&iad_desc); + ss_audio_desc[i++] = USBDHDR(&std_ac_if_desc); + ss_audio_desc[i++] = USBDHDR(&ac_hdr_desc); + if (EPIN_EN(opts)) + ss_audio_desc[i++] = USBDHDR(&in_clk_src_desc); + if (EPOUT_EN(opts)) { + ss_audio_desc[i++] = USBDHDR(&out_clk_src_desc); + ss_audio_desc[i++] = USBDHDR(&usb_out_it_desc); + } + if (EPIN_EN(opts)) { + ss_audio_desc[i++] = USBDHDR(&io_in_it_desc); + ss_audio_desc[i++] = USBDHDR(&usb_in_ot_desc); + } + if (EPOUT_EN(opts)) { + ss_audio_desc[i++] = USBDHDR(&io_out_ot_desc); + ss_audio_desc[i++] = USBDHDR(&std_as_out_if0_desc); + ss_audio_desc[i++] = USBDHDR(&std_as_out_if1_desc); + ss_audio_desc[i++] = USBDHDR(&as_out_hdr_desc); + ss_audio_desc[i++] = USBDHDR(&as_out_fmt1_desc); + ss_audio_desc[i++] = USBDHDR(&hs_epout_desc); + ss_audio_desc[i++] = USBDHDR(&ss_epout_comp_desc); + ss_audio_desc[i++] = USBDHDR(&as_iso_out_desc); + } + if (EPIN_EN(opts)) { + ss_audio_desc[i++] = USBDHDR(&std_as_in_if0_desc); + ss_audio_desc[i++] = USBDHDR(&std_as_in_if1_desc); + ss_audio_desc[i++] = USBDHDR(&as_in_hdr_desc); + ss_audio_desc[i++] = USBDHDR(&as_in_fmt1_desc); + ss_audio_desc[i++] = USBDHDR(&hs_epin_desc); + ss_audio_desc[i++] = USBDHDR(&ss_epin_comp_desc); + ss_audio_desc[i++] = USBDHDR(&as_iso_in_desc); + } + ss_audio_desc[i] = NULL; } static int @@ -706,8 +790,8 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn) setup_descriptor(uac2_opts); - ret = usb_assign_descriptors(fn, fs_audio_desc, hs_audio_desc, NULL, - NULL); + ret = usb_assign_descriptors(fn, fs_audio_desc, hs_audio_desc, + ss_audio_desc, ss_audio_desc); if (ret) return ret; @@ -1135,6 +1219,7 @@ static struct usb_function *afunc_alloc(struct usb_function_instance *fi) } DECLARE_USB_FUNCTION_INIT(uac2, afunc_alloc_inst, afunc_alloc); + MODULE_LICENSE("GPL"); MODULE_AUTHOR("Yadwinder Singh"); MODULE_AUTHOR("Jaswinder Singh"); diff --git a/drivers/usb/gadget/function/u_uac2.h b/drivers/usb/gadget/function/u_uac2.h index 82048791eb6e..61f8745176fc 100644 --- a/drivers/usb/gadget/function/u_uac2.h +++ b/drivers/usb/gadget/function/u_uac2.h @@ -19,7 +19,7 @@ #define UAC2_DEF_PSRATE 48000 #define UAC2_DEF_PSSIZE 2 #define UAC2_DEF_CCHMASK 0x3 -#define UAC2_DEF_CSRATE 64000 +#define UAC2_DEF_CSRATE 44100 #define UAC2_DEF_CSSIZE 2 #define UAC2_DEF_REQ_NUM 2