0x00 环境说明:
所使用的开发板为锐尔威视的插针版A33_Vstar
触摸屏驱动IC为GT911
接线参照开发板的TP线路
0x01 修改系统配置文件:
笔者所使用的A33开发板的系统配置文件路径问:
/root/a33_linux/dragonboard/tools/pack/chips/sun8iw5p1/configs/vstar/sys_config.fex
在配置文件中搜索 [twi0] 以及 [twi_para] 确保IIC0是开启的:
然后搜索 [ctp_para] ,修改TP配置:(注意屏幕分辨率按实际屏幕设置)
[ctp_para]
ctp_used = 1
ctp_name = "gt9xx_ts"
ctp_twi_id = 0
ctp_twi_addr = 0x5d
ctp_screen_max_x = 480
ctp_screen_max_y = 854
ctp_revert_x_flag = 0
ctp_revert_y_flag = 0
ctp_exchange_x_y_flag = 0ctp_int_port = port:PB05<0><0>
ctp_wakeup = port:PH01<1><1>
ctp_power_ldo = "axp22_eldo1"
ctp_power_ldo_vol = 3000
ctp_power_io =
0x02 修改初始化脚本:
初始化脚本路径为:
/root/a33_linux/dragonboard/buildroot/target/dragonboard/extra/autorun.sh
在文件中找到安装TP驱动的位置,将:
insmod "$tp_module_path"
修改为:
insmod /system/vendor/modules/gt9xx_ts.ko
找到 tslib config:
将其中的 ft5x_ts 修改为 gt9xx_ts :
修改完毕之后保存退出
0x03 修改驱动代码:
驱动代码路径为:
/root/a33_linux/dragonboard/linux-3.4/drivers/input/touchscreen/gt9xx/
修改 gt9xx_ts.h :
修改相关配置选项:
//***************************PART1:ON/OFF define*******************************
#define GTP_CUSTOM_CFG 1
#define GTP_DRIVER_SEND_CFG 1
#define GTP_HAVE_TOUCH_KEY 0
#define GTP_POWER_CTRL_SLEEP 0
#define GTP_AUTO_UPDATE 0
#define GTP_CHANGE_X2Y 0
#define GTP_ESD_PROTECT 0
#define GTP_CREATE_WR_NODE 0
#define GTP_ICS_SLOT_REPORT 0#define GTP_HEADER_FW_UPDATE 0
#define GTP_SLIDING_WAKEUP 0
//TP的调试输出控制(调试完毕之后建议关闭)
#define GTP_DEBUG_ON 1
#define GTP_DEBUG_ARRAY_ON 1
#define GTP_DEBUG_FUNC_ON 1
修改寄存器配置:(数据一般由屏厂直接给出)
#define CTP_CFG_GROUP1 {\
0x00,0xE0,0x01,0x56,0x03,0x0A,0x05,0x00,0x01,0x08,0x28,\
0x05,0x50,0x32,0x03,0x05,0x00,0x00,0x00,0x00,0x00,0x00,\
0x00,0x00,0x00,0x00,0x00,0x87,0x28,0x09,0x17,0x15,0x31,\
0x0D,0x00,0x00,0x02,0x9B,0x03,0x25,0x00,0x00,0x00,0x00,\
0x00,0x03,0x64,0x32,0x00,0x00,0x00,0x0F,0x36,0x94,0xC5,\
0x02,0x07,0x00,0x00,0x04,0x9B,0x11,0x00,0x7B,0x16,0x00,\
0x64,0x1C,0x00,0x50,0x25,0x00,0x42,0x2F,0x00,0x42,0x00,\
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
0x00,0x00,0x12,0x10,0x0E,0x0C,0x0A,0x08,0x06,0x04,0x02,\
0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,\
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x26,\
0x24,0x22,0x21,0x20,0x1F,0x1E,0x1D,0x00,0x02,0x04,0x06,\
0x08,0x0A,0x0C,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,\
0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6C,0x01}
只用CTP_CFG_GROUP1,其他组全部清空
修改分辨率设置:(按实际情况调整)
//STEP_3(optional):Custom set some config by themself,if need.
#if GTP_CUSTOM_CFG
#define GTP_MAX_WIDTH 480
#define GTP_MAX_HEIGHT 854
#define GTP_INT_TRIGGER 1 //0:Rising 1:Falling
#else
#define GTP_MAX_HEIGHT 4096
#define GTP_MAX_WIDTH 4096
#define GTP_INT_TRIGGER 1
#endif
修改 gt9xx.c :
参考《GT911编程指南》,修改初始化代码:
void gtp_io_init(int ms)
{
// ctp_wakeup(0, 0);
// msleep(ms);
//
// gtp_set_int_value(0);
// msleep(2);
//
// ctp_wakeup(1, 0);
// msleep(6);ctp_wakeup(0, 0);
gtp_set_int_value(0);
msleep(1);
ctp_wakeup(1, 0);
msleep(6);
gtp_set_int_value(0);
msleep(50);
#if GTP_ESD_PROTECT
// gtp_init_ext_watchdog(client);
#endif
}
保存修改之后重新编译系统
0x04 重新编译系统:
切换到系统源码顶层目录:
cd ~/a33_linux/dragonboard
重新编译系统:
./clean.sh
./build.sh config
cd linux-3.4/
cp a33_vstar_defconfig .config
cd ..
./build.sh
./build.sh pack
最终打包生成的系统镜像路径为:
~/a33_linux/dragonboard/tools/pack/sun8iw5p1_dragonboard_vstar.img
0x05 验证:
将打包生成的系统镜像烧录至板子,上电启动之后进入触摸屏校准:
点击屏幕,串口打印坐标数据: