Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4645371imu; Sat, 19 Jan 2019 14:48:20 -0800 (PST) X-Google-Smtp-Source: ALg8bN6jpa1RAaezOMc82GDgbcnknPmCU8nLnanlCuaEJ19EnaPD1YnyXepaSuGcAogmkbWFjVB/ X-Received: by 2002:a17:902:2a66:: with SMTP id i93mr23869149plb.113.1547938100367; Sat, 19 Jan 2019 14:48:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547938100; cv=none; d=google.com; s=arc-20160816; b=I5mrVHVnArpgcPSzXHjE4mo1mTnwrsmAMfX5EPeHqS1W47mfKrogh1kc1OfXDbBp99 IHYcoyWkrcANIXFZxTteIPjlH5f4n8nW46gTGlRzNCk2Rw6I6RAoJr8EhY80DQN8Jt+E AQSsSqaTaWMIrQJP10rtTFfvq3TA+Fh+gw9I/hF4BDnxtX9dXoageNBTaOfHWgH4XV03 4FGNOpQnTzDGTWuwgA78wTp/mo7v/WTBjCo3OAdKNQ0cBqyhwE6z5L0Dhg1CA4BuKIyM Db4ZUvldJPFWJ30ItXk8eFfhC7RiZiomU276uZh+30wLLqEFWn+IWBYfqpz6IF1jYpAG cLaQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=L0YOTIMsx7Tz+0+MhwsFS0SOqJvKIQRQut62VGkLkHc=; b=NHwgQUX65W5ztk6MlaKE8EDjJsvdo/rqWn6THJY98GkZxPeX3mvJFlWIi85VupsQwn PQGkcBgcAWZvzQsHC4VFIfaTbx05c11Yzi/PjBdjZyFLZSVg8MYc50IfgVmhfHSUno9t wimzjErQpSsjkrzgcbnM4UAMegoL3CDuL5p6Zod13X5YcnAVSgH28k1bZW4/XgbckEHO R1qDlECgb72Nvsio60aMV9kkHyiDRDGZhbmPNH+9+3mfNsZBfdoweuke/6ysjOHuEApV bdSCZifroMRQK/btHH7HP78ZXdzrdYur0jCzJz44lG+TMXhrb659XE0tSjEEeAAW/nNc pLLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Jxs6+VXJ; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h1si7709139plt.44.2019.01.19.14.47.45; Sat, 19 Jan 2019 14:48:20 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=Jxs6+VXJ; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729766AbfASWoV (ORCPT + 99 others); Sat, 19 Jan 2019 17:44:21 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:37703 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729704AbfASWoV (ORCPT ); Sat, 19 Jan 2019 17:44:21 -0500 Received: by mail-lf1-f66.google.com with SMTP id y11so13000505lfj.4; Sat, 19 Jan 2019 14:44:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=L0YOTIMsx7Tz+0+MhwsFS0SOqJvKIQRQut62VGkLkHc=; b=Jxs6+VXJML5Fx9X+DS7ccW1KqkjrBYoWTOj2L1ydlVcDJHFdivvIkSbXdkMRMBFUFu 0LuxfP9bFTF+2Zja8O+WJCjP+Tl+EIACVTRRT9QdIzuocAU8tS5UtH5dV9QgMTtNQ4Ke gsvAizRr8g+x7+3yXww14bpkRk7EMnsXicQuwcJP5A8beJYNF7+GCHLjiBGXhFFsKR/J lCgTAsYrHxxOMdHLCrgFJgAZ0FOEBgNJC6Y04oYc1cuogtiTw3aH9rLeag3XMf7XTjfV qMFyPF/BSQT85I9n9k+K8GPQV05HTrBIp9phd9CnGrcTTgrDCSrZNEN6PIojym2PDNhj jExQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=L0YOTIMsx7Tz+0+MhwsFS0SOqJvKIQRQut62VGkLkHc=; b=fbmGeLs0wAFOziaTy6LnVcHmwAJHBKKL3W+bPIW7AwViDO1ywDE+HosrXcXZTA7MX0 iW9MFXQeJyAJVskSb6sNaiP0fg4QkBw+snG9zRhpRknpuxj7l+2xvfiOYjzTXxd5kmtf VrGLR5Y0ugio9tlXdzpPvuvDcsYjTvzYO8u1bGwhzOmbO9peUQzBoVf3DCC/aOI4UVQt 1dZAW8kofnksVnhFa+Eo+QnzcOGm4rGXDL3xCuTCvRc4L8pitJpqZFka7eK6Sd13hh1/ ZBLOvHLys211/C1KafqlW6I/SOqdzOflvSCBg1qsRo7lYu2mnvTUSfxOC5Nd/FaBE1K3 niig== X-Gm-Message-State: AJcUukdoaLZf95ZQHR5hqT3aeK2v0w3RxdXFLuIYTCYuUZ013WrguJkW yj1E8DTVffF31hTaEep3pe0= X-Received: by 2002:a19:c014:: with SMTP id q20mr14492527lff.16.1547937857606; Sat, 19 Jan 2019 14:44:17 -0800 (PST) Received: from ?IPv6:2001:14ba:8017:3300:7056:8bb8:4271:58c3? (dtynxhydtm6g7ttxvndbt-3.rev.dnainternet.fi. [2001:14ba:8017:3300:7056:8bb8:4271:58c3]) by smtp.googlemail.com with ESMTPSA id j25-v6sm1436651lji.77.2019.01.19.14.44.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 19 Jan 2019 14:44:17 -0800 (PST) Subject: Re: [PATCH v2 2/2] leds: lp50xx: Add the LP50XX family of the RGB LED driver To: Pavel Machek Cc: Jacek Anaszewski , Dan Murphy , linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, robh+dt@kernel.org References: <20190114211723.11186-1-dmurphy@ti.com> <20190114211723.11186-2-dmurphy@ti.com> <20190115222223.GA17363@amd> <79394d17-3124-75b2-ccac-dc1046499d14@ti.com> <20190116105537.GA1803@amd> <4115ad75-22f7-d9ae-c38f-e0ab61fb6655@gmail.com> <20190119214606.GA4712@amd> From: =?UTF-8?B?VmVzYSBKw6TDpHNrZWzDpGluZW4=?= Message-ID: <90b9a3f3-c42b-ac65-a6bf-08f94fdff47c@gmail.com> Date: Sun, 20 Jan 2019 00:44:15 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190119214606.GA4712@amd> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Pavel, On 19/01/2019 23.46, Pavel Machek wrote: > Hi! > >>> Moreover, I think that RGB LED class with configurable >>> brightness-model, and with possible color range adjustments via >>> icc-profiles or something similar, is the best solution that has been >>> proposed so far. It is just flexible. >>> >>> I'd like to capitalize on the ideas shared in this thread and have >>> finally LED RGB class materialized. >>> >> >> I have now updated my github code with my understanding of the discussion: >> https://github.com/vesajaaskelainen/linux/tree/wip-multi-color-led >> >> Commits: >> - dt-bindings: leds: Introduce linux,default-brightness-model for all leds >> https://github.com/vesajaaskelainen/linux/commit/4ffb21d644056686096226bbede7c8c78b0254c2 >> - drivers: leds: Add core support for multi color element LEDs >> https://github.com/vesajaaskelainen/linux/commit/627f38bb78cebc694b8e6d735fb088c87925435d >> - dt-bindings: leds: leds-pwm: Introduce multi color element leds support >> https://github.com/vesajaaskelainen/linux/commit/ef6c5730d621e79ea0b02470caa83bc39439536a >> - WIP: drivers: leds: leds-pwm: Add multi color element LED support. >> https://github.com/vesajaaskelainen/linux/commit/0430a27823d9162926424b32c23be1c53eb9cbe2 >> >> First two commits are common and could be taken before I am happy with the >> pwm led driver changes. This new conditional feature flag makes it a bit >> harder. Of course one option would be to require it to be enabled. >> >> Current set of concepts: >> - brightness-model: hardware, onoff, linear >> - could be extended in future with other modes like hsv if wanted > > Would it be enough to tell userspace what is relation between values > it writes and output power? > > Onoff is subset of linear, I guess. We already have max_brightness in > the API. > >> # Setting up color to not so bright purple with brightness set to 255 >> $ echo "32 0 32 255" > color > >> # Setting up color to a bit brighter purple with brightness >> $ echo "128 0 128 255" > color > > This would require colorspace conversion in kernel. I have: > > scales = (1., 0.39, 0.11) # for n900 > val = map(lambda x: int((x**2.2)*255), val) > (r, g, b) = val > > (r_, g_, b_) = m.scales > red = r*r_ > ... > > x**2.2 is simplified, real expression is more complex. But it is > floating point math... > > Do we want to do that? If we would have range in user space let say 0..255 for components and then in devicetree we could define ramp for each of the element like what is done for backlight pwm [1] [2]. I believe this would generate same result and user space interface would be a bit easier than writing direct pwm/power values. You could then tune this ramp based on properties of your led. And if you ran your software in another device it could behave similarly only requiring tuning in devicetree. For some of our lcd backlights we had generate non-linear ramp definition in devicetree to have linearly looking response when user configures brightness values from 0-100. Definition could be something like this in devicetree: element-red { pwms = <&ehrpwm0 0 100000 0>; brightness-levels = <0 128 256 1024 2048 4096 8192 16384 65535>; num-interpolated-steps = <32>; }; Don't know if better name would actually be in this case "ramp-levels" or such. Used pwm-backlights terminology in this example. [1] https://www.kernel.org/doc/Documentation/devicetree/bindings/leds/backlight/pwm-backlight.txt [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/video/backlight/pwm_bl.c?h=v5.0-rc2#n253 Thanks, Vesa Jääskeläinen