From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.229.135 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796044586; b=FWmTzJx+juNqvO4v5ANrkmr9Lb34yj9fa/rcoysvfGdztmhN/J0iV81CtV2mJsid2y1T sspCaPh4gszkunH5uDjEhXtnh4ttFmVFqXzBr3zGTe4nd2H77YTqXMDGYr6sXRzNED5/q YvsXvd0zboml36cZP/aIdrmVl3xCvqYFAQdaopw+P95PAH0xD2Aj7PsujyMxj8OG/sqGT VkhMkmXLFZmU+hbX7ySteJMo1eb39o/2ka16Gp7Sb6ij8p00miP5DiG0Xa8kN7DWy0Jfi WlxWQo69GGb6QW0GKmHfL11JsWnaYK0IsMUjP00Ld+dwcpj4vgYNSJ8GViiFzsJvvSw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796044586; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=bQWIPYvcxwxXU/7bTQM0ugKYNaOAlQ8S4L1nqjB9hrM=; b=JJph6D3mo0pynPwvMrYf1ZNxbW+TyAhYh/RWQoKl8t2hmURmRebTNMUHK/fK9eneao8q m9zIa6mGV/6z3tEk3xfPwSsC0L4vEkzmiaCAfVKYMzVhO0hdCiQKMLu6UpsG/RAGSGZed bXooGgU8LVlThertG9KAz5Y62hdZd56GvGguqJvzi68PBlSyCXoYoMV+RpRAK4gZFtn71 XHSbRweld/UDisnYNsIvhabKJXrh47qgv33XTyddHhPyPETegk8g4Aewfxu/WDcGY3w/w QUEb6bygHWePm233hzQ3YvnpM/Rni1gm4yy8A8fqt7aAUmhE3iqPCa5Z9qRMobSWtnQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=uJNuatIo; arc=none smtp.remote-ip=74.125.229.135 Received: from mail-dl2-f7.google.com (mail-dl2-f7.google.com [74.125.229.135]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 23C47606A320 for ; Mon, 30 Nov 2026 13:16:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 23C47606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=uJNuatIo Received: by mail-dl2-f7.google.com with SMTP id a92af1059eb24-139b659a45eso1161492c88.1 for ; Mon, 30 Nov 2026 05:16:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796044584; x=1796649384; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=bQWIPYvcxwxXU/7bTQM0ugKYNaOAlQ8S4L1nqjB9hrM=; b=uJNuatIoD8OrbbSjtpl6CBVONOYUWTBuFK4XEo/9lclq7dlKzyAv2byXTqKOaMWI5v J+nKTS3R6+q8xA6L2nCcJkCuI+cNWkOvQ0CE8KNp5DIdwOy2OyHvWrEqA4KGQbfC1YAT Se7cy7R4vPrV2aaCo+SVj0syOG9x40Qmdy49w6BJcJeUQ0eIGnm7k9QwB8/XRjoETtzy swKh9YyyMj21r8d5+SNB9yYPnP3UUkwqO0YzEHRKxPa/b4NDEMPaadiT5HX+nXfCJTJN FXL4ZO+85NQVx5uTA3lHue3Dw3+lVIZtgvNpxNgoJpb07ciARzifY3b8/JX7zlU41ZM4 1nuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796044584; x=1796649384; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=bQWIPYvcxwxXU/7bTQM0ugKYNaOAlQ8S4L1nqjB9hrM=; b=P5Zz+wFbkuKxuAecEt05Rw7yy2nd4rIeMqJolhe+PLpA7GXeFc50AsUHpfBhZnxaWt vxx+8AbQ/SIUaz4cJejWU45BV0tECD0qRTUaQoTaf9iNnrDyiPEcqCqN2tT9aF/LotNh L77NLhxL5053OC96/zvuctwPgNSSl5t8PdGh9JwIHB0sre/Yrk7wM1Jui/ij623fT8oT tz/0nQgRE/vI8y8BlyLu/fKm0u5V84l7N255cpDh3yUMuso6cSo0YGW4f8M+5Wf5jDpw cW7aUe3F+IuEbP1EHaHowZWuoQRdIgmdMx6a5UlD6pMTgjwvQcoMAdJZLL16nb0lsRaV WvnQ== X-Forwarded-Encrypted: i=1; AL+hErFLZ/b4zCLzgL3pOKRA60UHOBcb4DYacifhUO6BQQCbpCNKP8x/fYGNTo0ceSLREp2I+qfe2QdSIFmmqFg=@vger.kernel.org X-Gm-Message-State: APuU4Z+9s4rTbIfE5wUB5MGU2T1YkW7TIj+NKe7M4SFJk6HgmQw1+CTw TZXnmFe9tQ06u8Qpbfa310eX2dQW2Bdax8yrxtdh+VrDrQKXflHAaLBe X-Gm-Gg: AZFdTZf4v0+zfFYLMjDFabgnuNJnCbwrHiS5TPFKeQp8dIoWlxwy7jC3jtKW2PItyb4 FOSgFMcPzV4YB7z9brdy1hCkgfZG4dX3EaVPm2wuI1pdp/wFnN+M84/sA5sBepTlSPDSGSNP6+S Jk00OTlQOhCQCR2iheJi6byHZynBjHSzTVV9TkQxTF3Y026kqDPIPR1caIfIt1T2CSmFV7P/UiF 1hO4mjn2V2/fe/KuD4VsQ/oBdcIMB/A2mx+fVsvobwOlq3w1sDgmxIufAad9S+BbbscNLIoRXSZ 4GPlmuoJY16c+wKDdXRcdDIl1TEwSTparMOiCxgC3Bo5EL44e3pmYfFPBFK8QqdEoef6DWGpyEr 9Lac0+Tfc4PofP61GiPONb2K5zVsBxhypkLdaw3s0QpoRaBErX+/r47ICtbS8Jau+t9+clANlQW jKmMNYeWh98a/KeViwZawKnpVSznl2wBCYJGPj2WErDSVEFzU+FetpUkB+5ZqrKwqlOvTvYPjjp UiuyyvEMX/Ji/JXzPBCsNYdahTPrEY3McFMdjlJzMKGy3Ru91AOLH+sxR4x8h15Qt3X9hmuyVK0 /Do63hMbpzmv/GmPl2626UI2uLW/ X-Received: by 2002:a05:7300:1c17:b0:386:a105:fa66 with SMTP id 5a478bee46e88-386a105fd17mr27173391eec.7.1796044584177; Mon, 30 Nov 2026 05:16:24 -0800 (PST) Received: from ThinkPad ([192.220.23.71]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-386992b404bsm84150401eec.1.2026.11.30.05.16.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 05:16:23 -0800 (PST) From: Qiling Zhu To: Mark Pearson , "Derek J. Clark" , Rong Zhang , Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Henrique de Moraes Holschuh Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, ibm-acpi-devel@lists.sourceforge.net, Lee Jones , Pavel Machek , Griffin Kroah-Hartman , linux-leds@vger.kernel.org, vishnuocv@gmail.com, vsankar@lenovo.com, Andrea Rabbaglietti Subject: [PATCH v5 4/6] platform/x86: thinkpad_acpi: Restore keyboard backlight level ourselves Date: Mon, 30 Nov 2026 21:12:50 +0800 Message-ID: <20261130131252.80436-5-kmatzkaczor244@gmail.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261130131252.80436-1-kmatzkaczor244@gmail.com> References: <20261130131252.80436-1-kmatzkaczor244@gmail.com> 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-Transfer-Encoding: 8bit kbdlight_suspend() and kbdlight_resume() leave the keyboard backlight to the LED core across sleep: the LED core caches the current brightness and turns the backlight off on suspend, and writes that brightness back on resume. On a ThinkPad X1 Carbon Gen 14 with thinkpad_acpi unloaded, the firmware turned the backlight off when entering both s2idle and hibernation. After waking from s2idle the EC was back at its previous level, for each of the four levels tested; after waking from hibernation it was at 0. Drop kbdlight_suspend() and leave turning the backlight off to the firmware. On resume, write the cached level back to the EC on all models, instead of relying on the LED core: this brings the backlight back where the firmware came up with it off, and changes nothing where the EC already has that level. For this to hold for every mode, have kbdlight_brightness track the EC level itself, 0 to 3, rather than the brightness reported to the LED core, in which the auto mode (level 3) shows up as 0. kbdlight_init() accordingly reads the level from the EC instead of the brightness; the notify helpers already work in terms of EC levels. Only s2idle and S4 were available on the test machine; S3-capable models were not tested. Signed-off-by: Qiling Zhu Reviewed-by: Rong Zhang --- drivers/platform/x86/lenovo/thinkpad_acpi.c | 28 +++++++++------------ 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/drivers/platform/x86/lenovo/thinkpad_acpi.c b/drivers/platform/x86/lenovo/thinkpad_acpi.c index 80601ed2c..764b1efa6 100644 --- a/drivers/platform/x86/lenovo/thinkpad_acpi.c +++ b/drivers/platform/x86/lenovo/thinkpad_acpi.c @@ -5105,7 +5105,12 @@ static struct ibm_struct video_driver_data = { /* EC level that selects the auto mode for the keyboard backlight */ #define TPACPI_KBD_LIGHT_AUTO_LEVEL 3 -static enum led_brightness kbdlight_brightness; +/* + * Cached EC level, including TPACPI_KBD_LIGHT_AUTO_LEVEL. All state + * tracking compares EC levels; the auto mode is translated to a + * brightness value only when reporting to the LED core. + */ +static int kbdlight_brightness; static DEFINE_MUTEX(kbdlight_mutex); static int kbdlight_set_level(int level) @@ -5247,7 +5252,10 @@ static int __init kbdlight_init(struct ibm_init_struct *iibm) return -ENODEV; } - kbdlight_brightness = kbdlight_sysfs_get(NULL); + kbdlight_brightness = kbdlight_get_level(); + if (kbdlight_brightness < 0) + kbdlight_brightness = 0; + tp_features.kbdlight = 1; rc = led_classdev_register(&tpacpi_pdev->dev, @@ -5343,31 +5351,19 @@ static int kbdlight_write(char *buf) return 0; } -static void kbdlight_suspend(void) -{ - struct led_classdev *led_cdev; - - if (!tp_features.kbdlight) - return; - - led_cdev = &tpacpi_led_kbdlight.led_classdev; - led_update_brightness(led_cdev); - led_classdev_suspend(led_cdev); -} - static void kbdlight_resume(void) { if (!tp_features.kbdlight) return; - led_classdev_resume(&tpacpi_led_kbdlight.led_classdev); + guard(mutex)(&kbdlight_mutex); + kbdlight_set_level(kbdlight_brightness); } static struct ibm_struct kbdlight_driver_data = { .name = "kbdlight", .read = kbdlight_read, .write = kbdlight_write, - .suspend = kbdlight_suspend, .resume = kbdlight_resume, .exit = kbdlight_exit, }; -- 2.56.1