Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1017310ima; Wed, 24 Oct 2018 12:56:20 -0700 (PDT) X-Google-Smtp-Source: AJdET5ew1bpH4a9cSqepMJwqUkrAubray9hkvEmhpfDq3OslQVLAHeujnmwPwOQApzKz66NmBJL0 X-Received: by 2002:a63:f811:: with SMTP id n17mr3903268pgh.23.1540410980516; Wed, 24 Oct 2018 12:56:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540410980; cv=none; d=google.com; s=arc-20160816; b=XJRMgQlX1D1LdHF1baHKk6tTuFb+hG7tpLQdcTtDSFc/4+JJGKdvXBSPe/zINgrK7s a5ViKqI/PMEYVaMNA+HufSGStU2FnP8cbiH+cn8tnhvQpdPh/BSjk6SWNT7q4xmOrjTZ sbjn1Ad7PScQulHfbcOVfp12MwFLgGLiL7fPNZFqZeGhv8+eQo2gaSPBeG6Ip/esrvzp I87FaaZnfEPOifbs9W+h/CeDqMTMRiZT6FQU480lwZ+AyCfNu84ycM4IMxtS/MmAXsJZ m3KMS/Rvi0J36YDnl6XM2BI+NHUT9UhZHilYuAD5u+shAv5OyQgbT1Bhy8/oayPfl2ou 9PJA== 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; bh=kP6kJ/jiYzv0ENmPErdMiLwD6VP9A4wwc5r+1ETRqOM=; b=bqueZ9ep9K8AQdZrMDFUT9QyZailxQbAqMUftRxGGOX+/OJj7PCfy6SauFej/CSdBX e0dIm5BnWHxEwQ2A6TsvNsVxDOvVjUCwBVRcnzC2wVzt7Ws/I1QM3b8U9+SSrcYpVuYv q07DGpnVJkHcyF21rWoZ5d+oFG19fwfWK1Y6GETqphVksSjRvWSkXTfEn7QsxrXGeSRb 9VeSHWY5S8CStqS6EoiY5H5Ne/Nl4b4C/312Jb3Q8uOV0XY24Eo+sma6ch6qrlrEdnj/ sTWHv8bppNmpfhMgl0i+iz+K2POEsrs3NGCvfGqEUH4Vy64RXnU8JgByrrM9UX02wn06 hJUg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 33-v6si5659671plt.65.2018.10.24.12.56.04; Wed, 24 Oct 2018 12:56:20 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727284AbeJYEY7 (ORCPT + 99 others); Thu, 25 Oct 2018 00:24:59 -0400 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:38044 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726221AbeJYEY7 (ORCPT ); Thu, 25 Oct 2018 00:24:59 -0400 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 512) id C08978080F; Wed, 24 Oct 2018 21:55:28 +0200 (CEST) Date: Wed, 24 Oct 2018 21:55:29 +0200 From: Pavel Machek To: Jacek Anaszewski Cc: Baolin Wang , rteysseyre@gmail.com, bjorn.andersson@linaro.org, broonie@kernel.org, linus.walleij@linaro.org, linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v15 1/2] leds: core: Introduce LED pattern trigger Message-ID: <20181024195529.GA23069@amd> References: <9794969ab8a5a6f62d8ac54cdebcaa3caedfc6d6.1539230481.git.baolin.wang@linaro.org> <20181024083143.GA24165@amd> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="EVF5PPMfhYS0aIcm" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --EVF5PPMfhYS0aIcm Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed 2018-10-24 21:17:25, Jacek Anaszewski wrote: > On 10/24/2018 10:31 AM, Pavel Machek wrote: > > Hi! > >=20 > >>> + > >>> + The gradual dimming format of the software pattern values should b= e: > >>> + "brightness_1 duration_1 brightness_2 duration_2 brightness_3 > >>> + duration_3 ...". For example: > >>> + > >>> + echo 0 1000 255 2000 > pattern > >>> + > >>> + It will make the LED go gradually from zero-intensity to max (255) > >>> + intensity in 1000 milliseconds, then back to zero intensity in 2000 > >>> + milliseconds: > >>> + > >>> + LED brightness > >>> + ^ > >>> + 255-| / \ / \ / > >>> + | / \ / \ / > >>> + | / \ / \ / > >>> + | / \ / \ / > >>> + 0-| / \/ \/ > >>> + +---0----1----2----3----4----5----6------------> time (s) > >>> + > >=20 > > Ok, so I got around to testing this. > >=20 > > echo "0 1000 10 2550 0 1000 0 100" > pattern > >=20 > > makes expected pattern [ .-xXx-. ]. > >=20 > > But when I do > >=20 > > echo "0 1000 10 2550 0 1000" > pattern > >=20 > > I only get expected pattern on the first iteration, then I get > > [ Xx-. ]. >=20 > This is because the tuples are processed in a loop, without > discerning between start and end of the sequence. >=20 > So this sequence ends up being squashed, because of the > comparison: >=20 > if (data->curr->brightness =3D=3D data->next->brightness) { > //step change od brightness > ... > /* Skip the tuple with zero duration */ >=20 > Here we actually only assume that this is zero duration since it > is not checked. Possibly needs fixing. >=20 > pattern_trig_update_patterns(data); > /* Select next tuple */ > pattern_trig_update_patterns(data); I came up with this (untested). diff --git a/drivers/leds/trigger/ledtrig-pattern.c b/drivers/leds/trigger/= ledtrig-pattern.c index ce7acd1..174a298 100644 --- a/drivers/leds/trigger/ledtrig-pattern.c +++ b/drivers/leds/trigger/ledtrig-pattern.c @@ -87,9 +87,10 @@ static void pattern_trig_timer_function(struct timer_lis= t *t) data->curr->brightness); mod_timer(&data->timer, jiffies + msecs_to_jiffies(data->curr->delta_t)); - - /* Skip the tuple with zero duration */ - pattern_trig_update_patterns(data); + if (!data->next->delta_t) { + /* Skip the tuple with zero duration */ + pattern_trig_update_patterns(data); + } /* Select next tuple */ pattern_trig_update_patterns(data); } else { > In effect we have: >=20 > 0 -> 10 // dimming > 10 -> 0 // dimming > 0 skipped // step > 10 -> 0 // dimming > 0 skipped // step > 10 -> 0 // dimming > ... >=20 > In order to get "rise - fall - rise - fall" sequence you need > only two tuples: Well, I wanted "rise - fall - delay - rise - fall - delay" sequence. Let me test the patch... Thanks, Pavel --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --EVF5PPMfhYS0aIcm Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAlvQzjEACgkQMOfwapXb+vKLkACeIHhMioSMLFhRKkNBlfclo3zN R5kAnRbvPqhpQxgvSggL2wIi9/fC84oX =5tUS -----END PGP SIGNATURE----- --EVF5PPMfhYS0aIcm--