Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp8543825rwi; Tue, 25 Oct 2022 07:59:19 -0700 (PDT) X-Google-Smtp-Source: AMsMyM48c/9u0dlQDyXzvXl7kr0YAwEW3LwbjNpGpde1/LaDl+29a3ePi+RtVGW1Ts+ip0PBgiUj X-Received: by 2002:a17:907:6d23:b0:78d:8f0f:1266 with SMTP id sa35-20020a1709076d2300b0078d8f0f1266mr33497952ejc.762.1666709959630; Tue, 25 Oct 2022 07:59:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666709959; cv=none; d=google.com; s=arc-20160816; b=J0iOsUtdQ97znBnhy2iuY7qJAXN3m1ZOYqRCZokc416ldZuxs7aMduQUf9bChmplYy AUO/BCetRqBLR0w2akVEtbKYZlclUM9+6KYB27+aExGzkBqt6lDYQsFbZsbHcyAB5cpo N6M0nxfwH6yRXwXhM+5+cgdSaWjRPha63tw6d3d/+p9wPjVq80dUb0ydOqzFs3FMBtXn AfjN5E2O6STDl8CeWUtoW7lT3wGatBjbsVQpUmZM9XLQA7oKvK9lk3uj/tJ4Efw/5+TW 9zoU/48LNhB+jvAkGVTtYEiZDH0m98qdYtvb8qODhfN8SMtz4dnIPzrnKBMOhm/KxcrX oTGQ== 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=EPUsq9ry6a/B8ysE7p/Gp0RizcV4HTBL3tocv0bMA9I=; b=0wQEbfSOPkKeJlYU6po4O512K6b08pKxBSHdlER99SxlnT+/w0n/H5JynPrUD6+S0u 2uvSgTcIIisxME6IQpgRu+Z8/rM5IMH4V2ksZxGO+vBLRzNrLqRgcrZoNzTyPkI4wYWh Gq6hemA1KOMRG/ueyWlzCR22tBiMWVghgw9Y+G33zlUB2w880HV5fB+2i91vsdOn+bk+ auM1tbNuGkvAbJgrs58a0pKRG/X7njz4J2BPAYDZn5QERta0OFE/ZjIikIPtEFkUASeL Nm5B2b9G4R/KltvHT8tDy4Frg/qpqOTFdQNoE60evQxHAduFkwUQkhHdgbGMX0Rvv2Fw iVjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=fTdB2oj5; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f22-20020a0564021e9600b0045d292ef641si3016485edf.493.2022.10.25.07.58.54; Tue, 25 Oct 2022 07:59:19 -0700 (PDT) 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=fTdB2oj5; 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 S232433AbiJYOfW (ORCPT + 99 others); Tue, 25 Oct 2022 10:35:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232179AbiJYOfO (ORCPT ); Tue, 25 Oct 2022 10:35:14 -0400 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 AE50789AF1 for ; Tue, 25 Oct 2022 07:35:13 -0700 (PDT) Received: by mail-ej1-x636.google.com with SMTP id 13so13047803ejn.3 for ; Tue, 25 Oct 2022 07:35:13 -0700 (PDT) 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=EPUsq9ry6a/B8ysE7p/Gp0RizcV4HTBL3tocv0bMA9I=; b=fTdB2oj5zXnht0oEeX2xmQrEskfYbWhGUNlF3H6haxGBao5IRjdLyR3preVA3LQeVZ 29aYtsL68obHnIarkE0OWrORdyGhwVRhNoNqhC3YnSq3HWVaiWq9VPMoEzowIiRd0n4n LY+xBjK2zsEa8RhE2TcTNt5FSnP8AxhJMYqnQ= 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=EPUsq9ry6a/B8ysE7p/Gp0RizcV4HTBL3tocv0bMA9I=; b=CxFQ+y/OXLrLx+VvJv/Ow22pilZ8FMplxPOMjwDvXqDvnzKoHkCe6UJ7VshZ1jkYe3 UnmSENY6XiDzNTl2mnUrfP9m93G35Gfq432R93VzUgLQ5jFV0TDp2mxeyuVSIaur2N+Z +mBxzDEUrt5+hlYKm8rvRL7QZkPvVcrld0qNAQrI/kucL10PvSAiIJUHPen84WR3QGm8 sq9HQzG1Y3z1KbUrr7o08u+Eu05ZqD1NXA1u8oGjt7Y59NfMhAMJfg6mHjLbWn4n0eOf Qgs5fnrnzDsea4+fyyuZ3f3BoS6lKjA8RE/xK8ZnBI/FxynVrcknn89LJnrLK/L0kcjY c9Eg== X-Gm-Message-State: ACrzQf1FWUCUFrxHRnBfnpxuZCNLbOIE9F0U4x0iV/xrkEMhwjRcTm5p mEuGkbBgmibUJwG4A0njuktNxg== X-Received: by 2002:a17:907:7203:b0:7a5:b062:2338 with SMTP id dr3-20020a170907720300b007a5b0622338mr11741623ejc.8.1666708512271; Tue, 25 Oct 2022 07:35:12 -0700 (PDT) Received: from alco.roam.corp.google.com ([2620:0:1059:10:e6ae:c7ac:c234:953c]) by smtp.gmail.com with ESMTPSA id e9-20020a170906314900b007acd04fcedcsm631021eje.46.2022.10.25.07.35.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 07:35:11 -0700 (PDT) From: Ricardo Ribalda Date: Tue, 25 Oct 2022 16:34:22 +0200 Subject: [PATCH v2 1/8] media: uvcvideo: Only create input devs if hw supports it MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20220920-resend-powersave-v2-1-5135d1bb1c38@chromium.org> References: <20220920-resend-powersave-v2-0-5135d1bb1c38@chromium.org> In-Reply-To: <20220920-resend-powersave-v2-0-5135d1bb1c38@chromium.org> To: Mauro Carvalho Chehab Cc: Laurent Pinchart , Guenter Roeck , Max Staudt , linux-media@vger.kernel.org, Tomasz Figa , linux-kernel@vger.kernel.org, Alan Stern , Ricardo Ribalda , Hans Verkuil X-Mailer: b4 0.11.0-dev-d93f8 X-Developer-Signature: v=1; a=openpgp-sha256; l=1336; i=ribalda@chromium.org; h=from:subject:message-id; bh=3NadNTBF4BvX9SA2sRowXe1SUqwds9fIYTSwvXBWhlY=; b=owEBbQKS/ZANAwAKAdE30T7POsSIAcsmYgBjV/QPx9RjCOkK3+R3LAQ5GMY4FjigtbgykVx6lPrt swaMdAeJAjMEAAEKAB0WIQREDzjr+/4oCDLSsx7RN9E+zzrEiAUCY1f0DwAKCRDRN9E+zzrEiJyPD/ 9f5qy1Bc9FRGR0NTl0gc9YOOsfmXgD5GOrksxDkgvooTyJLJwQbGlAy4UbzlXv7hGoE13ZpwVt7knm zSeQzm+to8p0nlRIBvQEyj5LGn6DXxBseUS9XoIUl9Ii/gMt9dnraRVsvjitYSNd2PHgNWmQc3gFV0 5dRMO5JZJ6DOiCdqYzoH3PiiIpZzuAwa+wQIc5uRPAV8Z9RAknxVkqD/bbpmNE7447clD6iGFkpnzT G66Q0s7Si1wtvus0CE7aGgS/WMkwQo7roJT2jQ6FdWc/41eFyYNx8byRLTcP9nD8IuC/mWIZgBLazZ pI2KG7XiJhP/6douXCtcuYKtSxfsHw11K4DtOQyRjw/PsgSLolAovRMA3/0/GuASTMD81MVJPeqtxG O2Cpde/SXeiEYYk0ySF1awU8tivB7lUl/EzQ2lCbtvQr5h7/rEgEfKeDpVJgvKMsIO+WC8dd238WAF QiLYsPHvZgrIBoIV8Gh3BOLN6zRA/W+wNXdlryR4NMcOZpQmoz0xVCoxsgXimdw1imHKop5Up0DidC 1uGuDn+jb9GsrIDaDmykie6PeZn311GDOaY/hb0SGu/ozfm2eTuGPF3bMqDeKGlqmThaKwZpQ+oOT4 gtlSk08fAtJqgGxkvqDdee5WzXnF5pExtS7xlW+xSzrH3tZt0ChSY4lXw3DA== X-Developer-Key: i=ribalda@chromium.org; a=openpgp; fpr=9EC3BB66E2FC129A6F90B39556A0D81F9F782DA9 X-Spam-Status: No, score=-2.6 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,URIBL_BLOCKED autolearn=ham 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: X-Mailing-List: linux-kernel@vger.kernel.org Examine the stream headers to figure out if the device has a button and can be used as an input. Reviewed-by: Laurent Pinchart Signed-off-by: Ricardo Ribalda diff --git a/drivers/media/usb/uvc/uvc_status.c b/drivers/media/usb/uvc/uvc_status.c index 7518ffce22ed..cb90aff344bc 100644 --- a/drivers/media/usb/uvc/uvc_status.c +++ b/drivers/media/usb/uvc/uvc_status.c @@ -18,11 +18,34 @@ * Input device */ #ifdef CONFIG_USB_VIDEO_CLASS_INPUT_EVDEV + +static bool uvc_input_has_button(struct uvc_device *dev) +{ + struct uvc_streaming *stream; + + /* + * The device has button events if both bTriggerSupport and + * bTriggerUsage are one. Otherwise the camera button does not + * exist or is handled automatically by the camera without host + * driver or client application intervention. + */ + list_for_each_entry(stream, &dev->streams, list) { + if (stream->header.bTriggerSupport == 1 && + stream->header.bTriggerUsage == 1) + return true; + } + + return false; +} + static int uvc_input_init(struct uvc_device *dev) { struct input_dev *input; int ret; + if (!uvc_input_has_button(dev)) + return 0; + input = input_allocate_device(); if (input == NULL) return -ENOMEM; -- b4 0.11.0-dev-d93f8