Lines Matching +full:input +full:- +full:debounce
2 * Touchscreen driver for the TS-4800 board
4 * Copyright (c) 2015 - Savoir-faire Linux
12 #include <linux/input.h>
13 #include <linux/input-polldev.h>
27 /* sensor values are 12-bit wide */
28 #define MAX_12BIT ((1 << 12) - 1)
46 int debounce; member
51 struct ts4800_ts *ts = dev->private; in ts4800_ts_open()
54 ts->pendown = false; in ts4800_ts_open()
55 ts->debounce = DEBOUNCE_COUNT; in ts4800_ts_open()
57 ret = regmap_update_bits(ts->regmap, ts->reg, ts->bit, ts->bit); in ts4800_ts_open()
59 dev_warn(ts->dev, "Failed to enable touchscreen\n"); in ts4800_ts_open()
64 struct ts4800_ts *ts = dev->private; in ts4800_ts_close()
67 ret = regmap_update_bits(ts->regmap, ts->reg, ts->bit, 0); in ts4800_ts_close()
69 dev_warn(ts->dev, "Failed to disable touchscreen\n"); in ts4800_ts_close()
75 struct input_dev *input_dev = dev->input; in ts4800_ts_poll()
76 struct ts4800_ts *ts = dev->private; in ts4800_ts_poll()
77 u16 last_x = readw(ts->base + X_OFFSET); in ts4800_ts_poll()
78 u16 last_y = readw(ts->base + Y_OFFSET); in ts4800_ts_poll()
82 if (ts->debounce) { in ts4800_ts_poll()
83 ts->debounce--; in ts4800_ts_poll()
87 if (!ts->pendown) { in ts4800_ts_poll()
89 ts->pendown = true; in ts4800_ts_poll()
98 } else if (ts->pendown) { in ts4800_ts_poll()
99 ts->pendown = false; in ts4800_ts_poll()
100 ts->debounce = DEBOUNCE_COUNT; in ts4800_ts_poll()
109 struct device *dev = &pdev->dev; in ts4800_parse_dt()
110 struct device_node *np = dev->of_node; in ts4800_parse_dt()
118 return -ENODEV; in ts4800_parse_dt()
121 ts->regmap = syscon_node_to_regmap(syscon_np); in ts4800_parse_dt()
123 if (IS_ERR(ts->regmap)) { in ts4800_parse_dt()
125 return PTR_ERR(ts->regmap); in ts4800_parse_dt()
134 ts->reg = reg; in ts4800_parse_dt()
142 ts->bit = BIT(bit); in ts4800_parse_dt()
154 ts = devm_kzalloc(&pdev->dev, sizeof(*ts), GFP_KERNEL); in ts4800_ts_probe()
156 return -ENOMEM; in ts4800_ts_probe()
163 ts->base = devm_ioremap_resource(&pdev->dev, res); in ts4800_ts_probe()
164 if (IS_ERR(ts->base)) in ts4800_ts_probe()
165 return PTR_ERR(ts->base); in ts4800_ts_probe()
167 poll_dev = devm_input_allocate_polled_device(&pdev->dev); in ts4800_ts_probe()
169 return -ENOMEM; in ts4800_ts_probe()
171 snprintf(ts->phys, sizeof(ts->phys), "%s/input0", dev_name(&pdev->dev)); in ts4800_ts_probe()
172 ts->poll_dev = poll_dev; in ts4800_ts_probe()
173 ts->dev = &pdev->dev; in ts4800_ts_probe()
175 poll_dev->private = ts; in ts4800_ts_probe()
176 poll_dev->poll_interval = POLL_INTERVAL; in ts4800_ts_probe()
177 poll_dev->open = ts4800_ts_open; in ts4800_ts_probe()
178 poll_dev->close = ts4800_ts_close; in ts4800_ts_probe()
179 poll_dev->poll = ts4800_ts_poll; in ts4800_ts_probe()
181 poll_dev->input->name = "TS-4800 Touchscreen"; in ts4800_ts_probe()
182 poll_dev->input->phys = ts->phys; in ts4800_ts_probe()
184 input_set_capability(poll_dev->input, EV_KEY, BTN_TOUCH); in ts4800_ts_probe()
185 input_set_abs_params(poll_dev->input, ABS_X, 0, MAX_12BIT, 0, 0); in ts4800_ts_probe()
186 input_set_abs_params(poll_dev->input, ABS_Y, 0, MAX_12BIT, 0, 0); in ts4800_ts_probe()
190 dev_err(&pdev->dev, in ts4800_ts_probe()
191 "Unabled to register polled input device (%d)\n", in ts4800_ts_probe()
200 { .compatible = "technologic,ts4800-ts", },
207 .name = "ts4800-ts",
215 MODULE_DESCRIPTION("TS-4800 Touchscreen Driver");