Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp578075imm; Tue, 5 Jun 2018 00:35:47 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL2NkD6rmuoXaHZNGZasL+WHxMsGcz6PszlwuBT2oH/Q9496P1SmEjAXGwZy03QxfRIHeDW X-Received: by 2002:a17:902:8306:: with SMTP id bd6-v6mr11904009plb.120.1528184147516; Tue, 05 Jun 2018 00:35:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528184147; cv=none; d=google.com; s=arc-20160816; b=nud6f0gQlMTGC/n3yzjYB5GqgoDFxDtbl7YG5xgwuKaqDgRb0HjabgYE2NebezpWrM BRD5lqH3kH2VHYofNhxS0Nm6RKYkSiGkXigGUXOCD9X2pHY/0Poa3ggrFMy5FJDke0Zo ilAWVClQ/qaP+UdtqsJpacqnF999e7kiz0PcfdpeMfUCmfaw0ixHNibCHZkwgj1fPH/X gsr6Gzzw+QrPfqrcp3X/OcET5c+RJra1xBFVsRPKHje9ZnXLk1Qy1m/pBPDdMKFDu3YH i/aw9PlvEy9y9nU8rtJdCDRgAW6c+Fu6pC6i5nKtlHxLlQ+0qxpbvfRmsUnQlyGgQ80q 0nlw== 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=2gW7SrEGsBygesfQyDP9JH/5tIW3ty3aC/un4OUWr9Y=; b=W4R0hqzE3HHOlKp4v5YZYAIKk8KswyUB7ngxfXjVFXE6bfTxBa6nljsFocb5/TNejq dA+osJf+vbtsCnI62wsglBEkK58iGy0eQvabtt8Bzx3zkAISNIQkvpo0PZyt+X3adm6F ww1oWO4O1vsUK7dwseJXrDof5/WRGHKhZeACc940et5WFqAnEbw2LWbQpNirGfitZX4Q s42ZW9VyRYHLIw/iuob4cAnApugx0yrMSO/LukkhTWv4PaUdaftNYG8PtRPPXj/bksnO CUkUrR8k0QfXE0UbZAP+NYdPSy3we2BK4TwO6DeFDzd4BYMEri4MGVb0/pFlsMWMiqar NjDg== 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 c1-v6si31417196pgn.281.2018.06.05.00.35.33; Tue, 05 Jun 2018 00:35:47 -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 S1751564AbeFEHfI (ORCPT + 99 others); Tue, 5 Jun 2018 03:35:08 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:55110 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751361AbeFEHfG (ORCPT ); Tue, 5 Jun 2018 03:35:06 -0400 Received: by mail-wm0-f68.google.com with SMTP id o13-v6so2852093wmf.4 for ; Tue, 05 Jun 2018 00:35:06 -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=2gW7SrEGsBygesfQyDP9JH/5tIW3ty3aC/un4OUWr9Y=; b=jRF8wN20qXRvM7qhDSRBuh53Y14dY/hsiDarlJ+NVypXTHhldMMpaYERMzcf15B45Q fPzPJB+gY+/CRX1IvWpuZ2Cp9s2bI6j+g53zhha957Ea/Dljz8oCl6+uY9LVLiuYgXnn /wGGe8lPv3ScNGjZdhi4+bCM6T05xeO43qoty6k09CQYqnZ28oEOvCzFwYPFAO1BXOGn wuC6v3yjahdhNrbH2UUScRcAB1RGsp11ROdvLbSnOyn5u76cwb4M2VIuXWdtJrh74DQE EFGfyDeCPkfqLPyFMMxTjcXHx+1XGH3h+k5qp86ZIG/mLmBGQQ9arZQkSv6eenMIfelP OpGg== X-Gm-Message-State: APt69E27+XS8muHzFm2IOqZEfc790PAmEte07+SXMVqoM9mhYmFj76hj c85W6nCnCApouVAc8ZErsqHD7w== X-Received: by 2002:a50:dac9:: with SMTP id s9-v6mr10197675edj.241.1528184105619; Tue, 05 Jun 2018 00:35: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 h38-v6sm16983197eda.43.2018.06.05.00.35.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jun 2018 00:35:04 -0700 (PDT) Subject: Re: [PATCH 1/2] platform/x86: asus-wmi: Call new led hw_changed API on kbd brightness change To: Darren Hart Cc: Daniel Drake , Chris Chiu , Corentin Chary , Andy Shevchenko , Linux Kernel , Platform Driver , acpi4asus-user , Linux Upstreaming Team , Bastien Nocera , Benjamin Berg References: <20180604123238.82200-1-chiu@endlessm.com> <20180605023124.GE47042@localhost.localdomain> From: Hans de Goede Message-ID: <85865f59-18bc-fb41-3a9d-30570647ec8e@redhat.com> Date: Tue, 5 Jun 2018 09:35: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: <20180605023124.GE47042@localhost.localdomain> 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, On 05-06-18 04:31, 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 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? I was thinking about doing that as a workaround myself, but I'm not sure that is a good idea (because of e.g. races with userspace auto-correcting the brightness based on ambient light and/or keyboard activity). As I see it 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. 2) Add a new KEY_KBDILLUMCYCLE event and send that for the TOGGLE code on these laptops. Regards, Hans *) Rather then separate up / down hotkeys > > Something like: > > if (code == TOGGLE && ledval < ledmax) > code = UP; > > sparse_keymap_report_event(..., code, ...) > > } >