Input: tegra-kbc - configure through device tree
v2 cover Input: tegra-kbc - configure through device tree
The following two patches add device-tree bindings and probing to tegra-kbc, and they also provide a simplified way of specifying the, to date, only known non-default keymap.
Fixes since v1: added debounce/repeat delay properties, setup of pin_cfg and verified that it works as expected on seaboard. Actual device tree update will be posted separately for inclusion through tegra tree.
-Olof
PATCH v2 1/2 Input: tegra-kbc - add device tree bindings
This adds a simple device tree binding to the tegra keyboard controller.
Also, mark the default keymap as __devinitdata since it is not referenced after boot, and shorten the name to not have to avoid line wraps.
--- .../devicetree/bindings/input/tegra-kbc.txt | 18 +++++ drivers/input/keyboard/tegra-kbc.c | 70 ++++++++++++++++++-- 2 files changed, 83 insertions(+), 5 deletions(-) create mode 100644 Documentation/devicetree/bindings/input/tegra-kbc.txt
Documentation/devicetree/bindings/input/tegra-kbc.txt new file +18 -0
@@ -0,0 +1,18 @@ +* Tegra keyboard controller + +Required properties: +- compatible : "nvidia,tegra20-kbc" + +Optional properties: +- debounce-delay: delay in milliseconds per row scan for debouncing +- repeat-delay: delay in milliseconds before repeat starts +- ghost-filter : enable ghost filtering for this device +- wakeup-source : configure keyboard as a wakeup source for suspend/resume + +Example: + +keyboard: keyboard { + compatible = "nvidia,tegra20-kbc"; + reg = <0x7000e200 0x100>; + ghost-filter; +};
drivers/input/keyboard/tegra-kbc.c +65 -5
118 lines not on this page · raw message
Signature · 1 line
1.7.8.GIT
Dmitry Torokhov
maintainerPATCH v2 1/2 Input: tegra-kbc - add device tree bindings
Hi Olof,
Quoted 4 lines · Olof Johansson
This adds a simple device tree binding to the tegra keyboard controller.
Also, mark the default keymap as
__devinitdatasince it is not referenced after boot, and shorten the name to not have to avoid line wraps.
No, let's keep the names prefixed to match the rest of the driver(s).
Review
Quoted 2 lines
(quoted diff) +2
-0+ + pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
Error handling is missing. I also dislike devm_* facilities as it causes inconsistencies in the way we handle releasing of resources: some of them will be released automatically while others need t be released manually. I prefer having consistent model.
Does the patch below still work for you?
Thanks.
Signature · 19 lines
Dmitry Input: tegra-kbc - add device tree bindings From: Olof Johansson <[email protected]> This adds a simple device tree binding to the tegra keyboard controller. Also, mark the default keymap as __devinitdata since it is not referenced after boot. Signed-off-by: Olof Johansson <[email protected]> Signed-off-by: Dmitry Torokhov <[email protected]> --- .../devicetree/bindings/input/tegra-kbc.txt | 18 ++++ drivers/input/keyboard/tegra-kbc.c | 92 ++++++++++++++++++-- 2 files changed, 102 insertions(+), 8 deletions(-) create mode 100644 Documentation/devicetree/bindings/input/tegra-kbc.txt
Documentation/devicetree/bindings/input/tegra-kbc.txt new file +18 -0
@@ -0,0 +1,18 @@ +* Tegra keyboard controller + +Required properties: +- compatible: "nvidia,tegra20-kbc" + +Optional properties: +- debounce-delay: delay in milliseconds per row scan for debouncing +- repeat-delay: delay in milliseconds before repeat starts +- ghost-filter: enable ghost filtering for this device +- wakeup-source: configure keyboard as a wakeup source for suspend/resume + +Example: + +keyboard: keyboard { + compatible = "nvidia,tegra20-kbc"; + reg = <0x7000e200 0x100>; + ghost-filter; +};
drivers/input/keyboard/tegra-kbc.c +84 -8
164 lines not on this page · raw message
PATCH v2 1/2 Input: tegra-kbc - add device tree bindings
Hi,
Quoted 9 lines · Dmitry Torokhov
Hi Olof,
Quoted 4 lines · Olof Johansson
This adds a simple device tree binding to the tegra keyboard controller.
Also, mark the default keymap as
__devinitdatasince it is not referenced after boot, and shorten the name to not have to avoid line wraps.No, let's keep the names prefixed to match the rest of the driver(s).
Sure, if you prefer.
Quoted 7 lines
Quoted 2 lines
+
+ ? ? pdata =devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);Error handling is missing. I also dislike devm_* facilities as it causes inconsistencies in the way we handle releasing of resources: some of them will be released automatically while others need t be released manually. I prefer having consistent model.
I disagree -- I think the devm allocators are an excellent invention instead of open-coding the error handling, which tends to be error prone and just adds special cases just like you explained below.
But, it's your subsystem and with that being said...
Quoted 1 line
Does the patch below still work for you?
... sure, if you're happy I'm happy -- it gets the work done, couldn't ask for more. No need to argue the details further. :)
-Olof
PATCH v2 1/2 Input: tegra-kbc - add device tree bindings
In reply to Dmitry TorokhovDmitry Torokhov wrote at Tuesday, December 27, 2011 11:49 PM:
Quoted 2 lines · Olof Johansson
Quoted 1 line
This adds a simple device tree binding to the tegra keyboard controller.
...
Quoted 6 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);Error handling is missing. I also dislike devm_* facilities as it causes inconsistencies in the way we handle releasing of resources: some of them will be released automatically while others need t be released manually. I prefer having consistent model.
I have to say that I also disagree here. Weren't the devm_* function specifically added to allow people not to write all the error-handling code themselves. Forcing everyone not to use them doesn't seem right. There have been a ton of patches throughout the kernel converting drivers to use devm_* and at the same time removing and simplifying error handling.
Signature · 1 line
nvpublic
Dmitry Torokhov
maintainerPATCH v2 1/2 Input: tegra-kbc - add device tree bindings
Quoted 11 lines · Stephen Warren
Dmitry Torokhov wrote at Tuesday, December 27, 2011 11:49 PM:
Quoted 2 lines · Olof Johansson
Quoted 1 line
This adds a simple device tree binding to the tegra keyboard controller.
...
Quoted 6 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);Error handling is missing. I also dislike devm_* facilities as it causes inconsistencies in the way we handle releasing of resources: some of them will be released automatically while others need t be released manually. I prefer having consistent model.
Quoted 3 lines
I have to say that I also disagree here. Weren't the devm_* function specifically added to allow people not to write all the error-handling code themselves.
I guess they were. Unfortunately they also introduce inconsistency in the way resources are tracked and freed since some of them support devm_* facilities while others don't. I might be OK with drivers that use one model for all resources but this patch was mixing the two.
devm_* facilities are also not free; you are saving on error handling code but pay with memory footprint required to implement tracking.
Quoted 5 lines
Forcing everyone not to use them doesn't seem right.
There have been a ton of patches throughout the kernel converting drivers to use devm_* and at the same time removing and simplifying error handling.
Thanks.
Signature · 1 line
Dmitry
PATCH v2 1/2 Input: tegra-kbc - add device tree bindings
Quoted 16 lines · Dmitry Torokhov
Quoted 11 lines · Stephen Warren
Dmitry Torokhov wrote at Tuesday, December 27, 2011 11:49 PM:
Quoted 2 lines · Olof Johansson
Quoted 1 line
This adds a simple device tree binding to the tegra keyboard controller.
...
Quoted 6 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);Error handling is missing. I also dislike devm_* facilities as it causes inconsistencies in the way we handle releasing of resources: some of them will be released automatically while others need t be released manually. I prefer having consistent model.
Quoted 3 lines
I have to say that I also disagree here. Weren't the devm_* function specifically added to allow people not to write all the error-handling code themselves.
Quoted 7 lines
I guess they were. Unfortunately they also introduce inconsistency in the way resources are tracked and freed since some of them support devm_* facilities while others don't. I might be OK with drivers that use one model for all resources but this patch was mixing the two.
devm_* facilities are also not free; you are saving on error handling code but pay with memory footprint required to implement tracking.
FWIW, I agree with Olof and Stephen. The devm_* functions are a good thing and I strongly encourage driver authors to use them. The cost in memory footprint is pretty negligible, but making it easier for driver authors to get things right is huge.
g.
PATCH v2 1/2 Input: tegra-kbc - add device tree bindings
In reply to Olof JohanssonQuoted 18 lines · Olof Johansson
This adds a simple device tree binding to the tegra keyboard controller.
Also, mark the default keymap as
__devinitdatasince it is not referenced after boot, and shorten the name to not have to avoid line wraps.Signed-off-by Olof Johansson <[email protected]>--- .../devicetree/bindings/input/tegra-kbc.txt | 18 +++++ drivers/input/keyboard/tegra-kbc.c | 70 ++++++++++++++++++-- 2 files changed, 83 insertions(+), 5 deletions(-) create mode 100644 Documentation/devicetree/bindings/input/tegra-kbc.txtDocumentation/devicetree/bindings/input/tegra-kbc.txt new file +0
-0
Documentation/devicetree/bindings/input/tegra-kbc.txt line 10
Quoted 10 lines
Documentation/devicetree/bindings/input/tegra-kbc.txt new file +10
-0@@ -0,0 +1,18 @@ +* Tegra keyboard controller + +Required properties: +- compatible : "nvidia,tegra20-kbc" + +Optional properties: +- debounce-delay: delay in milliseconds per row scan for debouncing +- repeat-delay: delay in milliseconds before repeat starts +- ghost-filter : enable ghost filtering for this device +- wakeup-source : configure keyboard as a wakeup source for suspend/resume
I'd like to see a "tegra," prefix on these custom properties, but otherwise the binding looks okay to me. You should also consider a '-ms' suffix on the millisecond properties.
Otherwise;
Quoted 141 lines
Documentation/devicetree/bindings/input/tegra-kbc.txt new file +8
-0+ +Example: + +keyboard: keyboard { + compatible = "nvidia,tegra20-kbc"; + reg = <0x7000e200 0x100>; + ghost-filter; +};drivers/input/keyboard/tegra-kbc.c +65
-5@@ -26,6 +26,7 @@#include <linux/delay.h> #include <linux/io.h> #include <linux/interrupt.h> +#include <linux/of.h> #include <linux/clk.h> #include <linux/slab.h> #include <mach/clk.h> @@ -82,7 +83,7 @@ struct tegra_kbc {struct clk *clk; }; -static const u32 tegra_kbc_default_keymap[] = { +static const u32 default_keymap[]__devinitdata = {KEY (0 ,2 ,KEY_W ),KEY (0 ,3 ,KEY_S ),KEY (0 ,4 ,KEY_A ),@@ -217,9 +218,9 @@ static const u32 tegra_kbc_default_keymap[] = { KEY(31, 4, KEY_HELP), }; -static const struct matrix_keymap_data tegra_kbc_default_keymap_data = { - .keymap = tegra_kbc_default_keymap, - .keymap_size =ARRAY_SIZE (tegra_kbc_default_keymap), +static const struct matrix_keymap_data default_keymap_data__devinitdata = { + .keymap = default_keymap, + .keymap_size =ARRAY_SIZE (default_keymap), }; static void tegra_kbc_report_released_keys(struct input_dev *input,@@ -576,6 +577,55 @@ tegra_kbc_check_pin_cfg(const struct tegra_kbc_platform_data *pdata,return true; } +#ifdef CONFIG_OF +static struct tegra_kbc_platform_data *__devinit tegra_kbc_dt_parse_pdata ( +struct platform_device *pdev) +{ +struct tegra_kbc_platform_data *pdata; +struct device_node *np = pdev->dev.of_node; +int i; +u32 prop; + +if (!np) +return NULL ; + + pdata =devm_kzalloc (&pdev->dev,sizeof (*pdata),GFP_KERNEL ); + +if (!of_property_read_u32 (np,"debounce-delay" , &prop)) + pdata->debounce_cnt = prop; + +if (!of_property_read_u32 (np,"repeat-delay" , &prop)) + pdata->repeat_cnt = prop; + +if (of_find_property (np,"needs-ghost-filter" ,NULL )) + pdata->use_ghost_filter = true; + +if (of_find_property (np,"wakeup-source" ,NULL )) + pdata->wakeup = true; + +/* All currently known keymaps with device tree support use the same +* pin_cfg, so set it up here. +*/ +for (i =0 ; i <KBC_MAX_ROW ; i++) { + pdata->pin_cfg[i].num = i; + pdata->pin_cfg[i].is_row = true; + } + +for (i =0 ; i <KBC_MAX_COL ; i++) { + pdata->pin_cfg[KBC_MAX_ROW + i].num = i; + pdata->pin_cfg[KBC_MAX_ROW + i].is_row = false; + } + +return pdata; +} +#else +static inline struct tegra_kbc_platform_data *tegra_kbc_dt_parse_pdata ( +struct platform_device *pdev) +{ +return NULL ; +} +#endif +static int __devinit tegra_kbc_probe (struct platform_device *pdev) {const struct tegra_kbc_platform_data *pdata = pdev->dev.platform_data;@@ -590,6 +640,9 @@ static int __devinit tegra_kbc_probe(struct platform_device *pdev)unsigned int scan_time_rows;if (!pdata) + pdata =tegra_kbc_dt_parse_pdata (pdev); + +if (!pdata)return -EINVAL ;if (!tegra_kbc_check_pin_cfg (pdata, &pdev->dev, &num_rows))@@ -671,7 +724,7 @@ static int __devinit tegra_kbc_probe(struct platform_device *pdev) kbc->use_fn_map = pdata->use_fn_map; kbc->use_ghost_filter = pdata->use_ghost_filter; - keymap_data = pdata->keymap_data ?: &tegra_kbc_default_keymap_data; + keymap_data = pdata->keymap_data ?: &default_keymap_data;matrix_keypad_build_keymap (keymap_data,KBC_ROW_SHIFT , input_dev->keycode, input_dev->keybit);@@ -793,6 +846,12 @@ static int tegra_kbc_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(tegra_kbc_pm_ops, tegra_kbc_suspend, tegra_kbc_resume); +static const struct of_device_id tegra_kbc_of_match[] = { + { .compatible ="nvidia,tegra20-kbc" , }, + { }, +}; +MODULE_DEVICE_TABLE (of, tegra_kbc_of_match); +static struct platform_driver tegra_kbc_driver = { .probe = tegra_kbc_probe, .remove =__devexit_p (tegra_kbc_remove),@@ -800,6 +859,7 @@ static struct platform_driver tegra_kbc_driver = { .name = "tegra-kbc", .owner = THIS_MODULE, .pm = &tegra_kbc_pm_ops, + .of_match_table = tegra_kbc_of_match, }, };Signature · 1 line
1.7.8.GIT
PATCH v2 1/2 Input: tegra-kbc - add device tree bindings
Quoted 3 lines · Grant Likely
I'd like to see a "tegra," prefix on these custom properties, but otherwise the binding looks okay to me. ?You should also consider a '-ms' suffix on the millisecond properties.
Ok, I added "nvidia," prefix for the properties, and pushed down the linux,fn-keymap binding to this level (but I left the implementation as a FIXME).
Quoted 3 lines
Otherwise;
Acked-by Grant Likely <[email protected]>
Thanks, added and I'll repost the patch together with the shared binding in a bit.
-Olof
PATCH v2 2/2 Input: tegra-kbc - add default chromeos map
In reply to Olof JohanssonThis adds a simple way to specify the ChromeOS-specific keyboard map instead of the "standard" map that is used on other Tegra devices such as Harmony-with-keyboard and Seaboard.
I expect the number of different keyboard layouts to be quite limited, and not many should be added over time. So instead of encoding the layout in the device tree, with all the can of worms that entails w.r.t. agreeing on a suitable binding, just add a property to specify that this is the map to be used, and include it in the driver.
If, over time, the number of mappings increase, the binding can be updated to include a custom map as a new property, without having to worry about backwards compatibility on existing devices.
--- .../devicetree/bindings/input/tegra-kbc.txt | 3 + drivers/input/keyboard/tegra-kbc.c | 103 ++++++++++++++++++++ 2 files changed, 106 insertions(+), 0 deletions(-)
Documentation/devicetree/bindings/input/tegra-kbc.txt +3 -0
@@ -8,6 +8,8 @@ Optional properties: - repeat-delay: delay in milliseconds before repeat starts - ghost-filter : enable ghost filtering for this device - wakeup-source : configure keyboard as a wakeup source for suspend/resume +- chromeos-layout : use the standard ChromeOS layout instead of default PC-style + keyboard if this property is present. Example:
@@ -15,4 +17,5 @@ keyboard: keyboard { compatible = "nvidia,tegra20-kbc"; reg = <0x7000e200 0x100>; ghost-filter; + chromeos-layout; };
drivers/input/keyboard/tegra-kbc.c +103 -0
115 lines not on this page · raw message
Signature · 1 line
1.7.8.GIT
Dmitry Torokhov
maintainerPATCH v2 2/2 Input: tegra-kbc - add default chromeos map
Quoted 10 lines · Olof Johansson
This adds a simple way to specify the ChromeOS-specific keyboard map instead of the "standard" map that is used on other Tegra devices such as Harmony-with-keyboard and Seaboard.
I expect the number of different keyboard layouts to be quite limited, and not many should be added over time. So instead of encoding the layout in the device tree, with all the can of worms that entails w.r.t. agreeing on a suitable binding, just add a property to specify that this is the map to be used, and include it in the driver.
Quoted 4 lines
If, over time, the number of mappings increase, the binding can be updated to include a custom map as a new property, without having to worry about backwards compatibility on existing devices.
I'd rather we did not make shortcuts and did the proper DT binding. Samsung folks want the similar thing so making a generic DT keymap parser and using it in the driver would be the best way.
Another option is to simply loading proper keymap by the early userspace.
Thanks.
Signature · 1 line
Dmitry
PATCH v2 2/2 Input: tegra-kbc - add default chromeos map
Hi,
Quoted 11 lines · Dmitry Torokhov
Quoted 10 lines · Olof Johansson
This adds a simple way to specify the ChromeOS-specific keyboard map instead of the "standard" map that is used on other Tegra devices such as Harmony-with-keyboard and Seaboard.
I expect the number of different keyboard layouts to be quite limited, and not many should be added over time. So instead of encoding the layout in the device tree, with all the can of worms that entails w.r.t. agreeing on a suitable binding, just add a property to specify that this is the map to be used, and include it in the driver.
Quoted 8 lines
Quoted 4 lines
If, over time, the number of mappings increase, the binding can be updated to include a custom map as a new property, without having to worry about backwards compatibility on existing devices.
I'd rather we did not make shortcuts and did the proper DT binding. Samsung folks want the similar thing so making a generic DT keymap parser and using it in the driver would be the best way.
Ok, fair point. I found the last posted version of the samsung driver in my archives so I'll continue the discussion there (see separate followup there).
Quoted 2 lines
Another option is to simply loading proper keymap by the early userspace.
I would prefer to do it in hardware, mostly because I don't want to have to add the keymaps to all possible distros I'd be interested in running on this hardware. :)
-Olof
PATCH v2 2/2 Input: tegra-kbc - add default chromeos map
Olof Johansson wrote at Wednesday, December 28, 2011 12:33 AM:
Quoted 18 lines
Quoted 16 lines · Dmitry Torokhov
Quoted 14 lines · Olof Johansson
This adds a simple way to specify the ChromeOS-specific keyboard map instead of the "standard" map that is used on other Tegra devices such as Harmony-with-keyboard and Seaboard.
I expect the number of different keyboard layouts to be quite limited, and not many should be added over time. So instead of encoding the layout in the device tree, with all the can of worms that entails w.r.t. agreeing on a suitable binding, just add a property to specify that this is the map to be used, and include it in the driver.
If, over time, the number of mappings increase, the binding can be updated to include a custom map as a new property, without having to worry about backwards compatibility on existing devices.
Quoted 7 lines
Quoted 3 lines
I'd rather we did not make shortcuts and did the proper DT binding. Samsung folks want the similar thing so making a generic DT keymap parser and using it in the driver would be the best way.
Ok, fair point. I found the last posted version of the samsung driver in my archives so I'll continue the discussion there (see separate followup there).
I agree here. Simon Glass has posted some patches to U-Boot to add the Tegra KBC driver including DT bindings. Can you please co-ordinate with him to ensure the bindings you're proposing for the kernel match those he's proposing for U-Boot; from memory, I don't think they are so far. Also, we need to work out the issue of the kernel needing just the base and function-modified keymap, but U-Boot needing a shift- and ctrl- modified keymap since there's no input layer handling shift/ctrl in U-Boot. I'd prefer that the DT binding be encoded as:
matrix -> keycode for base
matrix -> keycode for function-modified
With the binding for those two defined by either the Tegra KBC binding or a generic matrix KBC binding.
keycode -> keycode for shift-modified
keycode -> keycode for ctrl-modified
With the binding for those two defined by some kind of generic modifier mapping binding, so it could feed into the input layer on Linux, although in U-Boot, the Tegra KBC driver would have to handle it itself, since there's nowhere else to handle it.
Signature · 1 line
nvpublic
PATCH v2 2/2 Input: tegra-kbc - add default chromeos map
Quoted 27 lines · Stephen Warren
Olof Johansson wrote at Wednesday, December 28, 2011 12:33 AM:
Quoted 18 lines
Quoted 16 lines · Dmitry Torokhov
Quoted 14 lines · Olof Johansson
This adds a simple way to specify the ChromeOS-specific keyboard map instead of the "standard" map that is used on other Tegra devices such as Harmony-with-keyboard and Seaboard.
I expect the number of different keyboard layouts to be quite limited, and not many should be added over time. So instead of encoding the layout in the device tree, with all the can of worms that entails w.r.t. agreeing on a suitable binding, just add a property to specify that this is the map to be used, and include it in the driver.
If, over time, the number of mappings increase, the binding can be updated to include a custom map as a new property, without having to worry about backwards compatibility on existing devices.
Quoted 7 lines
Quoted 3 lines
I'd rather we did not make shortcuts and did the proper DT binding. Samsung folks want the similar thing so making a generic DT keymap parser and using it in the driver would be the best way.
Ok, fair point. I found the last posted version of the samsung driver in my archives so I'll continue the discussion there (see separate followup there).
Quoted 8 lines
I agree here. Simon Glass has posted some patches to U-Boot to add the Tegra KBC driver including DT bindings. Can you please co-ordinate with him to ensure the bindings you're proposing for the kernel match those he's proposing for U-Boot; from memory, I don't think they are so far. Also, we need to work out the issue of the kernel needing just the base and function-modified keymap, but U-Boot needing a shift- and ctrl- modified keymap since there's no input layer handling shift/ctrl in U-Boot.
I answered this in the other email; since the modifier keymaps don't actually describe hardware functionality but instead software remappings, it should be done in u-boot, and the device tree binding should be focused on describing the hardware.
Quoted 8 lines
I'd prefer that the DT binding be encoded as:
matrix -> keycode for base
matrix -> keycode for function-modifiedWith the binding for those two defined by either the Tegra KBC binding or a generic matrix KBC binding.
Quoted 7 lines
keycode -> keycode for shift-modified
keycode -> keycode for ctrl-modifiedWith the binding for those two defined by some kind of generic modifier mapping binding, so it could feed into the input layer on Linux, although in U-Boot, the Tegra KBC driver would have to handle it itself, since there's nowhere else to handle it.
This is in my opinion unnecessarily complicated, and it's trying to push too much upper-layer information down into the hardware description. Keeping the binding to the bare minimum needed to describe the actual hardware configuration is the natural common ground not just between u-boot and linux, but also with other operating systems and between different hardware vendors.
-Olof
PATCH v2 2/2 Input: tegra-kbc - add default chromeos map
Olof Johansson wrote at Wednesday, December 28, 2011 11:42 PM:
Quoted 37 lines · Stephen Warren
Quoted 27 lines
Olof Johansson wrote at Wednesday, December 28, 2011 12:33 AM:
Quoted 18 lines
Quoted 16 lines · Dmitry Torokhov
Quoted 14 lines · Olof Johansson
This adds a simple way to specify the ChromeOS-specific keyboard map instead of the "standard" map that is used on other Tegra devices such as Harmony-with-keyboard and Seaboard.
I expect the number of different keyboard layouts to be quite limited, and not many should be added over time. So instead of encoding the layout in the device tree, with all the can of worms that entails w.r.t. agreeing on a suitable binding, just add a property to specify that this is the map to be used, and include it in the driver.
If, over time, the number of mappings increase, the binding can be updated to include a custom map as a new property, without having to worry about backwards compatibility on existing devices.
Quoted 7 lines
Quoted 3 lines
I'd rather we did not make shortcuts and did the proper DT binding. Samsung folks want the similar thing so making a generic DT keymap parser and using it in the driver would be the best way.
Ok, fair point. I found the last posted version of the samsung driver in my archives so I'll continue the discussion there (see separate followup there).
Quoted 8 lines
I agree here. Simon Glass has posted some patches to U-Boot to add the Tegra KBC driver including DT bindings. Can you please co-ordinate with him to ensure the bindings you're proposing for the kernel match those he's proposing for U-Boot; from memory, I don't think they are so far. Also, we need to work out the issue of the kernel needing just the base and function-modified keymap, but U-Boot needing a shift- and ctrl- modified keymap since there's no input layer handling shift/ctrl in U-Boot.
Quoted 4 lines
I answered this in the other email; since the modifier keymaps don't actually describe hardware functionality but instead software remappings, it should be done in u-boot, and the device tree binding should be focused on describing the hardware.
For function/Fn, I think representing that in DT makes sense; there's no simple/standard mapping that any driver could implement to translate a raw keypress to an fn-keypress; the labeling is completely board- specific, and the Fn key is really multi-plexing two completely different keys onto a single physical key (on my x86 laptop, I have a single key for both Insert and Delete, differentiating by using the Fn key). PC (PS/2 or USB) keyboards handle Fn internally to the HW, so I think this gives precedent for considering an Fn mapping part of the HW for a matrix Keyboard.
For shift/ctrl, I agree not having the mappings in DT makes sense. However, Simon Glass gave me pushback on this when I requested the removal of those properties in the U-Boot patch.
Note that my comments immediately below were more about how to modify Simon Glass's patch to be acceptable rather than your proposal.
Quoted 22 lines
Quoted 8 lines
I'd prefer that the DT binding be encoded as:
matrix -> keycode for base
matrix -> keycode for function-modifiedWith the binding for those two defined by either the Tegra KBC binding or a generic matrix KBC binding.
Quoted 7 lines
keycode -> keycode for shift-modified
keycode -> keycode for ctrl-modifiedWith the binding for those two defined by some kind of generic modifier mapping binding, so it could feed into the input layer on Linux, although in U-Boot, the Tegra KBC driver would have to handle it itself, since there's nowhere else to handle it.
This is in my opinion unnecessarily complicated, and it's trying to push too much upper-layer information down into the hardware description. Keeping the binding to the bare minimum needed to describe the actual hardware configuration is the natural common ground not just between u-boot and linux, but also with other operating systems and between different hardware vendors.
Signature · 1 line
nvpublic
PATCH v2 2/2 Input: tegra-kbc - add default chromeos map
Quoted 43 lines · Stephen Warren
Olof Johansson wrote at Wednesday, December 28, 2011 11:42 PM:
Quoted 37 lines · Stephen Warren
Quoted 27 lines
Olof Johansson wrote at Wednesday, December 28, 2011 12:33 AM:
Quoted 18 lines
Quoted 16 lines · Dmitry Torokhov
Quoted 14 lines · Olof Johansson
This adds a simple way to specify the ChromeOS-specific keyboard map instead of the "standard" map that is used on other Tegra devices such as Harmony-with-keyboard and Seaboard.
I expect the number of different keyboard layouts to be quite limited, and not many should be added over time. So instead of encoding the layout in the device tree, with all the can of worms that entails w.r.t. agreeing on a suitable binding, just add a property to specify that this is the map to be used, and include it in the driver.
If, over time, the number of mappings increase, the binding can be updated to include a custom map as a new property, without having to worry about backwards compatibility on existing devices.
Quoted 7 lines
Quoted 3 lines
I'd rather we did not make shortcuts and did the proper DT binding. Samsung folks want the similar thing so making a generic DT keymap parser and using it in the driver would be the best way.
Ok, fair point. I found the last posted version of the samsung driver in my archives so I'll continue the discussion there (see separate followup there).
Quoted 8 lines
I agree here. Simon Glass has posted some patches to U-Boot to add the Tegra KBC driver including DT bindings. Can you please co-ordinate with him to ensure the bindings you're proposing for the kernel match those he's proposing for U-Boot; from memory, I don't think they are so far. Also, we need to work out the issue of the kernel needing just the base and function-modified keymap, but U-Boot needing a shift- and ctrl- modified keymap since there's no input layer handling shift/ctrl in U-Boot.
Quoted 4 lines
I answered this in the other email; since the modifier keymaps don't actually describe hardware functionality but instead software remappings, it should be done in u-boot, and the device tree binding should be focused on describing the hardware.
Quoted 6 lines
For function/Fn, I think representing that in DT makes sense; there's no simple/standard mapping that any driver could implement to translate a raw keypress to an fn-keypress; the labeling is completely board- specific, and the Fn key is really multi-plexing two completely different keys onto a single physical key (on my x86 laptop, I have a single key for both Insert and Delete, differentiating by using the Fn key).
I'm torn. The analogy here is more about localized keyboards than anything else, and the solution there is to handle it in higher layers of the input stack.
I could be OK with _one_ additional optional keymap for the fn modifier, but I think it's a slippery slope. I know Rakesh got pushback when he originally tried to present the hardware that way in the platform data, so I guess we might get pushback there now as well. Dmitry?
Quoted 4 lines
PC
(PS/2 or USB) keyboards handle Fn internally to the HW, so I think this gives precedent for considering an Fn mapping part of the HW for a matrix Keyboard.
Right, the modifier key in that case is either a physical modification of which circuits get closed, or at least it's treated that way by the EC that presents it in such a manner.
Quoted 6 lines
For shift/ctrl, I agree not having the mappings in DT makes sense. However, Simon Glass gave me pushback on this when I requested the removal of those properties in the U-Boot patch.
Note that my comments immediately below were more about how to modify Simon Glass's patch to be acceptable rather than your proposal.
Ok, I think we're in agreement on that. And since they already need software mappings for that, they could add one for unmodified keys and use that for the linux-keycode -> ascii char translation if needed.
-Olof
Dmitry Torokhov
maintainerPATCH v2 2/2 Input: tegra-kbc - add default chromeos map
Quoted 55 lines · Olof Johansson
Quoted 43 lines · Stephen Warren
Olof Johansson wrote at Wednesday, December 28, 2011 11:42 PM:
Quoted 37 lines · Stephen Warren
Quoted 27 lines
Olof Johansson wrote at Wednesday, December 28, 2011 12:33 AM:
Quoted 18 lines
Quoted 16 lines · Dmitry Torokhov
Quoted 14 lines · Olof Johansson
This adds a simple way to specify the ChromeOS-specific keyboard map instead of the "standard" map that is used on other Tegra devices such as Harmony-with-keyboard and Seaboard.
I expect the number of different keyboard layouts to be quite limited, and not many should be added over time. So instead of encoding the layout in the device tree, with all the can of worms that entails w.r.t. agreeing on a suitable binding, just add a property to specify that this is the map to be used, and include it in the driver.
If, over time, the number of mappings increase, the binding can be updated to include a custom map as a new property, without having to worry about backwards compatibility on existing devices.
Quoted 7 lines
Quoted 3 lines
I'd rather we did not make shortcuts and did the proper DT binding. Samsung folks want the similar thing so making a generic DT keymap parser and using it in the driver would be the best way.
Ok, fair point. I found the last posted version of the samsung driver in my archives so I'll continue the discussion there (see separate followup there).
Quoted 8 lines
I agree here. Simon Glass has posted some patches to U-Boot to add the Tegra KBC driver including DT bindings. Can you please co-ordinate with him to ensure the bindings you're proposing for the kernel match those he's proposing for U-Boot; from memory, I don't think they are so far. Also, we need to work out the issue of the kernel needing just the base and function-modified keymap, but U-Boot needing a shift- and ctrl- modified keymap since there's no input layer handling shift/ctrl in U-Boot.
Quoted 4 lines
I answered this in the other email; since the modifier keymaps don't actually describe hardware functionality but instead software remappings, it should be done in u-boot, and the device tree binding should be focused on describing the hardware.
Quoted 6 lines
For function/Fn, I think representing that in DT makes sense; there's no simple/standard mapping that any driver could implement to translate a raw keypress to an fn-keypress; the labeling is completely board- specific, and the Fn key is really multi-plexing two completely different keys onto a single physical key (on my x86 laptop, I have a single key for both Insert and Delete, differentiating by using the Fn key).
I'm torn. The analogy here is more about localized keyboards than anything else, and the solution there is to handle it in higher layers of the input stack.
Quoted 5 lines
I could be OK with _one_ additional optional keymap for the fn modifier, but I think it's a slippery slope. I know Rakesh got pushback when he originally tried to present the hardware that way in the platform data, so I guess we might get pushback there now as well. Dmitry?
I think having separate Fn map is OK since, as Stephen correctly mentioned, it usually emulates as Fn works in AT keyboards, i.e. completely hidden by the firmware. Also the set of keys produced by Fn is usually "control"-like and requiring keymaps would stop clients listening on /dev/input/eventX from recognizing them.
Here is what I wrote to Rakesh:
Quoted 9 lines
Yes, indeed, you are stumbling against limitation of X which does not allow to pass keycodes above 255 through it.
One option would be assigning
KEY_LEFTMETAorKEY_RIGHTMETAto your 'Fn' key and then adjusting keymaps, but after I looked again at the keys you have assigned by default to your Fn combinations can see how one would want to avoid involving X's keymaps and be able to generate needed keycodes directly (volume, brightness and other control events) so that infrastructure need not be hooked into X to be able to react to them.
The Shift, Ctrl and other modifiers, on the other hand, should be done in userspace so that standard locale-specific keymap could be loaded and used.
Quoted 21 lines
Quoted 5 lines
PC
(PS/2 or USB) keyboards handle Fn internally to the HW, so I think this gives precedent for considering an Fn mapping part of the HW for a matrix Keyboard.Right, the modifier key in that case is either a physical modification of which circuits get closed, or at least it's treated that way by the EC that presents it in such a manner.
Quoted 6 lines
For shift/ctrl, I agree not having the mappings in DT makes sense. However, Simon Glass gave me pushback on this when I requested the removal of those properties in the U-Boot patch.
Note that my comments immediately below were more about how to modify Simon Glass's patch to be acceptable rather than your proposal.
Ok, I think we're in agreement on that. And since they already need software mappings for that, they could add one for unmodified keys and use that for the linux-keycode -> ascii char translation if needed.
Signature · 1 line
Dmitry
PATCH v2 2/2 Input: tegra-kbc - add default chromeos map
Quoted 62 lines · Dmitry Torokhov
Quoted 55 lines · Olof Johansson
Quoted 43 lines · Stephen Warren
Olof Johansson wrote at Wednesday, December 28, 2011 11:42 PM:
Quoted 37 lines · Stephen Warren
Quoted 27 lines
Olof Johansson wrote at Wednesday, December 28, 2011 12:33 AM:
Quoted 18 lines
Quoted 16 lines · Dmitry Torokhov
Quoted 14 lines · Olof Johansson
This adds a simple way to specify the ChromeOS-specific keyboard map instead of the "standard" map that is used on other Tegra devices such as Harmony-with-keyboard and Seaboard.
I expect the number of different keyboard layouts to be quite limited, and not many should be added over time. So instead of encoding the layout in the device tree, with all the can of worms that entails w.r.t. agreeing on a suitable binding, just add a property to specify that this is the map to be used, and include it in the driver.
If, over time, the number of mappings increase, the binding can be updated to include a custom map as a new property, without having to worry about backwards compatibility on existing devices.
Quoted 7 lines
Quoted 3 lines
I'd rather we did not make shortcuts and did the proper DT binding. Samsung folks want the similar thing so making a generic DT keymap parser and using it in the driver would be the best way.
Ok, fair point. I found the last posted version of the samsung driver in my archives so I'll continue the discussion there (see separate followup there).
Quoted 8 lines
I agree here. Simon Glass has posted some patches to U-Boot to add the Tegra KBC driver including DT bindings. Can you please co-ordinate with him to ensure the bindings you're proposing for the kernel match those he's proposing for U-Boot; from memory, I don't think they are so far. Also, we need to work out the issue of the kernel needing just the base and function-modified keymap, but U-Boot needing a shift- and ctrl- modified keymap since there's no input layer handling shift/ctrl in U-Boot.
Quoted 4 lines
I answered this in the other email; since the modifier keymaps don't actually describe hardware functionality but instead software remappings, it should be done in u-boot, and the device tree binding should be focused on describing the hardware.
Quoted 6 lines
For function/Fn, I think representing that in DT makes sense; there's no simple/standard mapping that any driver could implement to translate a raw keypress to an fn-keypress; the labeling is completely board- specific, and the Fn key is really multi-plexing two completely different keys onto a single physical key (on my x86 laptop, I have a single key for both Insert and Delete, differentiating by using the Fn key).
I'm torn. The analogy here is more about localized keyboards than anything else, and the solution there is to handle it in higher layers of the input stack.
Quoted 5 lines
I could be OK with _one_ additional optional keymap for the fn modifier, but I think it's a slippery slope. I know Rakesh got pushback when he originally tried to present the hardware that way in the ?platform data, so I guess we might get pushback there now as well. Dmitry?
Quoted 5 lines
I think having separate Fn map is OK since, as Stephen correctly mentioned, it usually emulates as Fn works in AT keyboards, i.e. completely hidden by the firmware. Also the set of keys produced by Fn is usually "control"-like and requiring keymaps would stop clients listening on
/dev/input/eventXfrom recognizing them.
Alright, I'll revise the bindings (and make room for an optional linux,fn-keymap property) tomorrow morning.
[...]
Quoted 3 lines
The Shift, Ctrl and other modifiers, on the other hand, should be done in userspace so that standard locale-specific keymap could be loaded and used.
Alright. Now we just have to rope in Simon into agreement as well and we'll be all set. He's back from his vacation next week.
-Olof