From patchwork Thu May 30 18:16:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Murphy X-Patchwork-Id: 165451 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1309588ili; Thu, 30 May 2019 11:16:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqyY1yYkLS0cOO2M8o4x4fC7mHRkNKggBfBEOSfWUmGLIeBJJ7xOW7kooFuVaGC3EvsLWv8z X-Received: by 2002:a17:90a:cb10:: with SMTP id z16mr4582175pjt.81.1559240207724; Thu, 30 May 2019 11:16:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559240207; cv=none; d=google.com; s=arc-20160816; b=mj/iZHOjDMLx7LABRzJ5X2Lsiy5+jRSjOf3RpoNyc9BKLHsE4WldGvirq8jLkkCJAC 4khcGXk1IkmL6dwnaicDDkXXJyXgfIf58qAQt+ols7f7f7Yt7+iErgaZUiaSV2Rh2qSN xLxWjeeYGoNw/u5xvbE3f/nZcUmntM7uEIYBWtPOipWEUPbQOiIR9FTtcbVMDzqAyv3C 6sJ/BIGu5FnB8IW9uGx+Ql4+oKGROrgozd7tBVxhoO/RFz6+r9rm3WssquP06Oe2w2C6 36BuFCFmd4I+OTx7yZhW8uusJmsOcLzOKH2uzXGN+RgCoUQmChxraJPTYlNGmvF5/tfb 9mMg== 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=n5CWcuE9+ctR+DAwBJYtfbZT8XJJET44y5TBhMAnNIA=; b=U2GNaw+91NQ0g9GdYkDtPKIhfQOacn9j/YGRN1M9ARpyxO4I34443I+ec91dfn01hY 0LOCLSom9assWex1wF6vvsRbFS60dh6cmDg9BDtXACP4I+kETUyVAxzs3Lg2mGvMLDD3 wfh1Q5Lc3emdSw7gDUboaCHL0VOEXE7XuSY7Lw9aLgTWRr3RmHMbpubMsJRsNgryxMQQ ld4vgwKPQpLrMrEWIaEc6PTCmXQY/WOFwXDNRJiEaN/Qy9/SRquypgWl73qSayFgQL+D e1zJcyqTt1RmZ56FdhzL+zSnvEkHyzLeYfmnbBMckisXpC+/hM6Tk30Wcfppl39gBDQu bi9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=ldmRqpsU; 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 g8si3525458pjp.50.2019.05.30.11.16.47; Thu, 30 May 2019 11:16:47 -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=ldmRqpsU; 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 S1726779AbfE3SQq (ORCPT + 30 others); Thu, 30 May 2019 14:16:46 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:58358 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726280AbfE3SQp (ORCPT ); Thu, 30 May 2019 14:16:45 -0400 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id x4UIGVXa119476; Thu, 30 May 2019 13:16:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1559240191; bh=n5CWcuE9+ctR+DAwBJYtfbZT8XJJET44y5TBhMAnNIA=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=ldmRqpsUxMYEzje8WCgUGWkjZkNCMDZGIBa/oO4V8usY+yq0fDEShNdjdc3OMuvW2 uww3pZEqgtCeaFJVfqTgsJoPRJnld71wo2DMfVRd8nm/qmDzs89iieYbwAqHPu6Vt+ 69dsS/mSU39ClwezlMA6bDm3fwYJX1fXb3gxoyrs= Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x4UIGVGR094020 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 30 May 2019 13:16:31 -0500 Received: from DFLE104.ent.ti.com (10.64.6.25) 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; Thu, 30 May 2019 13:16:31 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE104.ent.ti.com (10.64.6.25) 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; Thu, 30 May 2019 13:16:31 -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 x4UIGVTM054264; Thu, 30 May 2019 13:16:31 -0500 From: Dan Murphy To: , CC: , , Dan Murphy Subject: [PATCH v4 2/2] documention: leds: Add multicolor class documentation Date: Thu, 30 May 2019 13:16:29 -0500 Message-ID: <20190530181630.30373-2-dmurphy@ti.com> X-Mailer: git-send-email 2.21.0.5.gaeb582a983 In-Reply-To: <20190530181630.30373-1-dmurphy@ti.com> References: <20190530181630.30373-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 --- v4 - Add LED class parent brightness description - https://lore.kernel.org/patchwork/patch/1078398/ Documentation/leds/leds-class-multicolor.txt | 159 +++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 Documentation/leds/leds-class-multicolor.txt -- 2.21.0.5.gaeb582a983 diff --git a/Documentation/leds/leds-class-multicolor.txt b/Documentation/leds/leds-class-multicolor.txt new file mode 100644 index 000000000000..c8658a068361 --- /dev/null +++ b/Documentation/leds/leds-class-multicolor.txt @@ -0,0 +1,159 @@ + +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 brightness 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 brightness and max_brightness files are presented for each LED. + +Under the "colors" directory there are two files created: "sync" and +"sync_enable". The sync_enable file controls whether the LED brightness +value is set real time or if the LED brightness value setting is deferred until +the "sync" file is written. If sync_enable is set then writing to each LED +"brightness" file will store the brightness value. Once the "sync" file is +written then each LED color defined in the node will write the brightness of +the LED in the device driver. + +If "sync_enable" is not set then writing the brightness value of the LED to the +device driver is done immediately. Writing the "sync" file has no affect. + +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 +--w------- 1 root root 4096 Jun 28 20:21 sync +-rw------- 1 root root 4096 Jun 28 20:22 sync_enable + +colors/blue: +-rw------- 1 root root 4096 Jun 28 20:21 brightness +-r-------- 1 root root 4096 Jun 28 20:27 max_brightness + +colors/green: +-rw------- 1 root root 4096 Jun 28 20:22 brightness +-r-------- 1 root root 4096 Jun 28 20:27 max_brightness + +colors/red: +-rw------- 1 root root 4096 Jun 28 20:21 brightness +-r-------- 1 root root 4096 Jun 28 20:27 max_brightness + +Example of Writing LEDs with Sync Enabled +----------------------------------------- +Below the red, green and blue LEDs are set to corresponding values. These +values are stored and not written until the sync file is written. + +cd /sys/class/leds/rgb:grouped_leds/colors + +echo 1 > sync_enable + +echo 100 > red/brightness +echo 80 > green/brightness +echo 180 > blue/brightness + +* LED device driver has not been updated and the LED states have not changed. +* Writing the LED brightness files again will only change the stored value and +* not the device driver value. + +echo 1 > sync + +* LED device driver has been updated; the LEDs should present the brightness +* levels that have been set. Since sync_enable is still enabled writing to the +* LED brightness files will not change the current brightnesses. + +Example of Writing LEDs with Sync Disabled +------------------------------------------ +Below the values of each LED are written to the device driver immediately upon +request. + +cd /sys/class/leds/rgb:grouped_leds/colors + +echo 0 > sync_enable + +echo 100 > red/brightness // Red LED should be on with the current brightness +echo 80 > green/brightness // Green LED should be on with the current brightness +echo 180 > blue/brightness // Blue LED should be on with the current brightness +. +. +. +echo 0 > green/brightness // Green LED should be off + +Multicolor Class Brightness Control +----------------------------------- +The multicolor class will redirect the device drivers call back +function for brightness control to the multicolor class brightness +control function. + +The brightness level for each LED is calculated based on the color LED +brightness setting divided by the color LED max brightness setting multiplied by +the requested value. + +led_brightness = requested_value*(led_color_brightness/led_color_max_brightness) + +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/brightness +echo 43 > /sys/class/leds/rgb:grouped_leds/green/brightness +echo 226 > /sys/class/leds/rgb:grouped_leds/blue/brightness + +red - + brightness = 138 + max_brightness = 255 +green - + brightness = 43 + max_brightness = 255 +blue - + brightness = 226 + max_brightness = 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 + +