All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Cc: linux-usb@vger.kernel.org,
	Paul Elder <paul.elder@ideasonboard.com>,
	Felipe Balbi <balbi@kernel.org>,
	Kieran Bingham <kieran.bingham@ideasonboard.com>
Subject: [v2] usb: gadget: uvc: Expose configuration name through video node
Date: Thu, 24 May 2018 22:19:36 +0300	[thread overview]
Message-ID: <4508402.IOBnECddXc@avalon> (raw)

Hi Kieran,

Thank you for the patch.

On Thursday, 24 May 2018 19:16:12 EEST Kieran Bingham wrote:
> From: Kieran Bingham <kieran.bingham@ideasonboard.com>
> 
> When utilising multiple instantiations of a UVC gadget on a composite
> device, there is no clear method to link a particular configuration to
> its respective video node.
> 
> Provide a means for identifying the correct video node by exposing the
> name of the function configuration through sysfs.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
> v2:
>  - Fix commit title (f_uvc -> uvc)
>  - Change identifier file name (now function_name)
>  - Document in ABI
> 
>  .../ABI/testing/configfs-usb-gadget-uvc       |  5 ++++
>  drivers/usb/gadget/function/f_uvc.c           | 24 ++++++++++++++++++-
>  2 files changed, 28 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/ABI/testing/configfs-usb-gadget-uvc
> b/Documentation/ABI/testing/configfs-usb-gadget-uvc index
> 1ba0d0fda9c0..9281e2aa38df 100644
> --- a/Documentation/ABI/testing/configfs-usb-gadget-uvc
> +++ b/Documentation/ABI/testing/configfs-usb-gadget-uvc
> @@ -263,3 +263,8 @@ Description:	Specific streaming header descriptors
>  					is connected
>  		bmInfo			- capabilities of this video streaming
>  					interface
> +
> +What:		/sys/class/udc/udc.name/device/gadget/video4linux/video.name/
functio
> n_name +Date:		May 2018
> +KernelVersion:	4.19
> +Description:	UVC configfs function instance name
> diff --git a/drivers/usb/gadget/function/f_uvc.c
> b/drivers/usb/gadget/function/f_uvc.c index d82cd61676d3..c8627cc698f8
> 100644
> --- a/drivers/usb/gadget/function/f_uvc.c
> +++ b/drivers/usb/gadget/function/f_uvc.c
> @@ -421,10 +421,21 @@ uvc_function_disconnect(struct uvc_device *uvc)
>   * USB probe and disconnect
>   */
> 
> +static ssize_t function_name_show(struct device *dev,
> +				  struct device_attribute *attr, char *buf)
> +{
> +	struct uvc_device *uvc = dev_get_drvdata(dev);
> +
> +	return sprintf(buf, "%s\n", uvc->func.fi->group.cg_item.ci_name);
> +}
> +
> +static DEVICE_ATTR_RO(function_name);
> +
>  static int
>  uvc_register_video(struct uvc_device *uvc)
>  {
>  	struct usb_composite_dev *cdev = uvc->func.config->cdev;
> +	int ret;
> 
>  	/* TODO reference counting. */
>  	uvc->vdev.v4l2_dev = &uvc->v4l2_dev;
> @@ -437,7 +448,17 @@ uvc_register_video(struct uvc_device *uvc)
> 
>  	video_set_drvdata(&uvc->vdev, uvc);
> 
> -	return video_register_device(&uvc->vdev, VFL_TYPE_GRABBER, -1);
> +	ret = video_register_device(&uvc->vdev, VFL_TYPE_GRABBER, -1);
> +	if (ret < 0)
> +		return ret;
> +
> +	ret = device_create_file(&uvc->vdev.dev, &dev_attr_function_name);
> +	if (ret < 0) {
> +		video_unregister_device(&uvc->vdev);
> +		return ret;
> +	}
> +
> +	return 0;
>  }
> 
>  #define UVC_COPY_DESCRIPTOR(mem, dst, desc) \
> @@ -877,6 +898,7 @@ static void uvc_unbind(struct usb_configuration *c,
> struct usb_function *f)
> 
>  	INFO(cdev, "%s\n", __func__);
> 
> +	device_remove_file(&uvc->vdev.dev, &dev_attr_function_name);
>  	video_unregister_device(&uvc->vdev);
>  	v4l2_device_unregister(&uvc->v4l2_dev);

             reply	other threads:[~2018-05-24 19:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-24 19:19 Laurent Pinchart [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-05-24 16:16 [v2] usb: gadget: uvc: Expose configuration name through video node Kieran Bingham

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=4508402.IOBnECddXc@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=balbi@kernel.org \
    --cc=kieran.bingham+renesas@ideasonboard.com \
    --cc=kieran.bingham@ideasonboard.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=paul.elder@ideasonboard.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.