• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* The industrial I/O core - generic buffer interfaces.
3  *
4  * Copyright (c) 2008 Jonathan Cameron
5  */
6 
7 #ifndef _IIO_BUFFER_GENERIC_H_
8 #define _IIO_BUFFER_GENERIC_H_
9 #include <linux/sysfs.h>
10 #include <linux/iio/iio.h>
11 
12 struct iio_buffer;
13 
14 int iio_push_to_buffers(struct iio_dev *indio_dev, const void *data);
15 
16 /**
17  * iio_push_to_buffers_with_timestamp() - push data and timestamp to buffers
18  * @indio_dev:		iio_dev structure for device.
19  * @data:		sample data
20  * @timestamp:		timestamp for the sample data
21  *
22  * Pushes data to the IIO device's buffers. If timestamps are enabled for the
23  * device the function will store the supplied timestamp as the last element in
24  * the sample data buffer before pushing it to the device buffers. The sample
25  * data buffer needs to be large enough to hold the additional timestamp
26  * (usually the buffer should be indio->scan_bytes bytes large).
27  *
28  * Returns 0 on success, a negative error code otherwise.
29  */
iio_push_to_buffers_with_timestamp(struct iio_dev * indio_dev,void * data,int64_t timestamp)30 static inline int iio_push_to_buffers_with_timestamp(struct iio_dev *indio_dev,
31 	void *data, int64_t timestamp)
32 {
33 	if (indio_dev->scan_timestamp) {
34 		size_t ts_offset = indio_dev->scan_bytes / sizeof(int64_t) - 1;
35 		((int64_t *)data)[ts_offset] = timestamp;
36 	}
37 
38 	return iio_push_to_buffers(indio_dev, data);
39 }
40 
41 bool iio_validate_scan_mask_onehot(struct iio_dev *indio_dev,
42 				   const unsigned long *mask);
43 
44 int iio_device_attach_buffer(struct iio_dev *indio_dev,
45 			     struct iio_buffer *buffer);
46 
47 #endif /* _IIO_BUFFER_GENERIC_H_ */
48