Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
at v6.9 72 lines 2.4 kB view raw
1/* SPDX-License-Identifier: GPL-2.0-or-later */ 2#ifndef _IIO_BACKEND_H_ 3#define _IIO_BACKEND_H_ 4 5#include <linux/types.h> 6 7struct fwnode_handle; 8struct iio_backend; 9struct device; 10struct iio_dev; 11 12enum iio_backend_data_type { 13 IIO_BACKEND_TWOS_COMPLEMENT, 14 IIO_BACKEND_OFFSET_BINARY, 15 IIO_BACKEND_DATA_TYPE_MAX 16}; 17 18/** 19 * struct iio_backend_data_fmt - Backend data format 20 * @type: Data type. 21 * @sign_extend: Bool to tell if the data is sign extended. 22 * @enable: Enable/Disable the data format module. If disabled, 23 * not formatting will happen. 24 */ 25struct iio_backend_data_fmt { 26 enum iio_backend_data_type type; 27 bool sign_extend; 28 bool enable; 29}; 30 31/** 32 * struct iio_backend_ops - operations structure for an iio_backend 33 * @enable: Enable backend. 34 * @disable: Disable backend. 35 * @chan_enable: Enable one channel. 36 * @chan_disable: Disable one channel. 37 * @data_format_set: Configure the data format for a specific channel. 38 * @request_buffer: Request an IIO buffer. 39 * @free_buffer: Free an IIO buffer. 40 **/ 41struct iio_backend_ops { 42 int (*enable)(struct iio_backend *back); 43 void (*disable)(struct iio_backend *back); 44 int (*chan_enable)(struct iio_backend *back, unsigned int chan); 45 int (*chan_disable)(struct iio_backend *back, unsigned int chan); 46 int (*data_format_set)(struct iio_backend *back, unsigned int chan, 47 const struct iio_backend_data_fmt *data); 48 struct iio_buffer *(*request_buffer)(struct iio_backend *back, 49 struct iio_dev *indio_dev); 50 void (*free_buffer)(struct iio_backend *back, 51 struct iio_buffer *buffer); 52}; 53 54int iio_backend_chan_enable(struct iio_backend *back, unsigned int chan); 55int iio_backend_chan_disable(struct iio_backend *back, unsigned int chan); 56int devm_iio_backend_enable(struct device *dev, struct iio_backend *back); 57int iio_backend_data_format_set(struct iio_backend *back, unsigned int chan, 58 const struct iio_backend_data_fmt *data); 59int devm_iio_backend_request_buffer(struct device *dev, 60 struct iio_backend *back, 61 struct iio_dev *indio_dev); 62 63void *iio_backend_get_priv(const struct iio_backend *conv); 64struct iio_backend *devm_iio_backend_get(struct device *dev, const char *name); 65struct iio_backend * 66__devm_iio_backend_get_from_fwnode_lookup(struct device *dev, 67 struct fwnode_handle *fwnode); 68 69int devm_iio_backend_register(struct device *dev, 70 const struct iio_backend_ops *ops, void *priv); 71 72#endif