21 #include <linux/module.h>
24 #include <linux/sched.h>
25 #include <linux/wait.h>
26 #include <linux/input.h>
27 #include <linux/device.h>
31 #define UCB1400_TS_POLL_PERIOD 10
34 static int ts_delay = 55;
35 static int ts_delay_pressure;
38 static void ucb1400_ts_mode_int(
struct ucb1400_ts *ucb)
50 static unsigned int ucb1400_ts_read_pressure(
struct ucb1400_ts *ucb)
68 static unsigned int ucb1400_ts_read_xpos(
struct ucb1400_ts *ucb)
91 static int ucb1400_ts_read_ypos(
struct ucb1400_ts *ucb)
112 static unsigned int ucb1400_ts_read_xres(
struct ucb1400_ts *ucb)
124 static unsigned int ucb1400_ts_read_yres(
struct ucb1400_ts *ucb)
132 static int ucb1400_ts_pen_up(
struct ucb1400_ts *ucb)
139 static void ucb1400_ts_irq_enable(
struct ucb1400_ts *ucb)
146 static void ucb1400_ts_irq_disable(
struct ucb1400_ts *ucb)
151 static void ucb1400_ts_report_event(
struct input_dev *
idev,
u16 pressure,
u16 x,
u16 y)
153 input_report_abs(idev,
ABS_X, x);
154 input_report_abs(idev,
ABS_Y, y);
160 static void ucb1400_ts_event_release(
struct input_dev *
idev)
167 static void ucb1400_clear_pending_irq(
struct ucb1400_ts *ucb)
176 ucb1400_ts_irq_disable(ucb);
179 "ucb1400: unexpected IE_STATUS = %#x\n", isr);
192 unsigned int x,
y,
p;
198 ucb1400_clear_pending_irq(ucb);
203 while (!ucb->
stopped && !(penup = ucb1400_ts_pen_up(ucb))) {
205 ucb1400_adc_enable(ucb->
ac97);
206 x = ucb1400_ts_read_xpos(ucb);
207 y = ucb1400_ts_read_ypos(ucb);
208 p = ucb1400_ts_read_pressure(ucb);
209 ucb1400_adc_disable(ucb->
ac97);
211 ucb1400_ts_report_event(ucb->
ts_idev, p, x, y);
217 ucb1400_ts_event_release(ucb->
ts_idev);
221 ucb1400_ts_mode_int(ucb);
222 ucb1400_ts_irq_enable(ucb);
228 static void ucb1400_ts_stop(
struct ucb1400_ts *ucb)
236 ucb1400_ts_irq_disable(ucb);
241 static void ucb1400_ts_start(
struct ucb1400_ts *ucb)
247 ucb1400_ts_mode_int(ucb);
248 ucb1400_ts_irq_enable(ucb);
253 static int ucb1400_ts_open(
struct input_dev *
idev)
255 struct ucb1400_ts *ucb = input_get_drvdata(idev);
257 ucb1400_ts_start(ucb);
262 static void ucb1400_ts_close(
struct input_dev *
idev)
264 struct ucb1400_ts *ucb = input_get_drvdata(idev);
266 ucb1400_ts_stop(ucb);
300 dev_err(&pdev->
dev,
"timed out in IRQ probe\n");
327 ucb->
ts_idev = input_allocate_device();
335 error = ucb1400_ts_detect_irq(ucb, pdev);
345 input_set_drvdata(ucb->
ts_idev, ucb);
348 ucb->
ts_idev->name =
"UCB1400 touchscreen interface";
349 ucb->
ts_idev->id.vendor = ucb1400_reg_read(ucb->
ac97,
352 ucb->
ts_idev->open = ucb1400_ts_open;
353 ucb->
ts_idev->close = ucb1400_ts_close;
365 ucb1400_adc_enable(ucb->
ac97);
366 x_res = ucb1400_ts_read_xres(ucb);
367 y_res = ucb1400_ts_read_yres(ucb);
368 ucb1400_adc_disable(ucb->
ac97);
369 dev_dbg(&pdev->
dev,
"x/y = %d/%d\n", x_res, y_res);
371 input_set_abs_params(ucb->
ts_idev,
ABS_X, 0, x_res, 0, 0);
372 input_set_abs_params(ucb->
ts_idev,
ABS_Y, 0, y_res, 0, 0);
375 ucb1400_ts_stop(ucb);
382 "unable to grab irq%d: %d\n", ucb->
irq, error);
386 error = input_register_device(ucb->
ts_idev);
395 input_free_device(ucb->
ts_idev);
405 input_unregister_device(ucb->
ts_idev);
410 #ifdef CONFIG_PM_SLEEP
411 static int ucb1400_ts_suspend(
struct device *
dev)
419 ucb1400_ts_start(ucb);
425 static int ucb1400_ts_resume(
struct device *dev)
428 struct input_dev *idev = ucb->
ts_idev;
433 ucb1400_ts_stop(ucb);
441 ucb1400_ts_suspend, ucb1400_ts_resume);
444 .probe = ucb1400_ts_probe,
447 .name =
"ucb1400_ts",
449 .pm = &ucb1400_ts_pm_ops,
459 " position read. Default = 55us.");
463 "delay between panel setup and pressure read."