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"
62 int report_id = -1; in prox_read_raw()
71 switch (chan->scan_index) { in prox_read_raw()
73 report_id = prox_state->prox_attr.report_id; in prox_read_raw()
74 min = prox_state->prox_attr.logical_minimum; in prox_read_raw()
78 report_id = -1; in prox_read_raw()
82 hid_sensor_power_state(&prox_state->common_attributes, in prox_read_raw()
85 prox_state->common_attributes.hsdev, in prox_read_raw()
90 hid_sensor_power_state(&prox_state->common_attributes, in prox_read_raw()
94 return -EINVAL; in prox_read_raw()
99 *val = prox_state->scale_pre_decml; in prox_read_raw()
100 *val2 = prox_state->scale_post_decml; in prox_read_raw()
101 ret_type = prox_state->scale_precision; in prox_read_raw()
105 prox_state->prox_attr.unit_expo); in prox_read_raw()
110 &prox_state->common_attributes, val, val2); in prox_read_raw()
114 &prox_state->common_attributes, val, val2); in prox_read_raw()
117 ret_type = -EINVAL; in prox_read_raw()
137 &prox_state->common_attributes, val, val2); in prox_write_raw()
141 &prox_state->common_attributes, val, val2); in prox_write_raw()
144 ret = -EINVAL; in prox_write_raw()
159 dev_dbg(&indio_dev->dev, "hid_sensor_push_data\n"); in hid_sensor_push_data()
163 /* Callback handler to send event after all samples are received and captured */
171 dev_dbg(&indio_dev->dev, "prox_proc_event\n"); in prox_proc_event()
172 if (atomic_read(&prox_state->common_attributes.data_ready)) in prox_proc_event()
174 &prox_state->human_presence, in prox_proc_event()
175 sizeof(prox_state->human_presence)); in prox_proc_event()
188 int ret = -EINVAL; in prox_capture_sample()
192 prox_state->human_presence = *(u32 *)raw_data; in prox_capture_sample()
214 &st->prox_attr); in prox_parse_report()
218 st->prox_attr.size); in prox_parse_report()
220 dev_dbg(&pdev->dev, "prox %x:%x\n", st->prox_attr.index, in prox_parse_report()
221 st->prox_attr.report_id); in prox_parse_report()
224 if (st->common_attributes.sensitivity.index < 0) { in prox_parse_report()
229 &st->common_attributes.sensitivity); in prox_parse_report()
230 dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n", in prox_parse_report()
231 st->common_attributes.sensitivity.index, in prox_parse_report()
232 st->common_attributes.sensitivity.report_id); in prox_parse_report()
234 if (st->common_attributes.sensitivity.index < 0) in prox_parse_report()
239 &st->common_attributes.sensitivity); in prox_parse_report()
241 st->scale_precision = hid_sensor_format_scale( in prox_parse_report()
242 hsdev->usage, in prox_parse_report()
243 &st->prox_attr, in prox_parse_report()
244 &st->scale_pre_decml, &st->scale_post_decml); in prox_parse_report()
253 static const char *name = "prox"; in hid_prox_probe()
256 struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; in hid_prox_probe()
258 indio_dev = devm_iio_device_alloc(&pdev->dev, in hid_prox_probe()
261 return -ENOMEM; in hid_prox_probe()
265 prox_state->common_attributes.hsdev = hsdev; in hid_prox_probe()
266 prox_state->common_attributes.pdev = pdev; in hid_prox_probe()
269 &prox_state->common_attributes); in hid_prox_probe()
271 dev_err(&pdev->dev, "failed to setup common attributes\n"); in hid_prox_probe()
275 indio_dev->channels = kmemdup(prox_channels, sizeof(prox_channels), in hid_prox_probe()
277 if (!indio_dev->channels) { in hid_prox_probe()
278 dev_err(&pdev->dev, "failed to duplicate channels\n"); in hid_prox_probe()
279 return -ENOMEM; in hid_prox_probe()
283 (struct iio_chan_spec *)indio_dev->channels, in hid_prox_probe()
286 dev_err(&pdev->dev, "failed to setup attributes\n"); in hid_prox_probe()
290 indio_dev->num_channels = ARRAY_SIZE(prox_channels); in hid_prox_probe()
291 indio_dev->info = &prox_info; in hid_prox_probe()
292 indio_dev->name = name; in hid_prox_probe()
293 indio_dev->modes = INDIO_DIRECT_MODE; in hid_prox_probe()
295 atomic_set(&prox_state->common_attributes.data_ready, 0); in hid_prox_probe()
298 &prox_state->common_attributes); in hid_prox_probe()
300 dev_err(&pdev->dev, "trigger setup failed\n"); in hid_prox_probe()
306 dev_err(&pdev->dev, "device register failed\n"); in hid_prox_probe()
310 prox_state->callbacks.send_event = prox_proc_event; in hid_prox_probe()
311 prox_state->callbacks.capture_sample = prox_capture_sample; in hid_prox_probe()
312 prox_state->callbacks.pdev = pdev; in hid_prox_probe()
314 &prox_state->callbacks); in hid_prox_probe()
316 dev_err(&pdev->dev, "callback reg failed\n"); in hid_prox_probe()
325 hid_sensor_remove_trigger(indio_dev, &prox_state->common_attributes); in hid_prox_probe()
327 kfree(indio_dev->channels); in hid_prox_probe()
334 struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; in hid_prox_remove()
340 hid_sensor_remove_trigger(indio_dev, &prox_state->common_attributes); in hid_prox_remove()
341 kfree(indio_dev->channels); in hid_prox_remove()
348 /* Format: HID-SENSOR-usage_id_in_hex_lowercase */
349 .name = "HID-SENSOR-200011",