Skip to content

iio: aop_sensors: publish the CT720 color channels - #2155

Merged
DjDeveloperr merged 3 commits into
aurora-silicon:mainfrom
scottjones:upstream/aop-ct720-color
Dec 2, 2026
Merged

DjDeveloperr merged 3 commits into
aurora-silicon:mainfrom
scottjones:upstream/aop-ct720-color

Conversation

@scottjones

@scottjones scottjones commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The CT720 report already carries red, green, blue and clear counts and a color temperature next to lux, but the driver registered only lux for that part. This publishes them on aop-sensors-als when the part is the CT720, gated on matching integration times. A report that fails the gate still publishes lux, and the color channels read ENODATA. Color temperature is published only when clear is at least 12. VD6286, CT817 and the lid-angle sensor keep the channels they had.

This is Lucas Goossen's patch (omacom/linux-aurora#220) rewritten for this tree's N-channel helper; the commit message says what changed in the rewrite.

Evidence

  • Built on integration/aurora a7dd26e6d60e with the 7.3 package config, LLVM 18 and Rust 1.85:
    • make W=1 rust/ drivers/iio/common/aop_sensors/: builds
    • W=1: no warnings the base does not have
    • run-host-tests.py: every tools/asahi test is registered
    • tools/asahi host tests (control and mutation runs): aop-als-channel-tests 1/1
    • Stacked with the other 12 PRs on the same base, the full kernel, modules and DTBs build and package (linux-aurora 7.3.0-0testastip2-1-ARCH, 137 DTBs).
  • Booted as part of the full set: a kernel built from integration/aurora a7dd26e6 plus all 13 branches of this set (before the three small fix-up commits) booted on an M3 MacBook Air (J613), a Neo (J700) and an M1 Pro with no regressions against their baselines (on the M1 Pro, only the checks already known to differ: GPU name and DRAM OPP), and a 25-minute GPU soak was clean on all three. No M3 Pro, M3 Max, J504, J615 or M4 Pro ran this kernel.
  • Checked against three captured J313 reports with an offline copy of the conversion; not run on hardware (from the commit message). The aop-als-channel host test is extended.

Merge Danger

Door: two-way

Blast Radius: ambient light

CT720 ambient-light sensors only.

The CT720 (FireFish2) report already carries four channel counts and a
correlated color temperature beside the lux float at +0x1d. The driver
registered one channel for that part, so those fields never reached sysfs.

Publish red, green, blue, and clear counts plus color temperature on
aop-sensors-als when the part is the CT720. Color is accepted only when
both integration-time copies match, are non-zero, and are at most
10000000. A report that fails that gate still publishes lux, and the
color channels then read ENODATA rather than a stale sample. VD6286,
CT817, and the lid-angle sensor keep the channels they had.

Covered J313 readings still had the firmware CCT byte set at clear
counts of 11 and below, and the published temperatures were 788 K,
1288 K, 2904 K and 6781 K. Publish the temperature only when clear is
at least 12. Red, green, blue, and clear stay published.

Checked against three captured J313 reports with an offline mirror of
the integer conversion. Not run on hardware.

Based on a patch by Lucas Goossen (omacom/linux-aurora#220), commits
b5677f7 and 88c4f98 there, rewritten for this tree.
[7.3 base: rewritten on this tree's N-channel helper, which already
 publishes the VD6286's color temperature, in place of the seqlock slot
 table the original added. The helper gains a per-channel spec (modifier
 and info mask) for the four intensity channels, and a channel_withdrawn()
 hook so a report can take a channel's last reading back; the decode,
 the gates and the offsets are the original's. Each channel is published
 on its own, so a reader can see counts from two adjacent reports.
 aop-als-channel-tests.py covers the CT720 layout, the gates and six
 mutants. Built; not run on hardware.]
Signed-off-by: Scott Jones <scottajones@gmail.com>
@RyanTheTide

Copy link
Copy Markdown
Contributor

Blockers: 2.

  1. The commit has a Co-Authored-By: Claude Fable 5.2 trailer. Please re-commit with only your Signed-off-by. The PR body ends in "Generated with Claude Code"; its last line should be Assisted-by: LLM (<Vendor>:<Model>).
  2. drivers/iio/common/aop_sensors/aop_als.rs:190-193 and :232: CT720_CCT_MIN_CLEAR overrides the firmware's own validity byte (+0x2a) with a cutoff fitted to three covered-sensor captures, and it has not been run on hardware. Either drop it and trust the validity byte, or derive the gate from something the report carries (its integration time or gain). As it stands it is a fitted threshold that will be wrong for a different cover glass or integration time.
  3. aop_als.rs:177-179: the comment quotes the sensor's calibration gains. Those are the part's calibration data, not something this code uses. Please remove them and describe the channels by role only.

The plumbing is sound. ChannelSpec and new_specs() keep the type check against data.ty. set_modified is set only for the four intensity channels. RAW counts are stored as count*MICRO and read back as IIO_VAL_INT. channel_withdrawn() (aop_als.rs:271) withdraws a color channel only when the same report carries lux, so a non-lux report leaves the last readings in place. VD6286 and CT817 keep register_channels().

HW row: a CT720 Mac (J313) on this commit: in_intensity_{red,green,blue,clear}_raw and in_colortemp_input under room light and covered, in_illuminance_input unchanged against the base kernel, and 0 AVC, 0 failed units, 0 new kernel errors.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Merge-train adversarial review (MERGETRAIN-LINUX2) at fdb999e: BLOCKERS.

Not merging until the blockers below are fixed or answered; the details give file:line and a failure case.

Full review

#2155 iio: aop_sensors: publish the CT720 color channels @fdb999e5

VERDICT: BLOCKERS

Blockers:

  1. Commit fdb999e carries Co-Authored-By: Claude Fable 5.2. The commit must have only the human Signed-off-by (Scott Jones is present). The PR body ends with "Generated with Claude Code".
  2. drivers/iio/common/aop_sensors/aop_als.rs:190-193, :232-234: CT720_CCT_MIN_CLEAR = 12 overrides the firmware's own validity byte (+0x2a, checked at :229). The cutoff was fitted to three covered-sensor captures from one J313, and its own doc comment says "Not hardware-tested". It is a fitted magic constant with no tie to integration time or gain, both of which the report carries (+0x2f). Either trust the validity byte or derive the gate from the report.
  3. Not run on hardware at all: the only evidence is an offline conversion of captured reports. A CT720 Mac must show the new sysfs channels before merge.

Nits:

  • aop_als.rs:177-179: the comment quotes calibration gains ("8, 8, 8, 4") that the code doesn't use. Drop them (provenance hygiene) and describe the channels by role.
  • aop_als.rs:203-204: counts are stored as count*MICRO and clamped at MAX_MICRO (i32::MAX), so counts above about 2.1e9 saturate silently. That is unreachable for a 32-bit integrating ALS in practice, but worth a comment.
  • The plumbing is correct:
    • new_specs() keeps the type check against data.ty.
    • set_modified is set only when a modifier is present.
    • RAW channels come back as IIO_VAL_INT from micro / MICRO (rust/kernel/iio/common/aop_sensors.rs read_raw).
    • channel_withdrawn() withdraws a reading only when the same report carries lux.
    • VD6286, CT817 and lid-angle keep register_channels().

Missing rows:

  • J313 (M1 Air, CT720) on this head:
    • in_intensity_{red,green,blue,clear}_raw and in_colortemp_input under room light and covered.
    • in_illuminance_input unchanged against the base.
    • 0 new kernel errors.
  • Any other Mac whose ALS reports as FireFish2 (if any) is unproven too.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Clarification to my merge-train review above: the commit-trailer point is a nit, not a blocker (already-pushed history stays as it is, no force push). The other blockers listed there still stand.

@DjDeveloperr DjDeveloperr left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formal §1–§6 pre-PR review at verified live head fdb999e5a5043108abf4a6fc2dba51f7b7e082e5 (base integration/aurora 70a00e583b03; not superseded; MERGEABLE/clean; live CI 7/7 PASS: Host tests run 44113819593, SEP source checks run 44113819784).

Technical Assessment

  • IIO / Rust plumbing (rust/kernel/iio/common/aop_sensors.rs, rust/bindings/bindings_helper.h): Sound. ChannelSpec + IIORegistration::new_specs() preserve the channel-type check against data.ty, set modified only when modifier is Some, map IIO_CHAN_INFO_RAW back as IIO_VAL_INT, and channel_withdrawn() only clears valid[channel] when the same report carries a valid lux reading (leaving VD6286, CT817, and lid-angle behavior unchanged). The extended tools/asahi/aop-als-channel-tests.py cases and 6 mutants are solid.

Blockers Before APPROVE

  1. §2 / §3 Untested magic threshold overriding firmware validity (drivers/iio/common/aop_sensors/aop_als.rs:190-193, 232-234):
    • CT720_CCT_MIN_CLEAR: u32 = 12 overrides the sensor firmware's own CCT validity byte (+0x2a) using a magic constant fitted to three covered-sensor captures from one J313, with its own doc comment stating "Not hardware-tested". Hardcoding an uncalibrated threshold uncoupled from integration time or gain violates §2 (no magic constants) and will misbehave across optical stacks or integration-time changes. Either drop CT720_CCT_MIN_CLEAR and trust the firmware validity flag (+0x2a) + positive finite float check, or derive the threshold from report metadata and prove it on hardware.
  2. §4 Clean-room & attribution (hard rules):
    • Provenance hygiene (drivers/iio/common/aop_sensors/aop_als.rs:177-179): The comment quotes unused sensor calibration gains ("the calibration gains are 8, 8, 8, 4"). Remove those unused calibration values and describe the channels by role only.
  3. §5 Exact-head hardware & regression evidence missing:
    • The commit message and PR body explicitly state "Not run on hardware", and the stacked boot set (J613/J700/M1 Pro) did not include a CT720 Mac (J313).
    • Please boot the exact updated head on default cmdline on a CT720 Mac (e.g., J313 M1 Air) and record: in_intensity_{red,green,blue,clear}_raw and in_colortemp_input (under room light and covered), in_illuminance_input unchanged vs base, no regression on a non-CT720 ALS part if available (or request one per §1), and the §5 regression triad (0 SELinux denials [or N/A], 0 failed units, 0 new kernel errors).

@scottjones
scottjones force-pushed the upstream/aop-ct720-color branch from fdb999e to 0acda1c Compare November 23, 2026 23:25
The CT720 report comment quoted the part's calibration gains and the
ranking of the counts under one captured light. The driver uses neither.
Name the four counts and say which one is wideband.

No code change.

Signed-off-by: Scott Jones <scottajones@gmail.com>
@scottjones
scottjones force-pushed the upstream/aop-ct720-color branch from 103cdff to ad63582 Compare November 24, 2026 05:06
@scottjones

Copy link
Copy Markdown
Contributor Author

Thanks for the careful review. The provenance point is fixed in ad63582: the comment no longer quotes the calibration gains or the channel ranking, and names the four counts by role only.

On the clear threshold, I'd like to keep it for now. Trusting +0x2a alone is what we started with, and it doesn't hold up on hardware. In malik-na's covered-sensor run on a J313 (omacom/linux-aurora#220), the firmware's CCT-valid byte was still set on noise at clear counts of 11 and below, and in_colortemp_input read 788 K, 1288 K, 2904 K and 6781 K with the sensor covered. The clear >= 12 gate is there to drop exactly those readings, so going back to the flag would publish them again.

You're right that 12 is fitted to one machine and isn't tied to integration time or gain. If you have a source for deriving it from the report metadata, I'm happy to switch to that.

In the meantime I can do a J313 run at the exact head on the default cmdline that covers your §5 list: in_intensity_{red,green,blue,clear}_raw and in_colortemp_input in room light and covered, in_illuminance_input against base, SELinux denials, failed units and new kernel errors. I'll add a check on a non-CT720 ALS part if one is available. Would that be enough to settle this item?

@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) area:rust Area from CODEOWNERS (bot) changes-requested A reviewer requested changes (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 24, 2026

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: FINISH, then merge at ad63582f81ac

Blockers:

  1. drivers/iio/common/aop_sensors/aop_als.rs:190-193, 232-234: CT720_CCT_MIN_CLEAR = 12 overrides the firmware's CCT-valid byte with a number fitted to one J313's covered-sensor captures. As you said, it isn't tied to integration time or gain, so on another unit or setting it may hide real readings or let noise through. Fix: scale the floor from the report's own integration time and gain. If that can't be done, say so in the commit message with the captures, and the J313 run you offered (room light and covered) shows what it does.
  2. Missing row: that J313 run at this head.

Checked: thank you for the careful follow-up. No Apple material; ad63582f names the four counts by role only, which fixes the provenance point.

@DjDeveloperr
DjDeveloperr dismissed their stale review November 25, 2026 00:27

Superseded by the review at ad63582

@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Merge readiness at 2a406f7b: not ready yet

Check Detail
CI at head running running: pr-text / pr-text, host-tests, KUnit ane-boot, rust-build, KUnit ane-pm, KUnit dcp-fabric
Review ok approved by DjDeveloperr, RyanTheTide
Requested changes ok none
Hardware row at head ok comment at 2a406f7b
Conflicts ok none
PR text adopt when you next edit add a 'Tested:' line; a 'Risk:' line (door and Macs) (guide)

Areas: area:gpu, area:rust

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@DjDeveloperr

Copy link
Copy Markdown
Contributor

One point is left. CT720_CCT_MIN_CLEAR = 12 was fitted to one unit's covered captures. Scale the floor from the report's own integration time and gain. If that can't be done, say why in the commit message and post the J313 room-light and covered run at this head.

Main replaced the IIORegistration-based ALS device with its own on-demand AlsIioDev (aurora-silicon#3473), so register the CT720 channels there: AlsIioDev::new() takes a ChannelSpec per channel (type, modifier, info mask), the four colour counts answer IIO_CHAN_INFO_RAW as whole counts, lux and colour temperature stay processed, and a CT720 report that carries lux but not a colour channel withdraws that channel, as channel_withdrawn() says. MAX_CHANNELS grows to the six CT720 channels; VD6286, CT817 and the other parts keep the channels they had.

Signed-off-by: DjDeveloperr <hey@djdev.me>

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: HOLD at 2a406f7bc385

Blockers:

  • Hosted CI workflows (apple-build, host-tests, pr-text, KUnit) have not yet executed on this fork head (2a406f7bc385; readiness is queued, other checks SKIPPED) — wait for CI to be dispatched and pass green (including aop-als-channel-tests.py).
  • Unaddressed review item from 2026-11-26 (CHANGES_REQUESTED on ad63582f): CT720_CCT_MIN_CLEAR = 12 is still a hardcoded constant in aop_als.rs — either scale from integration time/gain or explain why not in the commit message, and post an exact-head 2a406f7bc385 J313 room-light + covered-sensor run exercising the new AlsIioDev (#3473) integration.

Checked:

  • Audited merge commit 2a406f7bc385 (MERGEABLE against main, 4 files +279/-35): cleanly adapts CT720 color channels onto main's on-demand AlsIioDev (#3473), expanding MAX_CHANNELS to CT720_CHANS (6), registering the four RGBC channels as IIO_CHAN_INFO_RAW whole counts while keeping lux and CCT processed, withdrawing unavailable color channels (channel_withdrawn()) on lux-only reports so callers read -ENODATA rather than stale values, and leaving VD6286/CT817 unchanged.
Evidence
  • Head: 2a406f7bc3850f43e2576a6bc2c9b4712f11b2ab (base main, MERGEABLE).
  • Status checks at review time: readiness / readiness QUEUED; 7 checks SKIPPED.

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the conflict-pass merge commit 2a406f7 only: aop_als ported to main's ChannelSpec API (processed/raw channel specs, withdrawn-channel handling); the PR's behaviour is kept. The resolution keeps what each side had and adds nothing outside the conflict. Approved for the merge-up; merging still waits on CI and the rows at this head.

@github-actions github-actions Bot removed the merge-conflict Conflicts with the base branch (bot) label Dec 1, 2026

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CT720 colour channels are new, and the clear-count floor only affects them, so I'm treating the floor as a follow-up rather than a blocker.

Main replaced the ALS IIO device while this was open (#3473), so the merge at 2a406f7b registers these channels on the new device. The counts are raw, lux and colour temperature are processed, and a report without a colour channel withdraws it. The AOP sensor drivers typecheck, and the ALS host tests pass.

Left before merge: a J313 row at this head with room light and covered readings.

@github-actions github-actions Bot removed changes-requested A reviewer requested changes (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 1, 2026

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE at 2a406f7bc385

Converts this App's earlier review at the same head to an approval under the 12-01 merge bar (better than before and doesn't break; block only on a shown failure). No code blocker was found in it. The merge gate (a row on one Mac at this head + fast CI) is tracked by pr-readiness, not held here.

Checked: - Audited merge commit 2a406f7bc385 (MERGEABLE against main, 4 files +279/-35): cleanly adapts CT720 color channels onto main's on-demand AlsIioDev (#3473), expanding MAX_CHANNELS to CT720_CHANS (6), registering the four RGBC channels as IIO_CHAN_INFO_RAW whole counts while keeping lux and CCT processed, withdrawing unavailable color channels (channel_withdrawn()) on lux-only reports so callers read -ENODATA rather than stale values, and leaving VD6286/CT817 unchanged.

Follow-ups (not blocking): CI dispatch; explain/scale CT720_CCT_MIN_CLEAR; J313 room-light + covered row

@DjDeveloperr

Copy link
Copy Markdown
Contributor

At 2a406f7bc385, the J313 one-shot run registered all six CT720 channels and reported 4.41–4.49 lux and 2845–3029 K in room light, with no new kernel errors. The sensor was not covered during this run.

I ran the exact-head tools/asahi/aop-als-channel-tests.py fixture on Mini. All four tests passed and all 11 mutations were rejected, including removal of the minimum-clear check. The remaining physical check is one covered J313 sample with clear below 12 that keeps lux available and returns ENODATA for color temperature.

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Dec 2, 2026
@DjDeveloperr

DjDeveloperr commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Merge-tree check of 2a406f7bc385 on current main a2cc412a8c69. The merge commit was made locally and not pushed. The branch is 960 commits behind main, and #2220 changed aop_motion.rs after this head was made, so the check builds the merge rather than the head.

  • Configured like CI's apple-build: arm64 defconfig plus asahi.config, LLVM=1, Rust 1.100.1, the layout-corrected bindgen. RUST=y and all five IIO_AOP_SENSOR_* options are =m.
  • make modules_prepare builds the kernel crate with the changed aop_sensors.rs and bindings_helper.h: passed, 0 warnings.
  • make drivers/iio/common/aop_sensors/ builds aop_las, aop_als, aop_motion, aop_devmotion and aop_temp: passed, 0 errors, 0 warnings. aop_als and aop_las are the only users of the shared helper, and the helper change only adds things.
  • tools/asahi/aop-als-channel-tests.py: 4 passed, all 11 mutants rejected.
  • tools/testing/selftests/drivers/apple/aop-motion.py: 14 passed.

Hosted CI at this head: apple-build, rust-build, host-tests and pr-text passed. The KUnit and DWC3 jobs still queued don't cover these files.

The covered J313 reading from our 12-01 review is now a follow-up. CT720_CCT_MIN_CLEAR only decides whether the new colour-temperature channel reports a value. Lux on channel 0 doesn't pass through it, and the room-light run at this head covers registration and lux, so the floor can't break anything that worked before. Please post one covered J313 sample when you can: with clear below 12, lux still reads and in_colortemp_input returns ENODATA; uncovered, colour temperature comes back.

Main moved to 844502ef16a3 before the merge; none of its new changes touch rust/ or drivers/iio/. Merging with an admin merge, since only those unrelated hosted jobs are still pending.

@DjDeveloperr
DjDeveloperr merged commit 3d7cc83 into aurora-silicon:main Dec 2, 2026
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:gpu Area from CODEOWNERS (bot) area:rust Area from CODEOWNERS (bot) door:two-way Revertible or not, from Merge risk (bot) needs-template PR body lacks Tested or Risk (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants