mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Javier Carrasco <javier.carrasco.cruz@gmail.com>
To: "Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Javier Carrasco <javier.carrasco.cruz@gmail.com>
Subject: [PATCH] iio: light: veml6031x00: Enable internal calibration
Date: Thu, 24 Sep 2026 12:59:57 +0200	[thread overview]
Message-ID: <20260924-veml6031x00_als_cal-v1-1-c046a5e4e998@gmail.com> (raw)

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>


             reply	other threads:[~2026-09-24 11:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-24 10:59 Javier Carrasco [this message]
2026-09-27 18:44 ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260924-veml6031x00_als_cal-v1-1-c046a5e4e998@gmail.com \
    --to=javier.carrasco.cruz@gmail.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®