Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3a8b2de0 authored by Sriharsha Allenki's avatar Sriharsha Allenki Committed by Gerrit - the friendly Code Review server
Browse files

usb: f_uac2: Add support for UAC2 function



Add support for the UAC2 function with the configfs
framework.
Also fix the audio quality issues by increasing the
number of USB_XFERS.

Change-Id: Ie94aee43dd52b0b711778420e485af72730dd28b
Signed-off-by: default avatarSriharsha Allenki <sallenki@codeaurora.org>
parent 21dd77e4
Loading
Loading
Loading
Loading
+65 −2
Original line number Diff line number Diff line
@@ -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
@@ -288,6 +291,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,
@@ -365,6 +375,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,
@@ -437,6 +454,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;
};
@@ -527,6 +576,7 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
	iad_desc.bFirstInterface = ret;

	std_ac_if_desc.bInterfaceNumber = ret;
	iad_desc.bFirstInterface = ret;
	uac2->ac_intf = ret;
	uac2->ac_alt = 0;

@@ -578,8 +628,8 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
	hs_epout_desc.bEndpointAddress = fs_epout_desc.bEndpointAddress;
	hs_epin_desc.bEndpointAddress = fs_epin_desc.bEndpointAddress;

	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, NULL);
	if (ret)
		return ret;

@@ -1007,6 +1057,19 @@ static struct usb_function *afunc_alloc(struct usb_function_instance *fi)
}

DECLARE_USB_FUNCTION_INIT(uac2, afunc_alloc_inst, afunc_alloc);

static int afunc_init(void)
{
	return usb_function_register(&uac2usb_func);
}
module_init(afunc_init);

static void __exit afunc_exit(void)
{
	usb_function_unregister(&uac2usb_func);
}
module_exit(afunc_exit);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Yadwinder Singh");
MODULE_AUTHOR("Jaswinder Singh");
+1 −1
Original line number Diff line number Diff line
@@ -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