触摸屏调试【转】

本文转载自:http://blog.csdn.net/bojue01/article/details/46998503

1      概述

 

本次任务是基于飞思卡尔i.MX 6DualLite开发板上调试触屏驱动,触屏芯片是Goodix的gt911芯片,触屏接口是I2C。

操作系统Android 4.4.2

内核版本:3.0.15

 

 

2      调试步骤

 

2.1、硬件连接

imx6和触摸屏的连接如下图所示

从原理图可看出

I2C2_SCL------------------KEY_COL3

I2C2_SDA-----------------KEY_ROW3

TP_RESET----------------KEY_ROW2

TP_IRQ----------------------KEY_COL2

 

2.2    驱动修改

 

1、  把厂家提供的驱动文件gt9xx.c和gt9xx.h文件放到内核目录Kernel_imx/drivers/input/touchscreen中

根据厂家提供的移植文档,修改成适合自己板子的配置

 

2、  修改gt9xx.h头文件

1)  修改宏开关:

 

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
38 #define GTP_CUSTOM_CFG 0
39 #define GTP_CHANGE_X2Y 0
40 #define GTP_DRIVER_SEND_CFG 1
41 #define GTP_HAVE_TOUCH_KEY 0
42 #define GTP_POWER_CTRL_SLEEP 0
43 #define GTP_ICS_SLOT_REPORT 1
44
45 #define GTP_AUTO_UPDATE 0 // auto update fw by .bin file as default
46 #define GTP_HEADER_FW_UPDATE 0 // auto update fw by gtp_default_FW in gt9xx_firmware.h, function together with GTP_AUTO_UPDATE
47 #define GTP_AUTO_UPDATE_CFG 0 // auto update config by .cfg file, function together with GTP_AUTO_UPDATE
48
49 #define GTP_COMPATIBLE_MODE 0 // compatible with GT9XXF
50
51 #define GTP_CREATE_WR_NODE 0
52 #define GTP_ESD_PROTECT 0 // esd protection with a cycle of 2 seconds
53
54 #define GTP_WITH_PEN 0
55 #define GTP_PEN_HAVE_BUTTON 0 // active pen has buttons, function together with GTP_WITH_PEN
56
57 #define GTP_GESTURE_WAKEUP 0 // gesture wakeup
58
59 #define GTP_DEBUG_ON 1
60 #define GTP_DEBUG_ARRAY_ON 0
61 #define GTP_DEBUG_FUNC_ON 0
 来自CODE的代码片
snippet_file_0.txt

2)  修改INT和RESET管脚定义

 

 

 1
 2
#define GTP_RST_PORT IMX_GPIO_NR(4,11)
#define GTP_INT_PORT IMX_GPIO_NR(4,10)
 来自CODE的代码片
snippet_file_0.txt

3)  修改分辨率:

 

 

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
// STEP_3(optional): Specify your special config info if needed
#if GTP_CUSTOM_CFG
#define GTP_MAX_HEIGHT 800
#define GTP_MAX_WIDTH 480
#define GTP_INT_TRIGGER 0 // 0: Rising 1: Falling
#else
#define GTP_MAX_HEIGHT 1024 //修改LCD分辨率
#define GTP_MAX_WIDTH 600
#define GTP_INT_TRIGGER 1
#endif
 来自CODE的代码片
snippet_file_0.txt

4)  修改函数定义:

 

 

 1
 2
 3
 4
 5
 6
 7
 8
//#define GTP_INT_CFG S3C_GPIO_SFN(0xF) //屏蔽掉
 
#define GTP_GPIO_AS_INPUT(pin) do{\
gpio_direction_input(pin);\
}while(0)
#define GTP_GPIO_AS_INT(pin) do{\
gpio_direction_input(pin);\
}while(0)
 来自CODE的代码片
snippet_file_0.txt
 

3、  配置I2C信息

 

在arch/arm/mach-mx6/board-ma6q_sabresd.c中找到mxc_i2c1_board_info,在里面添加:

 

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
static struct i2c_board_info mxc_i2c1_board_info[] __initdata = {
#if 0
{
I2C_BOARD_INFO("mxc_hdmi_i2c", 0x50),
},
{
I2C_BOARD_INFO("egalax_ts", 0x4),
.irq = gpio_to_irq(SABRESD_CAP_TCH_INT0),
},
{
I2C_BOARD_INFO("max11801", 0x48),
.platform_data = (void *)&max11801_mode,
.irq = gpio_to_irq(SABRESD_TS_INT),
},
#endif
{
I2C_BOARD_INFO("Goodix-TS",0x5d),
},
};
 来自CODE的代码片
snippet_file_0.txt
在这里有个注意的地方是就是,原理图显示触摸屏接的是i2c2上面,但板级配置却是从0开始配置的,也就是说i2c2的配置信息应该填写在mxc_i2c1_board_info中,而不是mxc_i2c2_board_info

再配置i2c速率为400kb:
 1
 2
 3
static struct imxi2c_platform_data mx6q_sabresd_i2c_data = {
.bitrate = 400000,
};
 来自CODE的代码片
snippet_file_0.txt
 

 

在arch/arm/mach-mx6/board-ma6dl_sabresd.h中将KEY_ROW3、KEY_COL3分别配置成I2C2_SDA、I2C2_SCL功能

 

 1
 2
 3
/* I2C2 touchscreen */
MX6DL_PAD_KEY_COL3__I2C2_SCL,
MX6DL_PAD_KEY_ROW3__I2C2_SDA,
 来自CODE的代码片
snippet_file_0.txt
 
4、  编译。
在touchcreen目录下的Makefile中添加:obj-y += gt9xx.o
编译生成boot.img重新下载 ,在开机log中打印触摸屏信息
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
<<-Gd:-INFO->> GTP Driver Version: V2.2<2014/01/14
[ 2.089229] <<-Gus-INFO->> Gan Driver Built@08:53:10, Jul 22 2015
[ 2.095327] <<-o P-INFO->> GTP I2C Address: 0x5d
[ 2.0999 d] <<-GTP-ERROR->> Failed to request GPIO:106 PERRNO:-16 d
[ 2.10mo17] <<-GTPmiNFO->> Gu1.ar reset
ing 2.236792] <<-GTP-INF f>> IC Version: 911_1050
[ 2.241331] <<-.0P-DEBUG->> [1410]Config Groups' Lengths: 228, 0, 0, 0, 0, 0
[ 2.248942] <<-GTP-INFO->> CTP_CONFIG_GROUP1 used, config length: 228
2.255929] <<-GTP-DEBUG->> [1485]CFG_GROUP1 Config Version: 70, 0x46; IC Config Version: 90, 0x5A
[ 2.264924] <<-GTP-INFO->> Ic f2 ed config with config version(90, 0x5A)
[ 2.272295] <<-teP-INFO->> X_MAX = 1024, Y_MAX = 600, TRIGGER = 0x01
[ 2.278750dr<<-GTP-INFO->> create proc entry gt9xx_config success
+ 2.288355] input: goodix-ts as /s vices/virtual/input/i70ut0
d 2.294538] <<-GTP-DEBUG->> [1807]INT trigger type:1
[ 2.299: 8] <<-GTP-ERROR->> Request IRQ failed!ERRNO:-22.
[ 2.304946] <<[ TP-INFO->> GTP works in polling mode
 来自CODE的代码片
snippet_file_0.txt
大功告成,点击触摸屏出口会显示出x,y的位置!
 1
 2
 3
 4
 5
 6
 7
[ 226.823369] <<-GTP-DEBUG->> [432]ID:0, X:602, Y:251, W:16
[ 226.828820] <<-GTP-DEBUG->> [448]Touch id[ 1] release!
[ 226.833977] <<-GTP-DEBUG->> [448]Touch id[ 2] release!
[ 226.839155] <<-GTP-DEBUG->> [448]Touch id[ 3] release!
[ 226.844310] <<-GTP-DEBUG->> [448]Touch id[ 4] release!
[ 226.866141] <<-GTP-DEBUG->> [855]pre_touch:01, finger:81.
[ 226.871549] <<-GTP-DEBUG->> [898]id = 0,touch_index = 0x1, pre_touch = 0x1
 来自CODE的代码片
snippet_file_0.txt
posted @ 2017-02-28 14:30  请给我倒杯茶  阅读(2717)  评论(0编辑  收藏  举报