All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] Input: gpio_keys - trigger input event if key is pressed in boot stage
@ 2015-05-20 10:02 Barry Song
  2015-05-20 16:37 ` Dmitry Torokhov
  0 siblings, 1 reply; 3+ messages in thread
From: Barry Song @ 2015-05-20 10:02 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov; +Cc: DL-SHA-WorkGroupLinux, Andy.Sun

sometimes we press a key to boot, and the boot stage need to get this
event.
the current codes use edge trigger, so we have no chance to report
the cold-touch event.
but our user sceneries like Linux navigator does need it.

Signed-off-by: Barry Song <Baohua.Song@csr.com>
---
 -RFC: for the moment, only an idea

 drivers/input/keyboard/gpio_keys.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/input/keyboard/gpio_keys.c
b/drivers/input/keyboard/gpio_keys.c
index ddf4045..77fe0dd 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -766,6 +766,19 @@ static int gpio_keys_probe(struct platform_device *pdev)

     device_init_wakeup(&pdev->dev, wakeup);

+    /* if the key is pressed while system boot, force an interrupt */
+    for (i = 0; i < pdata->nbuttons; i++) {
+        const struct gpio_keys_button *button = &pdata->buttons[i];
+        struct gpio_button_data *bdata = &ddata->data[i];
+        int state;
+
+        if (gpio_is_valid(button->gpio)) {
+            state = (gpio_get_value_cansleep(button->gpio) ? 1 : 0) ^
button->active_low;
+            if (state)
+                gpio_keys_gpio_isr(bdata->irq, bdata);
+        }
+    }
+
     return 0;

 err_remove_group:
-- 
1.9.1

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

* Re: [RFC PATCH] Input: gpio_keys - trigger input event if key is pressed in boot stage
  2015-05-20 10:02 [RFC PATCH] Input: gpio_keys - trigger input event if key is pressed in boot stage Barry Song
@ 2015-05-20 16:37 ` Dmitry Torokhov
  2015-05-20 22:44   ` Barry Song
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Torokhov @ 2015-05-20 16:37 UTC (permalink / raw)
  To: Barry Song; +Cc: linux-input, DL-SHA-WorkGroupLinux, Andy.Sun

Hi Barry,

On Wed, May 20, 2015 at 06:02:36PM +0800, Barry Song wrote:
> sometimes we press a key to boot, and the boot stage need to get this
> event.
> the current codes use edge trigger, so we have no chance to report
> the cold-touch event.
> but our user sceneries like Linux navigator does need it.

Input events that come before input device is opened (either by
userspace or by a kernel consumer) are ignored by input core and we
already call gpio_keys_report_state() from gpio_keys_open() so I do not
think this patch has any effect.

Thanks.

> 
> Signed-off-by: Barry Song <Baohua.Song@csr.com>
> ---
>  -RFC: for the moment, only an idea
> 
>  drivers/input/keyboard/gpio_keys.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/drivers/input/keyboard/gpio_keys.c
> b/drivers/input/keyboard/gpio_keys.c
> index ddf4045..77fe0dd 100644
> --- a/drivers/input/keyboard/gpio_keys.c
> +++ b/drivers/input/keyboard/gpio_keys.c
> @@ -766,6 +766,19 @@ static int gpio_keys_probe(struct platform_device *pdev)
> 
>      device_init_wakeup(&pdev->dev, wakeup);
> 
> +    /* if the key is pressed while system boot, force an interrupt */
> +    for (i = 0; i < pdata->nbuttons; i++) {
> +        const struct gpio_keys_button *button = &pdata->buttons[i];
> +        struct gpio_button_data *bdata = &ddata->data[i];
> +        int state;
> +
> +        if (gpio_is_valid(button->gpio)) {
> +            state = (gpio_get_value_cansleep(button->gpio) ? 1 : 0) ^
> button->active_low;
> +            if (state)
> +                gpio_keys_gpio_isr(bdata->irq, bdata);
> +        }
> +    }
> +
>      return 0;
> 
>  err_remove_group:
> -- 
> 1.9.1

-- 
Dmitry

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

* Re: [RFC PATCH] Input: gpio_keys - trigger input event if key is pressed in boot stage
  2015-05-20 16:37 ` Dmitry Torokhov
@ 2015-05-20 22:44   ` Barry Song
  0 siblings, 0 replies; 3+ messages in thread
From: Barry Song @ 2015-05-20 22:44 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-input, DL-SHA-WorkGroupLinux, Andy.Sun

2015-05-21 0:37 GMT+08:00 Dmitry Torokhov <dmitry.torokhov@gmail.com>:
> Hi Barry,
>
> On Wed, May 20, 2015 at 06:02:36PM +0800, Barry Song wrote:
>> sometimes we press a key to boot, and the boot stage need to get this
>> event.
>> the current codes use edge trigger, so we have no chance to report
>> the cold-touch event.
>> but our user sceneries like Linux navigator does need it.
>
> Input events that come before input device is opened (either by
> userspace or by a kernel consumer) are ignored by input core and we
> already call gpio_keys_report_state() from gpio_keys_open() so I do not
> think this patch has any effect.

Dmitry,
you are right. i missed gpio_keys_open() has done that once it is opened.

556 static int gpio_keys_open(struct input_dev *input)
557 {
558         struct gpio_keys_drvdata *ddata = input_get_drvdata(input);
559         const struct gpio_keys_platform_data *pdata = ddata->pdata;
560         int error;
561
562         if (pdata->enable) {
563                 error = pdata->enable(input->dev.parent);
564                 if (error)
565                         return error;
566         }
567
568         /* Report current state of buttons that are connected to GPIOs */
569         gpio_keys_report_state(ddata);
570
571         return 0;
572 }


>
> Thanks.
>
>>
>> Signed-off-by: Barry Song <Baohua.Song@csr.com>
>> ---
>>  -RFC: for the moment, only an idea
>>
>>  drivers/input/keyboard/gpio_keys.c | 13 +++++++++++++
>>  1 file changed, 13 insertions(+)
>>
>> diff --git a/drivers/input/keyboard/gpio_keys.c
>> b/drivers/input/keyboard/gpio_keys.c
>> index ddf4045..77fe0dd 100644
>> --- a/drivers/input/keyboard/gpio_keys.c
>> +++ b/drivers/input/keyboard/gpio_keys.c
>> @@ -766,6 +766,19 @@ static int gpio_keys_probe(struct platform_device *pdev)
>>
>>      device_init_wakeup(&pdev->dev, wakeup);
>>
>> +    /* if the key is pressed while system boot, force an interrupt */
>> +    for (i = 0; i < pdata->nbuttons; i++) {
>> +        const struct gpio_keys_button *button = &pdata->buttons[i];
>> +        struct gpio_button_data *bdata = &ddata->data[i];
>> +        int state;
>> +
>> +        if (gpio_is_valid(button->gpio)) {
>> +            state = (gpio_get_value_cansleep(button->gpio) ? 1 : 0) ^
>> button->active_low;
>> +            if (state)
>> +                gpio_keys_gpio_isr(bdata->irq, bdata);
>> +        }
>> +    }
>> +
>>      return 0;
>>
>>  err_remove_group:
>> --
>> 1.9.1
>
> --
> Dmitry


-barry

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

end of thread, other threads:[~2015-05-20 22:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-20 10:02 [RFC PATCH] Input: gpio_keys - trigger input event if key is pressed in boot stage Barry Song
2015-05-20 16:37 ` Dmitry Torokhov
2015-05-20 22:44   ` Barry Song

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.