[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240928150905.2616313-7-crwulff@gmail.com>
Date: Sat, 28 Sep 2024 11:08:57 -0400
From: crwulff@...il.com
To: linux-usb@...r.kernel.org
Cc: Pavel Hofman <pavel.hofman@...tera.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
James Gruber <jimmyjgruber@...il.com>,
Jeff Johnson <quic_jjohnson@...cinc.com>,
John Keeping <jkeeping@...usicbrands.com>,
Jonathan Corbet <corbet@....net>,
Lee Jones <lee@...nel.org>,
Perr Zhang <perr@...7.net>,
linux-doc@...r.kernel.org,
linux-kernel@...r.kernel.org,
Chris Wulff <crwulff@...il.com>
Subject: [PATCH RFC 06/14] usb: gadget: f_uac1: Add terminal type attributes
From: Chris Wulff <crwulff@...il.com>
Allow the user to set the terminal types. This matches the options
in f_uac2.
Signed-off-by: Chris Wulff <crwulff@...il.com>
---
Documentation/ABI/testing/configfs-usb-gadget-uac1 | 2 ++
Documentation/usb/gadget-testing.rst | 2 ++
drivers/usb/gadget/function/f_uac1.c | 11 +++++++++++
drivers/usb/gadget/function/u_uac1.h | 5 +++++
4 files changed, 20 insertions(+)
diff --git a/Documentation/ABI/testing/configfs-usb-gadget-uac1 b/Documentation/ABI/testing/configfs-usb-gadget-uac1
index fed8567b10ec..9f7f626329e7 100644
--- a/Documentation/ABI/testing/configfs-usb-gadget-uac1
+++ b/Documentation/ABI/testing/configfs-usb-gadget-uac1
@@ -43,4 +43,6 @@ Description:
c_it_ch_name capture channels name
c_ot_name capture output terminal name
c_fu_vol_name capture mute/volume functional unit name
+ c_terminal_type code of the capture terminal type
+ p_terminal_type code of the playback terminal type
===================== =======================================
diff --git a/Documentation/usb/gadget-testing.rst b/Documentation/usb/gadget-testing.rst
index bdb82b58b260..53c2518dbf50 100644
--- a/Documentation/usb/gadget-testing.rst
+++ b/Documentation/usb/gadget-testing.rst
@@ -980,6 +980,8 @@ The uac1 function provides these attributes in its function directory:
c_it_ch_name capture channels name
c_ot_name capture output terminal name
c_fu_vol_name capture mute/volume functional unit name
+ c_terminal_type code of the capture terminal type
+ p_terminal_type code of the playback terminal type
================ ====================================================
The attributes have sane default values.
diff --git a/drivers/usb/gadget/function/f_uac1.c b/drivers/usb/gadget/function/f_uac1.c
index 861e6219552e..5813fe3e7146 100644
--- a/drivers/usb/gadget/function/f_uac1.c
+++ b/drivers/usb/gadget/function/f_uac1.c
@@ -1277,6 +1277,8 @@ static void setup_descriptor(struct f_uac1_opts *opts)
as_out_header_desc.bTerminalLink = usb_out_it_desc.bTerminalID;
as_in_header_desc.bTerminalLink = usb_in_ot_desc.bTerminalID;
+ io_in_it_desc.wTerminalType = cpu_to_le16(opts->c_terminal_type);
+ io_out_ot_desc.wTerminalType = cpu_to_le16(opts->p_terminal_type);
ac_header_desc->wTotalLength = cpu_to_le16(ac_header_desc->bLength);
if (EPIN_EN(opts)) {
@@ -1898,6 +1900,9 @@ UAC1_ATTRIBUTE_STRING(c_it_ch_name);
UAC1_ATTRIBUTE_STRING(c_ot_name);
UAC1_ATTRIBUTE_STRING(c_fu_vol_name);
+UAC1_ATTRIBUTE(s16, p_terminal_type);
+UAC1_ATTRIBUTE(s16, c_terminal_type);
+
static struct configfs_attribute *f_uac1_attrs[] = {
&f_uac1_opts_attr_c_chmask,
&f_uac1_opts_attr_c_srate,
@@ -1935,6 +1940,9 @@ static struct configfs_attribute *f_uac1_attrs[] = {
&f_uac1_opts_attr_c_ot_name,
&f_uac1_opts_attr_c_fu_vol_name,
+ &f_uac1_opts_attr_p_terminal_type,
+ &f_uac1_opts_attr_c_terminal_type,
+
NULL,
};
@@ -2003,6 +2011,9 @@ static struct usb_function_instance *f_audio_alloc_inst(void)
scnprintf(opts->c_ot_name, sizeof(opts->c_ot_name), "Playback Output terminal");
scnprintf(opts->c_fu_vol_name, sizeof(opts->c_fu_vol_name), "Playback Volume");
+ opts->p_terminal_type = UAC1_DEF_P_TERM_TYPE;
+ opts->c_terminal_type = UAC1_DEF_C_TERM_TYPE;
+
return &opts->func_inst;
}
diff --git a/drivers/usb/gadget/function/u_uac1.h b/drivers/usb/gadget/function/u_uac1.h
index c7e7480bf71f..df29018096d3 100644
--- a/drivers/usb/gadget/function/u_uac1.h
+++ b/drivers/usb/gadget/function/u_uac1.h
@@ -30,6 +30,8 @@
#define UAC1_DEF_MAX_DB 0 /* 0 dB */
#define UAC1_DEF_RES_DB (1*256) /* 1 dB */
+#define UAC1_DEF_P_TERM_TYPE UAC_INPUT_TERMINAL_MICROPHONE
+#define UAC1_DEF_C_TERM_TYPE UAC_OUTPUT_TERMINAL_SPEAKER
struct f_uac1_opts {
struct usb_function_instance func_inst;
@@ -71,6 +73,9 @@ struct f_uac1_opts {
char c_ot_name[USB_MAX_STRING_LEN];
char c_fu_vol_name[USB_MAX_STRING_LEN];
+ s16 p_terminal_type;
+ s16 c_terminal_type;
+
struct mutex lock;
int refcnt;
};
--
2.43.0
Powered by blists - more mailing lists