diff options
author | Bill Richardson <wfrichar@chromium.org> | 2015-01-15 17:01:45 -0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-01-21 05:05:47 +0000 |
commit | 43806f07e35de0ab9b27774e2f27841a78a2c527 (patch) | |
tree | 3a117ae15a5810dd9e24a57722b33fa6c686ff97 /driver | |
parent | b1f0de7b37e2730836b056c1672739b123d403e6 (diff) | |
download | chrome-ec-43806f07e35de0ab9b27774e2f27841a78a2c527.tar.gz |
samus: Add scale factor to account for ALS attenuation
This adds a sensor-specific attentuation factor, which will be
applied to the ALS raw sensor readings on the EC. This is to
account for the attenutation due to glass, tinting, etc.
BUG=chrome-os-partner:34590
BRANCH=ToT,Samus
TEST=manual
In a root shell, run this:
cd /sys/bus/acpi/drivers/acpi_als/ACPI0008:00/iio:device1
while true; do cat in_illuminance_raw; sleep 1 ;done
Shine a flashlight on the ALS. Note that the readings are 5X
higher than they were before this CL.
Change-Id: I2a53872ecb5fab62e5f443d43588a26d3d7e697f
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/241191
Reviewed-by: Bryan Freed <bfreed@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r-- | driver/als_isl29035.c | 15 | ||||
-rw-r--r-- | driver/als_isl29035.h | 2 |
2 files changed, 11 insertions, 6 deletions
diff --git a/driver/als_isl29035.c b/driver/als_isl29035.c index 3eef3a170e..f908e443bd 100644 --- a/driver/als_isl29035.c +++ b/driver/als_isl29035.c @@ -35,7 +35,7 @@ static void isl29035_init(void) } DECLARE_HOOK(HOOK_CHIPSET_RESUME, isl29035_init, HOOK_PRIO_DEFAULT); -int isl29035_read_lux(int *lux) +int isl29035_read_lux(int *lux, int af) { int rv, lsb, msb, data; @@ -62,11 +62,16 @@ int isl29035_read_lux(int *lux) /* * The default power-on values will give 16 bits of precision: - * 0x0000-0xffff indicates 0-1000 lux. If you change the defaults, - * you'll need to change the scale factor accordingly (and maybe this - * expression, to avoid rounding errors). + * 0x0000-0xffff indicates 0-1000 lux. We multiply the sensor value by + * a scaling factor to account for attentuation by glass, tinting, etc. + * + * Caution: Don't go nuts with the attentuation factor. If it's + * greater than 32, the signed int math will roll over and you'll get + * very wrong results. Of course, if you have that much attenuation and + * are still getting useful readings, you probably have your sensor + * pointed directly into the sun. */ - *lux = data * 1000 / 0xffff; + *lux = data * af * 1000 / 0xffff; return EC_SUCCESS; } diff --git a/driver/als_isl29035.h b/driver/als_isl29035.h index 8d3a4ac0f5..212af7a50f 100644 --- a/driver/als_isl29035.h +++ b/driver/als_isl29035.h @@ -8,6 +8,6 @@ #ifndef __CROS_EC_ALS_ILS29035_H #define __CROS_EC_ALS_ILS29035_H -int isl29035_read_lux(int *lux); +int isl29035_read_lux(int *lux, int af); #endif /* __CROS_EC_ALS_ILS29035_H */ |