实验环境:
飞思卡尔 IMX6 系列内核
配套使用 TSLIB 用于作为读写接口
记得删除 pointercal 一般位于 /etc 下,这东西对于电容屏没啥作用
附带 QT 将触摸事件改变配置
export QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS=/dev/input/event1:rotate=180
一、复制驱动
驱动连接 GT9XX (优快云 老版本需要积分下载,亲测ok)
Github 上的连接 (不需要积分,没有测试)
将链接所示驱动移动至 drivers/input/touchscreen/ 目录下
注意:Kconfig和makefile文件内容不要轻易覆盖你自己的内核包 GT9xx 所在的两个文件,可以将下载目录内文件关于 GT9xx 字样的语句复制到原有文件内。
1.1 修改 Kconfig (drivers/input/touchscreen/)
config TOUCHSCREEN_GT9XX
tristate "GT9XX I2C touchscreen"
depends on I2C
help
Say Y here if you have the 7 inch TP.
If unsure, say N.
To compile this driver as a module, choose M here.
1.2 修改 makefile (drivers/input/touchscreen/)
obj-$(CONFIG_TOUCHSCREEN_GT9XX) += gt9xx.o
二、修改设备树
找到你正在使用的设备树
这里你可以使用模拟I2C,也可以使用硬件I2C(推荐硬件 I2C 已测试)
模拟I2C
i2c_gpio: analog-i2c {
compatible = "i2c-gpio";
gpios = <&gpio5 8 0 /* sda */
&gpio5 7 0 /* scl */
>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_i2c>;
i2c-gpio,delay-us = <5>;
i2c-gpio,timeout-ms = <100>;
#address-cells = <1>;
#size-cells = <0>;
//注意这里主要讲解模拟I2C,没有配置GT9xx的IO引脚复用功能,请查看硬件配置内容
goodix_ts@14 { //goodix_ts @ 14 寄存器值
compatible = "goodix,gt9xx"; //这个兼容需要查看对应驱动文件
reg = <0x14>; //寄存器地址(7bit) 即:0x28-->0x14 / 0xBA-->0x5d
interrupt-parent = <&gpio3>; //设定中断控制
interrupts = <4 IRQ_TYPE_EDGE_FALLING>;//设定端口以及引脚变化
goodix,rst-gpio = <&gpio5 6 0x00>; //查看对应驱动文件
goodix,irq-gpio = <&gpio3 4 0x00>; //同上
goodix,cfg-group0 = [
5A 20 03 E0 01 05 3D 00 02 08 28
08 5A 46 03 05 00 00 00 00 00 00
04 04 04 04 03 88 29 0A 4B 4D 0C
08 00 00 00 21 02 1D 00 01 00 00
00 00 00 00 00 00 00 46 64 94 D5
02 07 00 00 04 83 48 00 77 4D 00
6D 53 00 64 59 00 5A 60 00 5A 00
00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00
00 00 02 04 06 08 0A 0C 0E 10 12
14 FF FF FF FF 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00
02 04 06 08 0F 10 12 16 18 1C 1D
1E 1F 20 21 22 FF FF FF FF FF FF
FF FF FF 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 7C 01];
};
};
&iomux {
pinctrl_i2c: i2cgrp {
fsl,pins = <
MX6UL_PAD_SNVS_TAMPER7__GPIO5_IO07 0x4001b8b0 /*scl*///0x400 表示启用
MX6UL_PAD_SNVS_TAMPER8__GPIO5_IO08 0x4001b8b0 /*sda*/
>;
};
};
硬件I2C
&i2c2 { //&i2c2 是在 imx6g2c-base.dtsi 中定义(对应 dts 文件顶端包含的 xx.dtsi 文件内容即可)
clock-frequency = <400000>; //使用频率 默认 100000,
pinctrl-names = "default"; // Pinctrl 子系统——设备树
pinctrl-0 = <&pinctrl_i2c2>; //&pinctrl_i2c2 这个命名没有特别要求
status = "okay"; // "okay" 启动 ;disable 关闭
goodix_ts@14 {
compatible = "goodix,gt9xx";
//drivers/input/touchscreen/gt9xx.c 的 of_device_id goodix_match_table[] {} 函数内
reg = <0x14>; //寄存器值
interrupt-parent = <&gpio1>;
//指向该设备连接的中断控制器的 phandle
interrupts = <29 IRQ_TYPE_EDGE_FALLING>;
// 说明中断端口号,以及中断标志位
goodix,rst-gpio = <&gpio1 28 0x00>;
//复位 gt9xx.c of_get_named_gpio(np, "goodix,irq-gpio", 0);
//看原理图,及引脚对应的标号
goodix,irq-gpio = <&gpio1 29 0x00>;
goodix,cfg-group0 = [ //配置参数
5A 20 03 E0 01 05 3D 00 02 08 28
08 5A 46 03 05 00 00 00 00 00 00
04 04 04 04 03 88 29 0A 4B 4D 0C
08 00 00 00 21 02 1D 00 01 00 00
00 00 00 00 00 00 00 46 64 94 D5
02 07 00 00 04 83 48 00 77 4D 00
6D 53 00 64 59 00 5A 60 00 5A 00
00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00
00 00 02 04 06 08 0A 0C 0E 10 12
14 FF FF FF FF 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00
02 04 06 08 0F 10 12 16 18 1C 1D
1E 1F 20 21 22 FF FF FF FF FF FF
FF FF FF 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 D6 01];
};
};
&iomuxc { //已存在一般在文件最低部
pinctrl_i2c2: i2c2grp { //pinctrl_i2c2 与上文命名相关 // i2c2grp
fsl,pins = < //固定写法
MX6UL_PAD_UART5_TX_DATA__I2C2_SCL 0x4001b8b0
//变量名 查 xxx-pinfun.h 定义 后面查看数据手册 config 的值,
//对于特殊功能 0x400开头表示启用 0x80000000 表示关闭
MX6UL_PAD_UART5_RX_DATA__I2C2_SDA 0x4001b8b0
MX6UL_PAD_UART4_RX_DATA__GPIO1_IO29 0x10059 //输入
MX6UL_PAD_UART4_TX_DATA__GPIO1_IO28 0x17059 //输出
>;
};
};
对于使用不到的IO设置也建议是注销 /* */
硬件I2C 同时在编译的时候打开如下驱动内容,别忘记将Input选项下touchscreen中的GT9xx加入编译内容
主要是 IMX I2C interface
三、 TSLIB
TSLIB 不需要做什么特备的处理,如果你当前使用的版本提示不支持 ABS_X 之类的试着使用新一点的版本,另外如果需要支持多点处理,可能需要修改 TSLIB 代码以及相关 GUI 软件的功能(此处未做深入研究,至此项目功能实现)
贴一下 tslib/etc/ts.conf 内容
# Access plugins
################
# Uncomment if you wish to use the linux input layer event interface
module_raw input
# For other driver modules, see the ts.conf man page
# Filter plugins
################
# Uncomment if first or last samples are unreliable
# module skip nhead=1 ntail=1
# Uncomment if needed for devices that measure pressure
module pthres pmin=1
# Uncomment if needed
# module debounce drop_threshold=40
# Uncomment if needed to filter spikes
# module median depth=5
# Uncomment to enable smoothing of fraction N/D
# module iir N=6 D=10
# Uncomment if needed
# module lowpass factor=0.1 threshold=1
# Uncomment if needed to filter noise samples
module dejitter delta=100
# Uncomment and adjust if you need to invert an axis or both
# module invert x0=800 y0=480
# Uncomment to use ts_calibrate's settings
module linear