Message ID | 20220920-resend-meta-v4-3-3ac355b66723@chromium.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp974205wrr; Fri, 2 Dec 2022 09:10:53 -0800 (PST) X-Google-Smtp-Source: AA0mqf4nHtn56u/2Llqh+3GTB+ijun7X7TRkHY/DLjhTnNCBeLSjL9Y0qvZzsGCF5Ds+eav7fxYc X-Received: by 2002:a05:6a00:2342:b0:575:1df5:4207 with SMTP id j2-20020a056a00234200b005751df54207mr27327670pfj.4.1670001052752; Fri, 02 Dec 2022 09:10:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670001052; cv=none; d=google.com; s=arc-20160816; b=W91+BsqoE71xWveHn2Lcx6YRUg84/nsp1HxTZz7ns3sGtz8kSuQYGvuYVTtuUJchBt xQOm76ZwtlCjGcrzC40ixrzFXn1RccdgREe50NiadZ2/Nin3cby/9rB9zBgwdSY3/zyQ qAVrENt1Jm5Q+z+3nnyAvXfthLXvYpQfakhzQz0ctzKygIjRwqP+hOU82xLbEOUa0A5P 3LXMhcm2/ayE29awM53j8aF6Py8hSU/iF6QxNQ+Hu0LntNsuzzhN3sXxehMS2oPg5/Fw DrolNWYVjAYNz9WfolzhwLHFshs9FF8ETuAy4L4kzUujPh6j+USQrHF2WcRfA+/7EwYH yY2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=wtZA1IbfmQV1q6JbQ4L1axaQ6pL7lh9jXHUHF+NGf+s=; b=crqX4Lfvvxvt+kLQwybQg9ISbqbBU0tTkk4qXW0BlIoS/L1aHmo1SsmkzLQWi+xhUL jqvIDFB7CFJvZCcMhboNWOOHeLrVNvgPPOb/tPF2p8EoxBau7nPxOuS+qS2VgQSxksk8 aSiOaUtsNc3B4y6vRoem8tJsz4NHC0nVvwiSf6nScPUqim65KAgCeNz9QgMYUFpuIcGf XgC5LDG+86nu09MXz7CU+S1yDgnpDDN7G3Cni723E5XvmNIxQQy3Vx8FAt0xQKDwyPMr 8mVw2ucFWymfRCfbORZnDChEC7aKwoWbqirqLebSpUQS88V8ndHm0ZRcuk+Ds9Q6HNzF su6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=XpikTCNV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g18-20020a056a000b9200b0054568a55597si8857953pfj.96.2022.12.02.09.10.38; Fri, 02 Dec 2022 09:10:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=XpikTCNV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234370AbiLBRIq (ORCPT <rfc822;lhua1029@gmail.com> + 99 others); Fri, 2 Dec 2022 12:08:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234211AbiLBRIe (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 2 Dec 2022 12:08:34 -0500 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6734D15AC for <linux-kernel@vger.kernel.org>; Fri, 2 Dec 2022 09:08:32 -0800 (PST) Received: by mail-ej1-x632.google.com with SMTP id n20so13078954ejh.0 for <linux-kernel@vger.kernel.org>; Fri, 02 Dec 2022 09:08:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=wtZA1IbfmQV1q6JbQ4L1axaQ6pL7lh9jXHUHF+NGf+s=; b=XpikTCNVTwEOA5uF8nNd5n/17A51tYzKCsH3sFvNsx7NQIlGfqeYPmt+MPPTil0B9c HoA1iwi/zEldKG9JkeVX+amy3q/vGckf4YOJJZq6aKxUtcpQqtvsP97cy1tjVEwII11V nOqCsWmk2LGIUPqE1HZG8UiN0l0cJKQvaKSjY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wtZA1IbfmQV1q6JbQ4L1axaQ6pL7lh9jXHUHF+NGf+s=; b=ERKZq23HCDfjemzOtv+HS/5uSbloHuwrZcHJNyYj6ViWrvLe/bq1bMUJWTI/HEv76q arSHFe57aOG+QQOXceU/61g1wfmynRRCpsTG7YG9r9jUx7FVBGwD7hDqrDYmTVxhnIV+ OhZ1H6Z7uqhw4AcNrtMOzEEKeILfGvDwpFOy8u1te/jg4x2MYGxqYjanhNoiePdHJySc vXq9ySDuvSbX7EIRHEIKYN9O8b5y/KIV1313vc8i2u9hrtysW/6nju77ieZExbSo6XCi kh5QZg7u4RMFwZz6Gmptw7cCgpxmivoI1+WbHymYts0X1+fKvCiauFtTMr5sdXakDV6k AbNQ== X-Gm-Message-State: ANoB5plpJGSLSshRRGwlbCbyKk6kY3VmCA1jCCYlndxR75Uf2y9osLhq 5Yn2HEQV/plCrQ1ksndiXs3Z1Q== X-Received: by 2002:a17:906:c303:b0:7ad:95d2:9df2 with SMTP id s3-20020a170906c30300b007ad95d29df2mr14266490ejz.607.1670000910978; Fri, 02 Dec 2022 09:08:30 -0800 (PST) Received: from alco.roam.corp.google.com (80.71.134.83.ipv4.parknet.dk. [80.71.134.83]) by smtp.gmail.com with ESMTPSA id p23-20020aa7d317000000b00461cdda400esm3168080edq.4.2022.12.02.09.08.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Dec 2022 09:08:30 -0800 (PST) From: Ricardo Ribalda <ribalda@chromium.org> Date: Fri, 02 Dec 2022 18:08:19 +0100 Subject: [PATCH v4 3/3] media: uvcvideo: Add a unique suffix to camera names MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20220920-resend-meta-v4-3-3ac355b66723@chromium.org> References: <20220920-resend-meta-v4-0-3ac355b66723@chromium.org> In-Reply-To: <20220920-resend-meta-v4-0-3ac355b66723@chromium.org> To: Yunke Cao <yunkec@chromium.org>, Mauro Carvalho Chehab <mchehab@kernel.org>, Laurent Pinchart <laurent.pinchart@ideasonboard.com>, Sergey Senozhatsky <senozhatsky@chromium.org> Cc: linux-media@vger.kernel.org, Mauro Carvalho Chehab <mchehab+huawei@kernel.org>, linux-kernel@vger.kernel.org, Ricardo Ribalda <ribalda@chromium.org> X-Mailer: b4 0.11.0-dev-696ae X-Developer-Signature: v=1; a=openpgp-sha256; l=1196; i=ribalda@chromium.org; h=from:subject:message-id; bh=nncAxgIlMLPqi8B4D2XzAtMUAbjMzg6DbKN4jx7ltvo=; b=owEBbQKS/ZANAwAKAdE30T7POsSIAcsmYgBjijEKf6IQrPsYfpx8DB/t21WB2f//wrtkc3pBusyj OJet42yJAjMEAAEKAB0WIQREDzjr+/4oCDLSsx7RN9E+zzrEiAUCY4oxCgAKCRDRN9E+zzrEiEf9EA CQ4I7QGoNfJc9SX11wg89UhJOeSV96QkPThsmoSd+ZSPI54GSWuTIU5scGGnYkXaCUoMlZh0UUvz2Q aIq7bDEfpmwCV6ioehV41ihZyXx3jAk8hHwjArKCdkvjxXL3qcBuYBvqDnNhPDufiMbdt020JrednB SlFrEa9DrGYNGERL7H5gyh60gLTxvT6i3TNP+8Q4+cgnXkMYDwTWXZ2Qgc5WY8ULBtXzWW8/BxNocr yVr3Lh795K3zVpg/AEiG+ZseaV9I5VTc5NzMDwAwEzOS66uLFPBNYuN67PlW/WO354hOJw8hdkgZqu nyem3E/OvSF6k5Je/csoQ3OUJFbw0b657ilB4bOQy/BL7yH6MYQPRfziUKJkLi4z+H7FdbuFZwpWEK EgdH9jGHSGYUD+ePn1TGzttAah24E17G4QOWGt2a23um4b00eIMvXZcYap/n6BfO6jDiJpMYiyfqZN swe6t1+t0zmKdYVcznkLD7F8Mj+WmkwYcQQrphdjKlQN8NsuSi2lXExVumSnGRNT3CahDuqovBw/Bq vJ187rhlO897Szhl+WuAzg1quLkKQ9J6sXb9M3Exexs3r1hdyg3alVYAjzxAFARErx9E4Y8C7HWJjG To1sxIYs0gyIO7Zacp/WnYB3q6NuiAnaIjJrWXFe32Bp18lk1ikY4VrFPJsg== X-Developer-Key: i=ribalda@chromium.org; a=openpgp; fpr=9EC3BB66E2FC129A6F90B39556A0D81F9F782DA9 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751123023865233199?= X-GMAIL-MSGID: =?utf-8?q?1751123023865233199?= |
Series |
Add Meta: to Metadata devices
|
|
Commit Message
Ricardo Ribalda
Dec. 2, 2022, 5:08 p.m. UTC
Some cameras have multiple data inputs (i.e. IR sensor and RGB sensor),
append a unique number to the device name.
Fixes v4l2-compliance:
Media Controller ioctls:
fail: v4l2-test-media.cpp(205): v2_entity_names_set.find(key) != v2_entity_names_set.end()
test MEDIA_IOC_G_TOPOLOGY: FAIL
fail: v4l2-test-media.cpp(394): num_data_links != num_links
test MEDIA_IOC_ENUM_ENTITIES/LINKS: FAIL
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
drivers/media/usb/uvc/uvc_driver.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Comments
On Sat, Dec 3, 2022 at 2:08 AM Ricardo Ribalda <ribalda@chromium.org> wrote: > > Some cameras have multiple data inputs (i.e. IR sensor and RGB sensor), > append a unique number to the device name. > > Fixes v4l2-compliance: > Media Controller ioctls: > fail: v4l2-test-media.cpp(205): v2_entity_names_set.find(key) != v2_entity_names_set.end() > test MEDIA_IOC_G_TOPOLOGY: FAIL > fail: v4l2-test-media.cpp(394): num_data_links != num_links > test MEDIA_IOC_ENUM_ENTITIES/LINKS: FAIL > > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> > --- > drivers/media/usb/uvc/uvc_driver.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c > index 215fb483efb0..f4032ebb3689 100644 > --- a/drivers/media/usb/uvc/uvc_driver.c > +++ b/drivers/media/usb/uvc/uvc_driver.c > @@ -1963,7 +1963,8 @@ int uvc_register_video_device(struct uvc_device *dev, > break; > } > > - strscpy(vdev->name, dev->name, sizeof(vdev->name)); > + snprintf(vdev->name, sizeof(vdev->name), "%s %u", dev->name, > + stream->header.bTerminalLink); > > /* > * Set the driver data before calling video_register_device, otherwise > > -- > 2.39.0.rc0.267.gcb52ba06e7-goog-b4-0.11.0-dev-696ae Reviewed-by: Yunke Cao <yunkec@chromium.org>
Hi Ricardo, Thank you for the patch. On Fri, Dec 02, 2022 at 06:08:19PM +0100, Ricardo Ribalda wrote: > Some cameras have multiple data inputs (i.e. IR sensor and RGB sensor), > append a unique number to the device name. > > Fixes v4l2-compliance: > Media Controller ioctls: > fail: v4l2-test-media.cpp(205): v2_entity_names_set.find(key) != v2_entity_names_set.end() > test MEDIA_IOC_G_TOPOLOGY: FAIL > fail: v4l2-test-media.cpp(394): num_data_links != num_links > test MEDIA_IOC_ENUM_ENTITIES/LINKS: FAIL > > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> > --- > drivers/media/usb/uvc/uvc_driver.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c > index 215fb483efb0..f4032ebb3689 100644 > --- a/drivers/media/usb/uvc/uvc_driver.c > +++ b/drivers/media/usb/uvc/uvc_driver.c > @@ -1963,7 +1963,8 @@ int uvc_register_video_device(struct uvc_device *dev, > break; > } > > - strscpy(vdev->name, dev->name, sizeof(vdev->name)); > + snprintf(vdev->name, sizeof(vdev->name), "%s %u", dev->name, > + stream->header.bTerminalLink); This won't be perfect as the string is not guaranteed to fit in vdev->name, but I suppose it will help as a quick fix for some devices. How about the other devices ? Won't they still exhibit the above v4l2-compliance failure ? Isn't that something that will still affect Chrome OS devices ? The change should not cause any regression as big as in patch 1/3. However, unless I'm mistaken users will notice a device name change, especially when selecting a device in their web browser. Could that be a problem ? > /* > * Set the driver data before calling video_register_device, otherwise >
Hi Laurent On Mon, 5 Dec 2022 at 23:16, Laurent Pinchart <laurent.pinchart@ideasonboard.com> wrote: > > Hi Ricardo, > > Thank you for the patch. > > On Fri, Dec 02, 2022 at 06:08:19PM +0100, Ricardo Ribalda wrote: > > Some cameras have multiple data inputs (i.e. IR sensor and RGB sensor), > > append a unique number to the device name. > > > > Fixes v4l2-compliance: > > Media Controller ioctls: > > fail: v4l2-test-media.cpp(205): v2_entity_names_set.find(key) != v2_entity_names_set.end() > > test MEDIA_IOC_G_TOPOLOGY: FAIL > > fail: v4l2-test-media.cpp(394): num_data_links != num_links > > test MEDIA_IOC_ENUM_ENTITIES/LINKS: FAIL > > > > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> > > --- > > drivers/media/usb/uvc/uvc_driver.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c > > index 215fb483efb0..f4032ebb3689 100644 > > --- a/drivers/media/usb/uvc/uvc_driver.c > > +++ b/drivers/media/usb/uvc/uvc_driver.c > > @@ -1963,7 +1963,8 @@ int uvc_register_video_device(struct uvc_device *dev, > > break; > > } > > > > - strscpy(vdev->name, dev->name, sizeof(vdev->name)); > > + snprintf(vdev->name, sizeof(vdev->name), "%s %u", dev->name, > > + stream->header.bTerminalLink); > > This won't be perfect as the string is not guaranteed to fit in > vdev->name, but I suppose it will help as a quick fix for some devices. > How about the other devices ? Won't they still exhibit the above > v4l2-compliance failure ? Isn't that something that will still affect > Chrome OS devices ? We could place the id first... but that will look bad: Eg: 1- My favorite camera Another option is to remove the last chars to fit the id. Eg: My favorite came-1 If you prefer any of those options or have a better idea I can implement that. > > The change should not cause any regression as big as in patch 1/3. > However, unless I'm mistaken users will notice a device name change, > especially when selecting a device in their web browser. Could that be a > problem ? I think the only side effect is that the first time that the kernel changes the naming convention, if there are more than one camera on the system, the video conference might pick a different camera. The good news is that the user will be presented with cameras with different names. Now some cameras show very confusing names: ribalda@alco:~/work/linux$ for a in /dev/video* ; do yavta -l $a| grep "Dell Webcam"; done Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver 'uvcvideo') supports video, capture, without mplanes. Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver 'uvcvideo') supports meta-data, capture, without mplanes. Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver 'uvcvideo') supports video, capture, without mplanes. Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver 'uvcvideo') supports meta-data, capture, without mplanes. > > > /* > > * Set the driver data before calling video_register_device, otherwise > > > > -- > Regards, > > Laurent Pinchart
Hi On Tue, 6 Dec 2022 at 00:02, Ricardo Ribalda <ribalda@chromium.org> wrote: > > Hi Laurent > > On Mon, 5 Dec 2022 at 23:16, Laurent Pinchart > <laurent.pinchart@ideasonboard.com> wrote: > > > > Hi Ricardo, > > > > Thank you for the patch. > > > > On Fri, Dec 02, 2022 at 06:08:19PM +0100, Ricardo Ribalda wrote: > > > Some cameras have multiple data inputs (i.e. IR sensor and RGB sensor), > > > append a unique number to the device name. > > > > > > Fixes v4l2-compliance: > > > Media Controller ioctls: > > > fail: v4l2-test-media.cpp(205): v2_entity_names_set.find(key) != v2_entity_names_set.end() > > > test MEDIA_IOC_G_TOPOLOGY: FAIL > > > fail: v4l2-test-media.cpp(394): num_data_links != num_links > > > test MEDIA_IOC_ENUM_ENTITIES/LINKS: FAIL > > > > > > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> > > > --- > > > drivers/media/usb/uvc/uvc_driver.c | 3 ++- > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c > > > index 215fb483efb0..f4032ebb3689 100644 > > > --- a/drivers/media/usb/uvc/uvc_driver.c > > > +++ b/drivers/media/usb/uvc/uvc_driver.c > > > @@ -1963,7 +1963,8 @@ int uvc_register_video_device(struct uvc_device *dev, > > > break; > > > } > > > > > > - strscpy(vdev->name, dev->name, sizeof(vdev->name)); > > > + snprintf(vdev->name, sizeof(vdev->name), "%s %u", dev->name, > > > + stream->header.bTerminalLink); > > > > This won't be perfect as the string is not guaranteed to fit in > > vdev->name, but I suppose it will help as a quick fix for some devices. > > How about the other devices ? Won't they still exhibit the above > > v4l2-compliance failure ? Isn't that something that will still affect > > Chrome OS devices ? > > We could place the id first... but that will look bad: Eg: > > 1- My favorite camera > > Another option is to remove the last chars to fit the id. Eg: > > My favorite came-1 > > If you prefer any of those options or have a better idea I can implement that. @Laurent Any preference here? Thanks! > > > > > > The change should not cause any regression as big as in patch 1/3. > > However, unless I'm mistaken users will notice a device name change, > > especially when selecting a device in their web browser. Could that be a > > problem ? > > I think the only side effect is that the first time that the kernel > changes the naming convention, if there are more than one camera on > the system, the video conference might pick a different camera. > The good news is that the user will be presented with cameras with > different names. Now some cameras show very confusing names: > > ribalda@alco:~/work/linux$ for a in /dev/video* ; do yavta -l $a| grep > "Dell Webcam"; done > Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver > 'uvcvideo') supports video, capture, without mplanes. > Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver > 'uvcvideo') supports meta-data, capture, without mplanes. > Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver > 'uvcvideo') supports video, capture, without mplanes. > Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver > 'uvcvideo') supports meta-data, capture, without mplanes. > > > > > > > > /* > > > * Set the driver data before calling video_register_device, otherwise > > > > > > > -- > > Regards, > > > > Laurent Pinchart > > > > -- > Ricardo Ribalda
Hi Ricardo, On Wed, Dec 21, 2022 at 12:00:58AM +0100, Ricardo Ribalda wrote: > On Tue, 6 Dec 2022 at 00:02, Ricardo Ribalda wrote: > > On Mon, 5 Dec 2022 at 23:16, Laurent Pinchart wrote: > > > On Fri, Dec 02, 2022 at 06:08:19PM +0100, Ricardo Ribalda wrote: > > > > Some cameras have multiple data inputs (i.e. IR sensor and RGB sensor), Did you mean "data outputs" by the way ? > > > > append a unique number to the device name. > > > > > > > > Fixes v4l2-compliance: > > > > Media Controller ioctls: > > > > fail: v4l2-test-media.cpp(205): v2_entity_names_set.find(key) != v2_entity_names_set.end() > > > > test MEDIA_IOC_G_TOPOLOGY: FAIL > > > > fail: v4l2-test-media.cpp(394): num_data_links != num_links > > > > test MEDIA_IOC_ENUM_ENTITIES/LINKS: FAIL > > > > > > > > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> > > > > --- > > > > drivers/media/usb/uvc/uvc_driver.c | 3 ++- > > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c > > > > index 215fb483efb0..f4032ebb3689 100644 > > > > --- a/drivers/media/usb/uvc/uvc_driver.c > > > > +++ b/drivers/media/usb/uvc/uvc_driver.c > > > > @@ -1963,7 +1963,8 @@ int uvc_register_video_device(struct uvc_device *dev, > > > > break; > > > > } > > > > > > > > - strscpy(vdev->name, dev->name, sizeof(vdev->name)); > > > > + snprintf(vdev->name, sizeof(vdev->name), "%s %u", dev->name, > > > > + stream->header.bTerminalLink); > > > > > > This won't be perfect as the string is not guaranteed to fit in > > > vdev->name, but I suppose it will help as a quick fix for some devices. > > > How about the other devices ? Won't they still exhibit the above > > > v4l2-compliance failure ? Isn't that something that will still affect > > > Chrome OS devices ? > > > > We could place the id first... but that will look bad: Eg: > > > > 1- My favorite camera > > > > Another option is to remove the last chars to fit the id. Eg: > > > > My favorite came-1 > > > > If you prefer any of those options or have a better idea I can implement that. > > @Laurent > > Any preference here? I think the latter is better. Could we do so only when there are multiple video capture devices (excluding the metadata device) though ? That way we won't have a weird "-n" suffix in the majority of use cases. > > > The change should not cause any regression as big as in patch 1/3. > > > However, unless I'm mistaken users will notice a device name change, > > > especially when selecting a device in their web browser. Could that be a > > > problem ? > > > > I think the only side effect is that the first time that the kernel > > changes the naming convention, if there are more than one camera on > > the system, the video conference might pick a different camera. > > The good news is that the user will be presented with cameras with > > different names. Now some cameras show very confusing names: > > > > ribalda@alco:~/work/linux$ for a in /dev/video* ; do yavta -l $a| grep > > "Dell Webcam"; done > > Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver > > 'uvcvideo') supports video, capture, without mplanes. > > Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver > > 'uvcvideo') supports meta-data, capture, without mplanes. > > Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver > > 'uvcvideo') supports video, capture, without mplanes. > > Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver > > 'uvcvideo') supports meta-data, capture, without mplanes. I'm tempted to add a new model read-only string control to overcome the length limitation. It could then be combined with other information (such as the location and supported pixel formats) to create a user-friendly camera name by applications. > > > > /* > > > > * Set the driver data before calling video_register_device, otherwise > > > >
Hi Laurent On Wed, 21 Dec 2022 at 11:55, Laurent Pinchart <laurent.pinchart@ideasonboard.com> wrote: > > Hi Ricardo, > > On Wed, Dec 21, 2022 at 12:00:58AM +0100, Ricardo Ribalda wrote: > > On Tue, 6 Dec 2022 at 00:02, Ricardo Ribalda wrote: > > > On Mon, 5 Dec 2022 at 23:16, Laurent Pinchart wrote: > > > > On Fri, Dec 02, 2022 at 06:08:19PM +0100, Ricardo Ribalda wrote: > > > > > Some cameras have multiple data inputs (i.e. IR sensor and RGB sensor), > > Did you mean "data outputs" by the way ? > > > > > > append a unique number to the device name. > > > > > > > > > > Fixes v4l2-compliance: > > > > > Media Controller ioctls: > > > > > fail: v4l2-test-media.cpp(205): v2_entity_names_set.find(key) != v2_entity_names_set.end() > > > > > test MEDIA_IOC_G_TOPOLOGY: FAIL > > > > > fail: v4l2-test-media.cpp(394): num_data_links != num_links > > > > > test MEDIA_IOC_ENUM_ENTITIES/LINKS: FAIL > > > > > > > > > > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> > > > > > --- > > > > > drivers/media/usb/uvc/uvc_driver.c | 3 ++- > > > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > > > > > diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c > > > > > index 215fb483efb0..f4032ebb3689 100644 > > > > > --- a/drivers/media/usb/uvc/uvc_driver.c > > > > > +++ b/drivers/media/usb/uvc/uvc_driver.c > > > > > @@ -1963,7 +1963,8 @@ int uvc_register_video_device(struct uvc_device *dev, > > > > > break; > > > > > } > > > > > > > > > > - strscpy(vdev->name, dev->name, sizeof(vdev->name)); > > > > > + snprintf(vdev->name, sizeof(vdev->name), "%s %u", dev->name, > > > > > + stream->header.bTerminalLink); > > > > > > > > This won't be perfect as the string is not guaranteed to fit in > > > > vdev->name, but I suppose it will help as a quick fix for some devices. > > > > How about the other devices ? Won't they still exhibit the above > > > > v4l2-compliance failure ? Isn't that something that will still affect > > > > Chrome OS devices ? > > > > > > We could place the id first... but that will look bad: Eg: > > > > > > 1- My favorite camera > > > > > > Another option is to remove the last chars to fit the id. Eg: > > > > > > My favorite came-1 > > > > > > If you prefer any of those options or have a better idea I can implement that. > > > > @Laurent > > > > Any preference here? > > I think the latter is better. Could we do so only when there are > multiple video capture devices (excluding the metadata device) though ? > That way we won't have a weird "-n" suffix in the majority of use cases. > > > > > The change should not cause any regression as big as in patch 1/3. > > > > However, unless I'm mistaken users will notice a device name change, > > > > especially when selecting a device in their web browser. Could that be a > > > > problem ? > > > > > > I think the only side effect is that the first time that the kernel > > > changes the naming convention, if there are more than one camera on > > > the system, the video conference might pick a different camera. > > > The good news is that the user will be presented with cameras with > > > different names. Now some cameras show very confusing names: > > > > > > ribalda@alco:~/work/linux$ for a in /dev/video* ; do yavta -l $a| grep > > > "Dell Webcam"; done > > > Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver > > > 'uvcvideo') supports video, capture, without mplanes. > > > Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver > > > 'uvcvideo') supports meta-data, capture, without mplanes. > > > Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver > > > 'uvcvideo') supports video, capture, without mplanes. > > > Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver > > > 'uvcvideo') supports meta-data, capture, without mplanes. > > I'm tempted to add a new model read-only string control to overcome the > length limitation. It could then be combined with other information > (such as the location and supported pixel formats) to create a > user-friendly camera name by applications. Adding the vid:pid would be really useful! Mapping a /dev/videoX to vid:pid is kind of complicated now. Thanks! > > > > > > /* > > > > > * Set the driver data before calling video_register_device, otherwise > > > > > > > -- > Regards, > > Laurent Pinchart
Hi Ricardo, On Wed, Dec 21, 2022 at 11:57:48AM +0100, Ricardo Ribalda wrote: > On Wed, 21 Dec 2022 at 11:55, Laurent Pinchart wrote: > > On Wed, Dec 21, 2022 at 12:00:58AM +0100, Ricardo Ribalda wrote: > > > On Tue, 6 Dec 2022 at 00:02, Ricardo Ribalda wrote: > > > > On Mon, 5 Dec 2022 at 23:16, Laurent Pinchart wrote: > > > > > On Fri, Dec 02, 2022 at 06:08:19PM +0100, Ricardo Ribalda wrote: > > > > > > Some cameras have multiple data inputs (i.e. IR sensor and RGB sensor), > > > > Did you mean "data outputs" by the way ? > > > > > > > > append a unique number to the device name. > > > > > > > > > > > > Fixes v4l2-compliance: > > > > > > Media Controller ioctls: > > > > > > fail: v4l2-test-media.cpp(205): v2_entity_names_set.find(key) != v2_entity_names_set.end() > > > > > > test MEDIA_IOC_G_TOPOLOGY: FAIL > > > > > > fail: v4l2-test-media.cpp(394): num_data_links != num_links > > > > > > test MEDIA_IOC_ENUM_ENTITIES/LINKS: FAIL > > > > > > > > > > > > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> > > > > > > --- > > > > > > drivers/media/usb/uvc/uvc_driver.c | 3 ++- > > > > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > > > > > > > diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c > > > > > > index 215fb483efb0..f4032ebb3689 100644 > > > > > > --- a/drivers/media/usb/uvc/uvc_driver.c > > > > > > +++ b/drivers/media/usb/uvc/uvc_driver.c > > > > > > @@ -1963,7 +1963,8 @@ int uvc_register_video_device(struct uvc_device *dev, > > > > > > break; > > > > > > } > > > > > > > > > > > > - strscpy(vdev->name, dev->name, sizeof(vdev->name)); > > > > > > + snprintf(vdev->name, sizeof(vdev->name), "%s %u", dev->name, > > > > > > + stream->header.bTerminalLink); > > > > > > > > > > This won't be perfect as the string is not guaranteed to fit in > > > > > vdev->name, but I suppose it will help as a quick fix for some devices. > > > > > How about the other devices ? Won't they still exhibit the above > > > > > v4l2-compliance failure ? Isn't that something that will still affect > > > > > Chrome OS devices ? > > > > > > > > We could place the id first... but that will look bad: Eg: > > > > > > > > 1- My favorite camera > > > > > > > > Another option is to remove the last chars to fit the id. Eg: > > > > > > > > My favorite came-1 > > > > > > > > If you prefer any of those options or have a better idea I can implement that. > > > > > > @Laurent > > > > > > Any preference here? > > > > I think the latter is better. Could we do so only when there are > > multiple video capture devices (excluding the metadata device) though ? > > That way we won't have a weird "-n" suffix in the majority of use cases. > > > > > > > The change should not cause any regression as big as in patch 1/3. > > > > > However, unless I'm mistaken users will notice a device name change, > > > > > especially when selecting a device in their web browser. Could that be a > > > > > problem ? > > > > > > > > I think the only side effect is that the first time that the kernel > > > > changes the naming convention, if there are more than one camera on > > > > the system, the video conference might pick a different camera. > > > > The good news is that the user will be presented with cameras with > > > > different names. Now some cameras show very confusing names: > > > > > > > > ribalda@alco:~/work/linux$ for a in /dev/video* ; do yavta -l $a| grep > > > > "Dell Webcam"; done > > > > Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver > > > > 'uvcvideo') supports video, capture, without mplanes. > > > > Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver > > > > 'uvcvideo') supports meta-data, capture, without mplanes. > > > > Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver > > > > 'uvcvideo') supports video, capture, without mplanes. > > > > Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver > > > > 'uvcvideo') supports meta-data, capture, without mplanes. > > > > I'm tempted to add a new model read-only string control to overcome the > > length limitation. It could then be combined with other information > > (such as the location and supported pixel formats) to create a > > user-friendly camera name by applications. > > Adding the vid:pid would be really useful! Mapping a /dev/videoX to > vid:pid is kind of complicated now. libcamera can help there ;-) We already extract the vendor and product ID. They are only used to create the camera ID at the moment, they are not exposed to applications independently. That would be a good addition. Overall, device naming is something that we have decided *not* to handle in libcamera. We provide information to applications to help them construct a meaningful name, but don't create the name ourselves. This was decided because naming schemes are dependent on application use cases, and in many cases should be localized (e.g. "Front camera" and "Back camera" vs. "Etukamera" and "Takakamera"). > > > > > > /* > > > > > > * Set the driver data before calling video_register_device, otherwise > > > > > >
Hi Laurent On Wed, 21 Dec 2022 at 12:23, Laurent Pinchart <laurent.pinchart@ideasonboard.com> wrote: > > Hi Ricardo, > > On Wed, Dec 21, 2022 at 11:57:48AM +0100, Ricardo Ribalda wrote: > > On Wed, 21 Dec 2022 at 11:55, Laurent Pinchart wrote: > > > On Wed, Dec 21, 2022 at 12:00:58AM +0100, Ricardo Ribalda wrote: > > > > On Tue, 6 Dec 2022 at 00:02, Ricardo Ribalda wrote: > > > > > On Mon, 5 Dec 2022 at 23:16, Laurent Pinchart wrote: > > > > > > On Fri, Dec 02, 2022 at 06:08:19PM +0100, Ricardo Ribalda wrote: > > > > > > > Some cameras have multiple data inputs (i.e. IR sensor and RGB sensor), > > > > > > Did you mean "data outputs" by the way ? > > > > > > > > > > append a unique number to the device name. > > > > > > > > > > > > > > Fixes v4l2-compliance: > > > > > > > Media Controller ioctls: > > > > > > > fail: v4l2-test-media.cpp(205): v2_entity_names_set.find(key) != v2_entity_names_set.end() > > > > > > > test MEDIA_IOC_G_TOPOLOGY: FAIL > > > > > > > fail: v4l2-test-media.cpp(394): num_data_links != num_links > > > > > > > test MEDIA_IOC_ENUM_ENTITIES/LINKS: FAIL > > > > > > > > > > > > > > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> > > > > > > > --- > > > > > > > drivers/media/usb/uvc/uvc_driver.c | 3 ++- > > > > > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > > > > > > > > > diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c > > > > > > > index 215fb483efb0..f4032ebb3689 100644 > > > > > > > --- a/drivers/media/usb/uvc/uvc_driver.c > > > > > > > +++ b/drivers/media/usb/uvc/uvc_driver.c > > > > > > > @@ -1963,7 +1963,8 @@ int uvc_register_video_device(struct uvc_device *dev, > > > > > > > break; > > > > > > > } > > > > > > > > > > > > > > - strscpy(vdev->name, dev->name, sizeof(vdev->name)); > > > > > > > + snprintf(vdev->name, sizeof(vdev->name), "%s %u", dev->name, > > > > > > > + stream->header.bTerminalLink); > > > > > > > > > > > > This won't be perfect as the string is not guaranteed to fit in > > > > > > vdev->name, but I suppose it will help as a quick fix for some devices. > > > > > > How about the other devices ? Won't they still exhibit the above > > > > > > v4l2-compliance failure ? Isn't that something that will still affect > > > > > > Chrome OS devices ? > > > > > > > > > > We could place the id first... but that will look bad: Eg: > > > > > > > > > > 1- My favorite camera > > > > > > > > > > Another option is to remove the last chars to fit the id. Eg: > > > > > > > > > > My favorite came-1 > > > > > > > > > > If you prefer any of those options or have a better idea I can implement that. > > > > > > > > @Laurent > > > > > > > > Any preference here? > > > > > > I think the latter is better. Could we do so only when there are > > > multiple video capture devices (excluding the metadata device) though ? > > > That way we won't have a weird "-n" suffix in the majority of use cases. > > > > > > > > > The change should not cause any regression as big as in patch 1/3. > > > > > > However, unless I'm mistaken users will notice a device name change, > > > > > > especially when selecting a device in their web browser. Could that be a > > > > > > problem ? > > > > > > > > > > I think the only side effect is that the first time that the kernel > > > > > changes the naming convention, if there are more than one camera on > > > > > the system, the video conference might pick a different camera. > > > > > The good news is that the user will be presented with cameras with > > > > > different names. Now some cameras show very confusing names: > > > > > > > > > > ribalda@alco:~/work/linux$ for a in /dev/video* ; do yavta -l $a| grep > > > > > "Dell Webcam"; done > > > > > Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver > > > > > 'uvcvideo') supports video, capture, without mplanes. > > > > > Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver > > > > > 'uvcvideo') supports meta-data, capture, without mplanes. > > > > > Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver > > > > > 'uvcvideo') supports video, capture, without mplanes. > > > > > Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver > > > > > 'uvcvideo') supports meta-data, capture, without mplanes. > > > > > > I'm tempted to add a new model read-only string control to overcome the > > > length limitation. It could then be combined with other information > > > (such as the location and supported pixel formats) to create a > > > user-friendly camera name by applications. > > > > Adding the vid:pid would be really useful! Mapping a /dev/videoX to > > vid:pid is kind of complicated now. > > libcamera can help there ;-) We already extract the vendor and product > ID. They are only used to create the camera ID at the moment, they are > not exposed to applications independently. That would be a good > addition. > > Overall, device naming is something that we have decided *not* to handle > in libcamera. We provide information to applications to help them > construct a meaningful name, but don't create the name ourselves. This > was decided because naming schemes are dependent on application use > cases, and in many cases should be localized (e.g. "Front camera" and > "Back camera" vs. "Etukamera" and "Takakamera"). Thanks for the explanation! My use case is: vendor apps for doing provisioning or low level testing. Libcamera would be a bit too much for that ;) Most of the time they do not get an image, but set fancy controls. Regards! > > > > > > > > /* > > > > > > > * Set the driver data before calling video_register_device, otherwise > > > > > > > > > -- > Regards, > > Laurent Pinchart
Em Tue, 6 Dec 2022 00:02:22 +0100 Ricardo Ribalda <ribalda@chromium.org> escreveu: > Hi Laurent > > On Mon, 5 Dec 2022 at 23:16, Laurent Pinchart > <laurent.pinchart@ideasonboard.com> wrote: > > > > Hi Ricardo, > > > > Thank you for the patch. > > > > On Fri, Dec 02, 2022 at 06:08:19PM +0100, Ricardo Ribalda wrote: > > > Some cameras have multiple data inputs (i.e. IR sensor and RGB sensor), > > > append a unique number to the device name. > > > > > > Fixes v4l2-compliance: > > > Media Controller ioctls: > > > fail: v4l2-test-media.cpp(205): v2_entity_names_set.find(key) != v2_entity_names_set.end() > > > test MEDIA_IOC_G_TOPOLOGY: FAIL > > > fail: v4l2-test-media.cpp(394): num_data_links != num_links > > > test MEDIA_IOC_ENUM_ENTITIES/LINKS: FAIL > > > > > > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> > > > --- > > > drivers/media/usb/uvc/uvc_driver.c | 3 ++- > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c > > > index 215fb483efb0..f4032ebb3689 100644 > > > --- a/drivers/media/usb/uvc/uvc_driver.c > > > +++ b/drivers/media/usb/uvc/uvc_driver.c > > > @@ -1963,7 +1963,8 @@ int uvc_register_video_device(struct uvc_device *dev, > > > break; > > > } > > > > > > - strscpy(vdev->name, dev->name, sizeof(vdev->name)); > > > + snprintf(vdev->name, sizeof(vdev->name), "%s %u", dev->name, > > > + stream->header.bTerminalLink); > > > > This won't be perfect as the string is not guaranteed to fit in > > vdev->name, but I suppose it will help as a quick fix for some devices. > > How about the other devices ? Won't they still exhibit the above > > v4l2-compliance failure ? Isn't that something that will still affect > > Chrome OS devices ? > > We could place the id first... but that will look bad: Eg: > > 1- My favorite camera > > Another option is to remove the last chars to fit the id. Eg: > > My favorite came-1 > > If you prefer any of those options or have a better idea I can implement that. > > > > > > The change should not cause any regression as big as in patch 1/3. > > However, unless I'm mistaken users will notice a device name change, > > especially when selecting a device in their web browser. Could that be a > > problem ? > > I think the only side effect is that the first time that the kernel > changes the naming convention, if there are more than one camera on > the system, the video conference might pick a different camera. > The good news is that the user will be presented with cameras with > different names. Now some cameras show very confusing names: > > ribalda@alco:~/work/linux$ for a in /dev/video* ; do yavta -l $a| grep > "Dell Webcam"; done > Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver > 'uvcvideo') supports video, capture, without mplanes. > Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver > 'uvcvideo') supports meta-data, capture, without mplanes. > Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver > 'uvcvideo') supports video, capture, without mplanes. > Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver > 'uvcvideo') supports meta-data, capture, without mplanes. That is bad, as some apps like camorama actually store the user preferences (last used resolution and fps), preserving them the next time the camera with the same name is used. In the specific case of camorama, it uses the by-id filename, which is derived from the name, as stored at: $ ls -la /dev/v4l/by-id/usb-Quanta_HD_Camera_0001-video-index* lrwxrwxrwx 1 root root 12 dez 21 09:59 /dev/v4l/by-id/usb-Quanta_HD_Camera_0001-video-index0 -> ../../video0 lrwxrwxrwx 1 root root 12 dez 21 09:59 /dev/v4l/by-id/usb-Quanta_HD_Camera_0001-video-index1 -> ../../video1 With this change, not only the camera name will become bigger (and may end losing the index0/index1 data), but it will also lost the stored preferences on apps like camorama, causing regressions. It sounds a lot easier to teach udev to change the name on an unique way, on machines where you need it. Regards, Mauro
Hi Mauro, On Wed, Dec 21, 2022 at 10:02:48PM +0000, Mauro Carvalho Chehab wrote: > Em Tue, 6 Dec 2022 00:02:22 +0100 Ricardo Ribalda escreveu: > > On Mon, 5 Dec 2022 at 23:16, Laurent Pinchart wrote: > > > On Fri, Dec 02, 2022 at 06:08:19PM +0100, Ricardo Ribalda wrote: > > > > Some cameras have multiple data inputs (i.e. IR sensor and RGB sensor), > > > > append a unique number to the device name. > > > > > > > > Fixes v4l2-compliance: > > > > Media Controller ioctls: > > > > fail: v4l2-test-media.cpp(205): v2_entity_names_set.find(key) != v2_entity_names_set.end() > > > > test MEDIA_IOC_G_TOPOLOGY: FAIL > > > > fail: v4l2-test-media.cpp(394): num_data_links != num_links > > > > test MEDIA_IOC_ENUM_ENTITIES/LINKS: FAIL > > > > > > > > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> > > > > --- > > > > drivers/media/usb/uvc/uvc_driver.c | 3 ++- > > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c > > > > index 215fb483efb0..f4032ebb3689 100644 > > > > --- a/drivers/media/usb/uvc/uvc_driver.c > > > > +++ b/drivers/media/usb/uvc/uvc_driver.c > > > > @@ -1963,7 +1963,8 @@ int uvc_register_video_device(struct uvc_device *dev, > > > > break; > > > > } > > > > > > > > - strscpy(vdev->name, dev->name, sizeof(vdev->name)); > > > > + snprintf(vdev->name, sizeof(vdev->name), "%s %u", dev->name, > > > > + stream->header.bTerminalLink); > > > > > > This won't be perfect as the string is not guaranteed to fit in > > > vdev->name, but I suppose it will help as a quick fix for some devices. > > > How about the other devices ? Won't they still exhibit the above > > > v4l2-compliance failure ? Isn't that something that will still affect > > > Chrome OS devices ? > > > > We could place the id first... but that will look bad: Eg: > > > > 1- My favorite camera > > > > Another option is to remove the last chars to fit the id. Eg: > > > > My favorite came-1 > > > > If you prefer any of those options or have a better idea I can implement that. > > > > > The change should not cause any regression as big as in patch 1/3. > > > However, unless I'm mistaken users will notice a device name change, > > > especially when selecting a device in their web browser. Could that be a > > > problem ? > > > > I think the only side effect is that the first time that the kernel > > changes the naming convention, if there are more than one camera on > > the system, the video conference might pick a different camera. > > The good news is that the user will be presented with cameras with > > different names. Now some cameras show very confusing names: > > > > ribalda@alco:~/work/linux$ for a in /dev/video* ; do yavta -l $a| grep > > "Dell Webcam"; done > > Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver > > 'uvcvideo') supports video, capture, without mplanes. > > Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver > > 'uvcvideo') supports meta-data, capture, without mplanes. > > Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver > > 'uvcvideo') supports video, capture, without mplanes. > > Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver > > 'uvcvideo') supports meta-data, capture, without mplanes. > > That is bad, as some apps like camorama actually store the user > preferences (last used resolution and fps), preserving them the next > time the camera with the same name is used. > > In the specific case of camorama, it uses the by-id filename, which is > derived from the name, as stored at: > > $ ls -la /dev/v4l/by-id/usb-Quanta_HD_Camera_0001-video-index* > lrwxrwxrwx 1 root root 12 dez 21 09:59 /dev/v4l/by-id/usb-Quanta_HD_Camera_0001-video-index0 -> ../../video0 > lrwxrwxrwx 1 root root 12 dez 21 09:59 /dev/v4l/by-id/usb-Quanta_HD_Camera_0001-video-index1 -> ../../video1 > > With this change, not only the camera name will become bigger (and may > end losing the index0/index1 data), but it will also lost the stored > preferences on apps like camorama, causing regressions. > > It sounds a lot easier to teach udev to change the name on an unique > way, on machines where you need it. It's not a udev issue, it's an API compliance problem, entity names in a media controller graph must be unique, and they are not. Losing the stored preference is possibly inconvenient in some cases, but I don't think it's a real blocker.
Hi Ricardo, On Wed, Dec 21, 2022 at 09:21:57PM +0100, Ricardo Ribalda wrote: > On Wed, 21 Dec 2022 at 12:23, Laurent Pinchart wrote: > > On Wed, Dec 21, 2022 at 11:57:48AM +0100, Ricardo Ribalda wrote: > > > On Wed, 21 Dec 2022 at 11:55, Laurent Pinchart wrote: > > > > On Wed, Dec 21, 2022 at 12:00:58AM +0100, Ricardo Ribalda wrote: > > > > > On Tue, 6 Dec 2022 at 00:02, Ricardo Ribalda wrote: > > > > > > On Mon, 5 Dec 2022 at 23:16, Laurent Pinchart wrote: > > > > > > > On Fri, Dec 02, 2022 at 06:08:19PM +0100, Ricardo Ribalda wrote: > > > > > > > > Some cameras have multiple data inputs (i.e. IR sensor and RGB sensor), > > > > > > > > Did you mean "data outputs" by the way ? > > > > > > > > > > > > append a unique number to the device name. > > > > > > > > > > > > > > > > Fixes v4l2-compliance: > > > > > > > > Media Controller ioctls: > > > > > > > > fail: v4l2-test-media.cpp(205): v2_entity_names_set.find(key) != v2_entity_names_set.end() > > > > > > > > test MEDIA_IOC_G_TOPOLOGY: FAIL > > > > > > > > fail: v4l2-test-media.cpp(394): num_data_links != num_links > > > > > > > > test MEDIA_IOC_ENUM_ENTITIES/LINKS: FAIL > > > > > > > > > > > > > > > > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> > > > > > > > > --- > > > > > > > > drivers/media/usb/uvc/uvc_driver.c | 3 ++- > > > > > > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > > > > > > > > > > > diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c > > > > > > > > index 215fb483efb0..f4032ebb3689 100644 > > > > > > > > --- a/drivers/media/usb/uvc/uvc_driver.c > > > > > > > > +++ b/drivers/media/usb/uvc/uvc_driver.c > > > > > > > > @@ -1963,7 +1963,8 @@ int uvc_register_video_device(struct uvc_device *dev, > > > > > > > > break; > > > > > > > > } > > > > > > > > > > > > > > > > - strscpy(vdev->name, dev->name, sizeof(vdev->name)); > > > > > > > > + snprintf(vdev->name, sizeof(vdev->name), "%s %u", dev->name, > > > > > > > > + stream->header.bTerminalLink); > > > > > > > > > > > > > > This won't be perfect as the string is not guaranteed to fit in > > > > > > > vdev->name, but I suppose it will help as a quick fix for some devices. > > > > > > > How about the other devices ? Won't they still exhibit the above > > > > > > > v4l2-compliance failure ? Isn't that something that will still affect > > > > > > > Chrome OS devices ? > > > > > > > > > > > > We could place the id first... but that will look bad: Eg: > > > > > > > > > > > > 1- My favorite camera > > > > > > > > > > > > Another option is to remove the last chars to fit the id. Eg: > > > > > > > > > > > > My favorite came-1 > > > > > > > > > > > > If you prefer any of those options or have a better idea I can implement that. > > > > > > > > > > @Laurent > > > > > > > > > > Any preference here? > > > > > > > > I think the latter is better. Could we do so only when there are > > > > multiple video capture devices (excluding the metadata device) though ? > > > > That way we won't have a weird "-n" suffix in the majority of use cases. > > > > > > > > > > > The change should not cause any regression as big as in patch 1/3. > > > > > > > However, unless I'm mistaken users will notice a device name change, > > > > > > > especially when selecting a device in their web browser. Could that be a > > > > > > > problem ? > > > > > > > > > > > > I think the only side effect is that the first time that the kernel > > > > > > changes the naming convention, if there are more than one camera on > > > > > > the system, the video conference might pick a different camera. > > > > > > The good news is that the user will be presented with cameras with > > > > > > different names. Now some cameras show very confusing names: > > > > > > > > > > > > ribalda@alco:~/work/linux$ for a in /dev/video* ; do yavta -l $a| grep > > > > > > "Dell Webcam"; done > > > > > > Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver > > > > > > 'uvcvideo') supports video, capture, without mplanes. > > > > > > Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver > > > > > > 'uvcvideo') supports meta-data, capture, without mplanes. > > > > > > Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver > > > > > > 'uvcvideo') supports video, capture, without mplanes. > > > > > > Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver > > > > > > 'uvcvideo') supports meta-data, capture, without mplanes. > > > > > > > > I'm tempted to add a new model read-only string control to overcome the > > > > length limitation. It could then be combined with other information > > > > (such as the location and supported pixel formats) to create a > > > > user-friendly camera name by applications. > > > > > > Adding the vid:pid would be really useful! Mapping a /dev/videoX to > > > vid:pid is kind of complicated now. > > > > libcamera can help there ;-) We already extract the vendor and product > > ID. They are only used to create the camera ID at the moment, they are > > not exposed to applications independently. That would be a good > > addition. > > > > Overall, device naming is something that we have decided *not* to handle > > in libcamera. We provide information to applications to help them > > construct a meaningful name, but don't create the name ourselves. This > > was decided because naming schemes are dependent on application use > > cases, and in many cases should be localized (e.g. "Front camera" and > > "Back camera" vs. "Etukamera" and "Takakamera"). > > Thanks for the explanation! > > My use case is: vendor apps for doing provisioning or low level > testing. Libcamera would be a bit too much for that ;) > > Most of the time they do not get an image, but set fancy controls. I see what you mean. libcamera isn't the right tool for that indeed, but maybe the additional complexity of looking up the VID:PID isn't such a big deal in those cases ? It's not that complicated using sysfs, and can even be done quite simply with a shell script. Maybe a standard simple script in v4l-utils (or in another location) could help ? > > > > > > > > /* > > > > > > > > * Set the driver data before calling video_register_device, otherwise > > > > > > > >
Em Thu, 22 Dec 2022 00:24:44 +0200 Laurent Pinchart <laurent.pinchart@ideasonboard.com> escreveu: > Hi Mauro, > > On Wed, Dec 21, 2022 at 10:02:48PM +0000, Mauro Carvalho Chehab wrote: > > Em Tue, 6 Dec 2022 00:02:22 +0100 Ricardo Ribalda escreveu: > > > On Mon, 5 Dec 2022 at 23:16, Laurent Pinchart wrote: > > > > On Fri, Dec 02, 2022 at 06:08:19PM +0100, Ricardo Ribalda wrote: > > > > > Some cameras have multiple data inputs (i.e. IR sensor and RGB sensor), > > > > > append a unique number to the device name. > > > > > > > > > > Fixes v4l2-compliance: > > > > > Media Controller ioctls: > > > > > fail: v4l2-test-media.cpp(205): v2_entity_names_set.find(key) != v2_entity_names_set.end() > > > > > test MEDIA_IOC_G_TOPOLOGY: FAIL > > > > > fail: v4l2-test-media.cpp(394): num_data_links != num_links > > > > > test MEDIA_IOC_ENUM_ENTITIES/LINKS: FAIL > > > > > > > > > > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> > > > > > --- > > > > > drivers/media/usb/uvc/uvc_driver.c | 3 ++- > > > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > > > > > diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c > > > > > index 215fb483efb0..f4032ebb3689 100644 > > > > > --- a/drivers/media/usb/uvc/uvc_driver.c > > > > > +++ b/drivers/media/usb/uvc/uvc_driver.c > > > > > @@ -1963,7 +1963,8 @@ int uvc_register_video_device(struct uvc_device *dev, > > > > > break; > > > > > } > > > > > > > > > > - strscpy(vdev->name, dev->name, sizeof(vdev->name)); > > > > > + snprintf(vdev->name, sizeof(vdev->name), "%s %u", dev->name, > > > > > + stream->header.bTerminalLink); > > > > > > > > This won't be perfect as the string is not guaranteed to fit in > > > > vdev->name, but I suppose it will help as a quick fix for some devices. > > > > How about the other devices ? Won't they still exhibit the above > > > > v4l2-compliance failure ? Isn't that something that will still affect > > > > Chrome OS devices ? > > > > > > We could place the id first... but that will look bad: Eg: > > > > > > 1- My favorite camera > > > > > > Another option is to remove the last chars to fit the id. Eg: > > > > > > My favorite came-1 > > > > > > If you prefer any of those options or have a better idea I can implement that. > > > > > > > The change should not cause any regression as big as in patch 1/3. > > > > However, unless I'm mistaken users will notice a device name change, > > > > especially when selecting a device in their web browser. Could that be a > > > > problem ? > > > > > > I think the only side effect is that the first time that the kernel > > > changes the naming convention, if there are more than one camera on > > > the system, the video conference might pick a different camera. > > > The good news is that the user will be presented with cameras with > > > different names. Now some cameras show very confusing names: > > > > > > ribalda@alco:~/work/linux$ for a in /dev/video* ; do yavta -l $a| grep > > > "Dell Webcam"; done > > > Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver > > > 'uvcvideo') supports video, capture, without mplanes. > > > Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver > > > 'uvcvideo') supports meta-data, capture, without mplanes. > > > Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver > > > 'uvcvideo') supports video, capture, without mplanes. > > > Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver > > > 'uvcvideo') supports meta-data, capture, without mplanes. > > > > That is bad, as some apps like camorama actually store the user > > preferences (last used resolution and fps), preserving them the next > > time the camera with the same name is used. > > > > In the specific case of camorama, it uses the by-id filename, which is > > derived from the name, as stored at: > > > > $ ls -la /dev/v4l/by-id/usb-Quanta_HD_Camera_0001-video-index* > > lrwxrwxrwx 1 root root 12 dez 21 09:59 /dev/v4l/by-id/usb-Quanta_HD_Camera_0001-video-index0 -> ../../video0 > > lrwxrwxrwx 1 root root 12 dez 21 09:59 /dev/v4l/by-id/usb-Quanta_HD_Camera_0001-video-index1 -> ../../video1 > > > > With this change, not only the camera name will become bigger (and may > > end losing the index0/index1 data), but it will also lost the stored > > preferences on apps like camorama, causing regressions. > > > > It sounds a lot easier to teach udev to change the name on an unique > > way, on machines where you need it. > > It's not a udev issue, it's an API compliance problem, entity names in a > media controller graph must be unique, and they are not. Then the right fix would be inside the media controller naming logic, in a way that it will ensure unique names. It sounds to me that mc core should then check, at device's register time, if the name was already used. If so, change it to be unique. > Losing the stored preference is possibly inconvenient in some cases, but > I don't think it's a real blocker. If it causes userspace regressions, then it is a blocker. Regards, Mauro
On Wed, Dec 21, 2022 at 10:54:50PM +0000, Mauro Carvalho Chehab wrote: > Em Thu, 22 Dec 2022 00:24:44 +0200 > Laurent Pinchart <laurent.pinchart@ideasonboard.com> escreveu: > > > Hi Mauro, > > > > On Wed, Dec 21, 2022 at 10:02:48PM +0000, Mauro Carvalho Chehab wrote: > > > Em Tue, 6 Dec 2022 00:02:22 +0100 Ricardo Ribalda escreveu: > > > > On Mon, 5 Dec 2022 at 23:16, Laurent Pinchart wrote: > > > > > On Fri, Dec 02, 2022 at 06:08:19PM +0100, Ricardo Ribalda wrote: > > > > > > Some cameras have multiple data inputs (i.e. IR sensor and RGB sensor), > > > > > > append a unique number to the device name. > > > > > > > > > > > > Fixes v4l2-compliance: > > > > > > Media Controller ioctls: > > > > > > fail: v4l2-test-media.cpp(205): v2_entity_names_set.find(key) != v2_entity_names_set.end() > > > > > > test MEDIA_IOC_G_TOPOLOGY: FAIL > > > > > > fail: v4l2-test-media.cpp(394): num_data_links != num_links > > > > > > test MEDIA_IOC_ENUM_ENTITIES/LINKS: FAIL > > > > > > > > > > > > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> > > > > > > --- > > > > > > drivers/media/usb/uvc/uvc_driver.c | 3 ++- > > > > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > > > > > > > diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c > > > > > > index 215fb483efb0..f4032ebb3689 100644 > > > > > > --- a/drivers/media/usb/uvc/uvc_driver.c > > > > > > +++ b/drivers/media/usb/uvc/uvc_driver.c > > > > > > @@ -1963,7 +1963,8 @@ int uvc_register_video_device(struct uvc_device *dev, > > > > > > break; > > > > > > } > > > > > > > > > > > > - strscpy(vdev->name, dev->name, sizeof(vdev->name)); > > > > > > + snprintf(vdev->name, sizeof(vdev->name), "%s %u", dev->name, > > > > > > + stream->header.bTerminalLink); > > > > > > > > > > This won't be perfect as the string is not guaranteed to fit in > > > > > vdev->name, but I suppose it will help as a quick fix for some devices. > > > > > How about the other devices ? Won't they still exhibit the above > > > > > v4l2-compliance failure ? Isn't that something that will still affect > > > > > Chrome OS devices ? > > > > > > > > We could place the id first... but that will look bad: Eg: > > > > > > > > 1- My favorite camera > > > > > > > > Another option is to remove the last chars to fit the id. Eg: > > > > > > > > My favorite came-1 > > > > > > > > If you prefer any of those options or have a better idea I can implement that. > > > > > > > > > The change should not cause any regression as big as in patch 1/3. > > > > > However, unless I'm mistaken users will notice a device name change, > > > > > especially when selecting a device in their web browser. Could that be a > > > > > problem ? > > > > > > > > I think the only side effect is that the first time that the kernel > > > > changes the naming convention, if there are more than one camera on > > > > the system, the video conference might pick a different camera. > > > > The good news is that the user will be presented with cameras with > > > > different names. Now some cameras show very confusing names: > > > > > > > > ribalda@alco:~/work/linux$ for a in /dev/video* ; do yavta -l $a| grep > > > > "Dell Webcam"; done > > > > Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver > > > > 'uvcvideo') supports video, capture, without mplanes. > > > > Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver > > > > 'uvcvideo') supports meta-data, capture, without mplanes. > > > > Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver > > > > 'uvcvideo') supports video, capture, without mplanes. > > > > Device `Dell Webcam WB7022' on `usb-0000:2d:00.0-1.2.3.1' (driver > > > > 'uvcvideo') supports meta-data, capture, without mplanes. > > > > > > That is bad, as some apps like camorama actually store the user > > > preferences (last used resolution and fps), preserving them the next > > > time the camera with the same name is used. > > > > > > In the specific case of camorama, it uses the by-id filename, which is > > > derived from the name, as stored at: > > > > > > $ ls -la /dev/v4l/by-id/usb-Quanta_HD_Camera_0001-video-index* > > > lrwxrwxrwx 1 root root 12 dez 21 09:59 /dev/v4l/by-id/usb-Quanta_HD_Camera_0001-video-index0 -> ../../video0 > > > lrwxrwxrwx 1 root root 12 dez 21 09:59 /dev/v4l/by-id/usb-Quanta_HD_Camera_0001-video-index1 -> ../../video1 > > > > > > With this change, not only the camera name will become bigger (and may > > > end losing the index0/index1 data), but it will also lost the stored > > > preferences on apps like camorama, causing regressions. > > > > > > It sounds a lot easier to teach udev to change the name on an unique > > > way, on machines where you need it. > > > > It's not a udev issue, it's an API compliance problem, entity names in a > > media controller graph must be unique, and they are not. > > Then the right fix would be inside the media controller naming > logic, in a way that it will ensure unique names. It sounds to me > that mc core should then check, at device's register time, if the > name was already used. If so, change it to be unique. The entity name and video device name are one and the same. > > Losing the stored preference is possibly inconvenient in some cases, but > > I don't think it's a real blocker. > > If it causes userspace regressions, then it is a blocker. I wouldn't necessarily call this a regression.
diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index 215fb483efb0..f4032ebb3689 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -1963,7 +1963,8 @@ int uvc_register_video_device(struct uvc_device *dev, break; } - strscpy(vdev->name, dev->name, sizeof(vdev->name)); + snprintf(vdev->name, sizeof(vdev->name), "%s %u", dev->name, + stream->header.bTerminalLink); /* * Set the driver data before calling video_register_device, otherwise