Lines Matching +full:multi +full:- +full:touch

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 2010-2011 Pixcir, Inc.
31 * idle: lower scan speed with automatic transition to active on touch
49 * level on touch: interrupt level asserted during touch
50 * pulse on touch: interrupt pulse asserted during touch
65 * struct pixcir_i2c_chip_data - chip related data
99 u8 touch; in pixcir_ts_parse() local
102 const struct pixcir_i2c_chip_data *chip = tsdata->chip; in pixcir_ts_parse()
106 i = chip->has_hw_ids ? 1 : 0; in pixcir_ts_parse()
107 readsize = 2 + tsdata->chip->max_fingers * (4 + i); in pixcir_ts_parse()
111 ret = i2c_master_send(tsdata->client, wrbuf, sizeof(wrbuf)); in pixcir_ts_parse()
113 dev_err(&tsdata->client->dev, in pixcir_ts_parse()
119 ret = i2c_master_recv(tsdata->client, rdbuf, readsize); in pixcir_ts_parse()
121 dev_err(&tsdata->client->dev, in pixcir_ts_parse()
127 touch = rdbuf[0] & 0x7; in pixcir_ts_parse()
128 if (touch > tsdata->chip->max_fingers) in pixcir_ts_parse()
129 touch = tsdata->chip->max_fingers; in pixcir_ts_parse()
131 report->num_touches = touch; in pixcir_ts_parse()
134 for (i = 0; i < touch; i++) { in pixcir_ts_parse()
135 touchscreen_set_mt_pos(&report->pos[i], &tsdata->prop, in pixcir_ts_parse()
138 if (chip->has_hw_ids) { in pixcir_ts_parse()
139 report->ids[i] = bufptr[4]; in pixcir_ts_parse()
152 struct device *dev = &ts->client->dev; in pixcir_ts_report()
153 const struct pixcir_i2c_chip_data *chip = ts->chip; in pixcir_ts_report()
155 n = report->num_touches; in pixcir_ts_report()
159 if (!ts->chip->has_hw_ids) in pixcir_ts_report()
160 input_mt_assign_slots(ts->input, slots, report->pos, n, 0); in pixcir_ts_report()
163 if (chip->has_hw_ids) { in pixcir_ts_report()
164 slot = input_mt_get_slot_by_key(ts->input, in pixcir_ts_report()
165 report->ids[i]); in pixcir_ts_report()
168 report->ids[i]); in pixcir_ts_report()
175 input_mt_slot(ts->input, slot); in pixcir_ts_report()
176 input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, true); in pixcir_ts_report()
178 input_report_abs(ts->input, ABS_MT_POSITION_X, in pixcir_ts_report()
179 report->pos[i].x); in pixcir_ts_report()
180 input_report_abs(ts->input, ABS_MT_POSITION_Y, in pixcir_ts_report()
181 report->pos[i].y); in pixcir_ts_report()
184 i, slot, report->pos[i].x, report->pos[i].y); in pixcir_ts_report()
187 input_mt_sync_frame(ts->input); in pixcir_ts_report()
188 input_sync(ts->input); in pixcir_ts_report()
196 while (tsdata->running) { in pixcir_ts_isr()
203 if (gpiod_get_value_cansleep(tsdata->gpio_attb)) { in pixcir_ts_isr()
209 input_mt_sync_frame(tsdata->input); in pixcir_ts_isr()
210 input_sync(tsdata->input); in pixcir_ts_isr()
223 if (!IS_ERR_OR_NULL(tsdata->gpio_reset)) { in pixcir_reset()
224 gpiod_set_value_cansleep(tsdata->gpio_reset, 1); in pixcir_reset()
226 gpiod_set_value_cansleep(tsdata->gpio_reset, 0); in pixcir_reset()
235 struct device *dev = &ts->client->dev; in pixcir_set_power_mode()
239 if (ts->gpio_wake) in pixcir_set_power_mode()
240 gpiod_set_value_cansleep(ts->gpio_wake, 1); in pixcir_set_power_mode()
243 ret = i2c_smbus_read_byte_data(ts->client, PIXCIR_REG_POWER_MODE); in pixcir_set_power_mode()
256 ret = i2c_smbus_write_byte_data(ts->client, PIXCIR_REG_POWER_MODE, ret); in pixcir_set_power_mode()
264 if (ts->gpio_wake) in pixcir_set_power_mode()
265 gpiod_set_value_cansleep(ts->gpio_wake, 0); in pixcir_set_power_mode()
279 struct device *dev = &ts->client->dev; in pixcir_set_int_mode()
282 ret = i2c_smbus_read_byte_data(ts->client, PIXCIR_REG_INT_MODE); in pixcir_set_int_mode()
297 ret = i2c_smbus_write_byte_data(ts->client, PIXCIR_REG_INT_MODE, ret); in pixcir_set_int_mode()
312 struct device *dev = &ts->client->dev; in pixcir_int_enable()
315 ret = i2c_smbus_read_byte_data(ts->client, PIXCIR_REG_INT_MODE); in pixcir_int_enable()
327 ret = i2c_smbus_write_byte_data(ts->client, PIXCIR_REG_INT_MODE, ret); in pixcir_int_enable()
339 struct device *dev = &ts->client->dev; in pixcir_start()
342 if (ts->gpio_enable) { in pixcir_start()
343 gpiod_set_value_cansleep(ts->gpio_enable, 1); in pixcir_start()
354 ts->running = true; in pixcir_start()
375 dev_err(&ts->client->dev, in pixcir_stop()
382 ts->running = false; in pixcir_stop()
386 synchronize_irq(ts->client->irq); in pixcir_stop()
388 if (ts->gpio_enable) in pixcir_stop()
389 gpiod_set_value_cansleep(ts->gpio_enable, 0); in pixcir_stop()
412 struct input_dev *input = ts->input; in pixcir_i2c_ts_suspend()
415 mutex_lock(&input->mutex); in pixcir_i2c_ts_suspend()
417 if (device_may_wakeup(&client->dev)) { in pixcir_i2c_ts_suspend()
430 mutex_unlock(&input->mutex); in pixcir_i2c_ts_suspend()
439 struct input_dev *input = ts->input; in pixcir_i2c_ts_resume()
442 mutex_lock(&input->mutex); in pixcir_i2c_ts_resume()
444 if (device_may_wakeup(&client->dev)) { in pixcir_i2c_ts_resume()
457 mutex_unlock(&input->mutex); in pixcir_i2c_ts_resume()
468 struct device *dev = &client->dev; in pixcir_i2c_ts_probe()
475 return -ENOMEM; in pixcir_i2c_ts_probe()
477 tsdata->chip = device_get_match_data(dev); in pixcir_i2c_ts_probe()
478 if (!tsdata->chip && id) in pixcir_i2c_ts_probe()
479 tsdata->chip = (const void *)id->driver_data; in pixcir_i2c_ts_probe()
480 if (!tsdata->chip) { in pixcir_i2c_ts_probe()
482 return -EINVAL; in pixcir_i2c_ts_probe()
488 return -ENOMEM; in pixcir_i2c_ts_probe()
491 tsdata->client = client; in pixcir_i2c_ts_probe()
492 tsdata->input = input; in pixcir_i2c_ts_probe()
494 input->name = client->name; in pixcir_i2c_ts_probe()
495 input->id.bustype = BUS_I2C; in pixcir_i2c_ts_probe()
496 input->open = pixcir_input_open; in pixcir_i2c_ts_probe()
497 input->close = pixcir_input_close; in pixcir_i2c_ts_probe()
501 touchscreen_parse_properties(input, true, &tsdata->prop); in pixcir_i2c_ts_probe()
505 return -EINVAL; in pixcir_i2c_ts_probe()
508 error = input_mt_init_slots(input, tsdata->chip->max_fingers, in pixcir_i2c_ts_probe()
511 dev_err(dev, "Error initializing Multi-Touch slots\n"); in pixcir_i2c_ts_probe()
517 tsdata->gpio_attb = devm_gpiod_get(dev, "attb", GPIOD_IN); in pixcir_i2c_ts_probe()
518 if (IS_ERR(tsdata->gpio_attb)) in pixcir_i2c_ts_probe()
519 return dev_err_probe(dev, PTR_ERR(tsdata->gpio_attb), in pixcir_i2c_ts_probe()
522 tsdata->gpio_reset = devm_gpiod_get_optional(dev, "reset", in pixcir_i2c_ts_probe()
524 if (IS_ERR(tsdata->gpio_reset)) in pixcir_i2c_ts_probe()
525 return dev_err_probe(dev, PTR_ERR(tsdata->gpio_reset), in pixcir_i2c_ts_probe()
528 tsdata->gpio_wake = devm_gpiod_get_optional(dev, "wake", in pixcir_i2c_ts_probe()
530 if (IS_ERR(tsdata->gpio_wake)) in pixcir_i2c_ts_probe()
531 return dev_err_probe(dev, PTR_ERR(tsdata->gpio_wake), in pixcir_i2c_ts_probe()
534 tsdata->gpio_enable = devm_gpiod_get_optional(dev, "enable", in pixcir_i2c_ts_probe()
536 if (IS_ERR(tsdata->gpio_enable)) in pixcir_i2c_ts_probe()
537 return dev_err_probe(dev, PTR_ERR(tsdata->gpio_enable), in pixcir_i2c_ts_probe()
540 if (tsdata->gpio_enable) in pixcir_i2c_ts_probe()
543 error = devm_request_threaded_irq(dev, client->irq, NULL, pixcir_ts_isr, in pixcir_i2c_ts_probe()
545 client->name, tsdata); in pixcir_i2c_ts_probe()
547 dev_err(dev, "failed to request irq %d\n", client->irq); in pixcir_i2c_ts_probe()