From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796380664; b=m9Yk3yyfqqv0WNKCmGm3a2QzEqUJjP/Jw/lcXUlIQw4dBv5V/nczyjsUP/ce36969fxy bgdMO4o+IjCfI7GtAj9Uoxuqp4nL50Rr690V/xrR4Eggj1ourcFuy76s+byHXf91t3EQN 2IiDJZ8Bz10+QO9xK6Uz+aCnSrXztqJkz1yO9Bo/HW3jtXviVa3R6sZk31GcNDbPAmbmT g85lgEvABFTUA5VaB4Rs6BvMPUXJ4OfM9Jja9yFB6cKjCruUzPm7TH973pk53MQZYysjy Gh8I8w3QaARrlPx3/vlaMGGP0xSZRc2DioPUhPvftJAY5P3sDWC6IaBon/M2Jrc57nw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380664; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=3vhytGYj29qJDKseyWb99yOrtiQUCydcIqcbXYIWkDE=; b=3x4cXeek9b0fS1/rm0Et7s30QHSHx0Pfx8/jGr/SW4FK6yoBPV/td9iOKv3yumJoB/t0 lJrdpfiWx7h97dFat/lbXDkyOuyXZAhgY+ucQIcnANStdfgO/QL2LKNv1I/A+I9UxE2eD GZ4uGBKVYz9tuV9Ed369nwfKY/Bh26Cygj5OCxutGzBhpXVEWNVECPyMs1dhPSE6AbtxI 0NuhWtnnZM+0dOAITvj36FoXx75NxVmXalsZuLaQL8eB6Av5I/v7CDEnH29eIvxhKCBu/ 2P2bqIxngYCjEPTThvxg8V2HAp39BR5ECjRg78nFL2tFmj3BeYSNiBskOAf1Yl1DlMQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=miI6xQqn; arc=none 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 892C8606A681; Fri, 4 Dec 2026 10:37:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=miI6xQqn Received: by smtp.kernel.org (Postfix) with ESMTPSA id A07091F000CE; Fri, 4 Dec 2026 10:37:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380664; bh=3vhytGYj29qJDKseyWb99yOrtiQUCydcIqcbXYIWkDE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=miI6xQqnkG/1ZRnodthmQTv/czWBQe9hqxbhKPk7OiTscOh6KvnwxPHZhOHlWfn+P /Hib5/7rwZh4Br2q/6FRPRwku5HFIremjt5o9BPAGX/cGyVK5z6ztqIa85YVR6LoTn HeDVRN9qHRKrnjxlS2CnVDLWB9Rda94ckqjioCak= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ray Wu , Hugo Sales , Wayne Lin , Alex Deucher Subject: [PATCH 7.3 372/742] drm/amd/display: Add the AUX backlight minimum once on the custom curve Date: Fri, 4 Dec 2026 19:03:56 +0900 Message-ID: <20261204100644.969817208@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@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 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hugo Sales commit 988ab04d773ac089588ce17742f491e9ee8b1793 upstream. On an AUX backlight, convert_brightness_from_user() maps the user level through the ATIF custom brightness curve with convert_custom_brightness(), which rescales the result to user_min..user_max. convert_brightness_from_user() then rescales it again, from 0..user_max to user_min..user_max, so the minimum goes in twice. On the 1..512 nits AUX fallback range, a request for 0 gives 1998 millinits instead of 1000 Rescale the curve's output to 0..user_max and leave the offset to the caller Fixes: 8dbd72cb7900 ("drm/amd/display: Export full brightness range to userspace") Reviewed-by: Ray Wu Signed-off-by: Hugo Sales Signed-off-by: Wayne Lin Signed-off-by: Alex Deucher (cherry picked from commit 5f95ef2cfd208ca7efe446abfc9e3144dc5ce4fa) Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_backlight.c | 9 ++---- drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_backlight_test.c | 14 +++++----- 2 files changed, 11 insertions(+), 12 deletions(-) --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_backlight.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_backlight.c @@ -113,10 +113,10 @@ static inline u32 scale_input_to_fw(int return DIV_ROUND_CLOSEST_ULL(input * AMDGPU_MAX_BL_LEVEL, max); } -/* Rescale from [0..AMDGPU_MAX_BL_LEVEL] to [min..max] */ -static inline u32 scale_fw_to_input(int min, int max, u64 input) +/* Rescale from [0..AMDGPU_MAX_BL_LEVEL] to [0..max] */ +static inline u32 scale_fw_to_input(int max, u64 input) { - return min + DIV_ROUND_CLOSEST_ULL(input * (max - min), AMDGPU_MAX_BL_LEVEL); + return DIV_ROUND_CLOSEST_ULL(input * max, AMDGPU_MAX_BL_LEVEL); } static u32 backlight_signal_to_luminance(const struct amdgpu_dm_backlight_caps *caps, @@ -242,8 +242,7 @@ void convert_custom_brightness(const str (brightness - lower_signal), upper_signal - lower_signal); scale: - *user_brightness = scale_fw_to_input(min, max, - DIV_ROUND_CLOSEST(lum * brightness, 101)); + *user_brightness = scale_fw_to_input(max, DIV_ROUND_CLOSEST(lum * brightness, 101)); } EXPORT_IF_KUNIT(convert_custom_brightness); --- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_backlight_test.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_backlight_test.c @@ -1104,10 +1104,10 @@ static void dm_test_custom_brightness_ex /* * Exact match: lum=50, brightness_scaled=128 - * result = scale_fw_to_input(min, max, DIV_ROUND_CLOSEST(50*128, 101)) - * = scale_fw_to_input(0, 65535, DIV_ROUND_CLOSEST(6400, 101)) - * = scale_fw_to_input(0, 65535, 63) - * = 0 + DIV_ROUND_CLOSEST(63 * 65535, 255) = 16191 (approx) + * result = scale_fw_to_input(max, DIV_ROUND_CLOSEST(50*128, 101)) + * = scale_fw_to_input(65535, DIV_ROUND_CLOSEST(6400, 101)) + * = scale_fw_to_input(65535, 63) + * = DIV_ROUND_CLOSEST(63 * 65535, 255) = 16191 (approx) */ KUNIT_EXPECT_TRUE(test, brightness != 32896); KUNIT_EXPECT_TRUE(test, brightness < 32896); @@ -1150,9 +1150,9 @@ static void dm_test_custom_brightness_be /* * Below first data point: lum = DIV_ROUND_CLOSEST(40 * 50, 100) = 20 - * Then: scale_fw_to_input(0, 65535, DIV_ROUND_CLOSEST(20 * 50, 101)) - * = scale_fw_to_input(0, 65535, DIV_ROUND_CLOSEST(1000, 101)) - * = scale_fw_to_input(0, 65535, 10) + * Then: scale_fw_to_input(65535, DIV_ROUND_CLOSEST(20 * 50, 101)) + * = scale_fw_to_input(65535, DIV_ROUND_CLOSEST(1000, 101)) + * = scale_fw_to_input(65535, 10) * The output should be significantly less than input. */ KUNIT_EXPECT_TRUE(test, brightness < 12850);