From nobody Tue Nov 24 12:36:04 2026 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795322143; b=YNVxsnyQAPUWipX4huXnpxDRbpxzdgKOgPEtu8LHLqRShtj+KJXVOJm3SCVWuCuhF246 D2imGkwTHNbCxIe5xZU6QVJy7Td6H6ynLNUIspy+gInKGWTbbHzG+ciWFjyBKmTkP0rne cUm0ngX2ocz0h96vn5DIBPo2hQ6icjid4kMGdyrGQKO9cL+BCTkwy0ZG/iRg//1dMw8bi bvekJDwHQxTLFsYXmeyHoMqpsSk/zU4ke/j4S6dtGT2XzasR20sahGAfr54iOx8v4241+ xHDlCT26r8yakH6hBX6keAYKxICqOswwF+0cDkOSbJBRNpY/2RbHUl5oq+qxGjiM5IQ== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795322143; h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version: Content-Type:Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=hDT/aECBwNbW2NyGACBkXyKf6xBKy+F1zx00muMQwYk=; b=MZyvpAJpSFwuTbZTL9fFBdZjLZbMwKSd73QOLKKzmeKo0gPiYGAPH/eMTR+XfBDr7YuO 4Yr/z7ZDe/GG23OOoiUNRIs3Upkv/zQIBPfUDWwiXSh9aITpSFsRUAucXldhFZA9RvF9+ 2os9g7NdmuFZawH1Kd47fd5H0p8RKjAwqj8xYS6HXixlbiulALgGljDTLdeqna4sYzyXf pPFuuUMhWm92MinHt2dQFuM1tYhTZoAnuWRttqez4ntJsa95DVi5hiFt/Wmf8QSGNyDvk FDj35kcogEGQljghMR+dhq8130a2PKWU7qU1BHYEzk2N4t191Sug1aI8ou9Abx8HcBw== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=lyafLCx9; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8C40D606A32A; Sun, 22 Nov 2026 04:35:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=lyafLCx9 Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1795322143; b=B4j4WMZIlOCuFk7fde5NWU8ou5jZFQJoaNlaD7JcfGyuBLohgVDg1SHpgTr5pXFAv5Ut 6G2DHvI2SltWHSYDGpaJ9zQwJkWlfVC8nwzywk8oBBROrRS0cLUpn8KiHRCUkWJcRUSCy 81HbLis0WiPAB6cegPv1n+qc56DFZjSi3RLev1E+0SRvGdqzifAjUNb11TNhJagehdk0v Vr/jLn+VpFDr0HI6u3uYZnKsTfRv8So6AtPhBlF3Kv01vclrjfI59qSBC8shISj37xe+y tv1HqriWxA6L3D/6vFrDtseEdq7tP9w7VFKdSP6KBNIyQdAWDdq1ZvyhUqcujU9jCFA== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1795322143; h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=hDT/aECBwNbW2NyGACBkXyKf6xBKy+F1zx00muMQwYk=; b=EH4J8jK6o6I5Swfys09n7YnZHgSaeo9O4qFe3ZpFDFm4b0LVHO28lCuZgBe2fRmeI7dx lTPTCVzpb2qWmkGp6cwMr9p6j1sNH/bQ/iLUM5v57vTteWAqGOyj3Y6a+xcv8XhsvV9eW lo0l7DO6TrkZHyCzUJp31MfZWIoFJmenr2a5fTCgUv/TIUTPUXnrK2arFO04yVWUcxh2j t6aSN7Uxvx2pyR1l+Y1BHuHtnShtEXtuAZTZb265+r68XofD211zaKkTA4KmHXsZePBUo c/zrTggyX057rq/xnEwTisglrugt7rG4pHGDTaHoPRidAzwAWU/ZAbHeoy7scCdt59A== ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id 8CCA61F000C6; Sun, 22 Nov 2026 04:35:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795322143; bh=hDT/aECBwNbW2NyGACBkXyKf6xBKy+F1zx00muMQwYk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=lyafLCx9VdmFPDGV06vNOjyFIG/zP2a04VGJTajolsDiXcFaxJxmvo6AjkfBUmleo TSeQPly3kbS8qw2q8RKo40bZvFH5j3SOQpysHm54RbdW3CyHsoORGUKsfNz6BwqvCS dELTPwGI6rktaYOK0/R+M282MizdVU10sdEe+zLpVhZqPzNEe1Tv/eLl66zqJLjq+n 6cHk4ETeMZ4Bgp4zP+6MTQdre0d5w6zYnRekkpn4CcuzfKGNicKRemt9TlwCSHwqe+ i3xFJzbe7JctHBwPUJB6qVHEGTvSJedCzpcQEyAWymyhsyb1/hwMpQoM11JOVvioKE Wj7CS3rnMB4VQ== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 0FD594BEEE; Sun, 22 Nov 2026 04:35:42 +0000 (UTC) From: Nick Dowsett via B4 Relay Date: Sun, 22 Nov 2026 12:35:38 +0800 Subject: [PATCH 1/4] platform/x86: clevo-laptop: add minimal WMI driver skeleton and Kbuild plumbing X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Message-Id: <20261122-clevo-laptop-v1-1-881debf4d4b0@gmail.com> References: <20261122-clevo-laptop-v1-0-881debf4d4b0@gmail.com> In-Reply-To: <20261122-clevo-laptop-v1-0-881debf4d4b0@gmail.com> To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Miguel Ojeda , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Daniel Almeida , Tamir Duberstein , Alexandre Courbot , =?utf-8?q?Onur_=C3=96zkan?= Cc: Armin Wolf , Werner Sembach , linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, rust-for-linux@vger.kernel.org, Nick Dowsett X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1795322140; l=4849; i=nick42d@gmail.com; h=from:subject:message-id; bh=e9AdSz41EP3ywu8H4Pe835LANDmSykHvhG+wsu9VTm0=; b=anPBWXAgeDelXVKsG1nyDfq5seJYrlBDPkqh3KwKnpA+NHh8NhWsZkOp8Ma8DT8s/zy84t9RA rOGeCqw3QfpCihA5a8gVD9q+r1aJgvG9SSAbJGB4mhukqD3/VjtEWSA X-Developer-Key: i=nick42d@gmail.com; a=ed25519; pk=1uIkNexEofzEXNN3Y3QW5z8IrgjWaP0yH6Es51jxWOg= X-Endpoint-Received: by B4 Relay for nick42d@gmail.com/default with auth_id=1596 X-Original-From: Nick Dowsett Reply-To: nick42d@gmail.com Content-Transfer-Encoding: quoted-printable From: Nick Dowsett - Add `drivers/platform/x86/clevo-laptop.rs` with module implementation, DMI board check, and Driver registration. - Add Kconfig and MAINTAINERS entries and Makefile wiring. Signed-off-by: Nick Dowsett --- MAINTAINERS | 6 +++ drivers/platform/x86/Kconfig | 17 +++++++++ drivers/platform/x86/Makefile | 3 ++ drivers/platform/x86/clevo-laptop.rs | 72 ++++++++++++++++++++++++++++++++= ++++ 4 files changed, 98 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 44540a1eb2b8..1130c293e84d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6566,6 +6566,12 @@ F: scripts/Makefile.clang F: scripts/clang-tools/ K: \b(?i:clang|llvm)\b =20 +CLEVO LAPTOP DRIVER +M: Nick Dowsett +L: platform-driver-x86@vger.kernel.org +S: Maintained +F: drivers/platform/x86/clevo-laptop.rs + CLK API M: Russell King L: linux-clk@vger.kernel.org diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig index 9ce384e0475e..18aa4550c9f4 100644 --- a/drivers/platform/x86/Kconfig +++ b/drivers/platform/x86/Kconfig @@ -1059,6 +1059,23 @@ config OXP_EC =20 source "drivers/platform/x86/tuxedo/Kconfig" =20 +config CLEVO_LAPTOP + tristate "Clevo Laptop Platform Driver" + depends on RUST + depends on ACPI_WMI=3Dy + depends on DMI + depends on LEDS_CLASS + help + This driver provides platform support for Clevo barebones and + rebranded laptops (Tuxedo, Metabox, Sager, XMG, etc.). + Currently only Clevo NLx0AU boards (e.g. Metabox Edge NL57AU) + with a 5-step white keyboard backlight are supported over WMI. + It is intended to be extended with additional Clevo models and + EC features over time. + + To compile this driver as a module, choose M here: the module + will be called clevo-laptop. + endif # X86_PLATFORM_DEVICES =20 config P2SB diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile index 229057234d00..070af05a2064 100644 --- a/drivers/platform/x86/Makefile +++ b/drivers/platform/x86/Makefile @@ -158,6 +158,9 @@ obj-$(CONFIG_SILICOM_PLATFORM) +=3D silicom-platform.o # TUXEDO obj-y +=3D tuxedo/ =20 +# Clevo +obj-$(CONFIG_CLEVO_LAPTOP) +=3D clevo-laptop.o + # Winmate obj-$(CONFIG_WINMATE_FM07_KEYS) +=3D winmate-fm07-keys.o =20 diff --git a/drivers/platform/x86/clevo-laptop.rs b/drivers/platform/x86/cl= evo-laptop.rs new file mode 100644 index 000000000000..1d862c57b3fe --- /dev/null +++ b/drivers/platform/x86/clevo-laptop.rs @@ -0,0 +1,72 @@ +// SPDX-License-Identifier: GPL-2.0 + +//! Clevo Laptop Driver. +//! +//! Currently supports only the 5-step white keyboard backlight on Clevo +//! NLx0AU boards (e.g., Metabox Edge NL57AU). +//! +//! Copyright (C) 2026 Nick Dowsett . +//! +//! Inspired by Tuxedo Computers' drivers. + +use kernel::{ + device, + dmi, + prelude::*, + wmi, // +}; + +/// # Note +/// +/// This GUID is non-unique (shared by Uniwill for example) and cannot be = trusted +/// to uniquely identify a Clevo device. +const CLEVO_WMI_METHOD_GUID: &CStr =3D c"ABBC0F6D-8EA1-11D1-00A0-C90629100= 000"; +/// DMI board name allowlist, restricted to tested boards since the WMI GU= ID is not +/// unique. +const SUPPORTED_BOARDS: &[&CStr] =3D &[c"NLx0AU"]; + +module! { + type: ClevoLaptopModule, + name: "clevo-laptop", + authors: ["Nick Dowsett "], + description: "Clevo Laptop Driver (Keyboard Backlight)", + license: "GPL", +} + +/// RAII guard for Clevo Laptop Module holding all subsystem drivers e.g W= MI. +#[pin_data] +struct ClevoLaptopModule { + #[pin] + _wmi_driver: wmi::Registration, +} + +impl kernel::InPlaceModule for ClevoLaptopModule { + fn init(module: &'static ThisModule) -> impl PinInit { + pin_init::pin_init_scope(move || { + if dmi::get_system_info(dmi::Field::BoardName) + .is_none_or(|board| !SUPPORTED_BOARDS.contains(&board)) + { + return Err(ENODEV); + } + Ok(try_pin_init!(Self { + _wmi_driver <- wmi::Registration::new(c"clevo-laptop", mod= ule), + })) + }) + } +} + +/// RAII guard for Clevo WMI driver holding all subsystem devices e.g LED = device. +#[pin_data] +struct WmiDriver {} + +kernel::wmi_device_table!(WMI_TABLE, [wmi::DeviceId::new(CLEVO_WMI_METHOD_= GUID)]); + +impl wmi::Driver for WmiDriver { + type Data<'bound> =3D WmiDriver; + const ID_TABLE: wmi::IdTable =3D &WMI_TABLE; + fn probe<'bound>( + _dev: &'bound wmi::Device>, + ) -> impl PinInit, Error> + 'bound { + try_pin_init!(WmiDriver {}) + } +} --=20 2.56.1 From nobody Tue Nov 24 12:36:04 2026 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795322144; b=FXfJVAx7SWRPhSkM/9cz3g4+D77hqYH9+JIWAERjvHwSf1/26U+qzKKBT/PH4umfZJzn eUgp1XHKIEarhwQl6yQDiwrfUu87MYbXWBJ/snN9/otj02kmSkNks9EyhmtGTwAZYubcJ gVH3JT8tCTZPt+omWFcA8NaxFrWeLdxflhkdn74zW9BRUxy031mrFexbJJdIEaO/7rAim 3crkO3nu9fbg53B106JjKHDtFrpDIJ9OGHLKcrJ8wE6jVtjsN9F31eaHFsfEecCEBgubE eclOzF+Fwi8nfXWkOmj/+4HmIEycN4HkyPL5ilHtdamSZGjszZFC5zdZPj9BwZrvhSw== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795322144; h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version: Content-Type:Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=nM5RZAWXXxV7flnIrsp6Ya4aRfvKlk/fkxnnJrnt4pQ=; b=ODF4qOy1nyiFYZBW7hZd8ZZHEV/C+c7VJOMOnmzKjUqSR/vQ4FsPG2ByaGZPBWPLoan8 dIid84HJ11SCv80qnTDPcGDQL4h2klvYQpklKknGDs3+3Z3WSKvr+Aoz2bUZf0cFRl8rp sYwRhMSJnge5JAlMn2spyimZ1eBuif4yJbAyjHaEHCxrFuV4AOMZrxlvFxXc5trtE9Qzq f5jJ5Rd8onUfpGeo3rU157aYZ0HsBimsu/MyFkRq6d4GqROuwUud+/VI0SvOiy2/8nbPz h5OUdRBhULps6obVu5b/51yRgk54T1GMj+81ntkmUO3yR2K8iNkZNnhmzY5Gz2ejsAQ== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=R3Pr00vU; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E369606A686; Sun, 22 Nov 2026 04:35:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=R3Pr00vU Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1795322144; b=VJwO6gp058k7vtqKOm9mvJGitPOANyMoHvNSV61p7E5BeAzCvj5qjmA3MYoM8a6ACsET KDc26lpwvbL+zq1Lz0KcwrvUP5BpL+V1uZSemmHUjQs74dvMH2JhHcFLCht4d5ycKSmIF usjQca1gL1BPeGzv8wuMWb4ksF0+CWcjBicK4iEVXHPj/EBnu4+YYTxuYqPBmFFyTiEdP a7TedpXtIojshDlckgs/K2AOyDXTggBdl+aQqx3p5bS4dCufHwJwrHmqOlGpinE8kGMYd tjmcQJ8iiOxPxjWIt3bviUPGpPlbE4MtA8swyE6IGsiNan4fx7ThMJwO4/xVSfYrZCg== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1795322144; h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=nM5RZAWXXxV7flnIrsp6Ya4aRfvKlk/fkxnnJrnt4pQ=; b=2PFFw4IpvoZtIuWMHJtW8A/uPLWb4dyPa8IWWGH3fRokfxcwAQtrR1rWS/jzlL8zJXuN nkXapXVhacIt6alRmIeRzOQT3+FudC5jA2GrqBQVKwUhZpQZGlxUhwCV730C9p0SLGreh Ht20XHwHdoaMMf4VKHEEdlYUw97wVg7p6bSIw2yxQJRnv2Wm3+XOXyiqfJDu08192gfFL Iw3jSNTxeU6V8obUy0WocJleRv8v94lfHKZDFyymNr2pryA5rqNZiE7fnAS99kKbVtimW 0YcoKv1C6zr6NoGHh2hkLKqmgE+yQIQBZc53Xw4ZfnNVur/uj+BBY7PVK+Uv0zeWxXA== ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id 9CBB01F000C0; Sun, 22 Nov 2026 04:35:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795322144; bh=nM5RZAWXXxV7flnIrsp6Ya4aRfvKlk/fkxnnJrnt4pQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=R3Pr00vUeishvthCtC8ioAQNOvBX9mS7bdrrMoizy0KNGzorAVdTBrqdvPoqwn9GP TDO1SokmNgKuHcUhmnm6jtfKRPtj2859aMeHyTu0ep+gsoLNN6S3eRdROfNX8Clcx0 kXIFl5Ql79ekEcl7RGlw4SNMATnpwOrjFKz6Sh6YRNO1Zq2ens3K0ddRQ/kSEhifNb 5AyGgEFsNJDC91JBSU2/ELN4vYAH1rbAqmOALsRQW0hYMqpWC38EdsF9mQAOO1ZDfr ZEUKD1uB9GWzTc0Xf+iNC+zxCryNOmVfe3bwflycchVLDWYfdWj83ZcKrDpKogWKJ9 BUZYU9tVBKQtQ== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 2A6EC4BEFF; Sun, 22 Nov 2026 04:35:42 +0000 (UTC) From: Nick Dowsett via B4 Relay Date: Sun, 22 Nov 2026 12:35:39 +0800 Subject: [PATCH 2/4] platform/x86: clevo-laptop: add EC WMI query interface and BIOS feature check X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Message-Id: <20261122-clevo-laptop-v1-2-881debf4d4b0@gmail.com> References: <20261122-clevo-laptop-v1-0-881debf4d4b0@gmail.com> In-Reply-To: <20261122-clevo-laptop-v1-0-881debf4d4b0@gmail.com> To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Miguel Ojeda , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Daniel Almeida , Tamir Duberstein , Alexandre Courbot , =?utf-8?q?Onur_=C3=96zkan?= Cc: Armin Wolf , Werner Sembach , linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, rust-for-linux@vger.kernel.org, Nick Dowsett X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1795322140; l=4496; i=nick42d@gmail.com; h=from:subject:message-id; bh=EPKNfrbkINZpqJuaFZ3pMA8YKpq/n10Zk87rakX3Q7k=; b=uw5Rn7jXoU00duppx5D21qAg0OfXBZjgW/qqa3ysThTq2dLQVxjgnkts4rkrqLMNvu8HujExs MFeKLSOZXTPBbJFihKx83xSn1X2mvk3RXgEHKsxxww0LQCSu/6jWl0c X-Developer-Key: i=nick42d@gmail.com; a=ed25519; pk=1uIkNexEofzEXNN3Y3QW5z8IrgjWaP0yH6Es51jxWOg= X-Endpoint-Received: by B4 Relay for nick42d@gmail.com/default with auth_id=1596 X-Original-From: Nick Dowsett Reply-To: nick42d@gmail.com Content-Transfer-Encoding: quoted-printable From: Nick Dowsett - Add `EcQuery` trait and implement `EcInterface` for sending commands to the Clevo EC over WMI. - Add `GetBiosFeatures1` query to verify the EC responds during probe. Signed-off-by: Nick Dowsett --- drivers/platform/x86/clevo-laptop.rs | 104 +++++++++++++++++++++++++++++++= +++- 1 file changed, 102 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/clevo-laptop.rs b/drivers/platform/x86/cl= evo-laptop.rs index 1d862c57b3fe..289b30c478ec 100644 --- a/drivers/platform/x86/clevo-laptop.rs +++ b/drivers/platform/x86/clevo-laptop.rs @@ -24,6 +24,8 @@ /// DMI board name allowlist, restricted to tested boards since the WMI GU= ID is not /// unique. const SUPPORTED_BOARDS: &[&CStr] =3D &[c"NLx0AU"]; +const CLEVO_EC_CMD_GET_BIOS_FEATURES_1: u8 =3D 0x52; +const CLEVO_EC_WMI_INSTANCE: u8 =3D 0; =20 module! { type: ClevoLaptopModule, @@ -33,6 +35,21 @@ license: "GPL", } =20 +/// Represents a query that can run on the Clevo Embedded Controller (EC). +/// +/// # Endianness note +/// Clevo EC sends and receives little endian data. +/// As this is a `platform/x86` driver, no conversion is required. +trait EcQuery { + type Output; + /// EC method code. + fn cmd(&self) -> u8; + /// EC method args. + fn args(&self) -> EcMethodArgs; + /// Each command must know how to deserialize itself from the raw EC o= utput. + fn deserialize_output(output: &[u8]) -> Result; +} + /// RAII guard for Clevo Laptop Module holding all subsystem drivers e.g W= MI. #[pin_data] struct ClevoLaptopModule { @@ -65,8 +82,91 @@ impl wmi::Driver for WmiDriver { type Data<'bound> =3D WmiDriver; const ID_TABLE: wmi::IdTable =3D &WMI_TABLE; fn probe<'bound>( - _dev: &'bound wmi::Device>, + dev: &'bound wmi::Device>, ) -> impl PinInit, Error> + 'bound { - try_pin_init!(WmiDriver {}) + pin_init::pin_init_scope(move || { + let backend =3D EcInterface::Wmi(dev); + + backend.query(GetBiosFeatures1).map_err(|_| ENODEV)?; + + Ok(try_pin_init!(WmiDriver {})) + }) + } +} + +/// Interface to Clevo Embedded Controller. +enum EcInterface<'a> { + Wmi(&'a wmi::Device), +} +impl<'a> EcInterface<'a> { + /// Send a query to the EC, receiving a response. + fn query(&self, query: Q) -> Result + where + Q: EcQuery + core::fmt::Debug, + Q::Output: core::fmt::Debug, + { + let cmd =3D query.cmd(); + let arg =3D query.args(); + + match self { + Self::Wmi(wdev) =3D> { + dev_dbg!( + wdev.as_ref(), + "ec cmd {query:?} method_id 0x{cmd:02x} arg {arg:x?}\n" + ); + let buf =3D wdev.invoke_method( + CLEVO_EC_WMI_INSTANCE, + cmd.into(), + arg.as_bytes(), + core::mem::size_of::(), + )?; + + let res =3D Q::deserialize_output(&buf)?; + dev_dbg!(wdev.as_ref(), "ec cmd {query:?} -> {res:?}\n"); + Ok(res) + } + } } } + +/// Args for a command sent to the EC. +#[derive(Debug)] +enum EcMethodArgs { + Scalar(u32), +} +impl EcMethodArgs { + /// Convert to the type expected by the EC. + fn as_bytes(&self) -> &[u8] { + match self { + // Clevo EC expects little-endian integers; x86 is always litt= le-endian. + Self::Scalar(val) =3D> val.as_bytes(), + } + } +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +struct GetBiosFeatures1; + +impl EcQuery for GetBiosFeatures1 { + type Output =3D BiosFeatures1; + fn cmd(&self) -> u8 { + CLEVO_EC_CMD_GET_BIOS_FEATURES_1 + } + fn args(&self) -> EcMethodArgs { + EcMethodArgs::Scalar(0) + } + fn deserialize_output(output: &[u8]) -> Result { + let (feat, _) =3D BiosFeatures1::read_from_prefix(output).map_err(= |_| ENODATA)?; + if feat =3D=3D BiosFeatures1::INVALID { + return Err(ENODEV); + } + Ok(feat) + } +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq, FromBytes)] +struct BiosFeatures1(u32); + +impl BiosFeatures1 { + const INVALID: Self =3D Self(0xFFFF_FFFF); +} --=20 2.56.1 From nobody Tue Nov 24 12:36:04 2026 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795322144; b=Pehot08C+e1hxaozXN9a4G6lT0GAqdYP9a7qgvyg4Kx3D9REflfZcxCubrG68va9UwV/ AHXn9cyvIW70Ig2po+P8jngNPuoNBqOeV50R5souzsa6HjiLizoS96YHbCd9KM3ckS2uo dM6hCXsXDEksiV2IRXEqrnLvrCr424I5pbQLq7hvU7t3OO0E/0WCVtG8F1BbXrL9i3Zwf rwLsAHD3tPMytZUPLhfVnVmXI2XAYYBcjV04yRMG+ADEXJ7pf942Uhkp2ly55+d26DQ/v i4WG/BxA2Fxpp15a72hHTNI9vcwf1B4yC09BznRSjQcVkD66CtkMfyo2Cxc/obhHFnQ== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795322144; h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version: Content-Type:Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=6w1KSDkRJhlso48nKJo/NCKPKTEqmQ7kzzIZEMGYM1I=; b=btO1DHpRC5Izm+nq5tE8iSLSN3vC98bpHqQtmqPgdeyWMKlSfwtCfaSZp1l0WPimwf/y DTtPvOJ7xdrV/N1x7ae8x1ri1OWgwtJUYpAoxlS0YMiiPFlhxPttsWbyyLAz2pgiWQY+9 r8w3vgYDA5VoT/hms7kMZcFlbc3rZX8rFP4EukbsTf8NY/0NGVzZh6yZyBAsRqmj4OnVL M11gmzGPTFMnzM5pIpWh6svXhJsJoKeUNIY1F0SSdbHtw3V90U284D7M9bhH5ClutqLQ6 +/SQ1TX/h+p8b6nfndQrEBYdoltgHHwumfB4l6Ttp0ImBT45d6PE72IGHQmKh3IQUtw== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JJ6J0RPC; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C5662606A695; Sun, 22 Nov 2026 04:35:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JJ6J0RPC Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1795322144; b=qRB3SnO976tTMBjGppYAD1V1i69UI5OO6FckXXGWg00+F+G+k7LxvKW1rKLmLCGw52h+ JGUZKErhdNppT2Oo342dLRBGbqrvpnGdk8p9zpsJXQjVkyzWLS95bIzGOK3gHnVpeG8hE MgN0kiDJIEucPaH2k4L6jLbJTgmV0l9rtHZ445R4D85nioDiJRmOP3w/GwqwBw+0oMoIi 9d+gMbsAi9sfKW6eGU7Vefd0OiBUDDc+mMc6FG786uewDiCpW3nPjtV0ANmGOhTtxM5hF Dk5JWReb5kWULE9a3C56GsWeiBli6awYW7bLAO5Ii7UGDYCMD2ukaePU6Pfrx/8iovw== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1795322144; h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=6w1KSDkRJhlso48nKJo/NCKPKTEqmQ7kzzIZEMGYM1I=; b=kgdBZyquGKJQW6UsWOGl4QvSxQlmvkJBbimw71TeYeBb23ZsXH9lad0y2HDeXMek5rJb MujHqUtfklppES2Rhlz2AsPYz3N4WvhDEVKRgZwY2ei+vCrNUaYqZLEsaqm9Fj8bRPM2t YOuQkoRa0dkE3kG+jyGE0N27FhntbVUi52N2EXqQcXVu6PzH4nA48w+A+kteSkUvjjF3k YgLN1gWyPR/0sMMNlge34c3c2G9nkQT2unfjpazBSoFHcZK+9mSt1vxaqFPFi3xDE83ii 75ZAwjxc/ZoQ8FtJwJXRN9Uqr2hcsJPH9781wBApNZfjyOdcC+UaIkkOYeqES+CvQ1A== ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id B96921F000C4; Sun, 22 Nov 2026 04:35:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795322144; bh=6w1KSDkRJhlso48nKJo/NCKPKTEqmQ7kzzIZEMGYM1I=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=JJ6J0RPCNC89lA72ejLOujbNO+KkgnS7o8khwTH+3atP+nqBqqxKxPdCz0Mu5YZQO eAJ8VWJha1PyBfkMq1I4J3MdO12JNa8YlK8GZJipsoqxux6JMacR1MX5ZbwW+o5cQf qnNQeHty0R2aEf6OZ52muSLxKuY+q0oJ8Q0/Ulq3BNVru9CXfra4Bh/G8hyWw+vh/1 ZGNud3btzo1Olfei5AkKUamkcQBq71FzHEAS37ialzFUnphez4wywITpWQba5OXrjH vNRxD88yR/xAUblSgswH6EriJZSLZ8l96RL2Sz24gulXJ/znTuPjQ8VgBFmpU/IXUC ggO88xGcK87gQ== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 471C84BF03; Sun, 22 Nov 2026 04:35:42 +0000 (UTC) From: Nick Dowsett via B4 Relay Date: Sun, 22 Nov 2026 12:35:40 +0800 Subject: [PATCH 3/4] platform/x86: clevo-laptop: probe keyboard backlight type and detect 5-step white backlight X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Message-Id: <20261122-clevo-laptop-v1-3-881debf4d4b0@gmail.com> References: <20261122-clevo-laptop-v1-0-881debf4d4b0@gmail.com> In-Reply-To: <20261122-clevo-laptop-v1-0-881debf4d4b0@gmail.com> To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Miguel Ojeda , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Daniel Almeida , Tamir Duberstein , Alexandre Courbot , =?utf-8?q?Onur_=C3=96zkan?= Cc: Armin Wolf , Werner Sembach , linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, rust-for-linux@vger.kernel.org, Nick Dowsett X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1795322140; l=6319; i=nick42d@gmail.com; h=from:subject:message-id; bh=zhmmGSNR3OSLrzhCCRTFeuk7Hl8QAWk96pymxiIpueQ=; b=yvR0HYD40/ncdu8Rn5vvHwCpW32+HFnym+lcwVUt/kQXf8VZqAtjZ/zw+rWOd5Q9J8uHsgisK 23wRgPoV2+YDpdkCiVYPzx0Bzf6TkwdzJy0afKrKMCGMniDJIrPfdyd X-Developer-Key: i=nick42d@gmail.com; a=ed25519; pk=1uIkNexEofzEXNN3Y3QW5z8IrgjWaP0yH6Es51jxWOg= X-Endpoint-Received: by B4 Relay for nick42d@gmail.com/default with auth_id=1596 X-Original-From: Nick Dowsett Reply-To: nick42d@gmail.com Content-Transfer-Encoding: quoted-printable From: Nick Dowsett - Add `GetSpecs` and `GetBiosFeatures2` EC queries and `KbBacklightType` detection (with retries and BIOS features fallback for older devices). - Restrict probe to the supported 5-step white keyboard backlight. Signed-off-by: Nick Dowsett --- drivers/platform/x86/clevo-laptop.rs | 125 +++++++++++++++++++++++++++++++= ++++ 1 file changed, 125 insertions(+) diff --git a/drivers/platform/x86/clevo-laptop.rs b/drivers/platform/x86/cl= evo-laptop.rs index 289b30c478ec..6f08bf295c07 100644 --- a/drivers/platform/x86/clevo-laptop.rs +++ b/drivers/platform/x86/clevo-laptop.rs @@ -13,6 +13,10 @@ device, dmi, prelude::*, + time::{ + delay::fsleep, + Delta, // + }, wmi, // }; =20 @@ -24,7 +28,12 @@ /// DMI board name allowlist, restricted to tested boards since the WMI GU= ID is not /// unique. const SUPPORTED_BOARDS: &[&CStr] =3D &[c"NLx0AU"]; +const CLEVO_EC_CMD_GET_SPECS: u8 =3D 0x0D; const CLEVO_EC_CMD_GET_BIOS_FEATURES_1: u8 =3D 0x52; +const CLEVO_EC_CMD_GET_BIOS_FEATURES_2: u8 =3D 0x7A; +const CLEVO_BIOS_FEATURE_CODE_WHITE_ONLY_KB: u32 =3D 0x4000_0000; +const CLEVO_BIOS_FEATURE_CODE_3_ZONE_RGB_KB: u32 =3D 0x0040_0000; +const CLEVO_BIOS_FEATURE_CODE_WHITE_ONLY_KB_MAX_5: u32 =3D 0x4000; const CLEVO_EC_WMI_INSTANCE: u8 =3D 0; =20 module! { @@ -89,6 +98,17 @@ fn probe<'bound>( =20 backend.query(GetBiosFeatures1).map_err(|_| ENODEV)?; =20 + // MVP: Only the NL57AU 5-step white backlight is supported. + if backend.detect_backlight_type()? !=3D Some(KbBacklightType:= :FixedColor) { + return Err(ENODEV); + } + let has_white_5 =3D backend + .query(GetBiosFeatures2) + .is_ok_and(|feat2| feat2.has_white_only_kb_max_5()); + if !has_white_5 { + return Err(ENODEV); + } + Ok(try_pin_init!(WmiDriver {})) }) } @@ -127,6 +147,61 @@ fn query(&self, query: Q) -> Result } } } + /// Detect backlight type e.g white. + fn detect_backlight_type(&self) -> Result> { + const MAX_RETRIES: usize =3D 3; + const RETRY_SLEEP_DURATION: Delta =3D Delta::from_millis(50); + + for attempt in 0..MAX_RETRIES { + if attempt !=3D 0 { + pr_debug!( + "KbBacklightType::None probably wrong, retrying - atte= mpt {} of {}\n", + attempt, + MAX_RETRIES - 1 + ); + fsleep(RETRY_SLEEP_DURATION); + } + if let Ok(specs) =3D self.query(GetSpecs) { + let backlight_type =3D specs.kb_backlight_type(); + if backlight_type !=3D Ok(None) { + return backlight_type.map_err(|_| ENODEV); + } + } + } + + // Check for devices <=3D Intel 8th gen (only white only, 3 zone R= GB, + // or no backlight on these devices) + let feat1 =3D self.query(GetBiosFeatures1).map_err(|_| ENODEV)?; + if feat1.has_3_zone_rgb_kb() { + Ok(Some(KbBacklightType::ThreeZoneRgb)) + } else if feat1.has_white_only_kb() { + Ok(Some(KbBacklightType::FixedColor)) + } else { + Ok(None) + } + } +} + +/// Keyboard backlight type - e.g Fixed Color +#[derive(PartialEq)] +#[repr(u8)] +enum KbBacklightType { + FixedColor =3D 0x01, + ThreeZoneRgb =3D 0x02, + OneZoneRgb =3D 0x06, + PerKeyRgb =3D 0xF3, +} +impl KbBacklightType { + const fn from_raw(raw: u8) -> Result, u8> { + match raw { + 0x01 =3D> Ok(Some(KbBacklightType::FixedColor)), + 0x02 =3D> Ok(Some(KbBacklightType::ThreeZoneRgb)), + 0x06 =3D> Ok(Some(KbBacklightType::OneZoneRgb)), + 0xF3 =3D> Ok(Some(KbBacklightType::PerKeyRgb)), + 0x00 =3D> Ok(None), + other =3D> Err(other), + } + } } =20 /// Args for a command sent to the EC. @@ -144,8 +219,12 @@ fn as_bytes(&self) -> &[u8] { } } =20 +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +struct GetSpecs; #[derive(Debug, Clone, Copy, PartialEq, Eq)] struct GetBiosFeatures1; +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +struct GetBiosFeatures2; =20 impl EcQuery for GetBiosFeatures1 { type Output =3D BiosFeatures1; @@ -163,10 +242,56 @@ fn deserialize_output(output: &[u8]) -> Result { Ok(feat) } } +impl EcQuery for GetBiosFeatures2 { + type Output =3D BiosFeatures2; + fn cmd(&self) -> u8 { + CLEVO_EC_CMD_GET_BIOS_FEATURES_2 + } + fn args(&self) -> EcMethodArgs { + EcMethodArgs::Scalar(0) + } + fn deserialize_output(output: &[u8]) -> Result { + let (feat, _) =3D BiosFeatures2::read_from_prefix(output).map_err(= |_| ENODATA)?; + Ok(feat) + } +} +impl EcQuery for GetSpecs { + type Output =3D Specs; + fn cmd(&self) -> u8 { + CLEVO_EC_CMD_GET_SPECS + } + fn args(&self) -> EcMethodArgs { + EcMethodArgs::Scalar(0) + } + fn deserialize_output(output: &[u8]) -> Result { + let (specs, _) =3D Specs::read_from_prefix(output).map_err(|_| ENO= DATA)?; + Ok(specs) + } +} =20 #[derive(Debug, Clone, Copy, PartialEq, Eq, FromBytes)] struct BiosFeatures1(u32); +#[derive(Debug, Clone, Copy, PartialEq, Eq, FromBytes)] +struct BiosFeatures2(u32); +#[derive(Debug, Clone, Copy, PartialEq, Eq, FromBytes)] +struct Specs([u8; 16]); =20 impl BiosFeatures1 { const INVALID: Self =3D Self(0xFFFF_FFFF); + const fn has_white_only_kb(self) -> bool { + (self.0 & CLEVO_BIOS_FEATURE_CODE_WHITE_ONLY_KB) !=3D 0 + } + const fn has_3_zone_rgb_kb(self) -> bool { + (self.0 & CLEVO_BIOS_FEATURE_CODE_3_ZONE_RGB_KB) !=3D 0 + } +} +impl BiosFeatures2 { + const fn has_white_only_kb_max_5(self) -> bool { + (self.0 & CLEVO_BIOS_FEATURE_CODE_WHITE_ONLY_KB_MAX_5) !=3D 0 + } +} +impl Specs { + const fn kb_backlight_type(&self) -> Result, u= 8> { + KbBacklightType::from_raw(self.0[0x0F]) + } } --=20 2.56.1 From nobody Tue Nov 24 12:36:04 2026 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795322144; b=S+4bCIyChh1WLh7aBUu8mqJDjRQXyV90JHlnv8qB8LeGFjlyxLw4GL64SGs3PFnlVwIB nyL5AseRIPi4Osyt2MY9DO8vPoMRGyAcaX7M++IihsxXcJDpdDdhmyy7qt3nWLhNO0NiZ TN3NUtsLkBjgW2mcYs9mmfeyluTS7B85sdWZfQTbgAvhzcGeOjE4cK0T8ThrpH+aOMhIi aKPZRBGd6QHvQ6BpH09z5Q2btaU6mwZZTH2c3Fsb/s4WE6SXLkIBCLm9lXD6kCswEdY+n pOe3tC3BToEBZ1xs4FXTho4vpj/pDPptZ/Si8fkVDz/nSbyJ7aJijYvboXKd8Zr6/sg== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795322144; h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version: Content-Type:Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=TEYgMxyx8vm22/gG+DhD0gLFIDLxgxoL7k4osD5HL1U=; b=RXj2x4pZEHv8md0IiyyjRjP3GUjkGMrcFjMGUKbBZFfLSKbUJcyL13+LsL5j8KQdh+L4 hRUx0Sx/jSOWBpDoRUc1QtzdbJO/56k9hhreD5tmrUJRdj5cbr/NCE1aJesvQWvodksWd XB2kdg/rhhNeUC1E25Vh6E6j4ZYjvoLhljtdpx2kUjyNn5XyWhxyqdrZ0JNsS1jpR3ZLS U3xFjh2Tj/+k519W2bCutePU057Zh+9UhHxHuBq+u05ClOdI4b49EXFIGei/5Rqwb0rKz kSPEuDQ9jIA4dnVG2ENK3ayKcZJwtXOSlJYxAJn2IKrFH9A8X2pkHuX/Ds9Lyocm6dw== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ZK7ZHEue; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E2C1606A685; Sun, 22 Nov 2026 04:35:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ZK7ZHEue Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1795322144; b=u4SbeDlPffFDQLgE4XNMlKNsWWAKb6c54D5Nx7gqnHJbeWMUh0Bl/lewbMpb5x/DbJhT RmjeKvuviH+1dIzBrkCgotjw25D3raKCwiKElaCXHOEVbEWGQwiMXkLPT54mAy70mY+2u B1i5qFRbwGu3dPivPx55bEOompGveMe4tjWG1QagDV7b3LcOwcXGDvJw731kJP4NZyr8h M2itODc7ZbcBeC6Wqy4rdLQ1Z+DKbyMoASGoBcbTJDBMXG40Lc0PxDdiNdXeo0qrqstU4 1uC8MwJnPYmVXNYYzSa3yWqFn+pB2NpehYHGOSEGeceCYngr0i6nYdtk0E+swPrP1Jw== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1795322144; h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=TEYgMxyx8vm22/gG+DhD0gLFIDLxgxoL7k4osD5HL1U=; b=oXP0OUX6zoKHztB2QTpvWwyxuoe6wtxEvzOP08Wtvtdjo3nZ09Nf+8OKWz2I4G8mALr/ we/5eMYKpKPvOTCzEGKLmnItDfzVcW+tI+CjY0//pbodBBNYAq0e7f/baDJYU1cKMO9Cd CZyDhOpCFWemNUBpSGp04uPkugakZa0cTNcCGlSswPiYUlNlSDS+6dqcE94dA9UzZ5N0e 9u/aMpCrrfY8PLE98LbS8BIjpaN2RWQbm1OlHDzBuiyliKn7+cqh4VUQ7S8mIlihi83ep 0+Tc294tzCFlo+C+9a1gYiNicumMviTKsw7q3G3DP2ULD1cZiZHBEKzt+2m1MK5L1Qg== ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id D38431F000CF; Sun, 22 Nov 2026 04:35:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795322144; bh=TEYgMxyx8vm22/gG+DhD0gLFIDLxgxoL7k4osD5HL1U=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=ZK7ZHEuerpryacHN3c6psuPT2VqJr0XZvsGA6ytrATBDbMSvCx3HH/BCgaVur2uTx HSty8RUkMITpjxtDHs4SJ0mMjzACO6EXzUn+YQMAKLnIIAh/mhmTkcYfwxp/DGk99n CzvhlkgEVPCEmhYSfHQP5iIt3em7H2UfwtKoeD2bSAPLgCY/1dhhWSgn10EwFKKU8I waQPbdV4sWmDovxljMq9/CdjBQYj1cXdtyhMAjXJ90QOzMYaOJ4W0n/r7TswBKVIP/ p9UTJuhBKmzR7RmvHjWjlvtrZrJMsafHw7RqLGjU44YV4ryeqGyTBxlLLJ9Synd1s5 lzQ1529at2nQQ== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 619454BF07; Sun, 22 Nov 2026 04:35:42 +0000 (UTC) From: Nick Dowsett via B4 Relay Date: Sun, 22 Nov 2026 12:35:41 +0800 Subject: [PATCH 4/4] platform/x86: clevo-laptop: register 5-step white keyboard backlight LED device X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Message-Id: <20261122-clevo-laptop-v1-4-881debf4d4b0@gmail.com> References: <20261122-clevo-laptop-v1-0-881debf4d4b0@gmail.com> In-Reply-To: <20261122-clevo-laptop-v1-0-881debf4d4b0@gmail.com> To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Miguel Ojeda , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Daniel Almeida , Tamir Duberstein , Alexandre Courbot , =?utf-8?q?Onur_=C3=96zkan?= Cc: Armin Wolf , Werner Sembach , linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, rust-for-linux@vger.kernel.org, Nick Dowsett X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1795322140; l=5814; i=nick42d@gmail.com; h=from:subject:message-id; bh=w57T94ShI0LShB2wRkuNbPlY4Amo9JRyqK2KuAoMqHs=; b=DKQ/TUsRuX2U3+TE48LKKw1KN+3UVUItfycAQrEs8Oltw7SsALlGlZo28PWc58J8UxbMamZ9j bR2yvY1GiytAwRQVKkLV3MSX3ZotBxc618ab7aPfD26+hGl3zrbmtTY X-Developer-Key: i=nick42d@gmail.com; a=ed25519; pk=1uIkNexEofzEXNN3Y3QW5z8IrgjWaP0yH6Es51jxWOg= X-Endpoint-Received: by B4 Relay for nick42d@gmail.com/default with auth_id=1596 X-Original-From: Nick Dowsett Reply-To: nick42d@gmail.com Content-Transfer-Encoding: quoted-printable From: Nick Dowsett - Add `SetWhiteBrightness` EC command and `Brightness` wrapper. - Implement `LedOps` (`FixedColorLedOperations`) and register a `white:kbd_backlight` LED class device during WMI probe. Signed-off-by: Nick Dowsett --- drivers/platform/x86/clevo-laptop.rs | 100 +++++++++++++++++++++++++++++++= ++-- 1 file changed, 95 insertions(+), 5 deletions(-) diff --git a/drivers/platform/x86/clevo-laptop.rs b/drivers/platform/x86/cl= evo-laptop.rs index 6f08bf295c07..0a9cb96e7811 100644 --- a/drivers/platform/x86/clevo-laptop.rs +++ b/drivers/platform/x86/clevo-laptop.rs @@ -10,8 +10,14 @@ //! Inspired by Tuxedo Computers' drivers. =20 use kernel::{ + self, device, dmi, + led::{ + self, + LedOps, + Normal, // + }, prelude::*, time::{ delay::fsleep, @@ -31,6 +37,7 @@ const CLEVO_EC_CMD_GET_SPECS: u8 =3D 0x0D; const CLEVO_EC_CMD_GET_BIOS_FEATURES_1: u8 =3D 0x52; const CLEVO_EC_CMD_GET_BIOS_FEATURES_2: u8 =3D 0x7A; +const CLEVO_EC_CMD_SET_KB_WHITE_LEDS: u8 =3D 0x27; const CLEVO_BIOS_FEATURE_CODE_WHITE_ONLY_KB: u32 =3D 0x4000_0000; const CLEVO_BIOS_FEATURE_CODE_3_ZONE_RGB_KB: u32 =3D 0x0040_0000; const CLEVO_BIOS_FEATURE_CODE_WHITE_ONLY_KB_MAX_5: u32 =3D 0x4000; @@ -63,7 +70,7 @@ trait EcQuery { #[pin_data] struct ClevoLaptopModule { #[pin] - _wmi_driver: wmi::Registration, + _wmi_driver: wmi::Registration>, } =20 impl kernel::InPlaceModule for ClevoLaptopModule { @@ -83,12 +90,14 @@ fn init(module: &'static ThisModule) -> impl PinInit { =20 /// RAII guard for Clevo WMI driver holding all subsystem devices e.g LED = device. #[pin_data] -struct WmiDriver {} +struct WmiDriver<'a> { + _led: LedRegistration<'a>, +} =20 kernel::wmi_device_table!(WMI_TABLE, [wmi::DeviceId::new(CLEVO_WMI_METHOD_= GUID)]); =20 -impl wmi::Driver for WmiDriver { - type Data<'bound> =3D WmiDriver; +impl wmi::Driver for WmiDriver<'_> { + type Data<'bound> =3D WmiDriver<'bound>; const ID_TABLE: wmi::IdTable =3D &WMI_TABLE; fn probe<'bound>( dev: &'bound wmi::Device>, @@ -109,11 +118,64 @@ fn probe<'bound>( return Err(ENODEV); } =20 - Ok(try_pin_init!(WmiDriver {})) + if let Err(e) =3D backend.query(SetWhiteBrightness(Brightness:= :OFF)) { + dev_dbg!( + dev, + "Error {e:?} setting keyboard brightness on initializa= tion.\n" + ); + } + + let led_dev =3D KBox::pin_init( + led::DeviceBuilder::new() + .name(c"white:kbd_backlight") + .color(led::Color::White) + .build( + dev.as_ref(), + try_pin_init!(FixedColorLedOperations { backend }), + ), + GFP_KERNEL, + )?; + + Ok(try_pin_init!(WmiDriver { + _led: LedRegistration::White5Step { _dev: led_dev }, + })) }) } } =20 +/// RAII guard for Clevo LED device holding the appropriate sysfs device f= or the backlight type. +enum LedRegistration<'a> { + White5Step { + _dev: Pin< + KBox>>, + >, + }, +} + +/// Represents how to perform LED operations for a Clevo single-color LED = keyboard, generic over +/// `MAX_BRIGHTNESS`. +#[pin_data] +struct FixedColorLedOperations<'a, const MAX_BRIGHTNESS: u8> { + backend: EcInterface<'a>, +} +#[vtable] +impl<'a, const MAX_BRIGHTNESS: u8> LedOps for FixedColorLedOperations<'a, = MAX_BRIGHTNESS> { + const BLOCKING: bool =3D true; + const MAX_BRIGHTNESS: u32 =3D MAX_BRIGHTNESS as u32; + type Mode =3D Normal; + + fn brightness_set<'bound>( + self: &::Device<'bound, Self>, + brightness: u32, + ) -> Result<()> { + let clamped =3D u8::try_from(brightness) + .unwrap_or(MAX_BRIGHTNESS) + .min(MAX_BRIGHTNESS); + self.backend + .query(SetWhiteBrightness(Brightness::new(clamped))) + } +} + /// Interface to Clevo Embedded Controller. enum EcInterface<'a> { Wmi(&'a wmi::Device), @@ -182,6 +244,20 @@ fn detect_backlight_type(&self) -> Result> { } } =20 +/// Keyboard backlight brightness level. +#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Copy, Clone)] +struct Brightness(u8); +impl Brightness { + const OFF: Self =3D Self(0); + const MAX_WHITE_5: Self =3D Self(5); + const fn new(val: u8) -> Self { + Self(val) + } + const fn raw(self) -> u8 { + self.0 + } +} + /// Keyboard backlight type - e.g Fixed Color #[derive(PartialEq)] #[repr(u8)] @@ -219,6 +295,8 @@ fn as_bytes(&self) -> &[u8] { } } =20 +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +struct SetWhiteBrightness(Brightness); #[derive(Debug, Clone, Copy, PartialEq, Eq)] struct GetSpecs; #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -226,6 +304,18 @@ fn as_bytes(&self) -> &[u8] { #[derive(Debug, Clone, Copy, PartialEq, Eq)] struct GetBiosFeatures2; =20 +impl EcQuery for SetWhiteBrightness { + type Output =3D (); + fn cmd(&self) -> u8 { + CLEVO_EC_CMD_SET_KB_WHITE_LEDS + } + fn args(&self) -> EcMethodArgs { + EcMethodArgs::Scalar(self.0.raw().into()) + } + fn deserialize_output(_output: &[u8]) -> Result { + Ok(()) + } +} impl EcQuery for GetBiosFeatures1 { type Output =3D BiosFeatures1; fn cmd(&self) -> u8 { --=20 2.56.1