Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1494618imm; Sun, 23 Sep 2018 05:26:21 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdaz5z8Q4xVUc6Acuf7UZdtWl9N8JRH+iV/QeIzf1MSLgZAsFdOQs2OxpmVjf61M8cFlvNvv X-Received: by 2002:a62:868b:: with SMTP id x133-v6mr6304477pfd.252.1537705581548; Sun, 23 Sep 2018 05:26:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537705581; cv=none; d=google.com; s=arc-20160816; b=t1b4FB2z6kwbOZaQd6bfweSf+93CD/ZAKHD+TnidsB1A9IgveDJDMFEYS2GfpytlBW SviP2sqxTCkuMshtihKwIBOokQJR2mVleYue78rsvDnrClAcY8O9pFwM8UrfzsuYDmgi NjGJ4iQKhYekia69PWrl+FBlldE84JivUyg7g+JJw3QcjzzmaJbpl+FGU5/Hmij5hZCe azfoByThXbDYWKI775mp5zDW7RLqiEqynxr6goS16QJ6IpbI1nq23yN+Ob03R4gmkQL5 i6ixYq4U0gcp/N/lV/ofEvv1x1I/VsYb0G8NREiTV4pi6TG3w8sSUPO9UQ3/CkgTM9zE z8vQ== 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=LDspJhMOAlGKyJ9NWxEIyCGnp1hXIbBRmHINJQZiN1Q=; b=zjFoNcBJkKRx0d/OR2g7aHs7aSRjXZFP4CaayaLFtRc8H0Zu7N32phv1a9xa1LkvW5 GAEE2Qts354IepjbH0LNV5QpZvVMFZDyWjykMxEAlOc2C98js7ztSNkJwkU6N7VkzqyJ FFa4gqC27+PuGO3c2obfeg+AIvwOW3T39SnAe1v9cUCpvcw7YdzZPjhhuF9ZTT2U4iGR PRC7v4VuYoC+TY7w3lWQFYzX7hd+QauVj2s4bLK8ecw8mKP7QIUPtO3HigGypnO56042 lQi33p28iHdLAmUi9xPnaJxfAsNSPKh4GNnX7oCq7Um63qU5gZDmxRftk/3FV0NOj1dL V47w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=N0A8wGUK; 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 y14-v6si31739432plp.371.2018.09.23.05.25.49; Sun, 23 Sep 2018 05:26:21 -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=@gmail.com header.s=20161025 header.b=N0A8wGUK; 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 S1726213AbeIWSXD (ORCPT + 99 others); Sun, 23 Sep 2018 14:23:03 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:41458 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725869AbeIWSXD (ORCPT ); Sun, 23 Sep 2018 14:23:03 -0400 Received: by mail-wr1-f65.google.com with SMTP id j15-v6so12895229wrt.8; Sun, 23 Sep 2018 05:25:43 -0700 (PDT) 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=LDspJhMOAlGKyJ9NWxEIyCGnp1hXIbBRmHINJQZiN1Q=; b=N0A8wGUKBTyIJFR0hCPZvjpvZkHdAOJ8tOSK8qw4xFxiH3DvL0lH2iX92tYuPK4y/A KHAx9HyZbuOqWLtXpuDSozjKI+fA+JjTqepWbYFP/fuuF51ucCgJrw2kletteKsjmObD ZyZX6J39RzXmg7CoPPaJrKdVWGMFEmOhcArx4KxgUwzMUEFm9YxwbgB46+CfkDI/4dUj OIJrnYk55CnPCwvDNkB1ojbzI2YuKAtHiTDWgU69TDKvlHIiA56JiCuabRA2vR++YdNA kHDPIFhaMkhjGazRasuNmjiVmCqBVKnNI92mYybDVIQaEI7JPmSBrr2tW6LRaL9Klbau JY+Q== 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=LDspJhMOAlGKyJ9NWxEIyCGnp1hXIbBRmHINJQZiN1Q=; b=REHMiO5vn+qziOdthYJSjJiYNI8y81qy6coIvtXLXzW69UiYYTbiIvRAXdTQ5zVgIx 2ORiuzctDW3wRql4RpH3E9zBFMlIPeGEUVm9PuhHuVvLIF34XQ/Yk4O5EgfdlK3VRJTS hvSUuyUKDUS8Alr8s0YJ7idGIMwlXZqmds3Xoz2p/bEpPwzXK278ipEHUKVewhwALB3y gecsdh3rISnC9vdmdt8enji2oU2VmnA1KQVNfMW3EOvOnFbAYyOWSn/n3eTyXYXOgI5o VCiitflAF3QbFXBMl4JvE3tvCv1baJCzeihI+XzeLlafv8/UTxavhKPvIgmeRsxHJyTi F/Qw== X-Gm-Message-State: ABuFfoh7uKh5f0DHJrYKtIOhpqi7mmIM8R5U2UUov+/zBcimKhjdR3IF 1OWN38yUjjktzHlTaB+d2vJTXJiu X-Received: by 2002:a5d:554b:: with SMTP id g11-v6mr5137747wrw.228.1537705542529; Sun, 23 Sep 2018 05:25:42 -0700 (PDT) Received: from [192.168.1.18] (bkw28.neoplus.adsl.tpnet.pl. [83.28.190.28]) by smtp.gmail.com with ESMTPSA id l12-v6sm28236429wrv.29.2018.09.23.05.25.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 23 Sep 2018 05:25:41 -0700 (PDT) Subject: Re: [PATCH v12 1/2] leds: core: Introduce LED pattern trigger To: Pavel Machek , Baolin Wang , Bjorn Andersson Cc: rteysseyre@gmail.com, Mark Brown , Linus Walleij , Linux LED Subsystem , LKML References: <67ebebf02edd6d8ee42a13b139733e9cc680ea86.1536631975.git.baolin.wang@linaro.org> <324778a9-a32c-ae6e-337a-39845f214bfc@gmail.com> <20180921211758.GC18062@amd> <20180921221813.GA20355@amd> <20180922194451.GA27826@amd> From: Jacek Anaszewski Message-ID: <470f4037-b682-73f8-8063-b4d7a70e04bc@gmail.com> Date: Sun, 23 Sep 2018 14:25:39 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180922194451.GA27826@amd> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/22/2018 09:44 PM, Pavel Machek wrote: > On Sat 2018-09-22 00:18:13, Pavel Machek wrote: >> On Sat 2018-09-22 00:11:29, Jacek Anaszewski wrote: >>> On 09/21/2018 11:17 PM, Pavel Machek wrote: >>>> On Fri 2018-09-21 22:59:40, Jacek Anaszewski wrote: >>>>> Hi Baolin, >>>>> >>>>> On 09/21/2018 05:31 AM, Baolin Wang wrote: >>>>>> Hi Jacek and Pavel, >>>>>> >>>>>> On 11 September 2018 at 10:47, Baolin Wang wrote: >>>>>>> This patch adds one new led trigger that LED device can configure >>>>>>> the software or hardware pattern and trigger it. >>>>>>> >>>>>>> Consumers can write 'pattern' file to enable the software pattern >>>>>>> which alters the brightness for the specified duration with one >>>>>>> software timer. >>>>>>> >>>>>>> Moreover consumers can write 'hw_pattern' file to enable the hardware >>>>>>> pattern for some LED controllers which can autonomously control >>>>>>> brightness over time, according to some preprogrammed hardware >>>>>>> patterns. >>>>>>> >>>>>>> Signed-off-by: Raphael Teysseyre >>>>>>> Signed-off-by: Baolin Wang >>>> >>>>>> Do you have any comments for the v12 patch set? Thanks. >>>>> >>>>> We will probably have to remove hw_pattern from ledtrig-pattern >>>>> since we are unable to come up with generic interface for it. >>>>> Unless thread [0] will end up with some brilliant ideas. So far >>>>> we're waiting for Pavel's reply. >>>>> >>>>> [0] https://lkml.org/lkml/2018/9/13/1216 >>>> >>>> To paint a picture: >>>> >>>> brightness >>>> >>>> rise hold lower hold down >>>> ^ XXXXXXXXXXXXXXX >>>> | X XX >>>> | X XX >>>> | X XXXXXXXXXXXXXXXXXXXXXXXXXX >>>> +-------------------------------------------------------> time >>>> >>>> This is what Baolin's hardware can do, right? >>>> >>>> This is also what pattern trigger can do, right? >>>> >>>> So all we need to do is match the two interfaces, so that hw_pattern >>>> returns -EINVAL on patterns hardware can not actually do. >>>> >>>> I believe I described code to do that in [0] above. >>> >>> You said that we should get the same effect by writing the >>> same series of tuples to either pattern or hw_pattern file. >>> >>> Below command consists of four tuples (marked with brackets >>> to highlight), and it will activate breathing mode in Baolin's >>> hw_pattern: >>> >>> "[0 rise_duration] [brightness high_duration] [brightness fall_duration] >>> [0 low_duration]" >>> >>> Now, I can't see how these four tuples could force the software >>> fallback to produce breathing effect you depicted. >> >> I really should get some sleep now. But my intention was that software >> fallback produces just that with those four tuples. (If it does not, >> we can fix the software fallback to do just that). > > And you are right, v12 1/2 seems to do the wrong thing. > > My "brilliant idea" is to something closer to the original version I > posted here. I'm attaching it for reference. > > I'm also attaching the original documentation. It was clearly designed > to do smooth transitions, too. (But pattern is written in slightly > different way there, AFAICT). > > Clearly, having same semantics for pattern and hw_pattern is possible. Thank you for the attachment. The documentation part makes everything clear. Comparing the patch from the attachment and the Baolin's patch there is one vital part missing, from the original pattern_trig_update(): if (data->next->brightness == data->curr->brightness) { [...] } else { /* Gradual dimming */ led_set_brightness(data->led_cdev, compute_brightness(data)); data->delta_t += UPDATE_INTERVAL; mod_timer(&data->timer, jiffies + msecs_to_jiffies(UPDATE_INTERVAL)); } And the compute_brightness() implementation: static int compute_brightness(struct pattern_trig_data *data) { if (data->delta_t == 0) return data->curr->brightness; if (data->curr->delta_t == 0) return data->next->brightness; return data->curr->brightness + data->delta_t * (data->next->brightness - data->curr->brightness) / data->curr->delta_t; } With the above the linear gradual dimming is indeed feasible. And for non-linear dimming like breathing mode the hw_pattern will do. There is also vital discrepancy between the documentation and the proposed ledtrig-pattern implementation. The doc says: "Duration of 0 means brightness should immediately change to new value" This syntax seems to be not supported in the Baolin's patch. With all the above covered we will be almost there. Now, only the issues raised by Bjorn need a clarification: On 09/08/2018 07:02 AM, Bjorn Andersson wrote: [...] > The controls for my hardware is: > * a list of brightness values > * the rate of the pattern The two can be described using [brightness delta_t] tuples. > * a flag to indicate that the pattern should be played from start > to end, end to start or start to end to start As above, but the tuples would have to be suitably arranged. We won't need any specific flag to indicate how the pattern should be played, but instead explicitly give the tuples in the required order. For the start-end-start case the sequence of tuples will need to be tripled, but the middle part should be put in the reverse order. > * a boolean indicating if the pattern should be played once or repeated > indefinitely. We will have "repeat" file for that. Baolin, would you mind adding the support for gradual dimming to your ledtrig-timer.c implementation? -- Best regards, Jacek Anaszewski