Lines Matching +full:event +full:- +full:touch
1 // SPDX-License-Identifier: GPL-2.0
60 /* event id */
64 /* event register masks */
74 /* event touch state values */
122 .addr = sdata->client->addr, in s6sy761_read_events()
127 .addr = sdata->client->addr, in s6sy761_read_events()
130 .buf = sdata->data + S6SY761_EVENT_SIZE, in s6sy761_read_events()
135 ret = i2c_transfer(sdata->client->adapter, msgs, ARRAY_SIZE(msgs)); in s6sy761_read_events()
139 return ret == ARRAY_SIZE(msgs) ? 0 : -EIO; in s6sy761_read_events()
143 u8 *event, u8 tid) in s6sy761_report_coordinates() argument
145 u8 major = event[4]; in s6sy761_report_coordinates()
146 u8 minor = event[5]; in s6sy761_report_coordinates()
147 u8 z = event[6] & S6SY761_MASK_Z; in s6sy761_report_coordinates()
148 u16 x = (event[1] << 3) | ((event[3] & S6SY761_MASK_X) >> 4); in s6sy761_report_coordinates()
149 u16 y = (event[2] << 3) | (event[3] & S6SY761_MASK_Y); in s6sy761_report_coordinates()
151 input_mt_slot(sdata->input, tid); in s6sy761_report_coordinates()
153 input_mt_report_slot_state(sdata->input, MT_TOOL_FINGER, true); in s6sy761_report_coordinates()
154 input_report_abs(sdata->input, ABS_MT_POSITION_X, x); in s6sy761_report_coordinates()
155 input_report_abs(sdata->input, ABS_MT_POSITION_Y, y); in s6sy761_report_coordinates()
156 input_report_abs(sdata->input, ABS_MT_TOUCH_MAJOR, major); in s6sy761_report_coordinates()
157 input_report_abs(sdata->input, ABS_MT_TOUCH_MINOR, minor); in s6sy761_report_coordinates()
158 input_report_abs(sdata->input, ABS_MT_PRESSURE, z); in s6sy761_report_coordinates()
160 input_sync(sdata->input); in s6sy761_report_coordinates()
164 u8 *event, u8 tid) in s6sy761_report_release() argument
166 input_mt_slot(sdata->input, tid); in s6sy761_report_release()
167 input_mt_report_slot_state(sdata->input, MT_TOOL_FINGER, false); in s6sy761_report_release()
169 input_sync(sdata->input); in s6sy761_report_release()
172 static void s6sy761_handle_coordinates(struct s6sy761_data *sdata, u8 *event) in s6sy761_handle_coordinates() argument
177 if (unlikely(!(event[0] & S6SY761_MASK_TID))) in s6sy761_handle_coordinates()
180 tid = ((event[0] & S6SY761_MASK_TID) >> 2) - 1; in s6sy761_handle_coordinates()
181 touch_state = (event[0] & S6SY761_MASK_TOUCH_STATE) >> 6; in s6sy761_handle_coordinates()
188 s6sy761_report_release(sdata, event, tid); in s6sy761_handle_coordinates()
192 s6sy761_report_coordinates(sdata, event, tid); in s6sy761_handle_coordinates()
202 u8 *event = &sdata->data[i * S6SY761_EVENT_SIZE]; in s6sy761_handle_events() local
203 u8 event_id = event[0] & S6SY761_MASK_EID; in s6sy761_handle_events()
205 if (!event[0]) in s6sy761_handle_events()
211 s6sy761_handle_coordinates(sdata, event); in s6sy761_handle_events()
229 ret = i2c_smbus_read_i2c_block_data(sdata->client, in s6sy761_irq_handler()
232 sdata->data); in s6sy761_irq_handler()
234 dev_err(&sdata->client->dev, "failed to read events\n"); in s6sy761_irq_handler()
238 if (!sdata->data[0]) in s6sy761_irq_handler()
241 n_events = sdata->data[7] & S6SY761_MASK_LEFT_EVENTS; in s6sy761_irq_handler()
242 if (unlikely(n_events > S6SY761_EVENT_COUNT - 1)) in s6sy761_irq_handler()
248 dev_err(&sdata->client->dev, "failed to read events\n"); in s6sy761_irq_handler()
262 return i2c_smbus_write_byte(sdata->client, S6SY761_SENSE_ON); in s6sy761_input_open()
270 ret = i2c_smbus_write_byte(sdata->client, S6SY761_SENSE_OFF); in s6sy761_input_close()
272 dev_err(&sdata->client->dev, "failed to turn off sensing\n"); in s6sy761_input_close()
280 return sprintf(buf, "%#x\n", sdata->devid); in s6sy761_sysfs_devid()
297 u8 event; in s6sy761_power_on() local
300 ret = regulator_bulk_enable(ARRAY_SIZE(sdata->regulators), in s6sy761_power_on()
301 sdata->regulators); in s6sy761_power_on()
307 /* double check whether the touch is functional */ in s6sy761_power_on()
308 ret = i2c_smbus_read_i2c_block_data(sdata->client, in s6sy761_power_on()
315 event = (buffer[0] >> 2) & 0xf; in s6sy761_power_on()
317 if ((event != S6SY761_EVENT_INFO && in s6sy761_power_on()
318 event != S6SY761_EVENT_VENDOR_INFO) || in s6sy761_power_on()
320 return -ENODEV; in s6sy761_power_on()
323 ret = i2c_smbus_read_byte_data(sdata->client, S6SY761_BOOT_STATUS); in s6sy761_power_on()
329 return -ENODEV; in s6sy761_power_on()
331 /* enable touch functionality */ in s6sy761_power_on()
332 ret = i2c_smbus_write_word_data(sdata->client, in s6sy761_power_on()
351 ret = i2c_smbus_read_i2c_block_data(sdata->client, in s6sy761_hw_init()
358 sdata->devid = get_unaligned_be16(buffer + 1); in s6sy761_hw_init()
360 ret = i2c_smbus_read_i2c_block_data(sdata->client, in s6sy761_hw_init()
371 sdata->tx_channel = max_t(u8, buffer[8], 1); in s6sy761_hw_init()
373 ret = i2c_smbus_read_byte_data(sdata->client, in s6sy761_hw_init()
378 return -ENODEV; in s6sy761_hw_init()
387 disable_irq(sdata->client->irq); in s6sy761_power_off()
388 regulator_bulk_disable(ARRAY_SIZE(sdata->regulators), in s6sy761_power_off()
389 sdata->regulators); in s6sy761_power_off()
399 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C | in s6sy761_probe()
402 return -ENODEV; in s6sy761_probe()
404 sdata = devm_kzalloc(&client->dev, sizeof(*sdata), GFP_KERNEL); in s6sy761_probe()
406 return -ENOMEM; in s6sy761_probe()
409 sdata->client = client; in s6sy761_probe()
411 sdata->regulators[S6SY761_REGULATOR_VDD].supply = "vdd"; in s6sy761_probe()
412 sdata->regulators[S6SY761_REGULATOR_AVDD].supply = "avdd"; in s6sy761_probe()
413 err = devm_regulator_bulk_get(&client->dev, in s6sy761_probe()
414 ARRAY_SIZE(sdata->regulators), in s6sy761_probe()
415 sdata->regulators); in s6sy761_probe()
419 err = devm_add_action_or_reset(&client->dev, s6sy761_power_off, sdata); in s6sy761_probe()
427 sdata->input = devm_input_allocate_device(&client->dev); in s6sy761_probe()
428 if (!sdata->input) in s6sy761_probe()
429 return -ENOMEM; in s6sy761_probe()
431 sdata->input->name = S6SY761_DEV_NAME; in s6sy761_probe()
432 sdata->input->id.bustype = BUS_I2C; in s6sy761_probe()
433 sdata->input->open = s6sy761_input_open; in s6sy761_probe()
434 sdata->input->close = s6sy761_input_close; in s6sy761_probe()
436 input_set_abs_params(sdata->input, ABS_MT_POSITION_X, 0, max_x, 0, 0); in s6sy761_probe()
437 input_set_abs_params(sdata->input, ABS_MT_POSITION_Y, 0, max_y, 0, 0); in s6sy761_probe()
438 input_set_abs_params(sdata->input, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); in s6sy761_probe()
439 input_set_abs_params(sdata->input, ABS_MT_TOUCH_MINOR, 0, 255, 0, 0); in s6sy761_probe()
440 input_set_abs_params(sdata->input, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); in s6sy761_probe()
441 input_set_abs_params(sdata->input, ABS_MT_TOUCH_MINOR, 0, 255, 0, 0); in s6sy761_probe()
442 input_set_abs_params(sdata->input, ABS_MT_PRESSURE, 0, 255, 0, 0); in s6sy761_probe()
444 touchscreen_parse_properties(sdata->input, true, &sdata->prop); in s6sy761_probe()
446 if (!input_abs_get_max(sdata->input, ABS_X) || in s6sy761_probe()
447 !input_abs_get_max(sdata->input, ABS_Y)) { in s6sy761_probe()
448 dev_warn(&client->dev, "the axis have not been set\n"); in s6sy761_probe()
451 err = input_mt_init_slots(sdata->input, sdata->tx_channel, in s6sy761_probe()
456 input_set_drvdata(sdata->input, sdata); in s6sy761_probe()
458 err = input_register_device(sdata->input); in s6sy761_probe()
462 err = devm_request_threaded_irq(&client->dev, client->irq, NULL, in s6sy761_probe()
469 err = devm_device_add_group(&client->dev, &s6sy761_attribute_group); in s6sy761_probe()
473 pm_runtime_enable(&client->dev); in s6sy761_probe()
480 pm_runtime_disable(&client->dev); in s6sy761_remove()
489 return i2c_smbus_write_byte_data(sdata->client, in s6sy761_runtime_suspend()
497 return i2c_smbus_write_byte_data(sdata->client, in s6sy761_runtime_resume()
514 enable_irq(sdata->client->irq); in s6sy761_resume()
553 MODULE_DESCRIPTION("Samsung S6SY761 Touch Screen");