Lines Matching +full:linux +full:- +full:event +full:- +full:codes

1 // SPDX-License-Identifier: GPL-2.0-or-later
11 #include <linux/gpio/consumer.h>
12 #include <linux/interrupt.h>
13 #include <linux/i2c.h>
14 #include <linux/input.h>
15 #include <linux/input/mt.h>
16 #include <linux/input/touchscreen.h>
17 #include <linux/module.h>
18 #include <linux/of.h>
34 __u8 event; member
61 .addr = client->addr, in icn8318_read_touch_data()
66 .addr = client->addr, in icn8318_read_touch_data()
73 return i2c_transfer(client->adapter, msg, 2); in icn8318_read_touch_data()
76 static inline bool icn8318_touch_active(u8 event) in icn8318_touch_active() argument
78 return (event == ICN8318_EVENT_UPDATE1) || in icn8318_touch_active()
79 (event == ICN8318_EVENT_UPDATE2); in icn8318_touch_active()
85 struct device *dev = &data->client->dev; in icn8318_irq()
89 ret = icn8318_read_touch_data(data->client, &touch_data); in icn8318_irq()
99 * softbutton codes to evdev codes. Currently no known devices in icn8318_irq()
113 bool act = icn8318_touch_active(touch->event); in icn8318_irq()
115 input_mt_slot(data->input, touch->slot); in icn8318_irq()
116 input_mt_report_slot_state(data->input, MT_TOOL_FINGER, act); in icn8318_irq()
120 touchscreen_report_pos(data->input, &data->prop, in icn8318_irq()
121 be16_to_cpu(touch->x), in icn8318_irq()
122 be16_to_cpu(touch->y), true); in icn8318_irq()
125 input_mt_sync_frame(data->input); in icn8318_irq()
126 input_sync(data->input); in icn8318_irq()
135 enable_irq(data->client->irq); in icn8318_start()
136 gpiod_set_value_cansleep(data->wake_gpio, 1); in icn8318_start()
145 disable_irq(data->client->irq); in icn8318_stop()
146 i2c_smbus_write_byte_data(data->client, ICN8318_REG_POWER, in icn8318_stop()
148 gpiod_set_value_cansleep(data->wake_gpio, 0); in icn8318_stop()
155 mutex_lock(&data->input->mutex); in icn8318_suspend()
156 if (input_device_enabled(data->input)) in icn8318_suspend()
157 icn8318_stop(data->input); in icn8318_suspend()
158 mutex_unlock(&data->input->mutex); in icn8318_suspend()
167 mutex_lock(&data->input->mutex); in icn8318_resume()
168 if (input_device_enabled(data->input)) in icn8318_resume()
169 icn8318_start(data->input); in icn8318_resume()
170 mutex_unlock(&data->input->mutex); in icn8318_resume()
179 struct device *dev = &client->dev; in icn8318_probe()
184 if (!client->irq) { in icn8318_probe()
186 return -EINVAL; in icn8318_probe()
191 return -ENOMEM; in icn8318_probe()
193 data->wake_gpio = devm_gpiod_get(dev, "wake", GPIOD_OUT_LOW); in icn8318_probe()
194 if (IS_ERR(data->wake_gpio)) in icn8318_probe()
195 return dev_err_probe(dev, PTR_ERR(data->wake_gpio), "Error getting wake gpio\n"); in icn8318_probe()
199 return -ENOMEM; in icn8318_probe()
201 input->name = client->name; in icn8318_probe()
202 input->id.bustype = BUS_I2C; in icn8318_probe()
203 input->open = icn8318_start; in icn8318_probe()
204 input->close = icn8318_stop; in icn8318_probe()
205 input->dev.parent = dev; in icn8318_probe()
210 touchscreen_parse_properties(input, true, &data->prop); in icn8318_probe()
213 dev_err(dev, "Error touchscreen-size-x and/or -y missing\n"); in icn8318_probe()
214 return -EINVAL; in icn8318_probe()
222 data->client = client; in icn8318_probe()
223 data->input = input; in icn8318_probe()
226 error = devm_request_threaded_irq(dev, client->irq, NULL, icn8318_irq, in icn8318_probe()
227 IRQF_ONESHOT, client->name, data); in icn8318_probe()
234 icn8318_stop(data->input); in icn8318_probe()
251 /* This is useless for OF-enabled devices, but it is needed by I2C subsystem */