Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1276358ybi; Tue, 16 Jul 2019 12:20:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqzJVs+blX3QJy0YatzqkImY3SPW43mQriWGXniwEViwED8pJQombjXvo5L6Blw9/cHA2GOv X-Received: by 2002:a17:902:bc83:: with SMTP id bb3mr38685310plb.56.1563304809781; Tue, 16 Jul 2019 12:20:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563304809; cv=none; d=google.com; s=arc-20160816; b=rFJ+xMuV+WfNa7vDsARPDosfF+DVhlE9WNBoeCWKX/iI/BBro/JNzkSnOT7ZfB6OY2 bq69B49XoBBPA9EJc6cPYnUiNSukaUQ6AwzR5KEMF1ecoh+cpOTyIHNUjkYw2t4NnYqj tLT80BdsQyfdQKpE2EQ3Id2U3V5geDWV52iB2SgrK5FWz2+NNBhq8a0D9okF7erX6nvB oIV4sGIl3Ol4POSmPpYVj4H4HxLH5vp2aApIHAsLUtAMuk8q7JRZ5MfNj8zS7+2XnpUu IayF/fGg6jiHRLqEIsvgMHxP1uOhooJEWVwdvgSPTOPskjqLeq4S8OExWi8nlm2MGKIF QinA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject :dkim-signature; bh=v2mTx1EqMffEGEst9Te19cokm4X5NiDrNxCf2bWm/vw=; b=s4/pt2vALb3mkAPlKBCogGqOTJx07clzeHwkokrbxAptGGiF3nJd7YglHODSaL8VAA 1lmG8NIXjtStanlO6MrKbCbwBhH/BASHOblIrsWmdty/UlpT1bhbO+b1Og+STGpXOWce S0bHAt9GCJIj8wnM6LhheBcLdWelxIS/fWQxNPozn0l7kTJk4ZJPhMABv39Jc45toBVG euQUkvbJmBS0TIwv6O6w2xBKg07jeT3WwaxMGNS+yxF+KTNZmWg35ph4NfLrsRJd2CUQ DI953l4Hn+WFoT99hE5NvNUj6f61wMWLSIEIhwMcLbqTgP3Enz7M3kCy1pd8ViUiCdzQ FW/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=p3xsA1si; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ci19si19540862plb.165.2019.07.16.12.19.53; Tue, 16 Jul 2019 12:20:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=p3xsA1si; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388518AbfGPTSh (ORCPT + 99 others); Tue, 16 Jul 2019 15:18:37 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:39663 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728137AbfGPTSh (ORCPT ); Tue, 16 Jul 2019 15:18:37 -0400 Received: by mail-wm1-f65.google.com with SMTP id u25so9393158wmc.4; Tue, 16 Jul 2019 12:18:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:openpgp:autocrypt:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=v2mTx1EqMffEGEst9Te19cokm4X5NiDrNxCf2bWm/vw=; b=p3xsA1sipzqDAboi2BYPJQZ8gQZWd6WlZ+fqAZb8d/KXf7JbHDFrxeKM2x+8FFQrWG T7SMTu4Q5nTf6ebnMvPyssBBXpRfFb4jmz1Q4kBME7ooVKI9GQGyS9+2HWlkjnF5zzCH TVdMcJEdKZdxCnjRfFqiUhXLcCTX5+mbb5XgPhoHCKJ5Ku1jAnbkVpwXPaTwj8tsqeTe +sCMZFiVOHu7qTcdi2yxk5OfP5s414MH3QUL6vi8tM+Watf3KmsDXJML4uKMYdLeRt4t vApIDAHvlZ1jnFUgoJGFn/6d7wG1Secra4e03iSoawKAujjrZxQYNteoXEQ473Vy/kI/ iCFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=v2mTx1EqMffEGEst9Te19cokm4X5NiDrNxCf2bWm/vw=; b=VbA0OvrqjbobkJbSpFIKII2vpcpV9jO3aVzDGdWKpiVj5scN4XqovVYAlkf2FJ/1Nt ZMj3MzPSqi42A3Ce3jQF4OLTavSWHpjdcuBseVEbvUUzeTrVdajJXQZJrCqATPfaP8dN qkAHYPJbTGuCdL/5mErEolJgQUEkHT0MZqfPN3YRPnpcUCzIUyhIPjwR9Hwtb7oyF4Bk oieeJzeeKMJIpi7/jjzp7f1OvhonVNylJm2C/meFnRQMbdNjk04pdzbCMpG7xS9tdWlb SGFddzuorRI/KSKdKNmX7jTkuh9Xrh34qiZOlS59lgfNt84G6eOIl40p6ACviprAF8LD LwKA== X-Gm-Message-State: APjAAAXmYLtZuTpbeEiYAVxj64kfOf8IoEn9HyyGad0Qlxyxf+l3MTP5 FDIp0bHoskFLPZgnadWJ7SnmWiNo X-Received: by 2002:a05:600c:2218:: with SMTP id z24mr31841977wml.84.1563304713081; Tue, 16 Jul 2019 12:18:33 -0700 (PDT) Received: from [192.168.1.19] (chm81.neoplus.adsl.tpnet.pl. [83.31.10.81]) by smtp.gmail.com with ESMTPSA id s63sm19076896wme.17.2019.07.16.12.18.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Jul 2019 12:18:32 -0700 (PDT) Subject: Re: [PATCH v5 2/2] documention: leds: Add multicolor class documentation To: Dan Murphy , pavel@ucw.cz Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org References: <20190701204634.10517-1-dmurphy@ti.com> <20190701204634.10517-3-dmurphy@ti.com> From: Jacek Anaszewski Openpgp: preference=signencrypt Autocrypt: addr=jacek.anaszewski@gmail.com; prefer-encrypt=mutual; keydata= mQINBFWjfaEBEADd66EQbd6yd8YjG0kbEDT2QIkx8C7BqMXR8AdmA1OMApbfSvEZFT1D/ECR eWFBS8XtApKQx1xAs1j5z70k3zebk2eeNs5ahxi6vM4Qh89vBM46biSKeeX5fLcv7asmGb/a FnHPAfQaKFyG/Bj9V+//ef67hpjJWR3s74C6LZCFLcbZM0z/wTH+baA5Jwcnqr4h/ygosvhP X3gkRzJLSFYekmEv+WHieeKXLrJdsUPUvPJTZtvi3ELUxHNOZwX2oRJStWpmL2QGMwPokRNQ 29GvnueQdQrIl2ylhul6TSrClMrKZqOajDFng7TLgvNfyVZE8WQwmrkTrdzBLfu3kScjE14Q Volq8OtQpTsw5570D4plVKh2ahlhrwXdneSot0STk9Dh1grEB/Jfw8dknvqkdjALUrrM45eF FM4FSMxIlNV8WxueHDss9vXRbCUxzGw37Ck9JWYo0EpcpcvwPf33yntYCbnt+RQRjv7vy3w5 osVwRR4hpbL/fWt1AnZ+RvbP4kYSptOCPQ+Pp1tCw16BOaPjtlqSTcrlD2fo2IbaB5D21SUa IsdZ/XkD+V2S9jCrN1yyK2iKgxtDoUkWiqlfRgH2Ep1tZtb4NLF/S0oCr7rNLO7WbqLZQh1q ShfZR16h7YW//1/NFwnyCVaG1CP/L/io719dPWgEd/sVSKT2TwARA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67bf-ef074c591f0a@gmail.com> Date: Tue, 16 Jul 2019 21:18:30 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190701204634.10517-3-dmurphy@ti.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Dan, Thanks for the update. I have some nits below, please take a look. On 7/1/19 10:46 PM, Dan Murphy wrote: > Add the support documentation on the multicolor LED framework. > This document defines the directores and file generated by the > multicolor framework. It also documents usage. > > Signed-off-by: Dan Murphy > --- > Documentation/leds/leds-class-multicolor.txt | 152 +++++++++++++++++++ > 1 file changed, 152 insertions(+) > create mode 100644 Documentation/leds/leds-class-multicolor.txt > > diff --git a/Documentation/leds/leds-class-multicolor.txt b/Documentation/leds/leds-class-multicolor.txt > new file mode 100644 > index 000000000000..01175288502e > --- /dev/null > +++ b/Documentation/leds/leds-class-multicolor.txt > @@ -0,0 +1,152 @@ > + > +Multi Color LED handling under Linux > +================================================= > + > +Author: Dan Murphy > + > +Description > +----------- > +There are varying monochrome LED colors available for application. These > +LEDs can be used as a single use case LED or can be mixed with other color > +LEDs to produce the full spectrum of color. Color LEDs that are grouped > +can be presented under a single LED node with individual color control. > +The multicolor class groups these LEDs and allows dynamically setting the value > +of a single LED or setting the intensity values of the LEDs in the group and > +updating the LEDs virtually simultaneously. > + > +Multicolor Class Control > +------------------------- > +The multicolor class presents the LED groups under a directory called "colors". > +This directory is a child under the LED parent node created by the led_class > +framework. The led_class framework is documented in led-class.txt within this > +documentation directory. > + > +Each colored LED is given its own directory. These directories can be, but not > +limited to red, green, blue, white, amber, yellow and violet. Under these > +directories the intensity and max_intensity files are presented for each LED. > + > + > +Directory Layout Example > +------------------------ > +root:/sys/class/leds/rgb:grouped_leds# ls -lR colors/ > +colors/: > +drwxr-xr-x 2 root root 0 Jun 28 20:21 blue > +drwxr-xr-x 2 root root 0 Jun 28 20:21 green > +drwxr-xr-x 2 root root 0 Jun 28 20:21 red > +-rw------- 1 root root 4096 Jun 28 20:21 color_mix > + > +colors/blue: > +-rw------- 1 root root 4096 Jun 28 20:21 intensity > +-r-------- 1 root root 4096 Jun 28 20:27 max_intensity > +-r-------- 1 root root 4096 Jun 28 20:21 color_id > + > +colors/green: > +-rw------- 1 root root 4096 Jun 28 20:22 intensity > +-r-------- 1 root root 4096 Jun 28 20:27 max_intensity > +-r-------- 1 root root 4096 Jun 28 20:21 color_id > + > +colors/red: > +-rw------- 1 root root 4096 Jun 28 20:21 intensity > +-r-------- 1 root root 4096 Jun 28 20:27 max_intensity > +-r-------- 1 root root 4096 Jun 28 20:21 color_id > + > +Multicolor Color Mixing > +----------------------- > +Multicolor monochrome LEDs intensity can be modified and mixed to produce a > +varying array of colors. The color_mix file gives the user the ability to write > +all the monochrome LEDs registered in the directory with a single call. > +To create a specific color from monochrome LEDs the color_mix file needs to be > +written with each color's intensity. The order in which the monochrome LEDs > +should be written is based on the colors color_id. > + > +For example: > +cat /sys/class/leds/rgb:grouped_leds/red/color_id > +0 > +cat /sys/class/leds/rgb:grouped_leds/green/color_id > +1 > +cat /sys/class/leds/rgb:grouped_leds/blue/color_id > +2 > + > +red - color_id = 0 > +green - color_id = 1 > +blue - color_id = 2 > + > +These id's are the order in which to write the color_mix file. > + > +echo " " > color_mix > + > +echo "0x80 0x00 0x80" > color_mix > + > +The order of the monochrome LEDs are determined during multicolor class > +registration and will not change unless unregistered and re-registered. > + > +Other example with amber monochrome LED: > +blue - color_id = 0 > +amber - color_id = 1 > + > +In this exampe blue is at ID 0 and amber ID is 1 so the user would write > +echo " " > color_mix > + > +echo "0x38 0x80" > color_mix > + > +If a single monochrome LED needs to be modified then the user would write the > +colors//intensity file. > + > + > +Multicolor Class Brightness Control > +----------------------------------- > +The multiclor class framework will calculate each monochrome LEDs intensity. > + > +The brightness level for each LED is calculated based on the color LED > +intensity setting divided by the color LED max intensity setting multiplied by > +the requested value. > + > +led_brightness = requested_value*(led_color_intensity/led_color_max_intensity) Please drop parentheses here as pointed out before in the code review. > + > +Example: > +Three LEDs are present in the group as defined in "Directory Layout Example" > +within this document. > + > +A user first writes the color LED brightness file with the brightness level that > +is neccesary to achieve a blueish violet output from the RGB LED group. > + > +echo 138 > /sys/class/leds/rgb:grouped_leds/red/intensity > +echo 43 > /sys/class/leds/rgb:grouped_leds/green/intensity > +echo 226 > /sys/class/leds/rgb:grouped_leds/blue/intensity > + > +red - > + intensity = 138 > + max_intensity = 255 > +green - > + intensity = 43 > + max_intensity = 255 > +blue - > + intensity = 226 > + max_intensity = 255 > + > +The user can control the brightness of that RGB group by writing the parent > +'brightness' control. Assuming a parent max_brightness of 255 the user may want > +to dim the LED color group to half. The user would write a value of 128 to the > +parent brightness file then the values written to each LED will be adjusted > +base on this value We probably need to state here that any amendment to color intensity values resets brightness to its max value. > +cat /sys/class/leds/rgb:grouped_leds/max_brightness > +255 > +echo 128 > /sys/class/leds/rgb:grouped_leds/brightness > + > +adjusted_red_value = 128 * (138/255) = 69 > +adjusted_green_value = 128 * (43/255) = 21 > +adjusted_blue_value = 128 * (226/255) = 113 Drop parentheses. > + > +Reading the parent brightness file will return the current brightness value of > +the color LED group. > + > +cat /sys/class/leds/rgb:grouped_leds/max_brightness > +255 > + > +echo 128 > /sys/class/leds/rgb:grouped_leds/brightness > + > +cat /sys/class/leds/rgb:grouped_leds/max_brightness > +128 > + > + > -- Best regards, Jacek Anaszewski