2019-12-23 15:31:46

by Guido Günther

[permalink] [raw]
Subject: [PATCH] iio: light: vcnl4000: Fix scale for vcnl4040

According to the data sheet the ambient sensors's scale is 0.12
lux/step, not 0.024 lux/step as used by vcnl4200.

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 <[email protected]>
---
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


2019-12-27 08:48:44

by Marco Felsch

[permalink] [raw]
Subject: Re: [PATCH] iio: light: vcnl4000: Fix scale for vcnl4040

Hi Guido,

On 19-12-23 16:30, Guido G?nther wrote:
> According to the data sheet the ambient sensors's scale is 0.12
> lux/step, not 0.024 lux/step as used by vcnl4200.

This is only true if the als_it bits are set to '0'. Is it worth to add
a comment here?

> 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 <[email protected]>

Reviewed-by: Marco Felsch <[email protected]>

> ---
> 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

2019-12-27 10:25:28

by Guido Günther

[permalink] [raw]
Subject: Re: [PATCH] iio: light: vcnl4000: Fix scale for vcnl4040

Hi,
On Fri, Dec 27, 2019 at 09:47:20AM +0100, Marco Felsch wrote:
> Hi Guido,
>
> On 19-12-23 16:30, Guido G?nther wrote:
> > According to the data sheet the ambient sensors's scale is 0.12
> > lux/step, not 0.024 lux/step as used by vcnl4200.
>
> This is only true if the als_it bits are set to '0'. Is it worth to add
> a comment here?

Good point. I've added that to the commit message.
Cheers,
-- Guido

>
> > 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 <[email protected]>
>
> Reviewed-by: Marco Felsch <[email protected]>
>
> > ---
> > 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
>