Lines Matching +full:pen +full:- +full:up
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* -------------------------------------------------------------------------
3 * Copyright (C) 2014-2015, Intel Corporation
7 * Copyright (C) 2010-2015, Shanghai Sileadinc Co.Ltd
9 * -------------------------------------------------------------------------
94 struct input_absinfo *absinfo_x = &data->input->absinfo[ABS_MT_POSITION_X]; in silead_apply_efi_fw_min_max()
95 struct input_absinfo *absinfo_y = &data->input->absinfo[ABS_MT_POSITION_Y]; in silead_apply_efi_fw_min_max()
97 if (!data->efi_fw_min_max_set) in silead_apply_efi_fw_min_max()
100 absinfo_x->minimum = data->efi_fw_min_max[0]; in silead_apply_efi_fw_min_max()
101 absinfo_x->maximum = data->efi_fw_min_max[1]; in silead_apply_efi_fw_min_max()
102 absinfo_y->minimum = data->efi_fw_min_max[2]; in silead_apply_efi_fw_min_max()
103 absinfo_y->maximum = data->efi_fw_min_max[3]; in silead_apply_efi_fw_min_max()
105 if (data->prop.invert_x) { in silead_apply_efi_fw_min_max()
106 absinfo_x->maximum -= absinfo_x->minimum; in silead_apply_efi_fw_min_max()
107 absinfo_x->minimum = 0; in silead_apply_efi_fw_min_max()
110 if (data->prop.invert_y) { in silead_apply_efi_fw_min_max()
111 absinfo_y->maximum -= absinfo_y->minimum; in silead_apply_efi_fw_min_max()
112 absinfo_y->minimum = 0; in silead_apply_efi_fw_min_max()
115 if (data->prop.swap_x_y) { in silead_apply_efi_fw_min_max()
116 swap(absinfo_x->minimum, absinfo_y->minimum); in silead_apply_efi_fw_min_max()
117 swap(absinfo_x->maximum, absinfo_y->maximum); in silead_apply_efi_fw_min_max()
123 struct device *dev = &data->client->dev; in silead_ts_request_input_dev()
126 data->input = devm_input_allocate_device(dev); in silead_ts_request_input_dev()
127 if (!data->input) { in silead_ts_request_input_dev()
130 return -ENOMEM; in silead_ts_request_input_dev()
133 input_set_abs_params(data->input, ABS_MT_POSITION_X, 0, 4095, 0, 0); in silead_ts_request_input_dev()
134 input_set_abs_params(data->input, ABS_MT_POSITION_Y, 0, 4095, 0, 0); in silead_ts_request_input_dev()
135 touchscreen_parse_properties(data->input, true, &data->prop); in silead_ts_request_input_dev()
138 input_mt_init_slots(data->input, SILEAD_MAX_FINGERS, in silead_ts_request_input_dev()
142 if (device_property_read_bool(dev, "silead,home-button")) in silead_ts_request_input_dev()
143 input_set_capability(data->input, EV_KEY, KEY_LEFTMETA); in silead_ts_request_input_dev()
145 data->input->name = SILEAD_TS_NAME; in silead_ts_request_input_dev()
146 data->input->phys = "input/ts"; in silead_ts_request_input_dev()
147 data->input->id.bustype = BUS_I2C; in silead_ts_request_input_dev()
149 error = input_register_device(data->input); in silead_ts_request_input_dev()
160 struct device *dev = &data->client->dev; in silead_ts_request_pen_input_dev()
163 if (!data->pen_supported) in silead_ts_request_pen_input_dev()
166 data->pen_input = devm_input_allocate_device(dev); in silead_ts_request_pen_input_dev()
167 if (!data->pen_input) in silead_ts_request_pen_input_dev()
168 return -ENOMEM; in silead_ts_request_pen_input_dev()
170 input_set_abs_params(data->pen_input, ABS_X, 0, 4095, 0, 0); in silead_ts_request_pen_input_dev()
171 input_set_abs_params(data->pen_input, ABS_Y, 0, 4095, 0, 0); in silead_ts_request_pen_input_dev()
172 input_set_capability(data->pen_input, EV_KEY, BTN_TOUCH); in silead_ts_request_pen_input_dev()
173 input_set_capability(data->pen_input, EV_KEY, BTN_TOOL_PEN); in silead_ts_request_pen_input_dev()
174 set_bit(INPUT_PROP_DIRECT, data->pen_input->propbit); in silead_ts_request_pen_input_dev()
175 touchscreen_parse_properties(data->pen_input, false, &data->prop); in silead_ts_request_pen_input_dev()
176 input_abs_set_res(data->pen_input, ABS_X, data->pen_x_res); in silead_ts_request_pen_input_dev()
177 input_abs_set_res(data->pen_input, ABS_Y, data->pen_y_res); in silead_ts_request_pen_input_dev()
179 data->pen_input->name = SILEAD_TS_NAME " pen"; in silead_ts_request_pen_input_dev()
180 data->pen_input->phys = "input/pen"; in silead_ts_request_pen_input_dev()
181 data->input->id.bustype = BUS_I2C; in silead_ts_request_pen_input_dev()
183 error = input_register_device(data->pen_input); in silead_ts_request_pen_input_dev()
185 dev_err(dev, "Failed to register pen input device: %d\n", error); in silead_ts_request_pen_input_dev()
197 if (data->gpio_power) { in silead_ts_set_power()
198 gpiod_set_value_cansleep(data->gpio_power, state); in silead_ts_set_power()
208 if (!data->pen_supported || buf[2] != 0x00 || buf[3] != 0x00) in silead_ts_handle_pen_data()
211 if (buf[0] == 0x00 && buf[1] == 0x00 && data->pen_down) { in silead_ts_handle_pen_data()
212 data->pen_up_count++; in silead_ts_handle_pen_data()
213 if (data->pen_up_count == 6) { in silead_ts_handle_pen_data()
214 data->pen_down = false; in silead_ts_handle_pen_data()
221 touchscreen_set_mt_pos(&pos, &data->prop, in silead_ts_handle_pen_data()
225 input_report_abs(data->pen_input, ABS_X, pos.x); in silead_ts_handle_pen_data()
226 input_report_abs(data->pen_input, ABS_Y, pos.y); in silead_ts_handle_pen_data()
228 data->pen_up_count = 0; in silead_ts_handle_pen_data()
229 data->pen_down = true; in silead_ts_handle_pen_data()
236 input_report_key(data->pen_input, BTN_TOOL_PEN, data->pen_down); in silead_ts_handle_pen_data()
237 input_report_key(data->pen_input, BTN_TOUCH, data->pen_down); in silead_ts_handle_pen_data()
238 input_sync(data->pen_input); in silead_ts_handle_pen_data()
245 struct input_dev *input = data->input; in silead_ts_read_data()
246 struct device *dev = &client->dev; in silead_ts_read_data()
265 goto sync; /* Pen is down, release all previous touches */ in silead_ts_read_data()
286 * Bits 4-7 are the touch id, note not all models have in silead_ts_read_data()
289 data->id[touch_nr] = (bufp[SILEAD_POINT_X_MSB_OFF] & in silead_ts_read_data()
291 touchscreen_set_mt_pos(&data->pos[touch_nr], &data->prop, in silead_ts_read_data()
297 input_mt_assign_slots(input, data->slots, data->pos, touch_nr, 0); in silead_ts_read_data()
300 input_mt_slot(input, data->slots[i]); in silead_ts_read_data()
302 input_report_abs(input, ABS_MT_POSITION_X, data->pos[i].x); in silead_ts_read_data()
303 input_report_abs(input, ABS_MT_POSITION_Y, data->pos[i].y); in silead_ts_read_data()
305 dev_dbg(dev, "x=%d y=%d hw_id=%d sw_id=%d\n", data->pos[i].x, in silead_ts_read_data()
306 data->pos[i].y, data->id[i], data->slots[i]); in silead_ts_read_data()
346 dev_err(&client->dev, "Registers clear error %d\n", error); in silead_ts_init()
375 dev_err(&client->dev, "Chip reset error %d\n", error); in silead_ts_reset()
385 dev_err(&client->dev, "Startup error %d\n", error); in silead_ts_startup()
396 struct device *dev = &client->dev; in silead_ts_load_fw()
403 dev_dbg(dev, "Firmware file name: %s", data->fw_name); in silead_ts_load_fw()
408 * Silead firmware files in linux-firmware. in silead_ts_load_fw()
411 * which contains an embedded copy of the firmware. The fw-loader code has a in silead_ts_load_fw()
425 * "silead,efi-fw-min-max" property. in silead_ts_load_fw()
427 error = firmware_request_nowarn(&fw, data->fw_name, dev); in silead_ts_load_fw()
429 error = firmware_request_platform(&fw, data->fw_name, dev); in silead_ts_load_fw()
435 error = device_property_read_u32_array(dev, "silead,efi-fw-min-max", in silead_ts_load_fw()
436 data->efi_fw_min_max, in silead_ts_load_fw()
437 ARRAY_SIZE(data->efi_fw_min_max)); in silead_ts_load_fw()
439 data->efi_fw_min_max_set = true; in silead_ts_load_fw()
441 /* The EFI (platform) embedded fw does not have pen support */ in silead_ts_load_fw()
442 if (data->pen_supported) { in silead_ts_load_fw()
444 data->fw_name); in silead_ts_load_fw()
445 dev_warn(dev, "Warning pen support is known to be broken in the EFI embedded fw version\n"); in silead_ts_load_fw()
446 data->pen_supported = false; in silead_ts_load_fw()
450 fw_size = fw->size / sizeof(*fw_data); in silead_ts_load_fw()
451 fw_data = (struct silead_fw_data *)fw->data; in silead_ts_load_fw()
476 dev_err(&client->dev, "Status read error %d\n", error); in silead_ts_get_status()
494 data->chip_id = le32_to_cpu(chip_id); in silead_ts_get_id()
495 dev_info(&client->dev, "Silead chip ID: 0x%8X", data->chip_id); in silead_ts_get_id()
506 * Some buggy BIOS-es bring up the chip in a stuck state where it in silead_ts_setup()
511 * response to which the I2C-bus-driver will call: in silead_ts_setup()
512 * i2c_recover_bus() which will unstuck the I2C-bus. Note the in silead_ts_setup()
513 * unstuck-ing of the I2C bus only works if we first drop the in silead_ts_setup()
519 * Resources. The workaround below runtime-suspends the chip to in silead_ts_setup()
520 * turn it off, leaving it up to the ACPI subsystem to deal with in silead_ts_setup()
524 if (device_property_read_bool(&client->dev, in silead_ts_setup()
525 "silead,stuck-controller-bug")) { in silead_ts_setup()
526 pm_runtime_set_active(&client->dev); in silead_ts_setup()
527 pm_runtime_enable(&client->dev); in silead_ts_setup()
528 pm_runtime_allow(&client->dev); in silead_ts_setup()
530 pm_runtime_suspend(&client->dev); in silead_ts_setup()
532 …dev_warn(&client->dev, FW_BUG "Stuck I2C bus: please ignore the next 'controller timed out' error\… in silead_ts_setup()
536 pm_runtime_forbid(&client->dev); in silead_ts_setup()
537 pm_runtime_disable(&client->dev); in silead_ts_setup()
545 dev_err(&client->dev, "Chip ID read error %d\n", error); in silead_ts_setup()
567 dev_err(&client->dev, in silead_ts_setup()
569 return -ENODEV; in silead_ts_setup()
578 struct i2c_client *client = data->client; in silead_ts_threaded_irq_handler()
588 struct device *dev = &client->dev; in silead_ts_read_props()
592 error = device_property_read_string(dev, "firmware-name", &str); in silead_ts_read_props()
594 snprintf(data->fw_name, sizeof(data->fw_name), in silead_ts_read_props()
599 data->pen_supported = device_property_read_bool(dev, "silead,pen-supported"); in silead_ts_read_props()
600 device_property_read_u32(dev, "silead,pen-resolution-x", &data->pen_x_res); in silead_ts_read_props()
601 device_property_read_u32(dev, "silead,pen-resolution-y", &data->pen_y_res); in silead_ts_read_props()
609 struct device *dev = &data->client->dev; in silead_ts_set_default_fw_name()
613 acpi_id = acpi_match_device(dev->driver->acpi_match_table, dev); in silead_ts_set_default_fw_name()
615 return -ENODEV; in silead_ts_set_default_fw_name()
617 snprintf(data->fw_name, sizeof(data->fw_name), in silead_ts_set_default_fw_name()
618 "silead/%s.fw", acpi_id->id); in silead_ts_set_default_fw_name()
620 for (i = 0; i < strlen(data->fw_name); i++) in silead_ts_set_default_fw_name()
621 data->fw_name[i] = tolower(data->fw_name[i]); in silead_ts_set_default_fw_name()
623 snprintf(data->fw_name, sizeof(data->fw_name), in silead_ts_set_default_fw_name()
624 "silead/%s.fw", id->name); in silead_ts_set_default_fw_name()
633 snprintf(data->fw_name, sizeof(data->fw_name), in silead_ts_set_default_fw_name()
634 "silead/%s.fw", id->name); in silead_ts_set_default_fw_name()
643 regulator_bulk_disable(ARRAY_SIZE(data->regulators), data->regulators); in silead_disable_regulator()
650 struct device *dev = &client->dev; in silead_ts_probe()
653 if (!i2c_check_functionality(client->adapter, in silead_ts_probe()
658 return -ENXIO; in silead_ts_probe()
663 return -ENOMEM; in silead_ts_probe()
666 data->client = client; in silead_ts_probe()
675 if (client->irq <= 0) in silead_ts_probe()
676 return -ENODEV; in silead_ts_probe()
678 data->regulators[0].supply = "vddio"; in silead_ts_probe()
679 data->regulators[1].supply = "avdd"; in silead_ts_probe()
680 error = devm_regulator_bulk_get(dev, ARRAY_SIZE(data->regulators), in silead_ts_probe()
681 data->regulators); in silead_ts_probe()
689 error = regulator_bulk_enable(ARRAY_SIZE(data->regulators), in silead_ts_probe()
690 data->regulators); in silead_ts_probe()
699 data->gpio_power = devm_gpiod_get_optional(dev, "power", GPIOD_OUT_LOW); in silead_ts_probe()
700 if (IS_ERR(data->gpio_power)) in silead_ts_probe()
701 return dev_err_probe(dev, PTR_ERR(data->gpio_power), in silead_ts_probe()
716 error = devm_request_threaded_irq(dev, client->irq, in silead_ts_probe()
718 IRQF_ONESHOT, client->name, data); in silead_ts_probe()
720 if (error != -EPROBE_DEFER) in silead_ts_probe()
732 disable_irq(client->irq); in silead_ts_suspend()
768 return -ENODEV; in silead_ts_resume()
771 enable_irq(client->irq); in silead_ts_resume()