Lines Matching +full:keyup +full:- +full:threshold +full:- +full:microvolt
1 // SPDX-License-Identifier: GPL-2.0-only
39 ret = iio_read_channel_processed(st->channel, &value); in adc_keys_poll()
42 value = st->keyup_voltage; in adc_keys_poll()
44 for (i = 0; i < st->num_keys; i++) { in adc_keys_poll()
45 diff = abs(st->map[i].voltage - value); in adc_keys_poll()
48 keycode = st->map[i].keycode; in adc_keys_poll()
53 if (abs(st->keyup_voltage - value) < closest) in adc_keys_poll()
56 if (st->last_key && st->last_key != keycode) in adc_keys_poll()
57 input_report_key(input, st->last_key, 0); in adc_keys_poll()
63 st->last_key = keycode; in adc_keys_poll()
72 st->num_keys = device_get_child_node_count(dev); in adc_keys_load_keymap()
73 if (st->num_keys == 0) { in adc_keys_load_keymap()
75 return -EINVAL; in adc_keys_load_keymap()
78 map = devm_kmalloc_array(dev, st->num_keys, sizeof(*map), GFP_KERNEL); in adc_keys_load_keymap()
80 return -ENOMEM; in adc_keys_load_keymap()
84 if (fwnode_property_read_u32(child, "press-threshold-microvolt", in adc_keys_load_keymap()
88 return -EINVAL; in adc_keys_load_keymap()
96 return -EINVAL; in adc_keys_load_keymap()
102 st->map = map; in adc_keys_load_keymap()
108 struct device *dev = &pdev->dev; in adc_keys_probe()
117 return -ENOMEM; in adc_keys_probe()
119 st->channel = devm_iio_channel_get(dev, "buttons"); in adc_keys_probe()
120 if (IS_ERR(st->channel)) in adc_keys_probe()
121 return PTR_ERR(st->channel); in adc_keys_probe()
123 if (!st->channel->indio_dev) in adc_keys_probe()
124 return -ENXIO; in adc_keys_probe()
126 error = iio_get_channel_type(st->channel, &type); in adc_keys_probe()
132 return -EINVAL; in adc_keys_probe()
135 if (device_property_read_u32(dev, "keyup-threshold-microvolt", in adc_keys_probe()
136 &st->keyup_voltage)) { in adc_keys_probe()
137 dev_err(dev, "Invalid or missing keyup voltage\n"); in adc_keys_probe()
138 return -EINVAL; in adc_keys_probe()
140 st->keyup_voltage /= 1000; in adc_keys_probe()
149 return -ENOMEM; in adc_keys_probe()
154 input->name = pdev->name; in adc_keys_probe()
155 input->phys = "adc-keys/input0"; in adc_keys_probe()
157 input->id.bustype = BUS_HOST; in adc_keys_probe()
158 input->id.vendor = 0x0001; in adc_keys_probe()
159 input->id.product = 0x0001; in adc_keys_probe()
160 input->id.version = 0x0100; in adc_keys_probe()
162 __set_bit(EV_KEY, input->evbit); in adc_keys_probe()
163 for (i = 0; i < st->num_keys; i++) in adc_keys_probe()
164 __set_bit(st->map[i].keycode, input->keybit); in adc_keys_probe()
167 __set_bit(EV_REP, input->evbit); in adc_keys_probe()
176 if (!device_property_read_u32(dev, "poll-interval", &value)) in adc_keys_probe()
190 { .compatible = "adc-keys", },
205 MODULE_AUTHOR("Alexandre Belloni <alexandre.belloni@free-electrons.com>");