Hi Jonathan & Mikael,
On 01/12/2024 15:20, Jonathan Cameron wrote:
First, regarding the integration time/gain/scale parameters. I took a look at the datasheet again as there is a table+};
+MODULE_DEVICE_TABLE(of, apds9160_of_match);
+
+static struct i2c_driver apds9160_driver = {
+ .driver = {
+ .name = APDS9160_DRIVER_NAME,
+ .owner = THIS_MODULE,
+ .of_match_table = apds9160_of_match,
+ },
+ .probe = apds9160_probe,
+ .remove = apds9160_remove,
+ .id_table = apds9160_id,
+};
provided to get lux/count (scale?) for the ALS sensor depending on gain and integration time.
It looks like the correlation in the table is almost linear but it's not as there is a loss of precision.
For example, at 1x gain with integration time 100ms the lux/count is 0.819 but at 3x the table is stating 0.269 instead of exepected 0.273.
Is it still possible to use the gts helpers in that case?
Ah. Probably not if it goes non linear. Matti? (+CC)
Disclaimer - I didn't go through the patch and I just respond from the top of my head :) So, please take my words with a pinch of salt.
AFAIR, it is not required that the impact of integration time is _linear_ through the range. The "multiplication factor" can be set for each integration time separately. So, it is perfectly Ok to say:
time 1 => multiply by 1
time 2 => multiply by 2
time 10 => multiply by 9 <= not linear, as linear would be 10.
time 15 => multiply by 15
...
The notable limitation of _current_ implementation is that the "multiplication factor" needs to be integer. So, this may result loss of accuracy.