linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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: Mon, 13 Mar 2023 11:39:06 +0200	[thread overview]
Message-ID: <1b55adf6-32ce-1fd3-78cf-b2011f023eac@gmail.com> (raw)
In-Reply-To: <20230312153655.052d5730@jic23-huawei>

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?

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.

> 
> In the rare case where you do get SCALE and PROCESSED it's there to allow
> for changes in the underlying signal measurement that are eaten up in the
> computation needed to get to PROCESSED - that is they have no visible
> affect (beyond range changes etc).

Oh, Ok. So there is a valid case for setting both SCALE and PROCESSED. 
Then we can't add teh warning I assume :(


Yours,
	-- Matti

-- 
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~


  reply	other threads:[~2023-03-13  9:40 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 [this message]
2023-03-18 16:54           ` Jonathan Cameron
2023-03-19 15:59             ` Matti Vaittinen
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=1b55adf6-32ce-1fd3-78cf-b2011f023eac@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;
as well as URLs for NNTP newsgroup(s).