diff mbox series

usb: gadget: f_uac1: Expose all string descriptors through configfs.

Message ID CO1PR17MB54198F836C3ED1B4FA5F14A9E10D2@CO1PR17MB5419.namprd17.prod.outlook.com (mailing list archive)
State Accepted
Headers show
Series usb: gadget: f_uac1: Expose all string descriptors through configfs. | expand

Commit Message

Chris Wulff April 19, 2024, 8:23 p.m. UTC
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(-)

Comments

Greg Kroah-Hartman April 21, 2024, 10:16 a.m. UTC | #1
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
Chris Wulff April 21, 2024, 3:41 p.m. UTC | #2
> 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
Greg Kroah-Hartman April 22, 2024, 4:53 a.m. UTC | #3
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
diff mbox series

Patch

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;