From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) (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 EC3E02882C5 for ; Thu, 9 Apr 2026 20:04:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775765093; cv=none; b=aKOnwDUr8Gc2XpnFpoMgQU3zj/MS2DW4OCCCJjpV+2HdUU4vJqCR1pE1wJyvffNheTrINq5qjxifUAbM2lTRK+TfazIPJfEQnxCrf3mIFTlTLyi2uDU7KY0s3hVVnnftDsSGp0NjllY1gbU2hfumBB1ut3HGR78I1Ta73Nswkow= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775765093; c=relaxed/simple; bh=oyfrRqRvZFeyIVwNrH6Z6dQPaitfntwHluGT/Ji3iNM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=UtqlE0Zu4937Hu0emCNVFQ1swBhhhxXBrQJ4ItJ1CX3YA09IJpoUYV4kE6oyV7B4M0izyFcoLdCCAHg9gdwxkDTzqNxLCyyQRUjQfGtX0Hw+NdJCIjL1/Nq9QwLEQRM0j0enC797Z3UT+STeTDH9G0FZNv410kgAShCf7XCvsBA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=abkonLHk; arc=none smtp.client-ip=209.85.208.49 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.b="abkonLHk" Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-66f8f556f39so1820513a12.0 for ; Thu, 09 Apr 2026 13:04:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775765090; x=1776369890; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=LqS5Pf7YsvspLFyoG0lx1qkP9YEtML5bQ5wp6Ju/2Tc=; b=abkonLHk1XDsvPUSD0TB6KNlfONxqGtUPmebaneZgLcwaftqUxUNwC1JGtjyC4ufnP jWIkOxhddhaDhs//r2va+3Tlec9CRfGpNYPi10Qg6B3ftauqKKJx1NnHP1PDvuouhnFN QHIUdQwqla3sm6LNHZG2NJ/6yxsi5yuFGHCjqcEopwKeOu3g0WLx987nk4jHr6lvRrYo m+8V/BU9VV6PwBV83gHN2jnjFWEfQKZ9YCInrqWIVuN0Q+1dCtuuUc5bvj3Btbj3k3zL YBh3sg1i8QM7ttjzeiejt+8249vqA64W1L6LalUmKJFJxNiYAsE+VaVy8Bbc6lNOpZFD xorQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775765090; x=1776369890; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=LqS5Pf7YsvspLFyoG0lx1qkP9YEtML5bQ5wp6Ju/2Tc=; b=SXs2Z+TbG8IiC+FReMAyjRrMngrm80ZlB7bVOQZfswtaII80fdZQaGGDO3b6HYdPZ/ zg8kzDRaSzPwqxwnMaKU713+fYLLxrZpDqTShrlCZdQ2aBE6TWwkHEitLSuv6eVMa9sG bBaE9cYfNG+MccCmvBna4x498Fm1qNRbFNHxrZff+oLQx2msK1fx0Upx264UoCXMxZyd tKkVL5NanLuMaggSSnpkK1COZQSd13VCZab3omjn1WuJFdw51up7wMGhvEFjoPxlcaZh 4L4sQsXs0mVPUz3Fuw2BvMNd5Fd2DDKIo0qbx1ffjEHyQGQDdE20uTG2tumR6W0j2h3f 503w== X-Gm-Message-State: AOJu0Yz0yGbsBYlY5LNdtWXAgTkzugt7zgmDM525hJHLkGgKl8vl2ZJq S1A9/K+Bx6LFc64TPgcYrY3xFZ+izkpzwvFkHDodrdpvz6p9948l9wTa X-Gm-Gg: AeBDietbAY+XUKQDYxWoknkFrdFiAGin0m7YvCglqwP/ILJhGGF/rVrMQPU2zEJCjsP ZLDOQreBhQWk1wciVBBCbh+65iaQIF9FNA2lTk4GJixld7XdkKfVfc/aqYMWikqjHLRwCciZsHb 1mQVzCDvehlVwy7mdXI80t1TPKRmuDeNCWssgILpmaXZq5O6V07dbja09zsxkCJcekILJGSW+Hj Y9ZD0f0n8mb7FMV+U8Xe1ut1DGJRg0J6pXoDMMIR40iFWwKFpjJhMqjJD5QiUnsgsBT4N/XyWSJ FcU25ulXqy1BGcCzI7DmAh7JBWGBoBDb5tLyErCeYooqifI3WTIffAk8JEsxHBuCVHpL+RxBh62 9NrNxzRxCFB+mfZYPk7RnrISjcXJy1MswbQTIoIDMN9BvgH6mOlRNSLrBqOAXEfKMCM5XdhCnUR TagDoiWPIoN/QtcGoNc9jKRiZMnhosEUw4nXc= X-Received: by 2002:a05:6402:4344:b0:66e:abc4:ffc5 with SMTP id 4fb4d7f45d1cf-670776521d8mr91248a12.2.1775765090059; Thu, 09 Apr 2026 13:04:50 -0700 (PDT) Received: from [192.168.0.193] ([194.183.54.57]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-67070816a8esm89789a12.25.2026.04.09.13.04.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 09 Apr 2026 13:04:48 -0700 (PDT) Message-ID: Date: Thu, 9 Apr 2026 22:04:47 +0200 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: [PATCH v2 1/1] leds: Introduce the multi_max_intensity sysfs attribute To: Armin Wolf , lee@kernel.org, pavel@kernel.org Cc: linux-kernel@vger.kernel.org, corbet@lwn.net, skhan@linuxfoundation.org, linux-leds@vger.kernel.org, linux-doc@vger.kernel.org, wse@tuxedocomputers.com, pobrn@protonmail.com, m.tretter@pengutronix.de References: <20260331191619.3729-1-W_Armin@gmx.de> <20260331191619.3729-2-W_Armin@gmx.de> Content-Language: en-US From: Jacek Anaszewski In-Reply-To: <20260331191619.3729-2-W_Armin@gmx.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi Armin, On 3/31/26 9:16 PM, Armin Wolf wrote: > Some multicolor LEDs support global brightness control in hardware, > meaning that the maximum intensity of the color components is not > connected to the maximum global brightness. Such LEDs cannot be > described properly by the current multicolor LED class interface, > because it assumes that the maximum intensity of each color component > is described by the maximum global brightness of the LED. > > Fix this by introducing a new sysfs attribute called > "multi_max_intensity" holding the maximum intensity values for the > color components of a multicolor LED class device. Drivers can use > the new max_intensity field inside struct mc_subled to tell the > multicolor LED class code about those values. Intensity values written > by userspace applications will be limited to this maximum value. > > Drivers for multicolor LEDs that do not support global brightness > control in hardware might still want to use the maximum global LED > brightness supplied via devicetree as the maximum intensity of each > individual color component. Such drivers should set max_intensity > to 0 so that the multicolor LED core can act accordingly. > > The lp50xx and ncp5623 LED drivers already use hardware-based control > for the global LED brightness. Modify those drivers to correctly > initalize .max_intensity to avoid being limited to the maximum global > brightness supplied via devicetree. > > Signed-off-by: Armin Wolf > --- > .../ABI/testing/sysfs-class-led-multicolor | 19 ++++++-- > Documentation/leds/leds-class-multicolor.rst | 21 ++++++++- > drivers/leds/led-class-multicolor.c | 47 ++++++++++++++++++- > drivers/leds/leds-lp50xx.c | 1 + > drivers/leds/rgb/leds-ncp5623.c | 4 +- > include/linux/led-class-multicolor.h | 30 +++++++++++- > 6 files changed, 113 insertions(+), 9 deletions(-) [...] > diff --git a/include/linux/led-class-multicolor.h b/include/linux/led-class-multicolor.h > index db9f34c6736e..6f89d92566b2 100644 > --- a/include/linux/led-class-multicolor.h > +++ b/include/linux/led-class-multicolor.h > @@ -9,10 +9,31 @@ > #include > #include > > +/** > + * struct mc_subled - Color component description. > + * @color_index: Color ID. > + * @brightness: Scaled intensity. > + * @intensity: Current intensity. > + * @max_intensity: Maximum supported intensity value. > + * @channel: Channel index. > + * > + * Describes a color component of a multicolor LED. Many multicolor LEDs > + * do no support gobal brightness control in hardware, so they use s/gobal/global/ > + * the brightness field in connection with led_mc_calc_color_components() > + * to perform the intensity scaling in software. > + * Such drivers should set max_intensity to 0 to signal the multicolor LED core > + * that the maximum global brightness of the LED class device should be used for > + * limiting incoming intensity values. > + * > + * Multicolor LEDs that do support global brightness control in hardware > + * should instead set max_intensity to the maximum intensity value supported > + * by the hardware for a given color component. > + */ > struct mc_subled { > unsigned int color_index; > unsigned int brightness; > unsigned int intensity; > + unsigned int max_intensity; > unsigned int channel; > }; > > @@ -53,7 +74,14 @@ int led_classdev_multicolor_register_ext(struct device *parent, > */ > void led_classdev_multicolor_unregister(struct led_classdev_mc *mcled_cdev); > > -/* Calculate brightness for the monochrome LED cluster */ > +/** > + * led_mc_calc_color_components() - Calculates component brightness values of a LED cluster. > + * @mcled_cdev - Multicolor LED class device of the LED cluster. > + * @brightness - Global brightness of the LED cluster. > + * > + * Calculates the brightness values for each color component of a monochrome LED cluster, > + * see Documentation/leds/leds-class-multicolor.rst for details. > + */ > int led_mc_calc_color_components(struct led_classdev_mc *mcled_cdev, > enum led_brightness brightness); > Reviewed-by: Jacek Anaszewski -- Best regards, Jacek Anaszewski