Commit Graph

29 Commits

Author SHA1 Message Date
Thomas Gleixner
a61127c213 treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 335
Based on 1 normalized pattern(s):

  this program is free software you can redistribute it and or modify
  it under the terms and conditions of the gnu general public license
  version 2 as published by the free software foundation this program
  is distributed in the hope it will be useful but without any
  warranty without even the implied warranty of merchantability or
  fitness for a particular purpose see the gnu general public license
  for more details you should have received a copy of the gnu general
  public license along with this program if not write to the free
  software foundation inc 51 franklin st fifth floor boston ma 02110
  1301 usa

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-only

has been chosen to replace the boilerplate/reference in 111 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Alexios Zavras <alexios.zavras@intel.com>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190530000436.567572064@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-05 17:37:06 +02:00
Colin Ian King
8611b69e95 iio: hid-sensor-hub: clean up indentation, remove extraneous tab
The statement is indented too much by one level, fix this by
removing the extraneous tab.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-11-25 14:03:59 +00:00
Srinivas Pandruvada
b0f847e16c HID: hid-sensor-hub: Force logical minimum to 1 for power and report state
In the reference HID sensor hub firmware all Named array enums were
0-based. There is no description of the default base of enums in HID
sensor hub specification as logical minimum should have set this base
value.

Every sensor hub implemented enum as 1-based, without explicitly setting
logical minimum to 1, because of the implementation by one of the major
OS vendor. In Linux we used logical minimum to decide the enum base.

Some sensor hub FWs already changed logical minimum from 0 to 1. We hoped
that every other vendor will follow. But that didn't happen and we had to
fix the report header for every sensor hub to change logical minimum to 1
by using .report_fixup() callback. So for every new sensor hub we had to
modify source code by adding this quirk based on the vendor and device id.
This is becoming a maintenance burden.

This patch hardcodes the logical minimum of power and report state
attributes to 1. In this way we can remove the existing quirks and also
we don't have to add more quirks.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2017-08-09 22:15:59 +02:00
Srinivas Pandruvada
138bc7969c iio: hid-sensor-hub: Implement batch mode
HID sensor hubs using Integrated Senor Hub (ISH) has added capability to
support batch mode. This allows host processor to go to sleep for extended
duration, while the sensor hub is storing samples in its internal buffers.

'Commit f4f4673b75 ("iio: add support for hardware fifo")' implements
feature in IIO core to implement such feature. This feature is used in
bmc150-accel-core.c to implement batch mode. This implementation allows
software device buffer watermark to be used as a hint to adjust hardware
FIFO.

But HID sensor hubs don't allow to change internal buffer size of FIFOs.
Instead an additional usage id to set "maximum report latency" is defined.
This allows host to go to sleep upto this latency period without getting
any report. Since there is no ABI to set this latency, a new attribute
"hwfifo_timeout" is added so that user mode can specify a latency.

This change checks presence of usage id to get/set maximum report latency
and if present, it will expose hwfifo_timeout.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-05-16 19:44:01 +01:00
Song Hongyan
a78587d338 iio: hid-sensor-rotation: Add "scale" and "offset" properties parse support
Add orientation sensor "scale" and "offset" parse support.
These two properties are needed for exponent data conversion.

Signed-off-by: Song Hongyan <hongyan.song@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Reviewed-by: Xu Even <even.xu@intel.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-05-07 12:22:36 +01:00
Colin Ian King
c894acc7bf iio: hid-sensor: fix return of -EINVAL on invalid values in ret or value
Ensure that when an invalid value in ret or value is found -EINVAL
is returned. A previous commit broke the way the return error is
being returned and instead caused the return code in ret to be
re-assigned rather than be returned.

Fixes: 5d9854eaea ("iio: hid-sensor: Store restore poll and hysteresis on S3")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-04-27 07:16:45 +01:00
Greg Kroah-Hartman
df47c0a638 Fifth set of IIO fixes for the 4.11 cycle.
As these are rather late in the cycle, they may sneak over into 4.12.
 There is a fix for a regression caused by another fix (hid sensors
 hardware seems to vary a lot in how various corner cases are handled).
 
 * ad7303
   - fix channel description. Numeric values were being passed as characters
   presumably leading to garbage from the userspace interface.
 * as3935
   - the write data macro was wrong so fix it.
 * bmp280
   - incorrect handling of negative values as being unsigned broke humidity
   calculation.
 * hid-sensor
   - Restore the poll and hysteresis values after resume as some hardware
   doesn't do it.
 * stm32-trigger
   - buglet in reading the sampling frequency
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAljw8ScRHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FojZvBAAh8K9e+3ObpS6/0wj26/XsakiFn4v2ah0
 xKUnafxAVVxU3AU01IJ3CtNdIMyqMwpnB+PvnpgDzZw749QrYKPsBIzheK64eabe
 fzA34X5MWGLwUdOXpfEB0xvsylWjJrqsf1rahgZjiUKkPeZe9EwzPM/fP1sEl5gu
 p+vfSMckboFaKheoQwnWMUTBp0HK+nbFpcSBzljX68u+epiXpDGrjuZC8NJ3JuBn
 Bloz9AhDliIn477H7mIUTXBbt3ixLIDiJ7haQuTNlagosPoUtCBpwY2O9mZ7VRVs
 wM62h7/F170077ReQJRjlfck+7uHoIgDeS46w5UYTzA1HJLxs+veO5xv3VOtHIUg
 BZ+mibQyIUBrFeyYDVbeUpBTffiU6rA+yiM4WFwUFabl7t7rlG0NhLEx7OIQcFMm
 l8u/5JUoJcoykaO8c9Jx5XtrgkXq+rCWVAmhjHqUDAlvsMa6pJWEyqgaVcQeIbdw
 ns9ppJRlOmEst7lMab9TI7BJp3oCIH6uRmctbme42Rw8XgDFdltxqkxmjB8d+cDC
 Q0INhNJN1jRgz6rT6lkxVhAYKtaP5T8qZeliT4MO1E59ggOVSSf8zuhjrEMUK397
 Tu/k7fmATtiKSG+blwYZVRC3+ixh/oKZsvfwZ4O+mFJyhQ616nKMYAywoaZcM8WT
 Z1ABipUDwsE=
 =H5KS
 -----END PGP SIGNATURE-----

Merge tag 'iio-fixes-for-4.11e' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

Jonathan writes:

Fifth set of IIO fixes for the 4.11 cycle.

As these are rather late in the cycle, they may sneak over into 4.12.
There is a fix for a regression caused by another fix (hid sensors
hardware seems to vary a lot in how various corner cases are handled).

* ad7303
  - fix channel description. Numeric values were being passed as characters
  presumably leading to garbage from the userspace interface.
* as3935
  - the write data macro was wrong so fix it.
* bmp280
  - incorrect handling of negative values as being unsigned broke humidity
  calculation.
* hid-sensor
  - Restore the poll and hysteresis values after resume as some hardware
  doesn't do it.
* stm32-trigger
  - buglet in reading the sampling frequency
2017-04-18 19:38:38 +02:00
Greg Kroah-Hartman
f78a8236c6 Merge 4.11-rc6 into staging-next
We want the staging and iio fixes in here to handle merging easier.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-04-10 15:21:55 +02:00
Srinivas Pandruvada
5d9854eaea iio: hid-sensor: Store restore poll and hysteresis on S3
This change undo the change done by 'commit 3bec247474
("iio: hid-sensor-trigger: Change get poll value function order to avoid
sensor properties losing after resume from S3")' as this breaks some
USB/i2c sensor hubs.

Instead of relying on HW for restoring poll and hysteresis, driver stores
and restores on resume (S3). In this way user space modified settings are
not lost for any kind of sensor hub behavior.

In this change, whenever user space modifies sampling frequency or
hysteresis driver will get the feature value from the hub and store in the
per device hid_sensor_common data structure. On resume callback from S3,
system will set the feature to sensor hub, if user space ever modified the
feature value.

Fixes: 3bec247474 ("iio: hid-sensor-trigger: Change get poll value function order to avoid sensor properties losing after resume from S3")
Reported-by: Ritesh Raj Sarraf <rrs@researchut.com>
Tested-by: Ritesh Raj Sarraf <rrs@researchut.com>
Tested-by: Song, Hongyan <hongyan.song@intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-04-08 15:13:36 +01:00
Song Hongyan
bba6d9e47f iio: hid-sensor-attributes: Fix sensor property setting failure.
When system bootup without get sensor property, set sensor
property will be fail.

If no get_feature operation done before set_feature, the sensor
properties will all be the initialized value, which is not the
same with sensor real properties. When set sensor property it will
write back to sensor the changed perperty data combines with other
sensor properties data, it is not right and may be dangerous.

In order to get all sensor properties, choose to read one of the sensor
properties(no matter read any sensor peroperty, driver will get all
the peroperties and return the requested one).

Fixes: 73c6768b71 ("iio: hid-sensors: Common attribute and trigger")
Signed-off-by: Song Hongyan <hongyan.song@intel.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-04-02 11:44:03 +01:00
Song Hongyan
d7ed89d5aa iio: hid: Add humidity sensor support
Environmental humidity sensor is a hid defined sensor,
it shows raw humidity measurement of air.

More information can be found in:
http://www.usb.org/developers/hidpage/HUTRR39b.pdf

According to IIO ABI definition, humidityrelative data output unit is
milli percent. Add the unit convert from percent to milli percent.

Signed-off-by: Song Hongyan <hongyan.song@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-25 16:32:24 +00:00
Song Hongyan
e0ad9b73e8 iio: hid-sensor-attributes: Fix gravity sensor scale value not right issue
Scale value include two parts: unit conversion and exponent conversion.
Add gravity unit convert table to fix gravity sensor scale value not
right issue.

Signed-off-by: Song Hongyan <hongyan.song@intel.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-25 16:25:11 +00:00
Song Hongyan
59d0f2da35 iio: hid: Add temperature sensor support
Environmental temperature sensor is a hid defined sensor,
it measures temperature.

More information can be found in:
http://www.usb.org/developers/hidpage/HUTRR39b.pdf

According to IIO ABI definition, IIO_TEMP data output unit is
milli degrees Celsius. Add the unit convert from degree to milli degree.

Signed-off-by: Song Hongyan <hongyan.song@intel.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-04 18:45:26 +00:00
Srinivas Pandruvada
a96cd0f901 iio: accel: hid-sensor-accel-3d: Add timestamp
Added timestamp channel. With this change, each sample has a timestamp.
This timestamp can be from the sensor hub when present or local kernel
timestamp. HID sensors can send timestamp with input data using usage id
HID_USAGE_SENSOR_TIME_TIMESTAMP. This timestamp value is converted to
nano seconds before pushing this sample to the iio core.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-12-03 10:06:13 +00:00
Greg Kroah-Hartman
ce0347c2b0 Merge 4.9-rc5 into staging-next
We want the staging/iio fixes in here as well to resolve issues and
merge problems.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-11-14 08:53:56 +01:00
Song Hongyan
6f77199e9e iio: hid-sensors: Increase the precision of scale to fix wrong reading interpretation.
While testing, it was observed that on some platforms the scale value
from iio sysfs for gyroscope is always 0 (E.g. Yoga 260). This results
in the final angular velocity component values to be zeros.

This is caused by insufficient precision of scale value displayed in sysfs.
If the precision is changed to nano from current micro, then this is
sufficient to display the scale value on this platform.
Since this can be a problem for all other HID sensors, increase scale
precision of all HID sensors to nano from current micro.

Results on Yoga 260:

name		scale before	scale now
--------------------------------------------
gyro_3d		0.000000	0.000000174
als			0.001000	0.001000000
magn_3d		0.000001	0.000001000
accel_3d		0.000009	0.000009806

Signed-off-by: Song Hongyan <hongyan.song@intel.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-11-05 17:50:56 +00:00
Song Hongyan
ab54163190 iio: hid-sensor-attributes: Check sample_frequency/hysteresis write data legitimacy
Neither sample frequency value nor hysteresis value can be set to be a
negative number, check and return "Invalid argument" if they are negative.

If not do this change, sample_frequency will be set into some unknown
value, read hysteresis value after write negative number will return
"Invalid argument".

Signed-off-by: Song Hongyan <hongyan.song@intel.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-11-05 16:25:33 +00:00
Kweh, Hock Leong
36afb176d3 iio: fix pressure data output unit in hid-sensor-attributes
According to IIO ABI definition, IIO_PRESSURE data output unit is
kilopascal:
http://lxr.free-electrons.com/source/Documentation/ABI/testing/sysfs-bus-iio

This patch fix output unit of HID pressure sensor IIO driver from pascal to
kilopascal to follow IIO ABI definition.

Signed-off-by: Kweh, Hock Leong <hock.leong.kweh@intel.com>
Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-09-03 17:09:58 +01:00
Srinivas Pandruvada
3950e03389 HID: hid-sensor-hub: Enhance feature report set API
Current API only allows setting one offset in the field. This API
is extended to set multiple offsets in the field report.
Also update parameters in the users of this API.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Reviewed-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2015-02-23 15:20:00 +01:00
Srinivas Pandruvada
6adc83fca7 HID: hid-sensor-hub: Enhance get feature report API
Some hid sensor feature report can contain more than one reports.
This API can now support receiving multiple values from the feature
report.
Also update the parameters in the users of this API.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2015-02-23 15:19:49 +01:00
Daniel Baluta
fb123a6b6b iio: hid-sensors: make hid_sensor_get_reporting_interval static
This fixes the following sparse warning:

  CHECK   drivers/iio/common/hid-sensors/hid-sensor-attributes.c
drivers/iio/common/hid-sensors/hid-sensor-attributes.c:346:5: warning:
symbol 'hid_sensor_get_reporting_interval' was not declared. Should it be static?

Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-07-07 13:29:49 +01:00
Sachin Kamat
a034234277 iio: hid-sensors: Fix compilation warning
Move the 'static' keyword to beginning of definition to silence the
following compilation warning:
drivers/iio/common/hid-sensors/hid-sensor-attributes.c:34:1: warning: ‘static’ is not at beginning of declaration [-Wold-style-declaration]

Signed-off-by: Sachin Kamat <sachin.kamat@samsung.com>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-07-05 11:21:09 +01:00
Archana Patni
3e729974d6 iio: hid-sensors: Set default unit of measure for report interval
For PROP_REPORT_INTERVAL, the spec does not mandate the presence
of the report interval unit in the feature report and expects the
default unit of measure to be used as milliseconds.

Currently, when the unit is not present, it gets set as zero leading
to issues in sampling frequency.

This patch sets the unit of measure to the default unit if it
is not defined by firmware.

Signed-off-by: Archana Patni <archana.patni@intel.com>
Signed-off-by: Subramony Sesha <subramony.sesha@intel.com>
Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-05-10 11:45:02 +01:00
Dan Carpenter
bf7f5204ab iio: hid-sensors: typo leads to potential forever loop
The "i < " was missing in this condition.

Fixes: 5d02edfc39 ('iio: hid-sensors: Convert units and exponent')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-05-10 11:38:10 +01:00
Srinivas Pandruvada
9030924510 iio: hid-sensors: Add api to get poll value
Added interface to get poll value in milli-seconds. This value is
changed by changing sampling frequency. This API allows clients
to wait for at least some poll milli seconds before reading a new sample.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-05-05 10:59:45 +01:00
Srinivas Pandruvada
5d02edfc39 iio: hid-sensors: Convert units and exponent
HID sensor hub specify a default unit and alternative units. This
along with unit exponent can be used adjust scale. This change
change HID sensor data units to IIO defined units for each
sensor type. So in this way user space can use a simply use:
"(data + offset) * scale" to get final result.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-05-05 10:59:44 +01:00
Alexander Holler
e07c6d170c hid: iio: rename struct hid_sensor_iio_common to hid_sensor_common
The structure with common attributes for hid-sensors isn't specific
to the iio-subsystem, so rename it to hid_sensor_common.

Signed-off-by: Alexander Holler <holler@ahsoftware.de>
Acked-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-01-06 11:48:11 +00:00
Alexander Holler
2974cdf293 iio: merge hid-sensor-attributes.h into hid-sensor-hub.h
The stuff in hid-sensor-attributes.h is needed by every piece which
uses hid-sensor-hub and merging it into hid-sensor-hub.h makes it accessible
from outside the iio subdirectory.

Signed-off-by: Alexander Holler <holler@ahsoftware.de>
Acked-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-01-06 11:43:37 +00:00
srinivas pandruvada
73c6768b71 iio: hid-sensors: Common attribute and trigger
This patch contains the common code, which is used by all HID sensors.
There are some common set of attributes, which every hid sensor
needs it. This patch contains all such attributes processing.
Also the trigger interface is common among all HID sensors. This
patch contains common trigger functions utilized by all HID sensors.

Signed-off-by: srinivas pandruvada <srinivas.pandruvada@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-06 19:20:11 +01:00