TP 调试
触摸 F5X06 GT818 mxt224
看资料了解触摸板的外部接口:中断 唤醒 复位 通讯方式
在i2c_board_info 中设置I2C 名字和地址
I2C_BOARD_INFO(FT5X06_DEV_NAME, 0x4c),
i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
通过名字就会初始化这个I2C器件
FT5X06_ts_init()
i2c_add_driver(&FT5X06_ts_driver);
进入FT5X06_ts_probe函数开始准备。
中间看是初始化 复位 上电 读取触摸IC的id 配置相应时间 力度等等 复制别人的
- static int cdtlcd_i2c_read_tp_info(void)
- {
- int rom_value,ret;
- unsigned char buf[8]={0};
- ret = cdtlcd_read_reg(FT5X0X_REG_FIRMID,buf); //读取 0xa5的固件ID
- if(ret < 0){
- return -1;
- }
- printk(FT5406_DEBUG_LEVEL "%s , firmware version[%0x h]: 0x%0x ",__func__,FT5X0X_REG_FIRMID,buf[0]);
- ret = cdtlcd_read_reg(FT5X0X_REG_FT5201ID,buf); //读取ft5406的 ID
- if(ret < 0){
- return -1;
- }
- printk(FT5406_DEBUG_LEVEL "%s , FT5201ID[%0x h]: 0x%0x ",__func__,FT5X0X_REG_FT5201ID,buf[0]);
- cdtlcd_set_reg(FT5X0X_REG_PMODE,PMODE_ACTIVE); //设置 0x00h = 0x00,为正常模式
- cdtlcd_read_reg(FT5X0X_REG_PMODE,buf);
- printk("FT5X0X_REG_PMODE=0x%x ",buf[0]);
- cdtlcd_read_reg(0x80,buf); //读取ft5406的灵敏度,此IC支持的触摸屏,触摸没反应基本需要调此参数。
- rom_value = buf[0];
- printk("read 0x80=0x%x ",buf[0]);
- cdtlcd_read_reg(0x88,buf); //上报频率,如何触摸感应太慢,可调节此地址。
- printk("read 0x88=0x%x ",buf[0]);
- {
- printk("write para to reg ");
- cdtlcd_set_reg(0x80,0x10); //设置 80h 值,s5pv210支持时,数值应小于0x3f,太大了触摸没反应
- cdtlcd_set_reg(0x88,0x9);
- cdtlcd_read_reg(0x80,buf);
- printk("read 0x80=0x%x ",buf[0]);
- cdtlcd_read_reg(0x88,buf);
- printk("read 0x88=0x%x ",buf[0]);
- }
- i2c.event.touch_point = TOUCH_POINT;
- i2c.event.pressure = PRESS_MAX;
- printk(FT5406_DEBUG_LEVEL "%s, max_tp: %d, max_btn: %d ", __func__,SCREEN_MAX_X ,SCREEN_MAX_Y );
- return ret;
开始创建工作函数用来读点上报 INIT_WORK(&ts->work, FT5X06_ts_work_func); 创建中断 当中断响应开始上报数据就是开始执行FT5X06_ts_work_func, ret = request_irq(client->irq, FT5X06_ts_irq_handler, irqflags, client->name, ts); 还要注册事件 input_set_abs_params(ts->input_dev, ABS_X, 0, FT5X06_X_RESOLUTION, 0, 0);
input_set_abs_params(ts->input_dev, ABS_Y, 0, FT5X06_Y_RESOLUTION, 0, 0);
input_set_abs_params(ts->input_dev, ABS_MT_POSITION_X, 0, FT5X06_X_RESOLUTION, 0, 0);
input_set_abs_params(ts->input_dev, ABS_MT_POSITION_Y, 0, FT5X06_Y_RESOLUTION, 0, 0);
input_set_abs_params(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0, MAX_FINGER_NUMBER, 0, 0);
input_set_abs_params(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0, MAX_PRESSURE, 0, 0);
就这样差不多了。 当点击开始中断会有响应会执行工作函数,开始读点,在上报坐标。 先读取是几点触摸,在读坐标。 event->touch_point = buf[2] & 0x07;// 000 0111
switch (event->touch_point) {
case 5:
event->x5 = (s16)(buf[0x1b] & 0x0F)<<8 | (s16)buf[0x1c];
event->y5 = (s16)(buf[0x1d] & 0x0F)<<8 | (s16)buf[0x1e];
#if CONFIG_VC088X_TOUCHSCREEN_ROTATE
vc088x_ts_rotate_proc(event->x5,event->y5,rotate_loc);
event->x5 = rotate_loc[0];
event->y5 = rotate_loc[1];
#endif
case 4:
event->x4 = (s16)(buf[0x15] & 0x0F)<<8 | (s16)buf[0x16];
event->y4 = (s16)(buf[0x17] & 0x0F)<<8 | (s16)buf[0x18];
#if CONFIG_VC088X_TOUCHSCREEN_ROTATE
vc088x_ts_rotate_proc(event->x4,event->y4,rotate_loc);
event->x4 = rotate_loc[0];
event->y4 = rotate_loc[1];
#endif
case 3:
event->x3 = (s16)(buf[0x0f] & 0x0F)<<8 | (s16)buf[0x10];
event->y3 = (s16)(buf[0x11] & 0x0F)<<8 | (s16)buf[0x12];
#if CONFIG_VC088X_TOUCHSCREEN_ROTATE
vc088x_ts_rotate_proc(event->x3,event->y3,rotate_loc);
event->x3 = rotate_loc[0];
event->y3 = rotate_loc[1];
#endif
case 2:
event->x2 = (s16)(buf[9] & 0x0F)<<8 | (s16)buf[10];
event->y2 = (s16)(buf[11] & 0x0F)<<8 | (s16)buf[12];
#if CONFIG_VC088X_TOUCHSCREEN_ROTATE
vc088x_ts_rotate_proc(event->x2,event->y2,rotate_loc);
event->x2 = rotate_loc[0];
event->y2 = rotate_loc[1];
#endif
case 1:
event->x1 = (s16)(buf[3] & 0x0F)<<8 | (s16)buf[4];
event->y1 = (s16)(buf[5] & 0x0F)<<8 | (s16)buf[6];
#if CONFIG_VC088X_TOUCHSCREEN_ROTATE
vc088x_ts_rotate_proc(event->x1,event->y1,rotate_loc);
event->x1 = rotate_loc[0];
event->y1 = rotate_loc[1];
#endif
break;
default:
return -1;
}
上报
switch(event->touch_point) {
case 5:
input_report_abs(data->input_dev, ABS_MT_TOUCH_MAJOR, event->pressure);
input_report_abs(data->input_dev, ABS_MT_POSITION_X, event->x5);
input_report_abs(data->input_dev, ABS_MT_POSITION_Y, event->y5);
input_report_abs(data->input_dev, ABS_MT_WIDTH_MAJOR, 1);
input_mt_sync(data->input_dev);
#ifdef VC8TPI_KEY_ENABLE
ft5x0x_report_key(data,4,event->x5,event->y5);
#endif
////printk("===x2 = %d,y2 = %d ==== ",event->x2,event->y2);
case 4:
input_report_abs(data->input_dev, ABS_MT_TOUCH_MAJOR, event->pressure);
input_report_abs(data->input_dev, ABS_MT_POSITION_X, event->x4);
input_report_abs(data->input_dev, ABS_MT_POSITION_Y, event->y4);
input_report_abs(data->input_dev, ABS_MT_WIDTH_MAJOR, 1);
input_mt_sync(data->input_dev);
#ifdef VC8TPI_KEY_ENABLE
ft5x0x_report_key(data,3,event->x4,event->y4);
#endif
////printk("===x2 = %d,y2 = %d ==== ",event->x2,event->y2);
case 3:
input_report_abs(data->input_dev, ABS_MT_TOUCH_MAJOR, event->pressure);
input_report_abs(data->input_dev, ABS_MT_POSITION_X, event->x3);
input_report_abs(data->input_dev, ABS_MT_POSITION_Y, event->y3);
input_report_abs(data->input_dev, ABS_MT_WIDTH_MAJOR, 1);
input_mt_sync(data->input_dev);
#ifdef VC8TPI_KEY_ENABLE
ft5x0x_report_key(data,2,event->x3,event->y3);
#endif
////printk("===x2 = %d,y2 = %d ==== ",event->x2,event->y2);
case 2:
input_report_abs(data->input_dev, ABS_MT_TOUCH_MAJOR, event->pressure);
input_report_abs(data->input_dev, ABS_MT_POSITION_X, event->x2);
input_report_abs(data->input_dev, ABS_MT_POSITION_Y, event->y2);
input_report_abs(data->input_dev, ABS_MT_WIDTH_MAJOR, 1);
input_mt_sync(data->input_dev);
#ifdef VC8TPI_KEY_ENABLE
ft5x0x_report_key(data,1,event->x2,event->y2);
#endif
////printk("===x2 = %d,y2 = %d ==== ",event->x2,event->y2);
case 1:
input_report_abs(data->input_dev, ABS_MT_TOUCH_MAJOR, event->pressure);
input_report_abs(data->input_dev, ABS_MT_POSITION_X, event->x1);
input_report_abs(data->input_dev, ABS_MT_POSITION_Y, event->y1);
input_report_abs(data->input_dev, ABS_MT_WIDTH_MAJOR, 1);
input_mt_sync(data->input_dev);
#ifdef VC8TPI_KEY_ENABLE
ft5x0x_report_key(data,0,event->x1,event->y1);
#endif
////printk("===x1 = %d,y1 = %d ==== ",event->x1,event->y1);
default:
////printk("==touch_point default = ");
break;
}
#else /* CONFIG_FT5X0X_MULTITOUCH*/
if (event->touch_point == 1) {
input_report_abs(data->input_dev, ABS_X, event->x1);
input_report_abs(data->input_dev, ABS_Y, event->y1);
input_report_abs(data->input_dev, ABS_PRESSURE, event->pressure);
}
input_report_key(data->input_dev, BTN_TOUCH, 1);
#endif /* CONFIG_FT5X0X_MULTITOUCH*/
input_sync(data->input_dev);
大部分就是个流程。
声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。
- 上一篇: C语言数组和链表删除元素速度比较
- 下一篇: JAVA中快速解析JSON对象里包含的JSON数组