linux/include/linux/iio/buffer.h
<<
>>
Prefs
   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
  12struct iio_buffer;
  13
  14void iio_buffer_set_attrs(struct iio_buffer *buffer,
  15                         const struct attribute **attrs);
  16
  17int iio_push_to_buffers(struct iio_dev *indio_dev, const void *data);
  18
  19/**
  20 * iio_push_to_buffers_with_timestamp() - push data and timestamp to buffers
  21 * @indio_dev:          iio_dev structure for device.
  22 * @data:               sample data
  23 * @timestamp:          timestamp for the sample data
  24 *
  25 * Pushes data to the IIO device's buffers. If timestamps are enabled for the
  26 * device the function will store the supplied timestamp as the last element in
  27 * the sample data buffer before pushing it to the device buffers. The sample
  28 * data buffer needs to be large enough to hold the additional timestamp
  29 * (usually the buffer should be indio->scan_bytes bytes large).
  30 *
  31 * Returns 0 on success, a negative error code otherwise.
  32 */
  33static inline int iio_push_to_buffers_with_timestamp(struct iio_dev *indio_dev,
  34        void *data, int64_t timestamp)
  35{
  36        if (indio_dev->scan_timestamp) {
  37                size_t ts_offset = indio_dev->scan_bytes / sizeof(int64_t) - 1;
  38                ((int64_t *)data)[ts_offset] = timestamp;
  39        }
  40
  41        return iio_push_to_buffers(indio_dev, data);
  42}
  43
  44bool iio_validate_scan_mask_onehot(struct iio_dev *indio_dev,
  45                                   const unsigned long *mask);
  46
  47void iio_device_attach_buffer(struct iio_dev *indio_dev,
  48                              struct iio_buffer *buffer);
  49
  50#endif /* _IIO_BUFFER_GENERIC_H_ */
  51