多点触控、坐标与触摸屏框架

多点触控、坐标与触摸屏框架

1. 触摸分类

  • touchscreen:直接映射显示区域,INPUT_PROP_DIRECT
  • touchpad:间接指针,INPUT_PROP_POINTER
  • stylus/tablet:笔、压力、倾角、工具类型。

分类错误会影响 libinput手势和坐标映射。

2. Protocol B

现代多点触控使用 slots:

1
2
3
4
5
6
ABS_MT_SLOT
ABS_MT_TRACKING_ID
ABS_MT_POSITION_X/Y
ABS_MT_PRESSURE
...
SYN_REPORT

driver:

1
2
3
4
5
6
input_mt_init_slots()
input_mt_slot()
input_mt_report_slot_state()
input_report_abs()
input_mt_sync_frame()
input_sync()

tracking ID标识接触生命周期,不等同于 slot编号。

3. 旧 Protocol A

SYN_MT_REPORT 分隔 contacts,没有 slot状态。仅兼容旧硬件;新驱动应优先 Protocol B。

4. 坐标

input_set_abs_params() 设置 min/max/fuzz/flat。touchscreen_parse_properties() 读取:

  • touchscreen-size-x/y;
  • min-x/y;
  • inverted-x/y;
  • swapped-x-y。

随后 touchscreen_report_pos() 可统一变换。

5. I2C触摸路径

1
2
3
4
5
6
7
8
IRQ
-> read report/frame
-> validate length/checksum
-> parse contacts
-> update slots
-> report BTN_TOUCH/tool keys
-> input_mt_sync_frame()
-> input_sync()

IRQ thread可睡眠并访问 I2C。中断顶半部不应进行长事务。

6. RK3588厂商驱动

公共板 DTS可见:

  • goodix,gt1x
  • hyn,3240
  • focaltech,fts

主配置启用多个厂商 driver。不同板可能在相同 I2C pins上并列定义多个候选节点;必须核对 status、实际 DT和硬件,避免地址/IRQ冲突。

7. 电源管理

suspend:

  • disable IRQ;
  • 进入 sleep或 gesture wake;
  • pinctrl sleep;
  • regulator/reset处理;
  • 清理 slots。

resume后应重新初始化并避免残留 touch。gesture wake需要 IRQ wake和输入策略协调。

8. 校准

电容触摸通常在控制器/firmware校准;Input Core只提供坐标范围和变换。显示旋转还可能由 compositor处理,不应在多个层重复 swap/invert。

9. 故障

  • ghost touch:供电/接地/EMI/firmware;
  • 坐标偏移:size/min配置;
  • 触点黏住:漏报 release或丢帧;
  • IRQ storm:极性错误;
  • resume无触摸:reset/power时序;
  • 多指错乱:tracking ID/slot复用错误。

文章互动

阅读 --

留言

0 条留言

正在加载留言…