From: Ye Xiang <xiang.ye@intel.com>
To: jikos@kernel.org, jic23@kernel.org, srinivas.pandruvada@linux.intel.com
Cc: linux-input@vger.kernel.org, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org, Ye Xiang <xiang.ye@intel.com>
Subject: [PATCH 2/3] hid-sensor-common: Add relative sensitivity check
Date: Wed, 20 Jan 2021 15:47:05 +0800 [thread overview]
Message-ID: <20210120074706.23199-3-xiang.ye@intel.com> (raw)
In-Reply-To: <20210120074706.23199-1-xiang.ye@intel.com>
Some hid sensors may use relative sensitivity such as als sensor.
This patch add relative sensitivity check for all hid-sensors.
Signed-off-by: Ye Xiang <xiang.ye@intel.com>
---
.../iio/common/hid-sensors/hid-sensor-attributes.c | 11 ++++++++++-
include/linux/hid-sensor-ids.h | 1 +
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
index d349ace2e33f..b685c292a179 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
+++ b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
@@ -480,7 +480,7 @@ int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev,
/*
* Set Sensitivity field ids, when there is no individual modifier, will
- * check absolute sensitivity of data field
+ * check absolute sensitivity and relative sensitivity of data field
*/
for (i = 0; i < sensitivity_addresses_len && st->sensitivity.index < 0; i++) {
sensor_hub_input_get_attribute_info(hsdev,
@@ -488,6 +488,15 @@ int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev,
HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
sensitivity_addresses[i],
&st->sensitivity);
+
+ if (st->sensitivity.index >= 0)
+ break;
+
+ sensor_hub_input_get_attribute_info(hsdev,
+ HID_FEATURE_REPORT, usage_id,
+ HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_REL_PCT |
+ sensitivity_addresses[i],
+ &st->sensitivity);
}
st->raw_hystersis = -1;
diff --git a/include/linux/hid-sensor-ids.h b/include/linux/hid-sensor-ids.h
index 3bbdbccc5805..ac631159403a 100644
--- a/include/linux/hid-sensor-ids.h
+++ b/include/linux/hid-sensor-ids.h
@@ -149,6 +149,7 @@
/* Per data field properties */
#define HID_USAGE_SENSOR_DATA_MOD_NONE 0x00
#define HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS 0x1000
+#define HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_REL_PCT 0xE000
/* Power state enumerations */
#define HID_USAGE_SENSOR_PROP_POWER_STATE_UNDEFINED_ENUM 0x200850
--
2.17.1
next prev parent reply other threads:[~2021-01-20 7:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-20 7:47 [PATCH 0/3] resolve read hystersis return invalid argument issue for hid sensors Ye Xiang
2021-01-20 7:47 ` [PATCH 1/3] iio: hid-sensors: Move get sensitivity attribute to hid-sensor-common Ye Xiang
2021-01-23 16:12 ` Jonathan Cameron
2021-01-20 7:47 ` Ye Xiang [this message]
2021-01-24 13:14 ` [PATCH 2/3] hid-sensor-common: Add relative sensitivity check Jonathan Cameron
2021-01-24 16:20 ` Srinivas Pandruvada
2021-01-28 16:35 ` Ye, Xiang
[not found] ` <20210131112648.3299b2a0@archlinux>
2021-01-31 20:32 ` Srinivas Pandruvada
2021-01-20 7:47 ` [PATCH 3/3] hid-sensors: Add more data fields for sensitivity checking Ye Xiang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210120074706.23199-3-xiang.ye@intel.com \
--to=xiang.ye@intel.com \
--cc=jic23@kernel.org \
--cc=jikos@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=srinivas.pandruvada@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).