From patchwork Thu Sep 19 18:36:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Murphy X-Patchwork-Id: 174093 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1376927ill; Thu, 19 Sep 2019 11:34:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqySQO6w4MnZbOCxru7nZDAKQvhaC6ItP88lTN5DJVO3FLXKdy1ZSj7R1vKG35AJc1wkz/b7 X-Received: by 2002:a17:906:2929:: with SMTP id v9mr15456843ejd.108.1568918074067; Thu, 19 Sep 2019 11:34:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568918074; cv=none; d=google.com; s=arc-20160816; b=XEGTKo0kgS+aMvgq3njJpzNRKuoKu27z7rhd/jNcC2qLswBFVtSNdayEjf5anKNCKX vPh52H9rfUrpu5HNFTLBN+j1O5UCTPNRCeg35992GR3le4ZT/Rq2t9hm/A7UoYzOyDCy +vjV3a9DGGe6smzB3lZPB4sbVqS4FFMsgDRGsS/Y093vwf+E9Ax9eCVftUcymZz3/svC TGH5fL4Fu6Qg3hts4cAjxS3Mok3CvBzFyY38oMgMZauBmEo0OoaPZW8ImXqR6gML7B/Q kBPk/x9IMVR+tdRIwyOK224h2HSEvSeMBlDuHppO7v6aWh7vXX8H2bFi3HcBmNb2qfnc qa0g== 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=ieQ+o/jIcTXK8zpFv7Xbkmj53STXWl23TqO60/qu/uNnLr04962FcSSsiTUfmq4vcm xFiaZCMzbUwDcMChvU6b/p0b1Uz+G5s/yPq9lwCfwNk6pg8brE/GYa/w7lxlXPKYJZfz jHt0Huyaoyp+sRhgdSLzSLqBj6+EyGzsqs5a5wydSNsCqfCeq1PP9L0qhq1v8wUTjtgv h+sermnWO588qoQGFj9A9It09ytnEd6uKPGMMNE42H6r23wUBrW1k9hYmuU8H8G61/6G yKrEOKTbQfYWNc+8BpBner2j6mq5ivloOZEd6p0vZEdH9d0pD4dTgHzrcA/HirH4xgdP wzog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="oRe9E6y/"; 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 i17si4908711ejy.374.2019.09.19.11.34.33; Thu, 19 Sep 2019 11:34:34 -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="oRe9E6y/"; 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 S2392078AbfISSeL (ORCPT + 26 others); Thu, 19 Sep 2019 14:34:11 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:50530 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732815AbfISSeL (ORCPT ); Thu, 19 Sep 2019 14:34:11 -0400 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id x8JIY7c7112788; Thu, 19 Sep 2019 13:34:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1568918047; bh=akFQwtB+8wepT0KN3wLxQAM5VrWw2YHk7/wv8nkby20=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=oRe9E6y/9LTAuKoAq0BztXONV2RRYzmn76pkNoryyhExi5CLxAgOfedRwXYFejABz wcXJ97bef9Sj2cJN6eEwGal5edYyXFhdP0ZRJGKpR4zdDuoCgbPMeGP/Qc00JuzhDd iV04cbUay+xwVNbS3VUBdzZVnIomW4hJ183km/h4= Received: from DLEE109.ent.ti.com (dlee109.ent.ti.com [157.170.170.41]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x8JIY71P107971 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 19 Sep 2019 13:34:07 -0500 Received: from DLEE104.ent.ti.com (157.170.170.34) 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; Thu, 19 Sep 2019 13:34:02 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE104.ent.ti.com (157.170.170.34) 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, 19 Sep 2019 13:34:03 -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 x8JIY6YC095536; Thu, 19 Sep 2019 13:34:06 -0500 From: Dan Murphy To: , CC: , , Dan Murphy Subject: [PATCH v7 2/9] documention: leds: Add multicolor class documentation Date: Thu, 19 Sep 2019 13:36:50 -0500 Message-ID: <20190919183657.1339-3-dmurphy@ti.com> X-Mailer: git-send-email 2.22.0.214.g8dca754b1e In-Reply-To: <20190919183657.1339-1-dmurphy@ti.com> References: <20190919183657.1339-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 --- 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