imx6需要添加4x4的矩阵键盘。本文记录添加方法。

参考链接

http://processors.wiki.ti.com/index.php/TI-Android-JB-PortingGuide

http://blog.sina.com.cn/s/blog_54aa47930102vesb.html

http://blog.csdn.net/shell_albert/article/details/46801091

http://www.kikikoo.com/uid-20768928-id-5084287.html

http://blog.csdn.net/shell_albert/article/details/46618655

添加驱动

驱动源码driver/input/keyboard/matrix_keypad.c

CONFIG_KEYBOARD_MATRIX:                                       

    Enable support for GPIO driven matrix keypad.     

    To compile this driver as a module, choose M here: the
module will be called matrix_keypad. Symbol: KEYBOARD_MATRIX [=y]
Type : tristate
Prompt: GPIO driven matrix keypad support
Defined at drivers/input/keyboard/Kconfig:224
Depends on: !S390 && INPUT [=y] && INPUT_KEYBOARD [=y] && GENERIC_GPIO [=y]
Location:
-> Device Drivers
-> Input device support
-> Generic input layer (needed for keyboard, mouse, ...) (INPUT [=y])
-> Keyboards (INPUT_KEYBOARD [=y])

添加设备

vi arch/arm/mach-mx6/board-mx6q_sabresd.c

// COL
#define SABRESD_KEY0 IMX_GPIO_NR(4, 6)
#define SABRESD_KEY1 IMX_GPIO_NR(4, 8)
#define SABRESD_KEY2 IMX_GPIO_NR(4, 10)
#define SABRESD_KEY3 IMX_GPIO_NR(4, 12)
// ROW
#define SABRESD_KEY4 IMX_GPIO_NR(4, 7)
#define SABRESD_KEY5 IMX_GPIO_NR(4, 9)
#define SABRESD_KEY6 IMX_GPIO_NR(4, 11)
#define SABRESD_KEY7 IMX_GPIO_NR(4, 13) static const uint32_t sabresd_keymap[] = {
KEY(0, 0, KEY_ESC),
KEY(0, 1, KEY_0),
KEY(0, 2, KEY_1),
KEY(0, 3, KEY_OK),
KEY(1, 0, KEY_2),
KEY(1, 1, KEY_3),
KEY(1, 2, KEY_4),
KEY(1, 3, KEY_5),
KEY(2, 0, KEY_6),
KEY(2, 1, KEY_7),
KEY(2, 2, KEY_8),
KEY(2, 3, KEY_9),
KEY(3, 0, KEY_F1),
KEY(3, 1, KEY_0),
KEY(3, 2, KEY_F2),
KEY(3, 3, KEY_F3),
}; static const struct matrix_keymap_data sabresd_keymap_data = {
.keymap = sabresd_keymap,
.keymap_size = ARRAY_SIZE(sabresd_keymap),
}; static const unsigned int sabresd_keypad_cols[] = {
SABRESD_KEY0,
SABRESD_KEY1,
SABRESD_KEY2,
SABRESD_KEY3,
}; static const unsigned int sabresd_keypad_rows[] = {
SABRESD_KEY4,
SABRESD_KEY5,
SABRESD_KEY6,
SABRESD_KEY7,
}; static struct matrix_keypad_platform_data sabresd_kpd_pdata = {
.keymap_data = &sabresd_keymap_data,
.col_gpios = sabresd_keypad_cols,
.row_gpios = sabresd_keypad_rows,
.num_col_gpios = ARRAY_SIZE(sabresd_keypad_cols),
.num_row_gpios = ARRAY_SIZE(sabresd_keypad_rows),
.col_scan_delay_us = 10,
.debounce_ms = 10,
.wakeup = 1,
.active_low = 1,
//.active_low = 0,
}; static struct platform_device sabresd_keypad = {
.name = "matrix-keypad",
.id = -1,
.dev = {
.platform_data = &sabresd_kpd_pdata,
},
}; 再添加初始化函数
static void __init mx6_sabresd_board_init(void)
{
......
platform_device_register(&sabresd_keypad)
......
}

查看效果

root@android:/data # cat /proc/bus/input/devices
I: Bus=0019 Vendor=0001 Product=0001 Version=0100
N: Name="gpio-keys"
P: Phys=gpio-keys/input0
S: Sysfs=/devices/platform/gpio-keys/input/input0
U: Uniq=
H: Handlers=event0
B: PROP=0
B: EV=3
B: KEY=100000 0 0 0 I: Bus=0019 Vendor=0000 Product=0000 Version=0000
N: Name="matrix-keypad"
P: Phys=
S: Sysfs=/devices/platform/matrix-keypad/input/input1
U: Uniq=
H: Handlers=event1
B: PROP=0
B: EV=100013
B: KEY=1 0 0 0 0 0 0 0 0 0 38000000 ffe
B: MSC=10 I: Bus=0003 Vendor=09da Product=c10a Version=0110
N: Name="A4Tech USB Mouse"
P: Phys=usb-fsl-ehci.1-1.3/input0
S: Sysfs=/devices/platform/fsl-ehci.1/usb2/2-1/2-1.3/2-1.3:1.0/input/input2
U: Uniq=
H: Handlers=mouse0 event2
B: PROP=0
B: EV=1f
B: KEY=ff0000 0 0 0 0 0 0 0 0
B: REL=303
B: ABS=1f00 0
B: MSC=10 root@android:/data # getevent
could not get driver version for /dev/input/mice, Not a typewriter
add device 1: /dev/input/event2
name: "A4Tech USB Mouse"
could not get driver version for /dev/input/mouse0, Not a typewriter
add device 2: /dev/input/event1
name: "matrix-keypad" # matrix-keypad
add device 3: /dev/input/event0
name: "gpio-keys" # gpio-keys```

Tony Liu

2016-12-30, Shenzhen

imx6 matrix keyboard的更多相关文章

  1. EDA课设-交通灯-Verilog版----FPGA--004

    分得到析四个状态: S1: 主干道(绿灯亮) ,支干道(亮红灯):--40S S1: 主干道 (黄灯亮) ,支干道(亮红灯):--4S S1: 主干道 (亮红灯),支干道(绿灯亮):--20S S1: ...

  2. EasyMonkeyDevice vs MonkeyDevice&HierarchyViewer API Mapping Matrix

    1. 前言 本来这次文章的title是写成和前几篇类似的<EasyMonkeyDevice API实践全记录>,内容也打算把每一个API的实践和建议给记录下来,但后来想了下认为这样子并非最 ...

  3. EasyMonkeyDevice vs MonkeyDevice&HierarchyViewer API Mapping Matrix

    1. 前言 本来这次文章的title是写成和前几篇类似的<EasyMonkeyDevice API实践全记录>,内容也打算把每个API的实践和建议给记录下来,但后来想了下觉得这样子并不是最 ...

  4. angular2系列教程(十一)路由嵌套、路由生命周期、matrix URL notation

    今天我们要讲的是ng2的路由的第二部分,包括路由嵌套.路由生命周期等知识点. 例子 例子仍然是上节课的例子:

  5. Pramp mock interview (4th practice): Matrix Spiral Print

    March 16, 2016 Problem statement:Given a 2D array (matrix) named M, print all items of M in a spiral ...

  6. Fedora 22中的Locale and Keyboard Configuration

    Introduction The system locale specifies the language settings of system services and user interface ...

  7. Atitit Data Matrix dm码的原理与特点

    Atitit Data Matrix dm码的原理与特点 Datamatrix原名Datacode,由美国国际资料公司(International Data Matrix, 简称ID Matrix)于 ...

  8. Android笔记——Matrix

    转自:http://www.cnblogs.com/qiengo/archive/2012/06/30/2570874.html#translate Matrix的数学原理 在Android中,如果你 ...

  9. 通过Matrix进行二维图形仿射变换

    Affine Transformation是一种二维坐标到二维坐标之间的线性变换,保持二维图形的"平直性"和"平行性".仿射变换可以通过一系列的原子变换的复合来 ...

随机推荐

  1. jmap之使用说明与JVM配置

    详情可参见:http://blog.csdn.net/fenglibing/article/details/6411953. 1 2. 3.vi 打开查看,具体介绍请看上述链接. 4.查看tomcat ...

  2. ajax实例2

    前台: function save() { var username = document.getElementById("username").value; var id = d ...

  3. 【Javascript】解决Ajax轮询造成的线程阻塞问题(过渡方案)

    一.背景 开发Web平台时,经常会需要定时向服务器轮询获取数据状态,并且通常不仅只开一个轮询,而是根据业务需要会产生数个轮询.这种情况下,性能低下的Ajax长轮询已经不能满足需求,频繁的访问还会造成线 ...

  4. Pyqt5 获取命令行参数sys.argv

    大家有没有注意到,很多软件都能接收第三方应用触发命令行参数,根据参数打开想要的效果. 在windows任务管理器调取命令行列,我们同样能看到进程中有好多是带有参数的. 现在,我们用Pyqt5 (Py3 ...

  5. js的回调函数 一些例子

    这边用bootstrap 3.0的  上传控件做例子 下面是上传控件的一段完整的 js 操作 代码. <!-- 上传缩略图控件配置 --><script> // 定义这四个全局 ...

  6. iOS通知的使用

    注册:[[NSNotificationCenter defaultCenter] postNotificationName:@"changeColor" object:self]; ...

  7. BZOJ 2115 [Wc2011] Xor ——线性基

    [题目分析] 显然,一个路径走过两边是不需要计算的,所以我么找到一条1-n的路径,然后向该异或值不断异或简单环即可. 但是找出所有简单环是相当复杂的,我们只需要dfs一遍,找出所有的环路即可,因为所有 ...

  8. QuickTest Professionar 快捷键

    新建Test – New Test CTRL + N录制 – Record F3打开Test – Open Test CTRL + O新建业务组件 – Business Component > ...

  9. 如何在插件中添加Actor类

    只要按照BlueprintFunctionLibrary的那个模板做就好了,把用编辑器生成的代码复制到插件对应的目录 之后需要注意做以下修改 1.H文件中的 GENERATED_UCLASS_BODY ...

  10. 非常详细的/etc/passwd解释

    root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nol ...