From patchwork Fri Sep 20 17:41:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Murphy X-Patchwork-Id: 174149 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp2785048ill; Fri, 20 Sep 2019 10:38:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqwN6M50uwydTcCbhc6qbXs5xr5H73lt/vS03qdmG6rSIoZlUwzPB1jPmEEiqgpRs4evPO9C X-Received: by 2002:aa7:dd8e:: with SMTP id g14mr20458049edv.233.1569001124073; Fri, 20 Sep 2019 10:38:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569001124; cv=none; d=google.com; s=arc-20160816; b=aVeaT2/fy/VsmSLKqLPSGbpqsMzI9qM9FnsJ6cAOvvR1mG+Bil+hxTBB/HI/ut1+Q4 yzGaHAHoRmtwZ+/Jxm59zcfRFoqo5nV/BZEwU2W2tsbEi7tufNU4ZFa1JZej9HQN48wd bj2y63A8qgIpBk6qRWzzw9UE3gEJgdRORT3+ZF2kZhWudOcFhi5iyU+13npCpzu7tl9z y+YlaFk1U8yYo/0dQ80ec1rvTQoz81XkDcqjGg0lPAAtlbT5SH0KdypeXXULz0EMDlKT gy3qbf7rBulaQdLNbFWsglkf+MRDBhDY1BI/grsUrOpvg7Z3+CsCcjO7xuVPAaJ5OEKF sksg== 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=MtXuJ92FL4DOwTwDiZA5d9Wg3Znuf/BWxvCovFJAC3riYP2IuXOG9CrSvaf5C8TZLB IjrkpWmjHLv7py26W/qMiRJJhM+XGNtHHxKa7jGYqp7ntlGEgjFoI9vOF1HZoXXVkBBs vz6jPTkyG37QFVZV7G0oHHaLxVxp22/f4cfNRsoKW4GjuPu4Ar+lZCkThi/muFUj6yHw jsmWKEF05MQcbxstOZaK3QQ2LPdUL+fd9AMosafn4jrMVqi2QARuPIsU4QKVIhcpYkdr zwqp+h2yZStrAJpMkY6rfD5XpE9aJZ2foSSNk8oQlY6S/wC6Xkj06SbbocDd/PTtMngi qqbg== 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-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 f14si1710061edt.92.2019.09.20.10.38.43; Fri, 20 Sep 2019 10:38:44 -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=V2pnsJrm; 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 S2392314AbfITRin (ORCPT + 1 other); Fri, 20 Sep 2019 13:38:43 -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 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/index.rst | 1 + Documentation/leds/leds-class-multicolor.rst | 91 ++++++++++++++++++++ 2 files changed, 92 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..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