diff mbox

[2/2] rc-main: remove input events for repeat messages

Message ID 149815944000.22167.2535987828056972392.stgit@zeus.hardeman.nu (mailing list archive)
State New, archived
Headers show

Commit Message

David Härdeman June 22, 2017, 7:24 p.m. UTC
Protocols like NEC generate around 10 repeat events per second.

The input events are not very useful for userspace but still waste power
by waking up every listener. So let's remove them (MSC_SCAN events
are still generated for the initial keypress).

Signed-off-by: David Härdeman <david@hardeman.nu>
---
 drivers/media/rc/rc-main.c |   13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

Comments

Sean Young July 1, 2017, 12:20 p.m. UTC | #1
On Thu, Jun 22, 2017 at 09:24:00PM +0200, David Härdeman wrote:
> Protocols like NEC generate around 10 repeat events per second.
> 
> The input events are not very useful for userspace but still waste power
> by waking up every listener. So let's remove them (MSC_SCAN events
> are still generated for the initial keypress).
> 
> Signed-off-by: David Härdeman <david@hardeman.nu>
> ---
>  drivers/media/rc/rc-main.c |   13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
> index 7387bd4d75b0..9f490aa11bc4 100644
> --- a/drivers/media/rc/rc-main.c
> +++ b/drivers/media/rc/rc-main.c
> @@ -616,16 +616,11 @@ void rc_repeat(struct rc_dev *dev)
>  
>  	spin_lock_irqsave(&dev->keylock, flags);
>  
> -	if (!dev->keypressed)
> -		goto out;
> -
> -	input_event(dev->input_dev, EV_MSC, MSC_SCAN, dev->last_scancode);
> -	input_sync(dev->input_dev);

I don't agree with this. It's good to see something in user space when
a repeat received. This is useful for debugging purposes.


Sean

> -
> -	dev->keyup_jiffies = jiffies + msecs_to_jiffies(IR_KEYPRESS_TIMEOUT);
> -	mod_timer(&dev->timer_keyup, dev->keyup_jiffies);
> +	if (dev->keypressed) {
> +		dev->keyup_jiffies = jiffies + msecs_to_jiffies(IR_KEYPRESS_TIMEOUT);
> +		mod_timer(&dev->timer_keyup, dev->keyup_jiffies);
> +	}
>  
> -out:
>  	spin_unlock_irqrestore(&dev->keylock, flags);
>  }
>  EXPORT_SYMBOL_GPL(rc_repeat);
David Härdeman July 4, 2017, 1:59 p.m. UTC | #2
On Sat, Jul 01, 2017 at 01:20:50PM +0100, Sean Young wrote:
>On Thu, Jun 22, 2017 at 09:24:00PM +0200, David Härdeman wrote:
>> Protocols like NEC generate around 10 repeat events per second.
>> 
>> The input events are not very useful for userspace but still waste power
>> by waking up every listener. So let's remove them (MSC_SCAN events
>> are still generated for the initial keypress).
>> 
>> Signed-off-by: David Härdeman <david@hardeman.nu>
>> ---
>>  drivers/media/rc/rc-main.c |   13 ++++---------
>>  1 file changed, 4 insertions(+), 9 deletions(-)
>> 
>> diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
>> index 7387bd4d75b0..9f490aa11bc4 100644
>> --- a/drivers/media/rc/rc-main.c
>> +++ b/drivers/media/rc/rc-main.c
>> @@ -616,16 +616,11 @@ void rc_repeat(struct rc_dev *dev)
>>  
>>  	spin_lock_irqsave(&dev->keylock, flags);
>>  
>> -	if (!dev->keypressed)
>> -		goto out;
>> -
>> -	input_event(dev->input_dev, EV_MSC, MSC_SCAN, dev->last_scancode);
>> -	input_sync(dev->input_dev);
>
>I don't agree with this. It's good to see something in user space when
>a repeat received. This is useful for debugging purposes.

Not going to press the issue, but dev_dbg might be another option if
debugging is the intended use-case?
diff mbox

Patch

diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index 7387bd4d75b0..9f490aa11bc4 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -616,16 +616,11 @@  void rc_repeat(struct rc_dev *dev)
 
 	spin_lock_irqsave(&dev->keylock, flags);
 
-	if (!dev->keypressed)
-		goto out;
-
-	input_event(dev->input_dev, EV_MSC, MSC_SCAN, dev->last_scancode);
-	input_sync(dev->input_dev);
-
-	dev->keyup_jiffies = jiffies + msecs_to_jiffies(IR_KEYPRESS_TIMEOUT);
-	mod_timer(&dev->timer_keyup, dev->keyup_jiffies);
+	if (dev->keypressed) {
+		dev->keyup_jiffies = jiffies + msecs_to_jiffies(IR_KEYPRESS_TIMEOUT);
+		mod_timer(&dev->timer_keyup, dev->keyup_jiffies);
+	}
 
-out:
 	spin_unlock_irqrestore(&dev->keylock, flags);
 }
 EXPORT_SYMBOL_GPL(rc_repeat);