[PATCH 1/1] iio: light: isl29018: support cover-glass gain compensation via DT
From: Herman van Hazendonk
Date: Thu Jun 04 2026 - 01:48:11 EST
Boards that mount the sensor under a tinted or coated cover glass need
to compensate for the optical loss before downstream consumers can map
the reading onto a useful lux range. The driver already exposes a
runtime knob through in_illuminance0_calibscale, but every user has to
re-apply it after every reboot (or rely on a board-specific udev rule),
and a power-of-two cover gain like 100x is a hardware constant of the
board rather than a policy choice that belongs in userspace.
Add an "isil,cover-comp-gain" device-tree property that seeds calibscale
at probe, mirroring the pattern tsl2563.c already uses for the same
class of problem (amstaos,cover-comp-gain). The default stays 1 so
existing systems are unaffected, and userspace can still re-tune via
the sysfs attribute afterwards.
Signed-off-by: Herman van Hazendonk <github.com@xxxxxxxxxx>
---
.../devicetree/bindings/iio/light/isl29018.yaml | 13 +++++++++++++
drivers/iio/light/isl29018.c | 9 +++++++++
2 files changed, 22 insertions(+)
diff --git a/Documentation/devicetree/bindings/iio/light/isl29018.yaml b/Documentation/devicetree/bindings/iio/light/isl29018.yaml
index 0ea278b07d1c..92ea2742bbd3 100644
--- a/Documentation/devicetree/bindings/iio/light/isl29018.yaml
+++ b/Documentation/devicetree/bindings/iio/light/isl29018.yaml
@@ -34,6 +34,19 @@ properties:
vcc-supply:
description: Regulator that provides power to the sensor
+ isil,cover-comp-gain:
+ description: |
+ Multiplier applied to the ambient-light reading at startup to
+ compensate for optical loss in the board's cover glass. Boards
+ that mount the sensor under a tinted or coated window typically
+ need a value between a few and a few hundred. The value seeds
+ in_illuminance0_calibscale, so it can still be retuned at
+ runtime through sysfs.
+ $ref: /schemas/types.yaml#/definitions/uint32
+ minimum: 1
+ maximum: 65535
+ default: 1
+
required:
- compatible
- reg
diff --git a/drivers/iio/light/isl29018.c b/drivers/iio/light/isl29018.c
index b6ab726d1dae..427dbb639141 100644
--- a/drivers/iio/light/isl29018.c
+++ b/drivers/iio/light/isl29018.c
@@ -727,7 +727,16 @@ static int isl29018_probe(struct i2c_client *client)
mutex_init(&chip->lock);
chip->type = dev_id;
+ /*
+ * Allow boards that mount the sensor behind tinted / coated cover
+ * glass to bake the optical-loss compensation into firmware via
+ * "isil,cover-comp-gain", following the precedent set by
+ * tsl2563.c. The value seeds calibscale (default 1), so userspace
+ * can still retune through in_illuminance0_calibscale.
+ */
chip->calibscale = 1;
+ device_property_read_u32(&client->dev, "isil,cover-comp-gain",
+ &chip->calibscale);
chip->ucalibscale = 0;
chip->int_time = ISL29018_INT_TIME_16;
chip->scale = isl29018_scales[chip->int_time][0];
--
2.43.0