Lines Matching +full:deep +full:- +full:touch
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
23 #include <linux/input/auo-pixcir-ts.h>
77 * sleep: scan speed 10Hz can be auto-activated, wakeup on 1st touch
78 * deep sleep: scan speed 1Hz can only be entered or left manually.
127 struct i2c_client *client = ts->client; in auo_pixcir_collect_data()
128 const struct auo_pixcir_ts_platdata *pdata = ts->pdata; in auo_pixcir_collect_data()
133 /* touch coordinates */ in auo_pixcir_collect_data()
137 dev_err(&client->dev, "failed to read coordinate, %d\n", ret); in auo_pixcir_collect_data()
141 /* touch area */ in auo_pixcir_collect_data()
145 dev_err(&client->dev, "could not read touch area, %d\n", ret); in auo_pixcir_collect_data()
155 if (point[i].coord_x > pdata->x_max || in auo_pixcir_collect_data()
156 point[i].coord_y > pdata->y_max) { in auo_pixcir_collect_data()
157 dev_warn(&client->dev, "coordinates (%d,%d) invalid\n", in auo_pixcir_collect_data()
162 /* determine touch major, minor and orientation */ in auo_pixcir_collect_data()
174 const struct auo_pixcir_ts_platdata *pdata = ts->pdata; in auo_pixcir_interrupt()
179 int abs = -1; in auo_pixcir_interrupt()
181 while (!ts->stopped) { in auo_pixcir_interrupt()
183 /* check for up event in touch touch_ind_mode */ in auo_pixcir_interrupt()
184 if (ts->touch_ind_mode) { in auo_pixcir_interrupt()
185 if (gpio_get_value(pdata->gpio_int) == 0) { in auo_pixcir_interrupt()
186 input_mt_sync(ts->input); in auo_pixcir_interrupt()
187 input_report_key(ts->input, BTN_TOUCH, 0); in auo_pixcir_interrupt()
188 input_sync(ts->input); in auo_pixcir_interrupt()
196 if (!ts->touch_ind_mode) in auo_pixcir_interrupt()
199 wait_event_timeout(ts->wait, ts->stopped, in auo_pixcir_interrupt()
206 input_report_abs(ts->input, ABS_MT_POSITION_X, in auo_pixcir_interrupt()
208 input_report_abs(ts->input, ABS_MT_POSITION_Y, in auo_pixcir_interrupt()
210 input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR, in auo_pixcir_interrupt()
212 input_report_abs(ts->input, ABS_MT_TOUCH_MINOR, in auo_pixcir_interrupt()
214 input_report_abs(ts->input, ABS_MT_ORIENTATION, in auo_pixcir_interrupt()
216 input_mt_sync(ts->input); in auo_pixcir_interrupt()
222 /* number of touch points could also be queried in auo_pixcir_interrupt()
229 input_report_key(ts->input, BTN_TOUCH, fingers > 0); in auo_pixcir_interrupt()
231 if (abs > -1) { in auo_pixcir_interrupt()
232 input_report_abs(ts->input, ABS_X, point[abs].coord_x); in auo_pixcir_interrupt()
233 input_report_abs(ts->input, ABS_Y, point[abs].coord_y); in auo_pixcir_interrupt()
236 input_sync(ts->input); in auo_pixcir_interrupt()
239 if (!ts->touch_ind_mode) in auo_pixcir_interrupt()
242 wait_event_timeout(ts->wait, ts->stopped, in auo_pixcir_interrupt()
252 * - AUO_PIXCIR_POWER_ACTIVE
253 * - AUO_PIXCIR_POWER_SLEEP - automatically left on first touch
254 * - AUO_PIXCIR_POWER_DEEP_SLEEP
258 struct i2c_client *client = ts->client; in auo_pixcir_power_mode()
263 dev_err(&client->dev, "unable to read reg %Xh, %d\n", in auo_pixcir_power_mode()
273 dev_err(&client->dev, "unable to write reg %Xh, %d\n", in auo_pixcir_power_mode()
284 struct i2c_client *client = ts->client; in auo_pixcir_int_config()
285 const struct auo_pixcir_ts_platdata *pdata = ts->pdata; in auo_pixcir_int_config()
290 dev_err(&client->dev, "unable to read reg %Xh, %d\n", in auo_pixcir_int_config()
302 dev_err(&client->dev, "unable to write reg %Xh, %d\n", in auo_pixcir_int_config()
307 ts->touch_ind_mode = pdata->int_setting == AUO_PIXCIR_INT_TOUCH_IND; in auo_pixcir_int_config()
315 struct i2c_client *client = ts->client; in auo_pixcir_int_toggle()
320 dev_err(&client->dev, "unable to read reg %Xh, %d\n", in auo_pixcir_int_toggle()
333 dev_err(&client->dev, "unable to write reg %Xh, %d\n", in auo_pixcir_int_toggle()
343 struct i2c_client *client = ts->client; in auo_pixcir_start()
348 dev_err(&client->dev, "could not set power mode, %d\n", in auo_pixcir_start()
353 ts->stopped = false; in auo_pixcir_start()
355 enable_irq(client->irq); in auo_pixcir_start()
359 dev_err(&client->dev, "could not enable interrupt, %d\n", in auo_pixcir_start()
361 disable_irq(client->irq); in auo_pixcir_start()
370 struct i2c_client *client = ts->client; in auo_pixcir_stop()
375 dev_err(&client->dev, "could not disable interrupt, %d\n", in auo_pixcir_stop()
381 disable_irq(client->irq); in auo_pixcir_stop()
382 ts->stopped = true; in auo_pixcir_stop()
384 wake_up(&ts->wait); in auo_pixcir_stop()
407 struct input_dev *input = ts->input; in auo_pixcir_suspend()
410 mutex_lock(&input->mutex); in auo_pixcir_suspend()
415 if (device_may_wakeup(&client->dev)) { in auo_pixcir_suspend()
417 if (!input->users) { in auo_pixcir_suspend()
423 enable_irq_wake(client->irq); in auo_pixcir_suspend()
425 } else if (input->users) { in auo_pixcir_suspend()
430 mutex_unlock(&input->mutex); in auo_pixcir_suspend()
439 struct input_dev *input = ts->input; in auo_pixcir_resume()
442 mutex_lock(&input->mutex); in auo_pixcir_resume()
444 if (device_may_wakeup(&client->dev)) { in auo_pixcir_resume()
445 disable_irq_wake(client->irq); in auo_pixcir_resume()
448 if (!input->users) { in auo_pixcir_resume()
455 } else if (input->users) { in auo_pixcir_resume()
460 mutex_unlock(&input->mutex); in auo_pixcir_resume()
472 struct device_node *np = dev->of_node; in auo_pixcir_parse_dt()
475 return ERR_PTR(-ENOENT); in auo_pixcir_parse_dt()
479 return ERR_PTR(-ENOMEM); in auo_pixcir_parse_dt()
481 pdata->gpio_int = of_get_gpio(np, 0); in auo_pixcir_parse_dt()
482 if (!gpio_is_valid(pdata->gpio_int)) { in auo_pixcir_parse_dt()
484 return ERR_PTR(-EINVAL); in auo_pixcir_parse_dt()
487 pdata->gpio_rst = of_get_gpio(np, 1); in auo_pixcir_parse_dt()
488 if (!gpio_is_valid(pdata->gpio_rst)) { in auo_pixcir_parse_dt()
490 return ERR_PTR(-EINVAL); in auo_pixcir_parse_dt()
493 if (of_property_read_u32(np, "x-size", &pdata->x_max)) { in auo_pixcir_parse_dt()
494 dev_err(dev, "failed to get x-size property\n"); in auo_pixcir_parse_dt()
495 return ERR_PTR(-EINVAL); in auo_pixcir_parse_dt()
498 if (of_property_read_u32(np, "y-size", &pdata->y_max)) { in auo_pixcir_parse_dt()
499 dev_err(dev, "failed to get y-size property\n"); in auo_pixcir_parse_dt()
500 return ERR_PTR(-EINVAL); in auo_pixcir_parse_dt()
504 pdata->int_setting = AUO_PIXCIR_INT_TOUCH_IND; in auo_pixcir_parse_dt()
511 return ERR_PTR(-EINVAL); in auo_pixcir_parse_dt()
519 gpio_set_value(ts->pdata->gpio_rst, 0); in auo_pixcir_reset()
531 pdata = dev_get_platdata(&client->dev); in auo_pixcir_probe()
533 pdata = auo_pixcir_parse_dt(&client->dev); in auo_pixcir_probe()
538 ts = devm_kzalloc(&client->dev, in auo_pixcir_probe()
541 return -ENOMEM; in auo_pixcir_probe()
543 input_dev = devm_input_allocate_device(&client->dev); in auo_pixcir_probe()
545 dev_err(&client->dev, "could not allocate input device\n"); in auo_pixcir_probe()
546 return -ENOMEM; in auo_pixcir_probe()
549 ts->pdata = pdata; in auo_pixcir_probe()
550 ts->client = client; in auo_pixcir_probe()
551 ts->input = input_dev; in auo_pixcir_probe()
552 ts->touch_ind_mode = 0; in auo_pixcir_probe()
553 ts->stopped = true; in auo_pixcir_probe()
554 init_waitqueue_head(&ts->wait); in auo_pixcir_probe()
556 snprintf(ts->phys, sizeof(ts->phys), in auo_pixcir_probe()
557 "%s/input0", dev_name(&client->dev)); in auo_pixcir_probe()
559 input_dev->name = "AUO-Pixcir touchscreen"; in auo_pixcir_probe()
560 input_dev->phys = ts->phys; in auo_pixcir_probe()
561 input_dev->id.bustype = BUS_I2C; in auo_pixcir_probe()
563 input_dev->open = auo_pixcir_input_open; in auo_pixcir_probe()
564 input_dev->close = auo_pixcir_input_close; in auo_pixcir_probe()
566 __set_bit(EV_ABS, input_dev->evbit); in auo_pixcir_probe()
567 __set_bit(EV_KEY, input_dev->evbit); in auo_pixcir_probe()
569 __set_bit(BTN_TOUCH, input_dev->keybit); in auo_pixcir_probe()
571 /* For single touch */ in auo_pixcir_probe()
572 input_set_abs_params(input_dev, ABS_X, 0, pdata->x_max, 0, 0); in auo_pixcir_probe()
573 input_set_abs_params(input_dev, ABS_Y, 0, pdata->y_max, 0, 0); in auo_pixcir_probe()
575 /* For multi touch */ in auo_pixcir_probe()
577 pdata->x_max, 0, 0); in auo_pixcir_probe()
579 pdata->y_max, 0, 0); in auo_pixcir_probe()
586 input_set_drvdata(ts->input, ts); in auo_pixcir_probe()
588 error = devm_gpio_request_one(&client->dev, pdata->gpio_int, in auo_pixcir_probe()
591 dev_err(&client->dev, "request of gpio %d failed, %d\n", in auo_pixcir_probe()
592 pdata->gpio_int, error); in auo_pixcir_probe()
596 error = devm_gpio_request_one(&client->dev, pdata->gpio_rst, in auo_pixcir_probe()
600 dev_err(&client->dev, "request of gpio %d failed, %d\n", in auo_pixcir_probe()
601 pdata->gpio_rst, error); in auo_pixcir_probe()
605 error = devm_add_action_or_reset(&client->dev, auo_pixcir_reset, ts); in auo_pixcir_probe()
607 dev_err(&client->dev, "failed to register reset action, %d\n", in auo_pixcir_probe()
620 dev_info(&client->dev, "firmware version 0x%X\n", version); in auo_pixcir_probe()
622 error = auo_pixcir_int_config(ts, pdata->int_setting); in auo_pixcir_probe()
626 error = devm_request_threaded_irq(&client->dev, client->irq, in auo_pixcir_probe()
629 input_dev->name, ts); in auo_pixcir_probe()
631 dev_err(&client->dev, "irq %d requested failed, %d\n", in auo_pixcir_probe()
632 client->irq, error); in auo_pixcir_probe()
636 /* stop device and put it into deep sleep until it is opened */ in auo_pixcir_probe()
643 dev_err(&client->dev, "could not register input device, %d\n", in auo_pixcir_probe()
679 MODULE_DESCRIPTION("AUO-PIXCIR touchscreen driver");