[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <addgrqhxanzrjdhb7y7y2qrqu4odpoclbwlswuua4yqinrzh2l@wcdtuquzuqvr>
Date: Sun, 21 Sep 2025 13:20:03 +0200
From: Ondřej Jirman <megi@....cz>
To: guptarud@...il.com
Cc: Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley <conor+dt@...nel.org>,
Heiko Stuebner <heiko@...ech.de>, devicetree@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-rockchip@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 5/5] arm64: dts: rk3399-pinephone-pro: Fix voltage
threshold for volume down key
Hi,
On Sun, Sep 21, 2025 at 01:04:23AM -0700, Rudraksha Gupta via B4 Relay wrote:
> From: Ondrej Jirman <megi@....cz>
>
> U-Boot and Linux use different algorithms for determining voltage ranges
> for comparison. Pick value that will work with both.
>
> Signed-off-by: Ondrej Jirman <megi@....cz>
> Signed-off-by: Rudraksha Gupta <guptarud@...il.com>
> ---
> arch/arm64/boot/dts/rockchip/rk3399-pinephone-pro.dts | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm64/boot/dts/rockchip/rk3399-pinephone-pro.dts b/arch/arm64/boot/dts/rockchip/rk3399-pinephone-pro.dts
> index 0a4121b05d36c5a7e05eddbd3514a11ae4f7d3eb..4e6df664d780ed4798015db6b2fe79bf7c4e4c00 100644
> --- a/arch/arm64/boot/dts/rockchip/rk3399-pinephone-pro.dts
> +++ b/arch/arm64/boot/dts/rockchip/rk3399-pinephone-pro.dts
> @@ -46,7 +46,7 @@ button-up {
> button-down {
> label = "Volume Down";
> linux,code = <KEY_VOLUMEDOWN>;
> - press-threshold-microvolt = <600000>;
> + press-threshold-microvolt = <400000>;
This is fixes the issue accidentally...
According to the schematic the actual threshold is 1.8V*(2/12) = 0.3V :)
https://xff.cz/dl/tmp/f1410ee03fac4c5b.png
Linux adc-keys driver uses the "closest to the threshold voltage key wins"
algorithm.
https://elixir.bootlin.com/linux/v6.16.8/source/drivers/input/keyboard/adc-keys.c#L32
U-Boot uses the same algorithm implemented differently:
https://elixir.bootlin.com/u-boot/v2025.10-rc4/source/drivers/button/button-adc.c#L97
So my description in the commit message is wrong.
For the current volume up/down key voltage DT "thresholds" the actual threshold
used by the driver to determine which key will be detected will be:
(100 + (600 - 100)/2) = 350 mV
So unless you press the key very lightly, a lot of the time adc voltage will be
below 350 mV for the Volume Down key and will be misdetected as Volume Up key
press.
Here a few volume down key presses on my PPP:
[ 32.567143] volkey val 1791
[ 32.671337] volkey val 1791
[ 32.775266] volkey val 1791
[ 32.879208] volkey val 1791
[ 32.983109] volkey val 1791
[ 33.086836] volkey val 1791
[ 33.191116] volkey val 300
[ 33.295158] volkey val 298 <-----
[ 33.399351] volkey val 1791
[ 33.503339] volkey val 1792
[ 33.607128] volkey val 1792
[ 33.711296] volkey val 1791
[ 33.815307] volkey val 1791
[ 33.919333] volkey val 1791
[ 34.023392] volkey val 311
[ 34.127329] volkey val 305
[ 34.231124] volkey val 1791
[ 34.335390] volkey val 1791
[ 34.439303] volkey val 1791
[ 34.543256] volkey val 1791
On my other Pinephone Pro it goes down even to 293 mV when the button is pressed harder.
It doesn't help that the Volume Up button threshold in DT is set incorrectly, too.
It should be 2mV and not 100mV.
So the correct fix here is to change both button thresholds to:
Volume Down
press-threshold-microvolt = <300000>;
Volume Up
press-threshold-microvolt = <2000>;
To match the schematic. Then the threshold/decision voltage will become ~150mV,
which works fine according to my tests.
Best regards,
o.
> };
> };
>
>
> --
> 2.51.0
>
>
Powered by blists - more mailing lists