summaryrefslogtreecommitdiff
path: root/drivers/staging/iio/Documentation
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging/iio/Documentation')
-rw-r--r--drivers/staging/iio/Documentation/device.txt78
-rw-r--r--drivers/staging/iio/Documentation/generic_buffer.c95
-rw-r--r--drivers/staging/iio/Documentation/iio_utils.h20
-rw-r--r--drivers/staging/iio/Documentation/overview.txt19
-rw-r--r--drivers/staging/iio/Documentation/ring.txt44
-rw-r--r--drivers/staging/iio/Documentation/sysfs-bus-iio13
-rw-r--r--drivers/staging/iio/Documentation/sysfs-bus-iio-light13
-rw-r--r--drivers/staging/iio/Documentation/sysfs-bus-iio-light-tsl258320
-rw-r--r--drivers/staging/iio/Documentation/trigger.txt16
-rw-r--r--drivers/staging/iio/Documentation/userspace.txt12
10 files changed, 177 insertions, 153 deletions
diff --git a/drivers/staging/iio/Documentation/device.txt b/drivers/staging/iio/Documentation/device.txt
index 69d9570f29fc..1abb80cb884e 100644
--- a/drivers/staging/iio/Documentation/device.txt
+++ b/drivers/staging/iio/Documentation/device.txt
@@ -8,34 +8,66 @@ The crucial structure for device drivers in iio is iio_dev.
First allocate one using:
-struct iio_dev *indio_dev = iio_allocate_device();
+struct iio_dev *indio_dev = iio_allocate_device(sizeof(struct chip_state));
+where chip_state is a structure of local state data for this instance of
+the chip.
-Then fill in the following:
-
-indio_dev->dev.parent
- the struct device associated with the underlying hardware.
-
-indio_dev->num_interrupt_lines
- number of event triggering hardware lines the device has.
+That data can be accessed using iio_priv(struct iio_dev *)
-indio_dev->event_attrs
- attributes used to enable / disable hardware events - note the
- attributes are embedded in iio_event_attr structures with an
- associated iio_event_handler which may or may note be shared.
- If num_interrupt_lines = 0, then no need to fill this in.
-
-indio_dev->attrs
- general attributes such as polled access to device channels.
+Then fill in the following:
-indio_dev->dev_data
- private device specific data.
+- indio_dev->dev.parent
+ Struct device associated with the underlying hardware.
+- indio_dev->name
+ Name of the device being driven - made available as the name
+ attribute in sysfs.
-indio_dev->driver_module
- typically set to THIS_MODULE. Used to specify ownership of some
- iio created resources.
+- indio_dev->info
+ pointer to a structure with elements that tend to be fixed for
+ large sets of different parts supported by a given driver.
+ This contains:
+ * info->driver_module:
+ Set to THIS_MODULE. Used to ensure correct ownership
+ of various resources allocate by the core.
+ * info->num_interrupt_lines:
+ Number of event triggering hardware lines the device has.
+ * info->event_attrs:
+ Attributes used to enable / disable hardware events.
+ * info->attrs:
+ General device attributes. Typically used for the weird
+ and the wonderful bits not covered by the channel specification.
+ * info->read_raw:
+ Raw data reading function. Used for both raw channel access
+ and for associate parameters such as offsets and scales.
+ * info->write_raw:
+ Raw value writing function. Used for writable device values such
+ as DAC values and caliboffset.
+ * info->read_event_config:
+ Typically only set if there are some interrupt lines. This
+ is used to read if an on sensor event detector is enabled.
+ * info->write_event_config:
+ Enable / disable an on sensor event detector.
+ * info->read_event_value:
+ Read value associated with on sensor event detectors. Note that
+ the meaning of the returned value is dependent on the event
+ type.
+ * info->write_event_value:
+ Write the value associated with on sensor event detectors. E.g.
+ a threshold above which an interrupt occurs. Note that the
+ meaning of the value to be set is event type dependant.
-indio_dev->modes
- whether direct access and / or ring buffer access is supported.
+- indio_dev->modes:
+ Specify whether direct access and / or ring buffer access is supported.
+- indio_dev->ring:
+ An optional associated buffer.
+- indio_dev->pollfunc:
+ Poll function related elements. This controls what occurs when a trigger
+ to which this device is attached sends and event.
+- indio_dev->channels:
+ Specification of device channels. Most attributes etc are built
+ form this spec.
+- indio_dev->num_channels:
+ How many channels are there?
Once these are set up, a call to iio_device_register(indio_dev),
will register the device with the iio core.
diff --git a/drivers/staging/iio/Documentation/generic_buffer.c b/drivers/staging/iio/Documentation/generic_buffer.c
index 3cc18ab4ebfd..f82894f42d27 100644
--- a/drivers/staging/iio/Documentation/generic_buffer.c
+++ b/drivers/staging/iio/Documentation/generic_buffer.c
@@ -27,6 +27,7 @@
#include <sys/dir.h>
#include <linux/types.h>
#include <string.h>
+#include <poll.h>
#include "iio_utils.h"
/**
@@ -53,6 +54,24 @@ int size_from_channelarray(struct iio_channel_info *channels, int num_channels)
return bytes;
}
+void print2byte(int input, struct iio_channel_info *info)
+{
+ /* shift before conversion to avoid sign extension
+ of left aligned data */
+ input = input >> info->shift;
+ if (info->is_signed) {
+ int16_t val = input;
+ val &= (1 << info->bits_used) - 1;
+ val = (int16_t)(val << (16 - info->bits_used)) >>
+ (16 - info->bits_used);
+ printf("%05f ", val,
+ (float)(val + info->offset)*info->scale);
+ } else {
+ uint16_t val = input;
+ val &= (1 << info->bits_used) - 1;
+ printf("%05f ", ((float)val + info->offset)*info->scale);
+ }
+}
/**
* process_scan() - print out the values in SI units
* @data: pointer to the start of the scan
@@ -70,25 +89,8 @@ void process_scan(char *data,
switch (infoarray[k].bytes) {
/* only a few cases implemented so far */
case 2:
- if (infoarray[k].is_signed) {
- int16_t val = *(int16_t *)
- (data
- + infoarray[k].location);
- if ((val >> infoarray[k].bits_used) & 1)
- val = (val & infoarray[k].mask) |
- ~infoarray[k].mask;
- printf("%05f ", ((float)val +
- infoarray[k].offset)*
- infoarray[k].scale);
- } else {
- uint16_t val = *(uint16_t *)
- (data +
- infoarray[k].location);
- val = (val & infoarray[k].mask);
- printf("%05f ", ((float)val +
- infoarray[k].offset)*
- infoarray[k].scale);
- }
+ print2byte(*(uint16_t *)(data + infoarray[k].location),
+ &infoarray[k]);
break;
case 8:
if (infoarray[k].is_signed) {
@@ -132,10 +134,9 @@ int main(int argc, char **argv)
int datardytrigger = 1;
char *data;
- size_t read_size;
- struct iio_event_data dat;
+ ssize_t read_size;
int dev_num, trig_num;
- char *buffer_access, *buffer_event;
+ char *buffer_access;
int scan_size;
int noevents = 0;
char *dummy;
@@ -210,7 +211,7 @@ int main(int argc, char **argv)
*/
ret = build_channel_array(dev_dir_name, &infoarray, &num_channels);
if (ret) {
- printf("Problem reading scan element information \n");
+ printf("Problem reading scan element information\n");
goto error_free_triggername;
}
@@ -251,54 +252,32 @@ int main(int argc, char **argv)
}
ret = asprintf(&buffer_access,
- "/dev/device%d:buffer0:access0",
+ "/dev/device%d:buffer0",
dev_num);
if (ret < 0) {
ret = -ENOMEM;
goto error_free_data;
}
- ret = asprintf(&buffer_event, "/dev/device%d:buffer0:event0", dev_num);
- if (ret < 0) {
- ret = -ENOMEM;
- goto error_free_buffer_access;
- }
/* Attempt to open non blocking the access dev */
fp = open(buffer_access, O_RDONLY | O_NONBLOCK);
if (fp == -1) { /*If it isn't there make the node */
printf("Failed to open %s\n", buffer_access);
ret = -errno;
- goto error_free_buffer_event;
- }
- /* Attempt to open the event access dev (blocking this time) */
- fp_ev = fopen(buffer_event, "rb");
- if (fp_ev == NULL) {
- printf("Failed to open %s\n", buffer_event);
- ret = -errno;
- goto error_close_buffer_access;
+ goto error_free_buffer_access;
}
/* Wait for events 10 times */
for (j = 0; j < num_loops; j++) {
if (!noevents) {
- read_size = fread(&dat,
- 1,
- sizeof(struct iio_event_data),
- fp_ev);
- switch (dat.id) {
- case IIO_EVENT_CODE_RING_100_FULL:
- toread = buf_len;
- break;
- case IIO_EVENT_CODE_RING_75_FULL:
- toread = buf_len*3/4;
- break;
- case IIO_EVENT_CODE_RING_50_FULL:
- toread = buf_len/2;
- break;
- default:
- printf("Unexpecteded event code\n");
- continue;
- }
+ struct pollfd pfd = {
+ .fd = fp,
+ .events = POLLIN,
+ };
+
+ poll(&pfd, 1, -1);
+ toread = buf_len;
+
} else {
usleep(timedelay);
toread = 64;
@@ -320,22 +299,18 @@ int main(int argc, char **argv)
/* Stop the ring buffer */
ret = write_sysfs_int("enable", buf_dir_name, 0);
if (ret < 0)
- goto error_close_buffer_event;
+ goto error_close_buffer_access;
/* Disconnect from the trigger - just write a dummy name.*/
write_sysfs_string("trigger/current_trigger",
dev_dir_name, "NULL");
-error_close_buffer_event:
- fclose(fp_ev);
error_close_buffer_access:
close(fp);
error_free_data:
free(data);
error_free_buffer_access:
free(buffer_access);
-error_free_buffer_event:
- free(buffer_event);
error_free_buf_dir_name:
free(buf_dir_name);
error_free_triggername:
diff --git a/drivers/staging/iio/Documentation/iio_utils.h b/drivers/staging/iio/Documentation/iio_utils.h
index fd78e4ff99ae..150f44073631 100644
--- a/drivers/staging/iio/Documentation/iio_utils.h
+++ b/drivers/staging/iio/Documentation/iio_utils.h
@@ -16,25 +16,11 @@
#define IIO_MAX_NAME_LENGTH 30
-#define IIO_EV_CLASS_BUFFER 0
-#define IIO_BUFFER_EVENT_CODE(code) \
- (IIO_EV_CLASS_BUFFER | (code << 8))
-
-#define IIO_EVENT_CODE_RING_50_FULL IIO_BUFFER_EVENT_CODE(0)
-#define IIO_EVENT_CODE_RING_75_FULL IIO_BUFFER_EVENT_CODE(1)
-#define IIO_EVENT_CODE_RING_100_FULL IIO_BUFFER_EVENT_CODE(2)
-
-
#define FORMAT_SCAN_ELEMENTS_DIR "%s:buffer0/scan_elements"
#define FORMAT_TYPE_FILE "%s_type"
const char *iio_dir = "/sys/bus/iio/devices/";
-struct iio_event_data {
- int id;
- __s64 timestamp;
-};
-
/**
* iioutils_break_up_name() - extract generic name from full channel name
* @full_name: the full channel name
@@ -85,6 +71,7 @@ struct iio_channel_info {
unsigned index;
unsigned bytes;
unsigned bits_used;
+ unsigned shift;
uint64_t mask;
unsigned is_signed;
unsigned enabled;
@@ -103,6 +90,7 @@ struct iio_channel_info {
inline int iioutils_get_type(unsigned *is_signed,
unsigned *bytes,
unsigned *bits_used,
+ unsigned *shift,
uint64_t *mask,
const char *device_dir,
const char *name,
@@ -157,7 +145,8 @@ inline int iioutils_get_type(unsigned *is_signed,
goto error_free_filename;
}
fscanf(sysfsfp,
- "%c%u/%u", &signchar, bits_used, &padint);
+ "%c%u/%u>>%u", &signchar, bits_used,
+ &padint, shift);
*bytes = padint / 8;
if (*bits_used == 64)
*mask = ~0;
@@ -395,6 +384,7 @@ inline int build_channel_array(const char *device_dir,
ret = iioutils_get_type(&current->is_signed,
&current->bytes,
&current->bits_used,
+ &current->shift,
&current->mask,
device_dir,
current->name,
diff --git a/drivers/staging/iio/Documentation/overview.txt b/drivers/staging/iio/Documentation/overview.txt
index d97106cb2b96..afc39ecde9ca 100644
--- a/drivers/staging/iio/Documentation/overview.txt
+++ b/drivers/staging/iio/Documentation/overview.txt
@@ -3,8 +3,7 @@ Overview of IIO
The Industrial I/O subsystem is intended to provide support for devices
that in some sense are analog to digital converters (ADCs). As many
actual devices combine some ADCs with digital to analog converters
-(DACs) the intention is to add that functionality at a future date
-(hence the name).
+(DACs) that functionality is also supported.
The aim is to fill the gap between the somewhat similar hwmon and
input subsystems. Hwmon is very much directed at low sample rate
@@ -31,32 +30,28 @@ event must be accessed via polling.
Note: A given device may have one or more event channel. These events are
turned on or off (if possible) via sysfs interfaces.
-* Hardware ring buffer support. Some recent sensors have included
+* Hardware buffer support. Some recent sensors have included
fifo / ring buffers on the sensor chip. These greatly reduce the load
on the host CPU by buffering relatively large numbers of data samples
based on an internal sampling clock. Examples include VTI SCA3000
-series and Analog Device ADXL345 accelerometers. Each ring buffer
-typically has an event chrdev (similar to the more general ones above)
-to pass on events such as buffer 50% full and an access chrdev via
-which the raw data it self may be read back.
+series and Analog Device ADXL345 accelerometers. Each buffer supports
+polling to establish when data is available.
-* Trigger and software ring buffer support. In many data analysis
+* Trigger and software buffer support. In many data analysis
applications it it useful to be able to capture data based on some
external signal (trigger). These triggers might be a data ready
signal, a gpio line connected to some external system or an on
processor periodic interrupt. A single trigger may initialize data
capture or reading from a number of sensors. These triggers are
-used in IIO to fill software ring buffers acting in a very similar
+used in IIO to fill software buffers acting in a very similar
fashion to the hardware buffers described above.
Other documentation:
-userspace.txt - overview of ring buffer reading from userspace.
-
device.txt - elements of a typical device driver.
trigger.txt - elements of a typical trigger driver.
-ring.txt - additional elements required for ring buffer support.
+ring.txt - additional elements required for buffer support.
sysfs-bus-iio - abi documentation file.
diff --git a/drivers/staging/iio/Documentation/ring.txt b/drivers/staging/iio/Documentation/ring.txt
index 3696c364e644..7e99ef2b7bc0 100644
--- a/drivers/staging/iio/Documentation/ring.txt
+++ b/drivers/staging/iio/Documentation/ring.txt
@@ -1,57 +1,55 @@
-Ring buffer support within IIO
+Buffer support within IIO
This document is intended as a general overview of the functionality
-a ring buffer may supply and how it is specified within IIO. For more
-specific information on a given ring buffer implementation, see the
-comments in the source code. Note that the intention is to allow
-some drivers to specify ring buffers choice at probe or runtime, but
-for now the selection is hard coded within a given driver.
+a buffer may supply and how it is specified within IIO. For more
+specific information on a given buffer implementation, see the
+comments in the source code. Note that some drivers allow buffer
+implementation to be selected at compile time via Kconfig options.
-A given ring buffer implementation typically embedded a struct
+A given buffer implementation typically embeds a struct
iio_ring_buffer and it is a pointer to this that is provided to the
IIO core. Access to the embedding structure is typically done via
container_of functions.
-struct iio_ring_buffer contains 4 function pointers
-(preenable, postenable, predisable, postdisable).
-These are used to perform implementation specific steps on either side
-of the core changing it's current mode to indicate that the ring buffer
+struct iio_ring_buffer contains a struct iio_ring_setup_ops *setup_ops
+which in turn contains the 4 function pointers
+(preenable, postenable, predisable and postdisable).
+These are used to perform device specific steps on either side
+of the core changing it's current mode to indicate that the buffer
is enabled or disabled (along with enabling triggering etc as appropriate).
Also in struct iio_ring_buffer is a struct iio_ring_access_funcs.
The function pointers within here are used to allow the core to handle
-as much ring buffer functionality as possible. Note almost all of these
+as much buffer functionality as possible. Note almost all of these
are optional.
mark_in_use, unmark_in_use
- Basically indicate that not changes should be made to the ring
- buffer state that will effect the form of the data being captures
- (e.g. scan elements or length)
+ Basically indicate that not changes should be made to the buffer state that
+ will effect the form of the data being captures (e.g. scan elements or length)
store_to
- If possible, push data to ring buffer.
+ If possible, push data to the buffer.
read_last
- If possible get the most recent entry from the buffer (without removal).
+ If possible, get the most recent scan from the buffer (without removal).
This provides polling like functionality whilst the ring buffering is in
use without a separate read from the device.
-rip_lots
- The primary ring buffer reading function. Note that it may well not return
- as much data as requested. The deadoffset is used to indicate that some
- initial data in the data array is not guaranteed to be valid.
+rip_first_n
+ The primary buffer reading function. Note that it may well not return
+ as much data as requested.
mark_param_changed
Used to indicate that something has changed. Used in conjunction with
request_update
If parameters have changed that require reinitialization or configuration of
- the ring buffer this will trigger it.
+ the buffer this will trigger it.
get_bytes_per_datum, set_bytes_per_datum
Get/set the number of bytes for a complete scan. (All samples + timestamp)
get_length / set_length
- Get/set the number of sample sets that may be held by the buffer.
+ Get/set the number of complete scans that may be held by the buffer.
is_enabled
Query if ring buffer is in use
diff --git a/drivers/staging/iio/Documentation/sysfs-bus-iio b/drivers/staging/iio/Documentation/sysfs-bus-iio
index 4915aee14d88..467c49a47258 100644
--- a/drivers/staging/iio/Documentation/sysfs-bus-iio
+++ b/drivers/staging/iio/Documentation/sysfs-bus-iio
@@ -6,6 +6,12 @@ Description:
Corresponds to a grouping of sensor channels. X is the IIO
index of the device.
+What: /sys/bus/iio/devices/device[n]/power_state
+KernelVersion: 2.6.37
+Contact: linux-iio@vger.kernel.org
+Description:
+ This property gets/sets the device power state.
+
What: /sys/bus/iio/devices/triggerX
KernelVersion: 2.6.35
Contact: linux-iio@vger.kernel.org
@@ -698,3 +704,10 @@ Description:
with all _en attributes to establish which channels are present,
and the relevant _type attributes to establish the data storage
format.
+
+What: /sys/bus/iio/devices/deviceX/gyro_z_quadrature_correction_raw
+KernelVersion: 2.6.38
+Contact: linux-iio@xxxxxxxxxxxxxxx
+Description:
+ This attribute is used to read the amount of quadrature error
+ present in the device at a given time.
diff --git a/drivers/staging/iio/Documentation/sysfs-bus-iio-light b/drivers/staging/iio/Documentation/sysfs-bus-iio-light
index 5d84856dc14a..21d277405816 100644
--- a/drivers/staging/iio/Documentation/sysfs-bus-iio-light
+++ b/drivers/staging/iio/Documentation/sysfs-bus-iio-light
@@ -62,3 +62,16 @@ Description:
sensing mode. This value should be the output from a reading
and if expressed in SI units, should include _input. If this
value is not in SI units, then it should include _raw.
+
+What: /sys/bus/iio/devices/device[n]/illuminance0_target
+KernelVersion: 2.6.37
+Contact: linux-iio@vger.kernel.org
+Description:
+ This property gets/sets the last known external
+ lux measurement used in/for calibration.
+
+What: /sys/bus/iio/devices/device[n]/illuminance0_integration_time
+KernelVersion: 2.6.37
+Contact: linux-iio@vger.kernel.org
+Description:
+ This property gets/sets the sensors ADC analog integration time.
diff --git a/drivers/staging/iio/Documentation/sysfs-bus-iio-light-tsl2583 b/drivers/staging/iio/Documentation/sysfs-bus-iio-light-tsl2583
new file mode 100644
index 000000000000..660781df409f
--- /dev/null
+++ b/drivers/staging/iio/Documentation/sysfs-bus-iio-light-tsl2583
@@ -0,0 +1,20 @@
+What: /sys/bus/iio/devices/device[n]/lux_table
+KernelVersion: 2.6.37
+Contact: linux-iio@vger.kernel.org
+Description:
+ This property gets/sets the table of coefficients
+ used in calculating illuminance in lux.
+
+What: /sys/bus/iio/devices/device[n]/illuminance0_calibrate
+KernelVersion: 2.6.37
+Contact: linux-iio@vger.kernel.org
+Description:
+ This property causes an internal calibration of the als gain trim
+ value which is later used in calculating illuminance in lux.
+
+What: /sys/bus/iio/devices/device[n]/illuminance0_input_target
+KernelVersion: 2.6.37
+Contact: linux-iio@vger.kernel.org
+Description:
+ This property is the known externally illuminance (in lux).
+ It is used in the process of calibrating the device accuracy.
diff --git a/drivers/staging/iio/Documentation/trigger.txt b/drivers/staging/iio/Documentation/trigger.txt
index 650157f5c9de..fc2012ebc100 100644
--- a/drivers/staging/iio/Documentation/trigger.txt
+++ b/drivers/staging/iio/Documentation/trigger.txt
@@ -5,14 +5,11 @@ an IIO device. Whilst this can create device specific complexities
such triggers are registered with the core in the same way as
stand-alone triggers.
-struct iio_trig *trig = iio_allocate_trigger();
+struct iio_trig *trig = iio_allocate_trigger("<trigger format string>", ...);
allocates a trigger structure. The key elements to then fill in within
a driver are:
-trig->control_attrs
- Any sysfs attributes needed to control parameters of the trigger
-
trig->private_data
Device specific private data.
@@ -20,8 +17,12 @@ trig->owner
Typically set to THIS_MODULE. Used to ensure correct
ownership of core allocated resources.
-trig->name
- A unique name for the trigger.
+trig->set_trigger_state:
+ Function that enables / disables the underlying source of the trigger.
+
+There is also a
+trig->alloc_list which is useful for drivers that allocate multiple
+triggers to keep track of what they have created.
When these have been set call:
@@ -30,9 +31,8 @@ iio_trigger_register(trig);
to register the trigger with the core, making it available to trigger
consumers.
-
Trigger Consumers
-Currently triggers are only used for the filling of software ring
+Currently triggers are only used for the filling of software
buffers and as such any device supporting INDIO_RING_TRIGGERED has the
consumer interface automatically created.
diff --git a/drivers/staging/iio/Documentation/userspace.txt b/drivers/staging/iio/Documentation/userspace.txt
deleted file mode 100644
index ff06e5dc7188..000000000000
--- a/drivers/staging/iio/Documentation/userspace.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-Userspace access to IIO
-
-The sysfs attributes are documented in sysfs-bus-iio.
-
-Udev will create the following entries under /dev by default:
-
-device0:buffer0:access0 - ring access chrdev
-device0:buffer0:event0 - ring event chrdev
-device0:event0 - general event chrdev.
-
-The files, lis3l02dqbuffersimple.c and iio_utils.h in this directory provide an example
-of how to use the ring buffer and event interfaces.