From patchwork Sat Oct 29 12:03:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Eray_Or=C3=A7unus?= X-Patchwork-Id: 13024622 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6AB90C433FE for ; Sat, 29 Oct 2022 12:04:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229798AbiJ2ME3 (ORCPT ); Sat, 29 Oct 2022 08:04:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229789AbiJ2ME1 (ORCPT ); Sat, 29 Oct 2022 08:04:27 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3D7274B85; Sat, 29 Oct 2022 05:04:24 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id c7-20020a05600c0ac700b003c6cad86f38so8033444wmr.2; Sat, 29 Oct 2022 05:04:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gzOvAyGDXhsFFUVp58xr8wzl/ct2UtB9GMmORTrIQvw=; b=B1sbLOE0BM4c0GsdSFUmM6NZvGRW76oTkt7BxEPlqKUIwlBOoJJZ0HKla36bv/DnuF KbsTbtMI0VLBBUuvWl0k2pQoNp6RLY2S2GUmtGVewbO+vW7vc8P015KC72a5QH2bD8xB 6Sq4H2DurFxuddYdKZ7WVZsBNTMqH5ZOkV4baF15MkBXbTA8CQtbZNApYzvLRASd9KVo FrO0bbsIlyWO6+yxtbtRLRyPLH/1l2Ma+GDwtJOh8Wng/KNQDnHzXE7nyE2sbbm5eU7Z HCjlugnC6Hjck61NtpKZfUGsXY2d08uOfXJSabWU+CTrlnqyNzUrnww6RTG++URhVyNe qNQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gzOvAyGDXhsFFUVp58xr8wzl/ct2UtB9GMmORTrIQvw=; b=eq9sNAebE8IrJjUoVNdYYibCGVNdMZnfYSxR2IR8oP2XKZWdvmqu6mr9t+ZctwyzUl czlE6vi/yQkzwERWQNSVaDG2LWqznSdGobGksS5yULNwACUlk1v3OJ0ia13PsS6g4U4q zy1gT9Q+IuIrXDQyDRsJcDojOSmbjwgvLk9UaaOLvKNSgoIdPW1zjTpE63Lb2NOjxnDH 04u7tvqzZ0cYaUSKpKH1DNNENnEEOgDWTo4U9ObU2gDiJd5IPgQ3Rn03rcnhYiB2eKG1 fxadHSn6Nlq5FCjp7OR9LleHUMBjA0YaZz6ZcfJaoiEI+okVRfrsfEYEYa7JMMMKwNOb gCKw== X-Gm-Message-State: ACrzQf2MEdUFSqP0MQe+5OG1y35R9AgWQsDCnm8uHgxPWQkaoiBJxWn/ N2Z/PIlFK0vD2N5X6aa4Q1XApiJ1fCxIMg== X-Google-Smtp-Source: AMsMyM5bYm+MdK/Txv55Qg9/EN1UUSHcdL5I6XiFB6bJLPl0/m+pITGbuyO0rwI5Iz9+ozgHuHxcfA== X-Received: by 2002:a1c:27c6:0:b0:3c2:e6df:c79b with SMTP id n189-20020a1c27c6000000b003c2e6dfc79bmr12025245wmn.14.1667045062904; Sat, 29 Oct 2022 05:04:22 -0700 (PDT) Received: from eray-Lenovo-Z50-70.. ([188.132.247.187]) by smtp.googlemail.com with ESMTPSA id z17-20020a05600c0a1100b003b492753826sm1472439wmp.43.2022.10.29.05.04.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Oct 2022 05:04:22 -0700 (PDT) From: =?utf-8?q?Eray_Or=C3=A7unus?= To: platform-driver-x86@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, ike.pan@canonical.com, jikos@kernel.org, benjamin.tissoires@redhat.com, dmitry.torokhov@gmail.com, hdegoede@redhat.com, mgross@linux.intel.com, pobrn@protonmail.com, =?utf-8?q?Eray_Or=C3=A7unus?= Subject: [PATCH v2 1/7] Revert "platform/x86: ideapad-laptop: check for touchpad support in _CFG" Date: Sat, 29 Oct 2022 15:03:06 +0300 Message-Id: <20221029120311.11152-2-erayorcunus@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221029120311.11152-1-erayorcunus@gmail.com> References: <20221029120311.11152-1-erayorcunus@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Last 8 bit of _CFG started being used in later IdeaPads, thus 30th bit doesn't always show whether device supports touchpad or touchpad switch. Remove checking bit 30 of _CFG, so older IdeaPads like S10-3 can switch touchpad again via touchpad attribute. This reverts commit b3ed1b7fe3786c8fe795c16ca07cf3bda67b652f. Signed-off-by: Eray Orçunus --- drivers/platform/x86/ideapad-laptop.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index e7a1299e3776..b67bac457a7a 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -46,11 +46,10 @@ static const char *const ideapad_wmi_fnesc_events[] = { #endif enum { - CFG_CAP_BT_BIT = 16, - CFG_CAP_3G_BIT = 17, - CFG_CAP_WIFI_BIT = 18, - CFG_CAP_CAM_BIT = 19, - CFG_CAP_TOUCHPAD_BIT = 30, + CFG_CAP_BT_BIT = 16, + CFG_CAP_3G_BIT = 17, + CFG_CAP_WIFI_BIT = 18, + CFG_CAP_CAM_BIT = 19, }; enum { @@ -367,8 +366,6 @@ static int debugfs_cfg_show(struct seq_file *s, void *data) seq_puts(s, " wifi"); if (test_bit(CFG_CAP_CAM_BIT, &priv->cfg)) seq_puts(s, " camera"); - if (test_bit(CFG_CAP_TOUCHPAD_BIT, &priv->cfg)) - seq_puts(s, " touchpad"); seq_puts(s, "\n"); seq_puts(s, "Graphics: "); @@ -661,8 +658,7 @@ static umode_t ideapad_is_visible(struct kobject *kobj, else if (attr == &dev_attr_fn_lock.attr) supported = priv->features.fn_lock; else if (attr == &dev_attr_touchpad.attr) - supported = priv->features.touchpad_ctrl_via_ec && - test_bit(CFG_CAP_TOUCHPAD_BIT, &priv->cfg); + supported = priv->features.touchpad_ctrl_via_ec; else if (attr == &dev_attr_usb_charging.attr) supported = priv->features.usb_charging; From patchwork Sat Oct 29 12:03:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Eray_Or=C3=A7unus?= X-Patchwork-Id: 13024623 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16EEDFA3744 for ; Sat, 29 Oct 2022 12:04:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229802AbiJ2MEa (ORCPT ); Sat, 29 Oct 2022 08:04:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229792AbiJ2ME3 (ORCPT ); Sat, 29 Oct 2022 08:04:29 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38F1F315; Sat, 29 Oct 2022 05:04:27 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id c7-20020a05600c0ac700b003c6cad86f38so8033512wmr.2; Sat, 29 Oct 2022 05:04:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+Bb6ASl23RrFIKXOSlIN+mXfWnuBP94uLLqr0AkpKDA=; b=UKY4lfhgMvDyzlpHGK828TVKM8bLmKYfTAbbSosf7Z9b84uk2IIBBGreNKB7zsd0Oe YhsjFdEHsTFBOH9hvI5wWplfWVVRKTdlg3VdEkA+rkxHnzl7ZwQcCdinB/clMYnxXFRP W7lTS0jxMLMzV0kIVLxjSNXsLxW1ckwMdyP/zWsBOXOJXEA8UElXeqTB5wWzzie+1rVm bPV6gcn2brP9Cg+2I83F4U/IV5o10Krrqv8ZY9eng4gOYGNRBjk3621/sLepeXIthPDE 0EHXPhsmdSFBK0nXg/5SsuNUk2hkYFjhM8vWD82cJU/l9T6WUBrdkoyvl4qjKgz14Oci sJUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+Bb6ASl23RrFIKXOSlIN+mXfWnuBP94uLLqr0AkpKDA=; b=Hu7DAdn4GRI9napf+xc7pHBP5EICA/9c3V42/9/6sM8GCPcRoxvlBMKzhYR1hb4Ttc mnKswA8ECsF+v5QQuGn66FzjiTHejzMRU/d9R/E8LN/DwEkrC3vTqc/XiZbpq3uWDAnB qkArHTPgkwCVULz+3Kmk015CZA+0ZWFyzJywyK5TXJDTNmElVv4F8SDiTOAuIbu3Yj4I onF/X8GZC527zqTeMd0aCMTtie4M8T/YF/DOkRFXU3n+3Po8Tw2xHgLTBYVe94QzCAQ9 tW3nwXtu5VOUrxS7JqGLBt5j4ZLdIpc7rgWmTSaWiuyMH1aoAkSYJrhBOlbxpkT0QorX zo2Q== X-Gm-Message-State: ACrzQf1vGmpjmbZ2xBkeuEHfjx1eonkVjWkT+ymEkd0iHBcd8kZFGX3S TJEP8BN74MgyBBsTmz9bcW9qgkJB9OEkWA== X-Google-Smtp-Source: AMsMyM4blD5KXFo+73nrI0cCUSDVZ0u2eLk1j3hQA9bFmryN7RZlb9mNN95IIWqw1SMHdaPNElMPUQ== X-Received: by 2002:a05:600c:1da7:b0:3ce:a1:f961 with SMTP id p39-20020a05600c1da700b003ce00a1f961mr12107085wms.175.1667045065486; Sat, 29 Oct 2022 05:04:25 -0700 (PDT) Received: from eray-Lenovo-Z50-70.. ([188.132.247.187]) by smtp.googlemail.com with ESMTPSA id z17-20020a05600c0a1100b003b492753826sm1472439wmp.43.2022.10.29.05.04.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Oct 2022 05:04:25 -0700 (PDT) From: =?utf-8?q?Eray_Or=C3=A7unus?= To: platform-driver-x86@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, ike.pan@canonical.com, jikos@kernel.org, benjamin.tissoires@redhat.com, dmitry.torokhov@gmail.com, hdegoede@redhat.com, mgross@linux.intel.com, pobrn@protonmail.com, =?utf-8?q?Eray_Or=C3=A7unus?= Subject: [PATCH v2 2/7] HID: add mapping for camera access keys Date: Sat, 29 Oct 2022 15:03:07 +0300 Message-Id: <20221029120311.11152-3-erayorcunus@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221029120311.11152-1-erayorcunus@gmail.com> References: <20221029120311.11152-1-erayorcunus@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org HUTRR72 added 3 new usage codes for keys that are supposed to enable, disable and toggle camera access. These are useful, considering many laptops today have key(s) for toggling access to camera. This patch adds new key definitions for KEY_CAMERA_ACCESS_ENABLE, KEY_CAMERA_ACCESS_DISABLE and KEY_CAMERA_ACCESS_TOGGLE. Additionally hid-debug is adjusted to recognize this new usage codes as well. Signed-off-by: Eray Orçunus Acked-by: Dmitry Torokhov Acked-by: Jiri Kosina Acked-by: Jiri Kosina --- drivers/hid/hid-debug.c | 3 +++ drivers/hid/hid-input.c | 3 +++ include/uapi/linux/input-event-codes.h | 3 +++ 3 files changed, 9 insertions(+) diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c index f48d3534e020..991f880fdbd4 100644 --- a/drivers/hid/hid-debug.c +++ b/drivers/hid/hid-debug.c @@ -936,6 +936,9 @@ static const char *keys[KEY_MAX + 1] = { [KEY_ASSISTANT] = "Assistant", [KEY_KBD_LAYOUT_NEXT] = "KbdLayoutNext", [KEY_EMOJI_PICKER] = "EmojiPicker", + [KEY_CAMERA_ACCESS_ENABLE] = "CameraAccessEnable", + [KEY_CAMERA_ACCESS_DISABLE] = "CameraAccessDisable", + [KEY_CAMERA_ACCESS_TOGGLE] = "CameraAccessToggle", [KEY_DICTATE] = "Dictate", [KEY_BRIGHTNESS_MIN] = "BrightnessMin", [KEY_BRIGHTNESS_MAX] = "BrightnessMax", diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index f197aed6444a..f8e6513e77b8 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c @@ -995,6 +995,9 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel case 0x0cd: map_key_clear(KEY_PLAYPAUSE); break; case 0x0cf: map_key_clear(KEY_VOICECOMMAND); break; + case 0x0d5: map_key_clear(KEY_CAMERA_ACCESS_ENABLE); break; + case 0x0d6: map_key_clear(KEY_CAMERA_ACCESS_DISABLE); break; + case 0x0d7: map_key_clear(KEY_CAMERA_ACCESS_TOGGLE); break; case 0x0d8: map_key_clear(KEY_DICTATE); break; case 0x0d9: map_key_clear(KEY_EMOJI_PICKER); break; diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h index 7989d9483ea7..ef392d0f943f 100644 --- a/include/uapi/linux/input-event-codes.h +++ b/include/uapi/linux/input-event-codes.h @@ -614,6 +614,9 @@ #define KEY_KBD_LAYOUT_NEXT 0x248 /* AC Next Keyboard Layout Select */ #define KEY_EMOJI_PICKER 0x249 /* Show/hide emoji picker (HUTRR101) */ #define KEY_DICTATE 0x24a /* Start or Stop Voice Dictation Session (HUTRR99) */ +#define KEY_CAMERA_ACCESS_ENABLE 0x24b /* Enables programmatic access to camera devices. (HUTRR72) */ +#define KEY_CAMERA_ACCESS_DISABLE 0x24c /* Disables programmatic access to camera devices. (HUTRR72) */ +#define KEY_CAMERA_ACCESS_TOGGLE 0x24d /* Toggles the current state of the camera access control. (HUTRR72) */ #define KEY_BRIGHTNESS_MIN 0x250 /* Set Brightness to Minimum */ #define KEY_BRIGHTNESS_MAX 0x251 /* Set Brightness to Maximum */ From patchwork Sat Oct 29 12:03:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Eray_Or=C3=A7unus?= X-Patchwork-Id: 13024625 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29FE8FA3745 for ; Sat, 29 Oct 2022 12:04:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229851AbiJ2MEq (ORCPT ); Sat, 29 Oct 2022 08:04:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229833AbiJ2MEo (ORCPT ); Sat, 29 Oct 2022 08:04:44 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 132F8A449; Sat, 29 Oct 2022 05:04:29 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id fn7-20020a05600c688700b003b4fb113b86so5372101wmb.0; Sat, 29 Oct 2022 05:04:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dxceK4h9km4GtO20VnsGtzfG02HWM3iZYATl3ehVRaM=; b=FWIbQyJhzY7HCJanl24skL2GSGNxq6sAVg1aer2Wqb/acbszlNYVkq16F4OOMoq+AV xMNccTxQ+q7rgmZjvE2ShT+0gMS1adXEw1HeBWvAd/DmL9jmKRRSyuYElTFIin6kkcwL ovzthrlffpvRDpQ86beWWHGFCehKjlv3ccF/S4Eq/UfJgSyqg2myipJ5+er06pBnjbSL 1U8gWIXIB2AhyjEqWG+HMNxitZr+YRnXbwCaZ8rRHNrxjaDGIEVE5LLzLfsS/UepvZ27 a3uMEE+M/jJaY9DgSfhlKLeX708197Ah67A3s9zkJzBI0DukTBtxmIHYnQGPNrSIShY4 4T4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dxceK4h9km4GtO20VnsGtzfG02HWM3iZYATl3ehVRaM=; b=VdTDVHe3hyWhjJL6BBWg9jFjOYUCnb0r3aD0XQ6MCJvXl52haigNlaeLNmFeKXW17k r1NXHUG7WWjYxigOh/YHiH/hkuOcMCgyw6Rft8v1oC+k07zIZzPQYL/StEefYlhltflA 8m3t54v1p/dUDKI/36NnAMqnAcTQrIqy4J2CnIw0dJ5WD2LuXqf6kQzSCgE9KXGA3jPR FfUvNEgIzilVJ+KqkAgznxa27s6eXY+kjJRdOKozD0g+7so7+A87aXbBnCTLkaaQei6S 2PVzj35mFfxagOvoXsEmP6C8qO6/PNK4KPzRJ6TMWbiitSQbljlinNWnMbzsJAe6lFhr DXkQ== X-Gm-Message-State: ACrzQf3pPhjDH2WAR+hE4UbUb8qOIDrBc00Ax8oaG7zD8Ln5GD+Cr8qx E5UkLkJ/V2SR/g4Y+J/nQYGsIJbKf7BUTQ== X-Google-Smtp-Source: AMsMyM54NGcIXLjs4cTJiBgHJMv72kMp4FYEhPZr09NXVbmP7g6ReX9ZGhef9J1RLW4V3OVnU6ktnA== X-Received: by 2002:a05:600c:4f87:b0:3cf:693b:3386 with SMTP id n7-20020a05600c4f8700b003cf693b3386mr876608wmq.55.1667045067861; Sat, 29 Oct 2022 05:04:27 -0700 (PDT) Received: from eray-Lenovo-Z50-70.. ([188.132.247.187]) by smtp.googlemail.com with ESMTPSA id z17-20020a05600c0a1100b003b492753826sm1472439wmp.43.2022.10.29.05.04.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Oct 2022 05:04:27 -0700 (PDT) From: =?utf-8?q?Eray_Or=C3=A7unus?= To: platform-driver-x86@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, ike.pan@canonical.com, jikos@kernel.org, benjamin.tissoires@redhat.com, dmitry.torokhov@gmail.com, hdegoede@redhat.com, mgross@linux.intel.com, pobrn@protonmail.com, =?utf-8?q?Eray_Or=C3=A7unus?= Subject: [PATCH v2 3/7] platform/x86: ideapad-laptop: Report KEY_CAMERA_ACCESS_TOGGLE instead of KEY_CAMERA Date: Sat, 29 Oct 2022 15:03:08 +0300 Message-Id: <20221029120311.11152-4-erayorcunus@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221029120311.11152-1-erayorcunus@gmail.com> References: <20221029120311.11152-1-erayorcunus@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Reporting KEY_CAMERA when pressing camera switch key is wrong, since KEY_CAMERA is supposed to be used for taking snapshot. Change it with KEY_CAMERA_ACCESS_TOGGLE, so user-space can act correctly. This patch needs KEY_CAMERA_ACCESS_TOGGLE to be defined, thus depends on "HID: add mapping for camera access keys" patch. Signed-off-by: Eray Orçunus --- drivers/platform/x86/ideapad-laptop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index b67bac457a7a..0ef40b88b240 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -1038,7 +1038,7 @@ static void ideapad_sysfs_exit(struct ideapad_private *priv) */ static const struct key_entry ideapad_keymap[] = { { KE_KEY, 6, { KEY_SWITCHVIDEOMODE } }, - { KE_KEY, 7, { KEY_CAMERA } }, + { KE_KEY, 7, { KEY_CAMERA_ACCESS_TOGGLE } }, { KE_KEY, 8, { KEY_MICMUTE } }, { KE_KEY, 11, { KEY_F16 } }, { KE_KEY, 13, { KEY_WLAN } }, From patchwork Sat Oct 29 12:03:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Eray_Or=C3=A7unus?= X-Patchwork-Id: 13024624 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD455C433FE for ; Sat, 29 Oct 2022 12:04:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229842AbiJ2MEq (ORCPT ); Sat, 29 Oct 2022 08:04:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229850AbiJ2MEn (ORCPT ); Sat, 29 Oct 2022 08:04:43 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35B401005C; Sat, 29 Oct 2022 05:04:32 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id j15so9730492wrq.3; Sat, 29 Oct 2022 05:04:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZJQTmtw1LKn8R21PdJOf+BsVQdKZOWcICNuuo0tryIQ=; b=hj63AntOayLxGuhmd58BTJfnSBtEsisiCc4yTtPlicPA/vqQRHwocJeXFMOZBBAUis OrGl0YhFMzlRDqEYYqWWMd2ipJb7mf8yB+DnMlbO5Mz5/j3woffowngqthtWzVDjbwX7 +M6l8hd/tf1kXrCsiBs0H8eJ5pOrkuyNAjGi/5ANOs+c/gMEbl/tUARRR/YOI0JnjXFt Ospy3Gl6sb59dTzyVYlp/YwJMsITljO61XAArV2qXP9yrqi277G3AGaaJsnXyK1ocJtB DegxftzOYqKeE1R2KpAGWhB3tbXOW/lC/Hjr87zDkRU1U1AsLyg+rhoW3aX6HCUGtkiL y98g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZJQTmtw1LKn8R21PdJOf+BsVQdKZOWcICNuuo0tryIQ=; b=1DJHjjefWCuhCke6r7ZIBjGE9X0lxUquEO5a3tvb5Q2tcJcqljYa+wi6s09imD90X7 H3haiRmvXxaUIjDL8RffC+BQfcXVbeARiuVtr+P3pF7ezE0Hb/mNRhngDuXxaLY/LxE+ bnGMSv+m9sVUExu8ewHy+nvsgTiVW+ZEK5lZAiXDNoLI+CE1Db+HVdBhmJNOFr/pQ6fr iIb1koG1Z8Gz3lmjCyj/QfdmPBFqrzq8OAKPabVMjGK0pQ6vC4jiE858DDaqpI/qK/C8 q7uHezxcDzurIGO1mYhas1fT2hm88IfD910djY+edcwz75NE7GSkjcb+QWu8EhrOVpvY 1PSg== X-Gm-Message-State: ACrzQf2TQ9TcOm/fL3t4rQ65pRSUH5kOD3ZPtrBacs5zmokZHEasnROt /evkSgKzJBJKYH56S02Qk6HyCCeLKZ4aWw== X-Google-Smtp-Source: AMsMyM7OfCgLILJ83WkCh8TrI7OLLHhrYyEMgaMdNxM6SuI9o6UysEZ0xPGxUNPgHnEBOXq5Jmxdew== X-Received: by 2002:adf:dd4d:0:b0:236:6e72:be17 with SMTP id u13-20020adfdd4d000000b002366e72be17mr2138838wrm.460.1667045070606; Sat, 29 Oct 2022 05:04:30 -0700 (PDT) Received: from eray-Lenovo-Z50-70.. ([188.132.247.187]) by smtp.googlemail.com with ESMTPSA id z17-20020a05600c0a1100b003b492753826sm1472439wmp.43.2022.10.29.05.04.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Oct 2022 05:04:30 -0700 (PDT) From: =?utf-8?q?Eray_Or=C3=A7unus?= To: platform-driver-x86@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, ike.pan@canonical.com, jikos@kernel.org, benjamin.tissoires@redhat.com, dmitry.torokhov@gmail.com, hdegoede@redhat.com, mgross@linux.intel.com, pobrn@protonmail.com, =?utf-8?q?Eray_Or=C3=A7unus?= Subject: [PATCH v2 4/7] platform/x86: ideapad-laptop: Add new _CFG bit numbers for future use Date: Sat, 29 Oct 2022 15:03:09 +0300 Message-Id: <20221029120311.11152-5-erayorcunus@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221029120311.11152-1-erayorcunus@gmail.com> References: <20221029120311.11152-1-erayorcunus@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Later IdeaPads report various things in last 8 bits of _CFG, at least 5 of them represent supported on-screen-displays. Add those bit numbers to the enum, and use CFG_OSD_ as prefix of their names. Also expose the values of these bits to debugfs, since they can be useful. Signed-off-by: Eray Orçunus --- drivers/platform/x86/ideapad-laptop.c | 33 +++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 0ef40b88b240..f3d4f2beda07 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -46,10 +46,22 @@ static const char *const ideapad_wmi_fnesc_events[] = { #endif enum { - CFG_CAP_BT_BIT = 16, - CFG_CAP_3G_BIT = 17, - CFG_CAP_WIFI_BIT = 18, - CFG_CAP_CAM_BIT = 19, + CFG_CAP_BT_BIT = 16, + CFG_CAP_3G_BIT = 17, + CFG_CAP_WIFI_BIT = 18, + CFG_CAP_CAM_BIT = 19, + + /* + * These are OnScreenDisplay support bits that can be useful to determine + * whether a hotkey exists/should show OSD. But they aren't particularly + * meaningful since they were introduced later, i.e. 2010 IdeaPads + * don't have these, but they still have had OSD for hotkeys. + */ + CFG_OSD_NUMLK_BIT = 27, + CFG_OSD_CAPSLK_BIT = 28, + CFG_OSD_MICMUTE_BIT = 29, + CFG_OSD_TOUCHPAD_BIT = 30, + CFG_OSD_CAM_BIT = 31, }; enum { @@ -368,6 +380,19 @@ static int debugfs_cfg_show(struct seq_file *s, void *data) seq_puts(s, " camera"); seq_puts(s, "\n"); + seq_puts(s, "OSD support:"); + if (test_bit(CFG_OSD_NUMLK_BIT, &priv->cfg)) + seq_puts(s, " num-lock"); + if (test_bit(CFG_OSD_CAPSLK_BIT, &priv->cfg)) + seq_puts(s, " caps-lock"); + if (test_bit(CFG_OSD_MICMUTE_BIT, &priv->cfg)) + seq_puts(s, " mic-mute"); + if (test_bit(CFG_OSD_TOUCHPAD_BIT, &priv->cfg)) + seq_puts(s, " touchpad"); + if (test_bit(CFG_OSD_CAM_BIT, &priv->cfg)) + seq_puts(s, " camera"); + seq_puts(s, "\n"); + seq_puts(s, "Graphics: "); switch (priv->cfg & 0x700) { case 0x100: From patchwork Sat Oct 29 12:03:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Eray_Or=C3=A7unus?= X-Patchwork-Id: 13024627 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF4E1FA3744 for ; Sat, 29 Oct 2022 12:05:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229894AbiJ2MFE (ORCPT ); Sat, 29 Oct 2022 08:05:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229875AbiJ2ME6 (ORCPT ); Sat, 29 Oct 2022 08:04:58 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59F56264D; Sat, 29 Oct 2022 05:04:34 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id k8so9742786wrh.1; Sat, 29 Oct 2022 05:04:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wGXCA0Znhtrtl7WIWCmuh0pNAj0t973nks/+SqSOkMk=; b=Kq8d9swEZJC+nW0K/BpjOuYHo34ZPHFZEu1GdCBJ2Ryp6xRclVEF8I5xy5YRvHJkea Zc3lRb5iduKxGyXp5ZVk90Qt6j1cLtyfl69DYFhj/P5dLwu0AbkBWyOJunzG14QgX+ZR UpuXyr3ukJ/J+uv2Hq2eBNlWGFH67LA+aU/L3pDs8JBiXiIq9M1SfwptnHLJqHyWEilr EHIhivbySeLMFSwx2a7hSPIiKQqPEtKpbqbQ+EbiElZ+Jk3upszJSrN0k5E5417rgK/L qwIktXArFlXrqJrtW4jGoMQ4bXI0igdrJ7b+Gut0bglwfLP9DLWSoUQCvrSvUfyyV7o/ +Dkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wGXCA0Znhtrtl7WIWCmuh0pNAj0t973nks/+SqSOkMk=; b=uJ06JhYMcyuRTo7XWFD2yrE9g3tLZ9EBCQQ/ltLHgruNMydvPpl/Dqvw8ttKobtZND jq/8xVfV6X8bWl54WAzPI6uIEvScatBHj/wJcI/rHBPOwWv2gPjTAJlhkYFObBAFOSOM crOVkY6dhnsh/A6qxwp+aCBZfzshBr3qaIINJ9AP90Q4xhw1s921IfSkZZU5EdK4Za7e MEjZ0G06OvJR75japOK6ztNmNAo2CXPiaVfpEdff16rRCsFPLaSNcowq/mfVfDKm5Mng CoVTT1BDx6WcXP+xrQGslniocg/VYDFMluvL1/g7b/2b+CshF4xrueMMVqefCfHyoIsV OPPA== X-Gm-Message-State: ACrzQf31u6Wcpaz7Fc3RqZ1n1y35UpzQKcPoWTRD7JYS2Vy+A9q1/C3S HKvnolSAvCS9SwKuB49iWSeCYTSJkAAicg== X-Google-Smtp-Source: AMsMyM7ZorsaTFpTIFUl8LTrz6j44QvR1x8lObMqc3pbgW+78LO5dep6owdwXzTEEDymMGOkEEHYGw== X-Received: by 2002:a05:6000:184:b0:236:7685:7e6d with SMTP id p4-20020a056000018400b0023676857e6dmr2196773wrx.305.1667045073003; Sat, 29 Oct 2022 05:04:33 -0700 (PDT) Received: from eray-Lenovo-Z50-70.. ([188.132.247.187]) by smtp.googlemail.com with ESMTPSA id z17-20020a05600c0a1100b003b492753826sm1472439wmp.43.2022.10.29.05.04.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Oct 2022 05:04:32 -0700 (PDT) From: =?utf-8?q?Eray_Or=C3=A7unus?= To: platform-driver-x86@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, ike.pan@canonical.com, jikos@kernel.org, benjamin.tissoires@redhat.com, dmitry.torokhov@gmail.com, hdegoede@redhat.com, mgross@linux.intel.com, pobrn@protonmail.com, =?utf-8?q?Eray_Or=C3=A7unus?= Subject: [PATCH v2 5/7] platform/x86: ideapad-laptop: Expose camera_power only if supported Date: Sat, 29 Oct 2022 15:03:10 +0300 Message-Id: <20221029120311.11152-6-erayorcunus@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221029120311.11152-1-erayorcunus@gmail.com> References: <20221029120311.11152-1-erayorcunus@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org IdeaPads dropped support for VPCCMD_W_CAMERA somewhere between 2014-2016, none of the IdeaPads produced after that I tested supports it. Fortunately I found a way to check it; if the DSDT has camera device(s) defined, it shouldn't have working VPCCMD_W_CAMERA, thus camera_power shouldn't be exposed to sysfs. To accomplish this, walk the ACPI namespace in ideapad_check_features and check the devices starting with "CAM". Tested on 520-15IKB and Legion Y520, which successfully didn't expose the camera_power attribute. Link: https://www.spinics.net/lists/platform-driver-x86/msg26147.html Signed-off-by: Eray Orçunus --- drivers/platform/x86/ideapad-laptop.c | 52 ++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index f3d4f2beda07..e8c088e7a53d 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -149,6 +149,7 @@ struct ideapad_private { bool fn_lock : 1; bool hw_rfkill_switch : 1; bool kbd_bl : 1; + bool cam_ctrl_via_ec : 1; bool touchpad_ctrl_via_ec : 1; bool usb_charging : 1; } features; @@ -163,6 +164,24 @@ static bool no_bt_rfkill; module_param(no_bt_rfkill, bool, 0444); MODULE_PARM_DESC(no_bt_rfkill, "No rfkill for bluetooth."); +static acpi_status acpi_find_device_callback(acpi_handle handle, u32 level, + void *context, void **return_value) +{ + struct acpi_buffer ret_buf; + char buffer[8]; + + ret_buf.length = sizeof(buffer); + ret_buf.pointer = buffer; + + if (ACPI_SUCCESS(acpi_get_name(handle, ACPI_SINGLE_NAME, &ret_buf))) + if (strstarts(ret_buf.pointer, context)) { + *return_value = handle; + return AE_CTRL_TERMINATE; + } + + return AE_OK; +} + /* * ACPI Helpers */ @@ -675,7 +694,7 @@ static umode_t ideapad_is_visible(struct kobject *kobj, bool supported = true; if (attr == &dev_attr_camera_power.attr) - supported = test_bit(CFG_CAP_CAM_BIT, &priv->cfg); + supported = priv->features.cam_ctrl_via_ec; else if (attr == &dev_attr_conservation_mode.attr) supported = priv->features.conservation_mode; else if (attr == &dev_attr_fan_mode.attr) @@ -1527,6 +1546,37 @@ static void ideapad_check_features(struct ideapad_private *priv) priv->features.hw_rfkill_switch = dmi_check_system(hw_rfkill_list); + /* + * Some IdeaPads have camera switch via EC (mostly older ones), + * some don't. Fortunately we know that if DSDT contains device + * object for the camera, camera isn't switchable via EC. + * So, let's walk the namespace and try to find CAM* object. + * If we can't find it, set cam_ctrl_via_ec to true. + */ + + priv->features.cam_ctrl_via_ec = false; + + if (test_bit(CFG_CAP_CAM_BIT, &priv->cfg)) { + acpi_handle temp_handle = NULL; + acpi_handle pci_handle; + acpi_status status; + + status = acpi_get_handle(handle, "^^^", &pci_handle); + if (ACPI_SUCCESS(status)) { + status = acpi_walk_namespace(ACPI_TYPE_DEVICE, pci_handle, + ACPI_UINT32_MAX, + acpi_find_device_callback, + NULL, "CAM", + &temp_handle); + + if (ACPI_SUCCESS(status) && temp_handle == NULL) + priv->features.cam_ctrl_via_ec = true; + + } else + dev_warn(&priv->platform_device->dev, + "Could not find PCI* node in the namespace\n"); + } + /* Most ideapads with ELAN0634 touchpad don't use EC touchpad switch */ priv->features.touchpad_ctrl_via_ec = !acpi_dev_present("ELAN0634", NULL, -1); From patchwork Sat Oct 29 12:03:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Eray_Or=C3=A7unus?= X-Patchwork-Id: 13024628 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27B23C38A02 for ; Sat, 29 Oct 2022 12:05:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229943AbiJ2MFE (ORCPT ); Sat, 29 Oct 2022 08:05:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229900AbiJ2ME7 (ORCPT ); Sat, 29 Oct 2022 08:04:59 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D62113DFA; Sat, 29 Oct 2022 05:04:37 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id k8so9742877wrh.1; Sat, 29 Oct 2022 05:04:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=t0H3gS6ENUsKWeShTc04Oxh9TJLnxL4twvq+6xgLItU=; b=qmjvl3YwbZ9mkYjbQnkigZC7V3qmEQ2UkKRzeSCA2PEwioQMDglgswpCaUnqSfH9Xc 3j5TVf51w7mEQcoFE8Gn2UqEGZNW1D/TCM635RxBGHovBX3n776hU4C8kyzKTO7BQ7IL LXxys5AXgm6dTws9lozGV9I+zF0lLsIKSLvAYtPWDC9aRFE7DnwHl9sLDfY88+2CM0Mu AmpmlSJa6xnU52SXAOa9eYXUvGfNH/B2k69svh5tiFZRSGkqoe2bvWdTAzLMhhJkMDOS nNiJTZYwHuRWx27K+gLFTKkFS03rPTKMeja5i0uNUePqfoN3znGR/KbTMMoXrfA2Dp+6 Du3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=t0H3gS6ENUsKWeShTc04Oxh9TJLnxL4twvq+6xgLItU=; b=omOXRDDqNj5p4KM7H2e6CZDgsZuogpsQAu6tqvrmHLzLSyggskuJa1vvGLcyyixEZI Hu384tYWB45bZOQFd5JMFGrBCO/t6av8FlShgSN5gcwIqZJ9nKOUBD2rDEEtIKEpZPR+ IK35EIfw1urGmaABHnRNbByhDdfGNQLEQtOGu9ADf8OSg0pRqA323pnvcWNDE17Ene8z 6E9UehiofAyupnl0qYzmawufnQ4P3H20htKH4fJ9DIxcgadzKmZ8KDvE61OuI5avy/AO 0KDj7S8D3/Iy0gWiKShxX93AsOVmmoly8Xpq97uNz0qdoTn/F1VgG+F/8OQTT3/QfvMR tR/g== X-Gm-Message-State: ACrzQf01XlAzBiHIR+j67OXAQvuPucdnY5eqkVsMm5NffDoIyDoL2He+ T4VZ972K+PQPd9owpgPfnkm8tEqXf6WyPg== X-Google-Smtp-Source: AMsMyM6R6lm46LHofH7az0q1px/k2yLCPNdrU5kIBjZo0Fy3rKRfp6gznMV4LthIARbqwRp5ue6iaQ== X-Received: by 2002:adf:e38d:0:b0:236:7217:827e with SMTP id e13-20020adfe38d000000b002367217827emr2283094wrm.652.1667045075620; Sat, 29 Oct 2022 05:04:35 -0700 (PDT) Received: from eray-Lenovo-Z50-70.. ([188.132.247.187]) by smtp.googlemail.com with ESMTPSA id z17-20020a05600c0a1100b003b492753826sm1472439wmp.43.2022.10.29.05.04.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Oct 2022 05:04:35 -0700 (PDT) From: =?utf-8?q?Eray_Or=C3=A7unus?= To: platform-driver-x86@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, ike.pan@canonical.com, jikos@kernel.org, benjamin.tissoires@redhat.com, dmitry.torokhov@gmail.com, hdegoede@redhat.com, mgross@linux.intel.com, pobrn@protonmail.com, =?utf-8?q?Eray_Or=C3=A7unus?= Subject: [PATCH v2 6/7] platform/x86: ideapad-laptop: Keyboard backlight support for more IdeaPads Date: Sat, 29 Oct 2022 15:03:11 +0300 Message-Id: <20221029120311.11152-7-erayorcunus@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221029120311.11152-1-erayorcunus@gmail.com> References: <20221029120311.11152-1-erayorcunus@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org IdeaPads with HALS_KBD_BL_SUPPORT_BIT have full keyboard light support, and they send an event via ACPI on light state change. Whereas some IdeaPads that don't have this bit set, i.e. 520-15ikb, 330-17ich and 5 (15), don't send an event, yet they still support switching keyboard light via KBLO object on DSDT. Detect these IdeaPads with searching for KBLO object, set their kbd_bl_partial to true and register led device for them. Tested on 520-15ikb. Signed-off-by: Eray Orçunus --- drivers/platform/x86/ideapad-laptop.c | 79 ++++++++++++++++++++++++--- 1 file changed, 70 insertions(+), 9 deletions(-) diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index e8c088e7a53d..b34fbc4d741c 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -149,6 +149,7 @@ struct ideapad_private { bool fn_lock : 1; bool hw_rfkill_switch : 1; bool kbd_bl : 1; + bool kbd_bl_partial : 1; bool cam_ctrl_via_ec : 1; bool touchpad_ctrl_via_ec : 1; bool usb_charging : 1; @@ -157,6 +158,9 @@ struct ideapad_private { bool initialized; struct led_classdev led; unsigned int last_brightness; + /* Below are used only if kbd_bl_partial is set */ + acpi_handle lfcm_mutex; + acpi_handle kblo_obj; } kbd_bl; }; @@ -1300,19 +1304,52 @@ static void ideapad_backlight_notify_brightness(struct ideapad_private *priv) backlight_force_update(priv->blightdev, BACKLIGHT_UPDATE_HOTKEY); } +#define IDEAPAD_ACPI_MUTEX_TIMEOUT 1500 + /* * keyboard backlight */ static int ideapad_kbd_bl_brightness_get(struct ideapad_private *priv) { - unsigned long hals; + unsigned long ret_val; int err; + acpi_status status; - err = eval_hals(priv->adev->handle, &hals); + /* + * Some IdeaPads with partially implemented keyboard lights don't give + * us the light state on HALS_KBD_BL_STATE_BIT in the return value of HALS, + * i.e. 5 (15) and 330-17ich. Fortunately we know how to gather it. + * Even if it won't work, we will still give HALS a try, because + * some IdeaPads with kbd_bl_partial, i.e. 520-15ikb, + * correctly sets HALS_KBD_BL_STATE_BIT in HALS return value. + */ + + if (priv->features.kbd_bl_partial && + priv->kbd_bl.lfcm_mutex != NULL && priv->kbd_bl.kblo_obj != NULL) { + + status = acpi_acquire_mutex(priv->kbd_bl.lfcm_mutex, NULL, + IDEAPAD_ACPI_MUTEX_TIMEOUT); + + if (ACPI_SUCCESS(status)) { + err = eval_int(priv->kbd_bl.kblo_obj, NULL, &ret_val); + + status = acpi_release_mutex(priv->kbd_bl.lfcm_mutex, NULL); + if (ACPI_FAILURE(status)) + dev_err(&priv->platform_device->dev, + "Failed to release LFCM mutex"); + + if (err) + return err; + + return !!ret_val; + } + } + + err = eval_hals(priv->adev->handle, &ret_val); if (err) return err; - return !!test_bit(HALS_KBD_BL_STATE_BIT, &hals); + return !!test_bit(HALS_KBD_BL_STATE_BIT, &ret_val); } static enum led_brightness ideapad_kbd_bl_led_cdev_brightness_get(struct led_classdev *led_cdev) @@ -1329,7 +1366,8 @@ static int ideapad_kbd_bl_brightness_set(struct ideapad_private *priv, unsigned if (err) return err; - priv->kbd_bl.last_brightness = brightness; + if (!priv->features.kbd_bl_partial) + priv->kbd_bl.last_brightness = brightness; return 0; } @@ -1349,6 +1387,9 @@ static void ideapad_kbd_bl_notify(struct ideapad_private *priv) if (!priv->kbd_bl.initialized) return; + if (priv->features.kbd_bl_partial) + return; + brightness = ideapad_kbd_bl_brightness_get(priv); if (brightness < 0) return; @@ -1371,17 +1412,20 @@ static int ideapad_kbd_bl_init(struct ideapad_private *priv) if (WARN_ON(priv->kbd_bl.initialized)) return -EEXIST; - brightness = ideapad_kbd_bl_brightness_get(priv); - if (brightness < 0) - return brightness; + /* IdeaPads with kbd_bl_partial don't have keyboard backlight event */ + if (!priv->features.kbd_bl_partial) { + brightness = ideapad_kbd_bl_brightness_get(priv); + if (brightness < 0) + return brightness; - priv->kbd_bl.last_brightness = brightness; + priv->kbd_bl.last_brightness = brightness; + priv->kbd_bl.led.flags = LED_BRIGHT_HW_CHANGED; + } priv->kbd_bl.led.name = "platform::" LED_FUNCTION_KBD_BACKLIGHT; priv->kbd_bl.led.max_brightness = 1; priv->kbd_bl.led.brightness_get = ideapad_kbd_bl_led_cdev_brightness_get; priv->kbd_bl.led.brightness_set_blocking = ideapad_kbd_bl_led_cdev_brightness_set; - priv->kbd_bl.led.flags = LED_BRIGHT_HW_CHANGED; err = led_classdev_register(&priv->platform_device->dev, &priv->kbd_bl.led); if (err) @@ -1594,8 +1638,25 @@ static void ideapad_check_features(struct ideapad_private *priv) if (test_bit(HALS_FNLOCK_SUPPORT_BIT, &val)) priv->features.fn_lock = true; + /* + * IdeaPads with HALS_KBD_BL_SUPPORT_BIT have full keyboard + * light support, and they send an event via ACPI on light + * state change. Whereas some IdeaPads, at least 520-15ikb + * and 5 (15), don't send an event, yet they still have + * KBLO object. In this case, set kbd_bl_partial to true + * and cache the LFCM mutex, it might be useful while + * getting the brightness. + */ + if (test_bit(HALS_KBD_BL_SUPPORT_BIT, &val)) priv->features.kbd_bl = true; + else if (ACPI_SUCCESS(acpi_get_handle(handle, "^KBLO", + &priv->kbd_bl.kblo_obj))) { + priv->features.kbd_bl = true; + priv->features.kbd_bl_partial = true; + (void)acpi_get_handle(handle, "^LFCM", + &priv->kbd_bl.lfcm_mutex); + } if (test_bit(HALS_USB_CHARGING_SUPPORT_BIT, &val)) priv->features.usb_charging = true; From patchwork Sat Oct 29 12:03:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Eray_Or=C3=A7unus?= X-Patchwork-Id: 13024626 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA744C433FE for ; Sat, 29 Oct 2022 12:05:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229615AbiJ2MFC (ORCPT ); Sat, 29 Oct 2022 08:05:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229891AbiJ2ME6 (ORCPT ); Sat, 29 Oct 2022 08:04:58 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FB7715FFC; Sat, 29 Oct 2022 05:04:39 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id y16so9680900wrt.12; Sat, 29 Oct 2022 05:04:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DYj6Sp/cMz1QQGhnefYTJGzG4F2mZ1RWGEdTPlv3qKQ=; b=dBztWbMdS8h8kYTzJohC6XiLtiEU7jiY2iKeUlLFpIZlu0uOolzIB3RdRmnLZHtImj tLHvzRD3/Kei173N7Am8Xd3FBCOk2VSiD2KnMI40kCIf1evjqtxSfVCDb8NK3KV6k3GW NPQ72X3AQ8lGxV9PnBDkjXJLYAtuVOTXqT4a5dzlBQ5AkQuLSkeUQ2Tl2gK4mOB/30zY USbqwfBMeki5H4LfiwLsGIBXFfbwCDWrBCcY12ciV3Dur6o4c7qMfkgYTf0wIr+y59Jg 0lD4NrWn9Jh3i2A0z3OTxlZnQQi6wkdeRLNP3GSD1psBn74q1oF+qTlQLanJRiBzS4e+ vdwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DYj6Sp/cMz1QQGhnefYTJGzG4F2mZ1RWGEdTPlv3qKQ=; b=XDwYVbG9urlsdYnw4LwW6JnL6K4a4fSPRdyS/90bzI5idWoRfsu4phXrug2JezaZsq 38Z8ikewoZLT2kyBnx0+Ht4QnXWC1+4FTjPM4PHobZm0u1LwJkV98Jx4GGmMoIysopEy rE27bmUIk0dkUHYukcVCbOuedLY5ZFUrkNf3X5V/zTbNOe5UMUQQ03nWeFQuJX+ipczm thsno1AZjshBuA2aV4TuVQEF5z6T9s6ePAd7hMR51sgAiRsS9NjHx/gaWdIyov+JQeoM N8wZTCFVkwFDcylRAjgKNk81nZ/jspnGp3GSTxB8ZgoxzsW5lT3fIPFFSld2sYH4sFCv XCUA== X-Gm-Message-State: ACrzQf3005jQ/353c37hM22hQYh8upFUSspYlle+U3Ykp+IvJJzO9jMP Tc+xKlNpZQ9ievgEZrcg2Cy7+hKkSAXjwg== X-Google-Smtp-Source: AMsMyM4OkiA9Gi3OyDCgw8PNiMvDWlI+WrztsTwmStHPclCL2TucObpKPQ8f75eqo+ygMGX7z24VJQ== X-Received: by 2002:a5d:6484:0:b0:230:7cad:c268 with SMTP id o4-20020a5d6484000000b002307cadc268mr2294941wri.335.1667045077968; Sat, 29 Oct 2022 05:04:37 -0700 (PDT) Received: from eray-Lenovo-Z50-70.. ([188.132.247.187]) by smtp.googlemail.com with ESMTPSA id z17-20020a05600c0a1100b003b492753826sm1472439wmp.43.2022.10.29.05.04.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Oct 2022 05:04:37 -0700 (PDT) From: =?utf-8?q?Eray_Or=C3=A7unus?= To: platform-driver-x86@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, ike.pan@canonical.com, jikos@kernel.org, benjamin.tissoires@redhat.com, dmitry.torokhov@gmail.com, hdegoede@redhat.com, mgross@linux.intel.com, pobrn@protonmail.com, =?utf-8?q?Eray_Or=C3=A7unus?= Subject: [PATCH v2 7/7] platform/x86: ideapad-laptop: Don't expose touchpad attr on IdeaPads with SYNA2B33 Date: Sat, 29 Oct 2022 15:03:12 +0300 Message-Id: <20221029120311.11152-8-erayorcunus@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221029120311.11152-1-erayorcunus@gmail.com> References: <20221029120311.11152-1-erayorcunus@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org My 520-15IKB (2017) with SYNA2B33 doesn't have working VPCCMD_W_TOUCHPAD command - it's the touchpad program switches the touchpad instead on Windows. Considering all IdeaPads with SYNA2B33 touchpad produced in 2017/2018, it's very likely that none of the IdeaPads with SYNA2B33 support touchpad switching via EC. So let's add SYNA2B33 to the touchpads not switchable via EC. Signed-off-by: Eray Orçunus --- drivers/platform/x86/ideapad-laptop.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index b34fbc4d741c..937126c62a14 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -1621,8 +1621,12 @@ static void ideapad_check_features(struct ideapad_private *priv) "Could not find PCI* node in the namespace\n"); } - /* Most ideapads with ELAN0634 touchpad don't use EC touchpad switch */ - priv->features.touchpad_ctrl_via_ec = !acpi_dev_present("ELAN0634", NULL, -1); + /* + * Most ideapads with ELAN0634 and SYNA2B33 touchpads don't use + * EC touchpad switch + */ + priv->features.touchpad_ctrl_via_ec = !acpi_dev_present("ELAN0634", NULL, -1) && + !acpi_dev_present("SYNA2B33", NULL, -1); if (!read_ec_data(handle, VPCCMD_R_FAN, &val)) priv->features.fan_mode = true;