Lines Matching +full:abs +full:- +full:range
1 // SPDX-License-Identifier: GPL-2.0
4 * Copyright (c) 2019-2020 Artur Rojek <contact@artur-rojek.eu>
18 s32 range[2]; member
37 for (i = 0; i < joy->num_chans; i++) { in adc_joystick_poll()
38 ret = iio_read_channel_raw(&joy->chans[i], &val); in adc_joystick_poll()
41 input_report_abs(input, joy->axes[i].code, val); in adc_joystick_poll()
54 bytes = joy->chans[0].channel->scan_type.storagebits >> 3; in adc_joystick_handle()
56 for (i = 0; i < joy->num_chans; ++i) { in adc_joystick_handle()
57 idx = joy->chans[i].channel->scan_index; in adc_joystick_handle()
58 endianness = joy->chans[i].channel->scan_type.endianness; in adc_joystick_handle()
59 msb = joy->chans[i].channel->scan_type.realbits - 1; in adc_joystick_handle()
60 sign = tolower(joy->chans[i].channel->scan_type.sign) == 's'; in adc_joystick_handle()
81 return -EINVAL; in adc_joystick_handle()
84 val >>= joy->chans[i].channel->scan_type.shift; in adc_joystick_handle()
89 input_report_abs(joy->input, joy->axes[i].code, val); in adc_joystick_handle()
92 input_sync(joy->input); in adc_joystick_handle()
100 struct device *devp = &dev->dev; in adc_joystick_open()
103 ret = iio_channel_start_all_cb(joy->buffer); in adc_joystick_open()
114 iio_channel_stop_all_cb(joy->buffer); in adc_joystick_close()
131 return -EINVAL; in adc_joystick_set_axes()
134 if (num_axes != joy->num_chans) { in adc_joystick_set_axes()
136 num_axes, joy->num_chans); in adc_joystick_set_axes()
137 return -EINVAL; in adc_joystick_set_axes()
142 return -ENOMEM; in adc_joystick_set_axes()
152 error = -EINVAL; in adc_joystick_set_axes()
164 error = fwnode_property_read_u32_array(child, "abs-range", in adc_joystick_set_axes()
165 axes[i].range, 2); in adc_joystick_set_axes()
167 dev_err(dev, "abs-range invalid or missing\n"); in adc_joystick_set_axes()
171 fwnode_property_read_u32(child, "abs-fuzz", &axes[i].fuzz); in adc_joystick_set_axes()
172 fwnode_property_read_u32(child, "abs-flat", &axes[i].flat); in adc_joystick_set_axes()
174 input_set_abs_params(joy->input, axes[i].code, in adc_joystick_set_axes()
175 axes[i].range[0], axes[i].range[1], in adc_joystick_set_axes()
177 input_set_capability(joy->input, EV_ABS, axes[i].code); in adc_joystick_set_axes()
180 joy->axes = axes; in adc_joystick_set_axes()
191 struct device *dev = &pdev->dev; in adc_joystick_probe()
201 return -ENOMEM; in adc_joystick_probe()
203 joy->chans = devm_iio_channel_get_all(dev); in adc_joystick_probe()
204 if (IS_ERR(joy->chans)) { in adc_joystick_probe()
205 error = PTR_ERR(joy->chans); in adc_joystick_probe()
206 if (error != -EPROBE_DEFER) in adc_joystick_probe()
211 error = device_property_read_u32(dev, "poll-interval", &poll_interval); in adc_joystick_probe()
213 /* -EINVAL means the property is absent. */ in adc_joystick_probe()
214 if (error != -EINVAL) in adc_joystick_probe()
217 dev_err(dev, "Unable to get poll-interval\n"); in adc_joystick_probe()
218 return -EINVAL; in adc_joystick_probe()
220 joy->polled = true; in adc_joystick_probe()
227 for (i = 0; joy->chans[i].indio_dev; i++) { in adc_joystick_probe()
228 if (joy->polled) in adc_joystick_probe()
230 bits = joy->chans[i].channel->scan_type.storagebits; in adc_joystick_probe()
233 return -EINVAL; in adc_joystick_probe()
235 if (bits != joy->chans[0].channel->scan_type.storagebits) { in adc_joystick_probe()
237 return -EINVAL; in adc_joystick_probe()
240 joy->num_chans = i; in adc_joystick_probe()
245 return -ENOMEM; in adc_joystick_probe()
248 joy->input = input; in adc_joystick_probe()
249 input->name = pdev->name; in adc_joystick_probe()
250 input->id.bustype = BUS_HOST; in adc_joystick_probe()
256 if (joy->polled) { in adc_joystick_probe()
260 input->open = adc_joystick_open; in adc_joystick_probe()
261 input->close = adc_joystick_close; in adc_joystick_probe()
263 joy->buffer = iio_channel_get_all_cb(dev, adc_joystick_handle, in adc_joystick_probe()
265 if (IS_ERR(joy->buffer)) { in adc_joystick_probe()
267 return PTR_ERR(joy->buffer); in adc_joystick_probe()
271 joy->buffer); in adc_joystick_probe()
290 { .compatible = "adc-joystick", },
297 .name = "adc-joystick",
305 MODULE_AUTHOR("Artur Rojek <contact@artur-rojek.eu>");