linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] iio: light: vcnl4000: Fix scale for vcnl4040
@ 2019-12-27 10:22 Guido Günther
  2019-12-30 16:49 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Guido Günther @ 2019-12-27 10:22 UTC (permalink / raw)
  To: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Angus Ainslie (Purism),
	Marco Felsch, Allison Randal, Thomas Gleixner,
	Guido Günther, linux-iio, linux-kernel

According to the data sheet the ambient sensor's scale is 0.12 lux/step
(not 0.024 lux/step as used by vcnl4200) when the integration time is
80ms. The integration time is currently hardcoded in the driver to that
value.

See p. 8 in https://www.vishay.com/docs/84307/designingvcnl4040.pdf

Fixes: 5a441aade5b3 ("light: vcnl4000 add support for the VCNL4040 proximity and light sensor")
Signed-off-by: Guido Günther <agx@sigxcpu.org>
Reviewed-by: Marco Felsch <m.felsch@pengutronix.de>
---
 drivers/iio/light/vcnl4000.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c
index 16dacea9eadf..b0e241aaefb4 100644
--- a/drivers/iio/light/vcnl4000.c
+++ b/drivers/iio/light/vcnl4000.c
@@ -163,7 +163,6 @@ static int vcnl4200_init(struct vcnl4000_data *data)
 	if (ret < 0)
 		return ret;
 
-	data->al_scale = 24000;
 	data->vcnl4200_al.reg = VCNL4200_AL_DATA;
 	data->vcnl4200_ps.reg = VCNL4200_PS_DATA;
 	switch (id) {
@@ -172,11 +171,13 @@ static int vcnl4200_init(struct vcnl4000_data *data)
 		/* show 54ms in total. */
 		data->vcnl4200_al.sampling_rate = ktime_set(0, 54000 * 1000);
 		data->vcnl4200_ps.sampling_rate = ktime_set(0, 4200 * 1000);
+		data->al_scale = 24000;
 		break;
 	case VCNL4040_PROD_ID:
 		/* Integration time is 80ms, add 10ms. */
 		data->vcnl4200_al.sampling_rate = ktime_set(0, 100000 * 1000);
 		data->vcnl4200_ps.sampling_rate = ktime_set(0, 100000 * 1000);
+		data->al_scale = 120000;
 		break;
 	}
 	data->vcnl4200_al.last_measurement = ktime_set(0, 0);
-- 
2.23.0


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

* Re: [PATCH v2] iio: light: vcnl4000: Fix scale for vcnl4040
  2019-12-27 10:22 [PATCH v2] iio: light: vcnl4000: Fix scale for vcnl4040 Guido Günther
@ 2019-12-30 16:49 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2019-12-30 16:49 UTC (permalink / raw)
  To: Guido Günther
  Cc: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Angus Ainslie (Purism),
	Marco Felsch, Allison Randal, Thomas Gleixner, linux-iio,
	linux-kernel

On Fri, 27 Dec 2019 11:22:54 +0100
Guido Günther <agx@sigxcpu.org> wrote:

> According to the data sheet the ambient sensor's scale is 0.12 lux/step
> (not 0.024 lux/step as used by vcnl4200) when the integration time is
> 80ms. The integration time is currently hardcoded in the driver to that
> value.
> 
> See p. 8 in https://www.vishay.com/docs/84307/designingvcnl4040.pdf
> 
> Fixes: 5a441aade5b3 ("light: vcnl4000 add support for the VCNL4040 proximity and light sensor")
> Signed-off-by: Guido Günther <agx@sigxcpu.org>
> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de>
Applied to the fixes-togreg branch of iio.git.

Thanks,

Jonathan

> ---
>  drivers/iio/light/vcnl4000.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c
> index 16dacea9eadf..b0e241aaefb4 100644
> --- a/drivers/iio/light/vcnl4000.c
> +++ b/drivers/iio/light/vcnl4000.c
> @@ -163,7 +163,6 @@ static int vcnl4200_init(struct vcnl4000_data *data)
>  	if (ret < 0)
>  		return ret;
>  
> -	data->al_scale = 24000;
>  	data->vcnl4200_al.reg = VCNL4200_AL_DATA;
>  	data->vcnl4200_ps.reg = VCNL4200_PS_DATA;
>  	switch (id) {
> @@ -172,11 +171,13 @@ static int vcnl4200_init(struct vcnl4000_data *data)
>  		/* show 54ms in total. */
>  		data->vcnl4200_al.sampling_rate = ktime_set(0, 54000 * 1000);
>  		data->vcnl4200_ps.sampling_rate = ktime_set(0, 4200 * 1000);
> +		data->al_scale = 24000;
>  		break;
>  	case VCNL4040_PROD_ID:
>  		/* Integration time is 80ms, add 10ms. */
>  		data->vcnl4200_al.sampling_rate = ktime_set(0, 100000 * 1000);
>  		data->vcnl4200_ps.sampling_rate = ktime_set(0, 100000 * 1000);
> +		data->al_scale = 120000;
>  		break;
>  	}
>  	data->vcnl4200_al.last_measurement = ktime_set(0, 0);


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

end of thread, other threads:[~2019-12-30 16:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-27 10:22 [PATCH v2] iio: light: vcnl4000: Fix scale for vcnl4040 Guido Günther
2019-12-30 16:49 ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).