From: Chris Wulff <Chris.Wulff@biamp.com>
To: "linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>
Subject: [PATCH] usb: gadget: f_uac1: Expose all string descriptors through configfs.
Date: Fri, 19 Apr 2024 20:23:21 +0000 [thread overview]
Message-ID: <CO1PR17MB54198F836C3ED1B4FA5F14A9E10D2@CO1PR17MB5419.namprd17.prod.outlook.com> (raw)
This makes all string descriptors configurable for the UAC1 gadget
so the user can configure names of terminals/controls/alt modes.
Signed-off-by: Chris Wulff <chris.wulff@biamp.com>
---
drivers/usb/gadget/function/f_uac1.c | 66 +++++++++++++++++++++-------
drivers/usb/gadget/function/u_uac1.h | 14 +++++-
2 files changed, 63 insertions(+), 17 deletions(-)
diff --git a/drivers/usb/gadget/function/f_uac1.c b/drivers/usb/gadget/function/f_uac1.c
index 7de74a3dd392..100169d6dca7 100644
--- a/drivers/usb/gadget/function/f_uac1.c
+++ b/drivers/usb/gadget/function/f_uac1.c
@@ -377,24 +377,10 @@ enum {
STR_AS_OUT_IF_ALT1,
STR_AS_IN_IF_ALT0,
STR_AS_IN_IF_ALT1,
+ NUM_STR_DESCRIPTORS,
};
-static struct usb_string strings_uac1[] = {
- /* [STR_AC_IF].s = DYNAMIC, */
- [STR_USB_OUT_IT].s = "Playback Input terminal",
- [STR_USB_OUT_IT_CH_NAMES].s = "Playback Channels",
- [STR_IO_OUT_OT].s = "Playback Output terminal",
- [STR_IO_IN_IT].s = "Capture Input terminal",
- [STR_IO_IN_IT_CH_NAMES].s = "Capture Channels",
- [STR_USB_IN_OT].s = "Capture Output terminal",
- [STR_FU_IN].s = "Capture Volume",
- [STR_FU_OUT].s = "Playback Volume",
- [STR_AS_OUT_IF_ALT0].s = "Playback Inactive",
- [STR_AS_OUT_IF_ALT1].s = "Playback Active",
- [STR_AS_IN_IF_ALT0].s = "Capture Inactive",
- [STR_AS_IN_IF_ALT1].s = "Capture Active",
- { },
-};
+static struct usb_string strings_uac1[NUM_STR_DESCRIPTORS + 1] = {};
static struct usb_gadget_strings str_uac1 = {
.language = 0x0409, /* en-us */
@@ -1264,6 +1250,18 @@ static int f_audio_bind(struct usb_configuration *c, struct usb_function *f)
audio_opts = container_of(f->fi, struct f_uac1_opts, func_inst);
strings_uac1[STR_AC_IF].s = audio_opts->function_name;
+ strings_uac1[STR_USB_OUT_IT].s = audio_opts->usb_out_it_string;
+ strings_uac1[STR_USB_OUT_IT_CH_NAMES].s = audio_opts->usb_out_it_ch_name_string;
+ strings_uac1[STR_IO_OUT_OT].s = audio_opts->io_out_ot_string;
+ strings_uac1[STR_IO_IN_IT].s = audio_opts->io_in_it_string;
+ strings_uac1[STR_IO_IN_IT_CH_NAMES].s = audio_opts->io_in_it_ch_name_string;
+ strings_uac1[STR_USB_IN_OT].s = audio_opts->usb_in_ot_string;
+ strings_uac1[STR_FU_IN].s = audio_opts->fu_in_string;
+ strings_uac1[STR_FU_OUT].s = audio_opts->fu_out_string;
+ strings_uac1[STR_AS_OUT_IF_ALT0].s = audio_opts->as_out_if_alt0_string;
+ strings_uac1[STR_AS_OUT_IF_ALT1].s = audio_opts->as_out_if_alt1_string;
+ strings_uac1[STR_AS_IN_IF_ALT0].s = audio_opts->as_in_if_alt0_string;
+ strings_uac1[STR_AS_IN_IF_ALT1].s = audio_opts->as_in_if_alt1_string;
us = usb_gstrings_attach(cdev, uac1_strings, ARRAY_SIZE(strings_uac1));
if (IS_ERR(us))
@@ -1682,6 +1680,18 @@ UAC1_ATTRIBUTE(s16, c_volume_min);
UAC1_ATTRIBUTE(s16, c_volume_max);
UAC1_ATTRIBUTE(s16, c_volume_res);
UAC1_ATTRIBUTE_STRING(function_name);
+UAC1_ATTRIBUTE_STRING(usb_out_it_string);
+UAC1_ATTRIBUTE_STRING(usb_out_it_ch_name_string);
+UAC1_ATTRIBUTE_STRING(io_out_ot_string);
+UAC1_ATTRIBUTE_STRING(io_in_it_string);
+UAC1_ATTRIBUTE_STRING(io_in_it_ch_name_string);
+UAC1_ATTRIBUTE_STRING(usb_in_ot_string);
+UAC1_ATTRIBUTE_STRING(fu_in_string);
+UAC1_ATTRIBUTE_STRING(fu_out_string);
+UAC1_ATTRIBUTE_STRING(as_out_if_alt0_string);
+UAC1_ATTRIBUTE_STRING(as_out_if_alt1_string);
+UAC1_ATTRIBUTE_STRING(as_in_if_alt0_string);
+UAC1_ATTRIBUTE_STRING(as_in_if_alt1_string);
static struct configfs_attribute *f_uac1_attrs[] = {
&f_uac1_opts_attr_c_chmask,
@@ -1705,6 +1715,18 @@ static struct configfs_attribute *f_uac1_attrs[] = {
&f_uac1_opts_attr_c_volume_res,
&f_uac1_opts_attr_function_name,
+ &f_uac1_opts_attr_usb_out_it_string,
+ &f_uac1_opts_attr_usb_out_it_ch_name_string,
+ &f_uac1_opts_attr_io_out_ot_string,
+ &f_uac1_opts_attr_io_in_it_string,
+ &f_uac1_opts_attr_io_in_it_ch_name_string,
+ &f_uac1_opts_attr_usb_in_ot_string,
+ &f_uac1_opts_attr_fu_in_string,
+ &f_uac1_opts_attr_fu_out_string,
+ &f_uac1_opts_attr_as_out_if_alt0_string,
+ &f_uac1_opts_attr_as_out_if_alt1_string,
+ &f_uac1_opts_attr_as_in_if_alt0_string,
+ &f_uac1_opts_attr_as_in_if_alt1_string,
NULL,
};
@@ -1759,6 +1781,18 @@ static struct usb_function_instance *f_audio_alloc_inst(void)
opts->req_number = UAC1_DEF_REQ_NUM;
scnprintf(opts->function_name, sizeof(opts->function_name), "AC Interface");
+ scnprintf(opts->usb_out_it_string, sizeof(opts->usb_out_it_string), "Playback Input terminal");
+ scnprintf(opts->usb_out_it_ch_name_string, sizeof(opts->usb_out_it_ch_name_string), "Playback Channels");
+ scnprintf(opts->io_out_ot_string, sizeof(opts->io_out_ot_string), "Playback Output terminal");
+ scnprintf(opts->io_in_it_string, sizeof(opts->io_in_it_string), "Capture Input terminal");
+ scnprintf(opts->io_in_it_ch_name_string, sizeof(opts->io_in_it_ch_name_string), "Capture Channels");
+ scnprintf(opts->usb_in_ot_string, sizeof(opts->usb_in_ot_string), "Capture Output terminal");
+ scnprintf(opts->fu_in_string, sizeof(opts->fu_in_string), "Capture Volume");
+ scnprintf(opts->fu_out_string, sizeof(opts->fu_out_string), "Playback Volume");
+ scnprintf(opts->as_out_if_alt0_string, sizeof(opts->as_out_if_alt0_string), "Playback Inactive");
+ scnprintf(opts->as_out_if_alt1_string, sizeof(opts->as_out_if_alt1_string), "Playback Active");
+ scnprintf(opts->as_in_if_alt0_string, sizeof(opts->as_in_if_alt0_string), "Capture Inactive");
+ scnprintf(opts->as_in_if_alt1_string, sizeof(opts->as_in_if_alt1_string), "Capture Active");
return &opts->func_inst;
}
diff --git a/drivers/usb/gadget/function/u_uac1.h b/drivers/usb/gadget/function/u_uac1.h
index f7a616760e31..818a335a309a 100644
--- a/drivers/usb/gadget/function/u_uac1.h
+++ b/drivers/usb/gadget/function/u_uac1.h
@@ -52,7 +52,19 @@ struct f_uac1_opts {
int req_number;
unsigned bound:1;
- char function_name[32];
+ char function_name[USB_MAX_STRING_LEN];
+ char usb_out_it_string[USB_MAX_STRING_LEN];
+ char usb_out_it_ch_name_string[USB_MAX_STRING_LEN];
+ char io_out_ot_string[USB_MAX_STRING_LEN];
+ char io_in_it_string[USB_MAX_STRING_LEN];
+ char io_in_it_ch_name_string[USB_MAX_STRING_LEN];
+ char usb_in_ot_string[USB_MAX_STRING_LEN];
+ char fu_in_string[USB_MAX_STRING_LEN];
+ char fu_out_string[USB_MAX_STRING_LEN];
+ char as_out_if_alt0_string[USB_MAX_STRING_LEN];
+ char as_out_if_alt1_string[USB_MAX_STRING_LEN];
+ char as_in_if_alt0_string[USB_MAX_STRING_LEN];
+ char as_in_if_alt1_string[USB_MAX_STRING_LEN];
struct mutex lock;
int refcnt;
--
2.34.1
next reply other threads:[~2024-04-19 20:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-19 20:23 Chris Wulff [this message]
2024-04-21 10:16 ` [PATCH] usb: gadget: f_uac1: Expose all string descriptors through configfs Greg KH
2024-04-21 15:41 ` Chris Wulff
2024-04-22 4:53 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CO1PR17MB54198F836C3ED1B4FA5F14A9E10D2@CO1PR17MB5419.namprd17.prod.outlook.com \
--to=chris.wulff@biamp.com \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).