Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3547711imm; Mon, 4 Jun 2018 05:33:41 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLPEyvphFcelfB48NbeMG8B54RPU0jBU0PVv+/Kypn8zDzJF18itElXU0EvFN1Tiocwcs/j X-Received: by 2002:a17:902:7242:: with SMTP id c2-v6mr13536757pll.383.1528115621061; Mon, 04 Jun 2018 05:33:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528115621; cv=none; d=google.com; s=arc-20160816; b=Yu68ttBSgPYvzdiyV6Ld6YSUmhyCX7bbmY3jpwVf1uQeWhytJ/o4CVscvXVeSKHosS eCazKFf84CLRo/sbTRnClyDqmzUJ2U5Jw6p3V/AInMwxPvyBwADoJNsBEgsgxKJV8Rwr F/BGTfjY8v4hIOHhya44lBLQw9MgIyAfpP4DnHYRNAvX25P2r8LCnGd3dKGHC1wtToef WIgTQxbmf3K9uURIIIyucFLRKcXK09Dzmb+ZXxBXeA6fPjdbyCS9nrDHIXA41N9mFmNa GkKDB9aiBFp+IDCccfZB+K2KFOwQ+ZN7HXqobCONP1GxkmMyYtGLu6tpjhUAZg/W4RSt aEug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=jEFSTmlAmFaGcsjanT5TQbctLYC4E6pA0uceJIDtyVg=; b=oJWrQAmrIt617Wymljo2YJOrNE512norZ+fWvlT1TJoMvaKhYxL3QIgj+5UExXya/V gkn4kwGivno25RkL4AO/7jHRwkBvrZNYltWyX3TSKAciEkdi/6t8xyCdjK5fZaAkS1P7 5d1s79gYJdw05VQf/MHdnboZDWK9/wqwlvS8oMnFFXmtN3yaKbfXnkJUQbl2lxp+qHpE 755KPd++W8gxmn7/P0flztjMFp3KZ4xMqcdOnSyjCcuGgS7RImGQ3RJlwZrJCa4MWZYX ADFjl7ndju9ifFbJ5/brF0agyKB/iLPeD4GoWSsACnh1gIiS+1gIOlNu6DkQr3rF0dbZ Vlnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@endlessm-com.20150623.gappssmtp.com header.s=20150623 header.b=X/mxe3wQ; 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 5-v6si18758987pgb.430.2018.06.04.05.33.25; Mon, 04 Jun 2018 05:33:41 -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=X/mxe3wQ; 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 S1752733AbeFDMc7 (ORCPT + 99 others); Mon, 4 Jun 2018 08:32:59 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:39893 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752712AbeFDMc4 (ORCPT ); Mon, 4 Jun 2018 08:32:56 -0400 Received: by mail-pf0-f193.google.com with SMTP id r11-v6so8370890pfl.6 for ; Mon, 04 Jun 2018 05:32:55 -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:in-reply-to:references; bh=jEFSTmlAmFaGcsjanT5TQbctLYC4E6pA0uceJIDtyVg=; b=X/mxe3wQqcSQlI0wwS4oCWdgaoOAw0RrkYrNZ4Lco2t/IOfeaGhX1Uf11Jinq4FlqR FT8zEWbBiPhPY82EXOBbWVZa5v6DosPPsnWQLvlWRH0u+RreW4oDASi4k92ex8zCePHS pm7sg+HC9Z/yBPsh+2YsreUopsXhV73mFH9e3tlCxqgpzRlsTLNbqyc0QGOqsYaHemct wjnpqZkyg1lwFisr5NgMvk5WHNaMqfEhURbiJ119kjR/L0qnszmZv5pCKWiKc13sPkEd XgRILiI9ZO94vSq5zzCbY33SqVfa8330oiQJ6iO1jgoEowq3MT1TaG/SWQqNk4bHVtUi An8w== 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:in-reply-to :references; bh=jEFSTmlAmFaGcsjanT5TQbctLYC4E6pA0uceJIDtyVg=; b=kW8p9sfPkOSPD3XoqHNGie8sKJFT7/2dUQoKqei7INuCQQKUdIwrZFRORKntnTs5n4 0Tee9ELurbtQhYL9QkVXenbFoQkt2SYW3vhpj9Dradj9lidGbfa8iRmL9UOsAWzmOqiY 9Fr7nWushuIEw3IIvCNMUmtJkdNrk1mXDrZ1sD8cSG/D/MRoZHDX/SHE8CjYJcURzApw hTsPx64JjqMJENL+phVD3rui4c1SJDcWWU3ZdFeTi0zWMJ6YipFaddytxpboAIZz0JfI ZyLgThj2/+9wiLxX8/WSLllH9rDxJH5c6rJN9FsdMVzEOTenJe/8TuS6uMoXgor92ir8 yXPw== X-Gm-Message-State: APt69E3fZZEPKEW4iS94qI/wB0QG10Wwg2KbvJoF4gGOreZI6jqrkr5D ggJn/N9YR7gfxVU0t08t5iPSiQ== X-Received: by 2002:a65:6303:: with SMTP id g3-v6mr132111pgv.424.1528115575564; Mon, 04 Jun 2018 05:32:55 -0700 (PDT) Received: from localhost.localdomain (123-204-46-122.static.seed.net.tw. [123.204.46.122]) by smtp.gmail.com with ESMTPSA id x124-v6sm12573033pgb.53.2018.06.04.05.32.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Jun 2018 05:32:54 -0700 (PDT) From: Chris Chiu To: corentin.chary@gmail.com, dvhart@infradead.org, andy.shevchenko@gmail.com Cc: linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, acpi4asus-user@lists.sourceforge.net, hdegoede@redhat.com, linux@endlessm.com, Chris Chiu Subject: [PATCH 2/2] platform/x86: asus-wmi: Add keyboard backlight toggle support Date: Mon, 4 Jun 2018 20:32:38 +0800 Message-Id: <20180604123238.82200-2-chiu@endlessm.com> X-Mailer: git-send-email 2.15.1 (Apple Git-101) In-Reply-To: <20180604123238.82200-1-chiu@endlessm.com> References: <20180604123238.82200-1-chiu@endlessm.com> 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 which would emit the scan code 0xc7 each keypress. On the UX550GE, the max keyboard brightness level is 3 so the toggle would not be simply on/off the led but need to be cyclic. Per ASUS spec, it should increment the brightness for each keypress, then toggle(off) the LED when it already reached the max level. Signed-off-by: Chris Chiu --- drivers/platform/x86/asus-wmi.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index b4915b7718c1..100e13e0817e 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 */ @@ -1704,7 +1705,9 @@ static int is_display_toggle(int code) static int is_kbd_led_event(int code) { - if (code == NOTIFY_KBD_BRTUP || code == NOTIFY_KBD_BRTDWN) + if (code == NOTIFY_KBD_BRTUP || + code == NOTIFY_KBD_BRTDWN || + code == NOTIFY_KBD_BRTTOGGLE) return 1; return 0; } @@ -1755,7 +1758,10 @@ static void asus_wmi_notify(u32 value, void *context) } if (is_kbd_led_event(code)) { - if (code == NOTIFY_KBD_BRTDWN) + if (code == NOTIFY_KBD_BRTTOGGLE && + asus->kbd_led_wk == asus->kbd_led.max_brightness) + kbd_led_set(&asus->kbd_led, 0); + else if (code == NOTIFY_KBD_BRTDWN) kbd_led_set(&asus->kbd_led, asus->kbd_led_wk - 1); else kbd_led_set(&asus->kbd_led, asus->kbd_led_wk + 1); -- 2.11.0