Lines Matching +full:event +full:- +full:touch
1 // SPDX-License-Identifier: GPL-2.0
54 /* multi touch related event masks */
61 /* key related event masks */
116 if (value != sdata->led_status && sdata->ledvdd) { in stmfts_brightness_set()
118 regulator_disable(sdata->ledvdd); in stmfts_brightness_set()
120 err = regulator_enable(sdata->ledvdd); in stmfts_brightness_set()
122 dev_warn(&sdata->client->dev, in stmfts_brightness_set()
128 sdata->led_status = value; in stmfts_brightness_set()
139 return !!regulator_is_enabled(sdata->ledvdd); in stmfts_brightness_get()
151 .addr = sdata->client->addr, in stmfts_read_events()
156 .addr = sdata->client->addr, in stmfts_read_events()
159 .buf = sdata->data, in stmfts_read_events()
164 ret = i2c_transfer(sdata->client->adapter, msgs, ARRAY_SIZE(msgs)); in stmfts_read_events()
168 return ret == ARRAY_SIZE(msgs) ? 0 : -EIO; in stmfts_read_events()
172 const u8 event[]) in stmfts_report_contact_event() argument
174 u8 slot_id = (event[0] & STMFTS_MASK_TOUCH_ID) >> 4; in stmfts_report_contact_event()
175 u16 x = event[1] | ((event[2] & STMFTS_MASK_X_MSB) << 8); in stmfts_report_contact_event()
176 u16 y = (event[2] >> 4) | (event[3] << 4); in stmfts_report_contact_event()
177 u8 maj = event[4]; in stmfts_report_contact_event()
178 u8 min = event[5]; in stmfts_report_contact_event()
179 u8 orientation = event[6]; in stmfts_report_contact_event()
180 u8 area = event[7]; in stmfts_report_contact_event()
182 input_mt_slot(sdata->input, slot_id); in stmfts_report_contact_event()
184 input_mt_report_slot_state(sdata->input, MT_TOOL_FINGER, true); in stmfts_report_contact_event()
185 input_report_abs(sdata->input, ABS_MT_POSITION_X, x); in stmfts_report_contact_event()
186 input_report_abs(sdata->input, ABS_MT_POSITION_Y, y); in stmfts_report_contact_event()
187 input_report_abs(sdata->input, ABS_MT_TOUCH_MAJOR, maj); in stmfts_report_contact_event()
188 input_report_abs(sdata->input, ABS_MT_TOUCH_MINOR, min); in stmfts_report_contact_event()
189 input_report_abs(sdata->input, ABS_MT_PRESSURE, area); in stmfts_report_contact_event()
190 input_report_abs(sdata->input, ABS_MT_ORIENTATION, orientation); in stmfts_report_contact_event()
192 input_sync(sdata->input); in stmfts_report_contact_event()
196 const u8 event[]) in stmfts_report_contact_release() argument
198 u8 slot_id = (event[0] & STMFTS_MASK_TOUCH_ID) >> 4; in stmfts_report_contact_release()
200 input_mt_slot(sdata->input, slot_id); in stmfts_report_contact_release()
201 input_mt_report_slot_inactive(sdata->input); in stmfts_report_contact_release()
203 input_sync(sdata->input); in stmfts_report_contact_release()
207 const u8 event[]) in stmfts_report_hover_event() argument
209 u16 x = (event[2] << 4) | (event[4] >> 4); in stmfts_report_hover_event()
210 u16 y = (event[3] << 4) | (event[4] & STMFTS_MASK_Y_LSB); in stmfts_report_hover_event()
211 u8 z = event[5]; in stmfts_report_hover_event()
213 input_report_abs(sdata->input, ABS_X, x); in stmfts_report_hover_event()
214 input_report_abs(sdata->input, ABS_Y, y); in stmfts_report_hover_event()
215 input_report_abs(sdata->input, ABS_DISTANCE, z); in stmfts_report_hover_event()
217 input_sync(sdata->input); in stmfts_report_hover_event()
220 static void stmfts_report_key_event(struct stmfts_data *sdata, const u8 event[]) in stmfts_report_key_event() argument
222 switch (event[2]) { in stmfts_report_key_event()
224 input_report_key(sdata->input, KEY_BACK, 0); in stmfts_report_key_event()
225 input_report_key(sdata->input, KEY_MENU, 0); in stmfts_report_key_event()
229 input_report_key(sdata->input, KEY_BACK, 1); in stmfts_report_key_event()
233 input_report_key(sdata->input, KEY_MENU, 1); in stmfts_report_key_event()
237 dev_warn(&sdata->client->dev, in stmfts_report_key_event()
238 "unknown key event: %#02x\n", event[2]); in stmfts_report_key_event()
242 input_sync(sdata->input); in stmfts_report_key_event()
250 u8 *event = &sdata->data[i * STMFTS_EVENT_SIZE]; in stmfts_parse_events() local
252 switch (event[0]) { in stmfts_parse_events()
257 complete(&sdata->cmd_done); in stmfts_parse_events()
265 switch (event[0] & STMFTS_MASK_EVENT_ID) { in stmfts_parse_events()
269 stmfts_report_contact_event(sdata, event); in stmfts_parse_events()
273 stmfts_report_contact_release(sdata, event); in stmfts_parse_events()
279 stmfts_report_hover_event(sdata, event); in stmfts_parse_events()
283 stmfts_report_key_event(sdata, event); in stmfts_parse_events()
287 dev_warn(&sdata->client->dev, in stmfts_parse_events()
289 event[6], event[5], event[4], in stmfts_parse_events()
290 event[3], event[2], event[1]); in stmfts_parse_events()
294 dev_err(&sdata->client->dev, in stmfts_parse_events()
295 "unknown event %#02x\n", event[0]); in stmfts_parse_events()
305 mutex_lock(&sdata->mutex); in stmfts_irq_handler()
309 dev_err(&sdata->client->dev, in stmfts_irq_handler()
314 mutex_unlock(&sdata->mutex); in stmfts_irq_handler()
322 reinit_completion(&sdata->cmd_done); in stmfts_command()
324 err = i2c_smbus_write_byte(sdata->client, cmd); in stmfts_command()
328 if (!wait_for_completion_timeout(&sdata->cmd_done, in stmfts_command()
330 return -ETIMEDOUT; in stmfts_command()
340 err = pm_runtime_get_sync(&sdata->client->dev); in stmfts_input_open()
344 err = i2c_smbus_write_byte(sdata->client, STMFTS_MS_MT_SENSE_ON); in stmfts_input_open()
348 mutex_lock(&sdata->mutex); in stmfts_input_open()
349 sdata->running = true; in stmfts_input_open()
351 if (sdata->hover_enabled) { in stmfts_input_open()
352 err = i2c_smbus_write_byte(sdata->client, in stmfts_input_open()
355 dev_warn(&sdata->client->dev, in stmfts_input_open()
358 mutex_unlock(&sdata->mutex); in stmfts_input_open()
360 if (sdata->use_key) { in stmfts_input_open()
361 err = i2c_smbus_write_byte(sdata->client, in stmfts_input_open()
364 /* I can still use only the touch screen */ in stmfts_input_open()
365 dev_warn(&sdata->client->dev, in stmfts_input_open()
377 err = i2c_smbus_write_byte(sdata->client, STMFTS_MS_MT_SENSE_OFF); in stmfts_input_close()
379 dev_warn(&sdata->client->dev, in stmfts_input_close()
382 mutex_lock(&sdata->mutex); in stmfts_input_close()
384 sdata->running = false; in stmfts_input_close()
386 if (sdata->hover_enabled) { in stmfts_input_close()
387 err = i2c_smbus_write_byte(sdata->client, in stmfts_input_close()
390 dev_warn(&sdata->client->dev, in stmfts_input_close()
393 mutex_unlock(&sdata->mutex); in stmfts_input_close()
395 if (sdata->use_key) { in stmfts_input_close()
396 err = i2c_smbus_write_byte(sdata->client, in stmfts_input_close()
399 dev_warn(&sdata->client->dev, in stmfts_input_close()
403 pm_runtime_put_sync(&sdata->client->dev); in stmfts_input_close()
411 return sprintf(buf, "%#x\n", sdata->chip_id); in stmfts_sysfs_chip_id()
419 return sprintf(buf, "%u\n", sdata->chip_ver); in stmfts_sysfs_chip_version()
427 return sprintf(buf, "%u\n", sdata->fw_ver); in stmfts_sysfs_fw_ver()
435 return sprintf(buf, "%#x\n", sdata->config_id); in stmfts_sysfs_config_id()
443 return sprintf(buf, "%u\n", sdata->config_ver); in stmfts_sysfs_config_version()
453 err = i2c_smbus_read_i2c_block_data(sdata->client, STMFTS_READ_STATUS, in stmfts_sysfs_read_status()
466 return sprintf(buf, "%u\n", sdata->hover_enabled); in stmfts_sysfs_hover_enable_read()
478 return -EINVAL; in stmfts_sysfs_hover_enable_write()
480 mutex_lock(&sdata->mutex); in stmfts_sysfs_hover_enable_write()
482 if (value && sdata->hover_enabled) in stmfts_sysfs_hover_enable_write()
485 if (sdata->running) in stmfts_sysfs_hover_enable_write()
486 err = i2c_smbus_write_byte(sdata->client, in stmfts_sysfs_hover_enable_write()
491 sdata->hover_enabled = !!value; in stmfts_sysfs_hover_enable_write()
494 mutex_unlock(&sdata->mutex); in stmfts_sysfs_hover_enable_write()
528 err = regulator_bulk_enable(ARRAY_SIZE(sdata->regulators), in stmfts_power_on()
529 sdata->regulators); in stmfts_power_on()
539 err = i2c_smbus_read_i2c_block_data(sdata->client, STMFTS_READ_INFO, in stmfts_power_on()
544 return -EIO; in stmfts_power_on()
546 sdata->chip_id = be16_to_cpup((__be16 *)®[6]); in stmfts_power_on()
547 sdata->chip_ver = reg[0]; in stmfts_power_on()
548 sdata->fw_ver = be16_to_cpup((__be16 *)®[2]); in stmfts_power_on()
549 sdata->config_id = reg[4]; in stmfts_power_on()
550 sdata->config_ver = reg[5]; in stmfts_power_on()
552 enable_irq(sdata->client->irq); in stmfts_power_on()
567 dev_warn(&sdata->client->dev, in stmfts_power_on()
573 dev_warn(&sdata->client->dev, in stmfts_power_on()
584 (void) i2c_smbus_write_byte(sdata->client, STMFTS_SLEEP_IN); in stmfts_power_on()
593 disable_irq(sdata->client->irq); in stmfts_power_off()
594 regulator_bulk_disable(ARRAY_SIZE(sdata->regulators), in stmfts_power_off()
595 sdata->regulators); in stmfts_power_off()
598 /* This function is void because I don't want to prevent using the touch key
606 sdata->ledvdd = devm_regulator_get(&sdata->client->dev, "ledvdd"); in stmfts_enable_led()
607 if (IS_ERR(sdata->ledvdd)) in stmfts_enable_led()
608 return PTR_ERR(sdata->ledvdd); in stmfts_enable_led()
610 sdata->led_cdev.name = STMFTS_DEV_NAME; in stmfts_enable_led()
611 sdata->led_cdev.max_brightness = LED_ON; in stmfts_enable_led()
612 sdata->led_cdev.brightness = LED_OFF; in stmfts_enable_led()
613 sdata->led_cdev.brightness_set_blocking = stmfts_brightness_set; in stmfts_enable_led()
614 sdata->led_cdev.brightness_get = stmfts_brightness_get; in stmfts_enable_led()
616 err = devm_led_classdev_register(&sdata->client->dev, &sdata->led_cdev); in stmfts_enable_led()
618 devm_regulator_put(sdata->ledvdd); in stmfts_enable_led()
631 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C | in stmfts_probe()
634 return -ENODEV; in stmfts_probe()
636 sdata = devm_kzalloc(&client->dev, sizeof(*sdata), GFP_KERNEL); in stmfts_probe()
638 return -ENOMEM; in stmfts_probe()
642 sdata->client = client; in stmfts_probe()
643 mutex_init(&sdata->mutex); in stmfts_probe()
644 init_completion(&sdata->cmd_done); in stmfts_probe()
646 sdata->regulators[STMFTS_REGULATOR_VDD].supply = "vdd"; in stmfts_probe()
647 sdata->regulators[STMFTS_REGULATOR_AVDD].supply = "avdd"; in stmfts_probe()
648 err = devm_regulator_bulk_get(&client->dev, in stmfts_probe()
649 ARRAY_SIZE(sdata->regulators), in stmfts_probe()
650 sdata->regulators); in stmfts_probe()
654 sdata->input = devm_input_allocate_device(&client->dev); in stmfts_probe()
655 if (!sdata->input) in stmfts_probe()
656 return -ENOMEM; in stmfts_probe()
658 sdata->input->name = STMFTS_DEV_NAME; in stmfts_probe()
659 sdata->input->id.bustype = BUS_I2C; in stmfts_probe()
660 sdata->input->open = stmfts_input_open; in stmfts_probe()
661 sdata->input->close = stmfts_input_close; in stmfts_probe()
663 input_set_capability(sdata->input, EV_ABS, ABS_MT_POSITION_X); in stmfts_probe()
664 input_set_capability(sdata->input, EV_ABS, ABS_MT_POSITION_Y); in stmfts_probe()
665 touchscreen_parse_properties(sdata->input, true, &sdata->prop); in stmfts_probe()
667 input_set_abs_params(sdata->input, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); in stmfts_probe()
668 input_set_abs_params(sdata->input, ABS_MT_TOUCH_MINOR, 0, 255, 0, 0); in stmfts_probe()
669 input_set_abs_params(sdata->input, ABS_MT_ORIENTATION, 0, 255, 0, 0); in stmfts_probe()
670 input_set_abs_params(sdata->input, ABS_MT_PRESSURE, 0, 255, 0, 0); in stmfts_probe()
671 input_set_abs_params(sdata->input, ABS_DISTANCE, 0, 255, 0, 0); in stmfts_probe()
673 sdata->use_key = device_property_read_bool(&client->dev, in stmfts_probe()
674 "touch-key-connected"); in stmfts_probe()
675 if (sdata->use_key) { in stmfts_probe()
676 input_set_capability(sdata->input, EV_KEY, KEY_MENU); in stmfts_probe()
677 input_set_capability(sdata->input, EV_KEY, KEY_BACK); in stmfts_probe()
680 err = input_mt_init_slots(sdata->input, in stmfts_probe()
685 input_set_drvdata(sdata->input, sdata); in stmfts_probe()
694 irq_set_status_flags(client->irq, IRQ_NOAUTOEN); in stmfts_probe()
695 err = devm_request_threaded_irq(&client->dev, client->irq, in stmfts_probe()
702 dev_dbg(&client->dev, "initializing ST-Microelectronics FTS...\n"); in stmfts_probe()
708 err = devm_add_action_or_reset(&client->dev, stmfts_power_off, sdata); in stmfts_probe()
712 err = input_register_device(sdata->input); in stmfts_probe()
716 if (sdata->use_key) { in stmfts_probe()
725 dev_warn(&client->dev, "unable to use touchkey leds\n"); in stmfts_probe()
726 sdata->ledvdd = NULL; in stmfts_probe()
730 err = devm_device_add_group(&client->dev, &stmfts_attribute_group); in stmfts_probe()
734 pm_runtime_enable(&client->dev); in stmfts_probe()
735 device_enable_async_suspend(&client->dev); in stmfts_probe()
742 pm_runtime_disable(&client->dev); in stmfts_remove()
752 ret = i2c_smbus_write_byte(sdata->client, STMFTS_SLEEP_IN); in stmfts_runtime_suspend()
764 ret = i2c_smbus_write_byte(sdata->client, STMFTS_SLEEP_OUT); in stmfts_runtime_resume()
821 MODULE_DESCRIPTION("STMicroelectronics FTS Touch Screen");