xref: /openbmc/linux/include/linux/iio/afe/rescale.h (revision 6c8c1406)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (C) 2018 Axentia Technologies AB
4  */
5 
6 #ifndef __IIO_RESCALE_H__
7 #define __IIO_RESCALE_H__
8 
9 #include <linux/types.h>
10 #include <linux/iio/iio.h>
11 
12 struct device;
13 struct rescale;
14 
15 struct rescale_cfg {
16 	enum iio_chan_type type;
17 	int (*props)(struct device *dev, struct rescale *rescale);
18 };
19 
20 struct rescale {
21 	const struct rescale_cfg *cfg;
22 	struct iio_channel *source;
23 	struct iio_chan_spec chan;
24 	struct iio_chan_spec_ext_info *ext_info;
25 	bool chan_processed;
26 	s32 numerator;
27 	s32 denominator;
28 	s32 offset;
29 };
30 
31 int rescale_process_scale(struct rescale *rescale, int scale_type,
32 			  int *val, int *val2);
33 int rescale_process_offset(struct rescale *rescale, int scale_type,
34 			   int scale, int scale2, int schan_off,
35 			   int *val, int *val2);
36 #endif /* __IIO_RESCALE_H__ */
37