Lines Matching full:scale
2 /* gain-time-scale conversion helpers for IIO light sensors
22 * iio_gts_get_gain - Convert scale to total gain
24 * Internal helper for converting scale to total gain.
26 * @max: Maximum linearized scale. As an example, when scale is created
27 * in magnitude of NANOs and max scale is 64.1 - The linearized
28 * scale is 64 100 000 000.
29 * @scale: Linearized scale to compute the gain for.
31 * Return: (floored) gain corresponding to the scale. -EINVAL if scale
34 static int iio_gts_get_gain(const u64 max, const u64 scale) in iio_gts_get_gain() argument
39 if (scale > full || !scale) in iio_gts_get_gain()
42 if (U64_MAX - full < scale) { in iio_gts_get_gain()
44 if (full - scale < scale) in iio_gts_get_gain()
47 full -= scale; in iio_gts_get_gain()
51 while (full > scale * (u64)tmp) in iio_gts_get_gain()
58 * gain_get_scale_fraction - get the gain or time based on scale and known one
60 * @max: Maximum linearized scale. As an example, when scale is created
61 * in magnitude of NANOs and max scale is 64.1 - The linearized
62 * scale is 64 100 000 000.
63 * @scale: Linearized scale to compute the gain/time for.
68 * Compute either gain or time based on scale and either the gain or time
73 static int gain_get_scale_fraction(const u64 max, u64 scale, int known, in gain_get_scale_fraction() argument
78 tot_gain = iio_gts_get_gain(max, scale); in gain_get_scale_fraction()
114 * Expect scale to be (mostly) NANO or MICRO. Divide divider instead of in iio_gts_linearize()
127 * iio_gts_total_gain_to_scale - convert gain to scale
128 * @gts: Gain time scale descriptor
130 * @scale_int: Pointer to integral part of the scale (typically val1)
131 * @scale_nano: Pointer to fractional part of the scale (nano or ppb)
133 * Convert the total gain value to scale. NOTE: This does not separate gain
153 * iio_gts_purge_avail_scale_table - free-up the available scale tables
154 * @gts: Gain time scale descriptor
274 * @gts: Gain time scale descriptor
353 * @gts: Gain time scale descriptor
416 * @gts: Gain time scale descriptor
431 * @gts: Gain time scale descriptor
471 * @gts: Gain time scale descriptor
474 * integration time and scale tables.
490 * @gts: Gain time scale descriptor
596 * devm_iio_init_iio_gts - Initialize the gain-time-scale helper
599 * @max_scale_int: integer part of the maximum scale value
600 * @max_scale_nano: fraction part of the maximum scale value
612 * Initialize the gain-time-scale helper for use. Note, gains, times, selectors
637 * @gts: Gain time scale descriptor
639 * @type: Type of returned scale values
660 * @gts: Gain time scale descriptor
663 * @type: Type of returned scale values
666 * Drivers which do not allow scale setting to change integration time can
694 * @gts: Gain time scale descriptor
696 * @type: Type of returned scale values
717 * @gts: Gain time scale descriptor
737 * @gts: Gain time scale descriptor
757 * @gts: Gain time scale descriptor
780 * @gts: Gain time scale descriptor
852 * iio_gts_find_gain_for_scale_using_time - Find gain by time and scale
853 * @gts: Gain time scale descriptor
856 * @scale_int: Integral part of the scale (typically val1)
857 * @scale_nano: Fractional part of the scale (nano or ppb)
861 * corresponds given scale and integration time. Sensors which fill the
896 * @gts: Gain time scale descriptor
899 * @scale_int: Integral part of the scale (typically val1)
900 * @scale_nano: Fractional part of the scale (nano or ppb)
944 u64 *scale) in iio_gts_get_scale_linear() argument
957 *scale = tmp; in iio_gts_get_scale_linear()
963 * iio_gts_get_scale - get scale based on integration time and HW-gain
964 * @gts: Gain time scale descriptor
965 * @gain: HW-gain for which the scale is computed
966 * @time: Integration time for which the scale is computed
967 * @scale_int: Integral part of the scale (typically val1)
968 * @scale_nano: Fractional part of the scale (nano or ppb)
970 * Compute scale matching the integration time and HW-gain given as parameter.
990 * @gts: Gain time scale descriptor
996 * We may want to mitigate the scale change caused by setting a new integration
998 * new gain value to maintain the scale with new integration time.
1006 * gain required to maintain the scale would not be an integer. In this case,
1015 u64 scale; in iio_gts_find_new_gain_sel_by_old_gain_time() local
1029 &scale); in iio_gts_find_new_gain_sel_by_old_gain_time()
1033 ret = gain_get_scale_fraction(gts->max_scale, scale, itime_new->mul, in iio_gts_find_new_gain_sel_by_old_gain_time()
1047 * @gts: Gain time scale descriptor
1053 * We may want to mitigate the scale change caused by setting a new integration
1055 * new gain value to maintain the scale with new integration time.
1063 * gain required to maintain the scale would not be an integer. In this case,
1072 u64 scale; in iio_gts_find_new_gain_by_old_gain_time() local
1081 ret = iio_gts_get_scale_linear(gts, old_gain, old_time, &scale); in iio_gts_find_new_gain_by_old_gain_time()
1085 ret = gain_get_scale_fraction(gts->max_scale, scale, itime_new->mul, in iio_gts_find_new_gain_by_old_gain_time()
1099 MODULE_DESCRIPTION("IIO light sensor gain-time-scale helpers");