* [PATCH v2 0/3] Add relative hysteresis support for hid sensors @ 2021-02-07 7:00 Ye Xiang 2021-02-07 7:00 ` [PATCH v2 1/3] iio: Add relative sensitivity support Ye Xiang ` (2 more replies) 0 siblings, 3 replies; 7+ messages in thread From: Ye Xiang @ 2021-02-07 7:00 UTC (permalink / raw) To: jikos, jic23, srinivas.pandruvada Cc: linux-input, linux-iio, linux-kernel, Ye Xiang Currently, hid sensor als are using the relative hysteresis. This patch series add the relative hysteresis for hid sensors. --- v2: - (1/3) fix the formatting issue in hid_sensor_read_raw_hyst_rel_value. - (3/3) add documentation just for light sensor. Ye Xiang (3): iio: Add relative sensitivity support iio: hid-sensor-als: Add relative hysteresis support iio: Add relative hysteresis in ABI documentation Documentation/ABI/testing/sysfs-bus-iio | 9 +++ .../hid-sensors/hid-sensor-attributes.c | 74 ++++++++++++++++++- drivers/iio/industrialio-core.c | 1 + drivers/iio/light/hid-sensor-als.c | 14 +++- include/linux/hid-sensor-hub.h | 5 ++ include/linux/hid-sensor-ids.h | 1 + include/linux/iio/types.h | 1 + 7 files changed, 99 insertions(+), 6 deletions(-) -- 2.17.1 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 1/3] iio: Add relative sensitivity support 2021-02-07 7:00 [PATCH v2 0/3] Add relative hysteresis support for hid sensors Ye Xiang @ 2021-02-07 7:00 ` Ye Xiang 2021-02-12 18:28 ` Jonathan Cameron 2021-02-07 7:00 ` [PATCH v2 2/3] iio: hid-sensor-als: Add relative hysteresis support Ye Xiang 2021-02-07 7:00 ` [PATCH v2 3/3] iio: Add relative hysteresis in ABI documentation Ye Xiang 2 siblings, 1 reply; 7+ messages in thread From: Ye Xiang @ 2021-02-07 7:00 UTC (permalink / raw) To: jikos, jic23, srinivas.pandruvada Cc: linux-input, linux-iio, linux-kernel, Ye Xiang Some hid sensors may use relative sensitivity such as als sensor. This patch adds relative sensitivity checking for all hid sensors. Signed-off-by: Ye Xiang <xiang.ye@intel.com> --- .../hid-sensors/hid-sensor-attributes.c | 74 ++++++++++++++++++- drivers/iio/industrialio-core.c | 1 + include/linux/hid-sensor-hub.h | 5 ++ include/linux/hid-sensor-ids.h | 1 + include/linux/iio/types.h | 1 + 5 files changed, 78 insertions(+), 4 deletions(-) diff --git a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c index d349ace2e33f..cb52b4fd6bf7 100644 --- a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c +++ b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c @@ -263,6 +263,29 @@ int hid_sensor_read_raw_hyst_value(struct hid_sensor_common *st, } EXPORT_SYMBOL(hid_sensor_read_raw_hyst_value); +int hid_sensor_read_raw_hyst_rel_value(struct hid_sensor_common *st, int *val1, + int *val2) +{ + s32 value; + int ret; + + ret = sensor_hub_get_feature(st->hsdev, + st->sensitivity_rel.report_id, + st->sensitivity_rel.index, sizeof(value), + &value); + if (ret < 0 || value < 0) { + *val1 = *val2 = 0; + return -EINVAL; + } + + convert_from_vtf_format(value, st->sensitivity_rel.size, + st->sensitivity_rel.unit_expo, val1, val2); + + return IIO_VAL_INT_PLUS_MICRO; +} +EXPORT_SYMBOL(hid_sensor_read_raw_hyst_rel_value); + + int hid_sensor_write_raw_hyst_value(struct hid_sensor_common *st, int val1, int val2) { @@ -294,6 +317,37 @@ int hid_sensor_write_raw_hyst_value(struct hid_sensor_common *st, } EXPORT_SYMBOL(hid_sensor_write_raw_hyst_value); +int hid_sensor_write_raw_hyst_rel_value(struct hid_sensor_common *st, + int val1, int val2) +{ + s32 value; + int ret; + + if (val1 < 0 || val2 < 0) + return -EINVAL; + + value = convert_to_vtf_format(st->sensitivity_rel.size, + st->sensitivity_rel.unit_expo, + val1, val2); + ret = sensor_hub_set_feature(st->hsdev, st->sensitivity_rel.report_id, + st->sensitivity_rel.index, sizeof(value), + &value); + if (ret < 0 || value < 0) + return -EINVAL; + + ret = sensor_hub_get_feature(st->hsdev, + st->sensitivity_rel.report_id, + st->sensitivity_rel.index, sizeof(value), + &value); + if (ret < 0 || value < 0) + return -EINVAL; + + st->raw_hystersis = value; + + return 0; +} +EXPORT_SYMBOL(hid_sensor_write_raw_hyst_rel_value); + /* * This fuction applies the unit exponent to the scale. * For example: @@ -478,16 +532,28 @@ int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev, HID_USAGE_SENSOR_PROP_SENSITIVITY_ABS, &st->sensitivity); + sensor_hub_input_get_attribute_info(hsdev, + HID_FEATURE_REPORT, usage_id, + HID_USAGE_SENSOR_PROP_SENSITIVITY_REL_PCT, + &st->sensitivity_rel); /* * 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, - HID_FEATURE_REPORT, usage_id, + for (i = 0; i < sensitivity_addresses_len; i++) { + if (st->sensitivity.index < 0) + sensor_hub_input_get_attribute_info( + hsdev, HID_FEATURE_REPORT, usage_id, HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS | sensitivity_addresses[i], &st->sensitivity); + + if (st->sensitivity_rel.index < 0) + 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_rel); } st->raw_hystersis = -1; diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 7db761afa578..3da8fcec3c16 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -157,6 +157,7 @@ static const char * const iio_chan_info_postfix[] = { [IIO_CHAN_INFO_PHASE] = "phase", [IIO_CHAN_INFO_HARDWAREGAIN] = "hardwaregain", [IIO_CHAN_INFO_HYSTERESIS] = "hysteresis", + [IIO_CHAN_INFO_HYSTERESIS_RELATIVE] = "hysteresis_relative", [IIO_CHAN_INFO_INT_TIME] = "integration_time", [IIO_CHAN_INFO_ENABLE] = "en", [IIO_CHAN_INFO_CALIBHEIGHT] = "calibheight", diff --git a/include/linux/hid-sensor-hub.h b/include/linux/hid-sensor-hub.h index 8b2599348554..5e7bc309172e 100644 --- a/include/linux/hid-sensor-hub.h +++ b/include/linux/hid-sensor-hub.h @@ -230,6 +230,7 @@ struct hid_sensor_common { struct hid_sensor_hub_attribute_info report_state; struct hid_sensor_hub_attribute_info power_state; struct hid_sensor_hub_attribute_info sensitivity; + struct hid_sensor_hub_attribute_info sensitivity_rel; struct hid_sensor_hub_attribute_info report_latency; struct work_struct work; }; @@ -252,8 +253,12 @@ int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev, u32 sensitivity_addresses_len); int hid_sensor_write_raw_hyst_value(struct hid_sensor_common *st, int val1, int val2); +int hid_sensor_write_raw_hyst_rel_value(struct hid_sensor_common *st, int val1, + int val2); int hid_sensor_read_raw_hyst_value(struct hid_sensor_common *st, int *val1, int *val2); +int hid_sensor_read_raw_hyst_rel_value(struct hid_sensor_common *st, + int *val1, int *val2); int hid_sensor_write_samp_freq_value(struct hid_sensor_common *st, int val1, int val2); int hid_sensor_read_samp_freq_value(struct hid_sensor_common *st, 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 diff --git a/include/linux/iio/types.h b/include/linux/iio/types.h index 1e3ed6f55bca..5aa7f66d4345 100644 --- a/include/linux/iio/types.h +++ b/include/linux/iio/types.h @@ -50,6 +50,7 @@ enum iio_chan_info_enum { IIO_CHAN_INFO_PHASE, IIO_CHAN_INFO_HARDWAREGAIN, IIO_CHAN_INFO_HYSTERESIS, + IIO_CHAN_INFO_HYSTERESIS_RELATIVE, IIO_CHAN_INFO_INT_TIME, IIO_CHAN_INFO_ENABLE, IIO_CHAN_INFO_CALIBHEIGHT, -- 2.17.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/3] iio: Add relative sensitivity support 2021-02-07 7:00 ` [PATCH v2 1/3] iio: Add relative sensitivity support Ye Xiang @ 2021-02-12 18:28 ` Jonathan Cameron 2021-02-17 11:55 ` Jiri Kosina 0 siblings, 1 reply; 7+ messages in thread From: Jonathan Cameron @ 2021-02-12 18:28 UTC (permalink / raw) To: Ye Xiang; +Cc: jikos, srinivas.pandruvada, linux-input, linux-iio, linux-kernel On Sun, 7 Feb 2021 15:00:46 +0800 Ye Xiang <xiang.ye@intel.com> wrote: > Some hid sensors may use relative sensitivity such as als sensor. > This patch adds relative sensitivity checking for all hid sensors. > > Signed-off-by: Ye Xiang <xiang.ye@intel.com> Hi, One totally trivial extra line below. I'll fix that whilst applying unless you need to respin for some reason. I'm fine with the series, but looking for an Ack from Jiri for the HID header changes. Unless we get a surprise on Sunday there is no chance I'll sneak this in for the coming merge window (or any of the things I've already gotten queued up in iio.git). Good to get it lined up soon for next time so we can all forget about it :) Jonathan > --- > .../hid-sensors/hid-sensor-attributes.c | 74 ++++++++++++++++++- > drivers/iio/industrialio-core.c | 1 + > include/linux/hid-sensor-hub.h | 5 ++ > include/linux/hid-sensor-ids.h | 1 + > include/linux/iio/types.h | 1 + > 5 files changed, 78 insertions(+), 4 deletions(-) > > diff --git a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c > index d349ace2e33f..cb52b4fd6bf7 100644 > --- a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c > +++ b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c > @@ -263,6 +263,29 @@ int hid_sensor_read_raw_hyst_value(struct hid_sensor_common *st, > } > EXPORT_SYMBOL(hid_sensor_read_raw_hyst_value); > > +int hid_sensor_read_raw_hyst_rel_value(struct hid_sensor_common *st, int *val1, > + int *val2) > +{ > + s32 value; > + int ret; > + > + ret = sensor_hub_get_feature(st->hsdev, > + st->sensitivity_rel.report_id, > + st->sensitivity_rel.index, sizeof(value), > + &value); > + if (ret < 0 || value < 0) { > + *val1 = *val2 = 0; > + return -EINVAL; > + } > + > + convert_from_vtf_format(value, st->sensitivity_rel.size, > + st->sensitivity_rel.unit_expo, val1, val2); > + > + return IIO_VAL_INT_PLUS_MICRO; > +} > +EXPORT_SYMBOL(hid_sensor_read_raw_hyst_rel_value); > + > + One line only. > int hid_sensor_write_raw_hyst_value(struct hid_sensor_common *st, > int val1, int val2) > { > @@ -294,6 +317,37 @@ int hid_sensor_write_raw_hyst_value(struct hid_sensor_common *st, > } > EXPORT_SYMBOL(hid_sensor_write_raw_hyst_value); > > +int hid_sensor_write_raw_hyst_rel_value(struct hid_sensor_common *st, > + int val1, int val2) > +{ > + s32 value; > + int ret; > + > + if (val1 < 0 || val2 < 0) > + return -EINVAL; > + > + value = convert_to_vtf_format(st->sensitivity_rel.size, > + st->sensitivity_rel.unit_expo, > + val1, val2); > + ret = sensor_hub_set_feature(st->hsdev, st->sensitivity_rel.report_id, > + st->sensitivity_rel.index, sizeof(value), > + &value); > + if (ret < 0 || value < 0) > + return -EINVAL; > + > + ret = sensor_hub_get_feature(st->hsdev, > + st->sensitivity_rel.report_id, > + st->sensitivity_rel.index, sizeof(value), > + &value); > + if (ret < 0 || value < 0) > + return -EINVAL; > + > + st->raw_hystersis = value; > + > + return 0; > +} > +EXPORT_SYMBOL(hid_sensor_write_raw_hyst_rel_value); > + > /* > * This fuction applies the unit exponent to the scale. > * For example: > @@ -478,16 +532,28 @@ int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev, > HID_USAGE_SENSOR_PROP_SENSITIVITY_ABS, > &st->sensitivity); > > + sensor_hub_input_get_attribute_info(hsdev, > + HID_FEATURE_REPORT, usage_id, > + HID_USAGE_SENSOR_PROP_SENSITIVITY_REL_PCT, > + &st->sensitivity_rel); > /* > * 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, > - HID_FEATURE_REPORT, usage_id, > + for (i = 0; i < sensitivity_addresses_len; i++) { > + if (st->sensitivity.index < 0) > + sensor_hub_input_get_attribute_info( > + hsdev, HID_FEATURE_REPORT, usage_id, > HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS | > sensitivity_addresses[i], > &st->sensitivity); > + > + if (st->sensitivity_rel.index < 0) > + 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_rel); > } > > st->raw_hystersis = -1; > diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c > index 7db761afa578..3da8fcec3c16 100644 > --- a/drivers/iio/industrialio-core.c > +++ b/drivers/iio/industrialio-core.c > @@ -157,6 +157,7 @@ static const char * const iio_chan_info_postfix[] = { > [IIO_CHAN_INFO_PHASE] = "phase", > [IIO_CHAN_INFO_HARDWAREGAIN] = "hardwaregain", > [IIO_CHAN_INFO_HYSTERESIS] = "hysteresis", > + [IIO_CHAN_INFO_HYSTERESIS_RELATIVE] = "hysteresis_relative", > [IIO_CHAN_INFO_INT_TIME] = "integration_time", > [IIO_CHAN_INFO_ENABLE] = "en", > [IIO_CHAN_INFO_CALIBHEIGHT] = "calibheight", > diff --git a/include/linux/hid-sensor-hub.h b/include/linux/hid-sensor-hub.h > index 8b2599348554..5e7bc309172e 100644 > --- a/include/linux/hid-sensor-hub.h > +++ b/include/linux/hid-sensor-hub.h > @@ -230,6 +230,7 @@ struct hid_sensor_common { > struct hid_sensor_hub_attribute_info report_state; > struct hid_sensor_hub_attribute_info power_state; > struct hid_sensor_hub_attribute_info sensitivity; > + struct hid_sensor_hub_attribute_info sensitivity_rel; > struct hid_sensor_hub_attribute_info report_latency; > struct work_struct work; > }; > @@ -252,8 +253,12 @@ int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev, > u32 sensitivity_addresses_len); > int hid_sensor_write_raw_hyst_value(struct hid_sensor_common *st, > int val1, int val2); > +int hid_sensor_write_raw_hyst_rel_value(struct hid_sensor_common *st, int val1, > + int val2); > int hid_sensor_read_raw_hyst_value(struct hid_sensor_common *st, > int *val1, int *val2); > +int hid_sensor_read_raw_hyst_rel_value(struct hid_sensor_common *st, > + int *val1, int *val2); > int hid_sensor_write_samp_freq_value(struct hid_sensor_common *st, > int val1, int val2); > int hid_sensor_read_samp_freq_value(struct hid_sensor_common *st, > 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 > diff --git a/include/linux/iio/types.h b/include/linux/iio/types.h > index 1e3ed6f55bca..5aa7f66d4345 100644 > --- a/include/linux/iio/types.h > +++ b/include/linux/iio/types.h > @@ -50,6 +50,7 @@ enum iio_chan_info_enum { > IIO_CHAN_INFO_PHASE, > IIO_CHAN_INFO_HARDWAREGAIN, > IIO_CHAN_INFO_HYSTERESIS, > + IIO_CHAN_INFO_HYSTERESIS_RELATIVE, > IIO_CHAN_INFO_INT_TIME, > IIO_CHAN_INFO_ENABLE, > IIO_CHAN_INFO_CALIBHEIGHT, ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/3] iio: Add relative sensitivity support 2021-02-12 18:28 ` Jonathan Cameron @ 2021-02-17 11:55 ` Jiri Kosina 2021-02-18 13:19 ` Jonathan Cameron 0 siblings, 1 reply; 7+ messages in thread From: Jiri Kosina @ 2021-02-17 11:55 UTC (permalink / raw) To: Jonathan Cameron Cc: Ye Xiang, srinivas.pandruvada, linux-input, linux-iio, linux-kernel On Fri, 12 Feb 2021, Jonathan Cameron wrote: > > Some hid sensors may use relative sensitivity such as als sensor. > > This patch adds relative sensitivity checking for all hid sensors. > > > > Signed-off-by: Ye Xiang <xiang.ye@intel.com> > Hi, > > One totally trivial extra line below. I'll fix that whilst applying > unless you need to respin for some reason. > > I'm fine with the series, but looking for an Ack from Jiri > for the HID header changes. Acked-by: Jiri Kosina <jkosina@suse.cz> Thanks, -- Jiri Kosina SUSE Labs ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/3] iio: Add relative sensitivity support 2021-02-17 11:55 ` Jiri Kosina @ 2021-02-18 13:19 ` Jonathan Cameron 0 siblings, 0 replies; 7+ messages in thread From: Jonathan Cameron @ 2021-02-18 13:19 UTC (permalink / raw) To: Jiri Kosina Cc: Ye Xiang, srinivas.pandruvada, linux-input, linux-iio, linux-kernel On Wed, 17 Feb 2021 12:55:41 +0100 (CET) Jiri Kosina <jikos@kernel.org> wrote: > On Fri, 12 Feb 2021, Jonathan Cameron wrote: > > > > Some hid sensors may use relative sensitivity such as als sensor. > > > This patch adds relative sensitivity checking for all hid sensors. > > > > > > Signed-off-by: Ye Xiang <xiang.ye@intel.com> > > Hi, > > > > One totally trivial extra line below. I'll fix that whilst applying > > unless you need to respin for some reason. > > > > I'm fine with the series, but looking for an Ack from Jiri > > for the HID header changes. > > Acked-by: Jiri Kosina <jkosina@suse.cz> > > Thanks, > Thanks, series (and precursor series that also had a tiny addition to those headers) applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to poke at it and see if they can find anything we missed. THanks, Jonathan ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 2/3] iio: hid-sensor-als: Add relative hysteresis support 2021-02-07 7:00 [PATCH v2 0/3] Add relative hysteresis support for hid sensors Ye Xiang 2021-02-07 7:00 ` [PATCH v2 1/3] iio: Add relative sensitivity support Ye Xiang @ 2021-02-07 7:00 ` Ye Xiang 2021-02-07 7:00 ` [PATCH v2 3/3] iio: Add relative hysteresis in ABI documentation Ye Xiang 2 siblings, 0 replies; 7+ messages in thread From: Ye Xiang @ 2021-02-07 7:00 UTC (permalink / raw) To: jikos, jic23, srinivas.pandruvada Cc: linux-input, linux-iio, linux-kernel, Ye Xiang Hid sensor als use relative hysteresis, this patch adds the support. Signed-off-by: Ye Xiang <xiang.ye@intel.com> --- drivers/iio/light/hid-sensor-als.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c index afcdb424bfb8..85c8a05b73cb 100644 --- a/drivers/iio/light/hid-sensor-als.c +++ b/drivers/iio/light/hid-sensor-als.c @@ -54,7 +54,8 @@ static const struct iio_chan_spec als_channels[] = { .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | BIT(IIO_CHAN_INFO_SCALE) | BIT(IIO_CHAN_INFO_SAMP_FREQ) | - BIT(IIO_CHAN_INFO_HYSTERESIS), + BIT(IIO_CHAN_INFO_HYSTERESIS) | + BIT(IIO_CHAN_INFO_HYSTERESIS_RELATIVE), .scan_index = CHANNEL_SCAN_INDEX_INTENSITY, }, { @@ -63,7 +64,8 @@ static const struct iio_chan_spec als_channels[] = { .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | BIT(IIO_CHAN_INFO_SCALE) | BIT(IIO_CHAN_INFO_SAMP_FREQ) | - BIT(IIO_CHAN_INFO_HYSTERESIS), + BIT(IIO_CHAN_INFO_HYSTERESIS) | + BIT(IIO_CHAN_INFO_HYSTERESIS_RELATIVE), .scan_index = CHANNEL_SCAN_INDEX_ILLUM, }, IIO_CHAN_SOFT_TIMESTAMP(CHANNEL_SCAN_INDEX_TIMESTAMP) @@ -141,6 +143,10 @@ static int als_read_raw(struct iio_dev *indio_dev, ret_type = hid_sensor_read_raw_hyst_value( &als_state->common_attributes, val, val2); break; + case IIO_CHAN_INFO_HYSTERESIS_RELATIVE: + ret_type = hid_sensor_read_raw_hyst_rel_value( + &als_state->common_attributes, val, val2); + break; default: ret_type = -EINVAL; break; @@ -168,6 +174,10 @@ static int als_write_raw(struct iio_dev *indio_dev, ret = hid_sensor_write_raw_hyst_value( &als_state->common_attributes, val, val2); break; + case IIO_CHAN_INFO_HYSTERESIS_RELATIVE: + ret = hid_sensor_write_raw_hyst_rel_value( + &als_state->common_attributes, val, val2); + break; default: ret = -EINVAL; } -- 2.17.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 3/3] iio: Add relative hysteresis in ABI documentation 2021-02-07 7:00 [PATCH v2 0/3] Add relative hysteresis support for hid sensors Ye Xiang 2021-02-07 7:00 ` [PATCH v2 1/3] iio: Add relative sensitivity support Ye Xiang 2021-02-07 7:00 ` [PATCH v2 2/3] iio: hid-sensor-als: Add relative hysteresis support Ye Xiang @ 2021-02-07 7:00 ` Ye Xiang 2 siblings, 0 replies; 7+ messages in thread From: Ye Xiang @ 2021-02-07 7:00 UTC (permalink / raw) To: jikos, jic23, srinivas.pandruvada Cc: linux-input, linux-iio, linux-kernel, Ye Xiang Add relative hysteresis in ABI documentation for als sensor. Signed-off-by: Ye Xiang <xiang.ye@intel.com> --- Documentation/ABI/testing/sysfs-bus-iio | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio index d957f5da5c04..0890bd113eea 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio +++ b/Documentation/ABI/testing/sysfs-bus-iio @@ -1823,3 +1823,12 @@ Description: hinge, keyboard, screen. It means the three channels each correspond respectively to hinge angle, keyboard angle, and screen angle. + +What: /sys/bus/iio/devices/iio:deviceX/in_illuminance_hysteresis_relative +What: /sys/bus/iio/devices/iio:deviceX/in_intensity_hysteresis_relative +KernelVersion: 5.12 +Contact: linux-iio@vger.kernel.org +Description: + Specify the percent for light sensor relative to the channel + absolute value that a data field should change before an event + is generated. Units are a percentage of the prior reading. -- 2.17.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-02-18 15:27 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-02-07 7:00 [PATCH v2 0/3] Add relative hysteresis support for hid sensors Ye Xiang 2021-02-07 7:00 ` [PATCH v2 1/3] iio: Add relative sensitivity support Ye Xiang 2021-02-12 18:28 ` Jonathan Cameron 2021-02-17 11:55 ` Jiri Kosina 2021-02-18 13:19 ` Jonathan Cameron 2021-02-07 7:00 ` [PATCH v2 2/3] iio: hid-sensor-als: Add relative hysteresis support Ye Xiang 2021-02-07 7:00 ` [PATCH v2 3/3] iio: Add relative hysteresis in ABI documentation Ye Xiang
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).