Lines Matching +full:event +full:- +full:prox
1 // SPDX-License-Identifier: GPL-2.0-only
11 #include <linux/hid-sensor-hub.h>
14 #include "../common/hid-sensors/hid-sensor-trigger.h"
65 int report_id = -1; in prox_read_raw()
74 switch (chan->scan_index) { in prox_read_raw()
76 report_id = prox_state->prox_attr.report_id; in prox_read_raw()
77 min = prox_state->prox_attr.logical_minimum; in prox_read_raw()
79 hsdev = prox_state->common_attributes.hsdev; in prox_read_raw()
82 report_id = -1; in prox_read_raw()
86 hid_sensor_power_state(&prox_state->common_attributes, in prox_read_raw()
89 hsdev, hsdev->usage, address, report_id, in prox_read_raw()
91 hid_sensor_power_state(&prox_state->common_attributes, in prox_read_raw()
95 return -EINVAL; in prox_read_raw()
100 *val = prox_state->scale_pre_decml; in prox_read_raw()
101 *val2 = prox_state->scale_post_decml; in prox_read_raw()
102 ret_type = prox_state->scale_precision; in prox_read_raw()
106 prox_state->prox_attr.unit_expo); in prox_read_raw()
111 &prox_state->common_attributes, val, val2); in prox_read_raw()
115 &prox_state->common_attributes, val, val2); in prox_read_raw()
118 ret_type = -EINVAL; in prox_read_raw()
138 &prox_state->common_attributes, val, val2); in prox_write_raw()
142 &prox_state->common_attributes, val, val2); in prox_write_raw()
145 ret = -EINVAL; in prox_write_raw()
160 dev_dbg(&indio_dev->dev, "hid_sensor_push_data\n"); in hid_sensor_push_data()
164 /* Callback handler to send event after all samples are received and captured */
172 dev_dbg(&indio_dev->dev, "prox_proc_event\n"); in prox_proc_event()
173 if (atomic_read(&prox_state->common_attributes.data_ready)) in prox_proc_event()
175 &prox_state->human_presence, in prox_proc_event()
176 sizeof(prox_state->human_presence)); in prox_proc_event()
189 int ret = -EINVAL; in prox_capture_sample()
195 prox_state->human_presence = *(u8 *)raw_data; in prox_capture_sample()
198 prox_state->human_presence = *(u32 *)raw_data; in prox_capture_sample()
221 &st->prox_attr); in prox_parse_report()
225 st->prox_attr.size); in prox_parse_report()
227 dev_dbg(&pdev->dev, "prox %x:%x\n", st->prox_attr.index, in prox_parse_report()
228 st->prox_attr.report_id); in prox_parse_report()
237 static const char *name = "prox"; in hid_prox_probe()
240 struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; in hid_prox_probe()
242 indio_dev = devm_iio_device_alloc(&pdev->dev, in hid_prox_probe()
245 return -ENOMEM; in hid_prox_probe()
249 prox_state->common_attributes.hsdev = hsdev; in hid_prox_probe()
250 prox_state->common_attributes.pdev = pdev; in hid_prox_probe()
252 ret = hid_sensor_parse_common_attributes(hsdev, hsdev->usage, in hid_prox_probe()
253 &prox_state->common_attributes, in hid_prox_probe()
257 dev_err(&pdev->dev, "failed to setup common attributes\n"); in hid_prox_probe()
261 indio_dev->channels = devm_kmemdup(&pdev->dev, prox_channels, in hid_prox_probe()
263 if (!indio_dev->channels) { in hid_prox_probe()
264 dev_err(&pdev->dev, "failed to duplicate channels\n"); in hid_prox_probe()
265 return -ENOMEM; in hid_prox_probe()
269 (struct iio_chan_spec *)indio_dev->channels, in hid_prox_probe()
270 hsdev->usage, prox_state); in hid_prox_probe()
272 dev_err(&pdev->dev, "failed to setup attributes\n"); in hid_prox_probe()
276 indio_dev->num_channels = ARRAY_SIZE(prox_channels); in hid_prox_probe()
277 indio_dev->info = &prox_info; in hid_prox_probe()
278 indio_dev->name = name; in hid_prox_probe()
279 indio_dev->modes = INDIO_DIRECT_MODE; in hid_prox_probe()
281 atomic_set(&prox_state->common_attributes.data_ready, 0); in hid_prox_probe()
284 &prox_state->common_attributes); in hid_prox_probe()
286 dev_err(&pdev->dev, "trigger setup failed\n"); in hid_prox_probe()
292 dev_err(&pdev->dev, "device register failed\n"); in hid_prox_probe()
296 prox_state->callbacks.send_event = prox_proc_event; in hid_prox_probe()
297 prox_state->callbacks.capture_sample = prox_capture_sample; in hid_prox_probe()
298 prox_state->callbacks.pdev = pdev; in hid_prox_probe()
299 ret = sensor_hub_register_callback(hsdev, hsdev->usage, in hid_prox_probe()
300 &prox_state->callbacks); in hid_prox_probe()
302 dev_err(&pdev->dev, "callback reg failed\n"); in hid_prox_probe()
311 hid_sensor_remove_trigger(indio_dev, &prox_state->common_attributes); in hid_prox_probe()
318 struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; in hid_prox_remove()
322 sensor_hub_remove_callback(hsdev, hsdev->usage); in hid_prox_remove()
324 hid_sensor_remove_trigger(indio_dev, &prox_state->common_attributes); in hid_prox_remove()
331 /* Format: HID-SENSOR-usage_id_in_hex_lowercase */
332 .name = "HID-SENSOR-200011",
335 /* Format: HID-SENSOR-tag-usage_id_in_hex_lowercase */
336 .name = "HID-SENSOR-LISS-0226",