Received: by 2002:ab2:5d18:0:b0:1ef:7a0f:c32d with SMTP id j24csp466904lqk; Sat, 9 Mar 2024 20:53:49 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXFOnDRP4OhIBb6fvuy+N9YJs2XUIGrGeRDu8DrWV2EEqbrYcsHROMPhAfcsIUoHDnDD70ZfJ8jpPjCxBO1utmv880sfUznX2kDFaSn8Q== X-Google-Smtp-Source: AGHT+IEnNugagCHtwi1mzPS7rfxv+oI6h2Nb178KB8LE9KKDhWZnPlZqxLPMrdBu4B6X+247wB4P X-Received: by 2002:a05:620a:7e6:b0:788:5739:cd13 with SMTP id k6-20020a05620a07e600b007885739cd13mr4065831qkk.36.1710046429628; Sat, 09 Mar 2024 20:53:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1710046429; cv=pass; d=google.com; s=arc-20160816; b=FPs2YhvpWIJFGyfAv8rwedY4HeA/i5eahl/4qYvFj6I/AbjZtNDBEFp9F39HIMyUBD KzuS1kt2LdfK1edhedO3QSrJGyLUFH0YX/gnw2N1zE+dT9ngFYyJlzPb3zmqcDhQt5OB bQm4iXKe8136FzRTYoNWpd4cNdVwilRkvl194kTtlhhuVFx3DB0g3MeFj1I9qoAzYD20 ClSyEWG66MF7WO56SImMkttvRpD7GulZ8lR9bPqKTQU5AG5bx+Yqm2q3IiJUDDJgMdeC YoQGVrV4geLrPLVOi3TTP+m/SsIbIuFmH2Y1xmL/bpy6DCEKkUh6qvpbkCqsDcZNF38W a3Ug== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=aHIvcn7AWPBiXWsyJb6YwJ3JRVnwhyEpRx+UlxGbkis=; fh=9hqwXqQZSqCbgMqpnH7Sb5dO8QmzEHtuKKYa0s3RjhU=; b=SO+33E+caiq0cTVvpdUrdIfzjvh1MNEbB8LWDsrM2YFDBRZYwnHPLyq1B8x0g+kLNn FMkE/basxMmjkCFq1DEKesPeahvOPfnOZA3we5Pdw9Qtvc8JGEaBbHPx7cIU++lsFwFa 8vmwFsXaxO52QTP7ysdr3voGuyrnLSDIIZjcp6oqXqlkuVCVdJBO85pKKtnoqvfoPhn3 F2xI5SeB+VQDhA+jmB2jDmKYA+kw/tfkNhpn6znzZYP71+ogtuJ+RTUj0V/0y62SsoiP MEtME3SycvaR6ii9aqZtGYKJSN2718/lFQWMJ7zNSXftp9zS+ctSmZv2nH0aFcdVaaxG 4Ing==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=AusT9Wk4; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-98117-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-98117-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id v24-20020a05620a091800b007882e4e7f5asi2727826qkv.506.2024.03.09.20.53.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Mar 2024 20:53:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-98117-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=AusT9Wk4; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-98117-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-98117-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 40ACA1C211B6 for ; Sun, 10 Mar 2024 04:53:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 856FB2B9B3; Sun, 10 Mar 2024 04:52:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AusT9Wk4" Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 33E0525601; Sun, 10 Mar 2024 04:52:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710046348; cv=none; b=gQwlq0Y9tiTMZg4yYzXSLLHm8am1MBu7CBViMPsQRpZa9aqBCmtcPPpRNacWLMLlLjUg1LhWqgYQ7ZVLLPAjsKso9TcAjyz77CmZtAJQdILxKouFWHQEf+r41P7WraCdnK8Wtfbej/O0TD8255BJz0es+Lz18lh/bpWX9LvEcAg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710046348; c=relaxed/simple; bh=Sn6sR3bYWe6Nd/XuPwoEl1cdtJZl2cYMod8tFFFbuSQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=rwbLHyuGfgZrIkD0QHgu4em30BjAAKnyC2NmT8jHBPEdKGVmV/Gt3YPADrEyiKEdt4oGBlYtq7CpkOJ7M922JBkMcDpFw68hLKdbnBuCUpEnwrmpDuSLgfeGvMj5oaE7/VYUBXns7iGtTVZHk8fQQDBc7Dfu9ur8MjgsJ3Cy39s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=AusT9Wk4; arc=none smtp.client-ip=209.85.214.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-1dd5df90170so22082635ad.0; Sat, 09 Mar 2024 20:52:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710046346; x=1710651146; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=aHIvcn7AWPBiXWsyJb6YwJ3JRVnwhyEpRx+UlxGbkis=; b=AusT9Wk4GrSKeW7uxwXn9hvvuWIxhyZpjkNBErHcqm2PxCdhRiNI+D8KNCNrsyJL2F Lrw80KEvA086kXY3JxaPflYQAPeVKY2hr4YIfIkw/vGih0R1h9xkKk7cXCo3nTVb9yO9 1W55tKoesyqgS/PNnlkzF0ckhyxHMiB03IOHo5LCxvRlDm9jLKCnXV/371ydlrRCqZ24 fAUPV/is//sLOwA14DiS6ZrhIUzXNdkE2s0ga0uD8YW+NrfqqnGMiGPBugUePOXAiJme GHUHgbEhZKXR547UCPhGj8/wLvQE1Q0VY21w58Y1ZStiOWOBTZz1jvGNVIb7zYFcw1TP jSlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710046346; x=1710651146; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=aHIvcn7AWPBiXWsyJb6YwJ3JRVnwhyEpRx+UlxGbkis=; b=JOdKlPTf6FqCJrzp29/qexggjvxuiTc9L24eVn2Pp9SVZyw3IcODzNGVqXc2CHeqwO MfrXbUvLVOf6aRmmUqnathfgC1sgOWXS83J6diOoHzHKRktHCjZtBqL2wh1WIbcR0KRy hA2U7j7Fcj39a5ELt36ByNQREEQpje1CKfs9geMoQcL1+qubdsIZPdeLI34iub7XjShO nwISkjY/gcucoLK/g8+hx7fOMetmGKTFILXs1xJ4/66StbWhAWGoclaxKfz627Q/Az9F Dq7nmjuhGeVIfpXmvr5jrzfRmsQ7hUW5SbeK6d7RuAZWCvJDunlJvBzM6QeHKciltf6N zqfQ== X-Forwarded-Encrypted: i=1; AJvYcCUFRymvhO5ugBPMpBeDHzHr9v47hrdNviHRO+EfWIIJNk3y3IodSsTT183FudR+0+lCHrVxCTPRSgyK8ZP2Xytv0FiMf4/hJfR+agALe7ZRniwPHLmBOgC2N3v1u9yfvzG8PqSZuF9ip4YXEhvb3jAYRIhjMhl/y8Dkt3S9ujVrz0Ti6RB5cl/Nk54yiRNJ X-Gm-Message-State: AOJu0Yzf/uXtL9dshPVGx1g+92VyNmOms12EdEHhhmdmSD5nMEa4SRfP FD4Qlfc9fvW+S2YCz5qQI7x+0mJdL2nwbdaiXi7y5OIOQbcOHX3p X-Received: by 2002:a17:902:c94f:b0:1dd:66e6:ec81 with SMTP id i15-20020a170902c94f00b001dd66e6ec81mr4534285pla.18.1710046346342; Sat, 09 Mar 2024 20:52:26 -0800 (PST) Received: from google.com ([2620:15c:9d:2:5296:fec3:1fa8:a601]) by smtp.gmail.com with ESMTPSA id q21-20020a170902c75500b001dc96b19616sm2077531plq.66.2024.03.09.20.52.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Mar 2024 20:52:25 -0800 (PST) Date: Sat, 9 Mar 2024 20:52:23 -0800 From: Dmitry Torokhov To: Armin Wolf Cc: =?utf-8?B?6Im+6LaF?= , hdegoede , "ilpo.jarvinen" , linux-kernel , platform-driver-x86 , linux-input@vger.kernel.org Subject: Re: [PATCH v5] platform/x86: add lenovo wmi camera button driver Message-ID: References: <1vk29ojvhrf-1vk4tk6plf0@nsmail7.0.0--kylin--1> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Fri, Mar 08, 2024 at 05:15:48PM +0100, Armin Wolf wrote: > Am 08.03.24 um 09:40 schrieb 艾超: > > > Hi > > > >     thanks for your help. > > > > > Is there a way to determine the current state of the camera switch > > without having > > > to wait for an WMI event? > > > > There is no other way to detemine the current state of the camera > > switch without > > > > a WMI event. > > > > > > > If its not possible to determine the current state of the camera > > switch, then your > > > driver has to defer the initialization of the input device until it > > knows the current > > > state of the camera switch. Otherwise the initial switch state > > reported by the > > > input device might be wrong. > > > > > In this case, that means your driver must initialize the input > > device when receiving > > > a valid WMI event for the first time. > > > > > Basically when your driver receives a WMI event, it has to check if > > the input device > > > is already initialized. If this is not the case, then the input > > device is initialized. > > > Please protect this check and the input device initialization with a > > mutex, since WMI > > > event handling is multithreaded. > > > > > > This Camera is a UVC device, and the Carema device is already > > initialized before the WMI > > > > event .  Whether the camera switch is on or off, we can used lsusb to > > check the Camera. It depends on which drivers are built-in and which are modules. The fact that on one distribution WMI happens to enumerate after PCI/USB is just a stroke of luck. > > > > This wmi-camera driver only need to report the current state of the > > camera switch. > > > > > > Thanks. > > > >     Ai Chao > > > I see, so userspace will notice when the camera is disabled. Since the camera disappears from > the USB bus when the switch is activated, i wonder if SW_CAMERA_LENS_COVER is the right thing > to use in this case after all. > > I CCed the maintainer of the input subsystem so that he can maybe provide some advise. > I for example would, taking the above information above the UVC device into account, say that > KEY_CAMERA_ACCESS_ENABLE/KEY_CAMERA_ACCESS_DISABLE is more suitable. Then userspace has to > keep track of the camera state (through lsusb for example). KEY_CAMERA_ACCESS_ENABLE/KEY_CAMERA_ACCESS_DISABLE is supposed to affect all cameras connected to the system (HUTRR72: "The proposal is to add a set of new Usage IDs to the Consumer Page (0x0C) to control programmatic access to *all* camera devices connected to a computer." - emphasis mine). SW_CAMERA_LENS_COVER is useful when camera is always present but may be covered. If I understand this correctly the camera disappears from the bus and reappears again when enabled. In this case why do you need the key event at all? Are you planning on having a "stub" for the camera so that userspace believes that the camera is always present but may be not operational? Thanks. -- Dmitry