Lines Matching defs: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)
38 if (scale > full || !scale)
41 return div64_u64(full, scale);
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,
65 tot_gain = iio_gts_get_gain(max, scale);
101 * Expect scale to be (mostly) NANO or MICRO. Divide divider instead of
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
261 * @gts: Gain time scale descriptor
340 * @gts: Gain time scale descriptor
403 * @gts: Gain time scale descriptor
418 * @gts: Gain time scale descriptor
458 * @gts: Gain time scale descriptor
461 * integration time and scale tables.
477 * @gts: Gain time scale descriptor
583 * devm_iio_init_iio_gts - Initialize the gain-time-scale helper
586 * @max_scale_int: integer part of the maximum scale value
587 * @max_scale_nano: fraction part of the maximum scale value
599 * Initialize the gain-time-scale helper for use. Note, gains, times, selectors
624 * @gts: Gain time scale descriptor
626 * @type: Type of returned scale values
647 * @gts: Gain time scale descriptor
650 * @type: Type of returned scale values
653 * Drivers which do not allow scale setting to change integration time can
681 * @gts: Gain time scale descriptor
683 * @type: Type of returned scale values
704 * @gts: Gain time scale descriptor
724 * @gts: Gain time scale descriptor
744 * @gts: Gain time scale descriptor
767 * @gts: Gain time scale descriptor
839 * iio_gts_find_gain_for_scale_using_time - Find gain by time and scale
840 * @gts: Gain time scale descriptor
843 * @scale_int: Integral part of the scale (typically val1)
844 * @scale_nano: Fractional part of the scale (nano or ppb)
848 * corresponds given scale and integration time. Sensors which fill the
883 * @gts: Gain time scale descriptor
886 * @scale_int: Integral part of the scale (typically val1)
887 * @scale_nano: Fractional part of the scale (nano or ppb)
931 u64 *scale)
944 *scale = tmp;
950 * iio_gts_get_scale - get scale based on integration time and HW-gain
951 * @gts: Gain time scale descriptor
952 * @gain: HW-gain for which the scale is computed
953 * @time: Integration time for which the scale is computed
954 * @scale_int: Integral part of the scale (typically val1)
955 * @scale_nano: Fractional part of the scale (nano or ppb)
957 * Compute scale matching the integration time and HW-gain given as parameter.
977 * @gts: Gain time scale descriptor
983 * We may want to mitigate the scale change caused by setting a new integration
985 * new gain value to maintain the scale with new integration time.
993 * gain required to maintain the scale would not be an integer. In this case,
1002 u64 scale;
1016 &scale);
1020 ret = gain_get_scale_fraction(gts->max_scale, scale, itime_new->mul,
1034 * @gts: Gain time scale descriptor
1040 * We may want to mitigate the scale change caused by setting a new integration
1042 * new gain value to maintain the scale with new integration time.
1050 * gain required to maintain the scale would not be an integer. In this case,
1059 u64 scale;
1068 ret = iio_gts_get_scale_linear(gts, old_gain, old_time, &scale);
1072 ret = gain_get_scale_fraction(gts->max_scale, scale, itime_new->mul,
1086 MODULE_DESCRIPTION("IIO light sensor gain-time-scale helpers");