RE: [PATCH, 4/7] HID-Sensors: Added accelerometer 3D

Started by Pandruvada, Srinivas on Jun 7, 2012 · 2 messages from 2 authors · Last reply Jun 7, 2012

open the first message on its own page

Message details and related content
Thanks for your excellent comments. I think I get some idea now.

Do you think the place for this driver is in "staging/iio/hid-sensors"?

Thanks,
Srinivas






-----Original Message-----
From: Jonathan Cameron [mailto:<redacted>] 
Sent: Thursday, June 07, 2012 1:11 AM
To: Pandruvada, Srinivas
Cc: <redacted>; <redacted>
Subject: Re: [PATCH, 4/7] HID-Sensors: Added accelerometer 3D

On 6/6/2012 5:57 PM, Pandruvada, Srinivas wrote:
The USB sensor spec has a report structure which it sends as part of report descriptor we get during initial plug in. This report structure describes elements and their sizes. For example, it may say that an Accelerometer X axis value as 4 bytes long and what is the exponent and unit. Also it sends what control elements it has.
The sequence is
- Set sensitivity, interval, activate sys-fs interface. The USB sensor will send an event by USB-IN report when the captured sample is changed by sensitivity value and stable for at least interval. Also you need to activate the sensor so that the usb will start sending events.

- Once USB report with the captured sample arrives, I format the data as defined in " struct accel_3d_sample" below and push to IIO ring buffer.
I define a single channel
	IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_X_AND_Y_AND_Z,
	IIO_CHAN_INFO_SCALE_SEPARATE_BIT |
	IIO_CHAN_INFO_OFFSET_SEPARATE_BIT,
	ACCEL_X_Y_Z, ACCEL_3D_SCAN_ACC_X_Y_Z,
		 IIO_ST('u', sizeof(struct accel_3d_sample) * 8,
		sizeof(struct accel_3d_sample) * 8, 0), 0), };

Please suggest me if this is not the way IIO channel used.
You have 3 channels here.  The iio buffer interface will handle the fact that they are 'at the same time' on it's own.

Btw I've killed off that macro so this won't build against current tree...  Feel free if sensible to define a local macro.  The global one was a maintenance nightmare hence we scrapped it...

Sketching out what you should have

{
          .type = IIO_ACCEL,
          .modified = 1,
          .channel2 = IIO_MOD_X,
          .info_mask = IIO_CHAN_INFO_SCALE_SEPARATE_BIT |
  		      IIO_CHAN_INFO_OFFSET_SEPARATE_BIT,
          .scan_index = 0,
          .scan_type = {
               .sign = 's',
               .realbits = 12,
               .storagebits = 16,
          },
}, {
          .type = IIO_ACCEL,
          .modified = 1,
          .channel2 = IIO_MOD_Y,
          .info_mask = IIO_CHAN_INFO_SCALE_SEPARATE_BIT |
  		      IIO_CHAN_INFO_OFFSET_SEPARATE_BIT,
          .scan_index = 1,
          .scan_type = {
               .sign = 's',
               .realbits = 12,
               .storagebits = 16,
          },
}, {
          .type = IIO_ACCEL,
          .modified = 1,
          .channel2 = IIO_MOD_Y,
          .info_mask = IIO_CHAN_INFO_SCALE_SEPARATE_BIT |
  		      IIO_CHAN_INFO_OFFSET_SEPARATE_BIT,
          .scan_index = 2,
          .scan_type = {
               .sign = 's',
               .realbits = 12,

9 more lines

Thanks,
Srinivas



-----Original Message-----
From: Jonathan Cameron [mailto:<redacted>]
Sent: Wednesday, June 06, 2012 9:29 AM
To: Pandruvada, Srinivas; <redacted>
Cc: <redacted>
Subject: Re: [PATCH, 4/7] HID-Sensors: Added accelerometer 3D



srinivas pandruvada[off-list ref]  wrote:
quoted
From: Srinivas pandruvada<redacted>

Added usage id processing for Accelrometer 3D. This uses IIO 
interfaces "ring/buffer and trigger interface" to present data to user mode.
I do not understand the data format.  The way iio describes the format is done through sysfs attrs built from the iio_Chan spec... that way a scan is made up of a number of channel readings each taken at roughly the same time.  However each is separately described.  Perhaps the description needs extending.  Please describe the format.
quoted
Signed-off-by: Srinivas pandruvada<redacted>
---
drivers/staging/hid-sensors/Makefile               |    1 +
drivers/staging/hid-sensors/hid-sensor-accel-3d.c  |  387
++++++++++++++++++++
drivers/staging/hid-sensors/hid-sensor-hub.c       |    1 +
drivers/staging/hid-sensors/hid-sensor-interface.h |    3 +
4 files changed, 392 insertions(+), 0 deletions(-) create mode 100644 
drivers/staging/hid-sensors/hid-sensor-accel-3d.c
diff --git a/drivers/staging/hid-sensors/Makefile
b/drivers/staging/hid-sensors/Makefile
index 9a03953..4412079 100644
--- a/drivers/staging/hid-sensors/Makefile
+++ b/drivers/staging/hid-sensors/Makefile
@@ -9,4 +9,5 @@ hid-sensors-y := hid-sensor-hub.o  hid-sensors-y += 
hid-sensor-attributes.o  hid-sensors-y += hid-sensor-ring.o 

446 more quoted lines

Message details and related content
On 06/07/2012 04:41 PM, Pandruvada, Srinivas wrote:
Thanks for your excellent comments. I think I get some idea now.

Do you think the place for this driver is in "staging/iio/hid-sensors"?
Firstly don't put it in staging unless you have non iio related reasons!
The iio core is now out in drivers/iio.
Secondly the question is whether to treat the individual sensor
components as individual drivers (and the core as effectively and mfd)
or to treat it all as one big 'compound' sensor, similar to we do with
IMUs. As it currently stands it is a compound sensor.

The mfd route breaks the various components into independent modules
with a core handling the data and interrupt flow to and from the
hardware.  Might be worth doing for a clean result...

Also note that there are some patches changing the route of data
into the buffers under review.  You might want to develop with
those in place as quite a few of your elements will probably want
bridging to input (which relies on that series...)

The series.
[PATCH 0/4 V2] staging:iio: Add support for multiple buffer.
Thanks,
Srinivas






-----Original Message-----
From: Jonathan Cameron [mailto:<redacted>] 
Sent: Thursday, June 07, 2012 1:11 AM
To: Pandruvada, Srinivas
Cc: <redacted>; <redacted>
Subject: Re: [PATCH, 4/7] HID-Sensors: Added accelerometer 3D

On 6/6/2012 5:57 PM, Pandruvada, Srinivas wrote:
quoted
The USB sensor spec has a report structure which it sends as part of report descriptor we get during initial plug in. This report structure describes elements and their sizes. For example, it may say that an Accelerometer X axis value as 4 bytes long and what is the exponent and unit. Also it sends what control elements it has.
The sequence is
- Set sensitivity, interval, activate sys-fs interface. The USB sensor will send an event by USB-IN report when the captured sample is changed by sensitivity value and stable for at least interval. Also you need to activate the sensor so that the usb will start sending events.

- Once USB report with the captured sample arrives, I format the data as defined in " struct accel_3d_sample" below and push to IIO ring buffer.
I define a single channel
	IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_X_AND_Y_AND_Z,
	IIO_CHAN_INFO_SCALE_SEPARATE_BIT |
	IIO_CHAN_INFO_OFFSET_SEPARATE_BIT,
	ACCEL_X_Y_Z, ACCEL_3D_SCAN_ACC_X_Y_Z,
		 IIO_ST('u', sizeof(struct accel_3d_sample) * 8,
		sizeof(struct accel_3d_sample) * 8, 0), 0), };

Please suggest me if this is not the way IIO channel used.
You have 3 channels here.  The iio buffer interface will handle the fact that they are 'at the same time' on it's own.

Btw I've killed off that macro so this won't build against current tree...  Feel free if sensible to define a local macro.  The global one was a maintenance nightmare hence we scrapped it...

Sketching out what you should have

{
          .type = IIO_ACCEL,
          .modified = 1,

527 more quoted lines

Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help