[mythtv-users] Remote control woes. Repeated keys.

Mark Lord mythtv at rtr.ca
Mon Feb 27 15:02:17 UTC 2012


On 12-02-26 05:24 AM, Bjørn Konestabo wrote:
> I'm getting multiple repeats when pressing a single key on my Hauppauge PVR150
> remote. I see from other threads that repeated keys are a somewhat common issue,
> but none of the other solutions I've tried have panned out. I'm on FC16 with
> kernel 3.2.7-1.fc16.i686.
> 
> I have the gray remote, and http://www.mythtv.org/wiki/Ir-kbd-i2c states that I
> need to have the hauppauge=1 option when inserting the ir-kbd-i2c, but that
> parameter is not being recognized. Is it obsolete?
> 
> The repeat delay of ir-keytable doesn't seem to do anything with anything. Can
> anyone point me to ir-kdb-i2c configuration options?


If you are using ir-kbd-i2c without any LIRC involvement,
then you might be interested in my kernel hack to smooth
out the repeats for that remote control.

I'm inlining a copy below, but my mailer will mangle the spacing,
so you can also grab a good copy from here:

    http://rtr.ca/mythtv_patches/00_kernel_ir-kbd-i2c_fix_repeats.patch

With that patch, my Hauppauge remote has been silky smooth for years.
But note that I was using it with a PVR250 IR interfaces, not a PVR150,
so I'd be interested to hear how this goes for you there.

Cheers

--- linux/drivers/media/video/ir-kbd-i2c.c.orig 2011-03-27 14:37:20.000000000 -0400
+++ linux/drivers/media/video/ir-kbd-i2c.c      2011-04-10 19:10:01.994104737 -0400
@@ -66,6 +66,39 @@

 /* ----------------------------------------------------------------------- */

+static int slow_down_repeats (unsigned int code)
+{
+       static unsigned long prev_time, delay;
+       static int prev_code;
+       unsigned long now      = jiffies;
+       const int max_delay    = 300;   /* msecs */
+       const int min_delay    = 100;   /* msecs */
+       const int acceleration = 50;    /* msecs per repeat */
+       int   new_delay        = max_delay;  /* default, for non-repeats */
+
+       if (code == prev_code) {  /* same key pressed as last time? */
+               if (time_before(now, prev_time + msecs_to_jiffies(delay)))
+                       return 1;       /* repeated too quickly: drop it */
+               if (!time_after(now, prev_time + msecs_to_jiffies(max_delay +
50))) {
+                       /*
+                        * Gradually ramp up the repeat rate if
+                        * the user holds the button down long enough.
+                        * This works only if the b0rked repeat logic
+                        * in rc-main.c is disabled.
+                        */
+                       new_delay = delay - acceleration;
+                       if (delay == max_delay)  /* start of a new repeat
sequence? */
+                               new_delay -= acceleration;  /* use a larger
initial adjustment */
+                       if (new_delay < min_delay)
+                               new_delay = min_delay;
+               }
+       }
+       delay     = new_delay;
+       prev_time = now;
+       prev_code = code;
+       return 0;       /* allow it */
+}
+
 static int get_key_haup_common(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw,
                               int size, int offset)
 {
@@ -111,6 +144,8 @@

        if (!range)
                code += 64;
+       if (slow_down_repeats(code))
+               return 0;  /* discard it */

        dprintk(1,"ir hauppauge (rc5): s%d r%d t%d dev=%d code=%d\n",
                start, range, toggle, dev, code);
@@ -267,6 +302,7 @@
        if (rc) {
                dprintk(1, "%s: keycode = 0x%04x\n", __func__, ir_key);
                rc_keydown(ir->rc, ir_key, 0);
+               ir->rc->last_scancode = ~0;  /* defeat b0rked repeat logic in
rc-main.c */
        }
 }

@@ -438,6 +474,7 @@
               ir->name, ir->phys, adap->name);

        /* start polling via eventd */
+       ir->polling_interval = 50;  /* poll 20 times/sec */
        INIT_DELAYED_WORK(&ir->work, ir_work);
        schedule_delayed_work(&ir->work, 0);


More information about the mythtv-users mailing list