aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/IR
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2010-10-29 15:08:07 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-12-29 05:16:35 -0500
commit62c6503125389763a74911408d984c5dd09eeb97 (patch)
treea9b419280d25fca5086d82f8992a1d5843da75f1 /drivers/media/IR
parent2997137be8eba5bf9c07a24d5fda1f4225f9ca7d (diff)
[media] ir-core: remove remaining users of the ir-functions keyhandlers
This patch removes the remaining usages of the ir_input_nokey() and ir_input_keydown() functions provided by drivers/media/IR/ir-functions.c by using the corresponding functionality in ir-core instead. Signed-off-by: David Härdeman <david@hardeman.nu> Acked-by: Jarod Wilson <jarod@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/IR')
-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
3 files changed, 94 insertions, 126 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);