Lines Matching +full:client +full:- +full:id

1 // SPDX-License-Identifier: GPL-2.0-only
9 #include <linux/crc-itu-t.h>
25 * u8 Report ID
26 * <contact data - variable length>
33 * u8 finger id
49 #define SIS_PKT_REPORT_OFFSET 2 /* Report ID/type */
71 #define SIS_CONTACT_ID_OFFSET 1 /* Contact ID */
76 #define SIS_CONTACT_PRESSURE_OFFSET(id) (SIS_PKT_HAS_AREA(id) ? 8 : 6) argument
95 struct i2c_client *client; member
104 static int sis_read_packet(struct i2c_client *client, u8 *buf, in sis_read_packet() argument
114 ret = i2c_master_recv(client, buf, SIS_MAX_PACKET_SIZE); in sis_read_packet()
116 return -EIO; in sis_read_packet()
120 dev_err(&client->dev, in sis_read_packet()
123 return -E2BIG; in sis_read_packet()
127 return -EINVAL; in sis_read_packet()
130 count_idx = len - 1; in sis_read_packet()
140 crc = crc_itu_t(0, buf + 2, len - 2 - 2); in sis_read_packet()
141 pkg_crc = get_unaligned_le16(&buf[len - 2]); in sis_read_packet()
144 dev_err(&client->dev, in sis_read_packet()
147 return -EINVAL; in sis_read_packet()
150 count_idx -= 2; in sis_read_packet()
153 dev_err(&client->dev, in sis_read_packet()
154 "%s: invalid packet ID %#02x\n", in sis_read_packet()
156 return -EINVAL; in sis_read_packet()
160 count_idx -= SIS_SCAN_TIME_LEN; in sis_read_packet()
172 static int sis_ts_report_contact(struct sis_ts_data *ts, const u8 *data, u8 id) in sis_ts_report_contact() argument
174 struct input_dev *input = ts->input; in sis_ts_report_contact()
182 dev_err(&ts->client->dev, "Unexpected touch status: %#02x\n", in sis_ts_report_contact()
184 return -EINVAL; in sis_ts_report_contact()
189 return -ENOENT; in sis_ts_report_contact()
197 if (id != SIS_ALL_IN_ONE_PACKAGE) { in sis_ts_report_contact()
198 if (SIS_PKT_HAS_AREA(id)) { in sis_ts_report_contact()
203 if (SIS_PKT_HAS_PRESSURE(id)) in sis_ts_report_contact()
205 data[SIS_CONTACT_PRESSURE_OFFSET(id)]; in sis_ts_report_contact()
234 error = sis_read_packet(ts->client, ts->packet, in sis_ts_handle_packet()
242 dev_err(&ts->client->dev, in sis_ts_handle_packet()
248 report_id = ts->packet[SIS_PKT_REPORT_OFFSET]; in sis_ts_handle_packet()
249 contact = &ts->packet[SIS_PKT_CONTACT_OFFSET]; in sis_ts_handle_packet()
258 num_to_report--; in sis_ts_handle_packet()
272 input_mt_sync_frame(ts->input); in sis_ts_handle_packet()
273 input_sync(ts->input); in sis_ts_handle_packet()
282 } while (ts->attn_gpio && gpiod_get_value_cansleep(ts->attn_gpio)); in sis_ts_irq_handler()
289 if (ts->reset_gpio) { in sis_ts_reset()
292 gpiod_set_value(ts->reset_gpio, 1); in sis_ts_reset()
294 gpiod_set_value(ts->reset_gpio, 0); in sis_ts_reset()
299 static int sis_ts_probe(struct i2c_client *client, in sis_ts_probe() argument
300 const struct i2c_device_id *id) in sis_ts_probe() argument
306 ts = devm_kzalloc(&client->dev, sizeof(*ts), GFP_KERNEL); in sis_ts_probe()
308 return -ENOMEM; in sis_ts_probe()
310 ts->client = client; in sis_ts_probe()
312 ts->attn_gpio = devm_gpiod_get_optional(&client->dev, in sis_ts_probe()
314 if (IS_ERR(ts->attn_gpio)) { in sis_ts_probe()
315 error = PTR_ERR(ts->attn_gpio); in sis_ts_probe()
316 if (error != -EPROBE_DEFER) in sis_ts_probe()
317 dev_err(&client->dev, in sis_ts_probe()
322 ts->reset_gpio = devm_gpiod_get_optional(&client->dev, in sis_ts_probe()
324 if (IS_ERR(ts->reset_gpio)) { in sis_ts_probe()
325 error = PTR_ERR(ts->reset_gpio); in sis_ts_probe()
326 if (error != -EPROBE_DEFER) in sis_ts_probe()
327 dev_err(&client->dev, in sis_ts_probe()
334 ts->input = input = devm_input_allocate_device(&client->dev); in sis_ts_probe()
336 dev_err(&client->dev, "Failed to allocate input device\n"); in sis_ts_probe()
337 return -ENOMEM; in sis_ts_probe()
340 input->name = "SiS Touchscreen"; in sis_ts_probe()
341 input->id.bustype = BUS_I2C; in sis_ts_probe()
353 dev_err(&client->dev, in sis_ts_probe()
358 error = devm_request_threaded_irq(&client->dev, client->irq, in sis_ts_probe()
361 client->name, ts); in sis_ts_probe()
363 dev_err(&client->dev, "Failed to request IRQ: %d\n", error); in sis_ts_probe()
367 error = input_register_device(ts->input); in sis_ts_probe()
369 dev_err(&client->dev, in sis_ts_probe()
379 { .compatible = "sis,9200-ts" },
387 { "9200-ts", 0 },