From patchwork Wed Oct 26 19:01:01 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: 11382 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp437468wru; Wed, 26 Oct 2022 12:04:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7R1N6U8wfkWQcFYljQBNgIR+iDQ1UZo0N6jFRojMLmPzpMOzv343lAfpOnRkvTyGiEkZzi X-Received: by 2002:aa7:951d:0:b0:56b:9937:c749 with SMTP id b29-20020aa7951d000000b0056b9937c749mr22433860pfp.78.1666811062925; Wed, 26 Oct 2022 12:04:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666811062; cv=none; d=google.com; s=arc-20160816; b=J7ibD3bMOZeQ70iScmSmqFWDESVdoTey1IdpNAcY2wMiJSOzvvJqgwZ77w4jAlmgpf vPGJp/wpX7SnJeTh4T/JEkrROvfmqT/B01P1KPNnuqxsXzobAXcNTA6o2FmCl6I9Pu7J KRX8tUhmbgbmgeFaxjjS8jix7CV05cVz0wvWrhIuukXPCgXiENtOwFIa+5LwjtjWa3Lq BfkuEYRwTIIhKz1PW/lJgTakE9cxL675DoJCE2PaJAGuLNdZys+mDZ950b9V42UiK/JS wu6BcOufRFhdmlpZVunzkm8XDvNajiI7b4BtzFvRNmdQfUglgeTuYKiBtivVGYq0kmb5 Bhdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gzOvAyGDXhsFFUVp58xr8wzl/ct2UtB9GMmORTrIQvw=; b=ogFFm8EBUcFD/D3z/qKLppH0gGIIkPvyRn8ZaSIav7Lo5+0XCrxFKoxmb3kqWZL5MD EM5mADQMRGLM1td/yvOrz9kYEGgsmctmpfdydTPNPEJ3UgxaELfOl8J2cK529Dbw/vuT 4AzcHUpV1pY9jCKOl5yyASxZ56FLE3lhAInMT7RYnpek7XyCX/rMf679Kn9kLR8hLZyH tY4fC+VDbBnkBBJE0hPr1282YKD42bClFvhUGKhfEaEK/6GFEllV9p1o67zckrPyAZjX iOfJ/lCb3R99krAh7NYNmssXlVA8peBi0c5rmI1trbcBp6HXumt0gr9IFPNgCpM0ZxiZ 9mmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=VkszwJfp; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z1-20020a170902834100b00186a3bb7ae3si6870509pln.213.2022.10.26.12.04.08; Wed, 26 Oct 2022 12:04:22 -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=@gmail.com header.s=20210112 header.b=VkszwJfp; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233809AbiJZTD3 (ORCPT + 99 others); Wed, 26 Oct 2022 15:03:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234765AbiJZTC5 (ORCPT ); Wed, 26 Oct 2022 15:02:57 -0400 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A6C510A7E1; Wed, 26 Oct 2022 12:01:11 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id v27so20888966eda.1; Wed, 26 Oct 2022 12:01:11 -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=VkszwJfpdTdcR/n7PA9ZaP+Z9XiOgGjMiVywP7tgwz3e0LJH/kgHgSMI5Jb176mnNG 8mlUJ/2mfq3cyFl+C/t0bqrEceaVwiatUL7boJoIgoWZ+VlA29ETng448qZo0bAquAf5 /GC4uGJCxDYaaND6YKkcd2l6+e+kd0O6A19PbMHRz1mZZmiKDZmJhTKHr0tJbO7BRMw4 VTuQrwgE886CRH6/3kZUDlC1lKgQJ5zSJ6Dzuc88j8yBS1vu2dkwiqu8RNQT5WgGOXd9 ypjFVyHF556cwvIBresZq6zqg+3GgGrH37RHgmcfjuY3UJ250M+ZoT/6HFkZwxV1nV1m KLVw== 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=iLqL9JkQcOQFi0skoBQesU+8zXXKSoqtDJq3p1bvvot3ICXnhYMsp7Fqp/7WfV9ie/ zjbADyoKIiLxNoqaD5Ai/xz5tzmNipDqQIavaSPT3LZ4dvvLN8keiRvD0am8qCc2NLtk aFSp5WniNcmHK5WO6gQjyNQIWxNWtewjhHl+U4aPh58gT5lMFQMlM0QBenrKTVutbTR7 t1q9R5LQ8fiBICIsehNZK0kSGdGE9xJ2woa4S5tHDEPl6+dIqQSPjd6DLtd/itKFgpT4 yaR1jqKhOyf0LzaE2x2JeebwdOEzNuFeNmesa5QGPZt+dVW/67IPJWaEPTOSD5TkRFTd iXqw== X-Gm-Message-State: ACrzQf01ySQOGdNAhpuJnwgqOfSaxuBffPU2pSm4XXzqXS4S8JI60Zua p4Ck6dix4QeSCpqgPUH1+pyf6OFl6DbCSQ== X-Received: by 2002:aa7:cb59:0:b0:461:7378:7be0 with SMTP id w25-20020aa7cb59000000b0046173787be0mr23230343edt.60.1666810870072; Wed, 26 Oct 2022 12:01:10 -0700 (PDT) Received: from eray-Lenovo-Z50-70.. ([188.132.247.187]) by smtp.googlemail.com with ESMTPSA id r18-20020a1709063d7200b0076ff600bf2csm3342945ejf.63.2022.10.26.12.01.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 12:01:09 -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, =?utf-8?q?Eray_Or=C3=A7unus?= Subject: [PATCH 1/6] Revert "platform/x86: ideapad-laptop: check for touchpad support in _CFG" Date: Wed, 26 Oct 2022 22:01:01 +0300 Message-Id: <20221026190106.28441-2-erayorcunus@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221026190106.28441-1-erayorcunus@gmail.com> References: <20221026190106.28441-1-erayorcunus@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747778077160391024?= X-GMAIL-MSGID: =?utf-8?q?1747778077160391024?= 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 Wed Oct 26 19:01:02 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: 11387 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp438609wru; Wed, 26 Oct 2022 12:07:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Y53iNQVwCIX1ACXUhmHpc1D85eOkRtZL5VggfwVHLNpyYJa1+1IoeYgeC+x6XB/h9LsFr X-Received: by 2002:a63:5415:0:b0:439:e932:e025 with SMTP id i21-20020a635415000000b00439e932e025mr38206721pgb.63.1666811231787; Wed, 26 Oct 2022 12:07:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666811231; cv=none; d=google.com; s=arc-20160816; b=V99+c5clZzUPJ52pl2yS9R8ztm93vZ9Sf91S1foQhsLcF8CfYfGXJgLhGcz2HH1uIf IrS8m3Nnmodn/li+hH4+Ogpjgsjy9wjEmd3MW9R2TFyCxTKi1C3bURoKvRMCTsryK1w1 aWAsDsuwbySGt9udKfz8alibzWxVe5GX1ALKF0bJcpB61O1jUKdSJ2rDO+9lR7L52OQH SXgnCVG3J+0kC5nAgjsvEOwh4jS0MqQ04b2hKQR6rzAd/kfWeFapxMaZ4H2DQNxwYFSo IHF4HEA2VyYfmC+2eI1qL4uSkZvtBMs2yi1kOuSytioaPsfDsMmQghxm22pEECimhOhr VIeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WkZbKsWATbAJjypqKd57ux62RrGOy/eY6B4J6gXFedg=; b=mZKwix+j1Z9AGShucah/inEOeqTKe+NSKQxx6GTvoOxfQ5lWKDNMaPFy6ec/dICRJa t/bG2l4gxPOnguXoEXbxBcy5FHIpsM8irVDAw2DbUNCQNUqAZ5g/LTIGnXMc8RHc2DPX Wlo1IKphoPgu+vJQT5cNnGCj2WgM4bzQVuEgZZ8fyFlWb6aLgXfRxBvjt0YDps+kTTdY NuS/KzFAqEddJuEH9AuGiLAduuVBI85mG81tjNwR+VH9Nxnxtl167CV4GbDM5Y/cNB3l RiCtLTlhEnr1Ui6UBaPqNrLaTiIGqgaGvD/82SFJiMHmrA8lPUcQXKqZbmfhkZEhgf2T 5quA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="C/ow4uw7"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q17-20020a170902f35100b001821a8d0568si5850981ple.601.2022.10.26.12.06.54; Wed, 26 Oct 2022 12:07:11 -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=@gmail.com header.s=20210112 header.b="C/ow4uw7"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234812AbiJZTDc (ORCPT + 99 others); Wed, 26 Oct 2022 15:03:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234759AbiJZTC5 (ORCPT ); Wed, 26 Oct 2022 15:02:57 -0400 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 3CE1910CF89; Wed, 26 Oct 2022 12:01:13 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id t25so18502318ejb.8; Wed, 26 Oct 2022 12:01:13 -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=WkZbKsWATbAJjypqKd57ux62RrGOy/eY6B4J6gXFedg=; b=C/ow4uw755Nyc8QdIC8LF4jIUJukOE1w/eQKeoX4AZW2iJKQ49pvP4ZfjZDI0owBws YRuJtIb9obY4QIVgsZNJ4/TqJAL3WJy+1kDxSdYePSfB/gIAaO3kzJhFJRQGBkZYUiwF Cbl/T9e7ixd4ZaQSnnWd4zNAR8HgDw5zsqaL2XPIR6eGFuKD1vCM6Rz6WTY3ndAfe5jh ndXG6Ji9Ch4nShNwaHUQz9herW3Hvk4UrgJWpVjOCdd58TNHRj2tENGOMx0RFLe6uBtR GJI4tbEmo3FIm7co2HwZPOqubfuzJ0UfEaz4flKTv8QMvgxja3MbJ1uHU89y0P5egj4X fRAQ== 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=WkZbKsWATbAJjypqKd57ux62RrGOy/eY6B4J6gXFedg=; b=uN5EkAYzqgT9GaPoSsIFTl31F8jQHK1wB2OrqyMcu795XhIKt0Lin4gYd1groySjpX pxRSzbiqvYfSrngsLq9fYLZsXJiTPK14ymblBhesfKTeShENlClnV7UCkK9h6ydWFsjA 2aPXfT2A9txQpFU8kJrfa1o8JiMcM4rf7F5wewayhjjfK1hQPRhT+8yDQxt8AhDRHBTa KyAVgEat0+XaYYnGTBqu6SE9KCeitPZ/GbaLOt9GUZqWFQZyv6cRhJ/vH55mORnaVkIX ttIZhGBHUYtySSUHXXG28PFp+jt9+3yvWWH+mmE2pLj0aMWG25U/sjuCTTGgUVOzeNQW ALtw== X-Gm-Message-State: ACrzQf0WwmHyl/haCY/qrv3tjVE/H80gQvRd33GAKsdrt7Hm8qkdvxBx uQThrYE6pyJUI8pIdaFXUM09YToSpXyFwA== X-Received: by 2002:a17:907:75e9:b0:7a4:31c:ae0d with SMTP id jz9-20020a17090775e900b007a4031cae0dmr19129734ejc.79.1666810871408; Wed, 26 Oct 2022 12:01:11 -0700 (PDT) Received: from eray-Lenovo-Z50-70.. ([188.132.247.187]) by smtp.googlemail.com with ESMTPSA id r18-20020a1709063d7200b0076ff600bf2csm3342945ejf.63.2022.10.26.12.01.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 12:01:11 -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, =?utf-8?q?Eray_Or=C3=A7unus?= Subject: [PATCH 2/6] HID: add mapping for camera access keys Date: Wed, 26 Oct 2022 22:01:02 +0300 Message-Id: <20221026190106.28441-3-erayorcunus@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221026190106.28441-1-erayorcunus@gmail.com> References: <20221026190106.28441-1-erayorcunus@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747778254181059394?= X-GMAIL-MSGID: =?utf-8?q?1747778254181059394?= 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 --- 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 Wed Oct 26 19:01:03 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: 11379 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp437352wru; Wed, 26 Oct 2022 12:04:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6UYtHL60MdQj3/X9XkfkYceXoFU2qt9whFF4xUE27KWg3g+KvCoelI4k15368YkP6kFOM4 X-Received: by 2002:a17:90a:fab:b0:213:1431:86d0 with SMTP id 40-20020a17090a0fab00b00213143186d0mr5900835pjz.154.1666811051514; Wed, 26 Oct 2022 12:04:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666811051; cv=none; d=google.com; s=arc-20160816; b=FK7kBHKIZRA2B8APrfNGohIcyA3B9ee0NLFMhD4whfnkGDzTKRXLqauZWFYPccbK5P rW83udtKg9uiLzxuu6smHgj3/gvlClb+HM7vU0zOFTV5DlUFtlfSzJZO1YaJz6NdjG3l n3q698B1oKx/zhWoBAEOlXDMNtYVn5fND7yQTaz/dCaxBFHQrbBS9WSzj5lK1Utob/SB /klOg9iy6jVgmN1yFApGF5LAvBE1tJ+Kk21tlojKGESB9xAMYUbjARSeoPjnNSlOPVqC wi0fRmKxYEPYjX4Wn2qGlZ0snI4vPb+FQiCihjXVUSTKX/6ULMJBlkM1X/qiqs4PyzDD ONbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dxceK4h9km4GtO20VnsGtzfG02HWM3iZYATl3ehVRaM=; b=qdDvTNTPx3DS/549QjwQDRsSefQ8GpI3TnKcUNB4rHMz5XHoeUvmALzGuULz49ZGtt TBQK/hIgY9IMP96sL24R/VLQL2z+1EoYs6czGvQ7wxf53flAgHPoUrMCQw39LuCUw+dZ 0WDytk4w++SwfdYQx7WfH7Kbfr3+WrM5eCvY/4C3X55kpSUA6uAEhpt7Ts4vMVFnzsvl y6rtr76iHGlW0ykuFVw9o/dvFIaUpo9OnXIP5ILe64DIhS+D54l2q4YqXG+3J/qhSw7N KN6QnjtL1iRattAsbepVdFrXFlG302Zt5xQA5IIWllIjKRXk89P1lJm+paNJGmuKK98y pRhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=eHui6vyv; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g6-20020a632006000000b0045fa2a39f45si7615235pgg.246.2022.10.26.12.03.55; Wed, 26 Oct 2022 12:04:11 -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=@gmail.com header.s=20210112 header.b=eHui6vyv; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234690AbiJZTDY (ORCPT + 99 others); Wed, 26 Oct 2022 15:03:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234672AbiJZTC5 (ORCPT ); Wed, 26 Oct 2022 15:02:57 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AFC710AC04; Wed, 26 Oct 2022 12:01:14 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id b2so24047627eja.6; Wed, 26 Oct 2022 12:01:14 -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=eHui6vyvmJL3NN+kpS1RZhq8hAbWvJ9JSsDODJnswnweEF5pbJUSuoNNMhU0+pFFm1 /hyTTeE1jy92zw3e6fGCUsZKaN8/P3ni4Cp8yQhQnEP7/wKCrg9PF5RVeOyEKNAcItey tabPYYF9PyohE1+KvhpMdoCqkyEhHiHKqhtwIP2CXyMVCQQajnQcqw7zuSXw8lPwg3i7 zcFmSIJJWWKBNmf7X4V5aN2q1HtQJQ712HtCgz3/Y0ajxcrsLKbMZlhC/ZJZKpKCeTaQ oMzu07uTr/fAV/v0L0rycmPgEabktu9Aig6E/d1U5Qp8zF9dFaG0QVrjEPR32VcetoyN W2fA== 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=Pn0+c0PK4bQvQp+4kJ0sXcDVrFJmLEjLO3JAp9ViwvLHXfnM/BLqwnbYvsY1Fw2SPb g6E8bi4uvcEdjlM6AZRlUo1MTC9jJfnDayoIhJChAolRCAQDbMws2VTdiWaGf6qvXjJw Ei5EQIDJvLJ/q6bdMD+hlE9Z5/o4u+3qEzKZ4ssq+JBuHsUdSvIe+qEfbQV7k2aawhQM kc4J0K57q4CupK6wsihoa++KwupNQLSY2uiA7J80N5VaXqTl1yRyHOQVwf0w+m7Qyggj pSa3odiYdf2m4Ihs/90iYR20CxJu/GCyt+wXL1EbSqxThCYDnLrJLIky8qGdoEvbzQxw lL9w== X-Gm-Message-State: ACrzQf0hWGyelanmbc6no0oLRCTl2DVLpwPAQux2NXCPCQ/w0VnW2RyF 4gcOFTH4bZwvV5pRUXL00Ncg6+qsSU3xag== X-Received: by 2002:a17:906:7314:b0:791:a45a:bc84 with SMTP id di20-20020a170906731400b00791a45abc84mr37343231ejc.394.1666810872684; Wed, 26 Oct 2022 12:01:12 -0700 (PDT) Received: from eray-Lenovo-Z50-70.. ([188.132.247.187]) by smtp.googlemail.com with ESMTPSA id r18-20020a1709063d7200b0076ff600bf2csm3342945ejf.63.2022.10.26.12.01.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 12:01:12 -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, =?utf-8?q?Eray_Or=C3=A7unus?= Subject: [PATCH 3/6] platform/x86: ideapad-laptop: Report KEY_CAMERA_ACCESS_TOGGLE instead of KEY_CAMERA Date: Wed, 26 Oct 2022 22:01:03 +0300 Message-Id: <20221026190106.28441-4-erayorcunus@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221026190106.28441-1-erayorcunus@gmail.com> References: <20221026190106.28441-1-erayorcunus@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747778065090801916?= X-GMAIL-MSGID: =?utf-8?q?1747778065090801916?= 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 Wed Oct 26 19:01:04 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: 11384 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp438080wru; Wed, 26 Oct 2022 12:05:58 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5ve9t4bFVay3DLjcFMxm3V3AT2bRrv02anCmJUuXFYGg39jHqCdwDP24Zlc2SA7Qo2MDTN X-Received: by 2002:a05:6a00:1749:b0:563:8346:12e9 with SMTP id j9-20020a056a00174900b00563834612e9mr45881990pfc.68.1666811158650; Wed, 26 Oct 2022 12:05:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666811158; cv=none; d=google.com; s=arc-20160816; b=qDCJZwonIslD1W2EGXitfPwDNpLDmYipdkrghscM9BoiD8iPVIYDKzFkKaMvSLXDsW CMpPBbKLHN4Nl53akwnpTb3+zj+jj29NSu/vXvs25v+bzxzght/bbUv0AfnkJSg24FTk fYvZ2RVI8NuXzFg1DlDjoAqbDDCDf5+II5ZomDRql/F+vqB2oUzdXuJLKHvSt/UtdF3+ FBYWvZqQfAglAEOc/cbQ3Yt2znG300Kh5PZTNYIUqthnkpEMHS+0JuOjqG7dVoXufMr8 1fkRWtCqk8TUyIQANXS4U2q9+HzyExZLEERqf94F7ki+9DfGgyuBsw/Xh2eLSVr4yow7 PvNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZJQTmtw1LKn8R21PdJOf+BsVQdKZOWcICNuuo0tryIQ=; b=Dtgtu3QTcZp5q5be9E8C77S3AMuxJb2gDMi2QL8g+t215LWpSuSDbuw5xKXiFu4R1J OsgRVg0RuEKShHY3QlgetSD+sRcRjvmx8gAKvXF0VMG02IbC9bEB4SMiSiTqze5f5aur T7zEHqjtMfx0QDq1xdlio/P/sCgC0SQ7f5IAO/FB4U0Fa2hiB6Cm6FkGEQhyHmpN16wy UwJQxjzWjE8wUDm9jitl2YZhoPgbK0BKb3OyCBhBrzUlMHwxZ39xUxxydV8RmO8vNfvo LoqaokvQ5j6mWBf1EH/AH9A51p1BIzhoi4j6j82yk/+M6ebaRnP85nTB0MYk54NpxJGy 67wQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=neNEagus; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e17-20020a170903241100b0017881dc6dc2si6571617plo.489.2022.10.26.12.05.43; Wed, 26 Oct 2022 12:05:58 -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=@gmail.com header.s=20210112 header.b=neNEagus; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233840AbiJZTDg (ORCPT + 99 others); Wed, 26 Oct 2022 15:03:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234701AbiJZTDC (ORCPT ); Wed, 26 Oct 2022 15:03:02 -0400 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 A03CD11D9B0; Wed, 26 Oct 2022 12:01:17 -0700 (PDT) Received: by mail-ej1-x62a.google.com with SMTP id kt23so18452890ejc.7; Wed, 26 Oct 2022 12:01:17 -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=neNEagusHI0mIvWPl23F6JovwYqCjOeOuCasrNdeOtHN4ZGulvchTm8Q3apJhsdwh8 05EHQm+NaJkcduy2FMktQyF7Cv9o6xXWo/qYfEkgTVB+d6UaIKN0VPUIG0FjPEwBsF7Y R7fJowG4xcyw5/3dLP/HdSLIJyTlZvRfP2bUwj+vlhCLStfByvH44sy7duWumjOzcD+l UZRpeEdE1tlDPDKxorkzhvbdpb7dw7Z2MjSR8E/FsCuI0lG0rR9KRunoQQftcl2p9UyI vGYQWEXLYAUyGqc1eXjsoxb9DUpQVTodT33ArN4g6ycrYBvlKlQpVyF2hMI45IpAqzYv Hv8A== 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=vvzNjlYPaPqHKAUmUvXF+tAEGMF2wepaVc/1fwh+vj5JeIac408TkIz04289pIF8PK awr/diptKV0LqHD2B1ySCyJp+XWGPSA7aeEXFaoGYIYRhwQaYb91jt/YLqDWicy8nSm6 Bu0Rjj3a4gPDQI/z7sX7KlG67f8V4imPyt3XjKpquqBYka8esf3G8Xfle8NhtX8Ar/rN x6LSyRA/0RgIOk31ULHvoTnBEPl/KNLDJGNrmHV6+xQ/SmRMy3TCQSptp0f8DcA11+xP iRjhP7Lsxt+WtMQkbmeqGoDxAGtnr3pYPLjg54eDxvWyJM0K+u8gbVlvhEWlXFx5cRmN atnQ== X-Gm-Message-State: ACrzQf3UPvJNO0kfQbtbFs15peKA0wf42Cd0N50Jq0wtZV0aEpCY30Ww yX62kcdZbV3SERnii6SL9wtpVmLG6aJTwA== X-Received: by 2002:a17:907:2bda:b0:78d:9144:fb6d with SMTP id gv26-20020a1709072bda00b0078d9144fb6dmr38898252ejc.238.1666810874018; Wed, 26 Oct 2022 12:01:14 -0700 (PDT) Received: from eray-Lenovo-Z50-70.. ([188.132.247.187]) by smtp.googlemail.com with ESMTPSA id r18-20020a1709063d7200b0076ff600bf2csm3342945ejf.63.2022.10.26.12.01.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 12:01:13 -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, =?utf-8?q?Eray_Or=C3=A7unus?= Subject: [PATCH 4/6] platform/x86: ideapad-laptop: Add new _CFG bit numbers for future use Date: Wed, 26 Oct 2022 22:01:04 +0300 Message-Id: <20221026190106.28441-5-erayorcunus@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221026190106.28441-1-erayorcunus@gmail.com> References: <20221026190106.28441-1-erayorcunus@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747778177382505514?= X-GMAIL-MSGID: =?utf-8?q?1747778177382505514?= 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 Wed Oct 26 19:01:05 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: 11385 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp438359wru; Wed, 26 Oct 2022 12:06:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM50Fa0P8LL+fZ+U4Lx8FzXFAqReU9e0WefkIKU13qYj7VzoiMZ4paG0YvEe/Vg5oaie7HZV X-Received: by 2002:a63:b545:0:b0:43c:2ad9:b00 with SMTP id u5-20020a63b545000000b0043c2ad90b00mr38561105pgo.535.1666811199132; Wed, 26 Oct 2022 12:06:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666811199; cv=none; d=google.com; s=arc-20160816; b=nA2xF1HzSP5yk8NIxQR++9Ke+FSiMN+3WlMC8v1WCm+90WsYcDHGSiMyLXx+4d0QQW hxT7+LLA8fqMExbuga0qlUtWeXu4wLYnhzbkZSiTpc8nqEiIOfqPBKuC6bXD/DDeuw97 s4TyJyLNIHigg/OtwPODFWbbqXnIJ0rUaJQK8K1zsU5hkHDLyQp0/IWTTbSTsFVGrm/r zdBWoD3qVjAMRyjIvI8V0Y/C4NMdvP/fzGYVg5io7cxsO5FYUJgIlaz/D+haG+QPMOKG AOOLiw4WbqdYpZrsEx4Zi4eScBAZwPR0jhrZmmJY2uJTWrg2WQiFGAx116Ay5TDp5Lm7 3djA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=e2j3t4nzz6tQaWHbnOlMhCLHOCykeeAlsKmfrUyBz6w=; b=HnIIr3VHquvVe7m5qBm9l6I8uBMM7X13s1UCiuHl5yhRwSGX2OqIrfs6uYVqQMDd00 1zBVpz+FkJwPFwKPWJi9idUFK6hw65LLiMLcX/JCHYL+wvA2dWeeN1D1kKY3T3myHnae qJu2nl3/jYRTpjRvP5l3s3ge3ea3oC6BCgD8/vbkFWTa9N0w0n0O+ZJVqp8zuoVQ7Z4u ZZ+xJj93Tt7jyIRx8PgWAnLq5lJpNWDJ1Fv/HIlZbeUDrei9vjxe2TuTOFHUiOOQOqfS 46VvN4ETGa3qufBCbLfy3iZjBmkFAcLLmVxRB/sntZxXFTKfGYYSRGuTScSn8WOtoF76 hEvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=NCpLWkzF; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t4-20020a170902e84400b0017f59ed2dfasi8638935plg.63.2022.10.26.12.06.25; Wed, 26 Oct 2022 12:06:39 -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=@gmail.com header.s=20210112 header.b=NCpLWkzF; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234822AbiJZTDj (ORCPT + 99 others); Wed, 26 Oct 2022 15:03:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234703AbiJZTDC (ORCPT ); Wed, 26 Oct 2022 15:03:02 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1A2E11DA82; Wed, 26 Oct 2022 12:01:17 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id t25so18503018ejb.8; Wed, 26 Oct 2022 12:01:17 -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=e2j3t4nzz6tQaWHbnOlMhCLHOCykeeAlsKmfrUyBz6w=; b=NCpLWkzFShB30f3P4o1tkFIZDJmYS508r1ad45rK4svollxncCgIHEQUWA8f6gmsQS x/kvSEEv+3qply4jnOvgfRkJRVnoktjgmZRHyioHo6MvsvZSZMRZgXrnwhglg5EhhIlj rXzyDcPYWJ6AJ1SOD/isCJ548FTqbKy62e74QH1WQfJlxFdJ78YFeKkuBVnx2WoAFBDz X5UDHT+Z3wgsGOt+YYky8KRbTQs7PeAaXPavQryBu52IBVRjXn5WhhPpqysUDDS1NMA9 kkZ+1sBSUNHcxUFBmcOVMKrZhdQBea/JOgdJRwSPiNuUU/dPhpwbF2Ih+aFZoUnoUJAy MS3Q== 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=e2j3t4nzz6tQaWHbnOlMhCLHOCykeeAlsKmfrUyBz6w=; b=Mx50uqLjhzaFSl6UUev9hdOMPaWvxeBQu9DxEt5HDRDcvpT1umiULnPcmJ3bwMRKCC P6nvfUUSDXdC1IVGx6RrCDYoMhee1LFZ4vtfzCVQjzq9tud3iS6GmS5WitcpetH+fXNu W2wAytpKdEzTSmjKew8Ertuq8adqwb4H5GVwY2r0IAqSFpQFAahz63CkInFryVJpctGo f+ej6o9hdr8Qih+f4zId2EsPRHOBpM6pNPzsanmXpITJlT4SFpSV80KK96K3J3BK9MWe cX5pZpI4z543F71exLL5pP74b5yDpmVQIN72G2TLWkpbR0sugT9rdUPDe89JBBPdbuXA 5xVw== X-Gm-Message-State: ACrzQf12PZ520TUtqucNmFIrUg2tS5vldlAaQ4BPR9tq1HxomZRMHPgS c9UkgNQOTt4KftcYQP+zVkHfKZV91uOtOQ== X-Received: by 2002:a17:907:74a:b0:77e:9455:b4e3 with SMTP id xc10-20020a170907074a00b0077e9455b4e3mr39556945ejb.471.1666810875816; Wed, 26 Oct 2022 12:01:15 -0700 (PDT) Received: from eray-Lenovo-Z50-70.. ([188.132.247.187]) by smtp.googlemail.com with ESMTPSA id r18-20020a1709063d7200b0076ff600bf2csm3342945ejf.63.2022.10.26.12.01.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 12:01:15 -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, =?utf-8?q?Eray_Or=C3=A7unus?= Subject: [PATCH 5/6] platform/x86: ideapad-laptop: Expose camera_power only if supported Date: Wed, 26 Oct 2022 22:01:05 +0300 Message-Id: <20221026190106.28441-6-erayorcunus@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221026190106.28441-1-erayorcunus@gmail.com> References: <20221026190106.28441-1-erayorcunus@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747778220214173213?= X-GMAIL-MSGID: =?utf-8?q?1747778220214173213?= 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 | 53 ++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index f3d4f2beda07..65eea2e65bbe 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,26 @@ static bool no_bt_rfkill; module_param(no_bt_rfkill, bool, 0444); MODULE_PARM_DESC(no_bt_rfkill, "No rfkill for bluetooth."); +static char *cam_device_prefix = "CAM"; + +static acpi_status acpi_find_device_callback(acpi_handle handle, u32 level, + void *context, void **return_value) +{ + char buffer[8]; + struct acpi_buffer ret_buf; + + ret_buf.length = sizeof(buffer); + ret_buf.pointer = buffer; + + if (ACPI_SUCCESS(acpi_get_name(handle, ACPI_SINGLE_NAME, &ret_buf))) + if (strncmp(ret_buf.pointer, context, strlen(context)) == 0) { + *return_value = handle; + return AE_CTRL_TERMINATE; + } + + return AE_OK; +} + /* * ACPI Helpers */ @@ -675,7 +696,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) @@ -1523,10 +1544,40 @@ static const struct dmi_system_id hw_rfkill_list[] = { static void ideapad_check_features(struct ideapad_private *priv) { acpi_handle handle = priv->adev->handle; + acpi_handle pci_handle; + acpi_handle temp_handle = NULL; unsigned long val; + acpi_status status; 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)) { + 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_device_prefix, + &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 Wed Oct 26 19:01: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: 11386 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp438423wru; Wed, 26 Oct 2022 12:06:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5A9gFTjwWwgiOGMmZuSrhkF13qlveXXBvYyv+qyhTWeoSJnJaYg6dY6k2P8hSg5XC1sTSp X-Received: by 2002:a17:90a:1508:b0:212:e56b:2b18 with SMTP id l8-20020a17090a150800b00212e56b2b18mr5667076pja.35.1666811206633; Wed, 26 Oct 2022 12:06:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666811206; cv=none; d=google.com; s=arc-20160816; b=BNgHCPf2k3XRMMsrmlH7uJfgJaRiS8Yobk6LBLxpZPdICKclt4fx95LAH0CwgvG3Vb UEA0UU1j0hk0WtJW8Rz76CnEKH3pGvy6nKZDAldPPa+EuVQ5cDThuyizcf9OnjGgD9ZE ddl74KO4aklzcOcp6g2W4oFXyWzZ3hMWLtrgL+MXbGb/w66DyZJzIVKi51+phUWVRlvK Bhxoa6dB7B9pVrEv6KRRTBKzRaquOb3u68JwhQl+xU4AnfgCxZ5y8gmYiQy1OSwuR9Zw zM4oG5RPbSLXX59ojcbIV32iOPivL3p4gN3yOu4wPkw4NP1mLu/ejdO5R0Ph4gJtcb1V ggeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=oFFOZJ/VadBNjE26xEB3SXj8jNBR5pKnqYBmJKPPaoI=; b=Dg7VLZ2hGHTsr063WgTkEBeV9voUt0QcLfDl4RiDx6MuGgzXuc+VbqalIDAdAMUW9R gj4d5tpfm2jRN35+dOb/1VJREzO810tPD2193Owgv9IulfaCr+0EVAM/R+ytVCiRsZm6 VhOHv/npKUU9rWlc0uhQW734S6M+tRdaGz2ZVVXOPqFvc/O2V/hztvwZalASgW4NpUeL UPbHTEfH/cU49zPBXQi9mZZW//kokW1fi7ecX1XxIgPsU9xUwEmQLWq0M3QCg/clxnK1 Ji1IcSBjnLTL8GuafajeA3iWl+M1EmfmuBz13RKp44+XkIRlMYFrsV/LfwUPvR4bfOBN qQFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=VVUaU8P5; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x1-20020a17090300c100b00186a4763532si5772082plc.28.2022.10.26.12.06.33; Wed, 26 Oct 2022 12:06:46 -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=@gmail.com header.s=20210112 header.b=VVUaU8P5; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234829AbiJZTDq (ORCPT + 99 others); Wed, 26 Oct 2022 15:03:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233788AbiJZTDL (ORCPT ); Wed, 26 Oct 2022 15:03:11 -0400 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A71861213FC; Wed, 26 Oct 2022 12:01:19 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id 21so9182689edv.3; Wed, 26 Oct 2022 12:01:18 -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=oFFOZJ/VadBNjE26xEB3SXj8jNBR5pKnqYBmJKPPaoI=; b=VVUaU8P58x2uWpriSK+QJTdSu6sPvez31gYpX8vt5AcwLa8R1dGZK0SGG8OVQvbpU3 LDvLtme+1it9dkDEASp+iphuJ/pWpbJw+MN+k+JftJ/9EApWzCuBHqjWgWyPeogiQbzB BtHiK0JjO8WMXviLW1RvGXGMFzaG5XdpHp+w1MeP4nFueM8uRA/HjJvlyhj4Ul2JWNaE ho7x+AcvCGPAO+Rl809Dlz1HMTj2tGnGKvjES5NevbmJyXf8ZXI/Iro5yYn3zJPa2c32 pLyBnnz51hzLiwlmp2BdpC7rlLVfZlSqcaIgFEa/ah4Y/nGqDXl+mGV1SqC46I8iegrs qGwg== 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=oFFOZJ/VadBNjE26xEB3SXj8jNBR5pKnqYBmJKPPaoI=; b=eo1aAaLir/aF9VjJ6WsdMLxaAfnhkWKPOHX17c3bbkvMmWbATeSBMlZdhPLl0WEGwA 6PdukPMt0hvcn7JlfHVRjBffk5RyZtsk+rXUIPY+JEo6Z3c/eU8Uy1nIUzpMKW2ekpqF RFORYMmYI7uxobgSxgfyufB7G9Fdj+sM6mOmapo2h1OYTFP7UwKlRCIhkKKnkP6aCpWX W4bG24LYRiyZpgc6Yl1yjndGjwGJW9umvtpE3BZ/tq6XYrofqpkrLc1d+P0kP3+EEK/M HAyENkKJsDaLY+PXn7H5kkBwwtWEv9Wsb1cEnD4oRdBwLj+fT6RyT5/ojVN5TiOZFEmd UOkg== X-Gm-Message-State: ACrzQf3Nx/pmSH8CxO4Q3cJdj6Qtwice0WGjkNMck/U3xZTl3UuyrpXt p1ssjxHvfChDcRA9tOK85BLAth0bCVBl5A== X-Received: by 2002:a05:6402:274c:b0:461:9921:60cf with SMTP id z12-20020a056402274c00b00461992160cfmr20464459edd.353.1666810877183; Wed, 26 Oct 2022 12:01:17 -0700 (PDT) Received: from eray-Lenovo-Z50-70.. ([188.132.247.187]) by smtp.googlemail.com with ESMTPSA id r18-20020a1709063d7200b0076ff600bf2csm3342945ejf.63.2022.10.26.12.01.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 12:01:16 -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, =?utf-8?q?Eray_Or=C3=A7unus?= Subject: [PATCH 6/6] platform/x86: ideapad-laptop: Keyboard backlight support for more IdeaPads Date: Wed, 26 Oct 2022 22:01:06 +0300 Message-Id: <20221026190106.28441-7-erayorcunus@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221026190106.28441-1-erayorcunus@gmail.com> References: <20221026190106.28441-1-erayorcunus@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747778227570900825?= X-GMAIL-MSGID: =?utf-8?q?1747778227570900825?= 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 65eea2e65bbe..c30bbe0ca156 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; }; @@ -1302,19 +1306,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) @@ -1331,7 +1368,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; } @@ -1351,6 +1389,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; @@ -1373,17 +1414,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) @@ -1595,8 +1639,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;