summaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/function/f_uac2.c
diff options
context:
space:
mode:
authorJames Gruber <jimmyjgruber@gmail.com>2023-09-14 15:27:46 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-10-05 09:35:43 +0200
commitde2eb28cdb76df9ce7587e1c6552b169069af4bb (patch)
tree1265bc4e1592071efb2410fd4be16cfd64292f40 /drivers/usb/gadget/function/f_uac2.c
parentaf313201946a7e64f6985711136ef02f9113a8fc (diff)
downloadlinux-stable-de2eb28cdb76df9ce7587e1c6552b169069af4bb.tar.gz
linux-stable-de2eb28cdb76df9ce7587e1c6552b169069af4bb.tar.bz2
linux-stable-de2eb28cdb76df9ce7587e1c6552b169069af4bb.zip
usb: gadget: f_uac2: allow changing terminal types through configfs
Add "c_terminal_type" and "p_terminal_type" configfs entries in order to allow the user to change the capture and playback terminal type codes. These fields affect the type of audio device that Windows detects, so being able to modify this is useful when it would be advantageous for a gadget to be detected as something other than a generic speaker/microphone. The fields default to microphone for the capture type field and speaker for the playback type field as was the case before. Signed-off-by: James Gruber <jimmyjgruber@gmail.com> Link: https://lore.kernel.org/r/20230914222746.155126-1-jimmyjgruber@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/gadget/function/f_uac2.c')
-rw-r--r--drivers/usb/gadget/function/f_uac2.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c
index 0219cd79493a..f9a0f07a7476 100644
--- a/drivers/usb/gadget/function/f_uac2.c
+++ b/drivers/usb/gadget/function/f_uac2.c
@@ -212,7 +212,7 @@ static struct uac2_input_terminal_descriptor io_in_it_desc = {
.bDescriptorSubtype = UAC_INPUT_TERMINAL,
/* .bTerminalID = DYNAMIC */
- .wTerminalType = cpu_to_le16(UAC_INPUT_TERMINAL_MICROPHONE),
+ /* .wTerminalType = DYNAMIC */
.bAssocTerminal = 0,
/* .bCSourceID = DYNAMIC */
.iChannelNames = 0,
@@ -240,7 +240,7 @@ static struct uac2_output_terminal_descriptor io_out_ot_desc = {
.bDescriptorSubtype = UAC_OUTPUT_TERMINAL,
/* .bTerminalID = DYNAMIC */
- .wTerminalType = cpu_to_le16(UAC_OUTPUT_TERMINAL_SPEAKER),
+ /* .wTerminalType = DYNAMIC */
.bAssocTerminal = 0,
/* .bSourceID = DYNAMIC */
/* .bCSourceID = DYNAMIC */
@@ -977,6 +977,9 @@ static void setup_descriptor(struct f_uac2_opts *opts)
iad_desc.bInterfaceCount++;
}
+ io_in_it_desc.wTerminalType = cpu_to_le16(opts->c_terminal_type);
+ io_out_ot_desc.wTerminalType = cpu_to_le16(opts->p_terminal_type);
+
setup_headers(opts, fs_audio_desc, USB_SPEED_FULL);
setup_headers(opts, hs_audio_desc, USB_SPEED_HIGH);
setup_headers(opts, ss_audio_desc, USB_SPEED_SUPER);
@@ -2095,6 +2098,9 @@ UAC2_ATTRIBUTE(s16, c_volume_res);
UAC2_ATTRIBUTE(u32, fb_max);
UAC2_ATTRIBUTE_STRING(function_name);
+UAC2_ATTRIBUTE(s16, p_terminal_type);
+UAC2_ATTRIBUTE(s16, c_terminal_type);
+
static struct configfs_attribute *f_uac2_attrs[] = {
&f_uac2_opts_attr_p_chmask,
&f_uac2_opts_attr_p_srate,
@@ -2122,6 +2128,9 @@ static struct configfs_attribute *f_uac2_attrs[] = {
&f_uac2_opts_attr_function_name,
+ &f_uac2_opts_attr_p_terminal_type,
+ &f_uac2_opts_attr_c_terminal_type,
+
NULL,
};
@@ -2180,6 +2189,9 @@ static struct usb_function_instance *afunc_alloc_inst(void)
snprintf(opts->function_name, sizeof(opts->function_name), "Source/Sink");
+ opts->p_terminal_type = UAC2_DEF_P_TERM_TYPE;
+ opts->c_terminal_type = UAC2_DEF_C_TERM_TYPE;
+
return &opts->func_inst;
}