Lines Matching +full:touch +full:- +full:overlay
1 // SPDX-License-Identifier: GPL-2.0
9 * - android.git.kernel.org: projects/kernel/common.git: synaptics_i2c_rmi.c
25 #include <linux/input/touch-overlay.h>
27 #define ST1232_TS_NAME "st1232-ts"
28 #define ST1633_TS_NAME "st1633-ts"
69 struct i2c_client *client = ts->client; in st1232_ts_read_data()
72 .addr = client->addr, in st1232_ts_read_data()
77 .addr = client->addr, in st1232_ts_read_data()
80 .buf = ts->read_buf, in st1232_ts_read_data()
85 ret = i2c_transfer(client->adapter, msg, ARRAY_SIZE(msg)); in st1232_ts_read_data()
87 return ret < 0 ? ret : -EIO; in st1232_ts_read_data()
97 for (retries = 100; retries; retries--) { in st1232_ts_wait_ready()
100 switch (ts->read_buf[0]) { in st1232_ts_wait_ready()
110 return -ENXIO; in st1232_ts_wait_ready()
124 buf = ts->read_buf; in st1232_ts_read_resolution()
126 *max_x = (((buf[0] & 0x0070) << 4) | buf[1]) - 1; in st1232_ts_read_resolution()
127 *max_y = (((buf[0] & 0x0007) << 8) | buf[2]) - 1; in st1232_ts_read_resolution()
134 struct input_dev *input = ts->input_dev; in st1232_ts_parse_and_report()
141 for (i = 0; i < ts->chip_info->max_fingers; i++) { in st1232_ts_parse_and_report()
142 u8 *buf = &ts->read_buf[i * 4]; in st1232_ts_parse_and_report()
149 &ts->prop, x, y); in st1232_ts_parse_and_report()
151 /* st1232 includes a z-axis / touch strength */ in st1232_ts_parse_and_report()
152 if (ts->chip_info->have_z) in st1232_ts_parse_and_report()
153 z[n_contacts] = ts->read_buf[i + 6]; in st1232_ts_parse_and_report()
161 if (touch_overlay_process_contact(&ts->touch_overlay_list, in st1232_ts_parse_and_report()
169 if (ts->chip_info->have_z) in st1232_ts_parse_and_report()
173 touch_overlay_sync_frame(&ts->touch_overlay_list, input); in st1232_ts_parse_and_report()
186 error = st1232_ts_read_data(ts, REG_XY_COORDINATES, ts->read_buf_len); in st1232_ts_irq_handler()
192 if (ts->low_latency_req.dev) { in st1232_ts_irq_handler()
193 dev_pm_qos_remove_request(&ts->low_latency_req); in st1232_ts_irq_handler()
194 ts->low_latency_req.dev = NULL; in st1232_ts_irq_handler()
196 } else if (!ts->low_latency_req.dev) { in st1232_ts_irq_handler()
198 dev_pm_qos_add_ancestor_request(&ts->client->dev, in st1232_ts_irq_handler()
199 &ts->low_latency_req, in st1232_ts_irq_handler()
209 if (ts->reset_gpio) in st1232_ts_power()
210 gpiod_set_value_cansleep(ts->reset_gpio, !poweron); in st1232_ts_power()
239 match = device_get_match_data(&client->dev); in st1232_ts_probe()
241 match = (const void *)id->driver_data; in st1232_ts_probe()
243 dev_err(&client->dev, "unknown device model\n"); in st1232_ts_probe()
244 return -ENODEV; in st1232_ts_probe()
247 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { in st1232_ts_probe()
248 dev_err(&client->dev, "need I2C_FUNC_I2C\n"); in st1232_ts_probe()
249 return -EIO; in st1232_ts_probe()
252 if (!client->irq) { in st1232_ts_probe()
253 dev_err(&client->dev, "no IRQ?\n"); in st1232_ts_probe()
254 return -EINVAL; in st1232_ts_probe()
257 ts = devm_kzalloc(&client->dev, sizeof(*ts), GFP_KERNEL); in st1232_ts_probe()
259 return -ENOMEM; in st1232_ts_probe()
261 ts->chip_info = match; in st1232_ts_probe()
264 ts->read_buf_len = ts->chip_info->max_fingers * 4; in st1232_ts_probe()
265 ts->read_buf = devm_kzalloc(&client->dev, ts->read_buf_len, GFP_KERNEL); in st1232_ts_probe()
266 if (!ts->read_buf) in st1232_ts_probe()
267 return -ENOMEM; in st1232_ts_probe()
269 input_dev = devm_input_allocate_device(&client->dev); in st1232_ts_probe()
271 return -ENOMEM; in st1232_ts_probe()
273 ts->client = client; in st1232_ts_probe()
274 ts->input_dev = input_dev; in st1232_ts_probe()
276 ts->reset_gpio = devm_gpiod_get_optional(&client->dev, NULL, in st1232_ts_probe()
278 if (IS_ERR(ts->reset_gpio)) { in st1232_ts_probe()
279 error = PTR_ERR(ts->reset_gpio); in st1232_ts_probe()
280 dev_err(&client->dev, "Unable to request GPIO pin: %d.\n", in st1232_ts_probe()
287 error = devm_add_action_or_reset(&client->dev, st1232_ts_power_off, ts); in st1232_ts_probe()
289 dev_err(&client->dev, in st1232_ts_probe()
294 input_dev->name = "st1232-touchscreen"; in st1232_ts_probe()
295 input_dev->id.bustype = BUS_I2C; in st1232_ts_probe()
302 if (ts->chip_info->have_z) in st1232_ts_probe()
304 ts->chip_info->max_area, 0, 0); in st1232_ts_probe()
306 /* map overlay objects if defined in the device tree */ in st1232_ts_probe()
307 INIT_LIST_HEAD(&ts->touch_overlay_list); in st1232_ts_probe()
308 error = touch_overlay_map(&ts->touch_overlay_list, input_dev); in st1232_ts_probe()
312 if (touch_overlay_mapped_touchscreen(&ts->touch_overlay_list)) { in st1232_ts_probe()
313 /* Read resolution from the overlay touchscreen if defined */ in st1232_ts_probe()
314 touch_overlay_get_touchscreen_abs(&ts->touch_overlay_list, in st1232_ts_probe()
320 dev_err(&client->dev, in st1232_ts_probe()
331 touchscreen_parse_properties(input_dev, true, &ts->prop); in st1232_ts_probe()
333 error = input_mt_init_slots(input_dev, ts->chip_info->max_fingers, in st1232_ts_probe()
337 dev_err(&client->dev, "failed to initialize MT slots\n"); in st1232_ts_probe()
341 error = devm_request_threaded_irq(&client->dev, client->irq, in st1232_ts_probe()
344 client->name, ts); in st1232_ts_probe()
346 dev_err(&client->dev, "Failed to register interrupt\n"); in st1232_ts_probe()
350 error = input_register_device(ts->input_dev); in st1232_ts_probe()
352 dev_err(&client->dev, "Unable to register %s input device\n", in st1232_ts_probe()
353 input_dev->name); in st1232_ts_probe()
367 disable_irq(client->irq); in st1232_ts_suspend()
369 if (!device_may_wakeup(&client->dev)) in st1232_ts_suspend()
380 if (!device_may_wakeup(&client->dev)) in st1232_ts_resume()
383 enable_irq(client->irq); in st1232_ts_resume()