[PATCH v2 2/2] dt-bindings: google,cros-ec-keyb: add use-fn-overlay prop

Fabio Baltieri posted 2 patches 1 month, 2 weeks ago
There is a newer version of this series
[PATCH v2 2/2] dt-bindings: google,cros-ec-keyb: add use-fn-overlay prop
Posted by Fabio Baltieri 1 month, 2 weeks ago
Add binding documentation for the use-fn-overlay property.

Signed-off-by: Fabio Baltieri <fabiobaltieri@chromium.org>
---
 .../bindings/input/google,cros-ec-keyb.yaml   | 25 +++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml b/Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml
index fefaaf46a240..437575cdf352 100644
--- a/Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml
+++ b/Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml
@@ -44,6 +44,14 @@ properties:
       where the lower 16 bits are reserved. This property is specified only
       when the keyboard has a custom design for the top row keys.
 
+  google,use-fn-overlay:
+    description: |
+      Use a function key overlay. This allows defining an extra set of codes
+      that are sent if a key is pressed while the KEY_FN is held pressed as
+      well. The function codes have to be defined in the linux,keymap property
+      with an offset of keypad,num-rows from the normal ones.
+    type: boolean
+
 dependencies:
   function-row-physmap: [ 'linux,keymap' ]
   google,needs-ghost-filter: [ 'linux,keymap' ]
@@ -132,6 +140,23 @@ examples:
             /* UP      LEFT    */
             0x070b0067 0x070c0069>;
     };
+  - |
+    /* With function keys */
+    #include <dt-bindings/input/input.h>
+    keyboard-controller {
+        compatible = "google,cros-ec-keyb";
+        keypad,num-rows = <8>;
+        keypad,num-columns = <18>;
+        google,use-fn-overlay;
+        linux,keymap = <
+            MATRIX_KEY(0x00, 0x00, KEY_FN)
+            MATRIX_KEY(0x01, 0x00, KEY_1)
+            MATRIX_KEY(0x02, 0x00, KEY_2)
+
+            MATRIX_KEY(8 + 0x01, 0x00, KEY_F1)
+            MATRIX_KEY(8 + 0x02, 0x00, KEY_F2)
+        >;
+    };
   - |
     /* No matrix keyboard, just buttons/switches */
     keyboard-controller {
-- 
2.52.0.351.gbe84eed79e-goog
Re: [PATCH v2 2/2] dt-bindings: google,cros-ec-keyb: add use-fn-overlay prop
Posted by Krzysztof Kozlowski 1 month, 2 weeks ago
On Wed, Dec 24, 2025 at 03:22:38PM +0000, Fabio Baltieri wrote:
> Add binding documentation for the use-fn-overlay property.
> 
> Signed-off-by: Fabio Baltieri <fabiobaltieri@chromium.org>
> ---
>  .../bindings/input/google,cros-ec-keyb.yaml   | 25 +++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml b/Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml
> index fefaaf46a240..437575cdf352 100644
> --- a/Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml
> +++ b/Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml
> @@ -44,6 +44,14 @@ properties:
>        where the lower 16 bits are reserved. This property is specified only
>        when the keyboard has a custom design for the top row keys.
>  
> +  google,use-fn-overlay:
> +    description: |
> +      Use a function key overlay. This allows defining an extra set of codes

What is a function key overlay? Overlays are DT term and therefore are
not suitable for bindings.

> +      that are sent if a key is pressed while the KEY_FN is held pressed as
> +      well. The function codes have to be defined in the linux,keymap property
> +      with an offset of keypad,num-rows from the normal ones.
> +    type: boolean
> +
>  dependencies:
>    function-row-physmap: [ 'linux,keymap' ]
>    google,needs-ghost-filter: [ 'linux,keymap' ]
> @@ -132,6 +140,23 @@ examples:
>              /* UP      LEFT    */
>              0x070b0067 0x070c0069>;
>      };
> +  - |
> +    /* With function keys */
> +    #include <dt-bindings/input/input.h>
> +    keyboard-controller {
> +        compatible = "google,cros-ec-keyb";
> +        keypad,num-rows = <8>;
> +        keypad,num-columns = <18>;
> +        google,use-fn-overlay;

Difference in one property does not justify new example.

Best regards,
Krzysztof
Re: [PATCH v2 2/2] dt-bindings: google,cros-ec-keyb: add use-fn-overlay prop
Posted by Fabio Baltieri 1 month, 2 weeks ago
On Sat, Dec 27, 2025 at 01:44:26PM +0100, Krzysztof Kozlowski wrote:
> > diff --git a/Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml b/Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml
> > index fefaaf46a240..437575cdf352 100644
> > --- a/Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml
> > +++ b/Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml
> > @@ -44,6 +44,14 @@ properties:
> >        where the lower 16 bits are reserved. This property is specified only
> >        when the keyboard has a custom design for the top row keys.
> >  
> > +  google,use-fn-overlay:
> > +    description: |
> > +      Use a function key overlay. This allows defining an extra set of codes
> 
> What is a function key overlay? Overlays are DT term and therefore are
> not suitable for bindings.

Ok, guess I can rename it to `use-fn-key` or `use-fn-layer`, open to
suggestions really.

> > +      that are sent if a key is pressed while the KEY_FN is held pressed as
> > +      well. The function codes have to be defined in the linux,keymap property
> > +      with an offset of keypad,num-rows from the normal ones.
> > +    type: boolean
> > +
> >  dependencies:
> >    function-row-physmap: [ 'linux,keymap' ]
> >    google,needs-ghost-filter: [ 'linux,keymap' ]
> > @@ -132,6 +140,23 @@ examples:
> >              /* UP      LEFT    */
> >              0x070b0067 0x070c0069>;
> >      };
> > +  - |
> > +    /* With function keys */
> > +    #include <dt-bindings/input/input.h>
> > +    keyboard-controller {
> > +        compatible = "google,cros-ec-keyb";
> > +        keypad,num-rows = <8>;
> > +        keypad,num-columns = <18>;
> > +        google,use-fn-overlay;
> 
> Difference in one property does not justify new example.

Sure but when the property is set then one has to specify the extra
codes in the linux,keymap property and this examples shows how. I'll
drop it if you want me to but I think there's value in it.

> Please organize the patch documenting the compatible (DT bindings)
> before the patch using that compatible.
> See also: https://elixir.bootlin.com/linux/v6.14-rc6/source/Documentation/devicetree/bindings/submitting-patches.rst#L46

Ack, will do for v3.

Thanks for the review.
Fabio
Re: [PATCH v2 2/2] dt-bindings: google,cros-ec-keyb: add use-fn-overlay prop
Posted by Krzysztof Kozlowski 1 month, 1 week ago
On 27/12/2025 16:48, Fabio Baltieri wrote:
> On Sat, Dec 27, 2025 at 01:44:26PM +0100, Krzysztof Kozlowski wrote:
>>> diff --git a/Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml b/Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml
>>> index fefaaf46a240..437575cdf352 100644
>>> --- a/Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml
>>> +++ b/Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml
>>> @@ -44,6 +44,14 @@ properties:
>>>        where the lower 16 bits are reserved. This property is specified only
>>>        when the keyboard has a custom design for the top row keys.
>>>  
>>> +  google,use-fn-overlay:
>>> +    description: |
>>> +      Use a function key overlay. This allows defining an extra set of codes
>>
>> What is a function key overlay? Overlays are DT term and therefore are
>> not suitable for bindings.
> 
> Ok, guess I can rename it to `use-fn-key` or `use-fn-layer`, open to
> suggestions really.

Use as Linux should use? Then it's software, so not suitable for DT.

> 
>>> +      that are sent if a key is pressed while the KEY_FN is held pressed as
>>> +      well. The function codes have to be defined in the linux,keymap property
>>> +      with an offset of keypad,num-rows from the normal ones.
>>> +    type: boolean
>>> +
>>>  dependencies:
>>>    function-row-physmap: [ 'linux,keymap' ]
>>>    google,needs-ghost-filter: [ 'linux,keymap' ]
>>> @@ -132,6 +140,23 @@ examples:
>>>              /* UP      LEFT    */
>>>              0x070b0067 0x070c0069>;
>>>      };
>>> +  - |
>>> +    /* With function keys */
>>> +    #include <dt-bindings/input/input.h>
>>> +    keyboard-controller {
>>> +        compatible = "google,cros-ec-keyb";
>>> +        keypad,num-rows = <8>;
>>> +        keypad,num-columns = <18>;
>>> +        google,use-fn-overlay;
>>
>> Difference in one property does not justify new example.
> 
> Sure but when the property is set then one has to specify the extra
> codes in the linux,keymap property and this examples shows how. I'll
> drop it if you want me to but I think there's value in it.

Examples are for verifying schema and you do not have schema enforcing
this, thus still pointless. Add schema for that, assuming property will
stay.

Best regards,
Krzysztof
Re: [PATCH v2 2/2] dt-bindings: google,cros-ec-keyb: add use-fn-overlay prop
Posted by Fabio Baltieri 1 month, 1 week ago
On Mon, Dec 29, 2025 at 01:49:05PM +0100, Krzysztof Kozlowski wrote:
> On 27/12/2025 16:48, Fabio Baltieri wrote:
> > On Sat, Dec 27, 2025 at 01:44:26PM +0100, Krzysztof Kozlowski wrote:
> >>> diff --git a/Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml b/Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml
> >>> index fefaaf46a240..437575cdf352 100644
> >>> --- a/Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml
> >>> +++ b/Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml
> >>> @@ -44,6 +44,14 @@ properties:
> >>>        where the lower 16 bits are reserved. This property is specified only
> >>>        when the keyboard has a custom design for the top row keys.
> >>>  
> >>> +  google,use-fn-overlay:
> >>> +    description: |
> >>> +      Use a function key overlay. This allows defining an extra set of codes
> >>
> >> What is a function key overlay? Overlays are DT term and therefore are
> >> not suitable for bindings.
> > 
> > Ok, guess I can rename it to `use-fn-key` or `use-fn-layer`, open to
> > suggestions really.
> 
> Use as Linux should use? Then it's software, so not suitable for DT.

Sorry I'm not sure how I understand the comment, this describes how the
driver handles a keyboard with Fn keys, the codes are defined in the DT
linux,keymap property and the driver needs to know that there's an extra
layer to interpret the codes correctly.

> >>> +      that are sent if a key is pressed while the KEY_FN is held pressed as
> >>> +      well. The function codes have to be defined in the linux,keymap property
> >>> +      with an offset of keypad,num-rows from the normal ones.
> >>> +    type: boolean
> >>> +
> >>>  dependencies:
> >>>    function-row-physmap: [ 'linux,keymap' ]
> >>>    google,needs-ghost-filter: [ 'linux,keymap' ]
> >>> @@ -132,6 +140,23 @@ examples:
> >>>              /* UP      LEFT    */
> >>>              0x070b0067 0x070c0069>;
> >>>      };
> >>> +  - |
> >>> +    /* With function keys */
> >>> +    #include <dt-bindings/input/input.h>
> >>> +    keyboard-controller {
> >>> +        compatible = "google,cros-ec-keyb";
> >>> +        keypad,num-rows = <8>;
> >>> +        keypad,num-columns = <18>;
> >>> +        google,use-fn-overlay;
> >>
> >> Difference in one property does not justify new example.
> > 
> > Sure but when the property is set then one has to specify the extra
> > codes in the linux,keymap property and this examples shows how. I'll
> > drop it if you want me to but I think there's value in it.
> 
> Examples are for verifying schema and you do not have schema enforcing
> this, thus still pointless. Add schema for that, assuming property will
> stay.

Ok got it, I'll just drop it in v3.
Re: [PATCH v2 2/2] dt-bindings: google,cros-ec-keyb: add use-fn-overlay prop
Posted by Krzysztof Kozlowski 1 month, 1 week ago
On 29/12/2025 14:33, Fabio Baltieri wrote:
> On Mon, Dec 29, 2025 at 01:49:05PM +0100, Krzysztof Kozlowski wrote:
>> On 27/12/2025 16:48, Fabio Baltieri wrote:
>>> On Sat, Dec 27, 2025 at 01:44:26PM +0100, Krzysztof Kozlowski wrote:
>>>>> diff --git a/Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml b/Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml
>>>>> index fefaaf46a240..437575cdf352 100644
>>>>> --- a/Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml
>>>>> +++ b/Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml
>>>>> @@ -44,6 +44,14 @@ properties:
>>>>>        where the lower 16 bits are reserved. This property is specified only
>>>>>        when the keyboard has a custom design for the top row keys.
>>>>>  
>>>>> +  google,use-fn-overlay:
>>>>> +    description: |
>>>>> +      Use a function key overlay. This allows defining an extra set of codes
>>>>
>>>> What is a function key overlay? Overlays are DT term and therefore are
>>>> not suitable for bindings.
>>>
>>> Ok, guess I can rename it to `use-fn-key` or `use-fn-layer`, open to
>>> suggestions really.
>>
>> Use as Linux should use? Then it's software, so not suitable for DT.
> 
> Sorry I'm not sure how I understand the comment, this describes how the
> driver handles a keyboard with Fn keys, the codes are defined in the DT

Exactly. The purpose of DT is not to describe how driver should handle
anything.

See also DTS101 from this year's ELCE.

Best regards,
Krzysztof
Re: [PATCH v2 2/2] dt-bindings: google,cros-ec-keyb: add use-fn-overlay prop
Posted by Fabio Baltieri 1 month, 1 week ago
On Mon, Dec 29, 2025 at 03:59:44PM +0100, Krzysztof Kozlowski wrote:
> On 29/12/2025 14:33, Fabio Baltieri wrote:
> > On Mon, Dec 29, 2025 at 01:49:05PM +0100, Krzysztof Kozlowski wrote:
> >> On 27/12/2025 16:48, Fabio Baltieri wrote:
> >>> On Sat, Dec 27, 2025 at 01:44:26PM +0100, Krzysztof Kozlowski wrote:
> >>>>> diff --git a/Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml b/Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml
> >>>>> index fefaaf46a240..437575cdf352 100644
> >>>>> --- a/Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml
> >>>>> +++ b/Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml
> >>>>> @@ -44,6 +44,14 @@ properties:
> >>>>>        where the lower 16 bits are reserved. This property is specified only
> >>>>>        when the keyboard has a custom design for the top row keys.
> >>>>>  
> >>>>> +  google,use-fn-overlay:
> >>>>> +    description: |
> >>>>> +      Use a function key overlay. This allows defining an extra set of codes
> >>>>
> >>>> What is a function key overlay? Overlays are DT term and therefore are
> >>>> not suitable for bindings.
> >>>
> >>> Ok, guess I can rename it to `use-fn-key` or `use-fn-layer`, open to
> >>> suggestions really.
> >>
> >> Use as Linux should use? Then it's software, so not suitable for DT.
> > 
> > Sorry I'm not sure how I understand the comment, this describes how the
> > driver handles a keyboard with Fn keys, the codes are defined in the DT
> 
> Exactly. The purpose of DT is not to describe how driver should handle
> anything.
> 
> See also DTS101 from this year's ELCE.

Sure so I guess this falls into the "describe the hardware feature"
category, so is the suggestion to rename it to something like
"has-fn-key"? That would be the hardware feature.
Re: [PATCH v2 2/2] dt-bindings: google,cros-ec-keyb: add use-fn-overlay prop
Posted by Krzysztof Kozlowski 1 month, 1 week ago
On 29/12/2025 16:39, Fabio Baltieri wrote:
> On Mon, Dec 29, 2025 at 03:59:44PM +0100, Krzysztof Kozlowski wrote:
>> On 29/12/2025 14:33, Fabio Baltieri wrote:
>>> On Mon, Dec 29, 2025 at 01:49:05PM +0100, Krzysztof Kozlowski wrote:
>>>> On 27/12/2025 16:48, Fabio Baltieri wrote:
>>>>> On Sat, Dec 27, 2025 at 01:44:26PM +0100, Krzysztof Kozlowski wrote:
>>>>>>> diff --git a/Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml b/Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml
>>>>>>> index fefaaf46a240..437575cdf352 100644
>>>>>>> --- a/Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml
>>>>>>> +++ b/Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml
>>>>>>> @@ -44,6 +44,14 @@ properties:
>>>>>>>        where the lower 16 bits are reserved. This property is specified only
>>>>>>>        when the keyboard has a custom design for the top row keys.
>>>>>>>  
>>>>>>> +  google,use-fn-overlay:
>>>>>>> +    description: |
>>>>>>> +      Use a function key overlay. This allows defining an extra set of codes
>>>>>>
>>>>>> What is a function key overlay? Overlays are DT term and therefore are
>>>>>> not suitable for bindings.
>>>>>
>>>>> Ok, guess I can rename it to `use-fn-key` or `use-fn-layer`, open to
>>>>> suggestions really.
>>>>
>>>> Use as Linux should use? Then it's software, so not suitable for DT.
>>>
>>> Sorry I'm not sure how I understand the comment, this describes how the
>>> driver handles a keyboard with Fn keys, the codes are defined in the DT
>>
>> Exactly. The purpose of DT is not to describe how driver should handle
>> anything.
>>
>> See also DTS101 from this year's ELCE.
> 
> Sure so I guess this falls into the "describe the hardware feature"
> category, so is the suggestion to rename it to something like
> "has-fn-key"? That would be the hardware feature.


Maybe, but then I would follow up with - what about "alt", "ctrl",
"shift" and "fn" keys? And what about combinations alt+ctrl, alt+shift?
And also caps-lock? And why exactly this has to be even specified if
matrix map already has the FN key?

Best regards,
Krzysztof
Re: [PATCH v2 2/2] dt-bindings: google,cros-ec-keyb: add use-fn-overlay prop
Posted by Fabio Baltieri 1 month, 1 week ago
On Tue, Dec 30, 2025 at 08:26:56AM +0100, Krzysztof Kozlowski wrote:
> On 29/12/2025 16:39, Fabio Baltieri wrote:
> > Sure so I guess this falls into the "describe the hardware feature"
> > category, so is the suggestion to rename it to something like
> > "has-fn-key"? That would be the hardware feature.
> 
> 
> Maybe, but then I would follow up with - what about "alt", "ctrl",
> "shift" and "fn" keys? And what about combinations alt+ctrl, alt+shift?
> And also caps-lock? And why exactly this has to be even specified if
> matrix map already has the FN key?

Fn works as a key layer, that is when the key is pressed the rest of the
matrix uses a different keymap, different codes. The driver has to make
extra space in the internal data structures for reading the new codes
from the keymap property and use them when they are specified. The other
combinations you mentioned behave normally, nothing special about them.

Looking at the input driver history the other driver that [used to] have
this was using a platform data field called use_fn_map, guess I'll go
with use-fn-map then (that one has never been ported over to dt).
Re: [PATCH v2 2/2] dt-bindings: google,cros-ec-keyb: add use-fn-overlay prop
Posted by Krzysztof Kozlowski 1 month, 2 weeks ago
On Wed, Dec 24, 2025 at 03:22:38PM +0000, Fabio Baltieri wrote:
> Add binding documentation for the use-fn-overlay property.
> 
> Signed-off-by: Fabio Baltieri <fabiobaltieri@chromium.org>
> ---

Please organize the patch documenting the compatible (DT bindings)
before the patch using that compatible.
See also: https://elixir.bootlin.com/linux/v6.14-rc6/source/Documentation/devicetree/bindings/submitting-patches.rst#L46

Best regards,
Krzysztof