Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp3162749lqp; Tue, 26 Mar 2024 00:57:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXPaP91yiJvPHmFCtzIcm5+bbdX0/KG18DgCqYOeBz1nyRvUU1lAnYVuJJlmnHPfSolfH9AnkLCCuVNajAu/USjeA5UkkLD62no4Z+BQg== X-Google-Smtp-Source: AGHT+IHXG+zheUTcy+xUwiWu5dOSy8QaCMolTp4g5cDW0a4xr2lZHi1svZHRB8HCyNlwnLFp2oeJ X-Received: by 2002:a05:620a:1d94:b0:789:e9c1:72a5 with SMTP id pj20-20020a05620a1d9400b00789e9c172a5mr2244823qkn.7.1711439846204; Tue, 26 Mar 2024 00:57:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711439846; cv=pass; d=google.com; s=arc-20160816; b=PQzcOHJjHrJ284gqJPVfhlkERPq4LWiIUgEyzc3fTykAtCz+zKhm1bPiL0UEpy06Uu D9zdbFnNuMHNEmW/pKJ2jsK3Clo5eWrgfySTB+M9r5AAk1RE6vHg6Ce6yr7eqkSWFDMw 9epDe7d+CjOfZQvd4CQvL4KM9AFZBLrC3CcOj6NyzfjrQR0xFsGs1Xs0H9slIq5qaW8D CCvBQAx20bt2D14M9B+qYeTf7OdDO1DxbC5qxsi9Bzf9wa6Gl/5NzzQhFHiitm7vksCf pXOLqVj4qyPL4FA5n728zoP6iiuXwvAlmPQB6NagUqWJsm49oa9ocMZykzB8g4XTNElJ GsAw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=07xpBINcmpFjLp2DaMcbvfvjJdTbGEJQdX9Jp0QEuaI=; fh=PCFrMAAJJN+RhJumM7J+YN72Dn3kCC3IkM4K+te4lWk=; b=sAZ+RkYhw55q4Dzec5m2UohJlkeJ+ecUIkgOxH8CDJrN/Xywt6+mcshb18eeWy6Vk/ RoTMwESkLFa/L9YANgob4ZqKQ9Tbczi+dK4LyKZ8Ny7Ml2zOkRUG7J7rQGc8jxxOdiHU tvwyalqY1mCYOHNi4aKpt3unth1RxCEFNBWu5r8LE1NRabTPRPBy7Xxl+KEfcoluT62S 6D7DQexLM5a9SK6n3ARZGScRx5OxwdDh0sTAZO2DriI4onpFR0+GQ7XbtcMLtYArGs4c FIIHAwURfq67JGZMq23oWbBCvQuL0Awfim4QLxJnrKhzk/fDbeDNLdQgcRXAfCR/xlUP IOUw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tuxedocomputers.com header.s=default header.b=ZZxU4hOu; arc=pass (i=1 spf=pass spfdomain=tuxedocomputers.com dkim=pass dkdomain=tuxedocomputers.com dmarc=pass fromdomain=tuxedocomputers.com); spf=pass (google.com: domain of linux-kernel+bounces-118496-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-118496-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=tuxedocomputers.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id p4-20020a05620a22a400b0078a05c943f5si6923246qkh.660.2024.03.26.00.57.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 00:57:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-118496-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@tuxedocomputers.com header.s=default header.b=ZZxU4hOu; arc=pass (i=1 spf=pass spfdomain=tuxedocomputers.com dkim=pass dkdomain=tuxedocomputers.com dmarc=pass fromdomain=tuxedocomputers.com); spf=pass (google.com: domain of linux-kernel+bounces-118496-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-118496-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=tuxedocomputers.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 8D7771C2F04E for ; Tue, 26 Mar 2024 07:57:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 74FA61332BC; Tue, 26 Mar 2024 07:57:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=tuxedocomputers.com header.i=@tuxedocomputers.com header.b="ZZxU4hOu" Received: from mail.tuxedocomputers.com (mail.tuxedocomputers.com [157.90.84.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F6A0132C04; Tue, 26 Mar 2024 07:57:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=157.90.84.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711439837; cv=none; b=hlm6RpZT6dOcw3hN05ZqJCoZGa0U8/Eh3TQvzpq5JS8mX3D7CSMi6xJPmrr5dRHPWScWd123YqrQRy2doq6p7xZKgfRA5DCCgI5yfJHhG+puy+gY3Evwdmeh6j9XrJfBMuHmYNfhJxtWtUfh+Vm/sGROFMb8qtm1DpIgyZTQo5E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711439837; c=relaxed/simple; bh=x6WrjRafnlw5XzCc1/F74fHotz9wYk2CFg6piVDCOPY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=lqXsFLoxE5ublub/g5QQdvGMAnS6owf0/oKunJc4ncETAgJUPJ1z3KjggZ1dP+04SIEtZzF1iGJ5h+KutHi+CBvJ9QhOG9iddwIvwfJIefe7ff0wCeohRD5JgZGqPujIvftBJtzGgWBRLcKYlUgtU7DPLZdUY8RGnu/LtRuaqKU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=tuxedocomputers.com; spf=pass smtp.mailfrom=tuxedocomputers.com; dkim=pass (1024-bit key) header.d=tuxedocomputers.com header.i=@tuxedocomputers.com header.b=ZZxU4hOu; arc=none smtp.client-ip=157.90.84.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=tuxedocomputers.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxedocomputers.com Received: from [192.168.42.20] (p5de453e6.dip0.t-ipconnect.de [93.228.83.230]) (Authenticated sender: wse@tuxedocomputers.com) by mail.tuxedocomputers.com (Postfix) with ESMTPSA id 8DA012FC005D; Tue, 26 Mar 2024 08:57:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxedocomputers.com; s=default; t=1711439831; 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=07xpBINcmpFjLp2DaMcbvfvjJdTbGEJQdX9Jp0QEuaI=; b=ZZxU4hOuwCtvDabH2XBAqsqirw65P6JRc6X/96CK7py49gMn5gLb9G3eYbkX77mqZnFAh0 qRSm6e7r5BXokKL/nl/xFX8hJAyeOO8ThhV9pekNzG3tGkiUr5jCVI7IegOY4WV5mmNWOS hp9tgJGlUHZ2TwI/GFe9rQ938u3I5TI= Authentication-Results: mail.tuxedocomputers.com; auth=pass smtp.auth=wse@tuxedocomputers.com smtp.mailfrom=wse@tuxedocomputers.com Message-ID: <65b24776-ae1a-4290-a1d5-c7637ad0accc@tuxedocomputers.com> Date: Tue, 26 Mar 2024 08:57:09 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: In kernel virtual HID devices (was Future handling of complex RGB devices on Linux v3) Content-Language: en-US To: Hans de Goede , Benjamin Tissoires Cc: Lee Jones , jikos@kernel.org, linux-kernel@vger.kernel.org, Jelle van der Waa , Miguel Ojeda , "dri-devel@lists.freedesktop.org" , linux-input@vger.kernel.org, ojeda@kernel.org, linux-leds@vger.kernel.org, Pavel Machek , Gregor Riepl References: <477d30ee-247e-47e6-bc74-515fd87fdc13@redhat.com> <247b5dcd-fda8-45a7-9896-eabc46568281@tuxedocomputers.com> <825129ea-d389-4c6c-8a23-39f05572e4b4@redhat.com> <1fb08a74-62c7-4d0c-ba5d-648e23082dcb@tuxedocomputers.com> <870cca8a-1a1b-4d17-874e-a26c30aca2bf@tuxedocomputers.com> From: Werner Sembach In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi all, Am 25.03.24 um 19:30 schrieb Hans de Goede: [snip] >>> If the kernel already handles the custom protocol into generic HID, the >>> work for userspace is not too hard because they can deal with a known >>> protocol and can be cross-platform in their implementation. >>> >>> I'm mentioning that cross-platform because SDL used to rely on the >>> input, LEDs, and other Linux peculiarities and eventually fell back on >>> using hidraw only because it's way more easier that way. >>> >>> The other advantage of LampArray is that according to Microsoft's >>> document, new devices are going to support it out of the box, so they'll >>> be supported out of the box directly. >>> >>> Most of the time my stance is "do not add new kernel API, you'll regret >>> it later". So in that case, given that we have a formally approved >>> standard, I would suggest to use it, and consider it your API. >> The only new UAPI would be the use_leds_uapi switch to turn on/off the backwards compatibility. > Actually we don't even need that. Typically there is a single HID > driver handling both keys and the backlight, so userspace cannot > just unbind the HID driver since then the keys stop working. > > But with a virtual LampArray HID device the only functionality > for an in kernel HID driver would be to export a basic keyboard > backlight control interface for simple non per key backlight control > to integrate nicely with e.g. GNOME's backlight control. Don't forget that in the future there will be devices that natively support LampArray in their firmware, so for them it is the same device. Regards, Werner > And then when OpenRGB wants to take over it can just unbind the HID > driver from the HID device using existing mechanisms for that. > > Hmm, I wonder if that will not also kill hidraw support though ... > I guess getting hidraw support back might require then also manually > binding the default HID input driver. Bentiss any input on this? > > Background info: as discussed earlier in the thread Werner would like > to have a basic driver registering a /sys/class/leds/foo::kbd_backlight/ > device, since those are automatically supported by GNOME (and others) > and will give basic kbd backlight brightness control in the desktop > environment. This could be a simple HID driver for > the hid_allocate_device()-ed virtual HID device, but userspace needs > to be able to move that out of the way when it wants to take over > full control of the per key lighting. > > Regards, > > Hans > > > > > > > >> The control flow for the whole system would look something like this: >> >> - System boots >> >>     - Kernel driver initializes keyboard (maybe stops rainbowpuke boot effects, sets brightness to a default value, or initializes a solid color) >> >>     - systemd-backlight restores last keyboard backlight brightness >> >>     - UPower sees sysfs leds entry and exposes it to DBus for DEs to do keyboard brightness handling >> >> - If the user wants more control they (auto-)start OpenRGB >> >>     - OpenRGB disables sysfs leds entry via use_leds_uapi to prevent double control of the same device by UPower >> >>     - OpenRGB directly interacts with hidraw device via LampArray API to give fine granular control of the backlight >> >>     - When OpenRGB closes it should reenable the sysfs leds entry >> >> - System shutdown >> >>     - Since OpenRGB reenables the sysfs leds entry, systemd-backlight can correctly store a brightness value for next boot >> >> Regards, >> >> Werner >> >>> Side note to self: I really need to resurrect the hidraw revoke series >>> so we could export those hidraw node to userspace with uaccess through >>> logind... >>> >>> Cheers, >>> Benjamin