From patchwork Tue Sep 17 17:59:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Murphy X-Patchwork-Id: 173901 Delivered-To: patch@linaro.org Received: by 2002:ac9:19ad:0:0:0:0:0 with SMTP id d45csp5443373oce; Tue, 17 Sep 2019 10:57:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqwpBwioTBbzcbJSGzodBZpRaKWJBW/EkliQQ5Qw36Bu3vYrARb1YYTW/yWSYJoGT6naFvzG X-Received: by 2002:a17:906:b2d4:: with SMTP id cf20mr3283509ejb.152.1568743065579; Tue, 17 Sep 2019 10:57:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568743065; cv=none; d=google.com; s=arc-20160816; b=uYWTGxk3XpX4bwuWpkrD2CbQfZMjXZ31yqj9Bm1gGEiB4M+5FNB8uwBdQeqpoz/dAf V/p02ZBMtDTyew4mxkLinN78WyB5D/5xhv8NWyS8FWnxK/2ZjpsXvHtPhuVhxJ31Ndhs oIvCS/6idBPWUhSqUnxFmi6QNZwNZNerzez3sZJ2NVCDH57dJMNAmD2xK9viY5ffut5b h94PLJnbp2+wSQ/G+mP0/Fj9mj3RQzxcWYnqox7PyAg5LAFZtIOx8xGHf/IiaBgp1OM9 TK68UVzsHROf0OZg4GfusCu0QohO0/TdEF4v6PZAFBwcY1M1oPHzSBSW4y2sfqqgHeOW PzaQ== 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=7MwYZlnlnWb2cwwvJ/JYyHXZiR63t3UoH9kTKj4QXnk=; b=Yz3A6xmUp8GdY+cb6oPQBahtvOHs8Zx3z2l/Ceo7W2bJzhy24LC1lrP/E9LyQRUtgz poNU+b5U8aqWJzt7AJ94Cbw3l3L2i3xZEtTY1sTH6uSxqC7nhTYfCNAnwLrlYYZfbRmg UErqyanQGdc+IoHqGZ5/kkFlo4YgmdiNgt7HBvvMLQJtfXu95alm61zmI2oZ/lsKicq6 3SYwmyiRrFl6P+MrLsa1LIKzqDOqCkOCQIOwdpoYnz1F3gDwoEe7aYP3JK39CPyF0usw sRlak8wMydY6uzzg0m6tGH4Y58FVjGjV5iCVyQ0QhAZaCzsK2eW5pNhK2Pk7RFTSMcL0 Db6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=nDfognu8; 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 q1si1470825eju.389.2019.09.17.10.57.45; Tue, 17 Sep 2019 10:57:45 -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=nDfognu8; 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 S1731423AbfIQR5o (ORCPT + 27 others); Tue, 17 Sep 2019 13:57:44 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:44372 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726758AbfIQR5k (ORCPT ); Tue, 17 Sep 2019 13:57:40 -0400 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id x8HHvYef051262; Tue, 17 Sep 2019 12:57:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1568743054; bh=7MwYZlnlnWb2cwwvJ/JYyHXZiR63t3UoH9kTKj4QXnk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=nDfognu8v/62eCHZnxmrOMuQZfTBTTuIOaGKVUBmbyR51fapcYh0wiVnKeXl3wMZX eTAnLMiEpSSPHRa6ZWTFY+CyXk5sTmimCY8PidFsyvjpDg5zNFOoRAPhAOwHDIvuB+ 1lcP+0OfVlOY1bIo+YcMXdP1cpS42p6YkWwMg4cA= Received: from DLEE109.ent.ti.com (dlee109.ent.ti.com [157.170.170.41]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x8HHvY5U116917 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 17 Sep 2019 12:57:34 -0500 Received: from DLEE110.ent.ti.com (157.170.170.21) by DLEE109.ent.ti.com (157.170.170.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Tue, 17 Sep 2019 12:57:31 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE110.ent.ti.com (157.170.170.21) 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; Tue, 17 Sep 2019 12:57:34 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id x8HHvXXa103830; Tue, 17 Sep 2019 12:57:34 -0500 From: Dan Murphy To: , CC: , , Dan Murphy Subject: [PATCH v6 2/9] documention: leds: Add multicolor class documentation Date: Tue, 17 Sep 2019 12:59:30 -0500 Message-ID: <20190917175937.13872-2-dmurphy@ti.com> X-Mailer: git-send-email 2.22.0.214.g8dca754b1e In-Reply-To: <20190917175937.13872-1-dmurphy@ti.com> References: <20190917175937.13872-1-dmurphy@ti.com> MIME-Version: 1.0 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 --- v6 - Removed color_mix and color_id files Documentation/leds/index.rst | 1 + Documentation/leds/leds-class-multicolor.rst | 101 +++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 Documentation/leds/leds-class-multicolor.rst -- 2.22.0.214.g8dca754b1e 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..d34feeb61284 --- /dev/null +++ b/Documentation/leds/leds-class-multicolor.rst @@ -0,0 +1,101 @@ +==================================== +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 is given its own directory. These directories will be one of +LED_COLOR_ID_* definitions from the header include/dt-bindings/leds/common.h. +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 + +colors/blue: +-rw------- 1 root root 4096 Jun 28 20:21 intensity +-r-------- 1 root root 4096 Jun 28 20:27 max_intensity + +colors/green: +-rw------- 1 root root 4096 Jun 28 20:22 intensity +-r-------- 1 root root 4096 Jun 28 20:27 max_intensity + +colors/red: +-rw------- 1 root root 4096 Jun 28 20:21 intensity +-r-------- 1 root root 4096 Jun 28 20:27 max_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