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
38 if (scale > full || !scale) in iio_gts_get_gain()
41 return div64_u64(full, scale); in iio_gts_get_gain()
45 * gain_get_scale_fraction - get the gain or time based on scale and known one
47 * @max: Maximum linearized scale. As an example, when scale is created
48 * in magnitude of NANOs and max scale is 64.1 - The linearized
49 * scale is 64 100 000 000.
50 * @scale: Linearized scale to compute the gain/time for.
55 * Compute either gain or time based on scale and either the gain or time
60 static int gain_get_scale_fraction(const u64 max, u64 scale, int known, in gain_get_scale_fraction() argument
65 tot_gain = iio_gts_get_gain(max, scale); in gain_get_scale_fraction()
101 * Expect scale to be (mostly) NANO or MICRO. Divide divider instead of in iio_gts_linearize()
114 * iio_gts_total_gain_to_scale - convert gain to scale
115 * @gts: Gain time scale descriptor
117 * @scale_int: Pointer to integral part of the scale (typically val1)
118 * @scale_nano: Pointer to fractional part of the scale (nano or ppb)
120 * Convert the total gain value to scale. NOTE: This does not separate gain
140 * iio_gts_purge_avail_scale_table - free-up the available scale tables
141 * @gts: Gain time scale descriptor
329 /* Convert the gains to scales and populate the scale tables */ in compute_per_time_tables()
339 * This can be used as available_scales by drivers which don't allow scale
366 * @gts: Gain time scale descriptor
418 * @gts: Gain time scale descriptor
484 * @gts: Gain time scale descriptor
499 * @gts: Gain time scale descriptor
539 * @gts: Gain time scale descriptor
542 * integration time and scale tables.
558 * @gts: Gain time scale descriptor
664 * devm_iio_init_iio_gts - Initialize the gain-time-scale helper
667 * @max_scale_int: integer part of the maximum scale value
668 * @max_scale_nano: fraction part of the maximum scale value
680 * Initialize the gain-time-scale helper for use. Note, gains, times, selectors
705 * @gts: Gain time scale descriptor
707 * @type: Type of returned scale values
728 * @gts: Gain time scale descriptor
731 * @type: Type of returned scale values
734 * Drivers which do not allow scale setting to change integration time can
762 * @gts: Gain time scale descriptor
764 * @type: Type of returned scale values
785 * @gts: Gain time scale descriptor
805 * @gts: Gain time scale descriptor
825 * @gts: Gain time scale descriptor
848 * @gts: Gain time scale descriptor
920 * iio_gts_find_gain_for_scale_using_time - Find gain by time and scale
921 * @gts: Gain time scale descriptor
924 * @scale_int: Integral part of the scale (typically val1)
925 * @scale_nano: Fractional part of the scale (nano or ppb)
929 * corresponds given scale and integration time. Sensors which fill the
964 * @gts: Gain time scale descriptor
967 * @scale_int: Integral part of the scale (typically val1)
968 * @scale_nano: Fractional part of the scale (nano or ppb)
995 * iio_gts_find_gain_time_sel_for_scale - Fetch gain and time selectors for scale
996 * @gts: Gain time scale descriptor
997 * @scale_int: Integral part of the scale (typically val1)
998 * @scale_nano: Fractional part of the scale (nano or ppb)
1003 * gain and time selectors for a given scale.
1031 * @gts: Gain time scale descriptor
1056 u64 *scale) in iio_gts_get_scale_linear() argument
1069 *scale = tmp; in iio_gts_get_scale_linear()
1075 * iio_gts_get_scale - get scale based on integration time and HW-gain
1076 * @gts: Gain time scale descriptor
1077 * @gain: HW-gain for which the scale is computed
1078 * @time: Integration time for which the scale is computed
1079 * @scale_int: Integral part of the scale (typically val1)
1080 * @scale_nano: Fractional part of the scale (nano or ppb)
1082 * Compute scale matching the integration time and HW-gain given as parameter.
1102 * @gts: Gain time scale descriptor
1108 * We may want to mitigate the scale change caused by setting a new integration
1110 * new gain value to maintain the scale with new integration time.
1118 * gain required to maintain the scale would not be an integer. In this case,
1127 u64 scale; in iio_gts_find_new_gain_sel_by_old_gain_time() local
1141 &scale); in iio_gts_find_new_gain_sel_by_old_gain_time()
1145 ret = gain_get_scale_fraction(gts->max_scale, scale, itime_new->mul, in iio_gts_find_new_gain_sel_by_old_gain_time()
1159 * @gts: Gain time scale descriptor
1165 * We may want to mitigate the scale change caused by setting a new integration
1167 * new gain value to maintain the scale with new integration time.
1175 * gain required to maintain the scale would not be an integer. In this case,
1184 u64 scale; in iio_gts_find_new_gain_by_old_gain_time() local
1193 ret = iio_gts_get_scale_linear(gts, old_gain, old_time, &scale); in iio_gts_find_new_gain_by_old_gain_time()
1197 ret = gain_get_scale_fraction(gts->max_scale, scale, itime_new->mul, in iio_gts_find_new_gain_by_old_gain_time()
1211 * @gts: Gain time scale descriptor
1253 MODULE_DESCRIPTION("IIO light sensor gain-time-scale helpers");