Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2859024rdb; Sat, 9 Dec 2023 01:52:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IFdWFmiQdne5r5gNdoj5fWOMOvJZG/HxXLogIfpMczhQX6SDdW0NxoLav19+QADS6AWrlj7 X-Received: by 2002:a05:6602:2195:b0:7b3:aa87:342a with SMTP id b21-20020a056602219500b007b3aa87342amr1700484iob.1.1702115546113; Sat, 09 Dec 2023 01:52:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702115546; cv=none; d=google.com; s=arc-20160816; b=TuWhi+cO1H4jS68hFhWvLmxAXqsM4K/wDUJzWF5J0rz5b71X4Stlv52xvnI9MhvkAf wprGkjGoU+YpG7/CDezJWfIzzeSdkfE6Wf8mdGkkn0KaVwkQu16shfrjrIhTM77UMTm1 hRSX3c8cgRSfwNuOxKHJUdI65gC3BYVRM951gAy8iYM4V3olzNLDLhS3X1rKCdh0TGVG ngDf7Tg3boa5Mb5W0n+VN6knLiX1el6/o69oiWSsC8fCqNn4gdgzR4ykqf504mFg6oWg BrvSpxScxkWZE+BrphVjTPIpqXTa27TKJ4/Vf5FfdZVS6pv1CBFIXVZBs6wp7saZc8Rj GG+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=hU3KmRUZBDCZYjS7Ip5BGpwQhT7+L+WI/LrXpAwkzo0=; fh=pQoMWjPiNOFc59Xiz5qGKlGospYvFN0vdCCy/WOWMnk=; b=Cov44v4t4sImtKGucPaINCGiZR2dhvvIKZHuLc+Vtz7gFV/Zy2SmbciGH2t/m+cwFs lsgne17bwg5YdiKERz3uuaRYrLpL6GWme+WkvMuVA9aZ7qqc9MqlRRtUCMnGqHj60Yh8 qg8ayPrmjxJ6HRE8dw+W3oiMwPN6jPai7HqO/gXQICFszmOPxKbKQcYgkONQtL+qtaIS V8a5iOeyCKSJ/SoDWo+H5qc7GDATV95EwzImGTJAyGse1v1PrF2MzRBRl5AF0HUzXWYd 0E5rA6Je7yt/eM/8/m5TCq3x3RT6j6nXIPlQSdyOIGzJizFQfEhR+oyt3bPTct1vfBFP uJLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mess.org header.s=2020 header.b=ji0yme4w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mess.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id i6-20020a170902eb4600b001d0b6caddbbsi2888411pli.545.2023.12.09.01.52.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Dec 2023 01:52:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@mess.org header.s=2020 header.b=ji0yme4w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mess.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id ACD158063035; Sat, 9 Dec 2023 01:52:23 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229451AbjLIJwG (ORCPT + 99 others); Sat, 9 Dec 2023 04:52:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229446AbjLIJwE (ORCPT ); Sat, 9 Dec 2023 04:52:04 -0500 Received: from gofer.mess.org (gofer.mess.org [IPv6:2a02:8011:d000:212::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FED210C7; Sat, 9 Dec 2023 01:52:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mess.org; s=2020; t=1702115529; bh=ylrgEA3zbjC4BUaTh9xcfvwH7XspfsRlgzCDfDuD0Cs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ji0yme4wBw9VwSR0+h+ffZxLjj3LK6jkp4/rm+0K39pVYaYYMpMVcTYEj74xUfhfg ET9cjglES2OqhiijJjav7UxIQvVLUFAYSvNRXwK+oxqfh8xTNxqNszVxqYs9tWJ6AJ pnK7Jnyia/WJOrRq179PhiZ6zLIh/dPzuwTKA2qrujCbiYlx7Kx4EcTTVDtrUkN9rl uh91y3c48meztAKYlLdvsL5pThDPl/uZMyVM1iecO4721Uy97/oGFqybVA9mTcmB4+ u8k9qDhW7glRaPj2SeLJHvxWVSB/KOTVWM8vte2/PRAUFMAh+1/GuHoMMoEJtq6mL8 F0ogWKqRYA0OQ== Received: by gofer.mess.org (Postfix, from userid 1000) id 4D4D1100091; Sat, 9 Dec 2023 09:52:09 +0000 (GMT) Date: Sat, 9 Dec 2023 09:52:09 +0000 From: Sean Young To: Thierry Reding Cc: linux-media@vger.kernel.org, linux-pwm@vger.kernel.org, Ivaylo Dimitrov , Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: Re: [PATCH v6 4/4] media: pwm-ir-tx: trigger edges from hrtimer interrupt context Message-ID: References: <88fdb3a200989458c6f95c26fa9bb84c1e864798.1701248996.git.sean@mess.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Sat, 09 Dec 2023 01:52:23 -0800 (PST) On Fri, Dec 08, 2023 at 05:29:55PM +0100, Thierry Reding wrote: > On Wed, Nov 29, 2023 at 09:13:37AM +0000, Sean Young wrote: > > This makes the generated IR much more precise. Before this change, the > > driver is unreliable and many users opted to use gpio-ir-tx instead. > > > > Signed-off-by: Sean Young > > --- > > drivers/media/rc/pwm-ir-tx.c | 79 ++++++++++++++++++++++++++++++++++-- > > 1 file changed, 76 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/media/rc/pwm-ir-tx.c b/drivers/media/rc/pwm-ir-tx.c > > index cf51e2760975..8575c4596d7b 100644 > > --- a/drivers/media/rc/pwm-ir-tx.c > > +++ b/drivers/media/rc/pwm-ir-tx.c > > @@ -10,6 +10,8 @@ > > #include > > #include > > #include > > +#include > > +#include > > #include > > > > #define DRIVER_NAME "pwm-ir-tx" > > @@ -17,8 +19,14 @@ > > > > struct pwm_ir { > > struct pwm_device *pwm; > > - unsigned int carrier; > > - unsigned int duty_cycle; > > + struct hrtimer timer; > > + struct completion tx_done; > > + struct pwm_state *state; > > + u32 carrier; > > + u32 duty_cycle; > > + uint *txbuf; > > Maybe mark this as const to signal that it's not going to get modified? Ah nice, I usually forget const. > > + uint txbuf_len; > > + uint txbuf_index; > > uint is rather rare. Or so I thought. There seem to be quite a few > occurrences throughout the kernel. I'd still prefer unsigned int over > this abbreviated form, but ultimately up to you and Mauro to decide. Yes, unsigned int is used a lot more. Changed. > > static int pwm_ir_probe(struct platform_device *pdev) > > { > > struct pwm_ir *pwm_ir; > > @@ -103,10 +167,19 @@ static int pwm_ir_probe(struct platform_device *pdev) > > if (!rcdev) > > return -ENOMEM; > > > > + if (pwm_is_atomic(pwm_ir->pwm)) { > > + init_completion(&pwm_ir->tx_done); > > + hrtimer_init(&pwm_ir->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); > > + pwm_ir->timer.function = pwm_ir_timer; > > + rcdev->tx_ir = pwm_ir_tx_atomic; > > + } else { > > + dev_info(&pdev->dev, "tx will not be accurate as pwm device does not support atomic mode"); > > s/tx/TX and s/pwm/PWM/? Also, I'm a bit unhappy about "atomic mode" here > because the term is overloaded in PWM. If you call pwm_appy_*() then by > definition it's going to be "atomic" in the "atomic state" sense. So > maybe switch to something like: > > "TX will not be accurate as PWM device might sleep" > > ? Very nice, changed. Thanks Sean