Received: by 2002:a05:7412:e79e:b0:f3:1519:9f41 with SMTP id o30csp108964rdd; Wed, 22 Nov 2023 10:36:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IEr1vPAyVwLdVnu4ggVP6+mrzpvg2hJI9CIEIjIRrvBNWMb6yMaXbv3ikIeuGc1eLDvp0SV X-Received: by 2002:a05:6808:2224:b0:3b8:3ddd:d490 with SMTP id bd36-20020a056808222400b003b83dddd490mr3448294oib.59.1700678167325; Wed, 22 Nov 2023 10:36:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700678167; cv=none; d=google.com; s=arc-20160816; b=TqZZkma2veWU3ISpNOHOD/ARytgHPlNMHFJdTC7FUEAloM6S3RFyf80RbNsXSJPWXQ vYfI4nDA7kH+b6bb30AlWVrB9iTqawEQ+LjQ/KDrqLFmUVrCbTLEL+OoEXlHcr/XIf4y Qz/vsSw/Ba7UkpiD7j/aNgEi8moMFRZTmzGRYJPJpoh3zed754nOT+JEDNPy5zrmMmR1 9hJZoL5Zhvi7eLNAszltMw7NW+j7PbzU3uGGR4jJG+IQKvbo6WeVSym6inlZc0lFNx+x Kr2YaYndO9S/S0lC4zrGGBNOgYHKpq+8Gj2uN/nng7UwDeNVseYSnoKNJ8Jwm3vzqqjz 9p4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=CSq4Z/8e2pXUHkDOJ7PPcDe9XGNiH9I/kXRfecMzXmE=; fh=za1hl5JJ93tBXvj/X5I16Zl2K909GkgQnTaPSvkAzsU=; b=sQEQZ1OfesvRUIHsy4cyLW4jqyLxqAL/Te/tqk8v/udUl0CGU138Fw5JFTcL1spui+ xiFCxe4x4DUaPFKAp0JJhypunJj8Tdp6FRre0jLLks+DNFjKsp5YZc09wmgNQuE30kut K4GXEzS/xhcBc13paYPd2F6JyTyQvHCEtPY5qZoYm0hHiKwP2Hfwp4GJ3s8J2+xcNToh AYj5NkTHhdQo4z5L99mgIyVFkIcSxeHWFpuCMTa812qcBPLQbMIFMUv7M8rVve2sc3L+ fuhqVPCrdQJ00CAeawuYAZiFbqUm/2IIfv0tCHjyrOCYFtx0rFlT09zNUMZjrMrvES+D Qf2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dtMb3Pm1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id t11-20020a63460b000000b005c14fc66ccasi6239pga.370.2023.11.22.10.36.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 10:36:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dtMb3Pm1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id E4A108385EE0; Wed, 22 Nov 2023 10:35:03 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344244AbjKVSe2 (ORCPT + 99 others); Wed, 22 Nov 2023 13:34:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344284AbjKVSe0 (ORCPT ); Wed, 22 Nov 2023 13:34:26 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A438F10C1 for ; Wed, 22 Nov 2023 10:34:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700678060; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CSq4Z/8e2pXUHkDOJ7PPcDe9XGNiH9I/kXRfecMzXmE=; b=dtMb3Pm1aDoYmhwNN/aBkTL4w4mk3iT8ube4dLsNmBbuJETQNPkr/gWXnQqWf5C1PfknuE Apb5S5fZ8cwhYyeKAcpKeJZOMFo+VYdTxRATND/fZ54+Jf5HGEGFnjXHLWBK0lJFlSP74k 1wK4AHrA3mXsU478CdzmDEEdoQ7LU8Y= Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-138-RrQkknhuOYiYeKWjQ__N3g-1; Wed, 22 Nov 2023 13:34:19 -0500 X-MC-Unique: RrQkknhuOYiYeKWjQ__N3g-1 Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-50aa6be164bso4747104e87.2 for ; Wed, 22 Nov 2023 10:34:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700678058; x=1701282858; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=CSq4Z/8e2pXUHkDOJ7PPcDe9XGNiH9I/kXRfecMzXmE=; b=akPDlc9RzyLxLef5Q+uQZHPlTlCi1DJJRLuVIudKbxkaF4eHfzpgQzvhfCyMxO950k Kd/OcN9EN0PsUQ7VkHBEN/FNNEbzFPfhvNxgvg+nBgPXyf6PE1wJI68s0fclDP642943 uDLd/XIp+jilOSDPGJ2qPrArlHOrWD75h3KetA4A1K6QsWsQg2yzCWlBYCn2ER154BYg 6JOm4c1oCgDWyg0jX8miIi7XcO4KYGiuOeaIN0yDue7beEvtmu0b1wFZNkERALDt6B7P QAzc4rFjaFYkz5sl2Ut9G9vptWujOXy0yg+BfATdZhr3HnTzH5NeKIiV+ODAAwrTkggW loEg== X-Gm-Message-State: AOJu0Yx0ig52xWqVUTtVnPRObuFrZotnl51zTh5ynOgMEkoBSriN1EG0 T+7OIC1CqqCPP0h1orO+n9uNZ7v1Cida4wC/gWnic8IsFFxZubpQ8Oupvj5E+mH3obW9ttUSdad lFkXcTiWiDh25h1akHVoVG6BS X-Received: by 2002:a05:6512:3b21:b0:507:c763:27b7 with SMTP id f33-20020a0565123b2100b00507c76327b7mr3162720lfv.40.1700678057735; Wed, 22 Nov 2023 10:34:17 -0800 (PST) X-Received: by 2002:a05:6512:3b21:b0:507:c763:27b7 with SMTP id f33-20020a0565123b2100b00507c76327b7mr3162697lfv.40.1700678057297; Wed, 22 Nov 2023 10:34:17 -0800 (PST) Received: from ?IPV6:2001:1c00:c32:7800:5bfa:a036:83f0:f9ec? (2001-1c00-0c32-7800-5bfa-a036-83f0-f9ec.cable.dynamic.v6.ziggo.nl. [2001:1c00:c32:7800:5bfa:a036:83f0:f9ec]) by smtp.gmail.com with ESMTPSA id r18-20020aa7cfd2000000b0053f10da1105sm68825edy.87.2023.11.22.10.34.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 Nov 2023 10:34:16 -0800 (PST) Message-ID: <4222268b-ff44-4b7d-bf11-e350594bbe24@redhat.com> Date: Wed, 22 Nov 2023 19:34:15 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Implement per-key keyboard backlight as auxdisplay? Content-Language: en-US, nl To: Werner Sembach , Pavel Machek , Jani Nikula , jikos@kernel.org, Jelle van der Waa Cc: Miguel Ojeda , Lee Jones , linux-kernel@vger.kernel.org, "dri-devel@lists.freedesktop.org" , linux-input@vger.kernel.org, ojeda@kernel.org, linux-leds@vger.kernel.org References: <20231011190017.1230898-1-wse@tuxedocomputers.com> <0440ed38-c53b-4aa1-8899-969e5193cfef@tuxedocomputers.com> <87sf61bm8t.fsf@intel.com> <8096a042-83bd-4b9f-b633-79e86995c9b8@redhat.com> From: Hans de Goede In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 22 Nov 2023 10:35:04 -0800 (PST) Hi Werner, On 11/21/23 14:29, Werner Sembach wrote: > > Am 21.11.23 um 13:20 schrieb Hans de Goede: >> Hi Werner, >> >> On 11/21/23 12:33, Werner Sembach wrote: >>> Hi, >>> >>> Am 20.11.23 um 21:52 schrieb Pavel Machek: >>>> Hi! >>>> >>>>>>> So... a bit of rationale. The keyboard does not really fit into the >>>>>>> LED subsystem; LEDs are expected to be independent ("hdd led") and not >>>>>>> a matrix of them. >>>>>> Makes sense. >>>>>> >>>>>>> We do see various strange displays these days -- they commonly have >>>>>>> rounded corners and holes in them. I'm not sure how that's currently >>>>>>> supported, but I believe it is reasonable to view keyboard as a >>>>>>> display with slightly weird placing of pixels. >>>>>>> >>>>>>> Plus, I'd really like to play tetris on one of those :-). >>>>>>> >>>>>>> So, would presenting them as auxdisplay be acceptable? Or are there >>>>>>> better options? >>>>>> It sounds like a fair use case -- auxdisplay are typically simple >>>>>> character-based or small graphical displays, e.g. 128x64, that may not >>>>>> be a "main" / usual screen as typically understood, but the concept is >>>>>> a bit fuzzy and we are a bit of a catch-all. >>>>>> >>>>>> And "keyboard backlight display with a pixel/color per-key" does not >>>>>> sound like a "main" screen, and having some cute effects displayed >>>>>> there are the kind of thing that one could do in the usual small >>>>>> graphical ones too. :) >>>>>> >>>>>> But if somebody prefers to create new categories (or subcategories >>>>>> within auxdisplay) to hold these, that could be nice too (in the >>>>>> latter case, I would perhaps suggest reorganizing all of the existing >>>>>> ones while at it). >>>>> One could also reasonably make the argument that controlling the >>>>> individual keyboard key backlights should be part of the input >>>>> subsystem. It's not a display per se. (Unless you actually have small >>>>> displays on the keycaps, and I think that's a thing too.) >>>> While it would not be completely crazy to do that... I believe the >>>> backlight is more of a display and less of a keyboard. Plus input >>>> subystem is very far away from supporting this, and we had no input >>>> from input people here. >>>> >>>> I don't think LED subsystem is right place for this, and I believe >>>> auxdisplay makes slightly more sense than input. >>>> >>>> Unless someone steps up, I'd suggest Werner tries to implement this as >>>> an auxdisplay. [And yes, this will not be simple task. RGB on LED is >>>> different from RGB on display. But there are other LED displays, so >>>> auxdisplay should handle this. Plus pixels are really funnily >>>> shaped. But displays with missing pixels -- aka holes for camera -- >>>> are common in phones, and I believe we'll get variable pixel densities >>>> -- less dense over camera -- too. So displays will have to deal with >>>> these in the end.] >>> Another idea I want to throw in the mix: >>> >>> Maybe the kernel is not the right place to implement this at all. RGB stuff is not at all standardized and every vendor is doing completely different interfaces, which does not fit the kernel userpsace apis desire to be uniformal and fixed. e.g. Auxdisplay might fit static setting of RGB values, but it does not fit the snake-effect mode, or the raindrops mode, or the 4-different-colors-in-the-edges-breathing-and-color-cycling mode. >>> >>> So my current idea: Implement these keyboards as a single zone RGB kbd_backlight in the leds interface to have something functional out of the box, but make it runtime disable-able if something like https://gitlab.com/CalcProgrammer1/OpenRGB wants to take over more fine granular control from userspace via hidraw. >> That sounds like a good approach to me. We are seeing the same with game controllers where steam and wine/proton also sometimes use hidraw mode to get access to all the crazy^W interesting features. >> >> That would mean that all we need to standardize and the kernel <-> userspace API level is adding a standard way to disable the single zone RGB kbd_backlight support in the kernel. > > I would suggest a simple "enable" entry. Default is 1. When set to 0 the kernel driver no longer does anything. I'm not in favor of using "enable" as sysfs attribute for this, I would like to see a more descriptive name, how about: "disable_kernel_kbd_backlight_support" And then maybe also have the driver actually unregister the LED class device ? Or just make the support inactive when writing 1 to this and allow re-enabling it by writing 0? > Questions: > > - Should the driver try to reset the settings to boot default? Or just leave the device in the current state? With the former I could see issues that they keyboard is flashing when changing from kernelspace control to userspace control. With the later the burden on bringing the device to a know state lies with the userspace driver. My vote would go to leave the state as is. Even if the hw does not support state readback, then the userspace code can readback the state before writing 1 to "disable_kernel_kbd_backlight_support" > - Should this be a optional entry that only shows up on drivers supporting it, or could this implemented in a generic way affecting all current led entries? IMHO this should be optional. If we go with the variant where writing 1 to "disable_kernel_kbd_backlight_support" just disables support and 0 re-enables it then I guess we could have support for this in the LED-core, enabled by a flag set by the driver. If we go with unregistering the led class device, then this needs to be mostly handled in the driver. Either way the kernel driver should know about this even if it is mostly handled in the LED core so that e.g. it does not try to restore settings on resume from suspend. > - I guess UPower integration for the userspace driver could be archived with https://www.kernel.org/doc/html/latest/leds/uleds.html however this limited to brightness atm, so when accent colors actually come to UPower this would also need some expansion to be able to pass a preferred color to the userspace driver (regardless of what that driver is then doing with that information). Using uleds is an interesting suggestion, but upower atm does not support LED class kbd_backlight devices getting hot-plugged. It only scans for them once at boot. Jelle van der Waa (a colleague of mine, added to the Cc) has indicated he is interested in maybe working on fixing this upower short-coming as a side project, once his current side-projects are finished. > On a different note: This approach does currently not cover the older EC controlled 3 zone keyboards from clevo. Here only the kernel has access access to the device so the kernel driver has to expose all functionality somehow. Should this be done by an arbitrarily designed platform device? Interesting question, this reminds there was a discussion about how to handle zoned keyboards using plain LED class APIs here: https://lore.kernel.org/linux-leds/544484b9-c0ac-2fd0-1f41-8fa94cb94d4b@redhat.com/ Basically the idea discussed there is to create separate multi-color LED sysfs devices for each zone, using :rgb:kbd_zoned_backlight-xxx as postfix, e.g. : :rgb:kbd_zoned_backlight-left :rgb:kbd_zoned_backlight-middle :rgb:kbd_zoned_backlight-right :rgb:kbd_zoned_backlight-wasd As postfixes for the 4 per zone LED class devices and then teach upower to just treat this as a single kbd-backlight for the existing upower DBUS API and maybe later extend the DBUS API. Would something like this work for the Clevo case you are describing? Unfortunately this was never implemented but I think that for simple zoned backlighting this still makes sense. Where as for per key controllable backlighting as mention in $subject I do believe that just using hidraw access directly from userspace is best. Regards, Hans