本文主要是介绍高通平台通过gpio-keys添加按键到input系统,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
添加新的按键到input系统,可以直接使用gpio-keys,gpio-keys驱动相关代码已实现,我们只需通过简单配置就可以实现该功能。
dtsi添加
找到gpio_keys,在里面添加对应的按键,如下talkback_sq, 主要需要配置的有如下几项
gpios,对应原理图中的引脚
linux,input-type,上报事件的类型,我们这里选择1(EV_KEY)按键事件,定义在input-event-codes.h
linux,code,上报的事件的code
gpio_keys {compatible = "gpio-keys";input-name = "gpio-keys";pinctrl-names = "tlmm_gpio_key_active","tlmm_gpio_key_suspend";pinctrl-0 = <&gpio_key_active>;pinctrl-1 = <&gpio_key_suspend>;vol_down {label = "vol_down";gpios = <&msm_gpio 91 0x1>;linux,input-type = <1>;linux,code = <114>;gpio-key,wakeup;debounce-interval = <15>;};talkback_sq {label = "talkback_sq";gpios = <&msm_gpio 28 0x1>;linux,input-type = <1>;linux,code = <188>;gpio-key,wakeup;debounce-interval = <15>;};};
pinctrl添加
将对应的gpio添加到gpio_key
tlmm_gpio_key {gpio_key_active: gpio_key_active {mux {pins = "gpio90", "gpio91", "gpio92", "gpio95"/*, "gpio28"*/;function = "gpio";};config {pins = "gpio90", "gpio91", "gpio92", "gpio95"/*, "gpio28"*/;drive-strength = <2>;bias-pull-up;};};gpio_key_suspend: gpio_key_suspend {mux {pins = "gpio90", "gpio91", "gpio92", "gpio95"/*, "gpio28"*/;function = "gpio";};config {pins = "gpio90", "gpio91", "gpio92", "gpio95"/*, "gpio28"*/;drive-strength = <2>;bias-pull-up;};};};
配置kl文件
编辑gpio-keys.kl
这篇关于高通平台通过gpio-keys添加按键到input系统的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!