diff options
| -rw-r--r-- | drivers/media/rc/rc-main.c | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c index f57cd5677ac2..3186ac7c2c10 100644 --- a/drivers/media/rc/rc-main.c +++ b/drivers/media/rc/rc-main.c | |||
| @@ -522,18 +522,20 @@ EXPORT_SYMBOL_GPL(rc_g_keycode_from_table); | |||
| 522 | /** | 522 | /** |
| 523 | * ir_do_keyup() - internal function to signal the release of a keypress | 523 | * ir_do_keyup() - internal function to signal the release of a keypress |
| 524 | * @dev: the struct rc_dev descriptor of the device | 524 | * @dev: the struct rc_dev descriptor of the device |
| 525 | * @sync: whether or not to call input_sync | ||
| 525 | * | 526 | * |
| 526 | * This function is used internally to release a keypress, it must be | 527 | * This function is used internally to release a keypress, it must be |
| 527 | * called with keylock held. | 528 | * called with keylock held. |
| 528 | */ | 529 | */ |
| 529 | static void ir_do_keyup(struct rc_dev *dev) | 530 | static void ir_do_keyup(struct rc_dev *dev, bool sync) |
| 530 | { | 531 | { |
| 531 | if (!dev->keypressed) | 532 | if (!dev->keypressed) |
| 532 | return; | 533 | return; |
| 533 | 534 | ||
| 534 | IR_dprintk(1, "keyup key 0x%04x\n", dev->last_keycode); | 535 | IR_dprintk(1, "keyup key 0x%04x\n", dev->last_keycode); |
| 535 | input_report_key(dev->input_dev, dev->last_keycode, 0); | 536 | input_report_key(dev->input_dev, dev->last_keycode, 0); |
| 536 | input_sync(dev->input_dev); | 537 | if (sync) |
| 538 | input_sync(dev->input_dev); | ||
| 537 | dev->keypressed = false; | 539 | dev->keypressed = false; |
| 538 | } | 540 | } |
| 539 | 541 | ||
| @@ -549,7 +551,7 @@ void rc_keyup(struct rc_dev *dev) | |||
| 549 | unsigned long flags; | 551 | unsigned long flags; |
| 550 | 552 | ||
| 551 | spin_lock_irqsave(&dev->keylock, flags); | 553 | spin_lock_irqsave(&dev->keylock, flags); |
| 552 | ir_do_keyup(dev); | 554 | ir_do_keyup(dev, true); |
| 553 | spin_unlock_irqrestore(&dev->keylock, flags); | 555 | spin_unlock_irqrestore(&dev->keylock, flags); |
| 554 | } | 556 | } |
| 555 | EXPORT_SYMBOL_GPL(rc_keyup); | 557 | EXPORT_SYMBOL_GPL(rc_keyup); |
| @@ -578,7 +580,7 @@ static void ir_timer_keyup(unsigned long cookie) | |||
| 578 | */ | 580 | */ |
| 579 | spin_lock_irqsave(&dev->keylock, flags); | 581 | spin_lock_irqsave(&dev->keylock, flags); |
| 580 | if (time_is_before_eq_jiffies(dev->keyup_jiffies)) | 582 | if (time_is_before_eq_jiffies(dev->keyup_jiffies)) |
| 581 | ir_do_keyup(dev); | 583 | ir_do_keyup(dev, true); |
| 582 | spin_unlock_irqrestore(&dev->keylock, flags); | 584 | spin_unlock_irqrestore(&dev->keylock, flags); |
| 583 | } | 585 | } |
| 584 | 586 | ||
| @@ -597,6 +599,7 @@ void rc_repeat(struct rc_dev *dev) | |||
| 597 | spin_lock_irqsave(&dev->keylock, flags); | 599 | spin_lock_irqsave(&dev->keylock, flags); |
| 598 | 600 | ||
| 599 | input_event(dev->input_dev, EV_MSC, MSC_SCAN, dev->last_scancode); | 601 | input_event(dev->input_dev, EV_MSC, MSC_SCAN, dev->last_scancode); |
| 602 | input_sync(dev->input_dev); | ||
| 600 | 603 | ||
| 601 | if (!dev->keypressed) | 604 | if (!dev->keypressed) |
| 602 | goto out; | 605 | goto out; |
| @@ -622,29 +625,28 @@ EXPORT_SYMBOL_GPL(rc_repeat); | |||
| 622 | static void ir_do_keydown(struct rc_dev *dev, int scancode, | 625 | static void ir_do_keydown(struct rc_dev *dev, int scancode, |
| 623 | u32 keycode, u8 toggle) | 626 | u32 keycode, u8 toggle) |
| 624 | { | 627 | { |
| 625 | input_event(dev->input_dev, EV_MSC, MSC_SCAN, scancode); | 628 | bool new_event = !dev->keypressed || |
| 626 | 629 | dev->last_scancode != scancode || | |
| 627 | /* Repeat event? */ | 630 | dev->last_toggle != toggle; |
| 628 | if (dev->keypressed && | ||
| 629 | dev->last_scancode == scancode && | ||
| 630 | dev->last_toggle == toggle) | ||
| 631 | return; | ||
| 632 | 631 | ||
| 633 | /* Release old keypress */ | 632 | if (new_event && dev->keypressed) |
| 634 | ir_do_keyup(dev); | 633 | ir_do_keyup(dev, false); |
| 635 | 634 | ||
| 636 | dev->last_scancode = scancode; | 635 | input_event(dev->input_dev, EV_MSC, MSC_SCAN, scancode); |
| 637 | dev->last_toggle = toggle; | ||
| 638 | dev->last_keycode = keycode; | ||
| 639 | 636 | ||
| 640 | if (keycode == KEY_RESERVED) | 637 | if (new_event && keycode != KEY_RESERVED) { |
| 641 | return; | 638 | /* Register a keypress */ |
| 639 | dev->keypressed = true; | ||
| 640 | dev->last_scancode = scancode; | ||
| 641 | dev->last_toggle = toggle; | ||
| 642 | dev->last_keycode = keycode; | ||
| 643 | |||
| 644 | IR_dprintk(1, "%s: key down event, " | ||
| 645 | "key 0x%04x, scancode 0x%04x\n", | ||
| 646 | dev->input_name, keycode, scancode); | ||
| 647 | input_report_key(dev->input_dev, keycode, 1); | ||
| 648 | } | ||
| 642 | 649 | ||
| 643 | /* Register a keypress */ | ||
| 644 | dev->keypressed = true; | ||
| 645 | IR_dprintk(1, "%s: key down event, key 0x%04x, scancode 0x%04x\n", | ||
| 646 | dev->input_name, keycode, scancode); | ||
| 647 | input_report_key(dev->input_dev, dev->last_keycode, 1); | ||
| 648 | input_sync(dev->input_dev); | 650 | input_sync(dev->input_dev); |
| 649 | } | 651 | } |
| 650 | 652 | ||
