Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3598638imm; Mon, 4 Jun 2018 06:23:50 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLkKVunRRPjXRUtX4Kl9P+7ui94pHv+hXuM1w0WYOBUUMfoAE5kqR1BBtm/qgm4gk3o3uFi X-Received: by 2002:a17:902:6b47:: with SMTP id g7-v6mr21765882plt.251.1528118630297; Mon, 04 Jun 2018 06:23:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528118630; cv=none; d=google.com; s=arc-20160816; b=WQKxl0hfPA7vkXAaWGVVDlcrc4AQEUS5S4kG3TZs1N3fA86IQ10HP2Z784v8+IkL2Y 7dXR45E5mvA9/muZ+sCpXyyXlr6d+SDv780F4Uyz/MBgy+xTH5G5Oaz5PcdfjBlM3AHF Xu3eMq4v7TMqs7Yf4SjSOyxJwU1goxdefo7Tdbmu3UsoGfmD7C3qVtGZGVIYwgsIdNTm aKPVa/WPC32qirNQM/IR3QrsU+8WKLnl1F3dvgdc9tR1wVKnHtXqpYdBxQ2nkBD4/Cc/ 2WlACLYgvIUwCM85q7NoFq2PHSdWwKinsiIi8Iq2ASTc7X+kU0wmFIoKI/Xg50v2bEX5 xr0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=Wst1/K/NrWWTZn2Io3c7CjoZQAExjkSt/O4d08aeCDY=; b=OQWO0HbYnSmwcyiU4HNZcPeNLzqFyMDQKaNkKxB0hKl/IQfvmHrDs5XlO4Emu/mdoJ t2bLKMNB2j8RxHunS/DbtK2WN7alV1UiYVTvBVuxhRm24QJxnrn4+l1GUMvcYVg8Y/q5 g87zEP9FrpHGyNhQxQsQ7ADKd/uol0m3hbp6ufa2Ui/CHFh+eT7uumYM6mCa6VOzTiq8 khZYIipKafWSVoYRUg7R2TJx4/x8aFZ468IydIQfGFI7uy7lRuRP/s0dkUohd8HC47Th M5FTGgKfGb2Bo2bH8sgLrWui+oV4f1ibKxGzmHj+9bLrm1BYGzKT22C7h9thsn2/9OiQ FEow== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y14-v6si7036728plr.30.2018.06.04.06.23.35; Mon, 04 Jun 2018 06:23:50 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753206AbeFDNWq (ORCPT + 99 others); Mon, 4 Jun 2018 09:22:46 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:40612 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752429AbeFDNWk (ORCPT ); Mon, 4 Jun 2018 09:22:40 -0400 Received: by mail-wr0-f195.google.com with SMTP id l41-v6so43430070wre.7 for ; Mon, 04 Jun 2018 06:22:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Wst1/K/NrWWTZn2Io3c7CjoZQAExjkSt/O4d08aeCDY=; b=IqzCD3JATZIH6AZS1JQmmCyQjIRRVvnOpZyAhcNrOQU4QH6wyjVbvjMDFA6oOOS5pN ZAznkC7WsK0k83vWmPStXog9s167MAaGsCmM+CIta8aJIc0shmtZ4xlnU5ax+IQDWIg9 E1lVShWkx9Lw9UPuv36U86C745ewbhlP0s7wOoiO36r/ZQ/i7AgvpnRtjcDnJJE1yGc/ kKmxIOxABYHXhL1i8Qqo9l88r5zY/Y+er+wGLFiVv49ZnPWm4Eie2YFPz0AFxnFK87on ytjDV5lHO12wd3t5rcWP/s2keGtM/KTZQLNOgGldZx2RivQ+dcoy6/Hv5DIWEKlpKs9Q vHog== X-Gm-Message-State: ALKqPwf73cEeHBKxR10NX8y57pcCz0gRaKLa2r62FZ1UGE1w2yJSfHsk KUgmHS3zG0k+6bhnv4QQIXhs6g== X-Received: by 2002:a50:b081:: with SMTP id j1-v6mr24401184edd.215.1528118559309; Mon, 04 Jun 2018 06:22:39 -0700 (PDT) Received: from shalem.localdomain (546A5441.cm-12-3b.dynamic.ziggo.nl. [84.106.84.65]) by smtp.gmail.com with ESMTPSA id b58-v6sm14256674edb.59.2018.06.04.06.22.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Jun 2018 06:22:38 -0700 (PDT) Subject: Re: [PATCH 1/2] platform/x86: asus-wmi: Call new led hw_changed API on kbd brightness change To: Chris Chiu , 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, linux@endlessm.com References: <20180604123238.82200-1-chiu@endlessm.com> From: Hans de Goede Message-ID: Date: Mon, 4 Jun 2018 15:22:38 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180604123238.82200-1-chiu@endlessm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Chris. On 04-06-18 14:32, Chris Chiu wrote: > Make asus-wmi notify on hotkey kbd brightness changes, listen for > brightness events and update the brightness directly in the driver. > For this purpose, bound check on brightness in kbd_led_set must be > based on the same data type to prevent illegal value been set. > > Update the brightness by led_classdev_notify_brightness_hw_changed. > This will allow userspace to monitor (poll) for brightness changes > on the LED without reporting via input keymapping. Is this really a case of the hardware itself processing the keypress and then changing the brightness *itself* ? From the "[PATCH 2/2] platform/x86: asus-wmi: Add keyboard backlight toggle support" patch I get the impression that the driver is modifying the brightness from within the kernel rather then the keyboard controller are ACPI embeddec-controller doing it itself. If that is the case then the right fix is for the driver to stop mucking with the brighness itself, it should simply report the right keyboard events and export a led interface and then userspace will do the right thing (and be able to offer flexible policies to the user). Regards, Hans > > Signed-off-by: Chris Chiu > --- > drivers/platform/x86/asus-nb-wmi.c | 2 -- > drivers/platform/x86/asus-wmi.c | 21 +++++++++++++++++++-- > 2 files changed, 19 insertions(+), 4 deletions(-) > > diff --git a/drivers/platform/x86/asus-nb-wmi.c b/drivers/platform/x86/asus-nb-wmi.c > index 136ff2b4cce5..7ce80e4bb5a3 100644 > --- a/drivers/platform/x86/asus-nb-wmi.c > +++ b/drivers/platform/x86/asus-nb-wmi.c > @@ -493,8 +493,6 @@ static const struct key_entry asus_nb_wmi_keymap[] = { > { KE_KEY, 0xA6, { KEY_SWITCHVIDEOMODE } }, /* SDSP CRT + TV + HDMI */ > { KE_KEY, 0xA7, { KEY_SWITCHVIDEOMODE } }, /* SDSP LCD + CRT + TV + HDMI */ > { KE_KEY, 0xB5, { KEY_CALC } }, > - { KE_KEY, 0xC4, { KEY_KBDILLUMUP } }, > - { KE_KEY, 0xC5, { KEY_KBDILLUMDOWN } }, > { KE_IGNORE, 0xC6, }, /* Ambient Light Sensor notification */ > { KE_END, 0}, > }; > diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c > index 1f6e68f0b646..b4915b7718c1 100644 > --- a/drivers/platform/x86/asus-wmi.c > +++ b/drivers/platform/x86/asus-wmi.c > @@ -460,6 +460,7 @@ static void kbd_led_update(struct work_struct *work) > ctrl_param = 0x80 | (asus->kbd_led_wk & 0x7F); > > asus_wmi_set_devstate(ASUS_WMI_DEVID_KBD_BACKLIGHT, ctrl_param, NULL); > + led_classdev_notify_brightness_hw_changed(&asus->kbd_led, asus->kbd_led_wk); > } > > static int kbd_led_read(struct asus_wmi *asus, int *level, int *env) > @@ -497,9 +498,9 @@ static void kbd_led_set(struct led_classdev *led_cdev, > > asus = container_of(led_cdev, struct asus_wmi, kbd_led); > > - if (value > asus->kbd_led.max_brightness) > + if ((int)value > (int)asus->kbd_led.max_brightness) > value = asus->kbd_led.max_brightness; > - else if (value < 0) > + else if ((int)value < 0) > value = 0; > > asus->kbd_led_wk = value; > @@ -656,6 +657,7 @@ static int asus_wmi_led_init(struct asus_wmi *asus) > > asus->kbd_led_wk = led_val; > asus->kbd_led.name = "asus::kbd_backlight"; > + asus->kbd_led.flags = LED_BRIGHT_HW_CHANGED; > asus->kbd_led.brightness_set = kbd_led_set; > asus->kbd_led.brightness_get = kbd_led_get; > asus->kbd_led.max_brightness = 3; > @@ -1700,6 +1702,13 @@ static int is_display_toggle(int code) > return 0; > } > > +static int is_kbd_led_event(int code) > +{ > + if (code == NOTIFY_KBD_BRTUP || code == NOTIFY_KBD_BRTDWN) > + return 1; > + return 0; > +} > + > static void asus_wmi_notify(u32 value, void *context) > { > struct asus_wmi *asus = context; > @@ -1745,6 +1754,14 @@ static void asus_wmi_notify(u32 value, void *context) > } > } > > + if (is_kbd_led_event(code)) { > + 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); > + goto exit; > + } > + > if (is_display_toggle(code) && > asus->driver->quirks->no_display_toggle) > goto exit; >