Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2827860lqp; Mon, 25 Mar 2024 10:16:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVuyeX2P5QVSMVWX3XPNVsyFQJUb4je96Ap0oon8R0X0STSewztFMXV4HrsKlY5EQ2pLA/IViwVe7uBdRqYB9FpZxIFFMtQ0k74oRvPKQ== X-Google-Smtp-Source: AGHT+IGNVmH283raUaraNfqRAOQoadjs8TS0aTkgsDnVnfHGe0g+xBXWqSriZe3u7PB8YtL3lSjm X-Received: by 2002:ac8:7dc7:0:b0:431:5f11:5da3 with SMTP id c7-20020ac87dc7000000b004315f115da3mr2456954qte.54.1711386995726; Mon, 25 Mar 2024 10:16:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711386995; cv=pass; d=google.com; s=arc-20160816; b=wK1pEl/i4zf2qGgWRNSb2ddKdTLL8+sst1NubG2aVkHO7y6OR2KuS6gr8wHdiiV1rp yIVaL/SaLqcz2vNfRJiou8c/s7V0HqZDBVgBDLPaoqNculaRfL7DHZ7P6xBSUPXjN1N+ wOU0ql2QaZ6f51Y+TN+EBZBsQqY/hPZTh9pj4twMi1wyFQvtq00DCTJC+1+cPjzaIZi3 j9EFSnBCt/Nsjx4z21SfRkqNlhB2o3a3L4xxyjNwx+8I/7rJ/On+ktW4NhXwzFORCD07 0NCNFs7T9pX973BHLqpW5TiIZ3nOTUn6fApyV+XE8G/vkSgT/gLFkjMyNjR7wVlqN51N eE0A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=OLexj8zcQ5CC/v1LHSDvGUCtQ5uU/xYrvCxnL4bHY7A=; fh=G/3clFhAZStyOPiTRRMnveewLEEd/sfJUzoTNSYU6cw=; b=zrNvMpyYVrvaAcEe3iQazqyBsga8kmFCnvAYmqPfIwoPsG8YiX8wrGr9Y/gIvifcMt YcZ3RB3xZFA3+RlKb5UM8Beg0/c0zEQ7KGwRj/9osdEKFecSn3BitrmdW7JzEkRq5EzI JDtjs18bGLOT9pSBCDuEiAXZZjqJFlIIKG7i9LVS3Q5IUzzshdVmUo71CXeQSDdIAD2j SGdWaR0mLE39SB2To2ZlbrqIaYVQiNIJpuxbYBdaZ4g3msWXiQimmSwPAqtOqWni+Mqy BhrEVV++/YU7bK3wdk7nBYDfk40wYL8vkmGeDNFHT4EbAGXhjPNWh94hGtCiziotnZ9F VIkA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qcMSEvh6; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-117420-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117420-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id s30-20020a05622a1a9e00b004311ddb94cbsi5579586qtc.404.2024.03.25.10.16.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 10:16:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-117420-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=@kernel.org header.s=k20201202 header.b=qcMSEvh6; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-117420-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117420-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 A0B271C39D9D for ; Mon, 25 Mar 2024 17:16:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2021F1487F9; Mon, 25 Mar 2024 15:56:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qcMSEvh6" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 350F410A39; Mon, 25 Mar 2024 15:56:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711382215; cv=none; b=GEkFybPFAN7z8NzgKwc0TjknBtg1/S46b384KysaXyxgCgU7IM2TESLNFCTakrFvZYvpk0nsZt03tPoCcTHy07V3i6eBQo3w/dgrEpus0JFHPAV03paOtcwO3a1yoK1hMqDopH2dQE7pgcLqmnZMuv4yDwmGmokFd+5pWyg9dCE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711382215; c=relaxed/simple; bh=ENDQ/e0q9PX0Cu5M/o6hx0CVqmsSUPAKQYjWkmXdgyw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Xtgxd6rn0QqJJ1PeEZUGHhmqZhpeLJ4BFmQ/CcXdegMYu+RLKawrC/EBdl6SdEvH9+QwkZb4Os63rp9LeOcAoG+zac8gxHAY7gYYXpwaq2ZK8wyB6VugkLbqrOM/VcGbfM74lE6C0hv7ewBdbNNqEXiMKNaAwEvY5J5lsdXvLXU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qcMSEvh6; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA093C433F1; Mon, 25 Mar 2024 15:56:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711382214; bh=ENDQ/e0q9PX0Cu5M/o6hx0CVqmsSUPAKQYjWkmXdgyw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=qcMSEvh6wLv5drqay/oxDcZ+vzz+1GCw0Q3n4gWaHMwTKnsG0cUZ7/bI90q2vE/av p6cyw0zqXIV8fzMYtCHudpFRcopl/3WeDp8449JCw0LyP4DDpUy+/6dKmmzjI5e5jU Rdb3Wfo4NUf2VlmA9ciXYrRiHD+XlGaO9gLIpmV1FHo1gjva2Mz9fgF9KlyJZldN2f bSeq6FJVHYQKzuzDjpdtwb5qpAz+3zk/FhfnE3aZfGtXEhXA6IhBs0mZeaReyf9tHN 6Ah7u0ksUVa+bzjSh5W6J3JO+LgU5innpV3/nBvqhIleCJjNxWroSNsMZISKuD8g// aFDT4lVjwF9BQ== Date: Mon, 25 Mar 2024 16:56:49 +0100 From: Benjamin Tissoires To: Hans de Goede Cc: Werner Sembach , 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 Subject: Re: In kernel virtual HID devices (was Future handling of complex RGB devices on Linux v3) Message-ID: 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Mar 25 2024, Hans de Goede wrote: > +Cc: Bentiss, Jiri > > Hi Werner, > > On 3/20/24 12:16 PM, Werner Sembach wrote: > > Hi Hans and the others, > > > > Am 22.02.24 um 14:14 schrieb Werner Sembach: > >> Hi, > >> > >> Thanks everyone for the exhaustive feedback. And at least this thread is a good comprehesive reference for the future ^^. > >> > >> To recap the hopefully final UAPI for complex RGB lighting devices: > >> > >> - By default there is a singular /sys/class/leds/* entry that treats the device as if it was a single zone RGB keyboard backlight with no special effects. > >> > >> - There is an accompanying misc device with the sysfs attributes "name", "device_type",? "firmware_version_string", "serial_number" for device identification and "use_leds_uapi" that defaults to 1. > >> > >> ??? - If set to 0 the?/sys/class/leds/* entry disappears. The driver should keep the last state the backlight was in active if possible. > >> > >> ??? - If set 1 it appears again. The driver should bring it back to a static 1 zone setting while avoiding flicker if possible. > >> > >> - If the device is not controllable by for example hidraw, the misc device might also implement additional ioctls or sysfs attributes to allow a more complex low level control for the keyboard backlight. This is will be a highly vendor specific UAPI. > > So in the OpenRGB issue thread https://learn.microsoft.com/en-us/windows-hardware/design/component-guidelines/dynamic-lighting-devices aka HID LampArray was mentioned. I did dismiss it because I thought that is only relevant for firmware, but I now stumbled upon the Virtual HID Framework (VHF) https://learn.microsoft.com/en-us/windows-hardware/drivers/hid/virtual-hid-framework--vhf- and now I wonder if an equivalent exists for Linux? A quick search did not yield any results for me. > > Oh, interesting. I did not know about the HID LampArray API. > > About your question about virtual HID devices, there is uHID, > but as the name suggests this allows userspace to emulate a HID > device. > > In your case you want to do the emulation in kernel so that you > can translate the proprietary WMI calls to something HID LampArray > compatible. > > I guess you could do this by defining your own HID transport driver, > like how e.g. the i2c-hid code defines 1 i2c-hid parent + 1 HID > "client" for each device which talks HID over i2c in the machine. > > Bentiss, Jiri, do you have any input on this. Would something like > that be acceptable to you (just based on the concept at least) ? I just read the thread, and I think I now understand a little bit what this request is :) IMO working with the HID LampArray is the way forward. So I would suggest to convert any non-HID RGB "LED display" that we are talking about as a HID LampArray device through `hid_allocate_device()` in the kernel. Basically what you are suggesting Hans. It's just that you don't need a formal transport layer, just a child device that happens to be HID. The next question IMO is: do we want the kernel to handle such machinery? Wouldn't it be simpler to just export the HID device and let userspace talk to it through hidraw, like what OpenRGB does? 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. 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