Lines Matching +full:event +full:- +full:prox
1 // SPDX-License-Identifier: GPL-2.0-only
13 #include <linux/hid-sensor-hub.h>
17 #include "../common/hid-sensors/hid-sensor-trigger.h"
59 int report_id = -1; in prox_read_raw()
68 switch (chan->scan_index) { in prox_read_raw()
70 report_id = prox_state->prox_attr.report_id; in prox_read_raw()
71 min = prox_state->prox_attr.logical_minimum; in prox_read_raw()
75 report_id = -1; in prox_read_raw()
79 hid_sensor_power_state(&prox_state->common_attributes, in prox_read_raw()
82 prox_state->common_attributes.hsdev, in prox_read_raw()
87 hid_sensor_power_state(&prox_state->common_attributes, in prox_read_raw()
91 return -EINVAL; in prox_read_raw()
96 *val = prox_state->prox_attr.units; in prox_read_raw()
101 prox_state->prox_attr.unit_expo); in prox_read_raw()
106 &prox_state->common_attributes, val, val2); in prox_read_raw()
110 &prox_state->common_attributes, val, val2); in prox_read_raw()
113 ret_type = -EINVAL; in prox_read_raw()
133 &prox_state->common_attributes, val, val2); in prox_write_raw()
137 &prox_state->common_attributes, val, val2); in prox_write_raw()
140 ret = -EINVAL; in prox_write_raw()
155 dev_dbg(&indio_dev->dev, "hid_sensor_push_data\n"); in hid_sensor_push_data()
159 /* Callback handler to send event after all samples are received and captured */
167 dev_dbg(&indio_dev->dev, "prox_proc_event\n"); in prox_proc_event()
168 if (atomic_read(&prox_state->common_attributes.data_ready)) in prox_proc_event()
170 &prox_state->human_presence, in prox_proc_event()
171 sizeof(prox_state->human_presence)); in prox_proc_event()
184 int ret = -EINVAL; in prox_capture_sample()
188 prox_state->human_presence = *(u32 *)raw_data; in prox_capture_sample()
210 &st->prox_attr); in prox_parse_report()
214 st->prox_attr.size); in prox_parse_report()
216 dev_dbg(&pdev->dev, "prox %x:%x\n", st->prox_attr.index, in prox_parse_report()
217 st->prox_attr.report_id); in prox_parse_report()
220 if (st->common_attributes.sensitivity.index < 0) { in prox_parse_report()
225 &st->common_attributes.sensitivity); in prox_parse_report()
226 dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n", in prox_parse_report()
227 st->common_attributes.sensitivity.index, in prox_parse_report()
228 st->common_attributes.sensitivity.report_id); in prox_parse_report()
230 if (st->common_attributes.sensitivity.index < 0) in prox_parse_report()
235 &st->common_attributes.sensitivity); in prox_parse_report()
244 static const char *name = "prox"; in hid_prox_probe()
247 struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; in hid_prox_probe()
249 indio_dev = devm_iio_device_alloc(&pdev->dev, in hid_prox_probe()
252 return -ENOMEM; in hid_prox_probe()
256 prox_state->common_attributes.hsdev = hsdev; in hid_prox_probe()
257 prox_state->common_attributes.pdev = pdev; in hid_prox_probe()
260 &prox_state->common_attributes); in hid_prox_probe()
262 dev_err(&pdev->dev, "failed to setup common attributes\n"); in hid_prox_probe()
266 indio_dev->channels = kmemdup(prox_channels, sizeof(prox_channels), in hid_prox_probe()
268 if (!indio_dev->channels) { in hid_prox_probe()
269 dev_err(&pdev->dev, "failed to duplicate channels\n"); in hid_prox_probe()
270 return -ENOMEM; in hid_prox_probe()
274 (struct iio_chan_spec *)indio_dev->channels, in hid_prox_probe()
277 dev_err(&pdev->dev, "failed to setup attributes\n"); in hid_prox_probe()
281 indio_dev->num_channels = ARRAY_SIZE(prox_channels); in hid_prox_probe()
282 indio_dev->info = &prox_info; in hid_prox_probe()
283 indio_dev->name = name; in hid_prox_probe()
284 indio_dev->modes = INDIO_DIRECT_MODE; in hid_prox_probe()
286 atomic_set(&prox_state->common_attributes.data_ready, 0); in hid_prox_probe()
289 &prox_state->common_attributes); in hid_prox_probe()
291 dev_err(&pdev->dev, "trigger setup failed\n"); in hid_prox_probe()
297 dev_err(&pdev->dev, "device register failed\n"); in hid_prox_probe()
301 prox_state->callbacks.send_event = prox_proc_event; in hid_prox_probe()
302 prox_state->callbacks.capture_sample = prox_capture_sample; in hid_prox_probe()
303 prox_state->callbacks.pdev = pdev; in hid_prox_probe()
305 &prox_state->callbacks); in hid_prox_probe()
307 dev_err(&pdev->dev, "callback reg failed\n"); in hid_prox_probe()
316 hid_sensor_remove_trigger(indio_dev, &prox_state->common_attributes); in hid_prox_probe()
318 kfree(indio_dev->channels); in hid_prox_probe()
325 struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; in hid_prox_remove()
331 hid_sensor_remove_trigger(indio_dev, &prox_state->common_attributes); in hid_prox_remove()
332 kfree(indio_dev->channels); in hid_prox_remove()
339 /* Format: HID-SENSOR-usage_id_in_hex_lowercase */
340 .name = "HID-SENSOR-200011",