iio_gts_find...ld_gain_time(9)
β¨ iio_gts_find_new_gain_by_old_gain_time(9) β¨
Okay so bestie, welcome to the Kernel API Manual π β this one's a helper in the IIO gain-time-scale (gts) cinematic universe, and honestly it's giving "quietly doing the most important math in the room." Let's get into it π«Ά
πΈ NAME πΈ
iio_gts_find_new_gain_by_old_gain_time β compensate for time change π
π¦ SYNOPSIS π¦
int iio_gts_find_new_gain_by_old_gain_time (struct iio_gts *gts , int
old_gain , int old_time , int new_time , int *new_gain );
π ARGUMENTS π
gtsβ the Gain time scale descriptor. This is the main character fr, it holds the whole scale situation πold_gainβ the gain that was previously set. The "before" pic πΈold_timeβ the selector that corresponds to the previously set timenew_timeβ the selector that corresponds to the new time you're about to setnew_gainβ pointer to the value where the new gain is gonna get written βοΈ
π DESCRIPTION π
So here's the vibe: when you set a new integration time on a light sensor, the scale can shift on you, and that's lowkey not the moment. The glow-up move is to also update the (HW)gain so the scale stays put π§
This helper does exactly that β it computes the new gain value needed to maintain the scale with the new integration time. No cap, that's the whole job. It's the friend who fixes your outfit after you changed one piece and everything else suddenly clashed π β¨
π₯ RETURN π₯
It returns 0 if an exactly matching supported new gain was found. Slay, perfect match, we love to see it π
When a non-zero value comes back, new_gain will be set to a negative or positive value:
- A negative value means no gain could be computed at all. π It's giving "we tried, bestie."
- A positive value is the "best possible new gain there could be" β the consolation prize, but make it math.
There can be two reasons why finding the "best possible" new gain is not deemed successful:
- This new value cannot be supported by the hardware π
- The new gain required to maintain the scale would not be an integer π¬
In that second case, the "best possible" new gain will be a floored optimal gain β which may or may not be supported by the hardware. So likeβ¦ don't assume it's valid just because it came back positive, okay? Do a vibe check on it first π
π SEE ALSO π
Kernel file ./drivers/iio/industrialio-gts-helper.c β and the whole extended friend group π:
iio_gts_get_gain(9)gain_get_scale_fraction(9)iio_gts_total_gain_to_scale(9)iio_gts_purge_avail_scale_table(9)iio_gts_build_avail_scale_table(9)iio_gts_build_avail_time_table(9)iio_gts_purge_avail_time_table(9)iio_gts_build_avail_tables(9)iio_gts_purge_avail_tables(9)devm_iio_gts_build_avail_tables(9)devm_iio_init_iio_gts(9)iio_gts_all_avail_scales(9)iio_gts_avail_scales_for_time(9)iio_gts_avail_times(9)iio_gts_find_sel_by_gain(9)iio_gts_find_gain_by_sel(9)iio_gts_get_min_gain(9)iio_find_closest_gain_low(9)iio_gts_find_gain_for_scale_using_time(9)iio_gts_find_gain_sel_for_scale_using_time(9)iio_gts_find_gain_time_sel_for_scale(9)iio_gts_get_total_gain(9)iio_gts_get_scale(9)iio_gts_find_new_gain_sel_by_old_gain_time(9)iio_gts_find_new_gain_by_gain_time_min(9)
That's the whole page, bestie β go forth and compensate those time changes π
Sign-off szn: this one lives in ./drivers/iio and the page is dated October 2026 ποΈπ« mwah, ily, read your manpages π«Άπ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms