iio: hid_Sensors: fix crash during trigger unregister
Subsystems (3)
Srinivas Pandruvada
maintainerPATCH v2 1/9 iio: hid_Sensors: fix crash during trigger unregister
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.
--- 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 | 1 + 7 files changed, 18 insertions(+), 14 deletions(-)
drivers/iio/accel/hid-sensor-accel-3d.c +3 -2
@@ -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);
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +4 -5
@@ -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->trig_ptr); +iio_trigger_free (attrb->trig_ptr); }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->trig_ptr = trig;return ret;
drivers/iio/common/hid-sensors/hid-sensor-trigger.h +1 -1
@@ -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
drivers/iio/gyro/hid-sensor-gyro-3d.c +3 -2
@@ -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);
drivers/iio/light/hid-sensor-als.c +3 -2
@@ -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_attribute);iio_triggered_buffer_cleanup (indio_dev);kfree (indio_dev->channels);
drivers/iio/magnetometer/hid-sensor-magn-3d.c +3 -2
@@ -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);
include/linux/hid-sensor-hub.h +1 -0
@@ -184,6 +184,7 @@ struct hid_sensor_common {struct platform_device *pdev;unsigned usage_id;bool data_ready; +void *trig_ptr;struct hid_sensor_hub_attribute_info poll;struct hid_sensor_hub_attribute_info report_state;struct hid_sensor_hub_attribute_info power_state;
Signature · 1 line
1.8.3.2
Srinivas Pandruvada
maintainerPATCH v2 2/9 iio: hid-sensors: Add connection type
Some sensor hub firmware are very strict about the connection type setting. The connection type specifies whether it is an integrated or external sensor hub.
By default choosing integrated type unless changed via a module param.
Also a fix a minor typo for POWER_STATE.
--- drivers/iio/common/hid-sensors/hid-sensor-attributes.c | 12 +++++++++--- drivers/iio/common/hid-sensors/hid-sensor-trigger.c | 8 ++++++++ include/linux/hid-sensor-hub.h | 1 + include/linux/hid-sensor-ids.h | 6 +++++- 4 files changed, 23 insertions(+), 4 deletions(-)
drivers/iio/common/hid-sensors/hid-sensor-attributes.c +9 -3
@@ -226,7 +226,7 @@ int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev,sensor_hub_input_get_attribute_info (hsdev,HID_FEATURE_REPORT , usage_id, -HID_USAGE_SENSOR_PROY_POWER_STATE , +HID_USAGE_SENSOR_PROT_POWER_STATE , &st->power_state); sensor_hub_input_get_attribute_info(hsdev,
@@ -234,11 +234,17 @@ int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev,HID_USAGE_SENSOR_PROP_SENSITIVITY_ABS , &st->sensitivity); -hid_dbg (hsdev->hdev,"common attributes: %x:%x, %x:%x, %x:%x %x:%x\n" , +sensor_hub_input_get_attribute_info (hsdev, +HID_FEATURE_REPORT , usage_id, +HID_USAGE_SENSOR_PROP_SENSOR_CONNECTION_TYPE , + &st->conn_type); + +hid_dbg (hsdev->hdev,"common attributes: %x:%x, %x:%x, %x:%x %x:%x %x:%x\n" , st->poll.index, st->poll.report_id, st->report_state.index, st->report_state.report_id, st->power_state.index, st->power_state.report_id, - st->sensitivity.index, st->sensitivity.report_id); + st->sensitivity.index, st->sensitivity.report_id, + st->conn_type.index, st->conn_type.report_id);return 0 ; }
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +8 -0
@@ -34,6 +34,10 @@ module_param(hid_sensor_named_array_base, int, 0644);MODULE_PARM_DESC (hid_sensor_named_array_base,"HID SENSOR NAMED ARRAY BASE (0 or 1)." ); +static int hid_sensor_conn_type =HID_USAGE_SENSOR_PROP_CONNEC_TYPE_PC_INT_ENUM ; +module_param (hid_sensor_conn_type, int,0644 ); +MODULE_PARM_DESC (hid_sensor_conn_type,"HID SENSOR CONNECT TYPE (1 to 3)." ); +static int hid_sensor_data_rdy_trigger_set_state (struct iio_trigger *trig,bool state) {
@@ -68,6 +72,10 @@ static int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig, st->report_state.index, (s32)report_state); +sensor_hub_set_feature (st->hsdev, st->conn_type.report_id, + st->conn_type.index, + hid_sensor_conn_type); +return 0 ; }
include/linux/hid-sensor-hub.h +1 -0
@@ -189,6 +189,7 @@ struct hid_sensor_common {struct hid_sensor_hub_attribute_info report_state;struct hid_sensor_hub_attribute_info power_state;struct hid_sensor_hub_attribute_info sensitivity; +struct hid_sensor_hub_attribute_info conn_type; };/* Convert from hid unit expo to regular exponent */
include/linux/hid-sensor-ids.h +5 -1
@@ -106,6 +106,7 @@#define HID_USAGE_SENSOR_UNITS_DEGREES_PER_SECOND 0x15/* Common selectors */ +#define HID_USAGE_SENSOR_PROP_SENSOR_CONNECTION_TYPE 0x200309#define HID_USAGE_SENSOR_PROP_REPORT_INTERVAL 0x20030E#define HID_USAGE_SENSOR_PROP_SENSITIVITY_ABS 0x20030F#define HID_USAGE_SENSOR_PROP_SENSITIVITY_RANGE_PCT 0x200310
@@ -115,7 +116,10 @@#define HID_USAGE_SENSOR_PROP_RANGE_MAXIMUM 0x200314#define HID_USAGE_SENSOR_PROP_RANGE_MINIMUM 0x200315#define HID_USAGE_SENSOR_PROP_REPORT_STATE 0x200316 -#define HID_USAGE_SENSOR_PROY_POWER_STATE 0x200319 +#define HID_USAGE_SENSOR_PROT_POWER_STATE 0x200319 + +/* Default connection type */ +#define HID_USAGE_SENSOR_PROP_CONNEC_TYPE_PC_INT_ENUM 0x01/* Power state enumerations */ #define HID_USAGE_SENSOR_PROP_POWER_STATE_UNDEFINED_ENUM 0x00
Signature · 1 line
1.8.3.2
Srinivas Pandruvada
maintainerPATCH v2 3/9 iio: hid-sensors: accelerometer: Add sensitivity
In reply to Srinivas PandruvadaA 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.
--- drivers/iio/accel/hid-sensor-accel-3d.c | 12 ++++++++++++ include/linux/hid-sensor-ids.h | 1 + 2 files changed, 13 insertions(+)
drivers/iio/accel/hid-sensor-accel-3d.c +12 -0
@@ -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; }
include/linux/hid-sensor-ids.h +1 -0
@@ -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
Signature · 1 line
1.8.3.2
Srinivas Pandruvada
maintainerPATCH v2 4/9 iio: hid-sensors: gyro : Add sensitivity
In reply to Srinivas PandruvadaA 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.
--- drivers/iio/gyro/hid-sensor-gyro-3d.c | 11 +++++++++++ include/linux/hid-sensor-ids.h | 1 + 2 files changed, 12 insertions(+)
drivers/iio/gyro/hid-sensor-gyro-3d.c +11 -0
@@ -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; }
include/linux/hid-sensor-ids.h +1 -0
@@ -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
Signature · 1 line
1.8.3.2
Srinivas Pandruvada
maintainerPATCH v2 5/9 iio: hid-sensors: light/als : Add sensitivity
In reply to Srinivas PandruvadaA 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.
--- drivers/iio/light/hid-sensor-als.c | 13 ++++++++++++- include/linux/hid-sensor-ids.h | 1 + 2 files changed, 13 insertions(+), 1 deletion(-)
drivers/iio/light/hid-sensor-als.c +12 -1
@@ -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; }
@@ -330,7 +341,7 @@ static int hid_als_remove(struct platform_device *pdev)sensor_hub_remove_callback (hsdev,HID_USAGE_SENSOR_ALS );iio_device_unregister (indio_dev); -hid_sensor_remove_trigger (&als_state->common_attribute); +hid_sensor_remove_trigger (&als_state->common_attributes);iio_triggered_buffer_cleanup (indio_dev);kfree (indio_dev->channels);
include/linux/hid-sensor-ids.h +1 -0
@@ -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) */
Signature · 1 line
1.8.3.2
Srinivas Pandruvada
maintainerPATCH v2 6/9 iio: hid-sensors: magnetometer : Add sensitivity
In reply to Srinivas PandruvadaA 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.
--- drivers/iio/magnetometer/hid-sensor-magn-3d.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/iio/magnetometer/hid-sensor-magn-3d.c +12 -0
@@ -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; }
Signature · 1 line
1.8.3.2
Srinivas Pandruvada
maintainerPATCH v2 7/9 iio: hid-sensors: Added Inclinometer 3D
In reply to Srinivas PandruvadaAdded 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.
--- 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
drivers/iio/Kconfig +1 -0
@@ -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
drivers/iio/Makefile +1 -0
@@ -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/
drivers/iio/orientation/Kconfig new file +19 -0
@@ -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
drivers/iio/orientation/Makefile new file +6 -0
@@ -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
drivers/iio/orientation/hid-sensor-incl-3d.c new file +428 -0
428 lines not on this page · raw message
include/linux/hid-sensor-ids.h +9 -0
@@ -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
@@ -136,4 +141,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
Signature · 1 line
1.8.3.2
Jonathan Cameron
maintainerRe: [PATCH v2 7/9] iio: hid-sensors: Added Inclinometer 3D
Quoted 6 lines · 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 <[email protected]>
Looks good. One little comment inline... I'd probably not have mentioned that but as there is going to be another version fo the series, might as well tidy it up ;)
Thanks,
Quoted 23 lines
drivers/iio/orientation/hid-sensor-incl-3d.c new file +23
-0+/* Channel definitions */ +static const struct iio_chan_spec incl_3d_channels[] = { + { + .type =IIO_INCLI , + .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_INCLI , + .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_INCLI , + .modified =1 ,
drivers/iio/orientation/hid-sensor-incl-3d.c
Quoted 10 lines
drivers/iio/orientation/hid-sensor-incl-3d.c new file +10
-0+ .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, + } +}; + +/* Adjust channel real bits based on report
This would be cleaner if it just took the channel in question? so
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;
}then call as
incl_3d_adjust_channel_bit_mask(&channels[CHANNEL_SCAN_INDEX_X], st->incl[CHANNEL_SCAN_INDEX_X].size);
Quoted 10 lines
drivers/iio/orientation/hid-sensor-incl-3d.c new file +10
-0+static void incl_3d_adjust_channel_bit_mask (struct iio_chan_spec *channels, +int channel,int size) +{ + channels[channel].scan_type.sign ='s' ; +/* Real storage bits will change based on the report desc. */ + channels[channel].scan_type.realbits = size *8 ; +/* Maximum size of a sample to capture is u32 */ + channels[channel].scan_type.storagebits =sizeof (u32) *8 ; +} +
...
Jonathan Cameron
maintainerRe: [PATCH v2 7/9] iio: hid-sensors: Added Inclinometer 3D
Quoted 10 lines · Jonathan Cameron
Quoted 6 lines · 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 <[email protected]>Looks good. One little comment inline... I'd probably not have mentioned that but as there is going to be another version fo the series, might as well tidy it up ;)
Just noticed another point to fix. In read raw you have case 0:
We long ago defined IIO_CHAN_INFO_RAW to be 0 so please use the enum rather than 0.
I'm guessing this might want some tidy up patches for any other remaining uses as well.
Quoted 69 lines
Thanks,
Quoted 23 lines
drivers/iio/orientation/hid-sensor-incl-3d.c new file +23
-0+/* Channel definitions */ +static const struct iio_chan_spec incl_3d_channels[] = { + { + .type =IIO_INCLI , + .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_INCLI , + .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_INCLI , + .modified =1 ,drivers/iio/orientation/hid-sensor-incl-3d.c
Quoted 10 lines
drivers/iio/orientation/hid-sensor-incl-3d.c new file +10
-0+ .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, + } +}; + +/* Adjust channel real bits based on report This would be cleaner if it just took the channel in question? so
static void incl_3d_adjust_channel_bit_mask(structiio_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; }then call as
incl_3d_adjust_channel_bit_mask(&channels[CHANNEL_SCAN_INDEX_X], st->incl[CHANNEL_SCAN_INDEX_X].size);drivers/iio/orientation/hid-sensor-incl-3d.c line 95
Quoted 10 lines
drivers/iio/orientation/hid-sensor-incl-3d.c new file +10
-0+static void incl_3d_adjust_channel_bit_mask (struct iio_chan_spec *channels, +int channel,int size) +{ + channels[channel].scan_type.sign ='s' ; +/* Real storage bits will change based on the report desc. */ + channels[channel].scan_type.realbits = size *8 ; +/* Maximum size of a sample to capture is u32 */ + channels[channel].scan_type.storagebits =sizeof (u32) *8 ; +} +...
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Srinivas Pandruvada
maintainerPATCH v2 8/9 iio: Add channel modifiers for Quaternion Rotations
In reply to Srinivas PandruvadaA quaternion is composed of four components: a vector with x, y, z coordinates and a w rotation. Added channel modifiers for exporting these four components via user space.
--- drivers/iio/industrialio-core.c | 4 ++++ include/linux/iio/types.h | 4 ++++ 2 files changed, 8 insertions(+)
drivers/iio/industrialio-core.c +4 -0
@@ -80,6 +80,10 @@ static const char * const iio_modifier_names[] = { [IIO_MOD_LIGHT_RED] = "red", [IIO_MOD_LIGHT_GREEN] = "green", [IIO_MOD_LIGHT_BLUE] = "blue", + [IIO_MOD_QUATERNION_X] = "quat_x", + [IIO_MOD_QUATERNION_Y] = "quat_y", + [IIO_MOD_QUATERNION_Z] = "quat_z", + [IIO_MOD_QUATERNION_W] = "quat_w", };/* relies on pairs of these shared then separate */
include/linux/iio/types.h +4 -0
@@ -52,6 +52,10 @@ enum iio_modifier {IIO_MOD_LIGHT_RED ,IIO_MOD_LIGHT_GREEN ,IIO_MOD_LIGHT_BLUE , +IIO_MOD_QUATERNION_X , +IIO_MOD_QUATERNION_Y , +IIO_MOD_QUATERNION_Z , + IIO_MOD_QUATERNION_W, };#define IIO_VAL_INT 1
Signature · 1 line
1.8.3.2
Jonathan Cameron
maintainerRe: [PATCH v2 8/9] iio: Add channel modifiers for Quaternion Rotations
Quoted 5 lines · Srinivas Pandruvada
A quaternion is composed of four components: a vector with x, y, z coordinates and a w rotation. Added channel modifiers for exporting these four components via user space.
Signed-off-by Srinivas Pandruvada <[email protected]>
Quaternions are one of the 'interesting' cases that make me wonder if we need a slightly more generic form of read_raw. The quaternion only has meaning with an associated scale. Hence you really have to guarantee that you can grab all 4 components together.
Do we need to rethink how the read callback works?
Mind you, if we do that then we need to extend the description of the buffer element in the scan_mask. We could define a compound description for a channel, but that is 'interesting'.
I also don't like this being defined as type IIO_ROT - the units (such as exist are different). See next patch for what I'm referring to here.
I've cc'd a few people who might have views on this.
Quoted 36 lines
--- drivers/iio/industrialio-core.c | 4 ++++ include/linux/iio/types.h | 4 ++++ 2 files changed, 8 insertions(+)drivers/iio/industrialio-core.c +4
-0@@ -80,6 +80,10 @@ static const char * const iio_modifier_names[] = { [IIO_MOD_LIGHT_RED] = "red", [IIO_MOD_LIGHT_GREEN] = "green", [IIO_MOD_LIGHT_BLUE] = "blue", + [IIO_MOD_QUATERNION_X] = "quat_x", + [IIO_MOD_QUATERNION_Y] = "quat_y", + [IIO_MOD_QUATERNION_Z] = "quat_z", + [IIO_MOD_QUATERNION_W] = "quat_w", };/* relies on pairs of these shared then separate */ include/linux/iio/types.h +4
-0@@ -52,6 +52,10 @@ enum iio_modifier {IIO_MOD_LIGHT_RED ,IIO_MOD_LIGHT_GREEN ,IIO_MOD_LIGHT_BLUE , +IIO_MOD_QUATERNION_X , +IIO_MOD_QUATERNION_Y , +IIO_MOD_QUATERNION_Z , + IIO_MOD_QUATERNION_W, };#define IIO_VAL_INT 1
Srinivas Pandruvada
maintainerRe: [PATCH v2 8/9] iio: Add channel modifiers for Quaternion Rotations
Hi Jonathan,
Quoted 11 lines · Jonathan Cameron
Quoted 5 lines · Srinivas Pandruvada
A quaternion is composed of four components: a vector with x, y, z coordinates and a w rotation. Added channel modifiers for exporting these four components via user space.
Signed-off-by Srinivas Pandruvada <[email protected]>Quaternions are one of the 'interesting' cases that make me wonder if we need a slightly more generic form of
read_raw. The quaternion only has meaning with an associated scale. Hence you really have to guarantee that you can grab all 4 components together.
Quoted 7 lines
Do we need to rethink how the read callback works?
Mind you, if we do that then we need to extend the description of the buffer element in the
scan_mask. We could define a compound description for a channel, but that is 'interesting'.I also don't like this being defined as type
IIO_ROT- the units (such as exist are different). See next patch for what I'm referring to here.
I didn't receive your next patch with comments. Can you please resend? Thanks,
Srinivas
Quoted 40 lines
I've cc'd a few people who might have views on this.
Quoted 36 lines
--- drivers/iio/industrialio-core.c | 4 ++++ include/linux/iio/types.h | 4 ++++ 2 files changed, 8 insertions(+)drivers/iio/industrialio-core.c +4
-0@@ -80,6 +80,10 @@ static const char * const iio_modifier_names[] = { [IIO_MOD_LIGHT_RED] = "red", [IIO_MOD_LIGHT_GREEN] = "green", [IIO_MOD_LIGHT_BLUE] = "blue", + [IIO_MOD_QUATERNION_X] = "quat_x", + [IIO_MOD_QUATERNION_Y] = "quat_y", + [IIO_MOD_QUATERNION_Z] = "quat_z", + [IIO_MOD_QUATERNION_W] = "quat_w", };/* relies on pairs of these shared then separate */ include/linux/iio/types.h +4
-0@@ -52,6 +52,10 @@ enum iio_modifier {IIO_MOD_LIGHT_RED ,IIO_MOD_LIGHT_GREEN ,IIO_MOD_LIGHT_BLUE , +IIO_MOD_QUATERNION_X , +IIO_MOD_QUATERNION_Y , +IIO_MOD_QUATERNION_Z , + IIO_MOD_QUATERNION_W, };#define IIO_VAL_INT 1
Jonathan Cameron
maintainerRe: [PATCH v2 8/9] iio: Add channel modifiers for Quaternion Rotations
Quoted 15 lines · Srinivas Pandruvada
Hi Jonathan,
Quoted 13 lines · Jonathan Cameron
Quoted 5 lines · Srinivas Pandruvada
A quaternion is composed of four components: a vector with x, y, z coordinates and a w rotation. Added channel modifiers for exporting these four components via user space.
Signed-off-by Srinivas Pandruvada <[email protected]>Quaternions are one of the 'interesting' cases that make me wonder if we need a slightly more generic form of
read_raw. The quaternion only has meaning with an associated scale. Hence you really have to guarantee that you can grab all 4 components together.Do we need to rethink how the read callback works?
Quoted 7 lines
Quoted 5 lines
Mind you, if we do that then we need to extend the description of the buffer element in the
scan_mask. We could define a compound description for a channel, but that is 'interesting'.I also don't like this being defined as type
IIO_ROT- the units (such as exist are different). See next patch for what I'm referring to here.I didn't receive your next patch with comments. Can you please resend? Thanks,
Sorry for not being clear, I simply meant the IIO_ROT bit was in the next batch, but as it is connected to my comment here, didn't want to start another discussion in reply to that patch.
(hence I never replied to that patch)
Quoted 44 lines
Srinivas
Quoted 38 lines
I've cc'd a few people who might have views on this.
Quoted 34 lines
--- drivers/iio/industrialio-core.c | 4 ++++ include/linux/iio/types.h | 4 ++++ 2 files changed, 8 insertions(+)drivers/iio/industrialio-core.c +4
-0@@ -80,6 +80,10 @@ static const char * const iio_modifier_names[] = { [IIO_MOD_LIGHT_RED] = "red", [IIO_MOD_LIGHT_GREEN] = "green", [IIO_MOD_LIGHT_BLUE] = "blue", + [IIO_MOD_QUATERNION_X] = "quat_x", + [IIO_MOD_QUATERNION_Y] = "quat_y", + [IIO_MOD_QUATERNION_Z] = "quat_z", + [IIO_MOD_QUATERNION_W] = "quat_w", };/* relies on pairs of these shared then separate */ include/linux/iio/types.h +4
-0@@ -52,6 +52,10 @@ enum iio_modifier {IIO_MOD_LIGHT_RED ,IIO_MOD_LIGHT_GREEN ,IIO_MOD_LIGHT_BLUE , +IIO_MOD_QUATERNION_X , +IIO_MOD_QUATERNION_Y , +IIO_MOD_QUATERNION_Z , + IIO_MOD_QUATERNION_W, };#define IIO_VAL_INT 1Signature · 3 lines
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Srinivas Pandruvada
maintainerRe: [PATCH v2 8/9] iio: Add channel modifiers for Quaternion Rotations
Quoted 8 lines · Jonathan Cameron
Quoted 7 lines · Srinivas Pandruvada
Hi Jonathan,
Quoted 5 lines · Jonathan Cameron
Quoted 4 lines · Srinivas Pandruvada
A quaternion is composed of four components: a vector with x, y, z coordinates and a w rotation. Added channel modifiers for exporting these four components via user space.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Signed-off-by Srinivas Pandruvada <[email protected]>Quaternions are one of the 'interesting' cases that make me wonder if we need a slightly more generic form of
read_raw. The quaternion only has meaning with an associated scale. Hence you really have to guarantee that you can grab all 4 components together.
What if we add two members in iio_chan_info:IIO_CHAN_INFO_TRIG_RAW_SYNC (WR): To trigger a read of and store sample in internal memory
(As per HID sensor spec you have to read/write all quaternion components together, data is also packed together. ) IIO_CHAN_INFO_RAW_SYNC (RD): To return individual channel raw data captured during IIO_CHAN_INFO_TRIG_RAW_SYNC In this way four reads will give all component data but they are related to each other.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Do we need to rethink how the read callback works?
Mind you, if we do that then we need to extend the description of the buffer element in the
scan_mask. We could define a compound description for a channel, but that is 'interesting'.
For scan elements we have to specify a way so that the scan_elem doesn't contain per channel enable/disable. We create one global channel enable sysfs entry. This is what you are thinking?
Thanks,
Srinivas
Quoted 52 lines
Quoted 4 lines
Quoted 2 lines
I also don't like this being defined as type
IIO_ROT- the units (such as exist are different). See next patch for what I'm referring to here.I didn't receive your next patch with comments. Can you please resend? Thanks,
Sorry for not being clear, I simply meant the
IIO_ROTbit was in the next batch, but as it is connected to my comment here, didn't want to start another discussion in reply to that patch.(hence I never replied to that patch)
Quoted 43 lines
Srinivas
Quoted 38 lines
I've cc'd a few people who might have views on this.
Quoted 34 lines
--- drivers/iio/industrialio-core.c | 4 ++++ include/linux/iio/types.h | 4 ++++ 2 files changed, 8 insertions(+)drivers/iio/industrialio-core.c +4
-0@@ -80,6 +80,10 @@ static const char * const iio_modifier_names[] = { [IIO_MOD_LIGHT_RED] = "red", [IIO_MOD_LIGHT_GREEN] = "green", [IIO_MOD_LIGHT_BLUE] = "blue", + [IIO_MOD_QUATERNION_X] = "quat_x", + [IIO_MOD_QUATERNION_Y] = "quat_y", + [IIO_MOD_QUATERNION_Z] = "quat_z", + [IIO_MOD_QUATERNION_W] = "quat_w", };/* relies on pairs of these shared then separate */ include/linux/iio/types.h +4
-0@@ -52,6 +52,10 @@ enum iio_modifier {IIO_MOD_LIGHT_RED ,IIO_MOD_LIGHT_GREEN ,IIO_MOD_LIGHT_BLUE , +IIO_MOD_QUATERNION_X , +IIO_MOD_QUATERNION_Y , +IIO_MOD_QUATERNION_Z , + IIO_MOD_QUATERNION_W, };#define IIO_VAL_INT 1Signature · 3 lines
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Jonathan Cameron
maintainerRe: [PATCH v2 8/9] iio: Add channel modifiers for Quaternion Rotations
Quoted 19 lines · Srinivas Pandruvada
Quoted 6 lines · Jonathan Cameron
Quoted 5 lines · Srinivas Pandruvada
Hi Jonathan,
Quoted 3 lines · Jonathan Cameron
Quoted 2 lines · Srinivas Pandruvada
A quaternion is composed of four components: a vector with x, y, z coordinates and a w rotation. Added channel modifiers for
exporting
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
these four components via user space.
Signed-off-by Srinivas PandruvadaQuoted 1 line
Quoted 1 line
Quoted 1 line
Quaternions are one of the 'interesting' cases that make me wonder
if we need
Quoted 1 line
Quoted 1 line
Quoted 1 line
a slightly more generic form of
read_raw. The quaternion only hasmeaning
Quoted 1 line
Quoted 1 line
Quoted 1 line
with an associated scale. Hence you really have to guarantee that
you can grab all
Quoted 1 line
Quoted 1 line
Quoted 1 line
4 components together.
Quoted 12 lines
What if we add two members in
iio_chan_info:IIO_CHAN_INFO_TRIG_RAW_SYNC(WR): To trigger a read of and store sample
in internal memory
(As per HID sensor spec you have to read/write all quaternion components
together, data is also packed together. )IIO_CHAN_INFO_RAW_SYNC(RD): To return individual channel raw data captured duringIIO_CHAN_INFO_TRIG_RAW_SYNC
In this way four reads will give all component data but they are related
to each other.
That is a bit ugly. I would rather consider a single channel that outputs all 4 components and change the handling to cope. If people want synchronized data across multiple normal channels then they should be using the buffer...
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Do we need to rethink how the read callback works?
Mind you, if we do that then we need to extend the description of
Quoted 8 lines
the buffer element
Quoted 1 line
Quoted 1 line
Quoted 1 line
in the
scan_mask. We could define a compound description for achannel, but that is 'interesting'.
For scan elements we have to specify a way so that thescan_elemdoesn't
contain per channel enable/disable.
We create one global channel enable sysfs entry. This is what you are thinking?
No. Either we have a single channel which contains all 4 components or just handle them separately. If anyone requests only some of them from user space it does not matter to us even if the data will be useless.
Quoted 69 lines
Thanks,
SrinivasQuoted 1 line
Quoted 1 line
Quoted 1 line
I also don't like this being defined as type
IIO_ROT- the units(such as exist are different).
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
See next patch for what I'm referring to here.
I didn't receive your next patch with comments. Can you please
resend?
Quoted 2 lines
Quoted 1 line
Thanks,
Sorry for not being clear, I simply meant the
IIO_ROTbit was in thenext batch,
Quoted 1 line
but as it is connected to my comment here, didn't want to start
another discussion
Quoted 8 lines
in reply to that patch.
(hence I never replied to that patch)
Quoted 5 lines
Srinivas
Quoted 4 lines
I've cc'd a few people who might have views on this.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Review
Quoted 6 lines
--- drivers/iio/industrialio-core.c | 4 ++++ include/linux/iio/types.h | 4 ++++ 2 files changed, 8 insertions(+)(quoted diff) +0
-0
b/drivers/iio/industrialio-core.cQuoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/iio/industrialio-core.c static const char * const iio_modifier_names[]
Quoted 4 lines
index f95c697..4ffaead 100644
drivers/iio/industrialio-core.c +0
-0@@ -80,6 +80,10 @@ static const char * const iio_modifier_names[]= {
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
drivers/iio/industrialio-core.c +4
-0[IIO_MOD_LIGHT_RED] = "red", [IIO_MOD_LIGHT_GREEN] = "green", [IIO_MOD_LIGHT_BLUE] = "blue", + [IIO_MOD_QUATERNION_X] = "quat_x", + [IIO_MOD_QUATERNION_Y] = "quat_y", + [IIO_MOD_QUATERNION_Z] = "quat_z", + [IIO_MOD_QUATERNION_W] = "quat_w", };/* relies on pairs of these shared then separate */ include/linux/iio/types.h +1
-0@@ -52,6 +52,10 @@ enum iio_modifier {IIO_MOD_LIGHT_RED ,IIO_MOD_LIGHT_GREEN ,IIO_MOD_LIGHT_BLUE , + IIO_MOD_QUATERNION_X,Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
include/linux/iio/types.h +3
-0+IIO_MOD_QUATERNION_Y , +IIO_MOD_QUATERNION_Z , + IIO_MOD_QUATERNION_W, };#define IIO_VAL_INT 1Signature · 1 line
To unsubscribe from this list: send the line "unsubscribe linux-iio"in
Quoted 2 lines
Quoted 2 lines
the body of a message to [email protected]
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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 1 line
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
Srinivas Pandruvada
maintainerPATCH v2 9/9 iio: hid-sensors: Added device rotation support
In reply to Srinivas PandruvadaAdded 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 quaternion rotation components.
--- drivers/iio/orientation/Kconfig | 11 + drivers/iio/orientation/Makefile | 1 + drivers/iio/orientation/hid-sensor-rotation.c | 426 ++++++++++++++++++++++++++ include/linux/hid-sensor-ids.h | 1 + 4 files changed, 439 insertions(+) create mode 100644 drivers/iio/orientation/hid-sensor-rotation.c
drivers/iio/orientation/Kconfig +11 -0
@@ -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
drivers/iio/orientation/Makefile +1 -0
@@ -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
drivers/iio/orientation/hid-sensor-rotation.c new file +426 -0
426 lines not on this page · raw message
include/linux/hid-sensor-ids.h +1 -0
@@ -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
Signature · 1 line
1.8.3.2
Jonathan Cameron
maintainerQuoted 7 lines · Srinivas Pandruvada
We can't store the trigger instance created by
iio_trigger_alloc, in trig field ofiio_devicestructure. This needs to be stored in the driver private data. Othewise it can result in crash during module unload. Hence created atrig_ptrin the common data structure for each HID sensor IIO driver and storing here.Signed-off-by Srinivas Pandruvada <[email protected]>
Other than the use of a void * this is fine. Please fix that little issue up...
include/linux/hid-sensor-hub.h struct hid_sensor_common { · line 187
Quoted 7 lines
include/linux/hid-sensor-hub.h +1
-0@@ -184,6 +184,7 @@ struct hid_sensor_common {struct platform_device *pdev;unsigned usage_id;bool data_ready; +void *trig_ptr;
Why a void *? It's struct iio_trigger *
Just put
struct iio_trigger;
above if you want to (reasonably) avoid including the header. Don't use a void pointer unless you really have no way of knowing what the type is.
Quoted 4 lines
include/linux/hid-sensor-hub.h +0
-0struct hid_sensor_hub_attribute_info poll;struct hid_sensor_hub_attribute_info report_state;struct hid_sensor_hub_attribute_info power_state;
Quoted 10 lines · Jonathan Cameron
Quoted 7 lines · Srinivas Pandruvada
We can't store the trigger instance created by
iio_trigger_alloc, in trig field ofiio_devicestructure. This needs to be stored in the driver private data. Othewise it can result in crash during module unload. Hence created atrig_ptrin the common data structure for each HID sensor IIO driver and storing here.Signed-off-by Srinivas Pandruvada <[email protected]>Other than the use of a void * this is fine. Please fix that little issue up...
Quoted 13 lines
include/linux/hid-sensor-hub.h struct hid_sensor_common { · line 187
Quoted 7 lines
include/linux/hid-sensor-hub.h +1
-0@@ -184,6 +184,7 @@ struct hid_sensor_common {struct platform_device *pdev;unsigned usage_id;bool data_ready; +void *trig_ptr;Why a void *? It's struct
iio_trigger*
Just put
structiio_trigger;
above if you want to (reasonably) avoid including the header. Don't use a void pointer unless you really have no way of knowing what the type is.
Also just 'trigger' might be a better name then 'trig_ptr'.
Quoted 10 lines
include/linux/hid-sensor-hub.h struct hid_sensor_common { · line 190
Quoted 5 lines
include/linux/hid-sensor-hub.h +0
-0struct hid_sensor_hub_attribute_info poll;struct hid_sensor_hub_attribute_info report_state;struct hid_sensor_hub_attribute_info power_state;--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Srinivas Pandruvada
maintainerQuoted 24 lines · Lars-Peter Clausen
Quoted 10 lines · Jonathan Cameron
Quoted 7 lines · Srinivas Pandruvada
We can't store the trigger instance created by
iio_trigger_alloc, in trig field ofiio_devicestructure. This needs to be stored in the driver private data. Othewise it can result in crash during module unload. Hence created atrig_ptrin the common data structure for each HID sensor IIO driver and storing here.Signed-off-by Srinivas Pandruvada <[email protected]>Other than the use of a void * this is fine. Please fix that little issue up...
Quoted 13 lines
include/linux/hid-sensor-hub.h struct hid_sensor_common { · line 187
Quoted 7 lines
include/linux/hid-sensor-hub.h +1
-0@@ -184,6 +184,7 @@ struct hid_sensor_common {struct platform_device *pdev;unsigned usage_id;bool data_ready; +void *trig_ptr;Why a void *? It's struct
iio_trigger*
Just put
structiio_trigger;
above if you want to (reasonably) avoid including the header. Don't use a void pointer unless you really have no way of knowing what the type is.
Quoted 1 line
Also just 'trigger' might be a better name then '
trig_ptr'.
Will change in next patch along with the suggestions from Jonathan.
Thanks,
Srinivas
Quoted 14 lines
Quoted 9 lines
include/linux/hid-sensor-hub.h struct hid_sensor_common { · line 190
Quoted 4 lines
include/linux/hid-sensor-hub.h +0
-0struct hid_sensor_hub_attribute_info poll;struct hid_sensor_hub_attribute_info report_state;struct hid_sensor_hub_attribute_info power_state;--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html