From patchwork Tue Apr 18 17:24:54 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: 9685917 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 99955602C2 for ; Tue, 18 Apr 2017 17:25:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 87B8220265 for ; Tue, 18 Apr 2017 17:25:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 79DD821E5A; Tue, 18 Apr 2017 17:25:09 +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=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 0EE3820265 for ; Tue, 18 Apr 2017 17:25:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757405AbdDRRZH (ORCPT ); Tue, 18 Apr 2017 13:25:07 -0400 Received: from mail-qt0-f182.google.com ([209.85.216.182]:34682 "EHLO mail-qt0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753042AbdDRRZG (ORCPT ); Tue, 18 Apr 2017 13:25:06 -0400 Received: by mail-qt0-f182.google.com with SMTP id c45so131059039qtb.1 for ; Tue, 18 Apr 2017 10:25:06 -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=vwH89UrY7tXisCJYNAtKb/8atMeiDSV71FbnhXho8hs=; b=G4Fvj74cH5JK9m1WrW6xAXRNu+yX4I+Mj1mfUujAm/fXmyGYNgIqbZKJqKDz4/JAOA DJ7QFHQwZERnhAVPxmwiFcVzz7989/yH9edmetffZSs9aUDATB1apL1p6R98JLypd7Lz KFbKr5aMhgIbgbarQ4I5g1MZkqmVrXyCwIMHyM3ZBnA9vGlvDFswE8MuwTf7S02RKNp+ QkWJwv2E25B+eGnMLlUofGFu+uk3YR3mIS0MaFp5Z19IzPLJRSecLu4dSIlJQtwza1Nn yMzTKSmW6B8SJAF9ZZERxh7DuouW9z/SM4FPZSgbltnuw56jkoNKjwUk6PGfQu07sWwW fAQg== 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=vwH89UrY7tXisCJYNAtKb/8atMeiDSV71FbnhXho8hs=; b=Bo8446+1Q3Yt0Wk5rfWChi0dIZ7fBm8jpdR3qnqKceAL40jvwpWzfMdWV/OSt3fpxV YsxWch3AgWXUMVh1/7tYQERkcj/YYwckqM33fQ4V+JCcvSMsDOZdZt+RA2Gm/px50GA9 pAAhZZU94VkBBNqQEo4mmjfpLzjBZYLxpQytMkZRPs8VrSoKbw/TBVoK+pCcFJmVyQy0 cWxvAh4DWL4BBqWQqP0NCMerOOW69Ui9Fplz9blMumHUhunmDjSj7yIGw8tCdOEcZdgd 7o+w/kwHa3EMdtgswCCH/ZAkDr4w4CBs0zYM2sTtQtLlPq32N2aMpRm3ViTkoG7kDMdk sqbg== X-Gm-Message-State: AN3rC/4P4aPssbGH9x5AiPiaIJ3aoNio/KBSGc/ShP0xS8GiikAsyVJu CHFCUL1vBOQ8IA0f0DDhIw== X-Received: by 10.237.35.50 with SMTP id h47mr14782522qtc.95.1492536305569; Tue, 18 Apr 2017 10:25:05 -0700 (PDT) Received: from pbos7.nyc.corp.google.com ([100.101.230.172]) by smtp.gmail.com with ESMTPSA id n99sm2684234qkh.27.2017.04.18.10.25.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 18 Apr 2017 10:25:04 -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 v3] [media] uvcvideo: Add iFunction or iInterface to device names. Date: Tue, 18 Apr 2017 13:24:54 -0400 Message-Id: <20170418172454.24465-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 --- 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..5676d916933d 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 additional_name; 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. + */ + additional_name = intf->cur_altsetting->desc.iInterface; + if (intf->intf_assoc && intf->intf_assoc->iFunction != 0) + additional_name = intf->intf_assoc->iFunction; + if (additional_name != 0) { + size_t len; + + strlcat(dev->name, ": ", sizeof(dev->name)); + len = strlen(dev->name); + usb_string(udev, additional_name, dev->name + len, + sizeof(dev->name) - len); + } /* Parse the Video Class control descriptor. */ if (uvc_parse_control(dev) < 0) {