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_resume_and_get(&sdata->client->dev); in stmfts_input_open()
344 err = i2c_smbus_write_byte(sdata->client, STMFTS_MS_MT_SENSE_ON); in stmfts_input_open()
346 pm_runtime_put_sync(&sdata->client->dev); in stmfts_input_open()
350 mutex_lock(&sdata->mutex); in stmfts_input_open()
351 sdata->running = true; in stmfts_input_open()
353 if (sdata->hover_enabled) { in stmfts_input_open()
354 err = i2c_smbus_write_byte(sdata->client, in stmfts_input_open()
357 dev_warn(&sdata->client->dev, in stmfts_input_open()
360 mutex_unlock(&sdata->mutex); in stmfts_input_open()
362 if (sdata->use_key) { in stmfts_input_open()
363 err = i2c_smbus_write_byte(sdata->client, in stmfts_input_open()
366 /* I can still use only the touch screen */ in stmfts_input_open()
367 dev_warn(&sdata->client->dev, in stmfts_input_open()
379 err = i2c_smbus_write_byte(sdata->client, STMFTS_MS_MT_SENSE_OFF); in stmfts_input_close()
381 dev_warn(&sdata->client->dev, in stmfts_input_close()
384 mutex_lock(&sdata->mutex); in stmfts_input_close()
386 sdata->running = false; in stmfts_input_close()
388 if (sdata->hover_enabled) { in stmfts_input_close()
389 err = i2c_smbus_write_byte(sdata->client, in stmfts_input_close()
392 dev_warn(&sdata->client->dev, in stmfts_input_close()
395 mutex_unlock(&sdata->mutex); in stmfts_input_close()
397 if (sdata->use_key) { in stmfts_input_close()
398 err = i2c_smbus_write_byte(sdata->client, in stmfts_input_close()
401 dev_warn(&sdata->client->dev, in stmfts_input_close()
405 pm_runtime_put_sync(&sdata->client->dev); in stmfts_input_close()
413 return sprintf(buf, "%#x\n", sdata->chip_id); in stmfts_sysfs_chip_id()
421 return sprintf(buf, "%u\n", sdata->chip_ver); in stmfts_sysfs_chip_version()
429 return sprintf(buf, "%u\n", sdata->fw_ver); in stmfts_sysfs_fw_ver()
437 return sprintf(buf, "%#x\n", sdata->config_id); in stmfts_sysfs_config_id()
445 return sprintf(buf, "%u\n", sdata->config_ver); in stmfts_sysfs_config_version()
455 err = i2c_smbus_read_i2c_block_data(sdata->client, STMFTS_READ_STATUS, in stmfts_sysfs_read_status()
468 return sprintf(buf, "%u\n", sdata->hover_enabled); in stmfts_sysfs_hover_enable_read()
480 return -EINVAL; in stmfts_sysfs_hover_enable_write()
482 mutex_lock(&sdata->mutex); in stmfts_sysfs_hover_enable_write()
484 if (value && sdata->hover_enabled) in stmfts_sysfs_hover_enable_write()
487 if (sdata->running) in stmfts_sysfs_hover_enable_write()
488 err = i2c_smbus_write_byte(sdata->client, in stmfts_sysfs_hover_enable_write()
493 sdata->hover_enabled = !!value; in stmfts_sysfs_hover_enable_write()
496 mutex_unlock(&sdata->mutex); in stmfts_sysfs_hover_enable_write()
527 err = regulator_bulk_enable(ARRAY_SIZE(sdata->regulators), in stmfts_power_on()
528 sdata->regulators); in stmfts_power_on()
538 err = i2c_smbus_read_i2c_block_data(sdata->client, STMFTS_READ_INFO, in stmfts_power_on()
543 return -EIO; in stmfts_power_on()
545 sdata->chip_id = be16_to_cpup((__be16 *)®[6]); in stmfts_power_on()
546 sdata->chip_ver = reg[0]; in stmfts_power_on()
547 sdata->fw_ver = be16_to_cpup((__be16 *)®[2]); in stmfts_power_on()
548 sdata->config_id = reg[4]; in stmfts_power_on()
549 sdata->config_ver = reg[5]; in stmfts_power_on()
551 enable_irq(sdata->client->irq); in stmfts_power_on()
566 dev_warn(&sdata->client->dev, in stmfts_power_on()
572 dev_warn(&sdata->client->dev, in stmfts_power_on()
583 (void) i2c_smbus_write_byte(sdata->client, STMFTS_SLEEP_IN); in stmfts_power_on()
592 disable_irq(sdata->client->irq); in stmfts_power_off()
593 regulator_bulk_disable(ARRAY_SIZE(sdata->regulators), in stmfts_power_off()
594 sdata->regulators); in stmfts_power_off()
597 /* This function is void because I don't want to prevent using the touch key
605 sdata->ledvdd = devm_regulator_get(&sdata->client->dev, "ledvdd"); in stmfts_enable_led()
606 if (IS_ERR(sdata->ledvdd)) in stmfts_enable_led()
607 return PTR_ERR(sdata->ledvdd); in stmfts_enable_led()
609 sdata->led_cdev.name = STMFTS_DEV_NAME; in stmfts_enable_led()
610 sdata->led_cdev.max_brightness = LED_ON; in stmfts_enable_led()
611 sdata->led_cdev.brightness = LED_OFF; in stmfts_enable_led()
612 sdata->led_cdev.brightness_set_blocking = stmfts_brightness_set; in stmfts_enable_led()
613 sdata->led_cdev.brightness_get = stmfts_brightness_get; in stmfts_enable_led()
615 err = devm_led_classdev_register(&sdata->client->dev, &sdata->led_cdev); in stmfts_enable_led()
617 devm_regulator_put(sdata->ledvdd); in stmfts_enable_led()
629 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C | in stmfts_probe()
632 return -ENODEV; in stmfts_probe()
634 sdata = devm_kzalloc(&client->dev, sizeof(*sdata), GFP_KERNEL); in stmfts_probe()
636 return -ENOMEM; in stmfts_probe()
640 sdata->client = client; in stmfts_probe()
641 mutex_init(&sdata->mutex); in stmfts_probe()
642 init_completion(&sdata->cmd_done); in stmfts_probe()
644 sdata->regulators[STMFTS_REGULATOR_VDD].supply = "vdd"; in stmfts_probe()
645 sdata->regulators[STMFTS_REGULATOR_AVDD].supply = "avdd"; in stmfts_probe()
646 err = devm_regulator_bulk_get(&client->dev, in stmfts_probe()
647 ARRAY_SIZE(sdata->regulators), in stmfts_probe()
648 sdata->regulators); in stmfts_probe()
652 sdata->input = devm_input_allocate_device(&client->dev); in stmfts_probe()
653 if (!sdata->input) in stmfts_probe()
654 return -ENOMEM; in stmfts_probe()
656 sdata->input->name = STMFTS_DEV_NAME; in stmfts_probe()
657 sdata->input->id.bustype = BUS_I2C; in stmfts_probe()
658 sdata->input->open = stmfts_input_open; in stmfts_probe()
659 sdata->input->close = stmfts_input_close; in stmfts_probe()
661 input_set_capability(sdata->input, EV_ABS, ABS_MT_POSITION_X); in stmfts_probe()
662 input_set_capability(sdata->input, EV_ABS, ABS_MT_POSITION_Y); in stmfts_probe()
663 touchscreen_parse_properties(sdata->input, true, &sdata->prop); in stmfts_probe()
665 input_set_abs_params(sdata->input, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); in stmfts_probe()
666 input_set_abs_params(sdata->input, ABS_MT_TOUCH_MINOR, 0, 255, 0, 0); in stmfts_probe()
667 input_set_abs_params(sdata->input, ABS_MT_ORIENTATION, 0, 255, 0, 0); in stmfts_probe()
668 input_set_abs_params(sdata->input, ABS_MT_PRESSURE, 0, 255, 0, 0); in stmfts_probe()
669 input_set_abs_params(sdata->input, ABS_DISTANCE, 0, 255, 0, 0); in stmfts_probe()
671 sdata->use_key = device_property_read_bool(&client->dev, in stmfts_probe()
672 "touch-key-connected"); in stmfts_probe()
673 if (sdata->use_key) { in stmfts_probe()
674 input_set_capability(sdata->input, EV_KEY, KEY_MENU); in stmfts_probe()
675 input_set_capability(sdata->input, EV_KEY, KEY_BACK); in stmfts_probe()
678 err = input_mt_init_slots(sdata->input, in stmfts_probe()
683 input_set_drvdata(sdata->input, sdata); in stmfts_probe()
692 err = devm_request_threaded_irq(&client->dev, client->irq, in stmfts_probe()
699 dev_dbg(&client->dev, "initializing ST-Microelectronics FTS...\n"); in stmfts_probe()
705 err = devm_add_action_or_reset(&client->dev, stmfts_power_off, sdata); in stmfts_probe()
709 err = input_register_device(sdata->input); in stmfts_probe()
713 if (sdata->use_key) { in stmfts_probe()
722 dev_warn(&client->dev, "unable to use touchkey leds\n"); in stmfts_probe()
723 sdata->ledvdd = NULL; in stmfts_probe()
727 pm_runtime_enable(&client->dev); in stmfts_probe()
728 device_enable_async_suspend(&client->dev); in stmfts_probe()
735 pm_runtime_disable(&client->dev); in stmfts_remove()
743 ret = i2c_smbus_write_byte(sdata->client, STMFTS_SLEEP_IN); in stmfts_runtime_suspend()
755 ret = i2c_smbus_write_byte(sdata->client, STMFTS_SLEEP_OUT); in stmfts_runtime_resume()
813 MODULE_DESCRIPTION("STMicroelectronics FTS Touch Screen");