touch_screen
linux kernel touch screen driver编写,需要用到i2c子系统、中断子系统、input子系统,这三个子系统前面文档已经介绍过如何操作,此处只介绍input子系统的多点触摸协议,需要五步:
手动分配与设置 struct input_dev * 变量
注册 input device
向linux系统上报事件
注销与释放 input device
应用层测试
1. 手动分配与设置 struct input_dev * 变量
struct input_dev *inputDev;
inputDev = input_allocate_device(); // 分配
inputDev->name = "xxx_inputDev"; // 设置input device名字
__set_bit(EV_ABS, inputdev->evbit); // 设置事件类型
input_set_abs_params(inputdev, ABS_MT_POSITION_X, 0, 480, 0, 0);//设置x轴事件码, x轴范围0~480
input_set_abs_params(inputdev, ABS_MT_POSITION_Y, 0, 272, 0, 0);//设置y轴事件码, y轴范围0~272
input_mt_init_slots(inputdev, MAX_SUPPORT_POINTS, 0); // 初始化触摸点个数 MAX_SUPPORT_POINTS2. 注册 input device
input_register_device(inputDev); // 注册3. 向linux系统上报事件
一般在中断处理函数或下半部函数中上报事件
4. 注销与释放 input device
5. 应用层测试
通过hexdump测试
通过tslib测试
注意:驱动需要上传手指按下/松开状态,tslib画图功能才能正常使用,否则只能使用图形化显示坐标位置功能
Last updated
Was this helpful?