|
android 增加物理静音按键
发表于 2019-11-12 11:37:51
浏览:5490
|
回复:1
打印
只看该作者
[复制链接]
楼主
1.rk3399-firefly-aio.dts处增加一个普通的gpio按键
gpio_keys{
compatible = "gpio-keys";
#address-cells = <1>;
#size-cells = <0>;
autorepeat;
mute_key { //静音按键
label = "mute_key";
linux,code = <248>; //对应linux层按键值
gpios = <&gpio4 22 GPIO_ACTIVE_HIGH>;
};
}
2.修改android 层Generic.kl
diff --git a/frameworks/base/data/keyboards/Generic.kl b/frameworks/base/data/keyboards/Generic.kl
index 2a10bdd46d..a91bbdc5ff 100644
--- a/frameworks/base/data/keyboards/Generic.kl
+++ b/frameworks/base/data/keyboards/Generic.kl
@@ -85,8 +85,8 @@ key 62 F4
key 63 F5
key 64 F6
key 65 F7
key 68 F10
key 69 NUM_LOCK
key 70 SCROLL_LOCK
@@ -132,7 +132,7 @@ key 109 PAGE_DOWN
key 110 INSERT
key 111 FORWARD_DEL
# key 112 "KEY_MACRO"
-key 113 VOLUME_MUTE
+key 248 VOLUME_MUTE
key 114 VOLUME_DOWN
key 115 VOLUME_UP
key 116 POWER
3.编译调试,按下按键会显示音量静音和非静音,如果平凡闪动,在那证明状态反了,修改gpio_key.c上报状态;
diff --git a/kernel/drivers/input/keyboard/gpio_keys.c b/kernel/drivers/input/keyboard/gpio_keys.c
index bef317ff73..68bef48f39 100644
--- a/kernel/drivers/input/keyboard/gpio_keys.c
+++ b/kernel/drivers/input/keyboard/gpio_keys.c
@@ -348,13 +348,14 @@ static void gpio_keys_gpio_report_event(struct gpio_button_data *bdata)
return;
}
- state = (state ? 1 : 0) ^ button->active_low;
+ state = (state ? 0 : 1) ^ button->active_low;
|
|