Deleted: trunk/drivers/staging/iio/Documentation/lis3l02dqbuffersimple.c (9383 => 9384)
--- trunk/drivers/staging/iio/Documentation/lis3l02dqbuffersimple.c 2010-10-24 20:56:21 UTC (rev 9383)
+++ trunk/drivers/staging/iio/Documentation/lis3l02dqbuffersimple.c 2010-10-24 20:58:26 UTC (rev 9384)
@@ -1,238 +0,0 @@
-/* Industrialio ring buffer with a lis3l02dq accelerometer
- *
- * Copyright (c) 2008 Jonathan Cameron
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by
- * the Free Software Foundation.
- *
- * This program is primarily intended as an example application.
- */
-
-#include <dirent.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <sys/dir.h>
-#include <linux/types.h>
-#include "iio_utils.h"
-
-const char *device_name = "lis3l02dq";
-const char *trigger_name_base = "lis3l02dq-dev";
-const int num_vals = 3;
-const int scan_ts = 1;
-const int buf_len = 128;
-const int num_loops = 10;
-
-/*
- * Could get this from ring bps, but only after starting the ring
- * which is a bit late for it to be useful.
- *
- * Todo: replace with much more generic version based on scan_elements
- * directory.
- */
-int size_from_scanmode(int num_vals, int timestamp)
-{
- if (num_vals && timestamp)
- return 16;
- else if (timestamp)
- return 8;
- else
- return num_vals*2;
-}
-
-int main(int argc, char **argv)
-{
- int ret;
- int i, j, k, toread;
- FILE *fp_ev;
- int fp;
-
- char *trigger_name, *dev_dir_name, *buf_dir_name;
- char *data;
- size_t read_size;
- struct iio_event_data dat;
- int dev_num, trig_num;
-
- char *buffer_access, *buffer_event;
- const char *iio_dir = "/sys/bus/iio/devices/";
- int scan_size;
- float gain = 1;
-
-
- /* Find out which iio device is the accelerometer. */
- dev_num = find_type_by_name(device_name, "device");
- if (dev_num < 0) {
- printf("Failed to find the %s\n", device_name);
- ret = -ENODEV;
- goto error_ret;
- }
- printf("iio device number being used is %d\n", dev_num);
- asprintf(&dev_dir_name, "%sdevice%d", iio_dir, dev_num);
-
- /*
- * Build the trigger name.
- * In this case we want the lis3l02dq's data ready trigger
- * for this lis3l02dq. The naming is lis3l02dq_dev[n], where
- * n matches the device number found above.
- */
- ret = asprintf(&trigger_name, "%s%d", trigger_name_base, dev_num);
- if (ret < 0) {
- ret = -ENOMEM;
- goto error_free_dev_dir_name;
- }
-
- /*
- * Find the trigger by name.
- * This is techically unecessary here as we only need to
- * refer to the trigger by name and that name is already
- * known.
- */
- trig_num = find_type_by_name(trigger_name, "trigger");
- if (trig_num < 0) {
- printf("Failed to find the %s\n", trigger_name);
- ret = -ENODEV;
- goto error_free_triggername;
- }
- printf("iio trigger number being used is %d\n", trig_num);
-
- /*
- * Read in the scale value - in a more generic case, first
- * check for accel_scale, then the indivual channel scales
- */
- ret = read_sysfs_float("accel_scale", dev_dir_name, &gain);
- if (ret)
- goto error_free_triggername;;
-
- /*
- * Construct the directory name for the associated buffer.
- * As we know that the lis3l02dq has only one buffer this may
- * be built rather than found.
- */
- ret = asprintf(&buf_dir_name, "%sdevice%d:buffer0", iio_dir, dev_num);
- if (ret < 0) {
- ret = -ENOMEM;
- goto error_free_triggername;
- }
- /* Set the device trigger to be the data rdy trigger found above */
- ret = write_sysfs_string_and_verify("trigger/current_trigger",
- dev_dir_name,
- trigger_name);
- if (ret < 0) {
- printf("Failed to write current_trigger file\n");
- goto error_free_buf_dir_name;
- }
-
- /* Setup ring buffer parameters */
- ret = write_sysfs_int("length", buf_dir_name, buf_len);
- if (ret < 0)
- goto error_free_buf_dir_name;
-
- /* Enable the buffer */
- ret = write_sysfs_int("enable", buf_dir_name, 1);
- if (ret < 0)
- goto error_free_buf_dir_name;
-
- data = "" scan_ts)*buf_len);
- if (!data) {
- ret = -ENOMEM;
- goto error_free_buf_dir_name;
- }
-
- ret = asprintf(&buffer_access,
- "/dev/device%d:buffer0:access0",
- 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_data;
- }
- /* 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;
- }
-
- /* Wait for events 10 times */
- for (j = 0; j < num_loops; j++) {
- 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;
- }
- read_size = read(fp,
- data,
- toread*size_from_scanmode(num_vals, scan_ts));
- if (read_size == -EAGAIN) {
- printf("nothing available\n");
- continue;
- }
- scan_size = size_from_scanmode(num_vals, scan_ts);
- for (i = 0; i < read_size/scan_size; i++) {
- for (k = 0; k < num_vals; k++) {
- __s16 val = *(__s16 *)(&data[i*scan_size
- + (k)*2]);
- printf("%05f ", (float)val*gain);
- }
- printf(" %lld\n",
- *(__s64 *)(&data[(i + 1)
- *size_from_scanmode(num_vals,
- scan_ts)
- - sizeof(__s64)]));
- }
- }
-
- /* Stop the ring buffer */
- ret = write_sysfs_int("enable", buf_dir_name, 0);
- if (ret < 0)
- goto error_close_buffer_event;
-
- /* 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:
- free(trigger_name);
-error_free_dev_dir_name:
- free(dev_dir_name);
-error_ret:
- return ret;
-}
Deleted: trunk/drivers/staging/iio/Documentation/sysfs-class-iio (9383 => 9384)
--- trunk/drivers/staging/iio/Documentation/sysfs-class-iio 2010-10-24 20:56:21 UTC (rev 9383)
+++ trunk/drivers/staging/iio/Documentation/sysfs-class-iio 2010-10-24 20:58:26 UTC (rev 9384)
@@ -1,294 +0,0 @@
-
-What: /sys/bus/iio/devices/device[n]
-KernelVersion: 2.6.35
-Contact: [email protected]
-Description:
- Hardware chip or device accessed by on communication port.
- Corresponds to a grouping of sensor channels.
-
-What: /sys/bus/iio/devices/trigger[n]
-KernelVersion: 2.6.35
-Contact: [email protected]
-Description:
- An event driven driver of data capture to an in kernel buffer.
- May be provided by a device driver that also has an IIO device
- based on hardware generated events (e.g. data ready) or
- provided by a separate driver for other hardware (e.g.
- periodic timer, gpio or high resolution timer).
- Contains trigger type specific elements. These do not
- generalize well and hence are not documented in this file.
-
-What: /sys/bus/iio/devices/device[n]:buffer
-KernelVersion: 2.6.35
-Contact: [email protected]
-Description:
- Link to /sys/class/iio/device[n]/device[n]:buffer. n indicates the
- device with which this buffer buffer is associated.
-
-What: /sys/.../device[n]/name
-KernelVersion: 2.6.35
-Contact: [email protected]
-Description:
- Description of the physical chip / device. Typically a part
- number.
-
-What: /sys/.../device[n]/sampling_frequency
-KernelVersion: 2.6.35
-Contact: [email protected]
-Description:
- Some devices have internal clocks. This parameter sets the
- resulting sampling frequency. In many devices this
- parameter has an effect on input filters etc rather than
- simply controlling when the input is sampled. As this
- effects datardy triggers, hardware buffers and the sysfs
- direct access interfaces, it may be found in any of the
- relevant directories. If it effects all of the above
- then it is to be found in the base device directory as here.
-
-What: /sys/.../device[n]/sampling_frequency_available
-KernelVersion: 2.6.35
-Contact: [email protected]
-Description:
- When the internal sampling clock can only take a small
- discrete set of values, this file lists those availale.
-
-What: /sys/.../device[n]/in[_name][m]_raw
-KernelVersion: 2.6.35
-Contact: [email protected]
-Description:
- Raw (unscaled no bias removal etc) voltage measurement from
- channel m. name is used in special cases where this does
- not correspond to externally available input (e.g. supply
- voltage monitoring in which case the file is in_supply_raw).
-
-What: /sys/.../device[n]/in[_name][m]_offset
-KernelVersion: 2.6.35
-Contact: [email protected]
-Description:
- If known for a device, offset to be added to in[m]_raw prior
- to scaling by in[_name][m]_scale in order to obtain voltage in
- millivolts. Not present if the offset is always 0 or unknown.
- If m is not present, then voltage offset applies to all in
- channels. May be writable if a variable offset is controlled
- by the device. Note that this is different to calibbias which
- is for devices that apply offsets to compensate for variation
- between different instances of the part, typically adjusted by
- using some hardware supported calibration procedure.
-
-What: /sys/.../device[n]/in[_name][m]_offset_available
-KernelVersion: 2.6.35
-Contact: [email protected]
-Description:
- If a small number of discrete offset values are available, this
- will be a space separated list. If these are independant (but
- options the same) for individual offsets then m should not be
- present.
-
-What: /sys/.../device[n]/in[_name][m]_offset_[min|max]
-KernelVersion: 2.6.35
-Contact: [email protected]
-Description:
- If a more or less continuous range of voltage offsets are supported
- then these specify the minimum and maximum. If shared by all
- in channels then m is not present.
-
-What: /sys/.../device[n]/in[_name][m]_calibbias
-KernelVersion: 2.6.35
-Contact: [email protected]
-Description:
- Hardware applied calibration offset. (assumed to fix production
- inaccuracies)
-
-What /sys/.../device[n]/in[_name][m]_calibscale
-KernelVersion: 2.6.35
-Contact: [email protected]
-Description:
- Hardware applied calibration scale factor. (assumed to fix production
- inaccuracies)
-
-What: /sys/.../device[n]/in[_name][m]_scale
-KernelVersion: 2.6.35
-Contact: [email protected]
-Description:
- If known for a device, scale to be applied to volt[m]_raw post
- addition of in[_name][m]_offset in order to obtain the measured
- voltage in millivolts. If shared across all in channels then m is not present.
-
-What: /sys/.../device[n]/in[m]-in[o]_raw
-KernelVersion: 2.6.35
-Contact: [email protected]
-Description:
- Raw (unscaled) differential voltage measurement equivalent to
- channel m - channel o where these channel numbers apply to the physically
- equivalent inputs when non differential readings are separately available.
- In differential only parts, then all that is required is a consistent
- labelling.
-
-What: /sys/.../device[n]/accel[_x|_y|_z][m]_raw
-KernelVersion: 2.6.35
-Contact: [email protected]
-Description:
- Acceleration in direction x, y or z (may be arbitrarily assigned
- but should match other such assignments on device)
- channel m (not present if only one accelerometer channel at
- this orientation). Has all of the equivalent parameters as per in[m].
- Units after application of scale and offset are m/s^2.
-
-What: /sys/.../device[n]/gyro[_x|_y|_z][m]_raw
-KernelVersion: 2.6.35
-Contact: [email protected]
-Description:
- Angular velocity about axis x, y or z (may be arbitrarily assigned)
- channel m (not present if only one gyroscope at this orientation).
- Data converted by application of offset then scale to
- radians per second. Has all the equivalent parameters as per in[m].
-
-What: /sys/.../device[n]/incli[_x|_y|_z][m]_raw
-KernelVersion: 2.6.35
-Contact: [email protected]
-Description:
- Inclination raw reading about axis x, y or z (may be arbitarily
- assigned) channel m (not present if only one inclinometer at
- this orientation). Data converted by application of offset
- and scale to Degrees.
-
-What: /sys/.../device[n]/magn[_x|_y|_z][m]_raw
-KernelVersion: 2.6.35
-Contact: [email protected]
-Description:
- Magnetic field along axis x, y or z (may be arbitrarily assigned)
- channel m (not present if only one magnetometer at this orientation).
- Data converted by application of offset then scale to Gauss.
- Has all the equivalent modifiers as per in[m].
-
-What: /sys/.../device[n]/device[n]:event[m]
-KernelVersion: 2.6.35
-Contact: [email protected]
-Description:
- Configuration of which hardware generated events are passed up to
- userspace. Some of these are a bit complex to generalize so this
- section is a work in progress.
-
-What: /sys/.../device[n]:event[m]/dev
-KernelVersion: 2.6.35
-Contact: [email protected]
-Description:
- major:minor character device numbers for the event line.
-
-Taking accel_x0 as an example
-
-What: /sys/.../device[n]:event[m]/accel_x0_thresh[_high|_low]_en
-KernelVersion: 2.6.35
-Contact: [email protected]
-Description:
- Event generated when accel_x0 passes a threshold in correction direction
- (or stays beyond one). If direction isn't specified, either triggers it.
- Note driver will assume last p events requested are enabled where p is
- however many it supports. So if you want to be sure you have
- set what you think you have, check the contents of these. Drivers
- may have to buffer any parameters so that they are consistent when a
- given event type is enabled a future point (and not those for whatever
- alarm was previously enabled).
-
-What: /sys/.../device[n]:event[m]/accel_x0_roc[_high|_low]_en
-KernelVersion: 2.6.35
-Contact: [email protected]
-Description:
- Same as above but based on the first differential of the value.
-
-
-What: /sys/.../device[n]:event[m]/accel_x0[_thresh|_roc][_high|_low]_period
-KernelVersion: 2.6.35
-Contact: [email protected]
-Description:
- A period of time (microsecs) for which the condition must be broken
- before an interrupt is triggered. Applies to all alarms if type is not
- specified.
-
-What: /sys/.../device[n]:event[m]/accel_x0[_thresh|_roc][_high|_low]_value
-KernelVersion: 2.6.35
-Contact: [email protected]
-Description:
- The actual value of the threshold in raw device units obtained by
- reverse application of scale and offfset to the acceleration in m/s^2.
-
-What: /sys/.../device[n]/device[n]:buffer:event/dev
-KernelVersion: 2.6.35
-Contact: [email protected]
-Description:
- Buffer for device n event character device major:minor numbers.
-
-What: /sys/.../device[n]/device[n]:buffer:access/dev
-KernelVersion: 2.6.35
-Contact: [email protected]
-Description:
- Buffer for device n access character device o major:minor numbers.
-
-What: /sys/.../device[n]:buffer/trigger
-KernelVersion: 2.6.35
-Contact: [email protected]
-Description:
- The name of the trigger source being used, as per string given
- in /sys/class/iio/trigger[n]/name.
-
-What: /sys/.../device[n]:buffer/length
-KernelVersion: 2.6.35
-Contact: [email protected]
-Description:
- Number of scans contained by the buffer.
-
-What: /sys/.../device[n]:buffer/bytes_per_datum
-KernelVersion: 2.6.37
-Contact: [email protected]
-Description:
- Bytes per scan. Due to alignment fun, the scan may be larger
- than implied directly by the scan_element parameters.
-
-What: /sys/.../device[n]:buffer/enable
-KernelVersion: 2.6.35
-Contact: [email protected]
-Description:
- Actually start the buffer capture up. Will start trigger
- if first device and appropriate.
-
-What: /sys/.../device[n]:buffer/alignment
-KernelVersion: 2.6.35
-Contact: [email protected]
-Description:
- Minimum data alignment. Scan elements larger than this are aligned
- to the nearest power of 2 times this. (may not be true in weird
- hardware buffers that pack data well)
-
-What: /sys/.../device[n]/buffer/scan_elements
-KernelVersion: 2.6.37
-Contact: [email protected]
-Description:
- Directory containing interfaces for elements that will be captured
- for a single triggered sample set in the buffer.
-
-What: /sys/.../device[n]/buffer/scan_elements/[m]_accel_x0_en
-KernelVersion: 2.6.37
-Contact: [email protected]
-Description:
- Scan element control for triggered data capture. m implies the
- ordering within the buffer. Next the type is specified with
- modifier and channel number as per the sysfs single channel
- access above.
-
-What: /sys/.../device[n]/buffer/scan_elements/accel[_x0]_precision
-KernelVersion: 2.6.37
-Contact: [email protected]
-Description:
- Scan element precision within the buffer. Note that the
- data alignment must restrictions must be read from within
- buffer to work out full data alignment for data read
- via buffer_access chrdev. _x0 dropped if shared across all
- acceleration channels.
-
-What: /sys/.../device[n]/buffer/scan_elements/accel[_x0]_shift
-KernelVersion: 2.6.37
-Contact: [email protected]
-Description:
- A bit shift (to right) that must be applied prior to
- extracting the bits specified by accel[_x0]_precision.
-