rescale.h 833 B

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