From patchwork Thu Mar 11 12:20:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 397969 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 2B0CDC433DB for ; Thu, 11 Mar 2021 12:21:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CCAC664FD9 for ; Thu, 11 Mar 2021 12:21:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232853AbhCKMU5 (ORCPT ); Thu, 11 Mar 2021 07:20:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233114AbhCKMUo (ORCPT ); Thu, 11 Mar 2021 07:20:44 -0500 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62714C061574 for ; Thu, 11 Mar 2021 04:20:44 -0800 (PST) Received: by mail-ej1-x62a.google.com with SMTP id p8so45764768ejb.10 for ; Thu, 11 Mar 2021 04:20:44 -0800 (PST) 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=EYGFrEW02KUhIrzCGk6j2y1DSBi0VEvJiIGApiPKgfI=; b=TyoGQkrwpHdv/lBARJpZfrijdU2O8+MCDuhgh5lx3pNzaKF8z3/1RIh3bbpQ8dvFV9 CWFbmvHewQd1NNb5IGRk/JBn2/4bTHHXKYYoMMyI2l++6uoCg+nmo60W6y8RFOzzvN1V WvuotfLz4U5ryDk7SNlIumi6A2y+ZCrSRcU3o= 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=EYGFrEW02KUhIrzCGk6j2y1DSBi0VEvJiIGApiPKgfI=; b=VAQLRc/ZxZEsx6f6523mfrhEGVVEDJYe7GBthjsdoG/uqFhy7RiHxmFhcYsu/2MRPp UwKChNwFgWkldWwQqQzTaRCoP7Equv4R14vAplUZldLCX72CpLcPRW4DmbLvMgqg8uXO A+tl4x/BCAlYECLzigErYtK86sENJZGg4bHGRM78TCEWQS6+sWbZWNlulHN1Wya1Fj6C QYffHC3iDUefVrSx7LS6z2ekWwPSTF0envs/U498ZqJhIxzHFwyqeDG5JxFaAUpZLyH4 x5XGOt75Fhy2QxF9FeWE2PllwxC1xaWQEay6WztfolORGztbNmYYCJxkLLbANd0GCGaf uStA== X-Gm-Message-State: AOAM53008HA/fv3XqVsmzQCwb/Hn9f/u9wUzTcq04+dS7VvkU+yR2ENR tcTTjKr4am0dUsWpzkXgwTCZ4g== X-Google-Smtp-Source: ABdhPJy7bhbwfcyIHHrbJaVpNHOyI4lk2ai/ZsUE5g7/tTa7JvpDxHhjLUm/S3pqzbNR/qp+NFRv1Q== X-Received: by 2002:a17:907:2093:: with SMTP id pv19mr2851780ejb.134.1615465243068; Thu, 11 Mar 2021 04:20:43 -0800 (PST) Received: from alco.lan ([80.71.134.83]) by smtp.gmail.com with ESMTPSA id u13sm1264126ejy.31.2021.03.11.04.20.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Mar 2021 04:20:42 -0800 (PST) From: Ricardo Ribalda To: Laurent Pinchart , Mauro Carvalho Chehab , Tomasz Figa , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, senozhatsky@chromium.org Cc: Ricardo Ribalda Subject: [PATCH 01/10] media: uvcvideo: Return -EINVAL for REQUEST API Date: Thu, 11 Mar 2021 13:20:30 +0100 Message-Id: <20210311122040.1264410-2-ribalda@chromium.org> X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog In-Reply-To: <20210311122040.1264410-1-ribalda@chromium.org> References: <20210311122040.1264410-1-ribalda@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The driver does not support it. Fixes v4l2-compliance: Buffer ioctls (Input 0): fail: v4l2-test-buffers.cpp(1925): ret != EINVAL && ret != EBADR && ret != ENOTTY test Requests: FAIL Signed-off-by: Ricardo Ribalda --- drivers/media/usb/uvc/uvc_v4l2.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c index 252136cc885c..5e3ec4a376e4 100644 --- a/drivers/media/usb/uvc/uvc_v4l2.c +++ b/drivers/media/usb/uvc/uvc_v4l2.c @@ -1046,6 +1046,9 @@ static int uvc_ioctl_g_ext_ctrls(struct file *file, void *fh, unsigned int i; int ret; + if (ctrls->which == V4L2_CTRL_WHICH_REQUEST_VAL) + return -EINVAL; + if (ctrls->which == V4L2_CTRL_WHICH_DEF_VAL) { for (i = 0; i < ctrls->count; ++ctrl, ++i) { struct v4l2_queryctrl qc = { .id = ctrl->id }; From patchwork Thu Mar 11 12:20:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 399175 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, URIBL_BLOCKED, 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 5F6FBC43381 for ; Thu, 11 Mar 2021 12:21:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0E76A64FE6 for ; Thu, 11 Mar 2021 12:21:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233148AbhCKMVA (ORCPT ); Thu, 11 Mar 2021 07:21:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233119AbhCKMUq (ORCPT ); Thu, 11 Mar 2021 07:20:46 -0500 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C275C061574 for ; Thu, 11 Mar 2021 04:20:45 -0800 (PST) Received: by mail-ej1-x62d.google.com with SMTP id mm21so45721744ejb.12 for ; Thu, 11 Mar 2021 04:20:45 -0800 (PST) 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=5NeM7Soa1KpDS0TograRre+Oj0MkKDYHA02GekTX+K8=; b=OtwZAJvoTG9SwWEwdqkr7b2wVuiQlAaV2T+6d6Wfy5YRuG2HsVfTnYTzFDyZFPAUQX a8VAZqgFH2DGuEifrLURo4a0HzwY4fvLLErBhqPuljh0zxE1XM/n1XUZKtxxAgecMdu+ tim/MixlxQ6NZv2ufjCz1qUOWrU0uRChF+vm0= 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=5NeM7Soa1KpDS0TograRre+Oj0MkKDYHA02GekTX+K8=; b=VWNV6DyYGAdXO0n1zNTar6S/0t+rLt2nVoxzgBcDDU7CtDT9mEUecgHYbbGN+dl+91 dabcDlNpbuPJ5TwBj6fwKddIb+/8WkQmbmtPIEKY8hiY+oSZe7tdnI3N1mBAUq0MdmeY 9w6BGbMAKTuTwa+v8Lfxci4rBOF/PNP+9JKLw/Avoxgyco3iU9RkK6o3pJDm+0oSbS7+ dHGbAf/rwDN7iZeyOZ1HEOZvxvH9LEkNB/xBioK8mJcFziS0UWPMVrYBvoqodfv/q8ij 2bhmsXSaIuXgngl+M629N56GU3muUkWstM64GPuK1Mj8FONz3NO50HiMVvQNso/qVewv JXOQ== X-Gm-Message-State: AOAM530+coTN0657S7OAQuY2fwm/guzqoQnCOg9TXlDT6TK/pv6Rc/xj 8nyJtcox5Cf0W8inGEX1v3ZM7g== X-Google-Smtp-Source: ABdhPJxMkGsld8bPDh1woow4boX8GSdu5EUrHojZV+uXD6RqFOwBbS027oD6S6w+tTZQ0EmR6pgMww== X-Received: by 2002:a17:906:565a:: with SMTP id v26mr2870780ejr.516.1615465244394; Thu, 11 Mar 2021 04:20:44 -0800 (PST) Received: from alco.lan ([80.71.134.83]) by smtp.gmail.com with ESMTPSA id u13sm1264126ejy.31.2021.03.11.04.20.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Mar 2021 04:20:44 -0800 (PST) From: Ricardo Ribalda To: Laurent Pinchart , Mauro Carvalho Chehab , Tomasz Figa , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, senozhatsky@chromium.org Cc: Ricardo Ribalda Subject: [PATCH 02/10] media: uvcvideo: Set capability in s_param Date: Thu, 11 Mar 2021 13:20:32 +0100 Message-Id: <20210311122040.1264410-4-ribalda@chromium.org> X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog In-Reply-To: <20210311122040.1264410-1-ribalda@chromium.org> References: <20210311122040.1264410-1-ribalda@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Fixes v4l2-compliance: Format ioctls (Input 0): warn: v4l2-test-formats.cpp(1339): S_PARM is supported but doesn't report V4L2_CAP_TIMEPERFRAME fail: v4l2-test-formats.cpp(1241): node->has_frmintervals && !cap->capability Signed-off-by: Ricardo Ribalda --- drivers/media/usb/uvc/uvc_v4l2.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c index 5e3ec4a376e4..625c216c46b5 100644 --- a/drivers/media/usb/uvc/uvc_v4l2.c +++ b/drivers/media/usb/uvc/uvc_v4l2.c @@ -472,10 +472,13 @@ static int uvc_v4l2_set_streamparm(struct uvc_streaming *stream, uvc_simplify_fraction(&timeperframe.numerator, &timeperframe.denominator, 8, 333); - if (parm->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) + if (parm->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { parm->parm.capture.timeperframe = timeperframe; - else + parm->parm.capture.capability = V4L2_CAP_TIMEPERFRAME; + } else { parm->parm.output.timeperframe = timeperframe; + parm->parm.output.capability = V4L2_CAP_TIMEPERFRAME; + } return 0; } From patchwork Thu Mar 11 12:20:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 399174 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 DA89CC4332B for ; Thu, 11 Mar 2021 12:21:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AA85D64FDF for ; Thu, 11 Mar 2021 12:21:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233113AbhCKMVA (ORCPT ); Thu, 11 Mar 2021 07:21:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233122AbhCKMUq (ORCPT ); Thu, 11 Mar 2021 07:20:46 -0500 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E158C061762 for ; Thu, 11 Mar 2021 04:20:46 -0800 (PST) Received: by mail-ed1-x536.google.com with SMTP id z1so2431727edb.8 for ; Thu, 11 Mar 2021 04:20:46 -0800 (PST) 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=Adt3VWd7Tr97xOkIDn3xdQPcPlfaPE3dZS8MA+RZVj8=; b=WHeLI+EZeWdnBLfu9US6qMqfpgSdFYoKlGy7DNd/hBlMkazrM0ZkVkMJhtB+Y9wBYy Cqx71vWATisDUPo/reydXXFvZv+wNnevjhLUNtQg/IIamfzNes1MWNg2+3cszxTOsvkC GyFIt+FhwbJdSYNve/ANvnB9WkuUwSysPVZso= 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=Adt3VWd7Tr97xOkIDn3xdQPcPlfaPE3dZS8MA+RZVj8=; b=O7cC4VU7mjjyX7umz9sB+qKFgHidhlTNxgAxL+7D5o9ESWyTiXKnVvZmrrQ3QjvFFw BgJ/JmrJLtqsLc5ijTxa78fa0ycuvnHp8zAnXARhGXu+w80NRuIjukCqC4Rr0EDZvD6R AU5jUDNFeb1wckaRXBM8VyK0+s0oz6RyQ+Al+xWJD5UQjZnIJ3NAHNOqxxVBzhbgE8iH irmSiuiaUNrFoab8PxOEb8ja2QvKbuTpgaCpoJAoLa+kNrFtrJDi3haRPJZ6nT9pGDrI mrSZ0AjRgZH0a0LjtGgJJ5Pu1iqIjihbkrgSOBqs64ja7bLm2KznXF0JMK3GEfXHSGXq cRMg== X-Gm-Message-State: AOAM530LsnpQZ8L8VjOUefmHZ2PVwPEfQ7C3YGbZUhZuJi+GHYMDujIZ GMJd1yoU8D/ESetZZTGakgi3YA== X-Google-Smtp-Source: ABdhPJwVmOkiZxLlFupp7sYHhXVU2F6SyyyL32qCCJVGSA2zlgH1LGnqJkv7e63m6qGH3s0tbxeYjQ== X-Received: by 2002:aa7:c0c7:: with SMTP id j7mr8195805edp.298.1615465244891; Thu, 11 Mar 2021 04:20:44 -0800 (PST) Received: from alco.lan ([80.71.134.83]) by smtp.gmail.com with ESMTPSA id u13sm1264126ejy.31.2021.03.11.04.20.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Mar 2021 04:20:44 -0800 (PST) From: Ricardo Ribalda To: Laurent Pinchart , Mauro Carvalho Chehab , Tomasz Figa , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, senozhatsky@chromium.org Cc: Ricardo Ribalda Subject: [PATCH 03/10] media: uvcvideo: Return -EIO for control errors Date: Thu, 11 Mar 2021 13:20:33 +0100 Message-Id: <20210311122040.1264410-5-ribalda@chromium.org> X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog In-Reply-To: <20210311122040.1264410-1-ribalda@chromium.org> References: <20210311122040.1264410-1-ribalda@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Fixes v4l2-compliance: Control ioctls (Input 0): fail: v4l2-test-controls.cpp(448): s_ctrl returned an error (22) test VIDIOC_G/S_CTRL: FAIL fail: v4l2-test-controls.cpp(698): s_ext_ctrls returned an error (22) test VIDIOC_G/S/TRY_EXT_CTRLS: FAIL Signed-off-by: Ricardo Ribalda --- drivers/media/usb/uvc/uvc_video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c index f2f565281e63..5442e9be1c55 100644 --- a/drivers/media/usb/uvc/uvc_video.c +++ b/drivers/media/usb/uvc/uvc_video.c @@ -113,7 +113,7 @@ int uvc_query_ctrl(struct uvc_device *dev, u8 query, u8 unit, case 6: /* Invalid control */ case 7: /* Invalid Request */ case 8: /* Invalid value within range */ - return -EINVAL; + return -EIO; default: /* reserved or unknown */ break; } From patchwork Thu Mar 11 12:20:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 397964 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 8B983C4332E for ; Thu, 11 Mar 2021 12:21:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 551C064FF1 for ; Thu, 11 Mar 2021 12:21:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233158AbhCKMVC (ORCPT ); Thu, 11 Mar 2021 07:21:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233126AbhCKMUr (ORCPT ); Thu, 11 Mar 2021 07:20:47 -0500 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA474C061760 for ; Thu, 11 Mar 2021 04:20:46 -0800 (PST) Received: by mail-ed1-x52b.google.com with SMTP id o19so2442866edc.3 for ; Thu, 11 Mar 2021 04:20:46 -0800 (PST) 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=R44PHCmTHiOQ1g4PsUUoNvPQgi1yYVMAOT6TAV1uoys=; b=Byu0qQk6vIIJ6EeWc0I1toh5q366cq/ebLRYMe82vzVG4YOrdoS3qye9fiu0qkpOJz y+YbEtrfpkiTutXJbawer5aLtJutmEauTIEXMCHYIizBZHJX7n8+zr/NEhzXGZSN18rb Ix7p2A3pYqjJ4lqWpdLv6enWvhadIpCVet8FI= 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=R44PHCmTHiOQ1g4PsUUoNvPQgi1yYVMAOT6TAV1uoys=; b=aVjRP+zXU/tz/hlBC+3E/NCNO31fqT7EfLe5R7+nApC6aWmZYRnNujW2j7+nXhpFRx nbG8MudmxqiDIV1LLxUhqPiptnofJA0ANLnReOgpnSyXynID8XY2g95TZo7RbtncEECi Vj/ijDbNJXOuUiYmgpeaUbvp4IH3WlTn9t128B5HvgiuANOjjg2FPr0RKhAW/d2cRrx+ uj0sjyGzUmdAF+Y2UvCzGSgk4ki4z7/WbsEeHdrdEz+j19sLKvlQvnTnZawUy9QDDamJ Seg/mjPqnI9DjTZtwLsSljcdjwb8agdkvsUB8KNjpg7YBzLB70Dfsob6PEgtvh7jSjDK v+Fw== X-Gm-Message-State: AOAM531NgHGuObJGtMwXjfn0yHQlJiH4N1FixDxdTQ/FYNZxH/MtL4rq sGQEN4u23VPIX+V9v4ckKgZuoA== X-Google-Smtp-Source: ABdhPJyszxRremqIrEWWYbkKeAyF8cED7xtBMgGlAUOPtlKpZQzErEt5Xce9oyp508GMZ7r9mzoHzg== X-Received: by 2002:a05:6402:51d4:: with SMTP id r20mr8250779edd.112.1615465245494; Thu, 11 Mar 2021 04:20:45 -0800 (PST) Received: from alco.lan ([80.71.134.83]) by smtp.gmail.com with ESMTPSA id u13sm1264126ejy.31.2021.03.11.04.20.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Mar 2021 04:20:45 -0800 (PST) From: Ricardo Ribalda To: Laurent Pinchart , Mauro Carvalho Chehab , Tomasz Figa , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, senozhatsky@chromium.org Cc: Ricardo Ribalda Subject: [PATCH 04/10] media: uvcvideo: Add support for V4L2_CTRL_TYPE_CTRL_CLASS Date: Thu, 11 Mar 2021 13:20:34 +0100 Message-Id: <20210311122040.1264410-6-ribalda@chromium.org> X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog In-Reply-To: <20210311122040.1264410-1-ribalda@chromium.org> References: <20210311122040.1264410-1-ribalda@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Fill all the fields for V4L2_CTRL_TYPE_CTRL_CLASS control types. Signed-off-by: Ricardo Ribalda --- drivers/media/usb/uvc/uvc_ctrl.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index b3dde98499f4..08877897dc5a 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -1097,6 +1097,13 @@ static int __uvc_query_v4l2_ctrl(struct uvc_video_chain *chain, v4l2_ctrl->step = 0; return 0; + case V4L2_CTRL_TYPE_CTRL_CLASS: + v4l2_ctrl->minimum = 0; + v4l2_ctrl->maximum = 0; + v4l2_ctrl->step = 0; + v4l2_ctrl->default_value = 0; + return 0; + default: break; } From patchwork Thu Mar 11 12:20:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 399170 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=unavailable 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 79FCAC43142 for ; Thu, 11 Mar 2021 12:21:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5280A64FE6 for ; Thu, 11 Mar 2021 12:21:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233153AbhCKMVB (ORCPT ); Thu, 11 Mar 2021 07:21:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233128AbhCKMUr (ORCPT ); Thu, 11 Mar 2021 07:20:47 -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 7938FC061574 for ; Thu, 11 Mar 2021 04:20:47 -0800 (PST) Received: by mail-ed1-x52f.google.com with SMTP id z1so2431837edb.8 for ; Thu, 11 Mar 2021 04:20:47 -0800 (PST) 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=H9SEgVG4eW/6G+FzcssVlXUnq9VbXCnxHNhzrfDeXOM=; b=oHho/dq2Er/TJG1cYRUOtK84ZV08O0m7lIIdCOL1I2yXh17pJGwEl7cvnU4QwwgRcv xUM4G0jILvbk6r3Ubw77aan4OXB+uTBERPPPLB0LEf9cVMlJ12CwYr1ByDExbFsjxgb2 e/BhlZqNtu/41CK9Sf+rNG6ljbKCXvc7QtouM= 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=H9SEgVG4eW/6G+FzcssVlXUnq9VbXCnxHNhzrfDeXOM=; b=iQ7JN1N/sGeW2Sme2QMVh5x+MDRo+lQznICV6JPZl4RmUY7femMUytcgD4qEH/pDW3 vW19tcSXaw8+i6i4XioMtx/h+HPoxGAQOBEDwNW52rTuNqUTwCrnFBihiIC0etlp1bo+ G6oqDfR843vtH2YSqFDNCeoCIASI3mV+bdZLsCfRwvgtN5bKoQu3/y6Y04O5WuXXxoKt PyE5aH6nJNH5mA71+OUKH3HKWDGlp8Ajv3TmyLr3HtxOTwK5shmazjhADKLk+5VWwS56 sVINUpwbQXWMGi7iEUY8tUyL+noYIiJCHYQ8Cu8OcbzNnNTq0Uv9VFfEEUX6fUG8SC/j cnBg== X-Gm-Message-State: AOAM530iU08q2LrDF/E0IZkD6C1ieAWw85pKzk2y4ez2hmJWjYScZf9v dVDlRNJrHb1U9PlPQa9teh4BdQ== X-Google-Smtp-Source: ABdhPJwoSMMiTwOlh9Fxqgpc06dFU06j7T75nybumv1yhnimMHvjmzrSOodv0w+ZUj3w9nU93NS/gQ== X-Received: by 2002:a50:cdd1:: with SMTP id h17mr8278139edj.178.1615465246224; Thu, 11 Mar 2021 04:20:46 -0800 (PST) Received: from alco.lan ([80.71.134.83]) by smtp.gmail.com with ESMTPSA id u13sm1264126ejy.31.2021.03.11.04.20.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Mar 2021 04:20:45 -0800 (PST) From: Ricardo Ribalda To: Laurent Pinchart , Mauro Carvalho Chehab , Tomasz Figa , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, senozhatsky@chromium.org Cc: Ricardo Ribalda Subject: [PATCH 05/10] media: uvcvideo: Define Control and GUIDs for class ctrls Date: Thu, 11 Mar 2021 13:20:35 +0100 Message-Id: <20210311122040.1264410-7-ribalda@chromium.org> X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog In-Reply-To: <20210311122040.1264410-1-ribalda@chromium.org> References: <20210311122040.1264410-1-ribalda@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add new bindings for class controls. This controls will be implemented by a virtual entity. Signed-off-by: Ricardo Ribalda --- drivers/media/usb/uvc/uvc_ctrl.c | 34 ++++++++++++++++++++++++++++++++ drivers/media/usb/uvc/uvcvideo.h | 8 ++++++++ 2 files changed, 42 insertions(+) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index 08877897dc5a..fd4d5ad098b9 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -355,6 +355,20 @@ static const struct uvc_control_info uvc_ctrls[] = { .flags = UVC_CTRL_FLAG_GET_CUR | UVC_CTRL_FLAG_AUTO_UPDATE, }, + { + .entity = UVC_GUID_CTRL_CLASS, + .selector = UVC_CC_CAMERA_CLASS, + .index = 0, + .size = 1, + .flags = 0, + }, + { + .entity = UVC_GUID_CTRL_CLASS, + .selector = UVC_CC_USER_CLASS, + .index = 1, + .size = 1, + .flags = 0, + }, }; static const struct uvc_menu_info power_line_frequency_controls[] = { @@ -753,6 +767,26 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { .v4l2_type = V4L2_CTRL_TYPE_BOOLEAN, .data_type = UVC_CTRL_DATA_TYPE_BOOLEAN, }, + { + .id = V4L2_CID_CAMERA_CLASS, + .name = "Camera Controls", + .entity = UVC_GUID_CTRL_CLASS, + .selector = UVC_CC_CAMERA_CLASS, + .size = 1, + .offset = 0, + .v4l2_type = V4L2_CTRL_TYPE_CTRL_CLASS, + .data_type = UVC_CTRL_DATA_TYPE_BOOLEAN, + }, + { + .id = V4L2_CID_USER_CLASS, + .name = "User Controls", + .entity = UVC_GUID_CTRL_CLASS, + .selector = UVC_CC_USER_CLASS, + .size = 1, + .offset = 0, + .v4l2_type = V4L2_CTRL_TYPE_CTRL_CLASS, + .data_type = UVC_CTRL_DATA_TYPE_BOOLEAN, + }, }; /* ------------------------------------------------------------------------ diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h index 97df5ecd66c9..5792232ed312 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -62,6 +62,9 @@ #define UVC_GUID_EXT_GPIO_CONTROLLER \ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03} +#define UVC_GUID_CTRL_CLASS \ + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04} #define UVC_GUID_FORMAT_MJPEG \ { 'M', 'J', 'P', 'G', 0x00, 0x00, 0x10, 0x00, \ @@ -175,6 +178,11 @@ { 'H', 'E', 'V', 'C', 0x00, 0x00, 0x10, 0x00, \ 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} +/* ------------------------------------------------------------------------ + * Control Class Constants + */ +#define UVC_CC_CAMERA_CLASS 0 +#define UVC_CC_USER_CLASS 1 /* ------------------------------------------------------------------------ * Driver specific constants. From patchwork Thu Mar 11 12:20:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 399173 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, URIBL_BLOCKED, 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 25DFBC43333 for ; Thu, 11 Mar 2021 12:21:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F116A64FFE for ; Thu, 11 Mar 2021 12:21:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233162AbhCKMVC (ORCPT ); Thu, 11 Mar 2021 07:21:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233131AbhCKMUs (ORCPT ); Thu, 11 Mar 2021 07:20:48 -0500 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 086CDC061574 for ; Thu, 11 Mar 2021 04:20:48 -0800 (PST) Received: by mail-ej1-x635.google.com with SMTP id mm21so45722025ejb.12 for ; Thu, 11 Mar 2021 04:20:47 -0800 (PST) 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=CaRhVK/8csj+vIrO16ApXt+4+Lm7p1eKMEWudzp2f7U=; b=gmjGSpExTAWAssj+18RP7Dlx4fkoDIUccDxXC04TbeBV0PT+XzNObVR3Q4Oe/gFjL1 b+m/r2+mTqwiTUxiI2rO61orwxdgpzrlTTjZ3V1j36I+mh9TA1zyqwA9v+IWQaSI25Xy FTXNwfE5qDdmUWnNgCapfmcqnmFFEhHizT9Cc= 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=CaRhVK/8csj+vIrO16ApXt+4+Lm7p1eKMEWudzp2f7U=; b=jvLQV+9nD63ahwIP7CjNq7SUziCmmmYIkAH45rPSAcHmuZXieMiSp+mUU/aDIdpcHF nt+ta+/y6P0H8Ylj8jRtxgrepC347yIFxKi+T/faio9WAR/6BR699V1FRCjIPMrDBqHv 3rSwDxi8NEKN6IPt/2+Sbzl9rrpxfrqVonaywdf5wcVjIo88G28Zh0XjTfP1z+tx7oGu L7EujJSfSMCHhDPRHinQfbkVimgVOmBJR0EZdA9VnG4lqvt1F2vlzec9BzOIviO0OwNU XknEziY7WaqXPFa6Z4dqz2YrOsHoW2QPJec68zAGJ3HlxO1BEykkuRYY848ZbH/QnIyh KSYQ== X-Gm-Message-State: AOAM533DGiqfo4+cthMAz8muuqM3m7qo8pwucPbZgVeXfuzvWOwIIjTN YXeALfcJDh7y7LUy3W77zggU0A== X-Google-Smtp-Source: ABdhPJz9csyyS/O02ggpZUqK882qN17Rjf54BW2VsvpJXVt4YaeHbCvtOfqPHRIQesuhtAKo8HIZYQ== X-Received: by 2002:a17:906:3b47:: with SMTP id h7mr2769759ejf.377.1615465246673; Thu, 11 Mar 2021 04:20:46 -0800 (PST) Received: from alco.lan ([80.71.134.83]) by smtp.gmail.com with ESMTPSA id u13sm1264126ejy.31.2021.03.11.04.20.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Mar 2021 04:20:46 -0800 (PST) From: Ricardo Ribalda To: Laurent Pinchart , Mauro Carvalho Chehab , Tomasz Figa , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, senozhatsky@chromium.org Cc: Ricardo Ribalda Subject: [PATCH 06/10] media: uvcvideo: Implement UVC_CTRL_CLASS_UNIT Date: Thu, 11 Mar 2021 13:20:36 +0100 Message-Id: <20210311122040.1264410-8-ribalda@chromium.org> X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog In-Reply-To: <20210311122040.1264410-1-ribalda@chromium.org> References: <20210311122040.1264410-1-ribalda@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Create a virtual entity that holds all the class control. Fixes v4l2-compliance: Control ioctls (Input 0): fail: v4l2-test-controls.cpp(216): missing control class for class 00980000 fail: v4l2-test-controls.cpp(253): missing control class for class 009a0000 test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: FAIL Signed-off-by: Ricardo Ribalda --- drivers/media/usb/uvc/uvc_ctrl.c | 3 ++ drivers/media/usb/uvc/uvc_driver.c | 52 +++++++++++++++++++++++++++--- drivers/media/usb/uvc/uvc_entity.c | 1 + drivers/media/usb/uvc/uvcvideo.h | 10 ++++++ 4 files changed, 61 insertions(+), 5 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index fd4d5ad098b9..273eccc136b8 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -2354,6 +2354,9 @@ int uvc_ctrl_init_device(struct uvc_device *dev) } else if (UVC_ENTITY_TYPE(entity) == UVC_EXT_GPIO_UNIT) { bmControls = entity->gpio.bmControls; bControlSize = entity->gpio.bControlSize; + } else if (UVC_ENTITY_TYPE(entity) == UVC_CTRL_CLASS_UNIT) { + bmControls = entity->ctrl_class.bmControls; + bControlSize = entity->ctrl_class.bControlSize; } /* Remove bogus/blacklisted controls */ diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index 30ef2a3110f7..996e8bd06ac5 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -1025,6 +1025,7 @@ static int uvc_parse_streaming(struct uvc_device *dev, } static const u8 uvc_camera_guid[16] = UVC_GUID_UVC_CAMERA; +static const u8 uvc_ctrl_class_guid[16] = UVC_GUID_CTRL_CLASS; static const u8 uvc_gpio_guid[16] = UVC_GUID_EXT_GPIO_CONTROLLER; static const u8 uvc_media_transport_input_guid[16] = UVC_GUID_UVC_MEDIA_TRANSPORT_INPUT; @@ -1057,6 +1058,9 @@ static struct uvc_entity *uvc_alloc_entity(u16 type, u16 id, * is initialized by the caller. */ switch (type) { + case UVC_CTRL_CLASS_UNIT: + memcpy(entity->guid, uvc_ctrl_class_guid, 16); + break; case UVC_EXT_GPIO_UNIT: memcpy(entity->guid, uvc_gpio_guid, 16); break; @@ -1474,6 +1478,39 @@ static int uvc_parse_control(struct uvc_device *dev) return 0; } +/* ----------------------------------------------------------------------------- + * Control Class + */ + +static int uvc_ctrl_class_get_info(struct uvc_device *dev, + struct uvc_entity *entity, + u8 cs, u8 *caps) +{ + *caps = 0; + return 0; +} + +static int uvc_ctrl_class_parse(struct uvc_device *dev) +{ + struct uvc_entity *unit; + + unit = uvc_alloc_entity(UVC_CTRL_CLASS_UNIT, + UVC_CTRL_CLASS_UNIT_ID, 0, 1); + if (!unit) + return -ENOMEM; + + unit->ctrl_class.bControlSize = 1; + unit->ctrl_class.bmControls = (u8 *)unit + sizeof(*unit); + unit->ctrl_class.bmControls[0] = (1 << (UVC_CC_LAST_CLASS + 1)) - 1; + unit->get_info = uvc_ctrl_class_get_info; + strncpy(unit->name, "Control Class", sizeof(unit->name) - 1); + + list_add_tail(&unit->list, &dev->entities); + dev->ctrl_class_unit = unit; + + return 0; +} + /* ----------------------------------------------------------------------------- * Privacy GPIO */ @@ -2054,12 +2091,11 @@ static int uvc_scan_device(struct uvc_device *dev) return -1; } - /* Add GPIO entity to the first chain. */ - if (dev->gpio_unit) { - chain = list_first_entry(&dev->chains, - struct uvc_video_chain, list); + /* Add virtual entities to the first chain. */ + chain = list_first_entry(&dev->chains, struct uvc_video_chain, list); + list_add_tail(&dev->ctrl_class_unit->chain, &chain->entities); + if (dev->gpio_unit) list_add_tail(&dev->gpio_unit->chain, &chain->entities); - } return 0; } @@ -2399,6 +2435,12 @@ static int uvc_probe(struct usb_interface *intf, goto error; } + /* Parse the control class. */ + if (uvc_ctrl_class_parse(dev) < 0) { + uvc_dbg(dev, PROBE, "Unable to parse UVC CTRL CLASS\n"); + goto error; + } + dev_info(&dev->udev->dev, "Found UVC %u.%02x device %s (%04x:%04x)\n", dev->uvc_version >> 8, dev->uvc_version & 0xff, udev->product ? udev->product : "", diff --git a/drivers/media/usb/uvc/uvc_entity.c b/drivers/media/usb/uvc/uvc_entity.c index 7c4d2f93d351..5285030a738c 100644 --- a/drivers/media/usb/uvc/uvc_entity.c +++ b/drivers/media/usb/uvc/uvc_entity.c @@ -106,6 +106,7 @@ static int uvc_mc_init_entity(struct uvc_video_chain *chain, case UVC_OTT_MEDIA_TRANSPORT_OUTPUT: case UVC_EXTERNAL_VENDOR_SPECIFIC: case UVC_EXT_GPIO_UNIT: + case UVC_CTRL_CLASS_UNIT: default: function = MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN; break; diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h index 5792232ed312..1d59ac10c2eb 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -41,6 +41,9 @@ #define UVC_EXT_GPIO_UNIT 0x7ffe #define UVC_EXT_GPIO_UNIT_ID 0x100 +#define UVC_CTRL_CLASS_UNIT 0x7ffd +#define UVC_CTRL_CLASS_UNIT_ID 0x101 + /* ------------------------------------------------------------------------ * GUIDs */ @@ -183,6 +186,7 @@ */ #define UVC_CC_CAMERA_CLASS 0 #define UVC_CC_USER_CLASS 1 +#define UVC_CC_LAST_CLASS UVC_CC_USER_CLASS /* ------------------------------------------------------------------------ * Driver specific constants. @@ -375,6 +379,11 @@ struct uvc_entity { struct gpio_desc *gpio_privacy; int irq; } gpio; + + struct { + u8 bControlSize; + u8 *bmControls; + } ctrl_class; }; u8 bNrInPins; @@ -715,6 +724,7 @@ struct uvc_device { } async_ctrl; struct uvc_entity *gpio_unit; + struct uvc_entity *ctrl_class_unit; }; enum uvc_handle_state { From patchwork Thu Mar 11 12:20:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 397967 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 6F975C433DB for ; Thu, 11 Mar 2021 12:21:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 420A564FEF for ; Thu, 11 Mar 2021 12:21:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233174AbhCKMVD (ORCPT ); Thu, 11 Mar 2021 07:21:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233132AbhCKMUt (ORCPT ); Thu, 11 Mar 2021 07:20:49 -0500 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D06CC061761 for ; Thu, 11 Mar 2021 04:20:48 -0800 (PST) Received: by mail-ej1-x636.google.com with SMTP id mj10so45783017ejb.5 for ; Thu, 11 Mar 2021 04:20:48 -0800 (PST) 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=cE8xpTSbvUqI5nMjBJ0pvMuuGdMpnM78Fy8IxgS4l98=; b=Huv9Y19kXhagaersIpHNejGQQOhYKU8EPfaSKkSGnmJK6OH368SVORPAMZexJMni3F uOK8bttwwrQoLzikNExxy8mj/XgIll7RzNrNOiREIOrSnHXont3I5d59WV/IoPkxLuF2 jNB6REsBgQmOPLPbJ4fFkhKju9q77gYmdyd68= 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=cE8xpTSbvUqI5nMjBJ0pvMuuGdMpnM78Fy8IxgS4l98=; b=Q2BO+zCXDGRPjxwuxINmbPzdAAlm67R5QzmU2mX4iNpunpa05X6AzDFsAyowGJMTD6 FX7rTlXTwq2x/4+lcek+qFbKbC6PVOojHVQoDQTfsiDqwflX6sH70mFw0ujEeKwAwcoD vkfQH2kmAtSBeGXnKWUppEHr5bJTpAqUDjh+uKPK+N3Umk5cbfzanx8LWAOfTJDT0tS6 1hKkWzNIDAzQ+oSxsJgd048XtTiarXshc49oW1g8/Yxs85RDUNFnx2qePR4aEyEfK8nG 9/TiCrcrzLoRKQT1IFjuoxgxZ+4GUBl8zRFiGC6pUVXsNxOM5Qvzj7EbfMGZT1DEMuAM fS9w== X-Gm-Message-State: AOAM531eu2MQx5hnZTedK6fNPUfi0JKsB8eD1MKn5spnR1CsGdLSu1cQ wdYNHSR5BolNJbf+hSd/4vPPxg== X-Google-Smtp-Source: ABdhPJyW0ijjsV3LshE2bLYCySkQerKGhiL8c9J/ooYtPjSHfFvct+Mi6sk46GtfADhuEaY6vcJs8Q== X-Received: by 2002:a17:907:10c1:: with SMTP id rv1mr2917878ejb.5.1615465247379; Thu, 11 Mar 2021 04:20:47 -0800 (PST) Received: from alco.lan ([80.71.134.83]) by smtp.gmail.com with ESMTPSA id u13sm1264126ejy.31.2021.03.11.04.20.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Mar 2021 04:20:46 -0800 (PST) From: Ricardo Ribalda To: Laurent Pinchart , Mauro Carvalho Chehab , Tomasz Figa , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, senozhatsky@chromium.org Cc: Ricardo Ribalda Subject: [PATCH 07/10] media: uvcvideo: set error_idx to count on EACCESS Date: Thu, 11 Mar 2021 13:20:37 +0100 Message-Id: <20210311122040.1264410-9-ribalda@chromium.org> X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog In-Reply-To: <20210311122040.1264410-1-ribalda@chromium.org> References: <20210311122040.1264410-1-ribalda@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org According to the doc: The, in hindsight quite poor, solution for that is to set error_idx to count if the validation failed. Fixes v4l2-compliance: Control ioctls (Input 0): fail: v4l2-test-controls.cpp(645): invalid error index write only control test VIDIOC_G/S/TRY_EXT_CTRLS: FAIL Signed-off-by: Ricardo Ribalda --- drivers/media/usb/uvc/uvc_v4l2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c index 625c216c46b5..9b6454bb2f28 100644 --- a/drivers/media/usb/uvc/uvc_v4l2.c +++ b/drivers/media/usb/uvc/uvc_v4l2.c @@ -1076,7 +1076,8 @@ static int uvc_ioctl_g_ext_ctrls(struct file *file, void *fh, ret = uvc_ctrl_get(chain, ctrl); if (ret < 0) { uvc_ctrl_rollback(handle); - ctrls->error_idx = i; + ctrls->error_idx = (ret == -EACCES) ? + ctrls->count : i; return ret; } } From patchwork Thu Mar 11 12:20:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 397966 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 0290DC43332 for ; Thu, 11 Mar 2021 12:21:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D07F164FE6 for ; Thu, 11 Mar 2021 12:21:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233169AbhCKMVD (ORCPT ); Thu, 11 Mar 2021 07:21:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233135AbhCKMUt (ORCPT ); Thu, 11 Mar 2021 07:20:49 -0500 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35522C061574 for ; Thu, 11 Mar 2021 04:20:49 -0800 (PST) Received: by mail-ej1-x62a.google.com with SMTP id bm21so45793489ejb.4 for ; Thu, 11 Mar 2021 04:20:49 -0800 (PST) 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=+2VPlkbiBZQvOkl3gccESI55+1fEnKM8yzQJ+4ZNUOo=; b=XJHDcFyZr/25m7sUaROvXVgRZWsuBS4L2oB9qni1bD8gOp2B338L4AJ7z5GBRXkyy8 2OVDNpRboXem5rWxvEz5mJ2PMKX7YLLmbK3DefterAIQVkU1JcCkf3YhD837Ac7PnWiB kK5bJFoSaLtXSCpBTkpGmscjYzLPjOGCD/2yY= 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=+2VPlkbiBZQvOkl3gccESI55+1fEnKM8yzQJ+4ZNUOo=; b=m72KsuwDni4cCtaNwTxHpkgY0NJFx+Ot3Y1Uj18xZ9YjkzYjm9Q5IMl0ZOzbNmTXxP MkCa2bRQNrYvoH/Xo2tyhnlQnZYREsngp4op0/GlpIUqLHDvW7wlzVkumzkcAua6g/dT +ORGW0OA5Vw7wyMg/uh2I2p4urXYszPSz+Y/fu848YIdYoTIGsadFhkiMiRTx9Gt/HsE cLcG+fd+esCIH+64xV5yc+KBQk7YuRAWm4ABagSRYMXvZQvYG7vUzhQ/i6TxiOBAmdAV bEaq2lqEp0OQ72egWsmcjcJ5QQv9cVhBjAu2YkuBNV4zSRiobxE0cNEG0zNsKFDpbT9v vNSw== X-Gm-Message-State: AOAM532ETteW5ea57um1Tby4cIesXfaN5F3ybFB19iZgVdAsffx8dWdt 0V9x90/GAXLPWS2a4/3Jsk36SA== X-Google-Smtp-Source: ABdhPJxOetNZ2J+JZUHp/jms7vJbrschr1qHqadBRSySKy3eYB1M2VhLPYjz/46qM4HlUa+rtDeueg== X-Received: by 2002:a17:906:a86:: with SMTP id y6mr2920176ejf.354.1615465247889; Thu, 11 Mar 2021 04:20:47 -0800 (PST) Received: from alco.lan ([80.71.134.83]) by smtp.gmail.com with ESMTPSA id u13sm1264126ejy.31.2021.03.11.04.20.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Mar 2021 04:20:47 -0800 (PST) From: Ricardo Ribalda To: Laurent Pinchart , Mauro Carvalho Chehab , Tomasz Figa , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, senozhatsky@chromium.org Cc: Ricardo Ribalda Subject: [PATCH 08/10] media: uvcvideo: Always return a value on V4L2_CTRL_WHICH_DEF_VAL Date: Thu, 11 Mar 2021 13:20:38 +0100 Message-Id: <20210311122040.1264410-10-ribalda@chromium.org> X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog In-Reply-To: <20210311122040.1264410-1-ribalda@chromium.org> References: <20210311122040.1264410-1-ribalda@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Fixes v4l2-compliance: Control ioctls (Input 0): fail: v4l2-test-controls.cpp(813): doioctl(node, VIDIOC_G_EXT_CTRLS, &ctrls) test VIDIOC_G/S/TRY_EXT_CTRLS: FAIL Signed-off-by: Ricardo Ribalda --- drivers/media/usb/uvc/uvc_v4l2.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c index 9b6454bb2f28..b500356fd06c 100644 --- a/drivers/media/usb/uvc/uvc_v4l2.c +++ b/drivers/media/usb/uvc/uvc_v4l2.c @@ -1057,12 +1057,7 @@ static int uvc_ioctl_g_ext_ctrls(struct file *file, void *fh, struct v4l2_queryctrl qc = { .id = ctrl->id }; ret = uvc_query_v4l2_ctrl(chain, &qc); - if (ret < 0) { - ctrls->error_idx = i; - return ret; - } - - ctrl->value = qc.default_value; + ctrl->value = (ret < 0) ? 0 : qc.default_value; } return 0; From patchwork Thu Mar 11 12:20:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 397965 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, URIBL_BLOCKED, 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 2808BC43619 for ; Thu, 11 Mar 2021 12:21:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F3D1B64FEC for ; Thu, 11 Mar 2021 12:21:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233142AbhCKMVE (ORCPT ); Thu, 11 Mar 2021 07:21:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233141AbhCKMUt (ORCPT ); Thu, 11 Mar 2021 07:20:49 -0500 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CA80C061760 for ; Thu, 11 Mar 2021 04:20:49 -0800 (PST) Received: by mail-ej1-x62f.google.com with SMTP id p8so45765382ejb.10 for ; Thu, 11 Mar 2021 04:20:49 -0800 (PST) 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=E+KNBZ7REWHEPMEYGabkE6Q+CytCIw0tnZHRNytamFc=; b=Tct1qP1En8JHx9Nj1KTwbp//IA5BpMyGDQZVotvomrcQS4N4h8oSRIqIiJRB7Vuht7 sAqsCzAsuVeGFrwa0AD5DObzALcNOC2Xi6gKM9KnrSzHoAsBWCtPnBXZ8vlS6qT4PLfi c3JTW4v5NuCZSwqVd+ruTxSqEUpyXiNeeJEzs= 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=E+KNBZ7REWHEPMEYGabkE6Q+CytCIw0tnZHRNytamFc=; b=Z+hQpSEy8YHiK9NCHXnDn2Ixnt2A0VgspVu5J/Tn3w3InYeNYK55VkUO3zQb08Rlag 1chxAwAx6uQkysZz5HiDOODoc6kZSrrzF/jDTiFuZEMeUjISRPy+DzuRBPctHVkUJRnH nZO0QzNtSCLaPV7yPbzQAKX9+2GL4/58/1wGuMEED1AuaIRjHAAdt58XoDjip0TNQjJ1 Rly6r58O8f/iklbi1gasR1BxsPPjFCMoYyK8BsWPf7DwIapNGN8ihfzh8cKt0TGihmtL 4SyQtJHRtpy5y3H8yrZSyPq5Vlh+RXxZInYjKXzQxVpkHa+G/Q4XllTSjP9TeY6i7Vor LaDg== X-Gm-Message-State: AOAM532RvVKrPhVmmMjkEIKib1gU/buW4xZNPU6q+F306JY08pT0l8yG jLBgVZ6dl9sSy8M9BrBUGnT6Tw== X-Google-Smtp-Source: ABdhPJwm4sLiGnNCtk6Xv0aD6B7aV+f3MF4koBw0bmpELVWq9+MFQ17QtCSUiokH99iIbAloAeEqlg== X-Received: by 2002:a17:906:2710:: with SMTP id z16mr2868707ejc.176.1615465248453; Thu, 11 Mar 2021 04:20:48 -0800 (PST) Received: from alco.lan ([80.71.134.83]) by smtp.gmail.com with ESMTPSA id u13sm1264126ejy.31.2021.03.11.04.20.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Mar 2021 04:20:48 -0800 (PST) From: Ricardo Ribalda To: Laurent Pinchart , Mauro Carvalho Chehab , Tomasz Figa , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, senozhatsky@chromium.org Cc: Ricardo Ribalda Subject: [PATCH 09/10] media: uvcvideo: Do not create initial events for class ctrls Date: Thu, 11 Mar 2021 13:20:39 +0100 Message-Id: <20210311122040.1264410-11-ribalda@chromium.org> X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog In-Reply-To: <20210311122040.1264410-1-ribalda@chromium.org> References: <20210311122040.1264410-1-ribalda@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org V4L2_CTRL_TYPE_CTRL_CLASS do not generate events. Fixes v4l2-compliance: Control ioctls (Input 0): fail: v4l2-test-controls.cpp(844): found event for control class 'User Controls' test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: FAIL Signed-off-by: Ricardo Ribalda --- drivers/media/usb/uvc/uvc_ctrl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index 273eccc136b8..433342efc63f 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -1456,6 +1456,7 @@ static void uvc_ctrl_send_events(struct uvc_fh *handle, } } +static const u8 uvc_ctrl_class_guid[16] = UVC_GUID_CTRL_CLASS; static int uvc_ctrl_add_event(struct v4l2_subscribed_event *sev, unsigned elems) { struct uvc_fh *handle = container_of(sev->fh, struct uvc_fh, vfh); @@ -1474,7 +1475,8 @@ static int uvc_ctrl_add_event(struct v4l2_subscribed_event *sev, unsigned elems) } list_add_tail(&sev->node, &mapping->ev_subs); - if (sev->flags & V4L2_EVENT_SUB_FL_SEND_INITIAL) { + if ((sev->flags & V4L2_EVENT_SUB_FL_SEND_INITIAL) && + memcmp(ctrl->info.entity, uvc_ctrl_class_guid, 16)) { struct v4l2_event ev; u32 changes = V4L2_EVENT_CTRL_CH_FLAGS; s32 val = 0; From patchwork Thu Mar 11 12:20:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 399172 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, URIBL_BLOCKED, 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 97FE1C432C3 for ; Thu, 11 Mar 2021 12:21:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6463065004 for ; Thu, 11 Mar 2021 12:21:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233121AbhCKMVD (ORCPT ); Thu, 11 Mar 2021 07:21:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233142AbhCKMUu (ORCPT ); Thu, 11 Mar 2021 07:20:50 -0500 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31F5EC061574 for ; Thu, 11 Mar 2021 04:20:50 -0800 (PST) Received: by mail-ej1-x631.google.com with SMTP id p8so45765442ejb.10 for ; Thu, 11 Mar 2021 04:20:50 -0800 (PST) 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=1yf2YrB+9ePey+5ffjDKSSNQEXh9aYpFqNXLN5g6o8k=; b=UWpxUfn40yEHnuDQeuL6xpp7zb4c5UdQlXpjfennxRmlvoD9KFBqCyGOtuHUtDXzDZ WIGCvr7nRFITDbvX8ybOr2U6Jy+AfEtadT356ynOU716OOinJL6L4Ci8zDIg05EwwkOK 2BMM8A59L2mNymMp7KslGnQmV66UDvY/UfrOg= 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=1yf2YrB+9ePey+5ffjDKSSNQEXh9aYpFqNXLN5g6o8k=; b=llgfodHJJmmGwJu0kxJV7MnRAGQM6bQ/FWSGWGm3C7DqKNqpBPPe/DW5/tMb69nNZ9 WtkOGesIUJGSdCrzP3aLK1PxI7MqpTudiPlC+MoHqsME4oEuEuDoB0yC0dZciuDI3zgk 21duzZoJJzy8Uv3CuNAjiR0lNei6K2oIckHXH7/7JynPSuhxAyQLhj/4sZ3LKmO9ys7k hbmfDbV2qyAPbP1+QuaUOuvpdL1C0jgueTW/MxS2zlwA5ewi3Gn5xbhHg4/pS4r5ZmXH Fq+XtHI7cLGdgffR09D6bTabEw27WKqNI1t3eOC1+VrcezMVUEw78A/xvMZ0ojB41/bL gnuw== X-Gm-Message-State: AOAM530kONLlBBWTtCu2xXoUB8qrgr/aVCo2toD24w0yEu8g4lLvFfYd LuS/Yvtbq8jWRa6tnnbYid5/Vw== X-Google-Smtp-Source: ABdhPJzKlYGFtnYmTjpMvBpjDQayUIgsCQZli3jY3pInTSxH8Hr1RTHo5tjAEWcKw48ge7wMxHR33g== X-Received: by 2002:a17:906:cd05:: with SMTP id oz5mr2864966ejb.345.1615465248945; Thu, 11 Mar 2021 04:20:48 -0800 (PST) Received: from alco.lan ([80.71.134.83]) by smtp.gmail.com with ESMTPSA id u13sm1264126ejy.31.2021.03.11.04.20.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Mar 2021 04:20:48 -0800 (PST) From: Ricardo Ribalda To: Laurent Pinchart , Mauro Carvalho Chehab , Tomasz Figa , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, senozhatsky@chromium.org Cc: Ricardo Ribalda Subject: [PATCH 10/10] media: uvcvideo: Populate only active control classes Date: Thu, 11 Mar 2021 13:20:40 +0100 Message-Id: <20210311122040.1264410-12-ribalda@chromium.org> X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog In-Reply-To: <20210311122040.1264410-1-ribalda@chromium.org> References: <20210311122040.1264410-1-ribalda@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Do not create Control Classes for empty classes. Fixes v4l2-compliance: Control ioctls (Input 0): fail: v4l2-test-controls.cpp(255): no controls in class 009d0000 test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: FAIL Signed-off-by: Ricardo Ribalda --- drivers/media/usb/uvc/uvc_ctrl.c | 11 +++++++++++ drivers/media/usb/uvc/uvc_driver.c | 1 - drivers/media/usb/uvc/uvcvideo.h | 1 - 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index 433342efc63f..5efbb3b5aa5b 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -2128,6 +2128,17 @@ static int __uvc_ctrl_add_mapping(struct uvc_device *dev, if (map->set == NULL) map->set = uvc_set_le_value; + switch (V4L2_CTRL_ID2WHICH(map->id)) { + case V4L2_CTRL_ID2WHICH(V4L2_CID_CAMERA_CLASS): + dev->ctrl_class_unit->ctrl_class.bmControls[0] |= + BIT(UVC_CC_CAMERA_CLASS); + break; + case V4L2_CTRL_ID2WHICH(V4L2_CID_USER_CLASS): + dev->ctrl_class_unit->ctrl_class.bmControls[0] |= + BIT(UVC_CC_USER_CLASS); + break; + } + list_add_tail(&map->list, &ctrl->info.mappings); uvc_dbg(dev, CONTROL, "Adding mapping '%s' to control %pUl/%u\n", map->name, ctrl->info.entity, ctrl->info.selector); diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index 996e8bd06ac5..4f368ab3a1f1 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -1501,7 +1501,6 @@ static int uvc_ctrl_class_parse(struct uvc_device *dev) unit->ctrl_class.bControlSize = 1; unit->ctrl_class.bmControls = (u8 *)unit + sizeof(*unit); - unit->ctrl_class.bmControls[0] = (1 << (UVC_CC_LAST_CLASS + 1)) - 1; unit->get_info = uvc_ctrl_class_get_info; strncpy(unit->name, "Control Class", sizeof(unit->name) - 1); diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h index 1d59ac10c2eb..cc573d63e459 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -186,7 +186,6 @@ */ #define UVC_CC_CAMERA_CLASS 0 #define UVC_CC_USER_CLASS 1 -#define UVC_CC_LAST_CLASS UVC_CC_USER_CLASS /* ------------------------------------------------------------------------ * Driver specific constants.