From patchwork Tue Dec 7 00:06:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda Delgado X-Patchwork-Id: 12660561 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9FBB0C433FE for ; Tue, 7 Dec 2021 00:06:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351463AbhLGAKI (ORCPT ); Mon, 6 Dec 2021 19:10:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357955AbhLGAKD (ORCPT ); Mon, 6 Dec 2021 19:10:03 -0500 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 569C0C061746; Mon, 6 Dec 2021 16:06:34 -0800 (PST) Received: by mail-ed1-x52c.google.com with SMTP id r11so49523499edd.9; Mon, 06 Dec 2021 16:06:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Y9BlW3tW97AkK+vn8PCzzi0aOsH6GB6w8a58eRmyYjc=; b=n98sMr+RdacEvvYXsn7f9OhBlVeGv2hXjrLPAAHqo2rpfVj5F01lCK8fizNs0zQGgJ 64DdvFJp6b/ko/a6DGstyiwFEtuZYUpQDJsL0Xe92Q/hImi/kotTB2Y5N2D6vNuMaKu3 UCSW196FvvubsS3QsCtj7M9T76MeoqVscv2F79UXcwd/wx1rc8APn7PHgXXJi7tPcOJ6 SZeVTwoikQbcM879oMhL8pCmUpDjtQhhSCXw03VyzE7JvJAK7dmY2/853lEQEHfEjyrc Lwbrz7ZqQs+jB43NUgWthI4FWEZMrRrHXCriFZq8GionOtPdM4Vn04+06A8++v9v2xBJ iihQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Y9BlW3tW97AkK+vn8PCzzi0aOsH6GB6w8a58eRmyYjc=; b=cgO0/98N9J6/CyQuxZ252az+w4OHxHqlEapzCogBBMzEwJLAp0DkFPoSbyDdmyj1c5 4mSdetoQX6LUE/mi+gtLrWDeEwjogadELAD+3RdFvfFRDISqL6pnUTOQ2+tXOkqJv/D5 //UCIWVAbmUh/RFDcnWi6Lw0bvuHHkQXs+/Xnt8W9Xj3DMzCPm3gVPcSket4KUfHDQzS gYp0f2cEowXCX/nHR3+GV1pGFoMCtoUf8uXOCd7AV8ABDCUWsWhe5X70y9DJN4bLT3fK 8UNa9bSb8BdN1rWN0vuqoMm4JRW8jUF1ZsDYqueTJaemSNiI+wdJAf/SHsBdVT//hfR0 yn+g== X-Gm-Message-State: AOAM531RfgMUNN+jnI9dJFg5TEC5c1bgmXwP7hwtnfRTKi51TcwOGkvU Qn7iOe3AxHeQYwS9qjAuwhI= X-Google-Smtp-Source: ABdhPJyToRWxuN4Kb29Mk+9wG4XQx3dJzRyIetHQPSJcO+et4L7HwrNpBjqlg+94u1xp79xjxCT9qQ== X-Received: by 2002:a17:906:3b84:: with SMTP id u4mr47852666ejf.310.1638835592899; Mon, 06 Dec 2021 16:06:32 -0800 (PST) Received: from piling.lan (80.71.134.83.ipv4.parknet.dk. [80.71.134.83]) by smtp.gmail.com with ESMTPSA id w18sm8713114edx.55.2021.12.06.16.06.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Dec 2021 16:06:32 -0800 (PST) From: Ricardo Ribalda X-Google-Original-From: Ricardo Ribalda To: Nicolas Dufresne , Laurent Pinchart , ": Ricardo Ribalda" , Hans Verkuil , Mauro Carvalho Chehab , Sergey Senozhatsky , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, tfiga@chromium.org, stable Subject: [PATCH 1/3] Revert "media: uvcvideo: Set unique vdev name based in type" Date: Tue, 7 Dec 2021 01:06:27 +0100 Message-Id: <20211207000629.4985-2-ribalda@chromium.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211207000629.4985-1-ribalda@chromium.org> References: <20211207000629.4985-1-ribalda@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org A lot of userspace depends on a descriptive name for vdev. Without this patch, users have a hard time figuring out which camera shall they use for their video conferencing. This reverts commit e3f60e7e1a2b451f538f9926763432249bcf39c4. Cc: Fixes: e3f60e7e1a2b ("media: uvcvideo: Set unique vdev name based in type") Reported-by: Nicolas Dufresne Signed-off-by: Ricardo Ribalda Reviewed-by: Laurent Pinchart --- drivers/media/usb/uvc/uvc_driver.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index 7c007426e082..058d28a0344b 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -2193,7 +2193,6 @@ int uvc_register_video_device(struct uvc_device *dev, const struct v4l2_file_operations *fops, const struct v4l2_ioctl_ops *ioctl_ops) { - const char *name; int ret; /* Initialize the video buffers queue. */ @@ -2222,20 +2221,16 @@ int uvc_register_video_device(struct uvc_device *dev, case V4L2_BUF_TYPE_VIDEO_CAPTURE: default: vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING; - name = "Video Capture"; break; case V4L2_BUF_TYPE_VIDEO_OUTPUT: vdev->device_caps = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING; - name = "Video Output"; break; case V4L2_BUF_TYPE_META_CAPTURE: vdev->device_caps = V4L2_CAP_META_CAPTURE | V4L2_CAP_STREAMING; - name = "Metadata"; break; } - snprintf(vdev->name, sizeof(vdev->name), "%s %u", name, - stream->header.bTerminalLink); + strscpy(vdev->name, dev->name, sizeof(vdev->name)); /* * Set the driver data before calling video_register_device, otherwise From patchwork Tue Dec 7 00:06:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda Delgado X-Patchwork-Id: 12660565 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 853D9C4332F for ; Tue, 7 Dec 2021 00:06:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377968AbhLGAKJ (ORCPT ); Mon, 6 Dec 2021 19:10:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377931AbhLGAKE (ORCPT ); Mon, 6 Dec 2021 19:10:04 -0500 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 444C8C061746; Mon, 6 Dec 2021 16:06:35 -0800 (PST) Received: by mail-ed1-x52f.google.com with SMTP id z5so50256874edd.3; Mon, 06 Dec 2021 16:06:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=6oO/DmCZBRIesH47nko+UAMyw7O3EO2xK/KulGn/MuY=; b=NLw7lDweGJvuzpZG1urmwqCOmLa8QmnqhT6s8iHpEn0tXkxfUO7CKfOlsL5+PDGllh FKU3TvN0wmada1BsHIVre5o2/Ca8XuhQbyAP+Hvn4FT3avURlmooBuULoG9Uaa8qOEgY Z2/4noS88LsB7M6B/I4jpWg7JHmDBhO8V+SuVXlHklvIQej8IQLSlnCU2paR1liZl3f9 UM43+L9FgEAAepHQNaKgQL6DZ0Fp2KzzYbrmvgL77FQ7Qgo3Y7mMuF7ScGuleE0yJ75b 5BLLqLL+VxymVvxqARGZY+3wyqeUKggWDJwTzi7FzTIbvJ8supifMimMaEEVpfrdsKME 1C8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6oO/DmCZBRIesH47nko+UAMyw7O3EO2xK/KulGn/MuY=; b=AC8z8FhwbebrInQ3LS2/PEfzhZGPRI+9XWGuoZ4+9/WUZP9qC/fzOz9lV57ehqSYnf UC9/N4FtF7+OMwyRkYe/DOWo2AqfYQQKfB1YE5yRC+mc3k4dKmKI98tMGPtEjVFYA98H NxWEkYEUszIaEfcJIbsolq59xDfVnArZ1Eti6ZLODzg8duvJJwNJIo9E9W48zk2c5aEm wtGp4Sq7rP6dTyRGfdSNu0RXS6lO5E97WU30MxhaGyEsANFWxQ6JvM3CtC+2TA78s+TK RZ70OhGISiiD1850/2DWDBQ/5XRnSgOyxIXVfk8z8fgunitZuxIkPeja6GJasFMqX90I Pkyw== X-Gm-Message-State: AOAM532cr6DyxZ3JpP67eGI2tvRdzVe2d1UNRM0ht2FyYua1713NiyZK yVM6Tz+1EGmcjp0/xwulCAA= X-Google-Smtp-Source: ABdhPJzmq4YQknoDmdZDEaunDUhyHzVUxw++prxmEkRu25E6qStXkavhxBOiLTlmWpZB9qzkZmC6Ag== X-Received: by 2002:a05:6402:1e90:: with SMTP id f16mr3564426edf.91.1638835593884; Mon, 06 Dec 2021 16:06:33 -0800 (PST) Received: from piling.lan (80.71.134.83.ipv4.parknet.dk. [80.71.134.83]) by smtp.gmail.com with ESMTPSA id w18sm8713114edx.55.2021.12.06.16.06.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Dec 2021 16:06:33 -0800 (PST) From: Ricardo Ribalda X-Google-Original-From: Ricardo Ribalda To: Nicolas Dufresne , Laurent Pinchart , ": Ricardo Ribalda" , Hans Verkuil , Mauro Carvalho Chehab , Sergey Senozhatsky , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, tfiga@chromium.org, stable Subject: [PATCH 2/3] media: v4l2-dev.c: Allow driver-defined entity names Date: Tue, 7 Dec 2021 01:06:28 +0100 Message-Id: <20211207000629.4985-3-ribalda@chromium.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211207000629.4985-1-ribalda@chromium.org> References: <20211207000629.4985-1-ribalda@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org If the driver provides an name for an entity, use it. This is particularly useful for drivers that export multiple video devices for the same hardware (i.e. metadata and data). Signed-off-by: Ricardo Ribalda --- drivers/media/v4l2-core/v4l2-dev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c index d03ace324db0..4c00503b9349 100644 --- a/drivers/media/v4l2-core/v4l2-dev.c +++ b/drivers/media/v4l2-core/v4l2-dev.c @@ -832,7 +832,9 @@ static int video_register_media_controller(struct video_device *vdev) } if (vdev->entity.function != MEDIA_ENT_F_UNKNOWN) { - vdev->entity.name = vdev->name; + /* Use entity names provided by the driver, if available. */ + if (!vdev->entity.name) + vdev->entity.name = vdev->name; /* Needed just for backward compatibility with legacy MC API */ vdev->entity.info.dev.major = VIDEO_MAJOR; From patchwork Tue Dec 7 00:06:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda Delgado X-Patchwork-Id: 12660563 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95DE4C433FE for ; Tue, 7 Dec 2021 00:06:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378021AbhLGAKK (ORCPT ); Mon, 6 Dec 2021 19:10:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377974AbhLGAKF (ORCPT ); Mon, 6 Dec 2021 19:10:05 -0500 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71897C061746; Mon, 6 Dec 2021 16:06:36 -0800 (PST) Received: by mail-ed1-x532.google.com with SMTP id e3so49965586edu.4; Mon, 06 Dec 2021 16:06:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=J/izVKc3tuBxJtnAJV+Cykg9SYVmJJjsg5mHWvc7FL8=; b=cBAw5wC55uc1Ko2CY/uFR3PpqvXUrPYByfqA/GKUr9zdfcbOMBzNkUb/hBoLfLIGLv 5k8D8j9+sPbpnkEFDQo7Ie7aVrSZaXaXfCQ0vuRO7NWdn8+UxTox4cLXu6f0nw40x+Y6 WW+aCxp/48t4SivOwsiFOjmFXUtauUJD13a7vZkQZMrLPUZ5rUrgpJ7F3vSOywKzP/eO H/lveWpy+laHm7T1FY4HFNVOeeskbuYVfkV1g0aYUyib29x519ofPHlxLID696NAvckd yJoUI6ISbmN/yRERPhvqhaYssEwIBTj07OwcmHZgpW5BHrXXPWJrPovSeaU/ePSW1H0d 17aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=J/izVKc3tuBxJtnAJV+Cykg9SYVmJJjsg5mHWvc7FL8=; b=uA2Xbgfw/KvPVOqSLk4jQvt1y42/9rALGemSpwGuVdbRwmBTNFKyFPx9aBO8DWtF48 QjV7HXihQVVmr+hgi8TseY29Ddto0BnHdtxlwd0Is1figDuVh4wGL8P4ENKAljyEjw3O kFUzdSk4IEPzOUfBX34iadb+CnvV/r5LuVdPDwRv9xYpPRVGaixZwaZ+Lse2RnsWpFPp F3j0+tcX+n4vTuolg+IwtHmhdo0r9eZBJpRAWalHDNgEjHsOXpK5n+B75d3Xq1o7O4aZ xyjBxYTXShDUwQ6R5FfyhhYc40aejwRMpVxWojFXLFOJF30S4QewMUgaqqt6xuj4waV9 R7/w== X-Gm-Message-State: AOAM531TibbMLZk9J5eAATA+eqDUsqkEA5ufBcEUjFJHZHAaflDy/vjf xWWdDBFa9SiX8+IosFMyE0g= X-Google-Smtp-Source: ABdhPJyfIL/kxLjWWeRlAaiJbtv6RSRylX5+dzF5ZAhoy3DC9sFI792+w+OoB3s7sb3RSeh6T3229w== X-Received: by 2002:a17:906:fa87:: with SMTP id lt7mr50151940ejb.426.1638835595028; Mon, 06 Dec 2021 16:06:35 -0800 (PST) Received: from piling.lan (80.71.134.83.ipv4.parknet.dk. [80.71.134.83]) by smtp.gmail.com with ESMTPSA id w18sm8713114edx.55.2021.12.06.16.06.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Dec 2021 16:06:34 -0800 (PST) From: Ricardo Ribalda X-Google-Original-From: Ricardo Ribalda To: Nicolas Dufresne , Laurent Pinchart , ": Ricardo Ribalda" , Hans Verkuil , Mauro Carvalho Chehab , Sergey Senozhatsky , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, tfiga@chromium.org, stable Subject: [PATCH 3/3] media: uvcvideo: Set unique entity name based in type Date: Tue, 7 Dec 2021 01:06:29 +0100 Message-Id: <20211207000629.4985-4-ribalda@chromium.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211207000629.4985-1-ribalda@chromium.org> References: <20211207000629.4985-1-ribalda@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org All the entities must have a unique name. We can have a descriptive and unique name by appending the function to their terminal link. This is even resilient to multi chain devices. 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 --- drivers/media/usb/uvc/uvc_driver.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index 058d28a0344b..3700e61a8701 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -2194,6 +2194,7 @@ int uvc_register_video_device(struct uvc_device *dev, const struct v4l2_ioctl_ops *ioctl_ops) { int ret; + const char *name; /* Initialize the video buffers queue. */ ret = uvc_queue_init(queue, type, !uvc_no_drop_param); @@ -2221,17 +2222,29 @@ int uvc_register_video_device(struct uvc_device *dev, case V4L2_BUF_TYPE_VIDEO_CAPTURE: default: vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING; + name = "Video Capture"; break; case V4L2_BUF_TYPE_VIDEO_OUTPUT: vdev->device_caps = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING; + name = "Video Output"; break; case V4L2_BUF_TYPE_META_CAPTURE: vdev->device_caps = V4L2_CAP_META_CAPTURE | V4L2_CAP_STREAMING; + name = "Metadata"; break; } + /* + * Many userspace apps identify the device with vdev->name, so we + * cannot change its name for its function. + */ strscpy(vdev->name, dev->name, sizeof(vdev->name)); +#if defined(CONFIG_MEDIA_CONTROLLER) + vdev->entity.name = devm_kasprintf(&stream->intf->dev, GFP_KERNEL, + "%s %u", name, stream->header.bTerminalLink); +#endif + /* * Set the driver data before calling video_register_device, otherwise * the file open() handler might race us.