Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp778644imm; Wed, 29 Aug 2018 11:58:17 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaxFajmtDNbz5FTf2qbK62uwnRIBV+xJKSjvXOyDWnRL33gpzwC0o4sqSUyGIRw5bxH8gcF X-Received: by 2002:a17:902:76c5:: with SMTP id j5-v6mr7110940plt.140.1535569097402; Wed, 29 Aug 2018 11:58:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535569097; cv=none; d=google.com; s=arc-20160816; b=LPwRjcJWdFrD5fvyZRHz7jajs7P+hVNP3qo9QpaFY2A+2k2QijpzAB3jp1NQqiBAk6 huX1uhuoOsUQuDxIQbdkr2WpfOh518yQnQEA56ChLjjvM9sZDJZyOfm2WD8gksnc22Ub nl6nC9vuG59ThiQjloPKqD6zdhAYn++jyMswLIbBDxHG9MRbBnl9wLrFJY/y3yC+pET2 JBqDBNnaHyJaXOJlWEBRKPaCBNHUJEdsyI6L2MuomECocarBSsIEZS/4be8bs9jS9FLW z4vvTpjDAI/Kzf1F7qSHWMqNwqxDY+b1judtz/Vw7VHu/BaNnorzeN8LsBZ2p8U9FM2Y sYtA== 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 :arc-authentication-results; bh=jrVnkk74ldmRMlSZTQnEn84eKYHk4HRLhSd4OxKqPq4=; b=FRp91FkQUr0w8fBUmQJuEv8tAxEdiGD40RFDmB33XWwwpyUEAD7Sc15AUl2w6+GXlD cruY2xesAiyN1KBjb95ta/+lrhg7gQhVW3gB4bd80muln+EfTOeiUhEa2STebjg+YmEr 57Qpyn2C6AobeQzY04JUTrIhVaSPMgYn83JoDOTDF1L23fMSa8oslTweXsh6YwUdUK+z an7wP9cKlS6pZxdhl91I879zxLdyeau5wg4/LhRecmJ3+b4XWrzIRiUwtcEwy/zPyXHl HMp2Zw4GzfnqaG0rdq+BwG/fC6jgjBOs/fpb/+RX1DJBXt+CX15zU8W+P+yEW5j7ktGs e75A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Bw7L1YkL; 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 h6-v6si4707726pls.150.2018.08.29.11.57.48; Wed, 29 Aug 2018 11:58:17 -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=Bw7L1YkL; 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 S1727856AbeH2WyM (ORCPT + 99 others); Wed, 29 Aug 2018 18:54:12 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:40588 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727335AbeH2WyL (ORCPT ); Wed, 29 Aug 2018 18:54:11 -0400 Received: by mail-wr1-f67.google.com with SMTP id n2-v6so5782889wrw.7; Wed, 29 Aug 2018 11:55:57 -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=jrVnkk74ldmRMlSZTQnEn84eKYHk4HRLhSd4OxKqPq4=; b=Bw7L1YkLdLsc4HvHky5AvKbtKWUV6gnBMNBP8Cq7/pMZuEP4Pg5eISByhu9QOhisrV cqt511l0jMSWnT8UhuC0thljNL/HoUMc1pkL2rLCI8gnqNO+Vo/JSytdXcWgpToFhiXl wKR/vUPdepnLTKD5s7rOwIcZXbYnxdWZdWJolJwZi2F7aStEtpcHwM877lG5C5d3Un8x ZljWZpyTnO4b4nQvQWdGBQ/ol5/8wLWJuHZHxxy3gfZ4QbaE1sG+sglLcOTW0tUPpP2V lXLK56GIX9No3+1w6NrU4svZuANgq+kSHh8uMKBnjDKWkMZ3QNMN27x2RLk+4yFt/fS+ uWuw== 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=jrVnkk74ldmRMlSZTQnEn84eKYHk4HRLhSd4OxKqPq4=; b=sJLtY3vgrRx0cS29+PE/MmSqD3ae+n5+JYIOsgwc1vfjAoJ+P/jYadKuHRXs9BUPIn iXE7YyifuocIPy8SI+XMZhDdv6TL0KAG9/ooAl4EY+xhCM6SQSZrl8i0y5laHdz/QeqC G8nEU/Vn+JJEAYU8yHYAXigQtKqTzOSNKbCgASGbQAMtg+L2In380ioXU8DGGaqZ1zxh vIvFOYuFusEDBsB4XPH/JwT9rSWOrnidYfP7lFLjJhfw3p45sEhqH+rpm7jMllCWVfwW tx/diWWnmnloiDhxfVHHGvatCZx65KXK3VdM+RAUdZTg2OZbUQEC9r3Zqj03rC3Z72ib mazg== X-Gm-Message-State: APzg51Bs5LMAjQiw1Be97DH2jSWmk1iYN3w5JKzwCpwIyp0ipfBTCZst lchgIk/WuPwACp+TwkJVqFmG1kM+ X-Received: by 2002:adf:ae01:: with SMTP id x1-v6mr5162831wrc.45.1535568956415; Wed, 29 Aug 2018 11:55:56 -0700 (PDT) Received: from [192.168.1.18] (bkz141.neoplus.adsl.tpnet.pl. [83.28.193.141]) by smtp.gmail.com with ESMTPSA id p89-v6sm8635500wrc.97.2018.08.29.11.55.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Aug 2018 11:55:55 -0700 (PDT) Subject: Re: [PATCH v5 1/2] leds: core: Introduce LED pattern trigger To: Bjorn Andersson Cc: Baolin Wang , Pavel Machek , rteysseyre@gmail.com, Mark Brown , Linux LED Subsystem , LKML 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> <20180828211326.GI2523@minitux> From: Jacek Anaszewski Message-ID: Date: Wed, 29 Aug 2018 20:55:53 +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: <20180828211326.GI2523@minitux> Content-Type: text/plain; charset=utf-8 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 08/28/2018 11:13 PM, Bjorn Andersson wrote: > 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? True, when it is related to hardware pattern. Software pattern would have common both file and interface. Alternatively, we could have two separate files for setting software and hardware pattern. -- Best regards, Jacek Anaszewski