]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/staging/iio/ring_sw.h
staging:iio: rationalization of different buffer implementation hooks.
[karo-tx-linux.git] / drivers / staging / iio / ring_sw.h
1 /* The industrial I/O simple minimally locked ring buffer.
2  *
3  * Copyright (c) 2008 Jonathan Cameron
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 as published by
7  * the Free Software Foundation.
8  *
9  * This code is deliberately kept separate from the main industrialio I/O core
10  * as it is intended that in the future a number of different software ring
11  * buffer implementations will exist with different characteristics to suit
12  * different applications.
13  *
14  * This particular one was designed for a data capture application where it was
15  * particularly important that no userspace reads would interrupt the capture
16  * process. To this end the ring is not locked during a read.
17  *
18  * Comments on this buffer design welcomed. It's far from efficient and some of
19  * my understanding of the effects of scheduling on this are somewhat limited.
20  * Frankly, to my mind, this is the current weak point in the industrial I/O
21  * patch set.
22  */
23
24 #ifndef _IIO_RING_SW_H_
25 #define _IIO_RING_SW_H_
26 #include "iio.h"
27 #include "ring_generic.h"
28
29 #if defined CONFIG_IIO_SW_RING || defined CONFIG_IIO_SW_RING_MODULE
30 /**
31  * ring_sw_access_funcs - access functions for a software ring buffer
32  **/
33 extern const struct iio_ring_access_funcs ring_sw_access_funcs;
34
35 struct iio_ring_buffer *iio_sw_rb_allocate(struct iio_dev *indio_dev);
36 void iio_sw_rb_free(struct iio_ring_buffer *ring);
37
38 struct iio_sw_ring_helper_state {
39         struct work_struct              work_trigger_to_ring;
40         struct iio_dev                  *indio_dev;
41         int (*get_ring_element)(struct iio_sw_ring_helper_state *st, u8 *buf);
42         s64                             last_timestamp;
43 };
44
45 void iio_sw_poll_func_th(struct iio_dev *indio_dev, s64 time);
46 void iio_sw_trigger_bh_to_ring(struct work_struct *work_s);
47 void iio_sw_trigger_to_ring(struct iio_sw_ring_helper_state *st);
48
49 #else /* CONFIG_IIO_RING_BUFFER*/
50 struct iio_sw_ring_helper_state {
51         struct iio_dev                  *indio_dev;
52 };
53 #endif /* !CONFIG_IIO_RING_BUFFER */
54 #endif /* _IIO_RING_SW_H_ */