linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Input: improve autorepeat initialization
@ 2015-10-09 21:10 Petri Gynther
  2015-10-10  0:15 ` Dmitry Torokhov
  0 siblings, 1 reply; 3+ messages in thread
From: Petri Gynther @ 2015-10-09 21:10 UTC (permalink / raw)
  To: linux-input; +Cc: Dmitry Torokhov, Petri Gynther

Allow driver to initialize only input_dev->rep[REP_DELAY] and
input_dev->rep[REP_PERIOD], but then use the input timer and
repeat function from input.c.

For example, a HID driver could do:

static void xyz_input_configured(struct hid_device *hid,
                                 struct hid_input *hidinput)
{
        hidinput->input->rep[REP_DELAY] = 400;
        hidinput->input->rep[REP_PERIOD] = 100;
}

static struct hid_driver xyz_driver = {
        .input_configured = xyz_input_configured,
}

Signed-off-by: Petri Gynther <pgynther@google.com>
---
 drivers/input/input.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/input/input.c b/drivers/input/input.c
index 5391abd..1984ba5 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -2115,6 +2115,15 @@ int input_register_device(struct input_dev *dev)
 		dev->rep[REP_PERIOD] = 33;
 	}
 
+	/*
+	 * If the driver didn't initialize the timer data and function, then
+	 * handle the autorepeating here in input.c.
+	 */
+	if (!dev->timer.data && !dev->timer.function) {
+		dev->timer.data = (unsigned long) dev;
+		dev->timer.function = input_repeat_key;
+	}
+
 	if (!dev->getkeycode)
 		dev->getkeycode = input_default_getkeycode;
 
-- 
2.6.0.rc2.230.g3dd15c0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Input: improve autorepeat initialization
  2015-10-09 21:10 [PATCH] Input: improve autorepeat initialization Petri Gynther
@ 2015-10-10  0:15 ` Dmitry Torokhov
  2015-10-12 18:50   ` Petri Gynther
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Torokhov @ 2015-10-10  0:15 UTC (permalink / raw)
  To: Petri Gynther; +Cc: linux-input

Hi Petri,

On Fri, Oct 09, 2015 at 02:10:01PM -0700, Petri Gynther wrote:
> Allow driver to initialize only input_dev->rep[REP_DELAY] and
> input_dev->rep[REP_PERIOD], but then use the input timer and
> repeat function from input.c.
> 
> For example, a HID driver could do:
> 
> static void xyz_input_configured(struct hid_device *hid,
>                                  struct hid_input *hidinput)
> {
>         hidinput->input->rep[REP_DELAY] = 400;
>         hidinput->input->rep[REP_PERIOD] = 100;
> }
> 
> static struct hid_driver xyz_driver = {
>         .input_configured = xyz_input_configured,
> }
> 

This will break drivers that either support hardware autorepeat (such as
atkbd) or ones that implement autorepeat themselves. If you want support
"starting" repeat rate/delay as you are proposing we need alternative
way of telling input core whether it should engage generic autorepeat
code or not. Maybe we should simply add a "softrepeat" flag in input_dev
structure and call it day.

Thanks.

> Signed-off-by: Petri Gynther <pgynther@google.com>
> ---
>  drivers/input/input.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/input/input.c b/drivers/input/input.c
> index 5391abd..1984ba5 100644
> --- a/drivers/input/input.c
> +++ b/drivers/input/input.c
> @@ -2115,6 +2115,15 @@ int input_register_device(struct input_dev *dev)
>  		dev->rep[REP_PERIOD] = 33;
>  	}
>  
> +	/*
> +	 * If the driver didn't initialize the timer data and function, then
> +	 * handle the autorepeating here in input.c.
> +	 */
> +	if (!dev->timer.data && !dev->timer.function) {
> +		dev->timer.data = (unsigned long) dev;
> +		dev->timer.function = input_repeat_key;
> +	}
> +
>  	if (!dev->getkeycode)
>  		dev->getkeycode = input_default_getkeycode;
>  
> -- 
> 2.6.0.rc2.230.g3dd15c0
> 

-- 
Dmitry

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Input: improve autorepeat initialization
  2015-10-10  0:15 ` Dmitry Torokhov
@ 2015-10-12 18:50   ` Petri Gynther
  0 siblings, 0 replies; 3+ messages in thread
From: Petri Gynther @ 2015-10-12 18:50 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: open list:HID CORE LAYER

Hi Dmitry,

On Fri, Oct 9, 2015 at 5:15 PM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> Hi Petri,
>
> On Fri, Oct 09, 2015 at 02:10:01PM -0700, Petri Gynther wrote:
>> Allow driver to initialize only input_dev->rep[REP_DELAY] and
>> input_dev->rep[REP_PERIOD], but then use the input timer and
>> repeat function from input.c.
>>
>> For example, a HID driver could do:
>>
>> static void xyz_input_configured(struct hid_device *hid,
>>                                  struct hid_input *hidinput)
>> {
>>         hidinput->input->rep[REP_DELAY] = 400;
>>         hidinput->input->rep[REP_PERIOD] = 100;
>> }
>>
>> static struct hid_driver xyz_driver = {
>>         .input_configured = xyz_input_configured,
>> }
>>
>
> This will break drivers that either support hardware autorepeat (such as
> atkbd) or ones that implement autorepeat themselves. If you want support
> "starting" repeat rate/delay as you are proposing we need alternative
> way of telling input core whether it should engage generic autorepeat
> code or not. Maybe we should simply add a "softrepeat" flag in input_dev
> structure and call it day.
>
> Thanks.
>

Thanks for pointing this out. I'll add softrepeat flag to input_dev.
Sending patch v2 shortly.

>> Signed-off-by: Petri Gynther <pgynther@google.com>
>> ---
>>  drivers/input/input.c | 9 +++++++++
>>  1 file changed, 9 insertions(+)
>>
>> diff --git a/drivers/input/input.c b/drivers/input/input.c
>> index 5391abd..1984ba5 100644
>> --- a/drivers/input/input.c
>> +++ b/drivers/input/input.c
>> @@ -2115,6 +2115,15 @@ int input_register_device(struct input_dev *dev)
>>               dev->rep[REP_PERIOD] = 33;
>>       }
>>
>> +     /*
>> +      * If the driver didn't initialize the timer data and function, then
>> +      * handle the autorepeating here in input.c.
>> +      */
>> +     if (!dev->timer.data && !dev->timer.function) {
>> +             dev->timer.data = (unsigned long) dev;
>> +             dev->timer.function = input_repeat_key;
>> +     }
>> +
>>       if (!dev->getkeycode)
>>               dev->getkeycode = input_default_getkeycode;
>>
>> --
>> 2.6.0.rc2.230.g3dd15c0
>>
>
> --
> Dmitry

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-10-12 18:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-09 21:10 [PATCH] Input: improve autorepeat initialization Petri Gynther
2015-10-10  0:15 ` Dmitry Torokhov
2015-10-12 18:50   ` Petri Gynther

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).