-
Notifications
You must be signed in to change notification settings - Fork 8.2k
drivers: input: Input subsystem #48342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
22ddd28 to
ed9cad3
Compare
mbolivar-nordic
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to the problems here, you need to fix your commit logs.
Please watch https://www.youtube.com/watch?v=mnVNLM7ynMQ or at least read the slides for an overview of the contribution process: https://static.sched.com/hosted_files/zephyr2022/a3/HOWTO_Get_Your_Zephyr_Patches_Merged_ZDS_2022.pdf
ed9cad3 to
d5ca8a3
Compare
dcpleung
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can I suggest to rename this to keyboard instead of just key? This would make it more clear that these are keyboard related stuff.
|
Tagging @petejohanson as he might be interested and have some feedback. |
|
I think if this is intended just for simple "send a key" uses, this will work, but for anything as complex as https://github.com/zmkfirmware/zmk/ this abstraction would not work for us.
Just a few thoughts, I'll think more and add more when I can. |
|
@petejohanson @dcpleung |
|
My issue is simply that setting up the callback should not be done from user thread. It can be done in kernel mode. |
I mean, If I solve the callback program, is there a chance to merge? this pull request is highly similar to kscan driver. |
d5ca8a3 to
fc649d9
Compare
|
@MichaelOwen2022 sorry, this flew under my radar. Could you please rebase? |
no longer working on dt bindings
Input subsystem support public API for input device. Signed-off-by: Michael Owen <[email protected]>
This driver scan gpio keyboard status, and report key event to input subsystem. Signed-off-by: Michael Owen <[email protected]>
This sample use input api to get gpio keyboard event. Signed-off-by: Michael Owen <[email protected]>
cfd44e5 to
32ac382
Compare
I've rebase already. |
tbursztyka
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Input is a way too generic name, a keyboard being one of the many input devices (and we already have kscan for this).
Hard to see how this could be used for a mouse, or else...
|
|
||
| #include "input_internal.h" | ||
|
|
||
| int input_internal_setup(struct input_dev *dev) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From one input device stand-point: are you going to call this more than once at runtime?
If not, then all of this can be integrated into a macro with relevant static intialization for each objects (rb, mutex, sem...)
| */ | ||
| __syscall int input_setup(const struct device *dev); | ||
|
|
||
| static inline int z_impl_input_setup(const struct device *dev) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't this be done at device initialization? (see previous comment)
| */ | ||
| __syscall int input_event_read(const struct device *dev, struct input_event *event); | ||
|
|
||
| static inline int z_impl_input_event_read(const struct device *dev, struct input_event *event) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as noted already, adding asynchronous input API would be a must here.
| KEY_EVENT_NONE = 0xff, | ||
| }; | ||
|
|
||
| struct kbd_gpio_driver { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
weird naming, the whole code in keyboard_gpio.c is the driver.
Actually I don't see the point of not including of these attributes into kbd_gpio_data
| struct input_dev *input = data->input; | ||
| int retval = 0; | ||
|
|
||
| retval = input_internal_attr_get(input, type, attr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
retval seems superfluous, just return from the called input_* function
| struct input_dev *input = data->input; | ||
| int retval = 0; | ||
|
|
||
| retval = input_internal_attr_set(input, type, attr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
| struct input_dev *input = data->input; | ||
| int retval = 0; | ||
|
|
||
| retval = input_internal_event_read(input, event); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
| struct input_dev *input = data->input; | ||
| int retval = 0; | ||
|
|
||
| retval = input_internal_event_write(input, event); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
| */ | ||
| __syscall int input_release(const struct device *dev); | ||
|
|
||
| static inline int z_impl_input_release(const struct device *dev) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what would be the use case for this function?
Like the setup above. It seems to bring concepts (pluggin in/out a keyboard? pm perhaps?) to the user level that should not be its role to manage. Which is not the right way.
With all due respect, I don't think you're good enough to understand this input subsysem framework. |
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| #define DT_DRV_COMPAT keyboard_gpio |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't know why this isn't done as a kscan driver, and this input system doesn't have a mapping to consume a kscan driver and map to input system events.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you understand enough of this input subsystem framework either.
| continue; | ||
| } | ||
|
|
||
| err = gpio_pin_interrupt_configure_dt(gpio, GPIO_INT_EDGE_TO_ACTIVE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not all gpio pins support interrupts. This will have limitations and only work on certain hardware configurations.
Also, using edge to active interrupt won't allow deep sleep/wake from deep sleep on nRF52.
| enum keyboard_value { | ||
| KEY_RELEASE, | ||
| KEY_PRESSED, | ||
| KEY_LONG_PRESSED, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these added. As soon as you have long press/release, why not support double tap? Triple?
If the goal is a "lowest common denominator" API good enough for basic input to programs, this is probably fine.
I think maybe this is my disconnect, I come from developing featureful input devices.
If the goal of this API is to focus on the consumers of input data, then we should clearly document that, since the current system doesn't seem to be flexible/powerful enough to handle the other.
|
|
||
| /* keyboard code */ | ||
|
|
||
| #define KEY_CODE_RESERVED 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current code set may be fine for a basic sample program, but definitely won't allow a complex system that covers the full range of possible keyboard codes, other possible layouts/languages, etc.
| #define KEY_CODE_Y 89 | ||
| #define KEY_CODE_Z 90 | ||
|
|
||
| #define KEY_CODE_KP0 96 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's far more keypad codes than these.
|
It's been a few months since this commit and the code review that followed was disappointing. I can't speak highly of the entire zephyr team and have no interest in committing anything on this project. |
|
It's no fun to waste time with a bunch of elementary school students。 |
Input subsystem support api for input devices (like keyboard, touscreen, etc).