Commit c8aca355 authored by Philipp Jungkamp's avatar Philipp Jungkamp Committed by Jiri Kosina

IIO: hid-sensor-prox: Use generic usage

Use a generic 'hsdev->usage' instead of the HID_USAGE_SENSOR_PROX to
allow this driver to drive the Lenvo custom proximity sensor, which is
registered under a 'custom' usage and not HID_USAGE_SENSOR_PROX.

Add the Lenovo Intelligent Sensing Solution (LISS) human presence sensor
to the platform device ids.
Signed-off-by: default avatarPhilipp Jungkamp <p.jungkamp@gmx.net>
Reviewed-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
Acked-by: default avatarSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 3a04a186
...@@ -61,6 +61,7 @@ static int prox_read_raw(struct iio_dev *indio_dev, ...@@ -61,6 +61,7 @@ static int prox_read_raw(struct iio_dev *indio_dev,
long mask) long mask)
{ {
struct prox_state *prox_state = iio_priv(indio_dev); struct prox_state *prox_state = iio_priv(indio_dev);
struct hid_sensor_hub_device *hsdev;
int report_id = -1; int report_id = -1;
u32 address; u32 address;
int ret_type; int ret_type;
...@@ -75,6 +76,7 @@ static int prox_read_raw(struct iio_dev *indio_dev, ...@@ -75,6 +76,7 @@ static int prox_read_raw(struct iio_dev *indio_dev,
report_id = prox_state->prox_attr.report_id; report_id = prox_state->prox_attr.report_id;
min = prox_state->prox_attr.logical_minimum; min = prox_state->prox_attr.logical_minimum;
address = HID_USAGE_SENSOR_HUMAN_PRESENCE; address = HID_USAGE_SENSOR_HUMAN_PRESENCE;
hsdev = prox_state->common_attributes.hsdev;
break; break;
default: default:
report_id = -1; report_id = -1;
...@@ -84,11 +86,8 @@ static int prox_read_raw(struct iio_dev *indio_dev, ...@@ -84,11 +86,8 @@ static int prox_read_raw(struct iio_dev *indio_dev,
hid_sensor_power_state(&prox_state->common_attributes, hid_sensor_power_state(&prox_state->common_attributes,
true); true);
*val = sensor_hub_input_attr_get_raw_value( *val = sensor_hub_input_attr_get_raw_value(
prox_state->common_attributes.hsdev, hsdev, hsdev->usage, address, report_id,
HID_USAGE_SENSOR_PROX, address, SENSOR_HUB_SYNC, min < 0);
report_id,
SENSOR_HUB_SYNC,
min < 0);
hid_sensor_power_state(&prox_state->common_attributes, hid_sensor_power_state(&prox_state->common_attributes,
false); false);
} else { } else {
...@@ -191,10 +190,16 @@ static int prox_capture_sample(struct hid_sensor_hub_device *hsdev, ...@@ -191,10 +190,16 @@ static int prox_capture_sample(struct hid_sensor_hub_device *hsdev,
switch (usage_id) { switch (usage_id) {
case HID_USAGE_SENSOR_HUMAN_PRESENCE: case HID_USAGE_SENSOR_HUMAN_PRESENCE:
prox_state->human_presence = *(u32 *)raw_data; switch (raw_len) {
ret = 0; case 1:
break; prox_state->human_presence = *(u8 *)raw_data;
default: return 0;
case 4:
prox_state->human_presence = *(u32 *)raw_data;
return 0;
default:
break;
}
break; break;
} }
...@@ -244,7 +249,7 @@ static int hid_prox_probe(struct platform_device *pdev) ...@@ -244,7 +249,7 @@ static int hid_prox_probe(struct platform_device *pdev)
prox_state->common_attributes.hsdev = hsdev; prox_state->common_attributes.hsdev = hsdev;
prox_state->common_attributes.pdev = pdev; prox_state->common_attributes.pdev = pdev;
ret = hid_sensor_parse_common_attributes(hsdev, HID_USAGE_SENSOR_PROX, ret = hid_sensor_parse_common_attributes(hsdev, hsdev->usage,
&prox_state->common_attributes, &prox_state->common_attributes,
prox_sensitivity_addresses, prox_sensitivity_addresses,
ARRAY_SIZE(prox_sensitivity_addresses)); ARRAY_SIZE(prox_sensitivity_addresses));
...@@ -262,7 +267,7 @@ static int hid_prox_probe(struct platform_device *pdev) ...@@ -262,7 +267,7 @@ static int hid_prox_probe(struct platform_device *pdev)
ret = prox_parse_report(pdev, hsdev, ret = prox_parse_report(pdev, hsdev,
(struct iio_chan_spec *)indio_dev->channels, (struct iio_chan_spec *)indio_dev->channels,
HID_USAGE_SENSOR_PROX, prox_state); hsdev->usage, prox_state);
if (ret) { if (ret) {
dev_err(&pdev->dev, "failed to setup attributes\n"); dev_err(&pdev->dev, "failed to setup attributes\n");
return ret; return ret;
...@@ -291,8 +296,8 @@ static int hid_prox_probe(struct platform_device *pdev) ...@@ -291,8 +296,8 @@ static int hid_prox_probe(struct platform_device *pdev)
prox_state->callbacks.send_event = prox_proc_event; prox_state->callbacks.send_event = prox_proc_event;
prox_state->callbacks.capture_sample = prox_capture_sample; prox_state->callbacks.capture_sample = prox_capture_sample;
prox_state->callbacks.pdev = pdev; prox_state->callbacks.pdev = pdev;
ret = sensor_hub_register_callback(hsdev, HID_USAGE_SENSOR_PROX, ret = sensor_hub_register_callback(hsdev, hsdev->usage,
&prox_state->callbacks); &prox_state->callbacks);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "callback reg failed\n"); dev_err(&pdev->dev, "callback reg failed\n");
goto error_iio_unreg; goto error_iio_unreg;
...@@ -314,7 +319,7 @@ static int hid_prox_remove(struct platform_device *pdev) ...@@ -314,7 +319,7 @@ static int hid_prox_remove(struct platform_device *pdev)
struct iio_dev *indio_dev = platform_get_drvdata(pdev); struct iio_dev *indio_dev = platform_get_drvdata(pdev);
struct prox_state *prox_state = iio_priv(indio_dev); struct prox_state *prox_state = iio_priv(indio_dev);
sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_PROX); sensor_hub_remove_callback(hsdev, hsdev->usage);
iio_device_unregister(indio_dev); iio_device_unregister(indio_dev);
hid_sensor_remove_trigger(indio_dev, &prox_state->common_attributes); hid_sensor_remove_trigger(indio_dev, &prox_state->common_attributes);
...@@ -326,6 +331,10 @@ static const struct platform_device_id hid_prox_ids[] = { ...@@ -326,6 +331,10 @@ static const struct platform_device_id hid_prox_ids[] = {
/* Format: HID-SENSOR-usage_id_in_hex_lowercase */ /* Format: HID-SENSOR-usage_id_in_hex_lowercase */
.name = "HID-SENSOR-200011", .name = "HID-SENSOR-200011",
}, },
{
/* Format: HID-SENSOR-tag-usage_id_in_hex_lowercase */
.name = "HID-SENSOR-LISS-0226",
},
{ /* sentinel */ } { /* sentinel */ }
}; };
MODULE_DEVICE_TABLE(platform, hid_prox_ids); MODULE_DEVICE_TABLE(platform, hid_prox_ids);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment