mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] iio: light: veml6031x00: Enable internal calibration
@ 2026-09-24 10:59 Javier Carrasco
  2026-09-27 18:44 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Javier Carrasco @ 2026-09-24 10:59 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko
  Cc: linux-iio, linux-kernel, Javier Carrasco

Enable the device's factory internal calibration before entering normal
operation to improve ambient light measurements.

Set ALS_CAL during hardware initialization.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
This feature is not documented beyond the bit to set in the CONF1 device
register, but after direct communication with the manufacturer and some
tests I carried out, it should improve the ALS measurements.

I could not tell much of a difference with the first device I tested,
but some other samples have slightly improved its measurements compared
to a reliable reference. The manufacturer could not tell me why this had
to be configurable at all, considering that you can't calibrate the
device on your own, and especially why it is disabled by default. But
fortunately, this feature only needs to be enabled after powering up the
device, and software on/off switches do not affect it.
---
 drivers/iio/light/veml6031x00.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/iio/light/veml6031x00.c b/drivers/iio/light/veml6031x00.c
index 085a6e2ff717..f6308498e422 100644
--- a/drivers/iio/light/veml6031x00.c
+++ b/drivers/iio/light/veml6031x00.c
@@ -52,6 +52,7 @@
 #define VEML6031X00_CONF0_SD        BIT(0)
 #define VEML6031X00_CONF0_AF_TRIG   BIT(2)
 #define VEML6031X00_CONF0_AF        BIT(3)
+#define VEML6031X00_CONF1_ALS_CAL   BIT(0)
 #define VEML6031X00_CONF1_IR_SD     BIT(7)
 #define VEML6031X00_INT_TH_H        BIT(1)
 #define VEML6031X00_INT_TH_L        BIT(2)
@@ -1121,6 +1122,11 @@ static int veml6031x00_hw_init(struct veml6031x00_data *data)
 	if (ret)
 		return dev_err_probe(dev, ret, "Failed to disable trigger\n");
 
+	ret = regmap_set_bits(data->regmap, VEML6031X00_REG_CONF1,
+			      VEML6031X00_CONF1_ALS_CAL);
+	if (ret)
+		return dev_err_probe(dev, ret, "Failed to enable internal calibration\n");
+
 	regval = 0;
 	ret = regmap_bulk_write(map, VEML6031X00_REG_WL_L, &regval, sizeof(regval));
 	if (ret)

---
base-commit: dceba8e581e3e8f475da0efbd7a73f3d9524ddd2
change-id: 20260921-veml6031x00_als_cal-93319bc0be81

Best regards,
-- 
Javier Carrasco <javier.carrasco.cruz@gmail.com>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-27 18:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-24 10:59 [PATCH] iio: light: veml6031x00: Enable internal calibration Javier Carrasco
2026-09-27 18:44 ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®