linux下GT911触摸屏驱动优化记录

article/2025/8/23 1:24:42

linux下GT911触摸屏驱动优化记录

背景

由于最近要做linux内核启动速度优化,所以就对着驱动一点一点优化,加上QT应用程序的初始化,总共的启动时间要做到4S以内。目前先调试GT911驱动程序。

平台

  • 芯片:全志A33
  • 内核:linux-3.4
  • 优化驱动:GT911

优化步骤

原始驱动加载信息

[   47.327870] ***CTP***GTP driver init
[   47.335887] =====ctp_fetch_sysconfig_para=====. 
[   47.353187] ctp_fetch_sysconfig_para: ctp_power_io script_get_item err. 
[   47.365240] ctp_irq gpio number is 37
[   47.371302] axp22_ldoio1: Failed to create debugfs directory
[   47.370921] CPU1: Booted secondary processor
[   47.383971] ***CTP***GTP driver gesture wakeup is used!
[   47.410038] ***CTP***info.ctp_used:1
[   47.414094] ***CTP***info.twi_id:0
[   47.418038] ***CTP***info.screen_max_x:1024
[   47.422781] ***CTP***info.screen_max_y:600
[   47.427413] ***CTP***info.revert_x_flag:0
[   47.432053] ***CTP***info.revert_y_flag:0
[   47.436591] ***CTP***info.exchange_x_y_flag:0
[   47.441606] ***CTP***info.irq_gpio_number:37
[   47.446430] ***CTP***info.wakeup_gpio_number:360
[   47.451661] ***CTP******CTP*** ctp_wakeup:status:0,ms = 0
[   47.520025] ***CTP******CTP*** ctp_wakeup:status:1,ms = 0
[   47.620873] the adapter number is 0
[   47.625075] ctp_detect: addr = 5d
[   47.629115] detect ret 2
[   47.632780] ======detect ok !=====
[   47.638369] ***CTP***GTP Driver Version: V2.2<2014/01/14>***CTP***GTP Driver Built@09:35:50, Dec 31 2019***CTP***GTP I2C Address: 0x5d<<-GTP-INFO->> IC Version: 911_1060
[   47.659088] ***CTP***Config Groups Lengths: 186, 186, 186, 186, 186, 186, 186
[   47.668453] ***CTP***CTP name : gt911_1024x600
[   47.675321] ***CTP***gt9xx:sensor_id = 6
[   47.679800] ***CTP***Sensor_ID: 6***CTP***CTP_CONFIG_GROUP7 used, config length: 186
[   47.689203] ***CTP***CFG_GROUP7 Config Version: 66, 0x42; IC Config Version: 65, 0x41
[   47.698040] <<-GTP-INFO->> Driver send config.
[   47.709369] <<-GTP-INFO->> X_MAX: 1024, Y_MAX: 600, TRIGGER: 0x00
[   47.730077] <<-GTP-INFO->> create proc entry gt9xx_config success
[   47.737015] <<-GTP-INFO->> Ready to run update thread.
[   47.743022] <<-GTP-INFO->> Update by default firmware array
[   47.751617] <<-GTP-INFO->> GTP works in interrupt mode.
[   47.757607] <<-GTP-INFO->> Applied memory size:2562.
[   47.763463] <<-GTP-INFO->> I2C function: without pre and end cmd!
[   47.770612] <<-GTP-INFO->> Create proc entry success!
[   47.776678] the adapter number is 1
[   47.782579] <<-GTP-INFO->> FILE HARDWARE INFO:00016000
[   47.780962] CPU2: Booted secondary processor
[   47.793334] <<-GTP-INFO->> FILE PID:9271
[   47.797777] <<-GTP-INFO->> FILE VID:1040
[   47.802322] <<-GTP-INFO->> IC HARDWARE INFO:00900600
[   47.807920] <<-GTP-INFO->> IC PID:911
[   47.812081] <<-GTP-INFO->> IC VID:1060
[   47.816416] <<-GTP-INFO->> Firmware length:90112(88K)
[   47.822130] <<-GTP-ERROR->> File PID != Ic PID, update aborted!
[   47.828871] <<-GTP-ERROR->> [update_proc]Check *.bin file fail.

由上图可以得知整个驱动的加载时间等于:47.8288-47.3278 = 500ms

对于一个tp驱动来说,一个初始化代码居然要500ms,不能忍。这个驱动是有很大的优化空间的,目标是第一阶段先优化到100ms以内。具体的操作步骤如下:

1、关闭自动更新(-200ms)

2、优化tp的上电复位时序(-100ms)

3、屏蔽多余的打印信息(-100ms)

更改记录

-------------------------- drivers/input/init-input.c --------------------------
index edfc4e1..0355baa 100755
@@ -37,7 +37,7 @@ static int ctp_fetch_sysconfig_para(enum input_sensor_type *ctp_type)struct ctp_config_info *data = container_of(ctp_type,struct ctp_config_info, input_type);-	pr_info("=====%s=====. \n", __func__);
+//	pr_info("=====%s=====. \n", __func__);type = script_get_item("ctp_para", "ctp_used", &val);if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
@@ -79,7 +79,7 @@ static int ctp_fetch_sysconfig_para(enum input_sensor_type *ctp_type)data->ctp_power_vol = val.val;type = script_get_item("ctp_para", "ctp_power_io", &val);if(SCIRPT_ITEM_VALUE_TYPE_PIO != type) {
-		pr_err("%s: ctp_power_io script_get_item err. \n",__func__ );
+//		pr_err("%s: ctp_power_io script_get_item err. \n",__func__ );}elsedata->ctp_power_io = val.gpio;
@@ -136,7 +136,7 @@ static int ctp_fetch_sysconfig_para(enum input_sensor_type *ctp_type)}data->irq_gpio = val.gpio;data->int_number = val.gpio.gpio;
-    pr_err("ctp_irq gpio number is %d\n", data->int_number);
+//    pr_err("ctp_irq gpio number is %d\n", data->int_number);#ifdef TOUCH_KEY_LIGHT_SUPPORT type = script_get_item("ctp_para", "ctp_light", &val);------------------ drivers/input/touchscreen/gt9xxnew/gt9xx.c ------------------
index 0a16c94..dbb317b 100755
@@ -170,8 +170,9 @@ enum{DEBUG_WAKEUP_INFO = 1U << 5,DEBUG_OTHERS_INFO = 1U << 6,};
-#define dprintk(level_mask,fmt,arg...)    if(unlikely(debug_mask & level_mask)) \
-        printk("***CTP***"fmt, ## arg)
+#define dprintk(level_mask,fmt,arg...)
+//#define dprintk(level_mask,fmt,arg...)    if(unlikely(debug_mask & level_mask)) \
+//        printk("***CTP***"fmt, ## arg)module_param_named(debug_mask,debug_mask,int,S_IRUGO | S_IWUSR | S_IWGRP);static const unsigned short normal_i2c[2] = {0x5d, I2C_CLIENT_END};struct ctp_config_info config_info = {
@@ -190,7 +191,6 @@ static int ctp_detect(struct i2c_client *client, struct i2c_board_info *info){struct i2c_adapter *adapter = client->adapter;int  ret = -1;
-	printk("the adapter number is %d\n", adapter->nr);if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)){printk("======return=====\n");
@@ -198,7 +198,6 @@ static int ctp_detect(struct i2c_client *client, struct i2c_board_info *info)}if(twi_id == adapter->nr){
-            printk("%s: addr = %x\n", __func__, client->addr);ret = gtp_i2c_test(client);printk("detect ret %d\n",ret);if(!ret){
@@ -206,7 +205,6 @@ static int ctp_detect(struct i2c_client *client, struct i2c_board_info *info)return -ENODEV;}else{           	    strlcpy(info->type, CTP_NAME, I2C_NAME_SIZE);
-				printk("======detect ok !=====\n");return 0;	}}else{
@@ -239,31 +237,10 @@ void ctp_print_info(struct ctp_config_info info,int debug_level)* ctp_wakeup - function**/
-int ctp_wakeup(int status,int ms)
+int ctp_wakeup(int status){
-	dprintk(DEBUG_INIT,"***CTP*** %s:status:%d,ms = %d\n",__func__,status,ms);
-
-	if (status == 0) {
-
-		if(ms == 0) {
-			__gpio_set_value(config_info.wakeup_gpio.gpio, 0);
-		}else {
-			__gpio_set_value(config_info.wakeup_gpio.gpio, 0);
-			msleep(ms);
-			__gpio_set_value(config_info.wakeup_gpio.gpio, 1);
-		}
-	}
-	if (status == 1) {
-		if(ms == 0) {
-			__gpio_set_value(config_info.wakeup_gpio.gpio, 1);
-		}else {
-			__gpio_set_value(config_info.wakeup_gpio.gpio, 1);
-			msleep(ms);
-			__gpio_set_value(config_info.wakeup_gpio.gpio, 0);
-		}
-	}
-	msleep(5);
-
+    dprintk(DEBUG_INIT,"***CTP*** %s:status:%d\n",__func__,status);
+    __gpio_set_value(config_info.wakeup_gpio.gpio, status);return 0;}@@ -295,19 +272,15 @@ void gtp_set_io_int(void)}-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);       
-	gpio_direction_output(config_info.wakeup_gpio.gpio,1); 
-	gtp_int_sync(50);
+void gtp_io_init()
+{
+    input_set_power_enable(&(config_info.input_type), 1);
+    gtp_set_int_value(0);
+    ctp_wakeup(0);
+    msleep(4);
+    ctp_wakeup(1);
+    msleep(28);
+    gtp_set_io_int();}/*******************************************************************************/static ssize_t gtp_gesture_enable_store(struct device *dev,struct device_attribute *attr,const char *buf, size_t count)
@@ -1357,7 +1330,6 @@ Output:*******************************************************/void gtp_int_sync(s32 ms){
-    gtp_set_int_value(0);msleep(ms);gtp_set_io_int();}
@@ -2713,11 +2685,11 @@ static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id}#endif-    ret = gtp_i2c_test(client);
-    if (ret < 0)
-    {
-        printk("I2C communication ERROR!");
-    }
+//    ret = gtp_i2c_test(client);
+//    if (ret < 0)
+//    {
+//        printk("I2C communication ERROR!");
+//    }ret = gtp_read_version(client, &version_info);if (ret < 0)
@@ -3249,10 +3221,10 @@ Output:********************************************************/static int __devinit goodix_ts_init(void){
+    printk("dzh-->GTP driver init\n");s32 ret = -1;script_item_u   val;script_item_value_type_e  type;
-    dprintk(DEBUG_INIT,"GTP driver init\n");if (input_fetch_sysconfig_para(&(config_info.input_type))) {printk("%s: ctp_fetch_sysconfig_para err.\n", __func__);return 0;
@@ -3282,8 +3254,6 @@ static int __devinit goodix_ts_init(void)if(!gtp_gesture_wakeup)gtp_power_ctrl_sleep = 1;	-    input_set_power_enable(&(config_info.input_type), 1);
-    msleep(10);if(!ctp_get_system_config()){printk("%s:read config fail!\n",__func__);
@@ -3292,7 +3262,7 @@ static int __devinit goodix_ts_init(void)sunxi_gpio_to_name(CTP_IRQ_NUMBER,irq_pin_name);
-    gtp_io_init(20);
+    gtp_io_init();goodix_wq = create_singlethread_workqueue("goodix_wq");if (!goodix_wq)
@@ -3304,9 +3274,10 @@ static int __devinit goodix_ts_init(void)INIT_DELAYED_WORK(&gtp_esd_check_work, gtp_esd_check_func);gtp_esd_check_workqueue = create_workqueue("gtp_esd_check");#endif
-	goodix_ts_driver.detect = ctp_detect;	
+    goodix_ts_driver.detect = ctp_detect;ret = i2c_add_driver(&goodix_ts_driver);
-    return ret; 
+    printk("dzh-->GTP driver init done\n");
+    return ret;}/*******************************************************    ------------------ drivers/input/touchscreen/gt9xxnew/gt9xx.h ------------------
index c43f741..42384d9 100755
@@ -49,7 +49,7 @@#define GTP_HAVE_TOUCH_KEY    0#define GTP_ICS_SLOT_REPORT   0-#define GTP_AUTO_UPDATE       1    // auto update fw by .bin file as default
+#define GTP_AUTO_UPDATE       0    // auto update fw by .bin file as default#define GTP_HEADER_FW_UPDATE  1    // auto update fw by gtp_default_FW in gt9xx_firmware.h, function together with GTP_AUTO_UPDATE#define GTP_AUTO_UPDATE_CFG   0    // auto update config by .cfg file, function together with GTP_AUTO_UPDATE@@ -437,7 +437,8 @@ enum{printk("***CTP***"fmt, ## arg)***************************************************************************/-#define GTP_INFO(fmt,arg...)           printk("<<-GTP-INFO->> "fmt"\n",##arg)
+#define GTP_INFO(fmt,arg...)
+//#define GTP_INFO(fmt,arg...)           printk("<<-GTP-INFO->> "fmt"\n",##arg)#define GTP_ERROR(fmt,arg...)          printk("<<-GTP-ERROR->> "fmt"\n",##arg)#define GTP_DEBUG(fmt,arg...)          do{\if(GTP_DEBUG_ON)\

参考上电时序复位时序图

在这里插入图片描述

在这里插入图片描述


http://chatgpt.dhexx.cn/article/qMlwD39E.shtml

相关文章

多点电容触摸驱动(基于gt911)

多点电容触摸的驱动使用到的知识主要有input子系统、gpio硬件中断、iic子系统&#xff0c;tslib测试等知识点&#xff0c;下面将针对多点电容触摸屏的驱动开发的四个知识点进行展开&#xff0c;以及gt911芯片的知识&#xff0c;官方gt9xx驱动的移植。 一、gt911芯片 gt911芯片…

rk3588s-pc gt911 gt9xx驱动

1.在官网拉取代码。配置好环境 2.进入hvml_rk3588s/device/rockchip/rk3588/目录下&#xff0c;我们可以看到我们编译的文件。 本项目中我们的config文件是firefly-linux.config dts文件是rk3588-firefly-itx-3588j-mipi101-M101014-BE45-A1.dtsi 3.进入tp驱动的目录 配置mak…

海思35xx实现GT911触摸屏功能

海思35xx通过gpio模拟i2c实现GT911触摸功能 1.遇到的问题 地址选配后一直不对,首先检测硬件问题,然后通过调试驱动部分,打印调试从设备给的ack&#xff08;没有逻辑分析仪&#xff09;;发现寄存器地址一直为FF或00,检查发现GT911地址均为16bit,而读写i2c接口是8位的;成功后点…

[RK3568 Android12] GT911触摸屏调试

屏幕规格书 需要主要硬件通信电压为:1.8V或者3.3V I2C通信的地址:0x5D 和0x40 系统上电时序:不同的地址,稍微有些差异 对应代码中如下:

全志F1C100s主线linux入坑记录 (4)GT911触摸移植

GT911触摸移植 百度网站 文章目录 GT911触摸移植一、添加gt911库文件二、添加设备树文件修改文件路径 &#xff1a;arch/arm/boot/dts/suniv-f1c100s.dtsi修改文件路径 &#xff1a;arch/arm/boot/dts/suniv-f1c100s-licheepi-nano.dts编译烧录 三、添加ts-lib触摸测试软件参考…

A40i使用笔记:调用系统自带驱动GT911触摸屏

一、前言 在一般情况下使用电容触摸屏时&#xff0c;都是使用USB直接驱动&#xff0c;但是在前文中我就提及过遇到的问题&#xff0c;就是USB触摸屏和我是用平台不是特别兼容的问题&#xff0c;问题现象在复述一遍&#xff0c;大概就是使用linux核心板USB接口连接ILTTEK的触摸芯…

GT911电容触摸屏使用

注&#xff1a;转载于https://blog.csdn.net/qlexcel/article/details/99696108 一、介绍与硬件连接 GT911、GT928、GT9147都属于GT9系列非单层多点触控芯片&#xff0c;他们支持的触控点数不同&#xff08;GT928支持10个点、GT911支持5个点&#xff09;、驱动和感应通道也可能…

openharmony hdf框架gt911触摸驱动移植

openharmony提供了hdf的驱动框架&#xff0c;今天以gt911触摸驱动的例子记录一下。首先hdf要加载进Linux的driver中&#xff0c;在Linux源码/driver/hdf目录有如下文件。 framwork和khdf两个软链接文件一定要链接成功。 在hdf的设备树中加入gt911的文件信息 /home/xu/openhar…

Linux运行911,韦东山-Linux下编写GT911触摸驱动 - 百问网嵌入式问答社区

源码在最下面 问题一:资源获取Gt911数据手册 在韦老师给的资料里,路径为\06_Datasheet\Extend_modules\7寸LCD模块\电容触控芯片GT911 Datasheet_121120(海威思.pdf 问题二:需要准备哪些知识 1.能够修改设备树 2.能够编写字符设备驱动 3.能够在linux下编写中断程序 4.能够在…

Linux下编写GT911触摸驱动

问题一&#xff1a;资源获取Gt911数据手册 在韦老师给的资料里&#xff0c;路径为\06_Datasheet\Extend_modules\7寸LCD模块\电容触控芯片GT911 Datasheet_121120&#xff08;海威思.pdf 问题二&#xff1a;需要准备哪些知识 1.能够修改设备树 2.能够编写字符设备驱动 3.能…

移植openharmony之调试gt911触摸

最近在调试触摸驱动&#xff0c;分析了一点openharmony的hdf框架下的触摸&#xff0c;将过程记录下&#xff0c;首先肯定是加载input设备管理驱动&#xff1a;input设备管理驱动由HDF驱动加载&#xff0c;完成设备manager的创建并对其初始化。如下图所示&#xff0c;我这里就是…

使用STM32+硬件IIC+DMA驱动GT系列触摸屏(GT911)

使用STM32硬件IICDMA驱动GT系列触摸屏&#xff08;GT911&#xff09; 初始化代码 /** brief GT911 初始化程序* param None* retval None*/ void GT911_init() {Dev_Now.GT911_RST0;GPIO_InitTypeDef GPIO_InitStruct;GPIO_InitStruct.Pin GT911_RST_PIN | GT911_INT_PIN;…

v3S驱动gt911触摸

文章目录 一、修改设备树二、编写驱动三、运行测试四、编译进内核1. 拷贝文件2. 修改对应的 Makefile3. 编译运行4.测试1.注释掉坐标信息 五、移植tslib1. buildroot配置tslib2. 配置tslib3. 测试 一、修改设备树 在sun8i-v3s-licheepi-zero-dock.dts中添加pio节点&#xff08…

gt911多点触摸实验

文章目录 一、设备树二、驱动程序三、测试四、编译进内核1. 拷贝文件2. 修改对应的 Makefile3. 编译运行4.测试 一、设备树 记得注释掉共用的引脚&#xff08;有好几处&#xff09; 在pinctrl_tsc节点下添加&#xff1a; pinctrl_tsc: tscgrp {fsl,pins <MX6UL_PAD_GPIO1_…

野火STM32F103驱动GT911触摸芯片

GT911触摸芯片 芯片介绍 GT911 是专为 7”~8”设计的新一代 5 点电容触控方案&#xff0c;拥有 26 个驱动通道和 14 个感 应通道&#xff0c;以满足更高的 touch 精度要求。 GT911 可同时识别 5 个触摸点位的实时准确位置&#xff0c;移动轨迹及触摸面积。并可根据主控需要&…

电容触摸屏控制芯片GT911

1.接口说明 GT9 非单层多点系列&#xff08;以下简称 GT9 系列&#xff09; 与主机接口共有 6 PIN&#xff0c;分别为&#xff1a; VDD、 GND、 SCL、SDA、 INT、 RESET。 主控的 INT 口线需具有上升沿或下降沿中断触发功能&#xff0c;并且当其在输入态时&#xff0c; 主控端必…

电容触摸屏GT911、GT928、GT9147的使用

一、介绍与硬件连接 GT911、GT928、GT9147都属于GT9系列非单层多点触控芯片&#xff0c;他们支持的触控点数不同&#xff08;GT928支持10个点、GT911支持5个点&#xff09;、驱动和感应通道也可能不同。可是他们的寄存器和IIC通讯时序是相同的&#xff0c;也就是说驱动程序是兼…

29-2-电容触摸屏控制芯片GT911

1.接口说明 GT9 非单层多点系列&#xff08;以下简称 GT9 系列&#xff09; 与主机接口共有 6 PIN&#xff0c;分别为&#xff1a; VDD、 GND、 SCL、SDA、 INT、 RESET。 主控的 INT 口线需具有上升沿或下降沿中断触发功能&#xff0c;并且当其在输入态时&#xff0c; 主控端…

hal编程 gt911 触摸芯片驱动 ( 枚举 结构体 熟用)( 安富莱 f429 4.3寸电容屏 )

使用板子类型以及屏幕类型 本文使用的是安富莱的板子stm32f429, 屏幕是TR433C1的4.3寸TFT显示屏, 480*272 RGB接口, 电容触摸 . I2C I2C简介、原理、时序请看这篇文章 使用cubemx工具的stm32用AT24C02实现简单密码(一点点面向对象的思想编程) gt911 gt911简介 gt911是深圳市…

python 倒计时手机app打卡_python 实现倒计时功能(gui界面)

运行效果&#xff1a; 完整源码&#xff1a; ##import library from tkinter import * import time from playsound import playsound ## display window root tk() root.geometry(400x300) root.resizable(0,0) root.config(bg blanched almond) root.title(techvidvan - cou…