From: Matti Vaittinen <mazziesaccount@gmail.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>,
Lars-Peter Clausen <lars@metafoo.de>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Paul Gazzillo <paul@pgazz.com>,
Zhigang Shi <Zhigang.Shi@liteon.com>,
Shreeya Patel <shreeya.patel@collabora.com>,
Dmitry Osipenko <dmitry.osipenko@collabora.com>,
linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org
Subject: Re: [PATCH v2 5/6] iio: light: ROHM BU27034 Ambient Light Sensor
Date: Sun, 19 Mar 2023 17:59:20 +0200 [thread overview]
Message-ID: <c52fb080-49ce-8eec-5c8c-efebd27417af@gmail.com> (raw)
In-Reply-To: <20230318165436.480f1a9a@jic23-huawei>
On 3/18/23 18:54, Jonathan Cameron wrote:
> On Mon, 13 Mar 2023 11:39:06 +0200
> Matti Vaittinen <mazziesaccount@gmail.com> wrote:
>
>> On 3/12/23 17:36, Jonathan Cameron wrote:
>>> On Sun, 5 Mar 2023 14:22:51 +0200
>>> Matti Vaittinen <mazziesaccount@gmail.com> wrote:
>>>
>>>> On 3/4/23 22:17, Jonathan Cameron wrote:
>>>>> On Thu, 2 Mar 2023 12:58:59 +0200
>>>>> Matti Vaittinen <mazziesaccount@gmail.com> wrote:
>>>>>
>>
>> // snip
>>
>>>>>> +static const struct iio_chan_spec bu27034_channels[] = {
>>>>>> + {
>>>>>> + .type = IIO_LIGHT,
>>>>>> + .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |
>>>>>> + BIT(IIO_CHAN_INFO_SCALE),
>>>>>
>>>>> What is this scale for?
>>>>
>>>> The scale is to inform users that we return data using milli lux.
>>>>
>>>>> Given the channel is computed from various different inputs, is there a
>>>>> clear definition of how it is scaled? What does a write to it mean?
>>>>
>>>> Nothing. writing anything else but milli lux scale fails with -EINVAL.
>>>>
>>>> I guess I am doing something in an unusual way here :) Do you have a
>>>> suggestion for me?
>>>
>>> Return data in lux?
>>
>> That's what I did originally have. But then I noticed we can get
>> slightly better accuracy than that. Hence I switched to mLux and added
>> the scale.
>>
>>> Or return it as INFO_RAW - thus making it clear
>>> that the reading is not in expected units and a conversion must be
>>> applied by userspace. SCALE is not applied to PROCESSED by userspace.
>>
>> Ah. This makes sense then. Maybe it would be worth adding a warning to
>> IIO-core if drivers set both the SCALE and PROCESSED info bits?
>
> Hmm. I'm not sure that we don't have valid users of it even if they
> are unusual. We also have some historical messes that do RAW + SCALE +
> PROCESSED so we can't really have a warning on it.
>
> Warning generally is that the test tools that come with the kernel
> will give you the wrong reading. :)
>
>>
>> So, I need to select between the simplicity or better accuracy here? :/
>> I really hate ending up making choices like this without knowing all the
>> real use-cases :( And it happens a lot for me. Well, I guess I'll drop
>> the scale, use luxes and go with the PROCESSED data. My understanding is
>> that the "thing" with the sensor is a wide-range for wavelengths, not
>> the accuracy. So, maybe luxes are just good enough - and again, users
>> needing something more accurate can utilize the raw intensity channels.
>
> Hmm. For the sysfs case you could use VAL_INT_PLUS_MICRO but that doesn't
> then work well with the buffered path.
>
> It is perfectly valid to just have this as _RAW and keep your _SCALE so
> that's probably the best option
> _RAW doesn't have to mean totally raw, it just means userspace is expected
> to applying a linear conversion to get a reading in the 'base' units for the channel.
Thanks for the insight!
I'll return the scale and switch to RAW for v5 :)
Yours,
-- Matti
--
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland
~~ When things go utterly wrong vim users can always type :help! ~~
next prev parent reply other threads:[~2023-03-19 15:59 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-02 10:57 [PATCH v2 0/6] Support ROHM BU27034 ALS sensor Matti Vaittinen
2023-03-02 10:57 ` [PATCH v2 1/6] dt-bindings: iio: light: Support ROHM BU27034 Matti Vaittinen
2023-03-02 10:57 ` [PATCH v2 2/6] iio: light: Add gain-time-scale helpers Matti Vaittinen
2023-03-02 15:05 ` Andy Shevchenko
2023-03-03 7:54 ` Vaittinen, Matti
2023-03-06 11:13 ` Andy Shevchenko
2023-03-13 11:31 ` Matti Vaittinen
2023-03-13 14:39 ` Andy Shevchenko
2023-03-14 10:28 ` Matti Vaittinen
2023-03-14 11:31 ` Andy Shevchenko
2023-03-14 11:36 ` Andy Shevchenko
2023-03-15 7:20 ` Vaittinen, Matti
2023-03-18 16:49 ` Jonathan Cameron
2023-03-04 18:35 ` Jonathan Cameron
2023-03-04 19:42 ` Matti Vaittinen
2023-03-06 11:15 ` Andy Shevchenko
2023-03-02 10:58 ` [PATCH v2 3/6] iio: test: test " Matti Vaittinen
2023-03-02 10:58 ` [PATCH v2 4/6] MAINTAINERS: Add IIO " Matti Vaittinen
2023-03-02 10:58 ` [PATCH v2 5/6] iio: light: ROHM BU27034 Ambient Light Sensor Matti Vaittinen
2023-03-02 14:17 ` Matti Vaittinen
2023-03-02 15:34 ` Andy Shevchenko
2023-03-03 9:17 ` Matti Vaittinen
2023-03-04 19:02 ` Jonathan Cameron
2023-03-04 20:28 ` Matti Vaittinen
2023-03-04 20:17 ` Jonathan Cameron
2023-03-05 12:22 ` Matti Vaittinen
2023-03-12 15:36 ` Jonathan Cameron
2023-03-13 9:39 ` Matti Vaittinen
2023-03-18 16:54 ` Jonathan Cameron
2023-03-19 15:59 ` Matti Vaittinen [this message]
2023-03-14 9:39 ` Matti Vaittinen
2023-03-18 16:57 ` Jonathan Cameron
2023-03-05 13:10 ` Matti Vaittinen
2023-03-06 11:21 ` Andy Shevchenko
2023-03-13 8:54 ` Matti Vaittinen
2023-03-02 10:59 ` [PATCH v2 6/6] MAINTAINERS: Add ROHM BU27034 Matti Vaittinen
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=c52fb080-49ce-8eec-5c8c-efebd27417af@gmail.com \
--to=mazziesaccount@gmail.com \
--cc=Zhigang.Shi@liteon.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=dmitry.osipenko@collabora.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matti.vaittinen@fi.rohmeurope.com \
--cc=paul@pgazz.com \
--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