Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3666119imm; Mon, 4 Jun 2018 07:25:07 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKPJna07HcVcUXonmHU9K7Gn8OjpwdNnxiKtZh1nnM9iEkszMkxKy7JBsZ1Y+BQKSVOfdGc X-Received: by 2002:a17:902:14cb:: with SMTP id y11-v6mr21594233plg.229.1528122307844; Mon, 04 Jun 2018 07:25:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528122307; cv=none; d=google.com; s=arc-20160816; b=PArXHpy3Yz0s1WDzxZjj5ja328YCgDAYFhyd2Nt4Y14tPfb6ypi1VNifs6269oecof IsApk81oM7Q84eFo4uwR+zsSomc2yMMyPyo2y6DqutN5LqcDi1mMZQHtPQpl0+Dx9/ZG +nbaIp1hopr0u9iApXF4+sz6i8REuw6h42x/XiqkXK/A7s6OBWsrZc9h3VLDCMg7D1ix JUfraHII3MsM2g0FWVRKawmzYoOVCgwAiezOYz6GWWxlP8Z0OOTSAwhY3ApAQ1HaomWa fB0nJC4qKU3lmns21YPZV3bSUSYEl8O3GlMSZK0/shWz9Is56gk4hn0844NH7NlEzRH8 ffcw== 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=SuyARyiAhFPsFQEGbCdOnVD/pYZNqaWGziXUKLEdgaU=; b=k4QaZRKuPIoByxAcydtzLvISfGt6/jo8z04ReygoDS3JSKQ7QwtpA497LVhxEzuIlD nX42VzjpKFajPb1xNQkcKQtvoBcMekENy2cUVYY1T2nrCgADX1Q9a0imLS8uVn2kUR+p arqGN2cm6atSbb81X6JElc+ZJtwooHTdJ46jd3eALV7rDmO+sFY9uKAaYw6iOayyfner Y5wMke7nq7Lah3sDZT5yoB/pZXrr/+Uyo7tpd1I0mH4BxBHXA2NCffu/MIJGte67q99/ Ap52ns/EbjraitppVrn+sptsEec7GsXfJF0YAvgLhmfCENs+0Vu2lAZ119Yp/AeHnyhL VCZQ== 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 x7-v6si10726796pfd.124.2018.06.04.07.24.52; Mon, 04 Jun 2018 07:25:07 -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 S1753503AbeFDOXI (ORCPT + 99 others); Mon, 4 Jun 2018 10:23:08 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:35270 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752222AbeFDOXG (ORCPT ); Mon, 4 Jun 2018 10:23:06 -0400 Received: by mail-wr0-f194.google.com with SMTP id l10-v6so9171523wrn.2 for ; Mon, 04 Jun 2018 07:23:05 -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=SuyARyiAhFPsFQEGbCdOnVD/pYZNqaWGziXUKLEdgaU=; b=N76eCeAaV3DW4wV3pSpb9x6/m965bWL5HGjF8aYJ6tGrAF6Bed19eyVJPfSkiM4sRG QjxvZhsc63gSnE3kQB7LH92a/QZirWTCEbvmTatbJc7G5XX3zCbGdiz7qoBVwQ71chXV OvWiRmqy/QSWK/2cknI1nDEObm5ODAVPYUFaT+flOTHPGBtXJ5nsvWtdLzlFWvwYOKbS iY3NG7T/ewp3rPE2zb/6lEL9NX6kVny2+3C/ID/zXYdKLAzBWH6nHD+9dh6ZRLYE8Gz4 PdFK6jzhXv6rjH+i5s0GTMt9Skp6tS0dqIIpPFIxniSkWby1WbaVlaGt4MVB/UcyOIbS d7ZQ== X-Gm-Message-State: ALKqPwesAFY8x0hViMoPrrKotypbtAExKzZ1/Er2yjYkthjqoXr3zWtx 2DMcA2F98DKt9IM7jibWWzlsiQ== X-Received: by 2002:a50:cfca:: with SMTP id i10-v6mr24850816edk.35.1528122185318; Mon, 04 Jun 2018 07:23:05 -0700 (PDT) Received: from shalem.localdomain (546A5441.cm-12-3b.dynamic.ziggo.nl. [84.106.84.65]) by smtp.gmail.com with ESMTPSA id k9-v6sm18586279edh.61.2018.06.04.07.23.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Jun 2018 07:23:04 -0700 (PDT) Subject: Re: [PATCH 1/2] platform/x86: asus-wmi: Call new led hw_changed API on kbd brightness change To: Daniel Drake Cc: Chris Chiu , Corentin Chary , Darren Hart , Andy Shevchenko , Linux Kernel , Platform Driver , acpi4asus-user , Linux Upstreaming Team , Bastien Nocera , Benjamin Berg References: <20180604123238.82200-1-chiu@endlessm.com> From: Hans de Goede Message-ID: Date: Mon, 4 Jun 2018 16:23:04 +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: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 04-06-18 15:51, Daniel Drake wrote: > On Mon, Jun 4, 2018 at 7:22 AM, Hans de Goede 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. ### With that all said lets look at a userspace solution grepping through the kernel for KEY_KBDILLUMTOGGLE there are 4 users: 1) drivers/platform/x86/toshiba_acpi.c I don't know how the key on Toshiba's behaves on models where it is hardwired / under Windows 2) drivers/platform/x86/dell-wmi.c All Dells I know of have the hotkey do a cycle, not a toggle on/off 3) Some apple specific drivers: According to: https://support.apple.com/en-us/HT202310 Apple has separate up/down keys, so no idea why the drivers sometimes send a KEY_KBDILLUMTOGGLE event 4) drivers/hid/hid-input.c Okay, so the HUT clearly defines the Consumer Page mapping 0x35 as "OOC – Toggles illumination of consumer control's buttons and controls on/off." which is a bit of a bummer, because I was hoping that we could just redefine KEY_KBDILLUMTOGGLE to mean cycle. Still despite HID HUT being clear about this being an on/off toggle. I'm thinking that cycling makes more sense everywhere and that we should simply rename gnome-settings-daemon/plugins/power/gsd-power-manager.c 's upower_kbd_toggle() function to upower_kbd_cycle() and make it behave accordingly. If we device the range up into 8 steps (if there are more then 8 to being with) then I think this will be more useful everywhere then just the on/off toggle. The alternative would be to define a new keycode, but that will be > 240 so it will only work on Wayland and not under X11. Benjamin, Bastien, opinions? Regards, Hans