summaryrefslogtreecommitdiff
path: root/drivers/staging/iio/iio_simple_dummy.c
diff options
context:
space:
mode:
authorJonathan Cameron <jic23@cam.ac.uk>2011-10-14 16:34:15 +0100
committerGreg Kroah-Hartman <gregkh@suse.de>2011-10-17 15:36:30 -0700
commit9ad2e2e1d6506252f31a142a9b04121992af25e3 (patch)
tree191e9dc30226336053b5b2f7dbe0b068c2cc799f /drivers/staging/iio/iio_simple_dummy.c
parente6477000fced2c961c26fa42845bd388fdf95e79 (diff)
staging:iio:dummy Add buffered reading support
Very simple buffered reading. Did not provide a trigger as the sysfs trigger already meets that requirement. Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/iio/iio_simple_dummy.c')
-rw-r--r--drivers/staging/iio/iio_simple_dummy.c73
1 files changed, 64 insertions, 9 deletions
diff --git a/drivers/staging/iio/iio_simple_dummy.c b/drivers/staging/iio/iio_simple_dummy.c
index c5119a0253bf..af0c99236d4f 100644
--- a/drivers/staging/iio/iio_simple_dummy.c
+++ b/drivers/staging/iio/iio_simple_dummy.c
@@ -21,6 +21,7 @@
#include "iio.h"
#include "sysfs.h"
+#include "buffer_generic.h"
#include "iio_simple_dummy.h"
/*
@@ -82,7 +83,14 @@ static struct iio_chan_spec iio_dummy_channels[] = {
* when converting to standard units (microvolts)
*/
(1 << IIO_CHAN_INFO_SCALE_SEPARATE),
-
+ /* The ordering of elements in the buffer via an enum */
+ .scan_index = voltage0,
+ .scan_type = { /* Description of storage in buffer */
+ .sign = 'u', /* unsigned */
+ .realbits = 13, /* 13 bits */
+ .storagebits = 16, /* 16 bits used for storage */
+ .shift = 0, /* zero shift */
+ },
#ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS
/*
* simple event - triggered when value rises above
@@ -110,6 +118,13 @@ static struct iio_chan_spec iio_dummy_channels[] = {
* input channels of type IIO_VOLTAGE.
*/
(1 << IIO_CHAN_INFO_SCALE_SHARED),
+ .scan_index = diffvoltage1m2,
+ .scan_type = { /* Description of storage in buffer */
+ .sign = 's', /* signed */
+ .realbits = 12, /* 12 bits */
+ .storagebits = 16, /* 16 bits used for storage */
+ .shift = 0, /* zero shift */
+ },
},
/* Differential ADC channel in_voltage3-voltage4_raw etc*/
{
@@ -120,13 +135,13 @@ static struct iio_chan_spec iio_dummy_channels[] = {
.channel2 = 4,
.info_mask =
(1 << IIO_CHAN_INFO_SCALE_SHARED),
- },
- /* DAC channel out_voltage0_raw */
- {
- .type = IIO_VOLTAGE,
- .output = 1,
- .indexed = 1,
- .channel = 0,
+ .scan_index = diffvoltage3m4,
+ .scan_type = {
+ .sign = 's',
+ .realbits = 11,
+ .storagebits = 16,
+ .shift = 0,
+ },
},
/*
* 'modified' (i.e. axis specified) acceleration channel
@@ -145,6 +160,25 @@ static struct iio_chan_spec iio_dummy_channels[] = {
* calibration.
*/
(1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE),
+ .scan_index = accelx,
+ .scan_type = { /* Description of storage in buffer */
+ .sign = 's', /* signed */
+ .realbits = 16, /* 12 bits */
+ .storagebits = 16, /* 16 bits used for storage */
+ .shift = 0, /* zero shift */
+ },
+ },
+ /*
+ * Convenience macro for timestamps. 4 is the index in
+ * the buffer.
+ */
+ IIO_CHAN_SOFT_TIMESTAMP(4),
+ /* DAC channel out_voltage0_raw */
+ {
+ .type = IIO_VOLTAGE,
+ .output = 1,
+ .indexed = 1,
+ .channel = 0,
},
};
@@ -391,11 +425,29 @@ static int __devinit iio_dummy_probe(int index)
ret = iio_simple_dummy_events_register(indio_dev);
if (ret < 0)
goto error_free_device;
- ret = iio_device_register(indio_dev);
+
+ /* Configure buffered capture support. */
+ ret = iio_simple_dummy_configure_buffer(indio_dev);
if (ret < 0)
goto error_unregister_events;
+ /*
+ * Register the channels with the buffer, but avoid the output
+ * channel being registered by reducing the number of channels by 1.
+ */
+ ret = iio_buffer_register(indio_dev, iio_dummy_channels, 5);
+ if (ret < 0)
+ goto error_unconfigure_buffer;
+
+ ret = iio_device_register(indio_dev);
+ if (ret < 0)
+ goto error_unregister_buffer;
+
return 0;
+error_unregister_buffer:
+ iio_buffer_unregister(indio_dev);
+error_unconfigure_buffer:
+ iio_simple_dummy_unconfigure_buffer(indio_dev);
error_unregister_events:
iio_simple_dummy_events_unregister(indio_dev);
error_free_device:
@@ -429,6 +481,9 @@ static int iio_dummy_remove(int index)
/* Device specific code to power down etc */
+ /* Buffered capture related cleanup */
+ iio_buffer_unregister(indio_dev);
+ iio_simple_dummy_unconfigure_buffer(indio_dev);
ret = iio_simple_dummy_events_unregister(indio_dev);
if (ret)