现在先说gt9触摸屏如何配置
首先拿到硬件厂商提供的cfg以及gt9xx文件夹
驱动源码路径:kernel/drivers/input/touchscreen/gtxx
注:可以自己定义最后把gt9xx.h以及gt9xx.c文件放在哪,放在哪就在makefile里指定对应位置
1.touchscreen文件夹下的Kconfig配置,主要是最后一句,应用到对应文件夹下的Kconfig
2.touchscreen文件夹下makefile配置,指向对应文件夹下
3.gtxx文件夹下的Kconfig配置
config TOUCHSCREEN_GTX911_MST
tristate "gtx911 touchscreen gt911 rk3288 for marvsmart"
default y
help
This enables support for goodix touchscreens.
4.gtxx文件夹下的Kconfig配置
obj-$(CONFIG_TOUCHSCREEN_GTX911_MST) += gt9xx.o gt9xx_update.o #goodix_tool.o
5.修改设备树,更改dts里配置,添加gt9xx
&i2c4 {
status = "okay";
goodix_ts@5d {
compatible = "goodix,gt9xx";
reg = <0x5d>;
goodix,rst-gpio = <&gpio7 5 GPIO_ACTIVE_LOW>;
goodix,irq-gpio = <&gpio7 6 IRQ_TYPE_EDGE_RISING>;
};
};
6.配置defconfig,注意这里的TOUCHSCREEN_GTX911_MST和前面touchscreen配置的是一一对应的
CONFIG_INPUT_TOUCHSCREEN=y
CONFIG_TOUCHSCREEN_GTX911_MST=y
7.源码修改
gt9xx.h 文件配置修改
#define DEBUG_SWITCH 1 开启调试开关,打印信息(很重要)
#define GTP_CUSTOM_CFG 1 用来用户自定义设置;
#define GTP_DRIVER_SEND_CFG 1 用来发送CFG文件配置;
group是厂家指定,6个group(0 - 5),该方案配置group3
// TODO: define your config for Sensor_ID == 3 here, if needed
#define CTP_CFG_GROUP3 {\
//厂家提供
0x00,0x00,0x04,0x58,0x02,0x05,0x0C,0x20,0x02,0xC6,0x28,0x0F,0x64,0x50,0x03, \
0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x1A,0x1E,0x14,0x8A,0x29,0x0C, \
0x2A,0x28,0x0F,0x0A,0x00,0x00,0x00,0x81,0x03,0x11,0x00,0x01,0x00,0x00,0x00, \
0x03,0x00,0x00,0x00,0x00,0x00,0x14,0x52,0x94,0xC5,0x02,0x07,0x00,0x00,0x04, \
0xD4,0x17,0x00,0xA6,0x1E,0x00,0x80,0x28,0x00,0x62,0x36,0x00,0x4E,0x47,0x00, \
0x4E,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,0x18,0x16,0x14,0x12,0x10,0x0E,0x0C,0x0A, \
0x08,0x06,0x04,0x02,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, \
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x22,0x21,0x20,0x1F,0x1E,0x1D,0x1C,0x18, \
0x16,0x12,0x10,0x0F,0x0C,0x0A,0x08,0x06,0x04,0x02,0x00,0xFF,0xFF,0xFF,0xFF, \
0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, \
0x00,0x00,0x00,0x00,0xFB,0x01 \
}
gt9xxx.c源码分析
触摸屏通过iic控制,驱动部分适配了5种不同的屏幕,通过读取触摸ic(GT9XX)的sensor id来判断,适配哪个屏幕,即哪个cfg。
static s32 gtp_init_panel(struct goodix_ts_data *ts)
{
……
ret = gtp_i2c_read_dbl_check(ts->client, GTP_REG_SENSOR_ID, &sensor_id, 1);
if (SUCCESS == ret)
{
if (sensor_id >= 0x06)
{
GTP_ERROR("Invalid sensor_id(0x%02X), No Config Sent!", sensor_id);
ts->pnl_init_error = 1;
return -1;
}
}
else
{
GTP_ERROR("Failed to get sensor_id, No config sent!");
ts->pnl_init_error = 1;
return -1;
}
GTP_INFO("Sensor_ID: %d", sensor_id);
/* parse config data*/
#ifdef GTP_CONFIG_OF
GTP_DEBUG("Get config data from device tree.");
ret = gtp_parse_dt_cfg(&ts->client->dev, &config[GTP_ADDR_LENGTH], &ts->gtp_cfg_len, sensor_id);
if (ret < 0) {
GTP_ERROR("Failed to parse config data form device tree.");
ts->pnl_init_error = 1;
return -1;
}
#else
GTP_DEBUG("Get config data from header file.");
if ((!cfg_info_len[1]) && (!cfg_info_len[2]) &&
(!cfg_info_len[3]) && (!cfg_info_len[4]) &&
(!cfg_info_len[5]))
{
sensor_id = 0;
}
ts->gtp_cfg_len = cfg_info_len[sensor_id];
memset(&config[GTP_ADDR_LENGTH], 0, GTP_CONFIG_MAX_LENGTH);
memcpy(&config[GTP_ADDR_LENGTH], send_cfg_buf[sensor_id], ts->gtp_cfg_len);
#endif
……
}
注意:如果屏幕可以触摸,但定位有误,第一反应就是cfg配置是否正确,通过串口获取sersor_Id到底是几,然后查看对应CTP_CFG_GROUP配置是否正确