* [PATCH v3 1/8] iio: hid_Sensors: fix crash during trigger unregister
@ 2013-10-30 22:48 Srinivas Pandruvada
2013-10-30 22:48 ` [PATCH v3 2/8] iio: hid-sensors: accelerometer: Add sensitivity Srinivas Pandruvada
` (7 more replies)
0 siblings, 8 replies; 17+ messages in thread
From: Srinivas Pandruvada @ 2013-10-30 22:48 UTC (permalink / raw)
To: jic23; +Cc: linux-iio, Srinivas Pandruvada
We can't store the trigger instance created by iio_trigger_alloc, in
trig field of iio_device structure. This needs to be stored in the
driver private data. Othewise it can result in crash during module
unload. Hence created a trig_ptr in the common data structure
for each HID sensor IIO driver and storing here.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/iio/accel/hid-sensor-accel-3d.c | 5 +++--
drivers/iio/common/hid-sensors/hid-sensor-trigger.c | 9 ++++-----
drivers/iio/common/hid-sensors/hid-sensor-trigger.h | 2 +-
drivers/iio/gyro/hid-sensor-gyro-3d.c | 5 +++--
drivers/iio/light/hid-sensor-als.c | 5 +++--
drivers/iio/magnetometer/hid-sensor-magn-3d.c | 5 +++--
include/linux/hid-sensor-hub.h | 3 +++
7 files changed, 20 insertions(+), 14 deletions(-)
diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c
index 46d22f3..7fbe136 100644
--- a/drivers/iio/accel/hid-sensor-accel-3d.c
+++ b/drivers/iio/accel/hid-sensor-accel-3d.c
@@ -349,7 +349,7 @@ static int hid_accel_3d_probe(struct platform_device *pdev)
error_iio_unreg:
iio_device_unregister(indio_dev);
error_remove_trigger:
- hid_sensor_remove_trigger(indio_dev);
+ hid_sensor_remove_trigger(&accel_state->common_attributes);
error_unreg_buffer_funcs:
iio_triggered_buffer_cleanup(indio_dev);
error_free_dev_mem:
@@ -362,10 +362,11 @@ static int hid_accel_3d_remove(struct platform_device *pdev)
{
struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
struct iio_dev *indio_dev = platform_get_drvdata(pdev);
+ struct accel_3d_state *accel_state = iio_priv(indio_dev);
sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_ACCEL_3D);
iio_device_unregister(indio_dev);
- hid_sensor_remove_trigger(indio_dev);
+ hid_sensor_remove_trigger(&accel_state->common_attributes);
iio_triggered_buffer_cleanup(indio_dev);
kfree(indio_dev->channels);
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
index dbc9141..363f8d2 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
+++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
@@ -71,11 +71,10 @@ static int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig,
return 0;
}
-void hid_sensor_remove_trigger(struct iio_dev *indio_dev)
+void hid_sensor_remove_trigger(struct hid_sensor_common *attrb)
{
- iio_trigger_unregister(indio_dev->trig);
- iio_trigger_free(indio_dev->trig);
- indio_dev->trig = NULL;
+ iio_trigger_unregister(attrb->trigger);
+ iio_trigger_free(attrb->trigger);
}
EXPORT_SYMBOL(hid_sensor_remove_trigger);
@@ -106,7 +105,7 @@ int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name,
dev_err(&indio_dev->dev, "Trigger Register Failed\n");
goto error_free_trig;
}
- indio_dev->trig = trig;
+ indio_dev->trig = attrb->trigger = trig;
return ret;
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.h b/drivers/iio/common/hid-sensors/hid-sensor-trigger.h
index 9a87314..ca02f78 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.h
+++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.h
@@ -21,6 +21,6 @@
int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name,
struct hid_sensor_common *attrb);
-void hid_sensor_remove_trigger(struct iio_dev *indio_dev);
+void hid_sensor_remove_trigger(struct hid_sensor_common *attrb);
#endif
diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c
index c688d97..74bbed7 100644
--- a/drivers/iio/gyro/hid-sensor-gyro-3d.c
+++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c
@@ -347,7 +347,7 @@ static int hid_gyro_3d_probe(struct platform_device *pdev)
error_iio_unreg:
iio_device_unregister(indio_dev);
error_remove_trigger:
- hid_sensor_remove_trigger(indio_dev);
+ hid_sensor_remove_trigger(&gyro_state->common_attributes);
error_unreg_buffer_funcs:
iio_triggered_buffer_cleanup(indio_dev);
error_free_dev_mem:
@@ -360,10 +360,11 @@ static int hid_gyro_3d_remove(struct platform_device *pdev)
{
struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
struct iio_dev *indio_dev = platform_get_drvdata(pdev);
+ struct gyro_3d_state *gyro_state = iio_priv(indio_dev);
sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_GYRO_3D);
iio_device_unregister(indio_dev);
- hid_sensor_remove_trigger(indio_dev);
+ hid_sensor_remove_trigger(&gyro_state->common_attributes);
iio_triggered_buffer_cleanup(indio_dev);
kfree(indio_dev->channels);
diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c
index e59d00c..c104bda 100644
--- a/drivers/iio/light/hid-sensor-als.c
+++ b/drivers/iio/light/hid-sensor-als.c
@@ -313,7 +313,7 @@ static int hid_als_probe(struct platform_device *pdev)
error_iio_unreg:
iio_device_unregister(indio_dev);
error_remove_trigger:
- hid_sensor_remove_trigger(indio_dev);
+ hid_sensor_remove_trigger(&als_state->common_attributes);
error_unreg_buffer_funcs:
iio_triggered_buffer_cleanup(indio_dev);
error_free_dev_mem:
@@ -326,10 +326,11 @@ static int hid_als_remove(struct platform_device *pdev)
{
struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
struct iio_dev *indio_dev = platform_get_drvdata(pdev);
+ struct als_state *als_state = iio_priv(indio_dev);
sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_ALS);
iio_device_unregister(indio_dev);
- hid_sensor_remove_trigger(indio_dev);
+ hid_sensor_remove_trigger(&als_state->common_attributes);
iio_triggered_buffer_cleanup(indio_dev);
kfree(indio_dev->channels);
diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
index a98460b..ff7b9da 100644
--- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c
+++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
@@ -350,7 +350,7 @@ static int hid_magn_3d_probe(struct platform_device *pdev)
error_iio_unreg:
iio_device_unregister(indio_dev);
error_remove_trigger:
- hid_sensor_remove_trigger(indio_dev);
+ hid_sensor_remove_trigger(&magn_state->common_attributes);
error_unreg_buffer_funcs:
iio_triggered_buffer_cleanup(indio_dev);
error_free_dev_mem:
@@ -363,10 +363,11 @@ static int hid_magn_3d_remove(struct platform_device *pdev)
{
struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
struct iio_dev *indio_dev = platform_get_drvdata(pdev);
+ struct magn_3d_state *magn_state = iio_priv(indio_dev);
sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_COMPASS_3D);
iio_device_unregister(indio_dev);
- hid_sensor_remove_trigger(indio_dev);
+ hid_sensor_remove_trigger(&magn_state->common_attributes);
iio_triggered_buffer_cleanup(indio_dev);
kfree(indio_dev->channels);
diff --git a/include/linux/hid-sensor-hub.h b/include/linux/hid-sensor-hub.h
index a265af2..206a2af 100644
--- a/include/linux/hid-sensor-hub.h
+++ b/include/linux/hid-sensor-hub.h
@@ -21,6 +21,8 @@
#include <linux/hid.h>
#include <linux/hid-sensor-ids.h>
+#include <linux/iio/iio.h>
+#include <linux/iio/trigger.h>
/**
* struct hid_sensor_hub_attribute_info - Attribute info
@@ -184,6 +186,7 @@ struct hid_sensor_common {
struct platform_device *pdev;
unsigned usage_id;
bool data_ready;
+ struct iio_trigger *trigger;
struct hid_sensor_hub_attribute_info poll;
struct hid_sensor_hub_attribute_info report_state;
struct hid_sensor_hub_attribute_info power_state;
--
1.8.3.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v3 2/8] iio: hid-sensors: accelerometer: Add sensitivity
2013-10-30 22:48 [PATCH v3 1/8] iio: hid_Sensors: fix crash during trigger unregister Srinivas Pandruvada
@ 2013-10-30 22:48 ` Srinivas Pandruvada
2013-11-05 23:04 ` Jonathan Cameron
2013-10-30 22:48 ` [PATCH v3 3/8] iio: hid-sensors: gyro : " Srinivas Pandruvada
` (6 subsequent siblings)
7 siblings, 1 reply; 17+ messages in thread
From: Srinivas Pandruvada @ 2013-10-30 22:48 UTC (permalink / raw)
To: jic23; +Cc: linux-iio, Srinivas Pandruvada
A number of Properties that can be applied to Data Fields are per data
field basis or for all data fields. Adding sensitivity field for all
accelerometer fields, which is most commonly used in currently
available sensor hubs.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/iio/accel/hid-sensor-accel-3d.c | 12 ++++++++++++
include/linux/hid-sensor-ids.h | 1 +
2 files changed, 13 insertions(+)
diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c
index 7fbe136..b89ba92 100644
--- a/drivers/iio/accel/hid-sensor-accel-3d.c
+++ b/drivers/iio/accel/hid-sensor-accel-3d.c
@@ -261,6 +261,18 @@ static int accel_3d_parse_report(struct platform_device *pdev,
st->accel[1].index, st->accel[1].report_id,
st->accel[2].index, st->accel[2].report_id);
+ /* Set Sensitivity field ids, when there is no individual modifier */
+ if (st->common_attributes.sensitivity.index < 0) {
+ sensor_hub_input_get_attribute_info(hsdev,
+ HID_FEATURE_REPORT, usage_id,
+ HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
+ HID_USAGE_SENSOR_DATA_ACCELERATION,
+ &st->common_attributes.sensitivity);
+ dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n",
+ st->common_attributes.sensitivity.index,
+ st->common_attributes.sensitivity.report_id);
+ }
+
return ret;
}
diff --git a/include/linux/hid-sensor-ids.h b/include/linux/hid-sensor-ids.h
index 8323775..bd97d60 100644
--- a/include/linux/hid-sensor-ids.h
+++ b/include/linux/hid-sensor-ids.h
@@ -23,6 +23,7 @@
/* Accel 3D (200073) */
#define HID_USAGE_SENSOR_ACCEL_3D 0x200073
+#define HID_USAGE_SENSOR_DATA_ACCELERATION 0x200452
#define HID_USAGE_SENSOR_ACCEL_X_AXIS 0x200453
#define HID_USAGE_SENSOR_ACCEL_Y_AXIS 0x200454
#define HID_USAGE_SENSOR_ACCEL_Z_AXIS 0x200455
--
1.8.3.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v3 3/8] iio: hid-sensors: gyro : Add sensitivity
2013-10-30 22:48 [PATCH v3 1/8] iio: hid_Sensors: fix crash during trigger unregister Srinivas Pandruvada
2013-10-30 22:48 ` [PATCH v3 2/8] iio: hid-sensors: accelerometer: Add sensitivity Srinivas Pandruvada
@ 2013-10-30 22:48 ` Srinivas Pandruvada
2013-11-05 23:05 ` Jonathan Cameron
2013-10-30 22:48 ` [PATCH v3 4/8] iio: hid-sensors: light/als " Srinivas Pandruvada
` (5 subsequent siblings)
7 siblings, 1 reply; 17+ messages in thread
From: Srinivas Pandruvada @ 2013-10-30 22:48 UTC (permalink / raw)
To: jic23; +Cc: linux-iio, Srinivas Pandruvada
A number of Properties that can be applied to Data Fields are per data
field basis or for all data fields. Adding sensitivity field for all
gyro fields, which is most commonly used in currently available
sensor hubs.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/iio/gyro/hid-sensor-gyro-3d.c | 11 +++++++++++
include/linux/hid-sensor-ids.h | 1 +
2 files changed, 12 insertions(+)
diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c
index 74bbed7..d665ec3 100644
--- a/drivers/iio/gyro/hid-sensor-gyro-3d.c
+++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c
@@ -261,6 +261,17 @@ static int gyro_3d_parse_report(struct platform_device *pdev,
st->gyro[1].index, st->gyro[1].report_id,
st->gyro[2].index, st->gyro[2].report_id);
+ /* Set Sensitivity field ids, when there is no individual modifier */
+ if (st->common_attributes.sensitivity.index < 0) {
+ sensor_hub_input_get_attribute_info(hsdev,
+ HID_FEATURE_REPORT, usage_id,
+ HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
+ HID_USAGE_SENSOR_DATA_ANGL_VELOCITY,
+ &st->common_attributes.sensitivity);
+ dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n",
+ st->common_attributes.sensitivity.index,
+ st->common_attributes.sensitivity.report_id);
+ }
return ret;
}
diff --git a/include/linux/hid-sensor-ids.h b/include/linux/hid-sensor-ids.h
index bd97d60..6473d93 100644
--- a/include/linux/hid-sensor-ids.h
+++ b/include/linux/hid-sensor-ids.h
@@ -34,6 +34,7 @@
/* Gyro 3D: (200076) */
#define HID_USAGE_SENSOR_GYRO_3D 0x200076
+#define HID_USAGE_SENSOR_DATA_ANGL_VELOCITY 0x200456
#define HID_USAGE_SENSOR_ANGL_VELOCITY_X_AXIS 0x200457
#define HID_USAGE_SENSOR_ANGL_VELOCITY_Y_AXIS 0x200458
#define HID_USAGE_SENSOR_ANGL_VELOCITY_Z_AXIS 0x200459
--
1.8.3.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v3 4/8] iio: hid-sensors: light/als : Add sensitivity
2013-10-30 22:48 [PATCH v3 1/8] iio: hid_Sensors: fix crash during trigger unregister Srinivas Pandruvada
2013-10-30 22:48 ` [PATCH v3 2/8] iio: hid-sensors: accelerometer: Add sensitivity Srinivas Pandruvada
2013-10-30 22:48 ` [PATCH v3 3/8] iio: hid-sensors: gyro : " Srinivas Pandruvada
@ 2013-10-30 22:48 ` Srinivas Pandruvada
2013-10-30 22:48 ` [PATCH v3 5/8] iio: hid-sensors: magnetometer " Srinivas Pandruvada
` (4 subsequent siblings)
7 siblings, 0 replies; 17+ messages in thread
From: Srinivas Pandruvada @ 2013-10-30 22:48 UTC (permalink / raw)
To: jic23; +Cc: linux-iio, Srinivas Pandruvada
A number of Properties that can be applied to Data Fields are per data
field basis or for all data fields. Adding sensitivity field for all
als fields, which is most commonly used in currently available
sensor hubs.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/iio/light/hid-sensor-als.c | 11 +++++++++++
include/linux/hid-sensor-ids.h | 1 +
2 files changed, 12 insertions(+)
diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c
index c104bda..b518488 100644
--- a/drivers/iio/light/hid-sensor-als.c
+++ b/drivers/iio/light/hid-sensor-als.c
@@ -228,6 +228,17 @@ static int als_parse_report(struct platform_device *pdev,
dev_dbg(&pdev->dev, "als %x:%x\n", st->als_illum.index,
st->als_illum.report_id);
+ /* Set Sensitivity field ids, when there is no individual modifier */
+ if (st->common_attributes.sensitivity.index < 0) {
+ sensor_hub_input_get_attribute_info(hsdev,
+ HID_FEATURE_REPORT, usage_id,
+ HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
+ HID_USAGE_SENSOR_DATA_LIGHT,
+ &st->common_attributes.sensitivity);
+ dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n",
+ st->common_attributes.sensitivity.index,
+ st->common_attributes.sensitivity.report_id);
+ }
return ret;
}
diff --git a/include/linux/hid-sensor-ids.h b/include/linux/hid-sensor-ids.h
index 6473d93..c7d62c7 100644
--- a/include/linux/hid-sensor-ids.h
+++ b/include/linux/hid-sensor-ids.h
@@ -30,6 +30,7 @@
/* ALS (200041) */
#define HID_USAGE_SENSOR_ALS 0x200041
+#define HID_USAGE_SENSOR_DATA_LIGHT 0x2004d0
#define HID_USAGE_SENSOR_LIGHT_ILLUM 0x2004d1
/* Gyro 3D: (200076) */
--
1.8.3.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v3 5/8] iio: hid-sensors: magnetometer : Add sensitivity
2013-10-30 22:48 [PATCH v3 1/8] iio: hid_Sensors: fix crash during trigger unregister Srinivas Pandruvada
` (2 preceding siblings ...)
2013-10-30 22:48 ` [PATCH v3 4/8] iio: hid-sensors: light/als " Srinivas Pandruvada
@ 2013-10-30 22:48 ` Srinivas Pandruvada
2013-11-05 23:06 ` Jonathan Cameron
2013-10-30 22:48 ` [PATCH v3 6/8] iio: hid-sensors: Added Inclinometer 3D Srinivas Pandruvada
` (3 subsequent siblings)
7 siblings, 1 reply; 17+ messages in thread
From: Srinivas Pandruvada @ 2013-10-30 22:48 UTC (permalink / raw)
To: jic23; +Cc: linux-iio, Srinivas Pandruvada
A number of Properties that can be applied to Data Fields are per data
field basis or for all data fields. Adding sensitivity field for all
magnetometer fields, which is most commonly used in currently available
sensor hubs.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/iio/magnetometer/hid-sensor-magn-3d.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
index ff7b9da..db9f27b 100644
--- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c
+++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
@@ -262,6 +262,18 @@ static int magn_3d_parse_report(struct platform_device *pdev,
st->magn[1].index, st->magn[1].report_id,
st->magn[2].index, st->magn[2].report_id);
+ /* Set Sensitivity field ids, when there is no individual modifier */
+ if (st->common_attributes.sensitivity.index < 0) {
+ sensor_hub_input_get_attribute_info(hsdev,
+ HID_FEATURE_REPORT, usage_id,
+ HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
+ HID_USAGE_SENSOR_DATA_ORIENTATION,
+ &st->common_attributes.sensitivity);
+ dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n",
+ st->common_attributes.sensitivity.index,
+ st->common_attributes.sensitivity.report_id);
+ }
+
return ret;
}
--
1.8.3.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v3 6/8] iio: hid-sensors: Added Inclinometer 3D
2013-10-30 22:48 [PATCH v3 1/8] iio: hid_Sensors: fix crash during trigger unregister Srinivas Pandruvada
` (3 preceding siblings ...)
2013-10-30 22:48 ` [PATCH v3 5/8] iio: hid-sensors: magnetometer " Srinivas Pandruvada
@ 2013-10-30 22:48 ` Srinivas Pandruvada
2013-10-30 22:48 ` [PATCH v3 7/8] iio: Add quaternion channel Srinivas Pandruvada
` (2 subsequent siblings)
7 siblings, 0 replies; 17+ messages in thread
From: Srinivas Pandruvada @ 2013-10-30 22:48 UTC (permalink / raw)
To: jic23; +Cc: linux-iio, Srinivas Pandruvada
Added usage id processing for Inclinometer 3D. This uses IIO
interfaces for triggered buffer to present data to user
mode.This uses HID sensor framework for registering callback
events from the sensor hub.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/iio/Kconfig | 1 +
drivers/iio/Makefile | 1 +
drivers/iio/orientation/Kconfig | 19 ++
drivers/iio/orientation/Makefile | 6 +
drivers/iio/orientation/hid-sensor-incl-3d.c | 428 +++++++++++++++++++++++++++
include/linux/hid-sensor-ids.h | 9 +
6 files changed, 464 insertions(+)
create mode 100644 drivers/iio/orientation/Kconfig
create mode 100644 drivers/iio/orientation/Makefile
create mode 100644 drivers/iio/orientation/hid-sensor-incl-3d.c
diff --git a/drivers/iio/Kconfig b/drivers/iio/Kconfig
index 90cf0cd..73ff5bb 100644
--- a/drivers/iio/Kconfig
+++ b/drivers/iio/Kconfig
@@ -68,6 +68,7 @@ source "drivers/iio/gyro/Kconfig"
source "drivers/iio/imu/Kconfig"
source "drivers/iio/light/Kconfig"
source "drivers/iio/magnetometer/Kconfig"
+source "drivers/iio/orientation/Kconfig"
if IIO_TRIGGER
source "drivers/iio/trigger/Kconfig"
endif #IIO_TRIGGER
diff --git a/drivers/iio/Makefile b/drivers/iio/Makefile
index bcf7e9e..c682e1b 100644
--- a/drivers/iio/Makefile
+++ b/drivers/iio/Makefile
@@ -21,6 +21,7 @@ obj-y += frequency/
obj-y += imu/
obj-y += light/
obj-y += magnetometer/
+obj-y += orientation/
obj-y += pressure/
obj-y += temperature/
obj-y += trigger/
diff --git a/drivers/iio/orientation/Kconfig b/drivers/iio/orientation/Kconfig
new file mode 100644
index 0000000..58c62c8
--- /dev/null
+++ b/drivers/iio/orientation/Kconfig
@@ -0,0 +1,19 @@
+#
+# Inclinometer sensors
+#
+# When adding new entries keep the list in alphabetical order
+
+menu "Inclinometer sensors"
+
+config HID_SENSOR_INCLINOMETER_3D
+ depends on HID_SENSOR_HUB
+ select IIO_BUFFER
+ select IIO_TRIGGERED_BUFFER
+ select HID_SENSOR_IIO_COMMON
+ select HID_SENSOR_IIO_TRIGGER
+ tristate "HID Inclinometer 3D"
+ help
+ Say yes here to build support for the HID SENSOR
+ Inclinometer 3D.
+
+endmenu
diff --git a/drivers/iio/orientation/Makefile b/drivers/iio/orientation/Makefile
new file mode 100644
index 0000000..2c97572
--- /dev/null
+++ b/drivers/iio/orientation/Makefile
@@ -0,0 +1,6 @@
+#
+# Makefile for industrial I/O Inclinometer sensor drivers
+#
+
+# When adding new entries keep the list in alphabetical order
+obj-$(CONFIG_HID_SENSOR_INCLINOMETER_3D) += hid-sensor-incl-3d.o
diff --git a/drivers/iio/orientation/hid-sensor-incl-3d.c b/drivers/iio/orientation/hid-sensor-incl-3d.c
new file mode 100644
index 0000000..070feab
--- /dev/null
+++ b/drivers/iio/orientation/hid-sensor-incl-3d.c
@@ -0,0 +1,428 @@
+/*
+ * HID Sensors Driver
+ * Copyright (c) 2013, Intel Corporation.
+ *
+ * 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.
+ *
+ */
+
+#include <linux/device.h>
+#include <linux/platform_device.h>
+#include <linux/module.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/slab.h>
+#include <linux/hid-sensor-hub.h>
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/iio/buffer.h>
+#include <linux/iio/trigger_consumer.h>
+#include <linux/iio/triggered_buffer.h>
+#include "../common/hid-sensors/hid-sensor-trigger.h"
+
+enum incl_3d_channel {
+ CHANNEL_SCAN_INDEX_X,
+ CHANNEL_SCAN_INDEX_Y,
+ CHANNEL_SCAN_INDEX_Z,
+ INCLI_3D_CHANNEL_MAX,
+};
+
+struct incl_3d_state {
+ struct hid_sensor_hub_callbacks callbacks;
+ struct hid_sensor_common common_attributes;
+ struct hid_sensor_hub_attribute_info incl[INCLI_3D_CHANNEL_MAX];
+ u32 incl_val[INCLI_3D_CHANNEL_MAX];
+};
+
+static const u32 incl_3d_addresses[INCLI_3D_CHANNEL_MAX] = {
+ HID_USAGE_SENSOR_ORIENT_TILT_X,
+ HID_USAGE_SENSOR_ORIENT_TILT_Y,
+ HID_USAGE_SENSOR_ORIENT_TILT_Z
+};
+
+/* Channel definitions */
+static const struct iio_chan_spec incl_3d_channels[] = {
+ {
+ .type = IIO_INCLI,
+ .modified = 1,
+ .channel2 = IIO_MOD_X,
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+ .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),
+ .scan_index = CHANNEL_SCAN_INDEX_X,
+ }, {
+ .type = IIO_INCLI,
+ .modified = 1,
+ .channel2 = IIO_MOD_Y,
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+ .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),
+ .scan_index = CHANNEL_SCAN_INDEX_Y,
+ }, {
+ .type = IIO_INCLI,
+ .modified = 1,
+ .channel2 = IIO_MOD_Z,
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+ .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),
+ .scan_index = CHANNEL_SCAN_INDEX_Z,
+ }
+};
+
+/* Adjust channel real bits based on report descriptor */
+static void incl_3d_adjust_channel_bit_mask(struct iio_chan_spec *chan,
+ int size)
+{
+ chan->scan_type.sign = 's';
+ /* Real storage bits will change based on the report desc. */
+ chan->scan_type.realbits = size * 8;
+ /* Maximum size of a sample to capture is u32 */
+ chan->scan_type.storagebits = sizeof(u32) * 8;
+}
+
+/* Channel read_raw handler */
+static int incl_3d_read_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ int *val, int *val2,
+ long mask)
+{
+ struct incl_3d_state *incl_state = iio_priv(indio_dev);
+ int report_id = -1;
+ u32 address;
+ int ret_type;
+
+ *val = 0;
+ *val2 = 0;
+ switch (mask) {
+ case IIO_CHAN_INFO_RAW:
+ report_id =
+ incl_state->incl[chan->scan_index].report_id;
+ address = incl_3d_addresses[chan->scan_index];
+ if (report_id >= 0)
+ *val = sensor_hub_input_attr_get_raw_value(
+ incl_state->common_attributes.hsdev,
+ HID_USAGE_SENSOR_INCLINOMETER_3D, address,
+ report_id);
+ else {
+ return -EINVAL;
+ }
+ ret_type = IIO_VAL_INT;
+ break;
+ case IIO_CHAN_INFO_SCALE:
+ *val = incl_state->incl[CHANNEL_SCAN_INDEX_X].units;
+ ret_type = IIO_VAL_INT;
+ break;
+ case IIO_CHAN_INFO_OFFSET:
+ *val = hid_sensor_convert_exponent(
+ incl_state->incl[CHANNEL_SCAN_INDEX_X].unit_expo);
+ ret_type = IIO_VAL_INT;
+ break;
+ case IIO_CHAN_INFO_SAMP_FREQ:
+ ret_type = hid_sensor_read_samp_freq_value(
+ &incl_state->common_attributes, val, val2);
+ break;
+ case IIO_CHAN_INFO_HYSTERESIS:
+ ret_type = hid_sensor_read_raw_hyst_value(
+ &incl_state->common_attributes, val, val2);
+ break;
+ default:
+ ret_type = -EINVAL;
+ break;
+ }
+
+ return ret_type;
+}
+
+/* Channel write_raw handler */
+static int incl_3d_write_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ int val,
+ int val2,
+ long mask)
+{
+ struct incl_3d_state *incl_state = iio_priv(indio_dev);
+ int ret;
+
+ switch (mask) {
+ case IIO_CHAN_INFO_SAMP_FREQ:
+ ret = hid_sensor_write_samp_freq_value(
+ &incl_state->common_attributes, val, val2);
+ break;
+ case IIO_CHAN_INFO_HYSTERESIS:
+ ret = hid_sensor_write_raw_hyst_value(
+ &incl_state->common_attributes, val, val2);
+ break;
+ default:
+ ret = -EINVAL;
+ }
+
+ return ret;
+}
+
+static const struct iio_info incl_3d_info = {
+ .driver_module = THIS_MODULE,
+ .read_raw = &incl_3d_read_raw,
+ .write_raw = &incl_3d_write_raw,
+};
+
+/* Function to push data to buffer */
+static void hid_sensor_push_data(struct iio_dev *indio_dev, u8 *data, int len)
+{
+ dev_dbg(&indio_dev->dev, "hid_sensor_push_data\n");
+ iio_push_to_buffers(indio_dev, (u8 *)data);
+}
+
+/* Callback handler to send event after all samples are received and captured */
+static int incl_3d_proc_event(struct hid_sensor_hub_device *hsdev,
+ unsigned usage_id,
+ void *priv)
+{
+ struct iio_dev *indio_dev = platform_get_drvdata(priv);
+ struct incl_3d_state *incl_state = iio_priv(indio_dev);
+
+ dev_dbg(&indio_dev->dev, "incl_3d_proc_event [%d]\n",
+ incl_state->common_attributes.data_ready);
+ if (incl_state->common_attributes.data_ready)
+ hid_sensor_push_data(indio_dev,
+ (u8 *)incl_state->incl_val,
+ sizeof(incl_state->incl_val));
+
+ return 0;
+}
+
+/* Capture samples in local storage */
+static int incl_3d_capture_sample(struct hid_sensor_hub_device *hsdev,
+ unsigned usage_id,
+ size_t raw_len, char *raw_data,
+ void *priv)
+{
+ struct iio_dev *indio_dev = platform_get_drvdata(priv);
+ struct incl_3d_state *incl_state = iio_priv(indio_dev);
+ int ret = 0;
+
+ switch (usage_id) {
+ case HID_USAGE_SENSOR_ORIENT_TILT_X:
+ incl_state->incl_val[CHANNEL_SCAN_INDEX_X] = *(u32 *)raw_data;
+ break;
+ case HID_USAGE_SENSOR_ORIENT_TILT_Y:
+ incl_state->incl_val[CHANNEL_SCAN_INDEX_Y] = *(u32 *)raw_data;
+ break;
+ case HID_USAGE_SENSOR_ORIENT_TILT_Z:
+ incl_state->incl_val[CHANNEL_SCAN_INDEX_Z] = *(u32 *)raw_data;
+ break;
+ default:
+ ret = -EINVAL;
+ break;
+ }
+
+ return ret;
+}
+
+/* Parse report which is specific to an usage id*/
+static int incl_3d_parse_report(struct platform_device *pdev,
+ struct hid_sensor_hub_device *hsdev,
+ struct iio_chan_spec *channels,
+ unsigned usage_id,
+ struct incl_3d_state *st)
+{
+ int ret;
+
+ ret = sensor_hub_input_get_attribute_info(hsdev,
+ HID_INPUT_REPORT,
+ usage_id,
+ HID_USAGE_SENSOR_ORIENT_TILT_X,
+ &st->incl[CHANNEL_SCAN_INDEX_X]);
+ if (ret)
+ return ret;
+ incl_3d_adjust_channel_bit_mask(&channels[CHANNEL_SCAN_INDEX_X],
+ st->incl[CHANNEL_SCAN_INDEX_X].size);
+
+ ret = sensor_hub_input_get_attribute_info(hsdev,
+ HID_INPUT_REPORT,
+ usage_id,
+ HID_USAGE_SENSOR_ORIENT_TILT_Y,
+ &st->incl[CHANNEL_SCAN_INDEX_Y]);
+ if (ret)
+ return ret;
+ incl_3d_adjust_channel_bit_mask(&channels[CHANNEL_SCAN_INDEX_Y],
+ st->incl[CHANNEL_SCAN_INDEX_Y].size);
+
+ ret = sensor_hub_input_get_attribute_info(hsdev,
+ HID_INPUT_REPORT,
+ usage_id,
+ HID_USAGE_SENSOR_ORIENT_TILT_Z,
+ &st->incl[CHANNEL_SCAN_INDEX_Z]);
+ if (ret)
+ return ret;
+ incl_3d_adjust_channel_bit_mask(&channels[CHANNEL_SCAN_INDEX_Z],
+ st->incl[CHANNEL_SCAN_INDEX_Z].size);
+
+ dev_dbg(&pdev->dev, "incl_3d %x:%x, %x:%x, %x:%x\n",
+ st->incl[0].index,
+ st->incl[0].report_id,
+ st->incl[1].index, st->incl[1].report_id,
+ st->incl[2].index, st->incl[2].report_id);
+
+ /* Set Sensitivity field ids, when there is no individual modifier */
+ if (st->common_attributes.sensitivity.index < 0) {
+ sensor_hub_input_get_attribute_info(hsdev,
+ HID_FEATURE_REPORT, usage_id,
+ HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
+ HID_USAGE_SENSOR_DATA_ORIENTATION,
+ &st->common_attributes.sensitivity);
+ dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n",
+ st->common_attributes.sensitivity.index,
+ st->common_attributes.sensitivity.report_id);
+ }
+ return ret;
+}
+
+/* Function to initialize the processing for usage id */
+static int hid_incl_3d_probe(struct platform_device *pdev)
+{
+ int ret;
+ static char *name = "incli_3d";
+ struct iio_dev *indio_dev;
+ struct incl_3d_state *incl_state;
+ struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
+ struct iio_chan_spec *channels;
+
+ indio_dev = devm_iio_device_alloc(&pdev->dev,
+ sizeof(struct incl_3d_state));
+ if (indio_dev == NULL)
+ return -ENOMEM;
+
+ platform_set_drvdata(pdev, indio_dev);
+
+ incl_state = iio_priv(indio_dev);
+ incl_state->common_attributes.hsdev = hsdev;
+ incl_state->common_attributes.pdev = pdev;
+
+ ret = hid_sensor_parse_common_attributes(hsdev,
+ HID_USAGE_SENSOR_INCLINOMETER_3D,
+ &incl_state->common_attributes);
+ if (ret) {
+ dev_err(&pdev->dev, "failed to setup common attributes\n");
+ return ret;
+ }
+
+ channels = kmemdup(incl_3d_channels, sizeof(incl_3d_channels),
+ GFP_KERNEL);
+ if (!channels) {
+ dev_err(&pdev->dev, "failed to duplicate channels\n");
+ return -ENOMEM;
+ }
+
+ ret = incl_3d_parse_report(pdev, hsdev, channels,
+ HID_USAGE_SENSOR_INCLINOMETER_3D, incl_state);
+ if (ret) {
+ dev_err(&pdev->dev, "failed to setup attributes\n");
+ goto error_free_dev_mem;
+ }
+
+ indio_dev->channels = channels;
+ indio_dev->num_channels = ARRAY_SIZE(incl_3d_channels);
+ indio_dev->dev.parent = &pdev->dev;
+ indio_dev->info = &incl_3d_info;
+ indio_dev->name = name;
+ indio_dev->modes = INDIO_DIRECT_MODE;
+
+ ret = iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time,
+ NULL, NULL);
+ if (ret) {
+ dev_err(&pdev->dev, "failed to initialize trigger buffer\n");
+ goto error_free_dev_mem;
+ }
+ incl_state->common_attributes.data_ready = false;
+ ret = hid_sensor_setup_trigger(indio_dev, name,
+ &incl_state->common_attributes);
+ if (ret) {
+ dev_err(&pdev->dev, "trigger setup failed\n");
+ goto error_unreg_buffer_funcs;
+ }
+
+ ret = iio_device_register(indio_dev);
+ if (ret) {
+ dev_err(&pdev->dev, "device register failed\n");
+ goto error_remove_trigger;
+ }
+
+ incl_state->callbacks.send_event = incl_3d_proc_event;
+ incl_state->callbacks.capture_sample = incl_3d_capture_sample;
+ incl_state->callbacks.pdev = pdev;
+ ret = sensor_hub_register_callback(hsdev,
+ HID_USAGE_SENSOR_INCLINOMETER_3D,
+ &incl_state->callbacks);
+ if (ret) {
+ dev_err(&pdev->dev, "callback reg failed\n");
+ goto error_iio_unreg;
+ }
+
+ return 0;
+
+error_iio_unreg:
+ iio_device_unregister(indio_dev);
+error_remove_trigger:
+ hid_sensor_remove_trigger(&incl_state->common_attributes);
+error_unreg_buffer_funcs:
+ iio_triggered_buffer_cleanup(indio_dev);
+error_free_dev_mem:
+ kfree(indio_dev->channels);
+ return ret;
+}
+
+/* Function to deinitialize the processing for usage id */
+static int hid_incl_3d_remove(struct platform_device *pdev)
+{
+ struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
+ struct iio_dev *indio_dev = platform_get_drvdata(pdev);
+ struct incl_3d_state *incl_state = iio_priv(indio_dev);
+
+ sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_INCLINOMETER_3D);
+ iio_device_unregister(indio_dev);
+ hid_sensor_remove_trigger(&incl_state->common_attributes);
+ iio_triggered_buffer_cleanup(indio_dev);
+ kfree(indio_dev->channels);
+
+ return 0;
+}
+
+static struct platform_device_id hid_incl_3d_ids[] = {
+ {
+ /* Format: HID-SENSOR-usage_id_in_hex_lowercase */
+ .name = "HID-SENSOR-200086",
+ },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(platform, hid_incl_3d_ids);
+
+static struct platform_driver hid_incl_3d_platform_driver = {
+ .id_table = hid_incl_3d_ids,
+ .driver = {
+ .name = KBUILD_MODNAME,
+ .owner = THIS_MODULE,
+ },
+ .probe = hid_incl_3d_probe,
+ .remove = hid_incl_3d_remove,
+};
+module_platform_driver(hid_incl_3d_platform_driver);
+
+MODULE_DESCRIPTION("HID Sensor Inclinometer 3D");
+MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>");
+MODULE_LICENSE("GPL");
diff --git a/include/linux/hid-sensor-ids.h b/include/linux/hid-sensor-ids.h
index c7d62c7..a3f863d 100644
--- a/include/linux/hid-sensor-ids.h
+++ b/include/linux/hid-sensor-ids.h
@@ -42,6 +42,7 @@
/* ORIENTATION: Compass 3D: (200083) */
#define HID_USAGE_SENSOR_COMPASS_3D 0x200083
+#define HID_USAGE_SENSOR_DATA_ORIENTATION 0x200470
#define HID_USAGE_SENSOR_ORIENT_MAGN_HEADING 0x200471
#define HID_USAGE_SENSOR_ORIENT_MAGN_HEADING_X 0x200472
#define HID_USAGE_SENSOR_ORIENT_MAGN_HEADING_Y 0x200473
@@ -57,10 +58,14 @@
#define HID_USAGE_SENSOR_ORIENT_DISTANCE_Y 0x20047B
#define HID_USAGE_SENSOR_ORIENT_DISTANCE_Z 0x20047C
#define HID_USAGE_SENSOR_ORIENT_DISTANCE_OUT_OF_RANGE 0x20047D
+
+/* ORIENTATION: Inclinometer 3D: (200086) */
+#define HID_USAGE_SENSOR_INCLINOMETER_3D 0x200086
#define HID_USAGE_SENSOR_ORIENT_TILT 0x20047E
#define HID_USAGE_SENSOR_ORIENT_TILT_X 0x20047F
#define HID_USAGE_SENSOR_ORIENT_TILT_Y 0x200480
#define HID_USAGE_SENSOR_ORIENT_TILT_Z 0x200481
+
#define HID_USAGE_SENSOR_ORIENT_ROTATION_MATRIX 0x200482
#define HID_USAGE_SENSOR_ORIENT_QUATERNION 0x200483
#define HID_USAGE_SENSOR_ORIENT_MAGN_FLUX 0x200484
@@ -132,4 +137,8 @@
#define HID_USAGE_SENSOR_PROP_REPORTING_STATE_NO_EVENTS_ENUM 0x00
#define HID_USAGE_SENSOR_PROP_REPORTING_STATE_ALL_EVENTS_ENUM 0x01
+/* Per data field properties */
+#define HID_USAGE_SENSOR_DATA_MOD_NONE 0x00
+#define HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS 0x1000
+
#endif
--
1.8.3.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v3 7/8] iio: Add quaternion channel
2013-10-30 22:48 [PATCH v3 1/8] iio: hid_Sensors: fix crash during trigger unregister Srinivas Pandruvada
` (4 preceding siblings ...)
2013-10-30 22:48 ` [PATCH v3 6/8] iio: hid-sensors: Added Inclinometer 3D Srinivas Pandruvada
@ 2013-10-30 22:48 ` Srinivas Pandruvada
2013-11-05 23:10 ` Jonathan Cameron
2013-10-30 22:48 ` [PATCH v3 8/8] iio: hid-sensors: Added device rotation support Srinivas Pandruvada
2013-11-05 22:56 ` [PATCH v3 1/8] iio: hid_Sensors: fix crash during trigger unregister Jonathan Cameron
7 siblings, 1 reply; 17+ messages in thread
From: Srinivas Pandruvada @ 2013-10-30 22:48 UTC (permalink / raw)
To: jic23; +Cc: linux-iio, Srinivas Pandruvada
A quaternion channel type is added. Here channel information is
composed of four components: a vector with x, y, z coordinates and
a w rotation. Reusing x, y, z channel modifiers, but added "w"
component in the modifier list.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/iio/industrialio-core.c | 2 ++
include/linux/iio/types.h | 2 ++
2 files changed, 4 insertions(+)
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index f95c697..b754f50 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -66,6 +66,7 @@ static const char * const iio_chan_type_name_spec[] = {
[IIO_ALTVOLTAGE] = "altvoltage",
[IIO_CCT] = "cct",
[IIO_PRESSURE] = "pressure",
+ [IIO_QUAT_ROT] = "quat_rot",
};
static const char * const iio_modifier_names[] = {
@@ -80,6 +81,7 @@ static const char * const iio_modifier_names[] = {
[IIO_MOD_LIGHT_RED] = "red",
[IIO_MOD_LIGHT_GREEN] = "green",
[IIO_MOD_LIGHT_BLUE] = "blue",
+ [IIO_MOD_W] = "w",
};
/* relies on pairs of these shared then separate */
diff --git a/include/linux/iio/types.h b/include/linux/iio/types.h
index 88bf0f0..4565f5c 100644
--- a/include/linux/iio/types.h
+++ b/include/linux/iio/types.h
@@ -29,6 +29,7 @@ enum iio_chan_type {
IIO_ALTVOLTAGE,
IIO_CCT,
IIO_PRESSURE,
+ IIO_QUAT_ROT,
};
enum iio_modifier {
@@ -52,6 +53,7 @@ enum iio_modifier {
IIO_MOD_LIGHT_RED,
IIO_MOD_LIGHT_GREEN,
IIO_MOD_LIGHT_BLUE,
+ IIO_MOD_W,
};
#define IIO_VAL_INT 1
--
1.8.3.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v3 8/8] iio: hid-sensors: Added device rotation support
2013-10-30 22:48 [PATCH v3 1/8] iio: hid_Sensors: fix crash during trigger unregister Srinivas Pandruvada
` (5 preceding siblings ...)
2013-10-30 22:48 ` [PATCH v3 7/8] iio: Add quaternion channel Srinivas Pandruvada
@ 2013-10-30 22:48 ` Srinivas Pandruvada
2013-11-05 22:56 ` [PATCH v3 1/8] iio: hid_Sensors: fix crash during trigger unregister Jonathan Cameron
7 siblings, 0 replies; 17+ messages in thread
From: Srinivas Pandruvada @ 2013-10-30 22:48 UTC (permalink / raw)
To: jic23; +Cc: linux-iio, Srinivas Pandruvada
Added usage id processing for device rotation. This uses IIO
interfaces for triggered buffer to present data to user
mode.This uses HID sensor framework for registering callback
events from the sensor hub.
Data is exported to user space in the form of quaternion rotation
components.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/iio/orientation/Kconfig | 11 +
drivers/iio/orientation/Makefile | 1 +
drivers/iio/orientation/hid-sensor-rotation.c | 406 ++++++++++++++++++++++++++
include/linux/hid-sensor-ids.h | 1 +
4 files changed, 419 insertions(+)
create mode 100644 drivers/iio/orientation/hid-sensor-rotation.c
diff --git a/drivers/iio/orientation/Kconfig b/drivers/iio/orientation/Kconfig
index 58c62c8..da8bd8a 100644
--- a/drivers/iio/orientation/Kconfig
+++ b/drivers/iio/orientation/Kconfig
@@ -16,4 +16,15 @@ config HID_SENSOR_INCLINOMETER_3D
Say yes here to build support for the HID SENSOR
Inclinometer 3D.
+config HID_SENSOR_DEVICE_ROTATION
+ depends on HID_SENSOR_HUB
+ select IIO_BUFFER
+ select IIO_TRIGGERED_BUFFER
+ select HID_SENSOR_IIO_COMMON
+ select HID_SENSOR_IIO_TRIGGER
+ tristate "HID Device Rotation"
+ help
+ Say yes here to build support for the HID SENSOR
+ device rotation.
+
endmenu
diff --git a/drivers/iio/orientation/Makefile b/drivers/iio/orientation/Makefile
index 2c97572..4734dab 100644
--- a/drivers/iio/orientation/Makefile
+++ b/drivers/iio/orientation/Makefile
@@ -4,3 +4,4 @@
# When adding new entries keep the list in alphabetical order
obj-$(CONFIG_HID_SENSOR_INCLINOMETER_3D) += hid-sensor-incl-3d.o
+obj-$(CONFIG_HID_SENSOR_DEVICE_ROTATION) += hid-sensor-rotation.o
diff --git a/drivers/iio/orientation/hid-sensor-rotation.c b/drivers/iio/orientation/hid-sensor-rotation.c
new file mode 100644
index 0000000..f6c31e5
--- /dev/null
+++ b/drivers/iio/orientation/hid-sensor-rotation.c
@@ -0,0 +1,406 @@
+/*
+ * HID Sensors Driver
+ * Copyright (c) 2013, Intel Corporation.
+ *
+ * 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.
+ *
+ */
+
+#include <linux/device.h>
+#include <linux/platform_device.h>
+#include <linux/module.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/slab.h>
+#include <linux/hid-sensor-hub.h>
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/iio/buffer.h>
+#include <linux/iio/trigger_consumer.h>
+#include <linux/iio/triggered_buffer.h>
+#include "../common/hid-sensors/hid-sensor-trigger.h"
+
+enum dev_rot_channel {
+ CHANNEL_SCAN_INDEX_X,
+ CHANNEL_SCAN_INDEX_Y,
+ CHANNEL_SCAN_INDEX_Z,
+ CHANNEL_SCAN_INDEX_W,
+ DEV_ROT_CHANNEL_MAX,
+};
+
+struct dev_rot_state {
+ struct hid_sensor_hub_callbacks callbacks;
+ struct hid_sensor_common common_attributes;
+ struct hid_sensor_hub_attribute_info incl[DEV_ROT_CHANNEL_MAX];
+ u32 incl_val[DEV_ROT_CHANNEL_MAX];
+};
+
+static const u32 dev_rot_addresses[DEV_ROT_CHANNEL_MAX] = {
+ HID_USAGE_SENSOR_ORIENT_QUATERNION,
+ HID_USAGE_SENSOR_ORIENT_QUATERNION,
+ HID_USAGE_SENSOR_ORIENT_QUATERNION,
+ HID_USAGE_SENSOR_ORIENT_QUATERNION
+};
+
+/* Channel definitions */
+static const struct iio_chan_spec dev_rot_channels[] = {
+ {
+ .type = IIO_QUAT_ROT,
+ .modified = 1,
+ .channel2 = IIO_MOD_X,
+ .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),
+ .scan_index = CHANNEL_SCAN_INDEX_X,
+ }, {
+ .type = IIO_QUAT_ROT,
+ .modified = 1,
+ .channel2 = IIO_MOD_Y,
+ .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),
+ .scan_index = CHANNEL_SCAN_INDEX_Y,
+ }, {
+ .type = IIO_QUAT_ROT,
+ .modified = 1,
+ .channel2 = IIO_MOD_Z,
+ .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),
+ .scan_index = CHANNEL_SCAN_INDEX_Z,
+ }, {
+ .type = IIO_QUAT_ROT,
+ .modified = 1,
+ .channel2 = IIO_MOD_W,
+ .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),
+ .scan_index = CHANNEL_SCAN_INDEX_W,
+ }
+};
+
+/* Adjust channel real bits based on report descriptor */
+static void dev_rot_adjust_channel_bit_mask(struct iio_chan_spec *chan,
+ int size)
+{
+ chan->scan_type.sign = 's';
+ /* Real storage bits will change based on the report desc. */
+ chan->scan_type.realbits = size * 8;
+ /* Maximum size of a sample to capture is u32 */
+ chan->scan_type.storagebits = sizeof(u32) * 8;
+}
+
+/* Channel read_raw handler */
+static int dev_rot_read_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ int *val, int *val2,
+ long mask)
+{
+ struct dev_rot_state *rot_state = iio_priv(indio_dev);
+ int ret_type;
+
+ *val = 0;
+ *val2 = 0;
+ switch (mask) {
+ case IIO_CHAN_INFO_SCALE:
+ *val = rot_state->incl[CHANNEL_SCAN_INDEX_X].units;
+ ret_type = IIO_VAL_INT;
+ break;
+ case IIO_CHAN_INFO_OFFSET:
+ *val = hid_sensor_convert_exponent(
+ rot_state->incl[CHANNEL_SCAN_INDEX_X].unit_expo);
+ ret_type = IIO_VAL_INT;
+ break;
+ case IIO_CHAN_INFO_SAMP_FREQ:
+ ret_type = hid_sensor_read_samp_freq_value(
+ &rot_state->common_attributes, val, val2);
+ break;
+ case IIO_CHAN_INFO_HYSTERESIS:
+ ret_type = hid_sensor_read_raw_hyst_value(
+ &rot_state->common_attributes, val, val2);
+ break;
+ default:
+ ret_type = -EINVAL;
+ break;
+ }
+
+ return ret_type;
+}
+
+/* Channel write_raw handler */
+static int dev_rot_write_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ int val,
+ int val2,
+ long mask)
+{
+ struct dev_rot_state *rot_state = iio_priv(indio_dev);
+ int ret;
+
+ switch (mask) {
+ case IIO_CHAN_INFO_SAMP_FREQ:
+ ret = hid_sensor_write_samp_freq_value(
+ &rot_state->common_attributes, val, val2);
+ break;
+ case IIO_CHAN_INFO_HYSTERESIS:
+ ret = hid_sensor_write_raw_hyst_value(
+ &rot_state->common_attributes, val, val2);
+ break;
+ default:
+ ret = -EINVAL;
+ }
+
+ return ret;
+}
+
+static const struct iio_info dev_rot_info = {
+ .driver_module = THIS_MODULE,
+ .read_raw = &dev_rot_read_raw,
+ .write_raw = &dev_rot_write_raw,
+};
+
+/* Function to push data to buffer */
+static void hid_sensor_push_data(struct iio_dev *indio_dev, u8 *data, int len)
+{
+ dev_dbg(&indio_dev->dev, "hid_sensor_push_data >>\n");
+ iio_push_to_buffers(indio_dev, (u8 *)data);
+ dev_dbg(&indio_dev->dev, "hid_sensor_push_data <<\n");
+
+}
+
+/* Callback handler to send event after all samples are received and captured */
+static int dev_rot_proc_event(struct hid_sensor_hub_device *hsdev,
+ unsigned usage_id,
+ void *priv)
+{
+ struct iio_dev *indio_dev = platform_get_drvdata(priv);
+ struct dev_rot_state *rot_state = iio_priv(indio_dev);
+
+ dev_dbg(&indio_dev->dev, "dev_rot_proc_event [%d]\n",
+ rot_state->common_attributes.data_ready);
+
+ if (rot_state->common_attributes.data_ready)
+ hid_sensor_push_data(indio_dev,
+ (u8 *)rot_state->incl_val,
+ sizeof(rot_state->incl_val));
+
+ return 0;
+}
+
+/* Capture samples in local storage */
+static int dev_rot_capture_sample(struct hid_sensor_hub_device *hsdev,
+ unsigned usage_id,
+ size_t raw_len, char *raw_data,
+ void *priv)
+{
+ struct iio_dev *indio_dev = platform_get_drvdata(priv);
+ struct dev_rot_state *rot_state = iio_priv(indio_dev);
+
+ if (usage_id == HID_USAGE_SENSOR_ORIENT_QUATERNION) {
+ memcpy(rot_state->incl_val, raw_data,
+ sizeof(rot_state->incl_val));
+ dev_dbg(&indio_dev->dev, "Recd Quat len:%lu::%lu\n", raw_len,
+ sizeof(rot_state->incl_val));
+ }
+
+ return 0;
+}
+
+/* Parse report which is specific to an usage id*/
+static int dev_rot_parse_report(struct platform_device *pdev,
+ struct hid_sensor_hub_device *hsdev,
+ struct iio_chan_spec *channels,
+ unsigned usage_id,
+ struct dev_rot_state *st)
+{
+ int ret;
+
+ ret = sensor_hub_input_get_attribute_info(hsdev,
+ HID_INPUT_REPORT,
+ usage_id,
+ HID_USAGE_SENSOR_ORIENT_QUATERNION,
+ &st->incl[CHANNEL_SCAN_INDEX_X]);
+ if (ret)
+ return ret;
+ dev_rot_adjust_channel_bit_mask(&channels[CHANNEL_SCAN_INDEX_X],
+ st->incl[CHANNEL_SCAN_INDEX_X].size/4);
+
+ dev_rot_adjust_channel_bit_mask(&channels[CHANNEL_SCAN_INDEX_Y],
+ st->incl[CHANNEL_SCAN_INDEX_X].size/4);
+
+ dev_rot_adjust_channel_bit_mask(&channels[CHANNEL_SCAN_INDEX_Z],
+ st->incl[CHANNEL_SCAN_INDEX_X].size/4);
+
+ dev_rot_adjust_channel_bit_mask(&channels[CHANNEL_SCAN_INDEX_W],
+ st->incl[CHANNEL_SCAN_INDEX_X].size/4);
+
+ dev_dbg(&pdev->dev, "dev_rot %x:%x, %x:%x, %x:%x\n",
+ st->incl[0].index,
+ st->incl[0].report_id,
+ st->incl[1].index, st->incl[1].report_id,
+ st->incl[2].index, st->incl[2].report_id);
+
+ dev_dbg(&pdev->dev, "dev_rot: attrib size %d\n",
+ st->incl[CHANNEL_SCAN_INDEX_X].size);
+
+ /* Set Sensitivity field ids, when there is no individual modifier */
+ if (st->common_attributes.sensitivity.index < 0) {
+ sensor_hub_input_get_attribute_info(hsdev,
+ HID_FEATURE_REPORT, usage_id,
+ HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
+ HID_USAGE_SENSOR_DATA_ORIENTATION,
+ &st->common_attributes.sensitivity);
+ dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n",
+ st->common_attributes.sensitivity.index,
+ st->common_attributes.sensitivity.report_id);
+ }
+ return 0;
+}
+
+/* Function to initialize the processing for usage id */
+static int hid_dev_rot_probe(struct platform_device *pdev)
+{
+ int ret;
+ static char *name = "dev_rotation";
+ struct iio_dev *indio_dev;
+ struct dev_rot_state *rot_state;
+ struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
+ struct iio_chan_spec *channels;
+
+ indio_dev = devm_iio_device_alloc(&pdev->dev,
+ sizeof(struct dev_rot_state));
+ if (indio_dev == NULL)
+ return -ENOMEM;
+
+ platform_set_drvdata(pdev, indio_dev);
+
+ rot_state = iio_priv(indio_dev);
+ rot_state->common_attributes.hsdev = hsdev;
+ rot_state->common_attributes.pdev = pdev;
+
+ ret = hid_sensor_parse_common_attributes(hsdev,
+ HID_USAGE_SENSOR_DEVICE_ORIENTATION,
+ &rot_state->common_attributes);
+ if (ret) {
+ dev_err(&pdev->dev, "failed to setup common attributes\n");
+ return ret;
+ }
+
+ channels = kmemdup(dev_rot_channels, sizeof(dev_rot_channels),
+ GFP_KERNEL);
+ if (!channels) {
+ dev_err(&pdev->dev, "failed to duplicate channels\n");
+ return -ENOMEM;
+ }
+
+ ret = dev_rot_parse_report(pdev, hsdev, channels,
+ HID_USAGE_SENSOR_DEVICE_ORIENTATION, rot_state);
+ if (ret) {
+ dev_err(&pdev->dev, "failed to setup attributes\n");
+ goto error_free_dev_mem;
+ }
+
+ indio_dev->channels = channels;
+ indio_dev->num_channels = ARRAY_SIZE(dev_rot_channels);
+ indio_dev->dev.parent = &pdev->dev;
+ indio_dev->info = &dev_rot_info;
+ indio_dev->name = name;
+ indio_dev->modes = INDIO_DIRECT_MODE;
+
+ ret = iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time,
+ NULL, NULL);
+ if (ret) {
+ dev_err(&pdev->dev, "failed to initialize trigger buffer\n");
+ goto error_free_dev_mem;
+ }
+ rot_state->common_attributes.data_ready = false;
+ ret = hid_sensor_setup_trigger(indio_dev, name,
+ &rot_state->common_attributes);
+ if (ret) {
+ dev_err(&pdev->dev, "trigger setup failed\n");
+ goto error_unreg_buffer_funcs;
+ }
+
+ ret = iio_device_register(indio_dev);
+ if (ret) {
+ dev_err(&pdev->dev, "device register failed\n");
+ goto error_remove_trigger;
+ }
+
+ rot_state->callbacks.send_event = dev_rot_proc_event;
+ rot_state->callbacks.capture_sample = dev_rot_capture_sample;
+ rot_state->callbacks.pdev = pdev;
+ ret = sensor_hub_register_callback(hsdev,
+ HID_USAGE_SENSOR_DEVICE_ORIENTATION,
+ &rot_state->callbacks);
+ if (ret) {
+ dev_err(&pdev->dev, "callback reg failed\n");
+ goto error_iio_unreg;
+ }
+
+ return 0;
+
+error_iio_unreg:
+ iio_device_unregister(indio_dev);
+error_remove_trigger:
+ hid_sensor_remove_trigger(&rot_state->common_attributes);
+error_unreg_buffer_funcs:
+ iio_triggered_buffer_cleanup(indio_dev);
+error_free_dev_mem:
+ kfree(indio_dev->channels);
+ return ret;
+}
+
+/* Function to deinitialize the processing for usage id */
+static int hid_dev_rot_remove(struct platform_device *pdev)
+{
+ struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
+ struct iio_dev *indio_dev = platform_get_drvdata(pdev);
+ struct dev_rot_state *rot_state = iio_priv(indio_dev);
+
+ sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_DEVICE_ORIENTATION);
+ iio_device_unregister(indio_dev);
+ hid_sensor_remove_trigger(&rot_state->common_attributes);
+ iio_triggered_buffer_cleanup(indio_dev);
+ kfree(indio_dev->channels);
+
+ return 0;
+}
+
+static struct platform_device_id hid_dev_rot_ids[] = {
+ {
+ /* Format: HID-SENSOR-usage_id_in_hex_lowercase */
+ .name = "HID-SENSOR-20008a",
+ },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(platform, hid_dev_rot_ids);
+
+static struct platform_driver hid_dev_rot_platform_driver = {
+ .id_table = hid_dev_rot_ids,
+ .driver = {
+ .name = KBUILD_MODNAME,
+ .owner = THIS_MODULE,
+ },
+ .probe = hid_dev_rot_probe,
+ .remove = hid_dev_rot_remove,
+};
+module_platform_driver(hid_dev_rot_platform_driver);
+
+MODULE_DESCRIPTION("HID Sensor Device Rotation");
+MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>");
+MODULE_LICENSE("GPL");
diff --git a/include/linux/hid-sensor-ids.h b/include/linux/hid-sensor-ids.h
index a3f863d..a264ec7 100644
--- a/include/linux/hid-sensor-ids.h
+++ b/include/linux/hid-sensor-ids.h
@@ -66,6 +66,7 @@
#define HID_USAGE_SENSOR_ORIENT_TILT_Y 0x200480
#define HID_USAGE_SENSOR_ORIENT_TILT_Z 0x200481
+#define HID_USAGE_SENSOR_DEVICE_ORIENTATION 0x20008A
#define HID_USAGE_SENSOR_ORIENT_ROTATION_MATRIX 0x200482
#define HID_USAGE_SENSOR_ORIENT_QUATERNION 0x200483
#define HID_USAGE_SENSOR_ORIENT_MAGN_FLUX 0x200484
--
1.8.3.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH v3 1/8] iio: hid_Sensors: fix crash during trigger unregister
2013-10-30 22:48 [PATCH v3 1/8] iio: hid_Sensors: fix crash during trigger unregister Srinivas Pandruvada
` (6 preceding siblings ...)
2013-10-30 22:48 ` [PATCH v3 8/8] iio: hid-sensors: Added device rotation support Srinivas Pandruvada
@ 2013-11-05 22:56 ` Jonathan Cameron
7 siblings, 0 replies; 17+ messages in thread
From: Jonathan Cameron @ 2013-11-05 22:56 UTC (permalink / raw)
To: Srinivas Pandruvada; +Cc: linux-iio
On 10/30/13 22:48, Srinivas Pandruvada wrote:
> We can't store the trigger instance created by iio_trigger_alloc, in
> trig field of iio_device structure. This needs to be stored in the
> driver private data. Othewise it can result in crash during module
> unload. Hence created a trig_ptr in the common data structure
> for each HID sensor IIO driver and storing here.
>
> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Applied to the fixes-togreg branch of iio.git
Will be a little while before this hits mainline because of the unusual merge window
timings.
Thanks,
Jonathan
> ---
> drivers/iio/accel/hid-sensor-accel-3d.c | 5 +++--
> drivers/iio/common/hid-sensors/hid-sensor-trigger.c | 9 ++++-----
> drivers/iio/common/hid-sensors/hid-sensor-trigger.h | 2 +-
> drivers/iio/gyro/hid-sensor-gyro-3d.c | 5 +++--
> drivers/iio/light/hid-sensor-als.c | 5 +++--
> drivers/iio/magnetometer/hid-sensor-magn-3d.c | 5 +++--
> include/linux/hid-sensor-hub.h | 3 +++
> 7 files changed, 20 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c
> index 46d22f3..7fbe136 100644
> --- a/drivers/iio/accel/hid-sensor-accel-3d.c
> +++ b/drivers/iio/accel/hid-sensor-accel-3d.c
> @@ -349,7 +349,7 @@ static int hid_accel_3d_probe(struct platform_device *pdev)
> error_iio_unreg:
> iio_device_unregister(indio_dev);
> error_remove_trigger:
> - hid_sensor_remove_trigger(indio_dev);
> + hid_sensor_remove_trigger(&accel_state->common_attributes);
> error_unreg_buffer_funcs:
> iio_triggered_buffer_cleanup(indio_dev);
> error_free_dev_mem:
> @@ -362,10 +362,11 @@ static int hid_accel_3d_remove(struct platform_device *pdev)
> {
> struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
> struct iio_dev *indio_dev = platform_get_drvdata(pdev);
> + struct accel_3d_state *accel_state = iio_priv(indio_dev);
>
> sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_ACCEL_3D);
> iio_device_unregister(indio_dev);
> - hid_sensor_remove_trigger(indio_dev);
> + hid_sensor_remove_trigger(&accel_state->common_attributes);
> iio_triggered_buffer_cleanup(indio_dev);
> kfree(indio_dev->channels);
>
> diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
> index dbc9141..363f8d2 100644
> --- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
> +++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
> @@ -71,11 +71,10 @@ static int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig,
> return 0;
> }
>
> -void hid_sensor_remove_trigger(struct iio_dev *indio_dev)
> +void hid_sensor_remove_trigger(struct hid_sensor_common *attrb)
> {
> - iio_trigger_unregister(indio_dev->trig);
> - iio_trigger_free(indio_dev->trig);
> - indio_dev->trig = NULL;
> + iio_trigger_unregister(attrb->trigger);
> + iio_trigger_free(attrb->trigger);
> }
> EXPORT_SYMBOL(hid_sensor_remove_trigger);
>
> @@ -106,7 +105,7 @@ int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name,
> dev_err(&indio_dev->dev, "Trigger Register Failed\n");
> goto error_free_trig;
> }
> - indio_dev->trig = trig;
> + indio_dev->trig = attrb->trigger = trig;
>
> return ret;
>
> diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.h b/drivers/iio/common/hid-sensors/hid-sensor-trigger.h
> index 9a87314..ca02f78 100644
> --- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.h
> +++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.h
> @@ -21,6 +21,6 @@
>
> int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name,
> struct hid_sensor_common *attrb);
> -void hid_sensor_remove_trigger(struct iio_dev *indio_dev);
> +void hid_sensor_remove_trigger(struct hid_sensor_common *attrb);
>
> #endif
> diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c
> index c688d97..74bbed7 100644
> --- a/drivers/iio/gyro/hid-sensor-gyro-3d.c
> +++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c
> @@ -347,7 +347,7 @@ static int hid_gyro_3d_probe(struct platform_device *pdev)
> error_iio_unreg:
> iio_device_unregister(indio_dev);
> error_remove_trigger:
> - hid_sensor_remove_trigger(indio_dev);
> + hid_sensor_remove_trigger(&gyro_state->common_attributes);
> error_unreg_buffer_funcs:
> iio_triggered_buffer_cleanup(indio_dev);
> error_free_dev_mem:
> @@ -360,10 +360,11 @@ static int hid_gyro_3d_remove(struct platform_device *pdev)
> {
> struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
> struct iio_dev *indio_dev = platform_get_drvdata(pdev);
> + struct gyro_3d_state *gyro_state = iio_priv(indio_dev);
>
> sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_GYRO_3D);
> iio_device_unregister(indio_dev);
> - hid_sensor_remove_trigger(indio_dev);
> + hid_sensor_remove_trigger(&gyro_state->common_attributes);
> iio_triggered_buffer_cleanup(indio_dev);
> kfree(indio_dev->channels);
>
> diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c
> index e59d00c..c104bda 100644
> --- a/drivers/iio/light/hid-sensor-als.c
> +++ b/drivers/iio/light/hid-sensor-als.c
> @@ -313,7 +313,7 @@ static int hid_als_probe(struct platform_device *pdev)
> error_iio_unreg:
> iio_device_unregister(indio_dev);
> error_remove_trigger:
> - hid_sensor_remove_trigger(indio_dev);
> + hid_sensor_remove_trigger(&als_state->common_attributes);
> error_unreg_buffer_funcs:
> iio_triggered_buffer_cleanup(indio_dev);
> error_free_dev_mem:
> @@ -326,10 +326,11 @@ static int hid_als_remove(struct platform_device *pdev)
> {
> struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
> struct iio_dev *indio_dev = platform_get_drvdata(pdev);
> + struct als_state *als_state = iio_priv(indio_dev);
>
> sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_ALS);
> iio_device_unregister(indio_dev);
> - hid_sensor_remove_trigger(indio_dev);
> + hid_sensor_remove_trigger(&als_state->common_attributes);
> iio_triggered_buffer_cleanup(indio_dev);
> kfree(indio_dev->channels);
>
> diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
> index a98460b..ff7b9da 100644
> --- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c
> +++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
> @@ -350,7 +350,7 @@ static int hid_magn_3d_probe(struct platform_device *pdev)
> error_iio_unreg:
> iio_device_unregister(indio_dev);
> error_remove_trigger:
> - hid_sensor_remove_trigger(indio_dev);
> + hid_sensor_remove_trigger(&magn_state->common_attributes);
> error_unreg_buffer_funcs:
> iio_triggered_buffer_cleanup(indio_dev);
> error_free_dev_mem:
> @@ -363,10 +363,11 @@ static int hid_magn_3d_remove(struct platform_device *pdev)
> {
> struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
> struct iio_dev *indio_dev = platform_get_drvdata(pdev);
> + struct magn_3d_state *magn_state = iio_priv(indio_dev);
>
> sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_COMPASS_3D);
> iio_device_unregister(indio_dev);
> - hid_sensor_remove_trigger(indio_dev);
> + hid_sensor_remove_trigger(&magn_state->common_attributes);
> iio_triggered_buffer_cleanup(indio_dev);
> kfree(indio_dev->channels);
>
> diff --git a/include/linux/hid-sensor-hub.h b/include/linux/hid-sensor-hub.h
> index a265af2..206a2af 100644
> --- a/include/linux/hid-sensor-hub.h
> +++ b/include/linux/hid-sensor-hub.h
> @@ -21,6 +21,8 @@
>
> #include <linux/hid.h>
> #include <linux/hid-sensor-ids.h>
> +#include <linux/iio/iio.h>
> +#include <linux/iio/trigger.h>
>
> /**
> * struct hid_sensor_hub_attribute_info - Attribute info
> @@ -184,6 +186,7 @@ struct hid_sensor_common {
> struct platform_device *pdev;
> unsigned usage_id;
> bool data_ready;
> + struct iio_trigger *trigger;
> struct hid_sensor_hub_attribute_info poll;
> struct hid_sensor_hub_attribute_info report_state;
> struct hid_sensor_hub_attribute_info power_state;
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v3 2/8] iio: hid-sensors: accelerometer: Add sensitivity
2013-10-30 22:48 ` [PATCH v3 2/8] iio: hid-sensors: accelerometer: Add sensitivity Srinivas Pandruvada
@ 2013-11-05 23:04 ` Jonathan Cameron
0 siblings, 0 replies; 17+ messages in thread
From: Jonathan Cameron @ 2013-11-05 23:04 UTC (permalink / raw)
To: Srinivas Pandruvada; +Cc: linux-iio
On 10/30/13 22:48, Srinivas Pandruvada wrote:
> A number of Properties that can be applied to Data Fields are per data
> field basis or for all data fields. Adding sensitivity field for all
> accelerometer fields, which is most commonly used in currently
> available sensor hubs.
>
> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
The defines needed for this bled into patch 6. Please build test you individual
patches to makes sure they can be bisected.
Anyhow fixed that up and applied to the togreg branch of iio.git
> ---
> drivers/iio/accel/hid-sensor-accel-3d.c | 12 ++++++++++++
> include/linux/hid-sensor-ids.h | 1 +
> 2 files changed, 13 insertions(+)
>
> diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c
> index 7fbe136..b89ba92 100644
> --- a/drivers/iio/accel/hid-sensor-accel-3d.c
> +++ b/drivers/iio/accel/hid-sensor-accel-3d.c
> @@ -261,6 +261,18 @@ static int accel_3d_parse_report(struct platform_device *pdev,
> st->accel[1].index, st->accel[1].report_id,
> st->accel[2].index, st->accel[2].report_id);
>
> + /* Set Sensitivity field ids, when there is no individual modifier */
> + if (st->common_attributes.sensitivity.index < 0) {
> + sensor_hub_input_get_attribute_info(hsdev,
> + HID_FEATURE_REPORT, usage_id,
> + HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
> + HID_USAGE_SENSOR_DATA_ACCELERATION,
> + &st->common_attributes.sensitivity);
> + dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n",
> + st->common_attributes.sensitivity.index,
> + st->common_attributes.sensitivity.report_id);
> + }
> +
> return ret;
> }
>
> diff --git a/include/linux/hid-sensor-ids.h b/include/linux/hid-sensor-ids.h
> index 8323775..bd97d60 100644
> --- a/include/linux/hid-sensor-ids.h
> +++ b/include/linux/hid-sensor-ids.h
> @@ -23,6 +23,7 @@
>
> /* Accel 3D (200073) */
> #define HID_USAGE_SENSOR_ACCEL_3D 0x200073
> +#define HID_USAGE_SENSOR_DATA_ACCELERATION 0x200452
> #define HID_USAGE_SENSOR_ACCEL_X_AXIS 0x200453
> #define HID_USAGE_SENSOR_ACCEL_Y_AXIS 0x200454
> #define HID_USAGE_SENSOR_ACCEL_Z_AXIS 0x200455
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v3 3/8] iio: hid-sensors: gyro : Add sensitivity
2013-10-30 22:48 ` [PATCH v3 3/8] iio: hid-sensors: gyro : " Srinivas Pandruvada
@ 2013-11-05 23:05 ` Jonathan Cameron
0 siblings, 0 replies; 17+ messages in thread
From: Jonathan Cameron @ 2013-11-05 23:05 UTC (permalink / raw)
To: Srinivas Pandruvada; +Cc: linux-iio
On 10/30/13 22:48, Srinivas Pandruvada wrote:
> A number of Properties that can be applied to Data Fields are per data
> field basis or for all data fields. Adding sensitivity field for all
> gyro fields, which is most commonly used in currently available
> sensor hubs.
>
> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Applied
> ---
> drivers/iio/gyro/hid-sensor-gyro-3d.c | 11 +++++++++++
> include/linux/hid-sensor-ids.h | 1 +
> 2 files changed, 12 insertions(+)
>
> diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c
> index 74bbed7..d665ec3 100644
> --- a/drivers/iio/gyro/hid-sensor-gyro-3d.c
> +++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c
> @@ -261,6 +261,17 @@ static int gyro_3d_parse_report(struct platform_device *pdev,
> st->gyro[1].index, st->gyro[1].report_id,
> st->gyro[2].index, st->gyro[2].report_id);
>
> + /* Set Sensitivity field ids, when there is no individual modifier */
> + if (st->common_attributes.sensitivity.index < 0) {
> + sensor_hub_input_get_attribute_info(hsdev,
> + HID_FEATURE_REPORT, usage_id,
> + HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
> + HID_USAGE_SENSOR_DATA_ANGL_VELOCITY,
> + &st->common_attributes.sensitivity);
> + dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n",
> + st->common_attributes.sensitivity.index,
> + st->common_attributes.sensitivity.report_id);
> + }
> return ret;
> }
>
> diff --git a/include/linux/hid-sensor-ids.h b/include/linux/hid-sensor-ids.h
> index bd97d60..6473d93 100644
> --- a/include/linux/hid-sensor-ids.h
> +++ b/include/linux/hid-sensor-ids.h
> @@ -34,6 +34,7 @@
>
> /* Gyro 3D: (200076) */
> #define HID_USAGE_SENSOR_GYRO_3D 0x200076
> +#define HID_USAGE_SENSOR_DATA_ANGL_VELOCITY 0x200456
> #define HID_USAGE_SENSOR_ANGL_VELOCITY_X_AXIS 0x200457
> #define HID_USAGE_SENSOR_ANGL_VELOCITY_Y_AXIS 0x200458
> #define HID_USAGE_SENSOR_ANGL_VELOCITY_Z_AXIS 0x200459
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v3 5/8] iio: hid-sensors: magnetometer : Add sensitivity
2013-10-30 22:48 ` [PATCH v3 5/8] iio: hid-sensors: magnetometer " Srinivas Pandruvada
@ 2013-11-05 23:06 ` Jonathan Cameron
0 siblings, 0 replies; 17+ messages in thread
From: Jonathan Cameron @ 2013-11-05 23:06 UTC (permalink / raw)
To: Srinivas Pandruvada; +Cc: linux-iio
On 10/30/13 22:48, Srinivas Pandruvada wrote:
> A number of Properties that can be applied to Data Fields are per data
> field basis or for all data fields. Adding sensitivity field for all
> magnetometer fields, which is most commonly used in currently available
> sensor hubs.
>
> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
This is dependent on defines that don't exist. I'm guessing they are later
in the series, so please fix this up.
Jonathan
> ---
> drivers/iio/magnetometer/hid-sensor-magn-3d.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
> index ff7b9da..db9f27b 100644
> --- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c
> +++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
> @@ -262,6 +262,18 @@ static int magn_3d_parse_report(struct platform_device *pdev,
> st->magn[1].index, st->magn[1].report_id,
> st->magn[2].index, st->magn[2].report_id);
>
> + /* Set Sensitivity field ids, when there is no individual modifier */
> + if (st->common_attributes.sensitivity.index < 0) {
> + sensor_hub_input_get_attribute_info(hsdev,
> + HID_FEATURE_REPORT, usage_id,
> + HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
> + HID_USAGE_SENSOR_DATA_ORIENTATION,
> + &st->common_attributes.sensitivity);
> + dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n",
> + st->common_attributes.sensitivity.index,
> + st->common_attributes.sensitivity.report_id);
> + }
> +
> return ret;
> }
>
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v3 7/8] iio: Add quaternion channel
2013-10-30 22:48 ` [PATCH v3 7/8] iio: Add quaternion channel Srinivas Pandruvada
@ 2013-11-05 23:10 ` Jonathan Cameron
2013-11-06 0:10 ` Srinivas Pandruvada
0 siblings, 1 reply; 17+ messages in thread
From: Jonathan Cameron @ 2013-11-05 23:10 UTC (permalink / raw)
To: Srinivas Pandruvada; +Cc: linux-iio
On 10/30/13 22:48, Srinivas Pandruvada wrote:
> A quaternion channel type is added. Here channel information is
> composed of four components: a vector with x, y, z coordinates and
> a w rotation. Reusing x, y, z channel modifiers, but added "w"
> component in the modifier list.
>
> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
In brief I am against this for the same reason I didn't like this before.
A quaternion has no meaning if it isn't all present. Hence we need to
ensure that it is always presented to userspace with all four components
present.
I'll hopefully have a few mins at the weekend to to bash out some example
code for how I would suggest we handle this.
If you could repost the patches before this one with everything that should
be in them then hopefully we can take those whilst still 'discussing'
how to handle the last 2!
Jonathan
> ---
> drivers/iio/industrialio-core.c | 2 ++
> include/linux/iio/types.h | 2 ++
> 2 files changed, 4 insertions(+)
>
> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
> index f95c697..b754f50 100644
> --- a/drivers/iio/industrialio-core.c
> +++ b/drivers/iio/industrialio-core.c
> @@ -66,6 +66,7 @@ static const char * const iio_chan_type_name_spec[] = {
> [IIO_ALTVOLTAGE] = "altvoltage",
> [IIO_CCT] = "cct",
> [IIO_PRESSURE] = "pressure",
> + [IIO_QUAT_ROT] = "quat_rot",
> };
>
> static const char * const iio_modifier_names[] = {
> @@ -80,6 +81,7 @@ static const char * const iio_modifier_names[] = {
> [IIO_MOD_LIGHT_RED] = "red",
> [IIO_MOD_LIGHT_GREEN] = "green",
> [IIO_MOD_LIGHT_BLUE] = "blue",
> + [IIO_MOD_W] = "w",
> };
>
> /* relies on pairs of these shared then separate */
> diff --git a/include/linux/iio/types.h b/include/linux/iio/types.h
> index 88bf0f0..4565f5c 100644
> --- a/include/linux/iio/types.h
> +++ b/include/linux/iio/types.h
> @@ -29,6 +29,7 @@ enum iio_chan_type {
> IIO_ALTVOLTAGE,
> IIO_CCT,
> IIO_PRESSURE,
> + IIO_QUAT_ROT,
> };
>
> enum iio_modifier {
> @@ -52,6 +53,7 @@ enum iio_modifier {
> IIO_MOD_LIGHT_RED,
> IIO_MOD_LIGHT_GREEN,
> IIO_MOD_LIGHT_BLUE,
> + IIO_MOD_W,
> };
>
> #define IIO_VAL_INT 1
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v3 7/8] iio: Add quaternion channel
2013-11-05 23:10 ` Jonathan Cameron
@ 2013-11-06 0:10 ` Srinivas Pandruvada
2013-11-06 7:58 ` Jonathan Cameron
0 siblings, 1 reply; 17+ messages in thread
From: Srinivas Pandruvada @ 2013-11-06 0:10 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio
On 11/05/2013 03:10 PM, Jonathan Cameron wrote:
> On 10/30/13 22:48, Srinivas Pandruvada wrote:
>> A quaternion channel type is added. Here channel information is
>> composed of four components: a vector with x, y, z coordinates and
>> a w rotation. Reusing x, y, z channel modifiers, but added "w"
>> component in the modifier list.
>>
>> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> In brief I am against this for the same reason I didn't like this before.
> A quaternion has no meaning if it isn't all present. Hence we need to
> ensure that it is always presented to userspace with all four components
> present.
>
> I'll hopefully have a few mins at the weekend to to bash out some example
> code for how I would suggest we handle this.
>
> If you could repost the patches before this one with everything that should
> be in them then hopefully we can take those whilst still 'discussing'
> how to handle the last 2!
Sorry about the issues with previous patches. I was trying to order new
driver at the end and missed dependencies.
I have applied all patches which I am sending after this email safely
apply to fixes-togreg branch.
For the last two, I will wait for your suggestion.
Thanks,
Srinivas
>
> Jonathan
>> ---
>> drivers/iio/industrialio-core.c | 2 ++
>> include/linux/iio/types.h | 2 ++
>> 2 files changed, 4 insertions(+)
>>
>> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
>> index f95c697..b754f50 100644
>> --- a/drivers/iio/industrialio-core.c
>> +++ b/drivers/iio/industrialio-core.c
>> @@ -66,6 +66,7 @@ static const char * const iio_chan_type_name_spec[] = {
>> [IIO_ALTVOLTAGE] = "altvoltage",
>> [IIO_CCT] = "cct",
>> [IIO_PRESSURE] = "pressure",
>> + [IIO_QUAT_ROT] = "quat_rot",
>> };
>>
>> static const char * const iio_modifier_names[] = {
>> @@ -80,6 +81,7 @@ static const char * const iio_modifier_names[] = {
>> [IIO_MOD_LIGHT_RED] = "red",
>> [IIO_MOD_LIGHT_GREEN] = "green",
>> [IIO_MOD_LIGHT_BLUE] = "blue",
>> + [IIO_MOD_W] = "w",
>> };
>>
>> /* relies on pairs of these shared then separate */
>> diff --git a/include/linux/iio/types.h b/include/linux/iio/types.h
>> index 88bf0f0..4565f5c 100644
>> --- a/include/linux/iio/types.h
>> +++ b/include/linux/iio/types.h
>> @@ -29,6 +29,7 @@ enum iio_chan_type {
>> IIO_ALTVOLTAGE,
>> IIO_CCT,
>> IIO_PRESSURE,
>> + IIO_QUAT_ROT,
>> };
>>
>> enum iio_modifier {
>> @@ -52,6 +53,7 @@ enum iio_modifier {
>> IIO_MOD_LIGHT_RED,
>> IIO_MOD_LIGHT_GREEN,
>> IIO_MOD_LIGHT_BLUE,
>> + IIO_MOD_W,
>> };
>>
>> #define IIO_VAL_INT 1
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v3 7/8] iio: Add quaternion channel
2013-11-06 0:10 ` Srinivas Pandruvada
@ 2013-11-06 7:58 ` Jonathan Cameron
2013-12-06 22:44 ` Srinivas Pandruvada
0 siblings, 1 reply; 17+ messages in thread
From: Jonathan Cameron @ 2013-11-06 7:58 UTC (permalink / raw)
To: Srinivas Pandruvada; +Cc: linux-iio
Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> wrote:
>On 11/05/2013 03:10 PM, Jonathan Cameron wrote:
>> On 10/30/13 22:48, Srinivas Pandruvada wrote:
>>> A quaternion channel type is added. Here channel information is
>>> composed of four components: a vector with x, y, z coordinates and
>>> a w rotation. Reusing x, y, z channel modifiers, but added "w"
>>> component in the modifier list.
>>>
>>> Signed-off-by: Srinivas Pandruvada
><srinivas.pandruvada@linux.intel.com>
>> In brief I am against this for the same reason I didn't like this
>before.
>> A quaternion has no meaning if it isn't all present. Hence we need
>to
>> ensure that it is always presented to userspace with all four
>components
>> present.
>>
>> I'll hopefully have a few mins at the weekend to to bash out some
>example
>> code for how I would suggest we handle this.
>>
>> If you could repost the patches before this one with everything that
>should
>> be in them then hopefully we can take those whilst still 'discussing'
>> how to handle the last 2!
>Sorry about the issues with previous patches. I was trying to order new
>
>driver at the end and missed dependencies.
Not to worry. We all make that mistake occasionally!
>I have applied all patches which I am sending after this email safely
>apply to fixes-togreg branch.
>For the last two, I will wait for your suggestion.
>
>Thanks,
>Srinivas
>>
>> Jonathan
>>> ---
>>> drivers/iio/industrialio-core.c | 2 ++
>>> include/linux/iio/types.h | 2 ++
>>> 2 files changed, 4 insertions(+)
>>>
>>> diff --git a/drivers/iio/industrialio-core.c
>b/drivers/iio/industrialio-core.c
>>> index f95c697..b754f50 100644
>>> --- a/drivers/iio/industrialio-core.c
>>> +++ b/drivers/iio/industrialio-core.c
>>> @@ -66,6 +66,7 @@ static const char * const
>iio_chan_type_name_spec[] = {
>>> [IIO_ALTVOLTAGE] = "altvoltage",
>>> [IIO_CCT] = "cct",
>>> [IIO_PRESSURE] = "pressure",
>>> + [IIO_QUAT_ROT] = "quat_rot",
>>> };
>>>
>>> static const char * const iio_modifier_names[] = {
>>> @@ -80,6 +81,7 @@ static const char * const iio_modifier_names[] = {
>>> [IIO_MOD_LIGHT_RED] = "red",
>>> [IIO_MOD_LIGHT_GREEN] = "green",
>>> [IIO_MOD_LIGHT_BLUE] = "blue",
>>> + [IIO_MOD_W] = "w",
>>> };
>>>
>>> /* relies on pairs of these shared then separate */
>>> diff --git a/include/linux/iio/types.h b/include/linux/iio/types.h
>>> index 88bf0f0..4565f5c 100644
>>> --- a/include/linux/iio/types.h
>>> +++ b/include/linux/iio/types.h
>>> @@ -29,6 +29,7 @@ enum iio_chan_type {
>>> IIO_ALTVOLTAGE,
>>> IIO_CCT,
>>> IIO_PRESSURE,
>>> + IIO_QUAT_ROT,
>>> };
>>>
>>> enum iio_modifier {
>>> @@ -52,6 +53,7 @@ enum iio_modifier {
>>> IIO_MOD_LIGHT_RED,
>>> IIO_MOD_LIGHT_GREEN,
>>> IIO_MOD_LIGHT_BLUE,
>>> + IIO_MOD_W,
>>> };
>>>
>>> #define IIO_VAL_INT 1
>>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-iio"
>in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>
>
>--
>To unsubscribe from this list: send the line "unsubscribe linux-iio" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v3 7/8] iio: Add quaternion channel
2013-11-06 7:58 ` Jonathan Cameron
@ 2013-12-06 22:44 ` Srinivas Pandruvada
2013-12-07 19:49 ` Jonathan Cameron
0 siblings, 1 reply; 17+ messages in thread
From: Srinivas Pandruvada @ 2013-12-06 22:44 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio
Hi Jonathan,
On 11/05/2013 11:58 PM, Jonathan Cameron wrote:
>
> Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> wrote:
>> On 11/05/2013 03:10 PM, Jonathan Cameron wrote:
>>> On 10/30/13 22:48, Srinivas Pandruvada wrote:
>>>> A quaternion channel type is added. Here channel information is
>>>> composed of four components: a vector with x, y, z coordinates and
>>>> a w rotation. Reusing x, y, z channel modifiers, but added "w"
>>>> component in the modifier list.
>>>>
>>>> Signed-off-by: Srinivas Pandruvada
>> <srinivas.pandruvada@linux.intel.com>
>>> In brief I am against this for the same reason I didn't like this
>> before.
>>> A quaternion has no meaning if it isn't all present. Hence we need
>> to
>>> ensure that it is always presented to userspace with all four
>> components
>>> present.
>>>
>>> I'll hopefully have a few mins at the weekend to to bash out some
>> example
>>> code for how I would suggest we handle this.
>>>
>>> If you could repost the patches before this one with everything that
>> should
>>> be in them then hopefully we can take those whilst still 'discussing'
>>> how to handle the last 2!
If you get chance, please send me some info on how you want to handle this.
Thanks,
Srinivas
>> Sorry about the issues with previous patches. I was trying to order new
>>
>> driver at the end and missed dependencies.
> Not to worry. We all make that mistake occasionally!
>> I have applied all patches which I am sending after this email safely
>> apply to fixes-togreg branch.
>> For the last two, I will wait for your suggestion.
>>
>> Thanks,
>> Srinivas
>>> Jonathan
>>>> ---
>>>> drivers/iio/industrialio-core.c | 2 ++
>>>> include/linux/iio/types.h | 2 ++
>>>> 2 files changed, 4 insertions(+)
>>>>
>>>> diff --git a/drivers/iio/industrialio-core.c
>> b/drivers/iio/industrialio-core.c
>>>> index f95c697..b754f50 100644
>>>> --- a/drivers/iio/industrialio-core.c
>>>> +++ b/drivers/iio/industrialio-core.c
>>>> @@ -66,6 +66,7 @@ static const char * const
>> iio_chan_type_name_spec[] = {
>>>> [IIO_ALTVOLTAGE] = "altvoltage",
>>>> [IIO_CCT] = "cct",
>>>> [IIO_PRESSURE] = "pressure",
>>>> + [IIO_QUAT_ROT] = "quat_rot",
>>>> };
>>>>
>>>> static const char * const iio_modifier_names[] = {
>>>> @@ -80,6 +81,7 @@ static const char * const iio_modifier_names[] = {
>>>> [IIO_MOD_LIGHT_RED] = "red",
>>>> [IIO_MOD_LIGHT_GREEN] = "green",
>>>> [IIO_MOD_LIGHT_BLUE] = "blue",
>>>> + [IIO_MOD_W] = "w",
>>>> };
>>>>
>>>> /* relies on pairs of these shared then separate */
>>>> diff --git a/include/linux/iio/types.h b/include/linux/iio/types.h
>>>> index 88bf0f0..4565f5c 100644
>>>> --- a/include/linux/iio/types.h
>>>> +++ b/include/linux/iio/types.h
>>>> @@ -29,6 +29,7 @@ enum iio_chan_type {
>>>> IIO_ALTVOLTAGE,
>>>> IIO_CCT,
>>>> IIO_PRESSURE,
>>>> + IIO_QUAT_ROT,
>>>> };
>>>>
>>>> enum iio_modifier {
>>>> @@ -52,6 +53,7 @@ enum iio_modifier {
>>>> IIO_MOD_LIGHT_RED,
>>>> IIO_MOD_LIGHT_GREEN,
>>>> IIO_MOD_LIGHT_BLUE,
>>>> + IIO_MOD_W,
>>>> };
>>>>
>>>> #define IIO_VAL_INT 1
>>>>
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-iio"
>> in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v3 7/8] iio: Add quaternion channel
2013-12-06 22:44 ` Srinivas Pandruvada
@ 2013-12-07 19:49 ` Jonathan Cameron
0 siblings, 0 replies; 17+ messages in thread
From: Jonathan Cameron @ 2013-12-07 19:49 UTC (permalink / raw)
To: Srinivas Pandruvada; +Cc: linux-iio
On 12/06/13 22:44, Srinivas Pandruvada wrote:
> Hi Jonathan,
>
> On 11/05/2013 11:58 PM, Jonathan Cameron wrote:
>>
>> Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> wrote:
>>> On 11/05/2013 03:10 PM, Jonathan Cameron wrote:
>>>> On 10/30/13 22:48, Srinivas Pandruvada wrote:
>>>>> A quaternion channel type is added. Here channel information is
>>>>> composed of four components: a vector with x, y, z coordinates and
>>>>> a w rotation. Reusing x, y, z channel modifiers, but added "w"
>>>>> component in the modifier list.
>>>>>
>>>>> Signed-off-by: Srinivas Pandruvada
>>> <srinivas.pandruvada@linux.intel.com>
>>>> In brief I am against this for the same reason I didn't like this
>>> before.
>>>> A quaternion has no meaning if it isn't all present. Hence we need
>>> to
>>>> ensure that it is always presented to userspace with all four
>>> components
>>>> present.
>>>>
>>>> I'll hopefully have a few mins at the weekend to to bash out some
>>> example
>>>> code for how I would suggest we handle this.
>>>>
>>>> If you could repost the patches before this one with everything that
>>> should
>>>> be in them then hopefully we can take those whilst still 'discussing'
>>>> how to handle the last 2!
> If you get chance, please send me some info on how you want to handle this.
>
Sorry for the delay on this - I might get time tomorrow to go into this in more
detail but maybe not so I'll give a very brief outline here.
Constraints:
1) Quaternions may have 4 elements but they all interact in a way that makes
them effectively a 'single value'. Thus they need to be handled as one.
Solutions
1) Introduce a IIO_VAL_* - probably IIO_VAL_QUATERNION
2) Introduced a replacement for read_raw that has the following form
int (*read)(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int *vals,
long mask);
- for previous cases vals[0] <- val and vals[1] <- val2
- for quaternion vals[0] <- i component, vals[1] <- j component etc
3) Add a case to iio_read_channel_info in industrialio-core.c to handle
the new type and pretty print it appropriately - possibly expand
iio_format_value to handle the new parameters.
4) Buffered support is only trickier in that the buffer element needs
describing and there is a lot of possible flexibility in there...
current format is :
[be|le]:[s|u]bits/storagebits[>>shift].
Reasonable to assume that whole thing is either be or le and that elements are byte aligned
plus all are signed (but need to state this)
Hence perhaps either
[be|le]:[s|u]bitsI/storagebitsI,bitsJ/storagebitsJ,bitsK/storagebitsK,bitsA/storagebitsA
or we assume that the elements are effectively independent but have the same placement and
indicated perhaps as
be:s12/16x4 or similar?
Either way this would need some extensions to the struct iio_chan_spec substructure
scan_type.
> Thanks,
> Srinivas
>
>>> Sorry about the issues with previous patches. I was trying to order new
>>>
>>> driver at the end and missed dependencies.
>> Not to worry. We all make that mistake occasionally!
>>> I have applied all patches which I am sending after this email safely
>>> apply to fixes-togreg branch.
>>> For the last two, I will wait for your suggestion.
>>>
>>> Thanks,
>>> Srinivas
>>>> Jonathan
>>>>> ---
>>>>> drivers/iio/industrialio-core.c | 2 ++
>>>>> include/linux/iio/types.h | 2 ++
>>>>> 2 files changed, 4 insertions(+)
>>>>>
>>>>> diff --git a/drivers/iio/industrialio-core.c
>>> b/drivers/iio/industrialio-core.c
>>>>> index f95c697..b754f50 100644
>>>>> --- a/drivers/iio/industrialio-core.c
>>>>> +++ b/drivers/iio/industrialio-core.c
>>>>> @@ -66,6 +66,7 @@ static const char * const
>>> iio_chan_type_name_spec[] = {
>>>>> [IIO_ALTVOLTAGE] = "altvoltage",
>>>>> [IIO_CCT] = "cct",
>>>>> [IIO_PRESSURE] = "pressure",
>>>>> + [IIO_QUAT_ROT] = "quat_rot",
>>>>> };
>>>>> static const char * const iio_modifier_names[] = {
>>>>> @@ -80,6 +81,7 @@ static const char * const iio_modifier_names[] = {
>>>>> [IIO_MOD_LIGHT_RED] = "red",
>>>>> [IIO_MOD_LIGHT_GREEN] = "green",
>>>>> [IIO_MOD_LIGHT_BLUE] = "blue",
>>>>> + [IIO_MOD_W] = "w",
>>>>> };
>>>>> /* relies on pairs of these shared then separate */
>>>>> diff --git a/include/linux/iio/types.h b/include/linux/iio/types.h
>>>>> index 88bf0f0..4565f5c 100644
>>>>> --- a/include/linux/iio/types.h
>>>>> +++ b/include/linux/iio/types.h
>>>>> @@ -29,6 +29,7 @@ enum iio_chan_type {
>>>>> IIO_ALTVOLTAGE,
>>>>> IIO_CCT,
>>>>> IIO_PRESSURE,
>>>>> + IIO_QUAT_ROT,
>>>>> };
>>>>> enum iio_modifier {
>>>>> @@ -52,6 +53,7 @@ enum iio_modifier {
>>>>> IIO_MOD_LIGHT_RED,
>>>>> IIO_MOD_LIGHT_GREEN,
>>>>> IIO_MOD_LIGHT_BLUE,
>>>>> + IIO_MOD_W,
>>>>> };
>>>>> #define IIO_VAL_INT 1
>>>>>
>>>> --
>>>> To unsubscribe from this list: send the line "unsubscribe linux-iio"
>>> in
>>>> the body of a message to majordomo@vger.kernel.org
>>>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>>>
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2013-12-07 19:49 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-30 22:48 [PATCH v3 1/8] iio: hid_Sensors: fix crash during trigger unregister Srinivas Pandruvada
2013-10-30 22:48 ` [PATCH v3 2/8] iio: hid-sensors: accelerometer: Add sensitivity Srinivas Pandruvada
2013-11-05 23:04 ` Jonathan Cameron
2013-10-30 22:48 ` [PATCH v3 3/8] iio: hid-sensors: gyro : " Srinivas Pandruvada
2013-11-05 23:05 ` Jonathan Cameron
2013-10-30 22:48 ` [PATCH v3 4/8] iio: hid-sensors: light/als " Srinivas Pandruvada
2013-10-30 22:48 ` [PATCH v3 5/8] iio: hid-sensors: magnetometer " Srinivas Pandruvada
2013-11-05 23:06 ` Jonathan Cameron
2013-10-30 22:48 ` [PATCH v3 6/8] iio: hid-sensors: Added Inclinometer 3D Srinivas Pandruvada
2013-10-30 22:48 ` [PATCH v3 7/8] iio: Add quaternion channel Srinivas Pandruvada
2013-11-05 23:10 ` Jonathan Cameron
2013-11-06 0:10 ` Srinivas Pandruvada
2013-11-06 7:58 ` Jonathan Cameron
2013-12-06 22:44 ` Srinivas Pandruvada
2013-12-07 19:49 ` Jonathan Cameron
2013-10-30 22:48 ` [PATCH v3 8/8] iio: hid-sensors: Added device rotation support Srinivas Pandruvada
2013-11-05 22:56 ` [PATCH v3 1/8] iio: hid_Sensors: fix crash during trigger unregister Jonathan Cameron
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).