static void pixcir_ts_report(struct pixcir_i2c_ts_data *ts, struct pixcir_report_data *report) { struct input_mt_pos pos[PIXCIR_MAX_SLOTS]; int slots[PIXCIR_MAX_SLOTS]; struct pixcir_touch *touch; int n, i, slot; struct device *dev = &ts->client->dev; const struct pixcir_i2c_chip_data *chip = &ts->pdata->chip; n = report->num_touches; if (n > PIXCIR_MAX_SLOTS) n = PIXCIR_MAX_SLOTS; if (!chip->has_hw_ids) { for (i = 0; i < n; i++) { touch = &report->touches[i]; pos[i].x = touch->x; pos[i].y = touch->y; } input_mt_assign_slots(ts->input, slots, pos, n); } for (i = 0; i < n; i++) { touch = &report->touches[i]; if (chip->has_hw_ids) { slot = input_mt_get_slot_by_key(ts->input, touch->id); if (slot < 0) { dev_dbg(dev, "no free slot for id 0x%x\n", touch->id); continue; } } else { slot = slots[i]; } input_mt_slot(ts->input, slot); input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, true); input_event(ts->input, EV_ABS, ABS_MT_POSITION_X, touch->x); input_event(ts->input, EV_ABS, ABS_MT_POSITION_Y, touch->y); dev_dbg(dev, "%d: slot %d, x %d, y %d\n", i, slot, touch->x, touch->y); } input_mt_sync_frame(ts->input); input_sync(ts->input); }
static int sis_ts_report_contact(struct sis_ts_data *ts, const u8 *data, u8 id) { struct input_dev *input = ts->input; int slot; u8 status = data[SIS_CONTACT_STATUS_OFFSET]; u8 pressure; u8 height, width; u16 x, y; if (status != SIS_STATUS_DOWN && status != SIS_STATUS_UP) { dev_err(&ts->client->dev, "Unexpected touch status: %#02x\n", data[SIS_CONTACT_STATUS_OFFSET]); return -EINVAL; } slot = input_mt_get_slot_by_key(input, data[SIS_CONTACT_ID_OFFSET]); if (slot < 0) return -ENOENT; input_mt_slot(input, slot); input_mt_report_slot_state(input, MT_TOOL_FINGER, status == SIS_STATUS_DOWN); if (status == SIS_STATUS_DOWN) { pressure = height = width = 1; if (id != SIS_ALL_IN_ONE_PACKAGE) { if (SIS_PKT_HAS_AREA(id)) { width = data[SIS_CONTACT_WIDTH_OFFSET]; height = data[SIS_CONTACT_HEIGHT_OFFSET]; } if (SIS_PKT_HAS_PRESSURE(id)) pressure = data[SIS_CONTACT_PRESSURE_OFFSET(id)]; } x = get_unaligned_le16(&data[SIS_CONTACT_X_OFFSET]); y = get_unaligned_le16(&data[SIS_CONTACT_Y_OFFSET]); input_report_abs(input, ABS_MT_TOUCH_MAJOR, width * SIS_AREA_UNIT); input_report_abs(input, ABS_MT_TOUCH_MINOR, height * SIS_AREA_UNIT); input_report_abs(input, ABS_MT_PRESSURE, pressure); input_report_abs(input, ABS_MT_POSITION_X, x); input_report_abs(input, ABS_MT_POSITION_Y, y); } return 0; }
static int mt_compute_slot(struct mt_device *td, struct input_dev *input) { __s32 quirks = td->mtclass.quirks; if (quirks & MT_QUIRK_SLOT_IS_CONTACTID) return td->curdata.contactid; if (quirks & MT_QUIRK_CYPRESS) return cypress_compute_slot(td); if (quirks & MT_QUIRK_SLOT_IS_CONTACTNUMBER) return td->num_received; if (quirks & MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE) return td->curdata.contactid - 1; return input_mt_get_slot_by_key(input, td->curdata.contactid); }
static void pixcir_ts_report(struct pixcir_i2c_ts_data *ts, struct pixcir_report_data *report) { int slots[PIXCIR_MAX_SLOTS]; int n, i, slot; struct device *dev = &ts->client->dev; const struct pixcir_i2c_chip_data *chip = ts->chip; n = report->num_touches; if (n > PIXCIR_MAX_SLOTS) n = PIXCIR_MAX_SLOTS; if (!ts->chip->has_hw_ids) input_mt_assign_slots(ts->input, slots, report->pos, n, 0); for (i = 0; i < n; i++) { if (chip->has_hw_ids) { slot = input_mt_get_slot_by_key(ts->input, report->ids[i]); if (slot < 0) { dev_dbg(dev, "no free slot for id 0x%x\n", report->ids[i]); continue; } } else { slot = slots[i]; } input_mt_slot(ts->input, slot); input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, true); input_report_abs(ts->input, ABS_MT_POSITION_X, report->pos[i].x); input_report_abs(ts->input, ABS_MT_POSITION_Y, report->pos[i].y); dev_dbg(dev, "%d: slot %d, x %d, y %d\n", i, slot, report->pos[i].x, report->pos[i].y); } input_mt_sync_frame(ts->input); input_sync(ts->input); }
static int mt_compute_slot(struct mt_device *td, struct input_dev *input) { __s32 quirks = td->mtclass.quirks; if (quirks & MT_QUIRK_SLOT_IS_CONTACTID) return td->curdata.contactid; if (quirks & MT_QUIRK_CYPRESS) return cypress_compute_slot(td); if (quirks & MT_QUIRK_SLOT_IS_CONTACTNUMBER) return td->num_received; if (quirks & MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE) return td->curdata.contactid - 1; if (!show_mt) { /* manually compute slot */ int i; int slot = -1; if (!td-> mouse_emulation_slot_states) return 0; for (i = 0; i < td->maxcontacts && slot < 0; i++) { if (td-> mouse_emulation_slot_states[i] == td->curdata.contactid) slot = i; } for (i = 0; i < td->maxcontacts && slot < 0; i++) { if (td-> mouse_emulation_slot_states[i] < 0) slot = i; } return slot; } return input_mt_get_slot_by_key(input, td->curdata.contactid); }