]>
Commit | Line | Data |
---|---|---|
14555b14 | 1 | /* The industrial I/O core - generic buffer interfaces. |
7026ea4b JC |
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 | ||
3811cd62 JC |
10 | #ifndef _IIO_BUFFER_GENERIC_H_ |
11 | #define _IIO_BUFFER_GENERIC_H_ | |
26d25ae3 | 12 | #include <linux/sysfs.h> |
06458e27 | 13 | #include <linux/iio/iio.h> |
2662051e | 14 | |
14555b14 | 15 | struct iio_buffer; |
7026ea4b | 16 | |
9f466777 JC |
17 | void iio_buffer_set_attrs(struct iio_buffer *buffer, |
18 | const struct attribute **attrs); | |
7026ea4b | 19 | |
5d65d920 | 20 | int iio_push_to_buffers(struct iio_dev *indio_dev, const void *data); |
5ada4ea9 | 21 | |
d4ad4f4b | 22 | /** |
d2c3d072 LPC |
23 | * iio_push_to_buffers_with_timestamp() - push data and timestamp to buffers |
24 | * @indio_dev: iio_dev structure for device. | |
25 | * @data: sample data | |
26 | * @timestamp: timestamp for the sample data | |
27 | * | |
28 | * Pushes data to the IIO device's buffers. If timestamps are enabled for the | |
29 | * device the function will store the supplied timestamp as the last element in | |
30 | * the sample data buffer before pushing it to the device buffers. The sample | |
31 | * data buffer needs to be large enough to hold the additional timestamp | |
32 | * (usually the buffer should be indio->scan_bytes bytes large). | |
33 | * | |
34 | * Returns 0 on success, a negative error code otherwise. | |
35 | */ | |
36 | static inline int iio_push_to_buffers_with_timestamp(struct iio_dev *indio_dev, | |
37 | void *data, int64_t timestamp) | |
38 | { | |
39 | if (indio_dev->scan_timestamp) { | |
40 | size_t ts_offset = indio_dev->scan_bytes / sizeof(int64_t) - 1; | |
41 | ((int64_t *)data)[ts_offset] = timestamp; | |
42 | } | |
43 | ||
44 | return iio_push_to_buffers(indio_dev, data); | |
45 | } | |
46 | ||
81636632 | 47 | bool iio_validate_scan_mask_onehot(struct iio_dev *indio_dev, |
33dd94cb | 48 | const unsigned long *mask); |
9e69c935 | 49 | |
2b827ad5 JC |
50 | void iio_device_attach_buffer(struct iio_dev *indio_dev, |
51 | struct iio_buffer *buffer); | |
9e69c935 | 52 | |
3811cd62 | 53 | #endif /* _IIO_BUFFER_GENERIC_H_ */ |