From patchwork Thu Jul 25 18:28:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Murphy X-Patchwork-Id: 169747 Delivered-To: patch@linaro.org Received: by 2002:ac9:2daa:0:0:0:0:0 with SMTP id g42csp4403149oce; Thu, 25 Jul 2019 11:28:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqwH+25Br+1PaHOBlWkdoKPFMzhT1/VJQxGFsIrQgw6xvWa3s0Ks1WbOiCbpuF3bPL8cGslM X-Received: by 2002:a17:90a:d817:: with SMTP id a23mr85460127pjv.54.1564079338756; Thu, 25 Jul 2019 11:28:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564079338; cv=none; d=google.com; s=arc-20160816; b=gA5hTc4ZwREtRTZx73Pa8P2ThzNHlmZ5kX9ZcG1LtVJuGshKH8MobK31FU6v/NBDhj I2H2ducNFogdztThhn2LQFc6DgWjKf5RO2ocf1MULKAnwXpTioi4Llvk54UrMkJIDSId Nh+crISycAB+CloWobLpyAdwqZLifO8TaeRMPBWkizkxKJn8g+czhvnZ+l1O549bLuXy R7A5BJNlohZANBdISV7TPMh/IhDrrXOZ8c57V1hcjcrMNfrahWDkH4L/aTfUBowoCyDh z6FKl7gaGb4DmQdWp3HSiXsme861qadc3uf9865oaZ9kqconrte6AjE3W/eC8AGNyzXk Ou0Q== 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=d2Um8NUSqmU41wh2Qu83Hg9Gzg2ws/jWIFwu+itt4hs=; b=jdJkNV/KPr5hPglotwhJgaDYwL6W8Zhu25LB9RJlobbgWcabjZQixV8ovHW4XvnD9C pXye5eSYT44eCBUCJPUXJRedTaIUuiquJoo+HkPgIgAmeprmh0ebq8dCrwY7PP1T6ObO cxg5TSWqzGtZLVEpHrvtozcWEa2063KgRfJ6SPV+4FnPP1VNXYioePQFWot1dURm4eOC dMH7AywC9+ZJ66UvGjAIcYGji7+qRn4fOUWE+l2I4YnjnLbJ+nY7oYoR0XQ6RStvxgin a99JPbZ/Q4+VoaMW/T7zV8GVddlErP9iNi9p5wI9fY5/YYMOZIxUOBTFBTFzlygBfld0 fHgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=X6qjt3oH; spf=pass (google.com: best guess record for domain of linux-leds-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-leds-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 u17si18430381pgn.387.2019.07.25.11.28.58; Thu, 25 Jul 2019 11:28:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-leds-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=X6qjt3oH; spf=pass (google.com: best guess record for domain of linux-leds-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-leds-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 S1725800AbfGYS26 (ORCPT + 1 other); Thu, 25 Jul 2019 14:28:58 -0400 Received: from lelv0142.ext.ti.com ([198.47.23.249]:33764 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726191AbfGYS2Z (ORCPT ); Thu, 25 Jul 2019 14:28:25 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id x6PISMFg047417; Thu, 25 Jul 2019 13:28:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1564079302; bh=d2Um8NUSqmU41wh2Qu83Hg9Gzg2ws/jWIFwu+itt4hs=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=X6qjt3oHTK2bmMx+wnm99p3LKnQjIzDkt5y0jwRdNUfkVzgKJwmI4/JIv2/r7dmk0 2cF7/NrAgyDVJJlnBs92LbMZq1k/6ByaR4X/rYOwWYsvzQniJovYm677HfitCicHUG 1zPPIDJ2NLj0vT6VxqoYMcfG7ztXnOMD9We1zJ5s= Received: from DFLE110.ent.ti.com (dfle110.ent.ti.com [10.64.6.31]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x6PISMWu123624 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 25 Jul 2019 13:28:22 -0500 Received: from DFLE110.ent.ti.com (10.64.6.31) 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; Thu, 25 Jul 2019 13:28:21 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) 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; Thu, 25 Jul 2019 13:28:21 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id x6PISL72006548; Thu, 25 Jul 2019 13:28:21 -0500 From: Dan Murphy To: , CC: , , Dan Murphy Subject: [PATCH v4 2/9] documention: leds: Add multicolor class documentation Date: Thu, 25 Jul 2019 13:28:11 -0500 Message-ID: <20190725182818.29556-3-dmurphy@ti.com> X-Mailer: git-send-email 2.22.0.214.g8dca754b1e In-Reply-To: <20190725182818.29556-1-dmurphy@ti.com> References: <20190725182818.29556-1-dmurphy@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-leds-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-leds@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/leds-class-multicolor.txt | 152 +++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 Documentation/leds/leds-class-multicolor.txt -- 2.22.0.214.g8dca754b1e diff --git a/Documentation/leds/leds-class-multicolor.txt b/Documentation/leds/leds-class-multicolor.txt new file mode 100644 index 000000000000..3b354e523660 --- /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 "80 00 80" > 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 "38 80" > 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 + +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 + +