public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Young <sean@mess.org>
To: Thierry Reding <thierry.reding@gmail.com>
Cc: linux-media@vger.kernel.org, linux-pwm@vger.kernel.org,
	"Ivaylo Dimitrov" <ivo.g.dimitrov.75@gmail.com>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Mauro Carvalho Chehab" <mchehab@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6 4/4] media: pwm-ir-tx: trigger edges from hrtimer interrupt context
Date: Sat, 9 Dec 2023 09:52:09 +0000	[thread overview]
Message-ID: <ZXQ4yYx8QKu6wWwY@gofer.mess.org> (raw)
In-Reply-To: <ZXNEg3ax4MChSJ5A@orome.fritz.box>

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 <sean@mess.org>
> > ---
> >  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 <linux/slab.h>
> >  #include <linux/of.h>
> >  #include <linux/platform_device.h>
> > +#include <linux/hrtimer.h>
> > +#include <linux/completion.h>
> >  #include <media/rc-core.h>
> >  
> >  #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

      reply	other threads:[~2023-12-09  9:52 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1701248996.git.sean@mess.org>
2023-11-29  9:13 ` [PATCH v6 1/4] pwm: rename pwm_apply_state() to pwm_apply_might_sleep() Sean Young
2023-12-09 13:57   ` Uwe Kleine-König
2023-12-11  8:30     ` Sean Young
2023-12-10  3:59   ` Dmitry Torokhov
2023-11-29  9:13 ` [PATCH v6 2/4] pwm: make it possible to apply pwm changes in atomic context Sean Young
2023-12-08 16:19   ` Thierry Reding
2023-12-09  9:49     ` Sean Young
2023-11-29  9:13 ` [PATCH v6 3/4] pwm: bcm2835: allow pwm driver to be used " Sean Young
2023-11-29 17:47   ` Florian Fainelli
2023-12-08 16:22   ` Thierry Reding
2023-12-08 17:01     ` Sean Young
2023-12-08 17:20       ` Uwe Kleine-König
2023-12-09  9:11         ` Sean Young
2023-12-11 14:17         ` Thierry Reding
2023-11-29  9:13 ` [PATCH v6 4/4] media: pwm-ir-tx: trigger edges from hrtimer interrupt context Sean Young
2023-12-08 16:29   ` Thierry Reding
2023-12-09  9:52     ` Sean Young [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZXQ4yYx8QKu6wWwY@gofer.mess.org \
    --to=sean@mess.org \
    --cc=ivo.g.dimitrov.75@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=thierry.reding@gmail.com \
    --cc=u.kleine-koenig@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox