RK Android7.1 移植gt9271 TP偏移
一.原理图
dts 配置
1 2 3 4 5 6 7 8 | goodix @14 { compatible = "goodix,gt9xx" ; reg = < 0x14 >; max-x = < 1280 >; max-y = < 800 >; tp-size= < 89 >; touch-gpio = <&gpio0 4 IRQ_TYPE_LEVEL_LOW>; rst-gpio = <&gpio0 3 GPIO_ACTIVE_HIGH>; |
通信失败
1 2 3 4 5 6 | [ 1.661711 ] <<-GTP-ERROR->> GTP i2c test failed time 4 . [ 1.675859 ] <<-GTP-ERROR->> I2C Read: 0x8047 , 1 bytes failed, errcode: - 6 ! Process reset. [ 1.758372 ] <<-GTP-ERROR->> GTP i2c test failed time 5 . [ 1.771698 ] <goodix_ts_probe>_2555 I2C communication ERROR! [ 1.771717 ] <goodix_ts_probe>_2623 prob error !!!!!!!!!!!!!!! [ 1.771787 ] rk3x-i2c ff3d0000.i2c: Initialized RK3xxx I2C bus at ffffff80099d4000 |
linux i2c 的通信函数i2c_transfer出错码
参考errno-base.h
#define EPERM 1 /* Operation not permitted */
#define ENOENT 2 /* No such file or directory */
#define ESRCH 3 /* No such process */
#define EINTR 4 /* Interrupted system call */
#define EIO 5 /* I/O error */
#define ENXIO 6 /* No such device or address */
#define E2BIG 7 /* Argument list too long */
#define ENOEXEC 8 /* Exec format error */
#define EBADF 9 /* Bad file number */
#define ECHILD 10 /* No child processes */
#define EAGAIN 11 /* Try again */
#define ENOMEM 12 /* Out of memory */
#define EACCES 13 /* Permission denied */
#define EFAULT 14 /* Bad address */
#define ENOTBLK 15 /* Block device required */
正常
1 2 3 | [ 1.298163 ] tp 00000000000000000000000000000 DPT [ 1.298163 ] [ 1.335636 ] input: goodix-ts as /devices/virtual/input/input1 |
三.kernel\drivers\input\touchscreen\GT9271\gt9xx.c
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | /******************************************************* Function: I2c probe. Input: client: i2c device struct. id: device id. Output: Executive outcomes. 0: succeed. *******************************************************/ static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id *id) { s32 ret = - 1 ; struct goodix_ts_data *ts; u16 version_info; struct device_node *np = client->dev.of_node; enum of_gpio_flags rst_flags, pwr_flags, tp_select_flags; unsigned long irq_flags; u32 val; printk( "___%s() start____ \n" , __func__); GTP_DEBUG_FUNC(); //do NOT remove these logs GTP_INFO( "GTP Driver Version: %s" , GTP_DRIVER_VERSION); GTP_INFO( "GTP Driver Built@%s, %s" , __TIME__, __DATE__); GTP_INFO( "GTP I2C Address: 0x%02x" , client->addr); i2c_connect_client = client; if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { GTP_ERROR( "I2C check functionality failed." ); return -ENODEV; } ts = kzalloc(sizeof(*ts), GFP_KERNEL); if (ts == NULL) { GTP_ERROR( "Alloc GFP_KERNEL memory failed." ); return -ENOMEM; } memset(ts, 0 , sizeof(*ts)); if (!np) { dev_err(&client->dev, "no device tree\n" ); return -EINVAL; } 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; mGtpChange_X2Y = TRUE; mGtp_X_Reverse = FALSE; mGtp_Y_Reverse = FALSE; } else if (val == 101 ){ m89or101 = TRUE; mGtpChange_X2Y = FALSE; mGtp_X_Reverse = FALSE; mGtp_Y_Reverse = FALSE; } 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; ts->pendown =PEN_RELEASE; ts->client = client; INIT_WORK(&ts->work, goodix_ts_work_func); ts->client = client; spin_lock_init(&ts->irq_lock); // 2.6.39 later // ts->irq_lock = SPIN_LOCK_UNLOCKED; // 2.6.39 & before # if GTP_ESD_PROTECT ts->clk_tick_cnt = 2 * HZ; // HZ: clock ticks in 1 second generated by system GTP_DEBUG( "Clock ticks for an esd cycle: %d" , ts->clk_tick_cnt); spin_lock_init(&ts->esd_lock); // ts->esd_lock = SPIN_LOCK_UNLOCKED; #endif i2c_set_clientdata(client, ts); ts->gtp_rawdiff_mode = 0 ; ret = gtp_request_io_port(ts); if (ret < 0 ) { GTP_ERROR( "GTP request IO port failed." ); //return ret; goto probe_init_error_requireio; } if (gpio_get_value(ts->tp_select_pin)) //WGJ { printk( "tp 11111111111111111111111111111 WGJ\n\n" ); mGtp_X_Reverse = FALSE; mGtp_Y_Reverse = FALSE; } else //DPT { printk( "tp 00000000000000000000000000000 DPT\n\n" ); mGtpChange_X2Y = TRUE; mGtp_X_Reverse = TRUE; //FALSE; mGtp_Y_Reverse = FALSE; } |
mGtpChange_X2Y = TRUE;
mGtp_X_Reverse = TRUE; X镜像
mGtp_Y_Reverse = FALSE; Y镜像
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | /******************************************************* Function: Report touch point event Input: ts: goodix i2c_client private data id: trackId x: input x coordinate y: input y coordinate w: input pressure Output: None. *********************************************************/ static void gtp_touch_down(struct goodix_ts_data* ts,s32 id,s32 x,s32 y,s32 w) { if (mGtpChange_X2Y){ GTP_SWAP(x, y); } if (mGtp_X_Reverse){ x = ts->abs_x_max - x; } if (mGtp_Y_Reverse){ y = ts->abs_y_max - y; } |
分类:
RockChip
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】