[mythtv-users] Hauppauge PVR250 remote -- Some success...but repeat issue now

Mark Lord mythtv at rtr.ca
Sun Oct 9 16:06:33 UTC 2011


On 11-10-07 12:14 PM, James MacKenzie wrote:
..
> One little issue I had was that sometimes one button press spawns multiple
> events...especially on my Harmony 1100.  I can get away with using the
> original Hauppauge remote, that's not a problem, but even that sometimes does
> multiple events for one quick button press.  I've tried messing with the
> ir-keytable period value but no matter what I change it to, it doesn't seem to
> make any difference.  I think that's one way that LIRC is better than
> ir-kbd-i2c, in that you can specify a 'repeat' value to ignore.
>
> Any ideas?
..

Repeat is broken in the in-kernel driver for this.
I solve it here by patching the b0rked driver:

(patch also available from: rtr.ca/mythtv_patches/00_kernel_ir_kbd_i2c.patch )

--- 2.6.38/drivers/media/video/ir-kbd-i2c.c	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