From: Gabriel Krisman Bertazi <krisman@collabora.com>
To: Shreeya Patel <shreeya.patel@collabora.com>
Cc: jic23@kernel.org, lars@metafoo.de, robh+dt@kernel.org,
Zhigang.Shi@liteon.com, linux-iio@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel@collabora.com, alvaro.soliverez@collabora.com
Subject: Re: [PATCH 3/3] iio: light: Add support for ltrf216a sensor
Date: Sun, 27 Mar 2022 23:59:28 -0400 [thread overview]
Message-ID: <878rsusp5r.fsf@collabora.com> (raw)
In-Reply-To: <20220325103014.6597-4-shreeya.patel@collabora.com> (Shreeya Patel's message of "Fri, 25 Mar 2022 16:00:14 +0530")
Shreeya Patel <shreeya.patel@collabora.com> writes:
> From: Zhigang Shi <Zhigang.Shi@liteon.com>
>
> Add initial support for ltrf216a ambient light sensor.
>
> Datasheet :-
> https://gitlab.steamos.cloud/shreeya/iio/-/blob/main/LTR-F216A-QT.pdf
> + struct ltrf216a_data *data = iio_priv(indio_dev);
> +
> + ret = i2c_smbus_write_byte_data(data->client, LTRF216A_MAIN_CTRL, 0);
> + if (ret < 0)
> + dev_err(&data->client->dev, "Error writing LTRF216A_MAIN_CTRL\n");
> +
> + return ret;
> +}
> +
> +static int ltrf216a_set_it_time(struct ltrf216a_data *data, int itime)
ltrf216a_set_int_time instad of it_time? although, ltr501 also uses
"it" instead of "int" on the function name..
> +
> +static int ltrf216a_get_lux(struct ltrf216a_data *data)
> +{
> + int greendata, cleardata, lux;
> +
> + greendata = ltrf216a_read_data(data, LTRF216A_ALS_DATA_0);
> + cleardata = ltrf216a_read_data(data, LTRF216A_CLEAR_DATA_0);
> +
> + if (greendata < 0 || cleardata < 0)
> + lux = 0;
> + else
> + lux = greendata * 8 * WIN_FAC / data->als_gain_fac / data->int_time_fac / 10;
This could be rewritten to avoid most of the divisions.
But it also doesn't fit the calculation shown in page 20 on the
datasheet.
I suspect that 8 was calculated from a specific Window Factor (~1.77),
which is specific to one device, but I'm not sure. The datasheet
formula is:
lux = (ALS_DATA_X * 0.45 * window_factor) / (gain * int_time)
Shouldn't WIN_FAC be a configurable parameter, instead of constant?
--
Gabriel Krisman Bertazi
prev parent reply other threads:[~2022-03-28 3:59 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-25 10:30 [PATCH 0/3] Add LTRF216A Driver Shreeya Patel
2022-03-25 10:30 ` [PATCH 1/3] dt-bindings: vendor-prefixes: Add 'ltr' as deprecated vendor prefix Shreeya Patel
2022-03-25 12:21 ` Krzysztof Kozlowski
2022-03-25 10:30 ` [PATCH 2/3] dt-bindings: Document ltrf216a light sensor bindings Shreeya Patel
2022-03-25 12:23 ` Krzysztof Kozlowski
2022-03-27 13:55 ` Jonathan Cameron
2022-03-28 2:49 ` Gabriel Krisman Bertazi
2022-03-25 10:30 ` [PATCH 3/3] iio: light: Add support for ltrf216a sensor Shreeya Patel
2022-03-25 12:25 ` Krzysztof Kozlowski
2022-03-27 14:30 ` Jonathan Cameron
2022-03-29 20:03 ` Shreeya Patel
2022-04-02 16:49 ` Jonathan Cameron
2022-04-11 17:06 ` Shreeya Patel
2022-04-12 14:06 ` Gabriel Krisman Bertazi
2022-04-12 14:53 ` Jonathan Cameron
2022-03-28 3:59 ` Gabriel Krisman Bertazi [this message]
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=878rsusp5r.fsf@collabora.com \
--to=krisman@collabora.com \
--cc=Zhigang.Shi@liteon.com \
--cc=alvaro.soliverez@collabora.com \
--cc=devicetree@vger.kernel.org \
--cc=jic23@kernel.org \
--cc=kernel@collabora.com \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=shreeya.patel@collabora.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;
as well as URLs for NNTP newsgroup(s).