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] << 4) | ((event[3] & S6SY761_MASK_X) >> 4); in s6sy761_report_coordinates()
149 u16 y = (event[2] << 4) | (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()
294 u8 event; in s6sy761_power_on() local
297 ret = regulator_bulk_enable(ARRAY_SIZE(sdata->regulators), in s6sy761_power_on()
298 sdata->regulators); in s6sy761_power_on()
304 /* double check whether the touch is functional */ in s6sy761_power_on()
305 ret = i2c_smbus_read_i2c_block_data(sdata->client, in s6sy761_power_on()
312 event = (buffer[0] >> 2) & 0xf; in s6sy761_power_on()
314 if ((event != S6SY761_EVENT_INFO && in s6sy761_power_on()
315 event != S6SY761_EVENT_VENDOR_INFO) || in s6sy761_power_on()
317 return -ENODEV; in s6sy761_power_on()
320 ret = i2c_smbus_read_byte_data(sdata->client, S6SY761_BOOT_STATUS); in s6sy761_power_on()
326 return -ENODEV; in s6sy761_power_on()
328 /* enable touch functionality */ in s6sy761_power_on()
329 ret = i2c_smbus_write_word_data(sdata->client, in s6sy761_power_on()
348 ret = i2c_smbus_read_i2c_block_data(sdata->client, in s6sy761_hw_init()
355 sdata->devid = get_unaligned_be16(buffer + 1); in s6sy761_hw_init()
357 ret = i2c_smbus_read_i2c_block_data(sdata->client, in s6sy761_hw_init()
368 sdata->tx_channel = max_t(u8, buffer[8], 1); in s6sy761_hw_init()
370 ret = i2c_smbus_read_byte_data(sdata->client, in s6sy761_hw_init()
375 return -ENODEV; in s6sy761_hw_init()
384 disable_irq(sdata->client->irq); in s6sy761_power_off()
385 regulator_bulk_disable(ARRAY_SIZE(sdata->regulators), in s6sy761_power_off()
386 sdata->regulators); in s6sy761_power_off()
395 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C | in s6sy761_probe()
398 return -ENODEV; in s6sy761_probe()
400 sdata = devm_kzalloc(&client->dev, sizeof(*sdata), GFP_KERNEL); in s6sy761_probe()
402 return -ENOMEM; in s6sy761_probe()
405 sdata->client = client; in s6sy761_probe()
407 sdata->regulators[S6SY761_REGULATOR_VDD].supply = "vdd"; in s6sy761_probe()
408 sdata->regulators[S6SY761_REGULATOR_AVDD].supply = "avdd"; in s6sy761_probe()
409 err = devm_regulator_bulk_get(&client->dev, in s6sy761_probe()
410 ARRAY_SIZE(sdata->regulators), in s6sy761_probe()
411 sdata->regulators); in s6sy761_probe()
415 err = devm_add_action_or_reset(&client->dev, s6sy761_power_off, sdata); in s6sy761_probe()
423 sdata->input = devm_input_allocate_device(&client->dev); in s6sy761_probe()
424 if (!sdata->input) in s6sy761_probe()
425 return -ENOMEM; in s6sy761_probe()
427 sdata->input->name = S6SY761_DEV_NAME; in s6sy761_probe()
428 sdata->input->id.bustype = BUS_I2C; in s6sy761_probe()
429 sdata->input->open = s6sy761_input_open; in s6sy761_probe()
430 sdata->input->close = s6sy761_input_close; in s6sy761_probe()
432 input_set_abs_params(sdata->input, ABS_MT_POSITION_X, 0, max_x, 0, 0); in s6sy761_probe()
433 input_set_abs_params(sdata->input, ABS_MT_POSITION_Y, 0, max_y, 0, 0); in s6sy761_probe()
434 input_set_abs_params(sdata->input, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); in s6sy761_probe()
435 input_set_abs_params(sdata->input, ABS_MT_TOUCH_MINOR, 0, 255, 0, 0); in s6sy761_probe()
436 input_set_abs_params(sdata->input, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); in s6sy761_probe()
437 input_set_abs_params(sdata->input, ABS_MT_TOUCH_MINOR, 0, 255, 0, 0); in s6sy761_probe()
438 input_set_abs_params(sdata->input, ABS_MT_PRESSURE, 0, 255, 0, 0); in s6sy761_probe()
440 touchscreen_parse_properties(sdata->input, true, &sdata->prop); in s6sy761_probe()
442 if (!input_abs_get_max(sdata->input, ABS_X) || in s6sy761_probe()
443 !input_abs_get_max(sdata->input, ABS_Y)) { in s6sy761_probe()
444 dev_warn(&client->dev, "the axis have not been set\n"); in s6sy761_probe()
447 err = input_mt_init_slots(sdata->input, sdata->tx_channel, in s6sy761_probe()
452 input_set_drvdata(sdata->input, sdata); in s6sy761_probe()
454 err = input_register_device(sdata->input); in s6sy761_probe()
458 err = devm_request_threaded_irq(&client->dev, client->irq, NULL, in s6sy761_probe()
465 pm_runtime_enable(&client->dev); in s6sy761_probe()
472 pm_runtime_disable(&client->dev); in s6sy761_remove()
479 return i2c_smbus_write_byte_data(sdata->client, in s6sy761_runtime_suspend()
487 return i2c_smbus_write_byte_data(sdata->client, in s6sy761_runtime_resume()
504 enable_irq(sdata->client->irq); in s6sy761_resume()
543 MODULE_DESCRIPTION("Samsung S6SY761 Touch Screen");