All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Scally <dan.scally@ideasonboard.com>
To: linux-usb@vger.kernel.org
Cc: balbi@kernel.org, gregkh@linuxfoundation.org,
	laurent.pinchart@ideasonboard.com,
	kieran.bingham@ideasonboard.com, torleiv@huddly.com,
	mgr@pengutronix.de, Daniel Scally <dan.scally@ideasonboard.com>
Subject: [PATCH v2 9/9] usb: gadget: uvc: Use custom strings if available
Date: Mon, 21 Nov 2022 09:25:17 +0000	[thread overview]
Message-ID: <20221121092517.225242-10-dan.scally@ideasonboard.com> (raw)
In-Reply-To: <20221121092517.225242-1-dan.scally@ideasonboard.com>

If the user has defined a custom string descriptor for the IAD or the
VideoControl or VideoStreaming interfaces then set their index field
to point to the custom descriptor instead of the hardcoded defaults.
If no custom descriptors have been linked to, then use the default
ones.

Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>
---
Changes in v2:

	- New patch

 drivers/usb/gadget/function/f_uvc.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/gadget/function/f_uvc.c b/drivers/usb/gadget/function/f_uvc.c
index 7821fe8f9120..ac6df8458cab 100644
--- a/drivers/usb/gadget/function/f_uvc.c
+++ b/drivers/usb/gadget/function/f_uvc.c
@@ -784,6 +784,10 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
 	list_for_each_entry(xu, &opts->extension_units, list)
 		xu->desc.iExtension = cus[xu->string_descriptor_index].id;
 
+	/*
+	 * We attach the hard-coded defaults incase the user does not provide
+	 * any more appropriate strings through configfs.
+	 */
 	uvc_en_us_strings[UVC_STRING_CONTROL_IDX].s = opts->function_name;
 	us = usb_gstrings_attach(cdev, uvc_function_strings,
 				 ARRAY_SIZE(uvc_en_us_strings));
@@ -791,11 +795,15 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
 		ret = PTR_ERR(us);
 		goto error;
 	}
-	uvc_iad.iFunction = us[UVC_STRING_CONTROL_IDX].id;
-	uvc_control_intf.iInterface = us[UVC_STRING_CONTROL_IDX].id;
-	ret = us[UVC_STRING_STREAMING_IDX].id;
-	uvc_streaming_intf_alt0.iInterface = ret;
-	uvc_streaming_intf_alt1.iInterface = ret;
+
+	uvc_iad.iFunction = opts->iad_index ? cus[opts->iad_index].id :
+			    us[UVC_STRING_CONTROL_IDX].id;
+	uvc_control_intf.iInterface = opts->iad_index ? cus[opts->iad_index].id :
+				      us[UVC_STRING_CONTROL_IDX].id;
+	uvc_streaming_intf_alt0.iInterface = opts->vs0_index ? cus[opts->vs0_index].id :
+					     us[UVC_STRING_STREAMING_IDX].id;
+	uvc_streaming_intf_alt1.iInterface = opts->vs1_index ? cus[opts->vs1_index].id :
+					     us[UVC_STRING_STREAMING_IDX].id;
 
 	/* Allocate interface IDs. */
 	if ((ret = usb_interface_id(c, f)) < 0)
-- 
2.34.1


  parent reply	other threads:[~2022-11-21  9:25 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-21  9:25 [PATCH v2 0/9] Add XU support to UVC Gadget Daniel Scally
2022-11-21  9:25 ` [PATCH v2 1/9] usb: gadget: uvc: Make bSourceID read/write Daniel Scally
2022-12-29  0:30   ` Laurent Pinchart
2022-12-29  0:30     ` Laurent Pinchart
2023-01-01 21:18       ` Dan Scally
2023-01-02 11:14         ` Laurent Pinchart
2023-01-25 12:27           ` Dan Scally
2022-11-21  9:25 ` [PATCH v2 2/9] usb: gadget: uvc: Generalise helper functions for reuse Daniel Scally
2022-12-29  0:48   ` Laurent Pinchart
2022-11-21  9:25 ` [PATCH v2 3/9] usb: gadget: uvc: Allow definition of XUs in configfs Daniel Scally
2022-11-22  1:32   ` kernel test robot
2022-12-29  1:35   ` Laurent Pinchart
2022-11-21  9:25 ` [PATCH v2 4/9] usb: gadget: uvc: Copy XU descriptors during .bind() Daniel Scally
2022-11-21  9:51   ` Dan Scally
2022-12-29  1:46     ` Laurent Pinchart
2022-11-21  9:25 ` [PATCH v2 5/9] usb: gadget: uvc: Support arbitrary string descriptors Daniel Scally
2022-11-21 11:33   ` kernel test robot
2022-12-29  1:56   ` Laurent Pinchart
2022-11-21  9:25 ` [PATCH v2 6/9] usb: gadget: uvc: Allow linking XUs to " Daniel Scally
2022-12-29  2:05   ` Laurent Pinchart
2023-01-01 21:09     ` Dan Scally
2023-01-02 12:25       ` Laurent Pinchart
2023-01-24 15:58         ` Dan Scally
2022-11-21  9:25 ` [PATCH v2 7/9] usb: gadget: uvc: Attach custom " Daniel Scally
2022-11-21  9:25 ` [PATCH v2 8/9] usb: gadget: uvc: Allow linking function to string descs Daniel Scally
2022-11-21  9:57   ` Dan Scally
2022-12-29  2:08     ` Laurent Pinchart
2022-12-29 14:59       ` Alan Stern
2022-11-21  9:25 ` Daniel Scally [this message]
2022-12-12  9:57 ` [PATCH v2 0/9] Add XU support to UVC Gadget Dan Scally
2022-12-29  0:18 ` Laurent Pinchart
2023-01-01 20:34   ` Dan Scally

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=20221121092517.225242-10-dan.scally@ideasonboard.com \
    --to=dan.scally@ideasonboard.com \
    --cc=balbi@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kieran.bingham@ideasonboard.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=mgr@pengutronix.de \
    --cc=torleiv@huddly.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.