Lines Matching +full:2 +full:- +full:point

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Driver for AUO in-cell touchscreens
7 * loosely based on auo_touch.c from Dell Streak vendor-kernel
71 #define AUO_PIXCIR_INT_POL_HIGH (1 << 2)
87 * sleep: scan speed 10Hz can be auto-activated, wakeup on 1st touch
95 #define AUO_PIXCIR_POWER_ALLOW_SLEEP (1 << 2)
109 #define AUO_PIXCIR_REPORT_POINTS 2
139 struct auo_point_t *point) in auo_pixcir_collect_data() argument
141 struct i2c_client *client = ts->client; in auo_pixcir_collect_data()
150 dev_err(&client->dev, "failed to read coordinate, %d\n", ret); in auo_pixcir_collect_data()
158 dev_err(&client->dev, "could not read touch area, %d\n", ret); in auo_pixcir_collect_data()
163 point[i].coord_x = in auo_pixcir_collect_data()
165 point[i].coord_y = in auo_pixcir_collect_data()
166 raw_coord[4 * i + 3] << 8 | raw_coord[4 * i + 2]; in auo_pixcir_collect_data()
168 if (point[i].coord_x > ts->x_max || in auo_pixcir_collect_data()
169 point[i].coord_y > ts->y_max) { in auo_pixcir_collect_data()
170 dev_warn(&client->dev, "coordinates (%d,%d) invalid\n", in auo_pixcir_collect_data()
171 point[i].coord_x, point[i].coord_y); in auo_pixcir_collect_data()
172 point[i].coord_x = point[i].coord_y = 0; in auo_pixcir_collect_data()
176 point[i].area_major = max(raw_area[2 * i], raw_area[2 * i + 1]); in auo_pixcir_collect_data()
177 point[i].area_minor = min(raw_area[2 * i], raw_area[2 * i + 1]); in auo_pixcir_collect_data()
178 point[i].orientation = raw_area[2 * i] > raw_area[2 * i + 1]; in auo_pixcir_collect_data()
187 struct auo_point_t point[AUO_PIXCIR_REPORT_POINTS]; in auo_pixcir_interrupt() local
191 int abs = -1; in auo_pixcir_interrupt()
193 while (!ts->stopped) { in auo_pixcir_interrupt()
196 if (ts->touch_ind_mode) { in auo_pixcir_interrupt()
197 if (gpiod_get_value_cansleep(ts->gpio_int) == 0) { in auo_pixcir_interrupt()
198 input_mt_sync(ts->input); in auo_pixcir_interrupt()
199 input_report_key(ts->input, BTN_TOUCH, 0); in auo_pixcir_interrupt()
200 input_sync(ts->input); in auo_pixcir_interrupt()
205 ret = auo_pixcir_collect_data(ts, point); in auo_pixcir_interrupt()
208 if (!ts->touch_ind_mode) in auo_pixcir_interrupt()
211 wait_event_timeout(ts->wait, ts->stopped, in auo_pixcir_interrupt()
217 if (point[i].coord_x > 0 || point[i].coord_y > 0) { in auo_pixcir_interrupt()
218 input_report_abs(ts->input, ABS_MT_POSITION_X, in auo_pixcir_interrupt()
219 point[i].coord_x); in auo_pixcir_interrupt()
220 input_report_abs(ts->input, ABS_MT_POSITION_Y, in auo_pixcir_interrupt()
221 point[i].coord_y); in auo_pixcir_interrupt()
222 input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR, in auo_pixcir_interrupt()
223 point[i].area_major); in auo_pixcir_interrupt()
224 input_report_abs(ts->input, ABS_MT_TOUCH_MINOR, in auo_pixcir_interrupt()
225 point[i].area_minor); in auo_pixcir_interrupt()
226 input_report_abs(ts->input, ABS_MT_ORIENTATION, in auo_pixcir_interrupt()
227 point[i].orientation); in auo_pixcir_interrupt()
228 input_mt_sync(ts->input); in auo_pixcir_interrupt()
241 input_report_key(ts->input, BTN_TOUCH, fingers > 0); in auo_pixcir_interrupt()
243 if (abs > -1) { in auo_pixcir_interrupt()
244 input_report_abs(ts->input, ABS_X, point[abs].coord_x); in auo_pixcir_interrupt()
245 input_report_abs(ts->input, ABS_Y, point[abs].coord_y); in auo_pixcir_interrupt()
248 input_sync(ts->input); in auo_pixcir_interrupt()
251 if (!ts->touch_ind_mode) in auo_pixcir_interrupt()
254 wait_event_timeout(ts->wait, ts->stopped, in auo_pixcir_interrupt()
264 * - AUO_PIXCIR_POWER_ACTIVE
265 * - AUO_PIXCIR_POWER_SLEEP - automatically left on first touch
266 * - AUO_PIXCIR_POWER_DEEP_SLEEP
270 struct i2c_client *client = ts->client; in auo_pixcir_power_mode()
275 dev_err(&client->dev, "unable to read reg %Xh, %d\n", in auo_pixcir_power_mode()
285 dev_err(&client->dev, "unable to write reg %Xh, %d\n", in auo_pixcir_power_mode()
295 struct i2c_client *client = ts->client; in auo_pixcir_int_config()
300 dev_err(&client->dev, "unable to read reg %Xh, %d\n", in auo_pixcir_int_config()
312 dev_err(&client->dev, "unable to write reg %Xh, %d\n", in auo_pixcir_int_config()
317 ts->touch_ind_mode = int_setting == AUO_PIXCIR_INT_TOUCH_IND; in auo_pixcir_int_config()
325 struct i2c_client *client = ts->client; in auo_pixcir_int_toggle()
330 dev_err(&client->dev, "unable to read reg %Xh, %d\n", in auo_pixcir_int_toggle()
343 dev_err(&client->dev, "unable to write reg %Xh, %d\n", in auo_pixcir_int_toggle()
353 struct i2c_client *client = ts->client; in auo_pixcir_start()
358 dev_err(&client->dev, "could not set power mode, %d\n", in auo_pixcir_start()
363 ts->stopped = false; in auo_pixcir_start()
365 enable_irq(client->irq); in auo_pixcir_start()
369 dev_err(&client->dev, "could not enable interrupt, %d\n", in auo_pixcir_start()
371 disable_irq(client->irq); in auo_pixcir_start()
380 struct i2c_client *client = ts->client; in auo_pixcir_stop()
385 dev_err(&client->dev, "could not disable interrupt, %d\n", in auo_pixcir_stop()
391 disable_irq(client->irq); in auo_pixcir_stop()
392 ts->stopped = true; in auo_pixcir_stop()
394 wake_up(&ts->wait); in auo_pixcir_stop()
417 struct input_dev *input = ts->input; in auo_pixcir_suspend()
420 mutex_lock(&input->mutex); in auo_pixcir_suspend()
425 if (device_may_wakeup(&client->dev)) { in auo_pixcir_suspend()
433 enable_irq_wake(client->irq); in auo_pixcir_suspend()
440 mutex_unlock(&input->mutex); in auo_pixcir_suspend()
449 struct input_dev *input = ts->input; in auo_pixcir_resume()
452 mutex_lock(&input->mutex); in auo_pixcir_resume()
454 if (device_may_wakeup(&client->dev)) { in auo_pixcir_resume()
455 disable_irq_wake(client->irq); in auo_pixcir_resume()
470 mutex_unlock(&input->mutex); in auo_pixcir_resume()
482 gpiod_set_value_cansleep(ts->gpio_rst, 1); in auo_pixcir_reset()
492 ts = devm_kzalloc(&client->dev, sizeof(*ts), GFP_KERNEL); in auo_pixcir_probe()
494 return -ENOMEM; in auo_pixcir_probe()
496 input_dev = devm_input_allocate_device(&client->dev); in auo_pixcir_probe()
498 dev_err(&client->dev, "could not allocate input device\n"); in auo_pixcir_probe()
499 return -ENOMEM; in auo_pixcir_probe()
502 ts->client = client; in auo_pixcir_probe()
503 ts->input = input_dev; in auo_pixcir_probe()
504 ts->touch_ind_mode = 0; in auo_pixcir_probe()
505 ts->stopped = true; in auo_pixcir_probe()
506 init_waitqueue_head(&ts->wait); in auo_pixcir_probe()
508 snprintf(ts->phys, sizeof(ts->phys), in auo_pixcir_probe()
509 "%s/input0", dev_name(&client->dev)); in auo_pixcir_probe()
511 if (device_property_read_u32(&client->dev, "x-size", &ts->x_max)) { in auo_pixcir_probe()
512 dev_err(&client->dev, "failed to get x-size property\n"); in auo_pixcir_probe()
513 return -EINVAL; in auo_pixcir_probe()
516 if (device_property_read_u32(&client->dev, "y-size", &ts->y_max)) { in auo_pixcir_probe()
517 dev_err(&client->dev, "failed to get y-size property\n"); in auo_pixcir_probe()
518 return -EINVAL; in auo_pixcir_probe()
521 input_dev->name = "AUO-Pixcir touchscreen"; in auo_pixcir_probe()
522 input_dev->phys = ts->phys; in auo_pixcir_probe()
523 input_dev->id.bustype = BUS_I2C; in auo_pixcir_probe()
525 input_dev->open = auo_pixcir_input_open; in auo_pixcir_probe()
526 input_dev->close = auo_pixcir_input_close; in auo_pixcir_probe()
528 __set_bit(EV_ABS, input_dev->evbit); in auo_pixcir_probe()
529 __set_bit(EV_KEY, input_dev->evbit); in auo_pixcir_probe()
531 __set_bit(BTN_TOUCH, input_dev->keybit); in auo_pixcir_probe()
534 input_set_abs_params(input_dev, ABS_X, 0, ts->x_max, 0, 0); in auo_pixcir_probe()
535 input_set_abs_params(input_dev, ABS_Y, 0, ts->y_max, 0, 0); in auo_pixcir_probe()
538 input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0, ts->x_max, 0, 0); in auo_pixcir_probe()
539 input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0, ts->y_max, 0, 0); in auo_pixcir_probe()
546 input_set_drvdata(ts->input, ts); in auo_pixcir_probe()
548 ts->gpio_int = devm_gpiod_get_index(&client->dev, NULL, 0, GPIOD_IN); in auo_pixcir_probe()
549 error = PTR_ERR_OR_ZERO(ts->gpio_int); in auo_pixcir_probe()
551 dev_err(&client->dev, in auo_pixcir_probe()
556 gpiod_set_consumer_name(ts->gpio_int, "auo_pixcir_ts_int"); in auo_pixcir_probe()
559 ts->gpio_rst = devm_gpiod_get_index(&client->dev, NULL, 1, in auo_pixcir_probe()
561 error = PTR_ERR_OR_ZERO(ts->gpio_rst); in auo_pixcir_probe()
563 dev_err(&client->dev, in auo_pixcir_probe()
568 gpiod_set_consumer_name(ts->gpio_rst, "auo_pixcir_ts_rst"); in auo_pixcir_probe()
570 error = devm_add_action_or_reset(&client->dev, auo_pixcir_reset, ts); in auo_pixcir_probe()
572 dev_err(&client->dev, "failed to register reset action, %d\n", in auo_pixcir_probe()
585 dev_info(&client->dev, "firmware version 0x%X\n", version); in auo_pixcir_probe()
592 error = devm_request_threaded_irq(&client->dev, client->irq, in auo_pixcir_probe()
595 input_dev->name, ts); in auo_pixcir_probe()
597 dev_err(&client->dev, "irq %d requested failed, %d\n", in auo_pixcir_probe()
598 client->irq, error); in auo_pixcir_probe()
609 dev_err(&client->dev, "could not register input device, %d\n", in auo_pixcir_probe()
645 MODULE_DESCRIPTION("AUO-PIXCIR touchscreen driver");