linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Kees Cook <keescook@chromium.org>,
	Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Sean Young <sean@mess.org>, Hans Verkuil <hans.verkuil@cisco.com>,
	linux-media@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH v2] media: ttpci: remove autorepeat handling and use timer_setup
Date: Thu, 2 Nov 2017 16:50:37 -0700	[thread overview]
Message-ID: <20171102235037.4gndwq5223uyv5kw@dtor-ws> (raw)
In-Reply-To: <CAGXu5jLZaSDXdCVO3G1zsh3WLYaKvqm32xrJ8saBnCP8a7dZ8w@mail.gmail.com>

On Thu, Nov 02, 2017 at 04:24:27PM -0700, Kees Cook wrote:
> On Tue, Oct 31, 2017 at 1:11 PM, Sean Young <sean@mess.org> wrote:
> > Leave the autorepeat handling up to the input layer, and move
> > to the new timer API.
> >
> > Compile tested only.
> >
> > Signed-off-by: Sean Young <sean@mess.org>
> 
> Hi! Just checking up on this... the input timer conversion is blocked
> by getting this sorted out, so I'd love to have something either
> media, input, or timer tree can carry. :)

Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

>From my POV the patch is good. Mauro, do you want me to take it through
my tree, or maybe you could create an immutable branch off 4.14-rc5 (or
6) with this commit and I will pull it in and then can apply Kees input
core conversion patch?

Thanks!

> 
> Thanks!
> 
> -Kees
> 
> > ---
> > v2:
> >  - fixes and improvements from Dmitry Torokhov
> >
> >  drivers/media/pci/ttpci/av7110.h    |  2 +-
> >  drivers/media/pci/ttpci/av7110_ir.c | 56 +++++++++++++------------------------
> >  2 files changed, 21 insertions(+), 37 deletions(-)
> >
> > diff --git a/drivers/media/pci/ttpci/av7110.h b/drivers/media/pci/ttpci/av7110.h
> > index 347827925c14..bcb72ecbedc0 100644
> > --- a/drivers/media/pci/ttpci/av7110.h
> > +++ b/drivers/media/pci/ttpci/av7110.h
> > @@ -93,7 +93,7 @@ struct infrared {
> >         u8                      inversion;
> >         u16                     last_key;
> >         u16                     last_toggle;
> > -       u8                      delay_timer_finished;
> > +       bool                    keypressed;
> >  };
> >
> >
> > diff --git a/drivers/media/pci/ttpci/av7110_ir.c b/drivers/media/pci/ttpci/av7110_ir.c
> > index ca05198de2c2..ee414803e6b5 100644
> > --- a/drivers/media/pci/ttpci/av7110_ir.c
> > +++ b/drivers/media/pci/ttpci/av7110_ir.c
> > @@ -84,15 +84,16 @@ static u16 default_key_map [256] = {
> >
> >
> >  /* key-up timer */
> > -static void av7110_emit_keyup(unsigned long parm)
> > +static void av7110_emit_keyup(struct timer_list *t)
> >  {
> > -       struct infrared *ir = (struct infrared *) parm;
> > +       struct infrared *ir = from_timer(ir, t, keyup_timer);
> >
> > -       if (!ir || !test_bit(ir->last_key, ir->input_dev->key))
> > +       if (!ir || !ir->keypressed)
> >                 return;
> >
> >         input_report_key(ir->input_dev, ir->last_key, 0);
> >         input_sync(ir->input_dev);
> > +       ir->keypressed = false;
> >  }
> >
> >
> > @@ -152,29 +153,18 @@ static void av7110_emit_key(unsigned long parm)
> >                 return;
> >         }
> >
> > -       if (timer_pending(&ir->keyup_timer)) {
> > -               del_timer(&ir->keyup_timer);
> > -               if (ir->last_key != keycode || toggle != ir->last_toggle) {
> > -                       ir->delay_timer_finished = 0;
> > -                       input_event(ir->input_dev, EV_KEY, ir->last_key, 0);
> > -                       input_event(ir->input_dev, EV_KEY, keycode, 1);
> > -                       input_sync(ir->input_dev);
> > -               } else if (ir->delay_timer_finished) {
> > -                       input_event(ir->input_dev, EV_KEY, keycode, 2);
> > -                       input_sync(ir->input_dev);
> > -               }
> > -       } else {
> > -               ir->delay_timer_finished = 0;
> > -               input_event(ir->input_dev, EV_KEY, keycode, 1);
> > -               input_sync(ir->input_dev);
> > -       }
> > +       if (ir->keypressed &&
> > +           (ir->last_key != keycode || toggle != ir->last_toggle))
> > +               input_event(ir->input_dev, EV_KEY, ir->last_key, 0);
> >
> > +       input_event(ir->input_dev, EV_KEY, keycode, 1);
> > +       input_sync(ir->input_dev);
> > +
> > +       ir->keypressed = true;
> >         ir->last_key = keycode;
> >         ir->last_toggle = toggle;
> >
> > -       ir->keyup_timer.expires = jiffies + UP_TIMEOUT;
> > -       add_timer(&ir->keyup_timer);
> > -
> > +       mod_timer(&ir->keyup_timer, jiffies + UP_TIMEOUT);
> >  }
> >
> >
> > @@ -204,16 +194,6 @@ static void input_register_keys(struct infrared *ir)
> >         ir->input_dev->keycodemax = ARRAY_SIZE(ir->key_map);
> >  }
> >
> > -
> > -/* called by the input driver after rep[REP_DELAY] ms */
> > -static void input_repeat_key(unsigned long parm)
> > -{
> > -       struct infrared *ir = (struct infrared *) parm;
> > -
> > -       ir->delay_timer_finished = 1;
> > -}
> > -
> > -
> >  /* check for configuration changes */
> >  int av7110_check_ir_config(struct av7110 *av7110, int force)
> >  {
> > @@ -333,8 +313,7 @@ int av7110_ir_init(struct av7110 *av7110)
> >         av_list[av_cnt++] = av7110;
> >         av7110_check_ir_config(av7110, true);
> >
> > -       setup_timer(&av7110->ir.keyup_timer, av7110_emit_keyup,
> > -                   (unsigned long)&av7110->ir);
> > +       timer_setup(&av7110->ir.keyup_timer, av7110_emit_keyup, 0);
> >
> >         input_dev = input_allocate_device();
> >         if (!input_dev)
> > @@ -365,8 +344,13 @@ int av7110_ir_init(struct av7110 *av7110)
> >                 input_free_device(input_dev);
> >                 return err;
> >         }
> > -       input_dev->timer.function = input_repeat_key;
> > -       input_dev->timer.data = (unsigned long) &av7110->ir;
> > +
> > +       /*
> > +        * Input core's default autorepeat is 33 cps with 250 msec
> > +        * delay, let's adjust to numbers more suitable for remote
> > +        * control.
> > +        */
> > +       input_enable_softrepeat(input_dev, 250, 125);
> >
> >         if (av_cnt == 1) {
> >                 e = proc_create("av7110_ir", S_IWUSR, NULL, &av7110_ir_proc_fops);
> > --
> > 2.13.6
> >
> 
> 
> 
> -- 
> Kees Cook
> Pixel Security

-- 
Dmitry

  reply	other threads:[~2017-11-02 23:50 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-25  0:40 [PATCH] media: av7110: switch to useing timer_setup() Dmitry Torokhov
2017-10-25  1:03 ` Jaejoong Kim
2017-10-26 18:27 ` kbuild test robot
2017-10-30 22:14 ` Kees Cook
2017-10-31 17:27 ` Sean Young
2017-10-31 17:45   ` [PATCH] media: ttpci: remove autorepeat handling and use timer_setup Sean Young
2017-10-31 18:22     ` Dmitry Torokhov
2017-10-31 20:07       ` Sean Young
2017-10-31 20:11         ` [PATCH v2] " Sean Young
2017-11-02 23:24           ` Kees Cook
2017-11-02 23:50             ` Dmitry Torokhov [this message]
2017-11-03  0:16               ` Mauro Carvalho Chehab
2017-11-03 22:17                 ` Dmitry Torokhov
2017-11-03 23:42                   ` Kees Cook
2017-10-31 18:14   ` [PATCH] media: av7110: switch to useing timer_setup() Mauro Carvalho Chehab

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=20171102235037.4gndwq5223uyv5kw@dtor-ws \
    --to=dmitry.torokhov@gmail.com \
    --cc=hans.verkuil@cisco.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=sean@mess.org \
    --cc=tglx@linutronix.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;
as well as URLs for NNTP newsgroup(s).