Lines Matching +full:input +full:- +full:threshold
1 // SPDX-License-Identifier: GPL-2.0
11 #include <linux/input.h>
12 #include <linux/input/mt.h>
13 #include <linux/input/touchscreen.h>
51 struct input_dev *input; member
60 int threshold; member
93 dev_err_ratelimited(&tsdata->client->dev, in hycon_hy46xx_check_checksum()
103 struct device *dev = &tsdata->client->dev; in hycon_hy46xx_isr()
110 error = regmap_bulk_read(tsdata->regmap, 0, rdbuf, sizeof(rdbuf)); in hycon_hy46xx_isr()
132 input_mt_slot(tsdata->input, id); in hycon_hy46xx_isr()
133 if (input_mt_report_slot_state(tsdata->input, MT_TOOL_FINGER, in hycon_hy46xx_isr()
135 touchscreen_report_pos(tsdata->input, &tsdata->prop, in hycon_hy46xx_isr()
139 input_mt_report_pointer_emulation(tsdata->input, false); in hycon_hy46xx_isr()
140 input_sync(tsdata->input); in hycon_hy46xx_isr()
183 u8 *field = (u8 *)tsdata + attr->field_offset; in hycon_hy46xx_setting_show()
188 mutex_lock(&tsdata->mutex); in hycon_hy46xx_setting_show()
190 error = regmap_read(tsdata->regmap, attr->address, &val); in hycon_hy46xx_setting_show()
192 dev_err(&tsdata->client->dev, in hycon_hy46xx_setting_show()
194 dattr->attr.name, error); in hycon_hy46xx_setting_show()
199 dev_warn(&tsdata->client->dev, in hycon_hy46xx_setting_show()
201 dattr->attr.name, val, *field); in hycon_hy46xx_setting_show()
208 mutex_unlock(&tsdata->mutex); in hycon_hy46xx_setting_show()
220 u8 *field = (u8 *)tsdata + attr->field_offset; in hycon_hy46xx_setting_store()
224 mutex_lock(&tsdata->mutex); in hycon_hy46xx_setting_store()
230 if (val < attr->limit_low || val > attr->limit_high) { in hycon_hy46xx_setting_store()
231 error = -ERANGE; in hycon_hy46xx_setting_store()
235 error = regmap_write(tsdata->regmap, attr->address, val); in hycon_hy46xx_setting_store()
237 dev_err(&tsdata->client->dev, in hycon_hy46xx_setting_store()
239 dattr->attr.name, error); in hycon_hy46xx_setting_store()
245 mutex_unlock(&tsdata->mutex); in hycon_hy46xx_setting_store()
249 static HYCON_ATTR_U8(threshold, 0644, HY46XX_THRESHOLD, 0, 255);
285 error = device_property_read_u32(dev, "hycon,threshold", &val); in hycon_hy46xx_get_defaults()
287 error = regmap_write(tsdata->regmap, HY46XX_THRESHOLD, val); in hycon_hy46xx_get_defaults()
291 tsdata->threshold = val; in hycon_hy46xx_get_defaults()
294 val_bool = device_property_read_bool(dev, "hycon,glove-enable"); in hycon_hy46xx_get_defaults()
295 error = regmap_write(tsdata->regmap, HY46XX_GLOVE_EN, val_bool); in hycon_hy46xx_get_defaults()
298 tsdata->glove_enable = val_bool; in hycon_hy46xx_get_defaults()
300 error = device_property_read_u32(dev, "hycon,report-speed-hz", &val); in hycon_hy46xx_get_defaults()
302 error = regmap_write(tsdata->regmap, HY46XX_REPORT_SPEED, val); in hycon_hy46xx_get_defaults()
306 tsdata->report_speed = val; in hycon_hy46xx_get_defaults()
309 val_bool = device_property_read_bool(dev, "hycon,noise-filter-enable"); in hycon_hy46xx_get_defaults()
310 error = regmap_write(tsdata->regmap, HY46XX_PWR_NOISE_EN, val_bool); in hycon_hy46xx_get_defaults()
313 tsdata->noise_filter_enable = val_bool; in hycon_hy46xx_get_defaults()
315 error = device_property_read_u32(dev, "hycon,filter-data", &val); in hycon_hy46xx_get_defaults()
317 error = regmap_write(tsdata->regmap, HY46XX_FILTER_DATA, val); in hycon_hy46xx_get_defaults()
321 tsdata->filter_data = val; in hycon_hy46xx_get_defaults()
326 error = regmap_write(tsdata->regmap, HY46XX_GAIN, val); in hycon_hy46xx_get_defaults()
330 tsdata->gain = val; in hycon_hy46xx_get_defaults()
333 error = device_property_read_u32(dev, "hycon,edge-offset", &val); in hycon_hy46xx_get_defaults()
335 error = regmap_write(tsdata->regmap, HY46XX_EDGE_OFFSET, val); in hycon_hy46xx_get_defaults()
339 tsdata->edge_offset = val; in hycon_hy46xx_get_defaults()
344 dev_err(&tsdata->client->dev, "Failed to set default settings"); in hycon_hy46xx_get_defaults()
352 error = regmap_read(tsdata->regmap, HY46XX_THRESHOLD, &val); in hycon_hy46xx_get_parameters()
355 tsdata->threshold = val; in hycon_hy46xx_get_parameters()
357 error = regmap_read(tsdata->regmap, HY46XX_GLOVE_EN, &val); in hycon_hy46xx_get_parameters()
360 tsdata->glove_enable = val; in hycon_hy46xx_get_parameters()
362 error = regmap_read(tsdata->regmap, HY46XX_REPORT_SPEED, &val); in hycon_hy46xx_get_parameters()
365 tsdata->report_speed = val; in hycon_hy46xx_get_parameters()
367 error = regmap_read(tsdata->regmap, HY46XX_PWR_NOISE_EN, &val); in hycon_hy46xx_get_parameters()
370 tsdata->noise_filter_enable = val; in hycon_hy46xx_get_parameters()
372 error = regmap_read(tsdata->regmap, HY46XX_FILTER_DATA, &val); in hycon_hy46xx_get_parameters()
375 tsdata->filter_data = val; in hycon_hy46xx_get_parameters()
377 error = regmap_read(tsdata->regmap, HY46XX_GAIN, &val); in hycon_hy46xx_get_parameters()
380 tsdata->gain = val; in hycon_hy46xx_get_parameters()
382 error = regmap_read(tsdata->regmap, HY46XX_EDGE_OFFSET, &val); in hycon_hy46xx_get_parameters()
385 tsdata->edge_offset = val; in hycon_hy46xx_get_parameters()
387 error = regmap_read(tsdata->regmap, HY46XX_RX_NR_USED, &val); in hycon_hy46xx_get_parameters()
390 tsdata->rx_number_used = val; in hycon_hy46xx_get_parameters()
392 error = regmap_read(tsdata->regmap, HY46XX_TX_NR_USED, &val); in hycon_hy46xx_get_parameters()
395 tsdata->tx_number_used = val; in hycon_hy46xx_get_parameters()
397 error = regmap_read(tsdata->regmap, HY46XX_PWR_MODE, &val); in hycon_hy46xx_get_parameters()
400 tsdata->power_mode = val; in hycon_hy46xx_get_parameters()
402 error = regmap_read(tsdata->regmap, HY46XX_FW_VERSION, &val); in hycon_hy46xx_get_parameters()
405 tsdata->fw_version = val; in hycon_hy46xx_get_parameters()
407 error = regmap_read(tsdata->regmap, HY46XX_LIB_VERSION, &val); in hycon_hy46xx_get_parameters()
410 tsdata->lib_version = val; in hycon_hy46xx_get_parameters()
412 error = regmap_read(tsdata->regmap, HY46XX_TP_INFO, &val); in hycon_hy46xx_get_parameters()
415 tsdata->tp_information = val; in hycon_hy46xx_get_parameters()
417 error = regmap_read(tsdata->regmap, HY46XX_TP_CHIP_ID, &val); in hycon_hy46xx_get_parameters()
420 tsdata->tp_chip_id = val; in hycon_hy46xx_get_parameters()
422 error = regmap_read(tsdata->regmap, HY46XX_BOOT_VER, &val); in hycon_hy46xx_get_parameters()
425 tsdata->bootloader_version = val; in hycon_hy46xx_get_parameters()
429 dev_err(&tsdata->client->dev, "Failed to read default settings"); in hycon_hy46xx_get_parameters()
436 regulator_disable(data->vcc); in hycon_hy46xx_disable_regulator()
442 struct input_dev *input; in hycon_hy46xx_probe() local
445 dev_dbg(&client->dev, "probing for HYCON HY46XX I2C\n"); in hycon_hy46xx_probe()
447 tsdata = devm_kzalloc(&client->dev, sizeof(*tsdata), GFP_KERNEL); in hycon_hy46xx_probe()
449 return -ENOMEM; in hycon_hy46xx_probe()
451 tsdata->vcc = devm_regulator_get(&client->dev, "vcc"); in hycon_hy46xx_probe()
452 if (IS_ERR(tsdata->vcc)) { in hycon_hy46xx_probe()
453 error = PTR_ERR(tsdata->vcc); in hycon_hy46xx_probe()
454 if (error != -EPROBE_DEFER) in hycon_hy46xx_probe()
455 dev_err(&client->dev, in hycon_hy46xx_probe()
460 error = regulator_enable(tsdata->vcc); in hycon_hy46xx_probe()
462 dev_err(&client->dev, "failed to enable vcc: %d\n", error); in hycon_hy46xx_probe()
466 error = devm_add_action_or_reset(&client->dev, in hycon_hy46xx_probe()
472 tsdata->reset_gpio = devm_gpiod_get_optional(&client->dev, in hycon_hy46xx_probe()
474 if (IS_ERR(tsdata->reset_gpio)) { in hycon_hy46xx_probe()
475 error = PTR_ERR(tsdata->reset_gpio); in hycon_hy46xx_probe()
476 dev_err(&client->dev, in hycon_hy46xx_probe()
481 if (tsdata->reset_gpio) { in hycon_hy46xx_probe()
483 gpiod_set_value_cansleep(tsdata->reset_gpio, 1); in hycon_hy46xx_probe()
485 gpiod_set_value_cansleep(tsdata->reset_gpio, 0); in hycon_hy46xx_probe()
489 input = devm_input_allocate_device(&client->dev); in hycon_hy46xx_probe()
490 if (!input) { in hycon_hy46xx_probe()
491 dev_err(&client->dev, "failed to allocate input device.\n"); in hycon_hy46xx_probe()
492 return -ENOMEM; in hycon_hy46xx_probe()
495 mutex_init(&tsdata->mutex); in hycon_hy46xx_probe()
496 tsdata->client = client; in hycon_hy46xx_probe()
497 tsdata->input = input; in hycon_hy46xx_probe()
499 tsdata->regmap = devm_regmap_init_i2c(client, in hycon_hy46xx_probe()
501 if (IS_ERR(tsdata->regmap)) { in hycon_hy46xx_probe()
502 dev_err(&client->dev, "regmap allocation failed\n"); in hycon_hy46xx_probe()
503 return PTR_ERR(tsdata->regmap); in hycon_hy46xx_probe()
506 hycon_hy46xx_get_defaults(&client->dev, tsdata); in hycon_hy46xx_probe()
509 input->name = "Hycon Capacitive Touch"; in hycon_hy46xx_probe()
510 input->id.bustype = BUS_I2C; in hycon_hy46xx_probe()
511 input->dev.parent = &client->dev; in hycon_hy46xx_probe()
513 input_set_abs_params(input, ABS_MT_POSITION_X, 0, -1, 0, 0); in hycon_hy46xx_probe()
514 input_set_abs_params(input, ABS_MT_POSITION_Y, 0, -1, 0, 0); in hycon_hy46xx_probe()
516 touchscreen_parse_properties(input, true, &tsdata->prop); in hycon_hy46xx_probe()
518 error = input_mt_init_slots(input, HY46XX_MAX_SUPPORTED_POINTS, in hycon_hy46xx_probe()
521 dev_err(&client->dev, "Unable to init MT slots.\n"); in hycon_hy46xx_probe()
527 error = devm_request_threaded_irq(&client->dev, client->irq, in hycon_hy46xx_probe()
529 client->name, tsdata); in hycon_hy46xx_probe()
531 dev_err(&client->dev, "Unable to request touchscreen IRQ.\n"); in hycon_hy46xx_probe()
535 error = input_register_device(input); in hycon_hy46xx_probe()
539 dev_dbg(&client->dev, in hycon_hy46xx_probe()
541 client->irq, in hycon_hy46xx_probe()
542 tsdata->reset_gpio ? desc_to_gpio(tsdata->reset_gpio) : -1); in hycon_hy46xx_probe()