diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2012-09-14 11:21:00 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2012-09-15 05:12:22 -0400 |
commit | 7985e7c1003bc5cdfa20755f8cfdada946ed8e18 (patch) | |
tree | 94adb3cf91ec3406361c2bc9d0c66485e1bf2436 /include/linux/iio | |
parent | ca7d1b32d2a0d4c62533b9401cf9ce4d14d183f7 (diff) |
iio: Introduce a new fractional value type
Currently IIO uses a decimal fixed point representations for real type numbers.
This patch introduces a new representation for rational type numbers. The number
will be expressed by specifying a numerator and denominator. For converting a
raw value to a processed value multiply it by the numerator and divide it by the
denominator.
The reasoning for introducing this new type is that for a lot of devices the
scale can be represented easily by a fractional number, but it is not possible
to represent it as fixed point number without rounding. E.g. for a simple DAC
the scale is often the reference voltage divided by the number of possible
values (Usually 2**n_bits - 1). Each driver currently implements the conversion
of this fraction to a fixed point number on its own.
Also when it comes to the in-kernel interface this allows to directly use the
fractional factors to convert a raw value to a processed value. This should on
one hand require less instructions and on the other hand increase the
precision.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'include/linux/iio')
-rw-r--r-- | include/linux/iio/types.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/include/linux/iio/types.h b/include/linux/iio/types.h index 44e397705d7f..5c647ecfd5ba 100644 --- a/include/linux/iio/types.h +++ b/include/linux/iio/types.h | |||
@@ -57,5 +57,6 @@ enum iio_modifier { | |||
57 | #define IIO_VAL_INT_PLUS_MICRO 2 | 57 | #define IIO_VAL_INT_PLUS_MICRO 2 |
58 | #define IIO_VAL_INT_PLUS_NANO 3 | 58 | #define IIO_VAL_INT_PLUS_NANO 3 |
59 | #define IIO_VAL_INT_PLUS_MICRO_DB 4 | 59 | #define IIO_VAL_INT_PLUS_MICRO_DB 4 |
60 | #define IIO_VAL_FRACTIONAL 10 | ||
60 | 61 | ||
61 | #endif /* _IIO_TYPES_H_ */ | 62 | #endif /* _IIO_TYPES_H_ */ |