Lines Matching +full:touch +full:- +full:max +full:- +full:x
1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * on the Acer Iconia One 7 B1-750 tablet.
70 .addr = client->addr, in nvt_ts_read_data()
75 .addr = client->addr, in nvt_ts_read_data()
83 ret = i2c_transfer(client->adapter, msg, ARRAY_SIZE(msg)); in nvt_ts_read_data()
85 dev_err(&client->dev, "Error reading from 0x%02x: %d\n", reg, ret); in nvt_ts_read_data()
86 return (ret < 0) ? ret : -EIO; in nvt_ts_read_data()
95 struct device *dev = &data->client->dev; in nvt_ts_irq()
96 int i, error, slot, x, y; in nvt_ts_irq() local
98 u8 *touch; in nvt_ts_irq() local
100 error = nvt_ts_read_data(data->client, NVT_TS_TOUCH_START, data->buf, in nvt_ts_irq()
101 data->max_touches * NVT_TS_TOUCH_SIZE); in nvt_ts_irq()
105 for (i = 0; i < data->max_touches; i++) { in nvt_ts_irq()
106 touch = &data->buf[i * NVT_TS_TOUCH_SIZE]; in nvt_ts_irq()
108 if (touch[0] == NVT_TS_TOUCH_INVALID) in nvt_ts_irq()
111 slot = touch[0] >> NVT_TS_TOUCH_SLOT_SHIFT; in nvt_ts_irq()
112 if (slot < 1 || slot > data->max_touches) { in nvt_ts_irq()
117 switch (touch[0] & NVT_TS_TOUCH_TYPE_MASK) { in nvt_ts_irq()
126 dev_warn(dev, "slot %d unknown state %d\n", slot, touch[0] & 7); in nvt_ts_irq()
130 slot--; in nvt_ts_irq()
131 x = (touch[1] << 4) | (touch[3] >> 4); in nvt_ts_irq()
132 y = (touch[2] << 4) | (touch[3] & 0x0f); in nvt_ts_irq()
134 input_mt_slot(data->input, slot); in nvt_ts_irq()
135 input_mt_report_slot_state(data->input, MT_TOOL_FINGER, active); in nvt_ts_irq()
136 touchscreen_report_pos(data->input, &data->prop, x, y, true); in nvt_ts_irq()
139 input_mt_sync_frame(data->input); in nvt_ts_irq()
140 input_sync(data->input); in nvt_ts_irq()
150 error = regulator_bulk_enable(ARRAY_SIZE(data->regulators), data->regulators); in nvt_ts_start()
152 dev_err(&data->client->dev, "failed to enable regulators\n"); in nvt_ts_start()
156 enable_irq(data->client->irq); in nvt_ts_start()
157 gpiod_set_value_cansleep(data->reset_gpio, 0); in nvt_ts_start()
166 disable_irq(data->client->irq); in nvt_ts_stop()
167 gpiod_set_value_cansleep(data->reset_gpio, 1); in nvt_ts_stop()
168 regulator_bulk_disable(ARRAY_SIZE(data->regulators), data->regulators); in nvt_ts_stop()
175 mutex_lock(&data->input->mutex); in nvt_ts_suspend()
176 if (input_device_enabled(data->input)) in nvt_ts_suspend()
177 nvt_ts_stop(data->input); in nvt_ts_suspend()
178 mutex_unlock(&data->input->mutex); in nvt_ts_suspend()
187 mutex_lock(&data->input->mutex); in nvt_ts_resume()
188 if (input_device_enabled(data->input)) in nvt_ts_resume()
189 nvt_ts_start(data->input); in nvt_ts_resume()
190 mutex_unlock(&data->input->mutex); in nvt_ts_resume()
199 struct device *dev = &client->dev; in nvt_ts_probe()
205 if (!client->irq) { in nvt_ts_probe()
207 return -EINVAL; in nvt_ts_probe()
212 return -ENOMEM; in nvt_ts_probe()
214 chip = device_get_match_data(&client->dev); in nvt_ts_probe()
216 return -EINVAL; in nvt_ts_probe()
218 data->client = client; in nvt_ts_probe()
225 data->regulators[0].supply = "vcc"; in nvt_ts_probe()
226 data->regulators[1].supply = "iovcc"; in nvt_ts_probe()
227 error = devm_regulator_bulk_get(dev, ARRAY_SIZE(data->regulators), data->regulators); in nvt_ts_probe()
233 error = regulator_bulk_enable(ARRAY_SIZE(data->regulators), data->regulators); in nvt_ts_probe()
239 data->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); in nvt_ts_probe()
240 error = PTR_ERR_OR_ZERO(data->reset_gpio); in nvt_ts_probe()
242 regulator_bulk_disable(ARRAY_SIZE(data->regulators), data->regulators); in nvt_ts_probe()
249 error = nvt_ts_read_data(data->client, NVT_TS_PARAMETERS_START, in nvt_ts_probe()
250 data->buf, NVT_TS_PARAMS_SIZE); in nvt_ts_probe()
251 gpiod_set_value_cansleep(data->reset_gpio, 1); /* Put back in reset */ in nvt_ts_probe()
252 regulator_bulk_disable(ARRAY_SIZE(data->regulators), data->regulators); in nvt_ts_probe()
256 width = get_unaligned_be16(&data->buf[NVT_TS_PARAMS_WIDTH]); in nvt_ts_probe()
257 height = get_unaligned_be16(&data->buf[NVT_TS_PARAMS_HEIGHT]); in nvt_ts_probe()
258 data->max_touches = data->buf[NVT_TS_PARAMS_MAX_TOUCH]; in nvt_ts_probe()
259 irq_type = data->buf[NVT_TS_PARAMS_IRQ_TYPE]; in nvt_ts_probe()
262 data->max_touches > NVT_TS_MAX_TOUCHES || in nvt_ts_probe()
264 data->buf[NVT_TS_PARAMS_WAKE_TYPE] != chip->wake_type || in nvt_ts_probe()
265 data->buf[NVT_TS_PARAMS_CHIP_ID] != chip->chip_id) { in nvt_ts_probe()
267 NVT_TS_PARAMS_SIZE, data->buf); in nvt_ts_probe()
268 return -EIO; in nvt_ts_probe()
271 dev_dbg(dev, "Detected %dx%d touchscreen with %d max touches\n", in nvt_ts_probe()
272 width, height, data->max_touches); in nvt_ts_probe()
274 if (data->buf[NVT_TS_PARAMS_MAX_BUTTONS]) in nvt_ts_probe()
279 return -ENOMEM; in nvt_ts_probe()
281 input->name = client->name; in nvt_ts_probe()
282 input->id.bustype = BUS_I2C; in nvt_ts_probe()
283 input->open = nvt_ts_start; in nvt_ts_probe()
284 input->close = nvt_ts_stop; in nvt_ts_probe()
286 input_set_abs_params(input, ABS_MT_POSITION_X, 0, width - 1, 0, 0); in nvt_ts_probe()
287 input_set_abs_params(input, ABS_MT_POSITION_Y, 0, height - 1, 0, 0); in nvt_ts_probe()
288 touchscreen_parse_properties(input, true, &data->prop); in nvt_ts_probe()
290 error = input_mt_init_slots(input, data->max_touches, in nvt_ts_probe()
295 data->input = input; in nvt_ts_probe()
298 error = devm_request_threaded_irq(dev, client->irq, NULL, nvt_ts_irq, in nvt_ts_probe()
301 client->name, data); in nvt_ts_probe()
327 { .compatible = "novatek,nt11205-ts", .data = &nvt_nt11205_ts_data },
328 { .compatible = "novatek,nt36672a-ts", .data = &nvt_nt36672a_ts_data },
334 { "nt11205-ts", (unsigned long) &nvt_nt11205_ts_data },
335 { "nt36672a-ts", (unsigned long) &nvt_nt36672a_ts_data },
342 .name = "novatek-nvt-ts",