2、功能配置
2.1、瑞芯微平台
读取按键ADC值
按住对应的ADC按键,执行以下命令即可
$ cat /sys/bus/iio/devices/iio\:device0/in_voltage*_raw
DTS配置
&adc_key {
up-key { // DTS节点名,不重复即可,无要求
linux,code = <184>; // 按键事件号,参考按键类型定义头文件填写
label = "F14"; // 按键类型,参考按键类型定义头文件填写
rockchip,adc_value = <839>; // 按键adc值
};
};
驱动目录
$
按键映射
-
按键映射文件
$ vim device/rockchip/common/rk29-keypad.kl key 184 F14
系统目录:/system/usr/keylayout/rk29-keypad.kl
格式解析:
184对应dts的linux,code
F14对应dts的label
2.2、全志平台
内核配置
$ cd lichee/linux-3.10
$ make ARCH=arm menuconfig
Device Drivers
Input device support
Generic input layer
Keyboards
softwinnner KEY BOARD support
读取按键ADC值
DTS配置
$ vim lichee/linux-3.10/arch/arm/boot/dts/sun8iw11p1.dtsi
/ {
keyboard0:keyboard{
compatible = "allwinner,keyboard_2000mv";
reg = <0x0 0x01c24400 0x0 0x400>;
interrupts = <GIC_SPI 31 IRQ_TYPE_NONE>;
status = "okay";
key_cnt = <3>; // 配置按键数量
key1 = <430 183>; // ADC电压为430mv,按键编号为183
key2 = <760 184>;
key3 = <1020 185>;
};
};
驱动目录
按键映射
$ vim android/device/softwinner/a40-p1/configs/sunxi-keyboard.kl
key 183 KEY_F13
key 184 KEY_F14
key 185 KEY_F15
2.3、Amlogic平台
驱动目录
common/drivers/amlogic/input/keyboard/adc_keypad.c
DTS配置
$ vim common/arch/arm/boot/dts/amlogic/g12b_a311d_w400.dts
/ {
adc_keypad {
compatible = "amlogic, adc_keypad";
status = "okay";
key_name = "vol-", "vol+", "home";
key_num = <1>;
io-channels = <&saradc SARADC_CH2>;
io-channel-names = "key-chan-2";
key_chan = <SARADC_CH2 SARADC_CH2 SARADC_CH2>;
key_code = <115 114 102>;
key_val = <0 266 389>; //val=voltage/1800mV*1023
key_tolerance = <40 40 40>;
};
};
-
参数说明
key_name 按键功能名 key_num 按键数量 key_chan ADC检测通道号 key_code 按键编码号 key_val ADC电压按键值 key_tolerance ADC值的误差范围
读取按键ADC值
按住对应ADC通道按键后,执行以下指令即可
$ cat /sys/bus/iio/devices/iio\:device0/in_voltage*_input
按键映射
-
按键映射文件系统路径
/vendor/usr/keylayout/Vendor_0001_Product_0001.kl
-
按键映射文件源码路径
A311D路径:device/amlogic/w400/files/Vendor_0001_Product_0001.kl
S905D3路径:device/amlogic//u202/files/Vendor_0001_Product_0001.kl