aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/media/IR/imon.c9
-rw-r--r--drivers/media/IR/ir-functions.c101
-rw-r--r--drivers/media/IR/ir-keytable.c110
-rw-r--r--drivers/media/video/bt8xx/bttv-input.c32
-rw-r--r--drivers/media/video/bt8xx/bttvp.h1
-rw-r--r--drivers/media/video/cx88/cx88-input.c11
-rw-r--r--drivers/media/video/ir-kbd-i2c.c3
-rw-r--r--drivers/media/video/saa7134/saa7134-input.c49
-rw-r--r--drivers/staging/tm6000/tm6000-input.c15
-rw-r--r--include/media/ir-common.h31
-rw-r--r--include/media/ir-core.h3
-rw-r--r--include/media/ir-kbd-i2c.h4
12 files changed, 133 insertions, 236 deletions
diff --git a/drivers/media/IR/imon.c b/drivers/media/IR/imon.c
index bc118066bc38..79f4f58c2ea4 100644
--- a/drivers/media/IR/imon.c
+++ b/drivers/media/IR/imon.c
@@ -1479,17 +1479,12 @@ static void imon_incoming_packet(struct imon_context *ictx,
1479 bool norelease = false; 1479 bool norelease = false;
1480 int i; 1480 int i;
1481 u64 scancode; 1481 u64 scancode;
1482 struct input_dev *rdev = NULL;
1483 struct ir_input_dev *irdev = NULL;
1484 int press_type = 0; 1482 int press_type = 0;
1485 int msec; 1483 int msec;
1486 struct timeval t; 1484 struct timeval t;
1487 static struct timeval prev_time = { 0, 0 }; 1485 static struct timeval prev_time = { 0, 0 };
1488 u8 ktype; 1486 u8 ktype;
1489 1487
1490 rdev = ictx->rdev;
1491 irdev = input_get_drvdata(rdev);
1492
1493 /* filter out junk data on the older 0xffdc imon devices */ 1488 /* filter out junk data on the older 0xffdc imon devices */
1494 if ((buf[0] == 0xff) && (buf[1] == 0xff) && (buf[2] == 0xff)) 1489 if ((buf[0] == 0xff) && (buf[1] == 0xff) && (buf[2] == 0xff))
1495 return; 1490 return;
@@ -1570,9 +1565,9 @@ static void imon_incoming_packet(struct imon_context *ictx,
1570 1565
1571 if (ktype != IMON_KEY_PANEL) { 1566 if (ktype != IMON_KEY_PANEL) {
1572 if (press_type == 0) 1567 if (press_type == 0)
1573 ir_keyup(irdev); 1568 ir_keyup(ictx->rdev);
1574 else { 1569 else {
1575 ir_keydown(rdev, ictx->rc_scancode, ictx->rc_toggle); 1570 ir_keydown(ictx->rdev, ictx->rc_scancode, ictx->rc_toggle);
1576 spin_lock_irqsave(&ictx->kc_lock, flags); 1571 spin_lock_irqsave(&ictx->kc_lock, flags);
1577 ictx->last_keycode = ictx->kc; 1572 ictx->last_keycode = ictx->kc;
1578 spin_unlock_irqrestore(&ictx->kc_lock, flags); 1573 spin_unlock_irqrestore(&ictx->kc_lock, flags);
diff --git a/drivers/media/IR/ir-functions.c b/drivers/media/IR/ir-functions.c
index f4c411535f3d..fca734c43e8d 100644
--- a/drivers/media/IR/ir-functions.c
+++ b/drivers/media/IR/ir-functions.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * 2 * some common functions to handle infrared remote protocol decoding for
3 * some common structs and functions to handle infrared remotes via 3 * drivers which have not yet been (or can't be) converted to use the
4 * input layer ... 4 * regular protocol decoders...
5 * 5 *
6 * (c) 2003 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs] 6 * (c) 2003 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
7 * 7 *
@@ -31,67 +31,6 @@
31MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]"); 31MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
32MODULE_LICENSE("GPL"); 32MODULE_LICENSE("GPL");
33 33
34static int repeat = 1;
35module_param(repeat, int, 0444);
36MODULE_PARM_DESC(repeat,"auto-repeat for IR keys (default: on)");
37
38/* -------------------------------------------------------------------------- */
39
40static void ir_input_key_event(struct input_dev *dev, struct ir_input_state *ir)
41{
42 if (KEY_RESERVED == ir->keycode) {
43 printk(KERN_INFO "%s: unknown key: key=0x%02x down=%d\n",
44 dev->name, ir->ir_key, ir->keypressed);
45 return;
46 }
47 IR_dprintk(1,"%s: key event code=%d down=%d\n",
48 dev->name,ir->keycode,ir->keypressed);
49 input_report_key(dev,ir->keycode,ir->keypressed);
50 input_sync(dev);
51}
52
53/* -------------------------------------------------------------------------- */
54
55int ir_input_init(struct input_dev *dev, struct ir_input_state *ir,
56 const u64 ir_type)
57{
58 ir->ir_type = ir_type;
59
60 if (repeat)
61 set_bit(EV_REP, dev->evbit);
62
63 return 0;
64}
65EXPORT_SYMBOL_GPL(ir_input_init);
66
67
68void ir_input_nokey(struct input_dev *dev, struct ir_input_state *ir)
69{
70 if (ir->keypressed) {
71 ir->keypressed = 0;
72 ir_input_key_event(dev,ir);
73 }
74}
75EXPORT_SYMBOL_GPL(ir_input_nokey);
76
77void ir_input_keydown(struct input_dev *dev, struct ir_input_state *ir,
78 u32 ir_key)
79{
80 u32 keycode = ir_g_keycode_from_table(dev, ir_key);
81
82 if (ir->keypressed && ir->keycode != keycode) {
83 ir->keypressed = 0;
84 ir_input_key_event(dev,ir);
85 }
86 if (!ir->keypressed) {
87 ir->ir_key = ir_key;
88 ir->keycode = keycode;
89 ir->keypressed = 1;
90 ir_input_key_event(dev,ir);
91 }
92}
93EXPORT_SYMBOL_GPL(ir_input_keydown);
94
95/* -------------------------------------------------------------------------- */ 34/* -------------------------------------------------------------------------- */
96/* extract mask bits out of data and pack them into the result */ 35/* extract mask bits out of data and pack them into the result */
97u32 ir_extract_bits(u32 data, u32 mask) 36u32 ir_extract_bits(u32 data, u32 mask)
@@ -115,7 +54,7 @@ EXPORT_SYMBOL_GPL(ir_extract_bits);
115 * saa7134 */ 54 * saa7134 */
116 55
117/* decode raw bit pattern to RC5 code */ 56/* decode raw bit pattern to RC5 code */
118u32 ir_rc5_decode(unsigned int code) 57static u32 ir_rc5_decode(unsigned int code)
119{ 58{
120 unsigned int org_code = code; 59 unsigned int org_code = code;
121 unsigned int pair; 60 unsigned int pair;
@@ -144,13 +83,12 @@ u32 ir_rc5_decode(unsigned int code)
144 RC5_TOGGLE(rc5), RC5_ADDR(rc5), RC5_INSTR(rc5)); 83 RC5_TOGGLE(rc5), RC5_ADDR(rc5), RC5_INSTR(rc5));
145 return rc5; 84 return rc5;
146} 85}
147EXPORT_SYMBOL_GPL(ir_rc5_decode);
148 86
149void ir_rc5_timer_end(unsigned long data) 87void ir_rc5_timer_end(unsigned long data)
150{ 88{
151 struct card_ir *ir = (struct card_ir *)data; 89 struct card_ir *ir = (struct card_ir *)data;
152 struct timeval tv; 90 struct timeval tv;
153 unsigned long current_jiffies, timeout; 91 unsigned long current_jiffies;
154 u32 gap; 92 u32 gap;
155 u32 rc5 = 0; 93 u32 rc5 = 0;
156 94
@@ -191,32 +129,11 @@ void ir_rc5_timer_end(unsigned long data)
191 u32 toggle = RC5_TOGGLE(rc5); 129 u32 toggle = RC5_TOGGLE(rc5);
192 u32 instr = RC5_INSTR(rc5); 130 u32 instr = RC5_INSTR(rc5);
193 131
194 /* Good code, decide if repeat/repress */ 132 /* Good code */
195 if (toggle != RC5_TOGGLE(ir->last_rc5) || 133 ir_keydown(ir->dev, instr, toggle);
196 instr != RC5_INSTR(ir->last_rc5)) { 134 IR_dprintk(1, "ir-common: instruction %x, toggle %x\n",
197 IR_dprintk(1, "ir-common: instruction %x, toggle %x\n", instr, 135 instr, toggle);
198 toggle);
199 ir_input_nokey(ir->dev, &ir->ir);
200 ir_input_keydown(ir->dev, &ir->ir, instr);
201 }
202
203 /* Set/reset key-up timer */
204 timeout = current_jiffies +
205 msecs_to_jiffies(ir->rc5_key_timeout);
206 mod_timer(&ir->timer_keyup, timeout);
207
208 /* Save code for repeat test */
209 ir->last_rc5 = rc5;
210 } 136 }
211 } 137 }
212} 138}
213EXPORT_SYMBOL_GPL(ir_rc5_timer_end); 139EXPORT_SYMBOL_GPL(ir_rc5_timer_end);
214
215void ir_rc5_timer_keyup(unsigned long data)
216{
217 struct card_ir *ir = (struct card_ir *)data;
218
219 IR_dprintk(1, "ir-common: key released\n");
220 ir_input_nokey(ir->dev, &ir->ir);
221}
222EXPORT_SYMBOL_GPL(ir_rc5_timer_keyup);
diff --git a/drivers/media/IR/ir-keytable.c b/drivers/media/IR/ir-keytable.c
index f60107c3b091..8039110350d3 100644
--- a/drivers/media/IR/ir-keytable.c
+++ b/drivers/media/IR/ir-keytable.c
@@ -431,13 +431,13 @@ u32 ir_g_keycode_from_table(struct input_dev *dev, u32 scancode)
431EXPORT_SYMBOL_GPL(ir_g_keycode_from_table); 431EXPORT_SYMBOL_GPL(ir_g_keycode_from_table);
432 432
433/** 433/**
434 * ir_keyup() - generates input event to cleanup a key press 434 * ir_do_keyup() - internal function to signal the release of a keypress
435 * @ir: the struct ir_input_dev descriptor of the device 435 * @ir: the struct ir_input_dev descriptor of the device
436 * 436 *
437 * This routine is used to signal that a key has been released on the 437 * This function is used internally to release a keypress, it must be
438 * remote control. It reports a keyup input event via input_report_key(). 438 * called with keylock held.
439 */ 439 */
440void ir_keyup(struct ir_input_dev *ir) 440static void ir_do_keyup(struct ir_input_dev *ir)
441{ 441{
442 if (!ir->keypressed) 442 if (!ir->keypressed)
443 return; 443 return;
@@ -447,6 +447,23 @@ void ir_keyup(struct ir_input_dev *ir)
447 input_sync(ir->input_dev); 447 input_sync(ir->input_dev);
448 ir->keypressed = false; 448 ir->keypressed = false;
449} 449}
450
451/**
452 * ir_keyup() - generates input event to signal the release of a keypress
453 * @dev: the struct input_dev descriptor of the device
454 *
455 * This routine is used to signal that a key has been released on the
456 * remote control.
457 */
458void ir_keyup(struct input_dev *dev)
459{
460 unsigned long flags;
461 struct ir_input_dev *ir = input_get_drvdata(dev);
462
463 spin_lock_irqsave(&ir->keylock, flags);
464 ir_do_keyup(ir);
465 spin_unlock_irqrestore(&ir->keylock, flags);
466}
450EXPORT_SYMBOL_GPL(ir_keyup); 467EXPORT_SYMBOL_GPL(ir_keyup);
451 468
452/** 469/**
@@ -473,7 +490,7 @@ static void ir_timer_keyup(unsigned long cookie)
473 */ 490 */
474 spin_lock_irqsave(&ir->keylock, flags); 491 spin_lock_irqsave(&ir->keylock, flags);
475 if (time_is_before_eq_jiffies(ir->keyup_jiffies)) 492 if (time_is_before_eq_jiffies(ir->keyup_jiffies))
476 ir_keyup(ir); 493 ir_do_keyup(ir);
477 spin_unlock_irqrestore(&ir->keylock, flags); 494 spin_unlock_irqrestore(&ir->keylock, flags);
478} 495}
479 496
@@ -506,44 +523,37 @@ out:
506EXPORT_SYMBOL_GPL(ir_repeat); 523EXPORT_SYMBOL_GPL(ir_repeat);
507 524
508/** 525/**
509 * ir_keydown() - generates input event for a key press 526 * ir_do_keydown() - internal function to process a keypress
510 * @dev: the struct input_dev descriptor of the device 527 * @dev: the struct input_dev descriptor of the device
511 * @scancode: the scancode that we're seeking 528 * @scancode: the scancode of the keypress
512 * @toggle: the toggle value (protocol dependent, if the protocol doesn't 529 * @keycode: the keycode of the keypress
513 * support toggle values, this should be set to zero) 530 * @toggle: the toggle value of the keypress
514 * 531 *
515 * This routine is used by the input routines when a key is pressed at the 532 * This function is used internally to register a keypress, it must be
516 * IR. It gets the keycode for a scancode and reports an input event via 533 * called with keylock held.
517 * input_report_key().
518 */ 534 */
519void ir_keydown(struct input_dev *dev, int scancode, u8 toggle) 535static void ir_do_keydown(struct input_dev *dev, int scancode,
536 u32 keycode, u8 toggle)
520{ 537{
521 unsigned long flags;
522 struct ir_input_dev *ir = input_get_drvdata(dev); 538 struct ir_input_dev *ir = input_get_drvdata(dev);
523 539
524 u32 keycode = ir_g_keycode_from_table(dev, scancode);
525
526 spin_lock_irqsave(&ir->keylock, flags);
527
528 input_event(dev, EV_MSC, MSC_SCAN, scancode); 540 input_event(dev, EV_MSC, MSC_SCAN, scancode);
529 541
530 /* Repeat event? */ 542 /* Repeat event? */
531 if (ir->keypressed && 543 if (ir->keypressed &&
532 ir->last_scancode == scancode && 544 ir->last_scancode == scancode &&
533 ir->last_toggle == toggle) 545 ir->last_toggle == toggle)
534 goto set_timer; 546 return;
535 547
536 /* Release old keypress */ 548 /* Release old keypress */
537 ir_keyup(ir); 549 ir_do_keyup(ir);
538 550
539 ir->last_scancode = scancode; 551 ir->last_scancode = scancode;
540 ir->last_toggle = toggle; 552 ir->last_toggle = toggle;
541 ir->last_keycode = keycode; 553 ir->last_keycode = keycode;
542 554
543
544 if (keycode == KEY_RESERVED) 555 if (keycode == KEY_RESERVED)
545 goto out; 556 return;
546
547 557
548 /* Register a keypress */ 558 /* Register a keypress */
549 ir->keypressed = true; 559 ir->keypressed = true;
@@ -551,15 +561,61 @@ void ir_keydown(struct input_dev *dev, int scancode, u8 toggle)
551 dev->name, keycode, scancode); 561 dev->name, keycode, scancode);
552 input_report_key(dev, ir->last_keycode, 1); 562 input_report_key(dev, ir->last_keycode, 1);
553 input_sync(dev); 563 input_sync(dev);
564}
554 565
555set_timer: 566/**
556 ir->keyup_jiffies = jiffies + msecs_to_jiffies(IR_KEYPRESS_TIMEOUT); 567 * ir_keydown() - generates input event for a key press
557 mod_timer(&ir->timer_keyup, ir->keyup_jiffies); 568 * @dev: the struct input_dev descriptor of the device
558out: 569 * @scancode: the scancode that we're seeking
570 * @toggle: the toggle value (protocol dependent, if the protocol doesn't
571 * support toggle values, this should be set to zero)
572 *
573 * This routine is used by the input routines when a key is pressed at the
574 * IR. It gets the keycode for a scancode and reports an input event via
575 * input_report_key().
576 */
577void ir_keydown(struct input_dev *dev, int scancode, u8 toggle)
578{
579 unsigned long flags;
580 struct ir_input_dev *ir = input_get_drvdata(dev);
581 u32 keycode = ir_g_keycode_from_table(dev, scancode);
582
583 spin_lock_irqsave(&ir->keylock, flags);
584 ir_do_keydown(dev, scancode, keycode, toggle);
585
586 if (ir->keypressed) {
587 ir->keyup_jiffies = jiffies + msecs_to_jiffies(IR_KEYPRESS_TIMEOUT);
588 mod_timer(&ir->timer_keyup, ir->keyup_jiffies);
589 }
559 spin_unlock_irqrestore(&ir->keylock, flags); 590 spin_unlock_irqrestore(&ir->keylock, flags);
560} 591}
561EXPORT_SYMBOL_GPL(ir_keydown); 592EXPORT_SYMBOL_GPL(ir_keydown);
562 593
594/**
595 * ir_keydown_notimeout() - generates input event for a key press without
596 * an automatic keyup event at a later time
597 * @dev: the struct input_dev descriptor of the device
598 * @scancode: the scancode that we're seeking
599 * @toggle: the toggle value (protocol dependent, if the protocol doesn't
600 * support toggle values, this should be set to zero)
601 *
602 * This routine is used by the input routines when a key is pressed at the
603 * IR. It gets the keycode for a scancode and reports an input event via
604 * input_report_key(). The driver must manually call ir_keyup() at a later
605 * stage.
606 */
607void ir_keydown_notimeout(struct input_dev *dev, int scancode, u8 toggle)
608{
609 unsigned long flags;
610 struct ir_input_dev *ir = input_get_drvdata(dev);
611 u32 keycode = ir_g_keycode_from_table(dev, scancode);
612
613 spin_lock_irqsave(&ir->keylock, flags);
614 ir_do_keydown(dev, scancode, keycode, toggle);
615 spin_unlock_irqrestore(&ir->keylock, flags);
616}
617EXPORT_SYMBOL_GPL(ir_keydown_notimeout);
618
563static int ir_open(struct input_dev *input_dev) 619static int ir_open(struct input_dev *input_dev)
564{ 620{
565 struct ir_input_dev *ir_dev = input_get_drvdata(input_dev); 621 struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
diff --git a/drivers/media/video/bt8xx/bttv-input.c b/drivers/media/video/bt8xx/bttv-input.c
index 6bf05a7dc5f9..eb71c3ae36de 100644
--- a/drivers/media/video/bt8xx/bttv-input.c
+++ b/drivers/media/video/bt8xx/bttv-input.c
@@ -38,8 +38,6 @@ module_param(repeat_period, int, 0644);
38 38
39static int ir_rc5_remote_gap = 885; 39static int ir_rc5_remote_gap = 885;
40module_param(ir_rc5_remote_gap, int, 0644); 40module_param(ir_rc5_remote_gap, int, 0644);
41static int ir_rc5_key_timeout = 200;
42module_param(ir_rc5_key_timeout, int, 0644);
43 41
44#undef dprintk 42#undef dprintk
45#define dprintk(arg...) do { \ 43#define dprintk(arg...) do { \
@@ -74,18 +72,17 @@ static void ir_handle_key(struct bttv *btv)
74 (gpio & ir->mask_keydown) ? " down" : "", 72 (gpio & ir->mask_keydown) ? " down" : "",
75 (gpio & ir->mask_keyup) ? " up" : ""); 73 (gpio & ir->mask_keyup) ? " up" : "");
76 74
77 if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) || 75 if ((ir->mask_keydown && (gpio & ir->mask_keydown)) ||
78 (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) { 76 (ir->mask_keyup && !(gpio & ir->mask_keyup))) {
79 ir_input_keydown(ir->dev, &ir->ir, data); 77 ir_keydown_notimeout(ir->dev, data, 0);
80 } else { 78 } else {
81 /* HACK: Probably, ir->mask_keydown is missing 79 /* HACK: Probably, ir->mask_keydown is missing
82 for this board */ 80 for this board */
83 if (btv->c.type == BTTV_BOARD_WINFAST2000) 81 if (btv->c.type == BTTV_BOARD_WINFAST2000)
84 ir_input_keydown(ir->dev, &ir->ir, data); 82 ir_keydown_notimeout(ir->dev, data, 0);
85 83
86 ir_input_nokey(ir->dev,&ir->ir); 84 ir_keyup(ir->dev);
87 } 85 }
88
89} 86}
90 87
91static void ir_enltv_handle_key(struct bttv *btv) 88static void ir_enltv_handle_key(struct bttv *btv)
@@ -107,9 +104,9 @@ static void ir_enltv_handle_key(struct bttv *btv)
107 gpio, data, 104 gpio, data,
108 (gpio & ir->mask_keyup) ? " up" : "up/down"); 105 (gpio & ir->mask_keyup) ? " up" : "up/down");
109 106
110 ir_input_keydown(ir->dev, &ir->ir, data); 107 ir_keydown_notimeout(ir->dev, data, 0);
111 if (keyup) 108 if (keyup)
112 ir_input_nokey(ir->dev, &ir->ir); 109 ir_keyup(ir->dev);
113 } else { 110 } else {
114 if ((ir->last_gpio & 1 << 31) == keyup) 111 if ((ir->last_gpio & 1 << 31) == keyup)
115 return; 112 return;
@@ -119,9 +116,9 @@ static void ir_enltv_handle_key(struct bttv *btv)
119 (gpio & ir->mask_keyup) ? " up" : "down"); 116 (gpio & ir->mask_keyup) ? " up" : "down");
120 117
121 if (keyup) 118 if (keyup)
122 ir_input_nokey(ir->dev, &ir->ir); 119 ir_keyup(ir->dev);
123 else 120 else
124 ir_input_keydown(ir->dev, &ir->ir, data); 121 ir_keydown_notimeout(ir->dev, data, 0);
125 } 122 }
126 123
127 ir->last_gpio = data | keyup; 124 ir->last_gpio = data | keyup;
@@ -215,14 +212,9 @@ static void bttv_ir_start(struct bttv *btv, struct card_ir *ir)
215 init_timer(&ir->timer_end); 212 init_timer(&ir->timer_end);
216 ir->timer_end.function = ir_rc5_timer_end; 213 ir->timer_end.function = ir_rc5_timer_end;
217 ir->timer_end.data = (unsigned long)ir; 214 ir->timer_end.data = (unsigned long)ir;
218
219 init_timer(&ir->timer_keyup);
220 ir->timer_keyup.function = ir_rc5_timer_keyup;
221 ir->timer_keyup.data = (unsigned long)ir;
222 ir->shift_by = 1; 215 ir->shift_by = 1;
223 ir->start = 3; 216 ir->start = 3;
224 ir->addr = 0x0; 217 ir->addr = 0x0;
225 ir->rc5_key_timeout = ir_rc5_key_timeout;
226 ir->rc5_remote_gap = ir_rc5_remote_gap; 218 ir->rc5_remote_gap = ir_rc5_remote_gap;
227 } 219 }
228} 220}
@@ -290,7 +282,6 @@ void __devinit init_bttv_i2c_ir(struct bttv *btv)
290 btv->init_data.name = "PV951"; 282 btv->init_data.name = "PV951";
291 btv->init_data.get_key = get_key_pv951; 283 btv->init_data.get_key = get_key_pv951;
292 btv->init_data.ir_codes = RC_MAP_PV951; 284 btv->init_data.ir_codes = RC_MAP_PV951;
293 btv->init_data.type = IR_TYPE_OTHER;
294 info.addr = 0x4b; 285 info.addr = 0x4b;
295 break; 286 break;
296 default: 287 default:
@@ -327,7 +318,6 @@ int bttv_input_init(struct bttv *btv)
327 struct card_ir *ir; 318 struct card_ir *ir;
328 char *ir_codes = NULL; 319 char *ir_codes = NULL;
329 struct input_dev *input_dev; 320 struct input_dev *input_dev;
330 u64 ir_type = IR_TYPE_OTHER;
331 int err = -ENOMEM; 321 int err = -ENOMEM;
332 322
333 if (!btv->has_remote) 323 if (!btv->has_remote)
@@ -448,10 +438,6 @@ int bttv_input_init(struct bttv *btv)
448 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", 438 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0",
449 pci_name(btv->c.pci)); 439 pci_name(btv->c.pci));
450 440
451 err = ir_input_init(input_dev, &ir->ir, ir_type);
452 if (err < 0)
453 goto err_out_free;
454
455 input_dev->name = ir->name; 441 input_dev->name = ir->name;
456 input_dev->phys = ir->phys; 442 input_dev->phys = ir->phys;
457 input_dev->id.bustype = BUS_PCI; 443 input_dev->id.bustype = BUS_PCI;
diff --git a/drivers/media/video/bt8xx/bttvp.h b/drivers/media/video/bt8xx/bttvp.h
index d1e26a448ed2..157285b434c9 100644
--- a/drivers/media/video/bt8xx/bttvp.h
+++ b/drivers/media/video/bt8xx/bttvp.h
@@ -305,7 +305,6 @@ struct bttv_pll_info {
305/* for gpio-connected remote control */ 305/* for gpio-connected remote control */
306struct bttv_input { 306struct bttv_input {
307 struct input_dev *dev; 307 struct input_dev *dev;
308 struct ir_input_state ir;
309 char name[32]; 308 char name[32];
310 char phys[32]; 309 char phys[32];
311 u32 mask_keycode; 310 u32 mask_keycode;
diff --git a/drivers/media/video/cx88/cx88-input.c b/drivers/media/video/cx88/cx88-input.c
index 436ace8196a5..564e3cb29c4d 100644
--- a/drivers/media/video/cx88/cx88-input.c
+++ b/drivers/media/video/cx88/cx88-input.c
@@ -131,16 +131,21 @@ static void cx88_ir_handle_key(struct cx88_IR *ir)
131 } else if (ir->mask_keydown) { 131 } else if (ir->mask_keydown) {
132 /* bit set on keydown */ 132 /* bit set on keydown */
133 if (gpio & ir->mask_keydown) 133 if (gpio & ir->mask_keydown)
134 ir_keydown(ir->input, data, 0); 134 ir_keydown_notimeout(ir->input, data, 0);
135 else
136 ir_keyup(ir->input);
135 137
136 } else if (ir->mask_keyup) { 138 } else if (ir->mask_keyup) {
137 /* bit cleared on keydown */ 139 /* bit cleared on keydown */
138 if (0 == (gpio & ir->mask_keyup)) 140 if (0 == (gpio & ir->mask_keyup))
139 ir_keydown(ir->input, data, 0); 141 ir_keydown_notimeout(ir->input, data, 0);
142 else
143 ir_keyup(ir->input);
140 144
141 } else { 145 } else {
142 /* can't distinguish keydown/up :-/ */ 146 /* can't distinguish keydown/up :-/ */
143 ir_keydown(ir->input, data, 0); 147 ir_keydown_notimeout(ir->input, data, 0);
148 ir_keyup(ir->input);
144 } 149 }
145} 150}
146 151
diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c
index ce4a75375909..a78883a6e0e7 100644
--- a/drivers/media/video/ir-kbd-i2c.c
+++ b/drivers/media/video/ir-kbd-i2c.c
@@ -269,7 +269,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
269{ 269{
270 char *ir_codes = NULL; 270 char *ir_codes = NULL;
271 const char *name = NULL; 271 const char *name = NULL;
272 u64 ir_type = 0; 272 u64 ir_type = IR_TYPE_UNKNOWN;
273 struct IR_i2c *ir; 273 struct IR_i2c *ir;
274 struct input_dev *input_dev; 274 struct input_dev *input_dev;
275 struct i2c_adapter *adap = client->adapter; 275 struct i2c_adapter *adap = client->adapter;
@@ -383,7 +383,6 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
383 dev_name(&client->dev)); 383 dev_name(&client->dev));
384 384
385 /* init + register input device */ 385 /* init + register input device */
386 ir->ir_type = ir_type;
387 input_dev->id.bustype = BUS_I2C; 386 input_dev->id.bustype = BUS_I2C;
388 input_dev->name = ir->name; 387 input_dev->name = ir->name;
389 input_dev->phys = ir->phys; 388 input_dev->phys = ir->phys;
diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c
index b6c682f0acec..3e37593a328f 100644
--- a/drivers/media/video/saa7134/saa7134-input.c
+++ b/drivers/media/video/saa7134/saa7134-input.c
@@ -44,8 +44,6 @@ MODULE_PARM_DESC(pinnacle_remote, "Specify Pinnacle PCTV remote: 0=coloured, 1=g
44 44
45static int ir_rc5_remote_gap = 885; 45static int ir_rc5_remote_gap = 885;
46module_param(ir_rc5_remote_gap, int, 0644); 46module_param(ir_rc5_remote_gap, int, 0644);
47static int ir_rc5_key_timeout = 115;
48module_param(ir_rc5_key_timeout, int, 0644);
49 47
50static int repeat_delay = 500; 48static int repeat_delay = 500;
51module_param(repeat_delay, int, 0644); 49module_param(repeat_delay, int, 0644);
@@ -70,7 +68,6 @@ static int saa7134_rc5_irq(struct saa7134_dev *dev);
70static int saa7134_nec_irq(struct saa7134_dev *dev); 68static int saa7134_nec_irq(struct saa7134_dev *dev);
71static int saa7134_raw_decode_irq(struct saa7134_dev *dev); 69static int saa7134_raw_decode_irq(struct saa7134_dev *dev);
72static void nec_task(unsigned long data); 70static void nec_task(unsigned long data);
73static void saa7134_nec_timer(unsigned long data);
74 71
75/* -------------------- GPIO generic keycode builder -------------------- */ 72/* -------------------- GPIO generic keycode builder -------------------- */
76 73
@@ -104,25 +101,25 @@ static int build_key(struct saa7134_dev *dev)
104 switch (dev->board) { 101 switch (dev->board) {
105 case SAA7134_BOARD_KWORLD_PLUS_TV_ANALOG: 102 case SAA7134_BOARD_KWORLD_PLUS_TV_ANALOG:
106 if (data == ir->mask_keycode) 103 if (data == ir->mask_keycode)
107 ir_input_nokey(ir->dev, &ir->ir); 104 ir_keyup(ir->dev);
108 else 105 else
109 ir_input_keydown(ir->dev, &ir->ir, data); 106 ir_keydown_notimeout(ir->dev, data, 0);
110 return 0; 107 return 0;
111 } 108 }
112 109
113 if (ir->polling) { 110 if (ir->polling) {
114 if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) || 111 if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) ||
115 (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) { 112 (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) {
116 ir_input_keydown(ir->dev, &ir->ir, data); 113 ir_keydown_notimeout(ir->dev, data, 0);
117 } else { 114 } else {
118 ir_input_nokey(ir->dev, &ir->ir); 115 ir_keyup(ir->dev);
119 } 116 }
120 } 117 }
121 else { /* IRQ driven mode - handle key press and release in one go */ 118 else { /* IRQ driven mode - handle key press and release in one go */
122 if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) || 119 if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) ||
123 (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) { 120 (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) {
124 ir_input_keydown(ir->dev, &ir->ir, data); 121 ir_keydown_notimeout(ir->dev, data, 0);
125 ir_input_nokey(ir->dev, &ir->ir); 122 ir_keyup(ir->dev);
126 } 123 }
127 } 124 }
128 125
@@ -465,17 +462,11 @@ static int __saa7134_ir_start(void *priv)
465 init_timer(&ir->timer_end); 462 init_timer(&ir->timer_end);
466 ir->timer_end.function = ir_rc5_timer_end; 463 ir->timer_end.function = ir_rc5_timer_end;
467 ir->timer_end.data = (unsigned long)ir; 464 ir->timer_end.data = (unsigned long)ir;
468 init_timer(&ir->timer_keyup);
469 ir->timer_keyup.function = ir_rc5_timer_keyup;
470 ir->timer_keyup.data = (unsigned long)ir;
471 ir->shift_by = 2; 465 ir->shift_by = 2;
472 ir->start = 0x2; 466 ir->start = 0x2;
473 ir->addr = 0x17; 467 ir->addr = 0x17;
474 ir->rc5_key_timeout = ir_rc5_key_timeout;
475 ir->rc5_remote_gap = ir_rc5_remote_gap; 468 ir->rc5_remote_gap = ir_rc5_remote_gap;
476 } else if (ir->nec_gpio) { 469 } else if (ir->nec_gpio) {
477 setup_timer(&ir->timer_keyup, saa7134_nec_timer,
478 (unsigned long)dev);
479 tasklet_init(&ir->tlet, nec_task, (unsigned long)dev); 470 tasklet_init(&ir->tlet, nec_task, (unsigned long)dev);
480 } else if (ir->raw_decode) { 471 } else if (ir->raw_decode) {
481 /* set timer_end for code completion */ 472 /* set timer_end for code completion */
@@ -596,7 +587,6 @@ int saa7134_input_init1(struct saa7134_dev *dev)
596 int nec_gpio = 0; 587 int nec_gpio = 0;
597 int raw_decode = 0; 588 int raw_decode = 0;
598 int allow_protocol_change = 0; 589 int allow_protocol_change = 0;
599 u64 ir_type = IR_TYPE_OTHER;
600 int err; 590 int err;
601 591
602 if (dev->has_remote != SAA7134_REMOTE_GPIO) 592 if (dev->has_remote != SAA7134_REMOTE_GPIO)
@@ -871,10 +861,6 @@ int saa7134_input_init1(struct saa7134_dev *dev)
871 ir->props.change_protocol = saa7134_ir_change_protocol; 861 ir->props.change_protocol = saa7134_ir_change_protocol;
872 } 862 }
873 863
874 err = ir_input_init(input_dev, &ir->ir, ir_type);
875 if (err < 0)
876 goto err_out_free;
877
878 input_dev->name = ir->name; 864 input_dev->name = ir->name;
879 input_dev->phys = ir->phys; 865 input_dev->phys = ir->phys;
880 input_dev->id.bustype = BUS_PCI; 866 input_dev->id.bustype = BUS_PCI;
@@ -1092,20 +1078,6 @@ static int saa7134_rc5_irq(struct saa7134_dev *dev)
1092 return 1; 1078 return 1;
1093} 1079}
1094 1080
1095/* On NEC protocol, One has 2.25 ms, and zero has 1.125 ms
1096 The first pulse (start) has 9 + 4.5 ms
1097 */
1098
1099static void saa7134_nec_timer(unsigned long data)
1100{
1101 struct saa7134_dev *dev = (struct saa7134_dev *) data;
1102 struct card_ir *ir = dev->remote;
1103
1104 dprintk("Cancel key repeat\n");
1105
1106 ir_input_nokey(ir->dev, &ir->ir);
1107}
1108
1109static void nec_task(unsigned long data) 1081static void nec_task(unsigned long data)
1110{ 1082{
1111 struct saa7134_dev *dev = (struct saa7134_dev *) data; 1083 struct saa7134_dev *dev = (struct saa7134_dev *) data;
@@ -1194,12 +1166,11 @@ static void nec_task(unsigned long data)
1194 dprintk("scancode = 0x%02x (code = 0x%02x, notcode= 0x%02x)\n", 1166 dprintk("scancode = 0x%02x (code = 0x%02x, notcode= 0x%02x)\n",
1195 ir->code, ircode, not_code); 1167 ir->code, ircode, not_code);
1196 1168
1197 ir_input_keydown(ir->dev, &ir->ir, ir->code); 1169 ir_keydown(ir->dev, ir->code, 0);
1198 } else 1170 } else {
1199 dprintk("Repeat last key\n"); 1171 dprintk("Repeat last key\n");
1200 1172 ir_repeat(ir->dev);
1201 /* Keep repeating the last key */ 1173 }
1202 mod_timer(&ir->timer_keyup, jiffies + msecs_to_jiffies(150));
1203 1174
1204 saa_setl(SAA7134_IRQ2, SAA7134_IRQ2_INTE_GPIO18_P); 1175 saa_setl(SAA7134_IRQ2, SAA7134_IRQ2_INTE_GPIO18_P);
1205} 1176}
diff --git a/drivers/staging/tm6000/tm6000-input.c b/drivers/staging/tm6000/tm6000-input.c
index 6022caaa739b..3e74884da251 100644
--- a/drivers/staging/tm6000/tm6000-input.c
+++ b/drivers/staging/tm6000/tm6000-input.c
@@ -25,7 +25,6 @@
25#include <linux/usb.h> 25#include <linux/usb.h>
26 26
27#include <media/ir-core.h> 27#include <media/ir-core.h>
28#include <media/ir-common.h>
29 28
30#include "tm6000.h" 29#include "tm6000.h"
31#include "tm6000-regs.h" 30#include "tm6000-regs.h"
@@ -52,7 +51,6 @@ struct tm6000_ir_poll_result {
52struct tm6000_IR { 51struct tm6000_IR {
53 struct tm6000_core *dev; 52 struct tm6000_core *dev;
54 struct ir_input_dev *input; 53 struct ir_input_dev *input;
55 struct ir_input_state ir;
56 char name[32]; 54 char name[32];
57 char phys[32]; 55 char phys[32];
58 56
@@ -67,6 +65,7 @@ struct tm6000_IR {
67 int (*get_key) (struct tm6000_IR *, struct tm6000_ir_poll_result *); 65 int (*get_key) (struct tm6000_IR *, struct tm6000_ir_poll_result *);
68 66
69 /* IR device properties */ 67 /* IR device properties */
68 u64 ir_type;
70 struct ir_dev_props props; 69 struct ir_dev_props props;
71}; 70};
72 71
@@ -145,7 +144,7 @@ static int default_polling_getkey(struct tm6000_IR *ir,
145 return 0; 144 return 0;
146 145
147 if (&dev->int_in) { 146 if (&dev->int_in) {
148 if (ir->ir.ir_type == IR_TYPE_RC5) 147 if (ir->ir_type == IR_TYPE_RC5)
149 poll_result->rc_data = ir->urb_data[0]; 148 poll_result->rc_data = ir->urb_data[0];
150 else 149 else
151 poll_result->rc_data = ir->urb_data[0] | ir->urb_data[1] << 8; 150 poll_result->rc_data = ir->urb_data[0] | ir->urb_data[1] << 8;
@@ -155,7 +154,7 @@ static int default_polling_getkey(struct tm6000_IR *ir,
155 tm6000_set_reg(dev, REQ_04_EN_DISABLE_MCU_INT, 2, 1); 154 tm6000_set_reg(dev, REQ_04_EN_DISABLE_MCU_INT, 2, 1);
156 msleep(10); 155 msleep(10);
157 156
158 if (ir->ir.ir_type == IR_TYPE_RC5) { 157 if (ir->ir_type == IR_TYPE_RC5) {
159 rc = tm6000_read_write_usb(dev, USB_DIR_IN | 158 rc = tm6000_read_write_usb(dev, USB_DIR_IN |
160 USB_TYPE_VENDOR | USB_RECIP_DEVICE, 159 USB_TYPE_VENDOR | USB_RECIP_DEVICE,
161 REQ_02_GET_IR_CODE, 0, 0, buf, 1); 160 REQ_02_GET_IR_CODE, 0, 0, buf, 1);
@@ -201,10 +200,7 @@ static void tm6000_ir_handle_key(struct tm6000_IR *ir)
201 dprintk("ir->get_key result data=%04x\n", poll_result.rc_data); 200 dprintk("ir->get_key result data=%04x\n", poll_result.rc_data);
202 201
203 if (ir->key) { 202 if (ir->key) {
204 ir_input_keydown(ir->input->input_dev, &ir->ir, 203 ir_keydown(ir->input->input_dev, poll_result.rc_data, 0);
205 (u32)poll_result.rc_data);
206
207 ir_input_nokey(ir->input->input_dev, &ir->ir);
208 ir->key = 0; 204 ir->key = 0;
209 } 205 }
210 return; 206 return;
@@ -291,9 +287,6 @@ int tm6000_ir_init(struct tm6000_core *dev)
291 strlcat(ir->phys, "/input0", sizeof(ir->phys)); 287 strlcat(ir->phys, "/input0", sizeof(ir->phys));
292 288
293 tm6000_ir_change_protocol(ir, IR_TYPE_UNKNOWN); 289 tm6000_ir_change_protocol(ir, IR_TYPE_UNKNOWN);
294 err = ir_input_init(ir_input_dev->input_dev, &ir->ir, IR_TYPE_OTHER);
295 if (err < 0)
296 goto err_out_free;
297 290
298 ir_input_dev->input_dev->name = ir->name; 291 ir_input_dev->input_dev->name = ir->name;
299 ir_input_dev->input_dev->phys = ir->phys; 292 ir_input_dev->input_dev->phys = ir->phys;
diff --git a/include/media/ir-common.h b/include/media/ir-common.h
index 415242047b6a..4a32e89a3cfe 100644
--- a/include/media/ir-common.h
+++ b/include/media/ir-common.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * 2 * some common functions to handle infrared remote protocol decoding for
3 * some common structs and functions to handle infrared remotes via 3 * drivers which have not yet been (or can't be) converted to use the
4 * input layer ... 4 * regular protocol decoders...
5 * 5 *
6 * (c) 2003 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs] 6 * (c) 2003 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
7 * 7 *
@@ -33,30 +33,17 @@
33#define RC5_ADDR(x) (((x)>>6)&31) 33#define RC5_ADDR(x) (((x)>>6)&31)
34#define RC5_INSTR(x) ((x)&63) 34#define RC5_INSTR(x) ((x)&63)
35 35
36struct ir_input_state {
37 /* configuration */
38 u64 ir_type;
39
40 /* key info */
41 u32 ir_key; /* ir scancode */
42 u32 keycode; /* linux key code */
43 int keypressed; /* current state */
44};
45
46/* this was saa7134_ir and bttv_ir, moved here for 36/* this was saa7134_ir and bttv_ir, moved here for
47 * rc5 decoding. */ 37 * rc5 decoding. */
48struct card_ir { 38struct card_ir {
49 struct input_dev *dev; 39 struct input_dev *dev;
50 struct ir_input_state ir;
51 char name[32]; 40 char name[32];
52 char phys[32]; 41 char phys[32];
53 int users; 42 int users;
54
55 u32 running:1; 43 u32 running:1;
56 struct ir_dev_props props; 44 struct ir_dev_props props;
57 45
58 /* Usual gpio signalling */ 46 /* Usual gpio signalling */
59
60 u32 mask_keycode; 47 u32 mask_keycode;
61 u32 mask_keydown; 48 u32 mask_keydown;
62 u32 mask_keyup; 49 u32 mask_keyup;
@@ -65,7 +52,6 @@ struct card_ir {
65 int shift_by; 52 int shift_by;
66 int start; // What should RC5_START() be 53 int start; // What should RC5_START() be
67 int addr; // What RC5_ADDR() should be. 54 int addr; // What RC5_ADDR() should be.
68 int rc5_key_timeout;
69 int rc5_remote_gap; 55 int rc5_remote_gap;
70 struct work_struct work; 56 struct work_struct work;
71 struct timer_list timer; 57 struct timer_list timer;
@@ -73,8 +59,6 @@ struct card_ir {
73 /* RC5 gpio */ 59 /* RC5 gpio */
74 u32 rc5_gpio; 60 u32 rc5_gpio;
75 struct timer_list timer_end; /* timer_end for code completion */ 61 struct timer_list timer_end; /* timer_end for code completion */
76 struct timer_list timer_keyup; /* timer_end for key release */
77 u32 last_rc5; /* last good rc5 code */
78 u32 last_bit; /* last raw bit seen */ 62 u32 last_bit; /* last raw bit seen */
79 u32 code; /* raw code under construction */ 63 u32 code; /* raw code under construction */
80 struct timeval base_time; /* time of last seen code */ 64 struct timeval base_time; /* time of last seen code */
@@ -89,16 +73,7 @@ struct card_ir {
89}; 73};
90 74
91/* Routines from ir-functions.c */ 75/* Routines from ir-functions.c */
92
93int ir_input_init(struct input_dev *dev, struct ir_input_state *ir,
94 const u64 ir_type);
95void ir_input_nokey(struct input_dev *dev, struct ir_input_state *ir);
96void ir_input_keydown(struct input_dev *dev, struct ir_input_state *ir,
97 u32 ir_key);
98u32 ir_extract_bits(u32 data, u32 mask); 76u32 ir_extract_bits(u32 data, u32 mask);
99u32 ir_rc5_decode(unsigned int code);
100
101void ir_rc5_timer_end(unsigned long data); 77void ir_rc5_timer_end(unsigned long data);
102void ir_rc5_timer_keyup(unsigned long data);
103 78
104#endif 79#endif
diff --git a/include/media/ir-core.h b/include/media/ir-core.h
index 6dc37fae6606..bff75f258fbc 100644
--- a/include/media/ir-core.h
+++ b/include/media/ir-core.h
@@ -159,7 +159,8 @@ void ir_input_unregister(struct input_dev *input_dev);
159 159
160void ir_repeat(struct input_dev *dev); 160void ir_repeat(struct input_dev *dev);
161void ir_keydown(struct input_dev *dev, int scancode, u8 toggle); 161void ir_keydown(struct input_dev *dev, int scancode, u8 toggle);
162void ir_keyup(struct ir_input_dev *ir); 162void ir_keydown_notimeout(struct input_dev *dev, int scancode, u8 toggle);
163void ir_keyup(struct input_dev *dev);
163u32 ir_g_keycode_from_table(struct input_dev *input_dev, u32 scancode); 164u32 ir_g_keycode_from_table(struct input_dev *input_dev, u32 scancode);
164 165
165/* From ir-raw-event.c */ 166/* From ir-raw-event.c */
diff --git a/include/media/ir-kbd-i2c.h b/include/media/ir-kbd-i2c.h
index 557c676ab7dc..8c37b5ec0cf6 100644
--- a/include/media/ir-kbd-i2c.h
+++ b/include/media/ir-kbd-i2c.h
@@ -12,8 +12,7 @@ struct IR_i2c {
12 12
13 struct i2c_client *c; 13 struct i2c_client *c;
14 struct input_dev *input; 14 struct input_dev *input;
15 struct ir_input_state ir; 15
16 u64 ir_type;
17 /* Used to avoid fast repeating */ 16 /* Used to avoid fast repeating */
18 unsigned char old; 17 unsigned char old;
19 18
@@ -41,6 +40,7 @@ struct IR_i2c_init_data {
41 const char *name; 40 const char *name;
42 u64 type; /* IR_TYPE_RC5, etc */ 41 u64 type; /* IR_TYPE_RC5, etc */
43 u32 polling_interval; /* 0 means DEFAULT_POLLING_INTERVAL */ 42 u32 polling_interval; /* 0 means DEFAULT_POLLING_INTERVAL */
43
44 /* 44 /*
45 * Specify either a function pointer or a value indicating one of 45 * Specify either a function pointer or a value indicating one of
46 * ir_kbd_i2c's internal get_key functions 46 * ir_kbd_i2c's internal get_key functions