mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Aldo Conte <aldocontelk@gmail.com>
To: David Lechner <dlechner@baylibre.com>, linux-iio@vger.kernel.org
Cc: "Jonathan Cameron" <jic23@kernel.org>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC] iio: light: tcs3472: implementing wait time TODO
Date: Sat, 25 Apr 2026 21:00:49 +0200	[thread overview]
Message-ID: <3d4a4dbd-6618-4b63-ade1-d68155bac3ac@gmail.com> (raw)
In-Reply-To: <46fd475f-8d54-4419-a195-d66c947fcc1b@baylibre.com>

On 4/25/26 18:49, David Lechner wrote:
> On 4/25/26 11:28 AM, Aldo Conte wrote:
>> Hi all,
>>
>> I'd like to resolve the wait time TODO in tcs3472.c.
> 
> Do you actually have this hardware to test it?
> 
> What is the application that needs to make use of this feature?
> 
I'm currently participating in the 2026 linux kernel mentorship program. 
I don't really have an application that would use this feature, but in 
any case, I have the hardware (Adafruit TCS34725 breakout board to test 
with a Raspberry Pi 3B) to test everything out.

As part of this experience, I'm focusing on “light” and, while looking 
through the TODO, i noticed this and wanted to explore it further.


>>
>> The TCS3472 has a WTIME register and WEN bit that insert a low-power
> 
> What about WLONG?
> 
>> wait state between RGBC cycles. The register is already defined in the driver but never used.
>> I noticed that tsl2772.c enables wait with a fixed default and no
>> userspace control. However, I think exposing the wait time to
>> userspace would be more useful to tune the power/responsiveness tradeoff.
> 
> I assume this would affect the effective sample rate?
yes
> 
>>
>> My plan would be to expose it via an ext_info attribute in
>> microseconds, following the same convention as integration_time.
>> Does that sound acceptable, or would you prefer a simpler approach
>> with just a fixed default like tsl2772?
> 
> So perhaps we could just use the standard sampling_frequency attribute?

Just want to make sure I understand the sampling_frequency approach
correctly before implementing.

The total cycle time of the chip is:

   cycle = wait_time + rgbc_init + integration_time
         = (256 - WTIME) * 2.4ms + 2.4ms + (256 - ATIME) * 2.4ms

So sampling_frequency = 1 / cycle.

On a write, the driver would keep ATIME fixed (since the user
controls it independently via integration_time) and solve for WTIME:

   wait_time = (1 / requested_freq) - 2.4ms - atime_duration
   WTIME = 256 - (wait_time / 2.4ms)

For very low frequencies where the wait exceeds 614 ms, the driver
would automatically enable WLONG in the CONFIG register to extend
the step from 2.4 ms to 28.8 ms.

But i wanto to clear my self this: changing integration_time would 
implicitly change
the effective sampling_frequency since both contribute to the cycle
time. Is that acceptable, or should the driver recalculate WTIME
when ATIME changes to maintain the current sampling_frequency?

>>
>> I also plan a following patch converting the driver to devm.
> 
> Would be better to do this first before adding new features.
> 
ok i could bring it up in the series assuming instead that the WTIME new 
feature is actually wanted, since I don't have a real-world application.
>>
>> Thanks,
>> Aldo
>>
> 


  reply	other threads:[~2026-04-25 19:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-25 16:28 Aldo Conte
2026-04-25 16:49 ` David Lechner
2026-04-25 19:00   ` Aldo Conte [this message]
2026-04-25 23:11     ` David Lechner
2026-04-26 10:48       ` Jonathan Cameron
2026-04-26 14:37         ` Aldo Conte
2026-04-26 15:51           ` David Lechner

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=3d4a4dbd-6618-4b63-ade1-d68155bac3ac@gmail.com \
    --to=aldocontelk@gmail.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.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

all inboxes | Powered by JetHome®