Received: by 10.192.165.148 with SMTP id m20csp1350515imm; Wed, 2 May 2018 20:05:21 -0700 (PDT) X-Google-Smtp-Source: AB8JxZok76QVONcnMYgnu2CmKQgLTW+GQReQCHs0HgxXpPGP5jeVwDlJmzr1EQpaDN4piXhRhrLB X-Received: by 10.98.129.5 with SMTP id t5mr21421617pfd.215.1525316721069; Wed, 02 May 2018 20:05:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525316721; cv=none; d=google.com; s=arc-20160816; b=LP56/tndyMbK1hd+TCVmFXaMSnh5DTDnSQrZWadwRFkJCNyTyT+2FW7uRTrknJNrAY 25CjOgS0yxc00eKmdynznUYCnuF3DmGuX5kKtGUuecUI3suqnHXjgiIFek4w6aOX7o2k eqKpxBy6kyqghzNkxi0TzLyW2bsI9Jh0EBTbaI/AV50TKBl6KQxMmH9B2xrNduKvCaeo 7/gaM7jHql8O0pr3JJaAM1FP6CKICFVTnqdnDXFvNzgD8cTTyLCLZO9rd5BiPZtQ07M2 pOzVlPqysOl+ctUhAy6SwfMsZf1OwSKz3CnNk01pRQ8n67fhfWHmekqeawjImEBd4pIF uB+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=p8gl9P//BcMLFZBtLA1FM7TBZmrWAtkqaNInIsizAgY=; b=0KA91gs6hV3lyBNBDCugsWkQQLN5Gwb27Bf5XWjvqUw1zh3SKG3lwJSSmhoqaFvM4q /0vG+yD8IgeW89qukkl2osntg0wbCkblebB+2KNb4DwiKbae3jKIGAetdcvgfLGPgHv5 XT9IevbH5ihdqkXmMff10OJZr7TA2S/SIt3QR8PTYzoM1zbaZavW3Z4n+KpPQPz+CjfZ Xu29QRcsiMs4LlMGLccO644PaIyAg4UXDC37ysTefptLiMPeewuPsJt0smfCVnNiQyx4 pyEijhzc0KnhurIoVPoaUyrPGWvzma/Izp/nS6X53zZQL9r2ol3+6kv7jqKrP0EEi5t4 ZJ9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@endlessm-com.20150623.gappssmtp.com header.s=20150623 header.b=wg2iffFl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j5-v6si10318909pga.638.2018.05.02.20.05.05; Wed, 02 May 2018 20:05:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@endlessm-com.20150623.gappssmtp.com header.s=20150623 header.b=wg2iffFl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752064AbeECDEy (ORCPT + 99 others); Wed, 2 May 2018 23:04:54 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:45914 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751993AbeECDEu (ORCPT ); Wed, 2 May 2018 23:04:50 -0400 Received: by mail-pf0-f195.google.com with SMTP id c10so13466903pfi.12 for ; Wed, 02 May 2018 20:04:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=endlessm-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=p8gl9P//BcMLFZBtLA1FM7TBZmrWAtkqaNInIsizAgY=; b=wg2iffFlecDLjM6FwzjYIwD0rbmyDolS2sCyi7gy8zmC25ot1p0Ck/ty0btGuuMmdC v7m3IEmwt5tbWN8/xZXyCgWsHNBDvht3+zfQvZV4ffaFiCfosJUNKAPVuOlojNDWTarN E4wtm3VdFDb7AK2XMODl6sy3oQ8E6d4n2Io7hSddkwK86Er+TEVrUhcd2OOoATgQdEzf 5+Yh5CQBxLtJjvu9LwfOhqQbg/RC3DNIdJMQX/nMq5p2q75LxuYZSa0bNqR2gvEMILVZ K9fE5vPq6MWNZxJ/cGS/kh21ehklTMx5Cf+hfMAKY4wn0I+1clUsw4d89OWW3lOpYoW2 +vPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=p8gl9P//BcMLFZBtLA1FM7TBZmrWAtkqaNInIsizAgY=; b=Ssm9QarvwpwXa04OXNjhn2hx0Nym164Jj5Si7sqtZaW3MEoGPW1Ew/rCTQTdxQqqq6 yiwF3Gflxy5AFMjrER/+9ysrFM/399a4bLb/EX7YrK8UTuErKuWXxt5xqO8Cx1rVW/Wr dUiOrBbKUwxt3MN3K8M7VI+wGIyl87GvtvcwCbfMR4Ks6pUJWkMkJcIg+BwfP/yW0RFF oCZ0tJ+r7Ue+2UBLWfKOJtDyqje3L5YPUMmTZ8bgZpjfgkLaMsFgkUv3dA0BEAdEh9dI f5qy0b1etEyJkY7DWQzB4l+9e/zVm4YGZI1JEgkEHeVHdb/NttPByDFIo/CDnfoMPp4m n9gw== X-Gm-Message-State: ALQs6tDjAjz2sJNUzuXU1UR9DKSQRSBDI43ihPxVdDSoqUYO4pfSim42 Yw5kaqXU+YTfj0ilvUXbTUoPfA== X-Received: by 10.98.75.22 with SMTP id y22mr21602170pfa.29.1525316690021; Wed, 02 May 2018 20:04:50 -0700 (PDT) Received: from localhost.localdomain ([115.82.168.207]) by smtp.gmail.com with ESMTPSA id r68sm29640261pfi.174.2018.05.02.20.04.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 02 May 2018 20:04:49 -0700 (PDT) From: Chris Chiu To: corentin.chary@gmail.com, dvhart@infradead.org, andy@infradead.org Cc: acpi4asus-user@lists.sourceforge.net, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, linux@endlessm.com, Chris Chiu , Jian-Hong Pan Subject: [PATCH v2] platform/x86: asus-wmi: Add keyboard backlight toggle support Date: Thu, 3 May 2018 11:04:38 +0800 Message-Id: <20180503030438.51150-1-chiu@endlessm.com> X-Mailer: git-send-email 2.15.1 (Apple Git-101) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some Asus laptops like UX550GE has hotkey (Fn+F7) for keyboard backlight toggle. In this UX550GE, the hotkey incremet the level of brightness for each keypress from 1 to 3, and then switch it off when the brightness has been the max. This commit interprets the code 0xc7 generated from hotkey to KEY_KBDILLUMUP to increment the brightness, then pass KEY_KBDILLUMTOGGLE to user space after the brightness max been reached for switching the led off. Signed-off-by: Chris Chiu Signed-off-by: Jian-Hong Pan Tested-by: Jian-Hong Pan --- Notes: v2: - Remove redundant 'else' branch logic drivers/platform/x86/asus-nb-wmi.c | 1 + drivers/platform/x86/asus-wmi.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/drivers/platform/x86/asus-nb-wmi.c b/drivers/platform/x86/asus-nb-wmi.c index 136ff2b4cce5..14c502e18579 100644 --- a/drivers/platform/x86/asus-nb-wmi.c +++ b/drivers/platform/x86/asus-nb-wmi.c @@ -496,6 +496,7 @@ static const struct key_entry asus_nb_wmi_keymap[] = { { KE_KEY, 0xC4, { KEY_KBDILLUMUP } }, { KE_KEY, 0xC5, { KEY_KBDILLUMDOWN } }, { KE_IGNORE, 0xC6, }, /* Ambient Light Sensor notification */ + { KE_KEY, 0xC7, { KEY_KBDILLUMTOGGLE } }, { KE_END, 0}, }; diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 1f6e68f0b646..4a3ba575c9ce 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -67,6 +67,7 @@ MODULE_LICENSE("GPL"); #define NOTIFY_BRNDOWN_MAX 0x2e #define NOTIFY_KBD_BRTUP 0xc4 #define NOTIFY_KBD_BRTDWN 0xc5 +#define NOTIFY_KBD_BRTTOGGLE 0xc7 /* WMI Methods */ #define ASUS_WMI_METHODID_SPEC 0x43455053 /* BIOS SPECification */ @@ -1745,6 +1746,10 @@ static void asus_wmi_notify(u32 value, void *context) } } + if (code == NOTIFY_KBD_BRTTOGGLE) + if (asus->kbd_led_wk < asus->kbd_led.max_brightness) + code = NOTIFY_KBD_BRTUP; + if (is_display_toggle(code) && asus->driver->quirks->no_display_toggle) goto exit; -- 2.14.1