blob: 7e99ef2b7bc01b667813edf1f3b1414ce3d00681 [file] [log] [blame]
Jonathan Cameron44d8b352011-05-18 14:42:40 +01001Buffer support within IIO
Jonathan Cameronc57f1ba2009-08-18 18:06:32 +01002
3This document is intended as a general overview of the functionality
Jonathan Cameron44d8b352011-05-18 14:42:40 +01004a buffer may supply and how it is specified within IIO. For more
5specific information on a given buffer implementation, see the
6comments in the source code. Note that some drivers allow buffer
7implementation to be selected at compile time via Kconfig options.
Jonathan Cameronc57f1ba2009-08-18 18:06:32 +01008
Jonathan Cameron44d8b352011-05-18 14:42:40 +01009A given buffer implementation typically embeds a struct
Jonathan Cameronc57f1ba2009-08-18 18:06:32 +010010iio_ring_buffer and it is a pointer to this that is provided to the
11IIO core. Access to the embedding structure is typically done via
12container_of functions.
13
Jonathan Cameron44d8b352011-05-18 14:42:40 +010014struct iio_ring_buffer contains a struct iio_ring_setup_ops *setup_ops
15which in turn contains the 4 function pointers
16(preenable, postenable, predisable and postdisable).
17These are used to perform device specific steps on either side
18of the core changing it's current mode to indicate that the buffer
Jonathan Cameronc57f1ba2009-08-18 18:06:32 +010019is enabled or disabled (along with enabling triggering etc as appropriate).
20
21Also in struct iio_ring_buffer is a struct iio_ring_access_funcs.
22The function pointers within here are used to allow the core to handle
Jonathan Cameron44d8b352011-05-18 14:42:40 +010023as much buffer functionality as possible. Note almost all of these
Jonathan Cameronc57f1ba2009-08-18 18:06:32 +010024are optional.
25
26mark_in_use, unmark_in_use
Jonathan Cameron44d8b352011-05-18 14:42:40 +010027 Basically indicate that not changes should be made to the buffer state that
28 will effect the form of the data being captures (e.g. scan elements or length)
Jonathan Cameronc57f1ba2009-08-18 18:06:32 +010029
30store_to
Jonathan Cameron44d8b352011-05-18 14:42:40 +010031 If possible, push data to the buffer.
Jonathan Cameronc57f1ba2009-08-18 18:06:32 +010032
33read_last
Jonathan Cameron44d8b352011-05-18 14:42:40 +010034 If possible, get the most recent scan from the buffer (without removal).
Jonathan Cameronc57f1ba2009-08-18 18:06:32 +010035 This provides polling like functionality whilst the ring buffering is in
36 use without a separate read from the device.
37
Jonathan Cameron44d8b352011-05-18 14:42:40 +010038rip_first_n
39 The primary buffer reading function. Note that it may well not return
40 as much data as requested.
Jonathan Cameronc57f1ba2009-08-18 18:06:32 +010041
42mark_param_changed
43 Used to indicate that something has changed. Used in conjunction with
44request_update
45 If parameters have changed that require reinitialization or configuration of
Jonathan Cameron44d8b352011-05-18 14:42:40 +010046 the buffer this will trigger it.
Jonathan Cameronc57f1ba2009-08-18 18:06:32 +010047
Manuel Stahl5770b8f2010-08-31 11:32:53 +020048get_bytes_per_datum, set_bytes_per_datum
49 Get/set the number of bytes for a complete scan. (All samples + timestamp)
Jonathan Cameronc57f1ba2009-08-18 18:06:32 +010050
51get_length / set_length
Jonathan Cameron44d8b352011-05-18 14:42:40 +010052 Get/set the number of complete scans that may be held by the buffer.
Jonathan Cameronc57f1ba2009-08-18 18:06:32 +010053
54is_enabled
55 Query if ring buffer is in use
56enable
57 Start the ring buffer.