Skip to content

Commit 2e455c2

Browse files
author
Jiri Kosina
committed
Merge branch 'for-4.1/sensor-hub' into for-linus
Conflicts: drivers/iio/common/hid-sensors/hid-sensor-trigger.c include/linux/hid-sensor-hub.h
2 parents 05f6d02 + b2eafd7 commit 2e455c2

File tree

17 files changed

+1154
-110
lines changed

17 files changed

+1154
-110
lines changed

Documentation/hid/hid-sensor.txt

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,87 @@ accelerometer wants to poll X axis value, then it can call this function with
138138
the usage id of X axis. HID sensors can provide events, so this is not necessary
139139
to poll for any field. If there is some new sample, the core driver will call
140140
registered callback function to process the sample.
141+
142+
143+
----------
144+
145+
HID Custom and generic Sensors
146+
147+
HID Sensor specification defines two special sensor usage types. Since they
148+
don't represent a standard sensor, it is not possible to define using Linux IIO
149+
type interfaces.
150+
The purpose of these sensors is to extend the functionality or provide a
151+
way to obfuscate the data being communicated by a sensor. Without knowing the
152+
mapping between the data and its encapsulated form, it is difficult for
153+
an application/driver to determine what data is being communicated by the sensor.
154+
This allows some differentiating use cases, where vendor can provide applications.
155+
Some common use cases are debug other sensors or to provide some events like
156+
keyboard attached/detached or lid open/close.
157+
158+
To allow application to utilize these sensors, here they are exported uses sysfs
159+
attribute groups, attributes and misc device interface.
160+
161+
An example of this representation on sysfs:
162+
/sys/devices/pci0000:00/INT33C2:00/i2c-0/i2c-INT33D1:00/0018:8086:09FA.0001/HID-SENSOR-2000e1.6.auto$ tree -R
163+
.
164+
????????? enable_sensor
165+
????????? feature-0-200316
166+
??????? ????????? feature-0-200316-maximum
167+
??????? ????????? feature-0-200316-minimum
168+
??????? ????????? feature-0-200316-name
169+
??????? ????????? feature-0-200316-size
170+
??????? ????????? feature-0-200316-unit-expo
171+
??????? ????????? feature-0-200316-units
172+
??????? ????????? feature-0-200316-value
173+
????????? feature-1-200201
174+
??????? ????????? feature-1-200201-maximum
175+
??????? ????????? feature-1-200201-minimum
176+
??????? ????????? feature-1-200201-name
177+
??????? ????????? feature-1-200201-size
178+
??????? ????????? feature-1-200201-unit-expo
179+
??????? ????????? feature-1-200201-units
180+
??????? ????????? feature-1-200201-value
181+
????????? input-0-200201
182+
??????? ????????? input-0-200201-maximum
183+
??????? ????????? input-0-200201-minimum
184+
??????? ????????? input-0-200201-name
185+
??????? ????????? input-0-200201-size
186+
??????? ????????? input-0-200201-unit-expo
187+
??????? ????????? input-0-200201-units
188+
??????? ????????? input-0-200201-value
189+
????????? input-1-200202
190+
??????? ????????? input-1-200202-maximum
191+
??????? ????????? input-1-200202-minimum
192+
??????? ????????? input-1-200202-name
193+
??????? ????????? input-1-200202-size
194+
??????? ????????? input-1-200202-unit-expo
195+
??????? ????????? input-1-200202-units
196+
??????? ????????? input-1-200202-value
197+
198+
Here there is a custom sensors with four fields, two feature and two inputs.
199+
Each field is represented by a set of attributes. All fields except the "value"
200+
are read only. The value field is a RW field.
201+
Example
202+
/sys/bus/platform/devices/HID-SENSOR-2000e1.6.auto/feature-0-200316$ grep -r . *
203+
feature-0-200316-maximum:6
204+
feature-0-200316-minimum:0
205+
feature-0-200316-name:property-reporting-state
206+
feature-0-200316-size:1
207+
feature-0-200316-unit-expo:0
208+
feature-0-200316-units:25
209+
feature-0-200316-value:1
210+
211+
How to enable such sensor?
212+
By default sensor can be power gated. To enable sysfs attribute "enable" can be
213+
used.
214+
$ echo 1 > enable_sensor
215+
216+
Once enabled and powered on, sensor can report value using HID reports.
217+
These reports are pushed using misc device interface in a FIFO order.
218+
/dev$ tree | grep HID-SENSOR-2000e1.6.auto
219+
??????? ????????? 10:53 -> ../HID-SENSOR-2000e1.6.auto
220+
????????? HID-SENSOR-2000e1.6.auto
221+
222+
Each reports can be of variable length preceded by a header. This header
223+
consist of a 32 bit usage id, 64 bit time stamp and 32 bit length field of raw
224+
data.

drivers/hid/Kconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,21 @@ config HID_SENSOR_HUB
878878
for events and handle data streams. Each sensor driver can format
879879
data and present to user mode using input or IIO interface.
880880

881+
config HID_SENSOR_CUSTOM_SENSOR
882+
tristate "HID Sensors hub custom sensor support"
883+
depends on HID_SENSOR_HUB
884+
default n
885+
---help---
886+
HID Sensor hub specification allows definition of some custom and
887+
generic sensors. Unlike other HID sensors, they can't be exported
888+
via Linux IIO because of custom fields. This is up to the manufacturer
889+
to decide how to interpret these special sensor ids and process in
890+
the user space. Currently some manufacturers are using these ids for
891+
sensor calibration and debugging other sensors. Manufacturers
892+
should't use these special custom sensor ids to export any of the
893+
standard sensors.
894+
Select this config option for custom/generic sensor support.
895+
881896
endmenu
882897

883898
endif # HID

drivers/hid/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ obj-$(CONFIG_HID_WACOM) += wacom.o
100100
obj-$(CONFIG_HID_WALTOP) += hid-waltop.o
101101
obj-$(CONFIG_HID_WIIMOTE) += hid-wiimote.o
102102
obj-$(CONFIG_HID_SENSOR_HUB) += hid-sensor-hub.o
103+
obj-$(CONFIG_HID_SENSOR_CUSTOM_SENSOR) += hid-sensor-custom.o
103104

104105
obj-$(CONFIG_USB_HID) += usbhid/
105106
obj-$(CONFIG_USB_MOUSE) += usbhid/

0 commit comments

Comments
 (0)