* Re: [PATCH v1 3/3] dt-bindings: google,cros-ec-keyb: add fn-key and f-keymap props [not found] ` <20251209192243.GA963693-robh@kernel.org> @ 2025-12-10 18:00 ` Fabio Baltieri 2025-12-12 4:44 ` Dmitry Torokhov 0 siblings, 1 reply; 6+ messages in thread From: Fabio Baltieri @ 2025-12-10 18:00 UTC (permalink / raw) To: Rob Herring Cc: Dmitry Torokhov, Krzysztof Kozlowski, Conor Dooley, Benson Leung, Guenter Roeck, Tzung-Bi Shih, Simon Glass, linux-input, devicetree, chrome-platform, linux-kernel Hey Rob, thanks for the review. On Tue, Dec 09, 2025 at 01:22:43PM -0600, Rob Herring wrote: > On Tue, Dec 09, 2025 at 03:47:06PM +0000, Fabio Baltieri wrote: > > + fn-key: > > + $ref: /schemas/types.yaml#/definitions/uint32 > > + description: | > > + An u32 containing the coordinate of the Fn key, use the MATRIX_KEY(row, > > + col, code) macro, code is ignored. > > + > > + fn-keymap: > > If keymap is linux,keymap, then this should perhaps be linux,fn-keymap. > Depends if we still think linux,keymap is Linux specific? I'm open for suggestions, trying to understand the pattern, these are specific to this binding I think if anything they should be google,fn-key and google,fn-keymap, similarly to the existing google,needs-ghost-filter -- no idea why function-row-physmap was not prefixed but I guess it slipped in and now it's not worth changing it. Would it make sense? Thanks, Fabio -- Fabio Baltieri ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 3/3] dt-bindings: google,cros-ec-keyb: add fn-key and f-keymap props 2025-12-10 18:00 ` [PATCH v1 3/3] dt-bindings: google,cros-ec-keyb: add fn-key and f-keymap props Fabio Baltieri @ 2025-12-12 4:44 ` Dmitry Torokhov 2025-12-16 12:23 ` Fabio Baltieri 0 siblings, 1 reply; 6+ messages in thread From: Dmitry Torokhov @ 2025-12-12 4:44 UTC (permalink / raw) To: Fabio Baltieri Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Benson Leung, Guenter Roeck, Tzung-Bi Shih, Simon Glass, linux-input, devicetree, chrome-platform, linux-kernel On Wed, Dec 10, 2025 at 06:00:29PM +0000, Fabio Baltieri wrote: > Hey Rob, thanks for the review. > > On Tue, Dec 09, 2025 at 01:22:43PM -0600, Rob Herring wrote: > > On Tue, Dec 09, 2025 at 03:47:06PM +0000, Fabio Baltieri wrote: > > > + fn-key: > > > + $ref: /schemas/types.yaml#/definitions/uint32 > > > + description: | > > > + An u32 containing the coordinate of the Fn key, use the MATRIX_KEY(row, > > > + col, code) macro, code is ignored. > > > + > > > + fn-keymap: > > > > If keymap is linux,keymap, then this should perhaps be linux,fn-keymap. > > Depends if we still think linux,keymap is Linux specific? > > I'm open for suggestions, trying to understand the pattern, these are > specific to this binding I think if anything they should be > google,fn-key and google,fn-keymap, similarly to the existing > google,needs-ghost-filter -- no idea why function-row-physmap was not > prefixed but I guess it slipped in and now it's not worth changing it. Just double the number of rows in the regular keymap to accommodate the FN modifier, no need for separate keymap. Also no need to have fn-key property, use whatever key that reports KEY_FN. See how it is done in drivers/input/keyboard/tegra-kbc.c Thanks. -- Dmitry ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 3/3] dt-bindings: google,cros-ec-keyb: add fn-key and f-keymap props 2025-12-12 4:44 ` Dmitry Torokhov @ 2025-12-16 12:23 ` Fabio Baltieri 2025-12-17 18:05 ` Dmitry Torokhov 0 siblings, 1 reply; 6+ messages in thread From: Fabio Baltieri @ 2025-12-16 12:23 UTC (permalink / raw) To: Dmitry Torokhov Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Benson Leung, Guenter Roeck, Tzung-Bi Shih, Simon Glass, linux-input, devicetree, chrome-platform, linux-kernel Hi Dmitry, On Thu, Dec 11, 2025 at 08:44:02PM -0800, Dmitry Torokhov wrote: > On Wed, Dec 10, 2025 at 06:00:29PM +0000, Fabio Baltieri wrote: > > Hey Rob, thanks for the review. > > > > On Tue, Dec 09, 2025 at 01:22:43PM -0600, Rob Herring wrote: > > > On Tue, Dec 09, 2025 at 03:47:06PM +0000, Fabio Baltieri wrote: > > > > + fn-key: > > > > + $ref: /schemas/types.yaml#/definitions/uint32 > > > > + description: | > > > > + An u32 containing the coordinate of the Fn key, use the MATRIX_KEY(row, > > > > + col, code) macro, code is ignored. > > > > + > > > > + fn-keymap: > > > > > > If keymap is linux,keymap, then this should perhaps be linux,fn-keymap. > > > Depends if we still think linux,keymap is Linux specific? > > > > I'm open for suggestions, trying to understand the pattern, these are > > specific to this binding I think if anything they should be > > google,fn-key and google,fn-keymap, similarly to the existing > > google,needs-ghost-filter -- no idea why function-row-physmap was not > > prefixed but I guess it slipped in and now it's not worth changing it. > > Just double the number of rows in the regular keymap to accommodate the > FN modifier, no need for separate keymap. Also no need to have fn-key > property, use whatever key that reports KEY_FN. See how it is done in > drivers/input/keyboard/tegra-kbc.c Had a look at the tegra-kbc driver as you suggested, first thing it seems like the fn-key functionality there is dead code since 2013, `use_fn_map` could only be enabled with platform data, not OF, and that has been removed in 3a495aeada2b, as it stands kbc->use_fn_map can only be false. I could send a patch to rip off that code if you want me to, clearly it hasn't been used in a while (unless I'm missing something). About the extended fn map, I've two problems with it: - it seems very wasteful: the normal map is loaded in a linear array so it can be access directly, which make sense as that's typically very densely populated, but in the case of the fn keys that's going to be mostly empty, I'd expect ~20 keys top from a 18x8 matrix. So that would waste load of space, direct access is good but for ~20 keys I think it's fine to scan it, especially since it only happens when Fn is pressed. - I'd end up with two values for cols kicking around the driver, the real one and the one used in the map, which I feel adds confusing in the code. - more importantly, one would have to keep the offset in mind when setting the keys in dt, we rely on OEM doing this and I think having a separate property with a meaningful name and a map with the same row,col and different code is more intuitive and would make their life easier, especially since we ship with keyboard of different size and the offset would be different depending on the device. As for the fn-key property, unfortunately based on past experience I'd expect such OEM to want to change that code, I could specify the code rather than the row,col but I would not plain hardcode. Even my (thinkpad) laptop sends KEY_WAKEUP for Fn. Cheers, Fabio -- Fabio Baltieri ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 3/3] dt-bindings: google,cros-ec-keyb: add fn-key and f-keymap props 2025-12-16 12:23 ` Fabio Baltieri @ 2025-12-17 18:05 ` Dmitry Torokhov 2025-12-23 15:29 ` Fabio Baltieri 0 siblings, 1 reply; 6+ messages in thread From: Dmitry Torokhov @ 2025-12-17 18:05 UTC (permalink / raw) To: Fabio Baltieri Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Benson Leung, Guenter Roeck, Tzung-Bi Shih, Simon Glass, linux-input, devicetree, chrome-platform, linux-kernel Hi Fabio, On Tue, Dec 16, 2025 at 12:23:06PM +0000, Fabio Baltieri wrote: > Hi Dmitry, > > On Thu, Dec 11, 2025 at 08:44:02PM -0800, Dmitry Torokhov wrote: > > On Wed, Dec 10, 2025 at 06:00:29PM +0000, Fabio Baltieri wrote: > > > Hey Rob, thanks for the review. > > > > > > On Tue, Dec 09, 2025 at 01:22:43PM -0600, Rob Herring wrote: > > > > On Tue, Dec 09, 2025 at 03:47:06PM +0000, Fabio Baltieri wrote: > > > > > + fn-key: > > > > > + $ref: /schemas/types.yaml#/definitions/uint32 > > > > > + description: | > > > > > + An u32 containing the coordinate of the Fn key, use the MATRIX_KEY(row, > > > > > + col, code) macro, code is ignored. > > > > > + > > > > > + fn-keymap: > > > > > > > > If keymap is linux,keymap, then this should perhaps be linux,fn-keymap. > > > > Depends if we still think linux,keymap is Linux specific? > > > > > > I'm open for suggestions, trying to understand the pattern, these are > > > specific to this binding I think if anything they should be > > > google,fn-key and google,fn-keymap, similarly to the existing > > > google,needs-ghost-filter -- no idea why function-row-physmap was not > > > prefixed but I guess it slipped in and now it's not worth changing it. > > > > Just double the number of rows in the regular keymap to accommodate the > > FN modifier, no need for separate keymap. Also no need to have fn-key > > property, use whatever key that reports KEY_FN. See how it is done in > > drivers/input/keyboard/tegra-kbc.c > > Had a look at the tegra-kbc driver as you suggested, first thing it > seems like the fn-key functionality there is dead code since 2013, > `use_fn_map` could only be enabled with platform data, not OF, and that > has been removed in 3a495aeada2b, as it stands kbc->use_fn_map can only > be false. I could send a patch to rip off that code if you want me to, > clearly it hasn't been used in a while (unless I'm missing something). I guess you are right, we shoudl clean that up. We have another newer driver that uses the same approach: drivers/input/keyboard/pinephone-keyboard.c > About the extended fn map, I've two problems with it: > - it seems very wasteful: the normal map is loaded in a linear array > so it can be access directly, which make sense as that's typically > very densely populated, but in the case of the fn keys that's going to > be mostly empty, I'd expect ~20 keys top from a 18x8 matrix. So that > would waste load of space, direct access is good but for ~20 keys I > think it's fine to scan it, especially since it only happens when Fn > is pressed. I am not concerned with this, as this is a singleton device. You probably "waste" as much space in the code segment by implementing the custom scanning logic. Additionally with the consolidated keymap approach you are not breaking ioctls dealing with setting and retrieving key codes. > - I'd end up with two values for cols kicking around the driver, the > real one and the one used in the map, which I feel adds confusing in > the code. Not sure I follow. You still have the same row and col reported, just when figuring out the final keycode you need to add an offset. > - more importantly, one would have to keep the offset in mind when > setting the keys in dt, we rely on OEM doing this and I think having a Do we now? I thought we retain greater control over this. Maybe we should sync internally. > separate property with a meaningful name and a map with the same > row,col and different code is more intuitive and would make their life > easier, especially since we ship with keyboard of different size > and the offset would be different depending on the device. > > As for the fn-key property, unfortunately based on past experience I'd > expect such OEM to want to change that code, I could specify the code > rather than the row,col but I would not plain hardcode. Even my > (thinkpad) laptop sends KEY_WAKEUP for Fn. Again, we need to make sure we control OEMs better. On Lenovo Fn sends wakeup only if it is not combined with another key, so it really has custom logic with events delivered either through the main AT keyboard or through custom interface in thinkpad platform driver. We do not need this in oiur designs. Thanks. -- Dmitry ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 3/3] dt-bindings: google,cros-ec-keyb: add fn-key and f-keymap props 2025-12-17 18:05 ` Dmitry Torokhov @ 2025-12-23 15:29 ` Fabio Baltieri 0 siblings, 0 replies; 6+ messages in thread From: Fabio Baltieri @ 2025-12-23 15:29 UTC (permalink / raw) To: Dmitry Torokhov Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Benson Leung, Guenter Roeck, Tzung-Bi Shih, Simon Glass, linux-input, devicetree, chrome-platform, linux-kernel On Wed, Dec 17, 2025 at 10:05:45AM -0800, Dmitry Torokhov wrote: > > Had a look at the tegra-kbc driver as you suggested, first thing it > > seems like the fn-key functionality there is dead code since 2013, > > `use_fn_map` could only be enabled with platform data, not OF, and that > > has been removed in 3a495aeada2b, as it stands kbc->use_fn_map can only > > be false. I could send a patch to rip off that code if you want me to, > > clearly it hasn't been used in a while (unless I'm missing something). > > I guess you are right, we shoudl clean that up. We have another newer > driver that uses the same approach: > > drivers/input/keyboard/pinephone-keyboard.c Alright I'll look into it and rework a v2 with the extended map, checked the code again and I see your arguments, sounds reasonable. Cheers, Fabio -- Fabio Baltieri ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <20251209154706.529784-3-fabiobaltieri@chromium.org>]
[parent not found: <CAFLszThUU4hfb4vY4mmGHQadRKThG3e=9cAKRy_ampKwA_XNcA@mail.gmail.com>]
* Re: [PATCH v1 2/3] Input: cros_ec_keyb: add function key support [not found] ` <CAFLszThUU4hfb4vY4mmGHQadRKThG3e=9cAKRy_ampKwA_XNcA@mail.gmail.com> @ 2025-12-15 13:09 ` Fabio Baltieri 0 siblings, 0 replies; 6+ messages in thread From: Fabio Baltieri @ 2025-12-15 13:09 UTC (permalink / raw) To: Simon Glass Cc: Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Benson Leung, Guenter Roeck, Tzung-Bi Shih, linux-input, devicetree, chrome-platform, linux-kernel Hey Simon, On Thu, Dec 11, 2025 at 06:29:01AM -0700, Simon Glass wrote: > > @@ -44,6 +52,13 @@ > > * @bs_idev: The input device for non-matrix buttons and switches (or NULL). > > * @notifier: interrupt event notifier for transport devices > > * @vdata: vivaldi function row data > > + * @fn_key: coordinate of the function key > > + * @fn_keymap: array of coordinate and codes for the function keys > > + * @fn_keymap_len: number of entries in the fn_keymap array > > + * @fn_key_status: active function keys bitmap > > + * @normal_key_status: active normal keys bitmap > > + * @fn_key_pressed: tracks the function key status > > + * @fn_key_triggered: tracks where any function key fired > > */ > > struct cros_ec_keyb { > > unsigned int rows; > > @@ -61,6 +76,14 @@ struct cros_ec_keyb { > > struct notifier_block notifier; > > > > struct vivaldi_data vdata; > > + > > + uint32_t fn_key; > > Normally we use u32/u8 these days Okay, I did notice the file was a bit of a mix, I'll change them in v2. > > > + uint32_t *fn_keymap; > > + int fn_keymap_len; > > + uint32_t fn_key_status; > > + uint8_t normal_key_status[CROS_EC_KEYBOARD_COLS_MAX]; > > + bool fn_key_pressed; > > + bool fn_key_triggered; > > }; > > > > /** > > @@ -166,16 +189,108 @@ static bool cros_ec_keyb_has_ghosting(struct cros_ec_keyb *ckdev, uint8_t *buf) > > return false; > > } > > > > +static bool cros_ec_key_is(int row, int col, uint32_t key) > > +{ > > + if (row == KEY_ROW(key) && col == KEY_COL(key)) > > + return true; > > + > > + return false; > > +} > > + > > +static void cros_ec_keyb_process_one(struct cros_ec_keyb *ckdev, > > + int row, int col, bool state) > > +{ > > + struct input_dev *idev = ckdev->idev; > > + const unsigned short *keycodes = idev->keycode; > > + int pos = MATRIX_SCAN_CODE(row, col, ckdev->row_shift); > > + unsigned int code = keycodes[pos]; > > + > > + dev_dbg(ckdev->dev, "changed: [r%d c%d]: byte %02x\n", row, col, state); > > + > > + if (ckdev->fn_keymap) { > > + if (cros_ec_key_is(row, col, ckdev->fn_key)) { > > + ckdev->fn_key_pressed = state; > > + > > + if (state) { > > + ckdev->fn_key_triggered = false; > > + } else if (!ckdev->fn_key_triggered) { > > + /* > > + * Send the original code if nothing else has > > + * been pressed together with Fn. > > + */ > > + input_event(idev, EV_MSC, MSC_SCAN, pos); > > + input_report_key(idev, code, true); > > + input_sync(ckdev->idev); > > What is this function? I might be missing a patch? input_sync? it sends an EV_SYN, been there from the start, though I noticed I miss one two lines below, was relying on the rest of the function to send it but I changed the logic at some point and broke that path, will fix that. > > > + > > + input_event(idev, EV_MSC, MSC_SCAN, pos); > > + input_report_key(idev, code, false); > > + } > > + > > + return; > > + } > > + > > + if (!state) { > > + /* Key release, may need to release the Fn code */ > > + for (int i = 0; i < ckdev->fn_keymap_len; i++) { > > + if (!cros_ec_key_is(row, col, > > + ckdev->fn_keymap[i])) > > + continue; > > + > > + if ((ckdev->fn_key_status & BIT(i)) == 0) > > + continue; > > + > > + code = KEY_VAL(ckdev->fn_keymap[i]); > > + ckdev->fn_key_status &= ~BIT(i); > > + > > + input_event(idev, EV_MSC, MSC_SCAN, pos); > > + input_report_key(idev, code, state); > > + > > + return; > > + } > > + > > + if ((ckdev->normal_key_status[col] & BIT(row)) == 0) > > + /* Discard, key press code was not sent */ > > + return; > > + } else if (ckdev->fn_key_pressed) { > > + /* Key press while holding Fn */ > > + ckdev->fn_key_triggered = true; > > + > > + for (int i = 0; i < ckdev->fn_keymap_len; i++) { > > + if (!cros_ec_key_is(row, col, > > + ckdev->fn_keymap[i])) > > + continue; > > + > > + code = KEY_VAL(ckdev->fn_keymap[i]); > > + ckdev->fn_key_status |= BIT(i); > > + > > + input_event(idev, EV_MSC, MSC_SCAN, pos); > > + input_report_key(idev, code, state); > > + > > + return; > > + } > > + > > + /* Do not emit a code if the key is not mapped */ > > + return; > > + } > > + } > > I think this function could do with splitting a bit Yeah, I don't love it either but there's a lot of logic intertwined in there, tried to split it myself and ended up breaking stuff, the logic for the fn key itsel though can go that's a good 16 lines, I'll start with that, send a v2 and then go from there. > Can the sandbox driver support this too? Not sure what you are referring to, can you give me a pointer? Hey thanks for the review, good to hear from you. :-) Cheers, Fabio -- Fabio Baltieri ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-12-23 15:29 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20251209154706.529784-1-fabiobaltieri@chromium.org>
[not found] ` <20251209154706.529784-4-fabiobaltieri@chromium.org>
[not found] ` <20251209192243.GA963693-robh@kernel.org>
2025-12-10 18:00 ` [PATCH v1 3/3] dt-bindings: google,cros-ec-keyb: add fn-key and f-keymap props Fabio Baltieri
2025-12-12 4:44 ` Dmitry Torokhov
2025-12-16 12:23 ` Fabio Baltieri
2025-12-17 18:05 ` Dmitry Torokhov
2025-12-23 15:29 ` Fabio Baltieri
[not found] ` <20251209154706.529784-3-fabiobaltieri@chromium.org>
[not found] ` <CAFLszThUU4hfb4vY4mmGHQadRKThG3e=9cAKRy_ampKwA_XNcA@mail.gmail.com>
2025-12-15 13:09 ` [PATCH v1 2/3] Input: cros_ec_keyb: add function key support Fabio Baltieri
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox