From patchwork Wed Mar 17 16:45:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 403550 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 114EAC43381 for ; Wed, 17 Mar 2021 16:46:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BFCB264F3E for ; Wed, 17 Mar 2021 16:46:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232755AbhCQQpl (ORCPT ); Wed, 17 Mar 2021 12:45:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232663AbhCQQpX (ORCPT ); Wed, 17 Mar 2021 12:45:23 -0400 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD321C06174A for ; Wed, 17 Mar 2021 09:45:22 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id r17so3648451ejy.13 for ; Wed, 17 Mar 2021 09:45:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VEHA0wDh2t06lBti+/CKy5TQQJ8gS0FLl9pl6QcZYKI=; b=mgQTBMdiVpGU1c8bhyl7HeAbSBfBcnKwGFIsbaMnLGEArbGwaUrNW154yqFq+3oYg3 gyjvzFIXeA63PU1mc0FBsLbHa5eYEPF0MPISC6TnIn/YRiuU2+2juO2e5tuxMFgKEBUm +R4KskFhh3ACtEQFBVEwqhZAtkG4nZ27cAsvk= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=VEHA0wDh2t06lBti+/CKy5TQQJ8gS0FLl9pl6QcZYKI=; b=YDEg7fnvSZnWpMlC0kmxRBbHu+OGXxT9wdDun/G1lpA8mQRq3MRw3BsG/Rzpbwj23g p5CJPrBL5470BAdqiiBUNmdQRZtBQ4cdpJH1i1YUZ1QSxCzmFymYF525UpC9j3vzaPfE husaIyrhC+u1onGlhNzgyMH73h4POs99cbGTsKlD2aGvYWFNK9OXNZLwD2wA3/u5cHe3 9FJaqvh6JjG9BwbA3tEDtH5DIM56RNM7sx/AqwxBoRr5zoM056O6nLA8s29vkoifDH/0 ZTpi1IN32NwTuB3tyuOnB1dgWYnVwkb8aowfufcMc57pTeuWt3V/PAmodBLAve3ZtHDk 8/eQ== X-Gm-Message-State: AOAM531QETH4SgeztweKCG9nCkq6NziQQ6e84x0Ngt27WieaHjI+/nBW bFBCw5b/9opPj1XyrxlLV95aZw== X-Google-Smtp-Source: ABdhPJwZT7QpP4sRlmOC/UBr9A2IKOvA97oOViqUgtTkafGPXJ+CcxqELLqJu0z5986oMv+qLN3NAg== X-Received: by 2002:a17:906:95d1:: with SMTP id n17mr35308578ejy.394.1615999521499; Wed, 17 Mar 2021 09:45:21 -0700 (PDT) Received: from alco.lan ([80.71.134.83]) by smtp.gmail.com with ESMTPSA id hy25sm12088128ejc.119.2021.03.17.09.45.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Mar 2021 09:45:21 -0700 (PDT) From: Ricardo Ribalda To: Laurent Pinchart , Mauro Carvalho Chehab , Hans Verkuil , Sergey Senozhatsky , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, tfiga@chromium.org Cc: Ricardo Ribalda Subject: [PATCH v6 12/17] media: uvcvideo: Set unique vdev name based in type Date: Wed, 17 Mar 2021 17:45:06 +0100 Message-Id: <20210317164511.39967-13-ribalda@chromium.org> X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog In-Reply-To: <20210317164511.39967-1-ribalda@chromium.org> References: <20210317164511.39967-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 and the entity->id. This is even resilent 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 Reviewed-by: Hans Verkuil --- drivers/media/usb/uvc/uvc_driver.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index 35873cf2773d..76ab6acecbc9 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -2163,6 +2163,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); @@ -2190,16 +2191,20 @@ 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; } - strscpy(vdev->name, dev->name, sizeof(vdev->name)); + snprintf(vdev->name, sizeof(vdev->name), "%s %u", name, + stream->header.bTerminalLink); /* * Set the driver data before calling video_register_device, otherwise