Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp5530216rwr; Tue, 9 May 2023 02:51:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5EOmbJWWyBXiJ6go3NGXTnVrkmLRxtrT5KwaQSKwA21aUiDLpqUPs3dqE3H6ZsGw/DuEbb X-Received: by 2002:a17:90a:3c8f:b0:247:bdd3:a039 with SMTP id g15-20020a17090a3c8f00b00247bdd3a039mr13622286pjc.8.1683625881672; Tue, 09 May 2023 02:51:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683625881; cv=none; d=google.com; s=arc-20160816; b=oXcXrfkjpy9BaesrCFOhnG6/RHYaQCG5ue9TQ/nJOh0XxgEp+hptJG6/he4B4/pjMX vG9vkxlGH5SL+Tg4uWqjb9fc1edXX3vleTh87sZkx3lKrSzjhXCQqtK9J4UGZR/eG2ef ya87bP+9poE6InTxCFWbvANoDc3txD8C+fcFU86QAUXeagquq+4JJc7zz29qfy6CIukL XoOb6FmvmcG53rq4uToVaBXTuHAluNkjBQfDPCN/DSv62sr8XtzI0K2XJ74Ux5QrSh9Z Jn/WK4ffjdrVXuc7Y9ALRBoyxSqRPMIv+4gQvpS4NIaBRYbgmgdm7jd+gusBeamJuQV4 Nx9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=eGDlZetmlCOLO0fUqhWWdR3cbHCPh418SeujG8QKx34=; b=AdNUbVQFkHqqr5XxGWTOvfSHzKFyEeegTPLkAkk5E5pRKLWAakrdAvmsGIeANllJ/d 61/rieSBwhLSgqLlkRVuXD3WPWFTQqbbnz6TN/We6iDBXoZZTG3bDr2lvdlyrkbluutP eg3LCXBmT8GULcwJftxhMr5FSUxGPt4cgDaY1zDe69a33vEbx4niay526el71q/k8P+b iDoRWjezFeO6j96/ON0k/oAN9wvGyLHYDWPpYRYB54U8x/e+95vSiMq2uvLFy38ankJW NO9evH1WJGtdJ3x8q94l+Orfmv3OcZhISg7DZIjOW2XY567YbPAPM2X+8DhgDjiBw0Bh M6JA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RnwQioB+; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x24-20020a63db58000000b0050beb3fe627si1133038pgi.459.2023.05.09.02.51.06; Tue, 09 May 2023 02:51:21 -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=@redhat.com header.s=mimecast20190719 header.b=RnwQioB+; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233586AbjEIJ0c (ORCPT + 99 others); Tue, 9 May 2023 05:26:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234496AbjEIJ03 (ORCPT ); Tue, 9 May 2023 05:26:29 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AF77E49 for ; Tue, 9 May 2023 02:25:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683624338; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eGDlZetmlCOLO0fUqhWWdR3cbHCPh418SeujG8QKx34=; b=RnwQioB+xFJd5kU2fwYnKCQn7c6/CW4T+DQUAkRi9wfvzJ52rivPgsT8oee2V9WmWmU/7v 66BBw71an2eDIUJSMGNe+24yweF4FMXizU/USOBzOR50gRfrQDn8OAfRnW3lX8gg5tGoQ2 PzOOgRUQvM8DHJFqgww5K5p3V7Nk2Hc= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-322-Ezvx3laoP2i1ffv3oLZpWg-1; Tue, 09 May 2023 05:25:37 -0400 X-MC-Unique: Ezvx3laoP2i1ffv3oLZpWg-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-94a356c74e0so537637466b.2 for ; Tue, 09 May 2023 02:25:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683624336; x=1686216336; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=eGDlZetmlCOLO0fUqhWWdR3cbHCPh418SeujG8QKx34=; b=NuJp1jmggeBpBtkfhGjWtJ/PL2VQWgv7OMzm/zImN/VCsY/h6+WRaAT4Uxck3Po3/4 eTrfHOE3nlcytzTusp34G3oeUoW68iGGBJe473Zo76IfT9qrOtQ6xgzrdZWHLbrs2PM/ TDgYLAlvWp8OQ2yQ+VpVjmjNM1mA9p3F0yZWUQb0RbMv3vJBe3mpa2si1eb2Qar3A8ji yavIU0gyCo3BR2OUZWO+hxb6XvfCQAMJGHmeeiQ9byDKyEKiIgPPUeV+HKc6Rzyt/+rr u7s7Amj9w3GbT/066609bufLsSxPkSZqtlMgVe1RS3zU820XxHQqZFta3JBGNIw9p0bb C//Q== X-Gm-Message-State: AC+VfDy2pKkkyPdB1d0mfP1xbTKKnyNJXoBAiTrbSOSptHT8TaUeCgxw zWKV+UBK/GkmVLpTmelR4n8At29/GzRxkLwGJkBStbLURPGpQekHcPTmCdRYNwfMU8JQMPbAq3q Qsl2DVbaD9igLfh6L9u9EEEkd X-Received: by 2002:a17:907:3203:b0:94a:8f3a:1a77 with SMTP id xg3-20020a170907320300b0094a8f3a1a77mr11316331ejb.8.1683624335962; Tue, 09 May 2023 02:25:35 -0700 (PDT) X-Received: by 2002:a17:907:3203:b0:94a:8f3a:1a77 with SMTP id xg3-20020a170907320300b0094a8f3a1a77mr11316318ejb.8.1683624335648; Tue, 09 May 2023 02:25:35 -0700 (PDT) Received: from ?IPV6:2001:1c00:c32:7800:5bfa:a036:83f0:f9ec? (2001-1c00-0c32-7800-5bfa-a036-83f0-f9ec.cable.dynamic.v6.ziggo.nl. [2001:1c00:c32:7800:5bfa:a036:83f0:f9ec]) by smtp.gmail.com with ESMTPSA id ml17-20020a170906cc1100b009661484e84esm1077409ejb.191.2023.05.09.02.25.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 09 May 2023 02:25:34 -0700 (PDT) Message-ID: Date: Tue, 9 May 2023 11:25:34 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH v3 1/2] platform/x86: hp-wmi: Add HP WMI camera switch Content-Language: en-US, nl To: Jonathan Singer , Mario Limonciello , Mark Gross Cc: Jorge Lopez , Rishit Bansal , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Kai-Heng Feng References: <20230426184852.2100-1-jes965@nyu.edu> From: Hans de Goede In-Reply-To: <20230426184852.2100-1-jes965@nyu.edu> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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 Hi, On 4/26/23 20:48, Jonathan Singer wrote: > Previously, when the camera toggle switch was hit, the hp-wmi driver > would report an invalid event code. By adding a case for that in the > event handling switch statement we can eliminate that error code and > enable a framework for potential further kernel handling of that key. > This change was tested on my HP Envy x360 15-ey0023dx laptop, but it > would likely work for any HP laptop with a camera toggle button. Now > we emit an SW_CAMERA_LENS_COVER event, on a device that gets created > on the first such event so as to not report incorrectly the state of > the camera shutter before we can know its state. > > Signed-off-by: Jonathan Singer Thank you for your patch-series, I've applied the series to my review-hans branch: https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans Note it will show up in my review-hans branch once I've pushed my local branch there, which might take a while. Once I've run some tests on this branch the patches there will be added to the platform-drivers-x86/for-next branch and eventually will be included in the pdx86 pull-request to Linus for the next merge-window. Regards, Hans > --- > V2 changes: Added SW_CAMERA_LENS_COVER switch event > V3 changes: removed input dev sync, changed pr_info to pr_err/pr_warn > > drivers/platform/x86/hp/hp-wmi.c | 46 ++++++++++++++++++++++++++++++++ > 1 file changed, 46 insertions(+) > > diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c > index 873f59c3e280..18d40270aa0d 100644 > --- a/drivers/platform/x86/hp/hp-wmi.c > +++ b/drivers/platform/x86/hp/hp-wmi.c > @@ -90,6 +90,7 @@ enum hp_wmi_event_ids { > HPWMI_PEAKSHIFT_PERIOD = 0x0F, > HPWMI_BATTERY_CHARGE_PERIOD = 0x10, > HPWMI_SANITIZATION_MODE = 0x17, > + HPWMI_CAMERA_TOGGLE = 0x1A, > HPWMI_OMEN_KEY = 0x1D, > HPWMI_SMART_EXPERIENCE_APP = 0x21, > }; > @@ -228,6 +229,7 @@ static const struct key_entry hp_wmi_keymap[] = { > }; > > static struct input_dev *hp_wmi_input_dev; > +static struct input_dev *camera_shutter_input_dev; > static struct platform_device *hp_wmi_platform_dev; > static struct platform_profile_handler platform_profile_handler; > static bool platform_profile_support; > @@ -739,6 +741,33 @@ static ssize_t postcode_store(struct device *dev, struct device_attribute *attr, > return count; > } > > +static int camera_shutter_input_setup(void) > +{ > + int err; > + > + camera_shutter_input_dev = input_allocate_device(); > + if (!camera_shutter_input_dev) > + return -ENOMEM; > + > + camera_shutter_input_dev->name = "HP WMI camera shutter"; > + camera_shutter_input_dev->phys = "wmi/input1"; > + camera_shutter_input_dev->id.bustype = BUS_HOST; > + > + __set_bit(EV_SW, camera_shutter_input_dev->evbit); > + __set_bit(SW_CAMERA_LENS_COVER, camera_shutter_input_dev->swbit); > + > + err = input_register_device(camera_shutter_input_dev); > + if (err) > + goto err_free_dev; > + > + return 0; > + > + err_free_dev: > + input_free_device(camera_shutter_input_dev); > + camera_shutter_input_dev = NULL; > + return err; > +} > + > static DEVICE_ATTR_RO(display); > static DEVICE_ATTR_RO(hddtemp); > static DEVICE_ATTR_RW(als); > @@ -866,6 +895,20 @@ static void hp_wmi_notify(u32 value, void *context) > break; > case HPWMI_SANITIZATION_MODE: > break; > + case HPWMI_CAMERA_TOGGLE: > + if (!camera_shutter_input_dev) > + if (camera_shutter_input_setup()) { > + pr_err("Failed to setup camera shutter input device\n"); > + break; > + } > + if (event_data == 0xff) > + input_report_switch(camera_shutter_input_dev, SW_CAMERA_LENS_COVER, 1); > + else if (event_data == 0xfe) > + input_report_switch(camera_shutter_input_dev, SW_CAMERA_LENS_COVER, 0); > + else > + pr_warn("Unknown camera shutter state - 0x%x\n", event_data); > + input_sync(camera_shutter_input_dev); > + break; > case HPWMI_SMART_EXPERIENCE_APP: > break; > default: > @@ -1564,6 +1607,9 @@ static void __exit hp_wmi_exit(void) > if (wmi_has_guid(HPWMI_EVENT_GUID)) > hp_wmi_input_destroy(); > > + if (camera_shutter_input_dev) > + input_unregister_device(camera_shutter_input_dev); > + > if (hp_wmi_platform_dev) { > platform_device_unregister(hp_wmi_platform_dev); > platform_driver_unregister(&hp_wmi_driver);