* [RFC] dt-bindings: input: Clarify that abs_min must be less than abs_max
@ 2023-12-15 2:40 Chris Morgan
2023-12-15 11:19 ` Artur Rojek
0 siblings, 1 reply; 8+ messages in thread
From: Chris Morgan @ 2023-12-15 2:40 UTC (permalink / raw)
To: linux-input
Cc: devicetree, contact, conor+dt, krzysztof.kozlowski+dt, robh+dt,
dmitry.torokhov, Chris Morgan
From: Chris Morgan <macromorgan@hotmail.com>
uinput refuses to work with abs devices where the min value is greater
than the max value. uinput_validate_absinfo() returns -EINVAL if this
is the case and prevents using uinput on such a device. Since uinput
has worked this way since at least kernel 2.6 (or prior) I presume that
this is the correct way of doing things, and that this documentation
needs to be clarified that min must always be less than max.
uinput is used in my use case to bind together adc-joystick devices
with gpio-keys devices to create a single unified gamepad for
userspace.
Note that there are several boards that will need to be corrected,
all but a few of them I maintain. Submitting as an RFC for now to get
comments from the input team and the original author in case there is
something I am missing.
Fixes: 7956b0d4694f ("dt-bindings: input: Add docs for ADC driven joystick")
Signed-off-by: Chris Morgan <macromorgan@hotmail.com>
---
Documentation/devicetree/bindings/input/adc-joystick.yaml | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/Documentation/devicetree/bindings/input/adc-joystick.yaml b/Documentation/devicetree/bindings/input/adc-joystick.yaml
index 6c244d66f8ce..8f5cdd5ef190 100644
--- a/Documentation/devicetree/bindings/input/adc-joystick.yaml
+++ b/Documentation/devicetree/bindings/input/adc-joystick.yaml
@@ -73,8 +73,9 @@ patternProperties:
description: >
Minimum and maximum values produced by the axis.
For an ABS_X axis this will be the left-most and right-most
- inclination of the joystick. If min > max, it is left to userspace to
- treat the axis as inverted.
+ inclination of the joystick. The axis must always be expressed as
+ min < max, if the axis is inverted it is left to userspace to handle
+ the inversion.
This property is interpreted as two signed 32 bit values.
abs-fuzz:
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [RFC] dt-bindings: input: Clarify that abs_min must be less than abs_max 2023-12-15 2:40 [RFC] dt-bindings: input: Clarify that abs_min must be less than abs_max Chris Morgan @ 2023-12-15 11:19 ` Artur Rojek 2023-12-18 17:11 ` Chris Morgan 2023-12-19 20:32 ` Dmitry Torokhov 0 siblings, 2 replies; 8+ messages in thread From: Artur Rojek @ 2023-12-15 11:19 UTC (permalink / raw) To: Chris Morgan Cc: linux-input, devicetree, conor+dt, krzysztof.kozlowski+dt, robh+dt, dmitry.torokhov, Chris Morgan, Paul Cercueil On 2023-12-15 03:40, Chris Morgan wrote: > From: Chris Morgan <macromorgan@hotmail.com> > > uinput refuses to work with abs devices where the min value is greater > than the max value. uinput_validate_absinfo() returns -EINVAL if this > is the case and prevents using uinput on such a device. Since uinput > has worked this way since at least kernel 2.6 (or prior) I presume that > this is the correct way of doing things, and that this documentation > needs to be clarified that min must always be less than max. > > uinput is used in my use case to bind together adc-joystick devices > with gpio-keys devices to create a single unified gamepad for > userspace. > > Note that there are several boards that will need to be corrected, > all but a few of them I maintain. Submitting as an RFC for now to get > comments from the input team and the original author in case there is > something I am missing. > > Fixes: 7956b0d4694f ("dt-bindings: input: Add docs for ADC driven > joystick") > > Signed-off-by: Chris Morgan <macromorgan@hotmail.com> > --- > Documentation/devicetree/bindings/input/adc-joystick.yaml | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/Documentation/devicetree/bindings/input/adc-joystick.yaml > b/Documentation/devicetree/bindings/input/adc-joystick.yaml > index 6c244d66f8ce..8f5cdd5ef190 100644 > --- a/Documentation/devicetree/bindings/input/adc-joystick.yaml > +++ b/Documentation/devicetree/bindings/input/adc-joystick.yaml > @@ -73,8 +73,9 @@ patternProperties: > description: > > Minimum and maximum values produced by the axis. > For an ABS_X axis this will be the left-most and right-most > - inclination of the joystick. If min > max, it is left to > userspace to > - treat the axis as inverted. > + inclination of the joystick. The axis must always be > expressed as > + min < max, if the axis is inverted it is left to userspace > to handle > + the inversion. Hi Chris, Device Tree is supposed to depict the actual state of the hardware. I worded the adc-joytick's adc-range property specifically, so that it covers a case of GCW Zero hardware [1], which has a joystick, where the ABS_X axis reports increasing values for the left-wards inclination of the joystick, and decreasing values for the right-wards inclination. You are saying that there are even more boards that need to be corrected - those are all situations, where DT depicts the actual behavior of the hardware. What you are trying to do is change hardware description, because of how a driver in an OS works. You should instead fix behavior of said driver, even if nobody stumbled upon that issue since 2.6 :) We fixed libSDL [2] for the same reason. Cheers, Artur PS. cc'd Paul to the conversation. [1] https://github.com/OpenDingux/linux/blob/jz-6.1/arch/mips/boot/dts/ingenic/gcw0.dts#L273C12-L273C12 [2] https://github.com/libsdl-org/SDL-1.2/commit/46806790ad043 > This property is interpreted as two signed 32 bit values. > > abs-fuzz: ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC] dt-bindings: input: Clarify that abs_min must be less than abs_max 2023-12-15 11:19 ` Artur Rojek @ 2023-12-18 17:11 ` Chris Morgan 2023-12-19 20:32 ` Dmitry Torokhov 1 sibling, 0 replies; 8+ messages in thread From: Chris Morgan @ 2023-12-18 17:11 UTC (permalink / raw) To: Artur Rojek Cc: Chris Morgan, linux-input, devicetree, conor+dt, krzysztof.kozlowski+dt, robh+dt, dmitry.torokhov, Paul Cercueil On Fri, Dec 15, 2023 at 12:19:51PM +0100, Artur Rojek wrote: > On 2023-12-15 03:40, Chris Morgan wrote: > > From: Chris Morgan <macromorgan@hotmail.com> > > > > uinput refuses to work with abs devices where the min value is greater > > than the max value. uinput_validate_absinfo() returns -EINVAL if this > > is the case and prevents using uinput on such a device. Since uinput > > has worked this way since at least kernel 2.6 (or prior) I presume that > > this is the correct way of doing things, and that this documentation > > needs to be clarified that min must always be less than max. > > > > uinput is used in my use case to bind together adc-joystick devices > > with gpio-keys devices to create a single unified gamepad for > > userspace. > > > > Note that there are several boards that will need to be corrected, > > all but a few of them I maintain. Submitting as an RFC for now to get > > comments from the input team and the original author in case there is > > something I am missing. > > > > Fixes: 7956b0d4694f ("dt-bindings: input: Add docs for ADC driven > > joystick") > > > > Signed-off-by: Chris Morgan <macromorgan@hotmail.com> > > --- > > Documentation/devicetree/bindings/input/adc-joystick.yaml | 5 +++-- > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > diff --git a/Documentation/devicetree/bindings/input/adc-joystick.yaml > > b/Documentation/devicetree/bindings/input/adc-joystick.yaml > > index 6c244d66f8ce..8f5cdd5ef190 100644 > > --- a/Documentation/devicetree/bindings/input/adc-joystick.yaml > > +++ b/Documentation/devicetree/bindings/input/adc-joystick.yaml > > @@ -73,8 +73,9 @@ patternProperties: > > description: > > > Minimum and maximum values produced by the axis. > > For an ABS_X axis this will be the left-most and right-most > > - inclination of the joystick. If min > max, it is left to > > userspace to > > - treat the axis as inverted. > > + inclination of the joystick. The axis must always be > > expressed as > > + min < max, if the axis is inverted it is left to userspace to > > handle > > + the inversion. > > Hi Chris, > > Device Tree is supposed to depict the actual state of the hardware. > I worded the adc-joytick's adc-range property specifically, so that it > covers a case of GCW Zero hardware [1], which has a joystick, where the > ABS_X axis reports increasing values for the left-wards inclination of > the joystick, and decreasing values for the right-wards inclination. You > are saying that there are even more boards that need to be corrected - > those are all situations, where DT depicts the actual behavior of the > hardware. > What you are trying to do is change hardware description, because of how > a driver in an OS works. You should instead fix behavior of said driver, > even if nobody stumbled upon that issue since 2.6 :) We fixed libSDL [2] > for the same reason. > > Cheers, > Artur > > PS. cc'd Paul to the conversation. > > [1] https://github.com/OpenDingux/linux/blob/jz-6.1/arch/mips/boot/dts/ingenic/gcw0.dts#L273C12-L273C12 > [2] https://github.com/libsdl-org/SDL-1.2/commit/46806790ad043 Thank you. Okay, I'll update uinput instead to drop checks for min > max, since that's valid/allowed. Chris > > > This property is interpreted as two signed 32 bit values. > > > > abs-fuzz: > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC] dt-bindings: input: Clarify that abs_min must be less than abs_max 2023-12-15 11:19 ` Artur Rojek 2023-12-18 17:11 ` Chris Morgan @ 2023-12-19 20:32 ` Dmitry Torokhov 2023-12-19 20:34 ` Dmitry Torokhov 2023-12-20 0:23 ` Paul Cercueil 1 sibling, 2 replies; 8+ messages in thread From: Dmitry Torokhov @ 2023-12-19 20:32 UTC (permalink / raw) To: Artur Rojek Cc: Chris Morgan, linux-input, devicetree, conor+dt, krzysztof.kozlowski+dt, robh+dt, Chris Morgan, Paul Cercueil On Fri, Dec 15, 2023 at 12:19:51PM +0100, Artur Rojek wrote: > On 2023-12-15 03:40, Chris Morgan wrote: > > From: Chris Morgan <macromorgan@hotmail.com> > > > > uinput refuses to work with abs devices where the min value is greater > > than the max value. uinput_validate_absinfo() returns -EINVAL if this > > is the case and prevents using uinput on such a device. Since uinput > > has worked this way since at least kernel 2.6 (or prior) I presume that > > this is the correct way of doing things, and that this documentation > > needs to be clarified that min must always be less than max. > > > > uinput is used in my use case to bind together adc-joystick devices > > with gpio-keys devices to create a single unified gamepad for > > userspace. > > > > Note that there are several boards that will need to be corrected, > > all but a few of them I maintain. Submitting as an RFC for now to get > > comments from the input team and the original author in case there is > > something I am missing. > > > > Fixes: 7956b0d4694f ("dt-bindings: input: Add docs for ADC driven > > joystick") > > > > Signed-off-by: Chris Morgan <macromorgan@hotmail.com> > > --- > > Documentation/devicetree/bindings/input/adc-joystick.yaml | 5 +++-- > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > diff --git a/Documentation/devicetree/bindings/input/adc-joystick.yaml > > b/Documentation/devicetree/bindings/input/adc-joystick.yaml > > index 6c244d66f8ce..8f5cdd5ef190 100644 > > --- a/Documentation/devicetree/bindings/input/adc-joystick.yaml > > +++ b/Documentation/devicetree/bindings/input/adc-joystick.yaml > > @@ -73,8 +73,9 @@ patternProperties: > > description: > > > Minimum and maximum values produced by the axis. > > For an ABS_X axis this will be the left-most and right-most > > - inclination of the joystick. If min > max, it is left to > > userspace to > > - treat the axis as inverted. > > + inclination of the joystick. The axis must always be > > expressed as > > + min < max, if the axis is inverted it is left to userspace to > > handle > > + the inversion. > > Hi Chris, > > Device Tree is supposed to depict the actual state of the hardware. > I worded the adc-joytick's adc-range property specifically, so that it > covers a case of GCW Zero hardware [1], which has a joystick, where the > ABS_X axis reports increasing values for the left-wards inclination of > the joystick, and decreasing values for the right-wards inclination. You > are saying that there are even more boards that need to be corrected - > those are all situations, where DT depicts the actual behavior of the > hardware. > What you are trying to do is change hardware description, because of how > a driver in an OS works. You should instead fix behavior of said driver, > even if nobody stumbled upon that issue since 2.6 :) We fixed libSDL [2] > for the same reason. We have several places in the kernel (such as mousedev and joydev) where we expect that max is greater or equal to min if they are specified. I am sure that at least some userspace components also have this assumption. In general, we expect min to be a minimum value reported and max being maximum value reported, and orientation expressed via different properties (see [1]). Since we codified min > max as inversion for adc-joystick devices in the bindings, I think we need to handle this *in that driver* and leave the rest alone. [1] Documentation/devicetree/bindings/input/touchscreen/touchscreen.yaml Thanks. -- Dmitry ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC] dt-bindings: input: Clarify that abs_min must be less than abs_max 2023-12-19 20:32 ` Dmitry Torokhov @ 2023-12-19 20:34 ` Dmitry Torokhov 2023-12-19 23:48 ` Peter Hutterer 2023-12-20 0:23 ` Paul Cercueil 1 sibling, 1 reply; 8+ messages in thread From: Dmitry Torokhov @ 2023-12-19 20:34 UTC (permalink / raw) To: Artur Rojek Cc: Chris Morgan, linux-input, devicetree, conor+dt, krzysztof.kozlowski+dt, robh+dt, Chris Morgan, Paul Cercueil, Peter Hutterer Sorry, meant to add Peter Hutterer to the conversation, but forgot before hitting send... On Tue, Dec 19, 2023 at 12:32:44PM -0800, Dmitry Torokhov wrote: > On Fri, Dec 15, 2023 at 12:19:51PM +0100, Artur Rojek wrote: > > On 2023-12-15 03:40, Chris Morgan wrote: > > > From: Chris Morgan <macromorgan@hotmail.com> > > > > > > uinput refuses to work with abs devices where the min value is greater > > > than the max value. uinput_validate_absinfo() returns -EINVAL if this > > > is the case and prevents using uinput on such a device. Since uinput > > > has worked this way since at least kernel 2.6 (or prior) I presume that > > > this is the correct way of doing things, and that this documentation > > > needs to be clarified that min must always be less than max. > > > > > > uinput is used in my use case to bind together adc-joystick devices > > > with gpio-keys devices to create a single unified gamepad for > > > userspace. > > > > > > Note that there are several boards that will need to be corrected, > > > all but a few of them I maintain. Submitting as an RFC for now to get > > > comments from the input team and the original author in case there is > > > something I am missing. > > > > > > Fixes: 7956b0d4694f ("dt-bindings: input: Add docs for ADC driven > > > joystick") > > > > > > Signed-off-by: Chris Morgan <macromorgan@hotmail.com> > > > --- > > > Documentation/devicetree/bindings/input/adc-joystick.yaml | 5 +++-- > > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > > > diff --git a/Documentation/devicetree/bindings/input/adc-joystick.yaml > > > b/Documentation/devicetree/bindings/input/adc-joystick.yaml > > > index 6c244d66f8ce..8f5cdd5ef190 100644 > > > --- a/Documentation/devicetree/bindings/input/adc-joystick.yaml > > > +++ b/Documentation/devicetree/bindings/input/adc-joystick.yaml > > > @@ -73,8 +73,9 @@ patternProperties: > > > description: > > > > Minimum and maximum values produced by the axis. > > > For an ABS_X axis this will be the left-most and right-most > > > - inclination of the joystick. If min > max, it is left to > > > userspace to > > > - treat the axis as inverted. > > > + inclination of the joystick. The axis must always be > > > expressed as > > > + min < max, if the axis is inverted it is left to userspace to > > > handle > > > + the inversion. > > > > Hi Chris, > > > > Device Tree is supposed to depict the actual state of the hardware. > > I worded the adc-joytick's adc-range property specifically, so that it > > covers a case of GCW Zero hardware [1], which has a joystick, where the > > ABS_X axis reports increasing values for the left-wards inclination of > > the joystick, and decreasing values for the right-wards inclination. You > > are saying that there are even more boards that need to be corrected - > > those are all situations, where DT depicts the actual behavior of the > > hardware. > > What you are trying to do is change hardware description, because of how > > a driver in an OS works. You should instead fix behavior of said driver, > > even if nobody stumbled upon that issue since 2.6 :) We fixed libSDL [2] > > for the same reason. > > We have several places in the kernel (such as mousedev and joydev) where > we expect that max is greater or equal to min if they are specified. I > am sure that at least some userspace components also have this > assumption. In general, we expect min to be a minimum value reported and > max being maximum value reported, and orientation expressed via > different properties (see [1]). > > Since we codified min > max as inversion for adc-joystick devices in the > bindings, I think we need to handle this *in that driver* and leave the > rest alone. > > [1] Documentation/devicetree/bindings/input/touchscreen/touchscreen.yaml > -- Dmitry ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC] dt-bindings: input: Clarify that abs_min must be less than abs_max 2023-12-19 20:34 ` Dmitry Torokhov @ 2023-12-19 23:48 ` Peter Hutterer 0 siblings, 0 replies; 8+ messages in thread From: Peter Hutterer @ 2023-12-19 23:48 UTC (permalink / raw) To: Dmitry Torokhov Cc: Artur Rojek, Chris Morgan, linux-input, devicetree, conor+dt, krzysztof.kozlowski+dt, robh+dt, Chris Morgan, Paul Cercueil On Tue, Dec 19, 2023 at 12:34:51PM -0800, Dmitry Torokhov wrote: > Sorry, meant to add Peter Hutterer to the conversation, but forgot > before hitting send... Thx for the CC, I only saw the other patch and had missed this one. > On Tue, Dec 19, 2023 at 12:32:44PM -0800, Dmitry Torokhov wrote: > > On Fri, Dec 15, 2023 at 12:19:51PM +0100, Artur Rojek wrote: > > > On 2023-12-15 03:40, Chris Morgan wrote: > > > > From: Chris Morgan <macromorgan@hotmail.com> > > > > > > > > uinput refuses to work with abs devices where the min value is greater > > > > than the max value. uinput_validate_absinfo() returns -EINVAL if this > > > > is the case and prevents using uinput on such a device. Since uinput > > > > has worked this way since at least kernel 2.6 (or prior) I presume that > > > > this is the correct way of doing things, and that this documentation > > > > needs to be clarified that min must always be less than max. > > > > > > > > uinput is used in my use case to bind together adc-joystick devices > > > > with gpio-keys devices to create a single unified gamepad for > > > > userspace. > > > > > > > > Note that there are several boards that will need to be corrected, > > > > all but a few of them I maintain. Submitting as an RFC for now to get > > > > comments from the input team and the original author in case there is > > > > something I am missing. > > > > > > > > Fixes: 7956b0d4694f ("dt-bindings: input: Add docs for ADC driven > > > > joystick") > > > > > > > > Signed-off-by: Chris Morgan <macromorgan@hotmail.com> > > > > --- > > > > Documentation/devicetree/bindings/input/adc-joystick.yaml | 5 +++-- > > > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > > > > > diff --git a/Documentation/devicetree/bindings/input/adc-joystick.yaml > > > > b/Documentation/devicetree/bindings/input/adc-joystick.yaml > > > > index 6c244d66f8ce..8f5cdd5ef190 100644 > > > > --- a/Documentation/devicetree/bindings/input/adc-joystick.yaml > > > > +++ b/Documentation/devicetree/bindings/input/adc-joystick.yaml > > > > @@ -73,8 +73,9 @@ patternProperties: > > > > description: > > > > > Minimum and maximum values produced by the axis. > > > > For an ABS_X axis this will be the left-most and right-most > > > > - inclination of the joystick. If min > max, it is left to > > > > userspace to > > > > - treat the axis as inverted. > > > > + inclination of the joystick. The axis must always be > > > > expressed as > > > > + min < max, if the axis is inverted it is left to userspace to > > > > handle > > > > + the inversion. > > > > > > Hi Chris, > > > > > > Device Tree is supposed to depict the actual state of the hardware. > > > I worded the adc-joytick's adc-range property specifically, so that it > > > covers a case of GCW Zero hardware [1], which has a joystick, where the > > > ABS_X axis reports increasing values for the left-wards inclination of > > > the joystick, and decreasing values for the right-wards inclination. You > > > are saying that there are even more boards that need to be corrected - > > > those are all situations, where DT depicts the actual behavior of the > > > hardware. > > > What you are trying to do is change hardware description, because of how > > > a driver in an OS works. You should instead fix behavior of said driver, > > > even if nobody stumbled upon that issue since 2.6 :) We fixed libSDL [2] > > > for the same reason. > > > > We have several places in the kernel (such as mousedev and joydev) where > > we expect that max is greater or equal to min if they are specified. I > > am sure that at least some userspace components also have this > > assumption. In general, we expect min to be a minimum value reported and > > max being maximum value reported, and orientation expressed via > > different properties (see [1]). > > > > Since we codified min > max as inversion for adc-joystick devices in the > > bindings, I think we need to handle this *in that driver* and leave the > > rest alone. > > > > [1] Documentation/devicetree/bindings/input/touchscreen/touchscreen.yaml I quickly checked libevdev and libinput and neither of them have checks for min < max but the base assumption is there. So we'll get entertaining results if that stops being the case. Cheers, Peter ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC] dt-bindings: input: Clarify that abs_min must be less than abs_max 2023-12-19 20:32 ` Dmitry Torokhov 2023-12-19 20:34 ` Dmitry Torokhov @ 2023-12-20 0:23 ` Paul Cercueil 2023-12-20 1:22 ` Dmitry Torokhov 1 sibling, 1 reply; 8+ messages in thread From: Paul Cercueil @ 2023-12-20 0:23 UTC (permalink / raw) To: Dmitry Torokhov, Artur Rojek Cc: Chris Morgan, linux-input, devicetree, conor+dt, krzysztof.kozlowski+dt, robh+dt, Chris Morgan Hi Dmitry, Le mardi 19 décembre 2023 à 12:32 -0800, Dmitry Torokhov a écrit : > On Fri, Dec 15, 2023 at 12:19:51PM +0100, Artur Rojek wrote: > > On 2023-12-15 03:40, Chris Morgan wrote: > > > From: Chris Morgan <macromorgan@hotmail.com> > > > > > > uinput refuses to work with abs devices where the min value is > > > greater > > > than the max value. uinput_validate_absinfo() returns -EINVAL if > > > this > > > is the case and prevents using uinput on such a device. Since > > > uinput > > > has worked this way since at least kernel 2.6 (or prior) I > > > presume that > > > this is the correct way of doing things, and that this > > > documentation > > > needs to be clarified that min must always be less than max. > > > > > > uinput is used in my use case to bind together adc-joystick > > > devices > > > with gpio-keys devices to create a single unified gamepad for > > > userspace. > > > > > > Note that there are several boards that will need to be > > > corrected, > > > all but a few of them I maintain. Submitting as an RFC for now to > > > get > > > comments from the input team and the original author in case > > > there is > > > something I am missing. > > > > > > Fixes: 7956b0d4694f ("dt-bindings: input: Add docs for ADC driven > > > joystick") > > > > > > Signed-off-by: Chris Morgan <macromorgan@hotmail.com> > > > --- > > > Documentation/devicetree/bindings/input/adc-joystick.yaml | 5 > > > +++-- > > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > > > diff --git a/Documentation/devicetree/bindings/input/adc- > > > joystick.yaml > > > b/Documentation/devicetree/bindings/input/adc-joystick.yaml > > > index 6c244d66f8ce..8f5cdd5ef190 100644 > > > --- a/Documentation/devicetree/bindings/input/adc-joystick.yaml > > > +++ b/Documentation/devicetree/bindings/input/adc-joystick.yaml > > > @@ -73,8 +73,9 @@ patternProperties: > > > description: > > > > Minimum and maximum values produced by the axis. > > > For an ABS_X axis this will be the left-most and > > > right-most > > > - inclination of the joystick. If min > max, it is left > > > to > > > userspace to > > > - treat the axis as inverted. > > > + inclination of the joystick. The axis must always be > > > expressed as > > > + min < max, if the axis is inverted it is left to > > > userspace to > > > handle > > > + the inversion. > > > > Hi Chris, > > > > Device Tree is supposed to depict the actual state of the hardware. > > I worded the adc-joytick's adc-range property specifically, so that > > it > > covers a case of GCW Zero hardware [1], which has a joystick, > > where the > > ABS_X axis reports increasing values for the left-wards inclination > > of > > the joystick, and decreasing values for the right-wards > > inclination. You > > are saying that there are even more boards that need to be > > corrected - > > those are all situations, where DT depicts the actual behavior of > > the > > hardware. > > What you are trying to do is change hardware description, because > > of how > > a driver in an OS works. You should instead fix behavior of said > > driver, > > even if nobody stumbled upon that issue since 2.6 :) We fixed > > libSDL [2] > > for the same reason. > > We have several places in the kernel (such as mousedev and joydev) > where > we expect that max is greater or equal to min if they are specified. > I > am sure that at least some userspace components also have this > assumption. In general, we expect min to be a minimum value reported > and > max being maximum value reported, and orientation expressed via > different properties (see [1]). You can express all you want in DT properties the orientation of the axis, it does not carry to userspace. As far as I can see there is absolutely no way to tell userspace that an axis is inverted. Cheers, -Paul > > Since we codified min > max as inversion for adc-joystick devices in > the > bindings, I think we need to handle this *in that driver* and leave > the > rest alone. > > [1] > Documentation/devicetree/bindings/input/touchscreen/touchscreen.yaml > > Thanks. > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC] dt-bindings: input: Clarify that abs_min must be less than abs_max 2023-12-20 0:23 ` Paul Cercueil @ 2023-12-20 1:22 ` Dmitry Torokhov 0 siblings, 0 replies; 8+ messages in thread From: Dmitry Torokhov @ 2023-12-20 1:22 UTC (permalink / raw) To: Paul Cercueil Cc: Artur Rojek, Chris Morgan, linux-input, devicetree, conor+dt, krzysztof.kozlowski+dt, robh+dt, Chris Morgan On Wed, Dec 20, 2023 at 01:23:31AM +0100, Paul Cercueil wrote: > Hi Dmitry, > > Le mardi 19 décembre 2023 à 12:32 -0800, Dmitry Torokhov a écrit : > > On Fri, Dec 15, 2023 at 12:19:51PM +0100, Artur Rojek wrote: > > > On 2023-12-15 03:40, Chris Morgan wrote: > > > > From: Chris Morgan <macromorgan@hotmail.com> > > > > > > > > uinput refuses to work with abs devices where the min value is > > > > greater > > > > than the max value. uinput_validate_absinfo() returns -EINVAL if > > > > this > > > > is the case and prevents using uinput on such a device. Since > > > > uinput > > > > has worked this way since at least kernel 2.6 (or prior) I > > > > presume that > > > > this is the correct way of doing things, and that this > > > > documentation > > > > needs to be clarified that min must always be less than max. > > > > > > > > uinput is used in my use case to bind together adc-joystick > > > > devices > > > > with gpio-keys devices to create a single unified gamepad for > > > > userspace. > > > > > > > > Note that there are several boards that will need to be > > > > corrected, > > > > all but a few of them I maintain. Submitting as an RFC for now to > > > > get > > > > comments from the input team and the original author in case > > > > there is > > > > something I am missing. > > > > > > > > Fixes: 7956b0d4694f ("dt-bindings: input: Add docs for ADC driven > > > > joystick") > > > > > > > > Signed-off-by: Chris Morgan <macromorgan@hotmail.com> > > > > --- > > > > Documentation/devicetree/bindings/input/adc-joystick.yaml | 5 > > > > +++-- > > > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > > > > > diff --git a/Documentation/devicetree/bindings/input/adc- > > > > joystick.yaml > > > > b/Documentation/devicetree/bindings/input/adc-joystick.yaml > > > > index 6c244d66f8ce..8f5cdd5ef190 100644 > > > > --- a/Documentation/devicetree/bindings/input/adc-joystick.yaml > > > > +++ b/Documentation/devicetree/bindings/input/adc-joystick.yaml > > > > @@ -73,8 +73,9 @@ patternProperties: > > > > description: > > > > > Minimum and maximum values produced by the axis. > > > > For an ABS_X axis this will be the left-most and > > > > right-most > > > > - inclination of the joystick. If min > max, it is left > > > > to > > > > userspace to > > > > - treat the axis as inverted. > > > > + inclination of the joystick. The axis must always be > > > > expressed as > > > > + min < max, if the axis is inverted it is left to > > > > userspace to > > > > handle > > > > + the inversion. > > > > > > Hi Chris, > > > > > > Device Tree is supposed to depict the actual state of the hardware. > > > I worded the adc-joytick's adc-range property specifically, so that > > > it > > > covers a case of GCW Zero hardware [1], which has a joystick, > > > where the > > > ABS_X axis reports increasing values for the left-wards inclination > > > of > > > the joystick, and decreasing values for the right-wards > > > inclination. You > > > are saying that there are even more boards that need to be > > > corrected - > > > those are all situations, where DT depicts the actual behavior of > > > the > > > hardware. > > > What you are trying to do is change hardware description, because > > > of how > > > a driver in an OS works. You should instead fix behavior of said > > > driver, > > > even if nobody stumbled upon that issue since 2.6 :) We fixed > > > libSDL [2] > > > for the same reason. > > > > We have several places in the kernel (such as mousedev and joydev) > > where > > we expect that max is greater or equal to min if they are specified. > > I > > am sure that at least some userspace components also have this > > assumption. In general, we expect min to be a minimum value reported > > and > > max being maximum value reported, and orientation expressed via > > different properties (see [1]). > > You can express all you want in DT properties the orientation of the > axis, it does not carry to userspace. As far as I can see there is > absolutely no way to tell userspace that an axis is inverted. That is true, and I will argue that it is a feature. Kernel's task is to normalize the data stream and present it to userspace so that it does not have to deal with differences of hardware. This abstraction often breaks, but when we can keep it, we should. Thanks. -- Dmitry ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-12-20 1:22 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-12-15 2:40 [RFC] dt-bindings: input: Clarify that abs_min must be less than abs_max Chris Morgan 2023-12-15 11:19 ` Artur Rojek 2023-12-18 17:11 ` Chris Morgan 2023-12-19 20:32 ` Dmitry Torokhov 2023-12-19 20:34 ` Dmitry Torokhov 2023-12-19 23:48 ` Peter Hutterer 2023-12-20 0:23 ` Paul Cercueil 2023-12-20 1:22 ` Dmitry Torokhov
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).