Merge pull request #2964 from adamg88/ace-joypad
RK3588-ACE: add joypad driver
This commit is contained in:
commit
9d4f95d534
10 changed files with 1664 additions and 1173 deletions
|
@ -1,23 +1,18 @@
|
||||||
[ControlMapping]
|
[ControlMapping]
|
||||||
Up = 1-19,10-19
|
Up = 10-19
|
||||||
Down = 1-20,10-20
|
Down = 10-20
|
||||||
Left = 1-21,10-21
|
Left = 10-21
|
||||||
Right = 1-22,10-22
|
Right = 10-22
|
||||||
Circle = 1-52,11-189,11-4004
|
Circle = 10-190
|
||||||
Cross = 1-54,11-190
|
Cross = 10-189
|
||||||
Square = 1-29,11-188,11-4005
|
Square = 10-188
|
||||||
Triangle = 1-47,11-191,11-4007
|
Triangle = 10-191
|
||||||
Start = 1-62,10-197
|
Start = 10-197
|
||||||
Select = 1-66,10-196
|
Select = 10-196
|
||||||
L = 1-45,10-194
|
L = 10-193
|
||||||
R = 1-51,10-195
|
R = 10-192
|
||||||
An.Up = 1-37,11-4002
|
An.Up = 10-4000
|
||||||
An.Down = 1-39,11-4003
|
An.Down = 10-4001
|
||||||
An.Left = 1-38,11-4001
|
An.Left = 10-4003
|
||||||
An.Right = 1-40,11-4000
|
An.Right = 10-4002
|
||||||
Analog limiter = 1-60
|
Pause = 10-107
|
||||||
RapidFire = 1-59
|
|
||||||
Fast-forward = 1-61
|
|
||||||
SpeedToggle = 1-68
|
|
||||||
Pause = 1-111,10-109,10-104
|
|
||||||
Rewind = 1-67
|
|
||||||
|
|
|
@ -11,3 +11,4 @@
|
||||||
190014b3010000009178000000050000,r33s_joypad,platform:Linux,x:b2,a:b1,b:b0,y:b3,back:b8,start:b9,dpleft:b12,dpdown:b11,dpright:b13,dpup:b10,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,
|
190014b3010000009178000000050000,r33s_joypad,platform:Linux,x:b2,a:b1,b:b0,y:b3,back:b8,start:b9,dpleft:b12,dpdown:b11,dpright:b13,dpup:b10,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,
|
||||||
1900e5914b4800007711000077010000,RGB20S Gamepad,platform:Linux,x:b2,a:b1,b:b0,y:b3,back:b12,start:b13,dpleft:b10,dpdown:b9,dpright:b11,dpup:b8,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,leftstick:b14,rightstick:b15,leftx:a0,lefty:a1,rightx:a2,righty:a3,
|
1900e5914b4800007711000077010000,RGB20S Gamepad,platform:Linux,x:b2,a:b1,b:b0,y:b3,back:b12,start:b13,dpleft:b10,dpdown:b9,dpright:b11,dpup:b8,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,leftstick:b14,rightstick:b15,leftx:a0,lefty:a1,rightx:a2,righty:a3,
|
||||||
1900e7444b4800000111000034020000,rg552_joypad,platform:Linux,x:b2,a:b1,b:b0,y:b3,back:b8,start:b9,dpleft:b15,dpdown:b14,dpright:b16,dpup:b13,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,leftstick:b11,rightstick:b12,leftx:a0,lefty:a1,rightx:a2,righty:a3,
|
1900e7444b4800000111000034020000,rg552_joypad,platform:Linux,x:b2,a:b1,b:b0,y:b3,back:b8,start:b9,dpleft:b15,dpdown:b14,dpright:b16,dpup:b13,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,leftstick:b11,rightstick:b12,leftx:a0,lefty:a1,rightx:a2,righty:a3,
|
||||||
|
03001a3447616d65466f726365204100,GameForce ACE Gamepad,a:b1,b:b0,dpdown:b13,dpleft:b14,+lefty:-a0,-leftx:-a1,+leftx:+a1,-lefty:+a0,leftshoulder:b5,leftstick:b10,lefttrigger:-a2,dpright:b15,+righty:+a4,-rightx:-a3,+rightx:+a3,-righty:-a4,rightshoulder:b6,rightstick:b11,righttrigger:-a5,back:b7,start:b8,dpup:b12,x:b3,y:b4,platform:Linux,
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
input_driver = "udev"
|
||||||
|
input_device = "GameForce ACE Gamepad"
|
||||||
|
input_b_btn = "0"
|
||||||
|
input_y_btn = "4"
|
||||||
|
input_select_btn = "7"
|
||||||
|
input_start_btn = "8"
|
||||||
|
input_up_btn = "12"
|
||||||
|
input_down_btn = "13"
|
||||||
|
input_left_btn = "14"
|
||||||
|
input_right_btn = "15"
|
||||||
|
input_a_btn = "1"
|
||||||
|
input_x_btn = "3"
|
||||||
|
input_l_btn = "5"
|
||||||
|
input_r_btn = "6"
|
||||||
|
input_l2_axis = "-2"
|
||||||
|
input_r2_axis = "-5"
|
||||||
|
input_l3_btn = "10"
|
||||||
|
input_r3_btn = "11"
|
||||||
|
input_l_x_plus_axis = "+1"
|
||||||
|
input_l_x_minus_axis = "-1"
|
||||||
|
input_l_y_plus_axis = "-0"
|
||||||
|
input_l_y_minus_axis = "+0"
|
||||||
|
input_r_x_plus_axis = "+3"
|
||||||
|
input_r_x_minus_axis = "-3"
|
||||||
|
input_r_y_plus_axis = "+4"
|
||||||
|
input_r_y_minus_axis = "-4"
|
|
@ -1472,32 +1472,32 @@
|
||||||
<input name="up" type="button" id="13" value="1" />
|
<input name="up" type="button" id="13" value="1" />
|
||||||
<input name="x" type="button" id="2" value="1" />
|
<input name="x" type="button" id="2" value="1" />
|
||||||
<input name="y" type="button" id="3" value="1" />
|
<input name="y" type="button" id="3" value="1" />
|
||||||
</inputConfig>
|
</inputConfig>
|
||||||
<inputConfig type="joystick" deviceName="gameforce_ace_gamepad" deviceGUID="1900243a341200003874000000000000">
|
<inputConfig type="joystick" deviceName="GameForce ACE Gamepad" deviceGUID="03001a3447616d65466f726365204100">
|
||||||
<input name="a" type="button" id="1" value="1" />
|
<input name="a" type="button" id="1" value="1" />
|
||||||
<input name="b" type="button" id="0" value="1" />
|
<input name="b" type="button" id="0" value="1" />
|
||||||
<input name="down" type="button" id="12" value="1" />
|
<input name="down" type="button" id="13" value="1" />
|
||||||
<input name="hotkeyenable" type="button" id="6" value="1" />
|
<input name="hotkeyenable" type="button" id="7" value="1" />
|
||||||
<input name="left" type="button" id="13" value="1" />
|
<input name="left" type="button" id="14" value="1" />
|
||||||
<input name="leftanalogdown" type="axis" id="1" value="-1" />
|
<input name="leftanalogdown" type="axis" id="0" value="-1" />
|
||||||
<input name="leftanalogleft" type="axis" id="0" value="-1" />
|
<input name="leftanalogleft" type="axis" id="1" value="-1" />
|
||||||
<input name="leftanalogright" type="axis" id="0" value="1" />
|
<input name="leftanalogright" type="axis" id="1" value="1" />
|
||||||
<input name="leftanalogup" type="axis" id="1" value="1" />
|
<input name="leftanalogup" type="axis" id="0" value="1" />
|
||||||
<input name="leftshoulder" type="button" id="4" value="1" />
|
<input name="leftshoulder" type="button" id="5" value="1" />
|
||||||
<input name="leftthumb" type="button" id="9" value="1" />
|
<input name="leftthumb" type="button" id="10" value="1" />
|
||||||
<input name="lefttrigger" type="axis" id="2" value="-1" />
|
<input name="lefttrigger" type="axis" id="2" value="-1" />
|
||||||
<input name="right" type="button" id="14" value="1" />
|
<input name="right" type="button" id="15" value="1" />
|
||||||
<input name="rightanalogdown" type="axis" id="4" value="1" />
|
<input name="rightanalogdown" type="axis" id="4" value="1" />
|
||||||
<input name="rightanalogleft" type="axis" id="3" value="-1" />
|
<input name="rightanalogleft" type="axis" id="3" value="-1" />
|
||||||
<input name="rightanalogright" type="axis" id="3" value="1" />
|
<input name="rightanalogright" type="axis" id="3" value="1" />
|
||||||
<input name="rightanalogup" type="axis" id="4" value="-1" />
|
<input name="rightanalogup" type="axis" id="4" value="-1" />
|
||||||
<input name="rightshoulder" type="button" id="5" value="1" />
|
<input name="rightshoulder" type="button" id="6" value="1" />
|
||||||
<input name="rightthumb" type="button" id="10" value="1" />
|
<input name="rightthumb" type="button" id="11" value="1" />
|
||||||
<input name="righttrigger" type="axis" id="5" value="-1" />
|
<input name="righttrigger" type="axis" id="5" value="-1" />
|
||||||
<input name="select" type="button" id="6" value="1" />
|
<input name="select" type="button" id="7" value="1" />
|
||||||
<input name="start" type="button" id="7" value="1" />
|
<input name="start" type="button" id="8" value="1" />
|
||||||
<input name="up" type="button" id="11" value="1" />
|
<input name="up" type="button" id="12" value="1" />
|
||||||
<input name="x" type="button" id="2" value="1" />
|
<input name="x" type="button" id="3" value="1" />
|
||||||
<input name="y" type="button" id="3" value="1" />
|
<input name="y" type="button" id="4" value="1" />
|
||||||
</inputConfig>
|
</inputConfig>
|
||||||
</inputList>
|
</inputList>
|
||||||
|
|
|
@ -3042,7 +3042,7 @@ CONFIG_MOUSE_ELAN_I2C_I2C=y
|
||||||
CONFIG_INPUT_JOYSTICK=y
|
CONFIG_INPUT_JOYSTICK=y
|
||||||
# CONFIG_JOYSTICK_ANALOG is not set
|
# CONFIG_JOYSTICK_ANALOG is not set
|
||||||
# CONFIG_JOYSTICK_A3D is not set
|
# CONFIG_JOYSTICK_A3D is not set
|
||||||
CONFIG_JOYSTICK_ADC=y
|
# CONFIG_JOYSTICK_ADC is not set
|
||||||
# CONFIG_JOYSTICK_ADI is not set
|
# CONFIG_JOYSTICK_ADI is not set
|
||||||
# CONFIG_JOYSTICK_COBRA is not set
|
# CONFIG_JOYSTICK_COBRA is not set
|
||||||
# CONFIG_JOYSTICK_GF2K is not set
|
# CONFIG_JOYSTICK_GF2K is not set
|
||||||
|
@ -3071,6 +3071,7 @@ CONFIG_JOYSTICK_PSXPAD_SPI=y
|
||||||
# CONFIG_JOYSTICK_QWIIC is not set
|
# CONFIG_JOYSTICK_QWIIC is not set
|
||||||
# CONFIG_JOYSTICK_FSIA6B is not set
|
# CONFIG_JOYSTICK_FSIA6B is not set
|
||||||
# CONFIG_JOYSTICK_SENSEHAT is not set
|
# CONFIG_JOYSTICK_SENSEHAT is not set
|
||||||
|
CONFIG_JOYSTICK_JELOS_JOYPAD=y
|
||||||
CONFIG_INPUT_TABLET=y
|
CONFIG_INPUT_TABLET=y
|
||||||
# CONFIG_TABLET_USB_ACECAD is not set
|
# CONFIG_TABLET_USB_ACECAD is not set
|
||||||
# CONFIG_TABLET_USB_AIPTEK is not set
|
# CONFIG_TABLET_USB_AIPTEK is not set
|
||||||
|
|
|
@ -88,7 +88,7 @@
|
||||||
# for a list of additional drivers see packages/linux-drivers
|
# for a list of additional drivers see packages/linux-drivers
|
||||||
# Space separated list is supported,
|
# Space separated list is supported,
|
||||||
# e.g. ADDITIONAL_DRIVERS="DRIVER1 DRIVER2"
|
# e.g. ADDITIONAL_DRIVERS="DRIVER1 DRIVER2"
|
||||||
ADDITIONAL_DRIVERS+=" RTW89 jelos-gamepad"
|
ADDITIONAL_DRIVERS+=" RTW89"
|
||||||
|
|
||||||
# build and install driver addons (yes / no)
|
# build and install driver addons (yes / no)
|
||||||
DRIVER_ADDONS_SUPPORT="no"
|
DRIVER_ADDONS_SUPPORT="no"
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/Makefile linux/arch/arm64/boot/dts/rockchip/Makefile
|
diff --git a/arch/arm64/boot/dts/rockchip/Makefile b/arch/arm64/boot/dts/rockchip/Makefile
|
||||||
--- linux.orig/arch/arm64/boot/dts/rockchip/Makefile 2024-02-28 20:10:38.318659129 +0000
|
index 364768ec4f47..2918159ddb4e 100644
|
||||||
+++ linux/arch/arm64/boot/dts/rockchip/Makefile 2024-02-28 20:29:01.089808951 +0000
|
--- a/arch/arm64/boot/dts/rockchip/Makefile
|
||||||
@@ -313,6 +313,7 @@ dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3588s-e
|
+++ b/arch/arm64/boot/dts/rockchip/Makefile
|
||||||
|
@@ -313,6 +313,7 @@ dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3588s-evb4-lp4x-v10.dtb
|
||||||
dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3588s-evb4-lp4x-v10-linux.dtb
|
dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3588s-evb4-lp4x-v10-linux.dtb
|
||||||
dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3588s-evb8-lp4x-v10.dtb
|
dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3588s-evb8-lp4x-v10.dtb
|
||||||
dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3588s-9tripod-linux.dtb
|
dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3588s-9tripod-linux.dtb
|
||||||
|
@ -9,9 +10,11 @@ diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/Makefile linux/arch/arm64/boo
|
||||||
dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3588s-khadas-edge2.dtb
|
dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3588s-khadas-edge2.dtb
|
||||||
dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3588s-lubancat-4.dtb
|
dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3588s-lubancat-4.dtb
|
||||||
dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3588s-nanopi-r6c.dtb
|
dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3588s-nanopi-r6c.dtb
|
||||||
diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/lcd-hx8399c_mipi.dtsi linux/arch/arm64/boot/dts/rockchip/lcd-hx8399c_mipi.dtsi
|
diff --git a/arch/arm64/boot/dts/rockchip/lcd-hx8399c_mipi.dtsi b/arch/arm64/boot/dts/rockchip/lcd-hx8399c_mipi.dtsi
|
||||||
--- linux.orig/arch/arm64/boot/dts/rockchip/lcd-hx8399c_mipi.dtsi 1970-01-01 00:00:00.000000000 +0000
|
new file mode 100644
|
||||||
+++ linux/arch/arm64/boot/dts/rockchip/lcd-hx8399c_mipi.dtsi 2024-02-28 20:29:01.089808951 +0000
|
index 000000000000..af4a6c170200
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/arch/arm64/boot/dts/rockchip/lcd-hx8399c_mipi.dtsi
|
||||||
@@ -0,0 +1,137 @@
|
@@ -0,0 +1,137 @@
|
||||||
+/*
|
+/*
|
||||||
+ * Copyright (c) 2017 Fuzhou Rockchip Electronics Co., Ltd
|
+ * Copyright (c) 2017 Fuzhou Rockchip Electronics Co., Ltd
|
||||||
|
@ -150,10 +153,12 @@ diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/lcd-hx8399c_mipi.dtsi linux/a
|
||||||
+ };
|
+ };
|
||||||
+
|
+
|
||||||
+};
|
+};
|
||||||
diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3588s-gameforce-ace.dts linux/arch/arm64/boot/dts/rockchip/rk3588s-gameforce-ace.dts
|
diff --git a/arch/arm64/boot/dts/rockchip/rk3588s-gameforce-ace.dts b/arch/arm64/boot/dts/rockchip/rk3588s-gameforce-ace.dts
|
||||||
--- linux.orig/arch/arm64/boot/dts/rockchip/rk3588s-gameforce-ace.dts 1970-01-01 00:00:00.000000000 +0000
|
new file mode 100644
|
||||||
+++ linux/arch/arm64/boot/dts/rockchip/rk3588s-gameforce-ace.dts 2024-02-28 22:05:19.125383648 +0000
|
index 000000000000..84eeaef5f066
|
||||||
@@ -0,0 +1,1489 @@
|
--- /dev/null
|
||||||
|
+++ b/arch/arm64/boot/dts/rockchip/rk3588s-gameforce-ace.dts
|
||||||
|
@@ -0,0 +1,1408 @@
|
||||||
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
|
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
|
||||||
+/*
|
+/*
|
||||||
+ * Copyright (c) 2021 Rockchip Electronics Co., Ltd.
|
+ * Copyright (c) 2021 Rockchip Electronics Co., Ltd.
|
||||||
|
@ -199,196 +204,115 @@ diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3588s-gameforce-ace.dts lin
|
||||||
+ };
|
+ };
|
||||||
+ };
|
+ };
|
||||||
+
|
+
|
||||||
+ /* Joystick range values based on hardware observation. */
|
+ joypad: gameforce-ace-joypad {
|
||||||
+ adc_joystick: adc-joystick {
|
+ compatible = "jelos-joypad";
|
||||||
+ compatible = "adc-joystick";
|
+ poll-interval = <10>;
|
||||||
+ #address-cells = <1>;
|
|
||||||
+ io-channels = <&saradc 2>, <&saradc 3>,
|
|
||||||
+ <&saradc 4>, <&saradc 5>;
|
|
||||||
+ poll-interval = <60>;
|
|
||||||
+ #size-cells = <0>;
|
|
||||||
+
|
|
||||||
+ axis@0 {
|
|
||||||
+ reg = <0>;
|
|
||||||
+ abs-flat = <40>;
|
|
||||||
+ abs-fuzz = <40>;
|
|
||||||
+ abs-range = <0 4095>;
|
|
||||||
+ linux,code = <ABS_RY>;
|
|
||||||
+ };
|
|
||||||
+
|
|
||||||
+ axis@1 {
|
|
||||||
+ reg = <1>;
|
|
||||||
+ abs-flat = <40>;
|
|
||||||
+ abs-fuzz = <40>;
|
|
||||||
+ abs-range = <0 4095>;
|
|
||||||
+ linux,code = <ABS_RX>;
|
|
||||||
+ };
|
|
||||||
+
|
|
||||||
+ axis@2 {
|
|
||||||
+ reg = <2>;
|
|
||||||
+ abs-flat = <40>;
|
|
||||||
+ abs-fuzz = <40>;
|
|
||||||
+ abs-range = <0 4095>;
|
|
||||||
+ linux,code = <ABS_X>;
|
|
||||||
+ };
|
|
||||||
+
|
|
||||||
+ axis@3 {
|
|
||||||
+ reg = <3>;
|
|
||||||
+ abs-flat = <40>;
|
|
||||||
+ abs-fuzz = <40>;
|
|
||||||
+ abs-range = <0 4095>;
|
|
||||||
+ linux,code = <ABS_Y>;
|
|
||||||
+ };
|
|
||||||
+ };
|
|
||||||
+
|
|
||||||
+ /* Trigger range values based on hardware observation. */
|
|
||||||
+ adc_triggers: adc-trigger {
|
|
||||||
+ compatible = "adc-joystick";
|
|
||||||
+ #address-cells = <1>;
|
|
||||||
+ io-channels = <&ti_adc 6>,
|
|
||||||
+ <&ti_adc 7>;
|
|
||||||
+ poll-interval = <60>;
|
|
||||||
+ #size-cells = <0>;
|
|
||||||
+
|
|
||||||
+ axis@0 {
|
|
||||||
+ reg = <0>;
|
|
||||||
+ abs-flat = <40>;
|
|
||||||
+ abs-fuzz = <40>;
|
|
||||||
+ abs-range = <1530 890>;
|
|
||||||
+ linux,code = <ABS_Z>;
|
|
||||||
+ };
|
|
||||||
+
|
|
||||||
+ axis@1 {
|
|
||||||
+ reg = <1>;
|
|
||||||
+ abs-flat = <40>;
|
|
||||||
+ abs-fuzz = <40>;
|
|
||||||
+ abs-range = <1550 1010>;
|
|
||||||
+ linux,code = <ABS_RZ>;
|
|
||||||
+ };
|
|
||||||
+ };
|
|
||||||
+
|
|
||||||
+ // lqb : 手柄GPIO按键
|
|
||||||
+ gpio-keys {
|
|
||||||
+ status = "okay";
|
+ status = "okay";
|
||||||
+ compatible = "gpio-keys";
|
|
||||||
+
|
+
|
||||||
+ mode {
|
+ joypad-name = "GameForce ACE Gamepad";
|
||||||
+ label = "GPIO Key MODE";
|
+ //joypad-vendor = <0x045e>;
|
||||||
+ debounce-interval = <0x0a>;
|
+ joypad-product = <0x1000>;
|
||||||
|
+ joypad-revision = <0x0100>;
|
||||||
|
+
|
||||||
|
+ /* Analog sticks */
|
||||||
|
+ io-channels = <&saradc 2>, <&saradc 3>, <&saradc 4>, <&saradc 5>, <&ti_adc 6>, <&ti_adc 7>;
|
||||||
|
+ io-channel-names = "key-RY", "key-RX", "key-X", "key-Y", "key-Z", "key-RZ";
|
||||||
|
+ button-adc-scale = <4>;
|
||||||
|
+ button-adc-deadzone = <64>;
|
||||||
|
+ button-adc-fuzz = <32>;
|
||||||
|
+ button-adc-flat = <32>;
|
||||||
|
+ abs_x-p-tuning = <350>;
|
||||||
|
+ abs_x-n-tuning = <350>;
|
||||||
|
+ abs_y-p-tuning = <350>;
|
||||||
|
+ abs_y-n-tuning = <350>;
|
||||||
|
+ abs_z-p-tuning = <350>;
|
||||||
|
+ abs_z-n-tuning = <350>;
|
||||||
|
+ abs_rx-p-tuning = <350>;
|
||||||
|
+ abs_rx-n-tuning = <350>;
|
||||||
|
+ abs_ry-p-tuning = <350>;
|
||||||
|
+ abs_ry-n-tuning = <350>;
|
||||||
|
+ abs_rz-p-tuning = <350>;
|
||||||
|
+ abs_rz-n-tuning = <350>;
|
||||||
|
+
|
||||||
|
+ /* Buttons */
|
||||||
|
+ sw1 {
|
||||||
+ gpios = <&gpio1 RK_PA0 0x01>;
|
+ gpios = <&gpio1 RK_PA0 0x01>;
|
||||||
+ linux,input-type = <0x01>;
|
+ label = "GPIO Key MODE";
|
||||||
+ linux,code = <BTN_MODE>;
|
+ linux,code = <BTN_MODE>;
|
||||||
+ };
|
+ };
|
||||||
+
|
+ sw2 {
|
||||||
+ start {
|
+ gpios = <&gpio1 RK_PB0 0x01>;
|
||||||
+ label = "GPIO Key START";
|
+ label = "GPIO Key HOME";
|
||||||
+ debounce-interval = <10>;
|
+ linux,code = <BTN_C>;
|
||||||
|
+ };
|
||||||
|
+ sw3 {
|
||||||
+ gpios = <&gpio1 RK_PB6 0x01>;
|
+ gpios = <&gpio1 RK_PB6 0x01>;
|
||||||
+ linux,input-type = <EV_KEY>;
|
+ label = "GPIO Key START";
|
||||||
+ linux,code = <BTN_START>;
|
+ linux,code = <BTN_START>;
|
||||||
+ };
|
+ };
|
||||||
+
|
+ sw4 {
|
||||||
+ select {
|
|
||||||
+ label = "GPIO Key SELECT";
|
|
||||||
+ debounce-interval = <10>;
|
|
||||||
+ gpios = <&gpio1 RK_PA3 0x01>;
|
+ gpios = <&gpio1 RK_PA3 0x01>;
|
||||||
+ linux,input-type = <EV_KEY>;
|
+ label = "GPIO Key SELECT";
|
||||||
+ linux,code = <BTN_SELECT>;
|
+ linux,code = <BTN_SELECT>;
|
||||||
+ };
|
+ };
|
||||||
+
|
+ sw5 {
|
||||||
+ up {
|
|
||||||
+ label = "GPIO Key Up";
|
|
||||||
+ debounce-interval = <0x0a>;
|
|
||||||
+ gpios = <&gpio1 RK_PA2 0x01>;
|
+ gpios = <&gpio1 RK_PA2 0x01>;
|
||||||
+ linux,input-type = <0x01>;
|
+ label = "GPIO Key Up";
|
||||||
+ linux,code = <BTN_DPAD_UP>;
|
+ linux,code = <BTN_DPAD_UP>;
|
||||||
+ };
|
+ };
|
||||||
+
|
+ sw6 {
|
||||||
+ down {
|
+ gpios = <&gpio1 RK_PB1 0x01>;
|
||||||
+ label = "GPIO Key Down";
|
+ label = "GPIO Key Down";
|
||||||
+ debounce-interval = <0x0a>;
|
|
||||||
+ gpios = <&gpio1 RK_PB1 0x01>;
|
|
||||||
+ linux,input-type = <0x01>;
|
|
||||||
+ linux,code = <BTN_DPAD_DOWN>;
|
+ linux,code = <BTN_DPAD_DOWN>;
|
||||||
+ };
|
+ };
|
||||||
+
|
+ sw7 {
|
||||||
+ left {
|
|
||||||
+ label = "GPIO Key Left";
|
|
||||||
+ debounce-interval = <0x0a>;
|
|
||||||
+ gpios = <&gpio1 RK_PD7 0x01>;
|
+ gpios = <&gpio1 RK_PD7 0x01>;
|
||||||
+ linux,input-type = <0x01>;
|
+ label = "GPIO Key Left";
|
||||||
+ linux,code = <BTN_DPAD_LEFT>;
|
+ linux,code = <BTN_DPAD_LEFT>;
|
||||||
+ };
|
+ };
|
||||||
+
|
+ sw8 {
|
||||||
+ right {
|
|
||||||
+ label = "GPIO Key Right";
|
|
||||||
+ debounce-interval = <0x0a>;
|
|
||||||
+ gpios = <&gpio1 RK_PB7 0x01>;
|
+ gpios = <&gpio1 RK_PB7 0x01>;
|
||||||
+ linux,input-type = <0x01>;
|
+ label = "GPIO Key Right";
|
||||||
+ linux,code = <BTN_DPAD_RIGHT>;
|
+ linux,code = <BTN_DPAD_RIGHT>;
|
||||||
+ };
|
+ };
|
||||||
+
|
+ sw9 {
|
||||||
+ keyX {
|
|
||||||
+ label = "GPIO Key X";
|
|
||||||
+ debounce-interval = <0x0a>;
|
|
||||||
+ gpios = <&gpio1 RK_PB4 0x01>;
|
+ gpios = <&gpio1 RK_PB4 0x01>;
|
||||||
+ linux,input-type = <0x01>;
|
+ label = "GPIO Key X";
|
||||||
+ linux,code = <BTN_NORTH>;
|
+ linux,code = <BTN_NORTH>;
|
||||||
+ };
|
+ };
|
||||||
+
|
+ sw10 {
|
||||||
+ keyY {
|
|
||||||
+ label = "GPIO Key Y";
|
|
||||||
+ debounce-interval = <0x0a>;
|
|
||||||
+ gpios = <&gpio1 RK_PB3 0x01>;
|
+ gpios = <&gpio1 RK_PB3 0x01>;
|
||||||
+ linux,input-type = <0x01>;
|
+ label = "GPIO Key Y";
|
||||||
+ linux,code = <BTN_WEST>;
|
+ linux,code = <BTN_WEST>;
|
||||||
+ };
|
+ };
|
||||||
+
|
+ sw11 {
|
||||||
+ keyA {
|
|
||||||
+ label = "GPIO Key B";
|
|
||||||
+ debounce-interval = <0x0a>;
|
|
||||||
+ gpios = <&gpio1 RK_PC6 0x01>;
|
+ gpios = <&gpio1 RK_PC6 0x01>;
|
||||||
+ linux,input-type = <0x01>;
|
+ label = "GPIO Key B";
|
||||||
+ linux,code = <BTN_EAST>;
|
+ linux,code = <BTN_EAST>;
|
||||||
+ };
|
+ };
|
||||||
+
|
+ sw12 {
|
||||||
+ keyB {
|
|
||||||
+ label = "GPIO Key A";
|
|
||||||
+ debounce-interval = <0x0a>;
|
|
||||||
+ gpios = <&gpio1 RK_PA5 0x01>;
|
+ gpios = <&gpio1 RK_PA5 0x01>;
|
||||||
+ linux,input-type = <0x01>;
|
+ label = "GPIO Key A";
|
||||||
+ linux,code = <BTN_SOUTH>;
|
+ linux,code = <BTN_SOUTH>;
|
||||||
+ };
|
+ };
|
||||||
+
|
+ sw13 {
|
||||||
+ keyTHUMBL {
|
|
||||||
+ label = "GPIO Key THU";
|
|
||||||
+ debounce-interval = <0x0a>;
|
|
||||||
+ gpios = <&gpio1 RK_PA4 0x01>;
|
+ gpios = <&gpio1 RK_PA4 0x01>;
|
||||||
+ linux,input-type = <0x01>;
|
+ label = "GPIO Key THU";
|
||||||
+ linux,code = <BTN_THUMBL>;
|
+ linux,code = <BTN_THUMBL>;
|
||||||
+ };
|
+ };
|
||||||
+
|
+ sw14 {
|
||||||
+ keyTL {
|
|
||||||
+ label = "GPIO Key TL";
|
|
||||||
+ debounce-interval = <0x0a>;
|
|
||||||
+ gpios = <&gpio1 RK_PB5 0x01>;
|
+ gpios = <&gpio1 RK_PB5 0x01>;
|
||||||
+ linux,input-type = <0x01>;
|
+ label = "GPIO Key TL";
|
||||||
+ linux,code = <BTN_TL>;
|
+ linux,code = <BTN_TL>;
|
||||||
+ };
|
+ };
|
||||||
+
|
+ sw15 {
|
||||||
+ keyTR {
|
|
||||||
+ label = "GPIO Key TR";
|
|
||||||
+ debounce-interval = <0x0a>;
|
|
||||||
+ gpios = <&gpio1 RK_PB2 0x01>;
|
+ gpios = <&gpio1 RK_PB2 0x01>;
|
||||||
+ linux,input-type = <EV_KEY>;
|
+ label = "GPIO Key TR";
|
||||||
+ linux,code = <BTN_TR>;
|
+ linux,code = <BTN_TR>;
|
||||||
+ };
|
+ };
|
||||||
+
|
+ sw16 {
|
||||||
+ keyTHUMBR {
|
+ gpios = <&gpio1 RK_PD6 0x01>;
|
||||||
+ label = "GPIO Key THUMBR";
|
+ label = "GPIO Key THUMBR";
|
||||||
+ debounce-interval = <10>;
|
|
||||||
+ gpios = <&gpio1 RK_PD6 0x01>;//新小板:交换右马达GPIO1 D6
|
|
||||||
+ linux,input-type = <EV_KEY>;
|
|
||||||
+ linux,code = <BTN_THUMBR>;
|
+ linux,code = <BTN_THUMBR>;
|
||||||
+ };
|
+ };
|
||||||
+ };
|
+ };
|
||||||
|
|
|
@ -1,974 +0,0 @@
|
||||||
diff -rupN linux.orig/drivers/input/Kconfig linux/drivers/input/Kconfig
|
|
||||||
--- linux.orig/drivers/input/Kconfig 2024-03-02 17:57:02.760204687 +0000
|
|
||||||
+++ linux/drivers/input/Kconfig 2024-03-02 18:09:13.825975926 +0000
|
|
||||||
@@ -51,6 +51,14 @@ config INPUT_FF_MEMLESS
|
|
||||||
To compile this driver as a module, choose M here: the
|
|
||||||
module will be called ff-memless.
|
|
||||||
|
|
||||||
+config INPUT_POLLDEV
|
|
||||||
+ tristate "Polled input device skeleton"
|
|
||||||
+ help
|
|
||||||
+ Say Y here if you are using a driver for an input
|
|
||||||
+ device that periodically polls hardware state. This
|
|
||||||
+ option is only useful for out-of-tree drivers since
|
|
||||||
+ in-tree drivers select it automatically.
|
|
||||||
+
|
|
||||||
config INPUT_SPARSEKMAP
|
|
||||||
tristate "Sparse keymap support library"
|
|
||||||
help
|
|
||||||
diff -rupN linux.orig/drivers/input/Makefile linux/drivers/input/Makefile
|
|
||||||
--- linux.orig/drivers/input/Makefile 2024-03-02 17:57:02.760204687 +0000
|
|
||||||
+++ linux/drivers/input/Makefile 2024-03-02 18:07:53.627958774 +0000
|
|
||||||
@@ -10,6 +10,7 @@ input-core-y := input.o input-compat.o i
|
|
||||||
input-core-y += touchscreen.o
|
|
||||||
|
|
||||||
obj-$(CONFIG_INPUT_FF_MEMLESS) += ff-memless.o
|
|
||||||
+obj-$(CONFIG_INPUT_POLLDEV) += input-polldev.o
|
|
||||||
obj-$(CONFIG_INPUT_SPARSEKMAP) += sparse-keymap.o
|
|
||||||
obj-$(CONFIG_INPUT_MATRIXKMAP) += matrix-keymap.o
|
|
||||||
obj-$(CONFIG_INPUT_VIVALDIFMAP) += vivaldi-fmap.o
|
|
||||||
diff -rupN linux.orig/drivers/input/input-polldev.c linux/drivers/input/input-polldev.c
|
|
||||||
--- linux.orig/drivers/input/input-polldev.c 1970-01-01 00:00:00.000000000 +0000
|
|
||||||
+++ linux/drivers/input/input-polldev.c 2024-03-02 18:07:18.547098087 +0000
|
|
||||||
@@ -0,0 +1,362 @@
|
|
||||||
+// SPDX-License-Identifier: GPL-2.0-only
|
|
||||||
+/*
|
|
||||||
+ * Generic implementation of a polled input device
|
|
||||||
+
|
|
||||||
+ * Copyright (c) 2007 Dmitry Torokhov
|
|
||||||
+ */
|
|
||||||
+
|
|
||||||
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
||||||
+
|
|
||||||
+#include <linux/jiffies.h>
|
|
||||||
+#include <linux/slab.h>
|
|
||||||
+#include <linux/mutex.h>
|
|
||||||
+#include <linux/workqueue.h>
|
|
||||||
+#include <linux/module.h>
|
|
||||||
+#include <linux/input-polldev.h>
|
|
||||||
+
|
|
||||||
+MODULE_AUTHOR("Dmitry Torokhov <dtor@mail.ru>");
|
|
||||||
+MODULE_DESCRIPTION("Generic implementation of a polled input device");
|
|
||||||
+MODULE_LICENSE("GPL v2");
|
|
||||||
+
|
|
||||||
+static void input_polldev_queue_work(struct input_polled_dev *dev)
|
|
||||||
+{
|
|
||||||
+ unsigned long delay;
|
|
||||||
+
|
|
||||||
+ delay = msecs_to_jiffies(dev->poll_interval);
|
|
||||||
+ if (delay >= HZ)
|
|
||||||
+ delay = round_jiffies_relative(delay);
|
|
||||||
+
|
|
||||||
+ queue_delayed_work(system_freezable_wq, &dev->work, delay);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void input_polled_device_work(struct work_struct *work)
|
|
||||||
+{
|
|
||||||
+ struct input_polled_dev *dev =
|
|
||||||
+ container_of(work, struct input_polled_dev, work.work);
|
|
||||||
+
|
|
||||||
+ dev->poll(dev);
|
|
||||||
+ input_polldev_queue_work(dev);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static int input_open_polled_device(struct input_dev *input)
|
|
||||||
+{
|
|
||||||
+ struct input_polled_dev *dev = input_get_drvdata(input);
|
|
||||||
+
|
|
||||||
+ if (dev->open)
|
|
||||||
+ dev->open(dev);
|
|
||||||
+
|
|
||||||
+ /* Only start polling if polling is enabled */
|
|
||||||
+ if (dev->poll_interval > 0) {
|
|
||||||
+ dev->poll(dev);
|
|
||||||
+ input_polldev_queue_work(dev);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return 0;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void input_close_polled_device(struct input_dev *input)
|
|
||||||
+{
|
|
||||||
+ struct input_polled_dev *dev = input_get_drvdata(input);
|
|
||||||
+
|
|
||||||
+ cancel_delayed_work_sync(&dev->work);
|
|
||||||
+
|
|
||||||
+ if (dev->close)
|
|
||||||
+ dev->close(dev);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+/* SYSFS interface */
|
|
||||||
+
|
|
||||||
+static ssize_t input_polldev_get_poll(struct device *dev,
|
|
||||||
+ struct device_attribute *attr, char *buf)
|
|
||||||
+{
|
|
||||||
+ struct input_polled_dev *polldev = dev_get_drvdata(dev);
|
|
||||||
+
|
|
||||||
+ return sprintf(buf, "%d\n", polldev->poll_interval);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static ssize_t input_polldev_set_poll(struct device *dev,
|
|
||||||
+ struct device_attribute *attr, const char *buf,
|
|
||||||
+ size_t count)
|
|
||||||
+{
|
|
||||||
+ struct input_polled_dev *polldev = dev_get_drvdata(dev);
|
|
||||||
+ struct input_dev *input = polldev->input;
|
|
||||||
+ unsigned int interval;
|
|
||||||
+ int err;
|
|
||||||
+
|
|
||||||
+ err = kstrtouint(buf, 0, &interval);
|
|
||||||
+ if (err)
|
|
||||||
+ return err;
|
|
||||||
+
|
|
||||||
+ if (interval < polldev->poll_interval_min)
|
|
||||||
+ return -EINVAL;
|
|
||||||
+
|
|
||||||
+ if (interval > polldev->poll_interval_max)
|
|
||||||
+ return -EINVAL;
|
|
||||||
+
|
|
||||||
+ mutex_lock(&input->mutex);
|
|
||||||
+
|
|
||||||
+ polldev->poll_interval = interval;
|
|
||||||
+
|
|
||||||
+ if (input->users) {
|
|
||||||
+ cancel_delayed_work_sync(&polldev->work);
|
|
||||||
+ if (polldev->poll_interval > 0)
|
|
||||||
+ input_polldev_queue_work(polldev);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ mutex_unlock(&input->mutex);
|
|
||||||
+
|
|
||||||
+ return count;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static DEVICE_ATTR(poll, S_IRUGO | S_IWUSR, input_polldev_get_poll,
|
|
||||||
+ input_polldev_set_poll);
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+static ssize_t input_polldev_get_max(struct device *dev,
|
|
||||||
+ struct device_attribute *attr, char *buf)
|
|
||||||
+{
|
|
||||||
+ struct input_polled_dev *polldev = dev_get_drvdata(dev);
|
|
||||||
+
|
|
||||||
+ return sprintf(buf, "%d\n", polldev->poll_interval_max);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static DEVICE_ATTR(max, S_IRUGO, input_polldev_get_max, NULL);
|
|
||||||
+
|
|
||||||
+static ssize_t input_polldev_get_min(struct device *dev,
|
|
||||||
+ struct device_attribute *attr, char *buf)
|
|
||||||
+{
|
|
||||||
+ struct input_polled_dev *polldev = dev_get_drvdata(dev);
|
|
||||||
+
|
|
||||||
+ return sprintf(buf, "%d\n", polldev->poll_interval_min);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static DEVICE_ATTR(min, S_IRUGO, input_polldev_get_min, NULL);
|
|
||||||
+
|
|
||||||
+static struct attribute *sysfs_attrs[] = {
|
|
||||||
+ &dev_attr_poll.attr,
|
|
||||||
+ &dev_attr_max.attr,
|
|
||||||
+ &dev_attr_min.attr,
|
|
||||||
+ NULL
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
+static struct attribute_group input_polldev_attribute_group = {
|
|
||||||
+ .attrs = sysfs_attrs
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
+static const struct attribute_group *input_polldev_attribute_groups[] = {
|
|
||||||
+ &input_polldev_attribute_group,
|
|
||||||
+ NULL
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
+/**
|
|
||||||
+ * input_allocate_polled_device - allocate memory for polled device
|
|
||||||
+ *
|
|
||||||
+ * The function allocates memory for a polled device and also
|
|
||||||
+ * for an input device associated with this polled device.
|
|
||||||
+ */
|
|
||||||
+struct input_polled_dev *input_allocate_polled_device(void)
|
|
||||||
+{
|
|
||||||
+ struct input_polled_dev *dev;
|
|
||||||
+
|
|
||||||
+ dev = kzalloc(sizeof(struct input_polled_dev), GFP_KERNEL);
|
|
||||||
+ if (!dev)
|
|
||||||
+ return NULL;
|
|
||||||
+
|
|
||||||
+ dev->input = input_allocate_device();
|
|
||||||
+ if (!dev->input) {
|
|
||||||
+ kfree(dev);
|
|
||||||
+ return NULL;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return dev;
|
|
||||||
+}
|
|
||||||
+EXPORT_SYMBOL(input_allocate_polled_device);
|
|
||||||
+
|
|
||||||
+struct input_polled_devres {
|
|
||||||
+ struct input_polled_dev *polldev;
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
+static int devm_input_polldev_match(struct device *dev, void *res, void *data)
|
|
||||||
+{
|
|
||||||
+ struct input_polled_devres *devres = res;
|
|
||||||
+
|
|
||||||
+ return devres->polldev == data;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void devm_input_polldev_release(struct device *dev, void *res)
|
|
||||||
+{
|
|
||||||
+ struct input_polled_devres *devres = res;
|
|
||||||
+ struct input_polled_dev *polldev = devres->polldev;
|
|
||||||
+
|
|
||||||
+ dev_dbg(dev, "%s: dropping reference/freeing %s\n",
|
|
||||||
+ __func__, dev_name(&polldev->input->dev));
|
|
||||||
+
|
|
||||||
+ input_put_device(polldev->input);
|
|
||||||
+ kfree(polldev);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void devm_input_polldev_unregister(struct device *dev, void *res)
|
|
||||||
+{
|
|
||||||
+ struct input_polled_devres *devres = res;
|
|
||||||
+ struct input_polled_dev *polldev = devres->polldev;
|
|
||||||
+
|
|
||||||
+ dev_dbg(dev, "%s: unregistering device %s\n",
|
|
||||||
+ __func__, dev_name(&polldev->input->dev));
|
|
||||||
+ input_unregister_device(polldev->input);
|
|
||||||
+
|
|
||||||
+ /*
|
|
||||||
+ * Note that we are still holding extra reference to the input
|
|
||||||
+ * device so it will stick around until devm_input_polldev_release()
|
|
||||||
+ * is called.
|
|
||||||
+ */
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+/**
|
|
||||||
+ * devm_input_allocate_polled_device - allocate managed polled device
|
|
||||||
+ * @dev: device owning the polled device being created
|
|
||||||
+ *
|
|
||||||
+ * Returns prepared &struct input_polled_dev or %NULL.
|
|
||||||
+ *
|
|
||||||
+ * Managed polled input devices do not need to be explicitly unregistered
|
|
||||||
+ * or freed as it will be done automatically when owner device unbinds
|
|
||||||
+ * from * its driver (or binding fails). Once such managed polled device
|
|
||||||
+ * is allocated, it is ready to be set up and registered in the same
|
|
||||||
+ * fashion as regular polled input devices (using
|
|
||||||
+ * input_register_polled_device() function).
|
|
||||||
+ *
|
|
||||||
+ * If you want to manually unregister and free such managed polled devices,
|
|
||||||
+ * it can be still done by calling input_unregister_polled_device() and
|
|
||||||
+ * input_free_polled_device(), although it is rarely needed.
|
|
||||||
+ *
|
|
||||||
+ * NOTE: the owner device is set up as parent of input device and users
|
|
||||||
+ * should not override it.
|
|
||||||
+ */
|
|
||||||
+struct input_polled_dev *devm_input_allocate_polled_device(struct device *dev)
|
|
||||||
+{
|
|
||||||
+ struct input_polled_dev *polldev;
|
|
||||||
+ struct input_polled_devres *devres;
|
|
||||||
+
|
|
||||||
+ devres = devres_alloc(devm_input_polldev_release, sizeof(*devres),
|
|
||||||
+ GFP_KERNEL);
|
|
||||||
+ if (!devres)
|
|
||||||
+ return NULL;
|
|
||||||
+
|
|
||||||
+ polldev = input_allocate_polled_device();
|
|
||||||
+ if (!polldev) {
|
|
||||||
+ devres_free(devres);
|
|
||||||
+ return NULL;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ polldev->input->dev.parent = dev;
|
|
||||||
+ polldev->devres_managed = true;
|
|
||||||
+
|
|
||||||
+ devres->polldev = polldev;
|
|
||||||
+ devres_add(dev, devres);
|
|
||||||
+
|
|
||||||
+ return polldev;
|
|
||||||
+}
|
|
||||||
+EXPORT_SYMBOL(devm_input_allocate_polled_device);
|
|
||||||
+
|
|
||||||
+/**
|
|
||||||
+ * input_free_polled_device - free memory allocated for polled device
|
|
||||||
+ * @dev: device to free
|
|
||||||
+ *
|
|
||||||
+ * The function frees memory allocated for polling device and drops
|
|
||||||
+ * reference to the associated input device.
|
|
||||||
+ */
|
|
||||||
+void input_free_polled_device(struct input_polled_dev *dev)
|
|
||||||
+{
|
|
||||||
+ if (dev) {
|
|
||||||
+ if (dev->devres_managed)
|
|
||||||
+ WARN_ON(devres_destroy(dev->input->dev.parent,
|
|
||||||
+ devm_input_polldev_release,
|
|
||||||
+ devm_input_polldev_match,
|
|
||||||
+ dev));
|
|
||||||
+ input_put_device(dev->input);
|
|
||||||
+ kfree(dev);
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+EXPORT_SYMBOL(input_free_polled_device);
|
|
||||||
+
|
|
||||||
+/**
|
|
||||||
+ * input_register_polled_device - register polled device
|
|
||||||
+ * @dev: device to register
|
|
||||||
+ *
|
|
||||||
+ * The function registers previously initialized polled input device
|
|
||||||
+ * with input layer. The device should be allocated with call to
|
|
||||||
+ * input_allocate_polled_device(). Callers should also set up poll()
|
|
||||||
+ * method and set up capabilities (id, name, phys, bits) of the
|
|
||||||
+ * corresponding input_dev structure.
|
|
||||||
+ */
|
|
||||||
+int input_register_polled_device(struct input_polled_dev *dev)
|
|
||||||
+{
|
|
||||||
+ struct input_polled_devres *devres = NULL;
|
|
||||||
+ struct input_dev *input = dev->input;
|
|
||||||
+ int error;
|
|
||||||
+
|
|
||||||
+ if (dev->devres_managed) {
|
|
||||||
+ devres = devres_alloc(devm_input_polldev_unregister,
|
|
||||||
+ sizeof(*devres), GFP_KERNEL);
|
|
||||||
+ if (!devres)
|
|
||||||
+ return -ENOMEM;
|
|
||||||
+
|
|
||||||
+ devres->polldev = dev;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ input_set_drvdata(input, dev);
|
|
||||||
+ INIT_DELAYED_WORK(&dev->work, input_polled_device_work);
|
|
||||||
+
|
|
||||||
+ if (!dev->poll_interval)
|
|
||||||
+ dev->poll_interval = 500;
|
|
||||||
+ if (!dev->poll_interval_max)
|
|
||||||
+ dev->poll_interval_max = dev->poll_interval;
|
|
||||||
+
|
|
||||||
+ input->open = input_open_polled_device;
|
|
||||||
+ input->close = input_close_polled_device;
|
|
||||||
+
|
|
||||||
+ input->dev.groups = input_polldev_attribute_groups;
|
|
||||||
+
|
|
||||||
+ error = input_register_device(input);
|
|
||||||
+ if (error) {
|
|
||||||
+ devres_free(devres);
|
|
||||||
+ return error;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /*
|
|
||||||
+ * Take extra reference to the underlying input device so
|
|
||||||
+ * that it survives call to input_unregister_polled_device()
|
|
||||||
+ * and is deleted only after input_free_polled_device()
|
|
||||||
+ * has been invoked. This is needed to ease task of freeing
|
|
||||||
+ * sparse keymaps.
|
|
||||||
+ */
|
|
||||||
+ input_get_device(input);
|
|
||||||
+
|
|
||||||
+ if (dev->devres_managed) {
|
|
||||||
+ dev_dbg(input->dev.parent, "%s: registering %s with devres.\n",
|
|
||||||
+ __func__, dev_name(&input->dev));
|
|
||||||
+ devres_add(input->dev.parent, devres);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return 0;
|
|
||||||
+}
|
|
||||||
+EXPORT_SYMBOL(input_register_polled_device);
|
|
||||||
+
|
|
||||||
+/**
|
|
||||||
+ * input_unregister_polled_device - unregister polled device
|
|
||||||
+ * @dev: device to unregister
|
|
||||||
+ *
|
|
||||||
+ * The function unregisters previously registered polled input
|
|
||||||
+ * device from input layer. Polling is stopped and device is
|
|
||||||
+ * ready to be freed with call to input_free_polled_device().
|
|
||||||
+ */
|
|
||||||
+void input_unregister_polled_device(struct input_polled_dev *dev)
|
|
||||||
+{
|
|
||||||
+ if (dev->devres_managed)
|
|
||||||
+ WARN_ON(devres_destroy(dev->input->dev.parent,
|
|
||||||
+ devm_input_polldev_unregister,
|
|
||||||
+ devm_input_polldev_match,
|
|
||||||
+ dev));
|
|
||||||
+
|
|
||||||
+ input_unregister_device(dev->input);
|
|
||||||
+}
|
|
||||||
+EXPORT_SYMBOL(input_unregister_polled_device);
|
|
||||||
diff -rupN linux.orig/drivers/input/keyboard/gpio_keys.c linux/drivers/input/keyboard/gpio_keys.c
|
|
||||||
--- linux.orig/drivers/input/keyboard/gpio_keys.c 2024-03-02 17:57:02.768204942 +0000
|
|
||||||
+++ linux/drivers/input/keyboard/gpio_keys.c 2024-03-02 22:59:30.386988471 +0000
|
|
||||||
@@ -8,7 +8,6 @@
|
|
||||||
|
|
||||||
#include <linux/module.h>
|
|
||||||
|
|
||||||
-#include <linux/hrtimer.h>
|
|
||||||
#include <linux/init.h>
|
|
||||||
#include <linux/fs.h>
|
|
||||||
#include <linux/interrupt.h>
|
|
||||||
@@ -30,6 +29,29 @@
|
|
||||||
#include <linux/spinlock.h>
|
|
||||||
#include <dt-bindings/input/gpio-keys.h>
|
|
||||||
|
|
||||||
+#include <linux/err.h>
|
|
||||||
+#include <linux/iio/consumer.h>
|
|
||||||
+#include <linux/iio/types.h>
|
|
||||||
+#include <linux/input-polldev.h>
|
|
||||||
+#include <linux/kernel.h>
|
|
||||||
+#include <linux/module.h>
|
|
||||||
+#include <linux/property.h>
|
|
||||||
+#include <linux/of_gpio.h>
|
|
||||||
+#include <linux/device/driver.h>
|
|
||||||
+#include <linux/sysfs.h>
|
|
||||||
+#include <linux/string.h>
|
|
||||||
+#include <linux/atomic.h>
|
|
||||||
+
|
|
||||||
+static int dbg_enable = 0;
|
|
||||||
+
|
|
||||||
+#define DBG(args...) \
|
|
||||||
+ do { \
|
|
||||||
+ if (dbg_enable) { \
|
|
||||||
+ pr_info(args); \
|
|
||||||
+ } \
|
|
||||||
+ } while(0)
|
|
||||||
+
|
|
||||||
+
|
|
||||||
struct gpio_button_data {
|
|
||||||
const struct gpio_keys_button *button;
|
|
||||||
struct input_dev *input;
|
|
||||||
@@ -37,11 +59,10 @@ struct gpio_button_data {
|
|
||||||
|
|
||||||
unsigned short *code;
|
|
||||||
|
|
||||||
- struct hrtimer release_timer;
|
|
||||||
+ struct timer_list release_timer;
|
|
||||||
unsigned int release_delay; /* in msecs, for IRQ-only buttons */
|
|
||||||
|
|
||||||
struct delayed_work work;
|
|
||||||
- struct hrtimer debounce_timer;
|
|
||||||
unsigned int software_debounce; /* in msecs, for GPIO-driven buttons */
|
|
||||||
|
|
||||||
unsigned int irq;
|
|
||||||
@@ -50,7 +71,7 @@ struct gpio_button_data {
|
|
||||||
bool disabled;
|
|
||||||
bool key_pressed;
|
|
||||||
bool suspended;
|
|
||||||
- bool debounce_use_hrtimer;
|
|
||||||
+
|
|
||||||
};
|
|
||||||
|
|
||||||
struct gpio_keys_drvdata {
|
|
||||||
@@ -58,50 +79,24 @@ struct gpio_keys_drvdata {
|
|
||||||
struct input_dev *input;
|
|
||||||
struct mutex disable_lock;
|
|
||||||
unsigned short *keymap;
|
|
||||||
+
|
|
||||||
+// struct iio_channel *channelx;
|
|
||||||
+// struct iio_channel *channely;
|
|
||||||
+// struct iio_channel *channelz;
|
|
||||||
+// struct iio_channel *channelrz;
|
|
||||||
+// int num_joystick;
|
|
||||||
+
|
|
||||||
+ unsigned char now_data[4];
|
|
||||||
+ int raw_data[4];
|
|
||||||
+
|
|
||||||
+// int last_bra;
|
|
||||||
+// int last_gas;
|
|
||||||
+
|
|
||||||
struct gpio_button_data data[];
|
|
||||||
};
|
|
||||||
|
|
||||||
-/*
|
|
||||||
- * SYSFS interface for enabling/disabling keys and switches:
|
|
||||||
- *
|
|
||||||
- * There are 4 attributes under /sys/devices/platform/gpio-keys/
|
|
||||||
- * keys [ro] - bitmap of keys (EV_KEY) which can be
|
|
||||||
- * disabled
|
|
||||||
- * switches [ro] - bitmap of switches (EV_SW) which can be
|
|
||||||
- * disabled
|
|
||||||
- * disabled_keys [rw] - bitmap of keys currently disabled
|
|
||||||
- * disabled_switches [rw] - bitmap of switches currently disabled
|
|
||||||
- *
|
|
||||||
- * Userland can change these values and hence disable event generation
|
|
||||||
- * for each key (or switch). Disabling a key means its interrupt line
|
|
||||||
- * is disabled.
|
|
||||||
- *
|
|
||||||
- * For example, if we have following switches set up as gpio-keys:
|
|
||||||
- * SW_DOCK = 5
|
|
||||||
- * SW_CAMERA_LENS_COVER = 9
|
|
||||||
- * SW_KEYPAD_SLIDE = 10
|
|
||||||
- * SW_FRONT_PROXIMITY = 11
|
|
||||||
- * This is read from switches:
|
|
||||||
- * 11-9,5
|
|
||||||
- * Next we want to disable proximity (11) and dock (5), we write:
|
|
||||||
- * 11,5
|
|
||||||
- * to file disabled_switches. Now proximity and dock IRQs are disabled.
|
|
||||||
- * This can be verified by reading the file disabled_switches:
|
|
||||||
- * 11,5
|
|
||||||
- * If we now want to enable proximity (11) switch we write:
|
|
||||||
- * 5
|
|
||||||
- * to disabled_switches.
|
|
||||||
- *
|
|
||||||
- * We can disable only those keys which don't allow sharing the irq.
|
|
||||||
- */
|
|
||||||
+//static unsigned char abs_date[]={128,128,128,128};
|
|
||||||
|
|
||||||
-/**
|
|
||||||
- * get_n_events_by_type() - returns maximum number of events per @type
|
|
||||||
- * @type: type of button (%EV_KEY, %EV_SW)
|
|
||||||
- *
|
|
||||||
- * Return value of this function can be used to allocate bitmap
|
|
||||||
- * large enough to hold all bits for given type.
|
|
||||||
- */
|
|
||||||
static int get_n_events_by_type(int type)
|
|
||||||
{
|
|
||||||
BUG_ON(type != EV_SW && type != EV_KEY);
|
|
||||||
@@ -111,7 +106,7 @@ static int get_n_events_by_type(int type
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get_bm_events_by_type() - returns bitmap of supported events per @type
|
|
||||||
- * @dev: input device from which bitmap is retrieved
|
|
||||||
+ * @input: input device from which bitmap is retrieved
|
|
||||||
* @type: type of button (%EV_KEY, %EV_SW)
|
|
||||||
*
|
|
||||||
* Return value of this function can be used to allocate bitmap
|
|
||||||
@@ -125,18 +120,6 @@ static const unsigned long *get_bm_event
|
|
||||||
return (type == EV_KEY) ? dev->keybit : dev->swbit;
|
|
||||||
}
|
|
||||||
|
|
||||||
-static void gpio_keys_quiesce_key(void *data)
|
|
||||||
-{
|
|
||||||
- struct gpio_button_data *bdata = data;
|
|
||||||
-
|
|
||||||
- if (!bdata->gpiod)
|
|
||||||
- hrtimer_cancel(&bdata->release_timer);
|
|
||||||
- else if (bdata->debounce_use_hrtimer)
|
|
||||||
- hrtimer_cancel(&bdata->debounce_timer);
|
|
||||||
- else
|
|
||||||
- cancel_delayed_work_sync(&bdata->work);
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
/**
|
|
||||||
* gpio_keys_disable_button() - disables given GPIO button
|
|
||||||
* @bdata: button data for button to be disabled
|
|
||||||
@@ -157,7 +140,12 @@ static void gpio_keys_disable_button(str
|
|
||||||
* Disable IRQ and associated timer/work structure.
|
|
||||||
*/
|
|
||||||
disable_irq(bdata->irq);
|
|
||||||
- gpio_keys_quiesce_key(bdata);
|
|
||||||
+
|
|
||||||
+ if (bdata->gpiod)
|
|
||||||
+ cancel_delayed_work_sync(&bdata->work);
|
|
||||||
+ else
|
|
||||||
+ del_timer_sync(&bdata->release_timer);
|
|
||||||
+
|
|
||||||
bdata->disabled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -247,7 +235,7 @@ static ssize_t gpio_keys_attr_store_help
|
|
||||||
ssize_t error;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
- bits = bitmap_alloc(n_events, GFP_KERNEL);
|
|
||||||
+ bits = bitmap_zalloc(n_events, GFP_KERNEL);
|
|
||||||
if (!bits)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
@@ -363,16 +351,28 @@ static struct attribute *gpio_keys_attrs
|
|
||||||
};
|
|
||||||
ATTRIBUTE_GROUPS(gpio_keys);
|
|
||||||
|
|
||||||
+static void other_key_report(struct input_dev *input,unsigned int code ,int state,int value){
|
|
||||||
+ if(state)
|
|
||||||
+ {
|
|
||||||
+ printk("11111111111other_key_report code = %d,state = %d,value = %d\n",code,state,value);
|
|
||||||
+ input_report_abs(input, code,value);
|
|
||||||
+ }
|
|
||||||
+ else{
|
|
||||||
+ input_report_abs(input, code,0);
|
|
||||||
+ printk("00000000000other_key_report code = %d,state = %d,value = %d\n",code,state,value);
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
static void gpio_keys_gpio_report_event(struct gpio_button_data *bdata)
|
|
||||||
{
|
|
||||||
const struct gpio_keys_button *button = bdata->button;
|
|
||||||
struct input_dev *input = bdata->input;
|
|
||||||
unsigned int type = button->type ?: EV_KEY;
|
|
||||||
int state;
|
|
||||||
+ unsigned short code = 0;
|
|
||||||
+ state = gpiod_get_value_cansleep(bdata->gpiod);
|
|
||||||
|
|
||||||
- state = bdata->debounce_use_hrtimer ?
|
|
||||||
- gpiod_get_value(bdata->gpiod) :
|
|
||||||
- gpiod_get_value_cansleep(bdata->gpiod);
|
|
||||||
+ printk("func = %s lqbirq state = %d,code = %d\n",__func__,state,*bdata->code);
|
|
||||||
if (state < 0) {
|
|
||||||
dev_err(input->dev.parent,
|
|
||||||
"failed to get gpio state: %d\n", state);
|
|
||||||
@@ -382,18 +382,23 @@ static void gpio_keys_gpio_report_event(
|
|
||||||
if (type == EV_ABS) {
|
|
||||||
if (state)
|
|
||||||
input_event(input, type, button->code, button->value);
|
|
||||||
+ printk("lqbirq type == EV_ABS");
|
|
||||||
} else {
|
|
||||||
- input_event(input, type, *bdata->code, state);
|
|
||||||
+ code = *bdata->code;
|
|
||||||
+ if(code < BTN_DPAD_UP || code > BTN_DPAD_RIGHT){
|
|
||||||
+ input_event(input, type, *bdata->code, state);
|
|
||||||
+ }
|
|
||||||
+ else if( code == BTN_DPAD_UP ){
|
|
||||||
+ other_key_report(input,ABS_HAT0Y,state,-1);
|
|
||||||
+ }else if(code == BTN_DPAD_DOWN){
|
|
||||||
+ other_key_report(input,ABS_HAT0Y,state,1);
|
|
||||||
+ }else if(code == BTN_DPAD_LEFT){
|
|
||||||
+ other_key_report(input,ABS_HAT0X,state,-1);
|
|
||||||
+ }else if(code == BTN_DPAD_RIGHT){
|
|
||||||
+ other_key_report(input,ABS_HAT0X,state,1);
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-static void gpio_keys_debounce_event(struct gpio_button_data *bdata)
|
|
||||||
-{
|
|
||||||
- gpio_keys_gpio_report_event(bdata);
|
|
||||||
- input_sync(bdata->input);
|
|
||||||
-
|
|
||||||
- if (bdata->button->wakeup)
|
|
||||||
- pm_relax(bdata->input->dev.parent);
|
|
||||||
+ input_sync(input);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void gpio_keys_gpio_work_func(struct work_struct *work)
|
|
||||||
@@ -401,17 +406,10 @@ static void gpio_keys_gpio_work_func(str
|
|
||||||
struct gpio_button_data *bdata =
|
|
||||||
container_of(work, struct gpio_button_data, work.work);
|
|
||||||
|
|
||||||
- gpio_keys_debounce_event(bdata);
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-static enum hrtimer_restart gpio_keys_debounce_timer(struct hrtimer *t)
|
|
||||||
-{
|
|
||||||
- struct gpio_button_data *bdata =
|
|
||||||
- container_of(t, struct gpio_button_data, debounce_timer);
|
|
||||||
-
|
|
||||||
- gpio_keys_debounce_event(bdata);
|
|
||||||
+ gpio_keys_gpio_report_event(bdata);
|
|
||||||
|
|
||||||
- return HRTIMER_NORESTART;
|
|
||||||
+ if (bdata->button->wakeup)
|
|
||||||
+ pm_relax(bdata->input->dev.parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
static irqreturn_t gpio_keys_gpio_isr(int irq, void *dev_id)
|
|
||||||
@@ -419,7 +417,7 @@ static irqreturn_t gpio_keys_gpio_isr(in
|
|
||||||
struct gpio_button_data *bdata = dev_id;
|
|
||||||
|
|
||||||
BUG_ON(irq != bdata->irq);
|
|
||||||
-
|
|
||||||
+ DBG("lqbirq func = %s\n,irq = %d\n",__func__,irq);
|
|
||||||
if (bdata->button->wakeup) {
|
|
||||||
const struct gpio_keys_button *button = bdata->button;
|
|
||||||
|
|
||||||
@@ -435,33 +433,25 @@ static irqreturn_t gpio_keys_gpio_isr(in
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- if (bdata->debounce_use_hrtimer) {
|
|
||||||
- hrtimer_start(&bdata->debounce_timer,
|
|
||||||
- ms_to_ktime(bdata->software_debounce),
|
|
||||||
- HRTIMER_MODE_REL);
|
|
||||||
- } else {
|
|
||||||
- mod_delayed_work(system_wq,
|
|
||||||
- &bdata->work,
|
|
||||||
- msecs_to_jiffies(bdata->software_debounce));
|
|
||||||
- }
|
|
||||||
+ mod_delayed_work(system_wq,
|
|
||||||
+ &bdata->work,
|
|
||||||
+ msecs_to_jiffies(bdata->software_debounce));
|
|
||||||
|
|
||||||
return IRQ_HANDLED;
|
|
||||||
}
|
|
||||||
|
|
||||||
-static enum hrtimer_restart gpio_keys_irq_timer(struct hrtimer *t)
|
|
||||||
+static void gpio_keys_irq_timer(struct timer_list *t)
|
|
||||||
{
|
|
||||||
- struct gpio_button_data *bdata = container_of(t,
|
|
||||||
- struct gpio_button_data,
|
|
||||||
- release_timer);
|
|
||||||
+ struct gpio_button_data *bdata = from_timer(bdata, t, release_timer);
|
|
||||||
struct input_dev *input = bdata->input;
|
|
||||||
-
|
|
||||||
+ unsigned long flags;
|
|
||||||
+ spin_lock_irqsave(&bdata->lock, flags);
|
|
||||||
if (bdata->key_pressed) {
|
|
||||||
input_event(input, EV_KEY, *bdata->code, 0);
|
|
||||||
input_sync(input);
|
|
||||||
bdata->key_pressed = false;
|
|
||||||
}
|
|
||||||
-
|
|
||||||
- return HRTIMER_NORESTART;
|
|
||||||
+ spin_unlock_irqrestore(&bdata->lock, flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
static irqreturn_t gpio_keys_irq_isr(int irq, void *dev_id)
|
|
||||||
@@ -471,9 +461,9 @@ static irqreturn_t gpio_keys_irq_isr(int
|
|
||||||
unsigned long flags;
|
|
||||||
|
|
||||||
BUG_ON(irq != bdata->irq);
|
|
||||||
+ DBG("func = %s,lqbjoystick irq = %d\n",__func__,irq);
|
|
||||||
|
|
||||||
spin_lock_irqsave(&bdata->lock, flags);
|
|
||||||
-
|
|
||||||
if (!bdata->key_pressed) {
|
|
||||||
if (bdata->button->wakeup)
|
|
||||||
pm_wakeup_event(bdata->input->dev.parent, 0);
|
|
||||||
@@ -491,14 +481,22 @@ static irqreturn_t gpio_keys_irq_isr(int
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bdata->release_delay)
|
|
||||||
- hrtimer_start(&bdata->release_timer,
|
|
||||||
- ms_to_ktime(bdata->release_delay),
|
|
||||||
- HRTIMER_MODE_REL_HARD);
|
|
||||||
+ mod_timer(&bdata->release_timer,
|
|
||||||
+ jiffies + msecs_to_jiffies(bdata->release_delay));
|
|
||||||
out:
|
|
||||||
spin_unlock_irqrestore(&bdata->lock, flags);
|
|
||||||
return IRQ_HANDLED;
|
|
||||||
}
|
|
||||||
|
|
||||||
+static void gpio_keys_quiesce_key(void *data)
|
|
||||||
+{
|
|
||||||
+ struct gpio_button_data *bdata = data;
|
|
||||||
+ if (bdata->gpiod)
|
|
||||||
+ cancel_delayed_work_sync(&bdata->work);
|
|
||||||
+ else
|
|
||||||
+ del_timer_sync(&bdata->release_timer);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
static int gpio_keys_setup_key(struct platform_device *pdev,
|
|
||||||
struct input_dev *input,
|
|
||||||
struct gpio_keys_drvdata *ddata,
|
|
||||||
@@ -568,20 +566,13 @@ static int gpio_keys_setup_key(struct pl
|
|
||||||
if (error < 0)
|
|
||||||
bdata->software_debounce =
|
|
||||||
button->debounce_interval;
|
|
||||||
-
|
|
||||||
- /*
|
|
||||||
- * If reading the GPIO won't sleep, we can use a
|
|
||||||
- * hrtimer instead of a standard timer for the software
|
|
||||||
- * debounce, to reduce the latency as much as possible.
|
|
||||||
- */
|
|
||||||
- bdata->debounce_use_hrtimer =
|
|
||||||
- !gpiod_cansleep(bdata->gpiod);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (button->irq) {
|
|
||||||
bdata->irq = button->irq;
|
|
||||||
} else {
|
|
||||||
irq = gpiod_to_irq(bdata->gpiod);
|
|
||||||
+
|
|
||||||
if (irq < 0) {
|
|
||||||
error = irq;
|
|
||||||
dev_err(dev,
|
|
||||||
@@ -594,10 +585,6 @@ static int gpio_keys_setup_key(struct pl
|
|
||||||
|
|
||||||
INIT_DELAYED_WORK(&bdata->work, gpio_keys_gpio_work_func);
|
|
||||||
|
|
||||||
- hrtimer_init(&bdata->debounce_timer,
|
|
||||||
- CLOCK_REALTIME, HRTIMER_MODE_REL);
|
|
||||||
- bdata->debounce_timer.function = gpio_keys_debounce_timer;
|
|
||||||
-
|
|
||||||
isr = gpio_keys_gpio_isr;
|
|
||||||
irqflags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING;
|
|
||||||
|
|
||||||
@@ -632,9 +619,7 @@ static int gpio_keys_setup_key(struct pl
|
|
||||||
}
|
|
||||||
|
|
||||||
bdata->release_delay = button->debounce_interval;
|
|
||||||
- hrtimer_init(&bdata->release_timer,
|
|
||||||
- CLOCK_REALTIME, HRTIMER_MODE_REL_HARD);
|
|
||||||
- bdata->release_timer.function = gpio_keys_irq_timer;
|
|
||||||
+ timer_setup(&bdata->release_timer, gpio_keys_irq_timer, 0);
|
|
||||||
|
|
||||||
isr = gpio_keys_irq_isr;
|
|
||||||
irqflags = 0;
|
|
||||||
@@ -804,9 +789,12 @@ static int gpio_keys_probe(struct platfo
|
|
||||||
struct fwnode_handle *child = NULL;
|
|
||||||
struct gpio_keys_drvdata *ddata;
|
|
||||||
struct input_dev *input;
|
|
||||||
+
|
|
||||||
+ int value;
|
|
||||||
+ enum iio_chan_type type;
|
|
||||||
int i, error;
|
|
||||||
int wakeup = 0;
|
|
||||||
-
|
|
||||||
+ DBG("lqb func = %s\n",__func__);
|
|
||||||
if (!pdata) {
|
|
||||||
pdata = gpio_keys_get_devtree_pdata(dev);
|
|
||||||
if (IS_ERR(pdata))
|
|
||||||
@@ -819,6 +807,7 @@ static int gpio_keys_probe(struct platfo
|
|
||||||
dev_err(dev, "failed to allocate state\n");
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
+ dev_set_drvdata(&pdev->dev,ddata);
|
|
||||||
|
|
||||||
ddata->keymap = devm_kcalloc(dev,
|
|
||||||
pdata->nbuttons, sizeof(ddata->keymap[0]),
|
|
||||||
@@ -831,6 +820,15 @@ static int gpio_keys_probe(struct platfo
|
|
||||||
dev_err(dev, "failed to allocate input device\n");
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
+ //error = input_setup_polling(input, adc_joystick_poll);
|
|
||||||
+ //if (error) {
|
|
||||||
+ // dev_err(dev, "Unable to set up polling: %d\n", error);
|
|
||||||
+ // return error;
|
|
||||||
+ //}
|
|
||||||
+ //if (!device_property_read_u32(dev, "poll-interval", &value))
|
|
||||||
+ //{
|
|
||||||
+ // input_set_poll_interval(input, value);
|
|
||||||
+ //}
|
|
||||||
|
|
||||||
ddata->pdata = pdata;
|
|
||||||
ddata->input = input;
|
|
||||||
@@ -839,21 +837,57 @@ static int gpio_keys_probe(struct platfo
|
|
||||||
platform_set_drvdata(pdev, ddata);
|
|
||||||
input_set_drvdata(input, ddata);
|
|
||||||
|
|
||||||
- input->name = pdata->name ? : pdev->name;
|
|
||||||
- input->phys = "gpio-keys/input0";
|
|
||||||
+// input->name = "Microsoft X-Box 360 pad";
|
|
||||||
+ input->name = "gpio-keys-control";
|
|
||||||
+
|
|
||||||
input->dev.parent = dev;
|
|
||||||
input->open = gpio_keys_open;
|
|
||||||
input->close = gpio_keys_close;
|
|
||||||
|
|
||||||
input->id.bustype = BUS_HOST;
|
|
||||||
- input->id.vendor = 0x0001;
|
|
||||||
- input->id.product = 0x0001;
|
|
||||||
- input->id.version = 0x0100;
|
|
||||||
+// input->id.bustype = BUS_USB;
|
|
||||||
+
|
|
||||||
+ input->id.vendor = 0x0003;
|
|
||||||
+ input->id.product = 0x0003;
|
|
||||||
+
|
|
||||||
+// input->id.vendor = 0x045e;
|
|
||||||
+// input->id.product = 0x0032;
|
|
||||||
+// input->id.product = 0x0b13;
|
|
||||||
+
|
|
||||||
+ input->id.version = 0x0110;
|
|
||||||
|
|
||||||
input->keycode = ddata->keymap;
|
|
||||||
input->keycodesize = sizeof(ddata->keymap[0]);
|
|
||||||
input->keycodemax = pdata->nbuttons;
|
|
||||||
|
|
||||||
+ __set_bit(EV_ABS, input->evbit);
|
|
||||||
+// __set_bit(ABS_BRAKE, input->absbit);
|
|
||||||
+// __set_bit(ABS_THROTTLE, input->absbit);
|
|
||||||
+ __set_bit(ABS_HAT0Y, input->absbit);
|
|
||||||
+ __set_bit(ABS_HAT0X, input->absbit);
|
|
||||||
+// __set_bit(ABS_X, input->absbit);
|
|
||||||
+// __set_bit(ABS_Y, input->absbit);
|
|
||||||
+// __set_bit(ABS_RX, input->absbit);
|
|
||||||
+// __set_bit(ABS_RY, input->absbit);
|
|
||||||
+// __set_bit(ABS_RZ, input->absbit);
|
|
||||||
+// __set_bit(ABS_Z, input->absbit);
|
|
||||||
+
|
|
||||||
+// __set_bit(BTN_TL2, input->keybit);
|
|
||||||
+// __set_bit(BTN_TR2, input->keybit);
|
|
||||||
+
|
|
||||||
+// input_set_abs_params(input, ABS_X, 0, 255, 0, 15);
|
|
||||||
+// input_set_abs_params(input, ABS_RX, 0, 255, 0, 15);
|
|
||||||
+// input_set_abs_params(input, ABS_RY, 0, 255, 0, 15);
|
|
||||||
+// input_set_abs_params(input, ABS_Y, 0, 255, 0, 15);
|
|
||||||
+// input_set_abs_params(input, ABS_Z, 0, 255, 0, 15);
|
|
||||||
+// input_set_abs_params(input, ABS_RZ, 0, 255, 0, 15);
|
|
||||||
+// input_set_abs_params(input, ABS_BRAKE, 0, 255, 0, 15);
|
|
||||||
+// input_set_abs_params(input, ABS_THROTTLE, 0, 255, 0, 15);
|
|
||||||
+ //0xff : up , 0x01 : down
|
|
||||||
+ input_set_abs_params(input, ABS_HAT0Y, -1, 1, 0, 0);
|
|
||||||
+ //0xff : left , 0x01 : right
|
|
||||||
+ input_set_abs_params(input, ABS_HAT0X, -1, 1, 0, 0);
|
|
||||||
+
|
|
||||||
/* Enable auto repeat feature of Linux input subsystem */
|
|
||||||
if (pdata->rep)
|
|
||||||
__set_bit(EV_REP, input->evbit);
|
|
||||||
@@ -1004,7 +1038,7 @@ static int __maybe_unused gpio_keys_susp
|
|
||||||
return error;
|
|
||||||
} else {
|
|
||||||
mutex_lock(&input->mutex);
|
|
||||||
- if (input_device_enabled(input))
|
|
||||||
+ if (input->users)
|
|
||||||
gpio_keys_close(input);
|
|
||||||
mutex_unlock(&input->mutex);
|
|
||||||
}
|
|
||||||
@@ -1022,7 +1056,7 @@ static int __maybe_unused gpio_keys_resu
|
|
||||||
gpio_keys_disable_wakeup(ddata);
|
|
||||||
} else {
|
|
||||||
mutex_lock(&input->mutex);
|
|
||||||
- if (input_device_enabled(input))
|
|
||||||
+ if (input->users)
|
|
||||||
error = gpio_keys_open(input);
|
|
||||||
mutex_unlock(&input->mutex);
|
|
||||||
}
|
|
||||||
diff -rupN linux.orig/include/linux/input-polldev.h linux/include/linux/input-polldev.h
|
|
||||||
--- linux.orig/include/linux/input-polldev.h 1970-01-01 00:00:00.000000000 +0000
|
|
||||||
+++ linux/include/linux/input-polldev.h 2024-03-02 18:10:15.311564040 +0000
|
|
||||||
@@ -0,0 +1,58 @@
|
|
||||||
+/* SPDX-License-Identifier: GPL-2.0-only */
|
|
||||||
+#ifndef _INPUT_POLLDEV_H
|
|
||||||
+#define _INPUT_POLLDEV_H
|
|
||||||
+
|
|
||||||
+/*
|
|
||||||
+ * Copyright (c) 2007 Dmitry Torokhov
|
|
||||||
+ */
|
|
||||||
+
|
|
||||||
+#include <linux/input.h>
|
|
||||||
+#include <linux/workqueue.h>
|
|
||||||
+
|
|
||||||
+/**
|
|
||||||
+ * struct input_polled_dev - simple polled input device
|
|
||||||
+ * @private: private driver data.
|
|
||||||
+ * @open: driver-supplied method that prepares device for polling
|
|
||||||
+ * (enabled the device and maybe flushes device state).
|
|
||||||
+ * @close: driver-supplied method that is called when device is no
|
|
||||||
+ * longer being polled. Used to put device into low power mode.
|
|
||||||
+ * @poll: driver-supplied method that polls the device and posts
|
|
||||||
+ * input events (mandatory).
|
|
||||||
+ * @poll_interval: specifies how often the poll() method should be called.
|
|
||||||
+ * Defaults to 500 msec unless overridden when registering the device.
|
|
||||||
+ * @poll_interval_max: specifies upper bound for the poll interval.
|
|
||||||
+ * Defaults to the initial value of @poll_interval.
|
|
||||||
+ * @poll_interval_min: specifies lower bound for the poll interval.
|
|
||||||
+ * Defaults to 0.
|
|
||||||
+ * @input: input device structure associated with the polled device.
|
|
||||||
+ * Must be properly initialized by the driver (id, name, phys, bits).
|
|
||||||
+ *
|
|
||||||
+ * Polled input device provides a skeleton for supporting simple input
|
|
||||||
+ * devices that do not raise interrupts but have to be periodically
|
|
||||||
+ * scanned or polled to detect changes in their state.
|
|
||||||
+ */
|
|
||||||
+struct input_polled_dev {
|
|
||||||
+ void *private;
|
|
||||||
+
|
|
||||||
+ void (*open)(struct input_polled_dev *dev);
|
|
||||||
+ void (*close)(struct input_polled_dev *dev);
|
|
||||||
+ void (*poll)(struct input_polled_dev *dev);
|
|
||||||
+ unsigned int poll_interval; /* msec */
|
|
||||||
+ unsigned int poll_interval_max; /* msec */
|
|
||||||
+ unsigned int poll_interval_min; /* msec */
|
|
||||||
+
|
|
||||||
+ struct input_dev *input;
|
|
||||||
+
|
|
||||||
+/* private: */
|
|
||||||
+ struct delayed_work work;
|
|
||||||
+
|
|
||||||
+ bool devres_managed;
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
+struct input_polled_dev *input_allocate_polled_device(void);
|
|
||||||
+struct input_polled_dev *devm_input_allocate_polled_device(struct device *dev);
|
|
||||||
+void input_free_polled_device(struct input_polled_dev *dev);
|
|
||||||
+int input_register_polled_device(struct input_polled_dev *dev);
|
|
||||||
+void input_unregister_polled_device(struct input_polled_dev *dev);
|
|
||||||
+
|
|
||||||
+#endif
|
|
|
@ -0,0 +1,485 @@
|
||||||
|
From bb62799748bd5492d80e9ebee4ac6b5702fb037e Mon Sep 17 00:00:00 2001
|
||||||
|
From: brooksytech <1673861+brooksytech@users.noreply.github.com>
|
||||||
|
Date: Wed, 24 Jan 2024 21:50:05 +0000
|
||||||
|
Subject: [PATCH 14/46] input: add input-polldev driver
|
||||||
|
|
||||||
|
---
|
||||||
|
drivers/input/Kconfig | 13 ++
|
||||||
|
drivers/input/Makefile | 1 +
|
||||||
|
drivers/input/input-polldev.c | 362 ++++++++++++++++++++++++++++++++++
|
||||||
|
include/linux/input-polldev.h | 58 ++++++
|
||||||
|
4 files changed, 434 insertions(+)
|
||||||
|
create mode 100644 drivers/input/input-polldev.c
|
||||||
|
create mode 100644 include/linux/input-polldev.h
|
||||||
|
|
||||||
|
diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig
|
||||||
|
index 3bdbd34314b3..779daf5009c1 100644
|
||||||
|
--- a/drivers/input/Kconfig
|
||||||
|
+++ b/drivers/input/Kconfig
|
||||||
|
@@ -51,6 +51,19 @@ config INPUT_FF_MEMLESS
|
||||||
|
To compile this driver as a module, choose M here: the
|
||||||
|
module will be called ff-memless.
|
||||||
|
|
||||||
|
+config INPUT_POLLDEV
|
||||||
|
+ tristate "Polled input device skeleton"
|
||||||
|
+ help
|
||||||
|
+ Say Y here if you are using a driver for an input
|
||||||
|
+ device that periodically polls hardware state. This
|
||||||
|
+ option is only useful for out-of-tree drivers since
|
||||||
|
+ in-tree drivers select it automatically.
|
||||||
|
+
|
||||||
|
+ If unsure, say N.
|
||||||
|
+
|
||||||
|
+ To compile this driver as a module, choose M here: the
|
||||||
|
+ module will be called input-polldev.
|
||||||
|
+
|
||||||
|
config INPUT_SPARSEKMAP
|
||||||
|
tristate "Sparse keymap support library"
|
||||||
|
help
|
||||||
|
diff --git a/drivers/input/Makefile b/drivers/input/Makefile
|
||||||
|
index c78753274921..e92c29174c36 100644
|
||||||
|
--- a/drivers/input/Makefile
|
||||||
|
+++ b/drivers/input/Makefile
|
||||||
|
@@ -10,6 +10,7 @@ input-core-y := input.o input-compat.o input-mt.o input-poller.o ff-core.o
|
||||||
|
input-core-y += touchscreen.o
|
||||||
|
|
||||||
|
obj-$(CONFIG_INPUT_FF_MEMLESS) += ff-memless.o
|
||||||
|
+obj-$(CONFIG_INPUT_POLLDEV) += input-polldev.o
|
||||||
|
obj-$(CONFIG_INPUT_SPARSEKMAP) += sparse-keymap.o
|
||||||
|
obj-$(CONFIG_INPUT_MATRIXKMAP) += matrix-keymap.o
|
||||||
|
obj-$(CONFIG_INPUT_VIVALDIFMAP) += vivaldi-fmap.o
|
||||||
|
diff --git a/drivers/input/input-polldev.c b/drivers/input/input-polldev.c
|
||||||
|
new file mode 100644
|
||||||
|
index 000000000000..9bf1c9aeb4c4
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/drivers/input/input-polldev.c
|
||||||
|
@@ -0,0 +1,362 @@
|
||||||
|
+// SPDX-License-Identifier: GPL-2.0-only
|
||||||
|
+/*
|
||||||
|
+ * Generic implementation of a polled input device
|
||||||
|
+
|
||||||
|
+ * Copyright (c) 2007 Dmitry Torokhov
|
||||||
|
+ */
|
||||||
|
+
|
||||||
|
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
||||||
|
+
|
||||||
|
+#include <linux/jiffies.h>
|
||||||
|
+#include <linux/slab.h>
|
||||||
|
+#include <linux/mutex.h>
|
||||||
|
+#include <linux/workqueue.h>
|
||||||
|
+#include <linux/module.h>
|
||||||
|
+#include <linux/input-polldev.h>
|
||||||
|
+
|
||||||
|
+MODULE_AUTHOR("Dmitry Torokhov <dtor@mail.ru>");
|
||||||
|
+MODULE_DESCRIPTION("Generic implementation of a polled input device");
|
||||||
|
+MODULE_LICENSE("GPL v2");
|
||||||
|
+
|
||||||
|
+static void input_polldev_queue_work(struct input_polled_dev *dev)
|
||||||
|
+{
|
||||||
|
+ unsigned long delay;
|
||||||
|
+
|
||||||
|
+ delay = msecs_to_jiffies(dev->poll_interval);
|
||||||
|
+ if (delay >= HZ)
|
||||||
|
+ delay = round_jiffies_relative(delay);
|
||||||
|
+
|
||||||
|
+ queue_delayed_work(system_freezable_wq, &dev->work, delay);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void input_polled_device_work(struct work_struct *work)
|
||||||
|
+{
|
||||||
|
+ struct input_polled_dev *dev =
|
||||||
|
+ container_of(work, struct input_polled_dev, work.work);
|
||||||
|
+
|
||||||
|
+ dev->poll(dev);
|
||||||
|
+ input_polldev_queue_work(dev);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int input_open_polled_device(struct input_dev *input)
|
||||||
|
+{
|
||||||
|
+ struct input_polled_dev *dev = input_get_drvdata(input);
|
||||||
|
+
|
||||||
|
+ if (dev->open)
|
||||||
|
+ dev->open(dev);
|
||||||
|
+
|
||||||
|
+ /* Only start polling if polling is enabled */
|
||||||
|
+ if (dev->poll_interval > 0) {
|
||||||
|
+ dev->poll(dev);
|
||||||
|
+ input_polldev_queue_work(dev);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void input_close_polled_device(struct input_dev *input)
|
||||||
|
+{
|
||||||
|
+ struct input_polled_dev *dev = input_get_drvdata(input);
|
||||||
|
+
|
||||||
|
+ cancel_delayed_work_sync(&dev->work);
|
||||||
|
+
|
||||||
|
+ if (dev->close)
|
||||||
|
+ dev->close(dev);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/* SYSFS interface */
|
||||||
|
+
|
||||||
|
+static ssize_t input_polldev_get_poll(struct device *dev,
|
||||||
|
+ struct device_attribute *attr, char *buf)
|
||||||
|
+{
|
||||||
|
+ struct input_polled_dev *polldev = dev_get_drvdata(dev);
|
||||||
|
+
|
||||||
|
+ return sprintf(buf, "%d\n", polldev->poll_interval);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static ssize_t input_polldev_set_poll(struct device *dev,
|
||||||
|
+ struct device_attribute *attr, const char *buf,
|
||||||
|
+ size_t count)
|
||||||
|
+{
|
||||||
|
+ struct input_polled_dev *polldev = dev_get_drvdata(dev);
|
||||||
|
+ struct input_dev *input = polldev->input;
|
||||||
|
+ unsigned int interval;
|
||||||
|
+ int err;
|
||||||
|
+
|
||||||
|
+ err = kstrtouint(buf, 0, &interval);
|
||||||
|
+ if (err)
|
||||||
|
+ return err;
|
||||||
|
+
|
||||||
|
+ if (interval < polldev->poll_interval_min)
|
||||||
|
+ return -EINVAL;
|
||||||
|
+
|
||||||
|
+ if (interval > polldev->poll_interval_max)
|
||||||
|
+ return -EINVAL;
|
||||||
|
+
|
||||||
|
+ mutex_lock(&input->mutex);
|
||||||
|
+
|
||||||
|
+ polldev->poll_interval = interval;
|
||||||
|
+
|
||||||
|
+ if (input->users) {
|
||||||
|
+ cancel_delayed_work_sync(&polldev->work);
|
||||||
|
+ if (polldev->poll_interval > 0)
|
||||||
|
+ input_polldev_queue_work(polldev);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ mutex_unlock(&input->mutex);
|
||||||
|
+
|
||||||
|
+ return count;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static DEVICE_ATTR(poll, S_IRUGO | S_IWUSR, input_polldev_get_poll,
|
||||||
|
+ input_polldev_set_poll);
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+static ssize_t input_polldev_get_max(struct device *dev,
|
||||||
|
+ struct device_attribute *attr, char *buf)
|
||||||
|
+{
|
||||||
|
+ struct input_polled_dev *polldev = dev_get_drvdata(dev);
|
||||||
|
+
|
||||||
|
+ return sprintf(buf, "%d\n", polldev->poll_interval_max);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static DEVICE_ATTR(max, S_IRUGO, input_polldev_get_max, NULL);
|
||||||
|
+
|
||||||
|
+static ssize_t input_polldev_get_min(struct device *dev,
|
||||||
|
+ struct device_attribute *attr, char *buf)
|
||||||
|
+{
|
||||||
|
+ struct input_polled_dev *polldev = dev_get_drvdata(dev);
|
||||||
|
+
|
||||||
|
+ return sprintf(buf, "%d\n", polldev->poll_interval_min);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static DEVICE_ATTR(min, S_IRUGO, input_polldev_get_min, NULL);
|
||||||
|
+
|
||||||
|
+static struct attribute *sysfs_attrs[] = {
|
||||||
|
+ &dev_attr_poll.attr,
|
||||||
|
+ &dev_attr_max.attr,
|
||||||
|
+ &dev_attr_min.attr,
|
||||||
|
+ NULL
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+static struct attribute_group input_polldev_attribute_group = {
|
||||||
|
+ .attrs = sysfs_attrs
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+static const struct attribute_group *input_polldev_attribute_groups[] = {
|
||||||
|
+ &input_polldev_attribute_group,
|
||||||
|
+ NULL
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * input_allocate_polled_device - allocate memory for polled device
|
||||||
|
+ *
|
||||||
|
+ * The function allocates memory for a polled device and also
|
||||||
|
+ * for an input device associated with this polled device.
|
||||||
|
+ */
|
||||||
|
+struct input_polled_dev *input_allocate_polled_device(void)
|
||||||
|
+{
|
||||||
|
+ struct input_polled_dev *dev;
|
||||||
|
+
|
||||||
|
+ dev = kzalloc(sizeof(struct input_polled_dev), GFP_KERNEL);
|
||||||
|
+ if (!dev)
|
||||||
|
+ return NULL;
|
||||||
|
+
|
||||||
|
+ dev->input = input_allocate_device();
|
||||||
|
+ if (!dev->input) {
|
||||||
|
+ kfree(dev);
|
||||||
|
+ return NULL;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return dev;
|
||||||
|
+}
|
||||||
|
+EXPORT_SYMBOL(input_allocate_polled_device);
|
||||||
|
+
|
||||||
|
+struct input_polled_devres {
|
||||||
|
+ struct input_polled_dev *polldev;
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+static int devm_input_polldev_match(struct device *dev, void *res, void *data)
|
||||||
|
+{
|
||||||
|
+ struct input_polled_devres *devres = res;
|
||||||
|
+
|
||||||
|
+ return devres->polldev == data;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void devm_input_polldev_release(struct device *dev, void *res)
|
||||||
|
+{
|
||||||
|
+ struct input_polled_devres *devres = res;
|
||||||
|
+ struct input_polled_dev *polldev = devres->polldev;
|
||||||
|
+
|
||||||
|
+ dev_dbg(dev, "%s: dropping reference/freeing %s\n",
|
||||||
|
+ __func__, dev_name(&polldev->input->dev));
|
||||||
|
+
|
||||||
|
+ input_put_device(polldev->input);
|
||||||
|
+ kfree(polldev);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void devm_input_polldev_unregister(struct device *dev, void *res)
|
||||||
|
+{
|
||||||
|
+ struct input_polled_devres *devres = res;
|
||||||
|
+ struct input_polled_dev *polldev = devres->polldev;
|
||||||
|
+
|
||||||
|
+ dev_dbg(dev, "%s: unregistering device %s\n",
|
||||||
|
+ __func__, dev_name(&polldev->input->dev));
|
||||||
|
+ input_unregister_device(polldev->input);
|
||||||
|
+
|
||||||
|
+ /*
|
||||||
|
+ * Note that we are still holding extra reference to the input
|
||||||
|
+ * device so it will stick around until devm_input_polldev_release()
|
||||||
|
+ * is called.
|
||||||
|
+ */
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * devm_input_allocate_polled_device - allocate managed polled device
|
||||||
|
+ * @dev: device owning the polled device being created
|
||||||
|
+ *
|
||||||
|
+ * Returns prepared &struct input_polled_dev or %NULL.
|
||||||
|
+ *
|
||||||
|
+ * Managed polled input devices do not need to be explicitly unregistered
|
||||||
|
+ * or freed as it will be done automatically when owner device unbinds
|
||||||
|
+ * from * its driver (or binding fails). Once such managed polled device
|
||||||
|
+ * is allocated, it is ready to be set up and registered in the same
|
||||||
|
+ * fashion as regular polled input devices (using
|
||||||
|
+ * input_register_polled_device() function).
|
||||||
|
+ *
|
||||||
|
+ * If you want to manually unregister and free such managed polled devices,
|
||||||
|
+ * it can be still done by calling input_unregister_polled_device() and
|
||||||
|
+ * input_free_polled_device(), although it is rarely needed.
|
||||||
|
+ *
|
||||||
|
+ * NOTE: the owner device is set up as parent of input device and users
|
||||||
|
+ * should not override it.
|
||||||
|
+ */
|
||||||
|
+struct input_polled_dev *devm_input_allocate_polled_device(struct device *dev)
|
||||||
|
+{
|
||||||
|
+ struct input_polled_dev *polldev;
|
||||||
|
+ struct input_polled_devres *devres;
|
||||||
|
+
|
||||||
|
+ devres = devres_alloc(devm_input_polldev_release, sizeof(*devres),
|
||||||
|
+ GFP_KERNEL);
|
||||||
|
+ if (!devres)
|
||||||
|
+ return NULL;
|
||||||
|
+
|
||||||
|
+ polldev = input_allocate_polled_device();
|
||||||
|
+ if (!polldev) {
|
||||||
|
+ devres_free(devres);
|
||||||
|
+ return NULL;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ polldev->input->dev.parent = dev;
|
||||||
|
+ polldev->devres_managed = true;
|
||||||
|
+
|
||||||
|
+ devres->polldev = polldev;
|
||||||
|
+ devres_add(dev, devres);
|
||||||
|
+
|
||||||
|
+ return polldev;
|
||||||
|
+}
|
||||||
|
+EXPORT_SYMBOL(devm_input_allocate_polled_device);
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * input_free_polled_device - free memory allocated for polled device
|
||||||
|
+ * @dev: device to free
|
||||||
|
+ *
|
||||||
|
+ * The function frees memory allocated for polling device and drops
|
||||||
|
+ * reference to the associated input device.
|
||||||
|
+ */
|
||||||
|
+void input_free_polled_device(struct input_polled_dev *dev)
|
||||||
|
+{
|
||||||
|
+ if (dev) {
|
||||||
|
+ if (dev->devres_managed)
|
||||||
|
+ WARN_ON(devres_destroy(dev->input->dev.parent,
|
||||||
|
+ devm_input_polldev_release,
|
||||||
|
+ devm_input_polldev_match,
|
||||||
|
+ dev));
|
||||||
|
+ input_put_device(dev->input);
|
||||||
|
+ kfree(dev);
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+EXPORT_SYMBOL(input_free_polled_device);
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * input_register_polled_device - register polled device
|
||||||
|
+ * @dev: device to register
|
||||||
|
+ *
|
||||||
|
+ * The function registers previously initialized polled input device
|
||||||
|
+ * with input layer. The device should be allocated with call to
|
||||||
|
+ * input_allocate_polled_device(). Callers should also set up poll()
|
||||||
|
+ * method and set up capabilities (id, name, phys, bits) of the
|
||||||
|
+ * corresponding input_dev structure.
|
||||||
|
+ */
|
||||||
|
+int input_register_polled_device(struct input_polled_dev *dev)
|
||||||
|
+{
|
||||||
|
+ struct input_polled_devres *devres = NULL;
|
||||||
|
+ struct input_dev *input = dev->input;
|
||||||
|
+ int error;
|
||||||
|
+
|
||||||
|
+ if (dev->devres_managed) {
|
||||||
|
+ devres = devres_alloc(devm_input_polldev_unregister,
|
||||||
|
+ sizeof(*devres), GFP_KERNEL);
|
||||||
|
+ if (!devres)
|
||||||
|
+ return -ENOMEM;
|
||||||
|
+
|
||||||
|
+ devres->polldev = dev;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ input_set_drvdata(input, dev);
|
||||||
|
+ INIT_DELAYED_WORK(&dev->work, input_polled_device_work);
|
||||||
|
+
|
||||||
|
+ if (!dev->poll_interval)
|
||||||
|
+ dev->poll_interval = 500;
|
||||||
|
+ if (!dev->poll_interval_max)
|
||||||
|
+ dev->poll_interval_max = dev->poll_interval;
|
||||||
|
+
|
||||||
|
+ input->open = input_open_polled_device;
|
||||||
|
+ input->close = input_close_polled_device;
|
||||||
|
+
|
||||||
|
+ input->dev.groups = input_polldev_attribute_groups;
|
||||||
|
+
|
||||||
|
+ error = input_register_device(input);
|
||||||
|
+ if (error) {
|
||||||
|
+ devres_free(devres);
|
||||||
|
+ return error;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /*
|
||||||
|
+ * Take extra reference to the underlying input device so
|
||||||
|
+ * that it survives call to input_unregister_polled_device()
|
||||||
|
+ * and is deleted only after input_free_polled_device()
|
||||||
|
+ * has been invoked. This is needed to ease task of freeing
|
||||||
|
+ * sparse keymaps.
|
||||||
|
+ */
|
||||||
|
+ input_get_device(input);
|
||||||
|
+
|
||||||
|
+ if (dev->devres_managed) {
|
||||||
|
+ dev_dbg(input->dev.parent, "%s: registering %s with devres.\n",
|
||||||
|
+ __func__, dev_name(&input->dev));
|
||||||
|
+ devres_add(input->dev.parent, devres);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+EXPORT_SYMBOL(input_register_polled_device);
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * input_unregister_polled_device - unregister polled device
|
||||||
|
+ * @dev: device to unregister
|
||||||
|
+ *
|
||||||
|
+ * The function unregisters previously registered polled input
|
||||||
|
+ * device from input layer. Polling is stopped and device is
|
||||||
|
+ * ready to be freed with call to input_free_polled_device().
|
||||||
|
+ */
|
||||||
|
+void input_unregister_polled_device(struct input_polled_dev *dev)
|
||||||
|
+{
|
||||||
|
+ if (dev->devres_managed)
|
||||||
|
+ WARN_ON(devres_destroy(dev->input->dev.parent,
|
||||||
|
+ devm_input_polldev_unregister,
|
||||||
|
+ devm_input_polldev_match,
|
||||||
|
+ dev));
|
||||||
|
+
|
||||||
|
+ input_unregister_device(dev->input);
|
||||||
|
+}
|
||||||
|
+EXPORT_SYMBOL(input_unregister_polled_device);
|
||||||
|
diff --git a/include/linux/input-polldev.h b/include/linux/input-polldev.h
|
||||||
|
new file mode 100644
|
||||||
|
index 000000000000..14821fd231c0
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/include/linux/input-polldev.h
|
||||||
|
@@ -0,0 +1,58 @@
|
||||||
|
+/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
|
+#ifndef _INPUT_POLLDEV_H
|
||||||
|
+#define _INPUT_POLLDEV_H
|
||||||
|
+
|
||||||
|
+/*
|
||||||
|
+ * Copyright (c) 2007 Dmitry Torokhov
|
||||||
|
+ */
|
||||||
|
+
|
||||||
|
+#include <linux/input.h>
|
||||||
|
+#include <linux/workqueue.h>
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * struct input_polled_dev - simple polled input device
|
||||||
|
+ * @private: private driver data.
|
||||||
|
+ * @open: driver-supplied method that prepares device for polling
|
||||||
|
+ * (enabled the device and maybe flushes device state).
|
||||||
|
+ * @close: driver-supplied method that is called when device is no
|
||||||
|
+ * longer being polled. Used to put device into low power mode.
|
||||||
|
+ * @poll: driver-supplied method that polls the device and posts
|
||||||
|
+ * input events (mandatory).
|
||||||
|
+ * @poll_interval: specifies how often the poll() method should be called.
|
||||||
|
+ * Defaults to 500 msec unless overridden when registering the device.
|
||||||
|
+ * @poll_interval_max: specifies upper bound for the poll interval.
|
||||||
|
+ * Defaults to the initial value of @poll_interval.
|
||||||
|
+ * @poll_interval_min: specifies lower bound for the poll interval.
|
||||||
|
+ * Defaults to 0.
|
||||||
|
+ * @input: input device structure associated with the polled device.
|
||||||
|
+ * Must be properly initialized by the driver (id, name, phys, bits).
|
||||||
|
+ *
|
||||||
|
+ * Polled input device provides a skeleton for supporting simple input
|
||||||
|
+ * devices that do not raise interrupts but have to be periodically
|
||||||
|
+ * scanned or polled to detect changes in their state.
|
||||||
|
+ */
|
||||||
|
+struct input_polled_dev {
|
||||||
|
+ void *private;
|
||||||
|
+
|
||||||
|
+ void (*open)(struct input_polled_dev *dev);
|
||||||
|
+ void (*close)(struct input_polled_dev *dev);
|
||||||
|
+ void (*poll)(struct input_polled_dev *dev);
|
||||||
|
+ unsigned int poll_interval; /* msec */
|
||||||
|
+ unsigned int poll_interval_max; /* msec */
|
||||||
|
+ unsigned int poll_interval_min; /* msec */
|
||||||
|
+
|
||||||
|
+ struct input_dev *input;
|
||||||
|
+
|
||||||
|
+/* private: */
|
||||||
|
+ struct delayed_work work;
|
||||||
|
+
|
||||||
|
+ bool devres_managed;
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+struct input_polled_dev *input_allocate_polled_device(void);
|
||||||
|
+struct input_polled_dev *devm_input_allocate_polled_device(struct device *dev);
|
||||||
|
+void input_free_polled_device(struct input_polled_dev *dev);
|
||||||
|
+int input_register_polled_device(struct input_polled_dev *dev);
|
||||||
|
+void input_unregister_polled_device(struct input_polled_dev *dev);
|
||||||
|
+
|
||||||
|
+#endif
|
||||||
|
--
|
||||||
|
2.34.1
|
||||||
|
|
1033
projects/Rockchip/patches/linux/RK3588-ACE/007-joypad-driver.patch
Normal file
1033
projects/Rockchip/patches/linux/RK3588-ACE/007-joypad-driver.patch
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue