Lines Matching +full:abs +full:- +full:flat

1 // SPDX-License-Identifier: GPL-2.0
4 * Copyright (c) 2019-2020 Artur Rojek <contact@artur-rojek.eu>
35 return (max + min) - val; in adc_joystick_invert()
43 for (i = 0; i < joy->num_chans; i++) { in adc_joystick_poll()
44 ret = iio_read_channel_raw(&joy->chans[i], &val); in adc_joystick_poll()
47 if (joy->axes[i].inverted) in adc_joystick_poll()
49 input_report_abs(input, joy->axes[i].code, val); in adc_joystick_poll()
62 bytes = joy->chans[0].channel->scan_type.storagebits >> 3; in adc_joystick_handle()
64 for (i = 0; i < joy->num_chans; ++i) { in adc_joystick_handle()
65 idx = joy->chans[i].channel->scan_index; in adc_joystick_handle()
66 endianness = joy->chans[i].channel->scan_type.endianness; in adc_joystick_handle()
67 msb = joy->chans[i].channel->scan_type.realbits - 1; in adc_joystick_handle()
68 sign = tolower(joy->chans[i].channel->scan_type.sign) == 's'; in adc_joystick_handle()
89 return -EINVAL; in adc_joystick_handle()
92 val >>= joy->chans[i].channel->scan_type.shift; in adc_joystick_handle()
97 if (joy->axes[i].inverted) in adc_joystick_handle()
98 val = adc_joystick_invert(joy->input, i, val); in adc_joystick_handle()
99 input_report_abs(joy->input, joy->axes[i].code, val); in adc_joystick_handle()
102 input_sync(joy->input); in adc_joystick_handle()
110 struct device *devp = &dev->dev; in adc_joystick_open()
113 ret = iio_channel_start_all_cb(joy->buffer); in adc_joystick_open()
124 iio_channel_stop_all_cb(joy->buffer); in adc_joystick_close()
134 struct adc_joystick_axis *axes = joy->axes; in adc_joystick_set_axes()
135 s32 range[2], fuzz, flat; in adc_joystick_set_axes() local
142 return -EINVAL; in adc_joystick_set_axes()
145 if (num_axes != joy->num_chans) { in adc_joystick_set_axes()
147 num_axes, joy->num_chans); in adc_joystick_set_axes()
148 return -EINVAL; in adc_joystick_set_axes()
160 return -EINVAL; in adc_joystick_set_axes()
170 error = fwnode_property_read_u32_array(child, "abs-range", in adc_joystick_set_axes()
173 dev_err(dev, "abs-range invalid or missing\n"); in adc_joystick_set_axes()
178 dev_dbg(dev, "abs-axis %d inverted\n", i); in adc_joystick_set_axes()
183 if (fwnode_property_read_u32(child, "abs-fuzz", &fuzz)) in adc_joystick_set_axes()
186 if (fwnode_property_read_u32(child, "abs-flat", &flat)) in adc_joystick_set_axes()
187 flat = 0; in adc_joystick_set_axes()
189 input_set_abs_params(joy->input, axes[i].code, in adc_joystick_set_axes()
190 range[0], range[1], fuzz, flat); in adc_joystick_set_axes()
212 bits = chans[i].channel->scan_type.storagebits; in adc_joystick_count_channels()
215 return -EINVAL; in adc_joystick_count_channels()
217 if (bits != chans[0].channel->scan_type.storagebits) { in adc_joystick_count_channels()
219 return -EINVAL; in adc_joystick_count_channels()
229 struct device *dev = &pdev->dev; in adc_joystick_probe()
240 if (error != -EPROBE_DEFER) in adc_joystick_probe()
245 error = device_property_read_u32(dev, "poll-interval", &poll_interval); in adc_joystick_probe()
247 /* -EINVAL means the property is absent. */ in adc_joystick_probe()
248 if (error != -EINVAL) in adc_joystick_probe()
251 dev_err(dev, "Unable to get poll-interval\n"); in adc_joystick_probe()
252 return -EINVAL; in adc_joystick_probe()
262 return -ENOMEM; in adc_joystick_probe()
264 joy->chans = chans; in adc_joystick_probe()
265 joy->num_chans = num_chans; in adc_joystick_probe()
270 return -ENOMEM; in adc_joystick_probe()
273 joy->input = input; in adc_joystick_probe()
274 input->name = pdev->name; in adc_joystick_probe()
275 input->id.bustype = BUS_HOST; in adc_joystick_probe()
285 input->open = adc_joystick_open; in adc_joystick_probe()
286 input->close = adc_joystick_close; in adc_joystick_probe()
288 joy->buffer = iio_channel_get_all_cb(dev, adc_joystick_handle, in adc_joystick_probe()
290 if (IS_ERR(joy->buffer)) { in adc_joystick_probe()
292 return PTR_ERR(joy->buffer); in adc_joystick_probe()
296 joy->buffer); in adc_joystick_probe()
315 { .compatible = "adc-joystick", },
322 .name = "adc-joystick",
330 MODULE_AUTHOR("Artur Rojek <contact@artur-rojek.eu>");