* [PATCH] usb: gadget: f_uac1: Expose all string descriptors through configfs.
@ 2024-04-19 20:23 Chris Wulff
2024-04-21 10:16 ` Greg KH
0 siblings, 1 reply; 4+ messages in thread
From: Chris Wulff @ 2024-04-19 20:23 UTC (permalink / raw)
To: linux-usb@vger.kernel.org
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
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] usb: gadget: f_uac1: Expose all string descriptors through configfs.
2024-04-19 20:23 [PATCH] usb: gadget: f_uac1: Expose all string descriptors through configfs Chris Wulff
@ 2024-04-21 10:16 ` Greg KH
2024-04-21 15:41 ` Chris Wulff
0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2024-04-21 10:16 UTC (permalink / raw)
To: Chris Wulff; +Cc: linux-usb@vger.kernel.org
On Fri, Apr 19, 2024 at 08:23:21PM +0000, Chris Wulff wrote:
>
> 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(-)
Any specific reason you didn't cc: the maintainer here? Or the
developers who touched the file last? scripts/get_maintainer.pl is your
friend :)
>
> 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,
Does this require a change to the Documentation/ABI/ files as well?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] usb: gadget: f_uac1: Expose all string descriptors through configfs.
2024-04-21 10:16 ` Greg KH
@ 2024-04-21 15:41 ` Chris Wulff
2024-04-22 4:53 ` Greg KH
0 siblings, 1 reply; 4+ messages in thread
From: Chris Wulff @ 2024-04-21 15:41 UTC (permalink / raw)
To: Greg KH; +Cc: linux-usb@vger.kernel.org
> Any specific reason you didn't cc: the maintainer here? Or the
> developers who touched the file last? scripts/get_maintainer.pl is your
> friend :)
Thanks for the script reference. I looked in MAINTAINERS and didn't see one for the file(s) I am patching. As luck would have it, the first person on the list is you :). I will CC the emails from the script in the future. I am struggling a bit with our Outlook 365 server as it doesn't allow SMTP mail with any kind of basic authentication so I am unable to directly use git send-email.
> >
> > 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,
>
> Does this require a change to the Documentation/ABI/ files as well?
I will add the additional configfs strings to Documentation/ABI/testing/configfs-usb-gadget-uac1 and Documentation/usb/gadget-testing.rst
Are you aware of any other documentation that I might need to update? Those are the ones I've found so far.
-- Chris Wulff
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] usb: gadget: f_uac1: Expose all string descriptors through configfs.
2024-04-21 15:41 ` Chris Wulff
@ 2024-04-22 4:53 ` Greg KH
0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2024-04-22 4:53 UTC (permalink / raw)
To: Chris Wulff; +Cc: linux-usb@vger.kernel.org
On Sun, Apr 21, 2024 at 03:41:23PM +0000, Chris Wulff wrote:
>
> > Any specific reason you didn't cc: the maintainer here? Or the
> > developers who touched the file last? scripts/get_maintainer.pl is your
> > friend :)
>
> Thanks for the script reference. I looked in MAINTAINERS and didn't see one for the file(s) I am patching. As luck would have it, the first person on the list is you :). I will CC the emails from the script in the future. I am struggling a bit with our Outlook 365 server as it doesn't allow SMTP mail with any kind of basic authentication so I am unable to directly use git send-email.
You might want to have your email client wrap lines at a sane length as
well :)
> > > 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,
> >
> > Does this require a change to the Documentation/ABI/ files as well?
>
> I will add the additional configfs strings to Documentation/ABI/testing/configfs-usb-gadget-uac1 and Documentation/usb/gadget-testing.rst
> Are you aware of any other documentation that I might need to update? Those are the ones I've found so far.
That's a good start and probably is all that is needed for now, thanks.
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-04-22 4:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-19 20:23 [PATCH] usb: gadget: f_uac1: Expose all string descriptors through configfs Chris Wulff
2024-04-21 10:16 ` Greg KH
2024-04-21 15:41 ` Chris Wulff
2024-04-22 4:53 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox