android 4.0已經漸漸流行,很多方案都已經基於其上,android 4.0的linux內核版本已經更新爲linux 3.0,這個變化導致和內核直接接觸的驅動需要或多或少的變化,以下描述的是觸摸設備驅動的一些小變化:
1.當一個(這時候的情境應該是多點觸摸的情況)手指或是觸摸工具擡起(UP)時,他應該立即消失在多點出沒的同步報告中,當所有的工具或手指擡起,驅動應該立即發送一個“空”同步消息,使用SYN_MT_REPORT其次是SYN_REPORT。
之前的版本是向上報告一個presssure爲0的消息,現在新的多點觸摸協議已經不再兼容舊的協議了。2.物理接觸或是信號強度將使用ABS_MT_PRESSURE上報。
之前的版本是用ABS_MT_TOUCH_MAJOR上報這個消息,同樣,舊的方式也已經不被兼容了。
3.觸摸接觸面積使用ABS_MT_TOUCH_MAJOR向上報告
舊的版本使用ABS_MT_TOOL_MAJOR向上報告,舊的方式也已經不被兼容了。
觸摸設備驅動程序不再需要特定的Android定製。依靠標準的Linux輸入協議,Android可以更廣泛支持觸摸外設,如外部HID多點觸摸觸摸屏,使用未修改的驅動程序。
example:
static irqreturn_t xxx_ts_irq_handler(int irq, void *dev_id)
{
struct xxx_ts_data *ts = dev_id;
struct xxx_ts_finger *finger = ts->finger;
struct input_dev *input_dev = ts->input_dev;
int count = 0;
int i, ret;
ret = xxx_ts_read_data(ts);
if (ret < 0)
goto end;
/* multi touch protocol */
for (i = 0; i < MAX_FINGERS; i++) {
if (!finger[i].is_valid)
continue;
input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR, finger[i].t);
input_report_abs(input_dev, ABS_MT_POSITION_X, finger[i].x);
input_report_abs(input_dev, ABS_MT_POSITION_Y, finger[i].y);
input_mt_sync(input_dev);
count++;
}
/* SYN_MT_REPORT only if no contact */
if (!count)
input_mt_sync(input_dev);
/* SYN_REPORT */
input_sync(input_dev);
end:
return IRQ_HANDLED;
}