1 ======= 2 Buffers 3 ======= 4 5 * struct iio_buffer — general buffer structu 6 * :c:func:`iio_validate_scan_mask_onehot` — 7 is selected 8 * :c:func:`iio_buffer_get` — Grab a referenc 9 * :c:func:`iio_buffer_put` — Release the ref 10 11 The Industrial I/O core offers a way for conti 12 trigger source. Multiple data channels can be 13 :file:`/dev/iio:device{X}` character device no 14 15 IIO buffer sysfs interface 16 ========================== 17 An IIO buffer has an associated attributes dir 18 :file:`/sys/bus/iio/devices/iio:device{X}/buff 19 existing attributes: 20 21 * :file:`length`, the total number of data sam 22 stored by the buffer. 23 * :file:`enable`, activate buffer capture. 24 25 IIO buffer setup 26 ================ 27 28 The meta information associated with a channel 29 called a scan element. The important bits conf 30 exposed to userspace applications via the 31 :file:`/sys/bus/iio/devices/iio:device{X}/scan 32 directory contains attributes of the following 33 34 * :file:`enable`, used for enabling a channel. 35 is non *zero*, then a triggered capture will 36 channel. 37 * :file:`index`, the scan_index of the channel 38 * :file:`type`, description of the scan elemen 39 and hence the form in which it is read from 40 Format is [be|le]:[s|u]bits/storagebits[Xrep 41 42 * *be* or *le*, specifies big or little endi 43 * *s* or *u*, specifies if signed (2's compl 44 * *bits*, is the number of valid data bits. 45 * *storagebits*, is the number of bits (afte 46 buffer. 47 * *repeat*, specifies the number of bits/sto 48 repeat element is 0 or 1, then the repeat 49 * *shift*, if specified, is the shift that n 50 masking out unused bits. 51 52 For example, a driver for a 3-axis acceleromet 53 data is stored in two 8-bits registers as foll 54 55 7 6 5 4 3 2 1 0 56 +---+---+---+---+---+---+---+---+ 57 |D3 |D2 |D1 |D0 | X | X | X | X | (LOW b 58 +---+---+---+---+---+---+---+---+ 59 60 7 6 5 4 3 2 1 0 61 +---+---+---+---+---+---+---+---+ 62 |D11|D10|D9 |D8 |D7 |D6 |D5 |D4 | (HIGH 63 +---+---+---+---+---+---+---+---+ 64 65 will have the following scan element type for 66 67 $ cat /sys/bus/iio/devices/iio:device0/s 68 le:s12/16>>4 69 70 A user space application will interpret data s 71 two byte little endian signed data, that needs 72 masking out the 12 valid bits of data. 73 74 For implementing buffer support a driver shoul 75 fields in iio_chan_spec definition:: 76 77 struct iio_chan_spec { 78 /* other members */ 79 int scan_index 80 struct { 81 char sign; 82 u8 realbits; 83 u8 storagebits; 84 u8 shift; 85 u8 repeat; 86 enum iio_endian endianness; 87 } scan_type; 88 }; 89 90 The driver implementing the accelerometer desc 91 following channel definition:: 92 93 struct iio_chan_spec accel_channels[] = { 94 { 95 .type = IIO_ACCEL, 96 .modified = 1, 97 .channel2 = IIO_MOD_X, 98 /* other stuff here */ 99 .scan_index = 0, 100 .scan_type = { 101 .sign = 's', 102 .realbits = 12, 103 .storagebits = 16, 104 .shift = 4, 105 .endianness = IIO_L 106 }, 107 } 108 /* similar for Y (with channel2 = I 109 * and Z (with channel2 = IIO_MOD_Z 110 */ 111 } 112 113 Here **scan_index** defines the order in which 114 inside the buffer. Channels with a lower **sca 115 channels with a higher index. Each channel nee 116 **scan_index**. 117 118 Setting **scan_index** to -1 can be used to in 119 does not support buffered capture. In this cas 120 the channel in the scan_elements directory. 121 122 More details 123 ============ 124 .. kernel-doc:: include/linux/iio/buffer.h 125 .. kernel-doc:: drivers/iio/industrialio-buffe 126 :export:
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.