在probe函数里会有
static s8 gtp_request_input_dev(struct goodix_ts_data *ts)
{
s8 ret = -1;
u8 index = 0;
ts->input_dev = input_allocate_device(); //先请求分配设备,初始化dev的lock
ts->input_dev->evbit[0] = BIT_MASK(EV_SYN) | BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS) ;
#if GTP_ICS_SLOT_REPORT
input_mt_init_slots(ts->input_dev, 16,0); // 最多上报多少个点
#else
ts->input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
#endif
__set_bit(INPUT_PROP_DIRECT, ts->input_dev->propbit);
#if GTP_HAVE_TOUCH_KEY
for (index = 0; index < GTP_MAX_KEY_NUM; index++)
{
input_set_capability(ts->input_dev, EV_KEY, touch_key_array[index]); //上报key的kernel的定义值
}
#endif
#if GTP_GESTURE_WAKEUP
input_set_capability(ts->input_dev, EV_KEY, KEY_POWER);//手势唤醒
#endif
#if GTP_CHANGE_X2Y
GTP_SWAP(ts->abs_x_max, ts->abs_y_max);
#endif
input_set_abs_params(ts->input_dev, ABS_MT_POSITION_X, 0, ts->abs_x_max, 0, 0);
input_set_abs_params(ts->input_dev, ABS_MT_POSITION_Y, 0, ts->abs_y_max, 0, 0);
input_set_abs_params(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0);
input_set_abs_params(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);
input_set_abs_params(ts->input_dev, ABS_MT_TRACKING_ID, 0, 255, 0, 0);
ts->input_dev->name = goodix_ts_name; //static const char *goodix_ts_name = "goodix-ts";
ts->input_dev->phys = goodix_input_phys; //static const char *goodix_input_phys = "input/ts";
ts->input_dev->id.bustype = BUS_I2C;
ts->input_dev->id.vendor = 0xDEAD;
ts->input_dev->id.product = 0xBEEF;
ts->input_dev->id.version = 10427;
ret = input_register_device(ts->input_dev); //注册这个device
if (ret)
{
GTP_ERROR("Register %s input device failed", ts->input_dev->name);
return -ENODEV;
}
#if GTP_WITH_PEN
gtp_pen_init(ts);
#endif
return 0;
}