From patchwork Wed Apr 19 20:45:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Peter_Bostr=C3=B6m?= X-Patchwork-Id: 9688883 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0A59460375 for ; Wed, 19 Apr 2017 20:45:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE65D282E2 for ; Wed, 19 Apr 2017 20:45:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E17B228437; Wed, 19 Apr 2017 20:45:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B195282E2 for ; Wed, 19 Apr 2017 20:45:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S937552AbdDSUpk (ORCPT ); Wed, 19 Apr 2017 16:45:40 -0400 Received: from mail-qt0-f171.google.com ([209.85.216.171]:34832 "EHLO mail-qt0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935028AbdDSUpj (ORCPT ); Wed, 19 Apr 2017 16:45:39 -0400 Received: by mail-qt0-f171.google.com with SMTP id y33so30120262qta.2 for ; Wed, 19 Apr 2017 13:45:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=cZ8WmfBvbKJ5h+s6BYnqhSfneYeKn7QRy6aiSV3Fqzs=; b=MZkP72m5Wc+SDXmA5st7nHnkab7eUtJH1ow/gA92JDqo/YZXuPalD6zyIv40zx9IVe uSmo4zDOZgN8PFkrDwxz6onrBXijZizBcFw0C3P7PwhAUvi8k4NSnCou4YPyZdKezGtG q6YXpXQF14vqqjx6+iPzxsuLywoD97grANkOjC0b2yCzQ5EsjmV5s6cc9Iqb4kIKAyZ4 780AZat/mpG3kMYOx2xtnMnhOTXViRKz+eD8SFX/Id9x2Wg4dITsE/I7gmHL3GgfxFyA KoS/BXyuX/5rFWJiXu9zJw33/KwizC8bktLsgSIfiL7vlghlXytkdDh61PtxesjC2b0Z kMTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=cZ8WmfBvbKJ5h+s6BYnqhSfneYeKn7QRy6aiSV3Fqzs=; b=quzgopht1ucgZ1JiXDdrDl32BfZ67iA3NtNbKS//pUkFAxowyrjeDMrwt16/keVVUi XmSSP+s8/2EAtRKpJIcZ4IWuLTd4yJ4rGKK/DJ9ApuK7yLu5BJ47wZjCt5i1DrH4llPV WuRI5ihAtFz48BLwp02oK6XP9iaa6wMXeW/uj+RZwZg3FMLBCD3PXZO7IQL4KrBtY9Ma KegHFjxxM7vXDI51vJmVn27Ss+7o3Na8+C8dRLqG4jM7OOiFFzKHxTrI137xIexsNdIM BbQIgY7DzUJUDvmFYhmN59UARdx/f4ao6bXIs1BxDjB1QveV5jh0v14dv02vvchZlLST NXrw== X-Gm-Message-State: AN3rC/5VYvX94JbBejpUgGdfkFB+4lLAt/PMnadafhlbLkQTgG5pm1LA 0NX+L3l8L5R+9qWN X-Received: by 10.237.37.106 with SMTP id w39mr5040296qtc.14.1492634737968; Wed, 19 Apr 2017 13:45:37 -0700 (PDT) Received: from pbos7.nyc.corp.google.com ([100.101.230.172]) by smtp.gmail.com with ESMTPSA id q66sm2655497qkd.69.2017.04.19.13.45.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Apr 2017 13:45:37 -0700 (PDT) From: =?UTF-8?q?Peter=20Bostr=C3=B6m?= To: linux-media@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com, =?UTF-8?q?Peter=20Bostr=C3=B6m?= Subject: [PATCH v4] [media] uvcvideo: Add iFunction or iInterface to device names. Date: Wed, 19 Apr 2017 16:45:27 -0400 Message-Id: <20170419204527.113504-1-pbos@google.com> X-Mailer: git-send-email 2.12.2.816.g2cccc81164-goog MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Permits distinguishing between two /dev/videoX entries from the same physical UVC device (that naturally share the same iProduct name). This change matches current Windows behavior by prioritizing iFunction over iInterface, but unlike Windows it displays both iProduct and iFunction/iInterface strings when both are available. Signed-off-by: Peter Boström Reviewed-by: Laurent Pinchart --- drivers/media/usb/uvc/uvc_driver.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index 04bf35063c4c..ae22fcf0a529 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -1998,6 +1998,7 @@ static int uvc_probe(struct usb_interface *intf, { struct usb_device *udev = interface_to_usbdev(intf); struct uvc_device *dev; + int function; int ret; if (id->idVendor && id->idProduct) @@ -2029,9 +2030,26 @@ static int uvc_probe(struct usb_interface *intf, strlcpy(dev->name, udev->product, sizeof dev->name); else snprintf(dev->name, sizeof dev->name, - "UVC Camera (%04x:%04x)", - le16_to_cpu(udev->descriptor.idVendor), - le16_to_cpu(udev->descriptor.idProduct)); + "UVC Camera (%04x:%04x)", + le16_to_cpu(udev->descriptor.idVendor), + le16_to_cpu(udev->descriptor.idProduct)); + + /* + * Add iFunction or iInterface to names when available as additional + * distinguishers between interfaces. iFunction is prioritized over + * iInterface which matches Windows behavior at the point of writing. + */ + function = intf->cur_altsetting->desc.iInterface; + if (intf->intf_assoc && intf->intf_assoc->iFunction != 0) + function = intf->intf_assoc->iFunction; + if (function != 0) { + size_t len; + + strlcat(dev->name, ": ", sizeof(dev->name)); + len = strlen(dev->name); + usb_string(udev, function, dev->name + len, + sizeof(dev->name) - len); + } /* Parse the Video Class control descriptor. */ if (uvc_parse_control(dev) < 0) {