Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp7549072imm; Tue, 28 Aug 2018 14:15:02 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaLh7G3eEogMNZ+za49XzbDwCJ3uaprTxNDr1MizhcVfwP+1kXLpqVVS1CfVxqgChfH9tbB X-Received: by 2002:a17:902:9a83:: with SMTP id w3-v6mr3191970plp.75.1535490902527; Tue, 28 Aug 2018 14:15:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535490902; cv=none; d=google.com; s=arc-20160816; b=t8p2R1BmSHI9IzCtRVZgrw5KEO+04xFE+EouyUrRrqk3uyMQA55u4c+9G2Ih2fOQ4+ S/a8941bZll4A8OVlKpoZLoNc1fro+al7uNX2d30aHbOa52l+llpeDZ1kojw6vQtpVEL Cfn0tfffp4AWflzwNv5RVc4hLuPJpVuhOpgf7l+PEfsyMJw81G9oVF1N52mZvgXqQ/aC 6mypwIQEra5MFqUjHN6o53yNhdl7yl3rwciACO1Y0NOqzI9f7yFS9O7LvPhB6yhns3ql SCcNhdHs+gjsEDJ0b33aRhOUXHDR9syLKFyd/G7OTYhV/QlA+Vq+KCfPHhGpWSV4fAld yiQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=e7VINsH8koltelR+yCyoQDvGAQJrwWmKRgn67eGDey0=; b=UhUbJfO/ohZa7ONLjvfZ9ZBqxy4LRjY+yJcZJXQdaLsNW865Eu/Uv0AI5wKGMxC3iK HKrp2rYFdXiMmM6j3rlfekHtPiIaYmL+nf4OmU7HxsAWnRWX8PybOJ/oAREPYFlUbem3 4hcNo3hHtCghrrvVX1z/xyPPeeOO7/9tW9U/Di7TIIe1Sz1Arh7rY7MCFxy9kh/SEj9N 78g42/QnzRII4dfGP7fywU05eZgmgw/zLsAlJ9M5vLxyYfq3GsEVJya5GigoNklfi9Lw 3Wul1ViyWvwbCxbxLOykGj8ZUQS7lzLMwzthHZykRZKbKgCuid87vuEI6vRXarPICb8C T45A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="K+y/pi44"; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p1-v6si1862869plb.197.2018.08.28.14.14.45; Tue, 28 Aug 2018 14:15:02 -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=@linaro.org header.s=google header.b="K+y/pi44"; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727452AbeH2BG6 (ORCPT + 99 others); Tue, 28 Aug 2018 21:06:58 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:46631 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727098AbeH2BG6 (ORCPT ); Tue, 28 Aug 2018 21:06:58 -0400 Received: by mail-pl1-f193.google.com with SMTP id a4-v6so1255755plm.13 for ; Tue, 28 Aug 2018 14:13:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=e7VINsH8koltelR+yCyoQDvGAQJrwWmKRgn67eGDey0=; b=K+y/pi447OAs4226ChuwMwGW1btAegKpfr8l8CD/yzbDe+3fgOZZnBW2bKxeTCPp3h cZiBoD3CZ4HeNhoMjsqoEdwvc9lURf8Mb/K9VhoSTCyNEADjJieSQ5UkCBlr+gp83Irt yv1Xu9wUwgA01mP5ce7eStpm+XaPys3xx9q0c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=e7VINsH8koltelR+yCyoQDvGAQJrwWmKRgn67eGDey0=; b=pTjXlMVwxFa20BwosYPQaj3C3kckklLEdsJOgem1Qd85mYranfL3THREezLxDfef9z gMNqpV3uvaGW9f2lIiGmhuFox8Rp97KUHUL5WcG85fZ5cRIG8DTiYaI9iQBUaBjGdkRq BUTdvBHzi96mw+JbA2rbBVsCnjc/MO4zwppH1W2o8CN3NGR4xF70dcVGNyjnXLEmeDNc GrSyO0qzzauFMiUHcFBLHw+NqnVKxEf7hbBBsQRmdzqgxD2nvCtwoPvSwExdUWT3SU/n TMiRr+DMGMHRWLmYgHNPtFMLLUOycSpZeae2f7M1/ILmqhiib5hyxz9kPZaRjcOqxRgf hApg== X-Gm-Message-State: APzg51ANSOD46uzx7cflmkKrbexmUa+Ej0MsON/2mM87/vhMoZ8UGL6w cay95BJHUSJIqlSSxTrXTEbTOg== X-Received: by 2002:a17:902:934c:: with SMTP id g12-v6mr3102508plp.67.1535490809579; Tue, 28 Aug 2018 14:13:29 -0700 (PDT) Received: from minitux (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id i1-v6sm5979332pgj.38.2018.08.28.14.13.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Aug 2018 14:13:28 -0700 (PDT) Date: Tue, 28 Aug 2018 14:13:26 -0700 From: Bjorn Andersson To: Jacek Anaszewski Cc: Baolin Wang , Pavel Machek , rteysseyre@gmail.com, Mark Brown , Linux LED Subsystem , LKML Subject: Re: [PATCH v5 1/2] leds: core: Introduce LED pattern trigger Message-ID: <20180828211326.GI2523@minitux> References: <1dc5d394324b2bf1ffe229b8e42691fab6d749e0.1533556992.git.baolin.wang@linaro.org> <20180824101145.GA1510@amd> <9bb7ac19-36a6-d11a-6d46-fc65c2026201@gmail.com> <20180824201227.GB17146@amd> <52eb7b5f-a405-06d1-2758-f27401a3ce3b@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <52eb7b5f-a405-06d1-2758-f27401a3ce3b@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 28 Aug 13:25 PDT 2018, Jacek Anaszewski wrote: > On 08/25/2018 09:51 AM, Baolin Wang wrote: > > On 25 August 2018 at 04:44, Jacek Anaszewski wrote: > >> On 08/24/2018 10:12 PM, Pavel Machek wrote: > >>> On Fri 2018-08-24 21:49:50, Jacek Anaszewski wrote: > >>>> Hi Pavel, > >>>> > >>>> On 08/24/2018 12:11 PM, Pavel Machek wrote: > >>>>> Hi! > >>>>> > >>>>>> I think that it would be more flexible if software pattern fallback > >>>>>> was applied in case of pattern_set failure. Otherwise, it would > >>>>>> lead to the situation where LED class devices that support hardware > >>>>>> blinking couldn't be applied the same set of patterns as LED class > >>>>>> devices that don't implement pattern_set. The latter will always have to > >>>>>> resort to using software pattern engine which will accept far greater > >>>>>> amount of pattern combinations. > >>>>>> > >>>>>> In this case we need to discuss on what basis the decision will be > >>>>>> made on whether hardware or software engine will be used. > >>>>>> > >>>>>> Possible options coming to mind: > >>>>>> - an interface will be provided to determine max difference between > >>>>>> the settings supported by the hardware and the settings requested by > >>>>>> the user, that will result in aligning user's setting to the hardware > >>>>>> capabilities > >>>>>> - the above alignment rate will be predefined instead > >>>>>> - hardware engine will be used only if user requests supported settings > >>>>>> on the whole span of the requested pattern > >>>>>> - in each of the above cases it would be worth to think of the > >>>>>> interface to show the scope of the settings supported by hardware > >>>>> > >>>>> I'd recommend keeping it simple. We use hardware engine if driver > >>>>> author thinks pattern is "close enough". > >>>> > >>>> The thing is that in the ledtrig-pattern v5 implementation there > >>>> is no option of using software fallback if pattern_set op > >>>> is initialized: > >>>> > >>>> + if (led_cdev->pattern_set) { > >>>> + return led_cdev->pattern_set(led_cdev, data->patterns, > >>>> + data->npatterns, data->repeat); > >>>> + } > >>> > >>> Yeah, that sounds wrong. (Sorry I did not pay enough attention). > >>> > >>> It pattern_set() returns special error code, it should just continue > >>> and use software pattern fallback. > >> > >> And now we can get back to the issue I was concerned about in the > >> email you replied to, i.e. what series of [brightness delta_t] tuples > >> should be written to the pattern file to enable hardware breathing > >> engine. > > > > OK. So now we've made a consensus to use the software pattern fallback > > if failed to set hardware pattern. How about introduce one interface > > to convert hardware patterns to software patterns if necessary? > > > > diff --git a/drivers/leds/trigger/ledtrig-pattern.c > > b/drivers/leds/trigger/ledtrig-pattern.c > > index 63b94a2..d46a641 100644 > > --- a/drivers/leds/trigger/ledtrig-pattern.c > > +++ b/drivers/leds/trigger/ledtrig-pattern.c > > @@ -66,8 +66,15 @@ static int pattern_trig_start_pattern(struct > > pattern_trig_data *data, > > return 0; > > > > if (led_cdev->pattern_set) { > > - return led_cdev->pattern_set(led_cdev, data->patterns, > > - data->npatterns, data->repeat); > > + ret = led_cdev->pattern_set(led_cdev, data->patterns, > > + data->npatterns, data->repeat); > > + if (!ret) > > + return 0; > > + > > + dev_warn(led_cdev->dev, "Failed to set hardware pattern\n"); > > + > > + if (led_cdev->pattern_convert) > > + led_cdev->pattern_convert(led_cdev, > > I can't see how it could help to assess if hw pattern > engine can launch given pattern, and with what accuracy. > > Instead, I propose to add a means for defining whether the pattern > to be set is intended for hardware pattern engine or for software > fallback. It could be either separate sysfs file e.g. hw_pattern, > or a modifier to the pattern written to the pattern file, e,g, > > echo "hw 100 2 200 3 100 2" > pattern > > hw format expected by given driver would have to be described > in the per-driver ABI documentation. All patterns without > "hw" prefix would enable software pattern engine. > We started this discussion with the suggestion that rather than introducing a new Qualcomm specific sysfs interface for controlling the pattern engine we should have a common one, but if I understand your suggestion we should not have a common interface, just a common sysfs file name? Regards, Bjorn