Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp707873imm; Tue, 5 Jun 2018 03:11:52 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJg0trqYk2lp7UoZ059uIWcNqJMd/B8FQzPledRX4Tl0/ld5k9TUpf2fGcfqH8enksANYR4 X-Received: by 2002:a17:902:6903:: with SMTP id j3-v6mr25829173plk.313.1528193512749; Tue, 05 Jun 2018 03:11:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528193512; cv=none; d=google.com; s=arc-20160816; b=OlVjRenhR5UjZqa/8Yo/lVqZfV4IvkTT/lfsv+B6Y5pXy8h5ki5vNsDZpYYhoEKjrC ro4SpmjUkgWGFIFTSakIt8Q6QXPaekkOywP66GEb+se3XelCPhgXhhGS4nLK08udgvaD 5VhteANOYJ0kqWdOt7r6fCoXwe4qvasdSsxXmEJjuGoXj1SXIV0Awk/Vl/KsiN9LaQ+p jiAzZuKNV9+fKtPH0iCmDSfpO/9USi7rEkNEnk7oTruzGVQ6yRqSlCKGsWyBiJY5crOg 6qJU9JWvTyJhZPWCWwpKqxIEkXd1/SSVLiRfn4941T54QeOXcLuW+/U/a8umuLFdadzt J3eg== 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:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=7oQyrmsDdwkHYiSHuOkmdD/cb3TxJWd39Je+j3xYtKA=; b=Ff6fxgOkGPLxcj8dZvSJlPtz24jB9iWpexi9/mUHdET15WkgOyN+gXFDEX4sSzL1/U vNguBsIs99iwfmaIi802oUMuHD2IRMiE7qoPBx0DKflSFI96ELe3RGc37AFkT+Zj5T3N 8P/s92mv4HzUmm6fQVdWGGkI2xVVbJomFfe7L+ATdDpPJwIxv6qOKrtNMit0iWFZNrNc eC3IYbfn/YoBzKbxUNxC6lNxLF6zHCOM7+Uma+s5Lbo1Mr++v3O/T5/0bXa06ypU79J5 9+3bEPNR0nRjYe/hpg+8IrBNPkBA3tjGCt051DCqAP+zy60eJQEIFTte5XPwytRefubQ c5kA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o5-v6si6012309pgn.458.2018.06.05.03.11.38; Tue, 05 Jun 2018 03:11:52 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751611AbeFEKLM (ORCPT + 99 others); Tue, 5 Jun 2018 06:11:12 -0400 Received: from mslow2.mail.gandi.net ([217.70.178.242]:34220 "EHLO slow1-d.mail.gandi.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751494AbeFEKLK (ORCPT ); Tue, 5 Jun 2018 06:11:10 -0400 Received: from relay11.mail.gandi.net (unknown [217.70.178.231]) by slow1-d.mail.gandi.net (Postfix) with ESMTP id 280803AB21C; Tue, 5 Jun 2018 11:58:23 +0200 (CEST) Received: from classic (mon69-7-83-155-44-161.fbx.proxad.net [83.155.44.161]) (Authenticated sender: hadess@hadess.net) by relay11.mail.gandi.net (Postfix) with ESMTPSA id B4BFA10002C; Tue, 5 Jun 2018 11:58:18 +0200 (CEST) Message-ID: <71df09bc89619aba975147e6b07920f1dfc2f46f.camel@hadess.net> Subject: Re: [PATCH 1/2] platform/x86: asus-wmi: Call new led hw_changed API on kbd brightness change From: Bastien Nocera To: Hans de Goede , Chris Chiu , Darren Hart Cc: Daniel Drake , Corentin Chary , Andy Shevchenko , Linux Kernel , Platform Driver , acpi4asus-user , Linux Upstreaming Team , Benjamin Berg Date: Tue, 05 Jun 2018 11:58:17 +0200 In-Reply-To: <38cb3527-8480-bdb9-a5d9-b601bc494a5f@redhat.com> References: <20180604123238.82200-1-chiu@endlessm.com> <20180605023124.GE47042@localhost.localdomain> <38cb3527-8480-bdb9-a5d9-b601bc494a5f@redhat.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.2 (3.28.2-1.fc28) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Spam-Level: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2018-06-05 at 09:37 +0200, Hans de Goede wrote: > Hi, > > On 05-06-18 05:18, Chris Chiu wrote: > > On Tue, Jun 5, 2018 at 10:31 AM, Darren Hart > > wrote: > > > On Mon, Jun 04, 2018 at 04:23:04PM +0200, Hans de Goede wrote: > > > > Hi, > > > > > > > > On 04-06-18 15:51, Daniel Drake wrote: > > > > > On Mon, Jun 4, 2018 at 7:22 AM, Hans de Goede > > > > t.com> wrote: > > > > > > 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). > > > > > > > > > > Before this modification, the driver reports the brightness > > > > > keypresses > > > > > to userspace and then userspace can respond by changing the > > > > > brightness > > > > > level, as you describe. > > > > > > > > > > You are right in that the hardware doesn't change the > > > > > brightness > > > > > directly itself, which is the normal usage of > > > > > LED_BRIGHT_HW_CHANGED. > > > > > > > > > > However this approach was suggested by Benjamin Berg and > > > > > Bastien > > > > > Nocera in the thread: Re: [PATCH v2] platform/x86: asus-wmi: > > > > > Add > > > > > keyboard backlight toggle support > > > > > https://marc.info/?l=linux-kernel&m=152639169210655&w=2 > > > > > > > > > > The issue is that we need to support a new "keyboard > > > > > backlight > > > > > brightness cycle" key (in the patch that follows this one) > > > > > which > > > > > doesn't fit into any definitions of keys recognised by the > > > > > kernel and > > > > > likewise there's no userspace code to handle it. > > > > > > > > > > If preferred we could leave the standard brightness keys > > > > > behaving as > > > > > they are (input events) and make the new special key type > > > > > directly > > > > > handled by the kernel? > > > > > > > > I'm sorry that Benjamin and Bastien steered you in this > > > > direction, > > > > IMHO none of it should be handled in the kernel. > > > > > > > > Anytime any sort of input is directly responded to by the > > > > kernel > > > > it is a huge PITA to deal with from userspace. The kernel will > > > > have > > > > a simplistic implementation which almost always is wrong. > > > > > > > > Benjamin, remember the pain we went through with rfkill hotkey > > > > presses being handled in the kernel ? > > > > > > > > And then there is the whole > > > > acpi_video.brightness_switch_enabled > > > > debacle, which is an option which defaults to true which causes > > > > the kernel to handle LCD brightness key presses, which all > > > > distros > > > > have been patching to default to off for ages. > > > > > > > > To give a concrete example, we may want to implement software > > > > dimming / auto-off of the kbd backlight when the no keys are > > > > touched for x seconds. This would seriously get in the way of > > > > that. > > > > > > > > So sorry, but NACK to this series. > > > > > > So if instead of modifying the LED value, the kernel platform > > > drivers > > > converted the TOGGLE into a cycle even by converting to an UP > > > event > > > based on awareness of the plaform specific max value and the read > > > current value, leaving userspace to act on the TOGGLE/UP events - > > > would > > > that be preferable? > > > > > > Something like: > > > > > > if (code == TOGGLE && ledval < ledmax) > > > code = UP; > > > > > > sparse_keymap_report_event(..., code, ...) > > > > > > } > > > -- > > > Darren Hart > > > VMware Open Source Technology Center > > > > That's what I was trying to do in [PATCH v2] platform/x86: asus- > > wmi: Add > > keyboard backlight toggle support. However, that brought another > > problem > > discussed in the thread. > > https://marc.info/?l=linux-kernel&m=152639169210655&w=2 > > > > So I moved the brightness change in the driver without passing to > > userspace. > > Per Hans, seems there're some other concerns and I also wonder if > > the > > TOGGLE event happens in ASUS HID (asus-hid.c) which also convert > > and > > pass the keycode to userspace but no TOGGLE key support yet What > > should > > we do then? > > As I mentioned in my reply to Darren, there are 2 proper solutions to > this: > > 1) Make userspace treat KEY_KBDILLUMTOGGLE as a cycle key, this is > what the kbd-backlight on most laptops with a single hotkey (*) does > in cases where this is handled in firmware, rather then left to the > OS. The handled in firmware is the case which I created the > led_classdev_notify_brightness_hw_changed() API for. This would be > my preferred solution and I believe that Benjamin is discussing this > with Bastien ATM. It isn't on Macs, at least. Toggle is a toggle, not a cycle key. It turns the keyboard backlight off and on, restoring the backlight level when turned back on. > 2) Add a new KEY_KBDILLUMCYCLE event Which won't be accessible to Xorg. > and send that for the TOGGLE code > on these laptops. > > Yes both will take time to get into end-users hand, but so will a > kernel-only solution. In the mean time endless can always carry > downstream patches to make things work right now (while waiting for > the changes to trickle down from upstream).