All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH 1/2] iio: Add support for linear accel
  2017-01-03 15:13 ` Song Hongyan
  (?)
@ 2017-01-03  7:22 ` Peter Meerwald-Stadler
  2017-01-03  7:47     ` Song, Hongyan
  -1 siblings, 1 reply; 12+ messages in thread
From: Peter Meerwald-Stadler @ 2017-01-03  7:22 UTC (permalink / raw)
  To: Song Hongyan; +Cc: linux-input, linux-iio, jikos, jic23, srinivas.pandruvada

[-- Attachment #1: Type: TEXT/PLAIN, Size: 3456 bytes --]


> Add new channel types support for linear accel sensor.
> 
> Linear acceleration differs from a standard accelerometor,
> its value depends on standard accel sensor and gravity sensor.
> Conceptually, this three sensors have following relationship:
> linear acceleration = acceleration - acceleration due to gravity
> 
> At rest, standard accelerometer displays 1g due to earth’s
> gravitational pull while a liner accelerometer will show 0g.

comment below
 
> More information can be found in:
> http://www.usb.org/developers/hidpage/HUTRR59_-_Usages_for_Wearables.pdf
> 
> Signed-off-by: Song Hongyan <hongyan.song@intel.com>
> ---
>  Documentation/ABI/testing/sysfs-bus-iio | 10 ++++++++++
>  drivers/iio/industrialio-core.c         |  1 +
>  include/uapi/linux/iio/types.h          |  1 +
>  tools/iio/iio_event_monitor.c           |  2 ++
>  4 files changed, 14 insertions(+)
> 
> diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio
> index 60b7406..8091f3d 100644
> --- a/Documentation/ABI/testing/sysfs-bus-iio
> +++ b/Documentation/ABI/testing/sysfs-bus-iio
> @@ -170,6 +170,16 @@ Description:
>  		Has all of the equivalent parameters as per voltageY. Units
>  		after application of scale and offset are m/s^2.
>  
> +What:		/sys/bus/iio/devices/iio:deviceX/in_linear_accel_x_raw
> +What:		/sys/bus/iio/devices/iio:deviceX/in_linear_accel_y_raw
> +What:		/sys/bus/iio/devices/iio:deviceX/in_linear_accel_z_raw

I think this would be in_linearaccel_x_raw, etc.?

> +KernelVersion:	4.11
> +Contact:	linux-iio@vger.kernel.org
> +Description:
> +		Linear Acceleration in direction x, y or z (may be arbitrarily assigned
> +		but should match other such assignments on device).
> +		Has all of the equivalent parameters as per voltageY. Units
> +		after application of scale and offset are m/s^2.
>  
>  What:		/sys/bus/iio/devices/iio:deviceX/in_gravity_x_raw
>  What:		/sys/bus/iio/devices/iio:deviceX/in_gravity_y_raw
> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
> index 72fc96a..da78c26 100644
> --- a/drivers/iio/industrialio-core.c
> +++ b/drivers/iio/industrialio-core.c
> @@ -82,6 +82,7 @@ struct bus_type iio_bus_type = {
>  	[IIO_UVINDEX] = "uvindex",
>  	[IIO_ELECTRICALCONDUCTIVITY] = "electricalconductivity",
>  	[IIO_GRAVITY]  = "gravity",
> +	[IIO_LINEAR_ACCEL] = "linearaccel",
>  };
>  
>  static const char * const iio_modifier_names[] = {
> diff --git a/include/uapi/linux/iio/types.h b/include/uapi/linux/iio/types.h
> index d3f7ba7..d6df101 100644
> --- a/include/uapi/linux/iio/types.h
> +++ b/include/uapi/linux/iio/types.h
> @@ -41,6 +41,7 @@ enum iio_chan_type {
>  	IIO_UVINDEX,
>  	IIO_ELECTRICALCONDUCTIVITY,
>  	IIO_GRAVITY,
> +	IIO_LINEAR_ACCEL,
>  };
>  
>  enum iio_modifier {
> diff --git a/tools/iio/iio_event_monitor.c b/tools/iio/iio_event_monitor.c
> index b61245e..116644a 100644
> --- a/tools/iio/iio_event_monitor.c
> +++ b/tools/iio/iio_event_monitor.c
> @@ -58,6 +58,7 @@
>  	[IIO_PH] = "ph",
>  	[IIO_UVINDEX] = "uvindex",
>  	[IIO_GRAVITY] = "gravity",
> +	[IIO_LINEAR_ACCEL] = "linearaccel",
>  };
>  
>  static const char * const iio_ev_type_text[] = {
> @@ -151,6 +152,7 @@ static bool event_is_known(struct iio_event_data *event)
>  	case IIO_PH:
>  	case IIO_UVINDEX:
>  	case IIO_GRAVITY:
> +	case IIO_LINEAR_ACCEL:
>  		break;
>  	default:
>  		return false;
> 

-- 

Peter Meerwald-Stadler
+43-664-2444418 (mobile)

^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [PATCH 1/2] iio: Add support for linear accel
  2017-01-03  7:22 ` Peter Meerwald-Stadler
@ 2017-01-03  7:47     ` Song, Hongyan
  0 siblings, 0 replies; 12+ messages in thread
From: Song, Hongyan @ 2017-01-03  7:47 UTC (permalink / raw)
  To: Peter Meerwald-Stadler
  Cc: linux-input, linux-iio, jikos, jic23, Pandruvada, Srinivas

Hi peter,
	 I checked and find that iio device name is usually named to be with underline if it has more than one word, so I assigned to be " linear_accel_3d".
 I think the device property node named to be "in_linear_accel_x_raw" is better than " in_linearaccel_x_raw" Just follow the former coding style.

"linearaccel" is only a name which specify IIO type [IIO_LINEAR_ACCEL]
I name [IIO_LINEAR_ACCEL] to be "linearaccel" just follow the history code style in " iio_chan_type_name_spec[]" which do not have any underline.

What do you think?

BR
Song Hongyan

-----Original Message-----
From: Peter Meerwald-Stadler [mailto:pmeerw@pmeerw.net] 
Sent: Tuesday, January 3, 2017 3:23 PM
To: Song, Hongyan <hongyan.song@intel.com>
Cc: linux-input@vger.kernel.org; linux-iio@vger.kernel.org; jikos@kernel.org; jic23@kernel.org; Pandruvada, Srinivas <srinivas.pandruvada@intel.com>
Subject: Re: [PATCH 1/2] iio: Add support for linear accel


> Add new channel types support for linear accel sensor.
> 
> Linear acceleration differs from a standard accelerometor, its value 
> depends on standard accel sensor and gravity sensor.
> Conceptually, this three sensors have following relationship:
> linear acceleration = acceleration - acceleration due to gravity
> 
> At rest, standard accelerometer displays 1g due to earth’s 
> gravitational pull while a liner accelerometer will show 0g.

comment below
 
> More information can be found in:
> http://www.usb.org/developers/hidpage/HUTRR59_-_Usages_for_Wearables.p
> df
> 
> Signed-off-by: Song Hongyan <hongyan.song@intel.com>
> ---
>  Documentation/ABI/testing/sysfs-bus-iio | 10 ++++++++++
>  drivers/iio/industrialio-core.c         |  1 +
>  include/uapi/linux/iio/types.h          |  1 +
>  tools/iio/iio_event_monitor.c           |  2 ++
>  4 files changed, 14 insertions(+)
> 
> diff --git a/Documentation/ABI/testing/sysfs-bus-iio 
> b/Documentation/ABI/testing/sysfs-bus-iio
> index 60b7406..8091f3d 100644
> --- a/Documentation/ABI/testing/sysfs-bus-iio
> +++ b/Documentation/ABI/testing/sysfs-bus-iio
> @@ -170,6 +170,16 @@ Description:
>  		Has all of the equivalent parameters as per voltageY. Units
>  		after application of scale and offset are m/s^2.
>  
> +What:		/sys/bus/iio/devices/iio:deviceX/in_linear_accel_x_raw
> +What:		/sys/bus/iio/devices/iio:deviceX/in_linear_accel_y_raw
> +What:		/sys/bus/iio/devices/iio:deviceX/in_linear_accel_z_raw

I think this would be in_linearaccel_x_raw, etc.?

> +KernelVersion:	4.11
> +Contact:	linux-iio@vger.kernel.org
> +Description:
> +		Linear Acceleration in direction x, y or z (may be arbitrarily assigned
> +		but should match other such assignments on device).
> +		Has all of the equivalent parameters as per voltageY. Units
> +		after application of scale and offset are m/s^2.
>  
>  What:		/sys/bus/iio/devices/iio:deviceX/in_gravity_x_raw
>  What:		/sys/bus/iio/devices/iio:deviceX/in_gravity_y_raw
> diff --git a/drivers/iio/industrialio-core.c 
> b/drivers/iio/industrialio-core.c index 72fc96a..da78c26 100644
> --- a/drivers/iio/industrialio-core.c
> +++ b/drivers/iio/industrialio-core.c
> @@ -82,6 +82,7 @@ struct bus_type iio_bus_type = {
>  	[IIO_UVINDEX] = "uvindex",
>  	[IIO_ELECTRICALCONDUCTIVITY] = "electricalconductivity",
>  	[IIO_GRAVITY]  = "gravity",
> +	[IIO_LINEAR_ACCEL] = "linearaccel",
>  };
>  
>  static const char * const iio_modifier_names[] = { diff --git 
> a/include/uapi/linux/iio/types.h b/include/uapi/linux/iio/types.h 
> index d3f7ba7..d6df101 100644
> --- a/include/uapi/linux/iio/types.h
> +++ b/include/uapi/linux/iio/types.h
> @@ -41,6 +41,7 @@ enum iio_chan_type {
>  	IIO_UVINDEX,
>  	IIO_ELECTRICALCONDUCTIVITY,
>  	IIO_GRAVITY,
> +	IIO_LINEAR_ACCEL,
>  };
>  
>  enum iio_modifier {
> diff --git a/tools/iio/iio_event_monitor.c 
> b/tools/iio/iio_event_monitor.c index b61245e..116644a 100644
> --- a/tools/iio/iio_event_monitor.c
> +++ b/tools/iio/iio_event_monitor.c
> @@ -58,6 +58,7 @@
>  	[IIO_PH] = "ph",
>  	[IIO_UVINDEX] = "uvindex",
>  	[IIO_GRAVITY] = "gravity",
> +	[IIO_LINEAR_ACCEL] = "linearaccel",
>  };
>  
>  static const char * const iio_ev_type_text[] = { @@ -151,6 +152,7 @@ 
> static bool event_is_known(struct iio_event_data *event)
>  	case IIO_PH:
>  	case IIO_UVINDEX:
>  	case IIO_GRAVITY:
> +	case IIO_LINEAR_ACCEL:
>  		break;
>  	default:
>  		return false;
> 

-- 

Peter Meerwald-Stadler
+43-664-2444418 (mobile)

^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [PATCH 1/2] iio: Add support for linear accel
@ 2017-01-03  7:47     ` Song, Hongyan
  0 siblings, 0 replies; 12+ messages in thread
From: Song, Hongyan @ 2017-01-03  7:47 UTC (permalink / raw)
  To: Peter Meerwald-Stadler
  Cc: linux-input, linux-iio, jikos, jic23, Pandruvada, Srinivas

SGkgcGV0ZXIsDQoJIEkgY2hlY2tlZCBhbmQgZmluZCB0aGF0IGlpbyBkZXZpY2UgbmFtZSBpcyB1
c3VhbGx5IG5hbWVkIHRvIGJlIHdpdGggdW5kZXJsaW5lIGlmIGl0IGhhcyBtb3JlIHRoYW4gb25l
IHdvcmQsIHNvIEkgYXNzaWduZWQgdG8gYmUgIiBsaW5lYXJfYWNjZWxfM2QiLg0KIEkgdGhpbmsg
dGhlIGRldmljZSBwcm9wZXJ0eSBub2RlIG5hbWVkIHRvIGJlICJpbl9saW5lYXJfYWNjZWxfeF9y
YXciIGlzIGJldHRlciB0aGFuICIgaW5fbGluZWFyYWNjZWxfeF9yYXciIEp1c3Qg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+ICBzdGF0aWMgY29uc3QgY2hhciAqIGNvbnN0
IGlpb19ldl90eXBlX3RleHRbXSA9IHsgQEAgLTE1MSw2ICsxNTIsNyBAQCANCj4gc3RhdGljIGJv
b2wgZXZlbnRfaXNfa25vd24oc3RydWN0IGlpb19ldmVudF9kYXRhICpldmVudCkNCj4gIAljYXNl
IElJT19QSDoNCj4gIAljYXNlIElJT19VVklOREVYOg0KPiAgCWNhc2UgSUlPX0dSQVZJVFk6DQo+
ICsJY2FzZSBJSU9fTElORUFSX0FDQ0VMOg0KPiAgCQlicmVhazsNCj4gIAlkZWZhdWx0Og0KPiAg
CQlyZXR1cm4gZmFsc2U7DQo+IA0KDQotLSANCg0KUGV0ZXIgTWVlcndhbGQtU3RhZGxlcg0KKzQz
LTY2NC0yNDQ0NDE4IChtb2JpbGUpDQo=

^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [PATCH 1/2] iio: Add support for linear accel
  2017-01-03  7:47     ` Song, Hongyan
@ 2017-01-03  8:04         ` Peter Meerwald-Stadler
  -1 siblings, 0 replies; 12+ messages in thread
From: Peter Meerwald-Stadler @ 2017-01-03  8:04 UTC (permalink / raw)
  To: Song, Hongyan
  Cc: linux-input-u79uwXL29TY76Z2rM5mHXA,
	linux-iio-u79uwXL29TY76Z2rM5mHXA, jikos-DgEjT+Ai2ygdnm+yROfE0A,
	jic23-DgEjT+Ai2ygdnm+yROfE0A, Pandruvada, Srinivas

Hi,

> 	 I checked and find that iio device name is usually named to be with underline if it has more than one word, so I assigned to be " linear_accel_3d".
>  I think the device property node named to be "in_linear_accel_x_raw" is better than " in_linearaccel_x_raw" Just follow the former coding style.
> "linearaccel" is only a name which specify IIO type [IIO_LINEAR_ACCEL]
> I name [IIO_LINEAR_ACCEL] to be "linearaccel" just follow the history code style in " iio_chan_type_name_spec[]" which do not have any underline.

> > +What:		/sys/bus/iio/devices/iio:deviceX/in_linear_accel_x_raw
> > +What:		/sys/bus/iio/devices/iio:deviceX/in_linear_accel_y_raw
> > +What:		/sys/bus/iio/devices/iio:deviceX/in_linear_accel_z_raw
> 
> I think this would be in_linearaccel_x_raw, etc.?

> > @@ -82,6 +82,7 @@ struct bus_type iio_bus_type = {
> >  	[IIO_UVINDEX] = "uvindex",
> >  	[IIO_ELECTRICALCONDUCTIVITY] = "electricalconductivity",
> >  	[IIO_GRAVITY]  = "gravity",
> > +	[IIO_LINEAR_ACCEL] = "linearaccel",
> >  };


linearaccel vs. linear_accel is a matter of taste, I have no preference;
nevertheless, the documentation should match what IIO outputs

if you have "linearaccel" in iio_bus_type, I think the name of a 
LINEAR_ACCEL channel will end up as "in_linearaccel_x_raw" and must be 
documented like that -- i.e. there is a mismatch between 
documentation and actual code/output

probably your patches should be rebased, iio/testing branch has IIO_COUNT 
and IIO_INDEX channels

regards, p.


-- 

Peter Meerwald-Stadler
+43-664-2444418 (mobile)

^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [PATCH 1/2] iio: Add support for linear accel
@ 2017-01-03  8:04         ` Peter Meerwald-Stadler
  0 siblings, 0 replies; 12+ messages in thread
From: Peter Meerwald-Stadler @ 2017-01-03  8:04 UTC (permalink / raw)
  To: Song, Hongyan; +Cc: linux-input, linux-iio, jikos, jic23, Pandruvada, Srinivas

Hi,

> 	 I checked and find that iio device name is usually named to be with underline if it has more than one word, so I assigned to be " linear_accel_3d".
>  I think the device property node named to be "in_linear_accel_x_raw" is better than " in_linearaccel_x_raw" Just follow the former coding style.
> "linearaccel" is only a name which specify IIO type [IIO_LINEAR_ACCEL]
> I name [IIO_LINEAR_ACCEL] to be "linearaccel" just follow the history code style in " iio_chan_type_name_spec[]" which do not have any underline.

> > +What:		/sys/bus/iio/devices/iio:deviceX/in_linear_accel_x_raw
> > +What:		/sys/bus/iio/devices/iio:deviceX/in_linear_accel_y_raw
> > +What:		/sys/bus/iio/devices/iio:deviceX/in_linear_accel_z_raw
> 
> I think this would be in_linearaccel_x_raw, etc.?

> > @@ -82,6 +82,7 @@ struct bus_type iio_bus_type = {
> >  	[IIO_UVINDEX] = "uvindex",
> >  	[IIO_ELECTRICALCONDUCTIVITY] = "electricalconductivity",
> >  	[IIO_GRAVITY]  = "gravity",
> > +	[IIO_LINEAR_ACCEL] = "linearaccel",
> >  };


linearaccel vs. linear_accel is a matter of taste, I have no preference;
nevertheless, the documentation should match what IIO outputs

if you have "linearaccel" in iio_bus_type, I think the name of a 
LINEAR_ACCEL channel will end up as "in_linearaccel_x_raw" and must be 
documented like that -- i.e. there is a mismatch between 
documentation and actual code/output

probably your patches should be rebased, iio/testing branch has IIO_COUNT 
and IIO_INDEX channels

regards, p.


-- 

Peter Meerwald-Stadler
+43-664-2444418 (mobile)

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/2] iio: Add support for linear accel
  2017-01-03  8:04         ` Peter Meerwald-Stadler
  (?)
@ 2017-01-03  9:49         ` Lars-Peter Clausen
       [not found]           ` <be267c7a-9ec3-d86e-2a32-2faef3e0650f-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
  -1 siblings, 1 reply; 12+ messages in thread
From: Lars-Peter Clausen @ 2017-01-03  9:49 UTC (permalink / raw)
  To: Peter Meerwald-Stadler, Song, Hongyan
  Cc: linux-input, linux-iio, jikos, jic23, Pandruvada, Srinivas

On 01/03/2017 09:04 AM, Peter Meerwald-Stadler wrote:
> Hi,
> 
>> 	 I checked and find that iio device name is usually named to be with underline if it has more than one word, so I assigned to be " linear_accel_3d".
>>  I think the device property node named to be "in_linear_accel_x_raw" is better than " in_linearaccel_x_raw" Just follow the former coding style.
>> "linearaccel" is only a name which specify IIO type [IIO_LINEAR_ACCEL]
>> I name [IIO_LINEAR_ACCEL] to be "linearaccel" just follow the history code style in " iio_chan_type_name_spec[]" which do not have any underline.
> 
>>> +What:		/sys/bus/iio/devices/iio:deviceX/in_linear_accel_x_raw
>>> +What:		/sys/bus/iio/devices/iio:deviceX/in_linear_accel_y_raw
>>> +What:		/sys/bus/iio/devices/iio:deviceX/in_linear_accel_z_raw
>>
>> I think this would be in_linearaccel_x_raw, etc.?
> 
>>> @@ -82,6 +82,7 @@ struct bus_type iio_bus_type = {
>>>  	[IIO_UVINDEX] = "uvindex",
>>>  	[IIO_ELECTRICALCONDUCTIVITY] = "electricalconductivity",
>>>  	[IIO_GRAVITY]  = "gravity",
>>> +	[IIO_LINEAR_ACCEL] = "linearaccel",
>>>  };
> 
> 
> linearaccel vs. linear_accel is a matter of taste, I have no preference;
> nevertheless, the documentation should match what IIO outputs

We use underscores as the field separator in the channel name. Having a
underscore as part of a field adds ambiguity and makes it a lot harder
to machine parse it. It's already complicated enough as it is. We should
avoid adding types with underscores in them.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/2] iio: Add support for linear accel
@ 2017-01-03 15:13 ` Song Hongyan
  0 siblings, 0 replies; 12+ messages in thread
From: Song Hongyan @ 2017-01-03 15:13 UTC (permalink / raw)
  To: linux-input-u79uwXL29TY76Z2rM5mHXA, linux-iio-u79uwXL29TY76Z2rM5mHXA
  Cc: jikos-DgEjT+Ai2ygdnm+yROfE0A, jic23-DgEjT+Ai2ygdnm+yROfE0A,
	srinivas.pandruvada-ral2JQCrhuEAvxtiuMwx3w, Song Hongyan

Add new channel types support for linear accel sensor.

Linear acceleration differs from a standard accelerometor,
its value depends on standard accel sensor and gravity sensor.
Conceptually, this three sensors have following relationship:
linear acceleration = acceleration - acceleration due to gravity

At rest, standard accelerometer displays 1g due to earth’s
gravitational pull while a liner accelerometer will show 0g.

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

Signed-off-by: Song Hongyan <hongyan.song-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
 Documentation/ABI/testing/sysfs-bus-iio | 10 ++++++++++
 drivers/iio/industrialio-core.c         |  1 +
 include/uapi/linux/iio/types.h          |  1 +
 tools/iio/iio_event_monitor.c           |  2 ++
 4 files changed, 14 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio
index 60b7406..8091f3d 100644
--- a/Documentation/ABI/testing/sysfs-bus-iio
+++ b/Documentation/ABI/testing/sysfs-bus-iio
@@ -170,6 +170,16 @@ Description:
 		Has all of the equivalent parameters as per voltageY. Units
 		after application of scale and offset are m/s^2.
 
+What:		/sys/bus/iio/devices/iio:deviceX/in_linear_accel_x_raw
+What:		/sys/bus/iio/devices/iio:deviceX/in_linear_accel_y_raw
+What:		/sys/bus/iio/devices/iio:deviceX/in_linear_accel_z_raw
+KernelVersion:	4.11
+Contact:	linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
+Description:
+		Linear Acceleration in direction x, y or z (may be arbitrarily assigned
+		but should match other such assignments on device).
+		Has all of the equivalent parameters as per voltageY. Units
+		after application of scale and offset are m/s^2.
 
 What:		/sys/bus/iio/devices/iio:deviceX/in_gravity_x_raw
 What:		/sys/bus/iio/devices/iio:deviceX/in_gravity_y_raw
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index 72fc96a..da78c26 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -82,6 +82,7 @@ struct bus_type iio_bus_type = {
 	[IIO_UVINDEX] = "uvindex",
 	[IIO_ELECTRICALCONDUCTIVITY] = "electricalconductivity",
 	[IIO_GRAVITY]  = "gravity",
+	[IIO_LINEAR_ACCEL] = "linearaccel",
 };
 
 static const char * const iio_modifier_names[] = {
diff --git a/include/uapi/linux/iio/types.h b/include/uapi/linux/iio/types.h
index d3f7ba7..d6df101 100644
--- a/include/uapi/linux/iio/types.h
+++ b/include/uapi/linux/iio/types.h
@@ -41,6 +41,7 @@ enum iio_chan_type {
 	IIO_UVINDEX,
 	IIO_ELECTRICALCONDUCTIVITY,
 	IIO_GRAVITY,
+	IIO_LINEAR_ACCEL,
 };
 
 enum iio_modifier {
diff --git a/tools/iio/iio_event_monitor.c b/tools/iio/iio_event_monitor.c
index b61245e..116644a 100644
--- a/tools/iio/iio_event_monitor.c
+++ b/tools/iio/iio_event_monitor.c
@@ -58,6 +58,7 @@
 	[IIO_PH] = "ph",
 	[IIO_UVINDEX] = "uvindex",
 	[IIO_GRAVITY] = "gravity",
+	[IIO_LINEAR_ACCEL] = "linearaccel",
 };
 
 static const char * const iio_ev_type_text[] = {
@@ -151,6 +152,7 @@ static bool event_is_known(struct iio_event_data *event)
 	case IIO_PH:
 	case IIO_UVINDEX:
 	case IIO_GRAVITY:
+	case IIO_LINEAR_ACCEL:
 		break;
 	default:
 		return false;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 1/2] iio: Add support for linear accel
@ 2017-01-03 15:13 ` Song Hongyan
  0 siblings, 0 replies; 12+ messages in thread
From: Song Hongyan @ 2017-01-03 15:13 UTC (permalink / raw)
  To: linux-input, linux-iio; +Cc: jikos, jic23, srinivas.pandruvada, Song Hongyan

Add new channel types support for linear accel sensor.

Linear acceleration differs from a standard accelerometor,
its value depends on standard accel sensor and gravity sensor.
Conceptually, this three sensors have following relationship:
linear acceleration = acceleration - acceleration due to gravity

At rest, standard accelerometer displays 1g due to earth’s
gravitational pull while a liner accelerometer will show 0g.

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

Signed-off-by: Song Hongyan <hongyan.song@intel.com>
---
 Documentation/ABI/testing/sysfs-bus-iio | 10 ++++++++++
 drivers/iio/industrialio-core.c         |  1 +
 include/uapi/linux/iio/types.h          |  1 +
 tools/iio/iio_event_monitor.c           |  2 ++
 4 files changed, 14 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio
index 60b7406..8091f3d 100644
--- a/Documentation/ABI/testing/sysfs-bus-iio
+++ b/Documentation/ABI/testing/sysfs-bus-iio
@@ -170,6 +170,16 @@ Description:
 		Has all of the equivalent parameters as per voltageY. Units
 		after application of scale and offset are m/s^2.
 
+What:		/sys/bus/iio/devices/iio:deviceX/in_linear_accel_x_raw
+What:		/sys/bus/iio/devices/iio:deviceX/in_linear_accel_y_raw
+What:		/sys/bus/iio/devices/iio:deviceX/in_linear_accel_z_raw
+KernelVersion:	4.11
+Contact:	linux-iio@vger.kernel.org
+Description:
+		Linear Acceleration in direction x, y or z (may be arbitrarily assigned
+		but should match other such assignments on device).
+		Has all of the equivalent parameters as per voltageY. Units
+		after application of scale and offset are m/s^2.
 
 What:		/sys/bus/iio/devices/iio:deviceX/in_gravity_x_raw
 What:		/sys/bus/iio/devices/iio:deviceX/in_gravity_y_raw
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index 72fc96a..da78c26 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -82,6 +82,7 @@ struct bus_type iio_bus_type = {
 	[IIO_UVINDEX] = "uvindex",
 	[IIO_ELECTRICALCONDUCTIVITY] = "electricalconductivity",
 	[IIO_GRAVITY]  = "gravity",
+	[IIO_LINEAR_ACCEL] = "linearaccel",
 };
 
 static const char * const iio_modifier_names[] = {
diff --git a/include/uapi/linux/iio/types.h b/include/uapi/linux/iio/types.h
index d3f7ba7..d6df101 100644
--- a/include/uapi/linux/iio/types.h
+++ b/include/uapi/linux/iio/types.h
@@ -41,6 +41,7 @@ enum iio_chan_type {
 	IIO_UVINDEX,
 	IIO_ELECTRICALCONDUCTIVITY,
 	IIO_GRAVITY,
+	IIO_LINEAR_ACCEL,
 };
 
 enum iio_modifier {
diff --git a/tools/iio/iio_event_monitor.c b/tools/iio/iio_event_monitor.c
index b61245e..116644a 100644
--- a/tools/iio/iio_event_monitor.c
+++ b/tools/iio/iio_event_monitor.c
@@ -58,6 +58,7 @@
 	[IIO_PH] = "ph",
 	[IIO_UVINDEX] = "uvindex",
 	[IIO_GRAVITY] = "gravity",
+	[IIO_LINEAR_ACCEL] = "linearaccel",
 };
 
 static const char * const iio_ev_type_text[] = {
@@ -151,6 +152,7 @@ static bool event_is_known(struct iio_event_data *event)
 	case IIO_PH:
 	case IIO_UVINDEX:
 	case IIO_GRAVITY:
+	case IIO_LINEAR_ACCEL:
 		break;
 	default:
 		return false;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/2] iio: Add linear accel sensor hid support
  2017-01-03 15:13 ` Song Hongyan
@ 2017-01-03 15:13     ` Song Hongyan
  -1 siblings, 0 replies; 12+ messages in thread
From: Song Hongyan @ 2017-01-03 15:13 UTC (permalink / raw)
  To: linux-input-u79uwXL29TY76Z2rM5mHXA, linux-iio-u79uwXL29TY76Z2rM5mHXA
  Cc: jikos-DgEjT+Ai2ygdnm+yROfE0A, jic23-DgEjT+Ai2ygdnm+yROfE0A,
	srinivas.pandruvada-ral2JQCrhuEAvxtiuMwx3w, Song Hongyan

Linear acceleration is a soft sensor it differs from a standard
accel sensor, it provides a three-dimensional vector representing
acceleration along each device axis, excluding gravity.
The sensor data is derives from standard accelerometer device
by filtering out the acceleration which is caused by the force
of Earth’s gravity.

The value can be used to perform gesture detection, it can also
serve as input to an inertial navigation system, which uses
dead reckoning.

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

Linear accel sensor, gravity sensor and accelerometer have similar
channels and share channel usage ids. So the most of the code for
accel_3d can be reused.

Signed-off-by: Song Hongyan <hongyan.song-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
 drivers/iio/accel/hid-sensor-accel-3d.c | 42 +++++++++++++++++++++++++++++++++
 include/linux/hid-sensor-ids.h          |  3 +++
 2 files changed, 45 insertions(+)

diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c
index 9edd574..6ce460f 100644
--- a/drivers/iio/accel/hid-sensor-accel-3d.c
+++ b/drivers/iio/accel/hid-sensor-accel-3d.c
@@ -91,6 +91,41 @@ struct accel_3d_state {
 };
 
 /* Channel definitions */
+static const struct iio_chan_spec linear_accel_3d_channels[] = {
+	{
+		.type = IIO_LINEAR_ACCEL,
+		.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_LINEAR_ACCEL,
+		.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_LINEAR_ACCEL,
+		.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,
+	}
+};
+
+/* Channel definitions */
 static const struct iio_chan_spec gravity_channels[] = {
 	{
 		.type = IIO_GRAVITY,
@@ -354,6 +389,10 @@ static int hid_accel_3d_probe(struct platform_device *pdev)
 		name = "accel_3d";
 		channel_spec = accel_3d_channels;
 		channel_size = sizeof(accel_3d_channels);
+	} else if (hsdev->usage == HID_USAGE_SENSOR_LINEAR_ACCEL_3D) {
+		name = "linear_accel_3d";
+		channel_spec = linear_accel_3d_channels;
+		channel_size = sizeof(linear_accel_3d_channels);
 	} else {
 		name = "gravity";
 		channel_spec = gravity_channels;
@@ -452,6 +491,9 @@ static int hid_accel_3d_remove(struct platform_device *pdev)
 	{	/* gravity sensor */
 		.name = "HID-SENSOR-20007b",
 	},
+	{	/* linear_accel sensor */
+		.name = "HID-SENSOR-20007c",
+	},
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(platform, hid_accel_3d_ids);
diff --git a/include/linux/hid-sensor-ids.h b/include/linux/hid-sensor-ids.h
index b6778fd2..b0b26a0 100644
--- a/include/linux/hid-sensor-ids.h
+++ b/include/linux/hid-sensor-ids.h
@@ -55,6 +55,9 @@
 /* Gravity vector */
 #define HID_USAGE_SENSOR_GRAVITY_VECTOR				0x20007B
 
+/* linear accel */
+#define HID_USAGE_SENSOR_LINEAR_ACCEL_3D			0x20007C
+
 /* ORIENTATION: Compass 3D: (200083) */
 #define HID_USAGE_SENSOR_COMPASS_3D				0x200083
 #define HID_USAGE_SENSOR_DATA_ORIENTATION			0x200470
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/2] iio: Add linear accel sensor hid support
@ 2017-01-03 15:13     ` Song Hongyan
  0 siblings, 0 replies; 12+ messages in thread
From: Song Hongyan @ 2017-01-03 15:13 UTC (permalink / raw)
  To: linux-input, linux-iio; +Cc: jikos, jic23, srinivas.pandruvada, Song Hongyan

Linear acceleration is a soft sensor it differs from a standard
accel sensor, it provides a three-dimensional vector representing
acceleration along each device axis, excluding gravity.
The sensor data is derives from standard accelerometer device
by filtering out the acceleration which is caused by the force
of Earth’s gravity.

The value can be used to perform gesture detection, it can also
serve as input to an inertial navigation system, which uses
dead reckoning.

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

Linear accel sensor, gravity sensor and accelerometer have similar
channels and share channel usage ids. So the most of the code for
accel_3d can be reused.

Signed-off-by: Song Hongyan <hongyan.song@intel.com>
---
 drivers/iio/accel/hid-sensor-accel-3d.c | 42 +++++++++++++++++++++++++++++++++
 include/linux/hid-sensor-ids.h          |  3 +++
 2 files changed, 45 insertions(+)

diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c
index 9edd574..6ce460f 100644
--- a/drivers/iio/accel/hid-sensor-accel-3d.c
+++ b/drivers/iio/accel/hid-sensor-accel-3d.c
@@ -91,6 +91,41 @@ struct accel_3d_state {
 };
 
 /* Channel definitions */
+static const struct iio_chan_spec linear_accel_3d_channels[] = {
+	{
+		.type = IIO_LINEAR_ACCEL,
+		.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_LINEAR_ACCEL,
+		.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_LINEAR_ACCEL,
+		.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,
+	}
+};
+
+/* Channel definitions */
 static const struct iio_chan_spec gravity_channels[] = {
 	{
 		.type = IIO_GRAVITY,
@@ -354,6 +389,10 @@ static int hid_accel_3d_probe(struct platform_device *pdev)
 		name = "accel_3d";
 		channel_spec = accel_3d_channels;
 		channel_size = sizeof(accel_3d_channels);
+	} else if (hsdev->usage == HID_USAGE_SENSOR_LINEAR_ACCEL_3D) {
+		name = "linear_accel_3d";
+		channel_spec = linear_accel_3d_channels;
+		channel_size = sizeof(linear_accel_3d_channels);
 	} else {
 		name = "gravity";
 		channel_spec = gravity_channels;
@@ -452,6 +491,9 @@ static int hid_accel_3d_remove(struct platform_device *pdev)
 	{	/* gravity sensor */
 		.name = "HID-SENSOR-20007b",
 	},
+	{	/* linear_accel sensor */
+		.name = "HID-SENSOR-20007c",
+	},
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(platform, hid_accel_3d_ids);
diff --git a/include/linux/hid-sensor-ids.h b/include/linux/hid-sensor-ids.h
index b6778fd2..b0b26a0 100644
--- a/include/linux/hid-sensor-ids.h
+++ b/include/linux/hid-sensor-ids.h
@@ -55,6 +55,9 @@
 /* Gravity vector */
 #define HID_USAGE_SENSOR_GRAVITY_VECTOR				0x20007B
 
+/* linear accel */
+#define HID_USAGE_SENSOR_LINEAR_ACCEL_3D			0x20007C
+
 /* ORIENTATION: Compass 3D: (200083) */
 #define HID_USAGE_SENSOR_COMPASS_3D				0x200083
 #define HID_USAGE_SENSOR_DATA_ORIENTATION			0x200470
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* RE: [PATCH 1/2] iio: Add support for linear accel
  2017-01-03  9:49         ` Lars-Peter Clausen
@ 2017-01-04  2:28               ` Song, Hongyan
  0 siblings, 0 replies; 12+ messages in thread
From: Song, Hongyan @ 2017-01-04  2:28 UTC (permalink / raw)
  To: Lars-Peter Clausen, Peter Meerwald-Stadler
  Cc: linux-input-u79uwXL29TY76Z2rM5mHXA,
	linux-iio-u79uwXL29TY76Z2rM5mHXA, jikos-DgEjT+Ai2ygdnm+yROfE0A,
	jic23-DgEjT+Ai2ygdnm+yROfE0A, Pandruvada, Srinivas

Hi Lars & Peter,

-----Original Message-----
From: Lars-Peter Clausen [mailto:lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org] 
Sent: Tuesday, January 3, 2017 5:49 PM
To: Peter Meerwald-Stadler <pmeerw-jW+XmwGofnusTnJN9+BGXg@public.gmane.org>; Song, Hongyan <hongyan.song-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; jikos-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org; jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org; Pandruvada, Srinivas <srinivas.pandruvada-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Subject: Re: [PATCH 1/2] iio: Add support for linear accel

On 01/03/2017 09:04 AM, Peter Meerwald-Stadler wrote:
> Hi,
> 
>> 	 I checked and find that iio device name is usually named to be with underline if it has more than one word, so I assigned to be " linear_accel_3d".
>>  I think the device property node named to be "in_linear_accel_x_raw" is better than " in_linearaccel_x_raw" Just follow the former coding style.
>> "linearaccel" is only a name which specify IIO type 
>> [IIO_LINEAR_ACCEL] I name [IIO_LINEAR_ACCEL] to be "linearaccel" just follow the history code style in " iio_chan_type_name_spec[]" which do not have any underline.
> 
>>> +What:		/sys/bus/iio/devices/iio:deviceX/in_linear_accel_x_raw
>>> +What:		/sys/bus/iio/devices/iio:deviceX/in_linear_accel_y_raw
>>> +What:		/sys/bus/iio/devices/iio:deviceX/in_linear_accel_z_raw
>>
>> I think this would be in_linearaccel_x_raw, etc.?
> 
>>> @@ -82,6 +82,7 @@ struct bus_type iio_bus_type = {
>>>  	[IIO_UVINDEX] = "uvindex",
>>>  	[IIO_ELECTRICALCONDUCTIVITY] = "electricalconductivity",
>>>  	[IIO_GRAVITY]  = "gravity",
>>> +	[IIO_LINEAR_ACCEL] = "linearaccel",
>>>  };
> 
> 
> >linearaccel vs. linear_accel is a matter of taste, I have no 
> >preference; nevertheless, the documentation should match what IIO 
>> outputs

>We use underscores as the field separator in the channel name. Having a underscore as part of a field adds ambiguity and makes it a lot  >
>harder to machine parse it. It's already complicated enough as it is. We should avoid adding types with underscores in them.

Thanks for your advice, I will update the patch.

BR
Song Hongyan

^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [PATCH 1/2] iio: Add support for linear accel
@ 2017-01-04  2:28               ` Song, Hongyan
  0 siblings, 0 replies; 12+ messages in thread
From: Song, Hongyan @ 2017-01-04  2:28 UTC (permalink / raw)
  To: Lars-Peter Clausen, Peter Meerwald-Stadler
  Cc: linux-input, linux-iio, jikos, jic23, Pandruvada, Srinivas

Hi Lars & Peter,

-----Original Message-----
From: Lars-Peter Clausen [mailto:lars@metafoo.de]=20
Sent: Tuesday, January 3, 2017 5:49 PM
To: Peter Meerwald-Stadler <pmeerw@pmeerw.net>; Song, Hongyan <hongyan.song=
@intel.com>
Cc: linux-input@vger.kernel.org; linux-iio@vger.kernel.org; jikos@kernel.or=
g; jic23@kernel.org; Pandruvada, Srinivas <srinivas.pandruvada@intel.com>
Subject: Re: [PATCH 1/2] iio: Add support for linear accel

On 01/03/2017 09:04 AM, Peter Meerwald-Stadler wrote:
> Hi,
>=20
>> 	 I checked and find that iio device name is usually named to be with un=
derline if it has more than one word, so I assigned to be " linear_accel_3d=
".
>>  I think the device property node named to be "in_linear_accel_x_raw" is=
 better than " in_linearaccel_x_raw" Just follow the former coding style.
>> "linearaccel" is only a name which specify IIO type=20
>> [IIO_LINEAR_ACCEL] I name [IIO_LINEAR_ACCEL] to be "linearaccel" just fo=
llow the history code style in " iio_chan_type_name_spec[]" which do not ha=
ve any underline.
>=20
>>> +What:		/sys/bus/iio/devices/iio:deviceX/in_linear_accel_x_raw
>>> +What:		/sys/bus/iio/devices/iio:deviceX/in_linear_accel_y_raw
>>> +What:		/sys/bus/iio/devices/iio:deviceX/in_linear_accel_z_raw
>>
>> I think this would be in_linearaccel_x_raw, etc.?
>=20
>>> @@ -82,6 +82,7 @@ struct bus_type iio_bus_type =3D {
>>>  	[IIO_UVINDEX] =3D "uvindex",
>>>  	[IIO_ELECTRICALCONDUCTIVITY] =3D "electricalconductivity",
>>>  	[IIO_GRAVITY]  =3D "gravity",
>>> +	[IIO_LINEAR_ACCEL] =3D "linearaccel",
>>>  };
>=20
>=20
> >linearaccel vs. linear_accel is a matter of taste, I have no=20
> >preference; nevertheless, the documentation should match what IIO=20
>> outputs

>We use underscores as the field separator in the channel name. Having a un=
derscore as part of a field adds ambiguity and makes it a lot  >
>harder to machine parse it. It's already complicated enough as it is. We s=
hould avoid adding types with underscores in them.

Thanks for your advice, I will update the patch.

BR
Song Hongyan

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2017-01-04  2:28 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-03 15:13 [PATCH 1/2] iio: Add support for linear accel Song Hongyan
2017-01-03 15:13 ` Song Hongyan
2017-01-03  7:22 ` Peter Meerwald-Stadler
2017-01-03  7:47   ` Song, Hongyan
2017-01-03  7:47     ` Song, Hongyan
     [not found]     ` <AE3E3DFA698D6144A7445C92D1D41E2F10BDBD57-0J0gbvR4kTggGBtAFL8yw7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
2017-01-03  8:04       ` Peter Meerwald-Stadler
2017-01-03  8:04         ` Peter Meerwald-Stadler
2017-01-03  9:49         ` Lars-Peter Clausen
     [not found]           ` <be267c7a-9ec3-d86e-2a32-2faef3e0650f-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
2017-01-04  2:28             ` Song, Hongyan
2017-01-04  2:28               ` Song, Hongyan
     [not found] ` <1483456430-6980-1-git-send-email-hongyan.song-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-01-03 15:13   ` [PATCH 2/2] iio: Add linear accel sensor hid support Song Hongyan
2017-01-03 15:13     ` Song Hongyan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.