P Pandruvada, Srinivas #
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,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.cdiff --git a/drivers/staging/hid-sensors/Makefileb/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