Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp1790453ybj; Sun, 22 Sep 2019 12:00:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqwfR++dE5gA6FPz8il2OPiwi03ZrgJObrDe0vDg+nanQfotaGLjHaLuLslq2O+dC9AV6er5 X-Received: by 2002:aa7:dc57:: with SMTP id g23mr20572672edu.38.1569178859445; Sun, 22 Sep 2019 12:00:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569178859; cv=none; d=google.com; s=arc-20160816; b=jHnllMa8J/+5Gp3puZ1nFxrfPlTtglCQNqUyf0HW6UNdi7MSz3ywZRsGmUrIWbbc06 I5ZCxt8IcThoy1ppmRKt7jpKN6Hj259/ouqkIjNHBL+DlUDCA+Pu2o/ogs8rMZeIOqIM Hw3fSQ7ir94yDs1QlglQ80WHU/nOPTqg+ClCKWK8ZlsCVt+2BqiXB7u2K+Z9jZu/O7IH 6GI3I/usKd1mNXMQfGQNp2MpVzeoSrT2Aw7oiA4YLDEu7QlkEYMYey1IJjhWuRXkSP4J AVXzvMjbCKVkU+6yQ3xOr8HYLmB+iunyvR+gzH+RJuARHbw5PM7BIt8MY4C/WcrudZam JTJQ== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=akFQwtB+8wepT0KN3wLxQAM5VrWw2YHk7/wv8nkby20=; b=F0EwME9+wI7nSMFsuxBWBvsWUYWb76/WDg9QWCTdCQ9YLjKN1G97fzKtnPPx/ZO9qj ejtnr+LG8F85/W6AaD8Xs9oZKwWniyuh2/ewaP03/g0bTMScnH9ULMvRDAC407JNOYLT QaIRbkBftOlUFudmDyxVT5Bs/zcUvY0AcPcelBBaQYxpQXrSj82kYWGsPp9U9xiyYMVN G1DoLzLbL5+Bkxe+bRgKQGQ8mv8p5YN+4a2D+cVb8NRbLVEa5mg0VEvGn3Ok372LGJaZ XGf/VuCqNf8AU+v3IyhCjJvckwrQTenIhlU87Q5SymFGpNuTpSZ1oslYe/Gc1RRWxPl7 qpMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=V2pnsJrm; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t26si3943643ejt.0.2019.09.22.12.00.35; Sun, 22 Sep 2019 12:00:59 -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=@ti.com header.s=ti-com-17Q1 header.b=V2pnsJrm; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392844AbfITRio (ORCPT + 99 others); Fri, 20 Sep 2019 13:38:44 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:60788 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392247AbfITRib (ORCPT ); Fri, 20 Sep 2019 13:38:31 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id x8KHcQZQ019948; Fri, 20 Sep 2019 12:38:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1569001106; bh=akFQwtB+8wepT0KN3wLxQAM5VrWw2YHk7/wv8nkby20=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=V2pnsJrmS5a0T7YWxcYaYkrDU8T+lXKi3gxgFOLvYoDtSAW9ExsriYiC83lHsZqeR C59XMYyfCeVOWOcgrW7M4Tgq83PC+1Gs/pFi0RrsTvMmRAujCviYG7P2y82zresAbb vTif9zOOKwGjPO/zleUKIAZXW86uE/sgR0L4W0vk= Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x8KHcQV9021608 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 20 Sep 2019 12:38:26 -0500 Received: from DFLE110.ent.ti.com (10.64.6.31) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Fri, 20 Sep 2019 12:38:22 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE110.ent.ti.com (10.64.6.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Fri, 20 Sep 2019 12:38:22 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id x8KHcQwP075336; Fri, 20 Sep 2019 12:38:26 -0500 From: Dan Murphy To: , CC: , , Dan Murphy Subject: [PATCH v8 2/9] documention: leds: Add multicolor class documentation Date: Fri, 20 Sep 2019 12:41:32 -0500 Message-ID: <20190920174139.30079-3-dmurphy@ti.com> X-Mailer: git-send-email 2.22.0.214.g8dca754b1e In-Reply-To: <20190920174139.30079-1-dmurphy@ti.com> References: <20190920174139.30079-1-dmurphy@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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/index.rst | 1 + Documentation/leds/leds-class-multicolor.rst | 91 ++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 Documentation/leds/leds-class-multicolor.rst diff --git a/Documentation/leds/index.rst b/Documentation/leds/index.rst index 060f4e485897..bc70c6aa7138 100644 --- a/Documentation/leds/index.rst +++ b/Documentation/leds/index.rst @@ -9,6 +9,7 @@ LEDs leds-class leds-class-flash + leds-class-multicolor ledtrig-oneshot ledtrig-transient ledtrig-usbport diff --git a/Documentation/leds/leds-class-multicolor.rst b/Documentation/leds/leds-class-multicolor.rst new file mode 100644 index 000000000000..063c9a411a1d --- /dev/null +++ b/Documentation/leds/leds-class-multicolor.rst @@ -0,0 +1,91 @@ +==================================== +Multi Color LED handling under Linux +==================================== + +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.rst within this +documentation directory. + +Each colored LED will have two files created under the colors directory +_intensity and _max_intensity. These files will contain +one of LED_COLOR_ID_* definitions from the header +include/dt-bindings/leds/common.h. + +Directory Layout Example +======================== +root:/sys/class/leds/rgb:grouped_leds# ls -lR colors/ +-rw-rwxr-- 1 root root 4096 Jul 7 03:10 red_max_intensity +--w--wx-w- 1 root root 4096 Jul 7 03:10 red_intensity +-rw-rwxr-- 1 root root 4096 Jul 7 03:10 green_max_intensity +--w--wx-w- 1 root root 4096 Jul 7 03:10 green_intensity +-rw-rwxr-- 1 root root 4096 Jul 7 03:10 blue_max_intensity +--w--wx-w- 1 root root 4096 Jul 7 03:10 blue_intensity + +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 + +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 necessary 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 + +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 + +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 -- 2.22.0.214.g8dca754b1e