文章目录
- 一、驱动注册失败
- 二、触摸屏可以触摸,但是x轴数据反了
- 三、可以触摸了,但是Y轴数据跳变,几乎只有一半的屏幕是可以正常滑动的
- 三、汇顶触摸屏配置文件解析
- 四、使用新的配置文件
- 4.1 新配置解决问题
- 4.2 测试触摸的方法
- 在kernel增加frame buffer(/dev/fb0)设备节点
- 在buildroot中配置增加tslib
- 4.3 测试
- 五、工作一段时间触摸屏驱动崩溃
- 六、在LVGL中的触摸修改:上下滑动方向相反
硬件:易百纳38x38mm RV1126板
SDK:2.2
一、驱动注册失败
上电信息中出现如下:
[ 0.403505] i2c /dev entries driver
[ 0.406719] goodix_ts_probe() start
[ 0.406762] Goodix-TS 3-005d: no max-x defined
[ 0.406797] Goodix-TS: probe of 3-005d failed with error -22
解决:在kernel/drivers/input/touchscreen/gt9xx/gt9xx.c
驱动中搜索“no max-x defined”的关键句;发现设备树中没有配置tp-size属性,根据代码的理解是选择触摸屏芯片的型号(若代码中没有对应的芯片型号,可以自己添加):
if (of_property_read_u32(np, "tp-size", &val)) {
dev_err(&client->dev, "no max-x defined\n");
return -EINVAL;
}
if (val == 89) {
m89or101 = TRUE;
gtp_change_x2y = TRUE;
gtp_x_reverse = FALSE;
gtp_y_reverse = TRUE;
} else if (val == 101) {
m89or101 = FALSE;
gtp_change_x2y = TRUE;
gtp_x_reverse = TRUE;
gtp_y_reverse = FALSE;
} else if (val == 911) {
m89or101 = FALSE;
bgt911 = TRUE;
gtp_change_x2y = TRUE;
gtp_x_reverse = FALSE;
gtp_y_reverse = TRUE;
} else if (val == 970) {
m89or101 = FALSE;
bgt911 = FALSE;
bgt970 = TRUE;
gtp_change_x2y = FALSE;
gtp_x_reverse = FALSE;
gtp_y_reverse = TRUE;
} else if (val == 910) {
m89or101 = FALSE;
bgt911 = FALSE;
bgt970 = FALSE;
bgt910 = TRUE;
gtp_change_x2y = TRUE;
gtp_x_reverse = FALSE;
gtp_y_reverse = TRUE;
}
在设备树文件/kernel/arch/arm/boot/dts/rv1109-38-v10-spi-nand.dts
修改增加tp-size
为如下:
&i2c3 {
status = "okay";
clock-frequency = <400000>;
pinctrl-names = "default";
pinctrl-0 = <&i2c3m1_xfer>;
gt9xx: gt9xx@5d {
compatible = "goodix,gt9xx";
reg = <0x5d>;
// gtp_ics_slot_report;
touch-gpio = <&gpio2 RK_PA6 IRQ_TYPE_EDGE_RISING>;
reset-gpio = <&gpio2 RK_PD6 GPIO_ACTIVE_HIGH>;
max-x = <1024>;
max-y = <600>;
tp-size = <911>;
// power-supply = <&vcc18_lcd_n>;
};
};
解决了:
[ 0.403886] i2c /dev entries driver
[ 0.407113] goodix_ts_probe() start
[ 0.407181] Goodix-TS 3-005d: 3-005d supply tp not found, using dummy regulator
[ 0.407292] Goodix-TS 3-005d: Linked as a consumer to regulator.0
[ 0.579130] input: goodix-ts as /devices/platform/ff520000.i2c/i2c-3/3-005d/input/input0
"tp-size” 这个参数表面看是 tp 的尺寸,实际在代码中通过这个参数来选择配置信息和触摸调整,在源码中根据 tp-size 设置 tp 方向是否需要镜像、切换,还有需要使用的配置参数。
如果 bgt927 设置为 TRUE,其他的 bgtxxx 都要设置 FALSE
开始调试时,下面三个参数都设置为 FALSE,然后根据 bgt927 选择配置参数,编译烧录后根据实际现象再调整下面三个参数
gtp_change-x2y:x、y交换方向
gtp_x_reverse:x 方向坐标镜像
gtp_y_reverse:y 方向左边镜像
if (val == 89) {
m89or101 = TRUE;
gtp_change_x2y = TRUE;
gtp_x_reverse = FALSE;
gtp_y_reverse = TRUE;
} else if (val == 101) {
m89or101 = FALSE;
gtp_change_x2y = TRUE;
gtp_x_reverse = TRUE;
gtp_y_reverse = FALSE;
} else if (val == 911) {
m89or101 = FALSE;
bgt911 = TRUE;
gtp_change_x2y = TRUE;
gtp_x_reverse = FALSE;
gtp_y_reverse = TRUE;
} else if (val == 970) {
m89or101 = FALSE;
bgt911 = FALSE;
bgt970 = TRUE;
gtp_change_x2y = FALSE;
gtp_x_reverse = FALSE;
gtp_y_reverse = TRUE;
} else if (val == 910) {
m89or101 = FALSE;
bgt911 = FALSE;
bgt970 = FALSE;
bgt910 = TRUE;
gtp_change_x2y = TRUE;
gtp_x_reverse = FALSE;
gtp_y_reverse = TRUE;
}
val是读取设备树里的tp-size来获取的:用于调节触摸xy轴
二、触摸屏可以触摸,但是x轴数据反了
gt9xx.c驱动里面有调整X轴和Y轴数据方向代码,只需要修改下驱动即可;
m89or101 = FALSE;
bgt9271 = TRUE;
gtp_change_x2y = FALSE; ===>X轴和Y轴数据交换
gtp_x_reverse = TRUE; ===>X轴数据反转
gtp_y_reverse = TRUE; ===>XY轴数据反转
如果上面配置修改没有起作用,看下代码哪里做了判断,修改如下即可触摸正常:
//if (!bgt911 && !bgt970) {
if (gtp_x_reverse)
x = ts->abs_x_max - x;
if (gtp_y_reverse)
y = ts->abs_y_max - y;
// }
三、可以触摸了,但是Y轴数据跳变,几乎只有一半的屏幕是可以正常滑动的
参考:RK3399触摸不准,修改drivers中gt9xx.h的cfg
文件目录kernel/drivers/input/touchscreen/gt9xx/gt9xx.h
打开这个调试宏
#define DEBUG_SWITCH 1
Debug看日志
[ 0.403131] <<-GTP-INFO->> GTP driver installing...
[ 0.403670] i2c /dev entries driver
[ 0.406933] goodix_ts_probe() start
[ 0.406968] <<-GTP-INFO->> GTP Driver Version: V2.2<2014/01/14>
[ 0.406983] <<-GTP-INFO->> GTP I2C Address: 0x5d
[ 0.407028] Goodix-TS 3-005d: 3-005d supply tp not found, using dummy regulator
[ 0.407138] Goodix-TS 3-005d: Linked as a consumer to regulator.0
[ 0.432077] <<-GTP-INFO->> Guitar reset
[ 0.556023] <<-GTP-INFO->> Chip Type: GOODIX_GT9
[ 0.556497] <<-GTP-INFO->> IC Version: 911_1060
[ 0.556524] <<-GTP-INFO->> <gtp_init_panel>_1429
[ 0.556524]
[ 0.556551] <<-GTP-DEBUG->> [1459]Config Groups' Lengths: 186, 0, 0, 0, 0, 0
[ 0.556888] <<-GTP-INFO->> CTP_CONFIG_GROUP1 used, config length: 186
[ 0.557242] <<-GTP-DEBUG->> [1534]CFG_GROUP1 Config Version: 67, 0x43; IC Config Version: 65, 0x41
[ 0.557269] <<-GTP-INFO->> <gtp_init_panel>_1538
[ 0.557269]
[ 0.557297] <<-GTP-INFO->> <gtp_init_panel>_1603 <4096, 4096>
[ 0.557297]
[ 0.557315] <<-GTP-INFO->> <gtp_init_panel>_1605
[ 0.557315]
[ 0.557332] <<-GTP-INFO->> <gtp_init_panel>_1644
[ 0.557332]
[ 0.557353] <<-GTP-INFO->> Driver send config.
[ 0.563126] <<-GTP-INFO->> X_MAX: 4096, Y_MAX: 4096, TRIGGER: 0x01
[ 0.578615] <<-GTP-INFO->> create proc entry gt9xx_config success
[ 0.578938] input: goodix-ts as /devices/platform/ff520000.i2c/i2c-3/3-005d/input/input0
[ 0.579234] <<-GTP-DEBUG->> [1870]INT trigger type:1
[ 0.579560] <<-GTP-INFO->> <gtp_request_irq>_1884 ts->irq=81 ret = 0
[ 0.579560]
[ 0.579596] <<-GTP-INFO->> <gtp_request_irq>_1914 ts->irq=81 ret = 0
[ 0.579596]
[ 0.579618] <<-GTP-INFO->> GTP works in interrupt mode.
这句话:
[ 0.563126] <<-GTP-INFO->> X_MAX: 4096, Y_MAX: 4096, TRIGGER: 0x01
那问题就很明显了,应该是cfg不对,X轴和Y轴的最大尺寸是错的!
根据文件kernel/drivers/input/touchscreen/gt9xx/gt9xx_cfg.h
#ifndef _GOODIX_GT9XX_CFG_H_
#define _GOODIX_GT9XX_CFG_H_
/* CFG for GT911 */
u8 gtp_dat_gt11[] = {
/* <1200, 1920>*/
#include "WGJ89006B_GT911_Config_20140625_085816_0X43.cfg"
};
u8 gtp_dat_8_9[] = {
/* TODO:Puts your update firmware data here! */
/* <1920, 1200> 8.9 */
/* #include "WGJ89006B_GT9271_Config_20140625_085816_0X41.cfg" */
/* #include "WGJ10162_GT9271_Config_20140820_182456.cfg" */
#include "WGJ10162B_GT9271_1060_Config_20140821_1341110X42.cfg"
};
u8 gtp_dat_8_9_1[] = {
#include "GT9271_Config_20170526.cfg"
};
u8 gtp_dat_9_7[] = {
/* <1536, 2048> 9.7 */
#include "GT9110P_Config_20160217_1526_2048_97.cfg"
};
u8 gtp_dat_10_1[] = {
/* TODO:Puts your update firmware data here! */
/* <1200, 1920> 10.1 */
#include "WGJ10187_GT9271_Config_20140623_104014_0X41.cfg"
};
u8 gtp_dat_7[] = {
/* TODO:Puts your update firmware data here! */
/* <1024, 600> 7.0 */
#include "WGJ10187_GT910_Config_20140623_104014_0X41.cfg"
};
#endif /* _GOODIX_GT9XX_CFG_H_ */
对应的配置文件gtp_dat_gt11
居然用的分辨率是<1200, 1920>
,所以确定是:kernel/drivers/input/touchscreen/gt9xx/gt9xx_cfg.h
文件里面的配置出错了!
需要找供应商要触摸屏的cfg文件,不然无解!
三、汇顶触摸屏配置文件解析
参考:汇顶GT9xxx触摸配置
使用汇顶Gt9xxx触摸屏,需要修改 drivers/input/touchscreen/gt9xxnewgt9xx.h 来更改分辨率
测试校验和的工具:
#include <QCoreApplication>
#include <stdio.h>
#include <QDebug>
uint8_t CTP_CFG_GROUP1[]= {\
0x00,0x00,0x04,0x58,0x02,0x0A,0x0D,0x00,0x01,0x0A,
0x1E,0x0F,0x58,0x41,0x03,0x05,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x8C,0x2E,0x0E,
0x2F,0x31,0xEB,0x04,0x00,0x00,0x00,0x22,0x02,0x1D,
0x00,0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,
0x00,0x1E,0x50,0x94,0xC5,0x02,0x07,0x00,0x00,0x04,
0xC8,0x21,0x00,0xAA,0x28,0x00,0x90,0x31,0x00,0x7C,
0x3B,0x00,0x6C,0x48,0x00,0x6C,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,0x02,0x04,0x06,0x08,0x0A,0x0C,0x0E,0x10,
0x12,0x14,0x16,0x18,0x1A,0x1C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x02,0x04,0x06,0x08,0x0A,0x0C,0x0F,
0x10,0x12,0x13,0x14,0x16,0x18,0x1C,0x1D,0x1E,0x1F,
0x20,0x21,0x22,0x24,0x26,0x28,0x29,0x2A,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x0F,0x01};
uint8_t CTP_CFG_GROUP2[]= {\
0x42,0x00,0x05,0x20,0x03,0x0A,0x3D,0x00,0x01,0x08,\
0x28,0x0F,0x50,0x32,0x03,0x05,0x00,0x00,0x00,0x00,\
0x00,0x00,0x00,0x17,0x19,0x1D,0x14,0x8D,0x2D,0x88,\
0x1E,0x20,0x31,0x0D,0x00,0x00,0x00,0x42,0x03,0x1D,\
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
0x00,0x14,0x2D,0x94,0xD5,0x02,0x07,0x00,0x00,0x04,\
0xAF,0x15,0x00,0x95,0x19,0x00,0x80,0x1E,0x00,0x70,\
0x23,0x00,0x63,0x29,0x00,0x63,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,0x00,0x01,0x04,0x05,0x06,0x07,0x08,0x09,\
0x0C,0x0D,0x0E,0x0F,0x10,0x11,0x14,0x15,0xFF,0xFF,\
0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
0x00,0x00,0x00,0x02,0x04,0x06,0x07,0x08,0x0A,0x0C,\
0x0F,0x10,0x11,0x12,0x13,0x19,0x1B,0x1C,0x1E,0x1F,\
0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0xFF,0xFF,\
0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,\
0x00,0x00,0x00,0x00,0xEE,0x01};
uint8_t SumCheck(uint8_t *data,int data_len)
{
uint8_t sum_check = 0;
for(int i = 0;(i<data_len)&&(i<1000);i++)
{
sum_check += data[i];
}
sum_check = ~sum_check;
sum_check += 1;
return sum_check;
}
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
uint8_t sum_check = 0;
uint8_t *list[2] = {CTP_CFG_GROUP1,CTP_CFG_GROUP2};
for(int i = 0;i<2;i++)
{
sum_check = SumCheck(list[i],184);
printf("-------------num:%d----------\n",i+1);
printf("lcd_x_pix = %d\n",(list[i][1])|list[i][2]<<8);
printf("lcd_y_pix = %d\n",(list[i][3])|list[i][4]<<8);
printf("sum_check = 0x%2x\n",sum_check);
printf("sum = 0x%2x\n",list[i][184]);
if(sum_check == list[i][184])
printf("check ok\n");
else
printf("check error!!!\n");
}
return a.exec();
}
四、使用新的配置文件
4.1 新配置解决问题
千方百计搞到一个可以使用的配置文件。
GT911.cfg
0x41,0x00,0x04,0x58,0x02,0x0A,0x3C,0x00,0x02,0x54,0x28,0x0F,0x50,0x2D,0x03,0x05,0x00,0x00,0x00,0x00,0x40,0x00,0x04,0x18,0x1A,0x1E,0x14,0x87,0x28,0x0A,0x3C,0x44,0x15,0x0E,0x00,0x00,0x00,0xA9,0x03,0x1C,0x00,0x01,0x00,0x00,0x00,0x00,0xFF,0x5D,0x66,0x98,0x32,0x28,0x50,0x94,0xC5,0x02,0x07,0x00,0x00,0x01,0xA1,0x2A,0x00,0x91,0x31,0x00,0x85,0x38,0x00,0x7A,0x41,0x00,0x72,0x4A,0x00,0x72,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,0x02,0x04,0x06,0x08,0x0A,0x0C,0x0E,0x10,0x12,0x14,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x04,0x06,0x08,0x0A,0x0C,0x1D,0x1E,0x1F,0x20,0x21,0x22,0x24,0x26,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,0x12,0x01
终于可以用了!
最后的配置(kernel/drivers/input/touchscreen/gt9xx/gt9xx_cfg.h
):
#ifndef _GOODIX_GT9XX_CFG_H_
#define _GOODIX_GT9XX_CFG_H_
/* CFG for GT911 */
u8 gtp_dat_gt11[] = {
/* <1200, 1920>*/
// #include "WGJ89006B_GT911_Config_20140625_085816_0X43.cfg"
/* <1024, 600> 7.0 */
#include "GT911.cfg"
};
.....
gt9xx.c
...
if (val == 89) {
m89or101 = TRUE;
gtp_change_x2y = TRUE;
gtp_x_reverse = FALSE;
gtp_y_reverse = TRUE;
} else if (val == 101) {
m89or101 = FALSE;
gtp_change_x2y = TRUE;
gtp_x_reverse = TRUE;
gtp_y_reverse = FALSE;
} else if (val == 911) {
m89or101 = FALSE;
bgt911 = TRUE;
gtp_change_x2y = FALSE;
gtp_x_reverse = TRUE;
gtp_y_reverse = TRUE;
} else if (val == 970) {
m89or101 = FALSE;
bgt911 = FALSE;
bgt970 = TRUE;
gtp_change_x2y = FALSE;
gtp_x_reverse = FALSE;
gtp_y_reverse = FALSE;
} else if (val == 910) {
m89or101 = FALSE;
bgt911 = FALSE;
bgt970 = FALSE;
bgt910 = TRUE;
gtp_change_x2y = TRUE;
gtp_x_reverse = FALSE;
gtp_y_reverse = TRUE;
}
ts->tp_regulator = devm_regulator_get(&client->dev, "tp");
if (IS_ERR(ts->tp_regulator)) {
dev_err(&client->dev, "failed to get regulator, %ld\n",
PTR_ERR(ts->tp_regulator));
return PTR_ERR(ts->tp_regulator);
}
ret = regulator_enable(ts->tp_regulator);
if (ret < 0)
GTP_ERROR("failed to enable tp regulator\n");
msleep(20);
ts->irq_pin = of_get_named_gpio_flags(np, "touch-gpio", 0, (enum of_gpio_flags *)(&ts->irq_flags));
ts->rst_pin = of_get_named_gpio_flags(np, "reset-gpio", 0, &rst_flags);
ts->pwr_pin = of_get_named_gpio_flags(np, "power-gpio", 0, &pwr_flags);
//ts->tp_select_pin = of_get_named_gpio_flags(np, "tp-select-gpio", 0, &tp_select_flags);
/* if (of_property_read_u32(np, "max-x", &val)) {
dev_err(&client->dev, "no max-x defined\n");
return -EINVAL;
}
//ts->abs_x_max = val;
if (of_property_read_u32(np, "max-y", &val)) {
dev_err(&client->dev, "no max-y defined\n");
return -EINVAL;
}*/
//ts->abs_y_max = val;
if (of_property_read_u32(np, "configfile-num", &val)) {
ts->cfg_file_num = 0;
} else {
ts->cfg_file_num = val;
}
ts->pendown =PEN_RELEASE;
ts->client = client;
...
设备树(rv1109-38-v10-spi-nand.dts)相关的部分:
&dsi {
status = "okay";
rockchip,lane-rate = <480>;
panel@0 {
compatible = "simple-panel-dsi";
reg = <0>;
//backlight = <&backlight>;
//power-supply = <&vcc18_lcd_n>;
prepare-delay-ms = <5>;
reset-delay-ms = <1>;
init-delay-ms = <80>;
disable-delay-ms = <10>;
unprepare-delay-ms = <5>;
width-mm = <165>;
height-mm = <100>;
dsi,flags = <(MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST | MIPI_DSI_MODE_LPM | MIPI_DSI_MODE_EOT_PACKET)>;
dsi,format = <MIPI_DSI_FMT_RGB888>;
dsi,lanes = <4>;
panel-init-sequence = [
05 64 01 11
05 78 01 29
];
display-timings {
native-mode = <&timing0>;
timing0: timing0 {
clock-frequency = <33359000>;
hactive = <1024>;
vactive = <600>;
hfront-porch = <50>;
hsync-len = <7>;
hback-porch = <50>;
vfront-porch = <18>;
vsync-len = <5>;
vback-porch = <17>;
hsync-active = <0>;
vsync-active = <0>;
de-active = <0>;
pixelclk-active = <0>;
};
};
ports {
#address-cells = <1>;
#size-cells = <0>;
port@0 {
reg = <0>;
panel_in_dsi: endpoint {
remote-endpoint = <&dsi_out_panel>;
};
};
};
};
ports {
#address-cells = <1>;
#size-cells = <0>;
port@1 {
reg = <1>;
dsi_out_panel: endpoint {
remote-endpoint = <&panel_in_dsi>;
};
};
};
};
&i2c3 {
status = "okay";
clock-frequency = <400000>;
pinctrl-names = "default";
pinctrl-0 = <&i2c3m1_xfer>;
gt9xx: gt9xx@5d {
compatible = "goodix,gt9xx";
reg = <0x5d>;
gtp_ics_slot_report;
touch-gpio = <&gpio2 RK_PA6 IRQ_TYPE_EDGE_RISING>;
reset-gpio = <&gpio2 RK_PD6 GPIO_ACTIVE_HIGH>;
//max-x = <600>;
//max-y = <1024>;
tp-size = <911>;
// power-supply = <&vcc18_lcd_n>;
status ="okay";
};
};
4.2 测试触摸的方法
在kernel增加frame buffer(/dev/fb0)设备节点
RV1126文件系统下面没有/dev/fb0设备节点:
进入kernel
cd kernel
make ARCH=arm rv1126_defconfig
make ARCH=arm menuconfig
进入配置:
修改位置一,如下:
位置二,如下:
之后重新编译生成固件烧写到开发板。
make ARCH=arm savedefconfig // 将.config 保存为 deconfig
cp defconfig arch/arm/configs/rv1126_defconfig
cd ..
./build.sh kernel
在buildroot中配置增加tslib
在上电后在/etc/profile文件中增加字段:
vi /etc/profile
export TSLIB_TSDEVICE=/dev/input/event0
export TSLIB_CALIBFILE=/etc/pointercal
export TSLIB_CONFFILE=/etc/ts.conf
export TSLIB_PLUGINDIR=/usr/lib/ts
export TSLIB_FBDEVICE=/dev/fb0
export TSLIB_CONSOLEDEVICE=none
4.3 测试
- 校准:
ts_calibrate
- 打印原始值:
ts_print_mt
- 确定左上角是
0,0
,右下角是1024,600
- 观察数据,手指从左上角连续滑动到右上角,是否数据是连续增加的?但凡有不连续,掉数据、跳数据的都是有问题的。
- 确定左上角是
五、工作一段时间触摸屏驱动崩溃
在上面触摸屏数据没有问题后,驱动工作一段时间就崩溃,驱动崩溃的log信息如下:
[ 7205.681477] irq 80: nobody cared (try booting with the "irqpoll" option)
[ 7205.681531] CPU: 0 PID: 367 Comm: dbus-daemon Tainted: G O 4.19.111 #2
[ 7205.681548] Hardware name: Generic DT based system
[ 7205.681592] [<b010f408>] (unwind_backtrace) from [<b010b96c>] (show_stack+0x10/0x14)
[ 7205.681623] [<b010b96c>] (show_stack) from [<b089b5a4>] (dump_stack+0x90/0xa4)
[ 7205.681654] [<b089b5a4>] (dump_stack) from [<b016f8a8>] (__report_bad_irq+0x28/0xcc)
[ 7205.681681] [<b016f8a8>] (__report_bad_irq) from [<b016fcb0>] (note_interrupt+0x28c/0x2dc)
[ 7205.681710] [<b016fcb0>] (note_interrupt) from [<b016cd8c>] (handle_irq_event_percpu+0x5c/0x7c)
[ 7205.681741] [<b016cd8c>] (handle_irq_event_percpu) from [<b016cde4>] (handle_irq_event+0x38/0x5c)
[ 7205.681771] [<b016cde4>] (handle_irq_event) from [<b0170b30>] (handle_edge_irq+0x134/0x1e4)
[ 7205.681798] [<b0170b30>] (handle_edge_irq) from [<b016bf68>] (generic_handle_irq+0x24/0x34)
[ 7205.681829] [<b016bf68>] (generic_handle_irq) from [<b03e5250>] (rockchip_irq_demux+0x10c/0x1bc)
[ 7205.681858] [<b03e5250>] (rockchip_irq_demux) from [<b016bf68>] (generic_handle_irq+0x24/0x34)
[ 7205.681887] [<b016bf68>] (generic_handle_irq) from [<b016c53c>] (__handle_domain_irq+0x5c/0xb4)
[ 7205.681919] [<b016c53c>] (__handle_domain_irq) from [<b03d6d8c>] (gic_handle_irq+0x3c/0x78)
[ 7205.681949] [<b03d6d8c>] (gic_handle_irq) from [<b0101a78>] (__irq_svc+0x58/0x8c)
[ 7205.681967] Exception stack(0xdcc23cd8 to 0xdcc23d20)
[ 7205.681985] 3cc0: 9e9654d6 00000000
[ 7205.682009] 3ce0: 3e2b9000 b0c52d00 00000202 00000013 dcc22000 00000000 dcc23d28 dcc22000
[ 7205.682033] 3d00: dd364500 dcc23e2c 05355555 dcc23d28 0000000b b010215c 400f0153 ffffffff
[ 7205.682061] [<b0101a78>] (__irq_svc) from [<b010215c>] (__do_softirq+0xa4/0x274)
[ 7205.682092] [<b010215c>] (__do_softirq) from [<b012ac98>] (irq_exit+0xdc/0x10c)
[ 7205.682123] [<b012ac98>] (irq_exit) from [<b016c540>] (__handle_domain_irq+0x60/0xb4)
[ 7205.682153] [<b016c540>] (__handle_domain_irq) from [<b03d6d8c>] (gic_handle_irq+0x3c/0x78)
[ 7205.682181] [<b03d6d8c>] (gic_handle_irq) from [<b0101a78>] (__irq_svc+0x58/0x8c)
[ 7205.682198] Exception stack(0xdcc23da8 to 0xdcc23df0)
[ 7205.682219] 3da0: eef0c140 00000002 00000000 0000a863 eef0c140 dd30c8c0
[ 7205.682243] 3dc0: b0d0b980 00000000 b08b15c4 dd30c8c0 dd364500 dcc23e2c 00000000 dcc23df8
[ 7205.682262] 3de0: b01479b8 b08b6244 600f0053 ffffffff
[ 7205.682292] [<b0101a78>] (__irq_svc) from [<b08b6244>] (_raw_spin_unlock_irq+0x1c/0x4c)
[ 7205.682324] [<b08b6244>] (_raw_spin_unlock_irq) from [<b01479b8>] (finish_task_switch+0x70/0x204)
[ 7205.682352] [<b01479b8>] (finish_task_switch) from [<b08b15c4>] (__schedule+0x1fc/0x580)
[ 7205.682380] [<b08b15c4>] (__schedule) from [<b08b1998>] (schedule+0x50/0xb4)
[ 7205.682410] [<b08b1998>] (schedule) from [<b08b5758>] (schedule_hrtimeout_range_clock+0x150/0x15c)
[ 7205.682440] [<b08b5758>] (schedule_hrtimeout_range_clock) from [<b08b577c>] (schedule_hrtimeout_range+0x18/0x20)
[ 7205.682472] [<b08b577c>] (schedule_hrtimeout_range) from [<b025074c>] (do_epoll_wait+0x38c/0x510)
[ 7205.682502] [<b025074c>] (do_epoll_wait) from [<b0101000>] (ret_fast_syscall+0x0/0x4c)
[ 7205.682520] Exception stack(0xdcc23fa8 to 0xdcc23ff0)
[ 7205.682542] 3fa0: 00000000 00000074 00000003 ae965608 00000040 ffffffff
[ 7205.682565] 3fc0: 00000000 00000074 0002e4ec 000000fc 00000001 ae965a48 00000002 00000053
[ 7205.682585] 3fe0: 000000fc ae9655e8 a6e4c9c5 a6dcd706
[ 7205.682599] handlers:
[ 7205.682624] [<96dc5706>] irq_default_primary_handler threaded [<ce5e0b64>] goodix_ts_irq_handler
[ 7205.682651] Disabling IRQ #80
解决方法:
在GT911.cfg配置文件中根据下面的内容
将第7个字节中的触发方式改成上升沿触发,就好了。改完以后要将第184位的校验码减1。或者按照上面的校验工具计算一下。
六、在LVGL中的触摸修改:上下滑动方向相反
在开发板中运行例程lv_port_linux_frame_buffer,触摸左右滑动正常,但是上下滑动是反的。直接修改:
从触摸屏事件回调evdev_read
进去:
evdev_init();
static lv_indev_drv_t indev_drv_1;
lv_indev_drv_init(&indev_drv_1); /*Basic initialization*/
indev_drv_1.type = LV_INDEV_TYPE_POINTER;
/*This function will be called periodically (by the library) to get the mouse position and state*/
indev_drv_1.read_cb = evdev_read; // 这里修改
lv_indev_t *mouse_indev = lv_indev_drv_register(&indev_drv_1);
修改:
void evdev_read(lv_indev_drv_t * drv, lv_indev_data_t * data)
{
struct input_event in;
while(read(evdev_fd, &in, sizeof(struct input_event)) > 0) {
if(in.type == EV_REL) {
if(in.code == REL_X)
#if EVDEV_SWAP_AXES
evdev_root_y += in.value;
#else
evdev_root_x += in.value;
#endif
else if(in.code == REL_Y)
#if EVDEV_SWAP_AXES
evdev_root_x += in.value;
#else
evdev_root_y += in.value;
#endif
} else if(in.type == EV_ABS) {
if(in.code == ABS_X)
#if EVDEV_SWAP_AXES
evdev_root_y = in.value;
#else
evdev_root_x = in.value;
#endif
else if(in.code == ABS_Y)
#if EVDEV_SWAP_AXES
evdev_root_x = in.value;
#else
evdev_root_y = in.value;
#endif
else if(in.code == ABS_MT_POSITION_X)
#if EVDEV_SWAP_AXES
evdev_root_y = in.value;
#else
evdev_root_x = in.value;
#endif
else if(in.code == ABS_MT_POSITION_Y)
#if EVDEV_SWAP_AXES
evdev_root_x = 600-in.value; // 在这里修改
#else
evdev_root_y = in.value;
#endif
else if(in.code == ABS_MT_TRACKING_ID) {
if(in.value == -1)
evdev_button = LV_INDEV_STATE_REL;
else if(in.value == 0)
evdev_button = LV_INDEV_STATE_PR;
}
}
...
}
触摸屏事件是ABS_MT_POSITION_X
和ABS_MT_POSITION_Y
这里,由于上下滑动是相反的,所以直接在ABS_MT_POSITION_Y
上下方向的最大值600减去得到的值就可以了。
将
else if(in.code == ABS_MT_POSITION_Y)
#if EVDEV_SWAP_AXES
evdev_root_x = in.value; // 在这里修改
#else
evdev_root_y = in.value;
#endif
改成:
else if(in.code == ABS_MT_POSITION_Y)
#if EVDEV_SWAP_AXES
evdev_root_x = 600-in.value; // 在这里修改
#else
evdev_root_y = in.value;
#endif
滑动就都正常了。
复盘了一下,这个问题画了一个礼拜才解决!花的时间35H+。不过收获真的太多了!第一次深入研究这个驱动这么久!