Lines Matching +full:pressure +full:- +full:min

1 // SPDX-License-Identifier: GPL-2.0
21 #define DRIVER_NAME "resistive-adc-touch"
37 * struct grts_state - generic resistive touch screen information struct
39 * @pressure_min: number representing the minimum for the pressure
40 * @pressure: are we getting pressure info or not
50 bool pressure; member
64 x = touch_info[st->ch_map[GRTS_CH_X]]; in grts_cb()
65 y = touch_info[st->ch_map[GRTS_CH_Y]]; in grts_cb()
67 if (st->ch_map[GRTS_CH_PRESSURE] < GRTS_MAX_CHANNELS) { in grts_cb()
68 press = touch_info[st->ch_map[GRTS_CH_PRESSURE]]; in grts_cb()
69 } else if (st->ch_map[GRTS_CH_Z1] < GRTS_MAX_CHANNELS) { in grts_cb()
70 unsigned int z1 = touch_info[st->ch_map[GRTS_CH_Z1]]; in grts_cb()
71 unsigned int z2 = touch_info[st->ch_map[GRTS_CH_Z2]]; in grts_cb()
76 Rt -= z1; in grts_cb()
77 Rt *= st->x_plate_ohms; in grts_cb()
83 * On increased pressure the resistance (Rt) is in grts_cb()
85 * real pressure. in grts_cb()
88 press = GRTS_DEFAULT_PRESSURE_MAX - Rt; in grts_cb()
92 if ((!x && !y) || (st->pressure && (press < st->pressure_min))) { in grts_cb()
94 input_report_key(st->input, BTN_TOUCH, 0); in grts_cb()
95 input_sync(st->input); in grts_cb()
100 touchscreen_report_pos(st->input, &st->prop, x, y, false); in grts_cb()
101 if (st->pressure) in grts_cb()
102 input_report_abs(st->input, ABS_PRESSURE, press); in grts_cb()
103 input_report_key(st->input, BTN_TOUCH, 1); in grts_cb()
104 input_sync(st->input); in grts_cb()
114 error = iio_channel_start_all_cb(st->iio_cb); in grts_open()
116 dev_err(dev->dev.parent, "failed to start callback buffer.\n"); in grts_open()
126 iio_channel_stop_all_cb(st->iio_cb); in grts_close()
140 idx = device_property_match_string(dev, "io-channel-names", name); in grts_map_channel()
146 return -EOVERFLOW; in grts_map_channel()
149 st->ch_map[type] = idx; in grts_map_channel()
165 /* pressure is optional */ in grts_get_properties()
166 error = grts_map_channel(st, dev, GRTS_CH_PRESSURE, "pressure", true); in grts_get_properties()
170 if (st->ch_map[GRTS_CH_PRESSURE] < GRTS_MAX_CHANNELS) { in grts_get_properties()
171 st->pressure = true; in grts_get_properties()
175 /* if no pressure is defined, try optional z1 + z2 */ in grts_get_properties()
180 if (st->ch_map[GRTS_CH_Z1] >= GRTS_MAX_CHANNELS) in grts_get_properties()
189 "touchscreen-x-plate-ohms", in grts_get_properties()
190 &st->x_plate_ohms); in grts_get_properties()
192 dev_err(dev, "can't get touchscreen-x-plate-ohms property\n"); in grts_get_properties()
196 st->pressure = true; in grts_get_properties()
204 struct device *dev = &pdev->dev; in grts_probe()
209 return -ENOMEM; in grts_probe()
212 st->iio_chans = devm_iio_channel_get_all(dev); in grts_probe()
213 if (IS_ERR(st->iio_chans)) in grts_probe()
214 return dev_err_probe(dev, PTR_ERR(st->iio_chans), "can't get iio channels\n"); in grts_probe()
216 if (!device_property_present(dev, "io-channel-names")) in grts_probe()
217 return -ENODEV; in grts_probe()
225 if (st->pressure) { in grts_probe()
227 "touchscreen-min-pressure", in grts_probe()
228 &st->pressure_min); in grts_probe()
230 dev_dbg(dev, "can't get touchscreen-min-pressure property.\n"); in grts_probe()
231 st->pressure_min = GRTS_DEFAULT_PRESSURE_MIN; in grts_probe()
238 return -ENOMEM; in grts_probe()
241 input->name = DRIVER_NAME; in grts_probe()
242 input->id.bustype = BUS_HOST; in grts_probe()
243 input->open = grts_open; in grts_probe()
244 input->close = grts_close; in grts_probe()
246 input_set_abs_params(input, ABS_X, 0, GRTS_MAX_POS_MASK - 1, 0, 0); in grts_probe()
247 input_set_abs_params(input, ABS_Y, 0, GRTS_MAX_POS_MASK - 1, 0, 0); in grts_probe()
248 if (st->pressure) in grts_probe()
249 input_set_abs_params(input, ABS_PRESSURE, st->pressure_min, in grts_probe()
255 touchscreen_parse_properties(input, false, &st->prop); in grts_probe()
257 st->input = input; in grts_probe()
266 st->iio_cb = iio_channel_get_all_cb(dev, grts_cb, st); in grts_probe()
267 if (IS_ERR(st->iio_cb)) { in grts_probe()
269 return PTR_ERR(st->iio_cb); in grts_probe()
272 error = devm_add_action_or_reset(dev, grts_disable, st->iio_cb); in grts_probe()
283 .compatible = "resistive-adc-touch",